From aaec8b2408d97f7c039f9d4dc2e96ba6001f22ef Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Wed, 8 Jan 2020 13:51:13 +0100 Subject: fix lint: "guarantess" is a misspelling of "guarantees" Signed-off-by: Valentin Rothberg --- libpod/config/config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libpod') diff --git a/libpod/config/config.go b/libpod/config/config.go index 6240bccb0..c99a1c947 100644 --- a/libpod/config/config.go +++ b/libpod/config/config.go @@ -72,7 +72,7 @@ const ( // SetOptions contains a subset of options in a Config. It's used to indicate if // a given option has either been set by the user or by a parsed libpod // configuration file. If not, the corresponding option might be overwritten by -// values from the database. This behavior guarantess backwards compat with +// values from the database. This behavior guarantees backwards compat with // older version of libpod and Podman. type SetOptions struct { // StorageConfigRunRootSet indicates if the RunRoot has been explicitly set @@ -119,7 +119,7 @@ type Config struct { // SetOptions contains a subset of config options. It's used to indicate if // a given option has either been set by the user or by a parsed libpod // configuration file. If not, the corresponding option might be - // overwritten by values from the database. This behavior guarantess + // overwritten by values from the database. This behavior guarantees // backwards compat with older version of libpod and Podman. SetOptions -- cgit v1.2.3-54-g00ecf From 8ae672632b36bce993860e782048dc72fab1662c Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Wed, 8 Jan 2020 13:52:27 +0100 Subject: fix lint: correct func identifier in comment Signed-off-by: Valentin Rothberg --- libpod/oci_conmon_linux.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libpod') diff --git a/libpod/oci_conmon_linux.go b/libpod/oci_conmon_linux.go index ef881802c..0312f0ba2 100644 --- a/libpod/oci_conmon_linux.go +++ b/libpod/oci_conmon_linux.go @@ -709,7 +709,7 @@ func (r *ConmonOCIRuntime) ExecUpdateStatus(ctr *Container, sessionID string) (b return true, nil } -// ExecCleanupContainer cleans up files created when a command is run via +// ExecContainerCleanup cleans up files created when a command is run via // ExecContainer. This includes the attach socket for the exec session. func (r *ConmonOCIRuntime) ExecContainerCleanup(ctr *Container, sessionID string) error { // Clean up the sockets dir. Issue #3962 -- cgit v1.2.3-54-g00ecf From baba52c6b585e6ca8c618c41072fcbb241a0b419 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Wed, 8 Jan 2020 13:55:14 +0100 Subject: fix lint: add comment for NameRegex and error Signed-off-by: Valentin Rothberg --- libpod/options.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libpod') diff --git a/libpod/options.go b/libpod/options.go index ebde4eecc..7ee9c9b56 100644 --- a/libpod/options.go +++ b/libpod/options.go @@ -20,7 +20,9 @@ import ( ) var ( + // NameRegex is a regular expression to validate container/pod names. NameRegex = regexp.MustCompile("^[a-zA-Z0-9][a-zA-Z0-9_.-]*$") + // RegexError is thrown in presence of an invalid container/pod name. RegexError = errors.Wrapf(define.ErrInvalidArg, "names must match [a-zA-Z0-9][a-zA-Z0-9_.-]*") ) -- cgit v1.2.3-54-g00ecf From 0b53ff290232f2854a5df09be91fed46d670f47e Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Wed, 8 Jan 2020 13:57:54 +0100 Subject: fix lint - drop else block Signed-off-by: Valentin Rothberg --- libpod/config/config.go | 60 +++++++++++++++++++++++++----------------------- libpod/config/default.go | 7 +++--- libpod/options.go | 2 +- libpod/runtime.go | 6 ++--- 4 files changed, 39 insertions(+), 36 deletions(-) (limited to 'libpod') diff --git a/libpod/config/config.go b/libpod/config/config.go index c99a1c947..13c128688 100644 --- a/libpod/config/config.go +++ b/libpod/config/config.go @@ -451,45 +451,47 @@ func NewConfig(userConfigPath string) (*Config, error) { } // Now, check if the user can access system configs and merge them if needed. - if configs, err := systemConfigs(); err != nil { + configs, err := systemConfigs() + if err != nil { return nil, errors.Wrapf(err, "error finding config on system") - } else { - migrated := false - for _, path := range configs { - systemConfig, err := readConfigFromFile(path) - if err != nil { - return nil, errors.Wrapf(err, "error reading system config %q", path) - } - // Handle CGroups v2 configuration migration. - // Migrate only the first config, and do it before - // merging. - if !migrated { - if err := cgroupV2Check(path, systemConfig); err != nil { - return nil, errors.Wrapf(err, "error rewriting configuration file %s", userConfigPath) - } - migrated = true - } - // Merge the it into the config. Any unset field in config will be - // over-written by the systemConfig. - if err := config.mergeConfig(systemConfig); err != nil { - return nil, errors.Wrapf(err, "error merging system config") + } + + migrated := false + for _, path := range configs { + systemConfig, err := readConfigFromFile(path) + if err != nil { + return nil, errors.Wrapf(err, "error reading system config %q", path) + } + // Handle CGroups v2 configuration migration. + // Migrate only the first config, and do it before + // merging. + if !migrated { + if err := cgroupV2Check(path, systemConfig); err != nil { + return nil, errors.Wrapf(err, "error rewriting configuration file %s", userConfigPath) } - logrus.Debugf("Merged system config %q: %v", path, config) + migrated = true + } + // Merge the it into the config. Any unset field in config will be + // over-written by the systemConfig. + if err := config.mergeConfig(systemConfig); err != nil { + return nil, errors.Wrapf(err, "error merging system config") } + logrus.Debugf("Merged system config %q: %v", path, config) } // Finally, create a default config from memory and forcefully merge it into // the config. This way we try to make sure that all fields are properly set // and that user AND system config can partially set. - if defaultConfig, err := defaultConfigFromMemory(); err != nil { + defaultConfig, err := defaultConfigFromMemory() + if err != nil { return nil, errors.Wrapf(err, "error generating default config from memory") - } else { - // Check if we need to switch to cgroupfs and logger=file on rootless. - defaultConfig.checkCgroupsAndLogger() + } - if err := config.mergeConfig(defaultConfig); err != nil { - return nil, errors.Wrapf(err, "error merging default config from memory") - } + // Check if we need to switch to cgroupfs and logger=file on rootless. + defaultConfig.checkCgroupsAndLogger() + + if err := config.mergeConfig(defaultConfig); err != nil { + return nil, errors.Wrapf(err, "error merging default config from memory") } // Relative paths can cause nasty bugs, because core paths we use could diff --git a/libpod/config/default.go b/libpod/config/default.go index 5decaeab7..c4a4efdaf 100644 --- a/libpod/config/default.go +++ b/libpod/config/default.go @@ -26,11 +26,12 @@ const ( // config is different for root and rootless. It also parses the storage.conf. func defaultConfigFromMemory() (*Config, error) { c := new(Config) - if tmp, err := defaultTmpDir(); err != nil { + tmp, err := defaultTmpDir() + if err != nil { return nil, err - } else { - c.TmpDir = tmp } + c.TmpDir = tmp + c.EventsLogFilePath = filepath.Join(c.TmpDir, "events", "events.log") storeOpts, err := storage.DefaultStoreOptions(rootless.IsRootless(), rootless.GetRootlessUID()) diff --git a/libpod/options.go b/libpod/options.go index 7ee9c9b56..031f4f705 100644 --- a/libpod/options.go +++ b/libpod/options.go @@ -21,7 +21,7 @@ import ( var ( // NameRegex is a regular expression to validate container/pod names. - NameRegex = regexp.MustCompile("^[a-zA-Z0-9][a-zA-Z0-9_.-]*$") + NameRegex = regexp.MustCompile("^[a-zA-Z0-9][a-zA-Z0-9_.-]*$") // RegexError is thrown in presence of an invalid container/pod name. RegexError = errors.Wrapf(define.ErrInvalidArg, "names must match [a-zA-Z0-9][a-zA-Z0-9_.-]*") ) diff --git a/libpod/runtime.go b/libpod/runtime.go index 001d850b0..b4cbde28e 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -213,11 +213,11 @@ func getLockManager(runtime *Runtime) (lock.Manager, error) { // Sets up containers/storage, state store, OCI runtime func makeRuntime(ctx context.Context, runtime *Runtime) (err error) { // Find a working conmon binary - if cPath, err := runtime.config.FindConmon(); err != nil { + cPath, err := runtime.config.FindConmon() + if err != nil { return err - } else { - runtime.conmonPath = cPath } + runtime.conmonPath = cPath // Make the static files directory if it does not exist if err := os.MkdirAll(runtime.config.StaticDir, 0700); err != nil { -- cgit v1.2.3-54-g00ecf From 583ff5320f879ad714d3482ed0ae23c8eecfdf05 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Wed, 8 Jan 2020 14:03:37 +0100 Subject: fix lint - ignore image.ImageDeleteResponse definition Golint claims that image.Image stutters but renaming the type would be a breaking change which isn't worth the consequences. Signed-off-by: Valentin Rothberg --- libpod/image/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libpod') diff --git a/libpod/image/config.go b/libpod/image/config.go index 40e7fd496..bb84175a3 100644 --- a/libpod/image/config.go +++ b/libpod/image/config.go @@ -2,7 +2,7 @@ package image // ImageDeleteResponse is the response for removing an image from storage and containers // what was untagged vs actually removed -type ImageDeleteResponse struct { +type ImageDeleteResponse struct { //nolint Untagged []string `json:"untagged"` Deleted string `json:"deleted"` } -- cgit v1.2.3-54-g00ecf