Skip to content

Commit 48b52be

Browse files
committed
Simplify publish-rhel.sh
The script calls functions in order, most steps only proceed if a certain condition is met. The subsequent step then immediately checks the same condition before proceeding which is redundant. This is an optimization, it's not a problem. Example: `wait_for_container_scan`: https://github.com/hazelcast/hazelcast-docker/blob/6729095dbdf6d8ba17f5eaf9b6d5dfbf6f321b99/.github/scripts/publish-rhel.sh#L68-L69 Immediately followed by `publish_the_image`: https://github.com/hazelcast/hazelcast-docker/blob/6729095dbdf6d8ba17f5eaf9b6d5dfbf6f321b99/.github/scripts/publish-rhel.sh#L103-L106 `wait_for_container_publish`: https://github.com/hazelcast/hazelcast-docker/blob/6729095dbdf6d8ba17f5eaf9b6d5dfbf6f321b99/.github/scripts/publish-rhel.sh#L138-L146 Immediately followed by `sync_tags`: https://github.com/hazelcast/hazelcast-docker/blob/6729095dbdf6d8ba17f5eaf9b6d5dfbf6f321b99/.github/scripts/publish-rhel.sh#L183-L189
1 parent 6729095 commit 48b52be

File tree

1 file changed

+1
-38
lines changed

1 file changed

+1
-38
lines changed

.github/scripts/publish-rhel.sh

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ get_image()
3636
}
3737

3838
wait_for_container_scan()
39-
{
39+
{
4040
local IMAGE
4141
local IS_PUBLISHED
4242

@@ -51,7 +51,6 @@ wait_for_container_scan()
5151
local NOF_RETRIES=$(( TIMEOUT_IN_MINS / 2 ))
5252
# Wait until the image is scanned
5353
for i in $(seq 1 "${NOF_RETRIES}"); do
54-
local IMAGE
5554
local SCAN_STATUS
5655
local IMAGE_CERTIFIED
5756

@@ -87,29 +86,6 @@ publish_the_image()
8786
{
8887
echo "Starting publishing the image for ${IMAGE_ID}"
8988

90-
local IMAGE
91-
local IMAGE_EXISTS
92-
93-
IMAGE=$(get_image not_published)
94-
IMAGE_EXISTS=$(echo "${IMAGE}" | jq -r '.total')
95-
96-
if [[ ${IMAGE_EXISTS} == "1" ]]; then
97-
local SCAN_STATUS
98-
local IMAGE_CERTIFIED
99-
100-
SCAN_STATUS=$(echo "${IMAGE}" | jq -r '.data[0].container_grades.status')
101-
IMAGE_CERTIFIED=$(echo "${IMAGE}" | jq -r '.data[0].certified')
102-
103-
if [[ ${SCAN_STATUS} != "completed" || "${IMAGE_CERTIFIED}" != "true" ]]; then
104-
echoerr "Image you are trying to publish did not pass the certification test, its status is \"${SCAN_STATUS}\" and certified is \"${IMAGE_CERTIFIED}\""
105-
return 1
106-
fi
107-
else
108-
echoerr "Image you are trying to publish does not exist."
109-
echoerr "${IMAGE}"
110-
return 1
111-
fi
112-
11389
echo "Publishing the image ${IMAGE_ID}..."
11490
# https://catalog.redhat.com/api/containers/docs/endpoints/RESTPostImageRequestByCertProjectId.html
11591
RESPONSE=$( \
@@ -175,19 +151,6 @@ wait_for_container_publish()
175151

176152
sync_tags()
177153
{
178-
echo "Starting sync tags for ${IMAGE_ID}"
179-
180-
local IMAGE
181-
local IMAGE_EXISTS
182-
183-
IMAGE=$(get_image published)
184-
IMAGE_EXISTS=$(echo "${IMAGE}" | jq -r '.total')
185-
186-
if [[ ${IMAGE_EXISTS} == "0" ]]; then
187-
echo "Image you are trying to sync does not exist."
188-
return 1
189-
fi
190-
191154
echo "Syncing tags of the image ${IMAGE_ID}..."
192155
# https://catalog.redhat.com/api/containers/docs/endpoints/RESTPostImageRequestByCertProjectId.html
193156
RESPONSE=$( \

0 commit comments

Comments
 (0)