diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2018-04-26 17:21:48 +0200 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-06-15 14:53:18 +0000 |
commit | 7bdfb4f9b361aca4f4f3337907feb3ca414d36e4 (patch) | |
tree | aff63093af49df79820e72a5a68f07e6fe70b863 /libpod/options.go | |
parent | 4b4de5dc21f034f5f678114dbf6d51f047c96a59 (diff) | |
download | podman-7bdfb4f9b361aca4f4f3337907feb3ca414d36e4.tar.gz podman-7bdfb4f9b361aca4f4f3337907feb3ca414d36e4.tar.bz2 podman-7bdfb4f9b361aca4f4f3337907feb3ca414d36e4.zip |
podman: accept option --rootfs to use exploded images
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Closes: #871
Approved by: mheon
Diffstat (limited to 'libpod/options.go')
-rw-r--r-- | libpod/options.go | 21 |
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. |