Skip to content

Commit 6a061de

Browse files
committed
feat: allow customizing family
Signed-off-by: Niccolò Fei <niccolo.fei@enterprisedb.com>
1 parent a30e03e commit 6a061de

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

.github/actions/generate-catalogs/action.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ inputs:
2222
required: false
2323
type: string
2424
default: "."
25+
family:
26+
description: "The family name to assign to the catalogs"
27+
required: false
28+
type: string
2529

2630
runs:
2731
using: composite
@@ -44,6 +48,7 @@ runs:
4448
DISTRIBUTIONS: ${{ inputs.distributions }}
4549
REGEX: ${{ inputs.regex }}
4650
OUTPUT_DIR: ${{ inputs.output-dir }}
51+
FAMILY: ${{ inputs.family }}
4752
run: |
4853
set -euo pipefail
4954
ARGS=()
@@ -66,6 +71,10 @@ runs:
6671
ARGS+=( --regex "$REGEX" )
6772
fi
6873
74+
if [[ -n "${FAMILY:-}" ]]; then
75+
ARGS+=( --family "$FAMILY" )
76+
fi
77+
6978
ARGS+=( --output-dir "$OUTPUT_DIR" )
7079
7180
python "$GITHUB_ACTION_PATH/catalogs_generator.py" "${ARGS[@]}"

.github/actions/generate-catalogs/catalogs_generator.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
min_supported_major = 13
3333

3434
default_registry = "ghcr.io/cloudnative-pg/postgresql"
35+
default_family = "postgresql"
3536
default_regex = r"(\d+)(?:\.\d+|beta\d+|rc\d+|alpha\d+)-(\d{12})"
3637
_token_cache = {"value": None, "expires_at": 0}
3738

@@ -161,9 +162,9 @@ def write_catalog(tags, version_re, img_type, os_name, output_dir="."):
161162
"apiVersion": "postgresql.cnpg.io/v1",
162163
"kind": "ClusterImageCatalog",
163164
"metadata": {
164-
"name": f"postgresql{image_suffix}",
165+
"name": f"{args.family}{image_suffix}",
165166
"labels": {
166-
"images.cnpg.io/family": "postgresql",
167+
"images.cnpg.io/family": args.family,
167168
"images.cnpg.io/type": img_type,
168169
"images.cnpg.io/os": os_name,
169170
"images.cnpg.io/date": time.strftime("%Y%m%d"),
@@ -213,15 +214,24 @@ def write_catalog(tags, version_re, img_type, os_name, output_dir="."):
213214
default=supported_os_names,
214215
help=f"Distributions to retrieve (default: {supported_os_names})",
215216
)
217+
parser.add_argument(
218+
"--family",
219+
default=default_family,
220+
help=f"The family name to assign to the catalogs (default: {default_family})",
221+
)
216222
args = parser.parse_args()
217223

218224
repo_json = get_json(args.registry)
219225
tags = repo_json["Tags"]
220226

227+
filename_prefix = "catalog"
228+
if args.family != default_family:
229+
filename_prefix = f"{args.family}"
230+
221231
catalogs = []
222232
for img_type in args.image_types:
223233
for os_name in args.distributions:
224-
filename = f"catalog-{img_type}-{os_name}.yaml"
234+
filename = f"{filename_prefix}-{img_type}-{os_name}.yaml"
225235
print(f"Generating {filename}")
226236
write_catalog(tags, args.regex, img_type, os_name, args.output_dir)
227237
catalogs.append(filename)

0 commit comments

Comments
 (0)