-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker.sh
More file actions
executable file
·49 lines (42 loc) · 2.22 KB
/
Copy pathdocker.sh
File metadata and controls
executable file
·49 lines (42 loc) · 2.22 KB
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
#!/bin/sh
need_helper="no"
if [ "x$(podman images -q kazimsarikaya/csi-sharedhostpath-|wc -l|tr -d ' ')" != "x2" ]; then
need_helper="yes"
elif [ "x$1" == "xhelper" ] && [ "x$2" == "xforce" ]; then
need_helper="yes"
fi
if [ "x$need_helper" == "xyes" ]; then
podman build -f container/builder.Dockerfile -t kazimsarikaya/csi-sharedhostpath-builder
podman build -f container/runner.Dockerfile -t kazimsarikaya/csi-sharedhostpath-runner
fi
if [ "x$1" != "xhelper" ]; then
TARGET_HOST=$(printenv CONTAINER_HOST|sed 's-tcp://--g'|cut -f1 -d:)
TARGET_HOST=${TARGET_HOST:-192.168.200.11}
REV=$(git describe --long --tags --match='v*' --dirty 2>/dev/null || echo dev)
if [ "x$1" == "xtest" ]; then
podman stop testdb
while [ "x$(podman ps -a -f "name=testdb" -q|wc -l|tr -d ' ')" != "x0" ]; do
sleep 0.5
done
podman run -d --name testdb --rm -e POSTGRES_USER=sharedhostpath -e POSTGRES_PASSWORD=sharedhostpath -p 5432:5432 postgres:12-alpine
podman build -f container/test.Dockerfile -t kazimsarikaya/csi-sharedhostpath:test-$REV . ||{ podman rm -f testdb; exit 1; }
while ! nc -z $TARGET_HOST 5432; do
sleep 0.5 # wait for 1/2 of the second before check again
done
podman run --name csi_tester -ti --rm --privileged kazimsarikaya/csi-sharedhostpath:test-$REV -test.coverprofile /dev/stdout -dataroot "/csi-data-dir/" -dsn "user=sharedhostpath password=sharedhostpath dbname=sharedhostpath port=5432 host=$TARGET_HOST sslmode=disable" -ginkgo.v -test.v -v ${VERBOSE:-5} |tee tmp/podman-run.out ||exit 1
podman rmi kazimsarikaya/csi-sharedhostpath:test-$REV
podman stop testdb
cov_start=$(grep -n "mode: set" tmp/podman-run.out |cut -d: -f1)
cov_end=$(($(grep -n "coverage:" tmp/podman-run.out |cut -d: -f1) - 1))
sed -n "${cov_start},${cov_end}p" tmp/podman-run.out > tmp/cover.out
go tool cover -html tmp/cover.out -o tmp/cover.html
else
podman build -f container/build.Dockerfile -t kazimsarikaya/csi-sharedhostpath:$REV . ||exit 1
if [ "x$REV" != "xdev" ]; then
podman tag kazimsarikaya/csi-sharedhostpath:$REV kazimsarikaya/csi-sharedhostpath:dev-latest
fi
if [ "x$1" == "xpush" ]; then
podman push kazimsarikaya/csi-sharedhostpath:dev-latest
fi
fi
fi