Skip to content

Commit

Permalink
add force-cache-upload params
Browse files Browse the repository at this point in the history
  • Loading branch information
chmouel committed Apr 30, 2024
1 parent 48f14d6 commit 9d1ca84
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
7 changes: 6 additions & 1 deletion examples/pipeline-go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -57,7 +60,7 @@ spec:
value: $(params.repo_url)
- name: revision
value: $(params.revision)
- name: fetch-cache
- name: cache-fetch
ref:
resolver: http
params:
Expand Down Expand Up @@ -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)
14 changes: 11 additions & 3 deletions tekton/cache-upload.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 9d1ca84

Please sign in to comment.