forked from infobloxopen/protoc-gen-atlas-validate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
61 lines (48 loc) · 2.01 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
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:
dep ensure -vendor-only
.PHONY: vendor-update
vendor-update:
dep ensure
install:
go install
.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="plugins=grpc:$(DOCKERPATH)" \
--grpc-gateway_out="logtostderr=true:$(DOCKERPATH)" \
--atlas-validate_out="$(DOCKERPATH)" \
example/examplepb/example.proto
$(GENERATOR) \
-I/go/src/github.com/infobloxopen/protoc-gen-atlas-validate \
--go_out="plugins=grpc:$(DOCKERPATH)" \
--grpc-gateway_out="logtostderr=true:$(DOCKERPATH)" \
--atlas-validate_out="$(DOCKERPATH)" \
example/external/external.proto
gentool-options:
$(GENERATOR) \
--gogo_out="Mgoogle/protobuf/descriptor.proto=github.com/gogo/protobuf/protoc-gen-gogo/descriptor:$(DOCKERPATH)" \
$(PROJECT_ROOT)/options/atlas_validate.proto
test: gentool-examples
go test -v -cover ./example/examplepb