From b24069dbc036dcc1d5d7d6f343fe23f085bbface Mon Sep 17 00:00:00 2001
From: Clement Bois <clement.bois@orange.com>
Date: Tue, 24 Sep 2024 15:31:32 +0200
Subject: [PATCH] fix: use up-to-date image and download yajsv

---
 templates/validation.yml | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/templates/validation.yml b/templates/validation.yml
index 31678cf..f34ee45 100644
--- a/templates/validation.yml
+++ b/templates/validation.yml
@@ -1,5 +1,6 @@
 variables:
-  YAJSV_IMAGE: "registry.hub.docker.com/amux/yajsv:latest"
+  YAJSV_IMAGE: "registry.hub.docker.com/badouralix/curl-jq:latest"
+  YAJSV_RELEASE: "https://github.com/neilpa/yajsv/releases/download/v1.4.1/yajsv.linux.amd64"
 
 .kicker-scripts: &kicker-scripts |
   set -e
@@ -29,6 +30,16 @@ variables:
     fi
   }
 
+  function install_yajsv() {
+    export PATH=$PATH:$(pwd)
+    if ! command -v yajsv > /dev/null
+    then
+      log_info "Installing yajsv"
+      curl -sSL -o ./yajsv "${YAJSV_RELEASE}"
+      chmod +x ./yajsv
+    fi
+  }
+
 # Abstract JSON schema validation job
 # $JSON_FILE  : the JSON file to test
 # $SCHEMA_URL : the schema url
@@ -38,9 +49,14 @@ variables:
   before_script:
     - !reference [.kicker-scripts]
     - install_ca_certs "${CUSTOM_CA_CERTS:-$DEFAULT_CA_CERTS}"
+    - install_yajsv
   script:
-    - 'wget --header "PRIVATE-TOKEN: $GITLAB_TOKEN" "$SCHEMA_URL" -O schema.json'
+    - 'curl -sSL -o schema.json -H "PRIVATE-TOKEN: $GITLAB_TOKEN" "$SCHEMA_URL"'
     - yajsv -s schema.json "$JSON_FILE"
+  cache:
+    key: "$CI_COMMIT_REF_NAME-yajsv"
+    paths:
+      - ./yajsv
   rules:
     # enabled if kicker.json file found
     - exists:
-- 
GitLab