This repository has been archived by the owner on Jul 28, 2023. It is now read-only.
forked from eclipse-che/che-devfile-registry
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from johnmcollier/masterfix
Fix devfile registry image
- Loading branch information
Showing
3 changed files
with
68 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2020 Red Hat, Inc. | ||
# This program and the accompanying materials are made | ||
# available under the terms of the Eclipse Public License 2.0 | ||
# which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 | ||
# | ||
|
||
SCRIPT_DIR=$(cd "$(dirname "$0")" || exit; pwd) | ||
LOG_FILE="/tmp/image_digests.log" | ||
|
||
function handle_error() { | ||
the_image="$1" | ||
echo " Could not read image metadata through skopeo inspect; skip $the_image" | ||
echo -n " Reason: " | ||
sed 's|^| |g' $LOG_FILE | ||
} | ||
|
||
readarray -d '' devfiles < <(find "$1" -name 'devfile.yaml' -print0) | ||
for image in $(yq -r '.components[]?.image' "${devfiles[@]}" | grep -v "null" | sort | uniq); do | ||
digest="$(skopeo inspect "docker://${image}" 2>"$LOG_FILE" | jq -r '.Digest')" | ||
if [[ ${digest} ]]; then | ||
echo " $digest # ${image}" | ||
else | ||
# for other build methods or for falling back to other registries when not found, can apply transforms here | ||
if [[ -x "${SCRIPT_DIR}/write_image_digests_alternate_urls.sh" ]]; then | ||
# since extension file may not exist, disable this check | ||
# shellcheck disable=SC1090 | ||
source "${SCRIPT_DIR}/write_image_digests_alternate_urls.sh" | ||
fi | ||
fi | ||
|
||
# don't rewrite if we couldn't get a digest from either the basic image or the alternative image | ||
if [[ ! ${digest} ]]; then | ||
handle_error "$image" | ||
continue | ||
fi | ||
|
||
digest_image="${image%:*}@${digest}" | ||
|
||
# Rewrite images to use sha-256 digests | ||
sed -i -E 's|"?'"${image}"'"?|"'"${digest_image}"'" # tag: '"${image}"'|g' "${devfiles[@]}" | ||
done | ||
rm $LOG_FILE |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.