Skip to content

Commit

Permalink
feat: image digest
Browse files Browse the repository at this point in the history
  • Loading branch information
mikhail-klimko committed Nov 1, 2024
1 parent 4158534 commit faaf32e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions scripts/update_values_with_digests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ set -eou xtrace

MYDIR=$(dirname $0)
CHARTDIR="${MYDIR}/../charts/cf-runtime"
VALUES_FILE="${MYDIR}/values.yaml"
VALUES_FILE="${CHARTDIR}/values.yaml"

runtime_images=$(yq e '.runtime.engine.runtimeImages' $CHARTDIR/values.yaml)
runtime_images=$(yq e '.runtime.engine.runtimeImages' $VALUES_FILE)

while read -r line; do
key=${line%%:*}
image=${line#*:}
digest=$(regctl manifest digest $image)
yq e -i ".runtime.engine.runtimeImages.$key |= . + \"$digest\"" $CHARTDIR/values.yaml
yq e -i ".runtime.engine.runtimeImages.$key |= . + \"$digest\"" $VALUES_FILE)
done <<< "$runtime_images"


Expand All @@ -30,15 +30,15 @@ get_image_digest() {
fi
}

yq eval-all '. as $item ireduce ({}; . * $item) | .. | select(has("image")) | path | join(".")' "$input_file" | \
yq eval-all '. as $item ireduce ({}; . * $item) | .. | select(has("image")) | path | join(".")' "$VALUES_FILE" | \
while read -r path; do
registry=$(yq eval ".$path.image.registry" "$input_file")
repository=$(yq eval ".$path.image.repository" "$input_file")
tag=$(yq eval ".$path.image.tag" "$input_file")
registry=$(yq eval ".$path.image.registry" "$VALUES_FILE")
repository=$(yq eval ".$path.image.repository" "$VALUES_FILE")
tag=$(yq eval ".$path.image.tag" "$VALUES_FILE")

digest=$(get_image_digest "$registry" "$repository" "$tag")

if [[ -n "$digest" ]]; then
yq eval -i ".$path.image.digest = \"$digest\"" "$input_file"
yq eval -i ".$path.image.digest = \"$digest\"" "$VALUES_FILE"
fi
done

0 comments on commit faaf32e

Please sign in to comment.