checkOptionalSecret checks if an optional secret is available (without prompting)
(req SecretRequirement, config EngineSecretConfig)
| 437 | |
| 438 | // checkOptionalSecret checks if an optional secret is available (without prompting) |
| 439 | func checkOptionalSecret(req SecretRequirement, config EngineSecretConfig) error { |
| 440 | // Check repository |
| 441 | if setutil.Contains(config.ExistingSecrets, req.Name) { |
| 442 | if config.Verbose { |
| 443 | fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Optional secret %s exists in repository", req.Name))) |
| 444 | } |
| 445 | return nil |
| 446 | } |
| 447 | |
| 448 | // Check environment |
| 449 | if os.Getenv(req.Name) != "" { |
| 450 | if config.Verbose { |
| 451 | fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Optional secret %s found in environment", req.Name))) |
| 452 | } |
| 453 | return nil |
| 454 | } |
| 455 | |
| 456 | return errors.New("not configured") |
| 457 | } |
| 458 | |
| 459 | // uploadSecretToRepo uploads a secret to the repository if it doesn't already exist |
| 460 | func uploadSecretToRepo(secretName, secretValue, repoSlug string, verbose bool) error { |
no test coverage detected