diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2018-11-28 04:43:41 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-28 04:43:41 -0800 |
commit | a7df0bc1fa5811481d0b52342a3a71005c361329 (patch) | |
tree | a187b7be15da09977d072906ca56a33762a340e9 | |
parent | 6688e9bc1457f1b5b96e55b01776bdb3f87bb535 (diff) | |
parent | 078cb630d3959200b4f9a14763714cf77258e8a2 (diff) | |
download | podman-a7df0bc1fa5811481d0b52342a3a71005c361329.tar.gz podman-a7df0bc1fa5811481d0b52342a3a71005c361329.tar.bz2 podman-a7df0bc1fa5811481d0b52342a3a71005c361329.zip |
Merge pull request #1839 from giuseppe/storage-save-only-subset
rootless: store only subset of storage.conf
-rw-r--r-- | pkg/util/utils.go | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/pkg/util/utils.go b/pkg/util/utils.go index c5ba38b9f..de29bc5d8 100644 --- a/pkg/util/utils.go +++ b/pkg/util/utils.go @@ -284,6 +284,35 @@ func GetRootlessStorageOpts() (storage.StoreOptions, error) { return opts, nil } +type tomlOptionsConfig struct { + MountProgram string `toml:"mount_program"` +} + +type tomlConfig struct { + Storage struct { + Driver string `toml:"driver"` + RunRoot string `toml:"runroot"` + GraphRoot string `toml:"graphroot"` + Options struct{ tomlOptionsConfig } `toml:"options"` + } `toml:"storage"` +} + +func getTomlStorage(storeOptions *storage.StoreOptions) *tomlConfig { + config := new(tomlConfig) + + config.Storage.Driver = storeOptions.GraphDriverName + config.Storage.RunRoot = storeOptions.RunRoot + config.Storage.GraphRoot = storeOptions.GraphRoot + for _, i := range storeOptions.GraphDriverOptions { + s := strings.Split(i, "=") + if s[0] == "overlay.mount_program" { + config.Storage.Options.MountProgram = s[1] + } + } + + return config +} + // GetDefaultStoreOptions returns the storage ops for containers func GetDefaultStoreOptions() (storage.StoreOptions, error) { storageOpts := storage.DefaultStoreOptions @@ -304,9 +333,10 @@ func GetDefaultStoreOptions() (storage.StoreOptions, error) { return storageOpts, errors.Wrapf(err, "cannot open %s", storageConf) } + tomlConfiguration := getTomlStorage(&storageOpts) defer file.Close() enc := toml.NewEncoder(file) - if err := enc.Encode(storageOpts); err != nil { + if err := enc.Encode(tomlConfiguration); err != nil { os.Remove(storageConf) } } |