MCPcopy Create free account
hub / github.com/cli/cli / getOrgVariables

Function getOrgVariables

pkg/cmd/variable/list/list.go:212–235  ·  view source on GitHub ↗
(client *http.Client, host, orgName string, showSelectedRepoInfo bool)

Source from the content-addressed store, hash-verified

210}
211
212func getOrgVariables(client *http.Client, host, orgName string, showSelectedRepoInfo bool) ([]shared.Variable, error) {
213 u, err := safeurl.JoinPath("orgs", orgName, "actions", "variables")
214 if err != nil {
215 return nil, err
216 }
217 variables, err := getVariables(client, host, u)
218 if err != nil {
219 return nil, err
220 }
221 apiClient := api.NewClientFromHTTP(client)
222 if showSelectedRepoInfo {
223 for i := range variables {
224 if variables[i].SelectedReposURL == "" {
225 continue
226 }
227 count, err := shared.SelectedRepositoryCount(apiClient, host, safeurl.NewImmutableSafeURL(variables[i].SelectedReposURL))
228 if err != nil {
229 return nil, fmt.Errorf("failed determining selected repositories for %s: %w", variables[i].Name, err)
230 }
231 variables[i].NumSelectedRepos = count
232 }
233 }
234 return variables, nil
235}
236
237func getVariables(client *http.Client, host string, u *safeurl.MutableSafeURL) ([]shared.Variable, error) {
238 var results []shared.Variable

Callers 1

listRunFunction · 0.85

Calls 6

JoinPathFunction · 0.92
NewClientFromHTTPFunction · 0.92
SelectedRepositoryCountFunction · 0.92
NewImmutableSafeURLFunction · 0.92
getVariablesFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected