diff --git a/pkg/client/create_builder.go b/pkg/client/create_builder.go index d2b184f01..fe2bfc50f 100644 --- a/pkg/client/create_builder.go +++ b/pkg/client/create_builder.go @@ -363,19 +363,38 @@ func (c *Client) addConfig(ctx context.Context, kind string, config pubbldr.Modu func (c *Client) processBuilderCreateTargets(ctx context.Context, opts CreateBuilderOptions) ([]dist.Target, error) { var targets []dist.Target - if len(opts.Targets) > 0 { - // when exporting to the daemon, we need to select just one target - if !opts.Publish { - daemonTarget, err := c.daemonTarget(ctx, opts.Targets) + + // For backward compatibility, we must create a target with de default platform used in the Fetch implementation for daemon and remote + // When daemon + // OS: daemonInfo.Os, + // Architecture: daemonInfo.Arch + // When remote || layout + // OS: "linux", + // Architecture: runtime.GOARCH + + if !opts.Publish { + // daemon option + info, err := c.docker.ServerVersion(ctx) + if err != nil { + return targets, err + } + if len(opts.Targets) > 0 { + // when exporting to the daemon, we need to select just one target + daemonTarget, err := c.daemonTarget(info, opts.Targets) if err != nil { return targets, err } targets = append(targets, daemonTarget) } else { - targets = opts.Targets + targets = append(targets, dist.Target{OS: info.Os, Arch: info.Arch}) } } else { - targets = append(targets, dist.Target{OS: runtime.GOOS, Arch: runtime.GOARCH}) + // remote option + if len(opts.Targets) > 0 { + targets = opts.Targets + } else { + targets = append(targets, dist.Target{OS: "linux", Arch: runtime.GOARCH}) + } } return targets, nil } diff --git a/pkg/client/package_buildpack.go b/pkg/client/package_buildpack.go index 854068551..ed08cd8b7 100644 --- a/pkg/client/package_buildpack.go +++ b/pkg/client/package_buildpack.go @@ -5,6 +5,7 @@ import ( "fmt" "path/filepath" + "github.com/docker/docker/api/types" "github.com/pkg/errors" pubbldpkg "github.com/buildpacks/pack/buildpackage" @@ -228,10 +229,14 @@ func (c *Client) downloadBuildpackFromURI(ctx context.Context, uri, relativeBase func (c *Client) processPackageBuildpackTargets(ctx context.Context, opts PackageBuildpackOptions) ([]dist.Target, error) { var targets []dist.Target + info, err := c.docker.ServerVersion(ctx) + if err != nil { + return targets, err + } if len(opts.Targets) > 0 { // when exporting to the daemon, we need to select just one target if !opts.Publish && opts.Format == FormatImage { - daemonTarget, err := c.daemonTarget(ctx, opts.Targets) + daemonTarget, err := c.daemonTarget(info, opts.Targets) if err != nil { return targets, err } @@ -262,12 +267,8 @@ func (c *Client) validateOSPlatform(ctx context.Context, os string, publish bool return nil } -func (c *Client) daemonTarget(ctx context.Context, targets []dist.Target) (dist.Target, error) { - info, err := c.docker.ServerVersion(ctx) - if err != nil { - return dist.Target{}, err - } - +// daemonTarget returns a target that matches with the given daemon os/arch +func (c *Client) daemonTarget(info types.Version, targets []dist.Target) (dist.Target, error) { for _, t := range targets { if t.Arch != "" && t.OS == info.Os && t.Arch == info.Arch { return t, nil