Added support for CONTAINERS_STORAGE_CONF override
Signed-off-by: Morten Larsen <mortenlarsens@gmail.com>
This commit is contained in:
parent
39e7061ea7
commit
74a61676d2
|
|
@ -155,6 +155,10 @@ Set options which will be passed to the storage driver. If not set, but
|
||||||
comma-separated list and used instead. If the storage tree has previously been
|
comma-separated list and used instead. If the storage tree has previously been
|
||||||
initialized, these need not be provided.
|
initialized, these need not be provided.
|
||||||
|
|
||||||
|
## ENVIRONMENT OVERRIDES
|
||||||
|
**CONTAINERS_STORAGE_CONF**
|
||||||
|
|
||||||
|
If set will use the configuration file path provided in *$CONTAINERS_STORAGE_CONF* instead of the default `/etc/containers/storage.conf`.
|
||||||
## EXAMPLES
|
## EXAMPLES
|
||||||
**containers-storage layers -t**
|
**containers-storage layers -t**
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
[storage]
|
||||||
|
|
||||||
|
# Default Storage Driver
|
||||||
|
driver = ""
|
||||||
|
|
||||||
|
# Primary Read/Write location of container storage
|
||||||
|
graphroot = "environment_override_graphroot"
|
||||||
|
|
||||||
|
# Storage path for rootless users
|
||||||
|
#
|
||||||
|
rootless_storage_path = "environment_override_rootless_storage_path"
|
||||||
|
|
@ -160,7 +160,14 @@ func expandEnvPath(path string, rootlessUID int) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func DefaultConfigFile(rootless bool) (string, error) {
|
func DefaultConfigFile(rootless bool) (string, error) {
|
||||||
if defaultConfigFileSet || !rootless {
|
if defaultConfigFileSet {
|
||||||
|
return defaultConfigFile, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if path, ok := os.LookupEnv("CONTAINERS_STORAGE_CONF"); ok {
|
||||||
|
return path, nil
|
||||||
|
}
|
||||||
|
if !rootless {
|
||||||
return defaultConfigFile, nil
|
return defaultConfigFile, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -272,3 +272,25 @@ func TestDefaultStoreOpts(t *testing.T) {
|
||||||
assert.Equal(t, storageOpts.GraphRoot, expectedPath)
|
assert.Equal(t, storageOpts.GraphRoot, expectedPath)
|
||||||
assert.Equal(t, storageOpts.RootlessStoragePath, expectedPath)
|
assert.Equal(t, storageOpts.RootlessStoragePath, expectedPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestStorageConfOverrideEnvironmentDefaultConfigFileRootless(t *testing.T) {
|
||||||
|
os.Setenv("CONTAINERS_STORAGE_CONF", "default_override_test.conf")
|
||||||
|
defer os.Unsetenv("CONTAINERS_STORAGE_CONF")
|
||||||
|
defaultFile, err := DefaultConfigFile(true)
|
||||||
|
|
||||||
|
expectedPath := "default_override_test.conf"
|
||||||
|
|
||||||
|
assert.NilError(t, err)
|
||||||
|
assert.Equal(t, defaultFile, expectedPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestStorageConfOverrideEnvironmentDefaultConfigFileRoot(t *testing.T) {
|
||||||
|
os.Setenv("CONTAINERS_STORAGE_CONF", "default_override_test.conf")
|
||||||
|
defer os.Unsetenv("CONTAINERS_STORAGE_CONF")
|
||||||
|
defaultFile, err := DefaultConfigFile(false)
|
||||||
|
|
||||||
|
expectedPath := "default_override_test.conf"
|
||||||
|
|
||||||
|
assert.NilError(t, err)
|
||||||
|
assert.Equal(t, defaultFile, expectedPath)
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue