Added checks for connectGofish to prevent panics

This commit is contained in:
David J. Allen 2023-10-10 10:35:44 -06:00
parent f59d68797d
commit 4d6ffd213b

View file

@ -632,12 +632,17 @@ func QueryProcessors(q *QueryParams) ([]byte, error) {
func connectGofish(q *QueryParams) (*gofish.APIClient, error) { func connectGofish(q *QueryParams) (*gofish.APIClient, error) {
config := makeGofishConfig(q) config := makeGofishConfig(q)
c, err := gofish.Connect(config) c, err := gofish.Connect(config)
if err != nil {
return nil, fmt.Errorf("could not connect to redfish endpoint: %v", err)
}
if c != nil {
c.Service.ProtocolFeaturesSupported = gofish.ProtocolFeaturesSupported{ c.Service.ProtocolFeaturesSupported = gofish.ProtocolFeaturesSupported{
ExpandQuery: gofish.Expand{ ExpandQuery: gofish.Expand{
ExpandAll: true, ExpandAll: true,
Links: true, Links: true,
}, },
} }
}
return c, err return c, err
} }