From 7c72363c466beb98624d64c220bfa7c1445d4586 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20OLIVIER?= <cedric3.olivier@orange.com>
Date: Fri, 3 Sep 2021 11:42:17 +0200
Subject: [PATCH] feat: Change boolean variable behaviour
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

BREAKING CHANGE: boolean variable now triggered on explicit 'true' value

Signed-off-by: Cédric OLIVIER <cedric3.olivier@orange.com>
---
 README.md                    | 18 +++++------
 templates/gitlab-ci-helm.yml | 58 ++++++++++++++++++------------------
 2 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/README.md b/README.md
index 22099c2..6b12a01 100644
--- a/README.md
+++ b/README.md
@@ -124,7 +124,7 @@ Here are variables supported to configure review environments:
 
 | Name                     | description                            | default value     |
 | ------------------------ | -------------------------------------- | ----------------- |
-| `HELM_REVIEW_DISABLED`   | Set to disable `review` env            | _none_ (enabled) |
+| `HELM_REVIEW_DISABLED`   | Set to `true` to disable `review` env            | _none_ (enabled) |
 | `HELM_REVIEW_APP_NAME`   | Application name for `review` env      | `"${HELM_BASE_APP_NAME}-${CI_ENVIRONMENT_SLUG}"` (ex: `myproject-review-fix-bug-12`) |
 | `HELM_REVIEW_NAMESPACE`  | The Kubernetes namespace to use for `review` env _(only define to override default)_ | `$KUBE_NAMESPACE` |
 | :lock: `HELM_REVIEW_KUBE_CONFIG` | kubeconfig content used for `review` env _(only define to override default)_ | `$HELM_DEFAULT_KUBE_CONFIG` |
@@ -144,7 +144,7 @@ Here are variables supported to configure the integration environment:
 
 | Name                     | description                            | default value     |
 | ------------------------ | -------------------------------------- | ----------------- |
-| `HELM_INTEG_DISABLED`    | Set to disable `integration` env       | _none_ (enabled) |
+| `HELM_INTEG_DISABLED`    | Set to `true` to disable `integration` env       | _none_ (enabled) |
 | `HELM_INTEG_APP_NAME`    | Application name for `integration` env | `$HELM_BASE_APP_NAME-integration` |
 | `HELM_INTEG_NAMESPACE`   | The Kubernetes namespace to use for `integration` env _(only define to override default)_ | `$KUBE_NAMESPACE` |
 | :lock: `HELM_INTEG_KUBE_CONFIG` | kubeconfig content used for `integration` env _(only define to override default)_ | `$HELM_DEFAULT_KUBE_CONFIG` |
@@ -161,7 +161,7 @@ Here are variables supported to configure the staging environment:
 
 | Name                     | description                            | default value     |
 | ------------------------ | -------------------------------------- | ----------------- |
-| `HELM_STAGING_DISABLED`  | Set to disable `staging` env           | _none_ (enabled) |
+| `HELM_STAGING_DISABLED`  | Set to `true` to disable `staging` env           | _none_ (enabled) |
 | `HELM_STAGING_APP_NAME`  | Application name for `staging` env     | `$HELM_BASE_APP_NAME-staging` |
 | `HELM_STAGING_NAMESPACE` | The Kubernetes namespace to use for `staging` env _(only define to override default)_ | `$KUBE_NAMESPACE` |
 | :lock: `HELM_STAGING_KUBE_CONFIG` | kubeconfig content used for `staging` env _(only define to override default)_ | `$HELM_DEFAULT_KUBE_CONFIG` |
@@ -178,7 +178,7 @@ Here are variables supported to configure the production environment:
 
 | Name                     | description                            | default value     |
 | ------------------------ | -------------------------------------- | ----------------- |
-| `HELM_PROD_DISABLED`     | Set to disable `production` env        | _none_ (enabled)  |
+| `HELM_PROD_DISABLED`     | Set to `true` to disable `production` env        | _none_ (enabled)  |
 | `HELM_PROD_APP_NAME`     | Application name for `production` env  | `$HELM_BASE_APP_NAME` |
 | `HELM_PROD_NAMESPACE`    | The Kubernetes namespace to use for `production` env _(only define to override default)_ | `$KUBE_NAMESPACE` |
 | :lock: `HELM_PROD_KUBE_CONFIG` | kubeconfig content used for `production` env _(only define to override default)_ | `$HELM_DEFAULT_KUBE_CONFIG` |
@@ -223,7 +223,7 @@ This job [examines your chart for possible issues](https://helm.sh/docs/helm/hel
 
 | Name                  | description                              | default value     |
 | --------------------- | ---------------------------------------- | ----------------- |
-| `HELM_LINT_DISABLED`  | Set to disable Helm lint                 | _none_ (enabled) |
+| `HELM_LINT_DISABLED`  | Set to `true` to disable Helm lint                 | _none_ (enabled) |
 | `HELM_LINT_ARGS`      | The Helm [command with options](https://helm.sh/docs/helm/helm_lint/) to trigger the analysis (_without dynamic arguments such as the chart path_) | `lint --strict` |
 | `HELM_DEPENDENCY_ARGS` | The Helm [command with options](https://helm.sh/docs/helm/helm_dependency_update/) to update on-disk the chart dependencies (_without dynamic arguments such as the chart path_) | `dependency update` |
 
@@ -234,7 +234,7 @@ These jobs perform a [Yaml Lint](https://github.com/adrienverge/yamllint) of you
 | Name                     | description                           | default value     |
 | ------------------------ | ------------------------------------- | ----------------- |
 | `HELM_YAMLLINT_IMAGE`    | The Docker image used to run YamlLint test | `cytopia/yamllint` |
-| `HELM_YAMLLINT_DISABLED` | Set to disable Yaml lint              | _none_ (enabled) |
+| `HELM_YAMLLINT_DISABLED` | Set to `true` to disable Yaml lint              | _none_ (enabled) |
 | `HELM_YAMLLINT_CONFIG`   | Config used with the yamllint tool    | `{extends: relaxed, rules: {line-length: {max: 160}}}` |
 | `HELM_YAMLLINT_ARGS`     | Arguments used by the lint job        | `-f colored --strict` |
 
@@ -244,7 +244,7 @@ This job runs [Kube-Score](https://kube-score.com/) on the resources to be creat
 
 | Name                  | description                              | default value     |
 | --------------------- | ---------------------------------------- | ----------------- |
-| `HELM_KUBE_SCORE_DISABLED`   | Set to disable [Kube-Score](https://kube-score.com/)   | _none_ (enabled) |
+| `HELM_KUBE_SCORE_DISABLED`   | Set to `true` to disable [Kube-Score](https://kube-score.com/)   | _none_ (enabled) |
 | `HELM_KUBE_SCORE_IMAGE`   | The Docker image used to run [Kube-Score](https://kube-score.com/)   | `zegl/kube-score:latest-helm3` |
 | `HELM_KUBE_SCORE_ARGS`   | Arguments used by the helm-score job   | _none_ |
 
@@ -256,7 +256,7 @@ This job [packages your chart into an archive](https://helm.sh/docs/helm/helm_pa
 | --------------------- | ---------------------------------------- | ----------------- |
 | `HELM_PACKAGE_ARGS`   | The Helm [command with options](https://helm.sh/docs/helm/helm_package/) to perform the packaging (_without dynamic arguments such as the chart path_)   | `package --dependency-update` |
 
-| `HELM_SEMREL_RELEASE_DISABLED`   | Set to disable usage of semrel release info for helm package  | _none_ (enabled) |
+| `HELM_SEMREL_RELEASE_DISABLED`   | Set to `true` to disable usage of semrel release info for helm package  | _none_ (enabled) |
 
 #### `semantic-release` integration
 
@@ -287,7 +287,7 @@ It  uses the following variables:
 
 | Name                  | description                              | default value     |
 | --------------------- | ---------------------------------------- | ----------------- |
-| `HELM_TEST_ENABLED`  | Set to enable Helm test                 | _none_ (disabled) |
+| `HELM_TEST_ENABLED`  | Set to `true` to enable Helm test                 | _none_ (disabled) |
 | `HELM_TEST_ARGS`      | The Helm [command with options](https://helm.sh/docs/helm/helm_test/) to perform acceptance test (_without dynamic arguments such as the chart path_) | `test`        |
 
 ## Variants
diff --git a/templates/gitlab-ci-helm.yml b/templates/gitlab-ci-helm.yml
index 27a7eb6..eed485a 100644
--- a/templates/gitlab-ci-helm.yml
+++ b/templates/gitlab-ci-helm.yml
@@ -17,8 +17,8 @@ variables:
   # Docker Image with Helm CLI tool (can be overridden)
   HELM_CLI_IMAGE: "alpine/helm"
   HELM_YAMLLINT_IMAGE: "cytopia/yamllint"
-#  HELM_LINT_DISABLED: "True"
-#  HELM_YAMLLINT_DISABLED: "True"
+#  HELM_LINT_DISABLED: "true"
+#  HELM_YAMLLINT_DISABLED: "true"
   HELM_YAMLLINT_CONFIG: "{extends: relaxed, rules: {line-length: {max: 160}}}"
   HELM_YAMLLINT_ARGS: "-f colored --strict"
   HELM_LINT_ARGS: "lint --strict"
@@ -40,17 +40,17 @@ variables:
 #  KUBE_NAMESPACE: "default"
 #  KUBECONFIG: ""
 
-#  HELM_REVIEW_DISABLED: "True"
+#  HELM_REVIEW_DISABLED: "true"
 #  HELM_REVIEW_VALUES: "values-review.yml"
 #  HELM_REVIEW_NAMESPACE: ""
 #  HELM_REVIEW_KUBE_CONFIG: ""
 
-#  HELM_INTEG_DISABLED: "True"
+#  HELM_INTEG_DISABLED: "true"
 #  HELM_INTEG_VALUES: "values-review.yml"
 #  HELM_INTEG_NAMESPACE: ""
 #  HELM_INTEG_KUBE_CONFIG: ""
 
-#  HELM_STAGING_DISABLED: "True"
+#  HELM_STAGING_DISABLED: "true"
 #  HELM_STAGING_VALUES: "values-staging.yml"
 #  HELM_STAGING_NAMESPACE: ""
 #  HELM_STAGING_KUBE_CONFIG: ""
@@ -456,7 +456,7 @@ stages:
     fi
   }
 
-  if [[ -z "$TEMPLATE_CHECK_UPDATE_DISABLED" ]]; then check_for_update helm "1.4.2"; fi
+  if [[ "$TEMPLATE_CHECK_UPDATE_DISABLED" != "true" ]]; then check_for_update helm "1.4.2"; fi
   unscope_variables
   eval_all_secrets
 
@@ -513,7 +513,7 @@ helm-lint:
     - helm $HELM_DEPENDENCY_ARGS $HELM_CHART_DIR
     - helm ${TRACE+--debug} $HELM_LINT_ARGS $HELM_CHART_DIR
   rules:
-    - if: $CI_MERGE_REQUEST_ID || $HELM_LINT_DISABLED
+    - if: '$CI_MERGE_REQUEST_ID || $HELM_LINT_DISABLED == "true"'
       when: never
     - exists:
         - "**/Chart.yaml"
@@ -525,7 +525,7 @@ helm-values-review-lint:
     - awkenvsubst < "$HELM_REVIEW_VALUES" > generated-values-review.yml
     - yamllint -d "$HELM_YAMLLINT_CONFIG" $HELM_YAMLLINT_ARGS generated-values-review.yml
   rules:
-    - if: $CI_MERGE_REQUEST_ID || $HELM_YAMLLINT_DISABLED
+    - if: '$CI_MERGE_REQUEST_ID || $HELM_YAMLLINT_DISABLED == "true"'
       when: never
     - if: $HELM_REVIEW_VALUES
 
@@ -535,7 +535,7 @@ helm-values-integration-lint:
     - awkenvsubst < "$HELM_INTEG_VALUES" > generated-values-integration.yml
     - yamllint -d "$HELM_YAMLLINT_CONFIG" $HELM_YAMLLINT_ARGS generated-values-integration.yml
   rules:
-    - if: $CI_MERGE_REQUEST_ID || $HELM_YAMLLINT_DISABLED
+    - if: '$CI_MERGE_REQUEST_ID || $HELM_YAMLLINT_DISABLED == "true"'
       when: never
     - if: $HELM_INTEG_VALUES
 
@@ -545,7 +545,7 @@ helm-values-staging-lint:
     - awkenvsubst < "$HELM_STAGING_VALUES" > generated-values-staging.yml
     - yamllint -d "$HELM_YAMLLINT_CONFIG" $HELM_YAMLLINT_ARGS generated-values-staging.yml
   rules:
-    - if: $CI_MERGE_REQUEST_ID || $HELM_YAMLLINT_DISABLED
+    - if: '$CI_MERGE_REQUEST_ID || $HELM_YAMLLINT_DISABLED == "true"'
       when: never
     - if: $HELM_STAGING_VALUES
 
@@ -555,7 +555,7 @@ helm-values-prod-lint:
     - awkenvsubst < "$HELM_PROD_VALUES" > generated-values-prod.yml
     - yamllint -d "$HELM_YAMLLINT_CONFIG" $HELM_YAMLLINT_ARGS generated-values-prod.yml
   rules:
-    - if: $CI_MERGE_REQUEST_ID || $HELM_YAMLLINT_DISABLED
+    - if: '$CI_MERGE_REQUEST_ID || $HELM_YAMLLINT_DISABLED == "true"'
       when: never
     - if: $HELM_PROD_VALUES
 
@@ -569,7 +569,7 @@ helm-review-score:
     - if: $CI_MERGE_REQUEST_ID
       when: never
     # exclude when $HELM_KUBE_SCORE_DISABLED is set
-    - if: $HELM_KUBE_SCORE_DISABLED
+    - if: '$HELM_KUBE_SCORE_DISABLED == "true"'
       when: never
     # else: allow failure
     - if: $HELM_REVIEW_VALUES
@@ -587,7 +587,7 @@ helm-integration-score:
     - if: $CI_MERGE_REQUEST_ID
       when: never
     # exclude when $K8S_SCORE_DISABLED is set
-    - if: $HELM_KUBE_SCORE_DISABLED
+    - if: '$HELM_KUBE_SCORE_DISABLED == "true"'
       when: never
     # else: allow failure
     - if: $HELM_INTEG_VALUES
@@ -605,7 +605,7 @@ helm-staging-score:
     - if: $CI_MERGE_REQUEST_ID
       when: never
     # exclude when $K8S_SCORE_DISABLED is set
-    - if: $HELM_KUBE_SCORE_DISABLED
+    - if: '$HELM_KUBE_SCORE_DISABLED == "true"'
       when: never
     # else: allow failure
     - if: $HELM_STAGING_VALUES
@@ -623,7 +623,7 @@ helm-prod-score:
     - if: $CI_MERGE_REQUEST_ID
       when: never
     # exclude when $K8S_SCORE_DISABLED is set
-    - if: $HELM_KUBE_SCORE_DISABLED
+    - if: '$HELM_KUBE_SCORE_DISABLED == "true"'
       when: never
     # else: allow failure
     - if: $HELM_PROD_VALUES
@@ -643,7 +643,7 @@ helm-package:
     - add_helm_repositories
   script:
     - |
-      if [[ "$SEMREL_INFO_ON" ]] && [[ "$SEMREL_INFO_NEXT_VERSION" ]] && [[ -z "$HELM_SEMREL_RELEASE_DISABLED" ]]
+      if [[ "$SEMREL_INFO_ON" ]] && [[ "$SEMREL_INFO_NEXT_VERSION" ]] && [[ "$HELM_SEMREL_RELEASE_DISABLED" != "true" ]]
       then
         log_info "semantic-release info is activated, using computed next version for release: \\e[1;94m${SEMREL_INFO_NEXT_VERSION}\\e[0m"
         helm_version_opts="--app-version ${SEMREL_INFO_NEXT_VERSION} --version ${SEMREL_INFO_NEXT_VERSION}"
@@ -773,7 +773,7 @@ helm-review:
   resource_group: review/$CI_COMMIT_REF_NAME
   rules:
     # exclude merge requests, tags and on $HELM_REVIEW_DISABLED set
-    - if: '$HELM_REVIEW_DISABLED || $CI_MERGE_REQUEST_ID || $CI_COMMIT_TAG'
+    - if: '$HELM_REVIEW_DISABLED == "true" || $CI_MERGE_REQUEST_ID || $CI_COMMIT_TAG'
       when: never
     # only on non-production, non-integration branches
     - if: '$CI_COMMIT_REF_NAME !~ $PROD_REF && $CI_COMMIT_REF_NAME !~ $INTEG_REF'
@@ -792,7 +792,7 @@ helm-cleanup-review:
   resource_group: review/$CI_COMMIT_REF_NAME
   rules:
     # exclude merge requests, tags and on $HELM_REVIEW_DISABLED set
-    - if: '$HELM_REVIEW_DISABLED || $CI_MERGE_REQUEST_ID || $CI_COMMIT_TAG'
+    - if: '$HELM_REVIEW_DISABLED == "true" || $CI_MERGE_REQUEST_ID || $CI_COMMIT_TAG'
       when: never
     # only on non-production, non-integration branches
     - if: '$CI_COMMIT_REF_NAME !~ $PROD_REF && $CI_COMMIT_REF_NAME !~ $INTEG_REF'
@@ -809,10 +809,10 @@ helm-test-review:
     ENV_NAMESPACE: "$HELM_REVIEW_NAMESPACE"
   rules:
     # exclude merge requests, tags and on $HELM_REVIEW_DISABLED set
-    - if: '$HELM_REVIEW_DISABLED || $CI_MERGE_REQUEST_ID || $CI_COMMIT_TAG'
+    - if: '$HELM_REVIEW_DISABLED == "true" || $CI_MERGE_REQUEST_ID || $CI_COMMIT_TAG'
       when: never
     # only on non-production, non-integration branches
-    - if: '$CI_COMMIT_REF_NAME !~ $PROD_REF && $CI_COMMIT_REF_NAME !~ $INTEG_REF && $HELM_TEST_ENABLED'
+    - if: '$CI_COMMIT_REF_NAME !~ $PROD_REF && $CI_COMMIT_REF_NAME !~ $INTEG_REF && $HELM_TEST_ENABLED == "true"'
 
 # ==================================================
 # Stage: integration
@@ -835,7 +835,7 @@ helm-integration:
   resource_group: integration
   rules:
     # exclude merge requests and on $HELM_INTEG_DISABLED set
-    - if: '$HELM_INTEG_DISABLED || $CI_MERGE_REQUEST_ID'
+    - if: '$HELM_INTEG_DISABLED == "true" || $CI_MERGE_REQUEST_ID'
       when: never
     # only on integration branch(es)
     - if: '$CI_COMMIT_REF_NAME =~ $INTEG_REF'
@@ -854,7 +854,7 @@ helm-cleanup-integration:
   resource_group: integration
   rules:
     # exclude merge requests and on $HELM_INTEG_DISABLED set
-    - if: '$HELM_INTEG_DISABLED || $CI_MERGE_REQUEST_ID'
+    - if: '$HELM_INTEG_DISABLED == "true" || $CI_MERGE_REQUEST_ID'
       when: never
     # only on integration branch(es)
     - if: '$CI_COMMIT_REF_NAME =~ $INTEG_REF'
@@ -872,10 +872,10 @@ helm-test-integration:
     ENV_VALUES: "$HELM_INTEG_VALUES"
   rules:
     # exclude merge requests and on $HELM_INTEG_DISABLED set
-    - if: '$HELM_INTEG_DISABLED || $CI_MERGE_REQUEST_ID'
+    - if: '$HELM_INTEG_DISABLED == "true" || $CI_MERGE_REQUEST_ID'
       when: never
     # only on integration branch(es)
-    - if: '$CI_COMMIT_REF_NAME =~ $INTEG_REF && $HELM_TEST_ENABLED'
+    - if: '$CI_COMMIT_REF_NAME =~ $INTEG_REF && $HELM_TEST_ENABLED == "true"'
 
 # ==================================================
 # Stage: staging
@@ -896,7 +896,7 @@ helm-staging:
   resource_group: staging
   rules:
     # exclude merge requests and on $HELM_STAGING_DISABLED set
-    - if: '$HELM_STAGING_DISABLED || $CI_MERGE_REQUEST_ID'
+    - if: '$HELM_STAGING_DISABLED == "true" || $CI_MERGE_REQUEST_ID'
       when: never
     # only on production branch(es)
     - if: '$CI_COMMIT_REF_NAME =~ $PROD_REF'
@@ -915,7 +915,7 @@ helm-cleanup-staging:
   resource_group: staging
   rules:
     # exclude merge requests and on $HELM_STAGING_DISABLED set
-    - if: '$HELM_STAGING_DISABLED || $CI_MERGE_REQUEST_ID'
+    - if: '$HELM_STAGING_DISABLED == "true" || $CI_MERGE_REQUEST_ID'
       when: never
     # only on production branch(es)
     - if: '$CI_COMMIT_REF_NAME =~ $PROD_REF'
@@ -932,10 +932,10 @@ helm-test-staging:
     ENV_VALUES: "$HELM_STAGING_VALUES"
   rules:
     # exclude merge requests and on $HELM_STAGING_DISABLED set
-    - if: '$HELM_STAGING_DISABLED  || $CI_MERGE_REQUEST_ID'
+    - if: '$HELM_STAGING_DISABLED == "true" || $CI_MERGE_REQUEST_ID'
       when: never
     # only on production branch(es)
-    - if: '$CI_COMMIT_REF_NAME =~ $PROD_REF && $HELM_TEST_ENABLED'
+    - if: '$CI_COMMIT_REF_NAME =~ $PROD_REF && $HELM_TEST_ENABLED == "true" '
 # ==================================================
 # Stage: production
 # ==================================================
@@ -962,7 +962,7 @@ helm-production:
     - if: '$CI_COMMIT_REF_NAME !~ $PROD_REF'
       when: never
     # exclude if $HELM_PROD_DISABLED set
-    - if: $HELM_PROD_DISABLED
+    - if: '$HELM_PROD_DISABLED == "true"'
       when: never
     # if $AUTODEPLOY_TO_PROD: auto
     - if: $AUTODEPLOY_TO_PROD
-- 
GitLab