From 744543262f631e9199f0fcd0d802ba7a4a4c61be Mon Sep 17 00:00:00 2001 From: Adam Cmiel Date: Mon, 27 May 2024 11:22:36 +0200 Subject: [PATCH] Check repo existence in konflux-ci/tekton-catalog STONEBLD-2339 And keep checking redhat-appstudio-tekton-catalog as well. The pipeline and task repos need to exist in both places. Signed-off-by: Adam Cmiel --- .../check-task-pipeline-bundle-repos.sh | 38 ++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/.tekton/scripts/check-task-pipeline-bundle-repos.sh b/.tekton/scripts/check-task-pipeline-bundle-repos.sh index d9607c619b..2442d835cb 100755 --- a/.tekton/scripts/check-task-pipeline-bundle-repos.sh +++ b/.tekton/scripts/check-task-pipeline-bundle-repos.sh @@ -7,13 +7,34 @@ set -o nounset SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" cd "$SCRIPTDIR/../.." -QUAY_ORG=redhat-appstudio-tekton-catalog +CATALOG_NAMESPACES=( + redhat-appstudio-tekton-catalog + konflux-ci/tekton-catalog +) locate_bundle_repo() { + local -r quay_namespace="$1" + local -r type="$2" + local -r object="$3" + + curl -I -s -L -w "%{http_code}\n" -o /dev/null "https://quay.io/v2/${quay_namespace}/${type}-${object}/tags/list" +} + +locate_in_all_namespaces() { local -r type="$1" local -r object="$2" - curl -I -s -L -w "%{http_code}\n" -o /dev/null "https://quay.io/v2/${QUAY_ORG}/${type}-${object}/tags/list" + local rc=0 + + for quay_namespace in "${CATALOG_NAMESPACES[@]}"; do + found=$(locate_bundle_repo "$quay_namespace" "$type" "$object") + if [ "$found" != "200" ]; then + echo "Missing $type bundle repo: ${quay_namespace}/${type}-${object}" + rc=1 + fi + done + + return "$rc" } has_missing_repo= @@ -27,9 +48,8 @@ for task_dir in $(find task/*/*/ -maxdepth 0 -type d); do else task_name=$(oc apply --dry-run=client -k "$task_dir" -o jsonpath='{.metadata.name}') fi - found=$(locate_bundle_repo task "$task_name") - if [ "$found" != "200" ]; then - echo "Missing task bundle repo: task-$task_name" + + if ! locate_in_all_namespaces task "$task_name"; then has_missing_repo=yes fi done @@ -39,15 +59,15 @@ pl_names=($(oc kustomize pipelines/ | oc apply --dry-run=client -f - -o jsonpath # Currently, only one pipeline for core services CI pl_names+=($(oc kustomize pipelines/core-services/ | oc apply --dry-run=client -f - -o jsonpath='{"core-services-"}{.metadata.name}')) for pl_name in ${pl_names[@]}; do - found=$(locate_bundle_repo pipeline "$pl_name") - if [ "$found" != "200" ]; then - echo "Missing pipeline bundle repo: pipeline-$pl_name" + if ! locate_in_all_namespaces pipeline "$pl_name"; then has_missing_repo=yes fi done if [ -n "$has_missing_repo" ]; then - echo "Please contact Build team - #forum-stonesoup-build that the missing repos should be created in https://quay.io/organization/redhat-appstudio-tekton-catalog" + echo "Please contact Build team - #forum-stonesoup-build that the missing repos should be created in:" + echo "- https://quay.io/organization/redhat-appstudio-tekton-catalog" + echo "- https://quay.io/organization/konflux-ci" exit 1 else echo "Done"