Skip to content

Commit 854e681

Browse files
authored
Ignore certified-operators if found another catalogsource (#2595)
* ignore certified-operators if we found 2 catalogsource Signed-off-by: Allen Li <[email protected]> * remove message Signed-off-by: Allen Li <[email protected]> --------- Signed-off-by: Allen Li <[email protected]>
1 parent 4e7abda commit 854e681

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

cp3pt0-deployment/common/utils.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,28 @@ function get_catalogsource() {
616616
# Extracting the values using string manipulation
617617
catalog_source=$(echo "$result" | awk -F': ' '{print $2}' | awk -F',' '{print $1}')
618618
catalog_namespace=$(echo "$result" | awk -F': ' '{print $NF}')
619+
elif [[ count -eq 2 ]]; then
620+
# If there are two catalog sources,
621+
# case 1: "catalog_source_1" and "catalog_source_2", we return both of them
622+
# case 2: "certified-operators" and "catalog_source_2", we only return "catalog_source_2"
623+
# Split the result into lines
624+
IFS=$'\n' read -rd '' -a lines <<< "$result"
625+
626+
for ((i = 0; i < ${#lines[@]}; i+=2)); do
627+
name_line=${lines[$i]}
628+
ns_line=${lines[$i+1]}
629+
name=$(echo "$name_line" | awk -F': ' '{print $2}')
630+
ns=$(echo "$ns_line" | awk -F': ' '{print $2}')
631+
# If the catalog source is not "certified-operators", we use it
632+
if [[ "$name" != "certified-operators" ]]; then
633+
catalog_source=$name
634+
catalog_namespace=$ns
635+
else
636+
# If the catalog source is "certified-operators", we skip it
637+
count=1
638+
continue
639+
fi
640+
done
619641
fi
620642
echo "$count $catalog_source $catalog_namespace"
621643
}

0 commit comments

Comments
 (0)