From 9d1ca842b067c2f7ad967b8bc52db7c5d49795ff Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Tue, 30 Apr 2024 14:54:44 +0200 Subject: [PATCH] add force-cache-upload params --- examples/pipeline-go.yaml | 7 ++++++- tekton/cache-upload.yaml | 14 +++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/examples/pipeline-go.yaml b/examples/pipeline-go.yaml index a50d164cc..b7139bf4a 100644 --- a/examples/pipeline-go.yaml +++ b/examples/pipeline-go.yaml @@ -20,6 +20,9 @@ spec: - name: image type: string default: cgr.dev/chainguard/go + - name: force-cache-upload + type: string + default: "false" workspaces: - name: source tasks: @@ -57,7 +60,7 @@ spec: value: $(params.repo_url) - name: revision value: $(params.revision) - - name: fetch-cache + - name: cache-fetch ref: resolver: http params: @@ -100,3 +103,5 @@ spec: value: $(workspaces.source.path)/cache - name: workingdir value: $(workspaces.source.path)/repo + - name: force-cache-upload + value: $(params.force-cache-upload) diff --git a/tekton/cache-upload.yaml b/tekton/cache-upload.yaml index f13268da3..a396aaf26 100644 --- a/tekton/cache-upload.yaml +++ b/tekton/cache-upload.yaml @@ -33,6 +33,11 @@ spec: Whether to use insecure mode for fetching the cache type: string default: "false" + - name: force-cache-upload + description: | + Whether to force the cache upload even if it was fetched previously + type: string + default: "false" env: - name: PARAM_TARGET value: $(params.target) @@ -42,14 +47,17 @@ spec: value: $(params.workingdir) - name: PARAM_INSECURE value: $(params.insecure) - - name: CACHE_FETCHED - value: $(steps.fetch-cache.results.fetched) + - name: RESULT_CACHE_FETCHED + value: $(steps.cache-fetch.results.fetched) + - name: PARAM_FORCE_CACHE_UPLOAD + value: $(params.force-cache-upload) # FIXME: use a released version once something is released :) image: ghcr.io/openshift-pipelines/tekton-caches/cache:latest args: ["$(params.patterns[*])"] script: | #!/usr/bin/env sh - if [[ ${CACHE_FETCHED} == "true" ]]; then + set -x + if [[ ${PARAM_FORCE_CACHE_UPLOAD} == "false" && ${RESULT_CACHE_FETCHED} == "true" ]]; then echo "no need to upload cache" exit 0 fi