Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

providers/supermicro/supermicro.go: Initialize sum 'client' during serviceclient init #402

Merged
merged 3 commits into from
Oct 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
splaspood marked this conversation as resolved.
Show resolved Hide resolved
}

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
Loading