mirror of https://github.com/containers/podman.git
Merge pull request #22124 from diplane/annotations
Add support for annotations
This commit is contained in:
commit
e64d81481d
|
@ -506,6 +506,10 @@ func (c *Container) generateInspectContainerHostConfig(ctrSpec *spec.Spec, named
|
||||||
|
|
||||||
// Annotations
|
// Annotations
|
||||||
if ctrSpec.Annotations != nil {
|
if ctrSpec.Annotations != nil {
|
||||||
|
if len(ctrSpec.Annotations) != 0 {
|
||||||
|
hostConfig.Annotations = ctrSpec.Annotations
|
||||||
|
}
|
||||||
|
|
||||||
hostConfig.ContainerIDFile = ctrSpec.Annotations[define.InspectAnnotationCIDFile]
|
hostConfig.ContainerIDFile = ctrSpec.Annotations[define.InspectAnnotationCIDFile]
|
||||||
if ctrSpec.Annotations[define.InspectAnnotationAutoremove] == define.InspectResponseTrue {
|
if ctrSpec.Annotations[define.InspectAnnotationAutoremove] == define.InspectResponseTrue {
|
||||||
hostConfig.AutoRemove = true
|
hostConfig.AutoRemove = true
|
||||||
|
|
|
@ -364,6 +364,9 @@ type InspectContainerHostConfig struct {
|
||||||
// It is not handled directly within libpod and is stored in an
|
// It is not handled directly within libpod and is stored in an
|
||||||
// annotation.
|
// annotation.
|
||||||
AutoRemove bool `json:"AutoRemove"`
|
AutoRemove bool `json:"AutoRemove"`
|
||||||
|
// Annotations are provided to the runtime when the container is
|
||||||
|
// started.
|
||||||
|
Annotations map[string]string `json:"Annotations"`
|
||||||
// VolumeDriver is presently unused and is retained for Docker
|
// VolumeDriver is presently unused and is retained for Docker
|
||||||
// compatibility.
|
// compatibility.
|
||||||
VolumeDriver string `json:"VolumeDriver"`
|
VolumeDriver string `json:"VolumeDriver"`
|
||||||
|
|
|
@ -451,6 +451,7 @@ func cliOpts(cc handlers.CreateContainerConfig, rtc *config.Config) (*entities.C
|
||||||
ReadOnly: cc.HostConfig.ReadonlyRootfs,
|
ReadOnly: cc.HostConfig.ReadonlyRootfs,
|
||||||
ReadWriteTmpFS: true, // podman default
|
ReadWriteTmpFS: true, // podman default
|
||||||
Rm: cc.HostConfig.AutoRemove,
|
Rm: cc.HostConfig.AutoRemove,
|
||||||
|
Annotation: stringMaptoArray(cc.HostConfig.Annotations),
|
||||||
SecurityOpt: cc.HostConfig.SecurityOpt,
|
SecurityOpt: cc.HostConfig.SecurityOpt,
|
||||||
StopSignal: cc.Config.StopSignal,
|
StopSignal: cc.Config.StopSignal,
|
||||||
StopTimeout: rtc.Engine.StopTimeout, // podman default
|
StopTimeout: rtc.Engine.StopTimeout, // podman default
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
# -*- sh -*-
|
||||||
|
|
||||||
|
podman pull $IMAGE &>/dev/null
|
||||||
|
t POST containers/create Image=$IMAGE HostConfig='{"annotations":{"foo":"bar","zoo":"boo"}}' 201 .Id~[0-9a-f]\\{64\\}
|
||||||
|
cid=$(jq -r '.Id' <<<"$output")
|
||||||
|
t GET containers/$cid/json 200 \
|
||||||
|
.HostConfig.Annotations.foo=bar \
|
||||||
|
.HostConfig.Annotations.zoo=boo \
|
Loading…
Reference in New Issue