From abf5c26b7681a44bb7f082bde30fad595caaaf36 Mon Sep 17 00:00:00 2001 From: Jake Heath <76011913+jakeyheath@users.noreply.github.com> Date: Tue, 17 Sep 2024 11:03:06 -0700 Subject: [PATCH] fix: need a dollar sign for the variable name (#117) --- stack/templates/_helpers.tpl | 8 ++++---- stack/tests/ingress_test.yaml | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/stack/templates/_helpers.tpl b/stack/templates/_helpers.tpl index f0cbe2b..73a28fe 100644 --- a/stack/templates/_helpers.tpl +++ b/stack/templates/_helpers.tpl @@ -191,17 +191,17 @@ app.kubernetes.io/instance: {{ .Release.Name }} {{- $id := printf "%s_%s" ($v.method |lower) ($v.path | replace "/" "")}} {{- $id := regexReplaceAll "\\W+" $id "_" -}} {{- $var_name := printf "%s_%s" "skip_auth" $id }} -set {{ $var_name }} 1; +set ${{ $var_name }} 1; if ( $request_uri !~ "{{$v.path}}" ) { - set {{ $var_name }} 0; + set ${{ $var_name }} 0; } if ( $request_method !~ "{{$v.method}}" ) { - set {{ $var_name }} 0; + set ${{ $var_name }} 0; } -if ( {{ $var_name }} ) { +if ( ${{ $var_name }} ) { return 200; } {{- end -}} diff --git a/stack/tests/ingress_test.yaml b/stack/tests/ingress_test.yaml index 4af5759..7ab3d72 100644 --- a/stack/tests/ingress_test.yaml +++ b/stack/tests/ingress_test.yaml @@ -73,29 +73,29 @@ tests: equal: path: metadata.annotations["nginx.ingress.kubernetes.io/auth-snippet"] value: | - set skip_auth_get_healthz 1; + set $skip_auth_get_healthz 1; if ( $request_uri !~ "/healthz" ) { - set skip_auth_get_healthz 0; + set $skip_auth_get_healthz 0; } if ( $request_method !~ "GET" ) { - set skip_auth_get_healthz 0; + set $skip_auth_get_healthz 0; } - if ( skip_auth_get_healthz ) { + if ( $skip_auth_get_healthz ) { return 200; } - set skip_auth___api_ 1; + set $skip_auth___api_ 1; if ( $request_uri !~ "/api/*" ) { - set skip_auth___api_ 0; + set $skip_auth___api_ 0; } if ( $request_method !~ "*" ) { - set skip_auth___api_ 0; + set $skip_auth___api_ 0; } - if ( skip_auth___api_ ) { + if ( $skip_auth___api_ ) { return 200; }