forked from nats-io/nack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
122 lines (102 loc) · 4.07 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
export GOFLAGS := -mod=vendor
export GO111MODULE := on
now := $(shell date -u +%Y-%m-%dT%H:%M:%S%z)
gitBranch := $(shell git rev-parse --abbrev-ref HEAD)
gitCommit := $(shell git rev-parse --short HEAD)
repoDirty := $(shell git diff --quiet || echo "-dirty")
VERSION ?= version-not-set
linkerVars := -X main.BuildTime=$(now) -X main.GitInfo=$(gitBranch)-$(gitCommit)$(repoDirty) -X main.Version=$(VERSION)
jetstreamGenIn:= $(shell grep -l -R -F "// +k8s:" pkg/jetstream/apis)
jetstreamSrc := $(shell find cmd/jetstream-controller pkg/jetstream controllers/jetstream -name "*.go")
configReloaderSrc := $(shell find cmd/nats-server-config-reloader/ pkg/natsreloader/ -name "*.go")
bootConfigSrc := $(shell find cmd/nats-boot-config/ pkg/bootconfig/ -name "*.go")
default:
# Try these (read Makefile for more recipes):
# make jetstream-controller
# make nats-server-config-reloader
# make nats-boot-config
vendor: go.mod go.sum
go mod vendor
touch $@
pkg/jetstream/generated pkg/jetstream/apis/jetstream/v1beta1/zz_generated.deepcopy.go: vendor $(jetstreamGenIn) pkg/k8scodegen/file-header.txt
rm -rf pkg/jetstream/generated
GOFLAGS='' bash vendor/k8s.io/code-generator/generate-groups.sh all \
github.com/nats-io/nack/pkg/jetstream/generated \
github.com/nats-io/nack/pkg/jetstream/apis \
"jetstream:v1beta1" \
--output-base . \
--go-header-file pkg/k8scodegen/file-header.txt
mv github.com/nats-io/nack/pkg/jetstream/generated pkg/jetstream/generated
mv github.com/nats-io/nack/pkg/jetstream/apis/jetstream/v1beta1/zz_generated.deepcopy.go pkg/jetstream/apis/jetstream/v1beta1/zz_generated.deepcopy.go
rm -rf github.com
jetstream-controller: $(jetstreamSrc) vendor
go build -race -o $@ \
-ldflags "$(linkerVars)" \
github.com/nats-io/nack/cmd/jetstream-controller
jetstream-controller.docker: $(jetstreamSrc) vendor
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $@ \
-ldflags "-s -w $(linkerVars)" \
-tags timetzdata \
github.com/nats-io/nack/cmd/jetstream-controller
.PHONY: jetstream-controller-docker
jetstream-controller-docker:
ifneq ($(ver),)
docker build --tag natsio/jetstream-controller:$(ver) \
--build-arg VERSION=$(ver) \
--file docker/jetstream-controller/Dockerfile .
else
# Missing version, try this.
# make jetstream-controller-docker ver=1.2.3
exit 1
endif
nats-server-config-reloader: $(configReloaderSrc) vendor
go build -race -o $@ \
-ldflags "$(linkerVars)" \
github.com/nats-io/nack/cmd/nats-server-config-reloader
nats-server-config-reloader.docker: $(configReloaderSrc) vendor
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $@ \
-ldflags "-s -w $(linkerVars)" \
-tags timetzdata \
github.com/nats-io/nack/cmd/nats-server-config-reloader
.PHONY: nats-server-config-reloader-docker
nats-server-config-reloader-docker:
ifneq ($(ver),)
docker build --tag natsio/nats-server-config-reloader:$(ver) \
--build-arg VERSION=$(ver) \
--file docker/nats-server-config-reloader/Dockerfile .
else
# Missing version, try this.
# make nats-server-config-reloader-docker ver=1.2.3
exit 1
endif
nats-boot-config: $(bootConfigSrc) vendor
go build -race -o $@ \
-ldflags "$(linkerVars)" \
github.com/nats-io/nack/cmd/nats-boot-config
nats-boot-config.docker: $(bootConfigSrc) vendor
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $@ \
-ldflags "-s -w $(linkerVars)" \
-tags timetzdata \
github.com/nats-io/nack/cmd/nats-boot-config
.PHONY: nats-boot-config-docker
nats-boot-config-docker:
ifneq ($(ver),)
docker build --tag natsio/nats-boot-config:$(ver) \
--build-arg VERSION=$(ver) \
--file docker/nats-boot-config/Dockerfile .
else
# Missing version, try this.
# make nats-boot-config-docker ver=1.2.3
exit 1
endif
.PHONY: build
build: jetstream-controller nats-server-config-reloader nats-boot-config
.PHONY: test
test:
go vet ./controllers/... ./pkg/natsreloader/...
go test -race -cover -count=1 -timeout 10s ./controllers/... ./pkg/natsreloader/...
.PHONY: clean
clean:
rm -f jetstream-controller jetstream-controller.docker \
nats-server-config-reloader nats-server-config-reloader.docker \
nats-boot-config nats-boot-config.docker