MCPcopy
hub / github.com/cli/cli / keyUpload

Function keyUpload

pkg/cmd/ssh-key/add/http.go:100–127  ·  view source on GitHub ↗
(httpClient *http.Client, url string, payload map[string]string)

Source from the content-addressed store, hash-verified

98}
99
100func keyUpload(httpClient *http.Client, url string, payload map[string]string) error {
101 payloadBytes, err := json.Marshal(payload)
102 if err != nil {
103 return err
104 }
105
106 req, err := http.NewRequest("POST", url, bytes.NewBuffer(payloadBytes))
107 if err != nil {
108 return err
109 }
110
111 resp, err := httpClient.Do(req)
112 if err != nil {
113 return err
114 }
115 defer resp.Body.Close()
116
117 if resp.StatusCode > 299 {
118 return api.HandleHTTPError(resp)
119 }
120
121 _, err = io.Copy(io.Discard, resp.Body)
122 if err != nil {
123 return err
124 }
125
126 return nil
127}

Callers 2

SSHKeyUploadFunction · 0.85
SSHSigningKeyUploadFunction · 0.85

Calls 4

HandleHTTPErrorFunction · 0.92
DoMethod · 0.65
CloseMethod · 0.65
CopyMethod · 0.45

Tested by

no test coverage detected