11ALL_ARCH = amd64 arm64 s390x
22all : $(addprefix build-arch-,$(ALL_ARCH ) )
33
4+ # TODO: #8127 - Use default analyzers set by `go test` to include `printf` analyzer.
5+ # Default analyzers that go test runs according to https://github.com/golang/go/blob/52624e533fe52329da5ba6ebb9c37712048168e0/src/cmd/go/internal/test/test.go#L649
6+ # This doesn't include the `printf` analyzer until cluster-autoscaler libraries are updated.
7+ GO_TEST_DEFAULT_ANALYZERS? =atomic,bool,buildtags,directive,errorsas,ifaceassert,nilfunc,slog,stringintconv,tests
48TAG? =dev
59FLAGS =
610LDFLAGS? =-s
711ENVVAR=CGO_ENABLED =0
812GOOS? =linux
913GOARCH? =$(shell go env GOARCH)
10- REGISTRY? =staging-k8s. gcr.io
14+ REGISTRY? =gcr.io/k8s-staging-autoscaling
1115DOCKER_NETWORK? =default
1216SUPPORTED_BUILD_TAGS =$(shell ls cloudprovider/builder/ | grep -e '^builder_.* \.go' | sed 's/builder_\(.* \) \.go/\1/')
1317ifdef BUILD_TAGS
2024 FOR_PROVIDER =
2125endif
2226ifdef LDFLAGS
23- LDFLAGS_FLAG =--ldflags "${LDFLAGS}"
27+ LDFLAGS_FLAG=--ldflags = "${LDFLAGS}"
2428else
2529 LDFLAGS_FLAG =
2630endif
@@ -38,8 +42,6 @@ IMAGE=$(REGISTRY)/cluster-autoscaler$(PROVIDER)
3842export DOCKER_CLI_EXPERIMENTAL := enabled
3943
4044build :
41- @echo " ⚠️ WARNING: The vendor directory will be removed soon. \
42- Please make sure your dependencies are managed via Go modules."
4345 @$(MAKE ) build-arch-$(GOARCH )
4446
4547build-arch-% : clean-arch-%
@@ -56,7 +58,7 @@ test-build-tags:
5658 done
5759
5860test-unit : clean build
59- go test --test.short -race ./... ${TAGS_FLAG}
61+ go test --test.short -race ./... -vet= " ${GO_TEST_DEFAULT_ANALYZERS} " ${TAGS_FLAG}
6062
6163dev-release : dev-release-arch-$(GOARCH )
6264
@@ -66,28 +68,27 @@ dev-release-arch-%: build-arch-% make-image-arch-% push-image-arch-%
6668make-image : make-image-arch-$(GOARCH )
6769
6870make-image-arch-% :
69- ifdef BASEIMAGE
70- docker build --pull --build-arg BASEIMAGE=${BASEIMAGE} \
71+ GOOS=$(GOOS ) docker buildx build --pull --platform linux/$* \
72+ --build-arg " GOARCH=$* " \
73+ --provenance=false \
7174 -t ${IMAGE} -$* :${TAG} \
72- -f Dockerfile.$* .
73- else
74- docker build --pull \
75- -t ${IMAGE}-$*:${TAG} \
76- -f Dockerfile.$* .
77- endif
75+ -f Dockerfile .
7876 @echo " Image ${TAG}${FOR_PROVIDER} -$* completed"
7977
8078push-image : push-image-arch-$(GOARCH )
8179
8280push-image-arch-% :
8381 ./push_image.sh ${IMAGE} -$* :${TAG}
8482
83+ push-release-image-arch-% :
84+ docker push ${IMAGE} -$* :${TAG}
85+
8586push-manifest :
8687 docker manifest create ${IMAGE} :${TAG} \
8788 $(addprefix $(REGISTRY ) /cluster-autoscaler$(PROVIDER ) -, $(addsuffix :$(TAG ) , $(ALL_ARCH ) ) )
8889 docker manifest push --purge ${IMAGE} :${TAG}
8990
90- execute-release : $(addprefix make-image-arch-,$(ALL_ARCH ) ) $(addprefix push-image-arch-,$(ALL_ARCH ) ) push-manifest
91+ execute-release : $(addprefix make-image-arch-,$(ALL_ARCH ) ) $(addprefix push-release- image-arch-,$(ALL_ARCH ) ) push-manifest
9192 @echo " Release ${TAG}${FOR_PROVIDER} completed"
9293
9394clean : clean-arch-$(GOARCH )
@@ -133,7 +134,7 @@ container-arch-%: build-in-docker-arch-% make-image-arch-%
133134 @echo " Full in-docker image ${TAG}${FOR_PROVIDER} -$* completed"
134135
135136test-in-docker : clean docker-builder
136- docker run ${RM_FLAG} -v ` pwd` :/cluster-autoscaler/:Z autoscaling-builder:latest bash -c ' cd /cluster-autoscaler && go test -race ./... ${TAGS_FLAG}'
137+ docker run ${RM_FLAG} -v ` pwd` :/cluster-autoscaler/:Z autoscaling-builder:latest bash -c ' cd /cluster-autoscaler && go test -race ./... -vet="${GO_TEST_DEFAULT_ANALYZERS}" ${TAGS_FLAG}'
137138
138139.PHONY : all build test-unit clean format execute-release dev-release docker-builder build-in-docker release generate push-image push-manifest
139140
0 commit comments