MCPcopy Create free account
hub / github.com/cloudbase/garm / resolveOrganization

Function resolveOrganization

cmd/garm-cli/cmd/util.go:94–122  ·  view source on GitHub ↗
(nameOrID, endpoint string)

Source from the content-addressed store, hash-verified

92}
93
94func resolveOrganization(nameOrID, endpoint string) (string, error) {
95 if nameOrID == "" {
96 return "", fmt.Errorf("missing organization name or ID")
97 }
98 entityID, err := uuid.Parse(nameOrID)
99 if err == nil {
100 return entityID.String(), nil
101 }
102
103 listOrgsReq := apiClientOrgs.NewListOrgsParams()
104 listOrgsReq.Name = &nameOrID
105 if endpoint != "" {
106 listOrgsReq.Endpoint = &endpoint
107 }
108 response, err := apiCli.Organizations.ListOrgs(listOrgsReq, authToken)
109 if err != nil {
110 return "", err
111 }
112
113 if len(response.Payload) == 0 {
114 return "", fmt.Errorf("organization %s was not found", nameOrID)
115 }
116
117 if len(response.Payload) > 1 {
118 return "", fmt.Errorf("multiple organizations with the name %s exist, please use the organization ID or specify the --endpoint parameter", nameOrID)
119 }
120
121 return response.Payload[0].ID, nil
122}
123
124func resolveEnterprise(nameOrID, endpoint string) (string, error) {
125 if nameOrID == "" {

Callers 4

scalesets.goFile · 0.85
pool.goFile · 0.85
runner.goFile · 0.85
organization.goFile · 0.85

Calls 2

ListOrgsMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected