summaryrefslogtreecommitdiff
path: root/libpod/options.go
diff options
context:
space:
mode:
Diffstat (limited to 'libpod/options.go')
-rw-r--r--libpod/options.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/libpod/options.go b/libpod/options.go
index 7ec7dfe63..d6eb97609 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -979,6 +979,25 @@ func WithStaticIP(ip net.IP) CtrCreateOption {
}
}
+// WithLogDriver sets the log driver for the container
+func WithLogDriver(driver string) CtrCreateOption {
+ return func(ctr *Container) error {
+ if ctr.valid {
+ return ErrCtrFinalized
+ }
+ if driver == "" {
+ return errors.Wrapf(ErrInvalidArg, "log driver must be set")
+ }
+ if driver != "journald" && driver != "k8s-file" && driver != "json-file" {
+ return errors.Wrapf(ErrInvalidArg, "invalid log driver")
+ }
+
+ ctr.config.LogDriver = driver
+
+ return nil
+ }
+}
+
// WithLogPath sets the path to the log file.
func WithLogPath(path string) CtrCreateOption {
return func(ctr *Container) error {