MCPcopy
hub / github.com/perkeep/perkeep / serverKeyId

Function serverKeyId

pkg/client/config.go:231–248  ·  view source on GitHub ↗

serverKeyId returns the public gpg key id ("identity" field) from the user's server config , if any. It returns the empty string otherwise.

()

Source from the content-addressed store, hash-verified

229// from the user's server config , if any.
230// It returns the empty string otherwise.
231func serverKeyId() string {
232 serverConfigFile := osutil.UserServerConfigPath()
233 if _, err := wkfs.Stat(serverConfigFile); err != nil {
234 if os.IsNotExist(err) {
235 return ""
236 }
237 log.Fatalf("Could not stat %v: %v", serverConfigFile, err)
238 }
239 obj, err := jsonconfig.ReadFile(serverConfigFile)
240 if err != nil {
241 return ""
242 }
243 keyID, ok := obj["identity"].(string)
244 if !ok {
245 return ""
246 }
247 return keyID
248}
249
250// cleanServer returns the canonical URL of the provided server, which must be a URL, IP, host (with dot), or host/ip:port.
251// The returned canonical URL will have trailing slashes removed and be prepended with "https://" if no scheme is provided.

Callers 1

parseConfigMethod · 0.85

Calls 3

UserServerConfigPathFunction · 0.92
StatMethod · 0.65
FatalfMethod · 0.65

Tested by

no test coverage detected