Add docker app specific annotations on push
@@ -21,10 +21,23 @@ import (
"github.com/docker/docker/pkg/term"
"github.com/docker/docker/registry"
"github.com/morikuni/aec"
+ ocischemav1 "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
+const ( // Docker specific annotations and values
+ // DockerAppFormatAnnotation is the top level annotation specifying the kind of the App Bundle
+ DockerAppFormatAnnotation = "io.docker.app.format"
+ // DockerAppFormatCNAB is the DockerAppFormatAnnotation value for CNAB
+ DockerAppFormatCNAB = "cnab"
+
+ // DockerTypeAnnotation is the annotation that designates the type of the application
+ DockerTypeAnnotation = "io.docker.type"
+ // DockerTypeApp is the value used to fill DockerTypeAnnotation when targeting a docker-app
+ DockerTypeApp = "app"
+)
+
type pushOptions struct {
registry registryOptions
tag string
@@ -114,7 +127,7 @@ func runPush(dockerCli command.Cli, name string, opts pushOptions) error {
return errors.Wrapf(err, "fixing up %q for push", retag.cnabRef)
}
// push bundle manifest
- descriptor, err := remotes.Push(context.Background(), bndl, retag.cnabRef, resolverConfig.Resolver, true)
+ descriptor, err := remotes.Push(context.Background(), bndl, retag.cnabRef, resolverConfig.Resolver, true, withAppAnnotations)
if err != nil {
return errors.Wrapf(err, "pushing to %q", retag.cnabRef)
}
@@ -122,6 +135,15 @@ func runPush(dockerCli command.Cli, name string, opts pushOptions) error {
return nil
}
+func withAppAnnotations(index *ocischemav1.Index) error {
+ if index.Annotations == nil {
+ index.Annotations = make(map[string]string)
+ }
+ index.Annotations[DockerAppFormatAnnotation] = DockerAppFormatCNAB
+ index.Annotations[DockerTypeAnnotation] = DockerTypeApp
+ return nil
+}
+
func retagInvocationImage(dockerCli command.Cli, bndl *bundle.Bundle, newName string) error {
err := dockerCli.Client().ImageTag(context.Background(), bndl.InvocationImages[0].Image, newName)
if err != nil {
