-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
83 lines (65 loc) · 1.8 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
MAKEFLAGS += --no-print-directory
COMPONENTS = pod-replicas-updater pod-autoscaler podscale-controller
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
.PHONY: all build cluster clean coverage controller-gen e2e fmt install install-crds install-rbac manifests release test vet
all: build test coverage manifests release clean
# Build binary
build: fmt test vet
$(call action, build)
coverage:
$(call action, coverage)
clean:
$(call action, clean)
cluster: kind
@kind create cluster --config ./config/cluster-conf/development-cluster.yaml --image systemautoscaler/kindest-node:latest
fmt:
$(call action, fmt)
install: install-crds install-rbac
install-crds:
@echo "install CRDs manifests"
@kubectl apply -f config/crd/bases
install-rbac:
@echo "install RBAC"
@kubectl apply -f config/permissions
release:
$(call action, release)
test:
@echo "run local tests"
$(call action, test)
e2e: install
@echo "run e2e tests"
@kubectl apply -f ./config/cluster-conf/e2e-namespace.yaml
$(call action, e2e)
vet:
$(call action, vet)
# Generate manifests e.g. CRD, RBAC etc.
manifests: controller-gen
@echo "generate CRDs manifests"
$(CONTROLLER_GEN) crd paths="./pkg/apis/systemautoscaler/..." crd:crdVersions={v1} output:crd:artifacts:config=config/crd/bases
controller-gen:
ifeq (, $(shell which controller-gen))
@{ \
set -e ;\
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$CONTROLLER_GEN_TMP_DIR ;\
go mod init tmp ;\
go get sigs.k8s.io/controller-tools/cmd/[email protected] ;\
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
}
CONTROLLER_GEN=$(GOBIN)/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
endif
define action
@for c in $(COMPONENTS); \
do \
$(MAKE) $(1) -C pkg/$$c; \
if [ $$? -ne 0 ]; then \
return 1; \
fi \
done
endef