SecretRingFile returns the filename to the user's GPG secret ring. The value comes from either the --secret-keyring flag, the CAMLI_SECRET_RING environment variable, the client config file's "identitySecretRing" value, or the operating system default location.
()
| 368 | // CAMLI_SECRET_RING environment variable, the client config file's |
| 369 | // "identitySecretRing" value, or the operating system default location. |
| 370 | func (c *Client) SecretRingFile() string { |
| 371 | if osutil.HasSecretRingFlag() { |
| 372 | if secretRing, ok := osutil.ExplicitSecretRingFile(); ok { |
| 373 | return secretRing |
| 374 | } |
| 375 | } |
| 376 | if android.OnAndroid() { |
| 377 | panic("on android, so CAMLI_SECRET_RING should have been defined, or --secret-keyring used.") |
| 378 | } |
| 379 | if c.noExtConfig { |
| 380 | log.Print("client: noExtConfig set; cannot get secret ring file from config or env vars.") |
| 381 | return "" |
| 382 | } |
| 383 | if configDisabled { |
| 384 | panic("Need a secret ring, and config file disabled") |
| 385 | } |
| 386 | configOnce.Do(parseConfig) |
| 387 | if config.IdentitySecretRing == "" { |
| 388 | return osutil.SecretRingFile() |
| 389 | } |
| 390 | return config.IdentitySecretRing |
| 391 | } |
| 392 | |
| 393 | func fileExists(name string) bool { |
| 394 | _, err := os.Stat(name) |
no test coverage detected