(orgContext *OrganizationContext)
| 232 | } |
| 233 | |
| 234 | func (r *RootCmd) updateOrganizationRole(orgContext *OrganizationContext) *serpent.Command { |
| 235 | formatter := cliui.NewOutputFormatter( |
| 236 | cliui.ChangeFormatterData( |
| 237 | cliui.TableFormat([]roleTableRow{}, []string{"name", "display name", "site permissions", "organization permissions", "user permissions"}), |
| 238 | func(data any) (any, error) { |
| 239 | typed, _ := data.(codersdk.Role) |
| 240 | return []roleTableRow{roleToTableView(typed)}, nil |
| 241 | }, |
| 242 | ), |
| 243 | cliui.JSONFormat(), |
| 244 | ) |
| 245 | |
| 246 | var ( |
| 247 | dryRun bool |
| 248 | jsonInput bool |
| 249 | ) |
| 250 | |
| 251 | cmd := &serpent.Command{ |
| 252 | Use: "update <role_name>", |
| 253 | Short: "Update an organization custom role", |
| 254 | Long: FormatExamples( |
| 255 | Example{ |
| 256 | Description: "Run with an input.json file", |
| 257 | Command: "coder roles update --stdin < role.json", |
| 258 | }, |
| 259 | ), |
| 260 | Options: []serpent.Option{ |
| 261 | cliui.SkipPromptOption(), |
| 262 | { |
| 263 | Name: "dry-run", |
| 264 | Description: "Does all the work, but does not submit the final updated role.", |
| 265 | Flag: "dry-run", |
| 266 | Value: serpent.BoolOf(&dryRun), |
| 267 | }, |
| 268 | { |
| 269 | Name: "stdin", |
| 270 | Description: "Reads stdin for the json role definition to upload.", |
| 271 | Flag: "stdin", |
| 272 | Value: serpent.BoolOf(&jsonInput), |
| 273 | }, |
| 274 | }, |
| 275 | Middleware: serpent.Chain( |
| 276 | serpent.RequireRangeArgs(0, 1), |
| 277 | ), |
| 278 | Handler: func(inv *serpent.Invocation) error { |
| 279 | client, err := r.InitClient(inv) |
| 280 | if err != nil { |
| 281 | return err |
| 282 | } |
| 283 | |
| 284 | ctx := inv.Context() |
| 285 | org, err := orgContext.Selected(inv, client) |
| 286 | if err != nil { |
| 287 | return err |
| 288 | } |
| 289 | |
| 290 | existingRoles, err := client.ListOrganizationRoles(ctx, org.ID) |
| 291 | if err != nil { |
no test coverage detected