@@ -27,21 +27,18 @@ endif
2727# #########################################
2828
2929images := $(images_$(HOST_ARCH ) )
30- images_files := $(foreach image,$(images ) ,$(subst :,+,$(image ) ) )
3130
3231images_tar_dir := $(bin_dir ) /downloaded/containers/$(HOST_ARCH )
33- images_tars := $(images_files:%= $( images_tar_dir ) /% .tar )
32+ images_tars := $(foreach image, $( images ) , $( images_tar_dir ) /$( subst :,+, $( image ) ) .tar)
3433
3534# Download the images as tarballs. After downloading the image using
36- # its digest, we untar the image and modify the .[0].RepoTags[0] value in
35+ # its digest, we use image-tool to modify the .[0].RepoTags[0] value in
3736# the manifest.json file to have the correct tag (instead of "i-was-a-digest"
3837# which is set when the image is pulled using its digest). This tag is used
3938# to reference the image after it has been imported using docker or kind. Otherwise,
4039# the image would be imported with the tag "i-was-a-digest" which is not very useful.
4140# We would have to use digests to reference the image everywhere which might
4241# not always be possible and does not match the default behavior of eg. our helm charts.
43- # Untarring and modifying manifest.json is a hack and we hope that crane adds an option
44- # in the future that allows setting the tag on images that are pulled by digest.
4542# NOTE: the tag is fully determined based on the input, we fully allow the remote
4643# tag to point to a different digest. This prevents CI from breaking due to upstream
4744# changes. However, it also means that we can incorrectly combine digests with tags,
@@ -55,17 +52,18 @@ $(images_tars): $(images_tar_dir)/%.tar: | $(NEEDS_IMAGE-TOOL) $(NEEDS_CRANE) $(
5552 $(CRANE ) pull " $( bare_image) @$( digest) " $@ --platform=linux/$(HOST_ARCH )
5653 $(IMAGE-TOOL ) tag-docker-tar $@ " $( bare_image) :$( tag) "
5754
58- images_tar_envs := $(images_files:%=env-% )
55+ # $1 = image
56+ # $2 = image:tag@sha256:digest
57+ define image_variables
58+ $1.TAR := $(images_tar_dir ) /$(subst :,+,$2) .tar
59+ $1.REPO := $1
60+ $1.TAG := $(word 2,$(subst :, ,$(word 1,$(subst @, ,$2) ) ) )
61+ $1.FULL := $(word 1,$(subst @, ,$2) )
62+ endef
5963
60- .PHONY : $(images_tar_envs )
61- $(images_tar_envs ) : env-% : $(images_tar_dir ) /% .tar | $(NEEDS_GOJQ )
62- @$(eval image_without_tag=$(shell cut -d+ -f1 <<<"$* ") )
63- @$(eval $(image_without_tag ) .TAR="$(images_tar_dir ) /$* .tar")
64- @$(eval $(image_without_tag ) .REPO=$(shell tar xfO "$(images_tar_dir ) /$* .tar" manifest.json | $(GOJQ ) '.[0].RepoTags[0]' -r | cut -d: -f1) )
65- @$(eval $(image_without_tag ) .TAG=$(shell tar xfO "$(images_tar_dir ) /$* .tar" manifest.json | $(GOJQ ) '.[0].RepoTags[0]' -r | cut -d: -f2) )
66- @$(eval $(image_without_tag ) .FULL=$($(image_without_tag ) .REPO) :$($(image_without_tag ) .TAG) )
64+ $(foreach image,$(images ) ,$(eval $(call image_variables,$(word 1,$(subst :, ,$(image ) )),$(image ) )))
6765
6866.PHONY : images-preload
6967# # Preload images.
7068# # @category [shared] Kind cluster
71- images-preload : | $(images_tar_envs )
69+ images-preload : | $(images_tars )
0 commit comments