@@ -140,7 +140,7 @@ func NewCmdInit(out io.Writer, initOptions *initOptions) *cobra.Command {
140
140
// adds flags to the init command
141
141
// init command local flags could be eventually inherited by the sub-commands automatically generated for phases
142
142
AddInitConfigFlags (cmd .Flags (), initOptions .externalcfg , & initOptions .featureGatesString )
143
- AddInitOtherFlags (cmd .Flags (), & initOptions . cfgPath , & initOptions . skipTokenPrint , & initOptions . dryRun , & initOptions . uploadCerts , & initOptions . ignorePreflightErrors )
143
+ AddInitOtherFlags (cmd .Flags (), initOptions )
144
144
initOptions .bto .AddTokenFlag (cmd .Flags ())
145
145
initOptions .bto .AddTTLFlag (cmd .Flags ())
146
146
options .AddImageMetaFlags (cmd .Flags (), & initOptions .externalcfg .ImageRepository )
@@ -225,27 +225,22 @@ func AddInitConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiv1beta1.InitConfig
225
225
226
226
// AddInitOtherFlags adds init flags that are not bound to a configuration file to the given flagset
227
227
// Note: All flags that are not bound to the cfg object should be allowed in cmd/kubeadm/app/apis/kubeadm/validation/validation.go
228
- func AddInitOtherFlags (
229
- flagSet * flag.FlagSet ,
230
- cfgPath * string ,
231
- skipTokenPrint , dryRun , uploadCerts * bool ,
232
- ignorePreflightErrors * []string ,
233
- ) {
234
- options .AddConfigFlag (flagSet , cfgPath )
228
+ func AddInitOtherFlags (flagSet * flag.FlagSet , initOptions * initOptions ) {
229
+ options .AddConfigFlag (flagSet , & initOptions .cfgPath )
235
230
flagSet .StringSliceVar (
236
- ignorePreflightErrors , options .IgnorePreflightErrors , * ignorePreflightErrors ,
231
+ & initOptions . ignorePreflightErrors , options .IgnorePreflightErrors , initOptions . ignorePreflightErrors ,
237
232
"A list of checks whose errors will be shown as warnings. Example: 'IsPrivilegedUser,Swap'. Value 'all' ignores errors from all checks." ,
238
233
)
239
234
flagSet .BoolVar (
240
- skipTokenPrint , options .SkipTokenPrint , * skipTokenPrint ,
235
+ & initOptions . skipTokenPrint , options .SkipTokenPrint , initOptions . skipTokenPrint ,
241
236
"Skip printing of the default bootstrap token generated by 'kubeadm init'." ,
242
237
)
243
238
flagSet .BoolVar (
244
- dryRun , options .DryRun , * dryRun ,
239
+ & initOptions . dryRun , options .DryRun , initOptions . dryRun ,
245
240
"Don't apply any changes; just output what would be done." ,
246
241
)
247
242
flagSet .BoolVar (
248
- uploadCerts , options .UploadCerts , * uploadCerts ,
243
+ & initOptions . uploadCerts , options .UploadCerts , initOptions . uploadCerts ,
249
244
"Upload certfificates to kubeadm-certs secret." ,
250
245
)
251
246
}
@@ -476,8 +471,8 @@ func (d *initData) Tokens() []string {
476
471
return tokens
477
472
}
478
473
479
- func printJoinCommand (out io.Writer , adminKubeConfigPath , token , key string , skipTokenPrint , uploadCerts bool ) error {
480
- joinCommand , err := cmdutil .GetJoinCommand (adminKubeConfigPath , token , key , skipTokenPrint , uploadCerts )
474
+ func printJoinCommand (out io.Writer , adminKubeConfigPath , token string , i * initData ) error {
475
+ joinCommand , err := cmdutil .GetJoinCommand (adminKubeConfigPath , token , i . certificateKey , i . skipTokenPrint , i . uploadCerts )
481
476
if err != nil {
482
477
return err
483
478
}
@@ -496,7 +491,7 @@ func showJoinCommand(i *initData, out io.Writer) error {
496
491
497
492
// Prints the join command, multiple times in case the user has multiple tokens
498
493
for _ , token := range i .Tokens () {
499
- if err := printJoinCommand (out , adminKubeConfigPath , token , i . certificateKey , i . skipTokenPrint , i . uploadCerts ); err != nil {
494
+ if err := printJoinCommand (out , adminKubeConfigPath , token , i ); err != nil {
500
495
return errors .Wrap (err , "failed to print join command" )
501
496
}
502
497
}
0 commit comments