karmadactl register add args check

Signed-off-by: 宋文杰 <wenjie.song@daocloud.io>
This commit is contained in:
宋文杰 2022-11-18 16:32:29 +08:00
parent 594ad9f44b
commit 5185b865f0
1 changed files with 3 additions and 3 deletions

View File

@ -151,6 +151,9 @@ func NewCmdRegister(parentCommand string) *cobra.Command {
Annotations: map[string]string{
cmdutil.TagCommandGroup: cmdutil.GroupClusterRegistration,
},
// We accept the control-plane location as an required positional argument karmada apiserver endpoint
Args: cobra.ExactArgs(1),
}
flags := cmd.Flags()
@ -238,9 +241,6 @@ type CommandRegisterOption struct {
// Complete ensures that options are valid and marshals them if necessary.
func (o *CommandRegisterOption) Complete(args []string) error {
// Get karmada apiserver endpoint from the command args.
if len(args) == 0 {
return fmt.Errorf("karmada apiserver endpoint is required")
}
o.BootstrapToken.APIServerEndpoint = args[0]
restConfig, err := apiclient.RestConfig(o.Context, o.KubeConfig)