From 09336f95000385c1dcba7cfb14f9b8d666cd23f5 Mon Sep 17 00:00:00 2001 From: Matt Toohey Date: Wed, 6 Nov 2024 12:14:56 +1100 Subject: [PATCH] Smarter image name replacement --- .../scaling/k8sscaling/deployment_provisioner.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/backend/controller/scaling/k8sscaling/deployment_provisioner.go b/backend/controller/scaling/k8sscaling/deployment_provisioner.go index ae441f0e6..a15742941 100644 --- a/backend/controller/scaling/k8sscaling/deployment_provisioner.go +++ b/backend/controller/scaling/k8sscaling/deployment_provisioner.go @@ -270,7 +270,17 @@ func (r *DeploymentProvisioner) handleNewDeployment(ctx context.Context, dep *sc // runner images use the same tag as the controller var runnerImage string if dep.Runtime.Image != "" { - runnerImage = strings.ReplaceAll(ourImage, "ftl0/ftl-controller", dep.Runtime.Image) + if strings.HasPrefix(dep.Runtime.Image, "ftl0/") { + // Images in the ftl0 namespace should use the same tag as the controller and use the same namespace as ourImage + runnerImage = strings.ReplaceAll(ourImage, "ftl-controller", dep.Runtime.Image[len(`ftl0/`):]) + } else { + // Images outside of the ftl0 namespace should use the same tag as the controller + ourImageComponents := strings.Split(ourImage, ":") + if len(ourImageComponents) != 2 { + return fmt.Errorf("expected : for image name %q", ourImage) + } + runnerImage = dep.Runtime.Image + ":" + ourImageComponents[1] + } } else { runnerImage = strings.ReplaceAll(ourImage, "ftl0/ftl-controller", "ftl0/ftl-runner") }