From be69c9dbae4ce2a7c92ae1a5fa663e522216769d Mon Sep 17 00:00:00 2001 From: Kim Christensen Date: Thu, 2 Jan 2025 10:04:36 +0100 Subject: [PATCH] fix: Fix unit tests Signed-off-by: Kim Christensen --- pkg/cnab/provider/credentials.go | 8 +++----- pkg/storage/credentialset.go | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pkg/cnab/provider/credentials.go b/pkg/cnab/provider/credentials.go index 12ba9b0f4..3fff0eed7 100644 --- a/pkg/cnab/provider/credentials.go +++ b/pkg/cnab/provider/credentials.go @@ -17,12 +17,10 @@ func (r *Runtime) loadCredentials(ctx context.Context, b cnab.ExtendedBundle, ru return span.Error(err) } - for _, key := range run.Credentials.Keys() { - cred, ok := run.Credentials.GetCredential(key) - if !ok { - return span.Errorf("credential %s not found", key) + for i, cred := range run.Credentials.Credentials { + if resolvedValue, ok := resolvedCredentials[cred.Name]; ok { + run.Credentials.Credentials[i].ResolvedValue = resolvedValue } - cred.ResolvedValue = resolvedCredentials[key] } err = run.Credentials.ValidateBundle(b.Credentials, run.Action) diff --git a/pkg/storage/credentialset.go b/pkg/storage/credentialset.go index 4e797cce4..ed0779d98 100644 --- a/pkg/storage/credentialset.go +++ b/pkg/storage/credentialset.go @@ -188,7 +188,7 @@ func (s CredentialSet) ValidateBundle(spec map[string]bundle.Credential, action // Keys returns the names of all the credentials in the set. func (s CredentialSet) Keys() []string { - keys := make([]string, len(s.Credentials)) + keys := make([]string, 0, len(s.Credentials)) for _, cred := range s.Credentials { keys = append(keys, cred.Name) }