MCPcopy Create free account
hub / github.com/github/gh-aw / checkOptionalSecret

Function checkOptionalSecret

pkg/cli/engine_secrets.go:439–457  ·  view source on GitHub ↗

checkOptionalSecret checks if an optional secret is available (without prompting)

(req SecretRequirement, config EngineSecretConfig)

Source from the content-addressed store, hash-verified

437
438// checkOptionalSecret checks if an optional secret is available (without prompting)
439func 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
460func uploadSecretToRepo(secretName, secretValue, repoSlug string, verbose bool) error {

Callers 1

Calls 3

ContainsFunction · 0.92
FormatInfoMessageFunction · 0.92
GetenvMethod · 0.80

Tested by

no test coverage detected