Skip to content

Commit

Permalink
common: support long and short cmd flags (#1347)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewChubatiuk authored Aug 27, 2024
1 parent 92e3901 commit e82e9cd
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 17 deletions.
3 changes: 2 additions & 1 deletion charts/victoria-metrics-common/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## Next release

- TODO
- Support short and long args flags in `vm.args`
- Updated `vm.enterprise.only` error message

## 0.0.6

Expand Down
2 changes: 1 addition & 1 deletion charts/victoria-metrics-common/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
type: library
description: Victoria Metrics Common - contains shared templates for all Victoria Metrics helm charts
name: victoria-metrics-common
version: 0.0.6
version: 0.0.7
sources:
- https://github.com/VictoriaMetrics/helm-charts
kubeVersion: ">=1.23.0-0"
Expand Down
6 changes: 5 additions & 1 deletion charts/victoria-metrics-common/templates/_enterprise.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
{{- $licenseSecretKey := (include "vm.license.secret.key" .) -}}
{{- $licenseSecretName := (include "vm.license.secret.name" .) -}}
{{- if and (empty $licenseKey) (and (empty $licenseSecretName) (empty $licenseSecretKey)) -}}
{{ fail "Pass valid license at .Values.license or .Values.global.license if you have an enterprise license for running this software. See https://victoriametrics.com/legal/esa/ for details"}}
{{ fail `Pass valid license at .Values.license or .Values.global.license if you have an enterprise license for running this software.
See https://victoriametrics.com/legal/esa/ for details.
Documentation - https://docs.victoriametrics.com/enterprise.html
for more information, visit https://victoriametrics.com/products/enterprise/
To request a trial license, go to https://victoriametrics.com/products/enterprise/trial/` }}
{{- end -}}
{{- end -}}

Expand Down
33 changes: 19 additions & 14 deletions charts/victoria-metrics-common/templates/_pod.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -86,26 +86,31 @@ Net probe port
{{- end -}}

{{- define "vm.arg" -}}
{{- if and (kindIs "bool" .value) .value -}}
-{{ .key }}
{{- if empty .value }}
{{ .key }}
{{- else if and (kindIs "bool" .value) .value -}}
-{{ ternary "" "-" (eq (len .key) 1) }}{{ .key }}
{{- else -}}
-{{ .key }}={{ .value }}
-{{ ternary "" "-" (eq (len .key) 1) }}{{ .key }}={{ .value }}
{{- end -}}
{{- end -}}

{{- /*
command line arguments
*/ -}}
{{- define "vm.args" -}}
{{- $args := default list -}}
{{- range $key, $value := . -}}
{{- if kindIs "slice" $value -}}
{{- range $v := $value -}}
{{- $args = append $args (include "vm.arg" (dict "key" $key "value" $v)) -}}
{{- end -}}
{{- else -}}
{{- $args = append $args (include "vm.arg" (dict "key" $key "value" $value)) -}}
{{- end -}}
{{- end -}}
{{- toYaml (dict "args" $args) -}}
{{- $args := default list -}}
{{- range $key, $value := . -}}
{{- if not $key -}}
{{- fail "Empty key in command line args is not allowed" -}}
{{- end -}}
{{- if kindIs "slice" $value -}}
{{- range $v := $value -}}
{{- $args = append $args (include "vm.arg" (dict "key" $key "value" $v)) -}}
{{- end -}}
{{- else -}}
{{- $args = append $args (include "vm.arg" (dict "key" $key "value" $value)) -}}
{{- end -}}
{{- end -}}
{{- toYaml (dict "args" $args) -}}
{{- end -}}

0 comments on commit e82e9cd

Please sign in to comment.