Skip to content

Commit

Permalink
common: new release with enterprise and image related functions (#1495)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewChubatiuk committed Sep 16, 2024
1 parent 64854ce commit 4bf417a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
4 changes: 3 additions & 1 deletion charts/victoria-metrics-common/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

## Next release

- TODO
- Add enterprise to existing variant if enterprise enabled
- Added `vm.enterprise.disabled` template to check if enterprise license is disabled
- Use `service.servicePort` as a port source if flag is not set in `vm.url`

## 0.0.11

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.11
version: 0.0.12
sources:
- https://github.com/VictoriaMetrics/helm-charts
kubeVersion: ">=1.23.0-0"
Expand Down
8 changes: 6 additions & 2 deletions charts/victoria-metrics-common/templates/_enterprise.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@
{{- ($Values.license).key | default (($Values.global).license).key | default "" -}}
{{- end -}}

{{- define "vm.enterprise.only" -}}
{{- define "vm.enterprise.disabled" -}}
{{- $licenseKey := (include "vm.license.key" .) -}}
{{- $licenseSecretKey := (include "vm.license.secret.key" .) -}}
{{- $licenseSecretName := (include "vm.license.secret.name" .) -}}
{{- if and (empty $licenseKey) (and (empty $licenseSecretName) (empty $licenseSecretKey)) -}}
{{- and (empty $licenseKey) (and (empty $licenseSecretName) (empty $licenseSecretKey)) -}}
{{- end -}}

{{- define "vm.enterprise.only" -}}
{{- if eq (include "vm.enterprise.disabled" .) "true" }}
{{ 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
Expand Down
11 changes: 8 additions & 3 deletions charts/victoria-metrics-common/templates/_image.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ Victoria Metrics Image
{{- $Values := (.helm).Values | default .Values -}}
{{- $image := (tpl (printf "%s:%s" .app.image.repository (.app.image.tag | default $Chart.AppVersion)) .) -}}
{{- $license := $Values.license | default dict }}
{{- if and (or $license.key (dig "secret" "name" "" $license)) (empty .app.image.tag) -}}
{{- $_ := set .app.image "variant" "enterprise" -}}
{{- $variant := .app.image.variant }}
{{- if and (eq (include "vm.enterprise.disabled" .) "false") (empty .app.image.tag) -}}
{{- if $variant }}
{{- $variant = printf "enterprise-%s" $variant }}
{{- else }}
{{- $variant = "enterprise" }}
{{- end }}
{{- end -}}
{{- with .app.image.variant -}}
{{- with $variant -}}
{{- $image = (printf "%s-%s" $image .) -}}
{{- end -}}
{{- with .app.image.registry | default (($Values.global).image).registry | default "" -}}
Expand Down
2 changes: 1 addition & 1 deletion charts/victoria-metrics-common/templates/_service.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
{{- end -}}
{{- $isSecure = (eq ($spec.extraArgs).tls "true") | default $isSecure -}}
{{- $port = (ternary 443 80 $isSecure) -}}
{{- $port = $spec.port | default $port -}}
{{- $port = $spec.port | default ($spec.service).servicePort | default $port -}}
{{- end }}
{{- $fqdn }}:{{ $port }}
{{- end -}}
Expand Down

0 comments on commit 4bf417a

Please sign in to comment.