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

Function userKeys

pkg/cmd/gpg-key/list/http.go:37–63  ·  view source on GitHub ↗
(httpClient *http.Client, host, userHandle string)

Source from the content-addressed store, hash-verified

35}
36
37func userKeys(httpClient *http.Client, host, userHandle string) ([]gpgKey, error) {
38 u, err := safeurl.JoinPath("user", "gpg_keys")
39 if err != nil {
40 return nil, err
41 }
42 if userHandle != "" {
43 u, err = safeurl.JoinPath("users", userHandle, "gpg_keys")
44 if err != nil {
45 return nil, err
46 }
47 }
48 u.SetQuery("per_page", "100")
49
50 var keys []gpgKey
51 // TODO(api-client-rollout)
52 // This line of code is part of a mechanical roll out of the api client.
53 // As a follow up, consider whether the api client can be injected to this call site, rather than constructed
54 err = api.NewClientFromHTTP(httpClient).REST(host, "GET", u.String(), nil, &keys)
55 if err != nil {
56 if httpErr, ok := errors.AsType[api.HTTPError](err); ok && httpErr.StatusCode == 404 {
57 return nil, errScopes
58 }
59 return nil, err
60 }
61
62 return keys, nil
63}

Callers 4

Test_userKeysHTTPErrorFunction · 0.85
Test_userKeysForUserFunction · 0.85
listRunFunction · 0.85

Calls 5

JoinPathFunction · 0.92
NewClientFromHTTPFunction · 0.92
SetQueryMethod · 0.80
RESTMethod · 0.65
StringMethod · 0.65

Tested by 3

Test_userKeysHTTPErrorFunction · 0.68
Test_userKeysForUserFunction · 0.68