Skip to content
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
3 changes: 3 additions & 0 deletions .github/workflows/helm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ jobs:
- name: Set up chart-testing
uses: helm/chart-testing-action@6ec842c01de15ebb84c8627d2744a0c2f2755c9f # v2.8.0

- name: Test numeric ID arguments
run: bash hack/test-helm-id-args.sh

- name: Run chart-testing (lint)
run: ct lint --check-version-increment=false --chart-dirs deploy --target-branch ${{ github.event.repository.default_branch }}

Expand Down
9 changes: 9 additions & 0 deletions deploy/chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,12 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/* Format numeric IDs as decimal while preserving comma-separated string values. */}}
{{- define "ccm-linode.idArg" -}}
{{- if kindIs "string" .value -}}
{{ printf "%s=%s" .flag .value | quote }}
{{- else -}}
{{ printf "%s=%d" .flag (int64 .value) | quote }}
{{- end -}}
{{- end -}}
6 changes: 3 additions & 3 deletions deploy/chart/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ spec:
- --nodebalancer-backend-ipv4-subnet-name={{ $nbvpcBackendIpv4SubnetName }}
{{- end }}
{{- if $nbvpcBackendIpv4SubnetID }}
- --nodebalancer-backend-ipv4-subnet-id={{ $nbvpcBackendIpv4SubnetID }}
- {{ include "ccm-linode.idArg" (dict "flag" "--nodebalancer-backend-ipv4-subnet-id" "value" $nbvpcBackendIpv4SubnetID) }}
{{- end }}
{{- if .Values.routeController }}
- --enable-route-controller=true
Expand Down Expand Up @@ -151,10 +151,10 @@ spec:
- --subnet-names={{ . }}
{{- end }}
{{- with $vpcIDs }}
- --vpc-ids={{ . }}
- {{ include "ccm-linode.idArg" (dict "flag" "--vpc-ids" "value" .) }}
{{- end }}
{{- with $subnetIDs }}
- --subnet-ids={{ . }}
- {{ include "ccm-linode.idArg" (dict "flag" "--subnet-ids" "value" .) }}
{{- end }}
{{- with $clusterCIDR }}
- --cluster-cidr={{ . }}
Expand Down
41 changes: 41 additions & 0 deletions hack/test-helm-id-args.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
set -euo pipefail

assert_contains() {
case "$rendered" in
*"$1"*) ;;
*) printf 'expected rendered chart to contain: %s\n' "$1" >&2; exit 1 ;;
esac
}

assert_no_scientific_ids() {
case "$rendered" in
*'1.054213e+06'*|*'1.054214e+06'*|*'1.054215e+06'*)
printf 'rendered chart contains a scientific-notation ID\n' >&2
exit 1
;;
esac
}

rendered=$(helm template ccm-linode deploy/chart \
--set-json 'vpcIDs=1.054213e+06' \
--set-json 'subnetIDs=1.054214e+06' \
--set-json 'nodeBalancerBackendIpv4SubnetID=1.054215e+06')
assert_contains '"--vpc-ids=1054213"'
assert_contains '"--subnet-ids=1054214"'
assert_contains '"--nodebalancer-backend-ipv4-subnet-id=1054215"'
assert_no_scientific_ids

rendered=$(helm template ccm-linode deploy/chart \
--set-json 'routeController.vpcIDs=1.054213e+06' \
--set-json 'routeController.subnetIDs=1.054214e+06' \
--set 'routeController.clusterCIDR=10.192.0.0/10')
assert_contains '"--vpc-ids=1054213"'
assert_contains '"--subnet-ids=1054214"'
assert_no_scientific_ids

rendered=$(helm template ccm-linode deploy/chart \
--set-string 'vpcIDs=1054213\,1054214' \
--set-string 'subnetIDs=1054215\,1054216')
assert_contains '"--vpc-ids=1054213,1054214"'
assert_contains '"--subnet-ids=1054215,1054216"'
Loading