Skip to content

Commit 3e2c316

Browse files
committed
Add support for overriding images of target containers
1 parent d2448ba commit 3e2c316

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

operator/crd.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ spec:
112112
description: Override the entrypoint of specific containers in the target Deployment or Statefulset when mounting the code volume.
113113
additionalProperties:
114114
type: string
115+
images:
116+
type: object
117+
description: Override the image of specific containers in the target Deployment or Statefulset when mounting the code volume.
115118
mounted:
116119
type: boolean
117120
description: Whether the volume should actually be mounted.

operator/op.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,3 +311,19 @@ def restore_entrypoints(*, manifest: dict, entrypoints: dict) -> None:
311311
if container.get("command"):
312312
del container["command"]
313313
del container["args"]
314+
315+
316+
def update_images(*, manifest: dict, images: dict) -> None:
317+
for container in manifest["spec"]["template"]["spec"]["containers"]:
318+
image = images.get(container["name"])
319+
if image is None:
320+
continue
321+
container["x-original-image"] = container["image"]
322+
container["image"] = image
323+
324+
325+
def restore_images(*, manifest: dict) -> None:
326+
for container in manifest["spec"]["template"]["spec"]["containers"]:
327+
if container.get("x-original-image"):
328+
container["image"] = container["x-original-image"]
329+
del container["x-original-image"]

0 commit comments

Comments
 (0)