MCPcopy Create free account
hub / github.com/gogs/gogs / writeTmpKeyFile

Function writeTmpKeyFile

internal/database/ssh_key.go:178–189  ·  view source on GitHub ↗

writeTmpKeyFile writes key content to a temporary file and returns the name of that file, along with any possible errors.

(content, keyTestPath string)

Source from the content-addressed store, hash-verified

176// writeTmpKeyFile writes key content to a temporary file
177// and returns the name of that file, along with any possible errors.
178func writeTmpKeyFile(content, keyTestPath string) (string, error) {
179 tmpFile, err := os.CreateTemp(keyTestPath, "gogs_keytest")
180 if err != nil {
181 return "", errors.Newf("TempFile: %v", err)
182 }
183 defer tmpFile.Close()
184
185 if _, err = tmpFile.WriteString(content); err != nil {
186 return "", errors.Newf("WriteString: %v", err)
187 }
188 return tmpFile.Name(), nil
189}
190
191// SSHKeygenParsePublicKey extracts key type and length using ssh-keygen.
192func SSHKeygenParsePublicKey(key, keyTestPath, keygenPath string) (string, int, error) {

Callers 1

SSHKeygenParsePublicKeyFunction · 0.85

Calls 1

NameMethod · 0.45

Tested by

no test coverage detected