diff --git a/.gitignore b/.gitignore index b5dfa49..304f7f9 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,7 @@ vendor # Test reports report/ + Makefile.common* +.go-pkg-cache + diff --git a/Makefile b/Makefile index 9315edc..21f3ff9 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ PACKAGE_NAME?=github.com/projectcalico/pod2daemon -GO_BUILD_VER?=v0.50 +GO_BUILD_VER?=v0.51 +ORGANIZATION=projectcalico SEMAPHORE_PROJECT_ID?=$(SEMAPHORE_POD2DAEMON_PROJECT_ID) # Used so semaphore can trigger the update pin pipelines in projects that have this project as a dependency. @@ -79,76 +80,6 @@ ifeq ($(ARCH),amd64) endif touch $@ -############################################################################### -# Image build/push -############################################################################### -# we want to be able to run the same recipe on multiple targets keyed on the image name -# to do that, we would use the entire image name, e.g. calico/node:abcdefg, as the stem, or '%', in the target -# however, make does **not** allow the usage of invalid filename characters - like / and : - in a stem, and thus errors out -# to get around that, we "escape" those characters by converting all : to --- and all / to ___ , so that we can use them -# in the target, we then unescape them back -escapefs = $(subst :,---,$(subst /,___,$(1))) -unescapefs = $(subst ---,:,$(subst ___,/,$(1))) - -# these macros create a list of valid architectures for pushing manifests -space := -space += -comma := , -prefix_linux = $(addprefix linux/,$(strip $1)) -join_platforms = $(subst $(space),$(comma),$(call prefix_linux,$(strip $1))) - -imagetag: -ifndef IMAGETAG - $(error IMAGETAG is undefined - run using make IMAGETAG=X.Y.Z) -endif - -## push one arch -push: imagetag $(addprefix sub-single-push-,$(call escapefs,$(PUSH_IMAGES))) - -sub-single-push-%: - docker push $(call unescapefs,$*:$(IMAGETAG)-$(ARCH)) - -## push all arches -push-all: imagetag $(addprefix sub-push-,$(VALIDARCHES)) -sub-push-%: - $(MAKE) push ARCH=$* IMAGETAG=$(IMAGETAG) - -## push multi-arch manifest where supported -push-manifests: imagetag $(addprefix sub-manifest-,$(call escapefs,$(PUSH_MANIFEST_IMAGES))) -sub-manifest-%: - # Docker login to hub.docker.com required before running this target as we are using - # $(DOCKER_CONFIG) holds the docker login credentials path to credentials based on - # manifest-tool's requirements here https://github.com/estesp/manifest-tool#sample-usage - docker run -t --entrypoint /bin/sh -v $(DOCKER_CONFIG):/root/.docker/config.json $(CALICO_BUILD) -c "/usr/bin/manifest-tool push from-args --platforms $(call join_platforms,$(VALIDARCHES)) --template $(call unescapefs,$*:$(IMAGETAG))-ARCH --target $(call unescapefs,$*:$(IMAGETAG))" - - ## push default amd64 arch where multi-arch manifest is not supported -push-non-manifests: imagetag $(addprefix sub-non-manifest-,$(call escapefs,$(PUSH_NONMANIFEST_IMAGES))) -sub-non-manifest-%: -ifeq ($(ARCH),amd64) - docker push $(call unescapefs,$*:$(IMAGETAG)) -else - $(NOECHO) $(NOOP) -endif - -## tag images of one arch for all supported registries -tag-images: imagetag $(addprefix sub-single-tag-images-arch-,$(call escapefs,$(PUSH_IMAGES))) $(addprefix sub-single-tag-images-non-manifest-,$(call escapefs,$(PUSH_NONMANIFEST_IMAGES))) - -sub-single-tag-images-arch-%: - docker tag $(BUILD_IMAGE):latest-$(ARCH) $(call unescapefs,$*:$(IMAGETAG)-$(ARCH)) - -# because some still do not support multi-arch manifest -sub-single-tag-images-non-manifest-%: -ifeq ($(ARCH),amd64) - docker tag $(BUILD_IMAGE):latest-$(ARCH) $(call unescapefs,$*:$(IMAGETAG)) -else - $(NOECHO) $(NOOP) -endif - -## tag images of all archs -tag-images-all: imagetag $(addprefix sub-tag-images-,$(VALIDARCHES)) -sub-tag-images-%: - $(MAKE) tag-images ARCH=$* IMAGETAG=$(IMAGETAG) - ############################################################################### # UTs ############################################################################### @@ -172,15 +103,7 @@ ci: clean mod-download build-all static-checks ut ############################################################################### .PHONY: cd ## Deploys images to registry -cd: image-all -ifndef CONFIRM - $(error CONFIRM is undefined - run using make CONFIRM=true) -endif -ifndef BRANCH_NAME - $(error BRANCH_NAME is undefined - run using make BRANCH_NAME=var or set an environment variable) -endif - $(MAKE) tag-images-all push-all push-manifests push-non-manifests IMAGETAG=${BRANCH_NAME} EXCLUDEARCH="$(EXCLUDEARCH)" - $(MAKE) tag-images-all push-all push-manifests push-non-manifests IMAGETAG=$(shell git describe --tags --dirty --always --long --abbrev=12) EXCLUDEARCH="$(EXCLUDEARCH)" +cd: cd-common ############################################################################### # Release