summaryrefslogtreecommitdiff
path: root/libpod/container_validate.go
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2021-07-14 16:03:55 -0500
committerBrent Baude <bbaude@redhat.com>2021-08-04 14:14:36 -0500
commit3c3fa6fac4d0f8e89181ea2d4e1fe0318d24b6f4 (patch)
treef087d0a772797a9028df514d8d0369835724b3a2 /libpod/container_validate.go
parente93661f5e765d84893e2ad5a488682c0a67412d0 (diff)
downloadpodman-3c3fa6fac4d0f8e89181ea2d4e1fe0318d24b6f4.tar.gz
podman-3c3fa6fac4d0f8e89181ea2d4e1fe0318d24b6f4.tar.bz2
podman-3c3fa6fac4d0f8e89181ea2d4e1fe0318d24b6f4.zip
implement init containers in podman
this is the first pass at implementing init containers for podman pods. init containersare made popular by k8s as a way to run setup for pods before the pods standard containers run. unlike k8s, we support two styles of init containers: always and oneshot. always means the container stays in the pod and starts whenever a pod is started. this does not apply to pods restarting. oneshot means the container runs onetime when the pod starts and then is removed. Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'libpod/container_validate.go')
-rw-r--r--libpod/container_validate.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/libpod/container_validate.go b/libpod/container_validate.go
index 6ff46f1b1..91ebe93fb 100644
--- a/libpod/container_validate.go
+++ b/libpod/container_validate.go
@@ -131,5 +131,11 @@ func (c *Container) validate() error {
if c.config.User == "" && (c.config.Spec.Process.User.UID != 0 || c.config.Spec.Process.User.GID != 0) {
return errors.Wrapf(define.ErrInvalidArg, "please set User explicitly via WithUser() instead of in OCI spec directly")
}
+
+ // Init-ctrs must be used inside a Pod. Check if a init container type is
+ // passed and if no pod is passed
+ if len(c.config.InitContainerType) > 0 && len(c.config.Pod) < 1 {
+ return errors.Wrap(define.ErrInvalidArg, "init containers must be created in a pod")
+ }
return nil
}