From a4928b9ebb3c4f84b8b0910f5d70ba1d1b2f7c0c Mon Sep 17 00:00:00 2001 From: "David J. Allen" Date: Wed, 19 Mar 2025 15:31:24 -0600 Subject: [PATCH] refactor: minor changes to store in collect --- pkg/collect.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/collect.go b/pkg/collect.go index 07591d5..a83c730 100644 --- a/pkg/collect.go +++ b/pkg/collect.go @@ -70,7 +70,6 @@ func CollectInventory(assets *[]RemoteAsset, params *CollectParams, store secret outputPath = path.Clean(params.OutputPath) smdClient = &client.SmdClient{Client: &http.Client{}} initialStore secrets.SecretStore = store - err error ) // set the client's params from CLI @@ -127,9 +126,14 @@ func CollectInventory(assets *[]RemoteAsset, params *CollectParams, store secret // the provided secretID... // if it does not, create a static store and use the username // and password provided instead - _, err = store.GetSecretByID(uri) - if store == nil || err != nil { - log.Warn().Err(err).Msgf("could not retrieve secrets for %s...falling back to default provided credentials", uri) + if store != nil { + _, err := store.GetSecretByID(uri) + if err != nil { + log.Warn().Err(err).Msgf("could not retrieve secrets for %s...falling back to default provided credentials", uri) + store = secrets.NewStaticStore(params.Username, params.Password) + } + } else { + log.Warn().Msgf("invalid store...falling back to default provided credentials for %s", uri) store = secrets.NewStaticStore(params.Username, params.Password) }