| 368 | } |
| 369 | |
| 370 | func (c *cli) customDomainPickerOptions(ctx context.Context) (pickerOptions, error) { |
| 371 | var opts pickerOptions |
| 372 | |
| 373 | domains, err := c.api.CustomDomain.List(ctx) |
| 374 | if err != nil { |
| 375 | errStatus := err.(management.Error) |
| 376 | // 403 is a valid response for free tenants that don't have |
| 377 | // custom domains enabled. |
| 378 | if errStatus != nil && errStatus.Status() == 403 { |
| 379 | return nil, errNoCustomDomains |
| 380 | } |
| 381 | |
| 382 | return nil, err |
| 383 | } |
| 384 | |
| 385 | for _, d := range domains { |
| 386 | if d.GetStatus() != "ready" { |
| 387 | continue |
| 388 | } |
| 389 | |
| 390 | opts = append(opts, pickerOption{value: d.GetDomain(), label: d.GetDomain()}) |
| 391 | } |
| 392 | |
| 393 | if len(opts) == 0 { |
| 394 | return nil, errNoCustomDomains |
| 395 | } |
| 396 | |
| 397 | opts = append(opts, pickerOption{value: "", label: fmt.Sprintf("none (use %s)", c.tenant)}) |
| 398 | |
| 399 | return opts, nil |
| 400 | } |
| 401 | |
| 402 | func (c *cli) appPickerWithCreateOption(ctx context.Context) (pickerOptions, error) { |
| 403 | options, err := c.appPickerOptions()(ctx) |