func CELMatcherImpl(macroName, funcName string, matcherDataTypes []*exprpb.Type, fac CELMatcherFactory) (cel.Library, error) {
	requestType := decls.NewObjectType("http.Request")
	var macro parser.Macro
	switch len(matcherDataTypes) {
	case 1:
		matcherDataType := matcherDataTypes[0]
		if isCELStringListType(matcherDataType) {
			macro = parser.NewGlobalVarArgMacro(macroName, celMatcherStringListMacroExpander(funcName))
		} else if isCELStringType(matcherDataType) {
			macro = parser.NewGlobalMacro(macroName, 1, celMatcherStringMacroExpander(funcName))
		} else if isCELJSONType(matcherDataType) {
			macro = parser.NewGlobalMacro(macroName, 1, celMatcherJSONMacroExpander(funcName))
		} else {
			return nil, fmt.Errorf("unsupported matcher data type: %s", cel.FormatType(matcherDataType))
		}
	case 2:
		if isCELStringType(matcherDataTypes[0]) && isCELStringType(matcherDataTypes[1]) {
			macro = parser.NewGlobalMacro(macroName, 2, celMatcherStringListMacroExpander(funcName))
			matcherDataTypes = []*exprpb.Type{CelTypeListString}
		} else {
			return nil, fmt.Errorf(
				"unsupported matcher data type: %s, %s",
				cel.FormatType(matcherDataTypes[0]), cel.FormatType(matcherDataTypes[1]),
			)
		}
	case 3:
		if isCELStringType(matcherDataTypes[0]) && isCELStringType(matcherDataTypes[1]) && isCELStringType(matcherDataTypes[2]) {
			macro = parser.NewGlobalMacro(macroName, 3, celMatcherStringListMacroExpander(funcName))
			matcherDataTypes = []*exprpb.Type{CelTypeListString}
		} else {
			return nil, fmt.Errorf(
				"unsupported matcher data type: %s, %s, %s",
				cel.FormatType(matcherDataTypes[0]), cel.FormatType(matcherDataTypes[1]), cel.FormatType(matcherDataTypes[2]),
			)
		}
	}
	envOptions := []cel.EnvOption{
		cel.Macros(macro),
		cel.Declarations(
			decls.NewFunction(funcName,
				decls.NewOverload(
					funcName,
					append([]*exprpb.Type{requestType}, matcherDataTypes...),
					decls.Bool,
				),
			),
		),
	}
	programOptions := []cel.ProgramOption{
		cel.CustomDecorator(CELMatcherDecorator(funcName, fac)),
		cel.Functions(
			&functions.Overload{
				Operator: funcName,
				Binary:   CELMatcherRuntimeFunction(funcName, fac),
			},
		),
	}
	return NewMatcherCELLibrary(envOptions, programOptions), nil
}
// CELMatcherImpl creates a new cel.Library based on the following pieces of
// data:
//
// - macroName: the function name to be used within CEL. This will be a macro
//   and not a function proper.
// - funcName: the function overload name generated by the CEL macro used to
//   represent the matcher.
// - matcherDataTypes: the argument types to the macro.
// - fac: a matcherFactory implementation which converts from CEL constant
//   values to a Matcher instance.
//
// Note, macro names and function names must not collide with other macros or
// functions exposed within CEL expressions, or an error will be produced
// during the expression matcher plan time.
//
// The existing CELMatcherImpl support methods are configured to support a
// limited set of function signatures. For strong type validation you may need
// to provide a custom macro which does a more detailed analysis of the CEL
// literal provided to the macro as an argument.
CELMatcherImpl creates a new cel.Library based on the following pieces of
data.

- macroName: the function name to be used within CEL. This will be a macro
and not a function proper.
- funcName: the function overload name generated by the CEL macro used to
represent the matcher.
- matcherDataTypes: the argument types to the macro.
- fac: a matcherFactory implementation which converts from CEL constant
values to a Matcher instance.

Note, macro names and function names must not collide with other macros or
functions exposed within CEL expressions, or an error will be produced
during the expression matcher plan time.

The existing CELMatcherImpl support methods are configured to support a
limited set of function signatures. For strong type validation you may need
to provide a custom macro which does a more detailed analysis of the CEL
literal provided to the macro as an argument.
// CELMatcherImpl creates a new cel . Library based on the following pieces of // data : // // - macroName : the function name to be used within CEL . This will be a macro // and not a function proper . // - funcName : the function overload name generated by the CEL macro used to // represent the matcher . // - matcherDataTypes : the argument types to the macro . // - fac : a matcherFactory implementation which converts from CEL constant // values to a Matcher instance . // // Note macro names and function names must not collide with other macros or // functions exposed within CEL expressions or an error will be produced // during the expression matcher plan time . // // The existing CELMatcherImpl support methods are configured to support a // limited set of function signatures . For strong type validation you may need // to provide a custom macro which does a more detailed analysis of the CEL // literal provided to the macro as an argument .
func CELMatcherImpl(macroName, funcName string, matcherDataTypes []*exprpb.Type, fac CELMatcherFactory) (cel.Library, error) {
	requestType := decls.NewObjectType("http.Request")
	var macro parser.Macro
	switch len(matcherDataTypes) {
	case 1:
		matcherDataType := matcherDataTypes[0]
		if isCELStringListType(matcherDataType) {
			macro = parser.NewGlobalVarArgMacro(macroName, celMatcherStringListMacroExpander(funcName))
		} else if isCELStringType(matcherDataType) {
			macro = parser.NewGlobalMacro(macroName, 1, celMatcherStringMacroExpander(funcName))
		} else if isCELJSONType(matcherDataType) {
			macro = parser.NewGlobalMacro(macroName, 1, celMatcherJSONMacroExpander(funcName))
		} else {
			return nil, fmt.Errorf("unsupported matcher data type: %s", cel.FormatType(matcherDataType))
		}
	case 2:
		if isCELStringType(matcherDataTypes[0]) && isCELStringType(matcherDataTypes[1]) {
			macro = parser.NewGlobalMacro(macroName, 2, celMatcherStringListMacroExpander(funcName))
			matcherDataTypes = []*exprpb.Type{CelTypeListString}
		} else {
			return nil, fmt.Errorf(
				"unsupported matcher data type: %s, %s",
				cel.FormatType(matcherDataTypes[0]), cel.FormatType(matcherDataTypes[1]),
			)
		}
	case 3:
		if isCELStringType(matcherDataTypes[0]) && isCELStringType(matcherDataTypes[1]) && isCELStringType(matcherDataTypes[2]) {
			macro = parser.NewGlobalMacro(macroName, 3, celMatcherStringListMacroExpander(funcName))
			matcherDataTypes = []*exprpb.Type{CelTypeListString}
		} else {
			return nil, fmt.Errorf(
				"unsupported matcher data type: %s, %s, %s",
				cel.FormatType(matcherDataTypes[0]), cel.FormatType(matcherDataTypes[1]), cel.FormatType(matcherDataTypes[2]),
			)
		}
	}
	envOptions := []cel.EnvOption{
		cel.Macros(macro),
		cel.Declarations(
			decls.NewFunction(funcName,
				decls.NewOverload(
					funcName,
					append([]*exprpb.Type{requestType}, matcherDataTypes...),
					decls.Bool,
				),
			),
		),
	}
	programOptions := []cel.ProgramOption{
		cel.CustomDecorator(CELMatcherDecorator(funcName, fac)),
		cel.Functions(
			&functions.Overload{
				Operator: funcName,
				Binary:   CELMatcherRuntimeFunction(funcName, fac),
			},
		),
	}
	return NewMatcherCELLibrary(envOptions, programOptions), nil
}
func CELMatcherImpl ( macroName , funcName string , matcherDataTypes [ ] * exprpb . Type , fac CELMatcherFactory ) ( cel . Library , error ) { requestType := decls . NewObjectType ( " " ) var macro parser . Macro switch len ( matcherDataTypes ) { case 1 : matcherDataType := matcherDataTypes [ 0 ] if isCELStringListType ( matcherDataType ) { macro = parser . NewGlobalVarArgMacro ( macroName , celMatcherStringListMacroExpander ( funcName ) ) } else if isCELStringType ( matcherDataType ) { macro = parser . NewGlobalMacro ( macroName , 1 , celMatcherStringMacroExpander ( funcName ) ) } else if isCELJSONType ( matcherDataType ) { macro = parser . NewGlobalMacro ( macroName , 1 , celMatcherJSONMacroExpander ( funcName ) ) } else { return nil , fmt . Errorf ( " " , cel . FormatType ( matcherDataType ) ) } case 2 : if isCELStringType ( matcherDataTypes [ 0 ] ) && isCELStringType ( matcherDataTypes [ 1 ] ) { macro = parser . NewGlobalMacro ( macroName , 2 , celMatcherStringListMacroExpander ( funcName ) ) matcherDataTypes = [ ] * exprpb . Type { CelTypeListString } } else { return nil , fmt . Errorf ( " " , cel . FormatType ( matcherDataTypes [ 0 ] ) , cel . FormatType ( matcherDataTypes [ 1 ] ) , ) } case 3 : if isCELStringType ( matcherDataTypes [ 0 ] ) && isCELStringType ( matcherDataTypes [ 1 ] ) && isCELStringType ( matcherDataTypes [ 2 ] ) { macro = parser . NewGlobalMacro ( macroName , 3 , celMatcherStringListMacroExpander ( funcName ) ) matcherDataTypes = [ ] * exprpb . Type { CelTypeListString } } else { return nil , fmt . Errorf ( " " , cel . FormatType ( matcherDataTypes [ 0 ] ) , cel . FormatType ( matcherDataTypes [ 1 ] ) , cel . FormatType ( matcherDataTypes [ 2 ] ) , ) } } envOptions := [ ] cel . EnvOption { cel . Macros ( macro ) , cel . Declarations ( decls . NewFunction ( funcName , decls . NewOverload ( funcName , append ( [ ] * exprpb . Type { requestType } , matcherDataTypes ... ) , decls . Bool , ) , ) , ) , } programOptions := [ ] cel . ProgramOption { cel . CustomDecorator ( CELMatcherDecorator ( funcName , fac ) ) , cel . Functions ( & functions . Overload { Operator : funcName , Binary : CELMatcherRuntimeFunction ( funcName , fac ) , } , ) , } return NewMatcherCELLibrary ( envOptions , programOptions ) , nil }
CELMatcherImpl creates a new cel.Library based on the following pieces of
data.
CELMatcherImpl creates a new cel . Library based on the following pieces of data .