Skip to content

Commit

Permalink
fix: fall back to global secrets was not working (#1340)
Browse files Browse the repository at this point in the history
fixes #1339
  • Loading branch information
matt2e authored Apr 26, 2024
1 parent 7d39eb7 commit 513f4e8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
5 changes: 2 additions & 3 deletions common/configuration/in_memory_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package configuration

import (
"context"
"fmt"
"net/url"
)

Expand All @@ -18,13 +17,13 @@ func NewInMemoryProvider[R Role]() *InMemoryProvider[R] {
}

func (p *InMemoryProvider[R]) Role() R { var r R; return r }
func (p *InMemoryProvider[R]) Key() string { return "grpc" }
func (p *InMemoryProvider[R]) Key() string { return "inmemory" }

func (p *InMemoryProvider[R]) Load(ctx context.Context, ref Ref, key *url.URL) ([]byte, error) {
if bytes, found := p.values[ref]; found {
return bytes, nil
}
return nil, fmt.Errorf("key %q not found", ref.Name)
return nil, ErrNotFound
}

func (p *InMemoryProvider[R]) Writer() bool {
Expand Down
3 changes: 1 addition & 2 deletions common/configuration/in_memory_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package configuration

import (
"context"
"fmt"
"net/url"
)

Expand All @@ -23,7 +22,7 @@ func (k InMemoryResolver[R]) Get(ctx context.Context, ref Ref) (*url.URL, error)
if key, found := k.keyMap[ref]; found {
return key, nil
}
return nil, fmt.Errorf("key %q not found", ref.Name)
return nil, ErrNotFound
}

func (k InMemoryResolver[R]) List(ctx context.Context) ([]Entry, error) {
Expand Down
5 changes: 2 additions & 3 deletions common/configuration/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ func (m *Manager[R]) getData(ctx context.Context, ref Ref) ([]byte, error) {
key, err := m.resolver.Get(ctx, ref)
// Try again at the global scope if the value is not found in module scope.
if ref.Module.Ok() && errors.Is(err, ErrNotFound) {
gref := ref
gref.Module = optional.None[string]()
key, err = m.resolver.Get(ctx, gref)
ref.Module = optional.None[string]()
key, err = m.resolver.Get(ctx, ref)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 513f4e8

Please sign in to comment.