Skip to content

Commit

Permalink
fix: allow 0 to be passed via --set
Browse files Browse the repository at this point in the history
  • Loading branch information
soniqua committed Aug 19, 2024
1 parent 4c4a51f commit 0865674
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions charts/snyk-broker/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ include "snyk-broker.genericSecretName" (dict "Context" $ "secretName" "secret-n
Handle tlsRejectUnauthorized.
If this is set to `false` (bool) we _want_ to disable trust. We don't allow `true`.
If this is set to "" we want to enable trust - any other allowed string value disables.
If this is set to `"0"` Helm might cast it as an integer - we need to catch that.
Checking for definition is insufficient
*/}}
{{- define "snyk-broker.setTlsRejectUnauthorized" -}}
Expand All @@ -150,4 +151,7 @@ true
{{- if ( and ( eq (kindOf $tlsRejectUnauthorized ) "string") ( not ( eq $tlsRejectUnauthorized "" ) ) ) -}}
true
{{- end }}
{{- if eq (toString $tlsRejectUnauthorized) "0" -}}
true
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ tests:
documentSelector:
path: kind
value: Deployment
- it: disables tls trust with '0' (integer)
set:
tlsRejectUnauthorized: 0
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: NODE_TLS_REJECT_UNAUTHORIZED
value: "0"
documentSelector:
path: kind
value: Deployment
- it: enables tls trust by default "" (string)
set:
tlsRejectUnauthorized: ""
Expand All @@ -78,4 +90,4 @@ tests:
tlsRejectUnauthorized: true
asserts:
- failedTemplate:
errorMessage: "values don't meet the specifications of the schema(s) in the following chart(s):\nsnyk-broker:\n- tlsRejectUnauthorized: tlsRejectUnauthorized must be one of the following: \"\", \"0\", \"false\", false, \"disable\"\n"
errorMessage: "values don't meet the specifications of the schema(s) in the following chart(s):\nsnyk-broker:\n- tlsRejectUnauthorized: tlsRejectUnauthorized must be one of the following: \"\", 0, \"0\", \"false\", false, \"disable\"\n"
4 changes: 3 additions & 1 deletion charts/snyk-broker/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,12 @@
"tlsRejectUnauthorized":{
"type": [
"string",
"boolean"
"boolean",
"integer"
],
"enum":[
"",
0,
"0",
"false",
false,
Expand Down

0 comments on commit 0865674

Please sign in to comment.