Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(internal/secrets): Error on Missing Secrets #260

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions internal/secrets/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ var (
// interpRe is used for parsing secrets during interpolation. Secrets
// must not contain any curly braces.
interpRe = regexp.MustCompile(`\${(SECRET:[^}]+)}`)
// errNoSecret is returned when no secrets are found in the cache.
errNoSecret = fmt.Errorf("secrets: no secret found")
// KV store is used as a secrets cache
cache kv.Storer
)
Expand Down Expand Up @@ -72,6 +74,10 @@ func Interpolate(ctx context.Context, s string) (string, error) {
return "", err
}

if secret == nil {
return "", errNoSecret
}

// Replaces each substring with a secret. If the secret is
// BAR and the string was "/path/to/secret/${SECRET:FOO}",
// then the interpolated string output is "/path/to/secret/BAR".
Expand Down