4
4
CRD_DIR : config/crd/bases
5
5
DOCS_OUT : ../../docs/operator/crd-api.md
6
6
CRDREF_CONFIG : ../../docs/operator/crd-ref-config.yaml
7
+ OCP_REGISTRY_ROUTE :
8
+ sh : |
9
+ if command -v oc >/dev/null 2>&1; then
10
+ oc get route default-route -n openshift-image-registry -o jsonpath='{.spec.host}' 2>/dev/null || echo ""
11
+ else
12
+ echo ""
13
+ fi
14
+ OCP_PROJECT : ' {{.OCP_PROJECT | default "toolhive-system"}}'
15
+ OCP_INSECURE_REGISTRY : ' {{.OCP_INSECURE_REGISTRY | default "false"}}'
16
+ CONTAINER_RUNTIME :
17
+ sh : |
18
+ if command -v podman >/dev/null 2>&1; then
19
+ echo "podman"
20
+ elif command -v docker >/dev/null 2>&1; then
21
+ echo "docker"
22
+ else
23
+ echo "docker"
24
+ fi
25
+
7
26
8
27
tasks :
9
28
kind-setup :
@@ -170,4 +189,48 @@ tasks:
170
189
- ' config/crd/bases/**/*.yaml'
171
190
- ' api/**/*.go'
172
191
generates :
173
- - ' {{ .DOCS_OUT }}'
192
+ - ' {{ .DOCS_OUT }}'
193
+
194
+ ocp-setup-registry-sa :
195
+ desc : Create registry-pusher service account with required permissions
196
+ cmds :
197
+ - |
198
+ if ! command -v oc >/dev/null 2>&1; then
199
+ echo "Error: 'oc' command not found. Please install the OpenShift CLI."
200
+ exit 1
201
+ fi
202
+ - oc create serviceaccount registry-pusher -n {{.OCP_PROJECT}} || echo "ServiceAccount registry-pusher already exists"
203
+ - oc policy add-role-to-user system:image-builder system:serviceaccount:{{.OCP_PROJECT}}:registry-pusher -n {{.OCP_PROJECT}} || echo "Role already assigned"
204
+ - echo "ServiceAccount registry-pusher created/verified with image-builder permissions"
205
+
206
+ ocp-registry-login :
207
+ desc : Login to OpenShift registry using detected container runtime ({{.CONTAINER_RUNTIME}})
208
+ deps : [ocp-setup-registry-sa]
209
+ cmds :
210
+ - |
211
+ if [ -z "{{.OCP_REGISTRY_ROUTE}}" ]; then
212
+ echo "Error: OCP_REGISTRY_ROUTE is empty. Please ensure 'oc' is installed and you're connected to an OpenShift cluster."
213
+ exit 1
214
+ fi
215
+ TOKEN=$(oc create token registry-pusher -n {{.OCP_PROJECT}} --duration=24h)
216
+ {{.CONTAINER_RUNTIME}} login -u serviceaccount -p $TOKEN {{.OCP_REGISTRY_ROUTE}}
217
+
218
+ ocp-build-and-push :
219
+ desc : Build ToolHive and Operator images and push them to OpenShift registry
220
+ cmds :
221
+ - task : ocp-registry-login
222
+ - echo "Building and pushing toolhive operator image to {{.OCP_REGISTRY_ROUTE}}/{{.OCP_PROJECT}}..."
223
+ - KO_DOCKER_REPO={{.OCP_REGISTRY_ROUTE}}/{{.OCP_PROJECT}} ko build --push --base-import-paths {{if eq .OCP_INSECURE_REGISTRY "true"}}--insecure-registry{{end}} ./cmd/thv-operator
224
+ - echo "Building and pushing toolhive proxy runner image to {{.OCP_REGISTRY_ROUTE}}/{{.OCP_PROJECT}}..."
225
+ - KO_DOCKER_REPO={{.OCP_REGISTRY_ROUTE}}/{{.OCP_PROJECT}} ko build --push --base-import-paths {{if eq .OCP_INSECURE_REGISTRY "true"}}--insecure-registry{{end}} ./cmd/thv-proxyrunner
226
+ - echo "Images pushed successfully to {{.OCP_REGISTRY_ROUTE}}/{{.OCP_PROJECT}}"
227
+
228
+ ocp-verify-push :
229
+ desc : Verify images were pushed successfully to OpenShift registry
230
+ cmds :
231
+ - echo "Checking image streams in project {{.OCP_PROJECT}}..."
232
+ - oc get is -n {{.OCP_PROJECT}}
233
+ - echo "Describing thv-operator image stream..."
234
+ - oc describe is thv-operator -n {{.OCP_PROJECT}} || echo "thv-operator image stream not found"
235
+ - echo "Describing thv-proxyrunner image stream..."
236
+ - oc describe is thv-proxyrunner -n {{.OCP_PROJECT}} || echo "thv-proxyrunner image stream not found"
0 commit comments