-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
63 lines (48 loc) · 1.56 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
NAME := terraform-provider-consulacl
PLATFORMS ?= darwin/amd64 linux/amd64 windows/amd64
VERSION = $(shell git describe 1>/dev/null 2>/dev/null && echo "_$$(git describe)")
temp = $(subst /, ,$@)
os = $(word 1, $(temp))
arch = $(word 2, $(temp))
BASE := $(NAME)$(VERSION)
RELEASE_DIR := ./release
CONSUL_ADDRESS ?= 127.0.0.1:8500
CONSUL_LOCAL_CONFIG ?= {"acl_datacenter": "dc1", "acl_master_token": "secret", "bootstrap_expect": 1, "server": true, "ui": true}
CONSUL_VERSION ?= latest
CONSUL_TOKEN ?= secret
.PHONY: all
all: clean test release
.PHONY: clean
clean:
rm -rf $(RELEASE_DIR) ./$(NAME)*
.PHONY: format
format:
GOPROXY="off" GOFLAGS="-mod=vendor" go fmt ./...
.PHONY: test
test:
GOPROXY="off" GOFLAGS="-mod=vendor" go test -count=1 -v ./...
GOPROXY="off" GOFLAGS="-mod=vendor" go vet ./...
.PHONY: test-server
test-server:
@docker pull 'consul:$(CONSUL_VERSION)'
docker run --rm -p $(CONSUL_ADDRESS):8500 -e CONSUL_LOCAL_CONFIG='$(CONSUL_LOCAL_CONFIG)' 'consul:$(CONSUL_VERSION)'
.PHONY: test-integration
test-integration:
TF_ACC=1 CONSUL_TOKEN=$(CONSUL_TOKEN) go test -count=1 -v ./... -timeout 1m
.PHONY: build
build:
GOPROXY="off" GOFLAGS="-mod=vendor" go build -o $(BASE)
.PHONY:
release: $(PLATFORMS)
.PHONY: $(PLATFORMS)
$(PLATFORMS):
GOPROXY="off" GOFLAGS="-mod=vendor" GOOS=$(os) GOARCH=$(arch) go build -ldflags="-s -w" -o '$(RELEASE_DIR)/$(BASE)-$(os)-$(arch)'
.PHONY: compress
compress:
upx $(RELEASE_DIR)/*
.PHONY: zip
zip:
cd $(RELEASE_DIR); ls -1 | xargs -I % zip -9 %.zip %
.PHONY: sums
sums:
cd $(RELEASE_DIR); shasum -a 256 $(NAME)* > SHA256SUMS