Skip to content

Commit 82f739d

Browse files
committed
remove crds
1 parent bf7a9b2 commit 82f739d

1 file changed

Lines changed: 7 additions & 71 deletions

File tree

scripts/generate-olm.py

Lines changed: 7 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"""
99
Generate OpenShift OLM (Operator Lifecycle Manager) manifests for the Stackable Secret Operator.
1010
11-
The script renders the Helm chart, generates CRDs via cargo, looks up image digests on
11+
The script renders the Helm chart, looks up image digests on
1212
quay.io, and writes a complete OLM bundle under deploy/olm/<version>/.
1313
1414
Usage:
@@ -17,9 +17,6 @@
1717
# Or directly with python3 (PyYAML must be installed):
1818
python3 scripts/generate-olm.py --version 26.3.0 --openshift-versions v4.18-v4.21
1919
20-
# Skip the cargo CRD build (use existing extra/crds.yaml):
21-
uv run --script scripts/generate-olm.py --version 26.3.0 --openshift-versions v4.18-v4.21 --skip-crd-build
22-
2320
Requirements:
2421
- uv (https://docs.astral.sh/uv/) — installs PyYAML automatically
2522
- helm (https://helm.sh)
@@ -1076,19 +1073,6 @@ def render_helm(version: str) -> list[dict]:
10761073
return [d for d in yaml.safe_load_all(result.stdout) if d is not None]
10771074

10781075

1079-
def get_crds() -> list[dict]:
1080-
"""Generate CRD manifests by running the operator binary with the 'crd' subcommand."""
1081-
print(" Running: cargo run --bin stackable-secret-operator -- crd")
1082-
result = subprocess.run(
1083-
["cargo", "run", "--bin", "stackable-secret-operator", "--", "crd"],
1084-
capture_output=True,
1085-
text=True,
1086-
check=True,
1087-
cwd=REPO_ROOT,
1088-
)
1089-
return [d for d in yaml.safe_load_all(result.stdout) if d is not None]
1090-
1091-
10921076
def load_values() -> dict:
10931077
with open(HELM_CHART / "values.yaml") as fh:
10941078
return yaml.safe_load(fh)
@@ -1224,22 +1208,6 @@ def build_configmap(
12241208
}
12251209

12261210

1227-
def _crd_owned_entry(crd: dict) -> dict:
1228-
spec = crd.get("spec", {})
1229-
kind = spec["names"]["kind"]
1230-
storage_version = next(
1231-
(v["name"] for v in spec.get("versions", []) if v.get("storage", False)),
1232-
spec["versions"][0]["name"] if spec.get("versions") else "v1alpha1",
1233-
)
1234-
return {
1235-
"description": f"{kind} resource managed by the Stackable Secret Operator.",
1236-
"displayName": kind,
1237-
"kind": kind,
1238-
"name": crd["metadata"]["name"],
1239-
"version": storage_version,
1240-
}
1241-
1242-
12431211
def _operator_cluster_rules(helm_docs: list[dict]) -> list[dict]:
12441212
for doc in helm_docs:
12451213
if doc.get("kind") == "ClusterRole":
@@ -1250,7 +1218,6 @@ def _operator_cluster_rules(helm_docs: list[dict]) -> list[dict]:
12501218
def build_csv(
12511219
version: str,
12521220
helm_docs: list[dict],
1253-
crds: list[dict],
12541221
images: dict[str, str],
12551222
icon_b64: str,
12561223
openshift_versions: str = "v4.18-v4.21",
@@ -1406,7 +1373,6 @@ def build_csv(
14061373
"deployments": [deployer_deployment],
14071374
},
14081375
},
1409-
"customresourcedefinitions": {"owned": [_crd_owned_entry(c) for c in crds]},
14101376
},
14111377
}
14121378

@@ -1460,11 +1426,6 @@ def main() -> None:
14601426
metavar="VERSION",
14611427
help="Operator version string, e.g. 26.3.0",
14621428
)
1463-
parser.add_argument(
1464-
"--skip-crd-build",
1465-
action="store_true",
1466-
help="Skip the cargo build; reuse extra/crds.yaml if it exists",
1467-
)
14681429
parser.add_argument(
14691430
"--openshift-versions",
14701431
metavar="RANGE",
@@ -1499,7 +1460,7 @@ def main() -> None:
14991460
# ------------------------------------------------------------------
15001461
# 1. Load values.yaml
15011462
# ------------------------------------------------------------------
1502-
print("[1/6] Reading Helm values.yaml ...")
1463+
print("[1/4] Reading Helm values.yaml ...")
15031464
values = load_values()
15041465
sidecars = sidecar_image_info(values)
15051466
main_oci_repo: str = values["image"]["repository"]
@@ -1508,7 +1469,7 @@ def main() -> None:
15081469
# ------------------------------------------------------------------
15091470
# 2. Look up quay.io image digests
15101471
# ------------------------------------------------------------------
1511-
print("[2/6] Resolving image digests on quay.io ...")
1472+
print("[2/4] Resolving image digests on quay.io ...")
15121473

15131474
print(f" {main_quay_repo}:{version}")
15141475
main_digest = get_quay_digest(main_quay_repo, version)
@@ -1535,39 +1496,14 @@ def main() -> None:
15351496
# ------------------------------------------------------------------
15361497
# 3. Render Helm chart
15371498
# ------------------------------------------------------------------
1538-
print("[3/6] Rendering Helm chart ...")
1499+
print("[3/4] Rendering Helm chart ...")
15391500
helm_docs = render_helm(version)
15401501
print(f" -> {len(helm_docs)} Kubernetes resources")
15411502

15421503
# ------------------------------------------------------------------
1543-
# 4. Generate / load CRDs
1544-
# ------------------------------------------------------------------
1545-
crd_cache = REPO_ROOT / "extra" / "crds.yaml"
1546-
if args.skip_crd_build and crd_cache.exists():
1547-
print(
1548-
f"[4/6] Loading CRDs from {crd_cache.relative_to(REPO_ROOT)} (--skip-crd-build) ..."
1549-
)
1550-
with open(crd_cache) as fh:
1551-
crds = [d for d in yaml.safe_load_all(fh) if d is not None]
1552-
else:
1553-
print("[4/6] Generating CRDs via cargo ...")
1554-
crds = get_crds()
1555-
print(f" -> {len(crds)} CRD(s)")
1556-
1557-
# ------------------------------------------------------------------
1558-
# 5. Use embedded Stackable logo icon
1559-
# ------------------------------------------------------------------
1560-
icon_b64 = _STACKABLE_ICON_B64
1561-
1562-
# ------------------------------------------------------------------
1563-
# 6. Write output files
1504+
# 4. Write output files
15641505
# ------------------------------------------------------------------
1565-
print(f"[6/6] Writing OLM bundle to {output_dir} ...")
1566-
1567-
# CRD files (one per CRD)
1568-
for crd in crds:
1569-
crd_name = crd["metadata"]["name"]
1570-
write_yaml(output_dir / "manifests" / f"{crd_name}.crd.yaml", crd)
1506+
print(f"[4/4] Writing OLM bundle to {output_dir} ...")
15711507

15721508
# tag_map: quay.io@digest -> human tag (for inline ``# <tag>`` comments)
15731509
tag_map: dict[str, str] = {
@@ -1584,7 +1520,7 @@ def main() -> None:
15841520

15851521
# ClusterServiceVersion
15861522
csv = build_csv(
1587-
version, helm_docs, crds, final_images, icon_b64, openshift_versions
1523+
version, helm_docs, final_images, _STACKABLE_ICON_B64, openshift_versions
15881524
)
15891525
csv_filename = f"stackable-secret-operator.v{version}.clusterserviceversion.yaml"
15901526
csv_path = output_dir / "manifests" / csv_filename

0 commit comments

Comments
 (0)