chore: added pre-condition guards for secrets

This commit is contained in:
David Allen 2025-03-17 10:14:36 -06:00 committed by David Allen
parent cdf380bd64
commit 9396de11c2
Signed by: towk
GPG key ID: 0430CDBE22619155
2 changed files with 8 additions and 1 deletions

View file

@ -148,7 +148,6 @@ func CrawlBMCForSystems(config CrawlerConfig) ([]InventoryDetail, error) {
return walkSystems(rf_systems, nil, config.URI)
}
// CrawlBMCForSystems pulls BMC manager information.
// CrawlBMCForManagers connects to a BMC (Baseboard Management Controller) using the provided configuration,
// retrieves the ServiceRoot, and then fetches the list of managers from the ServiceRoot.
//
@ -374,6 +373,10 @@ func walkManagers(rf_managers []*redfish.Manager, baseURI string) ([]Manager, er
}
func loadBMCCreds(config CrawlerConfig) (BMCUsernamePassword, error) {
// NOTE: it is possible for the SecretStore to be nil, so we need a check
if config.CredentialStore == nil {
return BMCUsernamePassword{}, fmt.Errorf("credential store is invalid")
}
creds, err := config.CredentialStore.GetSecretByID(config.URI)
if err != nil {
event := log.Error()