Complete completes all the required options.
(f cmdutil.Factory, cmd *cobra.Command, args []string)
| 86 | |
| 87 | // Complete completes all the required options. |
| 88 | func (o *CreateOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []string) error { |
| 89 | var err error |
| 90 | if len(args) < 3 { |
| 91 | return cmdutil.UsageErrorf(cmd, createUsageErrStr) |
| 92 | } |
| 93 | |
| 94 | if o.Nickname == "" { |
| 95 | o.Nickname = args[0] |
| 96 | } |
| 97 | |
| 98 | o.User = &v1.User{ |
| 99 | ObjectMeta: metav1.ObjectMeta{ |
| 100 | Name: args[0], |
| 101 | }, |
| 102 | Nickname: o.Nickname, |
| 103 | Password: args[1], |
| 104 | Email: args[2], |
| 105 | Phone: o.Phone, |
| 106 | } |
| 107 | |
| 108 | clientConfig, err := f.ToRESTConfig() |
| 109 | if err != nil { |
| 110 | return err |
| 111 | } |
| 112 | o.Client, err = apiclientv1.NewForConfig(clientConfig) |
| 113 | if err != nil { |
| 114 | return err |
| 115 | } |
| 116 | |
| 117 | return nil |
| 118 | } |
| 119 | |
| 120 | // Validate makes sure there is no discrepency in command options. |
| 121 | func (o *CreateOptions) Validate(cmd *cobra.Command, args []string) error { |
no test coverage detected