mirror of https://github.com/k3s-io/k3s
Set the emptyNameError to be a bad request. Always return a JSON error.
parent
cbe4a1a679
commit
4725ecac3f
|
@ -26,6 +26,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"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/runtime"
|
||||
|
||||
|
@ -47,7 +48,7 @@ type action struct {
|
|||
}
|
||||
|
||||
// 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.
|
||||
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
|
||||
namespace, name, err := namer.Name(req)
|
||||
if err != nil {
|
||||
notFound(w, req.Request)
|
||||
errorJSON(err, codec, w)
|
||||
return
|
||||
}
|
||||
ctx := ctxFn(req)
|
||||
|
@ -108,7 +108,7 @@ func ListResource(r RESTLister, ctxFn ContextFunc, namer ScopeNamer, codec runti
|
|||
|
||||
namespace, err := namer.Namespace(req)
|
||||
if err != nil {
|
||||
notFound(w, req.Request)
|
||||
errorJSON(err, codec, w)
|
||||
return
|
||||
}
|
||||
ctx := ctxFn(req)
|
||||
|
@ -143,7 +143,7 @@ func CreateResource(r RESTCreater, ctxFn ContextFunc, namer ScopeNamer, codec ru
|
|||
|
||||
namespace, err := namer.Namespace(req)
|
||||
if err != nil {
|
||||
notFound(w, req.Request)
|
||||
errorJSON(err, codec, w)
|
||||
return
|
||||
}
|
||||
ctx := ctxFn(req)
|
||||
|
@ -200,7 +200,7 @@ func PatchResource(r RESTPatcher, ctxFn ContextFunc, namer ScopeNamer, codec run
|
|||
|
||||
namespace, name, err := namer.Name(req)
|
||||
if err != nil {
|
||||
notFound(w, req.Request)
|
||||
errorJSON(err, codec, w)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -275,7 +275,7 @@ func UpdateResource(r RESTUpdater, ctxFn ContextFunc, namer ScopeNamer, codec ru
|
|||
|
||||
namespace, name, err := namer.Name(req)
|
||||
if err != nil {
|
||||
notFound(w, req.Request)
|
||||
errorJSON(err, codec, w)
|
||||
return
|
||||
}
|
||||
ctx := ctxFn(req)
|
||||
|
@ -339,7 +339,7 @@ func DeleteResource(r RESTDeleter, ctxFn ContextFunc, namer ScopeNamer, codec ru
|
|||
|
||||
namespace, name, err := namer.Name(req)
|
||||
if err != nil {
|
||||
notFound(w, req.Request)
|
||||
errorJSON(err, codec, w)
|
||||
return
|
||||
}
|
||||
ctx := ctxFn(req)
|
||||
|
|
Loading…
Reference in New Issue