Skip to content

Commit dff271f

Browse files
committed
chore: disable previews and add labels
Signed-off-by: Niccolò Fei <niccolo.fei@enterprisedb.com>
1 parent 7048fe0 commit dff271f

1 file changed

Lines changed: 25 additions & 18 deletions

File tree

.github/catalogs_generator.py

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
from packaging import version
2828
from subprocess import check_output
2929

30+
supported_img_types = ["minimal", "standard", "system"]
31+
supported_os_names = ["bullseye", "bookworm", "trixie"]
3032
min_supported_major = 13
3133

3234
repo_name = "cloudnative-pg/postgresql"
@@ -81,15 +83,20 @@ def get_digest(repository_name, tag):
8183
return digest
8284

8385

84-
def write_catalog(tags, version_re, suffix, output_dir="."):
85-
version_re = re.compile(rf"^{version_re}{re.escape(suffix)}$")
86+
def write_catalog(tags, version_re, img_type, os_name, output_dir="."):
87+
image_suffix = f"-{img_type}-{os_name}"
88+
version_re = re.compile(rf"^{version_re}{re.escape(image_suffix)}$")
8689

8790
# Filter out all the tags which do not match the version regexp
8891
tags = [item for item in tags if version_re.search(item)]
8992

93+
# Filter out preview versions
94+
exclude_preview = re.compile(r"(alpha|beta|rc)")
95+
tags = [item for item in tags if not exclude_preview.search(item)]
96+
9097
# Sort the tags according to semantic versioning
9198
tags.sort(
92-
key=lambda v: version.Version(v.removesuffix(suffix)),
99+
key=lambda v: version.Version(v.removesuffix(image_suffix)),
93100
reverse=True
94101
)
95102

@@ -112,7 +119,16 @@ def write_catalog(tags, version_re, suffix, output_dir="."):
112119
catalog = {
113120
"apiVersion": "postgresql.cnpg.io/v1",
114121
"kind": "ClusterImageCatalog",
115-
"metadata": {"name": f"postgresql{suffix}"},
122+
"metadata": {
123+
"name": f"postgresql{image_suffix}",
124+
"labels": {
125+
"images.cnpg.io/family": "postgresql",
126+
"images.cnpg.io/type": img_type,
127+
"images.cnpg.io/os": os_name,
128+
"images.cnpg.io/date": time.strftime("%Y%m%d"),
129+
"images.cnpg.io/publisher": "github.com/cloudnative-pg",
130+
},
131+
},
116132
"spec": {
117133
"images": [
118134
{"major": int(major), "image": images[0]} for major, images in sorted(results.items(), key=lambda x: int(x[0]))
@@ -121,7 +137,7 @@ def write_catalog(tags, version_re, suffix, output_dir="."):
121137
}
122138

123139
os.makedirs(output_dir, exist_ok=True)
124-
output_file = os.path.join(output_dir, f"catalog{suffix}.yaml")
140+
output_file = os.path.join(output_dir, f"catalog{image_suffix}.yaml")
125141
with open(output_file, "w") as f:
126142
yaml.dump(catalog, f, sort_keys=False)
127143

@@ -134,16 +150,7 @@ def write_catalog(tags, version_re, suffix, output_dir="."):
134150
repo_json = get_json(full_repo_name)
135151
tags = repo_json["Tags"]
136152

137-
for suffix in [
138-
"-minimal-bullseye",
139-
"-standard-bullseye",
140-
"-system-bullseye",
141-
"-minimal-bookworm",
142-
"-standard-bookworm",
143-
"-system-bookworm",
144-
"-minimal-trixie",
145-
"-standard-trixie",
146-
"-system-trixie",
147-
]:
148-
print(f"Generating catalog{suffix}.yaml")
149-
write_catalog(tags, pg_regexp, suffix, args.output_dir)
153+
for img_type in supported_img_types:
154+
for os_name in supported_os_names:
155+
print(f"Generating catalog-{img_type}-{os_name}.yaml")
156+
write_catalog(tags, pg_regexp, img_type, os_name, args.output_dir)

0 commit comments

Comments
 (0)