@@ -11,10 +11,14 @@ if [ -n "$ITA_KEY" ]; then
1111 TDX=true
1212fi
1313DEFAULT_IMAGE=quay.io/openshift_sandboxed_containers/kbs:v0.10.1
14+ DEFAULT_TRUSTEE_OPERATOR_CSV=trustee-operator.v0.2.0
15+
1416if [ -n " $ITA_KEY " ]; then
1517 DEFAULT_IMAGE+=" -ita"
1618fi
19+
1720TRUSTEE_IMAGE=${TRUSTEE_IMAGE:- $DEFAULT_IMAGE }
21+ TRUSTEE_OPERATOR_CSV=${TRUSTEE_OPERATOR_CSV:- $DEFAULT_TRUSTEE_OPERATOR_CSV }
1822
1923# Function to check if the oc command is available
2024function check_oc() {
@@ -105,6 +109,37 @@ function wait_for_mcp() {
105109
106110}
107111
112+ # Function to approve installPlan tied to specific CSV to be available in specific namespace
113+ approve_installplan_for_target_csv () {
114+ local ns=" $1 "
115+ local target_csv=" $2 "
116+ local timeout=300
117+ local interval=5
118+ local elapsed=0
119+
120+ echo " Waiting for InstallPlan with CSV '$target_csv ' in namespace '$ns '..."
121+
122+ while [ $elapsed -lt " $timeout " ]; do
123+ installplans=$( oc get installplan -n " $ns " -o jsonpath=' {.items[*].metadata.name}' 2> /dev/null)
124+ for ip in $installplans ; do
125+ csvs=$( oc get installplan " $ip " -n " $ns " -o jsonpath=" {.spec.clusterServiceVersionNames[*]}" 2> /dev/null)
126+ for csv in $csvs ; do
127+ if [ " $csv " == " $target_csv " ]; then
128+ echo " Found matching InstallPlan: $ip "
129+ echo " Approving InstallPlan: $ip "
130+ oc patch installplan " $ip " -n " $ns " -p ' {"spec":{"approved":true}}' --type merge || return 1
131+ return 0
132+ fi
133+ done
134+ done
135+ sleep $interval
136+ elapsed=$(( elapsed + interval))
137+ done
138+
139+ echo " Timed out waiting for InstallPlan with CSV '$target_csv ' in namespace '$ns '"
140+ return 1
141+ }
142+
108143# Function to set additional cluster-wide image pull secret
109144# Requires PULL_SECRET_JSON environment variable to be set
110145# eg. PULL_SECRET_JSON='{"my.registry.io": {"auth": "ABC"}}'
@@ -210,6 +245,7 @@ function apply_operator_manifests() {
210245 oc apply -f og.yaml || return 1
211246 if [[ " $GA_RELEASE " == " true" ]]; then
212247 oc apply -f subs-ga.yaml || return 1
248+ approve_installplan_for_target_csv trustee-operator-system " $TRUSTEE_OPERATOR_CSV " || return 1
213249 else
214250 oc apply -f trustee_catalog.yaml || return 1
215251 oc apply -f subs-upstream.yaml || return 1
@@ -363,9 +399,6 @@ check_oc || exit 1
363399# Check if openssl command is available
364400check_openssl || exit 1
365401
366- # Apply the operator manifests
367- apply_operator_manifests || exit 1
368-
369402# If MIRRORING is true, then create the image mirroring config
370403if [ " $MIRRORING " = true ]; then
371404 echo " Creating image mirroring config"
0 commit comments