Skip to content

Commit b788992

Browse files
authored
fix(internal/secrets): Error on Missing Secrets (#260)
1 parent c9947dd commit b788992

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

internal/secrets/secrets.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ var (
1717
// interpRe is used for parsing secrets during interpolation. Secrets
1818
// must not contain any curly braces.
1919
interpRe = regexp.MustCompile(`\${(SECRET:[^}]+)}`)
20+
// errNoSecret is returned when no secrets are found in the cache.
21+
errNoSecret = fmt.Errorf("secrets: no secret found")
2022
// KV store is used as a secrets cache
2123
cache kv.Storer
2224
)
@@ -72,6 +74,10 @@ func Interpolate(ctx context.Context, s string) (string, error) {
7274
return "", err
7375
}
7476

77+
if secret == nil {
78+
return "", errNoSecret
79+
}
80+
7581
// Replaces each substring with a secret. If the secret is
7682
// BAR and the string was "/path/to/secret/${SECRET:FOO}",
7783
// then the interpolated string output is "/path/to/secret/BAR".

0 commit comments

Comments
 (0)