Skip to content

Commit b466b6e

Browse files
authored
fix(olm-manifests): include webhook service (#120)
1 parent 14e654e commit b466b6e

2 files changed

Lines changed: 23 additions & 17 deletions

File tree

olm/build-bundles.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ bundle-deploy() {
118118
}
119119

120120
ensure_operator_sdk() {
121-
local OPERATOR_SDK_VERSION=v1.39.1
121+
local OPERATOR_SDK_VERSION=v1.42.0
122122
OPERATOR_SDK="$HOME/.local/bin/operator-sdk"
123123

124124
set +e

olm/build-manifests.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,15 @@ def write_manifests(args: argparse.Namespace, manifests: list[dict]) -> None:
303303
logging.info(f"Creating directory {manifests_dir}")
304304
os.makedirs(manifests_dir)
305305

306+
# The following objects are written as separate files:
307+
# - crds
308+
# - cluster service version
309+
# - cluster roles
310+
# - services
311+
# - config maps
312+
# The other objects are embedded in the CSV. These are:
313+
# - the operator cluster role (N.B. some products have more than one cluster role e.g. HDFS)
314+
# - the operator deployment
306315
for m in manifests:
307316
dest_file = None
308317
if m["kind"] == "ClusterServiceVersion":
@@ -317,27 +326,24 @@ def write_manifests(args: argparse.Namespace, manifests: list[dict]) -> None:
317326
/ "manifests"
318327
/ f"{m['metadata']['name']}.customresourcedefinition.yaml"
319328
)
320-
# Only the product cluster role and the product configmap are dumped as individual files
321-
# The other objects are embedded in the CSV. These are:
322-
# - the operator cluster role (N.B. some products have more than one cluster role e.g. HDFS)
323-
# - the operator deployment
324-
elif m["kind"] == "ClusterRole" and (
325-
m["metadata"]["name"] == f"{args.product}-clusterrole"
326-
or m["metadata"]["name"] == f"{args.product}-clusterrole-nodes"
327-
):
328-
dest_file = (
329-
args.dest_dir / "manifests" / f"{m['metadata']['name']}.yaml"
330-
)
331-
elif (
332-
m["kind"] == "ConfigMap"
333-
and m["metadata"]["name"] == f"{args.op_name}-configmap"
334-
):
329+
elif m["kind"] in ["ClusterRole", "ConfigMap", "Service"]:
330+
kind = m["kind"].lower()
331+
name = m["metadata"]["name"]
332+
# Some objects contain the kind in their name already while others (looking at you webhook service) do not.
333+
# To avoid conflicting file names we append the kind if it's not already part of the object name.
334+
if kind not in m['metadata']['name']:
335+
name = f"{name}-{kind}"
336+
335337
dest_file = (
336-
args.dest_dir / "manifests" / f"{m['metadata']['name']}.yaml"
338+
args.dest_dir / "manifests" / f"{name}.yaml"
337339
)
338340

339341
if dest_file:
340342
logging.info(f"Writing {dest_file}")
343+
if dest_file.exists():
344+
raise ManifestException(
345+
f"Manifest file '{dest_file}' already exists"
346+
)
341347
dest_file.write_text(yaml.dump(m))
342348

343349
except FileExistsError:

0 commit comments

Comments
 (0)