diff --git a/operator/crd/crd.yaml b/operator/crd/crd.yaml index 507ec46..2938859 100644 --- a/operator/crd/crd.yaml +++ b/operator/crd/crd.yaml @@ -51,6 +51,9 @@ spec: type: object additionalProperties: type: string + image: + description: "Container image to use for this IntegrationRoute. Overrides the cluster-wide default integration image set in the controller configuration." + type: string routeConfigMap: description: "Name of a ConfigMap containing integration route definitions. The ConfigMap should be in the same namespace as the IntegrationRoute resource" type: string diff --git a/webapp/core/sync.py b/webapp/core/sync.py index 82c7a9e..6073a0a 100644 --- a/webapp/core/sync.py +++ b/webapp/core/sync.py @@ -432,7 +432,7 @@ def _new_deployment(parent): }, "replicas": parent["spec"]["replicas"], "template": _create_pod_template( - parent, labels, cfg.INTEGRATION_CONTAINER_IMAGE + parent, labels, parent["spec"].get("image", cfg.INTEGRATION_CONTAINER_IMAGE) ), }, } diff --git a/webapp/core/test/test_sync.py b/webapp/core/test/test_sync.py index a208b5c..8932524 100644 --- a/webapp/core/test/test_sync.py +++ b/webapp/core/test/test_sync.py @@ -603,3 +603,29 @@ def check_volume_mounts_absent(deployment: Mapping, name: str): def get_container(deployment: Mapping) -> Mapping: pod_template = deployment["spec"]["template"] return pod_template["spec"]["containers"][0] + + +def test_per_route_image_override(full_route): + """When spec.image is set, the deployment should use that image instead of the default.""" + custom_image = "registry.example.com/my-app:1.0" + full_route["parent"]["spec"]["image"] = custom_image + + result = sync(full_route) + + deployment = result["children"][0] + container = deployment["spec"]["template"]["spec"]["containers"][0] + assert container["image"] == custom_image + + +def test_per_route_image_default_when_absent(full_route): + """When spec.image is not set, the deployment should use the global default.""" + # Ensure no image field + full_route["parent"]["spec"].pop("image", None) + + result = sync(full_route) + + deployment = result["children"][0] + container = deployment["spec"]["template"]["spec"]["containers"][0] + # Should use the default from config (INTEGRATION_CONTAINER_IMAGE) + import config as cfg + assert container["image"] == cfg.INTEGRATION_CONTAINER_IMAGE