Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions .ci/pipelines/lib/disconnected/mirror.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@
[[ -n "${_DISCONNECTED_MIRROR_SOURCED:-}" ]] && return 0
readonly _DISCONNECTED_MIRROR_SOURCED=1

Comment thread
nickboldt marked this conversation as resolved.
Resolved
# In-place yq edit that works with both yq flavors: mikefarah yq (the
# disconnected pipeline image default: bare --in-place) and the python
# jq-wrapper yq (developer environments: --in-place requires an output
# format, and it has no eval subcommand). $1 = python-yq-only extra flags
# (may be empty), $2 = expression, $3 = file.
disconnected::yq_inplace() {
Comment thread
nickboldt marked this conversation as resolved.
Resolved
local py_flags="$1" expr="$2" file="$3"
if yq --help 2>&1 | grep -q -- --yaml-roundtrip; then
# shellcheck disable=SC2086
yq --yaml-roundtrip ${py_flags} --in-place "${expr}" "${file}"
else
yq -i "${expr}" "${file}"
fi
}

# ---------------------------------------------------------------------------
# Hooks — overridable by local.sh (or other consumers) to customise CI-only
# behaviour for local-disconnected or alternative registry setups.
Expand Down Expand Up @@ -226,12 +241,12 @@ disconnected::patch_idms() {
local source="${source_registry}/${IMAGE_REPO}"
local mirror="${mirror_host}/${IMAGE_REPO}"

if yq eval ".spec.imageDigestMirrors[].source" "${idms_file}" 2> /dev/null | grep -qF "${source}"; then
if yq ".spec.imageDigestMirrors[].source" "${idms_file}" 2> /dev/null | grep -qF "${source}"; then
log::debug "IDMS already contains entry for ${source}"
continue
fi

yq eval -i \
disconnected::yq_inplace "" \
".spec.imageDigestMirrors += [{\"mirrors\": [\"${mirror}\"], \"source\": \"${source}\"}]" \
"${idms_file}"
log::info "Added IDMS entry: ${source} -> ${mirror}"
Expand All @@ -242,8 +257,8 @@ disconnected::patch_idms() {
local pg_source="${PG_REGISTRY}/${PG_REPO}"
local pg_mirror="${mirror_host}/${PG_REPO}"

if ! yq eval ".spec.imageDigestMirrors[].source" "${idms_file}" 2> /dev/null | grep -qF "${pg_source}"; then
yq eval -i \
if ! yq ".spec.imageDigestMirrors[].source" "${idms_file}" 2> /dev/null | grep -qF "${pg_source}"; then
disconnected::yq_inplace "" \
".spec.imageDigestMirrors += [{\"mirrors\": [\"${pg_mirror}\"], \"source\": \"${pg_source}\"}]" \
"${idms_file}"
log::info "Added IDMS entry: ${pg_source} -> ${pg_mirror}"
Expand Down
Loading