-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
60 lines (43 loc) · 1.67 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
GOARCH = amd64
UNAME = $(shell uname -s)
ifndef OS
ifeq ($(UNAME), Linux)
OS = linux
else ifeq ($(UNAME), Darwin)
OS = darwin
endif
endif
.DEFAULT_GOAL := all
OUTPUTFOLDER = ./vault/plugins
PROJECTNAME = benigma
PLUGINNAME = enigma
VERSION=$(shell git describe --abbrev=0 --dirty=d)
COMMIT=$(shell git rev-parse --short HEAD)
OUTPUTNAME = $(PLUGINNAME).$(VERSION)
debug: GOBUILDFLAGS = -gcflags "all=-N -l"
debug: build
all: debug register test
upgrade: register reload
build:
GOOS=$(OS) GOARCH="$(GOARCH)" CGO_ENABLED=0 go build -a -installsuffix cgo -o "$(OUTPUTFOLDER)/$(OUTPUTNAME)" $(GOBUILDFLAGS) -ldflags="-X 'github.com/vaups/benigma.Version=$(VERSION)' -X 'github.com/vaups/benigma.Commit=$(COMMIT)'" cmd/$(PROJECTNAME)/main.go
sha256sum $(OUTPUTFOLDER)/$(OUTPUTNAME)
dev:
vault server --dev --dev-root-token-id root --log-level trace --dev-plugin-dir=$$(pwd -P)/$(OUTPUTFOLDER)
test: build
find . -type f -name "*.shunit2" -exec bash {} \;
unregister:
vault secrets disable $(PLUGINNAME)
vault plugin deregister $(PLUGINNAME)
register:
curl -i --request PUT $$VAULT_ADDR/v1/sys/plugins/catalog/secret/$(PLUGINNAME) --header "X-Vault-Token: $$(vault print token)" --data "{ \"type\":\"secret\", \"command\":\"$(OUTPUTNAME)\", \"sha256\":\"$$($(OUTPUTFOLDER)/$(OUTPUTNAME) hash)\" }"
reload:
vault write sys/plugins/reload/backend plugin=$(PLUGINNAME) scope=global
clean:
vault secrets disable $(PLUGINNAME) || true
vault plugin deregister $(PLUGINNAME) || true
rm -vf ./vault/plugins/*
release: test
tar czfv enigma.tar.gz --directory=$(OUTPUTFOLDER) $$(ls -1 $(OUTPUTFOLDER) | sort -r | head -1)
fmt:
go fmt $$(go list ./...)
.PHONY: build clean fmt dev enable