summaryrefslogtreecommitdiff
path: root/libpod/options.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-07-06 17:15:26 -0400
committerGitHub <noreply@github.com>2020-07-06 17:15:26 -0400
commit1a93857acc4ee1e5a9213e2c22f12802d84cd277 (patch)
treed3f8c923e0750fa4aa5ed423dca52640a8ff187c /libpod/options.go
parentb1cc781c68964dff3ee4a00ef7ce71f56ae69e7c (diff)
parent10ad46eb7377ff504a65783a7a604b248b50f20a (diff)
downloadpodman-1a93857acc4ee1e5a9213e2c22f12802d84cd277.tar.gz
podman-1a93857acc4ee1e5a9213e2c22f12802d84cd277.tar.bz2
podman-1a93857acc4ee1e5a9213e2c22f12802d84cd277.zip
Merge pull request #6693 from goochjj/libpod-sd-notify-cmdline
Implement --sdnotify cmdline option to control sd-notify behavior
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 {