-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
61 lines (44 loc) · 1.48 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
GOARCH = amd64
UNAME = $(shell uname -s)
ifndef OS
ifeq ($(UNAME), Linux)
OS = linux
else ifeq ($(UNAME), Darwin)
OS = darwin
endif
endif
.DEFAULT_GOAL := all
all: fmt build start
build:
GOOS="$(OS)" GOARCH="$(GOARCH)" go build -o vault/plugins/vault-plugin-secrets-jenkins
chmod 755 vault/plugins/*
start:
vault server -dev -dev-root-token-id=root -dev-plugin-dir=./vault/plugins
enable:
vault secrets enable -path=jenkins vault-plugin-secrets-jenkins
clean:
rm -f ./vault/plugins/vault-plugin-secrets-jenkins
fmt:
go fmt $$(go list ./...)
lint:
golangci-lint run -v
jenkins:
docker rm -f vault-jenkins
docker build -t vault-jenkins -f Dockerfile.jenkins .
docker run --name vault-jenkins -d --rm -p 8080:8080 vault-jenkins
test: jenkins
sleep 15
go test -v ./...
set-vault-var:
export VAULT_ADDR="http://localhost:8200"
enable-plugin: build
vault secrets enable vault-plugin-secrets-jenkins || exit 0
vault write sys/plugins/catalog/jenkins \
sha_256="$$(shasum -a 256 ./vault/plugins/vault-plugin-secrets-jenkins | cut -d " " -f1)" \
command="vault-plugin-secrets-jenkins"
vault write vault-plugin-secrets-jenkins/config url=http://localhost:8080 username=admin password=admin
token: set-vault-var enable-plugin
vault read vault-plugin-secrets-jenkins/tokens/mytoken ttl=30
user: set-vault-var enable-plugin
vault write vault-plugin-secrets-jenkins/users/myuser ttl=45 password=testpass fullname=fullname [email protected]
.PHONY: build clean fmt start enable