Merge pull request #262 from rhatdan/test

Add CONTAINERS_STORAGE_CONF Environment hanlding for testing
This commit is contained in:
Daniel J Walsh 2020-08-17 14:37:43 -04:00 committed by GitHub
commit db2a82acdd
2 changed files with 23 additions and 4 deletions

View File

@ -452,6 +452,9 @@ containers. This convention is followed by the default volume driver, but may
not be by other drivers.
# FILES
**containers.conf**
Distributions often provide a `/usr/share/containers/containers.conf` file to
define default container configuration. Administrators can override fields in
this file by creating `/etc/containers/containers.conf` to specify their own
@ -465,6 +468,16 @@ this path will be used. This is primarily used for testing.
Fields specified in the containers.conf file override the default options, as
well as options in previously read containers.conf files.
**storage.conf**
The `/etc/containers/storage.conf` file is the default storage configuration file.
Rootless users can override fields in the storage config by creating
`$HOME/.config/containers/storage.conf`.
If the `CONTAINERS_STORAGE_CONF` path environment variable is set, this path
is used for the storage.conf file rather than the default.
This is primarily used for testing.
# SEE ALSO
containers-storage.conf(5), containers-policy.json(5), containers-registries.conf(5)

View File

@ -223,10 +223,16 @@ func defaultConfigFromMemory() (*EngineConfig, error) {
c.EventsLogFilePath = filepath.Join(c.TmpDir, "events", "events.log")
storeOpts, err := storage.DefaultStoreOptions(unshare.IsRootless(), unshare.GetRootlessUID())
var storeOpts storage.StoreOptions
if path, ok := os.LookupEnv("CONTAINER_STORAGE_CONF"); ok {
storage.ReloadConfigurationFile(path, &storeOpts)
} else {
storeOpts, err = storage.DefaultStoreOptions(unshare.IsRootless(), unshare.GetRootlessUID())
if err != nil {
return nil, err
}
}
if storeOpts.GraphRoot == "" {
logrus.Warnf("Storage configuration is unset - using hardcoded default graph root %q", _defaultGraphRoot)
storeOpts.GraphRoot = _defaultGraphRoot