diff --git a/pkg/model/aerospike_cluster.go b/pkg/model/aerospike_cluster.go index 2af167d0..b29cfff8 100644 --- a/pkg/model/aerospike_cluster.go +++ b/pkg/model/aerospike_cluster.go @@ -70,6 +70,11 @@ func (c *AerospikeCluster) GetPassword() *string { return password } + if c.Credentials != nil && c.Credentials.Password != nil { + c.pwd.Store(c.Credentials.Password) + return c.Credentials.Password + } + if c.Credentials == nil || c.Credentials.PasswordPath == nil { slog.Warn("No credentials provided to read password") return nil diff --git a/pkg/model/aerospike_cluster_test.go b/pkg/model/aerospike_cluster_test.go index e2e8e7e7..0156e84f 100644 --- a/pkg/model/aerospike_cluster_test.go +++ b/pkg/model/aerospike_cluster_test.go @@ -27,7 +27,6 @@ func TestAerospikeCluster_GetPassword(t *testing.T) { credentials: &Credentials{ User: nil, PasswordPath: ptr.String(passwordPath), - AuthMode: nil, }, expectedPassword: ptr.String("password"), expectedErr: false, @@ -38,7 +37,6 @@ func TestAerospikeCluster_GetPassword(t *testing.T) { credentials: &Credentials{ User: nil, PasswordPath: ptr.String("not-existing.txt"), - AuthMode: nil, }, expectedPassword: nil, expectedErr: true, @@ -82,7 +80,6 @@ func TestAerospikeCluster_GetPasswordCaching(t *testing.T) { Credentials: &Credentials{ User: nil, PasswordPath: ptr.String(passwordPath), - AuthMode: nil, }, } @@ -96,6 +93,17 @@ func TestAerospikeCluster_GetPasswordCaching(t *testing.T) { passwordAfterCache := cluster.GetPassword() assert.Equal(t, password, passwordAfterCache) } +func TestAerospikeCluster_GetPasswordFromCredentials(t *testing.T) { + cluster := &AerospikeCluster{ + Credentials: &Credentials{ + User: nil, + Password: ptr.String("password"), + }, + } + + password := cluster.GetPassword() + assert.Equal(t, ptr.String("password"), password) +} func createValidFile() { text := []byte("password")