Skip to content

Commit

Permalink
lookupchain: collect errors but continue with chain
Browse files Browse the repository at this point in the history
  • Loading branch information
malt3 committed Feb 24, 2025
1 parent f9d97e4 commit 6b84f14
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion authenticate/internal/lookupchain/lookupchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func (c *LookupChain) Lookup(binding string) (string, error) {
if len(c.config) == 0 {
return "", fmt.Errorf("no sources configured to look up binding %q", binding)
}
var errs []error
for _, entry := range c.config {
source, err := c.sourceFor(entry)
if err != nil {
Expand All @@ -43,12 +44,17 @@ func (c *LookupChain) Lookup(binding string) (string, error) {
if IsNotFoundErr(err) {
continue
}
return "", fmt.Errorf("looking up binding %q: %w", binding, err)
errs = append(errs, fmt.Errorf("source %q: %w", entry.Source, err))
}
sourceNames := make([]string, len(c.config))
for i, entry := range c.config {
sourceNames[i] = entry.Source
}

if len(errs) > 0 {
return "", fmt.Errorf("no value found for binding %q after querying: %w", binding, errors.Join(errs...))
}

return "", &NotFoundErr{reason: fmt.Sprintf("no value found for binding %q after querying %v", binding, strings.Join(sourceNames, ", "))}
}

Expand Down

0 comments on commit 6b84f14

Please sign in to comment.