Skip to content

Commit f233f93

Browse files
authored
chore(olm): Remove the unused listener and secret values files (#136)
* chore(olm): Remove the unused listener and secret values files * feat(olm): Set createdAt to the commit date of the release tag
1 parent 33e7799 commit f233f93

3 files changed

Lines changed: 28 additions & 59 deletions

File tree

‎olm/build-manifests.py‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@
2828
Requirements:
2929
- uv (https://docs.astral.sh/uv/) — installs PyYAML automatically
3030
- helm (https://helm.sh)
31+
- git (createdAt is the commit date of the checked-out release tag)
3132
"""
3233

3334
import argparse
35+
import datetime
3436
import json
3537
import logging
3638
import os
@@ -399,6 +401,7 @@ def generate_csv(
399401
result["spec"]["minKubeVersion"] = min_kube_version(args.release)
400402
result["metadata"]["name"] = f"{csv_name}.v{args.release}"
401403
result["metadata"]["annotations"]["containerImage"] = related_images[0]["image"]
404+
result["metadata"]["annotations"]["createdAt"] = created_at(args.repo_operator)
402405
result["metadata"]["annotations"]["description"] = chart["description"]
403406
result["metadata"]["annotations"]["capabilities"] = listing["capabilities"]
404407
result["metadata"]["annotations"]["categories"] = listing["categories"]
@@ -431,6 +434,31 @@ def generate_csv(
431434
return result
432435

433436

437+
def created_at(repo: pathlib.Path) -> str:
438+
"""Return the commit date of the checked-out commit, so createdAt stays the same when the bundle is rebuilt."""
439+
try:
440+
completed_proc = subprocess.run(
441+
["git", "-C", str(repo), "log", "-1", "--format=%ct"],
442+
capture_output=True,
443+
check=True,
444+
)
445+
except subprocess.CalledProcessError as e:
446+
logging.error(e.stderr.decode("utf-8"))
447+
raise ManifestException(f'Failed to read the commit date of "{repo}"')
448+
return format_created_at(int(completed_proc.stdout))
449+
450+
451+
def format_created_at(epoch_seconds: int) -> str:
452+
"""Format a Unix timestamp the way OLM bundles write createdAt, in UTC.
453+
454+
>>> format_created_at(1784628000)
455+
'2026-07-21T10:00:00Z'
456+
"""
457+
return datetime.datetime.fromtimestamp(
458+
epoch_seconds, tz=datetime.timezone.utc
459+
).strftime("%Y-%m-%dT%H:%M:%SZ")
460+
461+
434462
def load_chart(args: argparse.Namespace) -> dict:
435463
chart_path = args.repo_operator / "deploy" / "helm" / args.op_name / "Chart.yaml"
436464
return yaml.load(chart_path.read_text(), Loader=yaml.SafeLoader)

‎olm/resources/values/listener-operator/values.yaml‎

Lines changed: 0 additions & 29 deletions
This file was deleted.

‎olm/resources/values/secret-operator/values.yaml‎

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)