1
1
#! /usr/bin/env bash
2
2
3
+ set -x
4
+
5
+ # Load bingo tools for kind
6
+ source .bingo/variables.env
7
+
3
8
# Default values
9
+ KIND=${KIND:- kind}
10
+ KIND_CLUSTER_NAME=${KIND_CLUSTER_NAME:- kind-olmv0}
4
11
OPM_VERSION=$( go list -m github.com/operator-framework/operator-registry | cut -d" " -f2 | sed ' s/^v//' )
5
12
PUSH=false
13
+ SAVE=false
6
14
CONTAINER_RUNTIME=docker
7
15
REGISTRY=quay.io/olmtest
8
16
TARGET_BRANCH=master
9
17
JUST_CHECK=false
18
+ LOAD_KIND=false
10
19
11
20
while [ $# -gt 0 ]; do
12
21
case " $1 " in
@@ -34,7 +43,12 @@ while [ $# -gt 0 ]; do
34
43
--target-branch=* )
35
44
TARGET_BRANCH=" ${1#* =} "
36
45
;;
37
-
46
+ --kind-load)
47
+ LOAD_KIND=" true"
48
+ ;;
49
+ --save)
50
+ SAVE=" true"
51
+ ;;
38
52
* )
39
53
printf " *************************\n"
40
54
printf " * Error: Invalid argument.\n"
@@ -50,6 +64,7 @@ function check_changes() {
50
64
OPM_CHANGED=false
51
65
FIXTURES_CHANGED=false
52
66
67
+ git fetch origin " ${TARGET_BRANCH} " --depth=2
53
68
if git diff " origin/${TARGET_BRANCH} " -- go.mod | grep -E ' ^\+[[:space:]]+github.com/operator-framework/operator-registry' > /dev/null; then
54
69
OPM_CHANGED=true
55
70
fi
@@ -65,15 +80,6 @@ function check_changes() {
65
80
fi
66
81
}
67
82
68
- function push_fixtures() {
69
- ${CONTAINER_RUNTIME} push " ${TEST_CATALOG_IMAGE} "
70
- }
71
-
72
- if [ " $JUST_CHECK " = true ]; then
73
- check_changes
74
- exit 0
75
- fi
76
-
77
83
# Fixtures
78
84
BUNDLE_V1_IMAGE=" ${REGISTRY} /busybox-bundle:1.0.0-${OPM_VERSION} "
79
85
BUNDLE_V1_DEP_IMAGE=" ${REGISTRY} /busybox-dependency-bundle:1.0.0-${OPM_VERSION} "
@@ -85,36 +91,64 @@ INDEX_V2="${REGISTRY}/busybox-dependencies-index:2.0.0-with-ListBundles-method-$
85
91
86
92
TEST_CATALOG_IMAGE=" ${REGISTRY} /test-catalog:${OPM_VERSION} "
87
93
94
+ # Prints true if changes are detected, false otherwise
95
+ if [ " $JUST_CHECK " = true ]; then
96
+ check_changes
97
+ exit 0
98
+ fi
99
+
100
+ # Assumes images are already built, kind cluster is running, and kubeconfig is set
101
+ if [ " $LOAD_KIND " = true ]; then
102
+ ${KIND} load docker-image --name=" ${KIND_CLUSTER_NAME} " " ${BUNDLE_V1_IMAGE} "
103
+ ${KIND} load docker-image --name=" ${KIND_CLUSTER_NAME} " " ${BUNDLE_V1_DEP_IMAGE} "
104
+ ${KIND} load docker-image --name=" ${KIND_CLUSTER_NAME} " " ${BUNDLE_V2_IMAGE} "
105
+ ${KIND} load docker-image --name=" ${KIND_CLUSTER_NAME} " " ${BUNDLE_V2_DEP_IMAGE} "
106
+ ${KIND} load docker-image --name=" ${KIND_CLUSTER_NAME} " " ${INDEX_V1} "
107
+ ${KIND} load docker-image --name=" ${KIND_CLUSTER_NAME} " " ${INDEX_V2} "
108
+ ${KIND} load docker-image --name=" ${KIND_CLUSTER_NAME} " " ${TEST_CATALOG_IMAGE} "
109
+ exit 0
110
+ fi
111
+
112
+ # Assumes images are already built
113
+ if [ " ${SAVE} " = true ]; then
114
+ ${CONTAINER_RUNTIME} save " ${BUNDLE_V1_IMAGE} " | gzip > bundlev1.tar.gz
115
+ ${CONTAINER_RUNTIME} save " ${BUNDLE_V1_DEP_IMAGE} " | gzip > bundlev1dep.tar.gz
116
+
117
+ ${CONTAINER_RUNTIME} save " ${BUNDLE_V2_IMAGE} " | gzip > bundlev2.tar.gz
118
+ ${CONTAINER_RUNTIME} save " ${BUNDLE_V2_DEP_IMAGE} " | gzip > bundlev2dep.tar.gz
119
+
120
+ ${CONTAINER_RUNTIME} save " ${INDEX_V1} " | gzip > indexv1.tar.gz
121
+ ${CONTAINER_RUNTIME} save " ${INDEX_V2} " | gzip > indexv2.tar.gz
122
+
123
+ ${CONTAINER_RUNTIME} save " ${TEST_CATALOG_IMAGE} " | gzip > testcatalog.tar.gz
124
+ exit 0
125
+ fi
126
+
88
127
# Busybox Operator Index Image
89
128
${CONTAINER_RUNTIME} build -t " ${BUNDLE_V1_IMAGE} " ./test/images/busybox-index/busybox/1.0.0
90
129
${CONTAINER_RUNTIME} build -t " ${BUNDLE_V1_DEP_IMAGE} " ./test/images/busybox-index/busybox-dependency/1.0.0
91
130
${CONTAINER_RUNTIME} build -t " ${BUNDLE_V2_IMAGE} " ./test/images/busybox-index/busybox/2.0.0
92
131
${CONTAINER_RUNTIME} build -t " ${BUNDLE_V2_DEP_IMAGE} " ./test/images/busybox-index/busybox-dependency/2.0.0
93
132
94
133
# Build catalog from templates
95
- mkdir -p ./test/images/busybox-index/indexv1
96
- mkdir -p ./test/images/busybox-index/indexv2
97
- sed -e " s|#BUNDLE_V1_IMAGE#|\" ${BUNDLE_V1_IMAGE} \" |g" -e " s|#BUNDLE_V1_DEP_IMAGE#|\" ${BUNDLE_V1_DEP_IMAGE} \" |g" ./test/images/busybox-index/busybox-index-v1.template.json > ./test/images/busybox-index/indexv1/catalog.json
98
- sed -e " s|#BUNDLE_V1_IMAGE#|\" ${BUNDLE_V1_IMAGE} \" |g" -e " s|#BUNDLE_V1_DEP_IMAGE#|\" ${BUNDLE_V1_DEP_IMAGE} \" |g" -e " s|#BUNDLE_V2_IMAGE#|\" ${BUNDLE_V2_IMAGE} \" |g" -e " s|#BUNDLE_V2_DEP_IMAGE#|\" ${BUNDLE_V2_DEP_IMAGE} \" |g" ./test/images/busybox-index/busybox-index-v2.template.json > ./test/images/busybox-index/indexv2/catalog.json
99
-
100
- # Clean up
101
- rm -rf ./test/images/busybox-index/indexv1
102
- rm -rf ./test/images/busybox-index/indexv2
134
+ ${CONTAINER_RUNTIME} build -t " ${INDEX_V1} " --build-arg=" OPM_VERSION=v${OPM_VERSION} " --build-arg=" CONFIGS_DIR=indexv1" ./test/images/busybox-index
135
+ ${CONTAINER_RUNTIME} build -t " ${INDEX_V2} " --build-arg=" OPM_VERSION=v${OPM_VERSION} " --build-arg=" CONFIGS_DIR=indexv2" ./test/images/busybox-index
103
136
104
137
# Test catalog used for e2e tests related to serving an extracted registry
105
138
# Let's reuse one of the other indices for this
106
- ${CONTAINER_RUNTIME} tag -t " ${TEST_CATALOG_IMAGE } " " ${INDEX_V2 } "
139
+ ${CONTAINER_RUNTIME} tag " ${INDEX_V2 } " " ${TEST_CATALOG_IMAGE } "
107
140
108
141
if [ " $PUSH " = true ]; then
109
142
# push bundles
110
- ${CONTAINER_RUNTIME} push " ${BUNDLE_V1_IMAGE} "
111
- ${CONTAINER_RUNTIME} push " ${BUNDLE_V1_IMAGE} "
112
- ${CONTAINER_RUNTIME} push " ${BUNDLE_V1_IMAGE} "
113
- ${CONTAINER_RUNTIME} push " ${BUNDLE_V1_IMAGE} "
143
+ ${CONTAINER_RUNTIME} push " ${BUNDLE_V1_IMAGE} "
144
+ ${CONTAINER_RUNTIME} push " ${BUNDLE_V1_IMAGE} "
145
+ ${CONTAINER_RUNTIME} push " ${BUNDLE_V1_IMAGE} "
146
+ ${CONTAINER_RUNTIME} push " ${BUNDLE_V1_IMAGE} "
114
147
115
- # push indexes
116
- ${CONTAINER_RUNTIME} push " ${INDEX_V1} "
117
- ${CONTAINER_RUNTIME} push " ${INDEX_V2} "
148
+ # push indexes
149
+ ${CONTAINER_RUNTIME} push " ${INDEX_V1} "
150
+ ${CONTAINER_RUNTIME} push " ${INDEX_V2} "
118
151
119
- # push test catalog
152
+ # push test catalog
153
+ ${CONTAINER_RUNTIME} push " ${TEST_CATALOG_IMAGE} "
120
154
fi
0 commit comments