Skip to content

Commit de7e1e7

Browse files
authored
Merge pull request kubernetes#128181 from SataQiu/clean-20241018
kubeadm: using options.Force constant instead of 'force' string
2 parents 85ff7e7 + a0f8c51 commit de7e1e7

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

cmd/kubeadm/app/cmd/options/constant.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ const (
125125
// SkipCertificateKeyPrint flag instructs kubeadm to skip printing certificate key used to encrypt certs by 'kubeadm init'.
126126
SkipCertificateKeyPrint = "skip-certificate-key-print"
127127

128-
// ForceReset flag instructs kubeadm to reset the node without prompting for confirmation
129-
ForceReset = "force"
128+
// Force flag instructs kubeadm to do something (such as reset, upgrade, etc.) without prompting for confirmation.
129+
Force = "force"
130130

131131
// CertificateRenewal flag instructs kubeadm to execute certificate renewal during upgrades
132132
CertificateRenewal = "certificate-renewal"

cmd/kubeadm/app/cmd/phases/reset/preflight.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func NewPreflightPhase() workflow.Phase {
3939
Run: runPreflight,
4040
InheritFlags: []string{
4141
options.IgnorePreflightErrors,
42-
options.ForceReset,
42+
options.Force,
4343
options.DryRun,
4444
},
4545
}

cmd/kubeadm/app/cmd/phases/upgrade/apply/preflight.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ func NewPreflightPhase() workflow.Phase {
4747
InheritFlags: []string{
4848
options.CfgPath,
4949
options.KubeconfigPath,
50+
options.Force,
5051
options.DryRun,
5152
options.IgnorePreflightErrors,
5253
"allow-experimental-upgrades",
5354
"allow-release-candidate-upgrades",
54-
"force",
5555
"yes",
5656
},
5757
}

cmd/kubeadm/app/cmd/reset.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func newResetData(cmd *cobra.Command, opts *resetOptions, in io.Reader, out io.W
183183
cfg: initCfg,
184184
resetCfg: resetCfg,
185185
dryRun: dryRunFlag,
186-
forceReset: cmdutil.ValueFromFlagsOrConfig(cmd.Flags(), options.ForceReset, resetCfg.Force, opts.externalcfg.Force).(bool),
186+
forceReset: cmdutil.ValueFromFlagsOrConfig(cmd.Flags(), options.Force, resetCfg.Force, opts.externalcfg.Force).(bool),
187187
cleanupTmpDir: cmdutil.ValueFromFlagsOrConfig(cmd.Flags(), options.CleanupTmpDir, resetCfg.CleanupTmpDir, opts.externalcfg.CleanupTmpDir).(bool),
188188
}, nil
189189
}
@@ -195,7 +195,7 @@ func AddResetFlags(flagSet *flag.FlagSet, resetOptions *resetOptions) {
195195
`The path to the directory where the certificates are stored. If specified, clean this directory.`,
196196
)
197197
flagSet.BoolVarP(
198-
&resetOptions.externalcfg.Force, options.ForceReset, "f", resetOptions.externalcfg.Force,
198+
&resetOptions.externalcfg.Force, options.Force, "f", resetOptions.externalcfg.Force,
199199
"Reset the node without prompting for confirmation.",
200200
)
201201
flagSet.BoolVar(

cmd/kubeadm/app/cmd/reset_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func TestNewResetData(t *testing.T) {
8080
options.CertificatesDir: "/tmp",
8181
options.NodeCRISocket: constants.CRISocketCRIO,
8282
options.IgnorePreflightErrors: "all",
83-
options.ForceReset: "true",
83+
options.Force: "true",
8484
options.DryRun: "true",
8585
options.CleanupTmpDir: "true",
8686
},
@@ -184,8 +184,8 @@ func TestNewResetData(t *testing.T) {
184184
{
185185
name: "--force flag is not allowed to mix with config",
186186
flags: map[string]string{
187-
options.CfgPath: configFilePath,
188-
options.ForceReset: "false",
187+
options.CfgPath: configFilePath,
188+
options.Force: "false",
189189
},
190190
expectError: "can not mix '--config' with arguments",
191191
},

cmd/kubeadm/app/cmd/upgrade/apply.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func newCmdApply(apf *applyPlanFlags) *cobra.Command {
124124
addApplyPlanFlags(cmd.Flags(), flags.applyPlanFlags)
125125
// Specify the valid flags specific for apply
126126
cmd.Flags().BoolVarP(&flags.nonInteractiveMode, "yes", "y", flags.nonInteractiveMode, "Perform the upgrade and do not prompt for confirmation (non-interactive mode).")
127-
cmd.Flags().BoolVarP(&flags.force, "force", "f", flags.force, "Force upgrading although some requirements might not be met. This also implies non-interactive mode.")
127+
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.")
128128
cmd.Flags().BoolVar(&flags.dryRun, options.DryRun, flags.dryRun, "Do not change any state, just output what actions would be performed.")
129129
cmd.Flags().BoolVar(&flags.etcdUpgrade, options.EtcdUpgrade, flags.etcdUpgrade, "Perform the upgrade of etcd.")
130130
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
188188
return nil, err
189189
}
190190

191-
force, ok := cmdutil.ValueFromFlagsOrConfig(cmd.Flags(), "force", upgradeCfg.Apply.ForceUpgrade, &applyFlags.force).(*bool)
191+
force, ok := cmdutil.ValueFromFlagsOrConfig(cmd.Flags(), options.Force, upgradeCfg.Apply.ForceUpgrade, &applyFlags.force).(*bool)
192192
if !ok {
193193
return nil, cmdutil.TypeMismatchErr("forceUpgrade", "bool")
194194
}

0 commit comments

Comments
 (0)