diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-01-24 13:14:44 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-24 13:14:44 -0500 |
commit | 54bfabb78a09bc50f270a81756a303e49965f253 (patch) | |
tree | 12fad22a19318dd8ba1ca583cac2b7ba587cff83 /pkg/api/handlers/utils | |
parent | b75d6baf074a61f2119b8619c86bd2fae1cb2833 (diff) | |
parent | 7938f32c532557eff69ada6a29b46906c3e691a3 (diff) | |
download | podman-54bfabb78a09bc50f270a81756a303e49965f253.tar.gz podman-54bfabb78a09bc50f270a81756a303e49965f253.tar.bz2 podman-54bfabb78a09bc50f270a81756a303e49965f253.zip |
Merge pull request #12973 from jmguzik/api-unused-param
Remove unused param from utils.Error in pkg/api and clean API handlers
Diffstat (limited to 'pkg/api/handlers/utils')
-rw-r--r-- | pkg/api/handlers/utils/containers.go | 4 | ||||
-rw-r--r-- | pkg/api/handlers/utils/errors.go | 31 |
2 files changed, 13 insertions, 22 deletions
diff --git a/pkg/api/handlers/utils/containers.go b/pkg/api/handlers/utils/containers.go index d1e1164a4..3a5488a4a 100644 --- a/pkg/api/handlers/utils/containers.go +++ b/pkg/api/handlers/utils/containers.go @@ -39,7 +39,7 @@ func WaitContainerDocker(w http.ResponseWriter, r *http.Request) { decoder := ctx.Value(api.DecoderKey).(*schema.Decoder) if err = decoder.Decode(&query, r.URL.Query()); err != nil { - Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String())) + Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String())) return } @@ -107,7 +107,7 @@ func WaitContainerLibpod(w http.ResponseWriter, r *http.Request) { decoder := r.Context().Value(api.DecoderKey).(*schema.Decoder) query := waitQueryLibpod{} if err := decoder.Decode(&query, r.URL.Query()); err != nil { - Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String())) + Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String())) return } diff --git a/pkg/api/handlers/utils/errors.go b/pkg/api/handlers/utils/errors.go index 1bce19c10..919a8df1e 100644 --- a/pkg/api/handlers/utils/errors.go +++ b/pkg/api/handlers/utils/errors.go @@ -1,7 +1,6 @@ package utils import ( - "fmt" "net/http" "github.com/containers/podman/v4/libpod/define" @@ -22,7 +21,7 @@ var ( // // apiMessage and code must match the container API, and are sent to client // err is logged on the system running the podman service -func Error(w http.ResponseWriter, apiMessage string, code int, err error) { +func Error(w http.ResponseWriter, code int, err error) { // Log detailed message of what happened to machine running podman service log.Infof("Request Failed(%s): %s", http.StatusText(code), err.Error()) em := errorhandling.ErrorModel{ @@ -37,70 +36,62 @@ func VolumeNotFound(w http.ResponseWriter, name string, err error) { if errors.Cause(err) != define.ErrNoSuchVolume { InternalServerError(w, err) } - msg := fmt.Sprintf("No such volume: %s", name) - Error(w, msg, http.StatusNotFound, err) + Error(w, http.StatusNotFound, err) } func ContainerNotFound(w http.ResponseWriter, name string, err error) { if errors.Cause(err) != define.ErrNoSuchCtr { InternalServerError(w, err) } - msg := fmt.Sprintf("No such container: %s", name) - Error(w, msg, http.StatusNotFound, err) + Error(w, http.StatusNotFound, err) } func ImageNotFound(w http.ResponseWriter, name string, err error) { if errors.Cause(err) != storage.ErrImageUnknown { InternalServerError(w, err) } - msg := fmt.Sprintf("No such image: %s", name) - Error(w, msg, http.StatusNotFound, err) + Error(w, http.StatusNotFound, err) } func NetworkNotFound(w http.ResponseWriter, name string, err error) { if errors.Cause(err) != define.ErrNoSuchNetwork { InternalServerError(w, err) } - msg := fmt.Sprintf("No such network: %s", name) - Error(w, msg, http.StatusNotFound, err) + Error(w, http.StatusNotFound, err) } func PodNotFound(w http.ResponseWriter, name string, err error) { if errors.Cause(err) != define.ErrNoSuchPod { InternalServerError(w, err) } - msg := fmt.Sprintf("No such pod: %s", name) - Error(w, msg, http.StatusNotFound, err) + Error(w, http.StatusNotFound, err) } func SessionNotFound(w http.ResponseWriter, name string, err error) { if errors.Cause(err) != define.ErrNoSuchExecSession { InternalServerError(w, err) } - msg := fmt.Sprintf("No such exec session: %s", name) - Error(w, msg, http.StatusNotFound, err) + Error(w, http.StatusNotFound, err) } func SecretNotFound(w http.ResponseWriter, nameOrID string, err error) { if errors.Cause(err).Error() != "no such secret" { InternalServerError(w, err) } - msg := fmt.Sprintf("No such secret: %s", nameOrID) - Error(w, msg, http.StatusNotFound, err) + Error(w, http.StatusNotFound, err) } func ContainerNotRunning(w http.ResponseWriter, containerID string, err error) { - msg := fmt.Sprintf("Container %s is not running", containerID) - Error(w, msg, http.StatusConflict, err) + Error(w, http.StatusConflict, err) } func InternalServerError(w http.ResponseWriter, err error) { - Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError, err) + Error(w, http.StatusInternalServerError, err) } func BadRequest(w http.ResponseWriter, key string, value string, err error) { e := errors.Wrapf(err, "failed to parse query parameter '%s': %q", key, value) - Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest, e) + Error(w, http.StatusBadRequest, e) } // UnsupportedParameter logs a given param by its string name as not supported. |