Skip to content

Commit 7b7221d

Browse files
committed
update set quay visibility to capture success/failure and exit properly
Signed-off-by: Adam D. Cornett <adc@redhat.com>
1 parent 2e94162 commit 7b7221d

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

ansible/roles/operator-pipeline/templates/openshift/tasks/set-quay-repo-visibility.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,22 @@ spec:
2828
# DO NOT use `set -x` to avoid exposing the OAuth token
2929
set -e
3030
31-
curl -X POST \
31+
response=$(curl -s -w "\n%{http_code}" -X POST \
3232
-H "Authorization: Bearer $QUAY_OAUTH_TOKEN" \
3333
-H "Content-Type:application/json" \
3434
-d "{\"visibility\": \"$(params.visibility)\"}" \
35-
"https://quay.io/api/v1/repository/$(params.repository)/changevisibility"
35+
"https://quay.io/api/v1/repository/$(params.repository)/changevisibility")
3636
37-
echo "Repository visibility set to '$(params.visibility)'."
37+
http_code=$(echo "$response" | tail -n1)
38+
response_body=$(echo "$response" | head -n -1)
39+
40+
echo "Response body: $response_body"
41+
echo "HTTP status code: $http_code"
42+
43+
# Account for 200 and 201, since quay's docs mention 201, but in testing 200 is returned
44+
if [ "$http_code" != "200" || "$http_code" != "201"]; then
45+
echo "Error: Expected HTTP 2xx but got $http_code"
46+
exit 1
47+
fi
48+
49+
echo "Repository visibility successfully changed."

0 commit comments

Comments
 (0)