mirror of https://github.com/dragonflyoss/api.git
feat: change status_code to optional in errordetails (#348)
Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
parent
79d680fa38
commit
a43075ce0e
|
@ -160,7 +160,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dragonfly-api"
|
name = "dragonfly-api"
|
||||||
version = "2.0.133"
|
version = "2.0.134"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"prost 0.11.9",
|
"prost 0.11.9",
|
||||||
"prost-types 0.13.1",
|
"prost-types 0.13.1",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "dragonfly-api"
|
name = "dragonfly-api"
|
||||||
version = "2.0.133"
|
version = "2.0.134"
|
||||||
authors = ["Gaius <gaius.qi@gmail.com>"]
|
authors = ["Gaius <gaius.qi@gmail.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
|
|
@ -47,7 +47,7 @@ type Backend struct {
|
||||||
// Backend HTTP response header.
|
// Backend HTTP response header.
|
||||||
Header map[string]string `protobuf:"bytes,2,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
Header map[string]string `protobuf:"bytes,2,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||||
// Backend HTTP status code.
|
// Backend HTTP status code.
|
||||||
StatusCode int32 `protobuf:"varint,3,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"`
|
StatusCode *int32 `protobuf:"varint,3,opt,name=status_code,json=statusCode,proto3,oneof" json:"status_code,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Backend) Reset() {
|
func (x *Backend) Reset() {
|
||||||
|
@ -97,8 +97,8 @@ func (x *Backend) GetHeader() map[string]string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Backend) GetStatusCode() int32 {
|
func (x *Backend) GetStatusCode() int32 {
|
||||||
if x != nil {
|
if x != nil && x.StatusCode != nil {
|
||||||
return x.StatusCode
|
return *x.StatusCode
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -111,24 +111,25 @@ var file_pkg_apis_errordetails_v2_errordetails_proto_rawDesc = []byte{
|
||||||
0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x65,
|
0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x65,
|
||||||
0x72, 0x72, 0x6f, 0x72, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x2e, 0x76, 0x32, 0x1a, 0x17,
|
0x72, 0x72, 0x6f, 0x72, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x2e, 0x76, 0x32, 0x1a, 0x17,
|
||||||
0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74,
|
0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74,
|
||||||
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc9, 0x01, 0x0a, 0x07, 0x42, 0x61, 0x63, 0x6b,
|
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe0, 0x01, 0x0a, 0x07, 0x42, 0x61, 0x63, 0x6b,
|
||||||
0x65, 0x6e, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01,
|
0x65, 0x6e, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01,
|
||||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x3c, 0x0a,
|
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x3c, 0x0a,
|
||||||
0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e,
|
0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e,
|
||||||
0x65, 0x72, 0x72, 0x6f, 0x72, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x2e, 0x76, 0x32, 0x2e,
|
0x65, 0x72, 0x72, 0x6f, 0x72, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x2e, 0x76, 0x32, 0x2e,
|
||||||
0x42, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e,
|
0x42, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e,
|
||||||
0x74, 0x72, 0x79, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x2b, 0x0a, 0x0b, 0x73,
|
0x74, 0x72, 0x79, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x32, 0x0a, 0x0b, 0x73,
|
||||||
0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05,
|
0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05,
|
||||||
0x42, 0x0a, 0xfa, 0x42, 0x07, 0x1a, 0x05, 0x10, 0xd7, 0x04, 0x28, 0x64, 0x52, 0x0a, 0x73, 0x74,
|
0x42, 0x0c, 0xfa, 0x42, 0x09, 0x1a, 0x07, 0x10, 0xd7, 0x04, 0x28, 0x64, 0x40, 0x01, 0x48, 0x00,
|
||||||
0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64,
|
0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x88, 0x01, 0x01, 0x1a,
|
||||||
0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01,
|
0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10,
|
||||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c,
|
0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79,
|
||||||
0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a,
|
0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||||
0x02, 0x38, 0x01, 0x42, 0x35, 0x5a, 0x33, 0x64, 0x37, 0x79, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70,
|
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x0e, 0x0a, 0x0c, 0x5f, 0x73,
|
||||||
0x69, 0x2f, 0x76, 0x32, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x65, 0x72,
|
0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x42, 0x35, 0x5a, 0x33, 0x64, 0x37,
|
||||||
0x72, 0x6f, 0x72, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x2f, 0x76, 0x32, 0x3b, 0x65, 0x72,
|
0x79, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x70, 0x6b, 0x67, 0x2f,
|
||||||
0x72, 0x6f, 0x72, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
0x61, 0x70, 0x69, 0x73, 0x2f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c,
|
||||||
0x6f, 0x33,
|
0x73, 0x2f, 0x76, 0x32, 0x3b, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c,
|
||||||
|
0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -176,6 +177,7 @@ func file_pkg_apis_errordetails_v2_errordetails_proto_init() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
file_pkg_apis_errordetails_v2_errordetails_proto_msgTypes[0].OneofWrappers = []interface{}{}
|
||||||
type x struct{}
|
type x struct{}
|
||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
File: protoimpl.DescBuilder{
|
File: protoimpl.DescBuilder{
|
||||||
|
|
|
@ -60,15 +60,23 @@ func (m *Backend) validate(all bool) error {
|
||||||
|
|
||||||
// no validation rules for Header
|
// no validation rules for Header
|
||||||
|
|
||||||
if val := m.GetStatusCode(); val < 100 || val >= 599 {
|
if m.StatusCode != nil {
|
||||||
err := BackendValidationError{
|
|
||||||
field: "StatusCode",
|
if m.GetStatusCode() != 0 {
|
||||||
reason: "value must be inside range [100, 599)",
|
|
||||||
|
if val := m.GetStatusCode(); val < 100 || val >= 599 {
|
||||||
|
err := BackendValidationError{
|
||||||
|
field: "StatusCode",
|
||||||
|
reason: "value must be inside range [100, 599)",
|
||||||
|
}
|
||||||
|
if !all {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
errors = append(errors, err)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if !all {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
errors = append(errors, err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(errors) > 0 {
|
if len(errors) > 0 {
|
||||||
|
|
|
@ -29,6 +29,6 @@ message Backend {
|
||||||
// Backend HTTP response header.
|
// Backend HTTP response header.
|
||||||
map<string, string> header = 2;
|
map<string, string> header = 2;
|
||||||
// Backend HTTP status code.
|
// Backend HTTP status code.
|
||||||
int32 status_code = 3 [(validate.rules).int32 = {gte: 100, lt: 599}];
|
optional int32 status_code = 3 [(validate.rules).int32 = {gte: 100, lt: 599, ignore_empty: true}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,5 +25,5 @@ message Backend {
|
||||||
// Backend HTTP response header.
|
// Backend HTTP response header.
|
||||||
map<string, string> header = 2;
|
map<string, string> header = 2;
|
||||||
// Backend HTTP status code.
|
// Backend HTTP status code.
|
||||||
int32 status_code = 3;
|
optional int32 status_code = 3;
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -13,6 +13,6 @@ pub struct Backend {
|
||||||
::prost::alloc::string::String,
|
::prost::alloc::string::String,
|
||||||
>,
|
>,
|
||||||
/// Backend HTTP status code.
|
/// Backend HTTP status code.
|
||||||
#[prost(int32, tag = "3")]
|
#[prost(int32, optional, tag = "3")]
|
||||||
pub status_code: i32,
|
pub status_code: ::core::option::Option<i32>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue