@@ -4,8 +4,8 @@ USER_HASH=$1
4
4
REPO_OWNER=$2
5
5
BRANCH=$3
6
6
REPO_NAME=$4
7
-
8
7
REPO_ROOT=$( git rev-parse --show-toplevel)
8
+
9
9
# Declare and initialize the image skipping log file (This does not commit)
10
10
export SKIPPED_LOG=" $REPO_ROOT /skipped-images.txt"
11
11
@@ -34,20 +34,16 @@ fetch_latest_hash() {
34
34
fi
35
35
}
36
36
37
- # Updates the commits in commit.env
38
- update_commits () {
39
- local REPO_ROOT=" $1 "
40
- local HASH=" $2 "
41
- local COMMIT_ENV_PATH=" $REPO_ROOT /manifests/base/commit.env"
42
-
43
- # Get the complete list of commits N-version to update
44
- local COMMITS
45
- COMMITS=$( grep " \-n=" " $COMMIT_ENV_PATH " | cut -d " =" -f 1)
37
+ # Updates a corresponding image commit in commit.env
38
+ update_image_commit () {
39
+ local image_name=" $1 "
40
+ local hash=" $2 "
41
+ local commit_env_path=" $REPO_ROOT /manifests/base/commit.env"
46
42
47
- for val in $COMMITS ; do
48
- echo " Updating commit ' ${val} ' to $HASH "
49
- sed -i " s| ${val} =.*| ${val} = ${HASH} | " " $COMMIT_ENV_PATH "
50
- done
43
+ # Convert image name to match with commit variable name
44
+ commit_var= $( echo " $image_name " | sed ' s/-n$/-commit-n/ ' )
45
+ echo " Updating commit ' ${commit_var} ' to $hash "
46
+ sed -i " s|^ ${commit_var} =.*| ${commit_var} = ${hash} | " " $commit_env_path "
51
47
}
52
48
53
49
# Function to process runtime images
@@ -150,10 +146,8 @@ if [[ "$REPO_OWNER" == "opendatahub-io" ]]; then
150
146
log_skipped_image " $image "
151
147
continue
152
148
fi
153
-
154
149
# use `--no-tags` for skopeo once available in newer version
155
150
digest=$( skopeo inspect --retry-times 3 " docker://${registry} :${latest_tag} " | jq .Digest | tr -d ' "' )
156
-
157
151
# Check for digest validity
158
152
if [[ -z " $digest " || " $digest " == " null" ]]; then
159
153
echo " Failed to get digest for $latest_tag . Skipping."
@@ -164,9 +158,8 @@ if [[ "$REPO_OWNER" == "opendatahub-io" ]]; then
164
158
output=" ${registry} @${digest} "
165
159
echo " NEW: ${output} "
166
160
sed -i " s|${image} =.*|${image} =${output} |" " ${PARAMS_ENV_PATH} "
161
+ update_image_commit " $image " " $HASH "
167
162
done
168
-
169
- update_commits " $REPO_ROOT " " $HASH "
170
163
update_runtime_images
171
164
172
165
# In case the digest updater function is triggered downstream.
@@ -205,9 +198,7 @@ elif [[ "$REPO_OWNER" == "red-hat-data-services" ]]; then
205
198
log_skipped_image " $image "
206
199
continue
207
200
fi
208
-
209
201
digest=$( skopeo inspect --retry-times 3 " docker://${registry} :${latest_tag} " | jq .Digest | tr -d ' "' )
210
-
211
202
# Check for digest validity
212
203
if [[ -z " $digest " || " $digest " == " null" ]]; then
213
204
echo " Failed to get digest for $latest_tag . Skipping."
@@ -218,10 +209,9 @@ elif [[ "$REPO_OWNER" == "red-hat-data-services" ]]; then
218
209
output=" ${registry} @${digest} "
219
210
echo " NEW: ${output} "
220
211
sed -i " s|${image} =.*|${image} =${output} |" " ${PARAMS_ENV_PATH} "
212
+ update_image_commit " $image " " $HASH "
221
213
i=$(( i+ 1 ))
222
214
done
223
-
224
- update_commits " $REPO_ROOT " " $HASH "
225
215
update_runtime_images
226
216
227
217
else
0 commit comments