forked from infobloxopen/atlas-gentool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
80 lines (65 loc) · 2.34 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
# Utility docker image to generate Go files from .proto definition.
# https://github.com/infobloxopen/atlas-gentool
IMAGE_NAME := infoblox/atlas-gentool
GO_PATH := /go
SRCROOT_ON_HOST := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
SRCROOT_IN_CONTAINER := $(GO_PATH)/src/github.com/infobloxopen/atlas-gentool
IMAGE_VERSION ?= $(shell git describe --tags)
get_version = sed -n 's/^$(1)=//p' plugin.version
AATVersion ?= $(shell $(call get_version,atlas-app-toolkit))
PGGVersion ?= $(shell $(call get_version,protoc-gen-gorm))
PGAQVVersion ?= $(shell $(call get_version,protoc-gen-atlas-query-validate))
PGAVVersion ?= $(shell $(call get_version,protoc-gen-atlas-validate))
PGPVersion ?= $(shell $(call get_version,protoc-gen-preprocess))
.PHONY: all
all: latest
# Create the Docker image with the latest tag.
.PHONY: latest
latest:
docker build -f Dockerfile -t $(IMAGE_NAME):latest .
.PHONY: versioned
versioned:
docker build -f Dockerfile \
--build-arg AAT_VERSION=$(AATVersion) \
--build-arg PGG_VERSION=$(PGGVersion) \
--build-arg PGAQV_VERSION=$(PGAQVVersion) \
--build-arg PGAV_VERSION=$(PGAVVersion) \
--build-arg PGP_VERSION=$(PGPVersion) \
-t $(IMAGE_NAME):$(IMAGE_VERSION) .
.PHONY: clean
clean:
docker rmi -f $(IMAGE_NAME)
docker rmi `docker images --filter "label=intermediate=true" -q`
.PHONY: test test-gen test-check test-clean
test: test-gen test-check test-clean
test-gen:
docker run --rm -v $(SRCROOT_ON_HOST):$(SRCROOT_IN_CONTAINER) \
infoblox/atlas-gentool:latest \
--go_out=plugins=grpc:. \
--grpc-gateway_out=logtostderr=true:. \
--validate_out="lang=go:." \
--gorm_out=. \
--atlas-query-validate_out=. \
--atlas-validate_out=. \
--preprocess_out=. \
--swagger_out=:. github.com/infobloxopen/atlas-gentool/testdata/test.proto
test-check:
test -e testdata/test.pb.go
test -e testdata/test.pb.gw.go
test -e testdata/test.pb.gorm.go
test -e testdata/test.pb.atlas.query.validate.go
test -e testdata/test.pb.atlas.validate.go
test -e testdata/test.pb.validate.go
test -e testdata/test.pb.preprocess.go
test -e testdata/test.swagger.json
test-clean:
rm -f testdata/*.go
rm -f testdata/*.json
.PHONY: push-latest push-versioned
push-latest:
docker push $(IMAGE_NAME):latest
push-versioned:
docker push $(IMAGE_NAME):$(IMAGE_VERSION)
.PHONY: version
version:
@echo $(IMAGE_VERSION)