Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 33 additions & 7 deletions scripts/generate-olm.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@
Requirements:
- uv (https://docs.astral.sh/uv/) — installs PyYAML automatically
- helm (https://helm.sh)
- git (createdAt is the commit date of the checked-out release tag)
"""

import argparse
import subprocess
import datetime
import json
import urllib.request
import subprocess
import urllib.error
import urllib.request
from pathlib import Path

import yaml


SCRIPT_DIR = Path(__file__).parent.resolve()
REPO_ROOT = SCRIPT_DIR.parent
HELM_CHART = REPO_ROOT / "deploy" / "helm" / "listener-operator"
Expand Down Expand Up @@ -1179,9 +1180,7 @@ def build_configmap(
key = "storageclass.yaml"
elif kind == "Service":
key = "service.yaml"
elif kind == "DaemonSet":
key = f"{name}.yaml"
elif kind == "Deployment":
elif kind == "DaemonSet" or kind == "Deployment":
key = f"{name}.yaml"
else:
continue
Expand Down Expand Up @@ -1286,6 +1285,32 @@ def min_kube_version(release: str) -> str:
return lowest_kube_version(platforms)


def created_at() -> str:
"""Return the commit date of the checked-out commit, so createdAt stays the same when the bundle is rebuilt."""
try:
result = subprocess.run(
["git", "log", "-1", "--format=%ct"],
capture_output=True,
text=True,
check=True,
cwd=REPO_ROOT,
)
except subprocess.CalledProcessError as exc:
raise RuntimeError(f"Failed to read the commit date: {exc.stderr}") from exc
return format_created_at(int(result.stdout))


def format_created_at(epoch_seconds: int) -> str:
"""Format a Unix timestamp the way OLM bundles write createdAt, in UTC.

>>> format_created_at(1784628000)
'2026-07-21T10:00:00Z'
"""
return datetime.datetime.fromtimestamp(epoch_seconds, tz=datetime.UTC).strftime(
"%Y-%m-%dT%H:%M:%SZ"
)


def build_csv(
version: str,
helm_docs: list[dict],
Expand Down Expand Up @@ -1379,7 +1404,7 @@ def build_csv(
"operatorframework.io/suggested-namespace": "stackable-operators",
"features.operators.openshift.io/cnf": "false",
"features.operators.openshift.io/cni": "false",
"features.operators.openshift.io/csi": "false",
"features.operators.openshift.io/csi": "true",
"features.operators.openshift.io/disconnected": "false",
"features.operators.openshift.io/fips-compliant": "false",
"features.operators.openshift.io/proxy-aware": "false",
Expand All @@ -1392,6 +1417,7 @@ def build_csv(
"capabilities": "Basic Install",
"description": chart["description"],
"repository": "https://github.com/stackabletech/listener-operator",
"createdAt": created_at(),
"com.redhat.openshift.versions": openshift_versions,
},
},
Expand Down
Loading