Skip to content

Commit 7573106

Browse files
committed
Concurrently export/import charts/images
Signed-off-by: sami <sami@appscode.com>
1 parent a499384 commit 7573106

6 files changed

Lines changed: 66 additions & 15 deletions

File tree

catalog/copy-images.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
set -x
17+
set -euo pipefail
1818

19-
if [ -z "${IMAGE_REGISTRY}" ]; then
19+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
20+
source "$SCRIPT_DIR/concurrency-utils.sh"
21+
22+
if [ -z "${IMAGE_REGISTRY:-}" ]; then
2023
echo "IMAGE_REGISTRY is not set"
2124
exit 1
2225
fi
@@ -33,7 +36,7 @@ curl -sL "https://github.com/google/go-containerregistry/releases/latest/downloa
3336
tar -zxvf /tmp/go-containerregistry.tar.gz -C /tmp/
3437
mv /tmp/crane .
3538

36-
CMD="./crane"
39+
CMD="run_async ./crane"
3740

3841
$CMD cp --allow-nondistributable-artifacts --insecure ghcr.io/appscode-charts/ace-installer:v2026.3.30 $IMAGE_REGISTRY/appscode-charts/ace-installer:v2026.3.30
3942
$CMD cp --allow-nondistributable-artifacts --insecure ghcr.io/appscode-charts/ace:v2026.3.30 $IMAGE_REGISTRY/appscode-charts/ace:v2026.3.30
@@ -301,3 +304,5 @@ $CMD cp --allow-nondistributable-artifacts --insecure ghcr.io/appscode-charts/va
301304
$CMD cp --allow-nondistributable-artifacts --insecure ghcr.io/appscode-charts/virtual-secrets-server:v2026.2.27 $IMAGE_REGISTRY/appscode-charts/virtual-secrets-server:v2026.2.27
302305
$CMD cp --allow-nondistributable-artifacts --insecure ghcr.io/appscode-charts/voyager-gateway:v2026.1.15 $IMAGE_REGISTRY/appscode-charts/voyager-gateway:v2026.1.15
303306
$CMD cp --allow-nondistributable-artifacts --insecure ghcr.io/appscode-charts/voyager:v2026.3.23 $IMAGE_REGISTRY/appscode-charts/voyager:v2026.3.23
307+
308+
wait_all

catalog/export-images.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
set -x
17+
set -euo pipefail
18+
19+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
20+
source "$SCRIPT_DIR/concurrency-utils.sh"
1821

1922
mkdir -p images
2023

@@ -30,7 +33,8 @@ curl -sL "https://github.com/google/go-containerregistry/releases/latest/downloa
3033
tar -zxvf /tmp/go-containerregistry.tar.gz -C /tmp/
3134
mv /tmp/crane images
3235

33-
CMD="./images/crane"
36+
CMD="run_async ./images/crane"
37+
EXPECTED_COUNT=$(grep -cE '^\$CMD pull ' "${BASH_SOURCE[0]}")
3438

3539
$CMD pull --allow-nondistributable-artifacts --insecure ghcr.io/appscode-charts/ace-installer:v2026.3.30 images/appscode-charts-ace-installer-v2026.3.30.tar
3640
$CMD pull --allow-nondistributable-artifacts --insecure ghcr.io/appscode-charts/ace:v2026.3.30 images/appscode-charts-ace-v2026.3.30.tar
@@ -299,4 +303,15 @@ $CMD pull --allow-nondistributable-artifacts --insecure ghcr.io/appscode-charts/
299303
$CMD pull --allow-nondistributable-artifacts --insecure ghcr.io/appscode-charts/voyager-gateway:v2026.1.15 images/appscode-charts-voyager-gateway-v2026.1.15.tar
300304
$CMD pull --allow-nondistributable-artifacts --insecure ghcr.io/appscode-charts/voyager:v2026.3.23 images/appscode-charts-voyager-v2026.3.23.tar
301305

306+
if ! wait_all; then
307+
exit 1
308+
fi
309+
310+
actual=$(find images -name '*.tar' | wc -l)
311+
if [[ "$actual" -ne "$EXPECTED_COUNT" ]]; then
312+
printf '\033[31mValidation failed: expected %d files, got %d\033[0m\n' "$EXPECTED_COUNT" "$actual" >&2
313+
exit 1
314+
fi
315+
printf '\033[32mValidation passed: %d files\033[0m\n' "$actual" >&2
316+
302317
tar -czvf images.tar.gz images

catalog/import-images.sh

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,33 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
set -x
17+
set -euo pipefail
1818

19-
if [ -z "${IMAGE_REGISTRY}" ]; then
19+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
20+
source "$SCRIPT_DIR/concurrency-utils.sh"
21+
22+
if [ -z "${IMAGE_REGISTRY:-}" ]; then
2023
echo "IMAGE_REGISTRY is not set"
2124
exit 1
2225
fi
2326

2427
TARBALL=${1:-}
25-
tar -zxvf $TARBALL
28+
if [ -n "$TARBALL" ]; then
29+
if [ ! -f "$TARBALL" ]; then
30+
echo "Error: Tarball '$TARBALL' does not exist."
31+
exit 1
32+
fi
33+
echo "Extracting $TARBALL..."
34+
tar -zxvf "$TARBALL"
35+
elif [ -d "images" ] && [ -f "images/crane" ] && ls images/*.tar >/dev/null 2>&1; then
36+
echo "Found existing images directory with tarballs and crane binary. Skipping extraction..."
37+
else
38+
echo "Usage: $0 [images.tar.gz]"
39+
echo "Error: No tarball provided and valid images directory not found."
40+
exit 1
41+
fi
2642

27-
CMD="./crane"
43+
CMD="run_async ./images/crane"
2844

2945
$CMD push --allow-nondistributable-artifacts --insecure images/appscode-charts-ace-installer-v2026.3.30.tar $IMAGE_REGISTRY/appscode-charts/ace-installer:v2026.3.30
3046
$CMD push --allow-nondistributable-artifacts --insecure images/appscode-charts-ace-v2026.3.30.tar $IMAGE_REGISTRY/appscode-charts/ace:v2026.3.30
@@ -292,3 +308,5 @@ $CMD push --allow-nondistributable-artifacts --insecure images/appscode-charts-v
292308
$CMD push --allow-nondistributable-artifacts --insecure images/appscode-charts-virtual-secrets-server-v2026.2.27.tar $IMAGE_REGISTRY/appscode-charts/virtual-secrets-server:v2026.2.27
293309
$CMD push --allow-nondistributable-artifacts --insecure images/appscode-charts-voyager-gateway-v2026.1.15.tar $IMAGE_REGISTRY/appscode-charts/voyager-gateway:v2026.1.15
294310
$CMD push --allow-nondistributable-artifacts --insecure images/appscode-charts-voyager-v2026.3.23.tar $IMAGE_REGISTRY/appscode-charts/voyager:v2026.3.23
311+
312+
wait_all

catalog/import-into-k3s.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,28 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
set -x
17+
set -euxo pipefail
1818

19-
if [ -z "${IMAGE_REGISTRY}" ]; then
19+
if [ -z "${IMAGE_REGISTRY:-}" ]; then
2020
echo "IMAGE_REGISTRY is not set"
2121
exit 1
2222
fi
2323

2424
TARBALL=${1:-}
25-
tar -zxvf $TARBALL
25+
if [ -n "$TARBALL" ]; then
26+
if [ ! -f "$TARBALL" ]; then
27+
echo "Error: Tarball '$TARBALL' does not exist."
28+
exit 1
29+
fi
30+
echo "Extracting $TARBALL..."
31+
tar -zxvf "$TARBALL"
32+
elif [ -d "images" ] && ls images/*.tar >/dev/null 2>&1; then
33+
echo "Found existing images directory with tarballs. Skipping extraction..."
34+
else
35+
echo "Usage: $0 [images.tar.gz]"
36+
echo "Error: No tarball provided and valid images directory not found."
37+
exit 1
38+
fi
2639

2740
k3s ctr images import images/appscode-charts-ace-installer-v2026.3.30.tar
2841
k3s ctr images import images/appscode-charts-ace-v2026.3.30.tar

catalog/sync-gcp-mp-images.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
set -x
17+
set -euxo pipefail
1818

19-
if [ -z "${IMAGE_REGISTRY}" ]; then
19+
if [ -z "${IMAGE_REGISTRY:-}" ]; then
2020
echo "IMAGE_REGISTRY is not set"
2121
exit 1
2222
fi
23-
if [ -z "${TAG}" ]; then
23+
if [ -z "${TAG:-}" ]; then
2424
echo "TAG is not set"
2525
exit 1
2626
fi

0 commit comments

Comments
 (0)