fix(dockerCompose): mergeLastWinImage
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Markus Pesch 2023-07-26 14:44:12 +02:00
parent 3bf9380001
commit ce48d6dd0c
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982
2 changed files with 45 additions and 1 deletions

View File

@ -490,8 +490,17 @@ func (s *Service) mergeLastWinEnvironments(environments []string) {
} }
func (s *Service) mergeLastWinImage(image string) { func (s *Service) mergeLastWinImage(image string) {
if s.Image != image { switch {
case len(s.Image) == 0 && len(image) != 0:
s.Image = image s.Image = image
case len(s.Image) != 0 && len(image) == 0:
fallthrough
case len(s.Image) == 0 && len(image) == 0:
return
default:
if s.Image != image {
s.Image = image
}
} }
} }

View File

@ -735,6 +735,41 @@ func TestService_MergeLastWin(t *testing.T) {
}, },
}, },
// Image
{
serviceDeploymentA: &dockerCompose.Service{
Image: "",
},
serviceDeploymentB: &dockerCompose.Service{
Image: "",
},
expectedService: &dockerCompose.Service{
Image: "",
},
},
{
serviceDeploymentA: &dockerCompose.Service{
Image: "HelloWorld",
},
serviceDeploymentB: &dockerCompose.Service{
Image: "FooBar",
},
expectedService: &dockerCompose.Service{
Image: "FooBar",
},
},
{
serviceDeploymentA: &dockerCompose.Service{
Image: "HelloWorld",
},
serviceDeploymentB: &dockerCompose.Service{
Image: "",
},
expectedService: &dockerCompose.Service{
Image: "HelloWorld",
},
},
// Labels // Labels
{ {
serviceDeploymentA: &dockerCompose.Service{ serviceDeploymentA: &dockerCompose.Service{