Skip to content

Commit eff9d85

Browse files
committed
Use bin-dir override on setup_envtest
Rather than change XDG_DATA_HOME, since many distributions do not explicitly define XDG_DATA_HOME but rather fallback to the default, use a new optional variable SETUP_ENVTEST_BIN_DIR to override the setup_envtest binary directory. Signed-off-by: Tayler Geiger <[email protected]>
1 parent 265d60d commit eff9d85

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Makefile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ export WAIT_TIMEOUT ?= 60s
1212
IMG?=$(IMAGE_REPO):$(IMAGE_TAG)
1313
TESTDATA_DIR := testdata
1414

15-
# setup-envtest on *nix uses XDG_DATA_HOME, falling back to HOME, as the default storage directory. Some CI setups
16-
# don't have XDG_DATA_HOME set; in those cases, we set it here so setup-envtest functions correctly. This shouldn't
17-
# affect developers.
18-
export XDG_DATA_HOME ?= /tmp/.local/share
15+
# By default setup-envtest will write to $XDG_DATA_HOME, or $HOME/.local/share
16+
# if that is not defined. Set KUBEBUILDER_ASSETS_DIR to override.
17+
# Useful for some CI/CD environments that do not have or use the default $XDG_DATA_HOME.
18+
setup_envtest_bin_dir_override=
19+
ifdef SETUP_ENVTEST_BIN_DIR
20+
setup_envtest_bin_dir_override += --bin-dir $(SETUP_ENVTEST_BIN_DIR)
21+
endif
1922

2023
# bingo manages consistent tooling versions for things like kind, kustomize, etc.
2124
include .bingo/Variables.mk
@@ -125,7 +128,7 @@ test-ext-dev-e2e: $(SETUP_ENVTEST) $(OPERATOR_SDK) $(KUSTOMIZE) $(KIND) #HELP Ru
125128
ENVTEST_VERSION = $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\{1,\}\)\.[[:digit:]]\{1,\}$$/1.\1.x/')
126129
UNIT_TEST_DIRS=$(shell go list ./... | grep -v /test/)
127130
test-unit: $(SETUP_ENVTEST) #HELP Run the unit tests
128-
eval $$($(SETUP_ENVTEST) use -p env $(ENVTEST_VERSION)) && go test -tags $(GO_BUILD_TAGS) -count=1 -short $(UNIT_TEST_DIRS) -coverprofile cover.out
131+
eval $$($(SETUP_ENVTEST) use -p env $(ENVTEST_VERSION)) $(setup_envtest_bin_dir_override) && go test -tags $(GO_BUILD_TAGS) -count=1 -short $(UNIT_TEST_DIRS) -coverprofile cover.out
129132

130133
E2E_REGISTRY_NAME=docker-registry
131134
E2E_REGISTRY_NAMESPACE=operator-controller-e2e

0 commit comments

Comments
 (0)