diff options
author | baude <bbaude@redhat.com> | 2019-07-03 15:37:17 -0500 |
---|---|---|
committer | baude <bbaude@redhat.com> | 2019-07-08 09:18:11 -0500 |
commit | 1d36501f961889f554daf3c696fe95443ef211b6 (patch) | |
tree | 4a8d7aa79f46a0096ad7952f1390d6909a9d894b /libpod/runtime.go | |
parent | f7407f2eb512e1407f8281009eb829f37405119b (diff) | |
download | podman-1d36501f961889f554daf3c696fe95443ef211b6.tar.gz podman-1d36501f961889f554daf3c696fe95443ef211b6.tar.bz2 podman-1d36501f961889f554daf3c696fe95443ef211b6.zip |
code cleanup
clean up code identified as problematic by golands inspection
Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'libpod/runtime.go')
-rw-r--r-- | libpod/runtime.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go index 6c61e15d3..53c9a1209 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -245,7 +245,7 @@ type RuntimeConfig struct { // EventsLogger determines where events should be logged EventsLogger string `toml:"events_logger"` // EventsLogFilePath is where the events log is stored. - EventsLogFilePath string `toml:-"events_logfile_path"` + EventsLogFilePath string `toml:"-events_logfile_path"` //DetachKeys is the sequence of keys used to detach a container DetachKeys string `toml:"detach_keys"` } @@ -643,7 +643,9 @@ func newRuntimeFromConfig(ctx context.Context, userConfigPath string, options .. } if configPath != "" { - os.MkdirAll(filepath.Dir(configPath), 0755) + if err := os.MkdirAll(filepath.Dir(configPath), 0755); err != nil { + return nil, err + } file, err := os.OpenFile(configPath, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666) if err != nil && !os.IsExist(err) { return nil, errors.Wrapf(err, "cannot open file %s", configPath) @@ -652,7 +654,9 @@ func newRuntimeFromConfig(ctx context.Context, userConfigPath string, options .. defer file.Close() enc := toml.NewEncoder(file) if err := enc.Encode(runtime.config); err != nil { - os.Remove(configPath) + if removeErr := os.Remove(configPath); removeErr != nil { + logrus.Debugf("unable to remove %s: %q", configPath, err) + } } } } |