Skip to content

Commit 8dbdcc2

Browse files
Merge pull request #73 from CircleCI-Public/ONPREM-2694/portable-extract-images-from-helm-chart.sh
Make extract-images-from-helm-chart.sh more portable
2 parents 64a8012 + 8d6272f commit 8dbdcc2

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

air-gap/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
images.txt
2+

air-gap/extract-images-from-helm-chart.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
#!/bin/bash
22
set -euo pipefail
33

4-
if ! command -v yq >/dev/null || ! yq --version | grep -q 'v4.' 2>&1; then
5-
echo "Error: yq 4.x is required: https://mikefarah.gitbook.io/yq#install" >&2
6-
yq --version
7-
exit 1
8-
fi
9-
10-
CHART_PATH="${1:-.}"
4+
CHART_PATH=$(realpath "${1:-.}")
115
OUTPUT_FILE="${2:-images.txt}"
126

137
TMP_VALUES=$(mktemp)
148
TMP_IMAGES=$(mktemp)
159
trap 'rm -f "$TMP_VALUES" "$TMP_IMAGES"' EXIT
1610

11+
# Check if yq 4.x is available locally, otherwise use Docker
12+
if ! command -v yq >/dev/null || ! yq --version 2>&1 | grep -q 'v4\.'; then
13+
echo "yq 4.x not found locally, using Docker image mikefarah/yq:4" >&2
14+
yq() {
15+
docker run --rm -i \
16+
-u "$(id -u)" \
17+
-v "${CHART_PATH}:${CHART_PATH}" \
18+
-v "/tmp:/tmp" \
19+
-w "${PWD}" \
20+
mikefarah/yq:4 "$@"
21+
}
22+
fi
23+
1724
# Enable all components to ensure everything renders and we find all images
1825
yq '
1926
(.. | select(has("enabled")).enabled) = true

0 commit comments

Comments
 (0)