-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
74 lines (68 loc) · 2.57 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
goarch := $(shell go env GOARCH)
goos := $(shell go env GOOS)
out := vault-init_$(goos)_$(goarch)
.PHONY: build cross docker test test/integration test/integration/clean
build:
GOOS=$(goos) GOARCH=$(goarch) go build \
-ldflags "-X glow.dev.maio.me/seanj/vault-init/internal/version.Version=$(shell git describe --tags)" \
-o "$(out)" \
./cmd/vault-init/...
cross:
mkdir -p release
make build goos=linux goarch=amd64 out=release/vault-init_linux_amd64
make build goos=linux goarch=arm out=release/vault-init_linux_arm
make build goos=linux goarch=arm64 out=release/vault-init_linux_arm64
make build goos=linux goarch=386 out=release/vault-init_linux_386
make build goos=darwin goarch=amd64 out=release/vault-init_darwin_amd64
ls ./release/* | xargs -I{} tar czvpf {}.tar.gz {}
test:
go test -v ./...
docker:
docker build --no-cache --pull -t containers.dev.maio.me/seanj/vault-init:latest -f Dockerfile .
docker build --no-cache --pull -t containers.dev.maio.me/seanj/vault-init:debian-latest -f Dockerfile.debian .
docker push containers.dev.maio.me/seanj/vault-init:latest
docker push containers.dev.maio.me/seanj/vault-init:debian-latest
test/integration/clean:
cd contrib && docker-compose down
test/integration: export VAULT_ADDR = http://localhost:8200
test/integration: test/integration/clean build
cd contrib && docker-compose up -d
@echo "Waiting a second, Vault is coming up.."
@sleep 2
vault login -method token - <<<"secret"
vault secrets enable -path /totp totp
vault write totp/keys/Service generate=true issuer=Vault account_name=vault-init-test
vault kv put secret/shared session_key=pb5fgEOZwKHf09Zz373a835DteugBmte
env -i PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin \
SERVICE_VAULT_API_TOKEN="{{.Vault.token}}" \
KEY="{{.secret.data.shared.data.session_key}}" \
OTP="{{.totp.code.Service.code}}" \
./vault-init \
--debug \
--verbose \
--log-format json \
--vault-address "http://localhost:8200" \
--vault-token "secret" \
--without-reaper \
--orphan-token \
--one-shot \
--path /secret/data/shared \
--path /totp/code/Service \
--token-ttl 30s \
./test.sh
env -i PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin \
SERVICE_VAULT_API_TOKEN="{{.Vault.token}}" \
KEY="{{.secret.data.shared.data.session_key}}" \
OTP="{{.totp.code.Service.code}}" \
./vault-init \
--debug \
--verbose \
--log-format json \
--vault-address "http://localhost:8200" \
--vault-token "secret" \
--without-reaper \
--orphan-token \
--path /secret/data/shared \
--path /totp/code/Service \
--token-ttl 30s \
./test.sh