mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
Merge pull request #2932 from mstrYoda/master
add DisableNameSuffixHash parameter to edit Secret & ConfigMap
This commit is contained in:
@@ -81,6 +81,11 @@ func newCmdAddConfigMap(
|
||||
"from-env-file",
|
||||
"",
|
||||
"Specify the path to a file to read lines of key=val pairs to create a configmap (i.e. a Docker .env file).")
|
||||
cmd.Flags().BoolVar(
|
||||
&flags.DisableNameSuffixHash,
|
||||
"disableNameSuffixHash",
|
||||
false,
|
||||
"Disable the name suffix for the configmap")
|
||||
|
||||
return cmd
|
||||
}
|
||||
@@ -126,4 +131,9 @@ func mergeFlagsIntoCmArgs(args *types.ConfigMapArgs, flags flagsAndArgs) {
|
||||
args.EnvSources = append(
|
||||
args.EnvSources, flags.EnvFileSource)
|
||||
}
|
||||
if flags.DisableNameSuffixHash {
|
||||
args.Options = &types.GeneratorOptions{
|
||||
DisableNameSuffixHash: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ type flagsAndArgs struct {
|
||||
Type string
|
||||
// Namespace of secret
|
||||
Namespace string
|
||||
// Disable name suffix
|
||||
DisableNameSuffixHash bool
|
||||
}
|
||||
|
||||
// Validate validates required fields are set to support structured generation.
|
||||
|
||||
@@ -91,6 +91,11 @@ func newCmdAddSecret(
|
||||
"namespace",
|
||||
"",
|
||||
"Specify the namespace of the secret")
|
||||
cmd.Flags().BoolVar(
|
||||
&flags.DisableNameSuffixHash,
|
||||
"disableNameSuffixHash",
|
||||
false,
|
||||
"Disable the name suffix for the secret")
|
||||
|
||||
return cmd
|
||||
}
|
||||
@@ -139,4 +144,9 @@ func mergeFlagsIntoGeneratorArgs(args *types.GeneratorArgs, flags flagsAndArgs)
|
||||
args.EnvSources = append(
|
||||
args.EnvSources, flags.EnvFileSource)
|
||||
}
|
||||
if flags.DisableNameSuffixHash {
|
||||
args.Options = &types.GeneratorOptions{
|
||||
DisableNameSuffixHash: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,3 +114,14 @@ func TestMergeFlagsIntoSecretArgs_EnvSource(t *testing.T) {
|
||||
t.Fatalf("expected env2")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMergeFlagsIntoSecretArgs_DisableNameSuffixHash(t *testing.T) {
|
||||
k := &types.Kustomization{}
|
||||
args := findOrMakeSecretArgs(k, "foo", "bar", "forbidden")
|
||||
mergeFlagsIntoGeneratorArgs(
|
||||
&args.GeneratorArgs,
|
||||
flagsAndArgs{DisableNameSuffixHash: true})
|
||||
if k.SecretGenerator[0].Options.DisableNameSuffixHash != true {
|
||||
t.Fatalf("expected true")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user