matchers: add CEL matcher, input (#31)

* matchers: add CEL matcher, input

Signed-off-by: Sergii Tkachenko <sergiitk@google.com>

* Update HttpCelMatchInput per review

- Remove Attributes from HttpCelMatchInput
- Rename to HttpAttributesMatchInput

Signed-off-by: Sergii Tkachenko <sergiitk@google.com>

* Use rst reference instead.

Signed-off-by: Sergii Tkachenko <sergiitk@google.com>

* CelExpression WIP

Signed-off-by: Sergii Tkachenko <sergiitk@google.com>

* HttpAttributesCelMatchInput WIP

Signed-off-by: Sergii Tkachenko <sergiitk@google.com>

* Reset xds/type/matcher/v3/BUILD

Signed-off-by: Sergii Tkachenko <sergiitk@google.com>

* Finish HttpAttributesCelMatchInput - address skip_if_error

Signed-off-by: Sergii Tkachenko <sergiitk@google.com>

* Revert to cel-as-matcher approach

Signed-off-by: Sergii Tkachenko <sergiitk@google.com>

* Fixes per review: CEL matcher name, CelExtractString package

Signed-off-by: Sergii Tkachenko <sergiitk@google.com>

* Build fix, except //test/build:go_build_test

Signed-off-by: Sergii Tkachenko <sergiitk@google.com>

* Address //test/build:go_build_test build error

Signed-off-by: Sergii Tkachenko <sergiitk@google.com>

* Generate protobuf for the new files

Signed-off-by: Sergii Tkachenko <sergiitk@google.com>
pull/36/head
Sergii Tkachenko 3 years ago committed by GitHub
parent 42e9329d8a
commit d35b9e6a88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 45
      bazel/api_build_system.bzl
  2. 44
      bazel/external_proto_deps.bzl
  3. 167
      go/xds/type/matcher/v3/cel.pb.go
  4. 115
      go/xds/type/matcher/v3/cel.pb.validate.go
  5. 151
      go/xds/type/matcher/v3/http_inputs.pb.go
  6. 102
      go/xds/type/matcher/v3/http_inputs.pb.validate.go
  7. 298
      go/xds/type/v3/cel.pb.go
  8. 225
      go/xds/type/v3/cel.pb.validate.go
  9. 38
      xds/type/matcher/v3/cel.proto
  10. 29
      xds/type/matcher/v3/http_inputs.proto
  11. 8
      xds/type/v3/BUILD
  12. 54
      xds/type/v3/cel.proto

@ -3,6 +3,12 @@ load("@com_google_protobuf//:protobuf.bzl", _py_proto_library = "py_proto_librar
load("@io_bazel_rules_go//go:def.bzl", "go_test")
load("@io_bazel_rules_go//proto:def.bzl", "go_grpc_library", "go_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load(
"//bazel:external_proto_deps.bzl",
"EXTERNAL_PROTO_CC_BAZEL_DEP_MAP",
"EXTERNAL_PROTO_GO_BAZEL_DEP_MAP",
"EXTERNAL_PROTO_PY_BAZEL_DEP_MAP",
)
_PY_PROTO_SUFFIX = "_py_proto"
_CC_PROTO_SUFFIX = "_cc_proto"
@ -24,18 +30,21 @@ _COMMON_PROTO_DEPS = [
"@com_envoyproxy_protoc_gen_validate//validate:validate_proto",
]
def _proto_mapping(dep, proto_suffix):
prefix = "@" + Label(dep).workspace_name if not dep.startswith("//") else ""
return prefix + "//" + Label(dep).package + ":" + Label(dep).name + proto_suffix
def _proto_mapping(dep, proto_dep_map, proto_suffix):
mapped = proto_dep_map.get(dep)
if mapped == None:
prefix = "@" + Label(dep).workspace_name if not dep.startswith("//") else ""
return prefix + "//" + Label(dep).package + ":" + Label(dep).name + proto_suffix
return mapped
def _go_proto_mapping(dep):
return _proto_mapping(dep, _GO_PROTO_SUFFIX)
return _proto_mapping(dep, EXTERNAL_PROTO_GO_BAZEL_DEP_MAP, _GO_PROTO_SUFFIX)
def _cc_proto_mapping(dep):
return _proto_mapping(dep, _CC_PROTO_SUFFIX)
return _proto_mapping(dep, EXTERNAL_PROTO_CC_BAZEL_DEP_MAP, _CC_PROTO_SUFFIX)
def _py_proto_mapping(dep):
return _proto_mapping(dep, _PY_PROTO_SUFFIX)
return _proto_mapping(dep, EXTERNAL_PROTO_PY_BAZEL_DEP_MAP, _PY_PROTO_SUFFIX)
# TODO(htuch): Convert this to native py_proto_library once
# https://github.com/bazelbuild/bazel/issues/3935 and/or
@ -58,7 +67,7 @@ def _xds_py_proto_library(name, srcs = [], deps = []):
# This defines googleapis py_proto_library. The repository does not provide its definition and requires
# overriding it in the consuming project (see https://github.com/grpc/grpc/issues/19255 for more details).
def py_proto_library(name, deps = []):
def py_proto_library(name, deps = [], plugin = None):
srcs = [dep[:-6] + ".proto" if dep.endswith("_proto") else dep for dep in deps]
proto_deps = []
@ -67,6 +76,14 @@ def py_proto_library(name, deps = []):
# As a workaround, manually specify the proto dependencies for the imported python rules.
if name == "annotations_py_proto":
proto_deps = proto_deps + [":http_py_proto"]
# checked.proto depends on syntax.proto, we have to add this dependency manually as well.
if name == "checked_py_proto":
proto_deps = proto_deps + [":syntax_py_proto"]
# py_proto_library does not support plugin as an argument yet at gRPC v1.25.0:
# https://github.com/grpc/grpc/blob/v1.25.0/bazel/python_rules.bzl#L72.
# plugin should also be passed in here when gRPC version is greater than v1.25.x.
_py_proto_library(
name = name,
srcs = srcs,
@ -110,7 +127,12 @@ def _xds_cc_py_proto_library(
# TODO: neither C++ or Python service generation is supported today, follow the Envoy example to implementthis.
pass
def xds_proto_package(srcs = [], deps = [], has_services = False, visibility = ["//visibility:public"]):
def xds_proto_package(
name = "pkg",
srcs = [],
deps = [],
has_services = False,
visibility = ["//visibility:public"]):
if srcs == []:
srcs = native.glob(["*.proto"])
@ -127,13 +149,16 @@ def xds_proto_package(srcs = [], deps = [], has_services = False, visibility = [
if has_services:
compilers = ["@io_bazel_rules_go//proto:go_grpc", "//bazel:pgv_plugin_go"]
# Because RBAC proro depends on googleapis syntax.proto and checked.proto,
# which share the same go proto library, it causes duplicative dependencies.
# Thus, we use depset().to_list() to remove duplicated depenencies.
go_proto_library(
name = name + _GO_PROTO_SUFFIX,
compilers = compilers,
importpath = _GO_IMPORTPATH_PREFIX + native.package_name(),
proto = name,
visibility = ["//visibility:public"],
deps = [_go_proto_mapping(dep) for dep in deps] + [
deps = depset([_go_proto_mapping(dep) for dep in deps] + [
"@com_envoyproxy_protoc_gen_validate//validate:go_default_library",
"@com_github_golang_protobuf//ptypes:go_default_library_gen",
"@go_googleapis//google/api:annotations_go_proto",
@ -143,7 +168,7 @@ def xds_proto_package(srcs = [], deps = [], has_services = False, visibility = [
"@io_bazel_rules_go//proto/wkt:struct_go_proto",
"@io_bazel_rules_go//proto/wkt:timestamp_go_proto",
"@io_bazel_rules_go//proto/wkt:wrappers_go_proto",
],
]).to_list(),
)
def xds_cc_test(name, **kwargs):

@ -0,0 +1,44 @@
# Any external dependency imported in the xds/ .protos requires entries in
# the maps below, to allow the Bazel proto and language specific bindings to be
# inferred from the import directives.
#
# This file needs to be interpreted as both Python 3 and Starlark, so only the
# common subset of Python should be used.
# This maps from .proto import directive path to the Bazel dependency path for
# external dependencies. Since BUILD files are generated, this is the canonical
# place to define this mapping.
EXTERNAL_PROTO_IMPORT_BAZEL_DEP_MAP = {
"google/api/expr/v1alpha1/checked.proto": "@com_google_googleapis//google/api/expr/v1alpha1:checked_proto",
"google/api/expr/v1alpha1/syntax.proto": "@com_google_googleapis//google/api/expr/v1alpha1:syntax_proto",
}
# This maps from the Bazel proto_library target to the Go language binding target for external dependencies.
EXTERNAL_PROTO_GO_BAZEL_DEP_MAP = {
# Note @com_google_googleapis are point to @go_googleapis.
# This is done to address //test/build:go_build_test build error:
#
# link: package conflict error:
# google.golang.org/genproto/googleapis/api/annotations: multiple copies of package passed to linker:
#
# @go_googleapis//google/api:annotations_go_proto
# @com_google_googleapis//google/api:annotations_go_proto
#
# TODO(https://github.com/bazelbuild/rules_go/issues/1986): update to
# @com_google_googleapis when the bug is resolved. Also see the note to
# go_googleapis in https://github.com/bazelbuild/rules_go/blob/master/go/dependencies.rst#overriding-dependencies
"@com_google_googleapis//google/api/expr/v1alpha1:checked_proto": "@go_googleapis//google/api/expr/v1alpha1:expr_go_proto",
"@com_google_googleapis//google/api/expr/v1alpha1:syntax_proto": "@go_googleapis//google/api/expr/v1alpha1:expr_go_proto",
}
# This maps from the Bazel proto_library target to the C++ language binding target for external dependencies.
EXTERNAL_PROTO_CC_BAZEL_DEP_MAP = {
"@com_google_googleapis//google/api/expr/v1alpha1:checked_proto": "@com_google_googleapis//google/api/expr/v1alpha1:checked_cc_proto",
"@com_google_googleapis//google/api/expr/v1alpha1:syntax_proto": "@com_google_googleapis//google/api/expr/v1alpha1:syntax_cc_proto",
}
# This maps from the Bazel proto_library target to the Python language binding target for external dependencies.
EXTERNAL_PROTO_PY_BAZEL_DEP_MAP = {
"@com_google_googleapis//google/api/expr/v1alpha1:checked_proto": "@com_google_googleapis//google/api/expr/v1alpha1:checked_py_proto",
"@com_google_googleapis//google/api/expr/v1alpha1:syntax_proto": "@com_google_googleapis//google/api/expr/v1alpha1:syntax_py_proto",
}

@ -0,0 +1,167 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.18.0
// source: xds/type/matcher/v3/cel.proto
package v3
import (
_ "github.com/cncf/xds/go/xds/annotations/v3"
v3 "github.com/cncf/xds/go/xds/type/v3"
_ "github.com/envoyproxy/protoc-gen-validate/validate"
proto "github.com/golang/protobuf/proto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type CelMatcher struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ExprMatch *v3.CelExpression `protobuf:"bytes,1,opt,name=expr_match,json=exprMatch,proto3" json:"expr_match,omitempty"`
}
func (x *CelMatcher) Reset() {
*x = CelMatcher{}
if protoimpl.UnsafeEnabled {
mi := &file_xds_type_matcher_v3_cel_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CelMatcher) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CelMatcher) ProtoMessage() {}
func (x *CelMatcher) ProtoReflect() protoreflect.Message {
mi := &file_xds_type_matcher_v3_cel_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CelMatcher.ProtoReflect.Descriptor instead.
func (*CelMatcher) Descriptor() ([]byte, []int) {
return file_xds_type_matcher_v3_cel_proto_rawDescGZIP(), []int{0}
}
func (x *CelMatcher) GetExprMatch() *v3.CelExpression {
if x != nil {
return x.ExprMatch
}
return nil
}
var File_xds_type_matcher_v3_cel_proto protoreflect.FileDescriptor
var file_xds_type_matcher_v3_cel_proto_rawDesc = []byte{
0x0a, 0x1d, 0x78, 0x64, 0x73, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x2f, 0x6d, 0x61, 0x74, 0x63, 0x68,
0x65, 0x72, 0x2f, 0x76, 0x33, 0x2f, 0x63, 0x65, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
0x13, 0x78, 0x64, 0x73, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65,
0x72, 0x2e, 0x76, 0x33, 0x1a, 0x1f, 0x78, 0x64, 0x73, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x76, 0x33, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x15, 0x78, 0x64, 0x73, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x2f,
0x76, 0x33, 0x2f, 0x63, 0x65, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 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, 0x51, 0x0a, 0x0a, 0x43, 0x65, 0x6c, 0x4d, 0x61, 0x74, 0x63,
0x68, 0x65, 0x72, 0x12, 0x43, 0x0a, 0x0a, 0x65, 0x78, 0x70, 0x72, 0x5f, 0x6d, 0x61, 0x74, 0x63,
0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x78, 0x64, 0x73, 0x2e, 0x74, 0x79,
0x70, 0x65, 0x2e, 0x76, 0x33, 0x2e, 0x43, 0x65, 0x6c, 0x45, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73,
0x69, 0x6f, 0x6e, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x09, 0x65,
0x78, 0x70, 0x72, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x42, 0x60, 0x0a, 0x1e, 0x63, 0x6f, 0x6d, 0x2e,
0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x78, 0x64, 0x73, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x2e,
0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x42, 0x08, 0x43, 0x65, 0x6c, 0x50,
0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63,
0x6f, 0x6d, 0x2f, 0x63, 0x6e, 0x63, 0x66, 0x2f, 0x78, 0x64, 0x73, 0x2f, 0x67, 0x6f, 0x2f, 0x78,
0x64, 0x73, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x2f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x2f,
0x76, 0x33, 0xd2, 0xc6, 0xa4, 0xe1, 0x06, 0x02, 0x08, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
}
var (
file_xds_type_matcher_v3_cel_proto_rawDescOnce sync.Once
file_xds_type_matcher_v3_cel_proto_rawDescData = file_xds_type_matcher_v3_cel_proto_rawDesc
)
func file_xds_type_matcher_v3_cel_proto_rawDescGZIP() []byte {
file_xds_type_matcher_v3_cel_proto_rawDescOnce.Do(func() {
file_xds_type_matcher_v3_cel_proto_rawDescData = protoimpl.X.CompressGZIP(file_xds_type_matcher_v3_cel_proto_rawDescData)
})
return file_xds_type_matcher_v3_cel_proto_rawDescData
}
var file_xds_type_matcher_v3_cel_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_xds_type_matcher_v3_cel_proto_goTypes = []interface{}{
(*CelMatcher)(nil), // 0: xds.type.matcher.v3.CelMatcher
(*v3.CelExpression)(nil), // 1: xds.type.v3.CelExpression
}
var file_xds_type_matcher_v3_cel_proto_depIdxs = []int32{
1, // 0: xds.type.matcher.v3.CelMatcher.expr_match:type_name -> xds.type.v3.CelExpression
1, // [1:1] is the sub-list for method output_type
1, // [1:1] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_xds_type_matcher_v3_cel_proto_init() }
func file_xds_type_matcher_v3_cel_proto_init() {
if File_xds_type_matcher_v3_cel_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_xds_type_matcher_v3_cel_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CelMatcher); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_xds_type_matcher_v3_cel_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_xds_type_matcher_v3_cel_proto_goTypes,
DependencyIndexes: file_xds_type_matcher_v3_cel_proto_depIdxs,
MessageInfos: file_xds_type_matcher_v3_cel_proto_msgTypes,
}.Build()
File_xds_type_matcher_v3_cel_proto = out.File
file_xds_type_matcher_v3_cel_proto_rawDesc = nil
file_xds_type_matcher_v3_cel_proto_goTypes = nil
file_xds_type_matcher_v3_cel_proto_depIdxs = nil
}

@ -0,0 +1,115 @@
// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: xds/type/matcher/v3/cel.proto
package v3
import (
"bytes"
"errors"
"fmt"
"net"
"net/mail"
"net/url"
"regexp"
"strings"
"time"
"unicode/utf8"
"google.golang.org/protobuf/types/known/anypb"
)
// 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)
_ = anypb.Any{}
)
// Validate checks the field values on CelMatcher with the rules defined in the
// proto definition for this message. If any rules are violated, an error is returned.
func (m *CelMatcher) Validate() error {
if m == nil {
return nil
}
if m.GetExprMatch() == nil {
return CelMatcherValidationError{
field: "ExprMatch",
reason: "value is required",
}
}
if v, ok := interface{}(m.GetExprMatch()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CelMatcherValidationError{
field: "ExprMatch",
reason: "embedded message failed validation",
cause: err,
}
}
}
return nil
}
// CelMatcherValidationError is the validation error returned by
// CelMatcher.Validate if the designated constraints aren't met.
type CelMatcherValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e CelMatcherValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e CelMatcherValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e CelMatcherValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e CelMatcherValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e CelMatcherValidationError) ErrorName() string { return "CelMatcherValidationError" }
// Error satisfies the builtin error interface
func (e CelMatcherValidationError) 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 %sCelMatcher.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = CelMatcherValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = CelMatcherValidationError{}

@ -0,0 +1,151 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.18.0
// source: xds/type/matcher/v3/http_inputs.proto
package v3
import (
_ "github.com/cncf/xds/go/xds/annotations/v3"
_ "github.com/envoyproxy/protoc-gen-validate/validate"
proto "github.com/golang/protobuf/proto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type HttpAttributesCelMatchInput struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *HttpAttributesCelMatchInput) Reset() {
*x = HttpAttributesCelMatchInput{}
if protoimpl.UnsafeEnabled {
mi := &file_xds_type_matcher_v3_http_inputs_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *HttpAttributesCelMatchInput) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*HttpAttributesCelMatchInput) ProtoMessage() {}
func (x *HttpAttributesCelMatchInput) ProtoReflect() protoreflect.Message {
mi := &file_xds_type_matcher_v3_http_inputs_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use HttpAttributesCelMatchInput.ProtoReflect.Descriptor instead.
func (*HttpAttributesCelMatchInput) Descriptor() ([]byte, []int) {
return file_xds_type_matcher_v3_http_inputs_proto_rawDescGZIP(), []int{0}
}
var File_xds_type_matcher_v3_http_inputs_proto protoreflect.FileDescriptor
var file_xds_type_matcher_v3_http_inputs_proto_rawDesc = []byte{
0x0a, 0x25, 0x78, 0x64, 0x73, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x2f, 0x6d, 0x61, 0x74, 0x63, 0x68,
0x65, 0x72, 0x2f, 0x76, 0x33, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x5f, 0x69, 0x6e, 0x70, 0x75, 0x74,
0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x13, 0x78, 0x64, 0x73, 0x2e, 0x74, 0x79, 0x70,
0x65, 0x2e, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x1a, 0x1f, 0x78, 0x64,
0x73, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x76, 0x33,
0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 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, 0x1d, 0x0a, 0x1b, 0x48, 0x74, 0x74, 0x70, 0x41, 0x74,
0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x43, 0x65, 0x6c, 0x4d, 0x61, 0x74, 0x63, 0x68,
0x49, 0x6e, 0x70, 0x75, 0x74, 0x42, 0x67, 0x0a, 0x1e, 0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x69, 0x74,
0x68, 0x75, 0x62, 0x2e, 0x78, 0x64, 0x73, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x6d, 0x61, 0x74,
0x63, 0x68, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x42, 0x0f, 0x48, 0x74, 0x74, 0x70, 0x49, 0x6e, 0x70,
0x75, 0x74, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2a, 0x67, 0x69, 0x74, 0x68,
0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6e, 0x63, 0x66, 0x2f, 0x78, 0x64, 0x73, 0x2f,
0x67, 0x6f, 0x2f, 0x78, 0x64, 0x73, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x2f, 0x6d, 0x61, 0x74, 0x63,
0x68, 0x65, 0x72, 0x2f, 0x76, 0x33, 0xd2, 0xc6, 0xa4, 0xe1, 0x06, 0x02, 0x08, 0x01, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_xds_type_matcher_v3_http_inputs_proto_rawDescOnce sync.Once
file_xds_type_matcher_v3_http_inputs_proto_rawDescData = file_xds_type_matcher_v3_http_inputs_proto_rawDesc
)
func file_xds_type_matcher_v3_http_inputs_proto_rawDescGZIP() []byte {
file_xds_type_matcher_v3_http_inputs_proto_rawDescOnce.Do(func() {
file_xds_type_matcher_v3_http_inputs_proto_rawDescData = protoimpl.X.CompressGZIP(file_xds_type_matcher_v3_http_inputs_proto_rawDescData)
})
return file_xds_type_matcher_v3_http_inputs_proto_rawDescData
}
var file_xds_type_matcher_v3_http_inputs_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_xds_type_matcher_v3_http_inputs_proto_goTypes = []interface{}{
(*HttpAttributesCelMatchInput)(nil), // 0: xds.type.matcher.v3.HttpAttributesCelMatchInput
}
var file_xds_type_matcher_v3_http_inputs_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_xds_type_matcher_v3_http_inputs_proto_init() }
func file_xds_type_matcher_v3_http_inputs_proto_init() {
if File_xds_type_matcher_v3_http_inputs_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_xds_type_matcher_v3_http_inputs_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*HttpAttributesCelMatchInput); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_xds_type_matcher_v3_http_inputs_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_xds_type_matcher_v3_http_inputs_proto_goTypes,
DependencyIndexes: file_xds_type_matcher_v3_http_inputs_proto_depIdxs,
MessageInfos: file_xds_type_matcher_v3_http_inputs_proto_msgTypes,
}.Build()
File_xds_type_matcher_v3_http_inputs_proto = out.File
file_xds_type_matcher_v3_http_inputs_proto_rawDesc = nil
file_xds_type_matcher_v3_http_inputs_proto_goTypes = nil
file_xds_type_matcher_v3_http_inputs_proto_depIdxs = nil
}

@ -0,0 +1,102 @@
// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: xds/type/matcher/v3/http_inputs.proto
package v3
import (
"bytes"
"errors"
"fmt"
"net"
"net/mail"
"net/url"
"regexp"
"strings"
"time"
"unicode/utf8"
"google.golang.org/protobuf/types/known/anypb"
)
// 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)
_ = anypb.Any{}
)
// Validate checks the field values on HttpAttributesCelMatchInput with the
// rules defined in the proto definition for this message. If any rules are
// violated, an error is returned.
func (m *HttpAttributesCelMatchInput) Validate() error {
if m == nil {
return nil
}
return nil
}
// HttpAttributesCelMatchInputValidationError is the validation error returned
// by HttpAttributesCelMatchInput.Validate if the designated constraints
// aren't met.
type HttpAttributesCelMatchInputValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e HttpAttributesCelMatchInputValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e HttpAttributesCelMatchInputValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e HttpAttributesCelMatchInputValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e HttpAttributesCelMatchInputValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e HttpAttributesCelMatchInputValidationError) ErrorName() string {
return "HttpAttributesCelMatchInputValidationError"
}
// Error satisfies the builtin error interface
func (e HttpAttributesCelMatchInputValidationError) 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 %sHttpAttributesCelMatchInput.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = HttpAttributesCelMatchInputValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = HttpAttributesCelMatchInputValidationError{}

@ -0,0 +1,298 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.18.0
// source: xds/type/v3/cel.proto
package v3
import (
_ "github.com/cncf/xds/go/xds/annotations/v3"
_ "github.com/envoyproxy/protoc-gen-validate/validate"
proto "github.com/golang/protobuf/proto"
wrappers "github.com/golang/protobuf/ptypes/wrappers"
v1alpha1 "google.golang.org/genproto/googleapis/api/expr/v1alpha1"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type CelExpression struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Types that are assignable to ExprSpecifier:
// *CelExpression_ParsedExpr
// *CelExpression_CheckedExpr
ExprSpecifier isCelExpression_ExprSpecifier `protobuf_oneof:"expr_specifier"`
}
func (x *CelExpression) Reset() {
*x = CelExpression{}
if protoimpl.UnsafeEnabled {
mi := &file_xds_type_v3_cel_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CelExpression) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CelExpression) ProtoMessage() {}
func (x *CelExpression) ProtoReflect() protoreflect.Message {
mi := &file_xds_type_v3_cel_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CelExpression.ProtoReflect.Descriptor instead.
func (*CelExpression) Descriptor() ([]byte, []int) {
return file_xds_type_v3_cel_proto_rawDescGZIP(), []int{0}
}
func (m *CelExpression) GetExprSpecifier() isCelExpression_ExprSpecifier {
if m != nil {
return m.ExprSpecifier
}
return nil
}
func (x *CelExpression) GetParsedExpr() *v1alpha1.ParsedExpr {
if x, ok := x.GetExprSpecifier().(*CelExpression_ParsedExpr); ok {
return x.ParsedExpr
}
return nil
}
func (x *CelExpression) GetCheckedExpr() *v1alpha1.CheckedExpr {
if x, ok := x.GetExprSpecifier().(*CelExpression_CheckedExpr); ok {
return x.CheckedExpr
}
return nil
}
type isCelExpression_ExprSpecifier interface {
isCelExpression_ExprSpecifier()
}
type CelExpression_ParsedExpr struct {
ParsedExpr *v1alpha1.ParsedExpr `protobuf:"bytes,1,opt,name=parsed_expr,json=parsedExpr,proto3,oneof"`
}
type CelExpression_CheckedExpr struct {
CheckedExpr *v1alpha1.CheckedExpr `protobuf:"bytes,2,opt,name=checked_expr,json=checkedExpr,proto3,oneof"`
}
func (*CelExpression_ParsedExpr) isCelExpression_ExprSpecifier() {}
func (*CelExpression_CheckedExpr) isCelExpression_ExprSpecifier() {}
type CelExtractString struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ExprExtract *CelExpression `protobuf:"bytes,1,opt,name=expr_extract,json=exprExtract,proto3" json:"expr_extract,omitempty"`
DefaultValue *wrappers.StringValue `protobuf:"bytes,2,opt,name=default_value,json=defaultValue,proto3" json:"default_value,omitempty"`
}
func (x *CelExtractString) Reset() {
*x = CelExtractString{}
if protoimpl.UnsafeEnabled {
mi := &file_xds_type_v3_cel_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CelExtractString) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CelExtractString) ProtoMessage() {}
func (x *CelExtractString) ProtoReflect() protoreflect.Message {
mi := &file_xds_type_v3_cel_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CelExtractString.ProtoReflect.Descriptor instead.
func (*CelExtractString) Descriptor() ([]byte, []int) {
return file_xds_type_v3_cel_proto_rawDescGZIP(), []int{1}
}
func (x *CelExtractString) GetExprExtract() *CelExpression {
if x != nil {
return x.ExprExtract
}
return nil
}
func (x *CelExtractString) GetDefaultValue() *wrappers.StringValue {
if x != nil {
return x.DefaultValue
}
return nil
}
var File_xds_type_v3_cel_proto protoreflect.FileDescriptor
var file_xds_type_v3_cel_proto_rawDesc = []byte{
0x0a, 0x15, 0x78, 0x64, 0x73, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x2f, 0x76, 0x33, 0x2f, 0x63, 0x65,
0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x78, 0x64, 0x73, 0x2e, 0x74, 0x79, 0x70,
0x65, 0x2e, 0x76, 0x33, 0x1a, 0x26, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69,
0x2f, 0x65, 0x78, 0x70, 0x72, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x63,
0x68, 0x65, 0x63, 0x6b, 0x65, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x25, 0x67, 0x6f,
0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x65, 0x78, 0x70, 0x72, 0x2f, 0x76, 0x31,
0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x73, 0x79, 0x6e, 0x74, 0x61, 0x78, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x78, 0x64, 0x73, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x76, 0x33, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 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, 0xbb, 0x01,
0x0a, 0x0d, 0x43, 0x65, 0x6c, 0x45, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12,
0x47, 0x0a, 0x0b, 0x70, 0x61, 0x72, 0x73, 0x65, 0x64, 0x5f, 0x65, 0x78, 0x70, 0x72, 0x18, 0x01,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x61, 0x70,
0x69, 0x2e, 0x65, 0x78, 0x70, 0x72, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e,
0x50, 0x61, 0x72, 0x73, 0x65, 0x64, 0x45, 0x78, 0x70, 0x72, 0x48, 0x00, 0x52, 0x0a, 0x70, 0x61,
0x72, 0x73, 0x65, 0x64, 0x45, 0x78, 0x70, 0x72, 0x12, 0x4a, 0x0a, 0x0c, 0x63, 0x68, 0x65, 0x63,
0x6b, 0x65, 0x64, 0x5f, 0x65, 0x78, 0x70, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25,
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x65, 0x78, 0x70, 0x72,
0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x65,
0x64, 0x45, 0x78, 0x70, 0x72, 0x48, 0x00, 0x52, 0x0b, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x64,
0x45, 0x78, 0x70, 0x72, 0x42, 0x15, 0x0a, 0x0e, 0x65, 0x78, 0x70, 0x72, 0x5f, 0x73, 0x70, 0x65,
0x63, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x03, 0xf8, 0x42, 0x01, 0x22, 0x9e, 0x01, 0x0a, 0x10,
0x43, 0x65, 0x6c, 0x45, 0x78, 0x74, 0x72, 0x61, 0x63, 0x74, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67,
0x12, 0x47, 0x0a, 0x0c, 0x65, 0x78, 0x70, 0x72, 0x5f, 0x65, 0x78, 0x74, 0x72, 0x61, 0x63, 0x74,
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x78, 0x64, 0x73, 0x2e, 0x74, 0x79, 0x70,
0x65, 0x2e, 0x76, 0x33, 0x2e, 0x43, 0x65, 0x6c, 0x45, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69,
0x6f, 0x6e, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x0b, 0x65, 0x78,
0x70, 0x72, 0x45, 0x78, 0x74, 0x72, 0x61, 0x63, 0x74, 0x12, 0x41, 0x0a, 0x0d, 0x64, 0x65, 0x66,
0x61, 0x75, 0x6c, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0c,
0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x50, 0x0a, 0x16,
0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x78, 0x64, 0x73, 0x2e, 0x74,
0x79, 0x70, 0x65, 0x2e, 0x76, 0x33, 0x42, 0x08, 0x43, 0x65, 0x6c, 0x50, 0x72, 0x6f, 0x74, 0x6f,
0x50, 0x01, 0x5a, 0x22, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63,
0x6e, 0x63, 0x66, 0x2f, 0x78, 0x64, 0x73, 0x2f, 0x67, 0x6f, 0x2f, 0x78, 0x64, 0x73, 0x2f, 0x74,
0x79, 0x70, 0x65, 0x2f, 0x76, 0x33, 0xd2, 0xc6, 0xa4, 0xe1, 0x06, 0x02, 0x08, 0x01, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_xds_type_v3_cel_proto_rawDescOnce sync.Once
file_xds_type_v3_cel_proto_rawDescData = file_xds_type_v3_cel_proto_rawDesc
)
func file_xds_type_v3_cel_proto_rawDescGZIP() []byte {
file_xds_type_v3_cel_proto_rawDescOnce.Do(func() {
file_xds_type_v3_cel_proto_rawDescData = protoimpl.X.CompressGZIP(file_xds_type_v3_cel_proto_rawDescData)
})
return file_xds_type_v3_cel_proto_rawDescData
}
var file_xds_type_v3_cel_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_xds_type_v3_cel_proto_goTypes = []interface{}{
(*CelExpression)(nil), // 0: xds.type.v3.CelExpression
(*CelExtractString)(nil), // 1: xds.type.v3.CelExtractString
(*v1alpha1.ParsedExpr)(nil), // 2: google.api.expr.v1alpha1.ParsedExpr
(*v1alpha1.CheckedExpr)(nil), // 3: google.api.expr.v1alpha1.CheckedExpr
(*wrappers.StringValue)(nil), // 4: google.protobuf.StringValue
}
var file_xds_type_v3_cel_proto_depIdxs = []int32{
2, // 0: xds.type.v3.CelExpression.parsed_expr:type_name -> google.api.expr.v1alpha1.ParsedExpr
3, // 1: xds.type.v3.CelExpression.checked_expr:type_name -> google.api.expr.v1alpha1.CheckedExpr
0, // 2: xds.type.v3.CelExtractString.expr_extract:type_name -> xds.type.v3.CelExpression
4, // 3: xds.type.v3.CelExtractString.default_value:type_name -> google.protobuf.StringValue
4, // [4:4] is the sub-list for method output_type
4, // [4:4] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
}
func init() { file_xds_type_v3_cel_proto_init() }
func file_xds_type_v3_cel_proto_init() {
if File_xds_type_v3_cel_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_xds_type_v3_cel_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CelExpression); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_xds_type_v3_cel_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CelExtractString); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
file_xds_type_v3_cel_proto_msgTypes[0].OneofWrappers = []interface{}{
(*CelExpression_ParsedExpr)(nil),
(*CelExpression_CheckedExpr)(nil),
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_xds_type_v3_cel_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_xds_type_v3_cel_proto_goTypes,
DependencyIndexes: file_xds_type_v3_cel_proto_depIdxs,
MessageInfos: file_xds_type_v3_cel_proto_msgTypes,
}.Build()
File_xds_type_v3_cel_proto = out.File
file_xds_type_v3_cel_proto_rawDesc = nil
file_xds_type_v3_cel_proto_goTypes = nil
file_xds_type_v3_cel_proto_depIdxs = nil
}

@ -0,0 +1,225 @@
// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: xds/type/v3/cel.proto
package v3
import (
"bytes"
"errors"
"fmt"
"net"
"net/mail"
"net/url"
"regexp"
"strings"
"time"
"unicode/utf8"
"google.golang.org/protobuf/types/known/anypb"
)
// 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)
_ = anypb.Any{}
)
// Validate checks the field values on CelExpression with the rules defined in
// the proto definition for this message. If any rules are violated, an error
// is returned.
func (m *CelExpression) Validate() error {
if m == nil {
return nil
}
switch m.ExprSpecifier.(type) {
case *CelExpression_ParsedExpr:
if v, ok := interface{}(m.GetParsedExpr()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CelExpressionValidationError{
field: "ParsedExpr",
reason: "embedded message failed validation",
cause: err,
}
}
}
case *CelExpression_CheckedExpr:
if v, ok := interface{}(m.GetCheckedExpr()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CelExpressionValidationError{
field: "CheckedExpr",
reason: "embedded message failed validation",
cause: err,
}
}
}
default:
return CelExpressionValidationError{
field: "ExprSpecifier",
reason: "value is required",
}
}
return nil
}
// CelExpressionValidationError is the validation error returned by
// CelExpression.Validate if the designated constraints aren't met.
type CelExpressionValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e CelExpressionValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e CelExpressionValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e CelExpressionValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e CelExpressionValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e CelExpressionValidationError) ErrorName() string { return "CelExpressionValidationError" }
// Error satisfies the builtin error interface
func (e CelExpressionValidationError) 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 %sCelExpression.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = CelExpressionValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = CelExpressionValidationError{}
// Validate checks the field values on CelExtractString with the rules defined
// in the proto definition for this message. If any rules are violated, an
// error is returned.
func (m *CelExtractString) Validate() error {
if m == nil {
return nil
}
if m.GetExprExtract() == nil {
return CelExtractStringValidationError{
field: "ExprExtract",
reason: "value is required",
}
}
if v, ok := interface{}(m.GetExprExtract()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CelExtractStringValidationError{
field: "ExprExtract",
reason: "embedded message failed validation",
cause: err,
}
}
}
if v, ok := interface{}(m.GetDefaultValue()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return CelExtractStringValidationError{
field: "DefaultValue",
reason: "embedded message failed validation",
cause: err,
}
}
}
return nil
}
// CelExtractStringValidationError is the validation error returned by
// CelExtractString.Validate if the designated constraints aren't met.
type CelExtractStringValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e CelExtractStringValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e CelExtractStringValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e CelExtractStringValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e CelExtractStringValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e CelExtractStringValidationError) ErrorName() string { return "CelExtractStringValidationError" }
// Error satisfies the builtin error interface
func (e CelExtractStringValidationError) 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 %sCelExtractString.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = CelExtractStringValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = CelExtractStringValidationError{}

@ -0,0 +1,38 @@
syntax = "proto3";
package xds.type.matcher.v3;
import "xds/annotations/v3/status.proto";
import "xds/type/v3/cel.proto";
import "validate/validate.proto";
option java_package = "com.github.xds.type.matcher.v3";
option java_outer_classname = "CelProto";
option java_multiple_files = true;
option go_package = "github.com/cncf/xds/go/xds/type/matcher/v3";
option (xds.annotations.v3.file_status).work_in_progress = true;
// [#protodoc-title: Common Expression Language (CEL) matchers]
// Performs a match by evaluating a `Common Expression Language
// <https://github.com/google/cel-spec>`_ (CEL) expression against the standardized set of
// :ref:`HTTP attributes <arch_overview_attributes>` specified via ``HttpAttributesCelMatchInput``.
//
// .. attention::
//
// The match is ``true``, iff the result of the evaluation is a bool AND true.
// In all other cases, the match is ``false``, including but not limited to: non-bool types,
// ``false``, ``null``,`` int(1)``, etc.
// In case CEL expression raises an error, the result of the evaluation is interpreted "no match".
//
// Refer to :ref:`Unified Matcher API <envoy_v3_api_msg_.xds.type.matcher.v3.Matcher>` documentation
// for usage details.
//
// [#comment:TODO(sergiitk): Link HttpAttributesMatchInput + usage example.]
// [#comment:TODO(sergiitk): Add extension category.]
message CelMatcher {
// Either parsed or checked representation of the CEL program.
type.v3.CelExpression expr_match = 1 [(validate.rules).message = {required: true}];
}

@ -0,0 +1,29 @@
syntax = "proto3";
package xds.type.matcher.v3;
import "xds/annotations/v3/status.proto";
import "validate/validate.proto";
option java_package = "com.github.xds.type.matcher.v3";
option java_outer_classname = "HttpInputsProto";
option java_multiple_files = true;
option go_package = "github.com/cncf/xds/go/xds/type/matcher/v3";
option (xds.annotations.v3.file_status).work_in_progress = true;
// [#protodoc-title: Common HTTP Inputs]
// Specifies that matching should be performed on the set of :ref:`HTTP attributes
// <arch_overview_attributes>`.
//
// The attributes will be exposed via `Common Expression Language
// <https://github.com/google/cel-spec>`_ runtime to associated CEL matcher.
//
// Refer to :ref:`Unified Matcher API <envoy_v3_api_msg_.xds.type.matcher.v3.Matcher>` documentation
// for usage details.
//
// [#extension: envoy.matching.inputs.http_attributes]
message HttpAttributesCelMatchInput {
}

@ -2,4 +2,10 @@ load("//bazel:api_build_system.bzl", "xds_proto_package")
licenses(["notice"]) # Apache 2
xds_proto_package()
xds_proto_package(
deps = [
"//xds/annotations/v3:pkg",
"@com_google_googleapis//google/api/expr/v1alpha1:checked_proto",
"@com_google_googleapis//google/api/expr/v1alpha1:syntax_proto",
],
)

@ -0,0 +1,54 @@
syntax = "proto3";
package xds.type.v3;
import "google/api/expr/v1alpha1/checked.proto";
import "google/api/expr/v1alpha1/syntax.proto";
import "google/protobuf/wrappers.proto";
import "xds/annotations/v3/status.proto";
import "validate/validate.proto";
option java_package = "com.github.xds.type.v3";
option java_outer_classname = "CelProto";
option java_multiple_files = true;
option go_package = "github.com/cncf/xds/go/xds/type/v3";
option (xds.annotations.v3.file_status).work_in_progress = true;
// [#protodoc-title: Common Expression Language (CEL)]
// Either parsed or checked representation of the `Common Expression Language
// <https://github.com/google/cel-spec>`_ (CEL) program.
message CelExpression {
oneof expr_specifier {
option (validate.required) = true;
// Parsed expression in abstract syntax tree (AST) form.
google.api.expr.v1alpha1.ParsedExpr parsed_expr = 1;
// Parsed expression in abstract syntax tree (AST) form that has been successfully type checked.
google.api.expr.v1alpha1.CheckedExpr checked_expr = 2;
}
}
// Extracts a string by evaluating a `Common Expression Language
// <https://github.com/google/cel-spec>`_ (CEL) expression against the standardized set of
// :ref:`HTTP attributes <arch_overview_attributes>`.
//
// .. attention::
//
// Besides CEL evaluation raising an error explicitly, CEL program returning a type other than
// the ``string``, or not returning anything, are considered an error as well.
//
// [#comment:TODO(sergiitk): Add extension category.]
message CelExtractString {
// The CEL expression used to extract a string from the CEL environment.
// the "subject string") that should be replaced.
CelExpression expr_extract = 1 [(validate.rules).message = {required: true}];
// If CEL expression evaluates to an error, this value is be returned to the caller.
// If not set, the error is propagated to the caller.
google.protobuf.StringValue default_value = 2;
}
Loading…
Cancel
Save