Skip to content

Commit da3c208

Browse files
authored
fix redhat api changes for bundle release (#719)
1 parent e3eaccb commit da3c208

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

hack/publish-rhel.sh

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ get_image()
3434
fi
3535

3636
local FILTER="filter=deleted==false;${PUBLISHED_FILTER}"
37-
local INCLUDE="include=total,data.repositories.tags.name,data.scan_status,data._id"
37+
local INCLUDE="include=total,data.repositories.tags.name,data.certified,data.container_grades,data._id"
3838

3939
local RESPONSE=$( \
4040
curl --silent \
@@ -62,13 +62,14 @@ wait_for_container_scan()
6262
# Wait until the image is scanned
6363
for i in `seq 1 ${NOF_RETRIES}`; do
6464
local IMAGE=$(get_image not_published "${RHEL_PROJECT_ID}" "${VERSION}" "${RHEL_API_KEY}")
65-
local SCAN_STATUS=$(echo "$IMAGE" | jq -r '.data[0].scan_status')
65+
local SCAN_STATUS=$(echo "$IMAGE" | jq -r '.data[0].container_grades.status')
66+
local IMAGE_CERTIFIED=$(echo "$IMAGE" | jq -r '.data[0].certified')
6667

6768
if [[ $SCAN_STATUS == "in progress" ]]; then
6869
echo "Scanning in progress, waiting..."
6970
elif [[ $SCAN_STATUS == "null" ]]; then
7071
echo "Image is still not present in the registry!"
71-
elif [[ $SCAN_STATUS == "passed" ]]; then
72+
elif [[ $SCAN_STATUS == "completed" && "$IMAGE_CERTIFIED" == "true" ]]; then
7273
echo "Scan passed!" ; return 0
7374
else
7475
echo "Scan failed!" ; return 1
@@ -94,9 +95,10 @@ publish_the_image()
9495
local IMAGE=$(get_image not_published "${RHEL_PROJECT_ID}" "${VERSION}" "${RHEL_API_KEY}")
9596
local IMAGE_EXISTS=$(echo $IMAGE | jq -r '.total')
9697
if [[ $IMAGE_EXISTS == "1" ]]; then
97-
local SCAN_STATUS=$(echo $IMAGE | jq -r '.data[0].scan_status')
98-
if [[ $SCAN_STATUS != "passed" ]]; then
99-
echo "Image you are trying to publish did not pass the certification test, its status is \"${SCAN_STATUS}\""
98+
local SCAN_STATUS=$(echo "$IMAGE" | jq -r '.data[0].container_grades.status')
99+
local IMAGE_CERTIFIED=$(echo "$IMAGE" | jq -r '.data[0].certified')
100+
if [[ $SCAN_STATUS != "completed" || "$IMAGE_CERTIFIED" != "true" ]]; then
101+
echo "Image you are trying to publish did not pass the certification test, its status is \"${SCAN_STATUS}\" and certified is \"${IMAGE_CERTIFIED}\""
100102
return 1
101103
fi
102104
else
@@ -137,14 +139,8 @@ sync_tags()
137139

138140
local IMAGE=$(get_image published "${RHEL_PROJECT_ID}" "${VERSION}" "${RHEL_API_KEY}")
139141
local IMAGE_EXISTS=$(echo $IMAGE | jq -r '.total')
140-
if [[ $IMAGE_EXISTS != "0" ]]; then
141-
local SCAN_STATUS=$(echo $IMAGE | jq -r '.data[0].scan_status')
142-
if [[ $SCAN_STATUS != "passed" ]]; then
143-
echo "Image you are trying to publish did not pass the certification test, its status is \"${SCAN_STATUS}\""
144-
return 1
145-
fi
146-
else
147-
echo "Image you are trying to publish does not exist."
142+
if [[ $IMAGE_EXISTS == "0" ]]; then
143+
echo "Image you are trying to sync does not exist."
148144
return 1
149145
fi
150146

0 commit comments

Comments
 (0)