(ctx context.Context, ch *cmdutil.Helper)
| 556 | } |
| 557 | |
| 558 | func createOrgFlow(ctx context.Context, ch *cmdutil.Helper) error { |
| 559 | c, err := ch.Client() |
| 560 | if err != nil { |
| 561 | return err |
| 562 | } |
| 563 | |
| 564 | ch.PrintfBold("No organization found for your account. Creating a new organization.\n") |
| 565 | name, err := orgNamePrompt(ctx, ch) |
| 566 | if err != nil { |
| 567 | return err |
| 568 | } |
| 569 | |
| 570 | res, err := c.CreateOrganization(ctx, &adminv1.CreateOrganizationRequest{ |
| 571 | Name: name, |
| 572 | }) |
| 573 | if err != nil { |
| 574 | return err |
| 575 | } |
| 576 | |
| 577 | // Switching to the created org |
| 578 | ch.Org = res.Organization.Name |
| 579 | err = ch.DotRill.SetDefaultOrg(ch.Org) |
| 580 | if err != nil { |
| 581 | return err |
| 582 | } |
| 583 | |
| 584 | return nil |
| 585 | } |
| 586 | |
| 587 | func orgNamePrompt(ctx context.Context, ch *cmdutil.Helper) (string, error) { |
| 588 | qs := []*survey.Question{ |
no test coverage detected