Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
037eec3b
Unverified
Commit
037eec3b
authored
Jan 15, 2018
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add error helpers and constants for NotAcceptable and UnsupportedMediaType
parent
d3428a57
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
2 deletions
+32
-2
errors.go
staging/src/k8s.io/apimachinery/pkg/api/errors/errors.go
+18
-0
types.go
staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types.go
+12
-0
errors.go
...io/apiserver/pkg/endpoints/handlers/negotiation/errors.go
+2
-2
No files found.
staging/src/k8s.io/apimachinery/pkg/api/errors/errors.go
View file @
037eec3b
...
...
@@ -352,6 +352,14 @@ func NewGenericServerResponse(code int, verb string, qualifiedResource schema.Gr
reason
=
metav1
.
StatusReasonForbidden
// the server message has details about who is trying to perform what action. Keep its message.
message
=
serverMessage
case
http
.
StatusNotAcceptable
:
reason
=
metav1
.
StatusReasonNotAcceptable
// the server message has details about what types are acceptable
message
=
serverMessage
case
http
.
StatusUnsupportedMediaType
:
reason
=
metav1
.
StatusReasonUnsupportedMediaType
// the server message has details about what types are acceptable
message
=
serverMessage
case
http
.
StatusMethodNotAllowed
:
reason
=
metav1
.
StatusReasonMethodNotAllowed
message
=
"the server does not allow this method on the requested resource"
...
...
@@ -434,6 +442,16 @@ func IsResourceExpired(err error) bool {
return
ReasonForError
(
err
)
==
metav1
.
StatusReasonExpired
}
// IsNotAcceptable determines if err is an error which indicates that the request failed due to an invalid Accept header
func
IsNotAcceptable
(
err
error
)
bool
{
return
ReasonForError
(
err
)
==
metav1
.
StatusReasonNotAcceptable
}
// IsUnsupportedMediaType determines if err is an error which indicates that the request failed due to an invalid Content-Type header
func
IsUnsupportedMediaType
(
err
error
)
bool
{
return
ReasonForError
(
err
)
==
metav1
.
StatusReasonUnsupportedMediaType
}
// IsMethodNotSupported determines if the err is an error which indicates the provided action could not
// be performed because it is not supported by the server.
func
IsMethodNotSupported
(
err
error
)
bool
{
...
...
staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types.go
View file @
037eec3b
...
...
@@ -651,6 +651,18 @@ const (
// can only be created. API calls that return MethodNotAllowed can never succeed.
StatusReasonMethodNotAllowed
StatusReason
=
"MethodNotAllowed"
// StatusReasonNotAcceptable means that the accept types indicated by the client were not acceptable
// to the server - for instance, attempting to receive protobuf for a resource that supports only json and yaml.
// API calls that return NotAcceptable can never succeed.
// Status code 406
StatusReasonNotAcceptable
StatusReason
=
"NotAcceptable"
// StatusReasonUnsupportedMediaType means that the content type sent by the client is not acceptable
// to the server - for instance, attempting to send protobuf for a resource that supports only json and yaml.
// API calls that return UnsupportedMediaType can never succeed.
// Status code 415
StatusReasonUnsupportedMediaType
StatusReason
=
"UnsupportedMediaType"
// StatusReasonInternalError indicates that an internal error occurred, it is unexpected
// and the outcome of the call is unknown.
// Details (optional):
...
...
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/negotiation/errors.go
View file @
037eec3b
...
...
@@ -41,7 +41,7 @@ func (e errNotAcceptable) Status() metav1.Status {
return
metav1
.
Status
{
Status
:
metav1
.
StatusFailure
,
Code
:
http
.
StatusNotAcceptable
,
Reason
:
metav1
.
StatusReason
(
"NotAcceptable"
)
,
Reason
:
metav1
.
StatusReason
NotAcceptable
,
Message
:
e
.
Error
(),
}
}
...
...
@@ -63,7 +63,7 @@ func (e errUnsupportedMediaType) Status() metav1.Status {
return
metav1
.
Status
{
Status
:
metav1
.
StatusFailure
,
Code
:
http
.
StatusUnsupportedMediaType
,
Reason
:
metav1
.
StatusReason
(
"UnsupportedMediaType"
)
,
Reason
:
metav1
.
StatusReason
UnsupportedMediaType
,
Message
:
e
.
Error
(),
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment