summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Holzinger <paul.holzinger@web.de>2021-02-11 22:28:35 +0100
committerPaul Holzinger <paul.holzinger@web.de>2021-02-11 23:01:49 +0100
commit69ab67bf90aa4bbd285f360e3bca4c85b6028908 (patch)
tree3ab90163357d9d85aedae6555934ae5744b4ac83
parentef2fc90f2d0057bfddee1b83d307e853181a4988 (diff)
downloadpodman-69ab67bf90aa4bbd285f360e3bca4c85b6028908.tar.gz
podman-69ab67bf90aa4bbd285f360e3bca4c85b6028908.tar.bz2
podman-69ab67bf90aa4bbd285f360e3bca4c85b6028908.zip
Enable golint linter
Use the golint linter and fix the reported problems. [NO TESTS NEEDED] Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
-rw-r--r--.golangci.yml1
-rw-r--r--cmd/podman/containers/ps.go10
-rw-r--r--libpod/container_exec.go4
-rw-r--r--libpod/container_internal.go2
-rw-r--r--libpod/healthcheck.go2
-rw-r--r--libpod/image/utils.go3
-rw-r--r--libpod/info.go6
-rw-r--r--libpod/networking_linux.go3
-rw-r--r--libpod/plugin/volume_api.go3
-rw-r--r--libpod/runtime_img.go3
-rw-r--r--libpod/volume_internal_linux.go8
-rw-r--r--pkg/api/handlers/compat/containers_archive.go2
-rw-r--r--pkg/api/handlers/utils/containers.go8
-rw-r--r--pkg/bindings/containers/archive.go2
-rw-r--r--pkg/copy/fileinfo.go6
-rw-r--r--pkg/domain/entities/network.go2
-rw-r--r--pkg/domain/infra/abi/containers_stat.go4
-rw-r--r--pkg/domain/infra/abi/images.go7
18 files changed, 34 insertions, 42 deletions
diff --git a/.golangci.yml b/.golangci.yml
index 85b753ad3..5e98f5fb6 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -51,7 +51,6 @@ linters:
- gochecknoinits
- goconst
- gocyclo
- - golint
- lll
- structcheck
- typecheck
diff --git a/cmd/podman/containers/ps.go b/cmd/podman/containers/ps.go
index 31f44d92f..98aea73b3 100644
--- a/cmd/podman/containers/ps.go
+++ b/cmd/podman/containers/ps.go
@@ -243,12 +243,12 @@ func ps(cmd *cobra.Command, _ []string) error {
// responses will grow to the largest number of processes reported on, but will not thrash the gc
var responses []psReporter
for ; ; responses = responses[:0] {
- if ctnrs, err := getResponses(); err != nil {
+ ctnrs, err := getResponses()
+ if err != nil {
return err
- } else {
- for _, r := range ctnrs {
- responses = append(responses, psReporter{r})
- }
+ }
+ for _, r := range ctnrs {
+ responses = append(responses, psReporter{r})
}
tm.Clear()
diff --git a/libpod/container_exec.go b/libpod/container_exec.go
index 443d631db..0d18b55ca 100644
--- a/libpod/container_exec.go
+++ b/libpod/container_exec.go
@@ -78,11 +78,11 @@ type ExecConfig struct {
type ExecSession struct {
// Id is the ID of the exec session.
// Named somewhat strangely to not conflict with ID().
- // nolint:stylecheck
+ // nolint:stylecheck,golint
Id string `json:"id"`
// ContainerId is the ID of the container this exec session belongs to.
// Named somewhat strangely to not conflict with ContainerID().
- // nolint:stylecheck
+ // nolint:stylecheck,golint
ContainerId string `json:"containerId"`
// State is the state of the exec session.
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 9ea9e02cd..ced357096 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -266,7 +266,7 @@ func (c *Container) handleRestartPolicy(ctx context.Context) (_ bool, retErr err
c.newContainerEvent(events.Restart)
// Increment restart count
- c.state.RestartCount += 1
+ c.state.RestartCount++
logrus.Debugf("Container %s now on retry %d", c.ID(), c.state.RestartCount)
if err := c.save(); err != nil {
return false, err
diff --git a/libpod/healthcheck.go b/libpod/healthcheck.go
index f77075893..6c5becd5b 100644
--- a/libpod/healthcheck.go
+++ b/libpod/healthcheck.go
@@ -190,7 +190,7 @@ func (c *Container) updateHealthCheckLog(hcl define.HealthCheckLog, inStartPerio
}
if !inStartPeriod {
// increment failing streak
- healthCheck.FailingStreak += 1
+ healthCheck.FailingStreak++
// if failing streak > retries, then status to unhealthy
if healthCheck.FailingStreak >= c.HealthCheckConfig().Retries {
healthCheck.Status = define.HealthCheckUnhealthy
diff --git a/libpod/image/utils.go b/libpod/image/utils.go
index 5e7fed5c6..6cc613b28 100644
--- a/libpod/image/utils.go
+++ b/libpod/image/utils.go
@@ -75,9 +75,8 @@ func findImageInRepotags(search imageParts, images []*Image) (*storage.Image, er
}
if rwImageCnt > 1 {
return nil, errors.Wrapf(define.ErrMultipleImages, "found multiple read/write images %s", strings.Join(keys, ","))
- } else {
- return nil, errors.Wrapf(define.ErrMultipleImages, "found multiple read/only images %s", strings.Join(keys, ","))
}
+ return nil, errors.Wrapf(define.ErrMultipleImages, "found multiple read/only images %s", strings.Join(keys, ","))
}
return candidates[0].image.image, nil
}
diff --git a/libpod/info.go b/libpod/info.go
index 1b3550abd..f5bfb122e 100644
--- a/libpod/info.go
+++ b/libpod/info.go
@@ -222,11 +222,11 @@ func (r *Runtime) getContainerStoreInfo() (define.ContainerStore, error) {
}
switch state {
case define.ContainerStateRunning:
- running += 1
+ running++
case define.ContainerStatePaused:
- paused += 1
+ paused++
default:
- stopped += 1
+ stopped++
}
}
cs.Paused = paused
diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go
index 55d338e7d..de6f75d3e 100644
--- a/libpod/networking_linux.go
+++ b/libpod/networking_linux.go
@@ -480,9 +480,8 @@ func (r *Runtime) setupSlirp4netns(ctr *Container) error {
if havePortMapping {
if isSlirpHostForward {
return r.setupRootlessPortMappingViaSlirp(ctr, cmd, apiSocket)
- } else {
- return r.setupRootlessPortMappingViaRLK(ctr, netnsPath)
}
+ return r.setupRootlessPortMappingViaRLK(ctr, netnsPath)
}
return nil
}
diff --git a/libpod/plugin/volume_api.go b/libpod/plugin/volume_api.go
index c5dec651c..79aebed43 100644
--- a/libpod/plugin/volume_api.go
+++ b/libpod/plugin/volume_api.go
@@ -241,9 +241,8 @@ func (p *VolumePlugin) makeErrorResponse(err, endpoint, volName string) error {
}
if volName != "" {
return errors.Wrapf(errors.New(err), "error on %s on volume %s in volume plugin %s", endpoint, volName, p.Name)
- } else {
- return errors.Wrapf(errors.New(err), "error on %s in volume plugin %s", endpoint, p.Name)
}
+ return errors.Wrapf(errors.New(err), "error on %s in volume plugin %s", endpoint, p.Name)
}
// Handle error responses from plugin
diff --git a/libpod/runtime_img.go b/libpod/runtime_img.go
index 2c5442bd2..f56fa8cce 100644
--- a/libpod/runtime_img.go
+++ b/libpod/runtime_img.go
@@ -313,9 +313,8 @@ func (r *Runtime) LoadImageFromSingleImageArchive(ctx context.Context, writer io
if err == nil && src != nil {
if newImages, err := r.ImageRuntime().LoadFromArchiveReference(ctx, src, signaturePolicy, writer); err == nil {
return getImageNames(newImages), nil
- } else {
- saveErr = err
}
+ saveErr = err
}
}
return "", errors.Wrapf(saveErr, "error pulling image")
diff --git a/libpod/volume_internal_linux.go b/libpod/volume_internal_linux.go
index e184505e7..82c01be44 100644
--- a/libpod/volume_internal_linux.go
+++ b/libpod/volume_internal_linux.go
@@ -45,7 +45,7 @@ func (v *Volume) mount() error {
// If the count is non-zero, the volume is already mounted.
// Nothing to do.
if v.state.MountCount > 0 {
- v.state.MountCount += 1
+ v.state.MountCount++
logrus.Debugf("Volume %s mount count now at %d", v.Name(), v.state.MountCount)
return v.save()
}
@@ -67,7 +67,7 @@ func (v *Volume) mount() error {
return err
}
- v.state.MountCount += 1
+ v.state.MountCount++
v.state.MountPoint = mountPoint
return v.save()
}
@@ -109,7 +109,7 @@ func (v *Volume) mount() error {
logrus.Debugf("Mounted volume %s", v.Name())
// Increment the mount counter
- v.state.MountCount += 1
+ v.state.MountCount++
logrus.Debugf("Volume %s mount count now at %d", v.Name(), v.state.MountCount)
return v.save()
}
@@ -152,7 +152,7 @@ func (v *Volume) unmount(force bool) error {
}
if !force {
- v.state.MountCount -= 1
+ v.state.MountCount--
} else {
v.state.MountCount = 0
}
diff --git a/pkg/api/handlers/compat/containers_archive.go b/pkg/api/handlers/compat/containers_archive.go
index 083c72ce8..55bd62f90 100644
--- a/pkg/api/handlers/compat/containers_archive.go
+++ b/pkg/api/handlers/compat/containers_archive.go
@@ -62,7 +62,7 @@ func handleHeadAndGet(w http.ResponseWriter, r *http.Request, decoder *schema.De
w.Header().Add(copy.XDockerContainerPathStatHeader, statHeader)
}
- if errors.Cause(err) == define.ErrNoSuchCtr || errors.Cause(err) == copy.ENOENT {
+ if errors.Cause(err) == define.ErrNoSuchCtr || errors.Cause(err) == copy.ErrENOENT {
// 404 is returned for an absent container and path. The
// clients must deal with it accordingly.
utils.Error(w, "Not found.", http.StatusNotFound, err)
diff --git a/pkg/api/handlers/utils/containers.go b/pkg/api/handlers/utils/containers.go
index 518309a03..f281c616d 100644
--- a/pkg/api/handlers/utils/containers.go
+++ b/pkg/api/handlers/utils/containers.go
@@ -130,10 +130,9 @@ func WaitContainerLibpod(w http.ResponseWriter, r *http.Request) {
if errors.Cause(err) == define.ErrNoSuchCtr {
ContainerNotFound(w, name, err)
return
- } else {
- InternalServerError(w, err)
- return
}
+ InternalServerError(w, err)
+ return
}
WriteResponse(w, http.StatusOK, strconv.Itoa(int(exitCode)))
}
@@ -200,9 +199,8 @@ func waitRemoved(ctrWait containerWaitFn) (int32, error) {
code, err := ctrWait(define.ContainerStateUnknown)
if err != nil && errors.Cause(err) == define.ErrNoSuchCtr {
return code, nil
- } else {
- return code, err
}
+ return code, err
}
func waitNextExit(ctrWait containerWaitFn) (int32, error) {
diff --git a/pkg/bindings/containers/archive.go b/pkg/bindings/containers/archive.go
index d1bbc0b95..18871cfd1 100644
--- a/pkg/bindings/containers/archive.go
+++ b/pkg/bindings/containers/archive.go
@@ -30,7 +30,7 @@ func Stat(ctx context.Context, nameOrID string, path string) (*entities.Containe
var finalErr error
if response.StatusCode == http.StatusNotFound {
- finalErr = copy.ENOENT
+ finalErr = copy.ErrENOENT
} else if response.StatusCode != http.StatusOK {
finalErr = errors.New(response.Status)
}
diff --git a/pkg/copy/fileinfo.go b/pkg/copy/fileinfo.go
index ddb9b629c..b95bcd90c 100644
--- a/pkg/copy/fileinfo.go
+++ b/pkg/copy/fileinfo.go
@@ -16,9 +16,9 @@ import (
// base64 encoded JSON payload of stating a path in a container.
const XDockerContainerPathStatHeader = "X-Docker-Container-Path-Stat"
-// ENOENT mimics the stdlib's ENOENT and can be used to implement custom logic
+// ErrENOENT mimics the stdlib's ErrENOENT and can be used to implement custom logic
// while preserving the user-visible error message.
-var ENOENT = errors.New("No such file or directory")
+var ErrENOENT = errors.New("No such file or directory")
// FileInfo describes a file or directory and is returned by
// (*CopyItem).Stat().
@@ -70,7 +70,7 @@ func ResolveHostPath(path string) (*FileInfo, error) {
statInfo, err := os.Stat(resolvedHostPath)
if err != nil {
if os.IsNotExist(err) {
- return nil, ENOENT
+ return nil, ErrENOENT
}
return nil, err
}
diff --git a/pkg/domain/entities/network.go b/pkg/domain/entities/network.go
index 1738d49ec..f66a7f575 100644
--- a/pkg/domain/entities/network.go
+++ b/pkg/domain/entities/network.go
@@ -31,7 +31,7 @@ type NetworkReloadOptions struct {
// NetworkReloadReport describes the results of reloading a container network.
type NetworkReloadReport struct {
- // nolint:stylecheck
+ // nolint:stylecheck,golint
Id string
Err error
}
diff --git a/pkg/domain/infra/abi/containers_stat.go b/pkg/domain/infra/abi/containers_stat.go
index f3d0799a0..1844f4019 100644
--- a/pkg/domain/infra/abi/containers_stat.go
+++ b/pkg/domain/infra/abi/containers_stat.go
@@ -35,7 +35,7 @@ func (ic *ContainerEngine) containerStat(container *libpod.Container, containerM
// ENOENT let's the API handlers return the correct status code
// which is crucial for the remote client.
if os.IsNotExist(err) || strings.Contains(statInfoErr.Error(), "o such file or directory") {
- statInfoErr = copy.ENOENT
+ statInfoErr = copy.ErrENOENT
}
// If statInfo is nil, there's nothing we can do anymore. A
// non-nil statInfo may indicate a symlink where we must have
@@ -129,7 +129,7 @@ func secureStat(root string, path string) (*buildahCopiah.StatForItem, error) {
stat, exists := globStats[0].Results[glob] // only one glob passed, so that's okay
if !exists {
- return nil, copy.ENOENT
+ return nil, copy.ErrENOENT
}
var statErr error
diff --git a/pkg/domain/infra/abi/images.go b/pkg/domain/infra/abi/images.go
index f2d0f2c39..cf108ba9c 100644
--- a/pkg/domain/infra/abi/images.go
+++ b/pkg/domain/infra/abi/images.go
@@ -40,10 +40,9 @@ func (ir *ImageEngine) Exists(_ context.Context, nameOrID string) (*entities.Boo
if err != nil {
if errors.Cause(err) == define.ErrMultipleImages {
return &entities.BoolReport{Value: true}, nil
- } else {
- if errors.Cause(err) != define.ErrNoSuchImage {
- return nil, err
- }
+ }
+ if errors.Cause(err) != define.ErrNoSuchImage {
+ return nil, err
}
}
return &entities.BoolReport{Value: err == nil}, nil