Merge pull request #19835 from Juneezee/refactor/redundant-nil-check

Remove redundant nil checks in system connection remove
This commit is contained in:
OpenShift Merge Robot
2023-09-04 08:48:13 +02:00
committed by GitHub

View File

@ -54,18 +54,14 @@ func rm(cmd *cobra.Command, args []string) error {
} }
if rmOpts.All { if rmOpts.All {
if cfg.Engine.ServiceDestinations != nil { for k := range cfg.Engine.ServiceDestinations {
for k := range cfg.Engine.ServiceDestinations { delete(cfg.Engine.ServiceDestinations, k)
delete(cfg.Engine.ServiceDestinations, k)
}
} }
cfg.Engine.ActiveService = "" cfg.Engine.ActiveService = ""
// Clear all the connections in any existing farms // Clear all the connections in any existing farms
if cfg.Farms.List != nil { for k := range cfg.Farms.List {
for k := range cfg.Farms.List { cfg.Farms.List[k] = []string{}
cfg.Farms.List[k] = []string{}
}
} }
return cfg.Write() return cfg.Write()
} }
@ -83,12 +79,10 @@ func rm(cmd *cobra.Command, args []string) error {
} }
// If there are existing farm, remove the deleted connection that might be part of a farm // If there are existing farm, remove the deleted connection that might be part of a farm
if cfg.Farms.List != nil { for k, v := range cfg.Farms.List {
for k, v := range cfg.Farms.List { index := util.IndexOfStringInSlice(args[0], v)
index := util.IndexOfStringInSlice(args[0], v) if index > -1 {
if index > -1 { cfg.Farms.List[k] = append(v[:index], v[index+1:]...)
cfg.Farms.List[k] = append(v[:index], v[index+1:]...)
}
} }
} }