diff options
author | openshift-ci[bot] <75433959+openshift-ci[bot]@users.noreply.github.com> | 2022-07-08 09:24:25 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-08 09:24:25 +0000 |
commit | 6087fb2116aaeae995e8423872ffe637e8be128f (patch) | |
tree | e8bd00a9b325a51a49de02e868f06eec2deeb529 /pkg/api/handlers/compat/containers_attach.go | |
parent | a2bcf833c98cb38eb28dc65a8768963d0b7344fc (diff) | |
parent | a46f798831df06c472b288db7b34de8536a7ea5a (diff) | |
download | podman-6087fb2116aaeae995e8423872ffe637e8be128f.tar.gz podman-6087fb2116aaeae995e8423872ffe637e8be128f.tar.bz2 podman-6087fb2116aaeae995e8423872ffe637e8be128f.zip |
Merge pull request #14839 from saschagrunert/errors-pkg
pkg: switch to golang native error wrapping
Diffstat (limited to 'pkg/api/handlers/compat/containers_attach.go')
-rw-r--r-- | pkg/api/handlers/compat/containers_attach.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/pkg/api/handlers/compat/containers_attach.go b/pkg/api/handlers/compat/containers_attach.go index c8905808f..e804e628a 100644 --- a/pkg/api/handlers/compat/containers_attach.go +++ b/pkg/api/handlers/compat/containers_attach.go @@ -1,6 +1,8 @@ package compat import ( + "errors" + "fmt" "net/http" "github.com/containers/podman/v4/libpod" @@ -9,7 +11,6 @@ import ( "github.com/containers/podman/v4/pkg/api/server/idle" api "github.com/containers/podman/v4/pkg/api/types" "github.com/gorilla/schema" - "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -60,13 +61,13 @@ func AttachContainer(w http.ResponseWriter, r *http.Request) { streams = nil } if useStreams && !streams.Stdout && !streams.Stderr && !streams.Stdin { - utils.Error(w, http.StatusBadRequest, errors.Errorf("at least one of stdin, stdout, stderr must be true")) + utils.Error(w, http.StatusBadRequest, errors.New("at least one of stdin, stdout, stderr must be true")) return } // At least one of these must be set if !query.Stream && !query.Logs { - utils.Error(w, http.StatusBadRequest, errors.Errorf("at least one of Logs or Stream must be set")) + utils.Error(w, http.StatusBadRequest, errors.New("at least one of Logs or Stream must be set")) return } @@ -85,16 +86,16 @@ func AttachContainer(w http.ResponseWriter, r *http.Request) { // For Docker compatibility, we need to re-initialize containers in these states. if state == define.ContainerStateConfigured || state == define.ContainerStateExited || state == define.ContainerStateStopped { if err := ctr.Init(r.Context(), ctr.PodID() != ""); err != nil { - utils.Error(w, http.StatusConflict, errors.Wrapf(err, "error preparing container %s for attach", ctr.ID())) + utils.Error(w, http.StatusConflict, fmt.Errorf("error preparing container %s for attach: %w", ctr.ID(), err)) return } } else if !(state == define.ContainerStateCreated || state == define.ContainerStateRunning) { - utils.InternalServerError(w, errors.Wrapf(define.ErrCtrStateInvalid, "can only attach to created or running containers - currently in state %s", state.String())) + utils.InternalServerError(w, fmt.Errorf("can only attach to created or running containers - currently in state %s: %w", state.String(), define.ErrCtrStateInvalid)) return } logErr := func(e error) { - logrus.Error(errors.Wrapf(e, "error attaching to container %s", ctr.ID())) + logrus.Errorf("Error attaching to container %s: %v", ctr.ID(), e) } // Perform HTTP attach. |