diff options
author | Matthew Heon <mheon@redhat.com> | 2018-12-02 14:21:22 -0500 |
---|---|---|
committer | Matthew Heon <mheon@redhat.com> | 2018-12-02 14:21:22 -0500 |
commit | 92ff83f5b9dd00ff91dc8c3d6b48f1e0b5c5f3e2 (patch) | |
tree | e87c5909794f1b64c85b88420cb1d6d2a322edc9 /libpod/runtime.go | |
parent | aa7ce33b7a7698d220f258bf9b29068be6fdb531 (diff) | |
download | podman-92ff83f5b9dd00ff91dc8c3d6b48f1e0b5c5f3e2.tar.gz podman-92ff83f5b9dd00ff91dc8c3d6b48f1e0b5c5f3e2.tar.bz2 podman-92ff83f5b9dd00ff91dc8c3d6b48f1e0b5c5f3e2.zip |
Set default paths from DB if not explicitly overridden
If the DB contains default paths, and the user has not explicitly
overridden them, use the paths in the DB over our own defaults.
The DB validates these paths, so it would error and prevent
operation if they did not match. As such, instead of erroring, we
can use the DB's paths instead of our own.
Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'libpod/runtime.go')
-rw-r--r-- | libpod/runtime.go | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go index 1e05810fb..e01fa781b 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -484,7 +484,31 @@ func makeRuntime(runtime *Runtime) (err error) { return errors.Wrapf(ErrInvalidArg, "unrecognized state type passed") } - // Validate our config against the database + // Grab config from the database so we can reset some defaults + dbConfig, err := runtime.state.GetDBConfig() + if err != nil { + return errors.Wrapf(err, "error retrieving runtime configuration from database") + } + + // Reset defaults if they were not explicitly set + if !runtime.configuredFrom.storageGraphDriverSet && dbConfig.GraphDriver != "" { + runtime.config.StorageConfig.GraphDriverName = dbConfig.GraphDriver + } + if !runtime.configuredFrom.storageGraphRootSet && dbConfig.StorageRoot != "" { + runtime.config.StorageConfig.GraphRoot = dbConfig.StorageRoot + } + if !runtime.configuredFrom.storageRunRootSet && dbConfig.StorageTmp != "" { + runtime.config.StorageConfig.RunRoot = dbConfig.StorageTmp + } + if !runtime.configuredFrom.libpodStaticDirSet && dbConfig.LibpodRoot != "" { + runtime.config.StaticDir = dbConfig.LibpodRoot + } + if !runtime.configuredFrom.libpodTmpDirSet && dbConfig.LibpodTmp != "" { + runtime.config.TmpDir = dbConfig.LibpodTmp + } + + // Validate our config against the database, now that we've set our + // final storage configuration if err := runtime.state.ValidateDBConfig(runtime); err != nil { return err } |