@@ -23,7 +23,6 @@ import (
2323 "os"
2424 "time"
2525
26- ocispec "github.com/opencontainers/image-spec/specs-go/v1"
2726 "github.com/urfave/cli/v2"
2827
2928 containerd "github.com/containerd/containerd/v2/client"
@@ -141,33 +140,26 @@ If foobar.tar contains an OCI ref named "latest" and anonymous ref "sha256:deadb
141140 opts = append (opts , image .WithNamedPrefix (prefix , overwrite ))
142141 }
143142
144- var platSpec ocispec.Platform
145- // Only when all-platforms not specified, we will check platform value
146- // Implicitly if the platforms is empty, it means all-platforms
143+ // Even with --all-platforms, only the default platform layers are unpacked,
144+ // for compatibility with --local.
145+ //
146+ // This is still not fully compatible with --local, which only unpacks
147+ // the strict-default platform layers.
148+ platUnpack := platforms .DefaultSpec ()
147149 if ! cliContext .Bool ("all-platforms" ) {
148150 // If platform specified, use that one, if not use default
149151 if platform := cliContext .String ("platform" ); platform != "" {
150- platSpec , err = platforms .Parse (platform )
152+ platUnpack , err = platforms .Parse (platform )
151153 if err != nil {
152154 return err
153155 }
154- } else {
155- platSpec = platforms .DefaultSpec ()
156156 }
157- opts = append (opts , image .WithPlatforms (platSpec ))
157+ opts = append (opts , image .WithPlatforms (platUnpack ))
158158 }
159159
160160 if ! cliContext .Bool ("no-unpack" ) {
161161 snapshotter := cliContext .String ("snapshotter" )
162- // If OS field is not empty, it means platSpec was updated in the above block
163- // i.e all-platforms was not specified
164- if platSpec .OS != "" {
165- opts = append (opts , image .WithUnpack (platSpec , snapshotter ))
166- } else {
167- // Empty spec means all platforms
168- var emptySpec ocispec.Platform
169- opts = append (opts , image .WithUnpack (emptySpec , snapshotter ))
170- }
162+ opts = append (opts , image .WithUnpack (platUnpack , snapshotter ))
171163 }
172164
173165 is := image .NewStore (cliContext .String ("index-name" ), opts ... )
0 commit comments