3232min_supported_major = 13
3333
3434default_registry = "ghcr.io/cloudnative-pg/postgresql"
35+ default_family = "postgresql"
3536default_regex = r"(\d+)(?:\.\d+|beta\d+|rc\d+|alpha\d+)-(\d{12})"
3637_token_cache = {"value" : None , "expires_at" : 0 }
3738
@@ -124,6 +125,14 @@ def get_digest(repository_name, tag):
124125 return digest
125126
126127
128+ def get_filename (family , img_type , os ):
129+ filename_prefix = "catalog"
130+ if family != default_family :
131+ filename_prefix = family
132+
133+ return f"{ filename_prefix } -{ img_type } -{ os } .yaml"
134+
135+
127136def write_catalog (tags , version_re , img_type , os_name , output_dir = "." ):
128137 image_suffix = f"-{ img_type } -{ os_name } "
129138 version_re = re .compile (rf"^{ version_re } { re .escape (image_suffix )} $" )
@@ -161,9 +170,9 @@ def write_catalog(tags, version_re, img_type, os_name, output_dir="."):
161170 "apiVersion" : "postgresql.cnpg.io/v1" ,
162171 "kind" : "ClusterImageCatalog" ,
163172 "metadata" : {
164- "name" : f"postgresql { image_suffix } " ,
173+ "name" : f"{ args . family } { image_suffix } " ,
165174 "labels" : {
166- "images.cnpg.io/family" : "postgresql" ,
175+ "images.cnpg.io/family" : args . family ,
167176 "images.cnpg.io/type" : img_type ,
168177 "images.cnpg.io/os" : os_name ,
169178 "images.cnpg.io/date" : time .strftime ("%Y%m%d" ),
@@ -179,7 +188,7 @@ def write_catalog(tags, version_re, img_type, os_name, output_dir="."):
179188 }
180189
181190 os .makedirs (output_dir , exist_ok = True )
182- output_file = os .path .join (output_dir , f"catalog { image_suffix } .yaml" )
191+ output_file = os .path .join (output_dir , get_filename ( args . family , img_type , os_name ) )
183192 with open (output_file , "w" ) as f :
184193 yaml .dump (catalog , f , sort_keys = False )
185194
@@ -213,6 +222,11 @@ def write_catalog(tags, version_re, img_type, os_name, output_dir="."):
213222 default = supported_os_names ,
214223 help = f"Distributions to retrieve (default: { supported_os_names } )" ,
215224 )
225+ parser .add_argument (
226+ "--family" ,
227+ default = default_family ,
228+ help = f"The family name to assign to the catalogs (default: { default_family } )" ,
229+ )
216230 args = parser .parse_args ()
217231
218232 repo_json = get_json (args .registry )
@@ -221,7 +235,7 @@ def write_catalog(tags, version_re, img_type, os_name, output_dir="."):
221235 catalogs = []
222236 for img_type in args .image_types :
223237 for os_name in args .distributions :
224- filename = f"catalog- { img_type } - { os_name } .yaml"
238+ filename = get_filename ( args . family , img_type , os )
225239 print (f"Generating { filename } " )
226240 write_catalog (tags , args .regex , img_type , os_name , args .output_dir )
227241 catalogs .append (filename )
0 commit comments