Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix repository creation in push pipeline #1802

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .tekton/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ spec:
runAfter:
- build-appstudio-utils
- ec-task-checks
- create-repositories-if-missing
workspaces:
- name: source
workspace: workspace
Expand Down
20 changes: 11 additions & 9 deletions .tekton/scripts/create-task-pipeline-bundle-repos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,36 @@ locate_in_all_namespaces() {
for quay_namespace in "${CATALOG_NAMESPACES[@]}"; do
found=$(locate_bundle_repo "$quay_namespace" "$type" "$object")

quay_repo=${type}-${object}

# konflux-ci/tekton-catalog
if [[ $quay_namespace = */* ]]; then
# tekton-catalog/
quay_repo_prefix="${quay_namespace#*/}/"
# tekton-catalog/...
quay_repo="${quay_namespace#*/}/$quay_repo"
# konflux-ci
quay_namespace=${quay_namespace%%/*}
else
quay_repo_prefix=""
fi

echo "Checking ${quay_namespace}/${quay_repo_prefix}${object}, http code: ${found}"
echo "Checking ${quay_namespace}/${quay_repo}, http code: ${found}"
if [ "$found" != "200" ]; then
echo "Missing $type bundle repo: ${quay_repo_prefix}${object} in ${quay_namespace}, creating..."
echo "Missing $type bundle repo: ${quay_repo} in ${quay_namespace}, creating..."
payload=$(
jq -n \
--arg namespace "$quay_namespace" \
--arg repository "$quay_repo_prefix$object" \
--arg repository "$quay_repo" \
--arg visibility "public" \
--arg description "" \
'$ARGS.named'
)
if ! err_msg=$(curl --oauth2-bearer "${QUAY_TOKEN}" "https://quay.io/api/v1/repository" --data-binary "$payload" -H "Content-Type: application/json" -H "Accept: application/json" | jq '.error_message // empty');
if ! err_msg=$(curl --oauth2-bearer "${QUAY_TOKEN}" "https://quay.io/api/v1/repository" --data-binary "$payload" -H "Content-Type: application/json" -H "Accept: application/json" | jq -r '.error_message // empty');
then
echo "curl returned an error when creating the repository. See the error above."
exit 1
fi

if [ -n "$err_msg" ]; then
if [[ "$err_msg" == "Repository already exists" ]]; then
echo "WARNING: repository creation failed, but the error message was '$err_msg'. Assuming that's fine."
elif [[ -n "$err_msg" ]]; then
echo "Quay returned an error when creating the repository: ${err_msg}"
exit 1
fi
Expand Down
Loading