@@ -18,10 +18,21 @@ DOCKER_SBOM_PLUGIN_VERSION=0.6.1
1818# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
1919VERSION_FILE =version.json
2020CURRENT_VERSION := $(shell $(JQ ) -r .current $(VERSION_FILE ) )
21+ NEXT_VERSION := $(shell $(JQ ) -r .next $(VERSION_FILE ) )
2122VERSION ?= $(shell git describe --always --tags --dirty --broken | cut -c 2-)
2223BUILDTIME ?= $(shell date -u +"% Y-% m-% dT% H:% M:% SZ")
2324GITCOMMIT ?= $(shell git rev-parse --short HEAD 2> /dev/null || true)
2425
26+ # Fix for e2e-gov tests not to use a bad semver version instead
27+ ifdef USE_NEXT_VERSION
28+ VERSION =$(NEXT_VERSION )
29+ endif
30+
31+ # Fix for e2e2 all-in-one test so that it uses an image that already exists in pre-release
32+ ifdef USE_CURRENT_VERSION
33+ VERSION =$(CURRENT_VERSION )
34+ endif
35+
2536VERSION_PACKAGE = github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/version
2637
2738# LD_FLAGS
@@ -32,13 +43,6 @@ ifdef EXPERIMENTAL
3243LD_FLAGS += -X $(VERSION_PACKAGE ) .Experimental=$(EXPERIMENTAL )
3344endif
3445
35- # NEXT_VERSION represents a version that is higher than anything released
36- # VERSION default value does not play well with the run target which might end up failing
37- # with errors such as:
38- # "version of the resource $Resource is higher than the operator version $VERSION"
39- # This happens if you use exported YAMLs from CLI and the dirty version is deemed a pre-release
40- NEXT_VERSION = 99.99.99-next
41-
4246# CHANNELS define the bundle channels used in the bundle.
4347# Add a new line here if you would like to change its default config. (E.g CHANNELS = "preview,fast,stable")
4448# To re-generate a bundle for other specific channels without changing the standard setup, you can:
@@ -188,6 +192,18 @@ SBOMS_DIR ?= template
188192
189193SHELLCHECK_OPTIONS ?= -e SC2086
190194
195+ TEST_REGISTRY ?= localhost:5000
196+ DEFAULT_IMAGE_URL := $(TEST_REGISTRY ) /mongodb-atlas-kubernetes-operator:$(NEXT_VERSION ) -test
197+ export IMAGE_URL
198+
199+ ifndef IMAGE_URL
200+ IMAGE_URL := $(DEFAULT_IMAGE_URL )
201+ BUILD_DEPENDENCY := test-docker-image
202+ else
203+ $(info --- IMAGE_URL is set externally : $(IMAGE_URL ) )
204+ BUILD_DEPENDENCY :=
205+ endif
206+
191207.DEFAULT_GOAL := help
192208.PHONY : help
193209help : # # Show this help screen
@@ -246,11 +262,11 @@ envtest-assets:
246262 mkdir -p $(ENVTEST_ASSETS_DIR )
247263
248264.PHONY : e2e
249- e2e : bundle manifests run-kind # # Run e2e test. Command `make e2e label=cluster-ns` run cluster-ns test
265+ e2e : bundle manifests run-kind install-crds $( BUILD_DEPENDENCY ) # # Run e2e test. Command `make e2e label=cluster-ns` run cluster-ns test
250266 AKO_E2E_TEST=1 $(GINKGO ) $(shell pwd) /test/$@
251267
252268.PHONY : e2e2
253- e2e2 : run-kind manager install-credentials install-crds set-namespace # # Run e2e2 tests. Command `make e2e2 label=integrations-ctlr` run integrations-ctlr e2e2 test
269+ e2e2 : bundle run-kind manager install-credentials install-crds set-namespace # # Run e2e2 tests. Command `make e2e2 label=integrations-ctlr` run integrations-ctlr e2e2 test
254270 NO_GORUN=1 \
255271 AKO_E2E2_TEST=1 \
256272 OPERATOR_NAMESPACE=$(OPERATOR_NAMESPACE ) \
@@ -485,8 +501,21 @@ all-platforms:
485501
486502.PHONY : all-platforms-docker
487503all-platforms-docker : all-platforms
488- docker build --build-arg BINARY_PATH=bin/linux/amd64 -f fast.Dockerfile -t manager-amd64 .
489- docker build --build-arg BINARY_PATH=bin/linux/arm64 -f fast.Dockerfile -t manager-arm64 .
504+ docker build --build-arg TARGETOS=linux --build-arg TARGETARCH=amd64 \
505+ -f fast.Dockerfile -t manager-amd64 .
506+ docker build --build-arg TARGETOS=linux --build-arg TARGETARCH=arm64 \
507+ -f fast.Dockerfile -t manager-arm64 .
508+
509+ # docker-image builds the test image always for linux, even on MacOS.
510+ # This is because the Kubernetes cluster is always run within a Linux VM
511+ .PHONY : docker-image
512+ docker-image : all-platforms
513+ docker build --build-arg TARGETOS=linux --build-arg TARGETARCH=$(TARGET_ARCH ) \
514+ -f fast.Dockerfile -t $(DEFAULT_IMAGE_URL ) .
515+
516+ .PHONY : test-docker-image
517+ test-docker-image : docker-image run-kind
518+ docker push $(DEFAULT_IMAGE_URL )
490519
491520.PHONY : check-major-version
492521check-major-version : # # Check that VERSION starts with MAJOR_VERSION
0 commit comments