Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fixes a bug where filters do not deactivate #621

Merged
merged 4 commits into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() {
AlexsJones marked this conversation as resolved.
Show resolved Hide resolved
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
}