Skip to content

Commit 03c61d3

Browse files
Switch Nutanix Client to using Session Auth (#398)
This will ensure we make fewer basic auth requests to Prism Central IAM Services.
1 parent 8cef217 commit 03c61d3

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

pkg/client/client.go

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,12 @@ func (n *NutanixClientHelper) BuildClientForNutanixClusterWithFallback(ctx conte
8181
return nil, err
8282
}
8383
creds := prismgoclient.Credentials{
84-
URL: me.Address.Host,
85-
Endpoint: me.Address.Host,
86-
Insecure: me.Insecure,
87-
Username: me.ApiCredentials.Username,
88-
Password: me.ApiCredentials.Password,
84+
URL: me.Address.Host,
85+
Endpoint: me.Address.Host,
86+
Insecure: me.Insecure,
87+
Username: me.ApiCredentials.Username,
88+
Password: me.ApiCredentials.Password,
89+
SessionAuth: true,
8990
}
9091
return Build(creds, me.AdditionalTrustBundle)
9192
}
@@ -191,16 +192,7 @@ func (n *NutanixClientHelper) buildProviderFromFile() (envTypes.Provider, error)
191192
}
192193

193194
func Build(creds prismgoclient.Credentials, additionalTrustBundle string) (*nutanixClientV3.Client, error) {
194-
cli, err := buildClientFromCredentials(creds, additionalTrustBundle)
195-
if err != nil {
196-
return nil, err
197-
}
198-
// Check if the client is working
199-
_, err = cli.V3.GetCurrentLoggedInUser(context.Background())
200-
if err != nil {
201-
return nil, fmt.Errorf("failed to get current logged in user with client: %w", err)
202-
}
203-
return cli, nil
195+
return buildClientFromCredentials(creds, additionalTrustBundle)
204196
}
205197

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

0 commit comments

Comments
 (0)