diff --git a/providers/supermicro/supermicro.go b/providers/supermicro/supermicro.go index e7d224f0..d0e4929b 100644 --- a/providers/supermicro/supermicro.go +++ b/providers/supermicro/supermicro.go @@ -136,7 +136,7 @@ func NewClient(host, user, pass string, log logr.Logger, opts ...Option) *Client opt(defaultConfig) } - serviceClient := newBmcServiceClient( + serviceClient, err := newBmcServiceClient( host, defaultConfig.Port, user, @@ -144,6 +144,10 @@ func NewClient(host, user, pass string, log logr.Logger, opts ...Option) *Client httpclient.Build(defaultConfig.httpClientSetupFuncs...), ) + if err != nil { + return nil + } + return &Client{ serviceClient: serviceClient, log: log, @@ -443,12 +447,20 @@ type serviceClient struct { sum *sum.Sum } -func newBmcServiceClient(host, port, user, pass string, client *http.Client) *serviceClient { +func newBmcServiceClient(host, port, user, pass string, client *http.Client) (*serviceClient, error) { + sc := &serviceClient{host: host, port: port, user: user, pass: pass, client: client} + if !strings.HasPrefix(host, "https://") && !strings.HasPrefix(host, "http://") { - host = "https://" + host + sc.host = "https://" + host + } + + s, err := sum.New(host, user, pass) + if err != nil { + return nil, err } + sc.sum = s - return &serviceClient{host: host, port: port, user: user, pass: pass, client: client} + return sc } func (c *serviceClient) setCsrfToken(t string) {