From 0ee98cf06b8c3d24c383f4ab7d64f13c0ac5700d Mon Sep 17 00:00:00 2001 From: Tom Wieczorek Date: Fri, 13 Dec 2024 18:24:44 +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 | 8 +++- .github/workflows/go.yml | 2 +- Makefile | 13 +------ cmd/airgap/testdata/.gitattributes | 1 + hack/image-bundler/Dockerfile | 6 --- hack/image-bundler/bundler.sh | 37 ------------------- 6 files changed, 11 insertions(+), 56 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..31ea41ac3548 100644 --- a/.github/workflows/build-airgap-image-bundle.yml +++ b/.github/workflows/build-airgap-image-bundle.yml @@ -33,6 +33,11 @@ jobs: with: persist-credentials: false + - name: "Download :: k0s" + uses: actions/download-artifact@v4 + with: + name: k0s-linux-amd64 + - name: "Download :: Airgap image list" uses: actions/download-artifact@v4 with: @@ -44,7 +49,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" @@ -58,6 +63,7 @@ jobs: - name: "Build :: Airgap image bundle" if: steps.cache-airgap-image-bundle.outputs.cache-hit != 'true' run: | + chmod +x k0s mkdir -p "embedded-bins/staging/$TARGET_OS/bin" make --touch airgap-images.txt make "airgap-image-bundle-$TARGET_OS-$TARGET_ARCH.tar" 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..7c2e29b865a5 100644 --- a/Makefile +++ b/Makefile @@ -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: k0s airgap-images.txt + ./k0s airgap -v bundle-artifacts --platform='$(TARGET_PLATFORM)' -o '$@' &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