MCPcopy Index your code
hub / github.com/coder/coder / GitSSHKey

Method GitSSHKey

codersdk/gitsshkey.go:25–38  ·  view source on GitHub ↗

GitSSHKey returns the user's git SSH public key.

(ctx context.Context, user string)

Source from the content-addressed store, hash-verified

23
24// GitSSHKey returns the user's git SSH public key.
25func (c *Client) GitSSHKey(ctx context.Context, user string) (GitSSHKey, error) {
26 res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/users/%s/gitsshkey", user), nil)
27 if err != nil {
28 return GitSSHKey{}, xerrors.Errorf("execute request: %w", err)
29 }
30 defer res.Body.Close()
31
32 if res.StatusCode != http.StatusOK {
33 return GitSSHKey{}, ReadBodyAsError(res)
34 }
35
36 var gitsshkey GitSSHKey
37 return gitsshkey, json.NewDecoder(res.Body).Decode(&gitsshkey)
38}
39
40// RegenerateGitSSHKey will create a new SSH key pair for the user and return it.
41func (c *Client) RegenerateGitSSHKey(ctx context.Context, user string) (GitSSHKey, error) {

Callers 8

TestGitSSHKeyFunction · 0.45
TestAgentGitSSHKeyFunction · 0.45
publickeyMethod · 0.45
prepareTestGitSSHFunction · 0.45
gitsshFunction · 0.45

Calls 4

RequestMethod · 0.95
ReadBodyAsErrorFunction · 0.85
CloseMethod · 0.65
ErrorfMethod · 0.45

Tested by 6

TestGitSSHKeyFunction · 0.36
TestAgentGitSSHKeyFunction · 0.36
prepareTestGitSSHFunction · 0.36