summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/common.go4
-rw-r--r--cmd/podman/create.go23
2 files changed, 27 insertions, 0 deletions
diff --git a/cmd/podman/common.go b/cmd/podman/common.go
index 63c41d01c..f38348a65 100644
--- a/cmd/podman/common.go
+++ b/cmd/podman/common.go
@@ -80,6 +80,10 @@ var createFlags = []cli.Flag{
Usage: "Add a custom host-to-IP mapping (host:ip) (default [])",
},
cli.StringSliceFlag{
+ Name: "annotation",
+ Usage: "Add annotations to container (key:value) (default [])",
+ },
+ cli.StringSliceFlag{
Name: "attach, a",
Usage: "Attach to STDIN, STDOUT or STDERR (default [])",
},
diff --git a/cmd/podman/create.go b/cmd/podman/create.go
index 89a8baf6d..35487a83a 100644
--- a/cmd/podman/create.go
+++ b/cmd/podman/create.go
@@ -19,6 +19,7 @@ import (
"github.com/projectatomic/libpod/cmd/podman/libpodruntime"
"github.com/projectatomic/libpod/libpod"
"github.com/projectatomic/libpod/libpod/image"
+ ann "github.com/projectatomic/libpod/pkg/annotations"
"github.com/projectatomic/libpod/pkg/inspect"
cc "github.com/projectatomic/libpod/pkg/spec"
"github.com/projectatomic/libpod/pkg/util"
@@ -377,6 +378,27 @@ func parseCreateOpts(ctx context.Context, c *cli.Context, runtime *libpod.Runtim
}
}
+ // ANNOTATIONS
+ annotations := make(map[string]string)
+ // First, add our default annotations
+ annotations[ann.ContainerType] = "sandbox"
+ annotations[ann.TTY] = "false"
+ if tty {
+ annotations[ann.TTY] = "true"
+ }
+ // Next, add annotations from the image
+ for key, value := range data.Annotations {
+ annotations[key] = value
+ }
+ // Last, add user annotations
+ for _, annotation := range c.StringSlice("annotation") {
+ splitAnnotation := strings.SplitN(annotation, "=", 2)
+ if len(splitAnnotation) < 2 {
+ return nil, errors.Errorf("Annotations must be formatted KEY=VALUE")
+ }
+ annotations[splitAnnotation[0]] = splitAnnotation[1]
+ }
+
// WORKING DIRECTORY
workDir := "/"
if c.IsSet("workdir") {
@@ -463,6 +485,7 @@ func parseCreateOpts(ctx context.Context, c *cli.Context, runtime *libpod.Runtim
config := &cc.CreateConfig{
Runtime: runtime,
+ Annotations: annotations,
BuiltinImgVolumes: ImageVolumes,
ConmonPidFile: c.String("conmon-pidfile"),
ImageVolumeType: c.String("image-volume"),