@@ -29,6 +29,7 @@ import (
2929 "github.com/containerd/containerd/images"
3030 "github.com/containerd/containerd/log"
3131 "github.com/containerd/containerd/pkg/progress"
32+ "github.com/containerd/containerd/platforms"
3233 "github.com/containerd/containerd/remotes"
3334 "github.com/containerd/containerd/remotes/docker"
3435 digest "github.com/opencontainers/go-digest"
@@ -58,6 +59,10 @@ var pushCommand = cli.Command{
5859 Name : "manifest-type" ,
5960 Usage : "media type of manifest digest" ,
6061 Value : ocispec .MediaTypeImageManifest ,
62+ }, cli.StringSliceFlag {
63+ Name : "platform" ,
64+ Usage : "push content from a specific platform" ,
65+ Value : & cli.StringSlice {},
6166 }),
6267 Action : func (context * cli.Context ) error {
6368 var (
@@ -91,6 +96,27 @@ var pushCommand = cli.Command{
9196 return errors .Wrap (err , "unable to resolve image to manifest" )
9297 }
9398 desc = img .Target
99+
100+ if pss := context .StringSlice ("platform" ); len (pss ) == 1 {
101+ p , err := platforms .Parse (pss [0 ])
102+ if err != nil {
103+ return errors .Wrapf (err , "invalid platform %q" , pss [0 ])
104+ }
105+
106+ cs := client .ContentStore ()
107+ if manifests , err := images .Children (ctx , cs , desc ); err == nil && len (manifests ) > 0 {
108+ matcher := platforms .NewMatcher (p )
109+ for _ , manifest := range manifests {
110+ if manifest .Platform != nil && matcher .Match (* manifest .Platform ) {
111+ if _ , err := images .Children (ctx , cs , manifest ); err != nil {
112+ return errors .Wrap (err , "no matching manifest" )
113+ }
114+ desc = manifest
115+ break
116+ }
117+ }
118+ }
119+ }
94120 }
95121
96122 resolver , err := commands .GetResolver (ctx , context )
0 commit comments