From 9c1bfbf5fcafb9c8ef6d2b25ae1a63873f8cda47 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 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/backend/controller/scaling/k8sscaling/deployment_provisioner.go b/backend/controller/scaling/k8sscaling/deployment_provisioner.go index ae441f0e6..08efff73d 100644 --- a/backend/controller/scaling/k8sscaling/deployment_provisioner.go +++ b/backend/controller/scaling/k8sscaling/deployment_provisioner.go @@ -270,9 +270,19 @@ 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") + runnerImage = strings.ReplaceAll(ourImage, "controller", "runner") } deployment.Name = name