diff options
author | Jakub Guzik <jguzik@redhat.com> | 2022-01-21 23:56:23 +0100 |
---|---|---|
committer | Jakub Guzik <jguzik@redhat.com> | 2022-01-22 00:31:18 +0100 |
commit | 7938f32c532557eff69ada6a29b46906c3e691a3 (patch) | |
tree | 8dd31a941623eee1e46e6911ebbdae28c91e77df /pkg/api/handlers/utils | |
parent | d847ad598d752dad479250b7f289858cc272cb04 (diff) | |
download | podman-7938f32c532557eff69ada6a29b46906c3e691a3.tar.gz podman-7938f32c532557eff69ada6a29b46906c3e691a3.tar.bz2 podman-7938f32c532557eff69ada6a29b46906c3e691a3.zip |
Remove unused param and clean API handlers
This commit removes error message string from utils.Error in pkg/api.
Param was not used inside a function for quite a long time
[NO NEW TESTS NEEDED]
Signed-off-by: Jakub Guzik <jguzik@redhat.com>
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. |