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

Method RegenerateGitSSHKey

codersdk/gitsshkey.go:41–54  ·  view source on GitHub ↗

RegenerateGitSSHKey will create a new SSH key pair for the user and return it.

(ctx context.Context, user string)

Source from the content-addressed store, hash-verified

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) {
42 res, err := c.Request(ctx, http.MethodPut, fmt.Sprintf("/api/v2/users/%s/gitsshkey", user), nil)
43 if err != nil {
44 return GitSSHKey{}, xerrors.Errorf("execute request: %w", err)
45 }
46 defer res.Body.Close()
47
48 if res.StatusCode != http.StatusOK {
49 return GitSSHKey{}, ReadBodyAsError(res)
50 }
51
52 var gitsshkey GitSSHKey
53 return gitsshkey, json.NewDecoder(res.Body).Decode(&gitsshkey)
54}

Callers 2

TestGitSSHKeyFunction · 0.80
publickeyMethod · 0.80

Calls 4

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

Tested by 1

TestGitSSHKeyFunction · 0.64