File tree 3 files changed +35
-18
lines changed
3 files changed +35
-18
lines changed Original file line number Diff line number Diff line change @@ -54,3 +54,21 @@ function parseFlag() {
54
54
function parseArg() {
55
55
echo " $( echo " $1 " | awk ' { print gensub(/=/, " ", 1) }' | cut -d" " -f2) "
56
56
}
57
+
58
+ function builderFromArgs() {
59
+ IMAGE_BUILDER=" docker"
60
+ while [[ $# -gt 0 ]]; do
61
+ flag=" $( parseFlag " $1 " ) "
62
+ arg=" $2 "
63
+ if echo " $1 " | grep -qoE -e " --[^ =]*=" ; then arg=" $( parseArg " $1 " ) " ; fi
64
+ case $flag in
65
+ --image-builder)
66
+ IMAGE_BUILDER=" $arg "
67
+ shift
68
+ ;;
69
+ esac
70
+ shift
71
+ done
72
+
73
+ echo " $IMAGE_BUILDER "
74
+ }
Original file line number Diff line number Diff line change 3
3
source hack/lib/test_lib.sh
4
4
5
5
DEST_IMAGE=" quay.io/example/memcached-operator:v0.0.2"
6
-
7
- IMAGE_BUILDER=" docker"
8
- while [[ $# -gt 0 ]]; do
9
- flag=" $( parseFlag " $1 " ) "
10
- arg=" $2 "
11
- if echo " $1 " | grep -qoE -e " --[^ =]*=" ; then arg=" $( parseArg " $1 " ) " ; fi
12
- case $flag in
13
- --image-builder)
14
- IMAGE_BUILDER=" $arg "
15
- shift
16
- ;;
17
- esac
18
- shift
19
- done
6
+ IMAGE_BUILDER=" $( builderFromArgs $@ ) "
20
7
21
8
set -ex
22
9
23
- echo $IMAGE_BUILDER
24
-
25
10
# switch to the "default" namespace if on openshift, to match the minikube test
26
11
if which oc 2> /dev/null; then oc project default; fi
27
12
Original file line number Diff line number Diff line change 3
3
source hack/lib/test_lib.sh
4
4
5
5
DEST_IMAGE=" quay.io/example/nginx-operator:v0.0.2"
6
+ IMAGE_BUILDER=" $( builderFromArgs $@ ) "
7
+
8
+ echo " $IMAGE_BUILDER "
9
+ exit
6
10
7
11
set -ex
8
12
18
22
# build operator binary and base image
19
23
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o test/helm-operator/helm-operator test/helm-operator/cmd/helm-operator/main.go
20
24
pushd test/helm-operator
21
- docker build -t quay.io/water-hole/helm-operator .
25
+ HELM_OP_IMAGE=" quay.io/water-hole/helm-operator:latest"
26
+ # Use buildah by default.
27
+ if [[ " $IMAGE_BUILDER " == " buildah" ]] && command -v buildah; then
28
+ buildah bud --isolation=rootless --layers=true -t " $HELM_OP_IMAGE " .
29
+ buildah push " $HELM_OP_IMAGE " docker-daemon:" $HELM_OP_IMAGE "
30
+ else
31
+ docker build -t " $HELM_OP_IMAGE " .
32
+ fi
22
33
popd
23
34
24
35
# Make a test directory for Helm tests so we avoid using default GOPATH.
@@ -35,7 +46,10 @@ unset GOPATH GOROOT
35
46
operator-sdk new nginx-operator --api-version=helm.example.com/v1alpha1 --kind=Nginx --type=helm
36
47
pushd nginx-operator
37
48
38
- operator-sdk build " $DEST_IMAGE "
49
+ operator-sdk build " $DEST_IMAGE " --image-builder=" $IMAGE_BUILDER "
50
+ if [[ " $IMAGE_BUILDER " == " buildah" ]] && command -v buildah; then
51
+ buildah push " $DEST_IMAGE " docker-daemon:" $DEST_IMAGE "
52
+ fi
39
53
sed -i " s|REPLACE_IMAGE|$DEST_IMAGE |g" deploy/operator.yaml
40
54
sed -i ' s|Always|Never|g' deploy/operator.yaml
41
55
sed -i ' s|size: 3|replicaCount: 1|g' deploy/crds/helm_v1alpha1_nginx_cr.yaml
You can’t perform that action at this time.
0 commit comments