@ -1,8 +1,8 @@
VERSION ?= $( shell grep 'VERSION' cmd/flux/main.go | awk '{ print $$4 }' | head -n 1 | tr -d '"' )
EMBEDDED_MANIFESTS_TARGET = cmd/flux/.manifests.done
TEST_KUBECONFIG ?= /tmp/flux-e2e-test-kubeconfig
ENVTEST_BIN_VERSION ?= latest
KUBEBUILDER_ASSETS?= $( shell $( SETUP_ENVTEST) use -i $( ENVTEST_BIN_VERSION) -p path)
# Architecture to use envtest with
ENVTEST_ARCH ?= amd64
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
i f e q ( , $( shell go env GOBIN ) )
@ -34,6 +34,7 @@ cleanup-kind:
kind delete cluster --name= flux-e2e-test
rm $( TEST_KUBECONFIG)
KUBEBUILDER_ASSETS ?= " $( shell $( ENVTEST) --arch= $( ENVTEST_ARCH) use -i $( ENVTEST_KUBERNETES_VERSION) --bin-dir= $( ENVTEST_ASSETS_DIR) -p path) "
test : $( EMBEDDED_MANIFESTS_TARGET ) tidy fmt vet install -envtest
KUBEBUILDER_ASSETS = " $( KUBEBUILDER_ASSETS) " go test ./... -coverprofile cover.out --tags= unit
@ -59,27 +60,33 @@ install:
install-dev :
CGO_ENABLED = 0 go build -o /usr/local/bin ./cmd/flux
install-envtest : setup -envtest
$( SETUP_ENVTEST) use $( ENVTEST_BIN_VERSION)
setup-bootstrap-patch :
go run ./tests/bootstrap/main.go
setup-image-automation :
cd tests/image-automation && go run main.go
# Find or download setup-envtest
setup-envtest :
i f e q ( , $( shell which setup -envtest ) )
@{ \
ENVTEST_ASSETS_DIR = $( shell pwd ) /testbin
ENVTEST_KUBERNETES_VERSION ?= latest
install-envtest : setup -envtest
mkdir -p ${ ENVTEST_ASSETS_DIR }
$( ENVTEST) use $( ENVTEST_KUBERNETES_VERSION) --arch= $( ENVTEST_ARCH) --bin-dir= $( ENVTEST_ASSETS_DIR)
ENVTEST = $( shell pwd ) /bin/setup-envtest
.PHONY : envtest
setup-envtest : ## Download envtest-setup locally if necessary.
$( call go-install-tool,$( ENVTEST) ,sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)
# go-install-tool will 'go install' any package $2 and install it to $1.
PROJECT_DIR := $( shell dirname $( abspath $( lastword $( MAKEFILE_LIST) ) ) )
d e f i n e g o - i n s t a l l - t o o l
@ [ - f $( 1) ] | | { \
s e t - e ; \
SETUP_ENVTEST_TMP_DIR = $$ ( mktemp -d) ; \
cd $$ SETUP_ENVTEST_TMP_DIR ; \
TMP_DIR= $$ ( mktemp -d) ; \
c d $$ T M P _ D I R ; \
g o m o d i n i t t m p ; \
go get sigs.k8s.io/controller-runtime/tools/setup-envtest@latest ; \
rm -rf $$ SETUP_ENVTEST_TMP_DIR ; \
e c h o "Downloading $(2)" ; \
GOBIN = $( PROJECT_DIR) /bin go install $( 2) ; \
r m - r f $$ T M P _ D I R ; \
}
SETUP_ENVTEST = $( GOBIN) /setup-envtest
e l s e
SETUP_ENVTEST = $( shell which setup-envtest)
e n d i f
e n d e f