Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: generate containr args from type and extraArgs #17

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions charts/celestia-node/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,24 @@ Return the proper image name for the otel agent
{{- include "common.images.image" (dict "imageRoot" .Values.node.otelAgent.image "global" .Values.global) -}}
{{- end -}}

{{/*
Generate the args for the node container based on the nodeType setting
*/}}
{{- define "node.containerArgs" -}}
{{- if .Values.node.args -}}
{{- .Values.node.args -}}
{{- else -}}
{{- $nodeType := .Values.node.settings.nodeType | default "bridge" -}}
{{- $args := list $nodeType -}}
{{- $args := append $args "start" -}}
{{- $args := append $args (printf "--node.store=$(CELESTIA_HOME)") -}}
{{- if .Values.node.extraArgs -}}
{{- $args := append $args .Values.node.extraArgs -}}
{{- end -}}
{{- $args -}}
{{- end -}}
{{- end -}}

{{/*
Validate the node.settings.nodeType value against the first argument in node.args.
*/}}
Expand All @@ -45,10 +63,11 @@ Validate the node.settings.nodeType value against the first argument in node.arg
Node type is not set. Must be one of 'bridge', 'full', or 'light'.
{{- else if and (ne .Values.node.settings.nodeType "bridge") (ne .Values.node.settings.nodeType "full") (ne .Values.node.settings.nodeType "light") -}}
Invalid node type: {{ .Values.node.settings.nodeType }}. Must be one of 'bridge', 'full', or 'light'.
{{- else if not (hasKey .Values.node "args") -}}
Node args are not set.
{{- else if not (eq .Values.node.settings.nodeType (first .Values.node.args)) -}}
The nodeType value ({{ .Values.node.settings.nodeType }}) does not match the first argument in args ({{ first .Values.node.args }}).
{{- else if (hasKey .Values.node "args") -}}
DEPRECATION WARNING: The use of node.args is deprecated. Please configure container args using node.settings.nodeType and node.extraArgs.
{{- if not (eq .Values.node.settings.nodeType (first .Values.node.args)) -}}
The nodeType value ({{ .Values.node.settings.nodeType }}) does not match the first argument in args ({{ first .Values.node.args }}).
{{- end -}}
{{- end -}}
{{- end -}}

Expand Down
4 changes: 2 additions & 2 deletions charts/celestia-node/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ spec:
{{- end }}
{{- if .Values.diagnosticMode.enabled }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
{{- else if .Values.node.args }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.node.args "context" $) | nindent 12 }}
{{- else }}
args: {{ include "node.containerArgs" . | toYaml | nindent 12 }}
{{- end }}
env:
- name: CELESTIA_HOME
Expand Down
9 changes: 5 additions & 4 deletions charts/celestia-node/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,12 @@ node:
# -- celestia
- celestia
## @param node.args Override default node container args (useful when using custom images)
## DEPRECATION WARNING: The use of node.args is deprecated. Please configure container args using node.settings.nodeType and node.extraArgs.
##
args:
- bridge
- start
- --node.store=$(CELESTIA_HOME)
args: null
## @param node.extraArgs Extra arguments to pass to the node container
##
extraArgs:
- --metrics
- --metrics.tls=false
- --p2p.metrics
Expand Down
Loading