diff options
author | baude <bbaude@redhat.com> | 2019-07-11 05:44:12 -0500 |
---|---|---|
committer | baude <bbaude@redhat.com> | 2019-07-21 14:22:39 -0500 |
commit | db826d5d75630cca784bd7092eba5b06601ae27f (patch) | |
tree | c60cc844e499d5d57752fdb92d4036ea0487ae3c /pkg/adapter | |
parent | a5aa44c583612e210cf2ba44c3313a2ff27c94da (diff) | |
download | podman-db826d5d75630cca784bd7092eba5b06601ae27f.tar.gz podman-db826d5d75630cca784bd7092eba5b06601ae27f.tar.bz2 podman-db826d5d75630cca784bd7092eba5b06601ae27f.zip |
golangci-lint round #3
this is the third round of preparing to use the golangci-lint on our
code base.
Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/adapter')
-rw-r--r-- | pkg/adapter/checkpoint_restore.go | 6 | ||||
-rw-r--r-- | pkg/adapter/containers.go | 12 | ||||
-rw-r--r-- | pkg/adapter/pods.go | 4 | ||||
-rw-r--r-- | pkg/adapter/runtime.go | 5 | ||||
-rw-r--r-- | pkg/adapter/sigproxy_linux.go | 2 | ||||
-rw-r--r-- | pkg/adapter/terminal_linux.go | 2 |
6 files changed, 11 insertions, 20 deletions
diff --git a/pkg/adapter/checkpoint_restore.go b/pkg/adapter/checkpoint_restore.go index 533e9e3a2..1cac86d12 100644 --- a/pkg/adapter/checkpoint_restore.go +++ b/pkg/adapter/checkpoint_restore.go @@ -4,7 +4,6 @@ package adapter import ( "context" - "io" "io/ioutil" "os" "path/filepath" @@ -35,7 +34,7 @@ func crImportFromJSON(filePath string, v interface{}) error { return errors.Wrapf(err, "Failed to read container definition %s for restore", filePath) } json := jsoniter.ConfigCompatibleWithStandardLibrary - if err = json.Unmarshal([]byte(content), v); err != nil { + if err = json.Unmarshal(content, v); err != nil { return errors.Wrapf(err, "Failed to unmarshal container definition %s for restore", filePath) } @@ -106,9 +105,8 @@ func crImportCheckpoint(ctx context.Context, runtime *libpod.Runtime, input stri ctrName := config.Name // The code to load the images is copied from create.go - var writer io.Writer // In create.go this only set if '--quiet' does not exist. - writer = os.Stderr + writer := os.Stderr rtc, err := runtime.GetConfig() if err != nil { return nil, err diff --git a/pkg/adapter/containers.go b/pkg/adapter/containers.go index 7e2384e18..9726b237f 100644 --- a/pkg/adapter/containers.go +++ b/pkg/adapter/containers.go @@ -69,7 +69,7 @@ func (r *LocalRuntime) LookupContainer(idOrName string) (*Container, error) { func (r *LocalRuntime) StopContainers(ctx context.Context, cli *cliconfig.StopValues) ([]string, map[string]error, error) { var timeout *uint if cli.Flags().Changed("timeout") || cli.Flags().Changed("time") { - t := uint(cli.Timeout) + t := cli.Timeout timeout = &t } @@ -342,7 +342,7 @@ func (r *LocalRuntime) Run(ctx context.Context, c *cliconfig.RunValues, exitCode if err := ctr.Start(ctx, c.IsSet("pod")); err != nil { // This means the command did not exist exitCode = 127 - if strings.Index(err.Error(), "permission denied") > -1 { + if strings.Contains(err.Error(), "permission denied") { exitCode = 126 } return exitCode, err @@ -405,7 +405,7 @@ func (r *LocalRuntime) Run(ctx context.Context, c *cliconfig.RunValues, exitCode } // This means the command did not exist exitCode = 127 - if strings.Index(err.Error(), "permission denied") > -1 { + if strings.Contains(err.Error(), "permission denied") { exitCode = 126 } if c.IsSet("rm") { @@ -1057,7 +1057,7 @@ func (r *LocalRuntime) GenerateSystemd(c *cliconfig.GenerateSystemdValues) (stri } timeout := int(ctr.StopTimeout()) if c.StopTimeout >= 0 { - timeout = int(c.StopTimeout) + timeout = c.StopTimeout } name := ctr.ID() if c.Name { @@ -1153,9 +1153,7 @@ func (r *LocalRuntime) Exec(c *cliconfig.ExecValues, cmd []string) error { for _, e := range entries { i, err := strconv.Atoi(e.Name()) if err != nil { - if err != nil { - return errors.Wrapf(err, "cannot parse %s in /proc/self/fd", e.Name()) - } + return errors.Wrapf(err, "cannot parse %s in /proc/self/fd", e.Name()) } m[i] = true } diff --git a/pkg/adapter/pods.go b/pkg/adapter/pods.go index 2ca4f228f..5960fac60 100644 --- a/pkg/adapter/pods.go +++ b/pkg/adapter/pods.go @@ -155,7 +155,7 @@ func (r *LocalRuntime) StopPods(ctx context.Context, cli *cliconfig.PodStopValue for _, p := range pods { stopped := true - conErrs, stopErr := p.StopWithTimeout(ctx, true, int(timeout)) + conErrs, stopErr := p.StopWithTimeout(ctx, true, timeout) if stopErr != nil { errs = append(errs, stopErr) stopped = false @@ -532,7 +532,6 @@ func (r *LocalRuntime) PlayKubeYAML(ctx context.Context, c *cliconfig.KubePlayVa if err := libpod.LabelVolumePath(hostPath.Path, false); err != nil { return nil, errors.Wrapf(err, "Error giving %s a label", hostPath.Path) } - break case v1.HostPathFileOrCreate: if _, err := os.Stat(hostPath.Path); os.IsNotExist(err) { f, err := os.OpenFile(hostPath.Path, os.O_RDONLY|os.O_CREATE, createFilePermission) @@ -547,7 +546,6 @@ func (r *LocalRuntime) PlayKubeYAML(ctx context.Context, c *cliconfig.KubePlayVa if err := libpod.LabelVolumePath(hostPath.Path, false); err != nil { return nil, errors.Wrapf(err, "Error giving %s a label", hostPath.Path) } - break case v1.HostPathDirectory: case v1.HostPathFile: case v1.HostPathUnset: diff --git a/pkg/adapter/runtime.go b/pkg/adapter/runtime.go index dc193c738..ee6913cc0 100644 --- a/pkg/adapter/runtime.go +++ b/pkg/adapter/runtime.go @@ -332,10 +332,7 @@ func (r *LocalRuntime) LoadImage(ctx context.Context, name string, cli *cliconfi // IsImageNotFound checks if the error indicates that no image was found. func IsImageNotFound(err error) bool { - if errors.Cause(err) == image.ErrNoSuchImage { - return true - } - return false + return errors.Cause(err) == image.ErrNoSuchImage } // HealthCheck is a wrapper to same named function in libpod diff --git a/pkg/adapter/sigproxy_linux.go b/pkg/adapter/sigproxy_linux.go index efa6afa7b..ebfeab725 100644 --- a/pkg/adapter/sigproxy_linux.go +++ b/pkg/adapter/sigproxy_linux.go @@ -33,6 +33,4 @@ func ProxySignals(ctr *libpod.Container) { } } }() - - return } diff --git a/pkg/adapter/terminal_linux.go b/pkg/adapter/terminal_linux.go index e3255ecb6..9f6ddc2e6 100644 --- a/pkg/adapter/terminal_linux.go +++ b/pkg/adapter/terminal_linux.go @@ -14,6 +14,8 @@ import ( ) // StartAttachCtr starts and (if required) attaches to a container +// if you change the signature of this function from os.File to io.Writer, it will trigger a downstream +// error. we may need to just lint disable this one. func StartAttachCtr(ctx context.Context, ctr *libpod.Container, stdout, stderr, stdin *os.File, detachKeys string, sigProxy bool, startContainer bool, recursive bool) error { resize := make(chan remotecommand.TerminalSize) |