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

Function resolveRepository

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

Source from the content-addressed store, hash-verified

56}
57
58func resolveRepository(nameOrID, endpoint string) (string, error) {
59 if nameOrID == "" {
60 return "", fmt.Errorf("missing repository name or ID")
61 }
62 entityID, err := uuid.Parse(nameOrID)
63 if err == nil {
64 return entityID.String(), nil
65 }
66
67 parts := strings.SplitN(nameOrID, "/", 2)
68 if len(parts) < 2 {
69 // format of friendly name is invalid for a repository.
70 // Return the string as is.
71 return nameOrID, nil
72 }
73
74 listReposReq := apiClientRepos.NewListReposParams()
75 listReposReq.Owner = &parts[0]
76 listReposReq.Name = &parts[1]
77 if endpoint != "" {
78 listReposReq.Endpoint = &endpoint
79 }
80 response, err := apiCli.Repositories.ListRepos(listReposReq, authToken)
81 if err != nil {
82 return "", err
83 }
84 if len(response.Payload) == 0 {
85 return "", fmt.Errorf("repository %s was not found", nameOrID)
86 }
87
88 if len(response.Payload) > 1 {
89 return "", fmt.Errorf("multiple repositories with the name %s exist, please use the repository ID or specify the --endpoint parameter", nameOrID)
90 }
91 return response.Payload[0].ID, nil
92}
93
94func resolveOrganization(nameOrID, endpoint string) (string, error) {
95 if nameOrID == "" {

Callers 4

repository.goFile · 0.85
scalesets.goFile · 0.85
pool.goFile · 0.85
runner.goFile · 0.85

Calls 2

ListReposMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected