ctr pull unpack for default platform using transfer service

Signed-off-by: Jin Dong <djdongjin95@gmail.com>
This commit is contained in:
Jin Dong 2024-12-03 06:35:22 +00:00 committed by k8s-infra-cherrypick-robot
parent d93ae6232a
commit 44cdca68b5

View File

@ -119,19 +119,20 @@ command. As part of this process, we do the following:
if err != nil { if err != nil {
return err return err
} }
allPlatforms := cliContext.Bool("all-platforms")
// Set unpack configuration if len(p) > 0 && allPlatforms {
return errors.New("cannot specify both --platform and --all-platforms")
}
if len(p) == 0 && !allPlatforms {
p = append(p, platforms.DefaultSpec())
}
// we use an empty `Platform` slice to indicate that we want to pull all platforms
sopts = append(sopts, image.WithPlatforms(p...))
// TODO: Support unpack for all platforms..?
// Pass in a *?
for _, platform := range p { for _, platform := range p {
sopts = append(sopts, image.WithUnpack(platform, cliContext.String("snapshotter"))) sopts = append(sopts, image.WithUnpack(platform, cliContext.String("snapshotter")))
} }
if !cliContext.Bool("all-platforms") {
if len(p) == 0 {
p = append(p, platforms.DefaultSpec())
}
sopts = append(sopts, image.WithPlatforms(p...))
}
// TODO: Support unpack for all platforms..?
// Pass in a *?
if cliContext.Bool("metadata-only") { if cliContext.Bool("metadata-only") {
sopts = append(sopts, image.WithAllMetadata) sopts = append(sopts, image.WithAllMetadata)