MCPcopy Create free account
hub / github.com/rilldata/rill / orgNamePrompt

Function orgNamePrompt

cli/cmd/project/deploy.go:587–620  ·  view source on GitHub ↗
(ctx context.Context, ch *cmdutil.Helper)

Source from the content-addressed store, hash-verified

585}
586
587func orgNamePrompt(ctx context.Context, ch *cmdutil.Helper) (string, error) {
588 qs := []*survey.Question{
589 {
590 Name: "name",
591 Prompt: &survey.Input{
592 Message: "Enter an org name",
593 },
594 Validate: func(v any) error {
595 // Validate org name doesn't exist already
596 name := v.(string)
597 if name == "" {
598 return fmt.Errorf("empty name")
599 }
600
601 exists, err := orgExists(ctx, ch, name)
602 if err != nil {
603 return fmt.Errorf("failed to check org name: %w", err)
604 }
605
606 if exists {
607 return fmt.Errorf("org with name %q already exists", name)
608 }
609 return nil
610 },
611 },
612 }
613
614 name := ""
615 if err := survey.Ask(qs, &name); err != nil {
616 return "", err
617 }
618
619 return name, nil
620}
621
622func orgExists(ctx context.Context, ch *cmdutil.Helper, name string) (bool, error) {
623 c, err := ch.Client()

Callers 1

createOrgFlowFunction · 0.85

Calls 2

orgExistsFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected