forked from hashicorp/consul-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
137 lines (109 loc) · 3.55 KB
/
Makefile
File metadata and controls
137 lines (109 loc) · 3.55 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
SHELL = bash
GOOS?=$(shell go env GOOS)
GOARCH?=$(shell go env GOARCH)
GOPATH=$(shell go env GOPATH)
GOTAGS ?=
GOTOOLS = \
github.com/magiconair/vendorfmt/cmd/vendorfmt \
github.com/mitchellh/gox \
golang.org/x/tools/cmd/cover \
golang.org/x/tools/cmd/stringer
DEV_IMAGE?=consul-aws-dev
GO_BUILD_TAG?=consul-aws-build-go
GIT_COMMIT?=$(shell git rev-parse --short HEAD)
GIT_DIRTY?=$(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true)
GIT_DESCRIBE?=$(shell git describe --tags --always)
GIT_IMPORT=github.com/hashicorp/consul-aws/version
GOLDFLAGS=-X $(GIT_IMPORT).GitCommit=$(GIT_COMMIT)$(GIT_DIRTY) -X $(GIT_IMPORT).GitDescribe=$(GIT_DESCRIBE)
HTTP_FLAGS_PACKAGE_DIR=internal/flags
# Docker Image publishing variables
DOCKER_IMAGE_NAME=consul-aws
DOCKER_ORG=hashicorp
export DOCKER_IMAGE_NAME
export DOCKER_ORG
export GIT_COMMIT
export GIT_DIRTY
export GIT_DESCRIBE
export GOLDFLAGS
export GOTAGS
DIST_TAG?=1
DIST_BUILD?=1
DIST_SIGN?=1
ifdef DIST_VERSION
DIST_VERSION_ARG=-v "$(DIST_VERSION)"
else
DIST_VERSION_ARG=
endif
ifdef DIST_RELEASE_DATE
DIST_DATE_ARG=-d "$(DIST_RELEASE_DATE)"
else
DIST_DATE_ARG=
endif
ifdef DIST_PRERELEASE
DIST_REL_ARG=-r "$(DIST_PRERELEASE)"
else
DIST_REL_ARG=
endif
PUB_GIT?=1
PUB_WEBSITE?=1
ifeq ($(PUB_GIT),1)
PUB_GIT_ARG=-g
else
PUB_GIT_ARG=
endif
ifeq ($(PUB_WEBSITE),1)
PUB_WEBSITE_ARG=-w
else
PUB_WEBSITE_ARG=
endif
DEV_PUSH?=0
ifeq ($(DEV_PUSH),1)
DEV_PUSH_ARG=
else
DEV_PUSH_ARG=--no-push
endif
all: bin
bin:
@$(SHELL) $(CURDIR)/build-support/scripts/build-local.sh
dev:
@$(SHELL) $(CURDIR)/build-support/scripts/build-local.sh -o $(GOOS) -a $(GOARCH)
dev-docker:
@docker build -t '$(DEV_IMAGE)' --build-arg 'GIT_COMMIT=$(GIT_COMMIT)' --build-arg 'GIT_DIRTY=$(GIT_DIRTY)' --build-arg 'GIT_DESCRIBE=$(GIT_DESCRIBE)' -f $(CURDIR)/build-support/docker/Dev.dockerfile $(CURDIR)
dev-tree:
@$(SHELL) $(CURDIR)/build-support/scripts/dev.sh $(DEV_PUSH_ARG)
test:
go test ./...
tools:
go get -u -v $(GOTOOLS)
# dist builds binaries for all platforms and packages them for distribution
# make dist DIST_VERSION=<Desired Version> DIST_RELEASE_DATE=<release date>
# date is in "month day, year" format.
dist:
@$(SHELL) $(CURDIR)/build-support/scripts/release.sh -t '$(DIST_TAG)' -b '$(DIST_BUILD)' -S '$(DIST_SIGN)' $(DIST_VERSION_ARG) $(DIST_DATE_ARG) $(DIST_REL_ARG)
publish:
@$(SHELL) $(CURDIR)/build-support/scripts/publish.sh $(PUB_GIT_ARG) $(PUB_WEBSITE_ARG)
docker-images: go-build-image
go-build-image:
@echo "Building Golang build container"
@docker build $(NOCACHE) $(QUIET) --build-arg 'GOTOOLS=$(GOTOOLS)' -t $(GO_BUILD_TAG) - < build-support/docker/Build-Go.dockerfile
docker-publish:
@echo "Building Docker Image"
@$(SHELL) $(CURDIR)/build-support/scripts/publish-docker.sh
clean:
@rm -rf \
$(CURDIR)/bin \
$(CURDIR)/pkg
# We support all the same CLI flags for connecting to Consul as the main CLI.
# Rather than import the root Consul module, which is not supported, we copy the
# relevant module. This is similar to what we do in consul-dataplane.
# We don't include config_test.go because it pulls in a directory with test data.
.PHONY: copy-http-flags
copy-http-flags: ## copy http flags modules from consul
for file in config.go http.go http_test.go merge.go usage.go; do \
curl --fail https://raw.githubusercontent.com/hashicorp/consul/main/command/flags/$$file | \
sed 's/BUSL-1.1/MPL-2.0/' | \
sed '1s:^:// Code generated by make copy-http-flags. DO NOT EDIT.\n:' | \
gofmt \
> $(HTTP_FLAGS_PACKAGE_DIR)/$$file; \
done
.PHONY: all bin clean dev dist docker-images go-build-image test tools docker-publish