Skip to content

Commit

Permalink
Check repo existence in konflux-ci/tekton-catalog
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
chmeliik committed May 27, 2024
1 parent 02a0b15 commit 7445432
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions .tekton/scripts/check-task-pipeline-bundle-repos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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
Expand All @@ -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"
Expand Down

0 comments on commit 7445432

Please sign in to comment.