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


##########
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:
   [nitpick] The nested if statements for `$shouldInclude` can be simplified 
using a single conditional expression, improving readability. Consider: `{{- 
$shouldInclude := or (eq (len $configuredRoles) 0) (has $roleName 
$configuredRoles) }}`



##########
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:
   Corrected grammar: 'based on passing roles' should be 'based on passed 
roles' or 'based on specified roles'.
   ```suggestion
   Generate data node names list based on specified roles
   ```



-- 
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