kubeadm: Remove the usage to print the default component configs for reset and join

component configs is only needed for `kubeadm init`, the `join` and `reset` doesn't
need to provid the config with component configs.

Signed-off-by: Dave Chen <dave.chen@arm.com>
This commit is contained in:
Dave Chen 2023-07-15 19:13:27 +08:00
parent 5c96e5321e
commit 879dad9c2f
2 changed files with 12 additions and 48 deletions

View File

@ -133,8 +133,10 @@ func newCmdConfigPrintActionDefaults(out io.Writer, action string, configBytesPr
},
Args: cobra.NoArgs,
}
cmd.Flags().StringSliceVar(&kinds, "component-configs", kinds,
fmt.Sprintf("A comma-separated list for component config API objects to print the default values for. Available values: %v. If this flag is not set, no component configs will be printed.", getSupportedComponentConfigKinds()))
if action == "init" {
cmd.Flags().StringSliceVar(&kinds, "component-configs", kinds,
fmt.Sprintf("A comma-separated list for component config API objects to print the default values for. Available values: %v. If this flag is not set, no component configs will be printed.", getSupportedComponentConfigKinds()))
}
return cmd
}

View File

@ -426,56 +426,16 @@ func TestNewCmdConfigPrintActionDefaults(t *testing.T) {
cmdProc: newCmdConfigPrintInitDefaults,
},
{
name: "JoinConfiguration: No component configs",
name: "JoinConfiguration",
expectedKinds: []string{
constants.JoinConfigurationKind,
},
cmdProc: newCmdConfigPrintJoinDefaults,
},
{
name: "JoinConfiguration: KubeProxyConfiguration",
expectedKinds: []string{
constants.JoinConfigurationKind,
"KubeProxyConfiguration",
},
componentConfigs: "KubeProxyConfiguration",
cmdProc: newCmdConfigPrintJoinDefaults,
},
{
name: "JoinConfiguration: KubeProxyConfiguration and KubeletConfiguration",
expectedKinds: []string{
constants.JoinConfigurationKind,
"KubeProxyConfiguration",
"KubeletConfiguration",
},
componentConfigs: "KubeProxyConfiguration,KubeletConfiguration",
cmdProc: newCmdConfigPrintJoinDefaults,
},
{
name: "ResetConfiguration: No component configs",
expectedKinds: []string{
constants.ResetConfigurationKind,
},
cmdProc: newCmdConfigPrintResetDefaults,
},
{
name: "JoinConfiguration: KubeProxyConfiguration",
expectedKinds: []string{
"KubeProxyConfiguration",
constants.ResetConfigurationKind,
},
componentConfigs: "KubeProxyConfiguration",
cmdProc: newCmdConfigPrintResetDefaults,
},
{
name: "JoinConfiguration: KubeProxyConfiguration and KubeletConfiguration",
expectedKinds: []string{
"KubeProxyConfiguration",
"KubeletConfiguration",
constants.ResetConfigurationKind,
},
componentConfigs: "KubeProxyConfiguration,KubeletConfiguration",
cmdProc: newCmdConfigPrintResetDefaults,
name: "ResetConfiguration",
expectedKinds: []string{constants.ResetConfigurationKind},
cmdProc: newCmdConfigPrintResetDefaults,
},
}
@ -484,8 +444,10 @@ func TestNewCmdConfigPrintActionDefaults(t *testing.T) {
var output bytes.Buffer
command := test.cmdProc(&output)
if err := command.Flags().Set("component-configs", test.componentConfigs); err != nil {
t.Fatalf("failed to set component-configs flag")
if test.componentConfigs != "" {
if err := command.Flags().Set("component-configs", test.componentConfigs); err != nil {
t.Fatalf("failed to set component-configs flag")
}
}
if err := command.RunE(nil, nil); err != nil {
t.Fatalf("Error from running the print command: %v", err)