-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
82 lines (63 loc) · 2.53 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
include Makefile.buf
GOPATH ?= $(HOME)/go
SRCPATH := $(patsubst %/,%,$(GOPATH))/src
PROJECT_ROOT := github.com/infobloxopen/protoc-gen-atlas-validate
DOCKERFILE_PATH := $(CURDIR)/docker
IMAGE_REGISTRY ?= infoblox
IMAGE_VERSION ?= dev-atlasvalidate
# configuration for the protobuf gentool
SRCROOT_ON_HOST := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
SRCROOT_IN_CONTAINER := /home/go/src/$(PROJECT_ROOT)
DOCKERPATH := /home/go/src
DOCKER_RUNNER := docker run --rm
DOCKER_RUNNER += -v $(SRCROOT_ON_HOST):$(SRCROOT_IN_CONTAINER)
DOCKER_GENERATOR := infoblox/atlas-gentool:$(IMAGE_VERSION)
GENERATOR := $(DOCKER_RUNNER) $(DOCKER_GENERATOR)
GENVALIDATE_IMAGE := $(IMAGE_REGISTRY)/atlas-gentool
GENVALIDATE_DOCKERFILE := $(DOCKERFILE_PATH)/Dockerfile
default: vendor options install
.PHONY: vendor
vendor:
go mod vendor
install:
go install
regenerate: clean-gen generate
clean-gen:
cd example/examplepb && rm -f *.pb.atlas.validate.go && rm -f *.pb.gw.go && rm -f *.pb.go
cd example/external && rm -f *.pb.atlas.validate.go && rm -f *.pb.gw.go && rm -f *.pb.go
cd options && rm -f *.pb.go
generate: install-gen-gateway $(BUF) options install example
install-gen-gateway:
go generate tools/tools.go
.PHONY: example
example:
buf generate --template example/external/buf.gen.yaml --path example/external
buf generate --template example/examplepb/buf.gen.yaml --path example/examplepb
.PHONY: options
options:
buf generate --template options/buf.gen.yaml --path options/atlas_validate.proto
.PHONY: gentool
gentool:
docker build -f $(GENVALIDATE_DOCKERFILE) -t $(GENVALIDATE_IMAGE):$(IMAGE_VERSION) .
docker image prune -f --filter label=stage=server-intermediate
gentool-examples: gentool
$(GENERATOR) \
-I/go/src/github.com/infobloxopen/protoc-gen-atlas-validate \
--go_out="$(DOCKERPATH)" --go-grpc_out="$(DOCKERPATH)"\
--grpc-gateway_out="logtostderr=true:$(DOCKERPATH)" \
--atlas-validate_out="$(DOCKERPATH)" \
example/examplepb/example.proto \
example/examplepb/examplepb.proto \
example/examplepb/example_multi.proto
$(GENERATOR) \
-I/go/src/github.com/infobloxopen/protoc-gen-atlas-validate \
--go_out="$(DOCKERPATH)" --go-grpc_out="$(DOCKERPATH)"\
--grpc-gateway_out="logtostderr=true:$(DOCKERPATH)" \
--atlas-validate_out="$(DOCKERPATH)" \
example/external/external.proto
gentool-options:
$(GENERATOR) \
--go_out="Mgoogle/protobuf/descriptor.proto:$(DOCKERPATH)" \
$(PROJECT_ROOT)/options/atlas_validate.proto
test: regenerate
go test -v -cover ./example/examplepb