Skip to content

Commit be79481

Browse files
avagingvisor-bot
authored andcommitted
images: use the crane tool to detect whether the remote image exists
It worls with all registries and doesn't require any specific permissions. PiperOrigin-RevId: 613728858
1 parent d8d2285 commit be79481

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

.buildkite/pipeline.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,13 @@ steps:
215215
- <<: *common
216216
label: ":docker: Images (x86_64)"
217217
if: build.env("SKIP_LOADING_IMAGES") == null && build.env("STAGED_BINARIES") == null
218-
command: make ARCH=x86_64 -j 8 load-all-test-images
218+
command: make ARCH=x86_64 test-all-test-images
219219
agents:
220220
arch: "amd64"
221221
- <<: *common
222222
label: ":docker: Images (aarch64)"
223223
if: build.env("SKIP_LOADING_IMAGES") == null && build.env("STAGED_BINARIES") == null
224-
command: make ARCH=aarch64 -j 8 load-all-test-images
224+
command: make ARCH=aarch64 test-all-test-images
225225
agents:
226226
arch: "arm64"
227227

tools/images.mk

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ load-all-test-images: ## Load all test images.
7474
load-all-test-images: $(patsubst %,load-%,$(TEST_IMAGES))
7575
.PHONY: load-all-test-images
7676

77+
test-all-test-images: ## Test all test images.
78+
test-all-test-images: $(patsubst %,test-%,$(TEST_IMAGES))
79+
.PHONY: test-all-test-images
80+
7781
push-all-images: ## Push all images.
7882
push-all-images: $(patsubst %,push-%,$(ALL_IMAGES))
7983
.PHONY: push-all-images
@@ -129,10 +133,13 @@ tag-%: ## Tag a local image.
129133
@$(call header,TAG $*)
130134
@$(call local_tag,$*) && $(call latest_tag,$*)
131135

136+
image_manifest = \
137+
docker run --rm gcr.io/go-containerregistry/crane manifest $(call remote_image,$(1)):$(call tag,$(1))
138+
132139
# pull forces the image to be pulled.
133140
pull = \
134141
$(call header,PULL $(1)) && \
135-
docker pull -q $(DOCKER_PLATFORM_ARGS) $(call remote_image,$(1)):$(call tag,$(1)) >&2 && \
142+
docker pull $(DOCKER_PLATFORM_ARGS) $(call remote_image,$(1)):$(call tag,$(1)) >&2 && \
136143
$(call local_tag,$(1)) && \
137144
$(call latest_tag,$(1))
138145
pull-%: register-cross ## Force a repull of the image.
@@ -163,11 +170,14 @@ rebuild-%: register-cross ## Force rebuild an image locally.
163170
load-%: register-cross ## Pull or build an image locally.
164171
@($(call pull,$*)) || ($(call rebuild,$*))
165172

173+
test-%: register-cross ## Build an image locally if the remote doesn't exist.
174+
@($(call image_manifest,$*)) >&2 || ($(call rebuild,$*))
175+
166176
# push pushes the remote image, after validating that the tag doesn't exist
167177
# yet. Note that this generic rule will match the fully-expanded remote image
168178
# tag.
169179
push-%:
170-
gcloud artifacts docker images describe $(call remote_image,$*):$(call tag,$*) >&2 || \
180+
$(call image_manifest,$*) >&2 || \
171181
( $(call rebuild,$*) && docker image push $(call remote_image,$*):$(call tag,$*) >&2 )
172182

173183
# register-cross registers the necessary qemu binaries for cross-compilation.

0 commit comments

Comments
 (0)