mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-10 13:42:02 +00:00
kubectl delete command: adding labelSelector
Add a Visitor pattern on top of ResourcesFromArgs Allows ResourcesFromArgs to return an opaque list of items and have client commands react to them. Change request.go to return apiserver errors for arbitrary status codes to better respond to generic actions that don't make sense (kubectl delete operations foo)
This commit is contained in:
committed by
salvatore dario minonne
parent
da4967fe38
commit
61ac2f7437
@@ -411,11 +411,26 @@ func (r *Request) transformResponse(resp *http.Response, req *http.Request) ([]b
|
||||
switch {
|
||||
case resp.StatusCode < http.StatusOK || resp.StatusCode > http.StatusPartialContent:
|
||||
if !isStatusResponse {
|
||||
return nil, false, &UnexpectedStatusError{
|
||||
var err error = &UnexpectedStatusError{
|
||||
Request: req,
|
||||
Response: resp,
|
||||
Body: string(body),
|
||||
}
|
||||
// TODO: handle other error classes we know about
|
||||
switch resp.StatusCode {
|
||||
case http.StatusConflict:
|
||||
if req.Method == "POST" {
|
||||
// TODO: add Resource() and ResourceName() as Request methods so that we can set these
|
||||
err = errors.NewAlreadyExists("", "")
|
||||
} else {
|
||||
err = errors.NewConflict("", "", err)
|
||||
}
|
||||
case http.StatusNotFound:
|
||||
err = errors.NewNotFound("", "")
|
||||
case http.StatusBadRequest:
|
||||
err = errors.NewBadRequest(err.Error())
|
||||
}
|
||||
return nil, false, err
|
||||
}
|
||||
return nil, false, errors.FromObject(&status)
|
||||
}
|
||||
|
Reference in New Issue
Block a user