summaryrefslogtreecommitdiff
path: root/libpod/options.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-08-17 21:08:32 +0200
committerGitHub <noreply@github.com>2020-08-17 21:08:32 +0200
commit8caed305741c8c9e34ec767c9054e3c5e0d33576 (patch)
treea52d68931d6f620ff66ac31b7ca6629b420f7b06 /libpod/options.go
parent47108e2e093bae318773998a18f83d0504a402e0 (diff)
parentc4b2078508a45843034a86916b37a52d3e34d20d (diff)
downloadpodman-8caed305741c8c9e34ec767c9054e3c5e0d33576.tar.gz
podman-8caed305741c8c9e34ec767c9054e3c5e0d33576.tar.bz2
podman-8caed305741c8c9e34ec767c9054e3c5e0d33576.zip
Merge pull request #7283 from mheon/pod_infra_has_exit_cmd
Ensure pod infra containers have an exit command
Diffstat (limited to 'libpod/options.go')
-rw-r--r--libpod/options.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/libpod/options.go b/libpod/options.go
index 16b05d9b6..dccbb8741 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -2130,3 +2130,23 @@ func WithPodHostNetwork() PodCreateOption {
return nil
}
}
+
+// WithPodInfraExitCommand sets an exit command for the pod's infra container.
+// Semantics are identical to WithExitCommand() above - the ID of the container
+// will be appended to the end of the provided command (note that this will
+// specifically be the ID of the infra container *and not the pod's id*.
+func WithPodInfraExitCommand(exitCmd []string) PodCreateOption {
+ return func(pod *Pod) error {
+ if pod.valid {
+ return define.ErrPodFinalized
+ }
+
+ if !pod.config.InfraContainer.HasInfraContainer {
+ return errors.Wrapf(define.ErrInvalidArg, "cannot configure pod infra container exit command as no infra container is being created")
+ }
+
+ pod.config.InfraContainer.ExitCommand = exitCmd
+
+ return nil
+ }
+}