mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2025-04-28 03:20:56 +00:00
chore: fixes a bug where filters do not deactive (#621)
Signed-off-by: Alex Jones <alex@Alexs-MacBook-Pro.local> Co-authored-by: Alex Jones <alex@Alexs-MacBook-Pro.local>
This commit is contained in:
parent
09984c245d
commit
133850f984
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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 {
|
||||
|
@ -118,8 +118,3 @@ func (t *Trivy) AddAnalyzer(mergedMap *map[string]common.IAnalyzer) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (t *Trivy) RemoveAnalyzer() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user