diff --git a/hack/patch_catalog.py b/hack/patch_catalog.py new file mode 100644 index 000000000..f218577c2 --- /dev/null +++ b/hack/patch_catalog.py @@ -0,0 +1,31 @@ +import os +from sys import exit as sys_exit +from datetime import datetime +from ruamel.yaml import YAML +yaml = YAML() +yaml.explicit_start = True + +version = os.getenv('VERSION') +bundle_image = 'registry.redhat.io/network-observability/network-observability-operator-bundle@v{}'.format(version) + +def load_index(pathn): + if not pathn.endswith(".yaml"): + return None + try: + with open(pathn, "r") as f: + return list(yaml.load_all(f)) + except FileNotFoundError: + print("File can not found") + exit(6) + +def dump_index(pathn, index): + with open(pathn, "w") as f: + for o in index: + yaml.dump(o, f) + return + +index = load_index(os.getenv('TARGET_INDEX_FILE')) + +index[1]["image"] = bundle_image + +dump_index(os.getenv('TARGET_INDEX_FILE'), index) diff --git a/hack/update-build.sh b/hack/update-build.sh index bacf4aadd..875c990a0 100755 --- a/hack/update-build.sh +++ b/hack/update-build.sh @@ -18,6 +18,7 @@ crd_name="flows.netobserv.io_flowcollectors.yaml" crd_file="${manifests_dir}/${crd_name}" csv_name="netobserv-operator.clusterserviceversion.yaml" csv_file="${manifests_dir}/${csv_name}" +index_file="./catalog/index.yaml" cat <>"${CONTAINER_FILE}" LABEL com.redhat.component="network-observability-operator-container" @@ -69,6 +70,7 @@ export EPOC_TIMESTAMP=$(date +%s) export IN_CSV_DESC="./config/descriptions/ocp.md" REPLACES="${REPLACE_VERSION}" VERSION="${TARGET_VERSION}" TARGET_CSV_FILE="${csv_file}" python3 ./hack/patch_csv.py +REPLACES="${REPLACE_VERSION}" VERSION="${TARGET_VERSION}" TARGET_INDEX_FILE="${index_file}" python3 ./hack/patch_catalog.py sed -i 's/operators.operatorframework.io.bundle.channels.v1: latest,community/operators.operatorframework.io.bundle.channels.v1: stable/g' ./bundle/metadata/annotations.yaml sed -i 's/operators.operatorframework.io.bundle.channel.default.v1: community/operators.operatorframework.io.bundle.channel.default.v1: stable/g' ./bundle/metadata/annotations.yaml