Skip to content

Commit

Permalink
Replace imagte validity check with shell script
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Wieczorek <[email protected]>
  • Loading branch information
twz123 committed Jan 8, 2024
1 parent 39babe9 commit aa4e062
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
20 changes: 17 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,23 @@ jobs:
target-os: linux
target-arch: amd64

check-images:
name: "Check :: Images"
needs: [build-k0s]
runs-on: ubuntu-latest

steps:
- name: "Download :: Airgap image list"
uses: actions/download-artifact@v4
with:
name: airgap-image-list-linux-amd64

- name: "Check :: Image validity"
run: |
#mkdir -p "embedded-bins/staging/$TARGET_OS/bin"
make --touch airgap-images.txt
make check-image-validity
generate-sbom:
name: "Build :: SBOM"
needs: [build-k0s]
Expand Down Expand Up @@ -144,9 +161,6 @@ jobs:
make --touch codegen
make check-unit
- name: Validate OCI images manifests
run: make check-image-validity

unittests-k0s-windows-amd64:
name: "Unit tests :: windows-amd64"
runs-on: windows-2022
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ check-unit: go.sum codegen
CGO_CFLAGS='$(BUILD_CGO_CFLAGS)' $(GO) test -tags=hack $(GO_TEST_RACE) -ldflags='$(LD_FLAGS)' `$(GO) list -tags=hack $(GO_CHECK_UNIT_DIRS)`

.PHONY: check-image-validity
check-image-validity: go.sum
$(GO) run -tags=hack hack/validate-images/main.go -architectures amd64,arm64,arm
check-image-validity: go.sum airgap-images.txt
hack/vaildate-images.sh <airgap-images.txt

.PHONY: clean-gocache
clean-gocache:
Expand Down
29 changes: 29 additions & 0 deletions hack/validate-images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env sh
#shellcheck disable=SC3040,SC3043

set -euo pipefail

missing_platforms() {
# shellcheck disable=SC2016
local filter='$ARGS.positional - [.manifests[].platform | "\(.os)/\(.architecture)"] | join(", ")'
docker manifest inspect -- "$image" | jq --args -r "$filter" -- "$@"
}

ret=0
while read -r image; do
case "$image" in
*/envoy-distroless:*) set -- linux/amd64 linux/arm64 ;;
*) set -- linux/amd64 linux/arm64 linux/arm ;;
esac

printf 'Checking image validity for %s ... ' "$image" >&2
mp=$(missing_platforms "$@")
if [ -n "$mp" ]; then
ret=1
printf '\033[31mmissing platforms: %s\033[0m\n' "$mp" >&2
else
printf '\033[32mok: %s\033[0m\n' "$*" >&2
fi
done

exit $ret

0 comments on commit aa4e062

Please sign in to comment.