aboutsummaryrefslogtreecommitdiff
path: root/pkg/util/utils.go
diff options
context:
space:
mode:
authorMatthew Heon <mheon@redhat.com>2018-12-03 15:38:35 -0500
committerMatthew Heon <mheon@redhat.com>2018-12-03 15:48:20 -0500
commit795fbba7695b03736acaf9abe75922404f5eea44 (patch)
tree9a6289e016efeeede1035169746ec8365236df7c /pkg/util/utils.go
parent7c575bdce26b0cc5560bb5a8fe5ac680c2843903 (diff)
downloadpodman-795fbba7695b03736acaf9abe75922404f5eea44.tar.gz
podman-795fbba7695b03736acaf9abe75922404f5eea44.tar.bz2
podman-795fbba7695b03736acaf9abe75922404f5eea44.zip
Revert changes to GetDefaultStoreOptions
We don't need this for anything more than rootless work in Libpod now, but Buildah still uses it as it was originally written, so leave it intact as part of our API. Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'pkg/util/utils.go')
-rw-r--r--pkg/util/utils.go45
1 files changed, 23 insertions, 22 deletions
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
}