From f74d9ef2de5b4dc204b519e14c47862ea2b73b33 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20OLIVIER?= <cedric3.olivier@orange.com>
Date: Thu, 2 Sep 2021 15:00:04 +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                      |  4 ++--
 templates/gitlab-ci-docker.yml | 12 ++++++------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/README.md b/README.md
index e589a75..7f76991 100644
--- a/README.md
+++ b/README.md
@@ -241,7 +241,7 @@ It is bound to the `package-test` stage, and uses the following variables:
 
 | Name                                   | description                                                          | default value     |
 | -------------------------------------- | -------------------------------------------------------------------- | ----------------- |
-| `DOCKER_HEALTHCHECK_DISABLED`          | Set to disable health check                                          | _(none: enabled by default)_ |
+| `DOCKER_HEALTHCHECK_DISABLED`          | Set to `true` to disable health check                                          | _(none: enabled by default)_ |
 | `DOCKER_HEALTHCHECK_TIMEOUT`           | When testing a Docker Health (test stage), how long (in seconds) wait for the [HealthCheck status](https://docs.docker.com/engine/reference/builder/#healthcheck) | `60` |
 | `DOCKER_HEALTHCHECK_OPTIONS`           | Docker options for health check such as port mapping, environment... | _(none)_ |
 | `DOCKER_HEALTHCHECK_CONTAINER_ARGS`    | Set arguments sent to the running container for health check         | _(none)_ |
@@ -271,7 +271,7 @@ It is bound to the `package-test` stage, and uses the following variables:
 | `DOCKER_TRIVY_IMAGE`   | The docker image used to scan images with Trivy | `aquasec/trivy:latest` |
 | `DOCKER_TRIVY_ADDR`    | The Trivy server address               | _(none: disabled by default)_  |
 | `DOCKER_TRIVY_SECURITY_LEVEL_THRESHOLD`| Severities of vulnerabilities to be displayed (comma separated values: `UNKNOWN`, `LOW`, `MEDIUM`, `HIGH`, `CRITICAL`) | `UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL`  |
-| `DOCKER_TRIVY_DISABLED`| Set to disable Trivy analysis          | _(none)_ |
+| `DOCKER_TRIVY_DISABLED`| Set to `true` to disable Trivy analysis          | _(none)_ |
 
 ### `docker-publish` job
 
diff --git a/templates/gitlab-ci-docker.yml b/templates/gitlab-ci-docker.yml
index a86fa57..ced43ec 100644
--- a/templates/gitlab-ci-docker.yml
+++ b/templates/gitlab-ci-docker.yml
@@ -367,7 +367,7 @@ stages:
     fi
   }
 
-  if [[ -z "$TEMPLATE_CHECK_UPDATE_DISABLED" ]]; then check_for_update docker "1.2.3"; fi
+  if [[ "$TEMPLATE_CHECK_UPDATE_DISABLED" != "true" ]]; then check_for_update docker "1.2.3"; fi
   init_workspace
 
   # ENDSCRIPT
@@ -435,9 +435,9 @@ docker-lint:
       when: never
     # execute if DOCKER_LINT_ENABLED set
     # on production or integration branches: 
-    - if: '$DOCKER_LINT_ENABLED && ($CI_COMMIT_REF_NAME =~ $PROD_REF || $CI_COMMIT_REF_NAME =~ $INTEG_REF)'
+    - if: '$DOCKER_LINT_ENABLED == "true" && ($CI_COMMIT_REF_NAME =~ $PROD_REF || $CI_COMMIT_REF_NAME =~ $INTEG_REF)'
     # else (development branches): allow failure
-    - if: '$DOCKER_LINT_ENABLED'
+    - if: '$DOCKER_LINT_ENABLED == "true"'
       allow_failure: true
 
 docker-hadolint:
@@ -470,7 +470,7 @@ docker-hadolint:
     - if: $CI_MERGE_REQUEST_ID
       when: never
     # exclude if DOCKER_HADOLINT_DISABLED set
-    - if: $DOCKER_HADOLINT_DISABLED
+    - if: '$DOCKER_HADOLINT_DISABLED == "true"'
       when: never
     # on production or integration branches: auto
     - if: '$CI_COMMIT_REF_NAME =~ $PROD_REF || $CI_COMMIT_REF_NAME =~ $INTEG_REF'
@@ -589,7 +589,7 @@ docker-healthcheck:
     # exclude merge requests
     - if: $CI_MERGE_REQUEST_ID
       when: never
-    - if: $DOCKER_HEALTHCHECK_DISABLED
+    - if: '$DOCKER_HEALTHCHECK_DISABLED == "true"'
       when: never
     - if: $DOCKER_DIND_BUILD
 
@@ -624,7 +624,7 @@ docker-trivy:
     # exclude merge requests
     - if: $CI_MERGE_REQUEST_ID
       when: never
-    - if: $DOCKER_TRIVY_DISABLED
+    - if: '$DOCKER_TRIVY_DISABLED == "true"'
       when: never
     - if: '$DOCKER_TRIVY_ADDR && ($CI_COMMIT_REF_NAME =~ $PROD_REF || $CI_COMMIT_REF_NAME =~ $INTEG_REF)'
     # allow failure on development branches:
-- 
GitLab