mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 01:14:22 +00:00
add DisableNameSuffixHash for secret and configmap
This commit is contained in:
@@ -81,6 +81,11 @@ func newCmdAddConfigMap(
|
|||||||
"from-env-file",
|
"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).")
|
"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
|
return cmd
|
||||||
}
|
}
|
||||||
@@ -126,4 +131,9 @@ func mergeFlagsIntoCmArgs(args *types.ConfigMapArgs, flags flagsAndArgs) {
|
|||||||
args.EnvSources = append(
|
args.EnvSources = append(
|
||||||
args.EnvSources, flags.EnvFileSource)
|
args.EnvSources, flags.EnvFileSource)
|
||||||
}
|
}
|
||||||
|
if flags.DisableNameSuffixHash {
|
||||||
|
args.Options = &types.GeneratorOptions{
|
||||||
|
DisableNameSuffixHash: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ type flagsAndArgs struct {
|
|||||||
Type string
|
Type string
|
||||||
// Namespace of secret
|
// Namespace of secret
|
||||||
Namespace string
|
Namespace string
|
||||||
|
// Disable name suffix
|
||||||
|
DisableNameSuffixHash bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate validates required fields are set to support structured generation.
|
// Validate validates required fields are set to support structured generation.
|
||||||
|
|||||||
@@ -91,6 +91,11 @@ func newCmdAddSecret(
|
|||||||
"namespace",
|
"namespace",
|
||||||
"",
|
"",
|
||||||
"Specify the namespace of the secret")
|
"Specify the namespace of the secret")
|
||||||
|
cmd.Flags().BoolVar(
|
||||||
|
&flags.DisableNameSuffixHash,
|
||||||
|
"disableNameSuffixHash",
|
||||||
|
false,
|
||||||
|
"Disable the name suffix for the secret")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
@@ -139,4 +144,9 @@ func mergeFlagsIntoGeneratorArgs(args *types.GeneratorArgs, flags flagsAndArgs)
|
|||||||
args.EnvSources = append(
|
args.EnvSources = append(
|
||||||
args.EnvSources, flags.EnvFileSource)
|
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")
|
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