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

Function UserSigningKeys

pkg/cmd/ssh-key/shared/user_keys.go:53–77  ·  view source on GitHub ↗
(httpClient *http.Client, host, userHandle string)

Source from the content-addressed store, hash-verified

51}
52
53func UserSigningKeys(httpClient *http.Client, host, userHandle string) ([]sshKey, error) {
54 u, err := safeurl.JoinPathWithHostPrefix(ghinstance.RESTPrefix(host), "user", "ssh_signing_keys")
55 if err != nil {
56 return nil, err
57 }
58 if userHandle != "" {
59 u, err = safeurl.JoinPathWithHostPrefix(ghinstance.RESTPrefix(host), "users", userHandle, "ssh_signing_keys")
60 if err != nil {
61 return nil, err
62 }
63 }
64 u.SetQuery("per_page", "100")
65
66 keys, err := getUserKeys(httpClient, u)
67
68 if err != nil {
69 return nil, err
70 }
71
72 for i := 0; i < len(keys); i++ {
73 keys[i].Type = SigningKey
74 }
75
76 return keys, nil
77}
78
79func getUserKeys(httpClient *http.Client, u safeurl.SafeURL) ([]sshKey, error) {
80 req, err := http.NewRequest("GET", u.String(), nil)

Callers 2

listRunFunction · 0.92
SSHSigningKeyUploadFunction · 0.92

Calls 4

JoinPathWithHostPrefixFunction · 0.92
RESTPrefixFunction · 0.92
getUserKeysFunction · 0.85
SetQueryMethod · 0.80

Tested by

no test coverage detected