Skip to content

Commit

Permalink
Add Elasticsearch helper methods for StatefulSet names (#665)
Browse files Browse the repository at this point in the history
Signed-off-by: kamolhasan <kamol@appscode.com>
  • Loading branch information
Md Kamol Hasan committed Dec 6, 2020
1 parent 5917f09 commit 0e4574e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions apis/kubedb/v1alpha2/elasticsearch_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,31 @@ func (e *Elasticsearch) GetConnectionURL() string {
return fmt.Sprintf("%v://%s.%s:%d", e.GetConnectionScheme(), e.OffshootName(), e.Namespace, ElasticsearchRestPort)
}

func (e *Elasticsearch) CombinedStatefulSetName() string {
return e.OffshootName()
}

func (e *Elasticsearch) MasterStatefulSetName() string {
if e.Spec.Topology.Master.Prefix != "" {
return fmt.Sprintf("%s-%s", e.Spec.Topology.Master.Prefix, e.OffshootName())
}
return fmt.Sprintf("%s-%s", ElasticsearchMasterNodePrefix, e.OffshootName())
}

func (e *Elasticsearch) DataStatefulSetName() string {
if e.Spec.Topology.Data.Prefix != "" {
return fmt.Sprintf("%s-%s", e.Spec.Topology.Data.Prefix, e.OffshootName())
}
return fmt.Sprintf("%s-%s", ElasticsearchDataNodePrefix, e.OffshootName())
}

func (e *Elasticsearch) IngestStatefulSetName() string {
if e.Spec.Topology.Ingest.Prefix != "" {
return fmt.Sprintf("%s-%s", e.Spec.Topology.Ingest.Prefix, e.OffshootName())
}
return fmt.Sprintf("%s-%s", ElasticsearchIngestNodePrefix, e.OffshootName())
}

type elasticsearchApp struct {
*Elasticsearch
}
Expand Down

0 comments on commit 0e4574e

Please sign in to comment.