summaryrefslogtreecommitdiff
path: root/libpod/options.go
diff options
context:
space:
mode:
Diffstat (limited to 'libpod/options.go')
-rw-r--r--libpod/options.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/libpod/options.go b/libpod/options.go
index 34bde3211..02bcb8628 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -2,6 +2,7 @@ package libpod
import (
"net"
+ "os"
"path/filepath"
"regexp"
"syscall"
@@ -361,6 +362,9 @@ func WithRootFSFromImage(imageID string, imageName string, useImageVolumes bool)
if ctr.config.RootfsImageID != "" || ctr.config.RootfsImageName != "" {
return errors.Wrapf(ErrInvalidArg, "container already configured with root filesystem")
}
+ if ctr.config.Rootfs != "" {
+ return errors.Wrapf(ErrInvalidArg, "cannot set both an image ID and a rootfs for a container")
+ }
ctr.config.RootfsImageID = imageID
ctr.config.RootfsImageName = imageName
@@ -909,6 +913,23 @@ func WithCommand(command []string) CtrCreateOption {
}
}
+// WithRootFS sets the rootfs for the container
+func WithRootFS(rootfs string) CtrCreateOption {
+ return func(ctr *Container) error {
+ if ctr.valid {
+ return ErrCtrFinalized
+ }
+ if _, err := os.Stat(rootfs); err != nil {
+ return errors.Wrapf(err, "error checking path %q", rootfs)
+ }
+ if ctr.config.RootfsImageID != "" {
+ return errors.Wrapf(ErrInvalidArg, "cannot set both an image ID and a rootfs for a container")
+ }
+ ctr.config.Rootfs = rootfs
+ return nil
+ }
+}
+
// Pod Creation Options
// WithPodName sets the name of the pod.