Skip to content

Commit e5b7fd7

Browse files
committed
Add default --root flag value to help
1 parent e4c0595 commit e5b7fd7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

runsc/config/flags.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,16 @@ const (
4444
flagOCISeccomp = "oci-seccomp"
4545
flagOverlay2 = "overlay2"
4646
flagAllowFlagOverride = "allow-flag-override"
47+
48+
defaultRootDir = "/var/run/runsc"
49+
xdgRuntimeDirEnvVar = "XDG_RUNTIME_DIR"
4750
)
4851

4952
// RegisterFlags registers flags used to populate Config.
5053
func RegisterFlags(flagSet *flag.FlagSet) {
5154
// Although these flags are not part of the OCI spec, they are used by
5255
// Docker, and thus should not be changed.
53-
flagSet.String("root", "", "root directory for storage of container state.")
56+
flagSet.String("root", "", fmt.Sprintf("root directory for storage of container state, defaults are $%s/runsc, %s.", xdgRuntimeDirEnvVar, defaultRootDir))
5457
flagSet.String("log", "", "file path where internal debug information is written, default is stdout.")
5558
flagSet.String("log-format", "text", "log format: text (default), json, or json-k8s.")
5659
flagSet.Bool(flagDebug, false, "enable debug logging.")
@@ -252,9 +255,9 @@ func NewFromFlags(flagSet *flag.FlagSet) (*Config, error) {
252255

253256
if len(conf.RootDir) == 0 {
254257
// If not set, set default root dir to something (hopefully) user-writeable.
255-
conf.RootDir = "/var/run/runsc"
258+
conf.RootDir = defaultRootDir
256259
// NOTE: empty values for XDG_RUNTIME_DIR should be ignored.
257-
if runtimeDir := os.Getenv("XDG_RUNTIME_DIR"); runtimeDir != "" {
260+
if runtimeDir := os.Getenv(xdgRuntimeDirEnvVar); runtimeDir != "" {
258261
conf.RootDir = filepath.Join(runtimeDir, "runsc")
259262
}
260263
}

0 commit comments

Comments
 (0)