aboutsummaryrefslogtreecommitdiff
path: root/libpod/options.go
diff options
context:
space:
mode:
authorMatthew Heon <mheon@redhat.com>2018-12-02 14:06:33 -0500
committerMatthew Heon <mheon@redhat.com>2018-12-02 14:06:33 -0500
commitaa7ce33b7a7698d220f258bf9b29068be6fdb531 (patch)
tree15f60313cffac457e0eb88e0272a770479c40d94 /libpod/options.go
parent137e0948aed96c3fe6412512e0d138eedf71d499 (diff)
downloadpodman-aa7ce33b7a7698d220f258bf9b29068be6fdb531.tar.gz
podman-aa7ce33b7a7698d220f258bf9b29068be6fdb531.tar.bz2
podman-aa7ce33b7a7698d220f258bf9b29068be6fdb531.zip
Add a struct indicating if some Runtime fields were set
To configure runtime fields from the database, we need to know whether they were explicitly overwritten by the user (we don't want to overwrite anything that was explicitly set). Store a struct containing whether the variables we'll grab from the DB were explicitly set by the user so we know what we can and can't overwrite. This determines whether libpod runtime and static dirs were set via config file in a horribly hackish way (double TOML decode), but I can't think of a better way, and it shouldn't be that expensive as the libpod config is tiny. Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'libpod/options.go')
-rw-r--r--libpod/options.go21
1 files changed, 20 insertions, 1 deletions
diff --git a/libpod/options.go b/libpod/options.go
index 7f4e3ac6b..6783e2a39 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -30,9 +30,26 @@ func WithStorageConfig(config storage.StoreOptions) RuntimeOption {
}
rt.config.StorageConfig.RunRoot = config.RunRoot
+ if config.RunRoot != "" {
+ rt.configuredFrom.storageRunRootSet = true
+ }
+
rt.config.StorageConfig.GraphRoot = config.GraphRoot
+ if config.GraphRoot != "" {
+ rt.configuredFrom.storageGraphRootSet = true
+ }
+
rt.config.StorageConfig.GraphDriverName = config.GraphDriverName
- rt.config.StaticDir = filepath.Join(config.GraphRoot, "libpod")
+ if config.GraphDriverName != "" {
+ rt.configuredFrom.storageGraphDriverSet = true
+ }
+
+ // Only set our static dir if it was not already explicitly
+ // overridden
+ if config.GraphRoot != "" && !rt.configuredFrom.libpodStaticDirSet {
+ rt.config.StaticDir = filepath.Join(config.GraphRoot, "libpod")
+ rt.configuredFrom.libpodStaticDirSet = true
+ }
rt.config.StorageConfig.GraphDriverOptions = make([]string, len(config.GraphDriverOptions))
copy(rt.config.StorageConfig.GraphDriverOptions, config.GraphDriverOptions)
@@ -174,6 +191,7 @@ func WithStaticDir(dir string) RuntimeOption {
}
rt.config.StaticDir = dir
+ rt.configuredFrom.libpodStaticDirSet = true
return nil
}
@@ -226,6 +244,7 @@ func WithTmpDir(dir string) RuntimeOption {
}
rt.config.TmpDir = dir
+ rt.configuredFrom.libpodTmpDirSet = true
return nil
}