Skip to content

Commit

Permalink
Add GetSystemUserSecret Heplers on PerconaXtraDB (#989)
Browse files Browse the repository at this point in the history
Signed-off-by: Md. Alif Biswas <alif@appscode.com>
  • Loading branch information
Md. Alif Biswas authored Oct 10, 2022
1 parent 35e1d5e commit 2dae1fa
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions apis/kubedb/v1alpha2/perconaxtradb_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,24 @@ func (p PerconaXtraDB) GetAuthSecretName() string {
return meta_util.NameWithSuffix(p.OffshootName(), "auth")
}

func (p PerconaXtraDB) GetReplicationSecretName() string {
if p.Spec.SystemUserSecrets != nil &&
p.Spec.SystemUserSecrets.ReplicationUserSecret != nil &&
p.Spec.SystemUserSecrets.ReplicationUserSecret.Name != "" {
return p.Spec.SystemUserSecrets.ReplicationUserSecret.Name
}
return meta_util.NameWithSuffix(p.OffshootName(), "replication")
}

func (p PerconaXtraDB) GetMonitorSecretName() string {
if p.Spec.SystemUserSecrets != nil &&
p.Spec.SystemUserSecrets.MonitorUserSecret != nil &&
p.Spec.SystemUserSecrets.MonitorUserSecret.Name != "" {
return p.Spec.SystemUserSecrets.MonitorUserSecret.Name
}
return meta_util.NameWithSuffix(p.OffshootName(), "monitor")
}

func (p PerconaXtraDB) ClusterName() string {
return p.OffshootName()
}
Expand Down Expand Up @@ -292,6 +310,12 @@ func (p *PerconaXtraDBSpec) GetPersistentSecrets() []string {
if p.AuthSecret != nil {
secrets = append(secrets, p.AuthSecret.Name)
}
if p.SystemUserSecrets != nil && p.SystemUserSecrets.ReplicationUserSecret != nil {
secrets = append(secrets, p.SystemUserSecrets.ReplicationUserSecret.Name)
}
if p.SystemUserSecrets != nil && p.SystemUserSecrets.MonitorUserSecret != nil {
secrets = append(secrets, p.SystemUserSecrets.MonitorUserSecret.Name)
}
return secrets
}

Expand All @@ -312,14 +336,6 @@ func (p *PerconaXtraDB) GetCertSecretName(alias PerconaXtraDBCertificateAlias) s
return p.CertificateName(alias)
}

func (p *PerconaXtraDB) ReplicationSecretName() string {
return meta_util.NameWithSuffix(p.Name, "replication")
}

func (p *PerconaXtraDB) MonitorSecretName() string {
return meta_util.NameWithSuffix(p.Name, "monitor")
}

func (p *PerconaXtraDB) ReplicasAreReady(lister appslister.StatefulSetLister) (bool, string, error) {
// Desire number of statefulSets
expectedItems := 1
Expand Down

0 comments on commit 2dae1fa

Please sign in to comment.