From 9ba4a0b820e78c9dccf1c5e2a1495dccee1dff49 Mon Sep 17 00:00:00 2001 From: John Engelman Date: Wed, 25 Jan 2017 15:56:15 -0500 Subject: [PATCH] Better logic for splitting image and tag. --- main.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index cf36962..4754e13 100644 --- a/main.go +++ b/main.go @@ -130,9 +130,9 @@ func (s *ServiceUpdater) upgradeService(command UpdateCommand) { if !strings.HasPrefix(command.Image, "docker:") { command.Image = fmt.Sprintf("docker:%s", command.Image) } - parts := strings.Split(command.Image, ":") - wantedImage := parts[1] - wantedVer := parts[2] + idx := strings.LastIndex(command.Image, ":") + wantedImage := command.Image[0 : idx-1] + wantedVer := command.Image[idx:] services, err := s.service.List(&client.ListOpts{}) if err != nil { @@ -168,9 +168,10 @@ func (s *ServiceUpdater) upgradeService(command UpdateCommand) { if s.Config.Debug { log.Printf("Attempting to update service %s\n", svc.Name) } - parts := strings.Split(svc.LaunchConfig.ImageUuid, ":") - foundImage := parts[1] - foundVer := parts[2] + idx := strings.LastIndex(svc.LaunchConfig.ImageUuid, ":") + + foundImage := svc.LaunchConfig.ImageUuid[0 : idx-1] + foundVer := svc.LaunchConfig.ImageUuid[idx:] if utils.EnvironmentEnabled(envs[svc.AccountId], s.Config.EnvironmentNames) { if s.Config.Debug { log.Printf("Service %s Comparision: found-image %s, found-version %s, wanted-image %s, wanted-version %s\n", svc.Name, foundImage, foundVer, wantedImage, wantedVer)