refactor: minor changes to store in collect

This commit is contained in:
David Allen 2025-03-19 15:31:24 -06:00 committed by David Allen
parent b49b1f761d
commit a4928b9ebb
Signed by: towk
GPG key ID: 0430CDBE22619155

View file

@ -70,7 +70,6 @@ func CollectInventory(assets *[]RemoteAsset, params *CollectParams, store secret
outputPath = path.Clean(params.OutputPath) outputPath = path.Clean(params.OutputPath)
smdClient = &client.SmdClient{Client: &http.Client{}} smdClient = &client.SmdClient{Client: &http.Client{}}
initialStore secrets.SecretStore = store initialStore secrets.SecretStore = store
err error
) )
// set the client's params from CLI // set the client's params from CLI
@ -127,11 +126,16 @@ func CollectInventory(assets *[]RemoteAsset, params *CollectParams, store secret
// the provided secretID... // the provided secretID...
// if it does not, create a static store and use the username // if it does not, create a static store and use the username
// and password provided instead // and password provided instead
_, err = store.GetSecretByID(uri) if store != nil {
if store == nil || err != 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) 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) 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)
}
// crawl BMC node to fetch inventory data via Redfish // crawl BMC node to fetch inventory data via Redfish
var ( var (