Skip to content

Commit

Permalink
Support /usr/share/containers/storage.conf
Browse files Browse the repository at this point in the history
Man page says we support storage.conf in this directory, so if
system does not have /etc/containers/storage.conf we should use it.

Fixes: #1015

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
  • Loading branch information
rhatdan committed Oct 14, 2021
1 parent 1c7e3ea commit 5c5bf63
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions types/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ type tomlConfig struct {

// defaultConfigFile path to the system wide storage.conf file
var (
defaultConfigFile = "/etc/containers/storage.conf"
defaultConfigFileSet = false
defaultConfigFile = "/usr/share/containers/storage.conf"
defaultOverrideConfigFile = "/etc/containers/storage.conf"
defaultConfigFileSet = false
// DefaultStoreOptions is a reasonable default set of options.
defaultStoreOptions StoreOptions
)
Expand All @@ -40,7 +41,14 @@ func init() {
defaultStoreOptions.GraphRoot = "/var/lib/containers/storage"
defaultStoreOptions.GraphDriverName = ""

ReloadConfigurationFileIfNeeded(defaultConfigFile, &defaultStoreOptions)
if _, err := os.Stat(defaultOverrideConfigFile); err == nil {
ReloadConfigurationFileIfNeeded(defaultOverrideConfigFile, &defaultStoreOptions)
} else {
if !os.IsNotExist(err) {
logrus.Warningf("Attempting to use %s, %v", defaultConfigFile, err)
}
ReloadConfigurationFileIfNeeded(defaultConfigFile, &defaultStoreOptions)
}
}

// defaultStoreOptionsIsolated is an internal implementation detail of DefaultStoreOptions to allow testing.
Expand Down

0 comments on commit 5c5bf63

Please sign in to comment.