-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add missing early returns in compat API #9360
Add missing early returns in compat API #9360
Conversation
pkg/api/handlers/compat/secrets.go
Outdated
@@ -25,12 +25,14 @@ func ListSecrets(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, "Something went wrong.", http.StatusBadRequest, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think should not change this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea was to make it more similar to other endpoints ... I was under the impression that the "Something went wrong.
-style is the most common. But trying to prove my point I found quite some counter examples (see below). 🤷
If you still want it I can revert this.
"Something went wrong.
-style examples:
- https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/containers.go#L99
- https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/containers.go#L166
- https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/containers.go#L194
- https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/containers_logs.go#L38
- https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/containers_prune.go#L24
- https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/images_remove.go#L24
- https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/images_search.go#L33
- https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/networks.go#L221
- https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/networks.go#L300
- https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/networks.go#L340
- https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/networks.go#L371
- https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/volumes.go#L100
- https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/volumes.go#L277
http.StatusText(http.StatusBadRequest)
-style examples:
- https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/containers.go#L43
- https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/containers_top.go#L28
- https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/containers_stop.go#L31
- https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/containers_restart.go#L31
- https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/containers_create.go#L28
- https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/volumes.go#L34
- https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/volumes.go#L93
totally different style:
- https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/containers_start.go#L22
- https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/containers_attach.go#L30
- https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/events.go#L87
- https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/containers_archive.go#L39
965c340
to
19fdfab
Compare
should signed of at the git commit messages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes LGTM
To pass CI, the commit must be signed: git commit -s --amend
and repush
19fdfab
to
67d74e8
Compare
You also need to add [NO TESTS NEEDED] To this commit, otherwise you will need to add tests. LGTM |
444d999
to
fa9429a
Compare
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: rhatdan, riyad The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/hold |
[NO TESTS NEEDED] Signed-off-by: Riyad Preukschas <[email protected]>
fa9429a
to
68a8d39
Compare
I'm not sure what new changes the bot has detected. 😅 I just rebased the PR to re-trigger the CI. |
/lgtm |
/hold cancel |
Hmmm, yeah, I see it's not just Cirrus-CI but nothing ran for fa9429a9474ff8190b7a8686f43b5ba0ce9392c2 Most likely this was a Github problem and not a Cirrus-CI problem. I'll keep on the lookout for this happening again. |
While looking to "fix" #9314 I found a few more missing early returns.
This only fixes the double response part of #9314.
The weird thing is utils.Error() totally ignores the 2nd (i.e.
apiMessage
) argument which is sometimes used to add context to the error, but doesn't end up in either the logs or the response. This seems to be an oversight since its initial implementation. o.OCloses #9314