forked from vmware-tanzu/cartographer-conventions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
64 lines (51 loc) · 2.1 KB
/
Makefile
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
CONTROLLER_GEN ?= go run sigs.k8s.io/controller-tools/cmd/controller-gen
DIEGEN ?= go run dies.dev/diegen
GOIMPORTS ?= go run golang.org/x/tools/cmd/goimports
KUSTOMIZE ?= go run sigs.k8s.io/kustomize/kustomize/v4
YTT ?= go run github.com/k14s/ytt/cmd/ytt
.PHONY: all
all: test dist
.PHONY: test
test: generate fmt vet ## Run tests
go test ./... -coverprofile cover.out
# Generate manifests e.g. CRD, RBAC etc.
.PHONY: manifests
manifests:
$(CONTROLLER_GEN) crd:crdVersions=v1 rbac:roleName=manager-role webhook crd:maxDescLen=0 \
paths="./pkg/apis/conventions/...;./pkg/controllers/..." \
output:crd:dir=./config/crd/bases \
output:rbac:dir=./config/rbac \
output:webhook:dir=./config/webhook
# cleanup duplicate resource generation
@rm -f config/*.yaml
dist: dist/cartogrpaher-conventions.yaml
dist/cartogrpaher-conventions.yaml: generate manifests
$(KUSTOMIZE) build config/default \
| $(YTT) -f - -f dist/strip-status.yaml -f dist/aks-webhooks.yaml \
> dist/cartogrpaher-conventions.yaml
dist/third-party: dist/third-party/cert-manager.yaml
dist/third-party/cert-manager.yaml: Makefile
curl -Ls https://github.com/jetstack/cert-manager/releases/download/v1.4.1/cert-manager.yaml > dist/third-party/cert-manager.yaml
# Run go fmt against code
.PHONY: fmt
fmt:
$(GOIMPORTS) --local github.com/vmware-tanzu/cartographer-conventions -w pkg/ webhook/ samples/
# Run go vet against code
.PHONY: vet
vet:
go vet ./...
.PHONY: generate
generate: generate-internal fmt ## Generate code
.PHONY: generate-internal
generate-internal:
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths="./..."
$(DIEGEN) die:headerFile=./hack/boilerplate.go.txt paths="./..."
# Absolutely awesome: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help: ## Print help for each make target
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'