mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
Merge pull request #5573 from brendandburns/err
Set the emptyNameError to be a bad request. Always return a JSON error.
This commit is contained in:
commit
7e42fc86fd
@ -26,6 +26,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/meta"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/meta"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ type action struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// errEmptyName is returned when API requests do not fill the name section of the path.
|
// errEmptyName is returned when API requests do not fill the name section of the path.
|
||||||
var errEmptyName = fmt.Errorf("name must be provided")
|
var errEmptyName = errors.NewBadRequest("name must be provided")
|
||||||
|
|
||||||
// Installs handlers for API resources.
|
// Installs handlers for API resources.
|
||||||
func (a *APIInstaller) Install() (ws *restful.WebService, errors []error) {
|
func (a *APIInstaller) Install() (ws *restful.WebService, errors []error) {
|
||||||
|
@ -64,7 +64,7 @@ func GetResource(r RESTGetter, ctxFn ContextFunc, namer ScopeNamer, codec runtim
|
|||||||
w := res.ResponseWriter
|
w := res.ResponseWriter
|
||||||
namespace, name, err := namer.Name(req)
|
namespace, name, err := namer.Name(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
notFound(w, req.Request)
|
errorJSON(err, codec, w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx := ctxFn(req)
|
ctx := ctxFn(req)
|
||||||
@ -108,7 +108,7 @@ func ListResource(r RESTLister, ctxFn ContextFunc, namer ScopeNamer, codec runti
|
|||||||
|
|
||||||
namespace, err := namer.Namespace(req)
|
namespace, err := namer.Namespace(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
notFound(w, req.Request)
|
errorJSON(err, codec, w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx := ctxFn(req)
|
ctx := ctxFn(req)
|
||||||
@ -143,7 +143,7 @@ func CreateResource(r RESTCreater, ctxFn ContextFunc, namer ScopeNamer, codec ru
|
|||||||
|
|
||||||
namespace, err := namer.Namespace(req)
|
namespace, err := namer.Namespace(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
notFound(w, req.Request)
|
errorJSON(err, codec, w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx := ctxFn(req)
|
ctx := ctxFn(req)
|
||||||
@ -200,7 +200,7 @@ func PatchResource(r RESTPatcher, ctxFn ContextFunc, namer ScopeNamer, codec run
|
|||||||
|
|
||||||
namespace, name, err := namer.Name(req)
|
namespace, name, err := namer.Name(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
notFound(w, req.Request)
|
errorJSON(err, codec, w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,7 +275,7 @@ func UpdateResource(r RESTUpdater, ctxFn ContextFunc, namer ScopeNamer, codec ru
|
|||||||
|
|
||||||
namespace, name, err := namer.Name(req)
|
namespace, name, err := namer.Name(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
notFound(w, req.Request)
|
errorJSON(err, codec, w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx := ctxFn(req)
|
ctx := ctxFn(req)
|
||||||
@ -339,7 +339,7 @@ func DeleteResource(r RESTDeleter, ctxFn ContextFunc, namer ScopeNamer, codec ru
|
|||||||
|
|
||||||
namespace, name, err := namer.Name(req)
|
namespace, name, err := namer.Name(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
notFound(w, req.Request)
|
errorJSON(err, codec, w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx := ctxFn(req)
|
ctx := ctxFn(req)
|
||||||
|
Loading…
Reference in New Issue
Block a user