summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/libpod/play.go
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/libpod/play.go
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/libpod/play.go')
-rw-r--r--pkg/api/handlers/libpod/play.go27
1 files changed, 12 insertions, 15 deletions
diff --git a/pkg/api/handlers/libpod/play.go b/pkg/api/handlers/libpod/play.go
index 0c480dfbf..515d0e5cf 100644
--- a/pkg/api/handlers/libpod/play.go
+++ b/pkg/api/handlers/libpod/play.go
@@ -37,8 +37,7 @@ func PlayKube(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
}
@@ -46,8 +45,7 @@ func PlayKube(w http.ResponseWriter, r *http.Request) {
for _, ipString := range query.StaticIPs {
ip := net.ParseIP(ipString)
if ip == nil {
- utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest,
- errors.Errorf("Invalid IP address %s", ipString))
+ utils.Error(w, http.StatusBadRequest, errors.Errorf("Invalid IP address %s", ipString))
return
}
staticIPs = append(staticIPs, ip)
@@ -57,8 +55,7 @@ func PlayKube(w http.ResponseWriter, r *http.Request) {
for _, macString := range query.StaticMACs {
mac, err := net.ParseMAC(macString)
if err != nil {
- utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest,
- err)
+ utils.Error(w, http.StatusBadRequest, err)
return
}
staticMACs = append(staticMACs, mac)
@@ -67,7 +64,7 @@ func PlayKube(w http.ResponseWriter, r *http.Request) {
// Fetch the K8s YAML file from the body, and copy it to a temp file.
tmpfile, err := ioutil.TempFile("", "libpod-play-kube.yml")
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 func() {
@@ -79,16 +76,16 @@ func PlayKube(w http.ResponseWriter, r *http.Request) {
if err := tmpfile.Close(); err != nil {
logrus.Warn(err)
}
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "unable to write archive to temporary file"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "unable to write archive to temporary file"))
return
}
if err := tmpfile.Close(); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "error closing temporary file"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "error closing temporary file"))
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)
@@ -119,7 +116,7 @@ func PlayKube(w http.ResponseWriter, r *http.Request) {
}
report, err := containerEngine.PlayKube(r.Context(), tmpfile.Name(), options)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "error playing YAML file"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "error playing YAML file"))
return
}
utils.WriteResponse(w, http.StatusOK, report)
@@ -129,7 +126,7 @@ func PlayKubeDown(w http.ResponseWriter, r *http.Request) {
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
tmpfile, err := ioutil.TempFile("", "libpod-play-kube.yml")
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 func() {
@@ -141,18 +138,18 @@ func PlayKubeDown(w http.ResponseWriter, r *http.Request) {
if err := tmpfile.Close(); err != nil {
logrus.Warn(err)
}
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "unable to write archive to temporary file"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "unable to write archive to temporary file"))
return
}
if err := tmpfile.Close(); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "error closing temporary file"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "error closing temporary file"))
return
}
containerEngine := abi.ContainerEngine{Libpod: runtime}
options := new(entities.PlayKubeDownOptions)
report, err := containerEngine.PlayKubeDown(r.Context(), tmpfile.Name(), *options)
if err != nil {
- utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "error tearing down YAML file"))
+ utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "error tearing down YAML file"))
return
}
utils.WriteResponse(w, http.StatusOK, report)