forked from envoyproxy/ratelimit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
77 lines (68 loc) · 2.04 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
ifeq ("$(GOPATH)","")
$(error GOPATH must be set)
endif
SHELL := /bin/bash
GOREPO := ${GOPATH}/src/github.com/lyft/ratelimit
.PHONY: bootstrap
bootstrap:
script/install-glide
glide install
.PHONY: bootstrap_tests
bootstrap_tests:
cd ./vendor/github.com/golang/mock/mockgen && go install
define REDIS_STUNNEL
cert = private.pem
pid = /var/run/stunnel.pid
[redis]
accept = 127.0.0.1:16381
connect = 127.0.0.1:6381
endef
define REDIS_PER_SECOND_STUNNEL
cert = private.pem
pid = /var/run/stunnel-2.pid
[redis]
accept = 127.0.0.1:16382
connect = 127.0.0.1:6382
endef
export REDIS_STUNNEL
export REDIS_PER_SECOND_STUNNEL
redis.conf:
echo "$$REDIS_STUNNEL" >> $@
redis-per-second.conf:
echo "$$REDIS_PER_SECOND_STUNNEL" >> $@
.PHONY: bootstrap_redis_tls
bootstrap_redis_tls: redis.conf redis-per-second.conf
openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 \
-subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=localhost" \
-keyout key.pem -out cert.pem
cat key.pem cert.pem > private.pem
sudo cp cert.pem /usr/local/share/ca-certificates/redis-stunnel.crt
chmod 640 key.pem cert.pem private.pem
sudo update-ca-certificates
sudo stunnel redis.conf
sudo stunnel redis-per-second.conf
.PHONY: docs_format
docs_format:
script/docs_check_format
.PHONY: fix_format
fix_format:
script/docs_fix_format
go fmt $(shell glide nv)
.PHONY: check_format
check_format: docs_format
@gofmt -l $(shell glide nv | sed 's/\.\.\.//g') | tee /dev/stderr | read && echo "Files failed gofmt" && exit 1 || true
.PHONY: compile
compile:
mkdir -p ${GOREPO}/bin
cd ${GOREPO}/src/service_cmd && go build -o ratelimit ./ && mv ./ratelimit ${GOREPO}/bin
cd ${GOREPO}/src/client_cmd && go build -o ratelimit_client ./ && mv ./ratelimit_client ${GOREPO}/bin
cd ${GOREPO}/src/config_check_cmd && go build -o ratelimit_config_check ./ && mv ./ratelimit_config_check ${GOREPO}/bin
.PHONY: tests_unit
tests_unit: compile
go test -race ./...
.PHONY: tests
tests: compile
go test -race -tags=integration ./...
.PHONY: docker
docker: tests
docker build . -t lyft/ratelimit:`git rev-parse HEAD`