forked from jetstack/navigator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
143 lines (116 loc) · 3.83 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
BINDIR ?= bin
HACK_DIR ?= hack
NAVIGATOR_PKG = github.com/jetstack-experimental/navigator
TYPES_FILES = $(shell find pkg/apis -name types.go)
REGISTRY := jetstackexperimental
IMAGE_NAME := navigator
BUILD_TAG := build
IMAGE_TAGS := canary
BUILD_IMAGE_DIR := hack/builder
BUILD_IMAGE_NAME := navigator/builder
GOPATH ?= /tmp/go
help:
# all - runs verify, build and docker_build targets
# test - runs go_test target
# e2e-test - runs e2e tests
# build - runs generate, and then go_build targets
# generate - generates pkg/client/ files
# verify - verifies generated files & scripts
# Util targets
##############
.PHONY: all test verify
all: verify build docker_build
test: go_test
.hack_e2e:
@${HACK_DIR}/e2e.sh
e2e-test: build docker_build .hack_e2e
build: go_build
generate: .generate_files
verify: .hack_verify go_verify
.hack_verify: .generate_exes
@echo Running repo-infra verify scripts
@echo Running href checker:
@${HACK_DIR}/verify-links.sh
@echo Running errexit checker:
@${HACK_DIR}/verify-errexit.sh
@echo Running generated client checker:
@${HACK_DIR}/verify-client-gen.sh
# Builder image targets
#######################
docker_%: .builder_image
docker run -it \
-v ${GOPATH}/src:/go/src \
-v $(shell pwd):/go/src/${NAVIGATOR_PKG} \
-w /go/src/${NAVIGATOR_PKG} \
-e GOPATH=/go \
${BUILD_IMAGE_NAME} \
/bin/sh -c "make $*"
.builder_image:
docker build -t ${BUILD_IMAGE_NAME} ${BUILD_IMAGE_DIR}
# Docker targets
################
docker_build:
docker build -t $(REGISTRY)/$(IMAGE_NAME):$(BUILD_TAG) .
docker_push: docker_build
set -e; \
for tag in $(IMAGE_TAGS); do \
docker tag $(REGISTRY)/$(IMAGE_NAME):$(BUILD_TAG) $(REGISTRY)/$(IMAGE_NAME):$${tag} ; \
docker push $(REGISTRY)/$(IMAGE_NAME):$${tag}; \
done
# Go targets
#################
go_verify: go_fmt go_vet go_test
go_build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags netgo -ldflags '-w' -o navigator_linux_amd64 ./cmd/controller
go_test:
go test $$(go list ./... | grep -v '/vendor/')
go_fmt:
@set -e; \
GO_FMT=$$(git ls-files *.go | grep -v 'vendor/' | xargs gofmt -d); \
if [ -n "$${GO_FMT}" ] ; then \
echo "Please run go fmt"; \
echo "$$GO_FMT"; \
exit 1; \
fi
go_vet:
go vet $$(go list ./... | grep -v '/vendor/')
# This section contains the code generation stuff
#################################################
.generate_exes: \
$(BINDIR)/defaulter-gen \
$(BINDIR)/deepcopy-gen \
$(BINDIR)/conversion-gen \
$(BINDIR)/client-gen \
$(BINDIR)/lister-gen \
$(BINDIR)/informer-gen
touch $@
$(BINDIR)/%:
go build -o $@ ./vendor/k8s.io/code-generator/cmd/$*
# Regenerate all files if the gen exes changed or any "types.go" files changed
.generate_files: .generate_exes $(TYPES_FILES)
# Generate defaults
$(BINDIR)/defaulter-gen \
--v 1 --logtostderr \
--go-header-file "$(HACK_DIR)/boilerplate.go.txt" \
--input-dirs "$(NAVIGATOR_PKG)/pkg/apis/navigator" \
--input-dirs "$(NAVIGATOR_PKG)/pkg/apis/navigator/v1alpha1" \
--extra-peer-dirs "$(NAVIGATOR_PKG)/pkg/apis/navigator" \
--extra-peer-dirs "$(NAVIGATOR_PKG)/pkg/apis/navigator/v1alpha1" \
--output-file-base "zz_generated.defaults"
# Generate deep copies
$(BINDIR)/deepcopy-gen \
--v 1 --logtostderr \
--go-header-file "$(HACK_DIR)/boilerplate.go.txt" \
--input-dirs "$(NAVIGATOR_PKG)/pkg/apis/navigator" \
--input-dirs "$(NAVIGATOR_PKG)/pkg/apis/navigator/v1alpha1" \
--bounding-dirs "github.com/openshift/open-service-broker-sdk" \
--output-file-base zz_generated.deepcopy
# Generate conversions
$(BINDIR)/conversion-gen \
--v 1 --logtostderr \
--go-header-file "$(HACK_DIR)/boilerplate.go.txt" \
--input-dirs "$(NAVIGATOR_PKG)/pkg/apis/navigator" \
--input-dirs "$(NAVIGATOR_PKG)/pkg/apis/navigator/v1alpha1" \
--output-file-base zz_generated.conversion
# generate all pkg/client contents
$(HACK_DIR)/update-client-gen.sh