From efcf912fb35470672231c7b7bef620f3d17f655a Mon Sep 17 00:00:00 2001 From: htuch Date: Mon, 29 Jun 2020 16:34:42 -0400 Subject: [PATCH] udpa: clarify URI fragment encoding of directives. (#30) After spending some time looking at RFC3986 and chatting with Louis, it seems we can support multiple directives in the fragment, but we need to be very precise on how they are percent encoded. This patch proposes that we move from having multiple fragments (which are not allowed in RFC compliant URIs) to a single fragment with comma-separated percent encoded directives. Comma was selected as it is an available character in RFC3986 sub-delims, intuitively indicates separation, and is less likely to appear in URIs (forcing percent encoding) than other alternatives, e.g. '&' which would appear in most URIs with context parameters. Percent encoded directives in URIs should remain fairly readable, for example udpa://foo#entry=something,alt=udpa://bar/baz&x=y requires no percent encoding. Also renamed schema to scheme to match RFC3986. Signed-off-by: Harvey Tuch --- go/udpa/core/v1/collection_resource.pb.go | 195 --------------- .../v1/collection_resource.pb.validate.go | 227 ------------------ go/udpa/core/v1/resource_locator.pb.go | 30 +-- .../core/v1/resource_locator.pb.validate.go | 4 +- udpa/core/v1/resource_locator.proto | 42 +++- 5 files changed, 48 insertions(+), 450 deletions(-) delete mode 100644 go/udpa/core/v1/collection_resource.pb.go delete mode 100644 go/udpa/core/v1/collection_resource.pb.validate.go diff --git a/go/udpa/core/v1/collection_resource.pb.go b/go/udpa/core/v1/collection_resource.pb.go deleted file mode 100644 index 3fb5256..0000000 --- a/go/udpa/core/v1/collection_resource.pb.go +++ /dev/null @@ -1,195 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: udpa/core/v1/collection_resource.proto - -package udpa_core_v1 - -import ( - fmt "fmt" - _ "github.com/cncf/udpa/go/udpa/annotations" - _ "github.com/envoyproxy/protoc-gen-validate/validate" - proto "github.com/golang/protobuf/proto" - any "github.com/golang/protobuf/ptypes/any" - math "math" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package - -type CollectionResource struct { - // Types that are valid to be assigned to ResourceSpecifier: - // *CollectionResource_Locator - // *CollectionResource_Entry - ResourceSpecifier isCollectionResource_ResourceSpecifier `protobuf_oneof:"resource_specifier"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CollectionResource) Reset() { *m = CollectionResource{} } -func (m *CollectionResource) String() string { return proto.CompactTextString(m) } -func (*CollectionResource) ProtoMessage() {} -func (*CollectionResource) Descriptor() ([]byte, []int) { - return fileDescriptor_a105f4a9571f0c96, []int{0} -} - -func (m *CollectionResource) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CollectionResource.Unmarshal(m, b) -} -func (m *CollectionResource) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CollectionResource.Marshal(b, m, deterministic) -} -func (m *CollectionResource) XXX_Merge(src proto.Message) { - xxx_messageInfo_CollectionResource.Merge(m, src) -} -func (m *CollectionResource) XXX_Size() int { - return xxx_messageInfo_CollectionResource.Size(m) -} -func (m *CollectionResource) XXX_DiscardUnknown() { - xxx_messageInfo_CollectionResource.DiscardUnknown(m) -} - -var xxx_messageInfo_CollectionResource proto.InternalMessageInfo - -type isCollectionResource_ResourceSpecifier interface { - isCollectionResource_ResourceSpecifier() -} - -type CollectionResource_Locator struct { - Locator *ResourceLocator `protobuf:"bytes,1,opt,name=locator,proto3,oneof"` -} - -type CollectionResource_Entry struct { - Entry *CollectionResource_InlineEntry `protobuf:"bytes,2,opt,name=entry,proto3,oneof"` -} - -func (*CollectionResource_Locator) isCollectionResource_ResourceSpecifier() {} - -func (*CollectionResource_Entry) isCollectionResource_ResourceSpecifier() {} - -func (m *CollectionResource) GetResourceSpecifier() isCollectionResource_ResourceSpecifier { - if m != nil { - return m.ResourceSpecifier - } - return nil -} - -func (m *CollectionResource) GetLocator() *ResourceLocator { - if x, ok := m.GetResourceSpecifier().(*CollectionResource_Locator); ok { - return x.Locator - } - return nil -} - -func (m *CollectionResource) GetEntry() *CollectionResource_InlineEntry { - if x, ok := m.GetResourceSpecifier().(*CollectionResource_Entry); ok { - return x.Entry - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*CollectionResource) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*CollectionResource_Locator)(nil), - (*CollectionResource_Entry)(nil), - } -} - -type CollectionResource_InlineEntry struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` - Resource *any.Any `protobuf:"bytes,3,opt,name=resource,proto3" json:"resource,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CollectionResource_InlineEntry) Reset() { *m = CollectionResource_InlineEntry{} } -func (m *CollectionResource_InlineEntry) String() string { return proto.CompactTextString(m) } -func (*CollectionResource_InlineEntry) ProtoMessage() {} -func (*CollectionResource_InlineEntry) Descriptor() ([]byte, []int) { - return fileDescriptor_a105f4a9571f0c96, []int{0, 0} -} - -func (m *CollectionResource_InlineEntry) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CollectionResource_InlineEntry.Unmarshal(m, b) -} -func (m *CollectionResource_InlineEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CollectionResource_InlineEntry.Marshal(b, m, deterministic) -} -func (m *CollectionResource_InlineEntry) XXX_Merge(src proto.Message) { - xxx_messageInfo_CollectionResource_InlineEntry.Merge(m, src) -} -func (m *CollectionResource_InlineEntry) XXX_Size() int { - return xxx_messageInfo_CollectionResource_InlineEntry.Size(m) -} -func (m *CollectionResource_InlineEntry) XXX_DiscardUnknown() { - xxx_messageInfo_CollectionResource_InlineEntry.DiscardUnknown(m) -} - -var xxx_messageInfo_CollectionResource_InlineEntry proto.InternalMessageInfo - -func (m *CollectionResource_InlineEntry) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *CollectionResource_InlineEntry) GetVersion() string { - if m != nil { - return m.Version - } - return "" -} - -func (m *CollectionResource_InlineEntry) GetResource() *any.Any { - if m != nil { - return m.Resource - } - return nil -} - -func init() { - proto.RegisterType((*CollectionResource)(nil), "udpa.core.v1.CollectionResource") - proto.RegisterType((*CollectionResource_InlineEntry)(nil), "udpa.core.v1.CollectionResource.InlineEntry") -} - -func init() { - proto.RegisterFile("udpa/core/v1/collection_resource.proto", fileDescriptor_a105f4a9571f0c96) -} - -var fileDescriptor_a105f4a9571f0c96 = []byte{ - // 365 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x90, 0x4f, 0x4f, 0x2a, 0x31, - 0x14, 0xc5, 0x19, 0x78, 0x8f, 0x3f, 0xe5, 0xad, 0x9a, 0x67, 0x18, 0x08, 0x24, 0x46, 0x8d, 0x31, - 0xd1, 0xe9, 0x00, 0xae, 0x70, 0xc7, 0xa8, 0x09, 0x26, 0x2e, 0xc8, 0x2c, 0x15, 0x25, 0xa5, 0x14, - 0x6c, 0x32, 0xb4, 0xa4, 0xd3, 0x99, 0x04, 0x17, 0xc6, 0xbd, 0xdf, 0xc8, 0x85, 0x6b, 0xb7, 0x7e, - 0x1b, 0xe3, 0xca, 0x4c, 0x67, 0x4a, 0x20, 0xec, 0xda, 0xdc, 0xdf, 0xb9, 0xe7, 0xdc, 0x03, 0x8e, - 0xa3, 0xe9, 0x12, 0xbb, 0x44, 0x48, 0xea, 0xc6, 0x1d, 0x97, 0x88, 0x20, 0xa0, 0x44, 0x31, 0xc1, - 0xc7, 0x92, 0x86, 0x22, 0x92, 0x84, 0xa2, 0xa5, 0x14, 0x4a, 0xc0, 0x7f, 0x09, 0x87, 0x12, 0x0e, - 0xc5, 0x9d, 0x46, 0x7d, 0x2e, 0xc4, 0x3c, 0xa0, 0xae, 0x9e, 0x4d, 0xa2, 0x99, 0x8b, 0xf9, 0x2a, - 0x05, 0x1b, 0x2d, 0xbd, 0x10, 0x73, 0x2e, 0x14, 0x4e, 0x16, 0x85, 0x6e, 0xa8, 0xb0, 0x8a, 0xc2, - 0x6c, 0x7c, 0xb8, 0xe5, 0x67, 0x4c, 0xc6, 0x81, 0x20, 0x58, 0x09, 0x99, 0x41, 0xb5, 0x18, 0x07, - 0x6c, 0x8a, 0x15, 0x75, 0xcd, 0x23, 0x1d, 0x1c, 0x7c, 0xe4, 0x01, 0xbc, 0x5c, 0x67, 0xf4, 0x33, - 0x35, 0xec, 0x81, 0x52, 0xb6, 0xc0, 0xb6, 0xf6, 0xad, 0x93, 0x6a, 0xb7, 0x85, 0x36, 0xe3, 0x22, - 0x03, 0xde, 0xa6, 0xd0, 0x20, 0xe7, 0x1b, 0x1e, 0x5e, 0x81, 0xbf, 0x94, 0x2b, 0xb9, 0xb2, 0xf3, - 0x5a, 0x78, 0xb6, 0x2d, 0xdc, 0xf5, 0x42, 0x37, 0x3c, 0x60, 0x9c, 0x5e, 0x27, 0x9a, 0x41, 0xce, - 0x4f, 0xc5, 0x8d, 0x37, 0x0b, 0x54, 0x37, 0x06, 0xb0, 0x0d, 0xfe, 0x70, 0xbc, 0xa0, 0x3a, 0x4d, - 0xc5, 0x6b, 0xfe, 0x78, 0x75, 0x59, 0xeb, 0xee, 0x3d, 0xde, 0xb7, 0x9d, 0x1e, 0x76, 0x9e, 0xfb, - 0xce, 0xdd, 0x78, 0xe4, 0x8c, 0xd0, 0xcb, 0xc5, 0xc3, 0xe9, 0x91, 0xaf, 0x49, 0x68, 0x83, 0x52, - 0x4c, 0x65, 0xc8, 0x04, 0xd7, 0x49, 0x2a, 0xbe, 0xf9, 0xc2, 0x36, 0x28, 0x9b, 0x9a, 0xec, 0x82, - 0x0e, 0xf9, 0x1f, 0xa5, 0xf5, 0x23, 0x53, 0x3f, 0xea, 0xf3, 0x95, 0xbf, 0xa6, 0xbc, 0x3a, 0x80, - 0xeb, 0x62, 0xc3, 0x25, 0x25, 0x6c, 0xc6, 0xa8, 0x84, 0x85, 0x6f, 0xcf, 0xf2, 0xfa, 0xef, 0xaf, - 0x9f, 0x5f, 0xc5, 0x7c, 0xd9, 0x02, 0x4d, 0x22, 0x16, 0x68, 0xce, 0xd4, 0x53, 0x34, 0x49, 0x6f, - 0xde, 0x3c, 0xdc, 0xab, 0xed, 0x5e, 0x3e, 0x4c, 0xcc, 0x86, 0xd6, 0xa4, 0xa8, 0x5d, 0xcf, 0x7f, - 0x03, 0x00, 0x00, 0xff, 0xff, 0x7e, 0xab, 0x78, 0x80, 0x3a, 0x02, 0x00, 0x00, -} diff --git a/go/udpa/core/v1/collection_resource.pb.validate.go b/go/udpa/core/v1/collection_resource.pb.validate.go deleted file mode 100644 index a91f4f7..0000000 --- a/go/udpa/core/v1/collection_resource.pb.validate.go +++ /dev/null @@ -1,227 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: udpa/core/v1/collection_resource.proto - -package udpa_core_v1 - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "strings" - "time" - "unicode/utf8" - - "github.com/golang/protobuf/ptypes" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = ptypes.DynamicAny{} -) - -// define the regex for a UUID once up-front -var _collection_resource_uuidPattern = regexp.MustCompile("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$") - -// Validate checks the field values on CollectionResource with the rules -// defined in the proto definition for this message. If any rules are -// violated, an error is returned. -func (m *CollectionResource) Validate() error { - if m == nil { - return nil - } - - switch m.ResourceSpecifier.(type) { - - case *CollectionResource_Locator: - - if v, ok := interface{}(m.GetLocator()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CollectionResourceValidationError{ - field: "Locator", - reason: "embedded message failed validation", - cause: err, - } - } - } - - case *CollectionResource_Entry: - - if v, ok := interface{}(m.GetEntry()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CollectionResourceValidationError{ - field: "Entry", - reason: "embedded message failed validation", - cause: err, - } - } - } - - default: - return CollectionResourceValidationError{ - field: "ResourceSpecifier", - reason: "value is required", - } - - } - - return nil -} - -// CollectionResourceValidationError is the validation error returned by -// CollectionResource.Validate if the designated constraints aren't met. -type CollectionResourceValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CollectionResourceValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CollectionResourceValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CollectionResourceValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CollectionResourceValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CollectionResourceValidationError) ErrorName() string { - return "CollectionResourceValidationError" -} - -// Error satisfies the builtin error interface -func (e CollectionResourceValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sCollectionResource.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CollectionResourceValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CollectionResourceValidationError{} - -// Validate checks the field values on CollectionResource_InlineEntry with the -// rules defined in the proto definition for this message. If any rules are -// violated, an error is returned. -func (m *CollectionResource_InlineEntry) Validate() error { - if m == nil { - return nil - } - - if !_CollectionResource_InlineEntry_Name_Pattern.MatchString(m.GetName()) { - return CollectionResource_InlineEntryValidationError{ - field: "Name", - reason: "value does not match regex pattern \"^[0-9a-zA-Z_\\\\-\\\\.~:]+$\"", - } - } - - // no validation rules for Version - - if v, ok := interface{}(m.GetResource()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CollectionResource_InlineEntryValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - } - } - } - - return nil -} - -// CollectionResource_InlineEntryValidationError is the validation error -// returned by CollectionResource_InlineEntry.Validate if the designated -// constraints aren't met. -type CollectionResource_InlineEntryValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CollectionResource_InlineEntryValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CollectionResource_InlineEntryValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CollectionResource_InlineEntryValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CollectionResource_InlineEntryValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CollectionResource_InlineEntryValidationError) ErrorName() string { - return "CollectionResource_InlineEntryValidationError" -} - -// Error satisfies the builtin error interface -func (e CollectionResource_InlineEntryValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sCollectionResource_InlineEntry.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CollectionResource_InlineEntryValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CollectionResource_InlineEntryValidationError{} - -var _CollectionResource_InlineEntry_Name_Pattern = regexp.MustCompile("^[0-9a-zA-Z_\\-\\.~:]+$") diff --git a/go/udpa/core/v1/resource_locator.pb.go b/go/udpa/core/v1/resource_locator.pb.go index 890f861..c1a1032 100644 --- a/go/udpa/core/v1/resource_locator.pb.go +++ b/go/udpa/core/v1/resource_locator.pb.go @@ -22,36 +22,36 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package -type ResourceLocator_Schema int32 +type ResourceLocator_Scheme int32 const ( - ResourceLocator_UDPA ResourceLocator_Schema = 0 - ResourceLocator_HTTP ResourceLocator_Schema = 1 - ResourceLocator_FILE ResourceLocator_Schema = 2 + ResourceLocator_UDPA ResourceLocator_Scheme = 0 + ResourceLocator_HTTP ResourceLocator_Scheme = 1 + ResourceLocator_FILE ResourceLocator_Scheme = 2 ) -var ResourceLocator_Schema_name = map[int32]string{ +var ResourceLocator_Scheme_name = map[int32]string{ 0: "UDPA", 1: "HTTP", 2: "FILE", } -var ResourceLocator_Schema_value = map[string]int32{ +var ResourceLocator_Scheme_value = map[string]int32{ "UDPA": 0, "HTTP": 1, "FILE": 2, } -func (x ResourceLocator_Schema) String() string { - return proto.EnumName(ResourceLocator_Schema_name, int32(x)) +func (x ResourceLocator_Scheme) String() string { + return proto.EnumName(ResourceLocator_Scheme_name, int32(x)) } -func (ResourceLocator_Schema) EnumDescriptor() ([]byte, []int) { +func (ResourceLocator_Scheme) EnumDescriptor() ([]byte, []int) { return fileDescriptor_b10c84cf310f3232, []int{0, 0} } type ResourceLocator struct { - Schema ResourceLocator_Schema `protobuf:"varint,1,opt,name=schema,proto3,enum=udpa.core.v1.ResourceLocator_Schema" json:"schema,omitempty"` + Scheme ResourceLocator_Scheme `protobuf:"varint,1,opt,name=scheme,proto3,enum=udpa.core.v1.ResourceLocator_Scheme" json:"scheme,omitempty"` Id []string `protobuf:"bytes,2,rep,name=id,proto3" json:"id,omitempty"` Authority string `protobuf:"bytes,3,opt,name=authority,proto3" json:"authority,omitempty"` ResourceType string `protobuf:"bytes,4,opt,name=resource_type,json=resourceType,proto3" json:"resource_type,omitempty"` @@ -89,9 +89,9 @@ func (m *ResourceLocator) XXX_DiscardUnknown() { var xxx_messageInfo_ResourceLocator proto.InternalMessageInfo -func (m *ResourceLocator) GetSchema() ResourceLocator_Schema { +func (m *ResourceLocator) GetScheme() ResourceLocator_Scheme { if m != nil { - return m.Schema + return m.Scheme } return ResourceLocator_UDPA } @@ -236,7 +236,7 @@ func (*ResourceLocator_Directive) XXX_OneofWrappers() []interface{} { } func init() { - proto.RegisterEnum("udpa.core.v1.ResourceLocator_Schema", ResourceLocator_Schema_name, ResourceLocator_Schema_value) + proto.RegisterEnum("udpa.core.v1.ResourceLocator_Scheme", ResourceLocator_Scheme_name, ResourceLocator_Scheme_value) proto.RegisterType((*ResourceLocator)(nil), "udpa.core.v1.ResourceLocator") proto.RegisterType((*ResourceLocator_Directive)(nil), "udpa.core.v1.ResourceLocator.Directive") } @@ -258,7 +258,7 @@ var fileDescriptor_b10c84cf310f3232 = []byte{ 0x24, 0x92, 0xf1, 0x24, 0x73, 0x33, 0x49, 0x64, 0x9e, 0x55, 0x70, 0xe7, 0xce, 0xc6, 0xc4, 0x88, 0x27, 0x92, 0x9e, 0xcb, 0x30, 0x25, 0x82, 0x4c, 0x96, 0xc8, 0xee, 0x94, 0x8c, 0x59, 0x4c, 0x24, 0x75, 0x97, 0x45, 0x25, 0xec, 0xff, 0xaa, 0xc3, 0x6b, 0xc1, 0xc2, 0xc3, 0x49, 0x65, 0x01, 0x1d, - 0x43, 0x2d, 0x8b, 0x46, 0x74, 0x42, 0x4c, 0x60, 0x01, 0xfb, 0xaa, 0x77, 0xe0, 0xac, 0xbb, 0x71, + 0x43, 0x2d, 0x8b, 0x46, 0x74, 0x42, 0x4d, 0x60, 0x01, 0xfb, 0xaa, 0x77, 0xe0, 0xac, 0xbb, 0x71, 0x2e, 0xe1, 0xce, 0x9b, 0x92, 0xc5, 0xcd, 0x39, 0x6e, 0x7c, 0x07, 0x8a, 0x01, 0x82, 0x45, 0x37, 0x32, 0xa1, 0xc2, 0x62, 0x53, 0xb1, 0x54, 0x5b, 0x2f, 0xd5, 0x9f, 0x40, 0x69, 0x82, 0x40, 0x61, 0x31, 0xea, 0x42, 0x9d, 0xe4, 0x72, 0xc4, 0x05, 0x93, 0x33, 0x53, 0xb5, 0x80, 0xad, 0x07, 0x17, @@ -276,6 +276,6 @@ var fileDescriptor_b10c84cf310f3232 = []byte{ 0x7e, 0x7d, 0xf2, 0xd2, 0x50, 0xf0, 0x4d, 0xb8, 0xbb, 0x71, 0x33, 0x61, 0x96, 0xd2, 0x88, 0x7d, 0x62, 0x54, 0xe0, 0xe7, 0xbf, 0xbf, 0xfd, 0xf9, 0xab, 0x29, 0x4d, 0x00, 0xbb, 0x11, 0x9f, 0x38, 0x9f, 0x99, 0x1c, 0xe5, 0x67, 0x55, 0x8e, 0xf5, 0x30, 0xf8, 0xfa, 0xa5, 0x34, 0x7e, 0x71, 0x5b, - 0x3e, 0x38, 0xd3, 0xca, 0x23, 0x7b, 0xfc, 0x3f, 0x00, 0x00, 0xff, 0xff, 0xfb, 0x4e, 0xe4, 0x16, + 0x3e, 0x38, 0xd3, 0xca, 0x23, 0x7b, 0xfc, 0x3f, 0x00, 0x00, 0xff, 0xff, 0x7d, 0xa8, 0x3f, 0xc5, 0xf4, 0x02, 0x00, 0x00, } diff --git a/go/udpa/core/v1/resource_locator.pb.validate.go b/go/udpa/core/v1/resource_locator.pb.validate.go index 93f9dc0..28435f7 100644 --- a/go/udpa/core/v1/resource_locator.pb.validate.go +++ b/go/udpa/core/v1/resource_locator.pb.validate.go @@ -44,9 +44,9 @@ func (m *ResourceLocator) Validate() error { return nil } - if _, ok := ResourceLocator_Schema_name[int32(m.GetSchema())]; !ok { + if _, ok := ResourceLocator_Scheme_name[int32(m.GetScheme())]; !ok { return ResourceLocatorValidationError{ - field: "Schema", + field: "Scheme", reason: "value must be one of the defined enum values", } } diff --git a/udpa/core/v1/resource_locator.proto b/udpa/core/v1/resource_locator.proto index aadccee..a3c9031 100644 --- a/udpa/core/v1/resource_locator.proto +++ b/udpa/core/v1/resource_locator.proto @@ -18,27 +18,27 @@ option (udpa.annotations.file_status).work_in_progress = true; // // Resource locators have a canonical udpa:// URI representation: // -// udpa://{authority}/{type_url}/{id/*}?{context_params}{#directive*} +// udpa://{authority}/{type_url}/{id/*}?{context_params}{#directive,*} // // where context_params take the form of URI query parameters. // // Resource locators have a similar canonical http:// URI representation: // -// http://{authority}/{type_url}/{id/*}?{context_params}{#directive*} +// http://{authority}/{type_url}/{id/*}?{context_params}{#directive,*} // // Resource locators also have a simplified file:// URI representation: // -// file:///{id/*}{#directive*} +// file:///{id/*}{#directive,*} // message ResourceLocator { - enum Schema { + enum Scheme { UDPA = 0; HTTP = 1; FILE = 2; } - // URI schema. - Schema schema = 1 [(validate.rules).enum = {defined_only: true}]; + // URI scheme. + Scheme scheme = 1 [(validate.rules).enum = {defined_only: true}]; // Opaque identifiers for the resource. These are effectively concatenated // with ‘/’ to form the non-query param path as resource ID. This may end @@ -66,10 +66,26 @@ message ResourceLocator { } // Directives provide information to data-plane load balancers on how UDPA - // resource names are to be resolved. For example, they may provide - // alternative resource locators for when primary resolution fails. Directives - // are not part of resource names and do not appear in a xDS transport discovery - // request. + // resource names are to be interpreted and potentially further resolved. For + // example, they may provide alternative resource locators for when primary + // resolution fails. Directives are not part of resource names and do not + // appear in a xDS transport discovery request. + // + // When encoding to URIs, directives take the form: + // + // = + // + // For example, we can have alt=udpa://foo/bar or entry=some%20thing. Each + // directive value type may have its own string encoding, in the case of + // ResourceLocator there is a recursive URI encoding. + // + // Percent encoding applies to the URI encoding of the directive value. + // Multiple directives are comma-separated, so the reserved characters that + // require percent encoding in a directive value are [',', '#', '[', ']', + // '%']. These are the RFC3986 fragment reserved characters with the addition + // of the UDPA scheme specific ','. See + // https://tools.ietf.org/html/rfc3986#page-49 for further details on URI ABNF + // and reserved characters. message Directive { oneof directive { option (validate.required) = true; @@ -77,7 +93,7 @@ message ResourceLocator { // An alternative resource locator for fallback if the resource is // unavailable. For example, take the resource locator: // - // udpa://foo/some-type/some-route-table#alt=udpa://bar/some-type/another-route-table. + // udpa://foo/some-type/some-route-table#alt=udpa://bar/some-type/another-route-table // // If the data-plane load balancer is unable to reach `foo` to fetch the // resource, it will fallback to `bar`. Alternative resources do not need @@ -93,5 +109,9 @@ message ResourceLocator { } } + // A list of directives that appear in the UDPA resource locator #fragment. + // + // When encoding to URI form, directives are percent encoded with comma + // separation. repeated Directive directives = 6; }