Skip to content

Commit

Permalink
Merge pull request #1083 from flouthoc/default_graph_run_root
Browse files Browse the repository at this point in the history
options: fall back to default `graph` and `run` root for empty case
  • Loading branch information
rhatdan authored Dec 2, 2021
2 parents 1a158c8 + 0bc7e4d commit 0cdedf0
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions types/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ type tomlConfig struct {
} `toml:"storage"`
}

const (
// these are default path for run and graph root for rootful users
// for rootless path is constructed via getRootlessStorageOpts
defaultRunRoot string = "/run/containers/storage"
defaultGraphRoot string = "/var/lib/containers/storage"
)

// defaultConfigFile path to the system wide storage.conf file
var (
defaultConfigFile = "/usr/share/containers/storage.conf"
Expand All @@ -37,8 +44,8 @@ var (
)

func init() {
defaultStoreOptions.RunRoot = "/run/containers/storage"
defaultStoreOptions.GraphRoot = "/var/lib/containers/storage"
defaultStoreOptions.RunRoot = defaultRunRoot
defaultStoreOptions.GraphRoot = defaultGraphRoot
defaultStoreOptions.GraphDriverName = ""

if _, err := os.Stat(defaultOverrideConfigFile); err == nil {
Expand All @@ -53,6 +60,13 @@ func init() {
}
ReloadConfigurationFileIfNeeded(defaultConfigFile, &defaultStoreOptions)
}
// reload could set values to empty for run and graph root if config does not contains anything
if defaultStoreOptions.RunRoot == "" {
defaultStoreOptions.RunRoot = defaultRunRoot
}
if defaultStoreOptions.GraphRoot == "" {
defaultStoreOptions.GraphRoot = defaultGraphRoot
}
}

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

0 comments on commit 0cdedf0

Please sign in to comment.