mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
fix: correct lint issues
This commit is contained in:
@@ -59,20 +59,20 @@ func (o *removeConfigMapOptions) Validate(args []string) error {
|
|||||||
func (o *removeConfigMapOptions) RunRemoveConfigMap(fSys filesys.FileSystem) error {
|
func (o *removeConfigMapOptions) RunRemoveConfigMap(fSys filesys.FileSystem) error {
|
||||||
mf, err := kustfile.NewKustomizationFile(fSys)
|
mf, err := kustfile.NewKustomizationFile(fSys)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("configmap cannot load from file system, got %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
m, err := mf.Read()
|
m, err := mf.Read()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("configmap cannot read from file, got %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var newConfigMaps []types.ConfigMapArgs
|
|
||||||
foundConfigMaps := make(map[string]bool)
|
foundConfigMaps := make(map[string]bool)
|
||||||
for _, removeName := range o.configMapNames {
|
for _, removeName := range o.configMapNames {
|
||||||
foundConfigMaps[removeName] = false
|
foundConfigMaps[removeName] = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newConfigMaps := make([]types.ConfigMapArgs, 0, len(m.ConfigMapGenerator))
|
||||||
for _, currentConfigMap := range m.ConfigMapGenerator {
|
for _, currentConfigMap := range m.ConfigMapGenerator {
|
||||||
if kustfile.StringInSlice(currentConfigMap.Name, o.configMapNames) {
|
if kustfile.StringInSlice(currentConfigMap.Name, o.configMapNames) {
|
||||||
foundConfigMaps[currentConfigMap.Name] = true
|
foundConfigMaps[currentConfigMap.Name] = true
|
||||||
@@ -88,5 +88,9 @@ func (o *removeConfigMapOptions) RunRemoveConfigMap(fSys filesys.FileSystem) err
|
|||||||
}
|
}
|
||||||
|
|
||||||
m.ConfigMapGenerator = newConfigMaps
|
m.ConfigMapGenerator = newConfigMaps
|
||||||
return mf.Write(m)
|
err = mf.Write(m)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("configmap cannot write back to file, got %w", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Kubernetes Authors.
|
// Copyright 2019 The Kubernetes Authors.
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
package remove
|
package remove //nolint:testpackage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|||||||
Reference in New Issue
Block a user