Skip to content

Commit

Permalink
Merge pull request #19835 from Juneezee/refactor/redundant-nil-check
Browse files Browse the repository at this point in the history
Remove redundant nil checks in system connection remove
  • Loading branch information
openshift-merge-robot authored Sep 4, 2023
2 parents 8f7453f + f094884 commit 9bcab49
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions cmd/podman/system/connection/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,14 @@ func rm(cmd *cobra.Command, args []string) error {
}

if rmOpts.All {
if cfg.Engine.ServiceDestinations != nil {
for k := range cfg.Engine.ServiceDestinations {
delete(cfg.Engine.ServiceDestinations, k)
}
for k := range cfg.Engine.ServiceDestinations {
delete(cfg.Engine.ServiceDestinations, k)
}
cfg.Engine.ActiveService = ""

// Clear all the connections in any existing farms
if cfg.Farms.List != nil {
for k := range cfg.Farms.List {
cfg.Farms.List[k] = []string{}
}
for k := range cfg.Farms.List {
cfg.Farms.List[k] = []string{}
}
return cfg.Write()
}
Expand All @@ -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 cfg.Farms.List != nil {
for k, v := range cfg.Farms.List {
index := util.IndexOfStringInSlice(args[0], v)
if index > -1 {
cfg.Farms.List[k] = append(v[:index], v[index+1:]...)
}
for k, v := range cfg.Farms.List {
index := util.IndexOfStringInSlice(args[0], v)
if index > -1 {
cfg.Farms.List[k] = append(v[:index], v[index+1:]...)
}
}

Expand Down

0 comments on commit 9bcab49

Please sign in to comment.