Skip to content

Commit

Permalink
Switch Nutanix Client to using Session Auth (#398)
Browse files Browse the repository at this point in the history
This will ensure we make fewer basic auth requests to Prism Central
IAM Services.
  • Loading branch information
thunderboltsid committed Apr 24, 2024
1 parent 6e77e9c commit 9c7ba34
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@ func (n *NutanixClientHelper) BuildClientForNutanixClusterWithFallback(ctx conte
return nil, err
}
creds := prismgoclient.Credentials{
URL: me.Address.Host,
Endpoint: me.Address.Host,
Insecure: me.Insecure,
Username: me.ApiCredentials.Username,
Password: me.ApiCredentials.Password,
URL: me.Address.Host,
Endpoint: me.Address.Host,
Insecure: me.Insecure,
Username: me.ApiCredentials.Username,
Password: me.ApiCredentials.Password,
SessionAuth: true,
}
return Build(creds, me.AdditionalTrustBundle)
}
Expand Down Expand Up @@ -191,16 +192,7 @@ func (n *NutanixClientHelper) buildProviderFromFile() (envTypes.Provider, error)
}

func Build(creds prismgoclient.Credentials, additionalTrustBundle string) (*nutanixClientV3.Client, error) {
cli, err := buildClientFromCredentials(creds, additionalTrustBundle)
if err != nil {
return nil, err
}
// Check if the client is working
_, err = cli.V3.GetCurrentLoggedInUser(context.Background())
if err != nil {
return nil, fmt.Errorf("failed to get current logged in user with client: %w", err)
}
return cli, nil
return buildClientFromCredentials(creds, additionalTrustBundle)
}

func buildClientFromCredentials(creds prismgoclient.Credentials, additionalTrustBundle string) (*nutanixClientV3.Client, error) {
Expand Down

0 comments on commit 9c7ba34

Please sign in to comment.