From 6636900920a142f8c1ccf5f7464b09d5bd11bccc Mon Sep 17 00:00:00 2001 From: Tapajit Chandra Paul Date: Fri, 28 Jun 2024 15:58:42 +0600 Subject: [PATCH] Resolve reviewed changes Signed-off-by: Tapajit Chandra Paul --- apis/kubedb/v1alpha2/druid_helpers.go | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/apis/kubedb/v1alpha2/druid_helpers.go b/apis/kubedb/v1alpha2/druid_helpers.go index 16a5f3db03..f54e8bf547 100644 --- a/apis/kubedb/v1alpha2/druid_helpers.go +++ b/apis/kubedb/v1alpha2/druid_helpers.go @@ -513,6 +513,9 @@ func (d *Druid) SetDefaults() { if d.Spec.MetadataStorage == nil { d.Spec.MetadataStorage = &MetadataStorage{} } + if d.Spec.MetadataStorage.Namespace == "" { + d.Spec.MetadataStorage.Namespace = d.Namespace + } if d.Spec.MetadataStorage.LinkedDB == "" { d.Spec.MetadataStorage.LinkedDB = "druid" } @@ -535,15 +538,9 @@ func (d *Druid) SetDefaults() { if d.Spec.MetadataStorage.ObjectReference == nil { d.Spec.MetadataStorage.ObjectReference = &kmapi.ObjectReference{} } - if d.Spec.MetadataStorage.Type == DruidMetadataStorageMySQL { - d.Spec.MetadataStorage.Name = d.GetMySQLName() - } else { - d.Spec.MetadataStorage.Name = d.GetPostgresName() - } - if d.Spec.MetadataStorage.Namespace == "" { - d.Spec.MetadataStorage.Namespace = d.Namespace - } + d.Spec.MetadataStorage.Name = d.GetMetadataStorageName() } + if d.Spec.MetadataStorage.Version == nil { var defaultVersion string if d.Spec.MetadataStorage.Type == DruidMetadataStorageMySQL { @@ -696,14 +693,13 @@ func (d *Druid) GetAppBinding(name string, namespace string) (*appcat.AppBinding return appbinding, nil } -func (d *Druid) GetMySQLName() string { +func (d *Druid) GetMetadataStorageName() string { + if d.Spec.MetadataStorage.Type == DruidMetadataStoragePostgreSQL { + return d.OffShootName() + "-pg-metadata" + } return d.OffShootName() + "-mysql-metadata" } -func (d *Druid) GetPostgresName() string { - return d.OffShootName() + "-pg-metadata" -} - func (d *Druid) GetZooKeeperName() string { return d.OffShootName() + "-zk" }