Last active
May 5, 2022 15:52
-
-
Save benmoss/ab64832bf31aa06aa552b16559d7a383 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/pkg/build/gobuild.go b/pkg/build/gobuild.go | |
index bbf42a27..b6c35a56 100644 | |
--- a/pkg/build/gobuild.go | |
+++ b/pkg/build/gobuild.go | |
@@ -708,6 +708,9 @@ func (g *gobuild) buildOne(ctx context.Context, refStr string, base v1.Image, pl | |
OSVersion: cf.OSVersion, | |
} | |
} | |
+ if !g.platformMatcher.matches(platform) { | |
+ return nil, fmt.Errorf("base image does not match desired platform %q", platform.String()) | |
+ } | |
// Do the build into a temporary file. | |
file, err := g.build(ctx, ref.Path(), g.dir, *platform, g.configForImportPath(ref.Path())) | |
diff --git a/pkg/build/gobuild_test.go b/pkg/build/gobuild_test.go | |
index 0bd93af4..8aecabe3 100644 | |
--- a/pkg/build/gobuild_test.go | |
+++ b/pkg/build/gobuild_test.go | |
@@ -437,6 +437,7 @@ func TestGoBuildNoKoData(t *testing.T) { | |
WithBaseImages(func(context.Context, string) (name.Reference, Result, error) { return baseRef, base, nil }), | |
withBuilder(writeTempFile), | |
withSBOMber(fauxSBOM), | |
+ WithPlatforms("all"), | |
) | |
if err != nil { | |
t.Fatalf("NewGo() = %v", err) | |
@@ -719,6 +720,7 @@ func TestGoBuild(t *testing.T) { | |
withSBOMber(fauxSBOM), | |
WithLabel("foo", "bar"), | |
WithLabel("hello", "world"), | |
+ WithPlatforms("all"), | |
) | |
if err != nil { | |
t.Fatalf("NewGo() = %v", err) | |
@@ -794,6 +796,7 @@ func TestGoBuildWithKOCACHE(t *testing.T) { | |
"", | |
WithCreationTime(creationTime), | |
WithBaseImages(func(context.Context, string) (name.Reference, Result, error) { return baseRef, base, nil }), | |
+ WithPlatforms("all"), | |
) | |
if err != nil { | |
t.Fatalf("NewGo() = %v", err) | |
@@ -830,6 +833,7 @@ func TestGoBuildWithoutSBOM(t *testing.T) { | |
withSBOMber(fauxSBOM), | |
WithLabel("foo", "bar"), | |
WithLabel("hello", "world"), | |
+ WithPlatforms("all"), | |
WithDisabledSBOM(), | |
) | |
if err != nil { | |
diff --git a/pkg/build/gobuilds_test.go b/pkg/build/gobuilds_test.go | |
index c601974a..31f021b3 100644 | |
--- a/pkg/build/gobuilds_test.go | |
+++ b/pkg/build/gobuilds_test.go | |
@@ -31,6 +31,7 @@ func Test_gobuilds(t *testing.T) { | |
opts := []Option{ | |
WithBaseImages(func(context.Context, string) (name.Reference, Result, error) { return baseRef, base, nil }), | |
withBuilder(writeTempFile), | |
+ WithPlatforms("all"), | |
} | |
tests := []struct { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment