forked from metacontroller/metacontroller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
109 lines (90 loc) · 3.65 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
PWD := ${CURDIR}
PATH := $(PWD)/test/integration/hack/bin:$(PATH)
TAG?= dev
ADDITIONAL_BUILD_ARGUMENTS?=""
PKG := metacontroller.io
API_GROUPS := metacontroller/v1alpha1
export GO111MODULE=on
export GOTESTSUM_FORMAT=pkgname
CODE_GENERATOR_VERSION="v0.17.17"
PKGS = $(shell go list ./... | grep -v '/test/integration/\|/examples/')
COVER_PKGS = $(shell echo ${PKGS} | tr " " ",")
all: install
.PHONY: install
install: generated_files
go install -ldflags "-X main.version=$(TAG)" $(ADDITIONAL_BUILD_ARGUMENTS)
.PHONY: vendor
vendor:
@go mod download
@go mod tidy
.PHONY: unit-test
unit-test: test-setup
go test -i ${PKGS} && \
gotestsum -- -coverpkg="${COVER_PKGS}" -coverprofile=test/integration/hack/tmp/unit-coverage.out ${PKGS}
.PHONY: integration-test
integration-test: test-setup
cd ./test/integration; \
gotestsum -- -coverpkg="${COVER_PKGS}" -coverprofile=hack/tmp/integration-coverage.out ./... -v -timeout 5m -args --logtostderr -v=1
.PHONY: test-setup
test-setup: vendor
./test/integration/hack/setup.sh; \
mkdir -p ./test/integration/hack/tmp; \
.PHONY: image
image: generated_files
docker build -t metacontrollerio/metacontroller:$(TAG) .
# CRD generation
# remember to remove unnecessary metadata fields and
# add "api-approved.kubernetes.io": "unapproved, request not yet submitted"
# to annotations
.PHONY: generate_crds
generate_crds:
@echo "+ Generating crds"
@go install sigs.k8s.io/controller-tools/cmd/controller-gen
@controller-gen "crd:trivialVersions=true,crdVersions=v1beta1" rbac:roleName=manager-role paths="./apis/..." output:crd:artifacts:config=tmp/crds-v1beta1
@cat tmp/crds-v1beta1/*.yaml > manifests/production/metacontroller-crds-v1beta1.yaml
@controller-gen "crd:trivialVersions=false,crdVersions=v1" rbac:roleName=manager-role paths="./apis/..." output:crd:artifacts:config=tmp/crds-v1
@cat tmp/crds-v1/*.yaml > manifests/production/metacontroller-crds-v1.yaml
# Code generators
# https://github.com/kubernetes/community/blob/master/contributors/devel/api_changes.md#generate-code
.PHONY: generated_files
generated_files: deepcopy clientset lister informer
# also builds vendored version of deepcopy-gen tool
.PHONY: deepcopy
deepcopy:
@go get k8s.io/code-generator/cmd/deepcopy-gen@"${CODE_GENERATOR_VERSION}"
@echo "+ Generating deepcopy funcs for $(API_GROUPS)"
@deepcopy-gen \
--input-dirs $(PKG)/apis/$(API_GROUPS) \
--go-header-file ./hack/boilerplate.go.txt \
--output-file-base zz_generated.deepcopy
# also builds vendored version of client-gen tool
.PHONY: clientset
clientset:
@go get k8s.io/code-generator/cmd/client-gen@"${CODE_GENERATOR_VERSION}"
@echo "+ Generating clientsets for $(API_GROUPS)"
@client-gen \
--fake-clientset=false \
--go-header-file ./hack/boilerplate.go.txt \
--input $(API_GROUPS) \
--input-base $(PKG)/apis \
--clientset-path $(PKG)/client/generated/clientset
# also builds vendored version of lister-gen tool
.PHONY: lister
lister:
@go get k8s.io/code-generator/cmd/lister-gen@"${CODE_GENERATOR_VERSION}"
@echo "+ Generating lister for $(API_GROUPS)"
@lister-gen \
--input-dirs $(PKG)/apis/$(API_GROUPS) \
--go-header-file ./hack/boilerplate.go.txt \
--output-package $(PKG)/client/generated/lister
# also builds vendored version of informer-gen tool
.PHONY: informer
informer:
@go get k8s.io/code-generator/cmd/informer-gen@"${CODE_GENERATOR_VERSION}"
@echo "+ Generating informer for $(API_GROUPS)"
@informer-gen \
--input-dirs $(PKG)/apis/$(API_GROUPS) \
--go-header-file ./hack/boilerplate.go.txt \
--output-package $(PKG)/client/generated/informer \
--versioned-clientset-package $(PKG)/client/generated/clientset/internalclientset \
--listers-package $(PKG)/client/generated/lister