From d441d9140de1e220e4e132d934c912a8d3656fc0 Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Fri, 16 Aug 2024 17:00:20 +0300 Subject: [PATCH] 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. --- cmd/kubeadm/app/apis/kubeadm/validation/validation.go | 1 + cmd/kubeadm/app/apis/kubeadm/validation/validation_test.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/cmd/kubeadm/app/apis/kubeadm/validation/validation.go b/cmd/kubeadm/app/apis/kubeadm/validation/validation.go index 24e1fa0147e..939efa2ad07 100644 --- a/cmd/kubeadm/app/apis/kubeadm/validation/validation.go +++ b/cmd/kubeadm/app/apis/kubeadm/validation/validation.go @@ -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", diff --git a/cmd/kubeadm/app/apis/kubeadm/validation/validation_test.go b/cmd/kubeadm/app/apis/kubeadm/validation/validation_test.go index 5147c7ce6cd..60c5ebf0586 100644 --- a/cmd/kubeadm/app/apis/kubeadm/validation/validation_test.go +++ b/cmd/kubeadm/app/apis/kubeadm/validation/validation_test.go @@ -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)