Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 18 additions & 0 deletions .ci/pipelines/lib/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,25 @@ common::normalize_chart_image_ref() {
fi
}

# 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 on Mac/Linux: --in-place requires
# an output format, and it has no eval subcommand) — should allow this to
# run on both Macs and Linux dev / VM machines.
# $1 = expression, $2 = file, $3 = optional python-yq-only extra flags.
common::yq_inplace() {
local expr="$1" file="$2" py_flags="${3:-}"
local -a py_args=()
[[ -n "${py_flags}" ]] && py_args+=("${py_flags}")
if yq --help 2>&1 | grep -q -- --yaml-roundtrip; then
yq --yaml-roundtrip ${py_args[@]+"${py_args[@]}"} --in-place "${expr}" "${file}"
else
yq -i "${expr}" "${file}"
fi
Comment thread
nickboldt marked this conversation as resolved.
Resolved
}

# Export functions for subshell usage (e.g., timeout bash -c "...")
export -f common::base64_encode
export -f common::require_vars
export -f common::normalize_chart_image_ref
export -f common::yq_inplace
8 changes: 4 additions & 4 deletions .ci/pipelines/lib/disconnected/mirror.sh
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,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 \
common::yq_inplace \
".spec.imageDigestMirrors += [{\"mirrors\": [\"${mirror}\"], \"source\": \"${source}\"}]" \
"${idms_file}"
log::info "Added IDMS entry: ${source} -> ${mirror}"
Expand All @@ -242,8 +242,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
common::yq_inplace \
".spec.imageDigestMirrors += [{\"mirrors\": [\"${pg_mirror}\"], \"source\": \"${pg_source}\"}]" \
"${idms_file}"
log::info "Added IDMS entry: ${pg_source} -> ${pg_mirror}"
Expand Down
Loading