Skip to content

Commit cd761de

Browse files
committed
Replace image validity check with shell script
The script is more or less straight forward and saves us some go dependencies and a custom go build execution. Signed-off-by: Tom Wieczorek <[email protected]>
1 parent 39babe9 commit cd761de

File tree

6 files changed

+61
-134
lines changed

6 files changed

+61
-134
lines changed

.github/workflows/go.yml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,32 @@ jobs:
8585
target-os: linux
8686
target-arch: amd64
8787

88+
check-images:
89+
name: "Check :: Images"
90+
needs: [build-k0s]
91+
runs-on: ubuntu-latest
92+
93+
permissions:
94+
contents: read
95+
96+
steps:
97+
- name: "Workflow run :: Checkout"
98+
uses: actions/checkout@v4
99+
with:
100+
persist-credentials: false
101+
show-progress: false
102+
103+
- name: "Download :: Airgap image list"
104+
uses: actions/download-artifact@v4
105+
with:
106+
name: airgap-image-list-linux-amd64
107+
108+
- name: "Check :: Image validity"
109+
run: |
110+
mkdir -p embedded-bins/staging/linux/bin
111+
make --touch airgap-images.txt
112+
make check-image-validity
113+
88114
generate-sbom:
89115
name: "Build :: SBOM"
90116
needs: [build-k0s]
@@ -144,9 +170,6 @@ jobs:
144170
make --touch codegen
145171
make check-unit
146172
147-
- name: Validate OCI images manifests
148-
run: make check-image-validity
149-
150173
unittests-k0s-windows-amd64:
151174
name: "Unit tests :: windows-amd64"
152175
runs-on: windows-2022

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ check-unit: go.sum codegen
259259
CGO_CFLAGS='$(BUILD_CGO_CFLAGS)' $(GO) test -tags=hack $(GO_TEST_RACE) -ldflags='$(LD_FLAGS)' `$(GO) list -tags=hack $(GO_CHECK_UNIT_DIRS)`
260260

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

265265
.PHONY: clean-gocache
266266
clean-gocache:

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ require (
2121
github.com/containerd/cgroups/v3 v3.0.3
2222
github.com/containerd/containerd v1.7.8
2323
github.com/denisbrodbeck/machineid v1.0.1
24-
github.com/estesp/manifest-tool/v2 v2.1.3
2524
github.com/evanphx/json-patch v5.6.0+incompatible
2625
github.com/fsnotify/fsnotify v1.7.0
2726
github.com/go-logr/logr v1.4.1
@@ -38,7 +37,6 @@ require (
3837
github.com/mesosphere/toml-merge v0.2.0
3938
github.com/mitchellh/go-homedir v1.1.0
4039
github.com/olekukonko/tablewriter v0.0.5
41-
github.com/opencontainers/image-spec v1.1.0-rc5
4240
github.com/opencontainers/runtime-spec v1.1.0
4341
github.com/otiai10/copy v1.14.0
4442
github.com/pelletier/go-toml v1.9.5
@@ -213,6 +211,7 @@ require (
213211
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
214212
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
215213
github.com/opencontainers/go-digest v1.0.0 // indirect
214+
github.com/opencontainers/image-spec v1.1.0-rc5 // indirect
216215
github.com/opencontainers/runc v1.1.11 // indirect
217216
github.com/opencontainers/selinux v1.11.0 // indirect
218217
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
@@ -281,7 +280,6 @@ require (
281280
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
282281
k8s.io/metrics v0.29.0 // indirect
283282
oras.land/oras-go v1.2.4 // indirect
284-
oras.land/oras-go/v2 v2.2.1 // indirect
285283
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.28.0 // indirect
286284
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
287285
sigs.k8s.io/kustomize/api v0.13.5-0.20230601165947-6ce0bf390ce3 // indirect

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
180180
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
181181
github.com/envoyproxy/protoc-gen-validate v1.0.2 h1:QkIBuU5k+x7/QXPvPPnWXWlCdaBFApVqftFV6k087DA=
182182
github.com/envoyproxy/protoc-gen-validate v1.0.2/go.mod h1:GpiZQP3dDbg4JouG/NNS7QWXpgx6x8QiMKdmN72jogE=
183-
github.com/estesp/manifest-tool/v2 v2.1.3 h1:Xd0oxiwkXIcCYVdU4s7IZBIPYy5xbRJE2hzqQqb81EE=
184-
github.com/estesp/manifest-tool/v2 v2.1.3/go.mod h1:fVIu8tz5/04LXjFyE/LLd+uD8VFHXy38YFbCN4GrWHM=
185183
github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U=
186184
github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
187185
github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww=
@@ -971,8 +969,6 @@ k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSn
971969
k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
972970
oras.land/oras-go v1.2.4 h1:djpBY2/2Cs1PV87GSJlxv4voajVOMZxqqtq9AB8YNvY=
973971
oras.land/oras-go v1.2.4/go.mod h1:DYcGfb3YF1nKjcezfX2SNlDAeQFKSXmf+qrFmrh4324=
974-
oras.land/oras-go/v2 v2.2.1 h1:3VJTYqy5KfelEF9c2jo1MLSpr+TM3mX8K42wzZcd6qE=
975-
oras.land/oras-go/v2 v2.2.1/go.mod h1:GeAwLuC4G/JpNwkd+bSZ6SkDMGaaYglt6YK2WvZP7uQ=
976972
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.28.0 h1:TgtAeesdhpm2SGwkQasmbeqDo8th5wOBA5h/AjTKA4I=
977973
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.28.0/go.mod h1:VHVDI/KrK4fjnV61bE2g3sA7tiETLn8sooImelsCx3Y=
978974
sigs.k8s.io/controller-runtime v0.16.3 h1:2TuvuokmfXvDUamSx1SuAOO3eTyye+47mJCigwG62c4=

hack/validate-images.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env sh
2+
#shellcheck disable=SC3043
3+
4+
set -eu
5+
6+
check_platforms() {
7+
# shellcheck disable=SC2016
8+
local filter='
9+
$ARGS.positional - [.manifests[].platform | "\(.os)/\(.architecture)"]
10+
| if length == 0 then "ok" else "missing platforms: " + join(", ") end
11+
'
12+
docker manifest inspect -- "$image" | jq --args -r "$filter" -- "$@"
13+
}
14+
15+
ret=0
16+
while read -r image; do
17+
case "$image" in
18+
*/envoy-distroless:*) set -- linux/amd64 linux/arm64 ;;
19+
*) set -- linux/amd64 linux/arm64 linux/arm ;;
20+
esac
21+
22+
printf 'Checking image validity for %s ... ' "$image" >&2
23+
check=$(check_platforms "$@")
24+
if [ "$check" != "ok" ]; then
25+
ret=1
26+
printf '\033[31m%s\033[0m\n' "$check" >&2
27+
else
28+
printf '\033[32mok: %s\033[0m\n' "$*" >&2
29+
fi
30+
done
31+
32+
exit $ret

hack/validate-images/main.go

Lines changed: 0 additions & 122 deletions
This file was deleted.

0 commit comments

Comments
 (0)