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 c3e4cdc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/mounts-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
labels: ${LABELS}
entrypoints:
${ENTRYPOINTS}
images:
${IMAGES}
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 c3e4cdc

Please sign in to comment.