useDockerDefaultOrServicePlatform fct should return service.platform if defined

and present in the build.platforms list (or if the list is empty)

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
This commit is contained in:
Guillaume Lours 2022-11-23 22:35:12 +01:00 committed by Nicolas De loof
parent c3e5e49957
commit 10a5d998e6

View File

@ -415,8 +415,8 @@ func useDockerDefaultOrServicePlatform(project *types.Project, service types.Ser
return plats, err
}
if service.Platform != "" && !utils.StringContains(service.Build.Platforms, service.Platform) {
if len(service.Build.Platforms) > 0 {
if service.Platform != "" {
if len(service.Build.Platforms) > 0 && !utils.StringContains(service.Build.Platforms, service.Platform) {
return nil, fmt.Errorf("service.platform %q should be part of the service.build.platforms: %q", service.Platform, service.Build.Platforms)
}
// User defined a service platform and no build platforms, so we should keep the one define on the service level