def get_lso_channel(): """ Get the channel to use for installing the local storage operator Returns: str: local storage operator channel """ ocp_version = get_ocp_version() # If OCP version is not GA, we will be using the Optional Operators CatalogSource # This means there are two PackageManifests with the name local-storage-operator # so we need to also use a selector to ensure we retrieve the correct one ocp_ga_version = get_ocp_ga_version(ocp_version) selector = constants.OPTIONAL_OPERATORS_SELECTOR if not ocp_ga_version else None # Retrieve available channels for LSO package_manifest = PackageManifest( resource_name=constants.LOCAL_STORAGE_CSV_PREFIX, selector=selector) channels = package_manifest.get_channels() channel_names = [channel["name"] for channel in channels] # Ensure channel_names is sorted versions = [ LooseVersion(name) for name in channel_names if name != "stable" ] versions.sort() sorted_versions = [v.vstring for v in versions] if ocp_version in channel_names: # Use channel corresponding to OCP version return ocp_version else: # Use latest channel return sorted_versions[-1]
def get_lso_channel(): """ Get the channel to use for installing the local storage operator Returns: str: local storage operator channel """ ocp_version = get_ocp_version() # Retrieve available channels for LSO package_manifest = PackageManifest( resource_name=constants.LOCAL_STORAGE_CSV_PREFIX) channels = package_manifest.get_channels() channel_names = [channel['name'] for channel in channels] # Ensure channel_names is sorted versions = [LooseVersion(name) for name in channel_names] versions.sort() sorted_versions = [v.vstring for v in versions] if ocp_version in channel_names: # Use channel corresponding to OCP version return ocp_version else: # Use latest channel return sorted_versions[-1]