mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-11 21:12:07 +00:00
Merge pull request #128181 from SataQiu/clean-20241018
kubeadm: using options.Force constant instead of 'force' string
This commit is contained in:
commit
de7e1e7b28
@ -125,8 +125,8 @@ const (
|
||||
// SkipCertificateKeyPrint flag instructs kubeadm to skip printing certificate key used to encrypt certs by 'kubeadm init'.
|
||||
SkipCertificateKeyPrint = "skip-certificate-key-print"
|
||||
|
||||
// ForceReset flag instructs kubeadm to reset the node without prompting for confirmation
|
||||
ForceReset = "force"
|
||||
// Force flag instructs kubeadm to do something (such as reset, upgrade, etc.) without prompting for confirmation.
|
||||
Force = "force"
|
||||
|
||||
// CertificateRenewal flag instructs kubeadm to execute certificate renewal during upgrades
|
||||
CertificateRenewal = "certificate-renewal"
|
||||
|
@ -39,7 +39,7 @@ func NewPreflightPhase() workflow.Phase {
|
||||
Run: runPreflight,
|
||||
InheritFlags: []string{
|
||||
options.IgnorePreflightErrors,
|
||||
options.ForceReset,
|
||||
options.Force,
|
||||
options.DryRun,
|
||||
},
|
||||
}
|
||||
|
@ -47,11 +47,11 @@ func NewPreflightPhase() workflow.Phase {
|
||||
InheritFlags: []string{
|
||||
options.CfgPath,
|
||||
options.KubeconfigPath,
|
||||
options.Force,
|
||||
options.DryRun,
|
||||
options.IgnorePreflightErrors,
|
||||
"allow-experimental-upgrades",
|
||||
"allow-release-candidate-upgrades",
|
||||
"force",
|
||||
"yes",
|
||||
},
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ func newResetData(cmd *cobra.Command, opts *resetOptions, in io.Reader, out io.W
|
||||
cfg: initCfg,
|
||||
resetCfg: resetCfg,
|
||||
dryRun: dryRunFlag,
|
||||
forceReset: cmdutil.ValueFromFlagsOrConfig(cmd.Flags(), options.ForceReset, resetCfg.Force, opts.externalcfg.Force).(bool),
|
||||
forceReset: cmdutil.ValueFromFlagsOrConfig(cmd.Flags(), options.Force, resetCfg.Force, opts.externalcfg.Force).(bool),
|
||||
cleanupTmpDir: cmdutil.ValueFromFlagsOrConfig(cmd.Flags(), options.CleanupTmpDir, resetCfg.CleanupTmpDir, opts.externalcfg.CleanupTmpDir).(bool),
|
||||
}, nil
|
||||
}
|
||||
@ -195,7 +195,7 @@ func AddResetFlags(flagSet *flag.FlagSet, resetOptions *resetOptions) {
|
||||
`The path to the directory where the certificates are stored. If specified, clean this directory.`,
|
||||
)
|
||||
flagSet.BoolVarP(
|
||||
&resetOptions.externalcfg.Force, options.ForceReset, "f", resetOptions.externalcfg.Force,
|
||||
&resetOptions.externalcfg.Force, options.Force, "f", resetOptions.externalcfg.Force,
|
||||
"Reset the node without prompting for confirmation.",
|
||||
)
|
||||
flagSet.BoolVar(
|
||||
|
@ -80,7 +80,7 @@ func TestNewResetData(t *testing.T) {
|
||||
options.CertificatesDir: "/tmp",
|
||||
options.NodeCRISocket: constants.CRISocketCRIO,
|
||||
options.IgnorePreflightErrors: "all",
|
||||
options.ForceReset: "true",
|
||||
options.Force: "true",
|
||||
options.DryRun: "true",
|
||||
options.CleanupTmpDir: "true",
|
||||
},
|
||||
@ -184,8 +184,8 @@ func TestNewResetData(t *testing.T) {
|
||||
{
|
||||
name: "--force flag is not allowed to mix with config",
|
||||
flags: map[string]string{
|
||||
options.CfgPath: configFilePath,
|
||||
options.ForceReset: "false",
|
||||
options.CfgPath: configFilePath,
|
||||
options.Force: "false",
|
||||
},
|
||||
expectError: "can not mix '--config' with arguments",
|
||||
},
|
||||
|
@ -124,7 +124,7 @@ func newCmdApply(apf *applyPlanFlags) *cobra.Command {
|
||||
addApplyPlanFlags(cmd.Flags(), flags.applyPlanFlags)
|
||||
// Specify the valid flags specific for apply
|
||||
cmd.Flags().BoolVarP(&flags.nonInteractiveMode, "yes", "y", flags.nonInteractiveMode, "Perform the upgrade and do not prompt for confirmation (non-interactive mode).")
|
||||
cmd.Flags().BoolVarP(&flags.force, "force", "f", flags.force, "Force upgrading although some requirements might not be met. This also implies non-interactive mode.")
|
||||
cmd.Flags().BoolVarP(&flags.force, options.Force, "f", flags.force, "Force upgrading although some requirements might not be met. This also implies non-interactive mode.")
|
||||
cmd.Flags().BoolVar(&flags.dryRun, options.DryRun, flags.dryRun, "Do not change any state, just output what actions would be performed.")
|
||||
cmd.Flags().BoolVar(&flags.etcdUpgrade, options.EtcdUpgrade, flags.etcdUpgrade, "Perform the upgrade of etcd.")
|
||||
cmd.Flags().BoolVar(&flags.renewCerts, options.CertificateRenewal, flags.renewCerts, "Perform the renewal of certificates used by component changed during upgrades.")
|
||||
@ -188,7 +188,7 @@ func newApplyData(cmd *cobra.Command, args []string, applyFlags *applyFlags) (*a
|
||||
return nil, err
|
||||
}
|
||||
|
||||
force, ok := cmdutil.ValueFromFlagsOrConfig(cmd.Flags(), "force", upgradeCfg.Apply.ForceUpgrade, &applyFlags.force).(*bool)
|
||||
force, ok := cmdutil.ValueFromFlagsOrConfig(cmd.Flags(), options.Force, upgradeCfg.Apply.ForceUpgrade, &applyFlags.force).(*bool)
|
||||
if !ok {
|
||||
return nil, cmdutil.TypeMismatchErr("forceUpgrade", "bool")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user