Skip to content

Commit de747ce

Browse files
committed
feat(repo-server): Automatically reflect source changes for SytemCATrust
Signed-off-by: Oliver Gondža <[email protected]>
1 parent ae0908c commit de747ce

File tree

6 files changed

+494
-88
lines changed

6 files changed

+494
-88
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,9 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in
271271
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
272272
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=true -f -
273273

274+
.PHONY: olm-deploy
275+
olm-deploy: ## Build the operator bundle and deploy it to OpenShift through OLM
276+
./hack/scripts/olm-deploy.sh
274277

275278
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
276279
.PHONY: controller-gen

bundle/manifests/gitops-operator.clusterserviceversion.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ metadata:
180180
capabilities: Deep Insights
181181
console.openshift.io/plugins: '["gitops-plugin"]'
182182
containerImage: quay.io/redhat-developer/gitops-operator
183-
createdAt: "2025-10-23T13:34:07Z"
183+
createdAt: "2025-10-27T12:30:20Z"
184184
description: Enables teams to adopt GitOps principles for managing cluster configurations
185185
and application delivery across hybrid multi-cluster Kubernetes environments.
186186
features.operators.openshift.io/disconnected: "true"

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,4 +220,4 @@ replace (
220220
k8s.io/sample-controller => k8s.io/sample-controller v0.33.1
221221
)
222222

223-
replace github.com/argoproj-labs/argocd-operator => github.com/olivergondza/argocd-operator v0.14.0-rc1.0.20250930152012-c0a9ad2ab6f3
223+
replace github.com/argoproj-labs/argocd-operator => github.com/olivergondza/argocd-operator v0.14.0-rc1.0.20251027111201-9c3639cbd5eb

go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFI
3131
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
3232
github.com/argoproj-labs/argo-rollouts-manager v0.0.7-0.20251020065637-7f928e52c0d9 h1:WcUWvh0qIqUaY+JfVIUfBV0ACv9ep2by3YEi04dRNr4=
3333
github.com/argoproj-labs/argo-rollouts-manager v0.0.7-0.20251020065637-7f928e52c0d9/go.mod h1:iVIrf0/GJPZR3NMtJvpo1Ui6qqPjpY34Lp+5RmZo9vY=
34-
github.com/argoproj-labs/argocd-operator v0.14.0-rc1.0.20251017041829-18184f26c64e h1:0JYIQ9qRNce5t7ak5mEL1hLk9S3CKukdjvlVJySJNzE=
35-
github.com/argoproj-labs/argocd-operator v0.14.0-rc1.0.20251017041829-18184f26c64e/go.mod h1:LTBNqNbKk9Us5xiCrK612HLOr8SJFfyxlMJQErzMghg=
3634
github.com/argoproj/argo-cd/v3 v3.1.8 h1:NkLPiRI5qGkV+q1EN3O7/0Wb9O/MVl62vadKteZqMUw=
3735
github.com/argoproj/argo-cd/v3 v3.1.8/go.mod h1:ZHb/LOz/hr88VWMJiVTd8DGYL7MheHCAT8S6DgYOBFo=
3836
github.com/argoproj/gitops-engine v0.7.1-0.20250905160054-e48120133eec h1:rNAwbRQFvRIuW/e2bU+B10mlzghYXsnwZedYeA7Drz4=
@@ -262,8 +260,8 @@ github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+
262260
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
263261
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
264262
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
265-
github.com/olivergondza/argocd-operator v0.14.0-rc1.0.20250930152012-c0a9ad2ab6f3 h1:zWUUan5cef31AB1LwAC/ySan4QcwdPyhe+UTXiS8vjE=
266-
github.com/olivergondza/argocd-operator v0.14.0-rc1.0.20250930152012-c0a9ad2ab6f3/go.mod h1:LQn4PISLCKI4h8oDnJGywq45HLP12QAFZJUzEyARyxk=
263+
github.com/olivergondza/argocd-operator v0.14.0-rc1.0.20251027111201-9c3639cbd5eb h1:yJOhY6Bg9+LiwX6m4FCxmWvtsv9ZMLGcqHokv9Tkuuk=
264+
github.com/olivergondza/argocd-operator v0.14.0-rc1.0.20251027111201-9c3639cbd5eb/go.mod h1:LTBNqNbKk9Us5xiCrK612HLOr8SJFfyxlMJQErzMghg=
267265
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
268266
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
269267
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=

hack/scripts/olm-deploy.sh

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#!/usr/bin/env bash
2+
# https://github.com/olivergondza/bash-strict-mode
3+
set -eEuo pipefail
4+
trap 's=$?; echo >&2 "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
5+
6+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
7+
8+
SUBSCRIPTION_NAME="gitops-operator"
9+
OPERATOR_NAMESPACE="openshift-gitops-operator"
10+
VERSION="$(git describe --tags --dirty | sed 's/^v//')-$(date '+%Y%m%d-%H%M%S')"
11+
12+
function build_bundles() {
13+
export VERSION
14+
make build docker-build docker-push bundle bundle-build bundle-push catalog-build catalog-push
15+
}
16+
17+
function install_catalog_source() {
18+
oc apply -f - <<EOF
19+
apiVersion: operators.coreos.com/v1alpha1
20+
kind: CatalogSource
21+
metadata:
22+
name: devel-gitops-service-source
23+
namespace: openshift-marketplace
24+
spec:
25+
displayName: 'GITOPS DEVEL'
26+
publisher: 'GITOPS DEVEL'
27+
sourceType: grpc
28+
image: '${IMAGE}-catalog:v${VERSION}'
29+
EOF
30+
31+
local yaml=''
32+
for i in $(seq 1 20); do
33+
echo >&2 "Waiting for catalog source to be ready... ($i)"
34+
yaml=$(oc get -o yaml CatalogSource devel-gitops-service-source -n openshift-marketplace --ignore-not-found)
35+
if [ "$(yq '.status.connectionState.lastObservedState' <<< "$yaml")" == "READY" ]; then
36+
echo >&2 "Catalog source is ready"
37+
return 0
38+
fi
39+
40+
sleep 5
41+
done
42+
43+
echo >&2 "Timeout waiting for catalog source to be ready. Current state:"
44+
echo >&2 "$yaml"
45+
return 1
46+
}
47+
48+
function delete_operator() {
49+
oc delete subscription "$SUBSCRIPTION_NAME" -n "$OPERATOR_NAMESPACE" --ignore-not-found
50+
readarray -t ogs < <(oc get operatorgroup -n "$OPERATOR_NAMESPACE" -o name --ignore-not-found)
51+
if [[ ${#ogs[@]} -gt 0 ]]; then
52+
oc delete -n "$OPERATOR_NAMESPACE" "${ogs[@]}"
53+
fi
54+
oc delete csv -n "$OPERATOR_NAMESPACE" -l "operators.coreos.com/${SUBSCRIPTION_NAME}.${OPERATOR_NAMESPACE}" --ignore-not-found
55+
56+
readarray -t pods < <(oc get pod -n "$OPERATOR_NAMESPACE" -o name --ignore-not-found)
57+
if [[ ${#pods[@]} -gt 0 ]]; then
58+
# Pods might stop existing before query and delete, so ignoring not found ones
59+
oc delete -n "$OPERATOR_NAMESPACE" "${pods[@]}" --ignore-not-found
60+
fi
61+
oc delete ns "$OPERATOR_NAMESPACE" --ignore-not-found
62+
}
63+
64+
function install_operator() {
65+
oc create ns "$OPERATOR_NAMESPACE"
66+
oc apply -f - <<EOF
67+
apiVersion: operators.coreos.com/v1
68+
kind: OperatorGroup
69+
metadata:
70+
name: openshift-gitops-operator-devel
71+
namespace: $OPERATOR_NAMESPACE
72+
spec:
73+
upgradeStrategy: Default
74+
---
75+
apiVersion: operators.coreos.com/v1alpha1
76+
kind: Subscription
77+
metadata:
78+
name: $SUBSCRIPTION_NAME
79+
namespace: $OPERATOR_NAMESPACE
80+
spec:
81+
channel: latest
82+
name: $SUBSCRIPTION_NAME
83+
installPlanApproval: Automatic
84+
source: devel-gitops-service-source
85+
sourceNamespace: openshift-marketplace
86+
EOF
87+
88+
local out=''
89+
for i in $(seq 1 20); do
90+
echo >&2 "Waiting for operator to start... ($i)"
91+
out=$(oc get pods -n "$OPERATOR_NAMESPACE" --ignore-not-found --no-headers)
92+
echo "$out"
93+
if [[ "$out" =~ "Running" ]]; then
94+
echo >&2 "Operator is ready"
95+
return 0
96+
fi
97+
sleep 5
98+
done
99+
100+
echo >&2 "Timeout waiting for operator to start. Current state:"
101+
echo >&2 "$out"
102+
oc events -n "$OPERATOR_NAMESPACE" >&2
103+
return 1
104+
}
105+
106+
function main() {
107+
if [ ! -v IMAGE ]; then
108+
echo >&2 "Variable IMAGE not specified"
109+
exit 1
110+
fi
111+
112+
echo >&2 "Deploying version $VERSION"
113+
114+
build_bundles
115+
install_catalog_source
116+
delete_operator
117+
install_operator
118+
}
119+
120+
main "$@"

0 commit comments

Comments
 (0)