Skip to content

Commit db8fd12

Browse files
[patch] fallback for master catalog
1 parent 638f68c commit db8fd12

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/mas/devops/data/__init__.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,34 @@ class NoSuchCatalogError(Exception):
2424
pass
2525

2626

27-
def getCatalog(name: str) -> dict:
27+
def getCatalog(name: str) -> dict | None:
2828
"""
2929
Load a specific IBM Operator Catalog definition by name.
3030
3131
This function reads a catalog YAML file from the catalogs directory and returns
32-
its contents as a dictionary.
32+
its contents as a dictionary. Special handling for "master" catalogs: returns None
33+
to allow fallback to the newest catalog via Ansible playbook logic.
3334
3435
Args:
35-
name (str): The catalog name/tag (e.g., "v9-241205-amd64", "v8-240528-amd64").
36+
name (str): The catalog name/tag (e.g., "v9-241205-amd64", "v8-240528-amd64", "v9-master-amd64").
3637
3738
Returns:
3839
dict: The catalog definition dictionary containing operator versions and metadata.
40+
Returns None for master catalogs to trigger fallback logic.
3941
4042
Raises:
41-
NoSuchCatalogError: If the specified catalog does not exist.
43+
NoSuchCatalogError: If the specified catalog does not exist (except for master catalogs).
4244
"""
4345
moduleFile = path.abspath(__file__)
4446
modulePath = path.dirname(moduleFile)
4547
catalogFileName = f"{name}.yaml"
4648

4749
pathToCatalog = path.join(modulePath, "catalogs", catalogFileName)
4850
if not path.exists(pathToCatalog):
51+
# Special handling for master catalogs - return None to trigger fallback
52+
if "master" in name.lower():
53+
return None
54+
4955
raise NoSuchCatalogError(
5056
f"Catalog {name} is unknown: {pathToCatalog} does not exist"
5157
)
@@ -184,5 +190,8 @@ def getCatalogEditorial(catalogTag: str) -> dict | None:
184190
or has no editorial content.
185191
"""
186192
catalog = getCatalog(catalogTag)
193+
194+
if catalog is None:
195+
return None
187196

188197
return catalog.get("editorial")

0 commit comments

Comments
 (0)