mirror of
https://github.com/containers/podman.git
synced 2025-06-23 10:38:20 +08:00
Remove redundant nil checks in system connection remove
From the Go specification: "3. If the map is nil, the number of iterations is 0." [1] Therefore, an additional nil check for before the loop is unnecessary. [NO NEW TESTS NEEDED] [1]: https://go.dev/ref/spec#For_range Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
@ -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()
|
||||
}
|
||||
@ -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:]...)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user