summaryrefslogtreecommitdiff
path: root/pkg
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 /pkg
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>
Diffstat (limited to 'pkg')
-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
7 files changed, 14 insertions, 17 deletions
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