MCPcopy
hub / github.com/marmotedu/iam / Complete

Method Complete

internal/iamctl/cmd/user/user_create.go:88–118  ·  view source on GitHub ↗

Complete completes all the required options.

(f cmdutil.Factory, cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

86
87// Complete completes all the required options.
88func (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.
121func (o *CreateOptions) Validate(cmd *cobra.Command, args []string) error {

Callers 1

NewCmdCreateFunction · 0.95

Calls 1

ToRESTConfigMethod · 0.65

Tested by

no test coverage detected