Ensure specifying an empty platform is treated as default

The default platform had previously been provided using the
empty string. This change ensures that the platforms
field is always filled in correctly and empty string is
properly interpreted.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
Derek McGowan 2018-07-31 15:08:59 -07:00
parent 875b92c507
commit 3629344e6e
No known key found for this signature in database
GPG Key ID: F58C5D0A4405ACDB

View File

@ -18,6 +18,7 @@ package containerd
import (
"github.com/containerd/containerd/images"
"github.com/containerd/containerd/platforms"
"github.com/containerd/containerd/remotes"
"google.golang.org/grpc"
)
@ -76,6 +77,9 @@ type RemoteOpt func(*Client, *RemoteContext) error
// WithPlatform allows the caller to specify a platform to retrieve
// content for
func WithPlatform(platform string) RemoteOpt {
if platform == "" {
platform = platforms.Default()
}
return func(_ *Client, c *RemoteContext) error {
for _, p := range c.Platforms {
if p == platform {