From 58d779b7ee3352ddc829923101282e594f642897 Mon Sep 17 00:00:00 2001 From: Joel Rebello Date: Tue, 26 Apr 2022 16:48:02 +0200 Subject: [PATCH] providers: merge changes from master, a few suggested fixes --- providers/asrockrack/asrockrack.go | 2 -- providers/asrockrack/firmware.go | 7 +++++-- providers/redfish/redfish.go | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/providers/asrockrack/asrockrack.go b/providers/asrockrack/asrockrack.go index ff241cf9..faa44d46 100644 --- a/providers/asrockrack/asrockrack.go +++ b/providers/asrockrack/asrockrack.go @@ -4,8 +4,6 @@ import ( "bytes" "context" "crypto/x509" - "fmt" - "io" "net/http" "github.com/bmc-toolbox/bmclib/devices" diff --git a/providers/asrockrack/firmware.go b/providers/asrockrack/firmware.go index 74badd9a..078d37ff 100644 --- a/providers/asrockrack/firmware.go +++ b/providers/asrockrack/firmware.go @@ -10,6 +10,7 @@ import ( "github.com/bmc-toolbox/bmclib/devices" bmclibErrs "github.com/bmc-toolbox/bmclib/errors" + "github.com/bmc-toolbox/bmclib/internal" ) const ( @@ -179,6 +180,10 @@ func (a *ASRockRack) firmwareUpdateStatus(ctx context.Context, component string, // - 1 indicates the given version parameter does not match the version installed // - 2 the version parameter returned from the BMC is empty (which means the BMC needs a reset) func (a *ASRockRack) versionInstalled(ctx context.Context, component, version string) (status int, err error) { + if !internal.StringInSlice(component, []string{devices.SlugBIOS, devices.SlugBMC}) { + return versionStrError, errors.Wrap(bmclibErrs.ErrFirmwareInstall, "component unsupported: "+component) + } + fwInfo, err := a.firmwareInfo(ctx) if err != nil { err = errors.Wrap(err, "error querying for firmware info: ") @@ -193,8 +198,6 @@ func (a *ASRockRack) versionInstalled(ctx context.Context, component, version st installed = fwInfo.BIOSVersion case devices.SlugBMC: installed = fwInfo.BMCVersion - default: - return versionStrError, errors.Wrap(bmclibErrs.ErrFirmwareInstall, "component unsupported: "+component) } // version match diff --git a/providers/redfish/redfish.go b/providers/redfish/redfish.go index 9199acb6..a372bfbe 100644 --- a/providers/redfish/redfish.go +++ b/providers/redfish/redfish.go @@ -91,7 +91,7 @@ func (c *Conn) Open(ctx context.Context) (err error) { } config := gofish.ClientConfig{ - Endpoint: "https://" + c.Host, + Endpoint: c.Host, Username: c.User, Password: c.Pass, Insecure: true,