From 3eecb2d7f9120a51bb2bfc2507e8be334e3279ad Mon Sep 17 00:00:00 2001 From: Brian McMahon Date: Fri, 9 Apr 2021 15:53:26 -0700 Subject: [PATCH] Clean up Makefile Add ORGANIZATION env variable, remove duplicate targets / macros that exist in update common Makefile --- Makefile | 82 +++----------------------------------------------------- 1 file changed, 3 insertions(+), 79 deletions(-) diff --git a/Makefile b/Makefile index 630d55e176..51990f748e 100644 --- a/Makefile +++ b/Makefile @@ -28,8 +28,9 @@ # ############################################################################### PACKAGE_NAME?=github.com/projectcalico/felix -GO_BUILD_VER?=v0.49 +GO_BUILD_VER?=v0.51 +ORGANIZATION=projectcalico SEMAPHORE_PROJECT_ID?=$(SEMAPHORE_FELIX_PROJECT_ID) SEMAPHORE_AUTO_PIN_UPDATE_PROJECT_IDS=$(SEMAPHORE_NODE_PROJECT_ID) $(SEMAPHORE_KUBE_CONTROLLER_PROJECT_ID) @@ -281,75 +282,6 @@ ifeq ($(ARCH),amd64) docker tag $(BUILD_IMAGE)-wgtool:latest-$(ARCH) $(BUILD_IMAGE)-wgtool:latest endif -############################################################################### -# 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) ############################################################################### # Static checks @@ -566,15 +498,7 @@ ifeq (,$(filter k8sfv-test, $(EXCEPT))) endif ## Deploy images to registry -cd: -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) EXCLUDEARCH="$(EXCLUDEARCH)" +cd: cd-common ############################################################################### # Release