@@ -21,10 +21,23 @@ import (
2121 "github.com/docker/docker/pkg/term"
2222 "github.com/docker/docker/registry"
2323 "github.com/morikuni/aec"
24+ ocischemav1 "github.com/opencontainers/image-spec/specs-go/v1"
2425 "github.com/pkg/errors"
2526 "github.com/spf13/cobra"
2627)
2728
29+ const ( // Docker specific annotations and values
30+ // DockerAppFormatAnnotation is the top level annotation specifying the kind of the App Bundle
31+ DockerAppFormatAnnotation = "io.docker.app.format"
32+ // DockerAppFormatCNAB is the DockerAppFormatAnnotation value for CNAB
33+ DockerAppFormatCNAB = "cnab"
34+
35+ // DockerTypeAnnotation is the annotation that designates the type of the application
36+ DockerTypeAnnotation = "io.docker.type"
37+ // DockerTypeApp is the value used to fill DockerTypeAnnotation when targeting a docker-app
38+ DockerTypeApp = "app"
39+ )
40+
2841type pushOptions struct {
2942 registry registryOptions
3043 tag string
@@ -114,14 +127,23 @@ func runPush(dockerCli command.Cli, name string, opts pushOptions) error {
114127 return errors .Wrapf (err , "fixing up %q for push" , retag .cnabRef )
115128 }
116129 // push bundle manifest
117- descriptor , err := remotes .Push (context .Background (), bndl , retag .cnabRef , resolverConfig .Resolver , true )
130+ descriptor , err := remotes .Push (context .Background (), bndl , retag .cnabRef , resolverConfig .Resolver , true , withAppAnnotations )
118131 if err != nil {
119132 return errors .Wrapf (err , "pushing to %q" , retag .cnabRef )
120133 }
121134 fmt .Fprintf (os .Stdout , "Successfully pushed bundle to %s. Digest is %s.\n " , retag .cnabRef .String (), descriptor .Digest )
122135 return nil
123136}
124137
138+ func withAppAnnotations (index * ocischemav1.Index ) error {
139+ if index .Annotations == nil {
140+ index .Annotations = make (map [string ]string )
141+ }
142+ index .Annotations [DockerAppFormatAnnotation ] = DockerAppFormatCNAB
143+ index .Annotations [DockerTypeAnnotation ] = DockerTypeApp
144+ return nil
145+ }
146+
125147func retagInvocationImage (dockerCli command.Cli , bndl * bundle.Bundle , newName string ) error {
126148 err := dockerCli .Client ().ImageTag (context .Background (), bndl .InvocationImages [0 ].Image , newName )
127149 if err != nil {
0 commit comments