summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/compat
diff options
context:
space:
mode:
authorJakub Guzik <jguzik@redhat.com>2022-01-21 23:56:23 +0100
committerJakub Guzik <jguzik@redhat.com>2022-01-22 00:31:18 +0100
commit7938f32c532557eff69ada6a29b46906c3e691a3 (patch)
tree8dd31a941623eee1e46e6911ebbdae28c91e77df /pkg/api/handlers/compat
parentd847ad598d752dad479250b7f289858cc272cb04 (diff)
downloadpodman-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/compat')
-rw-r--r--pkg/api/handlers/compat/auth.go2
-rw-r--r--pkg/api/handlers/compat/changes.go4
-rw-r--r--pkg/api/handlers/compat/containers.go22
-rw-r--r--pkg/api/handlers/compat/containers_archive.go24
-rw-r--r--pkg/api/handlers/compat/containers_attach.go8
-rw-r--r--pkg/api/handlers/compat/containers_create.go23
-rw-r--r--pkg/api/handlers/compat/containers_export.go8
-rw-r--r--pkg/api/handlers/compat/containers_logs.go4
-rw-r--r--pkg/api/handlers/compat/containers_prune.go2
-rw-r--r--pkg/api/handlers/compat/containers_restart.go3
-rw-r--r--pkg/api/handlers/compat/containers_stats.go6
-rw-r--r--pkg/api/handlers/compat/containers_stop.go3
-rw-r--r--pkg/api/handlers/compat/containers_top.go6
-rw-r--r--pkg/api/handlers/compat/events.go4
-rw-r--r--pkg/api/handlers/compat/exec.go14
-rw-r--r--pkg/api/handlers/compat/images.go72
-rw-r--r--pkg/api/handlers/compat/images_build.go10
-rw-r--r--pkg/api/handlers/compat/images_history.go2
-rw-r--r--pkg/api/handlers/compat/images_prune.go2
-rw-r--r--pkg/api/handlers/compat/images_push.go13
-rw-r--r--pkg/api/handlers/compat/images_remove.go6
-rw-r--r--pkg/api/handlers/compat/images_search.go6
-rw-r--r--pkg/api/handlers/compat/images_tag.go8
-rw-r--r--pkg/api/handlers/compat/info.go6
-rw-r--r--pkg/api/handlers/compat/networks.go42
-rw-r--r--pkg/api/handlers/compat/resize.go8
-rw-r--r--pkg/api/handlers/compat/secrets.go13
-rw-r--r--pkg/api/handlers/compat/version.go4
-rw-r--r--pkg/api/handlers/compat/volumes.go16
29 files changed, 163 insertions, 178 deletions
diff --git a/pkg/api/handlers/compat/auth.go b/pkg/api/handlers/compat/auth.go
index 4c4ad8afd..7804c8230 100644
--- a/pkg/api/handlers/compat/auth.go
+++ b/pkg/api/handlers/compat/auth.go
@@ -28,7 +28,7 @@ func Auth(w http.ResponseWriter, r *http.Request) {
var authConfig docker.AuthConfig
err := json.NewDecoder(r.Body).Decode(&authConfig)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrapf(err, "failed to parse request"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrapf(err, "failed to parse request"))
return
}
diff --git a/pkg/api/handlers/compat/changes.go b/pkg/api/handlers/compat/changes.go
index f26f239dc..af0143fcf 100644
--- a/pkg/api/handlers/compat/changes.go
+++ b/pkg/api/handlers/compat/changes.go
@@ -20,7 +20,7 @@ func Changes(w http.ResponseWriter, r *http.Request) {
DiffType string `schema:"diffType"`
}{}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
var diffType define.DiffType
@@ -32,7 +32,7 @@ func Changes(w http.ResponseWriter, r *http.Request) {
case "image":
diffType = define.DiffImage
default:
- utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Errorf("invalid diffType value %q", query.DiffType))
+ utils.Error(w, http.StatusBadRequest, errors.Errorf("invalid diffType value %q", query.DiffType))
return
}
diff --git a/pkg/api/handlers/compat/containers.go b/pkg/api/handlers/compat/containers.go
index 94393886f..4830ef4b7 100644
--- a/pkg/api/handlers/compat/containers.go
+++ b/pkg/api/handlers/compat/containers.go
@@ -46,8 +46,7 @@ func RemoveContainer(w http.ResponseWriter, r *http.Request) {
}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest,
- errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
@@ -61,8 +60,7 @@ func RemoveContainer(w http.ResponseWriter, r *http.Request) {
options.Depend = query.Depend
} else {
if query.Link {
- utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest,
- utils.ErrLinkNotSupport)
+ utils.Error(w, http.StatusBadRequest, utils.ErrLinkNotSupport)
return
}
options.Volumes = query.DockerVolumes
@@ -112,12 +110,12 @@ func ListContainers(w http.ResponseWriter, r *http.Request) {
filterMap, err := util.PrepareFilters(r)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrapf(err, "failed to decode filter parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrapf(err, "failed to decode filter parameters for %s", r.URL.String()))
return
}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
@@ -189,7 +187,7 @@ func GetContainer(w http.ResponseWriter, r *http.Request) {
}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
@@ -217,7 +215,7 @@ func KillContainer(w http.ResponseWriter, r *http.Request) {
Signal: "KILL",
}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
@@ -232,7 +230,7 @@ func KillContainer(w http.ResponseWriter, r *http.Request) {
if err != nil {
if errors.Cause(err) == define.ErrCtrStateInvalid ||
errors.Cause(err) == define.ErrCtrStopped {
- utils.Error(w, fmt.Sprintf("Container %s is not running", name), http.StatusConflict, err)
+ utils.Error(w, http.StatusConflict, err)
return
}
if errors.Cause(err) == define.ErrNoSuchCtr {
@@ -262,7 +260,7 @@ func KillContainer(w http.ResponseWriter, r *http.Request) {
Interval: time.Millisecond * 250,
}
if _, err := containerEngine.ContainerWait(r.Context(), []string{name}, opts); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err)
+ utils.Error(w, http.StatusInternalServerError, err)
return
}
}
@@ -613,7 +611,7 @@ func RenameContainer(w http.ResponseWriter, r *http.Request) {
Name string `schema:"name"`
}{}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
@@ -625,7 +623,7 @@ func RenameContainer(w http.ResponseWriter, r *http.Request) {
if _, err := runtime.RenameContainer(r.Context(), ctr, query.Name); err != nil {
if errors.Cause(err) == define.ErrPodExists || errors.Cause(err) == define.ErrCtrExists {
- utils.Error(w, "Something went wrong.", http.StatusConflict, err)
+ utils.Error(w, http.StatusConflict, err)
return
}
utils.InternalServerError(w, err)
diff --git a/pkg/api/handlers/compat/containers_archive.go b/pkg/api/handlers/compat/containers_archive.go
index a0e3c6d02..f2ff4d100 100644
--- a/pkg/api/handlers/compat/containers_archive.go
+++ b/pkg/api/handlers/compat/containers_archive.go
@@ -28,7 +28,7 @@ func Archive(w http.ResponseWriter, r *http.Request) {
case http.MethodHead, http.MethodGet:
handleHeadAndGet(w, r, decoder, runtime)
default:
- utils.Error(w, fmt.Sprintf("unsupported method: %v", r.Method), http.StatusNotImplemented, errors.New(fmt.Sprintf("unsupported method: %v", r.Method)))
+ utils.Error(w, http.StatusNotImplemented, errors.New(fmt.Sprintf("unsupported method: %v", r.Method)))
}
}
@@ -39,12 +39,12 @@ func handleHeadAndGet(w http.ResponseWriter, r *http.Request, decoder *schema.De
err := decoder.Decode(&query, r.URL.Query())
if err != nil {
- utils.Error(w, "Bad Request.", http.StatusBadRequest, errors.Wrap(err, "couldn't decode the query"))
+ utils.Error(w, http.StatusBadRequest, errors.Wrap(err, "couldn't decode the query"))
return
}
if query.Path == "" {
- utils.Error(w, "Bad Request.", http.StatusBadRequest, errors.New("missing `path` parameter"))
+ utils.Error(w, http.StatusBadRequest, errors.New("missing `path` parameter"))
return
}
@@ -59,7 +59,7 @@ func handleHeadAndGet(w http.ResponseWriter, r *http.Request, decoder *schema.De
if statReport != nil {
statHeader, err := copy.EncodeFileInfo(&statReport.FileInfo)
if err != nil {
- utils.Error(w, "Something went wrong", http.StatusInternalServerError, err)
+ utils.Error(w, http.StatusInternalServerError, err)
return
}
w.Header().Add(copy.XDockerContainerPathStatHeader, statHeader)
@@ -68,10 +68,10 @@ func handleHeadAndGet(w http.ResponseWriter, r *http.Request, decoder *schema.De
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)
+ utils.Error(w, http.StatusNotFound, err)
return
} else if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err)
+ utils.Error(w, http.StatusInternalServerError, err)
return
}
@@ -83,7 +83,7 @@ func handleHeadAndGet(w http.ResponseWriter, r *http.Request, decoder *schema.De
copyFunc, err := containerEngine.ContainerCopyToArchive(r.Context(), containerName, query.Path, w)
if err != nil {
- utils.Error(w, "Something went wrong", http.StatusInternalServerError, err)
+ utils.Error(w, http.StatusInternalServerError, err)
return
}
w.Header().Set("Content-Type", "application/x-tar")
@@ -106,14 +106,14 @@ func handlePut(w http.ResponseWriter, r *http.Request, decoder *schema.Decoder,
err := decoder.Decode(&query, r.URL.Query())
if err != nil {
- utils.Error(w, "Bad Request.", http.StatusBadRequest, errors.Wrap(err, "couldn't decode the query"))
+ utils.Error(w, http.StatusBadRequest, errors.Wrap(err, "couldn't decode the query"))
return
}
var rename map[string]string
if query.Rename != "" {
if err := json.Unmarshal([]byte(query.Rename), &rename); err != nil {
- utils.Error(w, "Bad Request.", http.StatusBadRequest, errors.Wrap(err, "couldn't decode the query"))
+ utils.Error(w, http.StatusBadRequest, errors.Wrap(err, "couldn't decode the query"))
return
}
}
@@ -126,16 +126,16 @@ func handlePut(w http.ResponseWriter, r *http.Request, decoder *schema.Decoder,
if errors.Cause(err) == define.ErrNoSuchCtr || os.IsNotExist(err) {
// 404 is returned for an absent container and path. The
// clients must deal with it accordingly.
- utils.Error(w, "Not found.", http.StatusNotFound, errors.Wrap(err, "the container doesn't exists"))
+ utils.Error(w, http.StatusNotFound, errors.Wrap(err, "the container doesn't exists"))
return
} else if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err)
+ utils.Error(w, http.StatusInternalServerError, err)
return
}
if err := copyFunc(); err != nil {
logrus.Error(err.Error())
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err)
+ utils.Error(w, http.StatusInternalServerError, err)
return
}
w.WriteHeader(http.StatusOK)
diff --git a/pkg/api/handlers/compat/containers_attach.go b/pkg/api/handlers/compat/containers_attach.go
index ccdf054b9..027dadaa3 100644
--- a/pkg/api/handlers/compat/containers_attach.go
+++ b/pkg/api/handlers/compat/containers_attach.go
@@ -28,7 +28,7 @@ func AttachContainer(w http.ResponseWriter, r *http.Request) {
Stream: true,
}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, "Error parsing parameters", http.StatusBadRequest, err)
+ utils.Error(w, http.StatusBadRequest, err)
return
}
@@ -60,13 +60,13 @@ func AttachContainer(w http.ResponseWriter, r *http.Request) {
streams = nil
}
if useStreams && !streams.Stdout && !streams.Stderr && !streams.Stdin {
- utils.Error(w, "Parameter conflict", http.StatusBadRequest, errors.Errorf("at least one of stdin, stdout, stderr must be true"))
+ utils.Error(w, http.StatusBadRequest, errors.Errorf("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, "Unsupported parameter", http.StatusBadRequest, errors.Errorf("at least one of Logs or Stream must be set"))
+ utils.Error(w, http.StatusBadRequest, errors.Errorf("at least one of Logs or Stream must be set"))
return
}
@@ -85,7 +85,7 @@ 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 {
if err := ctr.Init(r.Context(), ctr.PodID() != ""); err != nil {
- utils.Error(w, "Container in wrong state", http.StatusConflict, errors.Wrapf(err, "error preparing container %s for attach", ctr.ID()))
+ utils.Error(w, http.StatusConflict, errors.Wrapf(err, "error preparing container %s for attach", ctr.ID()))
return
}
} else if !(state == define.ContainerStateCreated || state == define.ContainerStateRunning) {
diff --git a/pkg/api/handlers/compat/containers_create.go b/pkg/api/handlers/compat/containers_create.go
index 467231150..cd592a975 100644
--- a/pkg/api/handlers/compat/containers_create.go
+++ b/pkg/api/handlers/compat/containers_create.go
@@ -27,15 +27,14 @@ func CreateContainer(w http.ResponseWriter, r *http.Request) {
// override any golang type defaults
}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest,
- errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
// compatible configuration
body := handlers.CreateContainerConfig{}
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
return
}
@@ -43,18 +42,18 @@ func CreateContainer(w http.ResponseWriter, r *http.Request) {
body.Name = query.Name
if len(body.HostConfig.Links) > 0 {
- utils.Error(w, utils.ErrLinkNotSupport.Error(), http.StatusBadRequest, errors.Wrapf(utils.ErrLinkNotSupport, "bad parameter"))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(utils.ErrLinkNotSupport, "bad parameter"))
return
}
rtc, err := runtime.GetConfig()
if err != nil {
- utils.Error(w, "unable to obtain runtime config", http.StatusInternalServerError, errors.Wrap(err, "unable to get runtime config"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "unable to get runtime config"))
return
}
imageName, err := utils.NormalizeToDockerHub(r, body.Config.Image)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
return
}
body.Config.Image = imageName
@@ -62,18 +61,18 @@ func CreateContainer(w http.ResponseWriter, r *http.Request) {
newImage, resolvedName, err := runtime.LibimageRuntime().LookupImage(body.Config.Image, nil)
if err != nil {
if errors.Cause(err) == storage.ErrImageUnknown {
- utils.Error(w, "No such image", http.StatusNotFound, errors.Wrap(err, "No such image"))
+ utils.Error(w, http.StatusNotFound, errors.Wrap(err, "No such image"))
return
}
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "error looking up image"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "error looking up image"))
return
}
// Take body structure and convert to cliopts
cliOpts, args, err := common.ContainerCreateToContainerCLIOpts(body, rtc)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "make cli opts()"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "make cli opts()"))
return
}
@@ -81,7 +80,7 @@ func CreateContainer(w http.ResponseWriter, r *http.Request) {
// if the img had multi names with the same sha256 ID, should use the InputName, not the ID
if len(newImage.Names()) > 1 {
if err := utils.IsRegistryReference(resolvedName); err != nil {
- utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest, err)
+ utils.Error(w, http.StatusBadRequest, err)
return
}
// maybe the InputName has no tag, so use full name to display
@@ -90,7 +89,7 @@ func CreateContainer(w http.ResponseWriter, r *http.Request) {
sg := specgen.NewSpecGenerator(imgNameOrID, cliOpts.RootFS)
if err := specgenutil.FillOutSpecGen(sg, cliOpts, args); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "fill out specgen"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "fill out specgen"))
return
}
// moby always create the working directory
@@ -99,7 +98,7 @@ func CreateContainer(w http.ResponseWriter, r *http.Request) {
ic := abi.ContainerEngine{Libpod: runtime}
report, err := ic.ContainerCreate(r.Context(), sg)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "container create"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "container create"))
return
}
createResponse := entities.ContainerCreateResponse{
diff --git a/pkg/api/handlers/compat/containers_export.go b/pkg/api/handlers/compat/containers_export.go
index 8be1dcf99..743ce2d53 100644
--- a/pkg/api/handlers/compat/containers_export.go
+++ b/pkg/api/handlers/compat/containers_export.go
@@ -21,21 +21,21 @@ func ExportContainer(w http.ResponseWriter, r *http.Request) {
}
tmpfile, err := ioutil.TempFile("", "api.tar")
if err != nil {
- utils.Error(w, "unable to create tarball tempfile", http.StatusInternalServerError, errors.Wrap(err, "unable to create tempfile"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "unable to create tempfile"))
return
}
defer os.Remove(tmpfile.Name())
if err := tmpfile.Close(); err != nil {
- utils.Error(w, "unable to close tempfile", http.StatusInternalServerError, errors.Wrap(err, "unable to close tempfile"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "unable to close tempfile"))
return
}
if err := con.Export(tmpfile.Name()); err != nil {
- utils.Error(w, "failed to save the image", http.StatusInternalServerError, errors.Wrap(err, "failed to save image"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "failed to save image"))
return
}
rdr, err := os.Open(tmpfile.Name())
if err != nil {
- utils.Error(w, "failed to read temp tarball", http.StatusInternalServerError, errors.Wrap(err, "failed to read the exported tarfile"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "failed to read the exported tarfile"))
return
}
defer rdr.Close()
diff --git a/pkg/api/handlers/compat/containers_logs.go b/pkg/api/handlers/compat/containers_logs.go
index 20f71a4fe..fc894d815 100644
--- a/pkg/api/handlers/compat/containers_logs.go
+++ b/pkg/api/handlers/compat/containers_logs.go
@@ -36,13 +36,13 @@ func LogsFromContainer(w http.ResponseWriter, r *http.Request) {
Tail: "all",
}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
if !(query.Stdout || query.Stderr) {
msg := fmt.Sprintf("%s: you must choose at least one stream", http.StatusText(http.StatusBadRequest))
- utils.Error(w, msg, http.StatusBadRequest, errors.Errorf("%s for %s", msg, r.URL.String()))
+ utils.Error(w, http.StatusBadRequest, errors.Errorf("%s for %s", msg, r.URL.String()))
return
}
diff --git a/pkg/api/handlers/compat/containers_prune.go b/pkg/api/handlers/compat/containers_prune.go
index 2a2c9f678..9b5390d64 100644
--- a/pkg/api/handlers/compat/containers_prune.go
+++ b/pkg/api/handlers/compat/containers_prune.go
@@ -18,7 +18,7 @@ func PruneContainers(w http.ResponseWriter, r *http.Request) {
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
filtersMap, err := util.PrepareFilters(r)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
diff --git a/pkg/api/handlers/compat/containers_restart.go b/pkg/api/handlers/compat/containers_restart.go
index 66bca23e6..ded6480bc 100644
--- a/pkg/api/handlers/compat/containers_restart.go
+++ b/pkg/api/handlers/compat/containers_restart.go
@@ -29,8 +29,7 @@ func RestartContainer(w http.ResponseWriter, r *http.Request) {
// override any golang type defaults
}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest,
- errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
diff --git a/pkg/api/handlers/compat/containers_stats.go b/pkg/api/handlers/compat/containers_stats.go
index c770a03f5..99f14d02f 100644
--- a/pkg/api/handlers/compat/containers_stats.go
+++ b/pkg/api/handlers/compat/containers_stats.go
@@ -29,11 +29,11 @@ func StatsContainer(w http.ResponseWriter, r *http.Request) {
Stream: true,
}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
if query.Stream && query.OneShot { // mismatch. one-shot can only be passed with stream=false
- utils.Error(w, "invalid combination of stream and one-shot", http.StatusBadRequest, define.ErrInvalidArg)
+ utils.Error(w, http.StatusBadRequest, define.ErrInvalidArg)
return
}
@@ -52,7 +52,7 @@ func StatsContainer(w http.ResponseWriter, r *http.Request) {
return
}
if state != define.ContainerStateRunning {
- utils.Error(w, "Container not running and streaming requested", http.StatusConflict, define.ErrCtrStateInvalid)
+ utils.Error(w, http.StatusConflict, define.ErrCtrStateInvalid)
return
}
diff --git a/pkg/api/handlers/compat/containers_stop.go b/pkg/api/handlers/compat/containers_stop.go
index 5bc3a34ac..1c1fb310c 100644
--- a/pkg/api/handlers/compat/containers_stop.go
+++ b/pkg/api/handlers/compat/containers_stop.go
@@ -29,8 +29,7 @@ func StopContainer(w http.ResponseWriter, r *http.Request) {
// override any golang type defaults
}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest,
- errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
diff --git a/pkg/api/handlers/compat/containers_top.go b/pkg/api/handlers/compat/containers_top.go
index 6970cabe3..6ca178cf7 100644
--- a/pkg/api/handlers/compat/containers_top.go
+++ b/pkg/api/handlers/compat/containers_top.go
@@ -33,14 +33,12 @@ func TopContainer(w http.ResponseWriter, r *http.Request) {
PsArgs: psArgs,
}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest,
- errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
if query.Delay < 1 {
- utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest,
- fmt.Errorf("\"delay\" parameter of value %d < 1", query.Delay))
+ utils.Error(w, http.StatusBadRequest, fmt.Errorf("\"delay\" parameter of value %d < 1", query.Delay))
return
}
diff --git a/pkg/api/handlers/compat/events.go b/pkg/api/handlers/compat/events.go
index cdee56aee..03b3d54bc 100644
--- a/pkg/api/handlers/compat/events.go
+++ b/pkg/api/handlers/compat/events.go
@@ -34,7 +34,7 @@ func GetEvents(w http.ResponseWriter, r *http.Request) {
Stream: true,
}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, "failed to parse parameters", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
@@ -44,7 +44,7 @@ func GetEvents(w http.ResponseWriter, r *http.Request) {
libpodFilters, err := util.FiltersFromRequest(r)
if err != nil {
- utils.Error(w, "failed to parse parameters", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
eventChannel := make(chan *events.Event)
diff --git a/pkg/api/handlers/compat/exec.go b/pkg/api/handlers/compat/exec.go
index c1ace5a38..c6f7e0318 100644
--- a/pkg/api/handlers/compat/exec.go
+++ b/pkg/api/handlers/compat/exec.go
@@ -2,7 +2,6 @@ package compat
import (
"encoding/json"
- "fmt"
"net/http"
"strings"
@@ -48,7 +47,7 @@ func ExecCreateHandler(w http.ResponseWriter, r *http.Request) {
for _, envStr := range input.Env {
split := strings.SplitN(envStr, "=", 2)
if len(split) != 2 {
- utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest, errors.Errorf("environment variable %q badly formed, must be key=value", envStr))
+ utils.Error(w, http.StatusBadRequest, errors.Errorf("environment variable %q badly formed, must be key=value", envStr))
return
}
libpodConfig.Environment[split[0]] = split[1]
@@ -85,7 +84,7 @@ func ExecCreateHandler(w http.ResponseWriter, r *http.Request) {
// Ignore the error != nil case. We're already
// throwing an InternalServerError below.
if state == define.ContainerStatePaused {
- utils.Error(w, "Container is paused", http.StatusConflict, errors.Errorf("cannot create exec session as container %s is paused", ctr.ID()))
+ utils.Error(w, http.StatusConflict, errors.Errorf("cannot create exec session as container %s is paused", ctr.ID()))
return
}
}
@@ -107,7 +106,7 @@ func ExecInspectHandler(w http.ResponseWriter, r *http.Request) {
sessionID := mux.Vars(r)["id"]
sessionCtr, err := runtime.GetExecSessionContainer(sessionID)
if err != nil {
- utils.Error(w, fmt.Sprintf("No such exec session: %s", sessionID), http.StatusNotFound, err)
+ utils.Error(w, http.StatusNotFound, err)
return
}
@@ -138,15 +137,14 @@ func ExecStartHandler(w http.ResponseWriter, r *http.Request) {
bodyParams := new(handlers.ExecStartConfig)
if err := json.NewDecoder(r.Body).Decode(&bodyParams); err != nil {
- utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest,
- errors.Wrapf(err, "failed to decode parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to decode parameters for %s", r.URL.String()))
return
}
// TODO: Verify TTY setting against what inspect session was made with
sessionCtr, err := runtime.GetExecSessionContainer(sessionID)
if err != nil {
- utils.Error(w, fmt.Sprintf("No such exec session: %s", sessionID), http.StatusNotFound, err)
+ utils.Error(w, http.StatusNotFound, err)
return
}
@@ -158,7 +156,7 @@ func ExecStartHandler(w http.ResponseWriter, r *http.Request) {
return
}
if state != define.ContainerStateRunning {
- utils.Error(w, http.StatusText(http.StatusConflict), http.StatusConflict, errors.Errorf("cannot exec in a container that is not running; container %s is %s", sessionCtr.ID(), state.String()))
+ utils.Error(w, http.StatusConflict, errors.Errorf("cannot exec in a container that is not running; container %s is %s", sessionCtr.ID(), state.String()))
return
}
diff --git a/pkg/api/handlers/compat/images.go b/pkg/api/handlers/compat/images.go
index acb2172a2..3546f88a0 100644
--- a/pkg/api/handlers/compat/images.go
+++ b/pkg/api/handlers/compat/images.go
@@ -50,7 +50,7 @@ func ExportImage(w http.ResponseWriter, r *http.Request) {
tmpfile, err := ioutil.TempFile("", "api.tar")
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "unable to create tempfile"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "unable to create tempfile"))
return
}
defer os.Remove(tmpfile.Name())
@@ -58,7 +58,7 @@ func ExportImage(w http.ResponseWriter, r *http.Request) {
name := utils.GetName(r)
possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, name)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
return
}
@@ -74,18 +74,18 @@ func ExportImage(w http.ResponseWriter, r *http.Request) {
utils.ImageNotFound(w, name, errors.Wrapf(err, "failed to find image %s", name))
return
}
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "unable to create tempfile"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "unable to create tempfile"))
return
}
if err := tmpfile.Close(); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "unable to close tempfile"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "unable to close tempfile"))
return
}
rdr, err := os.Open(tmpfile.Name())
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "failed to read the exported tarfile"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "failed to read the exported tarfile"))
return
}
defer rdr.Close()
@@ -110,12 +110,12 @@ func CommitContainer(w http.ResponseWriter, r *http.Request) {
}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
rtc, err := runtime.GetConfig()
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
return
}
sc := runtime.SystemContext()
@@ -131,7 +131,7 @@ func CommitContainer(w http.ResponseWriter, r *http.Request) {
input := handlers.CreateContainerConfig{}
if err := json.NewDecoder(r.Body).Decode(&input); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
return
}
@@ -143,7 +143,7 @@ func CommitContainer(w http.ResponseWriter, r *http.Request) {
}
ctr, err := runtime.LookupContainer(query.Container)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusNotFound, err)
+ utils.Error(w, http.StatusNotFound, err)
return
}
@@ -152,7 +152,7 @@ func CommitContainer(w http.ResponseWriter, r *http.Request) {
destImage = fmt.Sprintf("%s:%s", query.Repo, query.Tag)
possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, destImage)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
return
}
destImage = possiblyNormalizedName
@@ -160,7 +160,7 @@ func CommitContainer(w http.ResponseWriter, r *http.Request) {
commitImage, err := ctr.Commit(r.Context(), destImage, options)
if err != nil && !strings.Contains(err.Error(), "is not running") {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrapf(err, "CommitFailure"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrapf(err, "CommitFailure"))
return
}
utils.WriteResponse(w, http.StatusCreated, handlers.IDResponse{ID: commitImage.ID()}) // nolint
@@ -184,7 +184,7 @@ func CreateImageFromSrc(w http.ResponseWriter, r *http.Request) {
}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
// fromSrc – Source to import. The value may be a URL from which the image can be retrieved or - to read the image from the request body. This parameter may only be used when importing an image.
@@ -192,13 +192,13 @@ func CreateImageFromSrc(w http.ResponseWriter, r *http.Request) {
if source == "-" {
f, err := ioutil.TempFile("", "api_load.tar")
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "failed to create tempfile"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "failed to create tempfile"))
return
}
source = f.Name()
if err := SaveFromBody(f, r); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "failed to write temporary file"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "failed to write temporary file"))
}
}
@@ -206,7 +206,7 @@ func CreateImageFromSrc(w http.ResponseWriter, r *http.Request) {
if query.Repo != "" {
possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, reference)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
return
}
reference = possiblyNormalizedName
@@ -227,7 +227,7 @@ func CreateImageFromSrc(w http.ResponseWriter, r *http.Request) {
imageEngine := abi.ImageEngine{Libpod: runtime}
report, err := imageEngine.Import(r.Context(), opts)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "unable to import tarball"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "unable to import tarball"))
return
}
// Success
@@ -263,19 +263,19 @@ func CreateImageFromImage(w http.ResponseWriter, r *http.Request) {
// This is where you can override the golang default value for one of fields
}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, mergeNameAndTagOrDigest(query.FromImage, query.Tag))
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
return
}
authConf, authfile, err := auth.GetCredentials(r)
if err != nil {
- utils.Error(w, "failed to retrieve repository credentials", http.StatusBadRequest, err)
+ utils.Error(w, http.StatusBadRequest, err)
return
}
defer auth.RemoveAuthfile(authfile)
@@ -386,7 +386,7 @@ func GetImage(w http.ResponseWriter, r *http.Request) {
name := utils.GetName(r)
possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, name)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
return
}
@@ -395,12 +395,12 @@ func GetImage(w http.ResponseWriter, r *http.Request) {
// Here we need to fiddle with the error message because docker-py is looking for "No
// such image" to determine on how to raise the correct exception.
errMsg := strings.ReplaceAll(err.Error(), "image not known", "No such image")
- utils.Error(w, "Something went wrong.", http.StatusNotFound, errors.Errorf("failed to find image %s: %s", name, errMsg))
+ utils.Error(w, http.StatusNotFound, errors.Errorf("failed to find image %s: %s", name, errMsg))
return
}
inspect, err := handlers.ImageDataToImageInspect(r.Context(), newImage)
if err != nil {
- utils.Error(w, "Server error", http.StatusInternalServerError, errors.Wrapf(err, "failed to convert ImageData to ImageInspect '%s'", inspect.ID))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrapf(err, "failed to convert ImageData to ImageInspect '%s'", inspect.ID))
return
}
utils.WriteResponse(w, http.StatusOK, inspect)
@@ -418,7 +418,7 @@ func GetImages(w http.ResponseWriter, r *http.Request) {
}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest,
+ utils.Error(w, http.StatusBadRequest,
errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
@@ -429,7 +429,7 @@ func GetImages(w http.ResponseWriter, r *http.Request) {
filterList, err := filters.FiltersFromRequest(r)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err)
+ utils.Error(w, http.StatusInternalServerError, err)
return
}
if !utils.IsLibpodRequest(r) {
@@ -444,7 +444,7 @@ func GetImages(w http.ResponseWriter, r *http.Request) {
listOptions := entities.ImageListOptions{All: query.All, Filter: filterList}
summaries, err := imageEngine.List(r.Context(), listOptions)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err)
+ utils.Error(w, http.StatusInternalServerError, err)
return
}
@@ -472,7 +472,7 @@ func LoadImages(w http.ResponseWriter, r *http.Request) {
}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
@@ -480,7 +480,7 @@ func LoadImages(w http.ResponseWriter, r *http.Request) {
// to load.
f, err := ioutil.TempFile("", "api_load.tar")
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "failed to create tempfile"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "failed to create tempfile"))
return
}
defer func() {
@@ -490,7 +490,7 @@ func LoadImages(w http.ResponseWriter, r *http.Request) {
}
}()
if err := SaveFromBody(f, r); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "failed to write temporary file"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "failed to write temporary file"))
return
}
@@ -499,12 +499,12 @@ func LoadImages(w http.ResponseWriter, r *http.Request) {
loadOptions := entities.ImageLoadOptions{Input: f.Name()}
loadReport, err := imageEngine.Load(r.Context(), loadOptions)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "failed to load image"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "failed to load image"))
return
}
if len(loadReport.Names) < 1 {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Errorf("one or more images are required"))
+ utils.Error(w, http.StatusInternalServerError, errors.Errorf("one or more images are required"))
return
}
@@ -527,11 +527,11 @@ func ExportImages(w http.ResponseWriter, r *http.Request) {
// This is where you can override the golang default value for one of fields
}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
if len(query.Names) <= 0 {
- utils.Error(w, "Something went wrong.", http.StatusBadRequest, fmt.Errorf("no images to download"))
+ utils.Error(w, http.StatusBadRequest, fmt.Errorf("no images to download"))
return
}
@@ -539,7 +539,7 @@ func ExportImages(w http.ResponseWriter, r *http.Request) {
for i, img := range query.Names {
possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, img)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
return
}
images[i] = possiblyNormalizedName
@@ -547,12 +547,12 @@ func ExportImages(w http.ResponseWriter, r *http.Request) {
tmpfile, err := ioutil.TempFile("", "api.tar")
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "unable to create tempfile"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "unable to create tempfile"))
return
}
defer os.Remove(tmpfile.Name())
if err := tmpfile.Close(); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "unable to close tempfile"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "unable to close tempfile"))
return
}
@@ -566,7 +566,7 @@ func ExportImages(w http.ResponseWriter, r *http.Request) {
rdr, err := os.Open(tmpfile.Name())
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "failed to read the exported tarfile"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "failed to read the exported tarfile"))
return
}
defer rdr.Close()
diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go
index d9c9558e5..707551eab 100644
--- a/pkg/api/handlers/compat/images_build.go
+++ b/pkg/api/handlers/compat/images_build.go
@@ -133,7 +133,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
decoder := r.Context().Value(api.DecoderKey).(*schema.Decoder)
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest, err)
+ utils.Error(w, http.StatusBadRequest, err)
return
}
@@ -291,7 +291,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
if len(tags) > 0 {
possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, tags[0])
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
return
}
output = possiblyNormalizedName
@@ -314,7 +314,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
for i := 1; i < len(tags); i++ {
possiblyNormalizedTag, err := utils.NormalizeToDockerHub(r, tags[i])
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
return
}
additionalTags = append(additionalTags, possiblyNormalizedTag)
@@ -457,7 +457,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
creds, authfile, err := auth.GetCredentials(r)
if err != nil {
// Credential value(s) not returned as their value is not human readable
- utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest, err)
+ utils.Error(w, http.StatusBadRequest, err)
return
}
defer auth.RemoveAuthfile(authfile)
@@ -466,7 +466,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
if fromImage != "" {
possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, fromImage)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
return
}
fromImage = possiblyNormalizedName
diff --git a/pkg/api/handlers/compat/images_history.go b/pkg/api/handlers/compat/images_history.go
index dfaea0a76..70a11ddc5 100644
--- a/pkg/api/handlers/compat/images_history.go
+++ b/pkg/api/handlers/compat/images_history.go
@@ -16,7 +16,7 @@ func HistoryImage(w http.ResponseWriter, r *http.Request) {
possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, name)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
return
}
diff --git a/pkg/api/handlers/compat/images_prune.go b/pkg/api/handlers/compat/images_prune.go
index 8fbf97248..88776dc49 100644
--- a/pkg/api/handlers/compat/images_prune.go
+++ b/pkg/api/handlers/compat/images_prune.go
@@ -24,7 +24,7 @@ func PruneImages(w http.ResponseWriter, r *http.Request) {
filterMap, err := util.PrepareFilters(r)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
diff --git a/pkg/api/handlers/compat/images_push.go b/pkg/api/handlers/compat/images_push.go
index 6d4a8cdcf..6765c30b6 100644
--- a/pkg/api/handlers/compat/images_push.go
+++ b/pkg/api/handlers/compat/images_push.go
@@ -28,7 +28,7 @@ func PushImage(w http.ResponseWriter, r *http.Request) {
digestFile, err := ioutil.TempFile("", "digest.txt")
if err != nil {
- utils.Error(w, "unable to create digest tempfile", http.StatusInternalServerError, errors.Wrap(err, "unable to create tempfile"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "unable to create tempfile"))
return
}
defer digestFile.Close()
@@ -50,7 +50,7 @@ func PushImage(w http.ResponseWriter, r *http.Request) {
}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
@@ -63,14 +63,13 @@ func PushImage(w http.ResponseWriter, r *http.Request) {
}
if _, err := utils.ParseStorageReference(imageName); err != nil {
- utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest,
- errors.Wrapf(err, "image source %q is not a containers-storage-transport reference", imageName))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "image source %q is not a containers-storage-transport reference", imageName))
return
}
possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, imageName)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
return
}
imageName = possiblyNormalizedName
@@ -81,13 +80,13 @@ func PushImage(w http.ResponseWriter, r *http.Request) {
}
rawManifest, _, err := localImage.Manifest(r.Context())
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusBadRequest, err)
+ utils.Error(w, http.StatusBadRequest, err)
return
}
authconf, authfile, err := auth.GetCredentials(r)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusBadRequest, err)
+ utils.Error(w, http.StatusBadRequest, err)
return
}
defer auth.RemoveAuthfile(authfile)
diff --git a/pkg/api/handlers/compat/images_remove.go b/pkg/api/handlers/compat/images_remove.go
index df4644b2a..f45b38c66 100644
--- a/pkg/api/handlers/compat/images_remove.go
+++ b/pkg/api/handlers/compat/images_remove.go
@@ -25,7 +25,7 @@ func RemoveImage(w http.ResponseWriter, r *http.Request) {
}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
if _, found := r.URL.Query()["noprune"]; found {
@@ -36,7 +36,7 @@ func RemoveImage(w http.ResponseWriter, r *http.Request) {
name := utils.GetName(r)
possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, name)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
return
}
@@ -53,7 +53,7 @@ func RemoveImage(w http.ResponseWriter, r *http.Request) {
return
}
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err)
+ utils.Error(w, http.StatusInternalServerError, err)
return
}
response := make([]map[string]string, 0, len(report.Untagged)+1)
diff --git a/pkg/api/handlers/compat/images_search.go b/pkg/api/handlers/compat/images_search.go
index cdf7b12ab..9f41c1b4f 100644
--- a/pkg/api/handlers/compat/images_search.go
+++ b/pkg/api/handlers/compat/images_search.go
@@ -30,13 +30,13 @@ func SearchImages(w http.ResponseWriter, r *http.Request) {
}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
_, authfile, err := auth.GetCredentials(r)
if err != nil {
- utils.Error(w, "failed to retrieve repository credentials", http.StatusBadRequest, err)
+ utils.Error(w, http.StatusBadRequest, err)
return
}
defer auth.RemoveAuthfile(authfile)
@@ -58,7 +58,7 @@ func SearchImages(w http.ResponseWriter, r *http.Request) {
ir := abi.ImageEngine{Libpod: runtime}
reports, err := ir.Search(r.Context(), query.Term, options)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err)
+ utils.Error(w, http.StatusInternalServerError, err)
return
}
if !utils.IsLibpodRequest(r) {
diff --git a/pkg/api/handlers/compat/images_tag.go b/pkg/api/handlers/compat/images_tag.go
index ce6b1de58..da0a04e84 100644
--- a/pkg/api/handlers/compat/images_tag.go
+++ b/pkg/api/handlers/compat/images_tag.go
@@ -17,7 +17,7 @@ func TagImage(w http.ResponseWriter, r *http.Request) {
name := utils.GetName(r)
possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, name)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
return
}
@@ -34,7 +34,7 @@ func TagImage(w http.ResponseWriter, r *http.Request) {
tag = r.Form.Get("tag")
}
if len(r.Form.Get("repo")) < 1 {
- utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.New("repo parameter is required to tag an image"))
+ utils.Error(w, http.StatusBadRequest, errors.New("repo parameter is required to tag an image"))
return
}
repo := r.Form.Get("repo")
@@ -42,12 +42,12 @@ func TagImage(w http.ResponseWriter, r *http.Request) {
possiblyNormalizedTag, err := utils.NormalizeToDockerHub(r, tagName)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "error normalizing image"))
return
}
if err := newImage.Tag(possiblyNormalizedTag); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err)
+ utils.Error(w, http.StatusInternalServerError, err)
return
}
utils.WriteResponse(w, http.StatusCreated, "")
diff --git a/pkg/api/handlers/compat/info.go b/pkg/api/handlers/compat/info.go
index 2dfca2f30..6286fdaee 100644
--- a/pkg/api/handlers/compat/info.go
+++ b/pkg/api/handlers/compat/info.go
@@ -33,18 +33,18 @@ func GetInfo(w http.ResponseWriter, r *http.Request) {
infoData, err := runtime.Info()
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrapf(err, "failed to obtain system memory info"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrapf(err, "failed to obtain system memory info"))
return
}
configInfo, err := runtime.GetConfig()
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrapf(err, "failed to obtain runtime config"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrapf(err, "failed to obtain runtime config"))
return
}
versionInfo, err := define.GetVersion()
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrapf(err, "failed to obtain podman versions"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrapf(err, "failed to obtain podman versions"))
return
}
stateInfo := getContainersState(runtime)
diff --git a/pkg/api/handlers/compat/networks.go b/pkg/api/handlers/compat/networks.go
index 90a8b3c12..eb1a5d59c 100644
--- a/pkg/api/handlers/compat/networks.go
+++ b/pkg/api/handlers/compat/networks.go
@@ -36,12 +36,12 @@ func InspectNetwork(w http.ResponseWriter, r *http.Request) {
}
decoder := r.Context().Value(api.DecoderKey).(*schema.Decoder)
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
if query.scope != "local" {
- utils.Error(w, "Invalid scope value. Can only be local.", http.StatusBadRequest, define.ErrInvalidArg)
+ utils.Error(w, http.StatusBadRequest, define.ErrInvalidArg)
return
}
name := utils.GetName(r)
@@ -133,7 +133,7 @@ func ListNetworks(w http.ResponseWriter, r *http.Request) {
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
filterMap, err := util.PrepareFilters(r)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
@@ -166,7 +166,7 @@ func CreateNetwork(w http.ResponseWriter, r *http.Request) {
)
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
if err := json.NewDecoder(r.Body).Decode(&networkCreate); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
return
}
@@ -262,7 +262,7 @@ func RemoveNetwork(w http.ResponseWriter, r *http.Request) {
decoder := r.Context().Value(api.DecoderKey).(*schema.Decoder)
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
@@ -274,17 +274,17 @@ func RemoveNetwork(w http.ResponseWriter, r *http.Request) {
name := utils.GetName(r)
reports, err := ic.NetworkRm(r.Context(), []string{name}, options)
if err != nil {
- utils.Error(w, "remove Network failed", http.StatusInternalServerError, err)
+ utils.Error(w, http.StatusInternalServerError, err)
return
}
if len(reports) == 0 {
- utils.Error(w, "remove Network failed", http.StatusInternalServerError, errors.Errorf("internal error"))
+ utils.Error(w, http.StatusInternalServerError, errors.Errorf("internal error"))
return
}
report := reports[0]
if report.Err != nil {
if errors.Cause(report.Err) == define.ErrNoSuchNetwork {
- utils.Error(w, "network not found", http.StatusNotFound, define.ErrNoSuchNetwork)
+ utils.Error(w, http.StatusNotFound, define.ErrNoSuchNetwork)
return
}
utils.InternalServerError(w, report.Err)
@@ -302,7 +302,7 @@ func Connect(w http.ResponseWriter, r *http.Request) {
netConnect types.NetworkConnect
)
if err := json.NewDecoder(r.Body).Decode(&netConnect); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
return
}
@@ -318,7 +318,7 @@ func Connect(w http.ResponseWriter, r *http.Request) {
if len(netConnect.EndpointConfig.IPAddress) > 0 {
staticIP := net.ParseIP(netConnect.EndpointConfig.IPAddress)
if staticIP == nil {
- utils.Error(w, "failed to parse the ip address", http.StatusInternalServerError,
+ utils.Error(w, http.StatusInternalServerError,
errors.Errorf("failed to parse the ip address %q", netConnect.EndpointConfig.IPAddress))
return
}
@@ -330,7 +330,7 @@ func Connect(w http.ResponseWriter, r *http.Request) {
if len(netConnect.EndpointConfig.IPAMConfig.IPv4Address) > 0 {
staticIP := net.ParseIP(netConnect.EndpointConfig.IPAMConfig.IPv4Address)
if staticIP == nil {
- utils.Error(w, "failed to parse the ipv4 address", http.StatusInternalServerError,
+ utils.Error(w, http.StatusInternalServerError,
errors.Errorf("failed to parse the ipv4 address %q", netConnect.EndpointConfig.IPAMConfig.IPv4Address))
return
}
@@ -340,7 +340,7 @@ func Connect(w http.ResponseWriter, r *http.Request) {
if len(netConnect.EndpointConfig.IPAMConfig.IPv6Address) > 0 {
staticIP := net.ParseIP(netConnect.EndpointConfig.IPAMConfig.IPv6Address)
if staticIP == nil {
- utils.Error(w, "failed to parse the ipv6 address", http.StatusInternalServerError,
+ utils.Error(w, http.StatusInternalServerError,
errors.Errorf("failed to parse the ipv6 address %q", netConnect.EndpointConfig.IPAMConfig.IPv6Address))
return
}
@@ -351,7 +351,7 @@ func Connect(w http.ResponseWriter, r *http.Request) {
if len(netConnect.EndpointConfig.MacAddress) > 0 {
staticMac, err := net.ParseMAC(netConnect.EndpointConfig.MacAddress)
if err != nil {
- utils.Error(w, "failed to parse the mac address", http.StatusInternalServerError,
+ utils.Error(w, http.StatusInternalServerError,
errors.Errorf("failed to parse the mac address %q", netConnect.EndpointConfig.IPAMConfig.IPv6Address))
return
}
@@ -365,10 +365,10 @@ func Connect(w http.ResponseWriter, r *http.Request) {
return
}
if errors.Cause(err) == define.ErrNoSuchNetwork {
- utils.Error(w, "network not found", http.StatusNotFound, err)
+ utils.Error(w, http.StatusNotFound, err)
return
}
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err)
+ utils.Error(w, http.StatusInternalServerError, err)
return
}
utils.WriteResponse(w, http.StatusOK, "OK")
@@ -380,7 +380,7 @@ func Disconnect(w http.ResponseWriter, r *http.Request) {
var netDisconnect types.NetworkDisconnect
if err := json.NewDecoder(r.Body).Decode(&netDisconnect); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
return
}
@@ -388,14 +388,14 @@ func Disconnect(w http.ResponseWriter, r *http.Request) {
err := runtime.DisconnectContainerFromNetwork(netDisconnect.Container, name, netDisconnect.Force)
if err != nil {
if errors.Cause(err) == define.ErrNoSuchCtr {
- utils.Error(w, "container not found", http.StatusNotFound, err)
+ utils.Error(w, http.StatusNotFound, err)
return
}
if errors.Cause(err) == define.ErrNoSuchNetwork {
- utils.Error(w, "network not found", http.StatusNotFound, err)
+ utils.Error(w, http.StatusNotFound, err)
return
}
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err)
+ utils.Error(w, http.StatusInternalServerError, err)
return
}
utils.WriteResponse(w, http.StatusOK, "OK")
@@ -406,7 +406,7 @@ func Prune(w http.ResponseWriter, r *http.Request) {
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
filterMap, err := util.PrepareFilters(r)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
return
}
@@ -416,7 +416,7 @@ func Prune(w http.ResponseWriter, r *http.Request) {
}
pruneReports, err := ic.NetworkPrune(r.Context(), pruneOptions)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err)
+ utils.Error(w, http.StatusInternalServerError, err)
return
}
type response struct {
diff --git a/pkg/api/handlers/compat/resize.go b/pkg/api/handlers/compat/resize.go
index 373d76f6b..ce7340f62 100644
--- a/pkg/api/handlers/compat/resize.go
+++ b/pkg/api/handlers/compat/resize.go
@@ -28,8 +28,7 @@ func ResizeTTY(w http.ResponseWriter, r *http.Request) {
}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest,
- errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
@@ -51,7 +50,7 @@ func ResizeTTY(w http.ResponseWriter, r *http.Request) {
if errors.Cause(err) != define.ErrCtrStateInvalid {
utils.InternalServerError(w, errors.Wrapf(err, "cannot resize container"))
} else {
- utils.Error(w, "Container not running", http.StatusConflict, err)
+ utils.Error(w, http.StatusConflict, err)
}
return
}
@@ -69,8 +68,7 @@ func ResizeTTY(w http.ResponseWriter, r *http.Request) {
utils.InternalServerError(w, errors.Wrapf(err, "cannot obtain session container state"))
return
} else if state != define.ContainerStateRunning && !query.IgnoreNotRunning {
- utils.Error(w, "Container not running", http.StatusConflict,
- fmt.Errorf("container %q in wrong state %q", name, state.String()))
+ utils.Error(w, http.StatusConflict, fmt.Errorf("container %q in wrong state %q", name, state.String()))
return
}
if err := ctnr.ExecResize(name, sz); err != nil {
diff --git a/pkg/api/handlers/compat/secrets.go b/pkg/api/handlers/compat/secrets.go
index b298ae626..0c2306dc8 100644
--- a/pkg/api/handlers/compat/secrets.go
+++ b/pkg/api/handlers/compat/secrets.go
@@ -4,7 +4,6 @@ import (
"bytes"
"encoding/base64"
"encoding/json"
- "fmt"
"net/http"
"github.com/containers/podman/v4/libpod"
@@ -22,8 +21,7 @@ func ListSecrets(w http.ResponseWriter, r *http.Request) {
)
filtersMap, err := util.PrepareFilters(r)
if err != nil {
- utils.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError,
- errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
ic := abi.ContainerEngine{Libpod: runtime}
@@ -116,12 +114,11 @@ func CreateSecret(w http.ResponseWriter, r *http.Request) {
}{}
if err := json.NewDecoder(r.Body).Decode(&createParams); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
return
}
if len(createParams.Labels) > 0 {
- utils.Error(w, "labels not supported", http.StatusBadRequest,
- errors.Wrapf(errors.New("bad parameter"), "labels not supported"))
+ utils.Error(w, http.StatusBadRequest, errors.Wrapf(errors.New("bad parameter"), "labels not supported"))
return
}
@@ -133,7 +130,7 @@ func CreateSecret(w http.ResponseWriter, r *http.Request) {
report, err := ic.SecretCreate(r.Context(), createParams.Name, reader, opts)
if err != nil {
if errors.Cause(err).Error() == "secret name in use" {
- utils.Error(w, "name conflicts with an existing object", http.StatusConflict, err)
+ utils.Error(w, http.StatusConflict, err)
return
}
utils.InternalServerError(w, err)
@@ -143,5 +140,5 @@ func CreateSecret(w http.ResponseWriter, r *http.Request) {
}
func UpdateSecret(w http.ResponseWriter, r *http.Request) {
- utils.Error(w, fmt.Sprintf("unsupported endpoint: %v", r.Method), http.StatusNotImplemented, errors.New("update is not supported"))
+ utils.Error(w, http.StatusNotImplemented, errors.New("update is not supported"))
}
diff --git a/pkg/api/handlers/compat/version.go b/pkg/api/handlers/compat/version.go
index c526a5aa2..b113fbc90 100644
--- a/pkg/api/handlers/compat/version.go
+++ b/pkg/api/handlers/compat/version.go
@@ -22,13 +22,13 @@ func VersionHandler(w http.ResponseWriter, r *http.Request) {
running, err := define.GetVersion()
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err)
+ utils.Error(w, http.StatusInternalServerError, err)
return
}
info, err := runtime.Info()
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrapf(err, "failed to obtain system memory info"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrapf(err, "failed to obtain system memory info"))
return
}
diff --git a/pkg/api/handlers/compat/volumes.go b/pkg/api/handlers/compat/volumes.go
index 352b5c7c3..c8e4339b0 100644
--- a/pkg/api/handlers/compat/volumes.go
+++ b/pkg/api/handlers/compat/volumes.go
@@ -26,7 +26,7 @@ func ListVolumes(w http.ResponseWriter, r *http.Request) {
filtersMap, err := util.PrepareFilters(r)
if err != nil {
- utils.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError,
+ utils.Error(w, http.StatusInternalServerError,
errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
@@ -35,7 +35,7 @@ func ListVolumes(w http.ResponseWriter, r *http.Request) {
// happily parse them for us.
for filter := range *filtersMap {
if filter == "opts" {
- utils.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError,
+ utils.Error(w, http.StatusInternalServerError,
errors.Errorf("unsupported libpod filters passed to docker endpoint"))
return
}
@@ -85,14 +85,14 @@ func CreateVolume(w http.ResponseWriter, r *http.Request) {
/* No query string data*/
query := struct{}{}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError,
+ utils.Error(w, http.StatusInternalServerError,
errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
// decode params from body
input := docker_api_types_volume.VolumeCreateBody{}
if err := json.NewDecoder(r.Body).Decode(&input); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
return
}
@@ -220,7 +220,7 @@ func RemoveVolume(w http.ResponseWriter, r *http.Request) {
}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError,
+ utils.Error(w, http.StatusInternalServerError,
errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
@@ -242,7 +242,7 @@ func RemoveVolume(w http.ResponseWriter, r *http.Request) {
// As above, we do not pass `force` from the query parameters here
if err := runtime.RemoveVolume(r.Context(), vol, false, query.Timeout); err != nil {
if errors.Cause(err) == define.ErrVolumeBeingUsed {
- utils.Error(w, "volumes being used", http.StatusConflict, err)
+ utils.Error(w, http.StatusConflict, err)
} else {
utils.InternalServerError(w, err)
}
@@ -268,14 +268,14 @@ func PruneVolumes(w http.ResponseWriter, r *http.Request) {
)
filterMap, err := util.PrepareFilters(r)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
return
}
f := (url.Values)(*filterMap)
filterFuncs, err := filters.GeneratePruneVolumeFilters(f)
if err != nil {
- utils.Error(w, "Something when wrong.", http.StatusInternalServerError, errors.Wrapf(err, "failed to parse filters for %s", f.Encode()))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrapf(err, "failed to parse filters for %s", f.Encode()))
return
}