mirror of
https://github.com/containers/podman.git
synced 2025-07-03 09:17:15 +08:00
Merge pull request #22124 from diplane/annotations
Add support for annotations
This commit is contained in:
@ -506,6 +506,10 @@ func (c *Container) generateInspectContainerHostConfig(ctrSpec *spec.Spec, named
|
||||
|
||||
// Annotations
|
||||
if ctrSpec.Annotations != nil {
|
||||
if len(ctrSpec.Annotations) != 0 {
|
||||
hostConfig.Annotations = ctrSpec.Annotations
|
||||
}
|
||||
|
||||
hostConfig.ContainerIDFile = ctrSpec.Annotations[define.InspectAnnotationCIDFile]
|
||||
if ctrSpec.Annotations[define.InspectAnnotationAutoremove] == define.InspectResponseTrue {
|
||||
hostConfig.AutoRemove = true
|
||||
|
@ -364,6 +364,9 @@ type InspectContainerHostConfig struct {
|
||||
// It is not handled directly within libpod and is stored in an
|
||||
// annotation.
|
||||
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
|
||||
// compatibility.
|
||||
VolumeDriver string `json:"VolumeDriver"`
|
||||
|
@ -451,6 +451,7 @@ func cliOpts(cc handlers.CreateContainerConfig, rtc *config.Config) (*entities.C
|
||||
ReadOnly: cc.HostConfig.ReadonlyRootfs,
|
||||
ReadWriteTmpFS: true, // podman default
|
||||
Rm: cc.HostConfig.AutoRemove,
|
||||
Annotation: stringMaptoArray(cc.HostConfig.Annotations),
|
||||
SecurityOpt: cc.HostConfig.SecurityOpt,
|
||||
StopSignal: cc.Config.StopSignal,
|
||||
StopTimeout: rtc.Engine.StopTimeout, // podman default
|
||||
|
8
test/apiv2/28-containersAnnotations.at
Normal file
8
test/apiv2/28-containersAnnotations.at
Normal file
@ -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 \
|
Reference in New Issue
Block a user