summaryrefslogtreecommitdiff
path: root/libpod/options.go
diff options
context:
space:
mode:
Diffstat (limited to 'libpod/options.go')
-rw-r--r--libpod/options.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/libpod/options.go b/libpod/options.go
index c1a8fdbe1..61d1676f1 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -4,6 +4,7 @@ import (
"net"
"os"
"path/filepath"
+ "strings"
"syscall"
"github.com/containers/common/pkg/config"
@@ -22,6 +23,10 @@ import (
)
// Runtime Creation Options
+var (
+ // SdNotifyModeValues describes the only values that SdNotifyMode can be
+ SdNotifyModeValues = []string{define.SdNotifyModeContainer, define.SdNotifyModeConmon, define.SdNotifyModeIgnore}
+)
// WithStorageConfig uses the given configuration to set up container storage.
// If this is not specified, the system default configuration will be used
@@ -550,6 +555,23 @@ func WithSystemd() CtrCreateOption {
}
}
+// WithSdNotifyMode sets the sd-notify method
+func WithSdNotifyMode(mode string) CtrCreateOption {
+ return func(ctr *Container) error {
+ if ctr.valid {
+ return define.ErrCtrFinalized
+ }
+
+ // verify values
+ if len(mode) > 0 && !util.StringInSlice(strings.ToLower(mode), SdNotifyModeValues) {
+ return errors.Wrapf(define.ErrInvalidArg, "--sdnotify values must be one of %q", strings.Join(SdNotifyModeValues, ", "))
+ }
+
+ ctr.config.SdNotifyMode = mode
+ return nil
+ }
+}
+
// WithShmSize sets the size of /dev/shm tmpfs mount.
func WithShmSize(size int64) CtrCreateOption {
return func(ctr *Container) error {