diff options
author | Matthew Heon <mheon@redhat.com> | 2019-10-28 13:09:01 -0400 |
---|---|---|
committer | Matthew Heon <mheon@redhat.com> | 2019-10-28 13:09:01 -0400 |
commit | 5f8bf3d07d94d58465dfa494f7720ca23b8d4c6f (patch) | |
tree | 179049da0c4d6664d2d4308fd6069bae8b929d03 /libpod/container.go | |
parent | ac73fd3fe5dcbf2647d589f9c9f37fe9531ed663 (diff) | |
download | podman-5f8bf3d07d94d58465dfa494f7720ca23b8d4c6f.tar.gz podman-5f8bf3d07d94d58465dfa494f7720ca23b8d4c6f.tar.bz2 podman-5f8bf3d07d94d58465dfa494f7720ca23b8d4c6f.zip |
Add ensureState helper for checking container state
We have a lot of checks for container state scattered throughout
libpod. Many of these need to ensure the container is in one of a
given set of states so an operation may safely proceed.
Previously there was no set way of doing this, so we'd use unique
boolean logic for each one. Introduce a helper to standardize
state checks.
Note that this is only intended to replace checks for multiple
states. A simple check for one state (ContainerStateRunning, for
example) should remain a straight equality, and not use this new
helper.
Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'libpod/container.go')
-rw-r--r-- | libpod/container.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libpod/container.go b/libpod/container.go index 7be73b3c3..fc9ef0c86 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -1185,3 +1185,12 @@ func (c *Container) HasHealthCheck() bool { func (c *Container) HealthCheckConfig() *manifest.Schema2HealthConfig { return c.config.HealthCheckConfig } + +// AutoRemove indicates whether the container will be removed after it is executed +func (c *Container) AutoRemove() bool { + spec := c.config.Spec + if spec.Annotations == nil { + return false + } + return c.Spec().Annotations[InspectAnnotationAutoremove] == InspectResponseTrue +} |