@@ -39,6 +39,7 @@ E2E_DATA_DIR ?= $(REPO_ROOT)/test/e2e/data
39
39
E2E_CONF_PATH ?= $(E2E_DATA_DIR ) /e2e_conf.yaml
40
40
KUBETEST_CONF_PATH ?= $(abspath $(E2E_DATA_DIR ) /kubetest/conformance.yaml)
41
41
KUBETEST_FAST_CONF_PATH ?= $(abspath $(E2E_DATA_DIR ) /kubetest/conformance-fast.yaml)
42
+ GO_INSTALL := ./scripts/go_install.sh
42
43
43
44
# Binaries.
44
45
CONTROLLER_GEN := $(TOOLS_BIN_DIR ) /controller-gen
@@ -53,6 +54,17 @@ KUSTOMIZE := $(TOOLS_BIN_DIR)/kustomize
53
54
MOCKGEN := $(TOOLS_BIN_DIR ) /mockgen
54
55
RELEASE_NOTES := $(TOOLS_BIN_DIR ) /release-notes
55
56
57
+ # Setup-envtest
58
+ SETUP_ENVTEST_VER := v0.0.0-20211110210527-619e6b92dab9
59
+ SETUP_ENVTEST_BIN := setup-envtest
60
+ SETUP_ENVTEST := $(abspath $(TOOLS_BIN_DIR ) /$(SETUP_ENVTEST_BIN ) -$(SETUP_ENVTEST_VER ) )
61
+ SETUP_ENVTEST_PKG := sigs.k8s.io/controller-runtime/tools/setup-envtest
62
+
63
+ # Kubebuilder
64
+ export KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.23.3
65
+ export KUBEBUILDER_CONTROLPLANE_START_TIMEOUT ?= 60s
66
+ export KUBEBUILDER_CONTROLPLANE_STOP_TIMEOUT ?= 60s
67
+
56
68
PATH := $(abspath $(TOOLS_BIN_DIR ) ) :$(PATH )
57
69
export PATH
58
70
export DOCKER_CLI_EXPERIMENTAL =enabled
@@ -116,9 +128,15 @@ E2E_ARGS ?=
116
128
$(ARTIFACTS ) :
117
129
mkdir -p $@
118
130
131
+ ifeq ($(shell go env GOOS) ,darwin) # Use the darwin/amd64 binary until an arm64 version is available
132
+ KUBEBUILDER_ASSETS ?= $(shell $(SETUP_ENVTEST ) use --use-env -p path --arch amd64 $(KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ) )
133
+ else
134
+ KUBEBUILDER_ASSETS ?= $(shell $(SETUP_ENVTEST ) use --use-env -p path $(KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ) )
135
+ endif
136
+
119
137
.PHONY : test
120
- test : # # Run tests
121
- go test -v ./...
138
+ test : $( SETUP_ENVTEST ) # # Run tests
139
+ KUBEBUILDER_ASSETS= " $( KUBEBUILDER_ASSETS ) " go test -v ./... $( TEST_ARGS )
122
140
123
141
# Can be run manually, e.g. via:
124
142
# export OPENSTACK_CLOUD_YAML_FILE="$(pwd)/clouds.yaml"
@@ -167,6 +185,12 @@ managers:
167
185
manager-openstack-infrastructure : # # Build manager binary.
168
186
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags " ${LDFLAGS} -extldflags '-static'" -o $(BIN_DIR ) /manager .
169
187
188
+ $(SETUP_ENVTEST ) : # Build setup-envtest from tools folder.
189
+ GOBIN=$(abspath $(TOOLS_BIN_DIR ) ) $(GO_INSTALL ) $(SETUP_ENVTEST_PKG ) $(SETUP_ENVTEST_BIN ) $(SETUP_ENVTEST_VER )
190
+
191
+ .PHONY : $(SETUP_ENVTEST_BIN )
192
+ $(SETUP_ENVTEST_BIN ) : $(SETUP_ENVTEST ) # # Build a local copy of setup-envtest.
193
+
170
194
# # --------------------------------------
171
195
# # Linting
172
196
# # --------------------------------------
0 commit comments