Skip to content

Commit

Permalink
options: use global const for run and graph root
Browse files Browse the repository at this point in the history
Signed-off-by: Aditya Rajan <[email protected]>
  • Loading branch information
flouthoc committed Dec 2, 2021
1 parent cf1b8c2 commit 0bc7e4d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 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 @@ -55,10 +62,10 @@ func init() {
}
// reload could set values to empty for run and graph root if config does not contains anything
if defaultStoreOptions.RunRoot == "" {
defaultStoreOptions.RunRoot = "/run/containers/storage"
defaultStoreOptions.RunRoot = defaultRunRoot
}
if defaultStoreOptions.GraphRoot == "" {
defaultStoreOptions.GraphRoot = "/var/lib/containers/storage"
defaultStoreOptions.GraphRoot = defaultGraphRoot
}
}

Expand Down

0 comments on commit 0bc7e4d

Please sign in to comment.