From 1c764cf224ddc74978cbae590088fc1e4cb452ac Mon Sep 17 00:00:00 2001 From: Tom Wieczorek Date: Fri, 13 Dec 2024 15:54:51 +0100 Subject: [PATCH] Replace image-bundler with k0s airgap bundle-artifacts Dog-food the new sub-command in the k0s build itself. Signed-off-by: Tom Wieczorek --- .../workflows/build-airgap-image-bundle.yml | 2 +- .github/workflows/go.yml | 2 +- Makefile | 15 ++------ cmd/airgap/testdata/.gitattributes | 1 + hack/image-bundler/Dockerfile | 6 --- hack/image-bundler/bundler.sh | 37 ------------------- 6 files changed, 6 insertions(+), 57 deletions(-) create mode 100644 cmd/airgap/testdata/.gitattributes delete mode 100644 hack/image-bundler/Dockerfile delete mode 100755 hack/image-bundler/bundler.sh diff --git a/.github/workflows/build-airgap-image-bundle.yml b/.github/workflows/build-airgap-image-bundle.yml index 72469322450f..0c4c3e9a0750 100644 --- a/.github/workflows/build-airgap-image-bundle.yml +++ b/.github/workflows/build-airgap-image-bundle.yml @@ -44,7 +44,7 @@ jobs: - name: "Cache :: Airgap image bundle :: Calculate cache key" id: cache-airgap-image-bundle-calc-key env: - HASH_VALUE: ${{ hashFiles('Makefile', 'airgap-images.txt', 'hack/image-bundler/*') }} + HASH_VALUE: ${{ hashFiles('Makefile', 'airgap-images.txt', 'cmd/airgap/*', 'pkg/airgap/*') }} run: | printf 'cache-key=build-airgap-image-bundle-%s-%s-%s\n' "$TARGET_OS" "$TARGET_ARCH" "$HASH_VALUE" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 7f270e62c472..554c8a05f360 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -322,7 +322,7 @@ jobs: id: cache-airgap-image-bundle uses: actions/cache@v4 with: - key: airgap-image-bundle-linux-${{ matrix.arch }}-${{ hashFiles('Makefile', 'airgap-images.txt', 'hack/image-bundler/*') }} + key: airgap-image-bundle-linux-${{ matrix.arch }}-${{ hashFiles('Makefile', 'airgap-images.txt', 'cmd/airgap/*', 'pkg/airgap/*') }} path: | airgap-images.txt airgap-image-bundle-linux-${{ matrix.arch }}.tar diff --git a/Makefile b/Makefile index 5c2825e6df47..9ab3eab2ab93 100644 --- a/Makefile +++ b/Makefile @@ -222,7 +222,7 @@ lint-go: .k0sbuild.docker-image.k0s go.sum bindata .PHONY: lint lint: lint-copyright lint-go -airgap-images.txt: k0s .k0sbuild.docker-image.k0s +airgap-images.txt: build .k0sbuild.docker-image.k0s $(GO_ENV) ./k0s airgap list-images --all > '$@' airgap-image-bundle-linux-amd64.tar: TARGET_PLATFORM := linux/amd64 @@ -230,15 +230,8 @@ airgap-image-bundle-linux-arm64.tar: TARGET_PLATFORM := linux/arm64 airgap-image-bundle-linux-arm.tar: TARGET_PLATFORM := linux/arm/v7 airgap-image-bundle-linux-amd64.tar \ airgap-image-bundle-linux-arm64.tar \ -airgap-image-bundle-linux-arm.tar: .k0sbuild.image-bundler.stamp airgap-images.txt - docker run --rm -i --privileged \ - -e TARGET_PLATFORM='$(TARGET_PLATFORM)' \ - '$(shell cat .k0sbuild.image-bundler.stamp)' < airgap-images.txt > '$@' - -.k0sbuild.image-bundler.stamp: hack/image-bundler/* embedded-bins/Makefile.variables - docker build --progress=plain --iidfile '$@' \ - --build-arg ALPINE_VERSION=$(alpine_patch_version) \ - -t k0sbuild.image-bundler -- hack/image-bundler +airgap-image-bundle-linux-arm.tar: build airgap-images.txt + ./k0s airgap -v bundle-images -o '$@' from-file airgap-images.txt .PHONY: $(smoketests) check-airgap check-ap-airgap: airgap-image-bundle-linux-$(HOST_ARCH).tar @@ -269,9 +262,7 @@ clean-docker-image: $(clean-iid-files) .PHONY: clean-airgap-image-bundles -clean-airgap-image-bundles: IID_FILES = .k0sbuild.image-bundler.stamp clean-airgap-image-bundles: - $(clean-iid-files) -rm airgap-images.txt -rm airgap-image-bundle-linux-amd64.tar airgap-image-bundle-linux-arm64.tar airgap-image-bundle-linux-arm.tar diff --git a/cmd/airgap/testdata/.gitattributes b/cmd/airgap/testdata/.gitattributes new file mode 100644 index 000000000000..43ddf5eee318 --- /dev/null +++ b/cmd/airgap/testdata/.gitattributes @@ -0,0 +1 @@ +oci-layout/blobs/** binary diff --git a/hack/image-bundler/Dockerfile b/hack/image-bundler/Dockerfile deleted file mode 100644 index f9dbdf7b1f8d..000000000000 --- a/hack/image-bundler/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -ARG ALPINE_VERSION -FROM docker.io/library/alpine:$ALPINE_VERSION - -RUN apk add --no-cache containerd containerd-ctr -COPY bundler.sh / -CMD /bundler.sh diff --git a/hack/image-bundler/bundler.sh b/hack/image-bundler/bundler.sh deleted file mode 100755 index 7e637b769ec3..000000000000 --- a/hack/image-bundler/bundler.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env sh - -set -eu - -containerd &2 & -#shellcheck disable=SC2064 -trap "{ kill -- $! && wait -- $!; } || true" INT EXIT - -while ! ctr version /dev/null; do - kill -0 $! - echo containerd not yet available >&2 - sleep 1 -done - -echo containerd up >&2 - -set -- - -while read -r image; do - echo Fetching content of "$image" ... >&2 - out="$(ctr content fetch --platform "$TARGET_PLATFORM" -- "$image")" || { - code=$? - echo "$out" >&2 - exit $code - } - - set -- "$@" "$image" -done - -[ -n "$*" ] || { - echo No images provided via STDIN! >&2 - exit 1 -} - -echo Exporting images ... >&2 -ctr images export --platform "$TARGET_PLATFORM" -- - "$@" -echo Images exported. >&2