Skip to content

Commit 16b82eb

Browse files
committed
feat: include credentials in cache key for Prism Central clients
Update cache key to include endpoint address, username, password, and insecure flag to ensure unique keys per credential set. This is necessary because Prism Central clients use session-based authentication, where each client maintains an authenticated session tied to specific credentials. This ensures that clusters with different credentials get separate cached clients, which is required for proper authentication.
1 parent b57399a commit 16b82eb

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pkg/webhook/preflight/nutanix/cache.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
package nutanix
55

66
import (
7+
"fmt"
8+
79
v4Converged "github.com/nutanix-cloud-native/prism-go-client/converged/v4"
810
"github.com/nutanix-cloud-native/prism-go-client/environment/types"
911
v3 "github.com/nutanix-cloud-native/prism-go-client/v3"
@@ -31,5 +33,12 @@ func (c *CacheParams) ManagementEndpoint() types.ManagementEndpoint {
3133

3234
// Key returns a unique key for the client cache based on the management endpoint.
3335
func (c *CacheParams) Key() string {
34-
return c.PrismManagementEndpoint.Address.String()
36+
endpoint := c.PrismManagementEndpoint
37+
// Include address, username, password, and insecure flag to ensure unique keys per credential set
38+
return fmt.Sprintf("%s:%s:%s:%t",
39+
endpoint.Address.String(),
40+
endpoint.ApiCredentials.Username,
41+
endpoint.ApiCredentials.Password,
42+
endpoint.Insecure,
43+
)
3544
}

0 commit comments

Comments
 (0)