Skip to content

Commit

Permalink
chore: update gomplate to v4
Browse files Browse the repository at this point in the history
and use its new plugins syntax
  • Loading branch information
aabouzaid committed Jun 29, 2024
1 parent 7f06de5 commit 6903fa6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
git-chglog 0.15.4
golang 1.22.4
gomplate v3.11.8
gomplate v4.0.1
helm 3.15.2
helm-ct 3.11.0
kubectl 1.27.15 # The kubectl version depends on the K8s CI cluster version
Expand Down
19 changes: 10 additions & 9 deletions scripts/generate-version-matrix.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -euox pipefail
set -euo pipefail

# Check dependencies.
dep_names="awk git gomplate helm jq tr yq"
Expand Down Expand Up @@ -42,6 +42,7 @@ get_versions_filtered () {
# Get all images used in a certain Helm chart.
get_chart_images () {
chart_version="${1}"
test -d "${CHART_DIR}" || CHART_DIR="charts/camunda-platform-latest"
helm template --skip-tests camunda "${CHART_SOURCE}" --version "${chart_version}" \
--values "${CHART_DIR}/test/integration/scenarios/chart-full-setup/values-integration-test-ingress.yaml" 2> /dev/null |
tr -d "\"'" | awk '/image:/{gsub(/^(camunda|bitnami)/, "docker.io/&", $2); printf "- %s\n", $2}' |
Expand Down Expand Up @@ -136,20 +137,20 @@ while test -n "${1:-}"; do
shift
;;
--chart-images-camunda)
test -n "${2:-}" || (
echo "[ERROR] Helm chart version is needed as an arg for this option";
test -n "${3:-}" || (
echo "[ERROR] Chart dir and Helm chart version are needed as an arg for this option";
exit 1
)
get_chart_images "${2}" | grep "camunda"
shift
CHART_DIR="${2}" get_chart_images "${3}" | grep "camunda"
shift 2
;;
--chart-images-non-camunda)
test -n "${2:-}" || (
echo "[ERROR] Helm chart version is needed as an arg for this option";
test -n "${3:-}" || (
echo "[ERROR] Chart dir and Helm chart version are needed as an arg for this option";
exit 1
)
get_chart_images "${2}" | grep -v "camunda"
shift
CHART_DIR="${2}" get_chart_images "${3}" | grep -v "camunda"
shift 2
;;
*)
print_help
Expand Down
33 changes: 13 additions & 20 deletions scripts/templates/version-matrix/.gomplate.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
plugins:
versionMatrix:
helmCLIVersion:
cmd: scripts/generate-version-matrix.sh
args:
- --helm-cli-version
timeout: 30s
chartImagesCamunda:
cmd: scripts/generate-version-matrix.sh
args:
- --chart-images-camunda
timeout: 30s
chartImagesNonCamunda:
cmd: scripts/generate-version-matrix.sh
args:
- --chart-images-non-camunda
timeout: 30s
# TODO: Move to the new format once gomplate v4 is released.
# https://github.com/hairyhenderson/gomplate/releases
# helmCLIVersion:
# cmd: scripts/generate-version-matrix.sh
# args:
# - --helm-cli-version
# timeout: 30s
# chartImagesCamunda:
# cmd: scripts/generate-version-matrix.sh
# args:
# - --chart-images-camunda
# pipe: true
# timeout: 30s
# chartImagesNonCamunda:
# cmd: scripts/generate-version-matrix.sh
# args:
# - --chart-images-non-camunda
# pipe: true
# timeout: 30s
13 changes: 7 additions & 6 deletions scripts/templates/version-matrix/VERSION-MATRIX-RELEASE.md.tpl
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
{{- $release := ds "release" -}}
{{- $releaseHeader := conv.ToBool (getenv "VERSION_MATRIX_RELEASE_HEADER" "true") -}}
{{- $chartDir := printf "charts/camunda-platform-%s" $release.app -}}
{{- if $releaseHeader -}}
<!-- THIS FILE IS AUTO-GENERATED, DO NOT EDIT IT MANUALLY! -->
# Camunda {{ $release.app }} Helm Chart Version Matrix
{{- end }}

{{- range $release.charts }}
{{- /* TODO: Unify charts image once gomplate v4 is released using coll.JQ */ -}}
{{- range $chartVersion := $release.charts }}
{{- $gitRef := printf "camunda-platform-%s" $chartVersion -}}
{{- $vars := dict
"app_version" $release.app
"chart_version" .
"chart_images_camunda" (versionMatrix "--chart-images-camunda" . | strings.Trim "\n")
"chart_images_non_camunda" (versionMatrix "--chart-images-non-camunda" . | strings.Trim "\n")
"helm_cli_version" (versionMatrix "--helm-cli-version" (printf "camunda-platform-%s" .) | strings.Trim " ")
"chart_version" $chartVersion
"chart_images_camunda" (chartImagesCamunda $chartDir $chartVersion | strings.Trim "\n")
"chart_images_non_camunda" (chartImagesNonCamunda $chartDir $chartVersion | strings.Trim "\n")
"helm_cli_version" (helmCLIVersion $gitRef | strings.Trim " ")
}}

{{- $helmCLIVersion := ternary
Expand Down

0 comments on commit 6903fa6

Please sign in to comment.