mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Get rid of argsLenAtDash in create job
This commit is contained in:
parent
59fc12006b
commit
ace8386d13
@ -85,8 +85,7 @@ func NewCmdCreateJob(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *
|
|||||||
Long: jobLong,
|
Long: jobLong,
|
||||||
Example: jobExample,
|
Example: jobExample,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
argsLenAtDash := cmd.ArgsLenAtDash()
|
cmdutil.CheckErr(o.Complete(f, cmd, args))
|
||||||
cmdutil.CheckErr(o.Complete(f, cmd, args, argsLenAtDash))
|
|
||||||
cmdutil.CheckErr(o.Validate())
|
cmdutil.CheckErr(o.Validate())
|
||||||
cmdutil.CheckErr(o.Run())
|
cmdutil.CheckErr(o.Run())
|
||||||
},
|
},
|
||||||
@ -103,11 +102,12 @@ func NewCmdCreateJob(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *
|
|||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *CreateJobOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []string, argsLenAtDash int) error {
|
func (o *CreateJobOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []string) error {
|
||||||
if len(args) == 0 || argsLenAtDash == 0 {
|
name, err := NameFromCommandArgs(cmd, args)
|
||||||
return cmdutil.UsageErrorf(cmd, "NAME is required")
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
o.Name = args[0]
|
o.Name = name
|
||||||
if len(args) > 1 {
|
if len(args) > 1 {
|
||||||
o.Command = args[1:]
|
o.Command = args[1:]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user