@@ -34,7 +34,7 @@ import (
3434 "github.com/containerd/containerd/pkg/progress"
3535 "github.com/containerd/containerd/platforms"
3636 "github.com/containerd/containerd/remotes"
37- digest "github.com/opencontainers/go-digest"
37+ "github.com/opencontainers/go-digest"
3838 ocispec "github.com/opencontainers/image-spec/specs-go/v1"
3939 "github.com/urfave/cli"
4040)
@@ -66,6 +66,14 @@ Most of this is experimental and there are few leaps to make this work.`,
6666 Name : "all-platforms" ,
6767 Usage : "pull content from all platforms" ,
6868 },
69+ cli.BoolFlag {
70+ Name : "all-metadata" ,
71+ Usage : "Pull metadata for all platforms" ,
72+ },
73+ cli.BoolFlag {
74+ Name : "metadata-only" ,
75+ Usage : "Pull all metadata including manifests and configs" ,
76+ },
6977 ),
7078 Action : func (clicontext * cli.Context ) error {
7179 var (
@@ -80,6 +88,7 @@ Most of this is experimental and there are few leaps to make this work.`,
8088 if err != nil {
8189 return err
8290 }
91+
8392 _ , err = Fetch (ctx , client , ref , config )
8493 return err
8594 },
@@ -93,8 +102,12 @@ type FetchConfig struct {
93102 ProgressOutput io.Writer
94103 // Labels to set on the content
95104 Labels []string
105+ // PlatformMatcher matches platforms, supersedes Platforms
106+ PlatformMatcher platforms.MatchComparer
96107 // Platforms to fetch
97108 Platforms []string
109+ // Whether or not download all metadata
110+ AllMetadata bool
98111}
99112
100113// NewFetchConfig returns the default FetchConfig from cli flags
@@ -117,6 +130,15 @@ func NewFetchConfig(ctx context.Context, clicontext *cli.Context) (*FetchConfig,
117130 }
118131 config .Platforms = p
119132 }
133+
134+ if clicontext .Bool ("metadata-only" ) {
135+ config .AllMetadata = true
136+ // Any with an empty set is None
137+ config .PlatformMatcher = platforms .Any ()
138+ } else if clicontext .Bool ("all-metadata" ) {
139+ config .AllMetadata = true
140+ }
141+
120142 return config , nil
121143}
122144
@@ -149,11 +171,18 @@ func Fetch(ctx context.Context, client *containerd.Client, ref string, config *F
149171 containerd .WithResolver (config .Resolver ),
150172 containerd .WithImageHandler (h ),
151173 containerd .WithSchema1Conversion ,
152- containerd .WithAppendDistributionSourceLabel (),
153174 }
154175
155- for _ , platform := range config .Platforms {
156- opts = append (opts , containerd .WithPlatform (platform ))
176+ if config .AllMetadata {
177+ opts = append (opts , containerd .WithAllMetadata ())
178+ }
179+
180+ if config .PlatformMatcher != nil {
181+ opts = append (opts , containerd .WithPlatformMatcher (config .PlatformMatcher ))
182+ } else {
183+ for _ , platform := range config .Platforms {
184+ opts = append (opts , containerd .WithPlatform (platform ))
185+ }
157186 }
158187
159188 img , err := client .Fetch (pctx , ref , opts ... )
0 commit comments