diff --git a/bake/bake.go b/bake/bake.go index 0563ca1c..ec0f3536 100644 --- a/bake/bake.go +++ b/bake/bake.go @@ -8,6 +8,7 @@ import ( "github.com/moby/buildkit/session/auth/authprovider" "github.com/pkg/errors" "github.com/tonistiigi/buildx/build" + "github.com/tonistiigi/buildx/util/platformutil" ) func ReadTargets(ctx context.Context, files, targets, overrides []string) (map[string]Target, error) { @@ -254,7 +255,7 @@ func toBuildOpt(t Target) (*build.Options, error) { // CacheFrom: t.CacheFrom, } - platforms, err := build.ParsePlatformSpecs(t.Platforms) + platforms, err := platformutil.Parse(t.Platforms) if err != nil { return nil, err } diff --git a/commands/build.go b/commands/build.go index 2193147d..47ca1f5e 100644 --- a/commands/build.go +++ b/commands/build.go @@ -14,6 +14,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" "github.com/tonistiigi/buildx/build" + "github.com/tonistiigi/buildx/util/platformutil" "github.com/tonistiigi/buildx/util/progress" ) @@ -92,7 +93,7 @@ func runBuild(dockerCli command.Cli, in buildOptions) error { NetworkMode: in.networkMode, } - platforms, err := build.ParsePlatformSpecs(in.platforms) + platforms, err := platformutil.Parse(in.platforms) if err != nil { return err } diff --git a/build/platform.go b/util/platformutil/parse.go similarity index 81% rename from build/platform.go rename to util/platformutil/parse.go index e24dad41..7cdbd81f 100644 --- a/build/platform.go +++ b/util/platformutil/parse.go @@ -1,4 +1,4 @@ -package build +package platformutil import ( "strings" @@ -7,7 +7,7 @@ import ( specs "github.com/opencontainers/image-spec/specs-go/v1" ) -func ParsePlatformSpecs(platformsStr []string) ([]specs.Platform, error) { +func Parse(platformsStr []string) ([]specs.Platform, error) { if len(platformsStr) == 0 { return nil, nil } @@ -15,7 +15,7 @@ func ParsePlatformSpecs(platformsStr []string) ([]specs.Platform, error) { for _, s := range platformsStr { parts := strings.Split(s, ",") if len(parts) > 1 { - p, err := ParsePlatformSpecs(parts) + p, err := Parse(parts) if err != nil { return nil, err }