-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
70 lines (53 loc) · 2.69 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
SHELL := /bin/bash
# Get Arch for tag and hardware (Golang style) to run test
arch_tag ?= $(shell ./tools/arch-tag)
arch ?= $(arch_tag)
VAULT_VERSION ?= 1.14.8
VAULT_GPGKEY ?= C874011F0AB405110D02105534365D9472D7468F
VAULT_PLUGIN_HASH := ""
EXECUTABLE := hznvaultauth
DOCKER_INAME ?= openhorizon/$(arch)_vault
VERSION ?= 1.1.5
DEV_VERSION ?=testing
DOCKER_IMAGE_LABELS ?= --label "name=$(arch)_vault" --label "version=$(VERSION)" --label "vault_version=$(VAULT_VERSION)" --label "release=$(shell git rev-parse --short HEAD)"
DOCKER_DEV_OPTS ?= --rm --no-cache --build-arg ARCH=$(arch) --build-arg VAULT_VERSION=$(VAULT_VERSION) --build-arg VAULT_GPGKEY=$(VAULT_GPGKEY) --build-arg VAULT_PLUGIN_HASH=$(VAULT_PLUGIN_HASH)
# license file name
export LICENSE_FILE = LICENSE.txt
COMPILE_ARGS ?= CGO_ENABLED=0 GOARCH=amd64 GOOS=linux
ifndef verbose
.SILENT:
endif
all: $(EXECUTABLE) vault-image
dev: $(EXECUTABLE) vault-dev-image
check: test
clean:
rm -f ./docker/bin/$(EXECUTABLE)
-@docker rmi $(DOCKER_INAME):$(VERSION) 2> /dev/null || :
-@docker rmi $(DOCKER_INAME):testing 2> /dev/null || :
format:
@echo "Formatting all Golang source code with gofmt"
find . -name '*.go' -exec gofmt -l -w {} \;
$(EXECUTABLE): $(shell find . -name '*.go')
@echo "Producing $(EXECUTABLE) for arch: amd64"
$(COMPILE_ARGS) go build -o ./docker/bin/$(EXECUTABLE)
vault-image: VAULT_PLUGIN_HASH=$(shell shasum -a 256 ./docker/bin/$(EXECUTABLE) | awk '{ print $$1 }')
vault-image:
@echo "Handling $(DOCKER_INAME):$(VERSION) with hash $(VAULT_PLUGIN_HASH)"
if [ -n "$(shell docker images | grep '$(DOCKER_INAME):$(VERSION)')" ]; then \
echo "Skipping since $(DOCKER_INAME):$(VERSION) image exists, run 'make clean && make' if a rebuild is desired"; \
elif [[ $(arch) == "amd64" ]]; then \
echo "Building container image $(DOCKER_INAME):$(VERSION)"; \
docker build $(DOCKER_DEV_OPTS) $(DOCKER_IMAGE_LABELS) -t $(DOCKER_INAME):$(VERSION) -f docker/Dockerfile.ubi.$(arch) ./docker; \
else echo "Building the vault docker image is not supported on $(arch)"; fi
vault-dev-image:
@echo "Handling $(DOCKER_INAME):$(DEV_VERSION)"
if [ -n "$(shell docker images | grep '$(DOCKER_INAME):$(DEV_VERSION)')" ]; then \
echo "Skipping since $(DOCKER_INAME):$(DEV_VERSION) image exists, run 'make clean && make' if a rebuild is desired"; \
elif [[ $(arch) == "amd64" ]]; then \
echo "Building container image $(DOCKER_INAME):$(DEV_VERSION)"; \
docker build $(DOCKER_DEV_OPTS) $(DOCKER_IMAGE_LABELS) -t $(DOCKER_INAME):$(DEV_VERSION) -f docker/Dockerfile.ubi.$(arch) ./docker; \
else echo "Building the vault docker image is not supported on $(arch)"; fi
test:
@echo "Executing unit tests"
-@$(COMPILE_ARGS) go test -cover -tags=unit
.PHONY: format