Skip to content

Commit

Permalink
providers/supermicro/supermicro.go: Initialize sum 'client' during se…
Browse files Browse the repository at this point in the history
…rviceclient init
  • Loading branch information
splaspood committed Oct 28, 2024
1 parent 490323d commit 43237b1
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions providers/supermicro/supermicro.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,18 @@ func NewClient(host, user, pass string, log logr.Logger, opts ...Option) *Client
opt(defaultConfig)
}

serviceClient := newBmcServiceClient(
serviceClient, err := newBmcServiceClient(
host,
defaultConfig.Port,
user,
pass,
httpclient.Build(defaultConfig.httpClientSetupFuncs...),
)

if err != nil {
return nil
}

return &Client{
serviceClient: serviceClient,
log: log,
Expand Down Expand Up @@ -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, nil
}

func (c *serviceClient) setCsrfToken(t string) {
Expand Down

0 comments on commit 43237b1

Please sign in to comment.