-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add condition for running scan image
Adds support for a condition that will look for a secret. This is integrated with the pipeline to skip the scan-image step if sysdig secret isn't there, unfortunately optional steps are not supported yet in Tekton so the whole rest of the pipeline will fail if there is no secret per here: tektoncd/pipeline#1023
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: Condition | ||
metadata: | ||
name: secret-exists | ||
spec: | ||
params: | ||
- name: SECRET_NAME | ||
description: "The name of the secret to check for in the specified project" | ||
- name: PROJECT | ||
description: "The name of the project in which to seek SECRET_NAME. Defaults to the project this condition is defined in" | ||
default: "" | ||
check: | ||
image: quay.io/openshift/origin-cli:latest | ||
script: | | ||
#!/usr/bin/env bash | ||
set -e -o pipefail | ||
declare CHECK_PRJ="$(params.PROJECT)" | ||
if [[ -z "${CHECK_PRJ}" ]]; then | ||
echo "Looking to the pod to determine the current namespace" | ||
CHECK_PRJ=$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace) | ||
fi | ||
echo "command to run is: oc get secret $(params.SECRET_NAME) -n ${CHECK_PRJ} 2>/dev/null" | ||
# check for non-empty string result looking for secret | ||
test -n "$(oc get secret $(params.SECRET_NAME) -n ${CHECK_PRJ} 2>/dev/null)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters