Skip to content

Commit

Permalink
Add GetKeystoreSecretName method for kafka and connect
Browse files Browse the repository at this point in the history
Signed-off-by: obaydullahmhs <obaydullah@appscode.com>
  • Loading branch information
obaydullahmhs committed Oct 31, 2024
1 parent 706d75f commit bd7bff6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
17 changes: 8 additions & 9 deletions apis/kafka/v1alpha1/connect_cluster_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,6 @@ func (k *ConnectCluster) KafkaClientCredentialsSecretName() string {
return meta_util.NameWithSuffix(k.Name, "kafka-client-cred")
}

func (k *ConnectCluster) DefaultUserCredSecretName() string {
return meta_util.NameWithSuffix(k.OffshootName(), "auth")
}

func (k *ConnectCluster) DefaultKeystoreCredSecretName() string {
return meta_util.NameWithSuffix(k.Name, strings.ReplaceAll("connect-keystore-cred", "_", "-"))
}

// CertificateName returns the default certificate name and/or certificate secret name for a certificate alias
func (k *ConnectCluster) CertificateName(alias ConnectClusterCertificateAlias) string {
return meta_util.NameWithSuffix(k.Name, fmt.Sprintf("%s-connect-cert", string(alias)))
Expand All @@ -213,7 +205,14 @@ func (k *ConnectCluster) GetAuthSecretName() string {
if k.Spec.AuthSecret != nil && k.Spec.AuthSecret.Name != "" {
return k.Spec.AuthSecret.Name
}
return k.DefaultUserCredSecretName()
return meta_util.NameWithSuffix(k.OffshootName(), "auth")
}

func (k *ConnectCluster) GetKeystoreSecretName() string {
if k.Spec.KeystoreCredSecret != nil && k.Spec.KeystoreCredSecret.Name != "" {
return k.Spec.KeystoreCredSecret.Name
}
return meta_util.NameWithSuffix(k.OffshootName(), "keystore-cred")
}

// GetCertSecretName returns the secret name for a certificate alias if any,
Expand Down
17 changes: 8 additions & 9 deletions apis/kubedb/v1/kafka_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,14 @@ func (k *Kafka) GetAuthSecretName() string {
if k.Spec.AuthSecret != nil && k.Spec.AuthSecret.Name != "" {
return k.Spec.AuthSecret.Name
}
return k.DefaultUserCredSecretName()
return meta_util.NameWithSuffix(k.OffshootName(), "auth")
}

func (k *Kafka) GetKeystoreSecretName() string {
if k.Spec.KeystoreCredSecret != nil && k.Spec.KeystoreCredSecret.Name != "" {
return k.Spec.KeystoreCredSecret.Name
}
return meta_util.NameWithSuffix(k.OffshootName(), "keystore-cred")
}

func (k *Kafka) GetPersistentSecrets() []string {
Expand All @@ -249,14 +256,6 @@ func (k *Kafka) CruiseControlConfigSecretName() string {
return meta_util.NameWithSuffix(k.OffshootName(), "cruise-control-config")
}

func (k *Kafka) DefaultUserCredSecretName() string {
return meta_util.NameWithSuffix(k.OffshootName(), "auth")
}

func (k *Kafka) DefaultKeystoreCredSecretName() string {
return meta_util.NameWithSuffix(k.Name, strings.ReplaceAll("keystore-cred", "_", "-"))
}

// CertificateName returns the default certificate name and/or certificate secret name for a certificate alias
func (k *Kafka) CertificateName(alias KafkaCertificateAlias) string {
return meta_util.NameWithSuffix(k.Name, fmt.Sprintf("%s-cert", string(alias)))
Expand Down

0 comments on commit bd7bff6

Please sign in to comment.