summaryrefslogtreecommitdiff
path: root/cmd/podman/libpodruntime/runtime.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2018-10-22 09:43:03 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2018-10-22 09:43:59 -0400
commit2444ac9926c651010a60a11eb372cca0ac7cc0e8 (patch)
tree51ce4dffa6d85261451a23a9185a900a4487a2f5 /cmd/podman/libpodruntime/runtime.go
parent0fefe3b191444cba8694119b5c30f484d146e162 (diff)
downloadpodman-2444ac9926c651010a60a11eb372cca0ac7cc0e8.tar.gz
podman-2444ac9926c651010a60a11eb372cca0ac7cc0e8.tar.bz2
podman-2444ac9926c651010a60a11eb372cca0ac7cc0e8.zip
Move rootless directory handling to the libpod/pkg/util directory
This should allow us to share this code with buildah. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'cmd/podman/libpodruntime/runtime.go')
-rw-r--r--cmd/podman/libpodruntime/runtime.go54
1 files changed, 2 insertions, 52 deletions
diff --git a/cmd/podman/libpodruntime/runtime.go b/cmd/podman/libpodruntime/runtime.go
index a0d497e8e..df422eb81 100644
--- a/cmd/podman/libpodruntime/runtime.go
+++ b/cmd/podman/libpodruntime/runtime.go
@@ -1,21 +1,16 @@
package libpodruntime
import (
- "fmt"
- "os"
- "path/filepath"
-
"github.com/containers/libpod/libpod"
"github.com/containers/libpod/pkg/rootless"
"github.com/containers/libpod/pkg/util"
"github.com/containers/storage"
- "github.com/pkg/errors"
"github.com/urfave/cli"
)
// GetRuntime generates a new libpod runtime configured by command line options
func GetRuntime(c *cli.Context) (*libpod.Runtime, error) {
- storageOpts, err := GetDefaultStoreOptions()
+ storageOpts, err := util.GetDefaultStoreOptions()
if err != nil {
return nil, err
}
@@ -28,7 +23,7 @@ func GetContainerRuntime(c *cli.Context) (*libpod.Runtime, error) {
if err != nil {
return nil, err
}
- storageOpts, err := GetDefaultStoreOptions()
+ storageOpts, err := util.GetDefaultStoreOptions()
if err != nil {
return nil, err
}
@@ -37,51 +32,6 @@ func GetContainerRuntime(c *cli.Context) (*libpod.Runtime, error) {
return GetRuntimeWithStorageOpts(c, &storageOpts)
}
-func GetRootlessStorageOpts() (storage.StoreOptions, error) {
- var opts storage.StoreOptions
-
- rootlessRuntime, err := libpod.GetRootlessRuntimeDir()
- if err != nil {
- return opts, err
- }
- opts.RunRoot = filepath.Join(rootlessRuntime, "run")
-
- dataDir := os.Getenv("XDG_DATA_HOME")
- if dataDir == "" {
- home := os.Getenv("HOME")
- if home == "" {
- return opts, fmt.Errorf("neither XDG_DATA_HOME nor HOME was set non-empty")
- }
- // runc doesn't like symlinks in the rootfs path, and at least
- // on CoreOS /home is a symlink to /var/home, so resolve any symlink.
- resolvedHome, err := filepath.EvalSymlinks(home)
- if err != nil {
- return opts, errors.Wrapf(err, "cannot resolve %s", home)
- }
- dataDir = filepath.Join(resolvedHome, ".local", "share")
- }
- opts.GraphRoot = filepath.Join(dataDir, "containers", "storage")
- opts.GraphDriverName = "vfs"
- return opts, nil
-}
-
-func GetDefaultStoreOptions() (storage.StoreOptions, error) {
- storageOpts := storage.DefaultStoreOptions
- if rootless.IsRootless() {
- var err error
- storageOpts, err = GetRootlessStorageOpts()
- if err != nil {
- return storageOpts, err
- }
-
- storageConf := filepath.Join(os.Getenv("HOME"), ".config/containers/storage.conf")
- if _, err := os.Stat(storageConf); err == nil {
- storage.ReloadConfigurationFile(storageConf, &storageOpts)
- }
- }
- return storageOpts, nil
-}
-
// GetRuntime generates a new libpod runtime configured by command line options
func GetRuntimeWithStorageOpts(c *cli.Context, storageOpts *storage.StoreOptions) (*libpod.Runtime, error) {
options := []libpod.RuntimeOption{}