hanahmily commented on code in PR #39:
URL: 
https://github.com/apache/skywalking-banyandb-helm/pull/39#discussion_r2505939130


##########
chart/templates/_helpers.tpl:
##########
@@ -98,4 +98,32 @@ EtcdEndpoints
 {{- end }}
 - name: BYDB_ETCD_ENDPOINTS
   value: "{{- $endpoints | join "," -}}"
-{{- end }}
\ No newline at end of file
+{{- end }}
+
+{{/*
+Generate data node names list based on passing roles
+*/}}
+{{- define "banyandb.dataNodeList" -}}
+{{- $dataNodes := list }}
+{{- $context := index . 0 }}
+{{- $configuredRoles := index . 1 }}
+{{- $fullname := include "banyandb.fullname" $context }}
+{{- range $roleName, $roleConfig := $context.Values.cluster.data.roles }}
+  {{- $shouldInclude := false }}
+  {{- if eq (len $configuredRoles) 0 }}
+    {{- $shouldInclude = true }}
+  {{- else }}
+    {{- if has $roleName $configuredRoles }}
+      {{- $shouldInclude = true }}
+    {{- end }}
+  {{- end }}
+  {{- if $shouldInclude }}
+    {{- $replicas := $roleConfig.replicas | default 
$context.Values.cluster.data.nodeTemplate.replicas }}
+    {{- range $i := until (int $replicas) }}
+      {{- $nodeName := printf "%s-data-%s-%d" $fullname $roleName $i }}
+      {{- $dataNodes = append $dataNodes $nodeName }}
+    {{- end }}
+  {{- end }}
+{{- end }}
+{{- $dataNodes | join "," -}}
+{{- end }}

Review Comment:
   The suggestion looks tidier.



##########
chart/values.yaml:
##########
@@ -276,6 +276,12 @@ cluster:
     ## @param cluster.liaison.env Environment variables for liaison pods
     ##
     env: []
+    ## Data node list environment configuration
+    ## @param cluster.liaison.dataNodeListEnv.enabled Enable 
BYDB_DATA_NODE_LIST environment variable
+    dataNodeListEnv:
+      enabled: false
+      ## @param cluster.liaison.dataNodeListEnv.roles List of data roles to 
include (empty list means all roles)
+      roles: []

Review Comment:
   ```suggestion
   ```
   
   The env var is mandatory. 



##########
chart/templates/_helpers.tpl:
##########
@@ -98,4 +98,32 @@ EtcdEndpoints
 {{- end }}
 - name: BYDB_ETCD_ENDPOINTS
   value: "{{- $endpoints | join "," -}}"
-{{- end }}
\ No newline at end of file
+{{- end }}
+
+{{/*
+Generate data node names list based on passing roles

Review Comment:
   This comment makes sense



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to