MCPcopy
hub / github.com/digitalocean/doctl / spacesKeysUpdate

Function spacesKeysUpdate

commands/spaces_keys.go:155–186  ·  view source on GitHub ↗
(c *CmdConfig)

Source from the content-addressed store, hash-verified

153}
154
155func spacesKeysUpdate(c *CmdConfig) error {
156 if len(c.Args) == 0 {
157 return doctl.NewMissingArgsErr(c.NS)
158 }
159
160 grants, err := c.Doit.GetStringSlice(c.NS, "grants")
161 if err != nil {
162 return err
163 }
164
165 parsedGrants, err := parseGrantsFromArg(grants)
166 if err != nil {
167 return err
168 }
169
170 name, err := c.Doit.GetString(c.NS, "name")
171 if err != nil {
172 return err
173 }
174
175 r := &godo.SpacesKeyUpdateRequest{
176 Name: name,
177 Grants: parsedGrants,
178 }
179
180 key, err := c.SpacesKeys().Update(c.Args[0], r)
181 if err != nil {
182 return err
183 }
184
185 return displaySpacesKeys(c, *key)
186}
187
188func displaySpacesKeys(c *CmdConfig, keys ...do.SpacesKey) error {
189 item := &displayers.SpacesKey{SpacesKeys: keys}

Callers 1

TestRunSpacesKeysUpdateFunction · 0.85

Calls 6

NewMissingArgsErrFunction · 0.92
parseGrantsFromArgFunction · 0.85
displaySpacesKeysFunction · 0.85
GetStringSliceMethod · 0.65
GetStringMethod · 0.65
UpdateMethod · 0.65

Tested by 1

TestRunSpacesKeysUpdateFunction · 0.68