diff --git a/Cargo.lock b/Cargo.lock index 525c767..2385a2c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -160,7 +160,7 @@ dependencies = [ [[package]] name = "dragonfly-api" -version = "2.0.133" +version = "2.0.134" dependencies = [ "prost 0.11.9", "prost-types 0.13.1", diff --git a/Cargo.toml b/Cargo.toml index 0df99e9..2b3dca2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dragonfly-api" -version = "2.0.133" +version = "2.0.134" authors = ["Gaius "] edition = "2021" license = "Apache-2.0" diff --git a/pkg/apis/errordetails/v2/errordetails.pb.go b/pkg/apis/errordetails/v2/errordetails.pb.go index c102127..54c7e87 100644 --- a/pkg/apis/errordetails/v2/errordetails.pb.go +++ b/pkg/apis/errordetails/v2/errordetails.pb.go @@ -47,7 +47,7 @@ type Backend struct { // 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"` // 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() { @@ -97,8 +97,8 @@ func (x *Backend) GetHeader() map[string]string { } func (x *Backend) GetStatusCode() int32 { - if x != nil { - return x.StatusCode + if x != nil && x.StatusCode != nil { + return *x.StatusCode } 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, 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, - 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, 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, 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, - 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, - 0x42, 0x0a, 0xfa, 0x42, 0x07, 0x1a, 0x05, 0x10, 0xd7, 0x04, 0x28, 0x64, 0x52, 0x0a, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, - 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, - 0x02, 0x38, 0x01, 0x42, 0x35, 0x5a, 0x33, 0x64, 0x37, 0x79, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, - 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x65, 0x72, - 0x72, 0x6f, 0x72, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 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, + 0x42, 0x0c, 0xfa, 0x42, 0x09, 0x1a, 0x07, 0x10, 0xd7, 0x04, 0x28, 0x64, 0x40, 0x01, 0x48, 0x00, + 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x88, 0x01, 0x01, 0x1a, + 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, + 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, + 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x0e, 0x0a, 0x0c, 0x5f, 0x73, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x42, 0x35, 0x5a, 0x33, 0x64, 0x37, + 0x79, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x70, 0x6b, 0x67, 0x2f, + 0x61, 0x70, 0x69, 0x73, 0x2f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, + 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 ( @@ -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{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/pkg/apis/errordetails/v2/errordetails.pb.validate.go b/pkg/apis/errordetails/v2/errordetails.pb.validate.go index d87206a..0b12f41 100644 --- a/pkg/apis/errordetails/v2/errordetails.pb.validate.go +++ b/pkg/apis/errordetails/v2/errordetails.pb.validate.go @@ -60,15 +60,23 @@ func (m *Backend) validate(all bool) error { // no validation rules for Header - if val := m.GetStatusCode(); val < 100 || val >= 599 { - err := BackendValidationError{ - field: "StatusCode", - reason: "value must be inside range [100, 599)", + if m.StatusCode != nil { + + if m.GetStatusCode() != 0 { + + 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 { diff --git a/pkg/apis/errordetails/v2/errordetails.proto b/pkg/apis/errordetails/v2/errordetails.proto index 86e7319..fccb666 100644 --- a/pkg/apis/errordetails/v2/errordetails.proto +++ b/pkg/apis/errordetails/v2/errordetails.proto @@ -29,6 +29,6 @@ message Backend { // Backend HTTP response header. map header = 2; // 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}]; } diff --git a/proto/errordetails.proto b/proto/errordetails.proto index c1fd436..63decaa 100644 --- a/proto/errordetails.proto +++ b/proto/errordetails.proto @@ -25,5 +25,5 @@ message Backend { // Backend HTTP response header. map header = 2; // Backend HTTP status code. - int32 status_code = 3; + optional int32 status_code = 3; } diff --git a/src/descriptor.bin b/src/descriptor.bin index c01baa6..6cc1272 100644 Binary files a/src/descriptor.bin and b/src/descriptor.bin differ diff --git a/src/errordetails.v2.rs b/src/errordetails.v2.rs index 9179f96..3ba29c7 100644 --- a/src/errordetails.v2.rs +++ b/src/errordetails.v2.rs @@ -13,6 +13,6 @@ pub struct Backend { ::prost::alloc::string::String, >, /// Backend HTTP status code. - #[prost(int32, tag = "3")] - pub status_code: i32, + #[prost(int32, optional, tag = "3")] + pub status_code: ::core::option::Option, }