diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2022-09-10 07:40:39 -0400 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2022-09-10 07:52:00 -0400 |
commit | 2c63b8439bbdc09203ea394ad2cf9352830861f0 (patch) | |
tree | 39b9d8d061bc248e4dbeb6445c2ad0c99b048ae1 /pkg/api | |
parent | 2d8417d86a7edf11bce5527f311bb951a651d40e (diff) | |
download | podman-2c63b8439bbdc09203ea394ad2cf9352830861f0.tar.gz podman-2c63b8439bbdc09203ea394ad2cf9352830861f0.tar.bz2 podman-2c63b8439bbdc09203ea394ad2cf9352830861f0.zip |
Fix stutters
Podman adds an Error: to every error message. So starting an error
message with "error" ends up being reported to the user as
Error: error ...
This patch removes the stutter.
Also ioutil.ReadFile errors report the Path, so wrapping the err message
with the path causes a stutter.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'pkg/api')
-rw-r--r-- | pkg/api/handlers/compat/containers_attach.go | 2 | ||||
-rw-r--r-- | pkg/api/handlers/compat/containers_create.go | 6 | ||||
-rw-r--r-- | pkg/api/handlers/compat/exec.go | 6 | ||||
-rw-r--r-- | pkg/api/handlers/compat/images.go | 12 | ||||
-rw-r--r-- | pkg/api/handlers/compat/images_build.go | 6 | ||||
-rw-r--r-- | pkg/api/handlers/compat/images_history.go | 2 | ||||
-rw-r--r-- | pkg/api/handlers/compat/images_push.go | 2 | ||||
-rw-r--r-- | pkg/api/handlers/compat/images_remove.go | 2 | ||||
-rw-r--r-- | pkg/api/handlers/compat/images_tag.go | 4 | ||||
-rw-r--r-- | pkg/api/handlers/libpod/generate.go | 4 | ||||
-rw-r--r-- | pkg/api/handlers/libpod/images_push.go | 2 | ||||
-rw-r--r-- | pkg/api/handlers/libpod/kube.go | 4 | ||||
-rw-r--r-- | pkg/api/handlers/libpod/manifests.go | 4 | ||||
-rw-r--r-- | pkg/api/handlers/libpod/pods.go | 12 |
14 files changed, 34 insertions, 34 deletions
diff --git a/pkg/api/handlers/compat/containers_attach.go b/pkg/api/handlers/compat/containers_attach.go index e804e628a..c37dc09af 100644 --- a/pkg/api/handlers/compat/containers_attach.go +++ b/pkg/api/handlers/compat/containers_attach.go @@ -86,7 +86,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 || state == define.ContainerStateStopped { if err := ctr.Init(r.Context(), ctr.PodID() != ""); err != nil { - utils.Error(w, http.StatusConflict, fmt.Errorf("error preparing container %s for attach: %w", ctr.ID(), err)) + utils.Error(w, http.StatusConflict, fmt.Errorf("preparing container %s for attach: %w", ctr.ID(), err)) 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 d4f5d5f36..a86b0b0d5 100644 --- a/pkg/api/handlers/compat/containers_create.go +++ b/pkg/api/handlers/compat/containers_create.go @@ -64,7 +64,7 @@ func CreateContainer(w http.ResponseWriter, r *http.Request) { imageName, err := utils.NormalizeToDockerHub(r, body.Config.Image) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } body.Config.Image = imageName @@ -76,7 +76,7 @@ func CreateContainer(w http.ResponseWriter, r *http.Request) { return } - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error looking up image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("looking up image: %w", err)) return } @@ -480,7 +480,7 @@ func cliOpts(cc handlers.CreateContainerConfig, rtc *config.Config) (*entities.C } if err := os.MkdirAll(vol, 0o755); err != nil { if !os.IsExist(err) { - return nil, nil, fmt.Errorf("error making volume mountpoint for volume %s: %w", vol, err) + return nil, nil, fmt.Errorf("making volume mountpoint for volume %s: %w", vol, err) } } } diff --git a/pkg/api/handlers/compat/exec.go b/pkg/api/handlers/compat/exec.go index 1b4dead8b..17f199a8b 100644 --- a/pkg/api/handlers/compat/exec.go +++ b/pkg/api/handlers/compat/exec.go @@ -26,7 +26,7 @@ func ExecCreateHandler(w http.ResponseWriter, r *http.Request) { input := new(handlers.ExecCreateConfig) if err := json.NewDecoder(r.Body).Decode(&input); err != nil { - utils.InternalServerError(w, fmt.Errorf("error decoding request body as JSON: %w", err)) + utils.InternalServerError(w, fmt.Errorf("decoding request body as JSON: %w", err)) return } @@ -114,7 +114,7 @@ func ExecInspectHandler(w http.ResponseWriter, r *http.Request) { session, err := sessionCtr.ExecSession(sessionID) if err != nil { - utils.InternalServerError(w, fmt.Errorf("error retrieving exec session %s from container %s: %w", sessionID, sessionCtr.ID(), err)) + utils.InternalServerError(w, fmt.Errorf("retrieving exec session %s from container %s: %w", sessionID, sessionCtr.ID(), err)) return } @@ -174,7 +174,7 @@ func ExecStartHandler(w http.ResponseWriter, r *http.Request) { } logErr := func(e error) { - logrus.Error(fmt.Errorf("error attaching to container %s exec session %s: %w", sessionCtr.ID(), sessionID, e)) + logrus.Error(fmt.Errorf("attaching to container %s exec session %s: %w", sessionCtr.ID(), sessionID, e)) } var size *resize.TerminalSize diff --git a/pkg/api/handlers/compat/images.go b/pkg/api/handlers/compat/images.go index 39bd165d6..0493c6ffb 100644 --- a/pkg/api/handlers/compat/images.go +++ b/pkg/api/handlers/compat/images.go @@ -59,7 +59,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, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } @@ -155,7 +155,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, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } destImage = possiblyNormalizedName @@ -209,7 +209,7 @@ func CreateImageFromSrc(w http.ResponseWriter, r *http.Request) { if query.Repo != "" { possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, reference) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } reference = possiblyNormalizedName @@ -272,7 +272,7 @@ func CreateImageFromImage(w http.ResponseWriter, r *http.Request) { possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, mergeNameAndTagOrDigest(query.FromImage, query.Tag)) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } @@ -390,7 +390,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, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } @@ -541,7 +541,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, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } images[i] = possiblyNormalizedName diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index 7ba1029a7..4035b4315 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -343,7 +343,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, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } output = possiblyNormalizedName @@ -376,7 +376,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, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } additionalTags = append(additionalTags, possiblyNormalizedTag) @@ -578,7 +578,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { if fromImage != "" { possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, fromImage) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } fromImage = possiblyNormalizedName diff --git a/pkg/api/handlers/compat/images_history.go b/pkg/api/handlers/compat/images_history.go index ebb5acdd9..1b83d274a 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, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } diff --git a/pkg/api/handlers/compat/images_push.go b/pkg/api/handlers/compat/images_push.go index f29808124..a1173de0b 100644 --- a/pkg/api/handlers/compat/images_push.go +++ b/pkg/api/handlers/compat/images_push.go @@ -69,7 +69,7 @@ func PushImage(w http.ResponseWriter, r *http.Request) { possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, imageName) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } imageName = possiblyNormalizedName diff --git a/pkg/api/handlers/compat/images_remove.go b/pkg/api/handlers/compat/images_remove.go index b59bfd0b1..71d6a644f 100644 --- a/pkg/api/handlers/compat/images_remove.go +++ b/pkg/api/handlers/compat/images_remove.go @@ -37,7 +37,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, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } diff --git a/pkg/api/handlers/compat/images_tag.go b/pkg/api/handlers/compat/images_tag.go index a1da7a4b9..e9f6dedd0 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, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } @@ -42,7 +42,7 @@ func TagImage(w http.ResponseWriter, r *http.Request) { possiblyNormalizedTag, err := utils.NormalizeToDockerHub(r, tagName) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } diff --git a/pkg/api/handlers/libpod/generate.go b/pkg/api/handlers/libpod/generate.go index 431927ac5..9b38829ad 100644 --- a/pkg/api/handlers/libpod/generate.go +++ b/pkg/api/handlers/libpod/generate.go @@ -78,7 +78,7 @@ func GenerateSystemd(w http.ResponseWriter, r *http.Request) { report, err := containerEngine.GenerateSystemd(r.Context(), utils.GetName(r), options) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error generating systemd units: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("generating systemd units: %w", err)) return } @@ -104,7 +104,7 @@ func GenerateKube(w http.ResponseWriter, r *http.Request) { options := entities.GenerateKubeOptions{Service: query.Service} report, err := containerEngine.GenerateKube(r.Context(), query.Names, options) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error generating YAML: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("generating YAML: %w", err)) return } diff --git a/pkg/api/handlers/libpod/images_push.go b/pkg/api/handlers/libpod/images_push.go index be6f5b131..4102f23de 100644 --- a/pkg/api/handlers/libpod/images_push.go +++ b/pkg/api/handlers/libpod/images_push.go @@ -91,7 +91,7 @@ func PushImage(w http.ResponseWriter, r *http.Request) { // Let's keep thing simple when running in quiet mode and push directly. if query.Quiet { if err := imageEngine.Push(r.Context(), source, destination, options); err != nil { - utils.Error(w, http.StatusBadRequest, fmt.Errorf("error pushing image %q: %w", destination, err)) + utils.Error(w, http.StatusBadRequest, fmt.Errorf("pushing image %q: %w", destination, err)) return } utils.WriteResponse(w, http.StatusOK, "") diff --git a/pkg/api/handlers/libpod/kube.go b/pkg/api/handlers/libpod/kube.go index 5c891b707..2a61d1723 100644 --- a/pkg/api/handlers/libpod/kube.go +++ b/pkg/api/handlers/libpod/kube.go @@ -103,7 +103,7 @@ func KubePlay(w http.ResponseWriter, r *http.Request) { report, err := containerEngine.PlayKube(r.Context(), r.Body, options) _ = r.Body.Close() if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error playing YAML file: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("playing YAML file: %w", err)) return } utils.WriteResponse(w, http.StatusOK, report) @@ -116,7 +116,7 @@ func KubePlayDown(w http.ResponseWriter, r *http.Request) { report, err := containerEngine.PlayKubeDown(r.Context(), r.Body, *options) _ = r.Body.Close() if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error tearing down YAML file: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("tearing down YAML file: %w", err)) return } utils.WriteResponse(w, http.StatusOK, report) diff --git a/pkg/api/handlers/libpod/manifests.go b/pkg/api/handlers/libpod/manifests.go index 8391def5c..d5af72a61 100644 --- a/pkg/api/handlers/libpod/manifests.go +++ b/pkg/api/handlers/libpod/manifests.go @@ -295,7 +295,7 @@ func ManifestPushV3(w http.ResponseWriter, r *http.Request) { imageEngine := abi.ImageEngine{Libpod: runtime} digest, err := imageEngine.ManifestPush(r.Context(), source, query.Destination, options) if err != nil { - utils.Error(w, http.StatusBadRequest, fmt.Errorf("error pushing image %q: %w", query.Destination, err)) + utils.Error(w, http.StatusBadRequest, fmt.Errorf("pushing image %q: %w", query.Destination, err)) return } utils.WriteResponse(w, http.StatusOK, entities.IDResponse{ID: digest}) @@ -369,7 +369,7 @@ func ManifestPush(w http.ResponseWriter, r *http.Request) { if query.Quiet { digest, err := imageEngine.ManifestPush(r.Context(), source, destination, options) if err != nil { - utils.Error(w, http.StatusBadRequest, fmt.Errorf("error pushing image %q: %w", destination, err)) + utils.Error(w, http.StatusBadRequest, fmt.Errorf("pushing image %q: %w", destination, err)) return } utils.WriteResponse(w, http.StatusOK, entities.ManifestPushReport{ID: digest}) diff --git a/pkg/api/handlers/libpod/pods.go b/pkg/api/handlers/libpod/pods.go index 8b1d456ec..c39b9ee2f 100644 --- a/pkg/api/handlers/libpod/pods.go +++ b/pkg/api/handlers/libpod/pods.go @@ -51,7 +51,7 @@ func PodCreate(w http.ResponseWriter, r *http.Request) { } err = specgenutil.FillOutSpecGen(psg.InfraContainerSpec, &infraOptions, []string{}) // necessary for default values in many cases (userns, idmappings) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error filling out specgen: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("filling out specgen: %w", err)) return } out, err := json.Marshal(psg) // marshal our spec so the matching options can be unmarshaled into infra @@ -178,7 +178,7 @@ func PodStop(w http.ResponseWriter, r *http.Request) { report := entities.PodStopReport{Id: pod.ID()} for id, err := range responses { - report.Errs = append(report.Errs, fmt.Errorf("error stopping container %s: %w", id, err)) + report.Errs = append(report.Errs, fmt.Errorf("stopping container %s: %w", id, err)) } code := http.StatusOK @@ -214,7 +214,7 @@ func PodStart(w http.ResponseWriter, r *http.Request) { report := entities.PodStartReport{Id: pod.ID()} for id, err := range responses { - report.Errs = append(report.Errs, fmt.Errorf("%v: %w", "error starting container "+id, err)) + report.Errs = append(report.Errs, fmt.Errorf("%v: %w", "starting container "+id, err)) } code := http.StatusOK @@ -270,7 +270,7 @@ func PodRestart(w http.ResponseWriter, r *http.Request) { report := entities.PodRestartReport{Id: pod.ID()} for id, err := range responses { - report.Errs = append(report.Errs, fmt.Errorf("error restarting container %s: %w", id, err)) + report.Errs = append(report.Errs, fmt.Errorf("restarting container %s: %w", id, err)) } code := http.StatusOK @@ -321,7 +321,7 @@ func PodPause(w http.ResponseWriter, r *http.Request) { report := entities.PodPauseReport{Id: pod.ID()} for id, v := range responses { - report.Errs = append(report.Errs, fmt.Errorf("error pausing container %s: %w", id, v)) + report.Errs = append(report.Errs, fmt.Errorf("pausing container %s: %w", id, v)) } code := http.StatusOK @@ -347,7 +347,7 @@ func PodUnpause(w http.ResponseWriter, r *http.Request) { report := entities.PodUnpauseReport{Id: pod.ID()} for id, v := range responses { - report.Errs = append(report.Errs, fmt.Errorf("error unpausing container %s: %w", id, v)) + report.Errs = append(report.Errs, fmt.Errorf("unpausing container %s: %w", id, v)) } code := http.StatusOK |