mirror of
https://github.com/bmc-toolbox/bmclib.git
synced 2025-06-03 05:14:43 +00:00
Merge pull request #317 from bmc-toolbox/biosattr-nil-check
providers/redfish: fixes a panic in cases where a nil bios object was returned
This commit is contained in:
commit
d39fb75b6a
@ -86,6 +86,9 @@ var (
|
|||||||
|
|
||||||
// ErrCompatibilityCheck is returned when the compatibility probe failed to complete successfully.
|
// ErrCompatibilityCheck is returned when the compatibility probe failed to complete successfully.
|
||||||
ErrCompatibilityCheck = errors.New("compatibility check failed")
|
ErrCompatibilityCheck = errors.New("compatibility check failed")
|
||||||
|
|
||||||
|
// ErrNoBiosAttributes is returned when no bios attributes are available from the BMC.
|
||||||
|
ErrNoBiosAttributes = errors.New("no BIOS attributes available")
|
||||||
)
|
)
|
||||||
|
|
||||||
type ErrUnsupportedHardware struct {
|
type ErrUnsupportedHardware struct {
|
||||||
|
@ -2,6 +2,8 @@ package redfish
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
bmclibErrs "github.com/bmc-toolbox/bmclib/v2/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Conn) GetBiosConfiguration(ctx context.Context) (biosConfig map[string]string, err error) {
|
func (c *Conn) GetBiosConfiguration(ctx context.Context) (biosConfig map[string]string, err error) {
|
||||||
@ -21,9 +23,14 @@ func (c *Conn) GetBiosConfiguration(ctx context.Context) (biosConfig map[string]
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if bios == nil {
|
||||||
|
return nil, bmclibErrs.ErrNoBiosAttributes
|
||||||
|
}
|
||||||
|
|
||||||
for attr := range bios.Attributes {
|
for attr := range bios.Attributes {
|
||||||
biosConfig[attr] = bios.Attributes.String(attr)
|
biosConfig[attr] = bios.Attributes.String(attr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return biosConfig, nil
|
return biosConfig, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user