-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
49 lines (37 loc) · 1.73 KB
/
Copy pathMakefile
File metadata and controls
49 lines (37 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
GOFLAGS ?= -mod=vendor
VENDOR_STAMP := vendor/.modules.stamp
MODULE_FILES := go.mod $(wildcard go.sum)
ENVTEST_K8S_VERSION ?= 1.35.x
ENVTEST_ASSETS_DIR := $(shell pwd)/bin/envtest
.PHONY: vendor test test-integration setup-envtest build lint vuln verify-vendor codegen manifests
$(VENDOR_STAMP): $(MODULE_FILES)
go mod tidy
go mod vendor
@mkdir -p $(dir $@)
@touch $@
vendor: $(VENDOR_STAMP)
setup-envtest:
GOFLAGS=-mod=vendor go run ./vendor/sigs.k8s.io/controller-runtime/tools/setup-envtest use $(ENVTEST_K8S_VERSION) --bin-dir $(ENVTEST_ASSETS_DIR) -p path > /dev/null
test: $(VENDOR_STAMP) setup-envtest
KUBEBUILDER_ASSETS="$$(GOFLAGS=-mod=vendor go run ./vendor/sigs.k8s.io/controller-runtime/tools/setup-envtest use $(ENVTEST_K8S_VERSION) --bin-dir $(ENVTEST_ASSETS_DIR) -p path)" \
GOFLAGS=$(GOFLAGS) go test ./...
test-integration: $(VENDOR_STAMP) setup-envtest
KUBEBUILDER_ASSETS="$$(GOFLAGS=-mod=vendor go run ./vendor/sigs.k8s.io/controller-runtime/tools/setup-envtest use $(ENVTEST_K8S_VERSION) --bin-dir $(ENVTEST_ASSETS_DIR) -p path)" \
GOFLAGS=$(GOFLAGS) go test ./internal/controller/... -count=1 -v
build: $(VENDOR_STAMP)
GOFLAGS=$(GOFLAGS) go build ./...
lint: $(VENDOR_STAMP)
@command -v golangci-lint >/dev/null || (echo "golangci-lint not found; use nix develop" && exit 1)
GOFLAGS=$(GOFLAGS) golangci-lint run ./...
GOFLAGS=$(GOFLAGS) golangci-lint fmt --diff
vuln: $(VENDOR_STAMP)
@command -v govulncheck >/dev/null || (echo "govulncheck not found; use nix develop" && exit 1)
GOFLAGS=$(GOFLAGS) govulncheck ./...
verify-vendor:
go mod tidy
go mod vendor
git diff --exit-code -- go.mod go.sum vendor/
manifests: $(VENDOR_STAMP)
bash ./hack/update-manifests.sh
codegen: $(VENDOR_STAMP)
bash ./hack/update-codegen.sh