Skip to content

Commit 5870033

Browse files
committed
linting
1 parent 9ed5347 commit 5870033

File tree

1 file changed

+0
-73
lines changed

1 file changed

+0
-73
lines changed

cli/organization.go

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@ package cli
22

33
import (
44
"fmt"
5-
"slices"
65
"strings"
76

87
"golang.org/x/xerrors"
98

109
"github.com/coder/coder/v2/cli/cliui"
11-
"github.com/coder/coder/v2/cli/config"
1210
"github.com/coder/coder/v2/codersdk"
13-
"github.com/coder/pretty"
1411
"github.com/coder/serpent"
1512
)
1613

@@ -37,76 +34,6 @@ func (r *RootCmd) organizations() *serpent.Command {
3734
return cmd
3835
}
3936

40-
// promptUserSelectOrg will prompt the user to select an organization from a list
41-
// of their organizations.
42-
func promptUserSelectOrg(inv *serpent.Invocation, conf config.Root, orgs []codersdk.Organization) (string, error) {
43-
// Default choice
44-
var defaultOrg string
45-
// Comes from config file
46-
if conf.Organization().Exists() {
47-
defaultOrg, _ = conf.Organization().Read()
48-
}
49-
50-
// No config? Comes from default org in the list
51-
if defaultOrg == "" {
52-
defIndex := slices.IndexFunc(orgs, func(org codersdk.Organization) bool {
53-
return org.IsDefault
54-
})
55-
if defIndex >= 0 {
56-
defaultOrg = orgs[defIndex].Name
57-
}
58-
}
59-
60-
// Defer to first org
61-
if defaultOrg == "" && len(orgs) > 0 {
62-
defaultOrg = orgs[0].Name
63-
}
64-
65-
// Ensure the `defaultOrg` value is an org name, not a uuid.
66-
// If it is a uuid, change it to the org name.
67-
index := slices.IndexFunc(orgs, func(org codersdk.Organization) bool {
68-
return org.ID.String() == defaultOrg || org.Name == defaultOrg
69-
})
70-
if index >= 0 {
71-
defaultOrg = orgs[index].Name
72-
}
73-
74-
// deselectOption is the option to delete the organization config file and defer
75-
// to default behavior.
76-
const deselectOption = "[Default]"
77-
if defaultOrg == "" {
78-
defaultOrg = deselectOption
79-
}
80-
81-
// Pull value from a prompt
82-
_, _ = fmt.Fprintln(inv.Stdout, pretty.Sprint(cliui.DefaultStyles.Wrap, "Select an organization below to set the current CLI context to:"))
83-
value, err := cliui.Select(inv, cliui.SelectOptions{
84-
Options: append([]string{deselectOption}, orgNames(orgs)...),
85-
Default: defaultOrg,
86-
Size: 10,
87-
HideSearch: false,
88-
})
89-
if err != nil {
90-
return "", err
91-
}
92-
// Deselect is an alias for ""
93-
if value == deselectOption {
94-
value = ""
95-
}
96-
97-
return value, nil
98-
}
99-
100-
// orgNames is a helper function to turn a list of organizations into a list of
101-
// their names as strings.
102-
func orgNames(orgs []codersdk.Organization) []string {
103-
names := make([]string, 0, len(orgs))
104-
for _, org := range orgs {
105-
names = append(names, org.Name)
106-
}
107-
return names
108-
}
109-
11037
func (r *RootCmd) showOrganization(orgContext *OrganizationContext) *serpent.Command {
11138
var (
11239
stringFormat func(orgs []codersdk.Organization) (string, error)

0 commit comments

Comments
 (0)