Skip to content

Commit

Permalink
chore: fixes a bug where filters do not deactive (#621)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Jones <alex@Alexs-MacBook-Pro.local>
Co-authored-by: Alex Jones <alex@Alexs-MacBook-Pro.local>
  • Loading branch information
AlexsJones and Alex Jones committed Sep 3, 2023
1 parent 09984c2 commit 133850f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 25 deletions.
26 changes: 6 additions & 20 deletions pkg/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ type IIntegration interface {
UnDeploy(namespace string) error
//
AddAnalyzer(*map[string]common.IAnalyzer)
// RemoveAnalyzer removes an analyzer from the cluster
RemoveAnalyzer() error

GetAnalyzerName() []string

Expand Down Expand Up @@ -73,9 +71,7 @@ func (*Integration) Activate(name string, namespace string, activeFilters []stri

mergedFilters := activeFilters

for _, integrationAnalyzer := range integrations[name].GetAnalyzerName() {
mergedFilters = append(mergedFilters, integrationAnalyzer)
}
mergedFilters = append(mergedFilters, integrations[name].GetAnalyzerName()...)

uniqueFilters, dupplicatedFilters := util.RemoveDuplicates(mergedFilters)

Expand Down Expand Up @@ -108,23 +104,13 @@ func (*Integration) Deactivate(name string, namespace string) error {

activeFilters := viper.GetStringSlice("active_filters")

// Update filters
// This might be a bad idea, but we cannot reference analyzer here
foundFilter := false
for i, v := range activeFilters {

for _, intanal := range integrations[name].GetAnalyzerName() {
if v == intanal {
foundFilter = true
activeFilters = append(activeFilters[:i], activeFilters[i+1:]...)
break
// Update filters and remove the specific filters for the integration
for _, filter := range integrations[name].GetAnalyzerName() {
for x, af := range activeFilters {
if af == filter {
activeFilters = append(activeFilters[:x], activeFilters[x+1:]...)
}
}

}
if !foundFilter {
color.Red("Ingregation %s does not exist in configuration file. Please use k8sgpt integration add.", name)
os.Exit(1)
}

if err := integrations[name].UnDeploy(namespace); err != nil {
Expand Down
5 changes: 0 additions & 5 deletions pkg/integration/trivy/trivy.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,3 @@ func (t *Trivy) AddAnalyzer(mergedMap *map[string]common.IAnalyzer) {
}

}

func (t *Trivy) RemoveAnalyzer() error {

return nil
}

0 comments on commit 133850f

Please sign in to comment.