Skip to content

Commit

Permalink
Smarter image name replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
matt2e committed Nov 6, 2024
1 parent 68e0e9c commit 9c1bfbf
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions backend/controller/scaling/k8sscaling/deployment_provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <name>:<tag> 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
Expand Down

0 comments on commit 9c1bfbf

Please sign in to comment.