Skip to content

Commit

Permalink
Update ctr image pull all platforms
Browse files Browse the repository at this point in the history
Allows supporting fetching of all platforms while unpacking for a subset
of platforms.

Signed-off-by: Derek McGowan <derek@mcg.dev>
(cherry picked from commit 2788604)
Signed-off-by: Derek McGowan <derek@mcg.dev>
  • Loading branch information
dmcgowan committed May 15, 2024
1 parent 32b594f commit 1573ea5
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions cmd/ctr/commands/images/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,24 +100,25 @@ command. As part of this process, we do the following:
}

var sopts []image.StoreOpt
if !context.Bool("all-platforms") {
var p []ocispec.Platform
for _, s := range context.StringSlice("platform") {
ps, err := platforms.Parse(s)
if err != nil {
return fmt.Errorf("unable to parse platform %s: %w", s, err)
}
p = append(p, ps)

var p []ocispec.Platform
for _, s := range context.StringSlice("platform") {
ps, err := platforms.Parse(s)
if err != nil {
return fmt.Errorf("unable to parse platform %s: %w", s, err)
}
p = append(p, ps)
}

// Set unpack configuration
for _, platform := range p {
sopts = append(sopts, image.WithUnpack(platform, context.String("snapshotter")))
}
if !context.Bool("all-platforms") {
if len(p) == 0 {
p = append(p, platforms.DefaultSpec())
}
sopts = append(sopts, image.WithPlatforms(p...))

// Set unpack configuration
for _, platform := range p {
sopts = append(sopts, image.WithUnpack(platform, context.String("snapshotter")))
}
}
// TODO: Support unpack for all platforms..?
// Pass in a *?
Expand Down

0 comments on commit 1573ea5

Please sign in to comment.