@@ -67,8 +67,12 @@ Most of this is experimental and there are few leaps to make this work.`,
6767 Usage : "pull content from all platforms" ,
6868 },
6969 cli.BoolFlag {
70- Name : "all-manifests" ,
71- Usage : "Pull manifests from all platforms and layers for a specific platform" ,
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" ,
7276 },
7377 ),
7478 Action : func (clicontext * cli.Context ) error {
@@ -84,6 +88,7 @@ Most of this is experimental and there are few leaps to make this work.`,
8488 if err != nil {
8589 return err
8690 }
91+
8792 _ , err = Fetch (ctx , client , ref , config )
8893 return err
8994 },
@@ -97,10 +102,12 @@ type FetchConfig struct {
97102 ProgressOutput io.Writer
98103 // Labels to set on the content
99104 Labels []string
105+ // PlatformMatcher matches platforms, supersedes Platforms
106+ PlatformMatcher platforms.MatchComparer
100107 // Platforms to fetch
101108 Platforms []string
102- // Whether or not download all manifests
103- IsAllManifests bool
109+ // Whether or not download all metadata
110+ AllMetadata bool
104111}
105112
106113// NewFetchConfig returns the default FetchConfig from cli flags
@@ -124,7 +131,13 @@ func NewFetchConfig(ctx context.Context, clicontext *cli.Context) (*FetchConfig,
124131 config .Platforms = p
125132 }
126133
127- config .IsAllManifests = clicontext .Bool ("all-manifests" )
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+ }
128141
129142 return config , nil
130143}
@@ -160,12 +173,16 @@ func Fetch(ctx context.Context, client *containerd.Client, ref string, config *F
160173 containerd .WithSchema1Conversion ,
161174 }
162175
163- if config .IsAllManifests {
164- opts = append (opts , containerd .WithAppendDistributionSourceLabel ())
176+ if config .AllMetadata {
177+ opts = append (opts , containerd .WithAllMetadata ())
165178 }
166179
167- for _ , platform := range config .Platforms {
168- opts = append (opts , containerd .WithPlatform (platform ))
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+ }
169186 }
170187
171188 img , err := client .Fetch (pctx , ref , opts ... )
0 commit comments