1TOOL?=vault-plugin-auth-kubernetes
2TEST?=$$(go list ./... | grep -v /vendor/)
3VETARGS?=-asmdecl -atomic -bool -buildtags -copylocks -methods -nilfunc -printf -rangeloops -shift -structtags -unsafeptr
4EXTERNAL_TOOLS=\
5	github.com/mitchellh/gox \
6	github.com/golang/dep/cmd/dep
7BUILD_TAGS?=${TOOL}
8GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)
9
10# bin generates the releaseable binaries for this plugin
11bin: fmtcheck generate
12	@CGO_ENABLED=0 BUILD_TAGS='$(BUILD_TAGS)' sh -c "'$(CURDIR)/scripts/build.sh'"
13
14default: dev
15
16# dev creates binaries for testing Vault locally. These are put
17# into ./bin/ as well as $GOPATH/bin, except for quickdev which
18# is only put into /bin/
19quickdev: generate
20	@CGO_ENABLED=0 go build -i -tags='$(BUILD_TAGS)' -o bin/vault-plugin-auth-kubernetes
21dev: fmtcheck generate
22	@CGO_ENABLED=0 BUILD_TAGS='$(BUILD_TAGS)' VAULT_DEV_BUILD=1 sh -c "'$(CURDIR)/scripts/build.sh'"
23dev-dynamic: generate
24	@CGO_ENABLED=1 BUILD_TAGS='$(BUILD_TAGS)' VAULT_DEV_BUILD=1 sh -c "'$(CURDIR)/scripts/build.sh'"
25
26# test runs the unit tests and vets the code
27test: fmtcheck generate
28	CGO_ENABLED=0 VAULT_TOKEN= VAULT_ACC= go test -tags='$(BUILD_TAGS)' $(TEST) $(TESTARGS) -timeout=20m -parallel=4
29
30testcompile: fmtcheck generate
31	@for pkg in $(TEST) ; do \
32		go test -v -c -tags='$(BUILD_TAGS)' $$pkg -parallel=4 ; \
33	done
34
35# testacc runs acceptance tests
36testacc: fmtcheck generate
37	@if [ "$(TEST)" = "./..." ]; then \
38		echo "ERROR: Set TEST to a specific package"; \
39		exit 1; \
40	fi
41	VAULT_ACC=1 go test -tags='$(BUILD_TAGS)' $(TEST) -v $(TESTARGS) -timeout 45m
42
43# generate runs `go generate` to build the dynamically generated
44# source files.
45generate:
46	go generate $(go list ./... | grep -v /vendor/)
47
48# bootstrap the build by downloading additional tools
49bootstrap:
50	@for tool in  $(EXTERNAL_TOOLS) ; do \
51		echo "Installing/Updating $$tool" ; \
52		go get -u $$tool; \
53	done
54
55fmtcheck:
56	@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
57
58fmt:
59	gofmt -w $(GOFMT_FILES)
60
61
62.PHONY: bin default generate test vet bootstrap fmt fmtcheck
63