mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Caps on StatusReason*
This commit is contained in:
parent
523731c509
commit
e73de49f81
@ -29,26 +29,26 @@ import (
|
||||
func TestErrorNew(t *testing.T) {
|
||||
err := NewAlreadyExists("test", "1")
|
||||
if !IsAlreadyExists(err) {
|
||||
t.Errorf("expected to be already_exists")
|
||||
t.Errorf("expected to be %s", api.StatusReasonAlreadyExists)
|
||||
}
|
||||
if IsConflict(err) {
|
||||
t.Errorf("expected to not be confict")
|
||||
t.Errorf("expected to not be %s", api.StatusReasonConflict)
|
||||
}
|
||||
if IsNotFound(err) {
|
||||
t.Errorf(fmt.Sprintf("expected to not be %s", api.StatusReasonNotFound))
|
||||
}
|
||||
if IsInvalid(err) {
|
||||
t.Errorf("expected to not be invalid")
|
||||
t.Errorf("expected to not be %s", api.StatusReasonInvalid)
|
||||
}
|
||||
|
||||
if !IsConflict(NewConflict("test", "2", errors.New("message"))) {
|
||||
t.Errorf("expected to be conflict")
|
||||
}
|
||||
if !IsNotFound(NewNotFound("test", "3")) {
|
||||
t.Errorf("expected to be not found")
|
||||
t.Errorf("expected to be %s", api.StatusReasonNotFound)
|
||||
}
|
||||
if !IsInvalid(NewInvalid("test", "2", nil)) {
|
||||
t.Errorf("expected to be invalid")
|
||||
t.Errorf("expected to be %s", api.StatusReasonInvalid)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -522,7 +522,7 @@ const (
|
||||
// "Location" - HTTP header populated with a URL that can retrieved the final
|
||||
// status of this operation.
|
||||
// Status code 202
|
||||
StatusReasonWorking StatusReason = "working"
|
||||
StatusReasonWorking StatusReason = "Working"
|
||||
|
||||
// StatusReasonNotFound means one or more resources required for this operation
|
||||
// could not be found.
|
||||
@ -532,21 +532,21 @@ const (
|
||||
// resource.
|
||||
// "id" string - the identifier of the missing resource
|
||||
// Status code 404
|
||||
StatusReasonNotFound StatusReason = "not_found"
|
||||
StatusReasonNotFound StatusReason = "NotFound"
|
||||
|
||||
// StatusReasonAlreadyExists means the resource you are creating already exists.
|
||||
// Details (optional):
|
||||
// "kind" string - the kind attribute of the conflicting resource
|
||||
// "id" string - the identifier of the conflicting resource
|
||||
// Status code 409
|
||||
StatusReasonAlreadyExists StatusReason = "already_exists"
|
||||
StatusReasonAlreadyExists StatusReason = "AlreadyExists"
|
||||
|
||||
// StatusReasonConflict means the requested update operation cannot be completed
|
||||
// due to a conflict in the operation. The client may need to alter the request.
|
||||
// Each resource may define custom details that indicate the nature of the
|
||||
// conflict.
|
||||
// Status code 409
|
||||
StatusReasonConflict StatusReason = "conflict"
|
||||
StatusReasonConflict StatusReason = "Conflict"
|
||||
|
||||
// StatusReasonInvalid means the requested create or update operation cannot be
|
||||
// completed due to invalid data provided as part of the request. The client may
|
||||
@ -559,7 +559,7 @@ const (
|
||||
// provided resource that was invalid. The code, message, and
|
||||
// field attributes will be set.
|
||||
// Status code 422
|
||||
StatusReasonInvalid StatusReason = "invalid"
|
||||
StatusReasonInvalid StatusReason = "Invalid"
|
||||
)
|
||||
|
||||
// StatusCause provides more information about an api.Status failure, including
|
||||
|
@ -538,7 +538,7 @@ const (
|
||||
// "Location" - HTTP header populated with a URL that can retrieved the final
|
||||
// status of this operation.
|
||||
// Status code 202
|
||||
StatusReasonWorking StatusReason = "working"
|
||||
StatusReasonWorking StatusReason = "Working"
|
||||
|
||||
// StatusReasonNotFound means one or more resources required for this operation
|
||||
// could not be found.
|
||||
@ -548,21 +548,21 @@ const (
|
||||
// resource.
|
||||
// "id" string - the identifier of the missing resource
|
||||
// Status code 404
|
||||
StatusReasonNotFound StatusReason = "notFound"
|
||||
StatusReasonNotFound StatusReason = "NotFound"
|
||||
|
||||
// StatusReasonAlreadyExists means the resource you are creating already exists.
|
||||
// Details (optional):
|
||||
// "kind" string - the kind attribute of the conflicting resource
|
||||
// "id" string - the identifier of the conflicting resource
|
||||
// Status code 409
|
||||
StatusReasonAlreadyExists StatusReason = "alreadyExists"
|
||||
StatusReasonAlreadyExists StatusReason = "AlreadyExists"
|
||||
|
||||
// StatusReasonConflict means the requested update operation cannot be completed
|
||||
// due to a conflict in the operation. The client may need to alter the request.
|
||||
// Each resource may define custom details that indicate the nature of the
|
||||
// conflict.
|
||||
// Status code 409
|
||||
StatusReasonConflict StatusReason = "conflict"
|
||||
StatusReasonConflict StatusReason = "Conflict"
|
||||
)
|
||||
|
||||
// StatusCause provides more information about an api.Status failure, including
|
||||
|
@ -535,7 +535,7 @@ const (
|
||||
// "Location" - HTTP header populated with a URL that can retrieved the final
|
||||
// status of this operation.
|
||||
// Status code 202
|
||||
StatusReasonWorking StatusReason = "working"
|
||||
StatusReasonWorking StatusReason = "Working"
|
||||
|
||||
// StatusReasonNotFound means one or more resources required for this operation
|
||||
// could not be found.
|
||||
@ -545,21 +545,21 @@ const (
|
||||
// resource.
|
||||
// "id" string - the identifier of the missing resource
|
||||
// Status code 404
|
||||
StatusReasonNotFound StatusReason = "not_found"
|
||||
StatusReasonNotFound StatusReason = "NotFound"
|
||||
|
||||
// StatusReasonAlreadyExists means the resource you are creating already exists.
|
||||
// Details (optional):
|
||||
// "kind" string - the kind attribute of the conflicting resource
|
||||
// "id" string - the identifier of the conflicting resource
|
||||
// Status code 409
|
||||
StatusReasonAlreadyExists StatusReason = "already_exists"
|
||||
StatusReasonAlreadyExists StatusReason = "AlreadyExists"
|
||||
|
||||
// StatusReasonConflict means the requested update operation cannot be completed
|
||||
// due to a conflict in the operation. The client may need to alter the request.
|
||||
// Each resource may define custom details that indicate the nature of the
|
||||
// conflict.
|
||||
// Status code 409
|
||||
StatusReasonConflict StatusReason = "conflict"
|
||||
StatusReasonConflict StatusReason = "Conflict"
|
||||
|
||||
// StatusReasonInvalid means the requested create or update operation cannot be
|
||||
// completed due to invalid data provided as part of the request. The client may
|
||||
@ -572,7 +572,7 @@ const (
|
||||
// provided resource that was invalid. The code, message, and
|
||||
// field attributes will be set.
|
||||
// Status code 422
|
||||
StatusReasonInvalid StatusReason = "invalid"
|
||||
StatusReasonInvalid StatusReason = "Invalid"
|
||||
)
|
||||
|
||||
// StatusCause provides more information about an api.Status failure, including
|
||||
|
@ -531,7 +531,7 @@ const (
|
||||
// "Location" - HTTP header populated with a URL that can retrieved the final
|
||||
// status of this operation.
|
||||
// Status code 202
|
||||
StatusReasonWorking StatusReason = "working"
|
||||
StatusReasonWorking StatusReason = "Working"
|
||||
|
||||
// StatusReasonNotFound means one or more resources required for this operation
|
||||
// could not be found.
|
||||
@ -541,21 +541,21 @@ const (
|
||||
// resource.
|
||||
// "id" string - the identifier of the missing resource
|
||||
// Status code 404
|
||||
StatusReasonNotFound StatusReason = "not_found"
|
||||
StatusReasonNotFound StatusReason = "NotFound"
|
||||
|
||||
// StatusReasonAlreadyExists means the resource you are creating already exists.
|
||||
// Details (optional):
|
||||
// "kind" string - the kind attribute of the conflicting resource
|
||||
// "id" string - the identifier of the conflicting resource
|
||||
// Status code 409
|
||||
StatusReasonAlreadyExists StatusReason = "already_exists"
|
||||
StatusReasonAlreadyExists StatusReason = "AlreadyExists"
|
||||
|
||||
// StatusReasonConflict means the requested update operation cannot be completed
|
||||
// due to a conflict in the operation. The client may need to alter the request.
|
||||
// Each resource may define custom details that indicate the nature of the
|
||||
// conflict.
|
||||
// Status code 409
|
||||
StatusReasonConflict StatusReason = "conflict"
|
||||
StatusReasonConflict StatusReason = "Conflict"
|
||||
|
||||
// StatusReasonInvalid means the requested create or update operation cannot be
|
||||
// completed due to invalid data provided as part of the request. The client may
|
||||
@ -568,7 +568,7 @@ const (
|
||||
// provided resource that was invalid. The code, message, and
|
||||
// field attributes will be set.
|
||||
// Status code 422
|
||||
StatusReasonInvalid StatusReason = "invalid"
|
||||
StatusReasonInvalid StatusReason = "Invalid"
|
||||
)
|
||||
|
||||
// StatusCause provides more information about an api.Status failure, including
|
||||
|
@ -706,7 +706,7 @@ func TestAsyncCreateError(t *testing.T) {
|
||||
expectedStatus := &api.Status{
|
||||
Status: api.StatusFailure,
|
||||
Code: http.StatusConflict,
|
||||
Reason: "already_exists",
|
||||
Reason: "AlreadyExists",
|
||||
Message: expectedErr.Error(),
|
||||
Details: &api.StatusDetails{
|
||||
Kind: "foo",
|
||||
|
@ -39,7 +39,7 @@ func TestErrorsToAPIStatus(t *testing.T) {
|
||||
errors.NewAlreadyExists("foo", "bar"): {
|
||||
Status: api.StatusFailure,
|
||||
Code: http.StatusConflict,
|
||||
Reason: "already_exists",
|
||||
Reason: "AlreadyExists",
|
||||
Message: "foo \"bar\" already exists",
|
||||
Details: &api.StatusDetails{
|
||||
Kind: "foo",
|
||||
@ -49,7 +49,7 @@ func TestErrorsToAPIStatus(t *testing.T) {
|
||||
errors.NewConflict("foo", "bar", stderrs.New("failure")): {
|
||||
Status: api.StatusFailure,
|
||||
Code: http.StatusConflict,
|
||||
Reason: "conflict",
|
||||
Reason: "Conflict",
|
||||
Message: "foo \"bar\" cannot be updated: failure",
|
||||
Details: &api.StatusDetails{
|
||||
Kind: "foo",
|
||||
|
Loading…
Reference in New Issue
Block a user