@@ -24,37 +24,55 @@ class NoSuchCatalogError(Exception):
2424 pass
2525
2626
27- def getCatalog (name : str ) -> dict | None :
27+ def getCatalog (name : str ) -> dict :
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. Special handling for "master" catalogs: returns None
33- to allow fallback to the newest catalog via Ansible playbook logic.
32+ its contents as a dictionary. Special handling for dev/master catalogs: if a catalog
33+ doesn't exist and matches dev patterns (master, branch names), automatically resolves
34+ to the newest catalog for that architecture.
3435
3536 Args:
3637 name (str): The catalog name/tag (e.g., "v9-241205-amd64", "v8-240528-amd64", "v9-master-amd64").
3738
3839 Returns:
3940 dict: The catalog definition dictionary containing operator versions and metadata.
40- Returns None for master catalogs to trigger fallback logic .
41+ For dev catalogs, returns the newest catalog data for that architecture .
4142
4243 Raises:
43- NoSuchCatalogError: If the specified catalog does not exist (except for master catalogs) .
44+ NoSuchCatalogError: If the specified catalog does not exist and is not a dev catalog pattern .
4445 """
4546 moduleFile = path .abspath (__file__ )
4647 modulePath = path .dirname (moduleFile )
4748 catalogFileName = f"{ name } .yaml"
4849
4950 pathToCatalog = path .join (modulePath , "catalogs" , catalogFileName )
5051 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-
55- raise NoSuchCatalogError (
56- f"Catalog { name } is unknown: { pathToCatalog } does not exist"
57- )
52+ # Check if this looks like a dev catalog (master or branch name pattern)
53+ parts = name .split ("-" )
54+ if len (parts ) >= 3 :
55+ middle_part = parts [1 ] # e.g., "master", "branchname", or "241205"
56+ arch = parts [- 1 ] # e.g., "amd64"
57+
58+ # Validate catalog format
59+ is_dev_catalog = not (middle_part .isdigit () and len (middle_part ) == 6 )
60+
61+ if is_dev_catalog :
62+ try :
63+ newestCatalog = getNewestCatalogTag (arch )
64+ catalogFileName = f"{ newestCatalog } .yaml"
65+ pathToCatalog = path .join (modulePath , "catalogs" , catalogFileName )
66+ except NoSuchCatalogError :
67+ raise NoSuchCatalogError (
68+ f"Catalog { name } appears to be a dev catalog, but no catalogs found for architecture { arch } "
69+ )
70+
71+ # Final check if the resolved path exists
72+ if not path .exists (pathToCatalog ):
73+ raise NoSuchCatalogError (
74+ f"Catalog { name } is unknown: { pathToCatalog } does not exist"
75+ )
5876
5977 with open (pathToCatalog ) as stream :
6078 return yaml .safe_load (stream )
@@ -186,12 +204,7 @@ def getCatalogEditorial(catalogTag: str) -> dict | None:
186204
187205 Returns:
188206 dict: Dictionary with 'whats_new' and 'known_issues' keys containing
189- structured lists. Returns None if catalog doesn't exist
190- or has no editorial content.
207+ structured lists. Returns None if catalog has no editorial content.
191208 """
192209 catalog = getCatalog (catalogTag )
193-
194- if catalog is None :
195- return None
196-
197210 return catalog .get ("editorial" )
0 commit comments