| 634 | } |
| 635 | |
| 636 | func (c *cli) customDomainsPickerOptions(ctx context.Context) (pickerOptions, error) { |
| 637 | var opts pickerOptions |
| 638 | |
| 639 | domains, err := c.api.CustomDomain.List(ctx) |
| 640 | if err != nil { |
| 641 | var errStatus management.Error |
| 642 | errors.As(err, &errStatus) |
| 643 | // 403 is a valid response for free tenants that don't have |
| 644 | // custom domains enabled. |
| 645 | if errStatus != nil && errStatus.Status() == 403 { |
| 646 | return nil, errNoCustomDomains |
| 647 | } |
| 648 | |
| 649 | return nil, fmt.Errorf("failed to list custom domains: %w", err) |
| 650 | } |
| 651 | |
| 652 | for _, d := range domains { |
| 653 | value := d.GetID() |
| 654 | label := fmt.Sprintf("%s %s", d.GetDomain(), ansi.Faint("("+value+")")) |
| 655 | opts = append(opts, pickerOption{value: value, label: label}) |
| 656 | } |
| 657 | |
| 658 | if len(opts) == 0 { |
| 659 | return nil, errNoCustomDomains |
| 660 | } |
| 661 | |
| 662 | return opts, nil |
| 663 | } |
| 664 | |
| 665 | func (c *cli) customDomainNamePickerOptions(ctx context.Context) (pickerOptions, error) { |
| 666 | var opts pickerOptions |