aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libpod/runtime.go2
-rw-r--r--pkg/util/utils.go45
2 files changed, 24 insertions, 23 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go
index 8b5bc32b4..e69b63a24 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -280,7 +280,7 @@ func NewRuntime(options ...RuntimeOption) (runtime *Runtime, err error) {
if rootless.IsRootless() {
// If we're rootless, override the default storage config
- storageConf, err := util.GetDefaultRootlessStoreOptions()
+ storageConf, err := util.GetDefaultStoreOptions()
if err != nil {
return nil, errors.Wrapf(err, "error retrieving rootless storage config")
}
diff --git a/pkg/util/utils.go b/pkg/util/utils.go
index ed79c4b46..e483253a4 100644
--- a/pkg/util/utils.go
+++ b/pkg/util/utils.go
@@ -313,32 +313,33 @@ func getTomlStorage(storeOptions *storage.StoreOptions) *tomlConfig {
return config
}
-// GetDefaultRootlessStoreOptions returns the storage opts for rootless
-// containers.
-func GetDefaultRootlessStoreOptions() (storage.StoreOptions, error) {
- 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)
- } else if os.IsNotExist(err) {
- os.MkdirAll(filepath.Dir(storageConf), 0755)
- file, err := os.OpenFile(storageConf, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666)
+// GetDefaultStoreOptions returns the default storage options for containers.
+func GetDefaultStoreOptions() (storage.StoreOptions, error) {
+ storageOpts := storage.DefaultStoreOptions
+ if rootless.IsRootless() {
+ var err error
+ storageOpts, err = GetRootlessStorageOpts()
if err != nil {
- return storageOpts, errors.Wrapf(err, "cannot open %s", storageConf)
+ return storageOpts, err
}
- tomlConfiguration := getTomlStorage(&storageOpts)
- defer file.Close()
- enc := toml.NewEncoder(file)
- if err := enc.Encode(tomlConfiguration); err != nil {
- os.Remove(storageConf)
+ storageConf := filepath.Join(os.Getenv("HOME"), ".config/containers/storage.conf")
+ if _, err := os.Stat(storageConf); err == nil {
+ storage.ReloadConfigurationFile(storageConf, &storageOpts)
+ } else if os.IsNotExist(err) {
+ os.MkdirAll(filepath.Dir(storageConf), 0755)
+ file, err := os.OpenFile(storageConf, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666)
+ if err != nil {
+ return storageOpts, errors.Wrapf(err, "cannot open %s", storageConf)
+ }
+
+ tomlConfiguration := getTomlStorage(&storageOpts)
+ defer file.Close()
+ enc := toml.NewEncoder(file)
+ if err := enc.Encode(tomlConfiguration); err != nil {
+ os.Remove(storageConf)
+ }
}
}
-
return storageOpts, nil
}