kubeadm: allow mix of --print-manifest and --config flags

The flag --print-manifest is only present for the subphases of
'kubeadm init phase addon'. It needs to be allowed to be mixed
with the flag --config so that the user can pass their custom
config that will affect the output of the printed manifests.
This commit is contained in:
Lubomir I. Ivanov 2024-08-16 17:00:20 +03:00
parent fa75c8c749
commit d441d9140d
2 changed files with 3 additions and 0 deletions

View File

@ -609,6 +609,7 @@ func isAllowedFlag(flagName string) bool {
kubeadmcmdoptions.NodeName,
kubeadmcmdoptions.KubeconfigDir,
kubeadmcmdoptions.UploadCerts,
kubeadmcmdoptions.PrintManifest,
kubeadmcmdoptions.FeatureGatesString, // TODO: remove this line when --feature-gates flag is deprecated and dropped from "kubeadm upgrade apply/plan"
"api-server-manifest", "controller-manager-manifest", "scheduler-manifest", // TODO: remove this line when these flags are deprecated and dropped from "kubeadm upgrade diff"
"allow-missing-template-keys", "output", "show-managed-fields",

View File

@ -751,6 +751,7 @@ func TestValidateMixedArguments(t *testing.T) {
{[]string{"--config=hello", "--skip-token-print=true"}, true},
{[]string{"--config=hello", "--ignore-preflight-errors=baz", "--skip-token-print"}, true},
{[]string{"--config=hello", "--yes=true"}, true},
{[]string{"--config=hello", "--print-manifest"}, true},
// Expected to fail, --config is mixed with the --foo flag
{[]string{"--config=hello", "--ignore-preflight-errors=baz", "--foo=bar"}, false},
{[]string{"--config=hello", "--foo=bar"}, false},
@ -771,6 +772,7 @@ func TestValidateMixedArguments(t *testing.T) {
f.Bool("allow-experimental-upgrades", true, "upgrade flags for plan and apply command")
f.Bool("skip-token-print", false, "flag not bound to config object")
f.Bool("yes", false, "flag not bound to config object")
f.Bool("print-manifest", false, "flag not bound to config object")
f.StringVar(&cfgPath, "config", cfgPath, "Path to kubeadm config file")
if err := f.Parse(rt.args); err != nil {
t.Fatal(err)