mirror of
https://github.com/containers/podman.git
synced 2025-06-30 15:49:03 +08:00
Merge pull request #22715 from rhatdan/volumes1
Return StatusNotFound when multiple volumes matching occurs
This commit is contained in:
@ -34,23 +34,25 @@ func Error(w http.ResponseWriter, code int, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func VolumeNotFound(w http.ResponseWriter, name string, err error) {
|
func VolumeNotFound(w http.ResponseWriter, name string, err error) {
|
||||||
if !errors.Is(err, define.ErrNoSuchVolume) {
|
if errors.Is(err, define.ErrNoSuchVolume) || errors.Is(err, define.ErrVolumeExists) {
|
||||||
InternalServerError(w, err)
|
Error(w, http.StatusNotFound, err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
Error(w, http.StatusNotFound, err)
|
InternalServerError(w, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ContainerNotFound(w http.ResponseWriter, name string, err error) {
|
func ContainerNotFound(w http.ResponseWriter, name string, err error) {
|
||||||
if errors.Is(err, define.ErrNoSuchCtr) || errors.Is(err, define.ErrCtrExists) {
|
if errors.Is(err, define.ErrNoSuchCtr) || errors.Is(err, define.ErrCtrExists) {
|
||||||
Error(w, http.StatusNotFound, err)
|
Error(w, http.StatusNotFound, err)
|
||||||
} else {
|
return
|
||||||
InternalServerError(w, err)
|
|
||||||
}
|
}
|
||||||
|
InternalServerError(w, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ImageNotFound(w http.ResponseWriter, name string, err error) {
|
func ImageNotFound(w http.ResponseWriter, name string, err error) {
|
||||||
if !errors.Is(err, storage.ErrImageUnknown) {
|
if !errors.Is(err, storage.ErrImageUnknown) {
|
||||||
InternalServerError(w, err)
|
InternalServerError(w, err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
Error(w, http.StatusNotFound, err)
|
Error(w, http.StatusNotFound, err)
|
||||||
}
|
}
|
||||||
@ -58,6 +60,7 @@ func ImageNotFound(w http.ResponseWriter, name string, err error) {
|
|||||||
func NetworkNotFound(w http.ResponseWriter, name string, err error) {
|
func NetworkNotFound(w http.ResponseWriter, name string, err error) {
|
||||||
if !errors.Is(err, define.ErrNoSuchNetwork) {
|
if !errors.Is(err, define.ErrNoSuchNetwork) {
|
||||||
InternalServerError(w, err)
|
InternalServerError(w, err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
Error(w, http.StatusNotFound, err)
|
Error(w, http.StatusNotFound, err)
|
||||||
}
|
}
|
||||||
@ -65,6 +68,7 @@ func NetworkNotFound(w http.ResponseWriter, name string, err error) {
|
|||||||
func PodNotFound(w http.ResponseWriter, name string, err error) {
|
func PodNotFound(w http.ResponseWriter, name string, err error) {
|
||||||
if !errors.Is(err, define.ErrNoSuchPod) {
|
if !errors.Is(err, define.ErrNoSuchPod) {
|
||||||
InternalServerError(w, err)
|
InternalServerError(w, err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
Error(w, http.StatusNotFound, err)
|
Error(w, http.StatusNotFound, err)
|
||||||
}
|
}
|
||||||
@ -72,6 +76,7 @@ func PodNotFound(w http.ResponseWriter, name string, err error) {
|
|||||||
func SessionNotFound(w http.ResponseWriter, name string, err error) {
|
func SessionNotFound(w http.ResponseWriter, name string, err error) {
|
||||||
if !errors.Is(err, define.ErrNoSuchExecSession) {
|
if !errors.Is(err, define.ErrNoSuchExecSession) {
|
||||||
InternalServerError(w, err)
|
InternalServerError(w, err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
Error(w, http.StatusNotFound, err)
|
Error(w, http.StatusNotFound, err)
|
||||||
}
|
}
|
||||||
@ -79,6 +84,7 @@ func SessionNotFound(w http.ResponseWriter, name string, err error) {
|
|||||||
func SecretNotFound(w http.ResponseWriter, nameOrID string, err error) {
|
func SecretNotFound(w http.ResponseWriter, nameOrID string, err error) {
|
||||||
if errorhandling.Cause(err).Error() != "no such secret" {
|
if errorhandling.Cause(err).Error() != "no such secret" {
|
||||||
InternalServerError(w, err)
|
InternalServerError(w, err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
Error(w, http.StatusNotFound, err)
|
Error(w, http.StatusNotFound, err)
|
||||||
}
|
}
|
||||||
|
@ -105,10 +105,6 @@ var _ = Describe("Podman volume rm", func() {
|
|||||||
// boltdb issues volume name in quotes
|
// boltdb issues volume name in quotes
|
||||||
expect = `more than one result for volume name "myv": volume already exists`
|
expect = `more than one result for volume name "myv": volume already exists`
|
||||||
}
|
}
|
||||||
if IsRemote() {
|
|
||||||
// FIXME: #22616
|
|
||||||
expect = `unmarshalling error into &errorhandling.ErrorModel`
|
|
||||||
}
|
|
||||||
Expect(session).To(ExitWithError(125, expect))
|
Expect(session).To(ExitWithError(125, expect))
|
||||||
|
|
||||||
session = podmanTest.Podman([]string{"volume", "ls"})
|
session = podmanTest.Podman([]string{"volume", "ls"})
|
||||||
|
Reference in New Issue
Block a user