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>
This commit is contained in:
parent
7c575bdce2
commit
795fbba769
|
|
@ -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")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue