Skip to content

Commit

Permalink
Add support for overriding images of target containers
Browse files Browse the repository at this point in the history
  • Loading branch information
d-mo committed Jun 4, 2024
1 parent d2448ba commit 3e2c316
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions operator/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ spec:
description: Override the entrypoint of specific containers in the target Deployment or Statefulset when mounting the code volume.
additionalProperties:
type: string
images:
type: object
description: Override the image of specific containers in the target Deployment or Statefulset when mounting the code volume.
mounted:
type: boolean
description: Whether the volume should actually be mounted.
Expand Down
16 changes: 16 additions & 0 deletions operator/op.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,3 +311,19 @@ def restore_entrypoints(*, manifest: dict, entrypoints: dict) -> None:
if container.get("command"):
del container["command"]
del container["args"]


def update_images(*, manifest: dict, images: dict) -> None:
for container in manifest["spec"]["template"]["spec"]["containers"]:
image = images.get(container["name"])
if image is None:
continue
container["x-original-image"] = container["image"]
container["image"] = image


def restore_images(*, manifest: dict) -> None:
for container in manifest["spec"]["template"]["spec"]["containers"]:
if container.get("x-original-image"):
container["image"] = container["x-original-image"]
del container["x-original-image"]

0 comments on commit 3e2c316

Please sign in to comment.