Skip to content

Commit

Permalink
Implement DBBindInterface for generic bindings (#1381)
Browse files Browse the repository at this point in the history
Signed-off-by: Arnob kumar saha <[email protected]>
  • Loading branch information
ArnobKumarSaha authored Jan 13, 2025
1 parent 7dd4fbe commit 051792b
Show file tree
Hide file tree
Showing 7 changed files with 270 additions and 0 deletions.
23 changes: 23 additions & 0 deletions apis/kubedb/v1alpha2/druid_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -803,3 +803,26 @@ func (d *Druid) CertSecretVolumeName(alias DruidCertificateAlias) string {
func (d *Druid) CertSecretVolumeMountPath(configDir string, cert string) string {
return filepath.Join(configDir, cert)
}

type DruidBind struct {
*Druid
}

var _ DBBindInterface = &DruidBind{}

func (d *DruidBind) ServiceNames() (string, string) {
return d.ServiceName(), d.ServiceName()
}

func (d *DruidBind) Ports() (int, int) {
p := int(d.DruidNodeContainerPort(DruidNodeRoleRouters))
return p, p
}

func (d *DruidBind) SecretName() string {
return d.GetAuthSecretName()
}

func (d *DruidBind) CertSecretName() string {
return d.GetCertSecretName(DruidClientCert)
}
84 changes: 84 additions & 0 deletions apis/kubedb/v1alpha2/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions apis/kubedb/v1alpha2/rabbitmq_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,3 +422,31 @@ func (r *RabbitMQ) ReplicasAreReady(lister pslister.PetSetLister) (bool, string,
expectedItems := 1
return checkReplicasOfPetSet(lister.PetSets(r.Namespace), labels.SelectorFromSet(r.OffshootLabels()), expectedItems)
}

type RabbitMQBind struct {
*RabbitMQ
}

var _ DBBindInterface = &RabbitMQBind{}

func (d *RabbitMQBind) ServiceNames() (string, string) {
return d.ServiceName(), d.DashboardServiceName()
}

func (d *RabbitMQBind) Ports() (int, int) {
dbPort := kubedb.RabbitMQAMQPPort
uiPort := kubedb.RabbitMQManagementUIPort
if d.Spec.TLS != nil {
dbPort = kubedb.RabbitMQAMQPSPort
uiPort = kubedb.RabbitMQManagementUIPortWithSSL
}
return dbPort, uiPort
}

func (d *RabbitMQBind) SecretName() string {
return d.GetAuthSecretName()
}

func (d *RabbitMQBind) CertSecretName() string {
return d.GetCertSecretName(RabbitmqClientCert)
}
22 changes: 22 additions & 0 deletions apis/kubedb/v1alpha2/singlestore_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,3 +519,25 @@ func (s *Singlestore) ReplicasAreReady(lister pslister.PetSetLister) (bool, stri
}
return checkReplicasOfPetSet(lister.PetSets(s.Namespace), labels.SelectorFromSet(s.OffshootLabels()), expectedItems)
}

type SinglestoreBind struct {
*Singlestore
}

var _ DBBindInterface = &SinglestoreBind{}

func (d *SinglestoreBind) ServiceNames() (string, string) {
return d.ServiceName(), d.ServiceName()
}

func (d *SinglestoreBind) Ports() (int, int) {
return kubedb.SinglestoreDatabasePort, kubedb.SinglestoreStudioPort
}

func (d *SinglestoreBind) SecretName() string {
return d.DefaultUserCredSecretName("root")
}

func (d *SinglestoreBind) CertSecretName() string {
return d.GetCertSecretName(SinglestoreClientCert)
}
22 changes: 22 additions & 0 deletions apis/kubedb/v1alpha2/solr_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,3 +518,25 @@ func (s *Solr) CertSecretVolumeName(alias SolrCertificateAlias) string {
func (s *Solr) CertSecretVolumeMountPath(configDir string, cert string) string {
return filepath.Join(configDir, cert)
}

type SolrBind struct {
*Solr
}

var _ DBBindInterface = &SolrBind{}

func (d *SolrBind) ServiceNames() (string, string) {
return d.ServiceName(), d.ServiceName()
}

func (d *SolrBind) Ports() (int, int) {
return kubedb.SolrRestPort, kubedb.SolrRestPort
}

func (d *SolrBind) SecretName() string {
return d.GetAuthSecretName()
}

func (d *SolrBind) CertSecretName() string {
return d.GetCertSecretName(SolrClientCert)
}
7 changes: 7 additions & 0 deletions apis/kubedb/v1alpha2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,10 @@ type ArchiverRecovery struct {
FullDBRepository *kmapi.ObjectReference `json:"fullDBRepository,omitempty"`
ReplicationStrategy *PITRReplicationStrategy `json:"replicationStrategy,omitempty"`
}

type DBBindInterface interface {
ServiceNames() (string, string) // (DBServiceName, UIServiceName)
Ports() (int, int) // (DBPort, UIPort)
SecretName() string
CertSecretName() string
}
84 changes: 84 additions & 0 deletions apis/kubedb/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 051792b

Please sign in to comment.