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

Function SetDefaultOrg

cli/cmd/org/switch.go:84–111  ·  view source on GitHub ↗

SetDefaultOrg sets a default org for the user if user is part of any org.

(ctx context.Context, ch *cmdutil.Helper)

Source from the content-addressed store, hash-verified

82
83// SetDefaultOrg sets a default org for the user if user is part of any org.
84func SetDefaultOrg(ctx context.Context, ch *cmdutil.Helper) error {
85 c, err := ch.Client()
86 if err != nil {
87 return err
88 }
89
90 res, err := c.ListOrganizations(ctx, &adminv1.ListOrganizationsRequest{
91 PageSize: 1000,
92 })
93 if err != nil {
94 return fmt.Errorf("listing orgs failed: %w", err)
95 }
96
97 if len(res.Organizations) == 0 {
98 return nil
99 }
100
101 orgName := res.Organizations[0].Name
102 if ch.Interactive && len(res.Organizations) > 1 {
103 orgName, err = SwitchSelectFlow(ch, res.Organizations)
104 if err != nil {
105 return fmt.Errorf("org selection failed %w", err)
106 }
107 }
108
109 ch.Org = orgName
110 return ch.DotRill.SetDefaultOrg(orgName)
111}

Callers 2

ConnectGithubFlowFunction · 0.92
DeployWithUploadFlowFunction · 0.92

Calls 5

SwitchSelectFlowFunction · 0.85
SetDefaultOrgMethod · 0.80
ListOrganizationsMethod · 0.65
ErrorfMethod · 0.65
ClientMethod · 0.45

Tested by

no test coverage detected