-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
198 lines (178 loc) · 7.99 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
UNAME = $(shell uname -s)
.DEFAULT_GOAL := all
TEST_RESULT_PATH = $(PWD)/
GOPATH=`go env GOPATH`
ifndef ARTIFACT_NAME
override ARTIFACT_NAME = HCVault_Plugin-Secrets-Engine
endif
all: fmt build start
release:
@if [ "$(OS)" == "" ] && [ "$(ARCH)" == "" ] && [ "$(UNAME)" == "windows" ] ; then\
echo "Build windows"; \
CGO_ENABLED=0 go build -o builds/securosys-hsm.exe cmd/securosys-hsm/main.go; \
cd builds; \
shasum -a 256 securosys-hsm.exe > securosys-hsm_SHA256SUM; \
zip -9 ${ARTIFACT_NAME}_${OS}_${ARCH}.zip securosys-hsm.exe securosys-hsm_SHA256SUM; \
shasum -a 256 ${ARTIFACT_NAME}_${OS}_${ARCH}.zip >> ${ARTIFACT_NAME}_SHA256SUMS; \
cd ..; \
rm builds/securosys-hsm.exe; \
rm builds/securosys-hsm_SHA256SUM; \
echo "Finished!"; \
exit 0; \
fi;
@if [ "$(OS)" == "" ] && [ "$(ARCH)" == "" ] && [ "$(UNAME)" != "windows" ] ; then\
echo "Build $(UNAME)"; \
CGO_ENABLED=0 go build -o builds/securosys-hsm cmd/securosys-hsm/main.go; \
cd builds; \
shasum -a 256 securosys-hsm > securosys-hsm_SHA256SUM; \
zip -9 ${ARTIFACT_NAME}_${OS}_${ARCH}.zip securosys-hsm securosys-hsm_SHA256SUM; \
shasum -a 256 ${ARTIFACT_NAME}_${OS}_${ARCH}.zip >> ${ARTIFACT_NAME}_SHA256SUMS; \
cd ..; \
rm builds/securosys-hsm; \
rm builds/securosys-hsm_SHA256SUM; \
echo "Finished!"; \
exit 0; \
fi;
@if [ "$(OS)" == "windows" ]; then\
echo "Build windows in ARCH: $${ARCH}"; \
CGO_ENABLED=0 GOOS=${OS} GOARCH="${ARCH}" go build -o builds/securosys-hsm.exe cmd/securosys-hsm/main.go; \
cd builds; \
shasum -a 256 securosys-hsm.exe > securosys-hsm_SHA256SUM; \
zip -9 ${ARTIFACT_NAME}_${OS}_${ARCH}.zip securosys-hsm.exe securosys-hsm_SHA256SUM; \
shasum -a 256 ${ARTIFACT_NAME}_${OS}_${ARCH}.zip >> ${ARTIFACT_NAME}_SHA256SUMS; \
cd ..; \
rm builds/securosys-hsm.exe; \
rm builds/securosys-hsm_SHA256SUM; \
echo "Finished!"; \
else\
echo "Build ${OS} in ARCH: ${ARCH}"; \
CGO_ENABLED=0 GOOS=${OS} GOARCH="${ARCH}" go build -o builds/securosys-hsm cmd/securosys-hsm/main.go; \
cd builds; \
shasum -a 256 securosys-hsm > securosys-hsm_SHA256SUM; \
zip -9 ${ARTIFACT_NAME}_${OS}_${ARCH}.zip securosys-hsm securosys-hsm_SHA256SUM; \
shasum -a 256 ${ARTIFACT_NAME}_${OS}_${ARCH}.zip >> ${ARTIFACT_NAME}_SHA256SUMS; \
cd ..; \
rm builds/securosys-hsm; \
rm builds/securosys-hsm_SHA256SUM; \
echo "Finished!"; \
fi;
release-all:
rm -rf builds
for ARCH in amd64 arm64; do\
echo "Build MacOS in ARCH: $${ARCH}"; \
CGO_ENABLED=0 GOOS=darwin GOARCH="$${ARCH}" go build -o builds/securosys-hsm cmd/securosys-hsm/main.go; \
cd builds; \
shasum -a 256 securosys-hsm > securosys-hsm_SHA256SUM; \
zip -9 ${ARTIFACT_NAME}_darwin_$${ARCH}.zip securosys-hsm securosys-hsm_SHA256SUM; \
shasum -a 256 ${ARTIFACT_NAME}_darwin_$${ARCH}.zip >> ${ARTIFACT_NAME}_SHA256SUMS; \
cd ..; \
rm builds/securosys-hsm; \
rm builds/securosys-hsm_SHA256SUM; \
done;
for ARCH in 386 amd64; do\
echo "Build Windows in ARCH: $${ARCH}"; \
CGO_ENABLED=0 GOOS=windows GOARCH="$${ARCH}" go build -o builds/securosys-hsm.exe cmd/securosys-hsm/main.go; \
cd builds; \
shasum -a 256 securosys-hsm.exe > securosys-hsm_SHA256SUM; \
zip -9 ${ARTIFACT_NAME}_windows_$${ARCH}.zip securosys-hsm.exe securosys-hsm_SHA256SUM; \
shasum -a 256 ${ARTIFACT_NAME}_windows_$${ARCH}.zip >> ${ARTIFACT_NAME}_SHA256SUMS; \
cd ..; \
rm builds/securosys-hsm.exe; \
rm builds/securosys-hsm_SHA256SUM; \
done;
for ARCH in 386 amd64 arm arm64; do\
echo "Build Linux in ARCH: $${ARCH}"; \
CGO_ENABLED=0 GOOS=linux GOARCH="$${ARCH}" go build -o builds/securosys-hsm cmd/securosys-hsm/main.go; \
cd builds; \
shasum -a 256 securosys-hsm > securosys-hsm_SHA256SUM; \
zip -9 ${ARTIFACT_NAME}_linux_$${ARCH}.zip securosys-hsm securosys-hsm_SHA256SUM; \
shasum -a 256 ${ARTIFACT_NAME}_linux_$${ARCH}.zip >> ${ARTIFACT_NAME}_SHA256SUMS; \
cd ..; \
rm builds/securosys-hsm; \
rm builds/securosys-hsm_SHA256SUM; \
done;
for ARCH in 386 amd64 arm; do\
echo "Build FreeBSD in ARCH: $${ARCH}"; \
CGO_ENABLED=0 GOOS=freebsd GOARCH="$${ARCH}" go build -o builds/securosys-hsm cmd/securosys-hsm/main.go; \
cd builds; \
shasum -a 256 securosys-hsm > securosys-hsm_SHA256SUM; \
zip -9 ${ARTIFACT_NAME}_freebsd_$${ARCH}.zip securosys-hsm securosys-hsm_SHA256SUM; \
shasum -a 256 ${ARTIFACT_NAME}_freebsd_$${ARCH}.zip >> ${ARTIFACT_NAME}_SHA256SUMS; \
cd ..; \
rm builds/securosys-hsm; \
rm builds/securosys-hsm_SHA256SUM; \
done;
for ARCH in 386 amd64 arm; do\
echo "Build NetBSD in ARCH: $${ARCH}"; \
CGO_ENABLED=0 GOOS=netbsd GOARCH="$${ARCH}" go build -o builds/securosys-hsm cmd/securosys-hsm/main.go; \
cd builds; \
shasum -a 256 securosys-hsm > securosys-hsm_SHA256SUM; \
zip -9 ${ARTIFACT_NAME}_netbsd_$${ARCH}.zip securosys-hsm securosys-hsm_SHA256SUM; \
shasum -a 256 ${ARTIFACT_NAME}_netbsd_$${ARCH}.zip >> ${ARTIFACT_NAME}_SHA256SUMS; \
cd ..; \
rm builds/securosys-hsm; \
rm builds/securosys-hsm_SHA256SUM; \
done;
for ARCH in 386 amd64 arm; do\
echo "Build OpenBSD in ARCH: $${ARCH}"; \
CGO_ENABLED=0 GOOS=openbsd GOARCH="$${ARCH}" go build -o builds/securosys-hsm cmd/securosys-hsm/main.go; \
cd builds; \
shasum -a 256 securosys-hsm > securosys-hsm_SHA256SUM; \
zip -9 ${ARTIFACT_NAME}_openbsd_$${ARCH}.zip securosys-hsm securosys-hsm_SHA256SUM; \
shasum -a 256 ${ARTIFACT_NAME}_openbsd_$${ARCH}.zip >> ${ARTIFACT_NAME}_SHA256SUMS; \
cd ..; \
rm builds/securosys-hsm; \
rm builds/securosys-hsm_SHA256SUM; \
done;
for ARCH in amd64; do\
echo "Build Solaris in ARCH: $${ARCH}"; \
CGO_ENABLED=0 GOOS=solaris GOARCH="$${ARCH}" go build -o builds/securosys-hsm cmd/securosys-hsm/main.go; \
cd builds; \
shasum -a 256 securosys-hsm >> securosys-hsm_SHA256SUM; \
zip -9 ${ARTIFACT_NAME}_solaris_$${ARCH}.zip securosys-hsm securosys-hsm_SHA256SUM; \
shasum -a 256 ${ARTIFACT_NAME}_solaris_$${ARCH}.zip >> ${ARTIFACT_NAME}_SHA256SUMS; \
cd ..; \
rm builds/securosys-hsm; \
rm builds/securosys-hsm_SHA256SUM; \
done;
make release-alpine3
echo "Finished!";
release-alpine3:
docker compose -f docker-builder/alpine3/docker-compose-alpine3.yml run -e ARTIFACT_NAME=${ARTIFACT_NAME} golang-builder-alpine3-amd64
make clean-docker-builder IMAGE=amd64/golang
docker compose -f docker-builder/alpine3/docker-compose-alpine3.yml run -e ARTIFACT_NAME=${ARTIFACT_NAME} golang-builder-alpine3-i386
make clean-docker-builder IMAGE=i386/golang
clean-docker-builder:
@if [ "$$(docker images | grep '$(IMAGE)')" != "" ]; then \
docker rmi -f $$(docker images | grep '$(IMAGE)' | awk '{ print $$3}') 2> /dev/null || true ; \
fi;
docker volume prune -f
docker container prune -f
docker network prune -f
run-docker-test-container:
docker compose -f ./integrationTests/docker/docker-compose.yml up --build -d
clean-docker-test-container:
docker compose -f ./integrationTests/docker/docker-compose.yml down --remove-orphans --rmi all
docker volume prune -f
docker container prune -f
integration-tests:
rm -fr integrationTests/docker/plugins/securosys-hsm
CGO_ENABLED=0 GOOS="linux" GOARCH="amd64" go build -o integrationTests/docker/plugins/securosys-hsm cmd/securosys-hsm/main.go
make run-docker-test-container
sleep 5
go install github.com/jstemmer/go-junit-report/v2@latest
cd integrationTests/tests && go test -count=1 -tags="unit integration" -v -timeout 60m 2>&1 ./... | ${GOPATH}/bin/go-junit-report -iocopy -out ${TEST_RESULT_PATH}integration_junit_report.xml -set-exit-code
build:
CGO_ENABLED=0 go build -o vault/plugins/securosys-hsm cmd/securosys-hsm/main.go
start:
./vault server -dev -dev-root-token-id=root -dev-plugin-dir=./vault/plugins
enable:
./vault secrets enable securosys-hsm
clean:
rm -f ./vault/plugins/securosys-hsm
fmt:
go fmt $$(go list ./...)
test:
go install github.com/jstemmer/go-junit-report/v2@latest
cd tests && go test -count=1 -tags="unit integration" -v -timeout 30m 2>&1 ./... | ${GOPATH}/bin/go-junit-report -iocopy -out ${TEST_RESULT_PATH}junit_report.xml -set-exit-code
.PHONY: build clean fmt start enable