@@ -21,10 +21,23 @@ import (
21
21
"github.com/docker/docker/pkg/term"
22
22
"github.com/docker/docker/registry"
23
23
"github.com/morikuni/aec"
24
+ ocischemav1 "github.com/opencontainers/image-spec/specs-go/v1"
24
25
"github.com/pkg/errors"
25
26
"github.com/spf13/cobra"
26
27
)
27
28
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
+
28
41
type pushOptions struct {
29
42
registry registryOptions
30
43
tag string
@@ -114,14 +127,23 @@ func runPush(dockerCli command.Cli, name string, opts pushOptions) error {
114
127
return errors .Wrapf (err , "fixing up %q for push" , retag .cnabRef )
115
128
}
116
129
// 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 )
118
131
if err != nil {
119
132
return errors .Wrapf (err , "pushing to %q" , retag .cnabRef )
120
133
}
121
134
fmt .Fprintf (os .Stdout , "Successfully pushed bundle to %s. Digest is %s.\n " , retag .cnabRef .String (), descriptor .Digest )
122
135
return nil
123
136
}
124
137
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
+
125
147
func retagInvocationImage (dockerCli command.Cli , bndl * bundle.Bundle , newName string ) error {
126
148
err := dockerCli .Client ().ImageTag (context .Background (), bndl .InvocationImages [0 ].Image , newName )
127
149
if err != nil {
0 commit comments