From 7bdfb4f9b361aca4f4f3337907feb3ca414d36e4 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Thu, 26 Apr 2018 17:21:48 +0200 Subject: podman: accept option --rootfs to use exploded images Signed-off-by: Giuseppe Scrivano Closes: #871 Approved by: mheon --- libpod/options.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'libpod/options.go') 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. -- cgit v1.2.3-54-g00ecf