forked from GoogleCloudPlatform/metacontroller
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
102 lines (81 loc) · 3.19 KB
/
Makefile
File metadata and controls
102 lines (81 loc) · 3.19 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
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
PWD := ${CURDIR}
PACKAGE_NAME := metacontroller.app
API_GROUPS := metacontroller/v1alpha1
PACKAGE_VERSION ?= $(shell git describe --always --tags)
OS = $(shell uname)
ALL_SRC = $(shell find . -name "*.go" | grep -v -e vendor \
-e ".*/\..*" \
-e ".*/_.*" \
-e ".*/mocks.*" \
-e ".*/*.pb.go")
ALL_PKGS = $(shell go list $(sort $(dir $(ALL_SRC))) | grep -v vendor)
BUILD_LDFLAGS = -X $(PACKAGE_NAME)/build.Hash=$(PACKAGE_VERSION)
GO_FLAGS = -gcflags '-N -l' -ldflags "$(BUILD_LDFLAGS)"
REGISTRY ?= quay.io/amitkumardas
IMG_NAME ?= metacontroller
all: vendor bins
bins: generated_files $(IMG_NAME)
$(IMG_NAME): $(ALL_SRC)
@echo "+ Generating $(IMG_NAME) binary"
@CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on \
go build -tags bins $(GO_FLAGS) -o $@ ./main.go
$(ALL_SRC): ;
unit-test:
@pkgs="$$(go list ./... | grep -v '/test/integration/\|/examples/')" ; \
go test -i $${pkgs} && \
go test $${pkgs}
gofmt:
@go fmt $(ALL_PKGS)
# go mod download modules to local cache
# make vendored copy of dependencies
# install other go binaries for code generation
.PHONY: vendor
vendor: go.mod go.sum
@GO111MODULE=on go mod download
@GO111MODULE=on go mod vendor
@GO111MODULE=on go get k8s.io/code-generator/cmd/deepcopy-gen
@GO111MODULE=on go get k8s.io/code-generator/cmd/client-gen
@GO111MODULE=on go get k8s.io/code-generator/cmd/lister-gen
@GO111MODULE=on go get k8s.io/code-generator/cmd/informer-gen
integration-test:
go test -i ./test/integration/...
PATH="$(PWD)/hack/bin:$(PATH)" go test ./test/integration/... -v -timeout 5m -args -v=6
image:
docker build -t $(REGISTRY)/$(IMG_NAME):$(PACKAGE_VERSION) .
push: image
docker push $(REGISTRY)/$(IMG_NAME):$(PACKAGE_VERSION)
# Code generators
# https://github.com/kubernetes/community/blob/master/contributors/devel/api_changes.md#generate-code
generated_files: deepcopy clientset lister informer
# also builds vendored version of deepcopy-gen tool
deepcopy:
@echo "+ Generating deepcopy funcs for $(API_GROUPS)"
@deepcopy-gen \
--go-header-file $(PWD)/hack/custom-boilerplate.go.txt \
--input-dirs $(PACKAGE_NAME)/apis/$(API_GROUPS) \
--output-file-base zz_generated.deepcopy
# also builds vendored version of client-gen tool
clientset:
@echo "+ Generating clientsets for $(API_GROUPS)"
@client-gen \
--go-header-file $(PWD)/hack/custom-boilerplate.go.txt \
--fake-clientset=false \
--input $(API_GROUPS) \
--input-base $(PACKAGE_NAME)/apis \
--clientset-path $(PACKAGE_NAME)/client/generated/clientset
# also builds vendored version of lister-gen tool
lister:
@echo "+ Generating lister for $(API_GROUPS)"
@lister-gen \
--go-header-file $(PWD)/hack/custom-boilerplate.go.txt \
--input-dirs $(PACKAGE_NAME)/apis/$(API_GROUPS) \
--output-package $(PACKAGE_NAME)/client/generated/lister
# also builds vendored version of informer-gen tool
informer:
@echo "+ Generating informer for $(API_GROUPS)"
@informer-gen \
--go-header-file $(PWD)/hack/custom-boilerplate.go.txt \
--input-dirs $(PACKAGE_NAME)/apis/$(API_GROUPS) \
--output-package $(PACKAGE_NAME)/client/generated/informer \
--versioned-clientset-package $(PACKAGE_NAME)/client/generated/clientset/internalclientset \
--listers-package $(PACKAGE_NAME)/client/generated/lister