Skip to content

Commit

Permalink
Merge pull request #9868 from bkielbasa/v2
Browse files Browse the repository at this point in the history
add more information when `service.platform` isn't part of `service.build.platforms`
  • Loading branch information
glours authored Sep 26, 2022
2 parents 3c641ed + aa297a9 commit 19a1454
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/compose/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ func useDockerDefaultPlatform(project *types.Project, platformList types.StringL
var plats []specs.Platform
if platform, ok := project.Environment["DOCKER_DEFAULT_PLATFORM"]; ok {
if len(platformList) > 0 && !utils.StringContains(platformList, platform) {
return nil, fmt.Errorf("the DOCKER_DEFAULT_PLATFORM value should be part of the service.build.platforms: %q", platform)
return nil, fmt.Errorf("the DOCKER_DEFAULT_PLATFORM %q value should be part of the service.build.platforms: %q", platform, platformList)
}
p, err := platforms.Parse(platform)
if err != nil {
Expand All @@ -417,7 +417,7 @@ func useDockerDefaultOrServicePlatform(project *types.Project, service types.Ser

if service.Platform != "" && !utils.StringContains(service.Build.Platforms, service.Platform) {
if len(service.Build.Platforms) > 0 {
return nil, fmt.Errorf("service.platform should be part of the service.build.platforms: %q", 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
p, err := platforms.Parse(service.Platform)
Expand Down
4 changes: 2 additions & 2 deletions pkg/e2e/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ func TestBuildPlatformsStandardErrors(t *testing.T) {
"-f", "fixtures/build-test/platforms/compose-service-platform-not-in-build-platforms.yaml", "build")
res.Assert(t, icmd.Expected{
ExitCode: 1,
Err: `service.platform should be part of the service.build.platforms: "linux/riscv64"`,
Err: `service.platform "linux/riscv64" should be part of the service.build.platforms: ["linux/amd64" "linux/arm64"]`,
})
})

Expand All @@ -377,7 +377,7 @@ func TestBuildPlatformsStandardErrors(t *testing.T) {
})
res.Assert(t, icmd.Expected{
ExitCode: 1,
Err: `DOCKER_DEFAULT_PLATFORM value should be part of the service.build.platforms: "windows/amd64"`,
Err: `DOCKER_DEFAULT_PLATFORM "windows/amd64" value should be part of the service.build.platforms: ["linux/amd64" "linux/arm64"]`,
})
})
}

0 comments on commit 19a1454

Please sign in to comment.