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

Function ParseAlgorithm

coderd/gitsshkey/gitsshkey.go:48–62  ·  view source on GitHub ↗

ParseAlgorithm returns a valid Algorithm or error if input is not a valid.

(t string)

Source from the content-addressed store, hash-verified

46
47// ParseAlgorithm returns a valid Algorithm or error if input is not a valid.
48func ParseAlgorithm(t string) (Algorithm, error) {
49 ok := []string{
50 string(AlgorithmEd25519),
51 string(AlgorithmECDSA),
52 string(AlgorithmRSA4096),
53 }
54
55 for _, a := range ok {
56 if strings.EqualFold(a, t) {
57 return Algorithm(a), nil
58 }
59 }
60
61 return "", xerrors.Errorf(`invalid key type: %s, must be one of: %s`, t, strings.Join(ok, ","))
62}
63
64// Generate creates a private key in the OpenSSH PEM format and public key in
65// the authorized key format.

Callers 3

TestGitSSHKeysFunction · 0.92
ServerMethod · 0.92

Calls 2

AlgorithmTypeAlias · 0.85
ErrorfMethod · 0.45

Tested by 1

TestGitSSHKeysFunction · 0.74