From 33e1b0daa1bc6c89cb651f5879e19d44d55b5025 Mon Sep 17 00:00:00 2001 From: Sid Shukla Date: Wed, 24 Apr 2024 10:25:46 -0400 Subject: [PATCH] Switch Nutanix Client to using Session Auth (#398) This will ensure we make fewer basic auth requests to Prism Central IAM Services. --- pkg/client/client.go | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/pkg/client/client.go b/pkg/client/client.go index fbb70ba842..db8bfb8a64 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -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) } @@ -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) {