From cd51abb215797a4e1d77ff2079fbce5d8a508d42 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Tue, 26 May 2020 09:36:07 -0400 Subject: [PATCH] Add full path for error messages on containers.conf Also add new function to allow container engines to tell users where to edit containers.conf file. Signed-off-by: Daniel J Walsh --- pkg/config/config.go | 13 +++++++++++++ pkg/config/libpodConfig.go | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index ef75d9847..e63aa9407 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -878,3 +878,16 @@ func Default() (*Config, error) { }) return config, err } + +func Path() string { + if path := os.Getenv("CONTAINERS_CONF"); path != "" { + return path + } + if unshare.IsRootless() { + if rpath, err := rootlessConfigPath(); err == nil { + return rpath + } + return "$HOME/" + UserOverrideContainersConfig + } + return OverrideContainersConfig +} diff --git a/pkg/config/libpodConfig.go b/pkg/config/libpodConfig.go index a8e4c9c93..ab507e864 100644 --- a/pkg/config/libpodConfig.go +++ b/pkg/config/libpodConfig.go @@ -226,7 +226,7 @@ func newLibpodConfig(c *Config) error { // hard code EventsLogger to "file" to match older podman versions. if config.EventsLogger != "file" { - logrus.Debugf("Ignoring lipod.conf EventsLogger setting %q. Use containers.conf if you want to change this setting and remove libpod.conf files.", config.EventsLogger) + logrus.Debugf("Ignoring libpod.conf EventsLogger setting %q. Use %q if you want to change this setting and remove libpod.conf files.", Path(), config.EventsLogger) config.EventsLogger = "file" } @@ -262,7 +262,7 @@ func systemLibpodConfigs() ([]string, error) { } // TODO: Raise to Warnf, when Podman is updated to // remove libpod.conf by default - logrus.Debugf("Found deprecated file %s, please remove. Use %s to override defaults.\n", path, containersConfPath) + logrus.Debugf("Found deprecated file %s, please remove. Use %s to override defaults.\n", Path(), containersConfPath) return []string{path}, nil } return nil, err