serverKeyId returns the public gpg key id ("identity" field) from the user's server config , if any. It returns the empty string otherwise.
()
| 229 | // from the user's server config , if any. |
| 230 | // It returns the empty string otherwise. |
| 231 | func 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. |
no test coverage detected