mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
chore: added pre-condition guards for secrets
This commit is contained in:
parent
cdf380bd64
commit
9396de11c2
2 changed files with 8 additions and 1 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -104,6 +104,10 @@ func (l *LocalSecretStore) ListSecrets() (map[string]string, error) {
|
|||
// openStore tries to create or open the LocalSecretStore based on the environment
|
||||
// variable MASTER_KEY. If not found, it prints an error.
|
||||
func OpenStore(filename string) (SecretStore, error) {
|
||||
if filename == "" {
|
||||
return nil, fmt.Errorf("no path to secret store provided")
|
||||
}
|
||||
|
||||
masterKey := os.Getenv("MASTER_KEY")
|
||||
if masterKey == "" {
|
||||
return nil, fmt.Errorf("MASTER_KEY environment variable not set")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue