From 0205843faaefee3ecb41bae4b8c8c348885fac14 Mon Sep 17 00:00:00 2001 From: Nikita Date: Fri, 9 Aug 2024 12:14:49 -0400 Subject: [PATCH] bump: eco-goinfra v0.0.0-20240809150049-0634a7a9fb27 (#146) Co-authored-by: nkononov --- go.mod | 12 +- go.sum | 168 +- .../github.com/antlr4-go/antlr/v4/.gitignore | 18 - vendor/github.com/antlr4-go/antlr/v4/LICENSE | 28 - .../github.com/antlr4-go/antlr/v4/README.md | 54 - .../github.com/antlr4-go/antlr/v4/antlrdoc.go | 102 - vendor/github.com/antlr4-go/antlr/v4/atn.go | 179 - .../antlr4-go/antlr/v4/atn_config.go | 335 - .../antlr4-go/antlr/v4/atn_config_set.go | 301 - .../antlr/v4/atn_deserialization_options.go | 62 - .../antlr4-go/antlr/v4/atn_deserializer.go | 684 -- .../antlr4-go/antlr/v4/atn_simulator.go | 41 - .../antlr4-go/antlr/v4/atn_state.go | 461 -- .../github.com/antlr4-go/antlr/v4/atn_type.go | 11 - .../antlr4-go/antlr/v4/char_stream.go | 12 - .../antlr/v4/common_token_factory.go | 56 - .../antlr4-go/antlr/v4/common_token_stream.go | 450 -- .../antlr4-go/antlr/v4/comparators.go | 150 - .../antlr4-go/antlr/v4/configuration.go | 214 - vendor/github.com/antlr4-go/antlr/v4/dfa.go | 175 - .../antlr4-go/antlr/v4/dfa_serializer.go | 158 - .../antlr4-go/antlr/v4/dfa_state.go | 170 - .../antlr/v4/diagnostic_error_listener.go | 110 - .../antlr4-go/antlr/v4/error_listener.go | 100 - .../antlr4-go/antlr/v4/error_strategy.go | 702 -- .../github.com/antlr4-go/antlr/v4/errors.go | 259 - .../antlr4-go/antlr/v4/file_stream.go | 67 - .../antlr4-go/antlr/v4/input_stream.go | 157 - .../antlr4-go/antlr/v4/int_stream.go | 16 - .../antlr4-go/antlr/v4/interval_set.go | 330 - .../github.com/antlr4-go/antlr/v4/jcollect.go | 685 -- vendor/github.com/antlr4-go/antlr/v4/lexer.go | 426 -- .../antlr4-go/antlr/v4/lexer_action.go | 452 -- .../antlr/v4/lexer_action_executor.go | 173 - .../antlr4-go/antlr/v4/lexer_atn_simulator.go | 677 -- .../antlr4-go/antlr/v4/ll1_analyzer.go | 218 - .../antlr4-go/antlr/v4/nostatistics.go | 47 - .../github.com/antlr4-go/antlr/v4/parser.go | 700 -- .../antlr/v4/parser_atn_simulator.go | 1668 ----- .../antlr4-go/antlr/v4/parser_rule_context.go | 421 -- .../antlr4-go/antlr/v4/prediction_context.go | 727 -- .../antlr/v4/prediction_context_cache.go | 48 - .../antlr4-go/antlr/v4/prediction_mode.go | 536 -- .../antlr4-go/antlr/v4/recognizer.go | 241 - .../antlr4-go/antlr/v4/rule_context.go | 40 - .../antlr4-go/antlr/v4/semantic_context.go | 464 -- .../antlr4-go/antlr/v4/statistics.go | 281 - .../antlr4-go/antlr/v4/stats_data.go | 23 - vendor/github.com/antlr4-go/antlr/v4/token.go | 213 - .../antlr4-go/antlr/v4/token_source.go | 17 - .../antlr4-go/antlr/v4/token_stream.go | 21 - .../antlr/v4/tokenstream_rewriter.go | 662 -- .../antlr4-go/antlr/v4/trace_listener.go | 32 - .../antlr4-go/antlr/v4/transition.go | 439 -- vendor/github.com/antlr4-go/antlr/v4/tree.go | 304 - vendor/github.com/antlr4-go/antlr/v4/trees.go | 142 - vendor/github.com/antlr4-go/antlr/v4/utils.go | 328 - vendor/github.com/google/cel-go/LICENSE | 233 - .../github.com/google/cel-go/cel/BUILD.bazel | 90 - vendor/github.com/google/cel-go/cel/cel.go | 19 - vendor/github.com/google/cel-go/cel/decls.go | 355 - vendor/github.com/google/cel-go/cel/env.go | 881 --- .../github.com/google/cel-go/cel/folding.go | 559 -- .../github.com/google/cel-go/cel/inlining.go | 240 - vendor/github.com/google/cel-go/cel/io.go | 252 - .../github.com/google/cel-go/cel/library.go | 784 -- vendor/github.com/google/cel-go/cel/macro.go | 576 -- .../github.com/google/cel-go/cel/optimizer.go | 482 -- .../github.com/google/cel-go/cel/options.go | 661 -- .../github.com/google/cel-go/cel/program.go | 542 -- .../github.com/google/cel-go/cel/validator.go | 375 - .../google/cel-go/checker/BUILD.bazel | 65 - .../google/cel-go/checker/checker.go | 696 -- .../github.com/google/cel-go/checker/cost.go | 702 -- .../google/cel-go/checker/decls/BUILD.bazel | 19 - .../google/cel-go/checker/decls/decls.go | 237 - .../github.com/google/cel-go/checker/env.go | 276 - .../google/cel-go/checker/errors.go | 88 - .../google/cel-go/checker/format.go | 216 - .../google/cel-go/checker/mapping.go | 49 - .../google/cel-go/checker/options.go | 42 - .../google/cel-go/checker/printer.go | 74 - .../google/cel-go/checker/scopes.go | 147 - .../google/cel-go/checker/standard.go | 35 - .../github.com/google/cel-go/checker/types.go | 309 - .../google/cel-go/common/BUILD.bazel | 35 - .../google/cel-go/common/ast/BUILD.bazel | 61 - .../google/cel-go/common/ast/ast.go | 450 -- .../google/cel-go/common/ast/conversion.go | 632 -- .../google/cel-go/common/ast/expr.go | 860 --- .../google/cel-go/common/ast/factory.go | 303 - .../google/cel-go/common/ast/navigable.go | 652 -- .../cel-go/common/containers/BUILD.bazel | 31 - .../cel-go/common/containers/container.go | 316 - .../github.com/google/cel-go/common/cost.go | 40 - .../google/cel-go/common/debug/BUILD.bazel | 20 - .../google/cel-go/common/debug/debug.go | 309 - .../google/cel-go/common/decls/BUILD.bazel | 39 - .../google/cel-go/common/decls/decls.go | 844 --- vendor/github.com/google/cel-go/common/doc.go | 17 - .../github.com/google/cel-go/common/error.go | 79 - .../github.com/google/cel-go/common/errors.go | 103 - .../cel-go/common/functions/BUILD.bazel | 17 - .../cel-go/common/functions/functions.go | 61 - .../google/cel-go/common/location.go | 51 - .../cel-go/common/operators/BUILD.bazel | 14 - .../cel-go/common/operators/operators.go | 157 - .../cel-go/common/overloads/BUILD.bazel | 14 - .../cel-go/common/overloads/overloads.go | 327 - .../google/cel-go/common/runes/BUILD.bazel | 25 - .../google/cel-go/common/runes/buffer.go | 194 - .../github.com/google/cel-go/common/source.go | 183 - .../google/cel-go/common/stdlib/BUILD.bazel | 25 - .../google/cel-go/common/stdlib/standard.go | 661 -- .../google/cel-go/common/types/BUILD.bazel | 90 - .../google/cel-go/common/types/any_value.go | 24 - .../google/cel-go/common/types/bool.go | 141 - .../google/cel-go/common/types/bytes.go | 130 - .../google/cel-go/common/types/compare.go | 97 - .../google/cel-go/common/types/doc.go | 17 - .../google/cel-go/common/types/double.go | 211 - .../google/cel-go/common/types/duration.go | 222 - .../google/cel-go/common/types/err.go | 146 - .../google/cel-go/common/types/int.go | 291 - .../google/cel-go/common/types/iterator.go | 55 - .../google/cel-go/common/types/json_value.go | 29 - .../google/cel-go/common/types/list.go | 523 -- .../google/cel-go/common/types/map.go | 854 --- .../google/cel-go/common/types/null.go | 111 - .../google/cel-go/common/types/object.go | 165 - .../google/cel-go/common/types/optional.go | 108 - .../google/cel-go/common/types/overflow.go | 389 - .../google/cel-go/common/types/pb/BUILD.bazel | 53 - .../google/cel-go/common/types/pb/checked.go | 93 - .../google/cel-go/common/types/pb/enum.go | 44 - .../google/cel-go/common/types/pb/equal.go | 206 - .../google/cel-go/common/types/pb/file.go | 202 - .../google/cel-go/common/types/pb/pb.go | 258 - .../google/cel-go/common/types/pb/type.go | 587 -- .../google/cel-go/common/types/provider.go | 734 -- .../cel-go/common/types/ref/BUILD.bazel | 20 - .../cel-go/common/types/ref/provider.go | 102 - .../cel-go/common/types/ref/reference.go | 63 - .../google/cel-go/common/types/string.go | 229 - .../google/cel-go/common/types/timestamp.go | 311 - .../cel-go/common/types/traits/BUILD.bazel | 29 - .../cel-go/common/types/traits/comparer.go | 33 - .../cel-go/common/types/traits/container.go | 23 - .../common/types/traits/field_tester.go | 30 - .../cel-go/common/types/traits/indexer.go | 25 - .../cel-go/common/types/traits/iterator.go | 36 - .../cel-go/common/types/traits/lister.go | 33 - .../cel-go/common/types/traits/mapper.go | 33 - .../cel-go/common/types/traits/matcher.go | 23 - .../google/cel-go/common/types/traits/math.go | 62 - .../cel-go/common/types/traits/receiver.go | 24 - .../cel-go/common/types/traits/sizer.go | 25 - .../cel-go/common/types/traits/traits.go | 64 - .../cel-go/common/types/traits/zeroer.go | 21 - .../google/cel-go/common/types/types.go | 806 --- .../google/cel-go/common/types/uint.go | 244 - .../google/cel-go/common/types/unknown.go | 326 - .../google/cel-go/common/types/util.go | 48 - .../google/cel-go/interpreter/BUILD.bazel | 74 - .../google/cel-go/interpreter/activation.go | 201 - .../cel-go/interpreter/attribute_patterns.go | 399 -- .../google/cel-go/interpreter/attributes.go | 1337 ---- .../google/cel-go/interpreter/decorators.go | 272 - .../google/cel-go/interpreter/dispatcher.go | 100 - .../google/cel-go/interpreter/evalstate.go | 79 - .../cel-go/interpreter/functions/BUILD.bazel | 17 - .../cel-go/interpreter/functions/functions.go | 39 - .../cel-go/interpreter/interpretable.go | 1262 ---- .../google/cel-go/interpreter/interpreter.go | 185 - .../cel-go/interpreter/optimizations.go | 46 - .../google/cel-go/interpreter/planner.go | 756 -- .../google/cel-go/interpreter/prune.go | 543 -- .../google/cel-go/interpreter/runtimecost.go | 316 - .../google/cel-go/parser/BUILD.bazel | 58 - .../github.com/google/cel-go/parser/errors.go | 43 - .../google/cel-go/parser/gen/BUILD.bazel | 26 - .../google/cel-go/parser/gen/CEL.g4 | 200 - .../google/cel-go/parser/gen/CEL.interp | 99 - .../google/cel-go/parser/gen/CEL.tokens | 64 - .../google/cel-go/parser/gen/CELLexer.interp | 136 - .../google/cel-go/parser/gen/CELLexer.tokens | 64 - .../cel-go/parser/gen/cel_base_listener.go | 219 - .../cel-go/parser/gen/cel_base_visitor.go | 141 - .../google/cel-go/parser/gen/cel_lexer.go | 344 - .../google/cel-go/parser/gen/cel_listener.go | 208 - .../google/cel-go/parser/gen/cel_parser.go | 6274 ----------------- .../google/cel-go/parser/gen/cel_visitor.go | 110 - .../google/cel-go/parser/gen/doc.go | 16 - .../google/cel-go/parser/gen/generate.sh | 35 - .../github.com/google/cel-go/parser/helper.go | 474 -- .../github.com/google/cel-go/parser/input.go | 129 - .../github.com/google/cel-go/parser/macro.go | 406 -- .../google/cel-go/parser/options.go | 140 - .../github.com/google/cel-go/parser/parser.go | 1008 --- .../google/cel-go/parser/unescape.go | 237 - .../google/cel-go/parser/unparser.go | 629 -- .../github.com/h2non/filetype/.editorconfig | 12 - vendor/github.com/h2non/filetype/.gitignore | 2 - vendor/github.com/h2non/filetype/.travis.yml | 16 - vendor/github.com/h2non/filetype/History.md | 163 - vendor/github.com/h2non/filetype/LICENSE | 24 - vendor/github.com/h2non/filetype/README.md | 294 - vendor/github.com/h2non/filetype/filetype.go | 102 - vendor/github.com/h2non/filetype/kind.go | 91 - vendor/github.com/h2non/filetype/match.go | 90 - .../h2non/filetype/matchers/application.go | 43 - .../h2non/filetype/matchers/archive.go | 211 - .../h2non/filetype/matchers/audio.go | 85 - .../h2non/filetype/matchers/document.go | 197 - .../h2non/filetype/matchers/font.go | 45 - .../h2non/filetype/matchers/image.go | 143 - .../filetype/matchers/isobmff/isobmff.go | 37 - .../h2non/filetype/matchers/matchers.go | 51 - .../h2non/filetype/matchers/video.go | 145 - .../h2non/filetype/types/defaults.go | 4 - .../github.com/h2non/filetype/types/mime.go | 14 - .../github.com/h2non/filetype/types/split.go | 11 - .../github.com/h2non/filetype/types/type.go | 16 - .../github.com/h2non/filetype/types/types.go | 23 - vendor/github.com/h2non/filetype/version.go | 4 - .../github.com/h2non/go-is-svg/.editorconfig | 12 - vendor/github.com/h2non/go-is-svg/.gitignore | 7 - vendor/github.com/h2non/go-is-svg/.travis.yml | 23 - vendor/github.com/h2non/go-is-svg/LICENSE | 24 - vendor/github.com/h2non/go-is-svg/README.md | 47 - vendor/github.com/h2non/go-is-svg/svg.go | 36 - .../gomega/gstruct/errors/nested_types.go | 72 - .../eco-goinfra/pkg/clients/clients.go | 16 - .../eco-goinfra/pkg/olm/packagemanifest.go | 102 +- .../pkg/olm/packagemanifestlist.go | 28 +- .../metallb/mlboperator/metallb_types.go | 9 +- .../metallb/mlboperator/metallb_webhook.go | 21 +- .../olm/package-server}/operators/doc.go | 0 .../operators/packagemanifest_types.go | 19 +- .../olm/package-server}/operators/register.go | 0 .../olm/package-server}/operators/v1/doc.go | 0 .../operators/v1/packagemanifest_types.go | 19 +- .../package-server}/operators/v1/register.go | 2 +- .../operators/v1/zz_generated.conversion.go | 40 +- .../operators/v1/zz_generated.deepcopy.go | 37 +- .../operators/v1/zz_generated.defaults.go | 0 .../operators/zz_generated.deepcopy.go | 37 +- .../api/pkg/constraints/cel.go | 135 - .../api/pkg/constraints/constraint.go | 87 - .../api/pkg/operators/v1/doc.go | 4 - .../api/pkg/operators/v1/groupversion_info.go | 28 - .../api/pkg/operators/v1/olmconfig_types.go | 90 - .../api/pkg/operators/v1/operator_types.go | 88 - .../operators/v1/operatorcondition_types.go | 49 - .../pkg/operators/v1/operatorgroup_types.go | 214 - .../pkg/operators/v1/zz_generated.deepcopy.go | 556 -- .../api/pkg/operators/v1alpha2/doc.go | 6 - .../operators/v1alpha2/groupversion_info.go | 42 - .../operators/v1alpha2/operatorgroup_types.go | 99 - .../v1alpha2/zz_generated.deepcopy.go | 139 - .../api/pkg/operators/v2/doc.go | 4 - .../api/pkg/operators/v2/groupversion_info.go | 28 - .../operators/v2/operatorcondition_types.go | 54 - .../pkg/operators/v2/zz_generated.deepcopy.go | 145 - .../operator-lifecycle-manager/LICENSE | 201 - .../client/clientset/versioned/scheme/doc.go | 20 - .../clientset/versioned/scheme/register.go | 62 - .../versioned/typed/operators/v1/doc.go | 20 - .../typed/operators/v1/generated_expansion.go | 27 - .../versioned/typed/operators/v1/olmconfig.go | 184 - .../versioned/typed/operators/v1/operator.go | 184 - .../typed/operators/v1/operatorcondition.go | 195 - .../typed/operators/v1/operatorgroup.go | 195 - .../typed/operators/v1/operators_client.go | 122 - .../typed/operators/v1alpha1/catalogsource.go | 195 - .../v1alpha1/clusterserviceversion.go | 195 - .../versioned/typed/operators/v1alpha1/doc.go | 20 - .../operators/v1alpha1/generated_expansion.go | 27 - .../typed/operators/v1alpha1/installplan.go | 195 - .../operators/v1alpha1/operators_client.go | 122 - .../typed/operators/v1alpha1/subscription.go | 195 - .../apis/operators/packagemanifest.go | 134 - .../apis/operators/v1/packagemanifest.go | 97 - .../client/clientset/versioned/scheme/doc.go | 20 - .../clientset/versioned/scheme/register.go | 56 - .../versioned/typed/operators/v1/doc.go | 20 - .../typed/operators/v1/generated_expansion.go | 21 - .../typed/operators/v1/operators_client.go | 107 - .../typed/operators/v1/packagemanifest.go | 195 - .../operator-registry/LICENSE | 201 - .../operator-registry/alpha/model/error.go | 66 - .../operator-registry/alpha/model/model.go | 407 -- .../alpha/property/errors.go | 25 - .../alpha/property/property.go | 286 - .../alpha/property/scheme.go | 34 - .../operator-registry/pkg/api/api_to_model.go | 155 - .../operator-registry/pkg/api/model_to_api.go | 207 - .../operator-registry/pkg/api/registry.pb.go | 1734 ----- .../operator-registry/pkg/api/registry.proto | 133 - .../pkg/api/registry_grpc.pb.go | 582 -- .../operator-registry/pkg/image/mock.go | 85 - .../operator-registry/pkg/image/reference.go | 16 - .../operator-registry/pkg/image/registry.go | 31 - .../pkg/lib/semver/semver.go | 54 - .../prettyunmarshaler/prettyunmarshaler.go | 93 - .../operator-registry/pkg/registry/bundle.go | 395 -- .../pkg/registry/bundlegraphloader.go | 160 - .../pkg/registry/channelupdateoptions.go | 27 - .../pkg/registry/conversion.go | 97 - .../operator-registry/pkg/registry/csv.go | 469 -- .../operator-registry/pkg/registry/decode.go | 69 - .../pkg/registry/directoryGraphLoader.go | 207 - .../operator-registry/pkg/registry/empty.go | 123 - .../operator-registry/pkg/registry/graph.go | 79 - .../pkg/registry/imageinput.go | 30 - .../pkg/registry/interface.go | 110 - .../operator-registry/pkg/registry/parse.go | 251 - .../pkg/registry/populator.go | 464 -- .../pkg/registry/registry_to_model.go | 147 - .../operator-registry/pkg/registry/types.go | 418 -- .../github.com/stoewer/go-strcase/.gitignore | 17 - .../stoewer/go-strcase/.golangci.yml | 26 - vendor/github.com/stoewer/go-strcase/LICENSE | 21 - .../github.com/stoewer/go-strcase/README.md | 50 - vendor/github.com/stoewer/go-strcase/camel.go | 40 - vendor/github.com/stoewer/go-strcase/doc.go | 8 - .../github.com/stoewer/go-strcase/helper.go | 71 - vendor/github.com/stoewer/go-strcase/kebab.go | 14 - vendor/github.com/stoewer/go-strcase/snake.go | 58 - .../x/net/internal/timeseries/timeseries.go | 525 -- vendor/golang.org/x/net/trace/events.go | 532 -- vendor/golang.org/x/net/trace/histogram.go | 365 - vendor/golang.org/x/net/trace/trace.go | 1130 --- vendor/golang.org/x/text/width/kind_string.go | 28 - .../golang.org/x/text/width/tables10.0.0.go | 1328 ---- .../golang.org/x/text/width/tables11.0.0.go | 1340 ---- .../golang.org/x/text/width/tables12.0.0.go | 1360 ---- .../golang.org/x/text/width/tables13.0.0.go | 1361 ---- .../golang.org/x/text/width/tables15.0.0.go | 1367 ---- vendor/golang.org/x/text/width/tables9.0.0.go | 1296 ---- vendor/golang.org/x/text/width/transform.go | 239 - vendor/golang.org/x/text/width/trieval.go | 30 - vendor/golang.org/x/text/width/width.go | 206 - .../genproto/googleapis/api/LICENSE | 202 - .../api/expr/v1alpha1/checked.pb.go | 1664 ----- .../googleapis/api/expr/v1alpha1/eval.pb.go | 580 -- .../api/expr/v1alpha1/explain.pb.go | 275 - .../googleapis/api/expr/v1alpha1/syntax.pb.go | 1990 ------ .../googleapis/api/expr/v1alpha1/value.pb.go | 721 -- .../genproto/googleapis/rpc/LICENSE | 202 - .../googleapis/rpc/status/status.pb.go | 203 - vendor/google.golang.org/grpc/AUTHORS | 1 - .../google.golang.org/grpc/CODE-OF-CONDUCT.md | 3 - vendor/google.golang.org/grpc/CONTRIBUTING.md | 73 - vendor/google.golang.org/grpc/GOVERNANCE.md | 1 - vendor/google.golang.org/grpc/LICENSE | 202 - vendor/google.golang.org/grpc/MAINTAINERS.md | 28 - vendor/google.golang.org/grpc/Makefile | 46 - vendor/google.golang.org/grpc/NOTICE.txt | 13 - vendor/google.golang.org/grpc/README.md | 107 - vendor/google.golang.org/grpc/SECURITY.md | 3 - .../grpc/attributes/attributes.go | 141 - vendor/google.golang.org/grpc/backoff.go | 61 - .../google.golang.org/grpc/backoff/backoff.go | 52 - .../grpc/balancer/balancer.go | 443 -- .../grpc/balancer/base/balancer.go | 264 - .../grpc/balancer/base/base.go | 71 - .../grpc/balancer/conn_state_evaluator.go | 74 - .../grpc/balancer/grpclb/state/state.go | 51 - .../grpc/balancer/roundrobin/roundrobin.go | 81 - .../grpc/balancer_wrapper.go | 337 - .../grpc_binarylog_v1/binarylog.pb.go | 1183 ---- vendor/google.golang.org/grpc/call.go | 74 - .../grpc/channelz/channelz.go | 36 - vendor/google.golang.org/grpc/clientconn.go | 1827 ----- vendor/google.golang.org/grpc/codec.go | 50 - vendor/google.golang.org/grpc/codegen.sh | 17 - .../grpc/codes/code_string.go | 111 - vendor/google.golang.org/grpc/codes/codes.go | 250 - .../grpc/connectivity/connectivity.go | 94 - .../grpc/credentials/credentials.go | 291 - .../grpc/credentials/insecure/insecure.go | 98 - .../google.golang.org/grpc/credentials/tls.go | 251 - vendor/google.golang.org/grpc/dialoptions.go | 726 -- vendor/google.golang.org/grpc/doc.go | 26 - .../grpc/encoding/encoding.go | 130 - .../grpc/encoding/proto/proto.go | 72 - .../grpc/grpclog/component.go | 117 - .../google.golang.org/grpc/grpclog/grpclog.go | 132 - .../google.golang.org/grpc/grpclog/logger.go | 87 - .../grpc/grpclog/loggerv2.go | 258 - vendor/google.golang.org/grpc/interceptor.go | 104 - .../grpc/internal/backoff/backoff.go | 109 - .../balancer/gracefulswitch/config.go | 83 - .../balancer/gracefulswitch/gracefulswitch.go | 420 -- .../grpc/internal/balancerload/load.go | 46 - .../grpc/internal/binarylog/binarylog.go | 192 - .../internal/binarylog/binarylog_testutil.go | 42 - .../grpc/internal/binarylog/env_config.go | 208 - .../grpc/internal/binarylog/method_logger.go | 446 -- .../grpc/internal/binarylog/sink.go | 170 - .../grpc/internal/buffer/unbounded.go | 116 - .../grpc/internal/channelz/channel.go | 255 - .../grpc/internal/channelz/channelmap.go | 402 -- .../grpc/internal/channelz/funcs.go | 230 - .../grpc/internal/channelz/logging.go | 75 - .../grpc/internal/channelz/server.go | 119 - .../grpc/internal/channelz/socket.go | 130 - .../grpc/internal/channelz/subchannel.go | 151 - .../grpc/internal/channelz/syscall_linux.go | 65 - .../internal/channelz/syscall_nonlinux.go | 47 - .../grpc/internal/channelz/trace.go | 204 - .../grpc/internal/credentials/credentials.go | 49 - .../grpc/internal/credentials/spiffe.go | 75 - .../grpc/internal/credentials/syscallconn.go | 58 - .../grpc/internal/credentials/util.go | 52 - .../grpc/internal/envconfig/envconfig.go | 69 - .../grpc/internal/envconfig/observability.go | 42 - .../grpc/internal/envconfig/xds.go | 56 - .../grpc/internal/experimental.go | 28 - .../grpc/internal/grpclog/grpclog.go | 126 - .../grpc/internal/grpclog/prefixLogger.go | 93 - .../grpc/internal/grpcrand/grpcrand.go | 100 - .../grpc/internal/grpcrand/grpcrand_go1.21.go | 73 - .../internal/grpcsync/callback_serializer.go | 100 - .../grpc/internal/grpcsync/event.go | 61 - .../grpc/internal/grpcsync/oncefunc.go | 32 - .../grpc/internal/grpcsync/pubsub.go | 121 - .../grpc/internal/grpcutil/compressor.go | 47 - .../grpc/internal/grpcutil/encode_duration.go | 63 - .../grpc/internal/grpcutil/grpcutil.go | 20 - .../grpc/internal/grpcutil/metadata.go | 40 - .../grpc/internal/grpcutil/method.go | 88 - .../grpc/internal/grpcutil/regex.go | 31 - .../grpc/internal/idle/idle.go | 278 - .../grpc/internal/internal.go | 230 - .../grpc/internal/metadata/metadata.go | 132 - .../grpc/internal/pretty/pretty.go | 73 - .../grpc/internal/resolver/config_selector.go | 167 - .../internal/resolver/dns/dns_resolver.go | 450 -- .../resolver/dns/internal/internal.go | 70 - .../resolver/passthrough/passthrough.go | 64 - .../grpc/internal/resolver/unix/unix.go | 78 - .../grpc/internal/serviceconfig/duration.go | 130 - .../internal/serviceconfig/serviceconfig.go | 180 - .../grpc/internal/status/status.go | 205 - .../grpc/internal/syscall/syscall_linux.go | 112 - .../grpc/internal/syscall/syscall_nonlinux.go | 77 - .../grpc/internal/tcp_keepalive_others.go | 29 - .../grpc/internal/tcp_keepalive_unix.go | 54 - .../grpc/internal/tcp_keepalive_windows.go | 54 - .../grpc/internal/transport/bdp_estimator.go | 141 - .../grpc/internal/transport/controlbuf.go | 1006 --- .../grpc/internal/transport/defaults.go | 55 - .../grpc/internal/transport/flowcontrol.go | 215 - .../grpc/internal/transport/handler_server.go | 489 -- .../grpc/internal/transport/http2_client.go | 1788 ----- .../grpc/internal/transport/http2_server.go | 1460 ---- .../grpc/internal/transport/http_util.go | 464 -- .../grpc/internal/transport/logging.go | 40 - .../transport/networktype/networktype.go | 46 - .../grpc/internal/transport/proxy.go | 144 - .../grpc/internal/transport/transport.go | 832 --- .../grpc/keepalive/keepalive.go | 85 - .../grpc/metadata/metadata.go | 300 - vendor/google.golang.org/grpc/peer/peer.go | 53 - .../google.golang.org/grpc/picker_wrapper.go | 223 - vendor/google.golang.org/grpc/pickfirst.go | 241 - vendor/google.golang.org/grpc/preloader.go | 67 - vendor/google.golang.org/grpc/regenerate.sh | 123 - .../grpc/resolver/dns/dns_resolver.go | 54 - vendor/google.golang.org/grpc/resolver/map.go | 251 - .../grpc/resolver/resolver.go | 332 - .../grpc/resolver_wrapper.go | 198 - vendor/google.golang.org/grpc/rpc_util.go | 981 --- vendor/google.golang.org/grpc/server.go | 2183 ------ .../google.golang.org/grpc/service_config.go | 354 - .../grpc/serviceconfig/serviceconfig.go | 44 - .../grpc/shared_buffer_pool.go | 154 - .../google.golang.org/grpc/stats/handlers.go | 63 - vendor/google.golang.org/grpc/stats/stats.go | 343 - .../google.golang.org/grpc/status/status.go | 162 - vendor/google.golang.org/grpc/stream.go | 1781 ----- vendor/google.golang.org/grpc/tap/tap.go | 62 - vendor/google.golang.org/grpc/trace.go | 143 - .../google.golang.org/grpc/trace_notrace.go | 52 - .../google.golang.org/grpc/trace_withtrace.go | 39 - vendor/google.golang.org/grpc/version.go | 22 - vendor/google.golang.org/grpc/vet.sh | 195 - .../protobuf/encoding/protojson/decode.go | 685 -- .../protobuf/encoding/protojson/doc.go | 11 - .../protobuf/encoding/protojson/encode.go | 382 - .../encoding/protojson/well_known_types.go | 876 --- .../protobuf/internal/encoding/json/decode.go | 340 - .../internal/encoding/json/decode_number.go | 254 - .../internal/encoding/json/decode_string.go | 91 - .../internal/encoding/json/decode_token.go | 192 - .../protobuf/internal/encoding/json/encode.go | 278 - .../protobuf/protoadapt/convert.go | 31 - .../protobuf/types/dynamicpb/dynamic.go | 718 -- .../protobuf/types/dynamicpb/types.go | 184 - .../types/known/durationpb/duration.pb.go | 374 - .../protobuf/types/known/emptypb/empty.pb.go | 166 - .../types/known/structpb/struct.pb.go | 810 --- .../types/known/wrapperspb/wrappers.pb.go | 760 -- vendor/modules.txt | 135 +- 506 files changed, 144 insertions(+), 124153 deletions(-) delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/.gitignore delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/LICENSE delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/README.md delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/antlrdoc.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/atn.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/atn_config.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/atn_config_set.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/atn_deserialization_options.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/atn_deserializer.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/atn_simulator.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/atn_state.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/atn_type.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/char_stream.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/common_token_factory.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/common_token_stream.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/comparators.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/configuration.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/dfa.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/dfa_serializer.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/dfa_state.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/diagnostic_error_listener.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/error_listener.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/error_strategy.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/errors.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/file_stream.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/input_stream.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/int_stream.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/interval_set.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/jcollect.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/lexer.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/lexer_action.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/lexer_action_executor.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/lexer_atn_simulator.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/ll1_analyzer.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/nostatistics.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/parser.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/parser_atn_simulator.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/parser_rule_context.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/prediction_context.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/prediction_context_cache.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/prediction_mode.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/recognizer.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/rule_context.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/semantic_context.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/statistics.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/stats_data.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/token.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/token_source.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/token_stream.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/tokenstream_rewriter.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/trace_listener.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/transition.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/tree.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/trees.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/utils.go delete mode 100644 vendor/github.com/google/cel-go/LICENSE delete mode 100644 vendor/github.com/google/cel-go/cel/BUILD.bazel delete mode 100644 vendor/github.com/google/cel-go/cel/cel.go delete mode 100644 vendor/github.com/google/cel-go/cel/decls.go delete mode 100644 vendor/github.com/google/cel-go/cel/env.go delete mode 100644 vendor/github.com/google/cel-go/cel/folding.go delete mode 100644 vendor/github.com/google/cel-go/cel/inlining.go delete mode 100644 vendor/github.com/google/cel-go/cel/io.go delete mode 100644 vendor/github.com/google/cel-go/cel/library.go delete mode 100644 vendor/github.com/google/cel-go/cel/macro.go delete mode 100644 vendor/github.com/google/cel-go/cel/optimizer.go delete mode 100644 vendor/github.com/google/cel-go/cel/options.go delete mode 100644 vendor/github.com/google/cel-go/cel/program.go delete mode 100644 vendor/github.com/google/cel-go/cel/validator.go delete mode 100644 vendor/github.com/google/cel-go/checker/BUILD.bazel delete mode 100644 vendor/github.com/google/cel-go/checker/checker.go delete mode 100644 vendor/github.com/google/cel-go/checker/cost.go delete mode 100644 vendor/github.com/google/cel-go/checker/decls/BUILD.bazel delete mode 100644 vendor/github.com/google/cel-go/checker/decls/decls.go delete mode 100644 vendor/github.com/google/cel-go/checker/env.go delete mode 100644 vendor/github.com/google/cel-go/checker/errors.go delete mode 100644 vendor/github.com/google/cel-go/checker/format.go delete mode 100644 vendor/github.com/google/cel-go/checker/mapping.go delete mode 100644 vendor/github.com/google/cel-go/checker/options.go delete mode 100644 vendor/github.com/google/cel-go/checker/printer.go delete mode 100644 vendor/github.com/google/cel-go/checker/scopes.go delete mode 100644 vendor/github.com/google/cel-go/checker/standard.go delete mode 100644 vendor/github.com/google/cel-go/checker/types.go delete mode 100644 vendor/github.com/google/cel-go/common/BUILD.bazel delete mode 100644 vendor/github.com/google/cel-go/common/ast/BUILD.bazel delete mode 100644 vendor/github.com/google/cel-go/common/ast/ast.go delete mode 100644 vendor/github.com/google/cel-go/common/ast/conversion.go delete mode 100644 vendor/github.com/google/cel-go/common/ast/expr.go delete mode 100644 vendor/github.com/google/cel-go/common/ast/factory.go delete mode 100644 vendor/github.com/google/cel-go/common/ast/navigable.go delete mode 100644 vendor/github.com/google/cel-go/common/containers/BUILD.bazel delete mode 100644 vendor/github.com/google/cel-go/common/containers/container.go delete mode 100644 vendor/github.com/google/cel-go/common/cost.go delete mode 100644 vendor/github.com/google/cel-go/common/debug/BUILD.bazel delete mode 100644 vendor/github.com/google/cel-go/common/debug/debug.go delete mode 100644 vendor/github.com/google/cel-go/common/decls/BUILD.bazel delete mode 100644 vendor/github.com/google/cel-go/common/decls/decls.go delete mode 100644 vendor/github.com/google/cel-go/common/doc.go delete mode 100644 vendor/github.com/google/cel-go/common/error.go delete mode 100644 vendor/github.com/google/cel-go/common/errors.go delete mode 100644 vendor/github.com/google/cel-go/common/functions/BUILD.bazel delete mode 100644 vendor/github.com/google/cel-go/common/functions/functions.go delete mode 100644 vendor/github.com/google/cel-go/common/location.go delete mode 100644 vendor/github.com/google/cel-go/common/operators/BUILD.bazel delete mode 100644 vendor/github.com/google/cel-go/common/operators/operators.go delete mode 100644 vendor/github.com/google/cel-go/common/overloads/BUILD.bazel delete mode 100644 vendor/github.com/google/cel-go/common/overloads/overloads.go delete mode 100644 vendor/github.com/google/cel-go/common/runes/BUILD.bazel delete mode 100644 vendor/github.com/google/cel-go/common/runes/buffer.go delete mode 100644 vendor/github.com/google/cel-go/common/source.go delete mode 100644 vendor/github.com/google/cel-go/common/stdlib/BUILD.bazel delete mode 100644 vendor/github.com/google/cel-go/common/stdlib/standard.go delete mode 100644 vendor/github.com/google/cel-go/common/types/BUILD.bazel delete mode 100644 vendor/github.com/google/cel-go/common/types/any_value.go delete mode 100644 vendor/github.com/google/cel-go/common/types/bool.go delete mode 100644 vendor/github.com/google/cel-go/common/types/bytes.go delete mode 100644 vendor/github.com/google/cel-go/common/types/compare.go delete mode 100644 vendor/github.com/google/cel-go/common/types/doc.go delete mode 100644 vendor/github.com/google/cel-go/common/types/double.go delete mode 100644 vendor/github.com/google/cel-go/common/types/duration.go delete mode 100644 vendor/github.com/google/cel-go/common/types/err.go delete mode 100644 vendor/github.com/google/cel-go/common/types/int.go delete mode 100644 vendor/github.com/google/cel-go/common/types/iterator.go delete mode 100644 vendor/github.com/google/cel-go/common/types/json_value.go delete mode 100644 vendor/github.com/google/cel-go/common/types/list.go delete mode 100644 vendor/github.com/google/cel-go/common/types/map.go delete mode 100644 vendor/github.com/google/cel-go/common/types/null.go delete mode 100644 vendor/github.com/google/cel-go/common/types/object.go delete mode 100644 vendor/github.com/google/cel-go/common/types/optional.go delete mode 100644 vendor/github.com/google/cel-go/common/types/overflow.go delete mode 100644 vendor/github.com/google/cel-go/common/types/pb/BUILD.bazel delete mode 100644 vendor/github.com/google/cel-go/common/types/pb/checked.go delete mode 100644 vendor/github.com/google/cel-go/common/types/pb/enum.go delete mode 100644 vendor/github.com/google/cel-go/common/types/pb/equal.go delete mode 100644 vendor/github.com/google/cel-go/common/types/pb/file.go delete mode 100644 vendor/github.com/google/cel-go/common/types/pb/pb.go delete mode 100644 vendor/github.com/google/cel-go/common/types/pb/type.go delete mode 100644 vendor/github.com/google/cel-go/common/types/provider.go delete mode 100644 vendor/github.com/google/cel-go/common/types/ref/BUILD.bazel delete mode 100644 vendor/github.com/google/cel-go/common/types/ref/provider.go delete mode 100644 vendor/github.com/google/cel-go/common/types/ref/reference.go delete mode 100644 vendor/github.com/google/cel-go/common/types/string.go delete mode 100644 vendor/github.com/google/cel-go/common/types/timestamp.go delete mode 100644 vendor/github.com/google/cel-go/common/types/traits/BUILD.bazel delete mode 100644 vendor/github.com/google/cel-go/common/types/traits/comparer.go delete mode 100644 vendor/github.com/google/cel-go/common/types/traits/container.go delete mode 100644 vendor/github.com/google/cel-go/common/types/traits/field_tester.go delete mode 100644 vendor/github.com/google/cel-go/common/types/traits/indexer.go delete mode 100644 vendor/github.com/google/cel-go/common/types/traits/iterator.go delete mode 100644 vendor/github.com/google/cel-go/common/types/traits/lister.go delete mode 100644 vendor/github.com/google/cel-go/common/types/traits/mapper.go delete mode 100644 vendor/github.com/google/cel-go/common/types/traits/matcher.go delete mode 100644 vendor/github.com/google/cel-go/common/types/traits/math.go delete mode 100644 vendor/github.com/google/cel-go/common/types/traits/receiver.go delete mode 100644 vendor/github.com/google/cel-go/common/types/traits/sizer.go delete mode 100644 vendor/github.com/google/cel-go/common/types/traits/traits.go delete mode 100644 vendor/github.com/google/cel-go/common/types/traits/zeroer.go delete mode 100644 vendor/github.com/google/cel-go/common/types/types.go delete mode 100644 vendor/github.com/google/cel-go/common/types/uint.go delete mode 100644 vendor/github.com/google/cel-go/common/types/unknown.go delete mode 100644 vendor/github.com/google/cel-go/common/types/util.go delete mode 100644 vendor/github.com/google/cel-go/interpreter/BUILD.bazel delete mode 100644 vendor/github.com/google/cel-go/interpreter/activation.go delete mode 100644 vendor/github.com/google/cel-go/interpreter/attribute_patterns.go delete mode 100644 vendor/github.com/google/cel-go/interpreter/attributes.go delete mode 100644 vendor/github.com/google/cel-go/interpreter/decorators.go delete mode 100644 vendor/github.com/google/cel-go/interpreter/dispatcher.go delete mode 100644 vendor/github.com/google/cel-go/interpreter/evalstate.go delete mode 100644 vendor/github.com/google/cel-go/interpreter/functions/BUILD.bazel delete mode 100644 vendor/github.com/google/cel-go/interpreter/functions/functions.go delete mode 100644 vendor/github.com/google/cel-go/interpreter/interpretable.go delete mode 100644 vendor/github.com/google/cel-go/interpreter/interpreter.go delete mode 100644 vendor/github.com/google/cel-go/interpreter/optimizations.go delete mode 100644 vendor/github.com/google/cel-go/interpreter/planner.go delete mode 100644 vendor/github.com/google/cel-go/interpreter/prune.go delete mode 100644 vendor/github.com/google/cel-go/interpreter/runtimecost.go delete mode 100644 vendor/github.com/google/cel-go/parser/BUILD.bazel delete mode 100644 vendor/github.com/google/cel-go/parser/errors.go delete mode 100644 vendor/github.com/google/cel-go/parser/gen/BUILD.bazel delete mode 100644 vendor/github.com/google/cel-go/parser/gen/CEL.g4 delete mode 100644 vendor/github.com/google/cel-go/parser/gen/CEL.interp delete mode 100644 vendor/github.com/google/cel-go/parser/gen/CEL.tokens delete mode 100644 vendor/github.com/google/cel-go/parser/gen/CELLexer.interp delete mode 100644 vendor/github.com/google/cel-go/parser/gen/CELLexer.tokens delete mode 100644 vendor/github.com/google/cel-go/parser/gen/cel_base_listener.go delete mode 100644 vendor/github.com/google/cel-go/parser/gen/cel_base_visitor.go delete mode 100644 vendor/github.com/google/cel-go/parser/gen/cel_lexer.go delete mode 100644 vendor/github.com/google/cel-go/parser/gen/cel_listener.go delete mode 100644 vendor/github.com/google/cel-go/parser/gen/cel_parser.go delete mode 100644 vendor/github.com/google/cel-go/parser/gen/cel_visitor.go delete mode 100644 vendor/github.com/google/cel-go/parser/gen/doc.go delete mode 100644 vendor/github.com/google/cel-go/parser/gen/generate.sh delete mode 100644 vendor/github.com/google/cel-go/parser/helper.go delete mode 100644 vendor/github.com/google/cel-go/parser/input.go delete mode 100644 vendor/github.com/google/cel-go/parser/macro.go delete mode 100644 vendor/github.com/google/cel-go/parser/options.go delete mode 100644 vendor/github.com/google/cel-go/parser/parser.go delete mode 100644 vendor/github.com/google/cel-go/parser/unescape.go delete mode 100644 vendor/github.com/google/cel-go/parser/unparser.go delete mode 100644 vendor/github.com/h2non/filetype/.editorconfig delete mode 100644 vendor/github.com/h2non/filetype/.gitignore delete mode 100644 vendor/github.com/h2non/filetype/.travis.yml delete mode 100644 vendor/github.com/h2non/filetype/History.md delete mode 100644 vendor/github.com/h2non/filetype/LICENSE delete mode 100644 vendor/github.com/h2non/filetype/README.md delete mode 100644 vendor/github.com/h2non/filetype/filetype.go delete mode 100644 vendor/github.com/h2non/filetype/kind.go delete mode 100644 vendor/github.com/h2non/filetype/match.go delete mode 100644 vendor/github.com/h2non/filetype/matchers/application.go delete mode 100644 vendor/github.com/h2non/filetype/matchers/archive.go delete mode 100644 vendor/github.com/h2non/filetype/matchers/audio.go delete mode 100644 vendor/github.com/h2non/filetype/matchers/document.go delete mode 100644 vendor/github.com/h2non/filetype/matchers/font.go delete mode 100644 vendor/github.com/h2non/filetype/matchers/image.go delete mode 100644 vendor/github.com/h2non/filetype/matchers/isobmff/isobmff.go delete mode 100644 vendor/github.com/h2non/filetype/matchers/matchers.go delete mode 100644 vendor/github.com/h2non/filetype/matchers/video.go delete mode 100644 vendor/github.com/h2non/filetype/types/defaults.go delete mode 100644 vendor/github.com/h2non/filetype/types/mime.go delete mode 100644 vendor/github.com/h2non/filetype/types/split.go delete mode 100644 vendor/github.com/h2non/filetype/types/type.go delete mode 100644 vendor/github.com/h2non/filetype/types/types.go delete mode 100644 vendor/github.com/h2non/filetype/version.go delete mode 100644 vendor/github.com/h2non/go-is-svg/.editorconfig delete mode 100644 vendor/github.com/h2non/go-is-svg/.gitignore delete mode 100644 vendor/github.com/h2non/go-is-svg/.travis.yml delete mode 100644 vendor/github.com/h2non/go-is-svg/LICENSE delete mode 100644 vendor/github.com/h2non/go-is-svg/README.md delete mode 100644 vendor/github.com/h2non/go-is-svg/svg.go delete mode 100644 vendor/github.com/onsi/gomega/gstruct/errors/nested_types.go rename vendor/github.com/{operator-framework/operator-lifecycle-manager/pkg/package-server/apis => openshift-kni/eco-goinfra/pkg/schemes/olm/package-server}/operators/doc.go (100%) rename vendor/github.com/{operator-framework/operator-lifecycle-manager/pkg/package-server/apis => openshift-kni/eco-goinfra/pkg/schemes/olm/package-server}/operators/packagemanifest_types.go (86%) rename vendor/github.com/{operator-framework/operator-lifecycle-manager/pkg/package-server/apis => openshift-kni/eco-goinfra/pkg/schemes/olm/package-server}/operators/register.go (100%) rename vendor/github.com/{operator-framework/operator-lifecycle-manager/pkg/package-server/apis => openshift-kni/eco-goinfra/pkg/schemes/olm/package-server}/operators/v1/doc.go (100%) rename vendor/github.com/{operator-framework/operator-lifecycle-manager/pkg/package-server/apis => openshift-kni/eco-goinfra/pkg/schemes/olm/package-server}/operators/v1/packagemanifest_types.go (87%) rename vendor/github.com/{operator-framework/operator-lifecycle-manager/pkg/package-server/apis => openshift-kni/eco-goinfra/pkg/schemes/olm/package-server}/operators/v1/register.go (95%) rename vendor/github.com/{operator-framework/operator-lifecycle-manager/pkg/package-server/apis => openshift-kni/eco-goinfra/pkg/schemes/olm/package-server}/operators/v1/zz_generated.conversion.go (90%) rename vendor/github.com/{operator-framework/operator-lifecycle-manager/pkg/package-server/apis => openshift-kni/eco-goinfra/pkg/schemes/olm/package-server}/operators/v1/zz_generated.deepcopy.go (89%) rename vendor/github.com/{operator-framework/operator-lifecycle-manager/pkg/package-server/apis => openshift-kni/eco-goinfra/pkg/schemes/olm/package-server}/operators/v1/zz_generated.defaults.go (100%) rename vendor/github.com/{operator-framework/operator-lifecycle-manager/pkg/package-server/apis => openshift-kni/eco-goinfra/pkg/schemes/olm/package-server}/operators/zz_generated.deepcopy.go (89%) delete mode 100644 vendor/github.com/operator-framework/api/pkg/constraints/cel.go delete mode 100644 vendor/github.com/operator-framework/api/pkg/constraints/constraint.go delete mode 100644 vendor/github.com/operator-framework/api/pkg/operators/v1/doc.go delete mode 100644 vendor/github.com/operator-framework/api/pkg/operators/v1/groupversion_info.go delete mode 100644 vendor/github.com/operator-framework/api/pkg/operators/v1/olmconfig_types.go delete mode 100644 vendor/github.com/operator-framework/api/pkg/operators/v1/operator_types.go delete mode 100644 vendor/github.com/operator-framework/api/pkg/operators/v1/operatorcondition_types.go delete mode 100644 vendor/github.com/operator-framework/api/pkg/operators/v1/operatorgroup_types.go delete mode 100644 vendor/github.com/operator-framework/api/pkg/operators/v1/zz_generated.deepcopy.go delete mode 100644 vendor/github.com/operator-framework/api/pkg/operators/v1alpha2/doc.go delete mode 100644 vendor/github.com/operator-framework/api/pkg/operators/v1alpha2/groupversion_info.go delete mode 100644 vendor/github.com/operator-framework/api/pkg/operators/v1alpha2/operatorgroup_types.go delete mode 100644 vendor/github.com/operator-framework/api/pkg/operators/v1alpha2/zz_generated.deepcopy.go delete mode 100644 vendor/github.com/operator-framework/api/pkg/operators/v2/doc.go delete mode 100644 vendor/github.com/operator-framework/api/pkg/operators/v2/groupversion_info.go delete mode 100644 vendor/github.com/operator-framework/api/pkg/operators/v2/operatorcondition_types.go delete mode 100644 vendor/github.com/operator-framework/api/pkg/operators/v2/zz_generated.deepcopy.go delete mode 100644 vendor/github.com/operator-framework/operator-lifecycle-manager/LICENSE delete mode 100644 vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/scheme/doc.go delete mode 100644 vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/scheme/register.go delete mode 100644 vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/doc.go delete mode 100644 vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/generated_expansion.go delete mode 100644 vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/olmconfig.go delete mode 100644 vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/operator.go delete mode 100644 vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/operatorcondition.go delete mode 100644 vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/operatorgroup.go delete mode 100644 vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/operators_client.go delete mode 100644 vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/catalogsource.go delete mode 100644 vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/clusterserviceversion.go delete mode 100644 vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/doc.go delete mode 100644 vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/generated_expansion.go delete mode 100644 vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/installplan.go delete mode 100644 vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/operators_client.go delete mode 100644 vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/subscription.go delete mode 100644 vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/packagemanifest.go delete mode 100644 vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1/packagemanifest.go delete mode 100644 vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/scheme/doc.go delete mode 100644 vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/scheme/register.go delete mode 100644 vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/typed/operators/v1/doc.go delete mode 100644 vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/typed/operators/v1/generated_expansion.go delete mode 100644 vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/typed/operators/v1/operators_client.go delete mode 100644 vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/typed/operators/v1/packagemanifest.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/LICENSE delete mode 100644 vendor/github.com/operator-framework/operator-registry/alpha/model/error.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/alpha/model/model.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/alpha/property/errors.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/alpha/property/property.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/alpha/property/scheme.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/pkg/api/api_to_model.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/pkg/api/model_to_api.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/pkg/api/registry.pb.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/pkg/api/registry.proto delete mode 100644 vendor/github.com/operator-framework/operator-registry/pkg/api/registry_grpc.pb.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/pkg/image/mock.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/pkg/image/reference.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/pkg/image/registry.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/pkg/lib/semver/semver.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/pkg/prettyunmarshaler/prettyunmarshaler.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/pkg/registry/bundle.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/pkg/registry/bundlegraphloader.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/pkg/registry/channelupdateoptions.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/pkg/registry/conversion.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/pkg/registry/csv.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/pkg/registry/decode.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/pkg/registry/directoryGraphLoader.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/pkg/registry/empty.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/pkg/registry/graph.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/pkg/registry/imageinput.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/pkg/registry/interface.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/pkg/registry/parse.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/pkg/registry/populator.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/pkg/registry/registry_to_model.go delete mode 100644 vendor/github.com/operator-framework/operator-registry/pkg/registry/types.go delete mode 100644 vendor/github.com/stoewer/go-strcase/.gitignore delete mode 100644 vendor/github.com/stoewer/go-strcase/.golangci.yml delete mode 100644 vendor/github.com/stoewer/go-strcase/LICENSE delete mode 100644 vendor/github.com/stoewer/go-strcase/README.md delete mode 100644 vendor/github.com/stoewer/go-strcase/camel.go delete mode 100644 vendor/github.com/stoewer/go-strcase/doc.go delete mode 100644 vendor/github.com/stoewer/go-strcase/helper.go delete mode 100644 vendor/github.com/stoewer/go-strcase/kebab.go delete mode 100644 vendor/github.com/stoewer/go-strcase/snake.go delete mode 100644 vendor/golang.org/x/net/internal/timeseries/timeseries.go delete mode 100644 vendor/golang.org/x/net/trace/events.go delete mode 100644 vendor/golang.org/x/net/trace/histogram.go delete mode 100644 vendor/golang.org/x/net/trace/trace.go delete mode 100644 vendor/golang.org/x/text/width/kind_string.go delete mode 100644 vendor/golang.org/x/text/width/tables10.0.0.go delete mode 100644 vendor/golang.org/x/text/width/tables11.0.0.go delete mode 100644 vendor/golang.org/x/text/width/tables12.0.0.go delete mode 100644 vendor/golang.org/x/text/width/tables13.0.0.go delete mode 100644 vendor/golang.org/x/text/width/tables15.0.0.go delete mode 100644 vendor/golang.org/x/text/width/tables9.0.0.go delete mode 100644 vendor/golang.org/x/text/width/transform.go delete mode 100644 vendor/golang.org/x/text/width/trieval.go delete mode 100644 vendor/golang.org/x/text/width/width.go delete mode 100644 vendor/google.golang.org/genproto/googleapis/api/LICENSE delete mode 100644 vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/checked.pb.go delete mode 100644 vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/eval.pb.go delete mode 100644 vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/explain.pb.go delete mode 100644 vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/syntax.pb.go delete mode 100644 vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/value.pb.go delete mode 100644 vendor/google.golang.org/genproto/googleapis/rpc/LICENSE delete mode 100644 vendor/google.golang.org/genproto/googleapis/rpc/status/status.pb.go delete mode 100644 vendor/google.golang.org/grpc/AUTHORS delete mode 100644 vendor/google.golang.org/grpc/CODE-OF-CONDUCT.md delete mode 100644 vendor/google.golang.org/grpc/CONTRIBUTING.md delete mode 100644 vendor/google.golang.org/grpc/GOVERNANCE.md delete mode 100644 vendor/google.golang.org/grpc/LICENSE delete mode 100644 vendor/google.golang.org/grpc/MAINTAINERS.md delete mode 100644 vendor/google.golang.org/grpc/Makefile delete mode 100644 vendor/google.golang.org/grpc/NOTICE.txt delete mode 100644 vendor/google.golang.org/grpc/README.md delete mode 100644 vendor/google.golang.org/grpc/SECURITY.md delete mode 100644 vendor/google.golang.org/grpc/attributes/attributes.go delete mode 100644 vendor/google.golang.org/grpc/backoff.go delete mode 100644 vendor/google.golang.org/grpc/backoff/backoff.go delete mode 100644 vendor/google.golang.org/grpc/balancer/balancer.go delete mode 100644 vendor/google.golang.org/grpc/balancer/base/balancer.go delete mode 100644 vendor/google.golang.org/grpc/balancer/base/base.go delete mode 100644 vendor/google.golang.org/grpc/balancer/conn_state_evaluator.go delete mode 100644 vendor/google.golang.org/grpc/balancer/grpclb/state/state.go delete mode 100644 vendor/google.golang.org/grpc/balancer/roundrobin/roundrobin.go delete mode 100644 vendor/google.golang.org/grpc/balancer_wrapper.go delete mode 100644 vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go delete mode 100644 vendor/google.golang.org/grpc/call.go delete mode 100644 vendor/google.golang.org/grpc/channelz/channelz.go delete mode 100644 vendor/google.golang.org/grpc/clientconn.go delete mode 100644 vendor/google.golang.org/grpc/codec.go delete mode 100644 vendor/google.golang.org/grpc/codegen.sh delete mode 100644 vendor/google.golang.org/grpc/codes/code_string.go delete mode 100644 vendor/google.golang.org/grpc/codes/codes.go delete mode 100644 vendor/google.golang.org/grpc/connectivity/connectivity.go delete mode 100644 vendor/google.golang.org/grpc/credentials/credentials.go delete mode 100644 vendor/google.golang.org/grpc/credentials/insecure/insecure.go delete mode 100644 vendor/google.golang.org/grpc/credentials/tls.go delete mode 100644 vendor/google.golang.org/grpc/dialoptions.go delete mode 100644 vendor/google.golang.org/grpc/doc.go delete mode 100644 vendor/google.golang.org/grpc/encoding/encoding.go delete mode 100644 vendor/google.golang.org/grpc/encoding/proto/proto.go delete mode 100644 vendor/google.golang.org/grpc/grpclog/component.go delete mode 100644 vendor/google.golang.org/grpc/grpclog/grpclog.go delete mode 100644 vendor/google.golang.org/grpc/grpclog/logger.go delete mode 100644 vendor/google.golang.org/grpc/grpclog/loggerv2.go delete mode 100644 vendor/google.golang.org/grpc/interceptor.go delete mode 100644 vendor/google.golang.org/grpc/internal/backoff/backoff.go delete mode 100644 vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/config.go delete mode 100644 vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/gracefulswitch.go delete mode 100644 vendor/google.golang.org/grpc/internal/balancerload/load.go delete mode 100644 vendor/google.golang.org/grpc/internal/binarylog/binarylog.go delete mode 100644 vendor/google.golang.org/grpc/internal/binarylog/binarylog_testutil.go delete mode 100644 vendor/google.golang.org/grpc/internal/binarylog/env_config.go delete mode 100644 vendor/google.golang.org/grpc/internal/binarylog/method_logger.go delete mode 100644 vendor/google.golang.org/grpc/internal/binarylog/sink.go delete mode 100644 vendor/google.golang.org/grpc/internal/buffer/unbounded.go delete mode 100644 vendor/google.golang.org/grpc/internal/channelz/channel.go delete mode 100644 vendor/google.golang.org/grpc/internal/channelz/channelmap.go delete mode 100644 vendor/google.golang.org/grpc/internal/channelz/funcs.go delete mode 100644 vendor/google.golang.org/grpc/internal/channelz/logging.go delete mode 100644 vendor/google.golang.org/grpc/internal/channelz/server.go delete mode 100644 vendor/google.golang.org/grpc/internal/channelz/socket.go delete mode 100644 vendor/google.golang.org/grpc/internal/channelz/subchannel.go delete mode 100644 vendor/google.golang.org/grpc/internal/channelz/syscall_linux.go delete mode 100644 vendor/google.golang.org/grpc/internal/channelz/syscall_nonlinux.go delete mode 100644 vendor/google.golang.org/grpc/internal/channelz/trace.go delete mode 100644 vendor/google.golang.org/grpc/internal/credentials/credentials.go delete mode 100644 vendor/google.golang.org/grpc/internal/credentials/spiffe.go delete mode 100644 vendor/google.golang.org/grpc/internal/credentials/syscallconn.go delete mode 100644 vendor/google.golang.org/grpc/internal/credentials/util.go delete mode 100644 vendor/google.golang.org/grpc/internal/envconfig/envconfig.go delete mode 100644 vendor/google.golang.org/grpc/internal/envconfig/observability.go delete mode 100644 vendor/google.golang.org/grpc/internal/envconfig/xds.go delete mode 100644 vendor/google.golang.org/grpc/internal/experimental.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpclog/grpclog.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpclog/prefixLogger.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpcrand/grpcrand.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpcrand/grpcrand_go1.21.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpcsync/callback_serializer.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpcsync/event.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpcsync/oncefunc.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpcsync/pubsub.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpcutil/compressor.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpcutil/encode_duration.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpcutil/grpcutil.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpcutil/metadata.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpcutil/method.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpcutil/regex.go delete mode 100644 vendor/google.golang.org/grpc/internal/idle/idle.go delete mode 100644 vendor/google.golang.org/grpc/internal/internal.go delete mode 100644 vendor/google.golang.org/grpc/internal/metadata/metadata.go delete mode 100644 vendor/google.golang.org/grpc/internal/pretty/pretty.go delete mode 100644 vendor/google.golang.org/grpc/internal/resolver/config_selector.go delete mode 100644 vendor/google.golang.org/grpc/internal/resolver/dns/dns_resolver.go delete mode 100644 vendor/google.golang.org/grpc/internal/resolver/dns/internal/internal.go delete mode 100644 vendor/google.golang.org/grpc/internal/resolver/passthrough/passthrough.go delete mode 100644 vendor/google.golang.org/grpc/internal/resolver/unix/unix.go delete mode 100644 vendor/google.golang.org/grpc/internal/serviceconfig/duration.go delete mode 100644 vendor/google.golang.org/grpc/internal/serviceconfig/serviceconfig.go delete mode 100644 vendor/google.golang.org/grpc/internal/status/status.go delete mode 100644 vendor/google.golang.org/grpc/internal/syscall/syscall_linux.go delete mode 100644 vendor/google.golang.org/grpc/internal/syscall/syscall_nonlinux.go delete mode 100644 vendor/google.golang.org/grpc/internal/tcp_keepalive_others.go delete mode 100644 vendor/google.golang.org/grpc/internal/tcp_keepalive_unix.go delete mode 100644 vendor/google.golang.org/grpc/internal/tcp_keepalive_windows.go delete mode 100644 vendor/google.golang.org/grpc/internal/transport/bdp_estimator.go delete mode 100644 vendor/google.golang.org/grpc/internal/transport/controlbuf.go delete mode 100644 vendor/google.golang.org/grpc/internal/transport/defaults.go delete mode 100644 vendor/google.golang.org/grpc/internal/transport/flowcontrol.go delete mode 100644 vendor/google.golang.org/grpc/internal/transport/handler_server.go delete mode 100644 vendor/google.golang.org/grpc/internal/transport/http2_client.go delete mode 100644 vendor/google.golang.org/grpc/internal/transport/http2_server.go delete mode 100644 vendor/google.golang.org/grpc/internal/transport/http_util.go delete mode 100644 vendor/google.golang.org/grpc/internal/transport/logging.go delete mode 100644 vendor/google.golang.org/grpc/internal/transport/networktype/networktype.go delete mode 100644 vendor/google.golang.org/grpc/internal/transport/proxy.go delete mode 100644 vendor/google.golang.org/grpc/internal/transport/transport.go delete mode 100644 vendor/google.golang.org/grpc/keepalive/keepalive.go delete mode 100644 vendor/google.golang.org/grpc/metadata/metadata.go delete mode 100644 vendor/google.golang.org/grpc/peer/peer.go delete mode 100644 vendor/google.golang.org/grpc/picker_wrapper.go delete mode 100644 vendor/google.golang.org/grpc/pickfirst.go delete mode 100644 vendor/google.golang.org/grpc/preloader.go delete mode 100644 vendor/google.golang.org/grpc/regenerate.sh delete mode 100644 vendor/google.golang.org/grpc/resolver/dns/dns_resolver.go delete mode 100644 vendor/google.golang.org/grpc/resolver/map.go delete mode 100644 vendor/google.golang.org/grpc/resolver/resolver.go delete mode 100644 vendor/google.golang.org/grpc/resolver_wrapper.go delete mode 100644 vendor/google.golang.org/grpc/rpc_util.go delete mode 100644 vendor/google.golang.org/grpc/server.go delete mode 100644 vendor/google.golang.org/grpc/service_config.go delete mode 100644 vendor/google.golang.org/grpc/serviceconfig/serviceconfig.go delete mode 100644 vendor/google.golang.org/grpc/shared_buffer_pool.go delete mode 100644 vendor/google.golang.org/grpc/stats/handlers.go delete mode 100644 vendor/google.golang.org/grpc/stats/stats.go delete mode 100644 vendor/google.golang.org/grpc/status/status.go delete mode 100644 vendor/google.golang.org/grpc/stream.go delete mode 100644 vendor/google.golang.org/grpc/tap/tap.go delete mode 100644 vendor/google.golang.org/grpc/trace.go delete mode 100644 vendor/google.golang.org/grpc/trace_notrace.go delete mode 100644 vendor/google.golang.org/grpc/trace_withtrace.go delete mode 100644 vendor/google.golang.org/grpc/version.go delete mode 100644 vendor/google.golang.org/grpc/vet.sh delete mode 100644 vendor/google.golang.org/protobuf/encoding/protojson/decode.go delete mode 100644 vendor/google.golang.org/protobuf/encoding/protojson/doc.go delete mode 100644 vendor/google.golang.org/protobuf/encoding/protojson/encode.go delete mode 100644 vendor/google.golang.org/protobuf/encoding/protojson/well_known_types.go delete mode 100644 vendor/google.golang.org/protobuf/internal/encoding/json/decode.go delete mode 100644 vendor/google.golang.org/protobuf/internal/encoding/json/decode_number.go delete mode 100644 vendor/google.golang.org/protobuf/internal/encoding/json/decode_string.go delete mode 100644 vendor/google.golang.org/protobuf/internal/encoding/json/decode_token.go delete mode 100644 vendor/google.golang.org/protobuf/internal/encoding/json/encode.go delete mode 100644 vendor/google.golang.org/protobuf/protoadapt/convert.go delete mode 100644 vendor/google.golang.org/protobuf/types/dynamicpb/dynamic.go delete mode 100644 vendor/google.golang.org/protobuf/types/dynamicpb/types.go delete mode 100644 vendor/google.golang.org/protobuf/types/known/durationpb/duration.pb.go delete mode 100644 vendor/google.golang.org/protobuf/types/known/emptypb/empty.pb.go delete mode 100644 vendor/google.golang.org/protobuf/types/known/structpb/struct.pb.go delete mode 100644 vendor/google.golang.org/protobuf/types/known/wrapperspb/wrappers.pb.go diff --git a/go.mod b/go.mod index 8de55d04b..e98360572 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/nmstate/kubernetes-nmstate/api v0.0.0-20240605150941-df565dd7bf35 github.com/onsi/ginkgo/v2 v2.19.0 github.com/onsi/gomega v1.33.1 - github.com/openshift-kni/eco-goinfra v0.0.0-20240809133315-01bbbf4c9ede // latest + github.com/openshift-kni/eco-goinfra v0.0.0-20240809150049-0634a7a9fb27 // latest github.com/openshift-kni/k8sreporter v1.0.5 github.com/openshift/api v3.9.1-0.20191111211345-a27ff30ebf09+incompatible github.com/openshift/cluster-nfd-operator v0.0.0-20240604082319-19bf50784aa7 @@ -59,7 +59,6 @@ require ( require ( github.com/PaesslerAG/gval v1.0.0 // indirect github.com/PaesslerAG/jsonpath v0.1.1 // indirect - github.com/antlr4-go/antlr/v4 v4.13.0 // indirect github.com/expr-lang/expr v1.16.5 // indirect github.com/go-jose/go-jose/v4 v4.0.1 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect @@ -134,7 +133,6 @@ require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/btree v1.1.2 // indirect - github.com/google/cel-go v0.18.2 // indirect github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/gofuzz v1.2.0 // indirect @@ -143,8 +141,6 @@ require ( github.com/google/uuid v1.6.0 // indirect github.com/grafana-operator/grafana-operator/v4 v4.10.1 // indirect github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect - github.com/h2non/filetype v1.1.3 // indirect - github.com/h2non/go-is-svg v0.0.0-20160927212452-35e8c4b0612c // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect @@ -185,8 +181,6 @@ require ( github.com/openshift/custom-resource-status v1.1.3-0.20220503160415-f2fdb4999d87 // indirect github.com/openshift/library-go v0.0.0-20240419113445-f1541d628746 // indirect github.com/openshift/ptp-operator v0.0.0-20240404165119-29a3d7b3d60b // indirect - github.com/operator-framework/operator-lifecycle-manager v0.28.0 // indirect - github.com/operator-framework/operator-registry v1.41.0 // indirect github.com/otiai10/copy v1.14.0 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/pkg/errors v0.9.1 // indirect @@ -206,7 +200,6 @@ require ( github.com/spf13/cast v1.6.0 // indirect github.com/spf13/cobra v1.8.0 // indirect github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace // indirect - github.com/stoewer/go-strcase v1.3.0 // indirect github.com/thoas/go-funk v0.9.2 // indirect github.com/vincent-petithory/dataurl v1.0.0 // indirect github.com/xlab/treeprint v1.2.0 // indirect @@ -225,9 +218,6 @@ require ( golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.22.0 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be // indirect - google.golang.org/grpc v1.63.2 // indirect google.golang.org/protobuf v1.34.1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect diff --git a/go.sum b/go.sum index 582e5a66a..80a5bbce3 100644 --- a/go.sum +++ b/go.sum @@ -754,8 +754,6 @@ cloud.google.com/go/workflows v1.11.1/go.mod h1:Z+t10G1wF7h8LgdY/EmRcQY8ptBD/nvo dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zumjgTw83q2ge/PI+yyw8= git.sr.ht/~sbinet/gg v0.3.1/go.mod h1:KGYtlADtqsqANL9ueOFkWymvzUvLMQllU5Ixo+8v3pc= -github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU= -github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= github.com/Azure/azure-sdk-for-go v62.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= @@ -772,8 +770,6 @@ github.com/Azure/go-autorest/autorest/validation v0.3.1/go.mod h1:yhLgjC0Wda5DYX github.com/Azure/go-autorest/logger v0.2.1/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8= github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= -github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/IBM/keyprotect-go-client v0.5.1/go.mod h1:5TwDM/4FRJq1ZOlwQL1xFahLWQ3TveR88VmL1u3njyI= github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk= @@ -788,10 +784,6 @@ github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0 github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA= github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM= -github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= -github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= -github.com/Microsoft/hcsshim v0.12.0-rc.3 h1:5GNGrobGs/sN/0nFO21W9k4lFn+iXXZAE8fCZbmdRak= -github.com/Microsoft/hcsshim v0.12.0-rc.3/go.mod h1:WuNfcaYNaw+KpCEsZCIM6HCEmu0c5HfXpi+dDSmveP0= github.com/NVIDIA/gpu-operator v1.11.1 h1:MuM3nFga8dcK0krgxarYaSmpGSnFYOl2zBQRBNvHKD0= github.com/NVIDIA/gpu-operator v1.11.1/go.mod h1:cKk+zdpWTj5fR7nRri+DzFoW8aG5iD3RkoYOMCMcNEU= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= @@ -822,8 +814,6 @@ github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8V github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df/go.mod h1:pSwJ0fSY5KhvocuWSx4fz3BA8OrA1bQn+K1Eli3BRwM= -github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI= -github.com/antlr4-go/antlr/v4 v4.13.0/go.mod h1:pfChB/xh/Unjila75QW7+VU4TSnWnnk9UTnmpPaOR2g= github.com/apache/arrow/go/v10 v10.0.1/go.mod h1:YvhnlEePVnBS4+0z3fhPfUy7W1Ikj0Ih0vcRo/gZ1M0= github.com/apache/arrow/go/v11 v11.0.0/go.mod h1:Eg5OsL5H+e299f7u5ssuXsuHQVEGC4xei5aX110hRiI= github.com/apache/arrow/go/v12 v12.0.0/go.mod h1:d+tV/eHZZ7Dz7RPrFKtPK02tpr+c9/PEd/zm8mDS9Vg= @@ -860,8 +850,6 @@ github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= -github.com/bshuster-repo/logrus-logstash-hook v1.0.0 h1:e+C0SB5R1pu//O4MQ3f9cFuPGoOVeF2fE4Og9otCc70= -github.com/bshuster-repo/logrus-logstash-hook v1.0.0/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk= github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= github.com/cavaliergopher/cpio v1.0.1 h1:KQFSeKmZhv0cr+kawA3a0xTQCU4QxXF1vhU7P7av2KM= @@ -869,15 +857,12 @@ github.com/cavaliergopher/cpio v1.0.1/go.mod h1:pBdaqQjnvXxdS/6CvNDwIANIFSP0xRKI github.com/cavaliergopher/grab/v3 v3.0.1 h1:4z7TkBfmPjmLAAmkkAZNX/6QJ1nNFdv3SdIHXju0Fr4= github.com/cavaliergopher/grab/v3 v3.0.1/go.mod h1:1U/KNnD+Ft6JJiYoYBAimKH2XrYptb8Kl3DFGmsjpq4= github.com/cenkalti/backoff v2.1.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= -github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/cenkalti/backoff/v3 v3.0.0/go.mod h1:cIeZDE3IrqwwJl6VUwCN6trj1oXrTS4rc0ij+ULvLYs= github.com/cenkalti/backoff/v3 v3.2.2 h1:cfUAAO3yvKMYKPrvhDuHSwQnhZNk/RMHKdZqKTxfm6M= github.com/cenkalti/backoff/v3 v3.2.2/go.mod h1:cIeZDE3IrqwwJl6VUwCN6trj1oXrTS4rc0ij+ULvLYs= github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= -github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= -github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw= @@ -911,35 +896,10 @@ github.com/cncf/xds/go v0.0.0-20230310173818-32f1caf87195/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20230428030218-4003588d1b74/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/datadriven v1.0.2/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= -github.com/containerd/cgroups/v3 v3.0.2 h1:f5WFqIVSgo5IZmtTT3qVBo6TzI1ON6sycSBKkymb9L0= -github.com/containerd/cgroups/v3 v3.0.2/go.mod h1:JUgITrzdFqp42uI2ryGA+ge0ap/nxzYgkGmIcetmErE= -github.com/containerd/containerd v1.7.16 h1:7Zsfe8Fkj4Wi2My6DXGQ87hiqIrmOXolm72ZEkFU5Mg= -github.com/containerd/containerd v1.7.16/go.mod h1:NL49g7A/Fui7ccmxV6zkBWwqMgmMxFWzujYCc+JLt7k= -github.com/containerd/continuity v0.4.3 h1:6HVkalIp+2u1ZLH1J/pYX2oBVXlJZvh1X1A7bEZ9Su8= -github.com/containerd/continuity v0.4.3/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ= -github.com/containerd/errdefs v0.1.0 h1:m0wCRBiu1WJT/Fr+iOoQHMQS/eP5myQ8lCv4Dz5ZURM= -github.com/containerd/errdefs v0.1.0/go.mod h1:YgWiiHtLmSeBrvpw+UfPijzbLaB77mEG1WwJTDETIV0= -github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= -github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= -github.com/containerd/ttrpc v1.2.3 h1:4jlhbXIGvijRtNC8F/5CpuJZ7yKOBFGFOOXg1bkISz0= -github.com/containerd/ttrpc v1.2.3/go.mod h1:ieWsXucbb8Mj9PH0rXCw1i8IunRbbAiDkpXkbfflWBM= -github.com/containerd/typeurl/v2 v2.1.1 h1:3Q4Pt7i8nYwy2KmQWIw2+1hTvwTE/6w9FqcttATPO/4= -github.com/containerd/typeurl/v2 v2.1.1/go.mod h1:IDp2JFvbwZ31H8dQbEIY7sDl2L3o3HZj1hsSQlywkQ0= github.com/containernetworking/cni v1.2.1-0.20240513144334-1e7858f9879a h1:+ZeeuLIKTxF+PrcvI7j31Yk7/bWp1MZFVebVjEYy1ms= github.com/containernetworking/cni v1.2.1-0.20240513144334-1e7858f9879a/go.mod h1:RbSTl6BZ50vy9XlUsGY3U0OF2H7nwaQguD0dcNsPSxo= github.com/containernetworking/plugins v1.1.0 h1:kTIldaDo9SlbQsjhUKvDx0v9q7zyIFJH/Rm9F4xRBro= github.com/containernetworking/plugins v1.1.0/go.mod h1:Sr5TH/eBsGLXK/h71HeLfX19sZPp3ry5uHSkI4LPxV8= -github.com/containers/common v0.58.2 h1:5nu9lQz4QNSgovNk7NRk33SkqkVNKYoXh7L6gXmACow= -github.com/containers/common v0.58.2/go.mod h1:l3vMqanJGj7tZ3W/i76gEJ128VXgFUO1tLaohJXPvdk= -github.com/containers/image v3.0.2+incompatible h1:B1lqAE8MUPCrsBLE86J0gnXleeRq8zJnQryhiiGQNyE= -github.com/containers/image/v5 v5.31.0 h1:eDFVlz5XaYICxe9dXpf23htEKvyosgkl62mJlIATXE4= -github.com/containers/image/v5 v5.31.0/go.mod h1:5QfOqSackPkSbF7Qxc1DnVNnPJKQ+KWLkfEfDpK590Q= -github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 h1:Qzk5C6cYglewc+UyGf6lc8Mj2UaPTHy/iF2De0/77CA= -github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01/go.mod h1:9rfv8iPl1ZP7aqh9YA68wnZv2NUDbXdcdPHVz0pFbPY= -github.com/containers/ocicrypt v1.1.9 h1:2Csfba4jse85Raxk5HIyEk8OwZNjRvfkhEGijOjIdEM= -github.com/containers/ocicrypt v1.1.9/go.mod h1:dTKx1918d8TDkxXvarscpNVY+lyPakPNFN4jwA9GBys= -github.com/containers/storage v1.54.0 h1:xwYAlf6n9OnIlURQLLg3FYHbO74fQ/2W2N6EtQEUM4I= -github.com/containers/storage v1.54.0/go.mod h1:PlMOoinRrBSnhYODLxt4EXl0nmJt+X0kjG0Xdt9fMTw= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/bbolt v1.3.3/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= @@ -983,29 +943,7 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/distribution/distribution/v3 v3.0.0-alpha.1 h1:jn7I1gvjOvmLztH1+1cLiUFud7aeJCIQcgzugtwjyJo= -github.com/distribution/distribution/v3 v3.0.0-alpha.1/go.mod h1:LCp4JZp1ZalYg0W/TN05jarCQu+h4w7xc7ZfQF4Y/cY= -github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= -github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= -github.com/docker/cli v26.1.3+incompatible h1:bUpXT/N0kDE3VUHI2r5VMsYQgi38kYuoC0oL9yt3lqc= -github.com/docker/cli v26.1.3+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= -github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= -github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v26.1.3+incompatible h1:lLCzRbrVZrljpVNobJu1J2FHk8V0s4BawoZippkc+xo= -github.com/docker/docker v26.1.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/docker-credential-helpers v0.8.1 h1:j/eKUktUltBtMzKqmfLB0PAgqYyMHOp5vfsD1807oKo= -github.com/docker/docker-credential-helpers v0.8.1/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M= -github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= -github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= -github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c h1:+pKlWGMw7gf6bQ+oDZB4KHQFypsfjYlq/C4rfL7D3g8= -github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c/go.mod h1:Uw6UezgYA44ePAFQYUehOuCzmy5zmg/+nl2ZfMWGkpA= -github.com/docker/go-metrics v0.0.1 h1:AgB/0SvBxihN0X8OR4SjsblXkbMvalQ8cjmtKQ2rQV8= -github.com/docker/go-metrics v0.0.1/go.mod h1:cG1hvH2utMXtqgqqYE9plW6lDxS3/5ayHzueweSI3Vw= -github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= -github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= @@ -1050,8 +988,6 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= -github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= @@ -1098,7 +1034,6 @@ github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbV github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-logr/zapr v1.2.3/go.mod h1:eIauM6P8qSvTw5o2ez6UEAfGjQKrxQTl5EoK+Qa2oG4= github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= @@ -1191,8 +1126,6 @@ github.com/golang-jwt/jwt/v4 v4.2.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzw github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/golang-migrate/migrate/v4 v4.17.1 h1:4zQ6iqL6t6AiItphxJctQb3cFqWiSpMnX7wLTPnnYO4= -github.com/golang-migrate/migrate/v4 v4.17.1/go.mod h1:m8hinFyWBn0SA4QKHuKh175Pm9wjmxj3S2Mia7dbXzM= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= @@ -1243,8 +1176,6 @@ github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9 github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= github.com/google/cel-go v0.17.7/go.mod h1:HXZKzB0LXqer5lHHgfWAnlYwJaQBDKMjxjulNQzhwhY= -github.com/google/cel-go v0.18.2 h1:L0B6sNBSVmt0OyECi8v6VOS74KOc9W/tLiWKfZABvf4= -github.com/google/cel-go v0.18.2/go.mod h1:kWcIzTsPX0zmQ+H3TirHstLLf9ep5QTsZBN9u4dOYLg= github.com/google/flatbuffers v2.0.8+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/gnostic v0.5.7-v3refs/go.mod h1:73MKFl6jIHelAJNaBGFzt3SPtZULs9dYrGFt8OiIsHQ= github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= @@ -1329,11 +1260,7 @@ github.com/googleapis/gnostic v0.5.1/go.mod h1:6U4PtQXGIEt/Z3h5MAT7FNofLnw9vXk2c github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyEE= -github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= -github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= -github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= @@ -1349,17 +1276,10 @@ github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmg github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM= -github.com/h2non/filetype v1.1.3 h1:FKkx9QbD7HR/zjK1Ia5XiBsq9zdLi5Kf3zGyFTAFkGg= -github.com/h2non/filetype v1.1.3/go.mod h1:319b3zT68BvV+WRj7cwy856M2ehB3HqNOt6sy1HndBY= -github.com/h2non/go-is-svg v0.0.0-20160927212452-35e8c4b0612c h1:fEE5/5VNnYUoBOj2I9TP8Jc+a7lge3QWn9DKE7NCwfc= -github.com/h2non/go-is-svg v0.0.0-20160927212452-35e8c4b0612c/go.mod h1:ObS/W+h8RYb1Y7fYivughjxojTmIu5iAIjSrSLCLeqE= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= @@ -1404,11 +1324,6 @@ github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09 github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= -github.com/hashicorp/golang-lru/arc/v2 v2.0.5 h1:l2zaLDubNhW4XO3LnliVj0GXO3+/CGNJAg1dcN2Fpfw= -github.com/hashicorp/golang-lru/arc/v2 v2.0.5/go.mod h1:ny6zBSQZi2JxIeYcv7kt2sH2PXJtirBN7RDhRpxPkxU= -github.com/hashicorp/golang-lru/v2 v2.0.5 h1:wW7h1TG88eUIJ2i69gaE3uNVtEPIagzhGvHgwfx2Vm4= -github.com/hashicorp/golang-lru/v2 v2.0.5/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/hcl v1.0.1-vault-5 h1:kI3hhbbyzr4dldA8UdTb7ZlVVlI2DACdCfz31RPDgJM= github.com/hashicorp/hcl v1.0.1-vault-5/go.mod h1:XYhtn6ijBSAj6n4YqAaf7RBPS4I06AItNorpy+MoQNM= @@ -1486,8 +1401,6 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/klauspost/asmfmt v1.3.2/go.mod h1:AG8TuvYojzulgDAMCnYn50l/5QV3Bs/tp6j0HLHbNSE= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= -github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU= -github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -1545,8 +1458,6 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= -github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U= -github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/metal3-io/baremetal-operator/apis v0.6.1 h1:CL5paLPWn0VEAcdtGaKKNMCR9AVYXjSuiO83vwlOHRI= @@ -1578,16 +1489,8 @@ github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg= -github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc= github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8= github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= -github.com/moby/sys/mountinfo v0.7.1 h1:/tTvQaSJRr2FshkhXiIpux6fQ2Zvc4j7tAhMTStAG2g= -github.com/moby/sys/mountinfo v0.7.1/go.mod h1:IJb6JQeOklcdMU9F5xQ8ZALD+CUr5VlGpwtX+VE0rpI= -github.com/moby/sys/sequential v0.5.0 h1:OPvI35Lzn9K04PBbCLW0g4LcFAJgHsvXsRyewg5lXtc= -github.com/moby/sys/sequential v0.5.0/go.mod h1:tH2cOOs5V9MlPiXcQzRC+eEyab644PWKGRYaaV5ZZlo= -github.com/moby/sys/user v0.1.0 h1:WmZ93f5Ux6het5iituh9x2zAG7NFY9Aqi49jjE1PaQg= -github.com/moby/sys/user v0.1.0/go.mod h1:fKJhFOnsCN6xZ5gSfbM6zaHGgDJMrqt9/reuj4T7MmU= github.com/moby/term v0.0.0-20221205130635-1aeaba878587/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= @@ -1669,16 +1572,10 @@ github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3ev github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0= -github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= -github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= -github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM= -github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE7dzrbT927iTk= -github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/openshift-kni/cluster-group-upgrades-operator v0.0.0-20240423171335-f07cdbf8af2c h1:wAPCXsnAXOUAJ5DYlVgGUcV9YBSiVlH4o9tbQ9py8ZY= github.com/openshift-kni/cluster-group-upgrades-operator v0.0.0-20240423171335-f07cdbf8af2c/go.mod h1:hkzqKpmQvh7vgPx8Hw6IExJorKPM0dEeJdOXjIW3gNw= -github.com/openshift-kni/eco-goinfra v0.0.0-20240809133315-01bbbf4c9ede h1:v6GQ4N7NxraI01w77+V+y7LRIZpExkCJq9lj5BowU8I= -github.com/openshift-kni/eco-goinfra v0.0.0-20240809133315-01bbbf4c9ede/go.mod h1:8ZRjyXSCF76jL77Cd5EQucWPIUTabUM3aI5JblC/vMk= +github.com/openshift-kni/eco-goinfra v0.0.0-20240809150049-0634a7a9fb27 h1:QdUSvJsUF0V/l0j8GWubibMgvc5YVet4YBCylJim29o= +github.com/openshift-kni/eco-goinfra v0.0.0-20240809150049-0634a7a9fb27/go.mod h1:tqKhg1yCCQCQanRagr2t2AaYu4+8dtfDam95KoQ6xvA= github.com/openshift-kni/k8sreporter v1.0.5 h1:1GYBc/BTZyVoXilHef43v9A8BSzw700zAPZ6zsZvo6Y= github.com/openshift-kni/k8sreporter v1.0.5/go.mod h1:fg8HI9yxiKAi6UzR6NTtrmQmA2WKzUqmkRUHwQ1+Bj8= github.com/openshift-kni/lifecycle-agent v0.0.0-20240606123201-0c45cd13c2f1 h1:y+0Ecc+MSZA/GNS3VOpKq+XK9x8qoNA7TlyHvqbVbpw= @@ -1715,10 +1612,6 @@ github.com/openshift/sriov-network-operator v0.0.0-20240508132640-2b61056c9758/g github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/operator-framework/api v0.23.0 h1:kHymOwcHBpBVujT49SKOCd4EVG7Odwj4wl3NbOR2LLA= github.com/operator-framework/api v0.23.0/go.mod h1:oKcFOz+Xc1UhMi2Pzcp6qsO7wjS4r+yP7EQprQBXrfM= -github.com/operator-framework/operator-lifecycle-manager v0.28.0 h1:4mgPKwDp8p3giQtHEvunNVcYlgY17vqx/RKgwjTc/2w= -github.com/operator-framework/operator-lifecycle-manager v0.28.0/go.mod h1:JfufNEB+v2NVuVshDN1tuYjv+zvXvFYrWiINQA3Anok= -github.com/operator-framework/operator-registry v1.41.0 h1:MFLrMIce1biq6Gd0gsDnjpvYMXwDjoM7I5YdtvUYOLw= -github.com/operator-framework/operator-registry v1.41.0/go.mod h1:hvOar2ikD/BhyG+I6gGHe85cdqup7NV5b8LkP18H7wU= github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU= github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w= github.com/otiai10/mint v1.5.1 h1:XaPLeE+9vGbuyEHem1JNk3bYc7KKqyI/na0/mLd/Kks= @@ -1732,8 +1625,6 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9 github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= -github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 h1:Ii+DKncOVM8Cu1Hc+ETb5K+23HdAMvESYE3ZJ5b5cMI= -github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE= github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY= github.com/phpdave11/gofpdi v1.0.12/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= github.com/phpdave11/gofpdi v1.0.13/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= @@ -1810,12 +1701,6 @@ github.com/red-hat-storage/ocs-operator v0.4.13 h1:+FdRGqgewn7v22LvhQUV8iSzLm8d6 github.com/red-hat-storage/ocs-operator v0.4.13/go.mod h1:92CGJGBXykejC89+h8s0pohpb0JRwfwPE9IwUNF5+sY= github.com/red-hat-storage/odf-operator v0.0.0-20240703093545-0e22236e2160 h1:g54q5MJklMCVUwW4OJoCuaF94HiEHQj5pzcEau/o64U= github.com/red-hat-storage/odf-operator v0.0.0-20240703093545-0e22236e2160/go.mod h1:uJqcyW9de0frTa708MZR++0SgLvIHiwL793tY6EAuqM= -github.com/redis/go-redis/extra/rediscmd/v9 v9.0.5 h1:EaDatTxkdHG+U3Bk4EUr+DZ7fOGwTfezUiUJMaIcaho= -github.com/redis/go-redis/extra/rediscmd/v9 v9.0.5/go.mod h1:fyalQWdtzDBECAQFBJuQe5bzQ02jGd5Qcbgb97Flm7U= -github.com/redis/go-redis/extra/redisotel/v9 v9.0.5 h1:EfpWLLCyXw8PSM2/XNJLjI3Pb27yVE+gIAfeqp8LUCc= -github.com/redis/go-redis/extra/redisotel/v9 v9.0.5/go.mod h1:WZjPDy7VNzn77AAfnAfVjZNvfJTYfPetfZk5yoSTLaQ= -github.com/redis/go-redis/v9 v9.5.1 h1:H1X4D3yHPaYrkL5X06Wh6xNVM/pX0Ft4RV0vMGvLBh8= -github.com/redis/go-redis/v9 v9.5.1/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rh-ecosystem-edge/kernel-module-management v0.0.0-20240605101434-e1de2798b3c4 h1:UJTG3zw+Y8MJckZV2JgxTij8mwjWSNc7il+HpVWCXKg= @@ -1894,8 +1779,6 @@ github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5q github.com/stmcginnis/gofish v0.15.1-0.20231121142100-22a60a77be91 h1:WmABtU8y6kTgzoVUn3FWCQGAfyodve3uz3xno28BrRs= github.com/stmcginnis/gofish v0.15.1-0.20231121142100-22a60a77be91/go.mod h1:BLDSFTp8pDlf/xDbLZa+F7f7eW0E/CHCboggsu8CznI= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= -github.com/stoewer/go-strcase v1.3.0 h1:g0eASXYtp+yvN9fK8sH94oCIk0fau9uV1/ZdJ0AVEzs= -github.com/stoewer/go-strcase v1.3.0/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8wodgtPmh1xo= github.com/stolostron/cluster-lifecycle-api v0.0.0-20240109072430-f5fe6043d1f8 h1:DRFh4ML+WuDovJsrdgszqMQ4+qGznlYlX9/pItxWwQ8= github.com/stolostron/cluster-lifecycle-api v0.0.0-20240109072430-f5fe6043d1f8/go.mod h1:ZNQ3Rttgk4HEreCHfocrhXavLDaUgHbZaUqk5dP8/As= github.com/stolostron/klusterlet-addon-controller v0.0.0-20240606130554-01338045271a h1:eBHb7E/A7Ev2CnggwCKfGpV7nTltmQhK+QYiMEls+AY= @@ -1922,8 +1805,6 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= -github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 h1:kdXcSzyDtseVEc4yCz2qF8ZrQvIDBJLl4S1c3GCXmoI= -github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/thoas/go-funk v0.9.2 h1:oKlNYv0AY5nyf9g+/GhMgS/UO2ces0QRdPKwkhY3VCk= github.com/thoas/go-funk v0.9.2/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= @@ -1965,8 +1846,6 @@ github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.8/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= -go.etcd.io/bbolt v1.3.10 h1:+BqfJTcCzTItrop8mq/lbzL8wSGtj94UO/3U31shqG0= -go.etcd.io/bbolt v1.3.10/go.mod h1:bK3UQLPJZly7IlNmV7uVHJDxfe5aK9Ll93e/74Y9oEQ= go.etcd.io/etcd/api/v3 v3.5.10/go.mod h1:TidfmT4Uycad3NM/o25fG3J07odo4GBB9hoxaodFCtI= go.etcd.io/etcd/client/pkg/v3 v3.5.10/go.mod h1:DYivfIviIuQ8+/lCq4vcxuseg2P2XbHygkKwFo9fc8U= go.etcd.io/etcd/client/v2 v2.305.10/go.mod h1:m3CKZi69HzilhVqtPDcjhSGp+kA1OmbNn0qamH80xjA= @@ -1987,65 +1866,32 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/contrib/exporters/autoexport v0.46.1 h1:ysCfPZB9AjUlMa1UHYup3c9dAOCMQX/6sxSfPBUoxHw= -go.opentelemetry.io/contrib/exporters/autoexport v0.46.1/go.mod h1:ha0aiYm+DOPsLHjh0zoQ8W8sLT+LJ58J3j47lGpSLrU= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.25.0/go.mod h1:E5NNboN0UqSAki0Atn9kVwaN7I+l25gGxDqBueo/74E= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.42.0/go.mod h1:5z+/ZWJQKXa9YT34fQNx5K8Hd1EoIhvtUygUQPqEOgQ= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.44.0/go.mod h1:SeQhzAEccGVZVEy7aH87Nh0km+utSpo1pTv6eMMop48= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= go.opentelemetry.io/otel v1.0.1/go.mod h1:OPEOD4jIT2SlZPMmwT6FqZz2C0ZNdQqiWcoK6M0SNFU= go.opentelemetry.io/otel v1.16.0/go.mod h1:vl0h9NUa1D5s1nv3A5vZOYWn8av4K8Ml6JDeHrT/bx4= go.opentelemetry.io/otel v1.18.0/go.mod h1:9lWqYO0Db579XzVuCKFNPDl4s73Voa+zEck3wHaAYQI= go.opentelemetry.io/otel v1.19.0/go.mod h1:i0QyjOq3UPoTzff0PJB2N66fb4S0+rSbSB15/oyH9fY= -go.opentelemetry.io/otel v1.26.0 h1:LQwgL5s/1W7YiiRwxf03QGnWLb2HW4pLiAhaA5cZXBs= -go.opentelemetry.io/otel v1.26.0/go.mod h1:UmLkJHUAidDval2EICqBMbnAd0/m2vmpf/dAM+fvFs4= -go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.26.0 h1:+hm+I+KigBy3M24/h1p/NHkUx/evbLH0PNcjpMyCHc4= -go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.26.0/go.mod h1:NjC8142mLvvNT6biDpaMjyz78kyEHIwAJlSX0N9P5KI= -go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.26.0 h1:HGZWGmCVRCVyAs2GQaiHQPbDHo+ObFWeUEOd+zDnp64= -go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.26.0/go.mod h1:SaH+v38LSCHddyk7RGlU9uZyQoRrKao6IBnJw6Kbn+c= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.1/go.mod h1:Kv8liBeVNFkkkbilbgWRpV+wWuu+H5xdOT6HAgd30iw= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0/go.mod h1:IPtUMKL4O3tH5y+iXVyAXqpAwMuzC1IrxVS81rummfE= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.23.1 h1:o8iWeVFa1BcLtVEV0LzrCxV2/55tB3xLxADr6Kyoey4= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.23.1/go.mod h1:SEVfdK4IoBnbT2FXNM/k8yC08MrfbhWk3U4ljM8B3HE= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.1/go.mod h1:xOvWoTOrQjxjW61xtOmD/WKGRYb/P4NzRo3bs65U6Rk= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0/go.mod h1:0+KuTDyKL4gjKCF75pHOX4wuzYDUZYfAQdSu43o+Z2I= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.23.1 h1:p3A5+f5l9e/kuEBwLOrnpkIDHQFlHmbiVxMURWRK6gQ= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.23.1/go.mod h1:OClrnXUjBqQbInvjJFjYSnMxBSCXBF8r3b34WqjiIrQ= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0 h1:digkEZCJWobwBqMwC0cwCq8/wkkRy/OowZg5OArWZrM= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0/go.mod h1:/OpE/y70qVkndM0TrxT4KBoN3RsFZP0QaofcfYrj76I= -go.opentelemetry.io/otel/exporters/prometheus v0.44.0 h1:08qeJgaPC0YEBu2PQMbqU3rogTlyzpjhCI2b58Yn00w= -go.opentelemetry.io/otel/exporters/prometheus v0.44.0/go.mod h1:ERL2uIeBtg4TxZdojHUwzZfIFlUIjZtxubT5p4h1Gjg= -go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.44.0 h1:dEZWPjVN22urgYCza3PXRUGEyCB++y1sAqm6guWFesk= -go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.44.0/go.mod h1:sTt30Evb7hJB/gEk27qLb1+l9n4Tb8HvHkR0Wx3S6CU= -go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 h1:VhlEQAPp9R1ktYfrPk5SOryw1e9LDDTZCbIPFrho0ec= -go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0/go.mod h1:kB3ufRbfU+CQ4MlUcqtW8Z7YEOBeK2DJ6CmR5rYYF3E= go.opentelemetry.io/otel/metric v1.16.0/go.mod h1:QE47cpOmkwipPiefDwo2wDzwJrlfxxNYodqc4xnGCo4= go.opentelemetry.io/otel/metric v1.18.0/go.mod h1:nNSpsVDjWGfb7chbRLUNW+PBNdcSTHD4Uu5pfFMOI0k= go.opentelemetry.io/otel/metric v1.19.0/go.mod h1:L5rUsV9kM1IxCj1MmSdS+JQAcVm319EUrDVLrt7jqt8= -go.opentelemetry.io/otel/metric v1.26.0 h1:7S39CLuY5Jgg9CrnA9HHiEjGMF/X2VHvoXGgSllRz30= -go.opentelemetry.io/otel/metric v1.26.0/go.mod h1:SY+rHOI4cEawI9a7N1A4nIg/nTQXe1ccCNWYOJUrpX4= go.opentelemetry.io/otel/sdk v1.0.1/go.mod h1:HrdXne+BiwsOHYYkBE5ysIcv2bvdZstxzmCQhxTcZkI= go.opentelemetry.io/otel/sdk v1.19.0/go.mod h1:NedEbbS4w3C6zElbLdPJKOpJQOrGUJ+GfzpjUvI0v1A= -go.opentelemetry.io/otel/sdk v1.26.0 h1:Y7bumHf5tAiDlRYFmGqetNcLaVUZmh4iYfmGxtmz7F8= -go.opentelemetry.io/otel/sdk v1.26.0/go.mod h1:0p8MXpqLeJ0pzcszQQN4F0S5FVjBLgypeGSngLsmirs= -go.opentelemetry.io/otel/sdk/metric v1.26.0 h1:cWSks5tfriHPdWFnl+qpX3P681aAYqlZHcAyHw5aU9Y= -go.opentelemetry.io/otel/sdk/metric v1.26.0/go.mod h1:ClMFFknnThJCksebJwz7KIyEDHO+nTB6gK8obLy8RyE= go.opentelemetry.io/otel/trace v1.0.1/go.mod h1:5g4i4fKLaX2BQpSBsxw8YYcgKpMMSW3x7ZTuYBr3sUk= go.opentelemetry.io/otel/trace v1.16.0/go.mod h1:Yt9vYq1SdNz3xdjZZK7wcXv1qv2pwLkqr2QVwea0ef0= go.opentelemetry.io/otel/trace v1.18.0/go.mod h1:T2+SGJGuYZY3bjj5rgh/hN7KIrlpWC5nS8Mjvzckz+0= go.opentelemetry.io/otel/trace v1.19.0/go.mod h1:mfaSyvGyEJEI0nyV2I4qhNQnbBOUUmYZpYojqMnX2vo= -go.opentelemetry.io/otel/trace v1.26.0 h1:1ieeAUb4y0TE26jUFrCIXKpTuVK7uJGN9/Z/2LP5sQA= -go.opentelemetry.io/otel/trace v1.26.0/go.mod h1:4iDxvGDQuUkHve82hJJ8UqrwswHYsZuWCBllGV2U2y0= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.opentelemetry.io/proto/otlp v0.9.0/go.mod h1:1vKfU9rv61e9EVGthD1zNvUbiwPcimSsOPU9brfSHJg= go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= -go.opentelemetry.io/proto/otlp v1.2.0 h1:pVeZGk7nXDC9O2hncA6nHldxEjm6LByfA2aN8IOkz94= -go.opentelemetry.io/proto/otlp v1.2.0/go.mod h1:gGpR8txAl5M03pDhMC79G6SdqNV26naRm/KDsgaHD8A= go.starlark.net v0.0.0-20240123142251-f86470692795 h1:LmbG8Pq7KDGkglKVn8VpZOZj6vb9b8nKEGcg9l03epM= go.starlark.net v0.0.0-20240123142251-f86470692795/go.mod h1:LcLNIzVOMp4oV+uusnpk+VU+SzXaJakUuBjoCSWH5dM= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= @@ -2802,8 +2648,6 @@ google.golang.org/genproto v0.0.0-20230629202037-9506855d4529/go.mod h1:xZnkP7mR google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130/go.mod h1:O9kGHb51iE/nOGvQaDUuadVYqovW56s5emA88lQnj6Y= google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98/go.mod h1:S7mY02OqCJTD0E1OiQy1F72PWFB4bZJ87cAtLPYgDR0= google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5/go.mod h1:oH/ZOT02u4kWEp7oYBGYFFkCdKS/uYR9Z7+0/xuuFp8= -google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY= -google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo= google.golang.org/genproto/googleapis/api v0.0.0-20230525234020-1aefcd67740a/go.mod h1:ts19tUU+Z0ZShN1y3aPyq2+O3d5FUNNgT6FtOzmrNn8= google.golang.org/genproto/googleapis/api v0.0.0-20230525234035-dd9d682886f9/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig= google.golang.org/genproto/googleapis/api v0.0.0-20230526203410-71b5a4ffd15e/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig= @@ -2812,8 +2656,6 @@ google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529/go. google.golang.org/genproto/googleapis/api v0.0.0-20230706204954-ccb25ca9f130/go.mod h1:mPBs5jNgx2GuQGvFwUvVKqtn6HsUw9nP64BedgvqEsQ= google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ= google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ= -google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda h1:b6F6WIV4xHHD0FA4oIyzU6mHWg2WI2X1RBehwa5QN38= -google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda/go.mod h1:AHcE/gZH76Bk/ROZhQphlRoWo5xKDEtz3eVEO1LfA8c= google.golang.org/genproto/googleapis/bytestream v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:ylj+BE99M198VPbBh6A8d9n3w8fChvyLK3wwBOjXBFA= google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234015-3fc162c6f38a/go.mod h1:xURIpW9ES5+/GZhnV6beoEtxQrnkRGIfP5VQG2tCBLc= google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= @@ -2824,8 +2666,6 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20230706204954-ccb25ca9f130/go. google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be h1:LG9vZxsWGOmUKieR8wPAUR3u3MpnYFQZROPIMaXh7/A= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -2873,8 +2713,6 @@ google.golang.org/grpc v1.56.2/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpX google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= google.golang.org/grpc v1.58.2/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= -google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= -google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -3067,8 +2905,6 @@ rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.28.0/go.mod h1:VHVDI/KrK4fjnV61bE2g3sA7tiETLn8sooImelsCx3Y= -sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.29.0 h1:/U5vjBbQn3RChhv7P11uhYvCSm5G2GaIi5AIGBS6r4c= -sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.29.0/go.mod h1:z7+wmGM2dfIiLRfrC6jb5kV2Mq/sK1ZP303cxzkV5Y4= sigs.k8s.io/container-object-storage-interface-api v0.1.0 h1:8tB6JFQhbQIC1hwGQ+q4+tmSSNfjKemb7bFI6C0CK/4= sigs.k8s.io/container-object-storage-interface-api v0.1.0/go.mod h1:YiB+i/UGkzqgODDhRG3u7jkbWkQcoUeLEJ7hwOT/2Qk= sigs.k8s.io/controller-runtime v0.17.5 h1:1FI9Lm7NiOOmBsgTV36/s2XrEFXnO2C4sbg/Zme72Rw= diff --git a/vendor/github.com/antlr4-go/antlr/v4/.gitignore b/vendor/github.com/antlr4-go/antlr/v4/.gitignore deleted file mode 100644 index 38ea34ff5..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/.gitignore +++ /dev/null @@ -1,18 +0,0 @@ -### Go template - -# Binaries for programs and plugins -*.exe -*.exe~ -*.dll -*.so -*.dylib - -# Test binary, built with `go test -c` -*.test - - -# Go workspace file -go.work - -# No Goland stuff in this repo -.idea diff --git a/vendor/github.com/antlr4-go/antlr/v4/LICENSE b/vendor/github.com/antlr4-go/antlr/v4/LICENSE deleted file mode 100644 index a22292eb5..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/LICENSE +++ /dev/null @@ -1,28 +0,0 @@ -Copyright (c) 2012-2023 The ANTLR Project. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -3. Neither name of copyright holders nor the names of its contributors -may be used to endorse or promote products derived from this software -without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/antlr4-go/antlr/v4/README.md b/vendor/github.com/antlr4-go/antlr/v4/README.md deleted file mode 100644 index 03e5b83eb..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/README.md +++ /dev/null @@ -1,54 +0,0 @@ -[![Go Report Card](https://goreportcard.com/badge/github.com/antlr4-go/antlr?style=flat-square)](https://goreportcard.com/report/github.com/antlr4-go/antlr) -[![PkgGoDev](https://pkg.go.dev/badge/github.com/github.com/antlr4-go/antlr)](https://pkg.go.dev/github.com/antlr4-go/antlr) -[![Release](https://img.shields.io/github/v/release/antlr4-go/antlr?sort=semver&style=flat-square)](https://github.com/antlr4-go/antlr/releases/latest) -[![Release](https://img.shields.io/github/go-mod/go-version/antlr4-go/antlr?style=flat-square)](https://github.com/antlr4-go/antlr/releases/latest) -[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg?style=flat-square)](https://github.com/antlr4-go/antlr/commit-activity) -[![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause) -[![GitHub stars](https://img.shields.io/github/stars/antlr4-go/antlr?style=flat-square&label=Star&maxAge=2592000)](https://GitHub.com/Naereen/StrapDown.js/stargazers/) -# ANTLR4 Go Runtime Module Repo - -IMPORTANT: Please submit PRs via a clone of the https://github.com/antlr/antlr4 repo, and not here. - - - Do not submit PRs or any change requests to this repo - - This repo is read only and is updated by the ANTLR team to create a new release of the Go Runtime for ANTLR - - This repo contains the Go runtime that your generated projects should import - -## Introduction - -This repo contains the official modules for the Go Runtime for ANTLR. It is a copy of the runtime maintained -at: https://github.com/antlr/antlr4/tree/master/runtime/Go/antlr and is automatically updated by the ANTLR team to create -the official Go runtime release only. No development work is carried out in this repo and PRs are not accepted here. - -The dev branch of this repo is kept in sync with the dev branch of the main ANTLR repo and is updated periodically. - -### Why? - -The `go get` command is unable to retrieve the Go runtime when it is embedded so -deeply in the main repo. A `go get` against the `antlr/antlr4` repo, while retrieving the correct source code for the runtime, -does not correctly resolve tags and will create a reference in your `go.mod` file that is unclear, will not upgrade smoothly and -causes confusion. - -For instance, the current Go runtime release, which is tagged with v4.13.0 in `antlr/antlr4` is retrieved by go get as: - -```sh -require ( - github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230219212500-1f9a474cc2dc -) -``` - -Where you would expect to see: - -```sh -require ( - github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.13.0 -) -``` - -The decision was taken to create a separate org in a separate repo to hold the official Go runtime for ANTLR and -from whence users can expect `go get` to behave as expected. - - -# Documentation -Please read the official documentation at: https://github.com/antlr/antlr4/blob/master/doc/index.md for tips on -migrating existing projects to use the new module location and for information on how to use the Go runtime in -general. diff --git a/vendor/github.com/antlr4-go/antlr/v4/antlrdoc.go b/vendor/github.com/antlr4-go/antlr/v4/antlrdoc.go deleted file mode 100644 index 3bb4fd7c4..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/antlrdoc.go +++ /dev/null @@ -1,102 +0,0 @@ -/* -Package antlr implements the Go version of the ANTLR 4 runtime. - -# The ANTLR Tool - -ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, -or translating structured text or binary files. It's widely used to build languages, tools, and frameworks. -From a grammar, ANTLR generates a parser that can build parse trees and also generates a listener interface -(or visitor) that makes it easy to respond to the recognition of phrases of interest. - -# Go Runtime - -At version 4.11.x and prior, the Go runtime was not properly versioned for go modules. After this point, the runtime -source code to be imported was held in the `runtime/Go/antlr/v4` directory, and the go.mod file was updated to reflect the version of -ANTLR4 that it is compatible with (I.E. uses the /v4 path). - -However, this was found to be problematic, as it meant that with the runtime embedded so far underneath the root -of the repo, the `go get` and related commands could not properly resolve the location of the go runtime source code. -This meant that the reference to the runtime in your `go.mod` file would refer to the correct source code, but would not -list the release tag such as @4.12.0 - this was confusing, to say the least. - -As of 4.12.1, the runtime is now available as a go module in its own repo, and can be imported as `github.com/antlr4-go/antlr` -(the go get command should also be used with this path). See the main documentation for the ANTLR4 project for more information, -which is available at [ANTLR docs]. The documentation for using the Go runtime is available at [Go runtime docs]. - -This means that if you are using the source code without modules, you should also use the source code in the [new repo]. -Though we highly recommend that you use go modules, as they are now idiomatic for Go. - -I am aware that this change will prove Hyrum's Law, but am prepared to live with it for the common good. - -Go runtime author: [Jim Idle] jimi@idle.ws - -# Code Generation - -ANTLR supports the generation of code in a number of [target languages], and the generated code is supported by a -runtime library, written specifically to support the generated code in the target language. This library is the -runtime for the Go target. - -To generate code for the go target, it is generally recommended to place the source grammar files in a package of -their own, and use the `.sh` script method of generating code, using the go generate directive. In that same directory -it is usual, though not required, to place the antlr tool that should be used to generate the code. That does mean -that the antlr tool JAR file will be checked in to your source code control though, so you are, of course, free to use any other -way of specifying the version of the ANTLR tool to use, such as aliasing in `.zshrc` or equivalent, or a profile in -your IDE, or configuration in your CI system. Checking in the jar does mean that it is easy to reproduce the build as -it was at any point in its history. - -Here is a general/recommended template for an ANTLR based recognizer in Go: - - . - ├── parser - │ ├── mygrammar.g4 - │ ├── antlr-4.12.1-complete.jar - │ ├── generate.go - │ └── generate.sh - ├── parsing - generated code goes here - │ └── error_listeners.go - ├── go.mod - ├── go.sum - ├── main.go - └── main_test.go - -Make sure that the package statement in your grammar file(s) reflects the go package the generated code will exist in. - -The generate.go file then looks like this: - - package parser - - //go:generate ./generate.sh - -And the generate.sh file will look similar to this: - - #!/bin/sh - - alias antlr4='java -Xmx500M -cp "./antlr4-4.12.1-complete.jar:$CLASSPATH" org.antlr.v4.Tool' - antlr4 -Dlanguage=Go -no-visitor -package parsing *.g4 - -depending on whether you want visitors or listeners or any other ANTLR options. Not that another option here -is to generate the code into a - -From the command line at the root of your source package (location of go.mo)d) you can then simply issue the command: - - go generate ./... - -Which will generate the code for the parser, and place it in the parsing package. You can then use the generated code -by importing the parsing package. - -There are no hard and fast rules on this. It is just a recommendation. You can generate the code in any way and to anywhere you like. - -# Copyright Notice - -Copyright (c) 2012-2023 The ANTLR Project. All rights reserved. - -Use of this file is governed by the BSD 3-clause license, which can be found in the [LICENSE.txt] file in the project root. - -[target languages]: https://github.com/antlr/antlr4/tree/master/runtime -[LICENSE.txt]: https://github.com/antlr/antlr4/blob/master/LICENSE.txt -[ANTLR docs]: https://github.com/antlr/antlr4/blob/master/doc/index.md -[new repo]: https://github.com/antlr4-go/antlr -[Jim Idle]: https://github.com/jimidle -[Go runtime docs]: https://github.com/antlr/antlr4/blob/master/doc/go-target.md -*/ -package antlr diff --git a/vendor/github.com/antlr4-go/antlr/v4/atn.go b/vendor/github.com/antlr4-go/antlr/v4/atn.go deleted file mode 100644 index cdeefed24..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/atn.go +++ /dev/null @@ -1,179 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import "sync" - -// ATNInvalidAltNumber is used to represent an ALT number that has yet to be calculated or -// which is invalid for a particular struct such as [*antlr.BaseRuleContext] -var ATNInvalidAltNumber int - -// ATN represents an “[Augmented Transition Network]”, though general in ANTLR the term -// “Augmented Recursive Transition Network” though there are some descriptions of “[Recursive Transition Network]” -// in existence. -// -// ATNs represent the main networks in the system and are serialized by the code generator and support [ALL(*)]. -// -// [Augmented Transition Network]: https://en.wikipedia.org/wiki/Augmented_transition_network -// [ALL(*)]: https://www.antlr.org/papers/allstar-techreport.pdf -// [Recursive Transition Network]: https://en.wikipedia.org/wiki/Recursive_transition_network -type ATN struct { - - // DecisionToState is the decision points for all rules, sub-rules, optional - // blocks, ()+, ()*, etc. Each sub-rule/rule is a decision point, and we must track them, so we - // can go back later and build DFA predictors for them. This includes - // all the rules, sub-rules, optional blocks, ()+, ()* etc... - DecisionToState []DecisionState - - // grammarType is the ATN type and is used for deserializing ATNs from strings. - grammarType int - - // lexerActions is referenced by action transitions in the ATN for lexer ATNs. - lexerActions []LexerAction - - // maxTokenType is the maximum value for any symbol recognized by a transition in the ATN. - maxTokenType int - - modeNameToStartState map[string]*TokensStartState - - modeToStartState []*TokensStartState - - // ruleToStartState maps from rule index to starting state number. - ruleToStartState []*RuleStartState - - // ruleToStopState maps from rule index to stop state number. - ruleToStopState []*RuleStopState - - // ruleToTokenType maps the rule index to the resulting token type for lexer - // ATNs. For parser ATNs, it maps the rule index to the generated bypass token - // type if ATNDeserializationOptions.isGenerateRuleBypassTransitions was - // specified, and otherwise is nil. - ruleToTokenType []int - - // ATNStates is a list of all states in the ATN, ordered by state number. - // - states []ATNState - - mu sync.Mutex - stateMu sync.RWMutex - edgeMu sync.RWMutex -} - -// NewATN returns a new ATN struct representing the given grammarType and is used -// for runtime deserialization of ATNs from the code generated by the ANTLR tool -func NewATN(grammarType int, maxTokenType int) *ATN { - return &ATN{ - grammarType: grammarType, - maxTokenType: maxTokenType, - modeNameToStartState: make(map[string]*TokensStartState), - } -} - -// NextTokensInContext computes and returns the set of valid tokens that can occur starting -// in state s. If ctx is nil, the set of tokens will not include what can follow -// the rule surrounding s. In other words, the set will be restricted to tokens -// reachable staying within the rule of s. -func (a *ATN) NextTokensInContext(s ATNState, ctx RuleContext) *IntervalSet { - return NewLL1Analyzer(a).Look(s, nil, ctx) -} - -// NextTokensNoContext computes and returns the set of valid tokens that can occur starting -// in state s and staying in same rule. [antlr.Token.EPSILON] is in set if we reach end of -// rule. -func (a *ATN) NextTokensNoContext(s ATNState) *IntervalSet { - a.mu.Lock() - defer a.mu.Unlock() - iset := s.GetNextTokenWithinRule() - if iset == nil { - iset = a.NextTokensInContext(s, nil) - iset.readOnly = true - s.SetNextTokenWithinRule(iset) - } - return iset -} - -// NextTokens computes and returns the set of valid tokens starting in state s, by -// calling either [NextTokensNoContext] (ctx == nil) or [NextTokensInContext] (ctx != nil). -func (a *ATN) NextTokens(s ATNState, ctx RuleContext) *IntervalSet { - if ctx == nil { - return a.NextTokensNoContext(s) - } - - return a.NextTokensInContext(s, ctx) -} - -func (a *ATN) addState(state ATNState) { - if state != nil { - state.SetATN(a) - state.SetStateNumber(len(a.states)) - } - - a.states = append(a.states, state) -} - -func (a *ATN) removeState(state ATNState) { - a.states[state.GetStateNumber()] = nil // Just free the memory; don't shift states in the slice -} - -func (a *ATN) defineDecisionState(s DecisionState) int { - a.DecisionToState = append(a.DecisionToState, s) - s.setDecision(len(a.DecisionToState) - 1) - - return s.getDecision() -} - -func (a *ATN) getDecisionState(decision int) DecisionState { - if len(a.DecisionToState) == 0 { - return nil - } - - return a.DecisionToState[decision] -} - -// getExpectedTokens computes the set of input symbols which could follow ATN -// state number stateNumber in the specified full parse context ctx and returns -// the set of potentially valid input symbols which could follow the specified -// state in the specified context. This method considers the complete parser -// context, but does not evaluate semantic predicates (i.e. all predicates -// encountered during the calculation are assumed true). If a path in the ATN -// exists from the starting state to the RuleStopState of the outermost context -// without Matching any symbols, Token.EOF is added to the returned set. -// -// A nil ctx defaults to ParserRuleContext.EMPTY. -// -// It panics if the ATN does not contain state stateNumber. -func (a *ATN) getExpectedTokens(stateNumber int, ctx RuleContext) *IntervalSet { - if stateNumber < 0 || stateNumber >= len(a.states) { - panic("Invalid state number.") - } - - s := a.states[stateNumber] - following := a.NextTokens(s, nil) - - if !following.contains(TokenEpsilon) { - return following - } - - expected := NewIntervalSet() - - expected.addSet(following) - expected.removeOne(TokenEpsilon) - - for ctx != nil && ctx.GetInvokingState() >= 0 && following.contains(TokenEpsilon) { - invokingState := a.states[ctx.GetInvokingState()] - rt := invokingState.GetTransitions()[0] - - following = a.NextTokens(rt.(*RuleTransition).followState, nil) - expected.addSet(following) - expected.removeOne(TokenEpsilon) - ctx = ctx.GetParent().(RuleContext) - } - - if following.contains(TokenEpsilon) { - expected.addOne(TokenEOF) - } - - return expected -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/atn_config.go b/vendor/github.com/antlr4-go/antlr/v4/atn_config.go deleted file mode 100644 index a83f25d34..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/atn_config.go +++ /dev/null @@ -1,335 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import ( - "fmt" -) - -const ( - lexerConfig = iota // Indicates that this ATNConfig is for a lexer - parserConfig // Indicates that this ATNConfig is for a parser -) - -// ATNConfig is a tuple: (ATN state, predicted alt, syntactic, semantic -// context). The syntactic context is a graph-structured stack node whose -// path(s) to the root is the rule invocation(s) chain used to arrive in the -// state. The semantic context is the tree of semantic predicates encountered -// before reaching an ATN state. -type ATNConfig struct { - precedenceFilterSuppressed bool - state ATNState - alt int - context *PredictionContext - semanticContext SemanticContext - reachesIntoOuterContext int - cType int // lexerConfig or parserConfig - lexerActionExecutor *LexerActionExecutor - passedThroughNonGreedyDecision bool -} - -// NewATNConfig6 creates a new ATNConfig instance given a state, alt and context only -func NewATNConfig6(state ATNState, alt int, context *PredictionContext) *ATNConfig { - return NewATNConfig5(state, alt, context, SemanticContextNone) -} - -// NewATNConfig5 creates a new ATNConfig instance given a state, alt, context and semantic context -func NewATNConfig5(state ATNState, alt int, context *PredictionContext, semanticContext SemanticContext) *ATNConfig { - if semanticContext == nil { - panic("semanticContext cannot be nil") // TODO: Necessary? - } - - pac := &ATNConfig{} - pac.state = state - pac.alt = alt - pac.context = context - pac.semanticContext = semanticContext - pac.cType = parserConfig - return pac -} - -// NewATNConfig4 creates a new ATNConfig instance given an existing config, and a state only -func NewATNConfig4(c *ATNConfig, state ATNState) *ATNConfig { - return NewATNConfig(c, state, c.GetContext(), c.GetSemanticContext()) -} - -// NewATNConfig3 creates a new ATNConfig instance given an existing config, a state and a semantic context -func NewATNConfig3(c *ATNConfig, state ATNState, semanticContext SemanticContext) *ATNConfig { - return NewATNConfig(c, state, c.GetContext(), semanticContext) -} - -// NewATNConfig2 creates a new ATNConfig instance given an existing config, and a context only -func NewATNConfig2(c *ATNConfig, semanticContext SemanticContext) *ATNConfig { - return NewATNConfig(c, c.GetState(), c.GetContext(), semanticContext) -} - -// NewATNConfig1 creates a new ATNConfig instance given an existing config, a state, and a context only -func NewATNConfig1(c *ATNConfig, state ATNState, context *PredictionContext) *ATNConfig { - return NewATNConfig(c, state, context, c.GetSemanticContext()) -} - -// NewATNConfig creates a new ATNConfig instance given an existing config, a state, a context and a semantic context, other 'constructors' -// are just wrappers around this one. -func NewATNConfig(c *ATNConfig, state ATNState, context *PredictionContext, semanticContext SemanticContext) *ATNConfig { - if semanticContext == nil { - panic("semanticContext cannot be nil") // TODO: Remove this - probably put here for some bug that is now fixed - } - b := &ATNConfig{} - b.InitATNConfig(c, state, c.GetAlt(), context, semanticContext) - b.cType = parserConfig - return b -} - -func (a *ATNConfig) InitATNConfig(c *ATNConfig, state ATNState, alt int, context *PredictionContext, semanticContext SemanticContext) { - - a.state = state - a.alt = alt - a.context = context - a.semanticContext = semanticContext - a.reachesIntoOuterContext = c.GetReachesIntoOuterContext() - a.precedenceFilterSuppressed = c.getPrecedenceFilterSuppressed() -} - -func (a *ATNConfig) getPrecedenceFilterSuppressed() bool { - return a.precedenceFilterSuppressed -} - -func (a *ATNConfig) setPrecedenceFilterSuppressed(v bool) { - a.precedenceFilterSuppressed = v -} - -// GetState returns the ATN state associated with this configuration -func (a *ATNConfig) GetState() ATNState { - return a.state -} - -// GetAlt returns the alternative associated with this configuration -func (a *ATNConfig) GetAlt() int { - return a.alt -} - -// SetContext sets the rule invocation stack associated with this configuration -func (a *ATNConfig) SetContext(v *PredictionContext) { - a.context = v -} - -// GetContext returns the rule invocation stack associated with this configuration -func (a *ATNConfig) GetContext() *PredictionContext { - return a.context -} - -// GetSemanticContext returns the semantic context associated with this configuration -func (a *ATNConfig) GetSemanticContext() SemanticContext { - return a.semanticContext -} - -// GetReachesIntoOuterContext returns the count of references to an outer context from this configuration -func (a *ATNConfig) GetReachesIntoOuterContext() int { - return a.reachesIntoOuterContext -} - -// SetReachesIntoOuterContext sets the count of references to an outer context from this configuration -func (a *ATNConfig) SetReachesIntoOuterContext(v int) { - a.reachesIntoOuterContext = v -} - -// Equals is the default comparison function for an ATNConfig when no specialist implementation is required -// for a collection. -// -// An ATN configuration is equal to another if both have the same state, they -// predict the same alternative, and syntactic/semantic contexts are the same. -func (a *ATNConfig) Equals(o Collectable[*ATNConfig]) bool { - switch a.cType { - case lexerConfig: - return a.LEquals(o) - case parserConfig: - return a.PEquals(o) - default: - panic("Invalid ATNConfig type") - } -} - -// PEquals is the default comparison function for a Parser ATNConfig when no specialist implementation is required -// for a collection. -// -// An ATN configuration is equal to another if both have the same state, they -// predict the same alternative, and syntactic/semantic contexts are the same. -func (a *ATNConfig) PEquals(o Collectable[*ATNConfig]) bool { - var other, ok = o.(*ATNConfig) - - if !ok { - return false - } - if a == other { - return true - } else if other == nil { - return false - } - - var equal bool - - if a.context == nil { - equal = other.context == nil - } else { - equal = a.context.Equals(other.context) - } - - var ( - nums = a.state.GetStateNumber() == other.state.GetStateNumber() - alts = a.alt == other.alt - cons = a.semanticContext.Equals(other.semanticContext) - sups = a.precedenceFilterSuppressed == other.precedenceFilterSuppressed - ) - - return nums && alts && cons && sups && equal -} - -// Hash is the default hash function for a parser ATNConfig, when no specialist hash function -// is required for a collection -func (a *ATNConfig) Hash() int { - switch a.cType { - case lexerConfig: - return a.LHash() - case parserConfig: - return a.PHash() - default: - panic("Invalid ATNConfig type") - } -} - -// PHash is the default hash function for a parser ATNConfig, when no specialist hash function -// is required for a collection -func (a *ATNConfig) PHash() int { - var c int - if a.context != nil { - c = a.context.Hash() - } - - h := murmurInit(7) - h = murmurUpdate(h, a.state.GetStateNumber()) - h = murmurUpdate(h, a.alt) - h = murmurUpdate(h, c) - h = murmurUpdate(h, a.semanticContext.Hash()) - return murmurFinish(h, 4) -} - -// String returns a string representation of the ATNConfig, usually used for debugging purposes -func (a *ATNConfig) String() string { - var s1, s2, s3 string - - if a.context != nil { - s1 = ",[" + fmt.Sprint(a.context) + "]" - } - - if a.semanticContext != SemanticContextNone { - s2 = "," + fmt.Sprint(a.semanticContext) - } - - if a.reachesIntoOuterContext > 0 { - s3 = ",up=" + fmt.Sprint(a.reachesIntoOuterContext) - } - - return fmt.Sprintf("(%v,%v%v%v%v)", a.state, a.alt, s1, s2, s3) -} - -func NewLexerATNConfig6(state ATNState, alt int, context *PredictionContext) *ATNConfig { - lac := &ATNConfig{} - lac.state = state - lac.alt = alt - lac.context = context - lac.semanticContext = SemanticContextNone - lac.cType = lexerConfig - return lac -} - -func NewLexerATNConfig4(c *ATNConfig, state ATNState) *ATNConfig { - lac := &ATNConfig{} - lac.lexerActionExecutor = c.lexerActionExecutor - lac.passedThroughNonGreedyDecision = checkNonGreedyDecision(c, state) - lac.InitATNConfig(c, state, c.GetAlt(), c.GetContext(), c.GetSemanticContext()) - lac.cType = lexerConfig - return lac -} - -func NewLexerATNConfig3(c *ATNConfig, state ATNState, lexerActionExecutor *LexerActionExecutor) *ATNConfig { - lac := &ATNConfig{} - lac.lexerActionExecutor = lexerActionExecutor - lac.passedThroughNonGreedyDecision = checkNonGreedyDecision(c, state) - lac.InitATNConfig(c, state, c.GetAlt(), c.GetContext(), c.GetSemanticContext()) - lac.cType = lexerConfig - return lac -} - -func NewLexerATNConfig2(c *ATNConfig, state ATNState, context *PredictionContext) *ATNConfig { - lac := &ATNConfig{} - lac.lexerActionExecutor = c.lexerActionExecutor - lac.passedThroughNonGreedyDecision = checkNonGreedyDecision(c, state) - lac.InitATNConfig(c, state, c.GetAlt(), context, c.GetSemanticContext()) - lac.cType = lexerConfig - return lac -} - -//goland:noinspection GoUnusedExportedFunction -func NewLexerATNConfig1(state ATNState, alt int, context *PredictionContext) *ATNConfig { - lac := &ATNConfig{} - lac.state = state - lac.alt = alt - lac.context = context - lac.semanticContext = SemanticContextNone - lac.cType = lexerConfig - return lac -} - -// LHash is the default hash function for Lexer ATNConfig objects, it can be used directly or via -// the default comparator [ObjEqComparator]. -func (a *ATNConfig) LHash() int { - var f int - if a.passedThroughNonGreedyDecision { - f = 1 - } else { - f = 0 - } - h := murmurInit(7) - h = murmurUpdate(h, a.state.GetStateNumber()) - h = murmurUpdate(h, a.alt) - h = murmurUpdate(h, a.context.Hash()) - h = murmurUpdate(h, a.semanticContext.Hash()) - h = murmurUpdate(h, f) - h = murmurUpdate(h, a.lexerActionExecutor.Hash()) - h = murmurFinish(h, 6) - return h -} - -// LEquals is the default comparison function for Lexer ATNConfig objects, it can be used directly or via -// the default comparator [ObjEqComparator]. -func (a *ATNConfig) LEquals(other Collectable[*ATNConfig]) bool { - var otherT, ok = other.(*ATNConfig) - if !ok { - return false - } else if a == otherT { - return true - } else if a.passedThroughNonGreedyDecision != otherT.passedThroughNonGreedyDecision { - return false - } - - switch { - case a.lexerActionExecutor == nil && otherT.lexerActionExecutor == nil: - return true - case a.lexerActionExecutor != nil && otherT.lexerActionExecutor != nil: - if !a.lexerActionExecutor.Equals(otherT.lexerActionExecutor) { - return false - } - default: - return false // One but not both, are nil - } - - return a.PEquals(otherT) -} - -func checkNonGreedyDecision(source *ATNConfig, target ATNState) bool { - var ds, ok = target.(DecisionState) - - return source.passedThroughNonGreedyDecision || (ok && ds.getNonGreedy()) -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/atn_config_set.go b/vendor/github.com/antlr4-go/antlr/v4/atn_config_set.go deleted file mode 100644 index 52dbaf806..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/atn_config_set.go +++ /dev/null @@ -1,301 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import ( - "fmt" -) - -// ATNConfigSet is a specialized set of ATNConfig that tracks information -// about its elements and can combine similar configurations using a -// graph-structured stack. -type ATNConfigSet struct { - cachedHash int - - // configLookup is used to determine whether two ATNConfigSets are equal. We - // need all configurations with the same (s, i, _, semctx) to be equal. A key - // effectively doubles the number of objects associated with ATNConfigs. All - // keys are hashed by (s, i, _, pi), not including the context. Wiped out when - // read-only because a set becomes a DFA state. - configLookup *JStore[*ATNConfig, Comparator[*ATNConfig]] - - // configs is the added elements that did not match an existing key in configLookup - configs []*ATNConfig - - // TODO: These fields make me pretty uncomfortable, but it is nice to pack up - // info together because it saves re-computation. Can we track conflicts as they - // are added to save scanning configs later? - conflictingAlts *BitSet - - // dipsIntoOuterContext is used by parsers and lexers. In a lexer, it indicates - // we hit a pred while computing a closure operation. Do not make a DFA state - // from the ATNConfigSet in this case. TODO: How is this used by parsers? - dipsIntoOuterContext bool - - // fullCtx is whether it is part of a full context LL prediction. Used to - // determine how to merge $. It is a wildcard with SLL, but not for an LL - // context merge. - fullCtx bool - - // Used in parser and lexer. In lexer, it indicates we hit a pred - // while computing a closure operation. Don't make a DFA state from this set. - hasSemanticContext bool - - // readOnly is whether it is read-only. Do not - // allow any code to manipulate the set if true because DFA states will point at - // sets and those must not change. It not, protect other fields; conflictingAlts - // in particular, which is assigned after readOnly. - readOnly bool - - // TODO: These fields make me pretty uncomfortable, but it is nice to pack up - // info together because it saves re-computation. Can we track conflicts as they - // are added to save scanning configs later? - uniqueAlt int -} - -// Alts returns the combined set of alts for all the configurations in this set. -func (b *ATNConfigSet) Alts() *BitSet { - alts := NewBitSet() - for _, it := range b.configs { - alts.add(it.GetAlt()) - } - return alts -} - -// NewATNConfigSet creates a new ATNConfigSet instance. -func NewATNConfigSet(fullCtx bool) *ATNConfigSet { - return &ATNConfigSet{ - cachedHash: -1, - configLookup: NewJStore[*ATNConfig, Comparator[*ATNConfig]](aConfCompInst, ATNConfigLookupCollection, "NewATNConfigSet()"), - fullCtx: fullCtx, - } -} - -// Add merges contexts with existing configs for (s, i, pi, _), -// where 's' is the ATNConfig.state, 'i' is the ATNConfig.alt, and -// 'pi' is the [ATNConfig].semanticContext. -// -// We use (s,i,pi) as the key. -// Updates dipsIntoOuterContext and hasSemanticContext when necessary. -func (b *ATNConfigSet) Add(config *ATNConfig, mergeCache *JPCMap) bool { - if b.readOnly { - panic("set is read-only") - } - - if config.GetSemanticContext() != SemanticContextNone { - b.hasSemanticContext = true - } - - if config.GetReachesIntoOuterContext() > 0 { - b.dipsIntoOuterContext = true - } - - existing, present := b.configLookup.Put(config) - - // The config was not already in the set - // - if !present { - b.cachedHash = -1 - b.configs = append(b.configs, config) // Track order here - return true - } - - // Merge a previous (s, i, pi, _) with it and save the result - rootIsWildcard := !b.fullCtx - merged := merge(existing.GetContext(), config.GetContext(), rootIsWildcard, mergeCache) - - // No need to check for existing.context because config.context is in the cache, - // since the only way to create new graphs is the "call rule" and here. We cache - // at both places. - existing.SetReachesIntoOuterContext(intMax(existing.GetReachesIntoOuterContext(), config.GetReachesIntoOuterContext())) - - // Preserve the precedence filter suppression during the merge - if config.getPrecedenceFilterSuppressed() { - existing.setPrecedenceFilterSuppressed(true) - } - - // Replace the context because there is no need to do alt mapping - existing.SetContext(merged) - - return true -} - -// GetStates returns the set of states represented by all configurations in this config set -func (b *ATNConfigSet) GetStates() *JStore[ATNState, Comparator[ATNState]] { - - // states uses the standard comparator and Hash() provided by the ATNState instance - // - states := NewJStore[ATNState, Comparator[ATNState]](aStateEqInst, ATNStateCollection, "ATNConfigSet.GetStates()") - - for i := 0; i < len(b.configs); i++ { - states.Put(b.configs[i].GetState()) - } - - return states -} - -func (b *ATNConfigSet) GetPredicates() []SemanticContext { - predicates := make([]SemanticContext, 0) - - for i := 0; i < len(b.configs); i++ { - c := b.configs[i].GetSemanticContext() - - if c != SemanticContextNone { - predicates = append(predicates, c) - } - } - - return predicates -} - -func (b *ATNConfigSet) OptimizeConfigs(interpreter *BaseATNSimulator) { - if b.readOnly { - panic("set is read-only") - } - - // Empty indicate no optimization is possible - if b.configLookup == nil || b.configLookup.Len() == 0 { - return - } - - for i := 0; i < len(b.configs); i++ { - config := b.configs[i] - config.SetContext(interpreter.getCachedContext(config.GetContext())) - } -} - -func (b *ATNConfigSet) AddAll(coll []*ATNConfig) bool { - for i := 0; i < len(coll); i++ { - b.Add(coll[i], nil) - } - - return false -} - -// Compare The configs are only equal if they are in the same order and their Equals function returns true. -// Java uses ArrayList.equals(), which requires the same order. -func (b *ATNConfigSet) Compare(bs *ATNConfigSet) bool { - if len(b.configs) != len(bs.configs) { - return false - } - for i := 0; i < len(b.configs); i++ { - if !b.configs[i].Equals(bs.configs[i]) { - return false - } - } - - return true -} - -func (b *ATNConfigSet) Equals(other Collectable[ATNConfig]) bool { - if b == other { - return true - } else if _, ok := other.(*ATNConfigSet); !ok { - return false - } - - other2 := other.(*ATNConfigSet) - var eca bool - switch { - case b.conflictingAlts == nil && other2.conflictingAlts == nil: - eca = true - case b.conflictingAlts != nil && other2.conflictingAlts != nil: - eca = b.conflictingAlts.equals(other2.conflictingAlts) - } - return b.configs != nil && - b.fullCtx == other2.fullCtx && - b.uniqueAlt == other2.uniqueAlt && - eca && - b.hasSemanticContext == other2.hasSemanticContext && - b.dipsIntoOuterContext == other2.dipsIntoOuterContext && - b.Compare(other2) -} - -func (b *ATNConfigSet) Hash() int { - if b.readOnly { - if b.cachedHash == -1 { - b.cachedHash = b.hashCodeConfigs() - } - - return b.cachedHash - } - - return b.hashCodeConfigs() -} - -func (b *ATNConfigSet) hashCodeConfigs() int { - h := 1 - for _, config := range b.configs { - h = 31*h + config.Hash() - } - return h -} - -func (b *ATNConfigSet) Contains(item *ATNConfig) bool { - if b.readOnly { - panic("not implemented for read-only sets") - } - if b.configLookup == nil { - return false - } - return b.configLookup.Contains(item) -} - -func (b *ATNConfigSet) ContainsFast(item *ATNConfig) bool { - return b.Contains(item) -} - -func (b *ATNConfigSet) Clear() { - if b.readOnly { - panic("set is read-only") - } - b.configs = make([]*ATNConfig, 0) - b.cachedHash = -1 - b.configLookup = NewJStore[*ATNConfig, Comparator[*ATNConfig]](aConfCompInst, ATNConfigLookupCollection, "NewATNConfigSet()") -} - -func (b *ATNConfigSet) String() string { - - s := "[" - - for i, c := range b.configs { - s += c.String() - - if i != len(b.configs)-1 { - s += ", " - } - } - - s += "]" - - if b.hasSemanticContext { - s += ",hasSemanticContext=" + fmt.Sprint(b.hasSemanticContext) - } - - if b.uniqueAlt != ATNInvalidAltNumber { - s += ",uniqueAlt=" + fmt.Sprint(b.uniqueAlt) - } - - if b.conflictingAlts != nil { - s += ",conflictingAlts=" + b.conflictingAlts.String() - } - - if b.dipsIntoOuterContext { - s += ",dipsIntoOuterContext" - } - - return s -} - -// NewOrderedATNConfigSet creates a config set with a slightly different Hash/Equal pair -// for use in lexers. -func NewOrderedATNConfigSet() *ATNConfigSet { - return &ATNConfigSet{ - cachedHash: -1, - // This set uses the standard Hash() and Equals() from ATNConfig - configLookup: NewJStore[*ATNConfig, Comparator[*ATNConfig]](aConfEqInst, ATNConfigCollection, "ATNConfigSet.NewOrderedATNConfigSet()"), - fullCtx: false, - } -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/atn_deserialization_options.go b/vendor/github.com/antlr4-go/antlr/v4/atn_deserialization_options.go deleted file mode 100644 index bdb30b362..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/atn_deserialization_options.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import "errors" - -var defaultATNDeserializationOptions = ATNDeserializationOptions{true, true, false} - -type ATNDeserializationOptions struct { - readOnly bool - verifyATN bool - generateRuleBypassTransitions bool -} - -func (opts *ATNDeserializationOptions) ReadOnly() bool { - return opts.readOnly -} - -func (opts *ATNDeserializationOptions) SetReadOnly(readOnly bool) { - if opts.readOnly { - panic(errors.New("cannot mutate read only ATNDeserializationOptions")) - } - opts.readOnly = readOnly -} - -func (opts *ATNDeserializationOptions) VerifyATN() bool { - return opts.verifyATN -} - -func (opts *ATNDeserializationOptions) SetVerifyATN(verifyATN bool) { - if opts.readOnly { - panic(errors.New("cannot mutate read only ATNDeserializationOptions")) - } - opts.verifyATN = verifyATN -} - -func (opts *ATNDeserializationOptions) GenerateRuleBypassTransitions() bool { - return opts.generateRuleBypassTransitions -} - -func (opts *ATNDeserializationOptions) SetGenerateRuleBypassTransitions(generateRuleBypassTransitions bool) { - if opts.readOnly { - panic(errors.New("cannot mutate read only ATNDeserializationOptions")) - } - opts.generateRuleBypassTransitions = generateRuleBypassTransitions -} - -//goland:noinspection GoUnusedExportedFunction -func DefaultATNDeserializationOptions() *ATNDeserializationOptions { - return NewATNDeserializationOptions(&defaultATNDeserializationOptions) -} - -func NewATNDeserializationOptions(other *ATNDeserializationOptions) *ATNDeserializationOptions { - o := new(ATNDeserializationOptions) - if other != nil { - *o = *other - o.readOnly = false - } - return o -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/atn_deserializer.go b/vendor/github.com/antlr4-go/antlr/v4/atn_deserializer.go deleted file mode 100644 index 2dcb9ae11..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/atn_deserializer.go +++ /dev/null @@ -1,684 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import ( - "fmt" - "strconv" -) - -const serializedVersion = 4 - -type loopEndStateIntPair struct { - item0 *LoopEndState - item1 int -} - -type blockStartStateIntPair struct { - item0 BlockStartState - item1 int -} - -type ATNDeserializer struct { - options *ATNDeserializationOptions - data []int32 - pos int -} - -func NewATNDeserializer(options *ATNDeserializationOptions) *ATNDeserializer { - if options == nil { - options = &defaultATNDeserializationOptions - } - - return &ATNDeserializer{options: options} -} - -//goland:noinspection GoUnusedFunction -func stringInSlice(a string, list []string) int { - for i, b := range list { - if b == a { - return i - } - } - - return -1 -} - -func (a *ATNDeserializer) Deserialize(data []int32) *ATN { - a.data = data - a.pos = 0 - a.checkVersion() - - atn := a.readATN() - - a.readStates(atn) - a.readRules(atn) - a.readModes(atn) - - sets := a.readSets(atn, nil) - - a.readEdges(atn, sets) - a.readDecisions(atn) - a.readLexerActions(atn) - a.markPrecedenceDecisions(atn) - a.verifyATN(atn) - - if a.options.GenerateRuleBypassTransitions() && atn.grammarType == ATNTypeParser { - a.generateRuleBypassTransitions(atn) - // Re-verify after modification - a.verifyATN(atn) - } - - return atn - -} - -func (a *ATNDeserializer) checkVersion() { - version := a.readInt() - - if version != serializedVersion { - panic("Could not deserialize ATN with version " + strconv.Itoa(version) + " (expected " + strconv.Itoa(serializedVersion) + ").") - } -} - -func (a *ATNDeserializer) readATN() *ATN { - grammarType := a.readInt() - maxTokenType := a.readInt() - - return NewATN(grammarType, maxTokenType) -} - -func (a *ATNDeserializer) readStates(atn *ATN) { - nstates := a.readInt() - - // Allocate worst case size. - loopBackStateNumbers := make([]loopEndStateIntPair, 0, nstates) - endStateNumbers := make([]blockStartStateIntPair, 0, nstates) - - // Preallocate states slice. - atn.states = make([]ATNState, 0, nstates) - - for i := 0; i < nstates; i++ { - stype := a.readInt() - - // Ignore bad types of states - if stype == ATNStateInvalidType { - atn.addState(nil) - continue - } - - ruleIndex := a.readInt() - - s := a.stateFactory(stype, ruleIndex) - - if stype == ATNStateLoopEnd { - loopBackStateNumber := a.readInt() - - loopBackStateNumbers = append(loopBackStateNumbers, loopEndStateIntPair{s.(*LoopEndState), loopBackStateNumber}) - } else if s2, ok := s.(BlockStartState); ok { - endStateNumber := a.readInt() - - endStateNumbers = append(endStateNumbers, blockStartStateIntPair{s2, endStateNumber}) - } - - atn.addState(s) - } - - // Delay the assignment of loop back and end states until we know all the state - // instances have been initialized - for _, pair := range loopBackStateNumbers { - pair.item0.loopBackState = atn.states[pair.item1] - } - - for _, pair := range endStateNumbers { - pair.item0.setEndState(atn.states[pair.item1].(*BlockEndState)) - } - - numNonGreedyStates := a.readInt() - for j := 0; j < numNonGreedyStates; j++ { - stateNumber := a.readInt() - - atn.states[stateNumber].(DecisionState).setNonGreedy(true) - } - - numPrecedenceStates := a.readInt() - for j := 0; j < numPrecedenceStates; j++ { - stateNumber := a.readInt() - - atn.states[stateNumber].(*RuleStartState).isPrecedenceRule = true - } -} - -func (a *ATNDeserializer) readRules(atn *ATN) { - nrules := a.readInt() - - if atn.grammarType == ATNTypeLexer { - atn.ruleToTokenType = make([]int, nrules) - } - - atn.ruleToStartState = make([]*RuleStartState, nrules) - - for i := range atn.ruleToStartState { - s := a.readInt() - startState := atn.states[s].(*RuleStartState) - - atn.ruleToStartState[i] = startState - - if atn.grammarType == ATNTypeLexer { - tokenType := a.readInt() - - atn.ruleToTokenType[i] = tokenType - } - } - - atn.ruleToStopState = make([]*RuleStopState, nrules) - - for _, state := range atn.states { - if s2, ok := state.(*RuleStopState); ok { - atn.ruleToStopState[s2.ruleIndex] = s2 - atn.ruleToStartState[s2.ruleIndex].stopState = s2 - } - } -} - -func (a *ATNDeserializer) readModes(atn *ATN) { - nmodes := a.readInt() - atn.modeToStartState = make([]*TokensStartState, nmodes) - - for i := range atn.modeToStartState { - s := a.readInt() - - atn.modeToStartState[i] = atn.states[s].(*TokensStartState) - } -} - -func (a *ATNDeserializer) readSets(_ *ATN, sets []*IntervalSet) []*IntervalSet { - m := a.readInt() - - // Preallocate the needed capacity. - if cap(sets)-len(sets) < m { - isets := make([]*IntervalSet, len(sets), len(sets)+m) - copy(isets, sets) - sets = isets - } - - for i := 0; i < m; i++ { - iset := NewIntervalSet() - - sets = append(sets, iset) - - n := a.readInt() - containsEOF := a.readInt() - - if containsEOF != 0 { - iset.addOne(-1) - } - - for j := 0; j < n; j++ { - i1 := a.readInt() - i2 := a.readInt() - - iset.addRange(i1, i2) - } - } - - return sets -} - -func (a *ATNDeserializer) readEdges(atn *ATN, sets []*IntervalSet) { - nedges := a.readInt() - - for i := 0; i < nedges; i++ { - var ( - src = a.readInt() - trg = a.readInt() - ttype = a.readInt() - arg1 = a.readInt() - arg2 = a.readInt() - arg3 = a.readInt() - trans = a.edgeFactory(atn, ttype, src, trg, arg1, arg2, arg3, sets) - srcState = atn.states[src] - ) - - srcState.AddTransition(trans, -1) - } - - // Edges for rule stop states can be derived, so they are not serialized - for _, state := range atn.states { - for _, t := range state.GetTransitions() { - var rt, ok = t.(*RuleTransition) - - if !ok { - continue - } - - outermostPrecedenceReturn := -1 - - if atn.ruleToStartState[rt.getTarget().GetRuleIndex()].isPrecedenceRule { - if rt.precedence == 0 { - outermostPrecedenceReturn = rt.getTarget().GetRuleIndex() - } - } - - trans := NewEpsilonTransition(rt.followState, outermostPrecedenceReturn) - - atn.ruleToStopState[rt.getTarget().GetRuleIndex()].AddTransition(trans, -1) - } - } - - for _, state := range atn.states { - if s2, ok := state.(BlockStartState); ok { - // We need to know the end state to set its start state - if s2.getEndState() == nil { - panic("IllegalState") - } - - // Block end states can only be associated to a single block start state - if s2.getEndState().startState != nil { - panic("IllegalState") - } - - s2.getEndState().startState = state - } - - if s2, ok := state.(*PlusLoopbackState); ok { - for _, t := range s2.GetTransitions() { - if t2, ok := t.getTarget().(*PlusBlockStartState); ok { - t2.loopBackState = state - } - } - } else if s2, ok := state.(*StarLoopbackState); ok { - for _, t := range s2.GetTransitions() { - if t2, ok := t.getTarget().(*StarLoopEntryState); ok { - t2.loopBackState = state - } - } - } - } -} - -func (a *ATNDeserializer) readDecisions(atn *ATN) { - ndecisions := a.readInt() - - for i := 0; i < ndecisions; i++ { - s := a.readInt() - decState := atn.states[s].(DecisionState) - - atn.DecisionToState = append(atn.DecisionToState, decState) - decState.setDecision(i) - } -} - -func (a *ATNDeserializer) readLexerActions(atn *ATN) { - if atn.grammarType == ATNTypeLexer { - count := a.readInt() - - atn.lexerActions = make([]LexerAction, count) - - for i := range atn.lexerActions { - actionType := a.readInt() - data1 := a.readInt() - data2 := a.readInt() - atn.lexerActions[i] = a.lexerActionFactory(actionType, data1, data2) - } - } -} - -func (a *ATNDeserializer) generateRuleBypassTransitions(atn *ATN) { - count := len(atn.ruleToStartState) - - for i := 0; i < count; i++ { - atn.ruleToTokenType[i] = atn.maxTokenType + i + 1 - } - - for i := 0; i < count; i++ { - a.generateRuleBypassTransition(atn, i) - } -} - -func (a *ATNDeserializer) generateRuleBypassTransition(atn *ATN, idx int) { - bypassStart := NewBasicBlockStartState() - - bypassStart.ruleIndex = idx - atn.addState(bypassStart) - - bypassStop := NewBlockEndState() - - bypassStop.ruleIndex = idx - atn.addState(bypassStop) - - bypassStart.endState = bypassStop - - atn.defineDecisionState(&bypassStart.BaseDecisionState) - - bypassStop.startState = bypassStart - - var excludeTransition Transition - var endState ATNState - - if atn.ruleToStartState[idx].isPrecedenceRule { - // Wrap from the beginning of the rule to the StarLoopEntryState - endState = nil - - for i := 0; i < len(atn.states); i++ { - state := atn.states[i] - - if a.stateIsEndStateFor(state, idx) != nil { - endState = state - excludeTransition = state.(*StarLoopEntryState).loopBackState.GetTransitions()[0] - - break - } - } - - if excludeTransition == nil { - panic("Couldn't identify final state of the precedence rule prefix section.") - } - } else { - endState = atn.ruleToStopState[idx] - } - - // All non-excluded transitions that currently target end state need to target - // blockEnd instead - for i := 0; i < len(atn.states); i++ { - state := atn.states[i] - - for j := 0; j < len(state.GetTransitions()); j++ { - transition := state.GetTransitions()[j] - - if transition == excludeTransition { - continue - } - - if transition.getTarget() == endState { - transition.setTarget(bypassStop) - } - } - } - - // All transitions leaving the rule start state need to leave blockStart instead - ruleToStartState := atn.ruleToStartState[idx] - count := len(ruleToStartState.GetTransitions()) - - for count > 0 { - bypassStart.AddTransition(ruleToStartState.GetTransitions()[count-1], -1) - ruleToStartState.SetTransitions([]Transition{ruleToStartState.GetTransitions()[len(ruleToStartState.GetTransitions())-1]}) - } - - // Link the new states - atn.ruleToStartState[idx].AddTransition(NewEpsilonTransition(bypassStart, -1), -1) - bypassStop.AddTransition(NewEpsilonTransition(endState, -1), -1) - - MatchState := NewBasicState() - - atn.addState(MatchState) - MatchState.AddTransition(NewAtomTransition(bypassStop, atn.ruleToTokenType[idx]), -1) - bypassStart.AddTransition(NewEpsilonTransition(MatchState, -1), -1) -} - -func (a *ATNDeserializer) stateIsEndStateFor(state ATNState, idx int) ATNState { - if state.GetRuleIndex() != idx { - return nil - } - - if _, ok := state.(*StarLoopEntryState); !ok { - return nil - } - - maybeLoopEndState := state.GetTransitions()[len(state.GetTransitions())-1].getTarget() - - if _, ok := maybeLoopEndState.(*LoopEndState); !ok { - return nil - } - - var _, ok = maybeLoopEndState.GetTransitions()[0].getTarget().(*RuleStopState) - - if maybeLoopEndState.(*LoopEndState).epsilonOnlyTransitions && ok { - return state - } - - return nil -} - -// markPrecedenceDecisions analyzes the StarLoopEntryState states in the -// specified ATN to set the StarLoopEntryState.precedenceRuleDecision field to -// the correct value. -func (a *ATNDeserializer) markPrecedenceDecisions(atn *ATN) { - for _, state := range atn.states { - if _, ok := state.(*StarLoopEntryState); !ok { - continue - } - - // We analyze the [ATN] to determine if an ATN decision state is the - // decision for the closure block that determines whether a - // precedence rule should continue or complete. - if atn.ruleToStartState[state.GetRuleIndex()].isPrecedenceRule { - maybeLoopEndState := state.GetTransitions()[len(state.GetTransitions())-1].getTarget() - - if s3, ok := maybeLoopEndState.(*LoopEndState); ok { - var _, ok2 = maybeLoopEndState.GetTransitions()[0].getTarget().(*RuleStopState) - - if s3.epsilonOnlyTransitions && ok2 { - state.(*StarLoopEntryState).precedenceRuleDecision = true - } - } - } - } -} - -func (a *ATNDeserializer) verifyATN(atn *ATN) { - if !a.options.VerifyATN() { - return - } - - // Verify assumptions - for _, state := range atn.states { - if state == nil { - continue - } - - a.checkCondition(state.GetEpsilonOnlyTransitions() || len(state.GetTransitions()) <= 1, "") - - switch s2 := state.(type) { - case *PlusBlockStartState: - a.checkCondition(s2.loopBackState != nil, "") - - case *StarLoopEntryState: - a.checkCondition(s2.loopBackState != nil, "") - a.checkCondition(len(s2.GetTransitions()) == 2, "") - - switch s2.transitions[0].getTarget().(type) { - case *StarBlockStartState: - _, ok := s2.transitions[1].getTarget().(*LoopEndState) - - a.checkCondition(ok, "") - a.checkCondition(!s2.nonGreedy, "") - - case *LoopEndState: - var _, ok = s2.transitions[1].getTarget().(*StarBlockStartState) - - a.checkCondition(ok, "") - a.checkCondition(s2.nonGreedy, "") - - default: - panic("IllegalState") - } - - case *StarLoopbackState: - a.checkCondition(len(state.GetTransitions()) == 1, "") - - var _, ok = state.GetTransitions()[0].getTarget().(*StarLoopEntryState) - - a.checkCondition(ok, "") - - case *LoopEndState: - a.checkCondition(s2.loopBackState != nil, "") - - case *RuleStartState: - a.checkCondition(s2.stopState != nil, "") - - case BlockStartState: - a.checkCondition(s2.getEndState() != nil, "") - - case *BlockEndState: - a.checkCondition(s2.startState != nil, "") - - case DecisionState: - a.checkCondition(len(s2.GetTransitions()) <= 1 || s2.getDecision() >= 0, "") - - default: - var _, ok = s2.(*RuleStopState) - - a.checkCondition(len(s2.GetTransitions()) <= 1 || ok, "") - } - } -} - -func (a *ATNDeserializer) checkCondition(condition bool, message string) { - if !condition { - if message == "" { - message = "IllegalState" - } - - panic(message) - } -} - -func (a *ATNDeserializer) readInt() int { - v := a.data[a.pos] - - a.pos++ - - return int(v) // data is 32 bits but int is at least that big -} - -func (a *ATNDeserializer) edgeFactory(atn *ATN, typeIndex, _, trg, arg1, arg2, arg3 int, sets []*IntervalSet) Transition { - target := atn.states[trg] - - switch typeIndex { - case TransitionEPSILON: - return NewEpsilonTransition(target, -1) - - case TransitionRANGE: - if arg3 != 0 { - return NewRangeTransition(target, TokenEOF, arg2) - } - - return NewRangeTransition(target, arg1, arg2) - - case TransitionRULE: - return NewRuleTransition(atn.states[arg1], arg2, arg3, target) - - case TransitionPREDICATE: - return NewPredicateTransition(target, arg1, arg2, arg3 != 0) - - case TransitionPRECEDENCE: - return NewPrecedencePredicateTransition(target, arg1) - - case TransitionATOM: - if arg3 != 0 { - return NewAtomTransition(target, TokenEOF) - } - - return NewAtomTransition(target, arg1) - - case TransitionACTION: - return NewActionTransition(target, arg1, arg2, arg3 != 0) - - case TransitionSET: - return NewSetTransition(target, sets[arg1]) - - case TransitionNOTSET: - return NewNotSetTransition(target, sets[arg1]) - - case TransitionWILDCARD: - return NewWildcardTransition(target) - } - - panic("The specified transition type is not valid.") -} - -func (a *ATNDeserializer) stateFactory(typeIndex, ruleIndex int) ATNState { - var s ATNState - - switch typeIndex { - case ATNStateInvalidType: - return nil - - case ATNStateBasic: - s = NewBasicState() - - case ATNStateRuleStart: - s = NewRuleStartState() - - case ATNStateBlockStart: - s = NewBasicBlockStartState() - - case ATNStatePlusBlockStart: - s = NewPlusBlockStartState() - - case ATNStateStarBlockStart: - s = NewStarBlockStartState() - - case ATNStateTokenStart: - s = NewTokensStartState() - - case ATNStateRuleStop: - s = NewRuleStopState() - - case ATNStateBlockEnd: - s = NewBlockEndState() - - case ATNStateStarLoopBack: - s = NewStarLoopbackState() - - case ATNStateStarLoopEntry: - s = NewStarLoopEntryState() - - case ATNStatePlusLoopBack: - s = NewPlusLoopbackState() - - case ATNStateLoopEnd: - s = NewLoopEndState() - - default: - panic(fmt.Sprintf("state type %d is invalid", typeIndex)) - } - - s.SetRuleIndex(ruleIndex) - - return s -} - -func (a *ATNDeserializer) lexerActionFactory(typeIndex, data1, data2 int) LexerAction { - switch typeIndex { - case LexerActionTypeChannel: - return NewLexerChannelAction(data1) - - case LexerActionTypeCustom: - return NewLexerCustomAction(data1, data2) - - case LexerActionTypeMode: - return NewLexerModeAction(data1) - - case LexerActionTypeMore: - return LexerMoreActionINSTANCE - - case LexerActionTypePopMode: - return LexerPopModeActionINSTANCE - - case LexerActionTypePushMode: - return NewLexerPushModeAction(data1) - - case LexerActionTypeSkip: - return LexerSkipActionINSTANCE - - case LexerActionTypeType: - return NewLexerTypeAction(data1) - - default: - panic(fmt.Sprintf("lexer action %d is invalid", typeIndex)) - } -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/atn_simulator.go b/vendor/github.com/antlr4-go/antlr/v4/atn_simulator.go deleted file mode 100644 index afe6c9f80..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/atn_simulator.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -var ATNSimulatorError = NewDFAState(0x7FFFFFFF, NewATNConfigSet(false)) - -type IATNSimulator interface { - SharedContextCache() *PredictionContextCache - ATN() *ATN - DecisionToDFA() []*DFA -} - -type BaseATNSimulator struct { - atn *ATN - sharedContextCache *PredictionContextCache - decisionToDFA []*DFA -} - -func (b *BaseATNSimulator) getCachedContext(context *PredictionContext) *PredictionContext { - if b.sharedContextCache == nil { - return context - } - - //visited := NewJMap[*PredictionContext, *PredictionContext, Comparator[*PredictionContext]](pContextEqInst, PredictionVisitedCollection, "Visit map in getCachedContext()") - visited := NewVisitRecord() - return getCachedBasePredictionContext(context, b.sharedContextCache, visited) -} - -func (b *BaseATNSimulator) SharedContextCache() *PredictionContextCache { - return b.sharedContextCache -} - -func (b *BaseATNSimulator) ATN() *ATN { - return b.atn -} - -func (b *BaseATNSimulator) DecisionToDFA() []*DFA { - return b.decisionToDFA -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/atn_state.go b/vendor/github.com/antlr4-go/antlr/v4/atn_state.go deleted file mode 100644 index 2ae5807cd..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/atn_state.go +++ /dev/null @@ -1,461 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import ( - "fmt" - "os" - "strconv" -) - -// Constants for serialization. -const ( - ATNStateInvalidType = 0 - ATNStateBasic = 1 - ATNStateRuleStart = 2 - ATNStateBlockStart = 3 - ATNStatePlusBlockStart = 4 - ATNStateStarBlockStart = 5 - ATNStateTokenStart = 6 - ATNStateRuleStop = 7 - ATNStateBlockEnd = 8 - ATNStateStarLoopBack = 9 - ATNStateStarLoopEntry = 10 - ATNStatePlusLoopBack = 11 - ATNStateLoopEnd = 12 - - ATNStateInvalidStateNumber = -1 -) - -//goland:noinspection GoUnusedGlobalVariable -var ATNStateInitialNumTransitions = 4 - -type ATNState interface { - GetEpsilonOnlyTransitions() bool - - GetRuleIndex() int - SetRuleIndex(int) - - GetNextTokenWithinRule() *IntervalSet - SetNextTokenWithinRule(*IntervalSet) - - GetATN() *ATN - SetATN(*ATN) - - GetStateType() int - - GetStateNumber() int - SetStateNumber(int) - - GetTransitions() []Transition - SetTransitions([]Transition) - AddTransition(Transition, int) - - String() string - Hash() int - Equals(Collectable[ATNState]) bool -} - -type BaseATNState struct { - // NextTokenWithinRule caches lookahead during parsing. Not used during construction. - NextTokenWithinRule *IntervalSet - - // atn is the current ATN. - atn *ATN - - epsilonOnlyTransitions bool - - // ruleIndex tracks the Rule index because there are no Rule objects at runtime. - ruleIndex int - - stateNumber int - - stateType int - - // Track the transitions emanating from this ATN state. - transitions []Transition -} - -func NewATNState() *BaseATNState { - return &BaseATNState{stateNumber: ATNStateInvalidStateNumber, stateType: ATNStateInvalidType} -} - -func (as *BaseATNState) GetRuleIndex() int { - return as.ruleIndex -} - -func (as *BaseATNState) SetRuleIndex(v int) { - as.ruleIndex = v -} -func (as *BaseATNState) GetEpsilonOnlyTransitions() bool { - return as.epsilonOnlyTransitions -} - -func (as *BaseATNState) GetATN() *ATN { - return as.atn -} - -func (as *BaseATNState) SetATN(atn *ATN) { - as.atn = atn -} - -func (as *BaseATNState) GetTransitions() []Transition { - return as.transitions -} - -func (as *BaseATNState) SetTransitions(t []Transition) { - as.transitions = t -} - -func (as *BaseATNState) GetStateType() int { - return as.stateType -} - -func (as *BaseATNState) GetStateNumber() int { - return as.stateNumber -} - -func (as *BaseATNState) SetStateNumber(stateNumber int) { - as.stateNumber = stateNumber -} - -func (as *BaseATNState) GetNextTokenWithinRule() *IntervalSet { - return as.NextTokenWithinRule -} - -func (as *BaseATNState) SetNextTokenWithinRule(v *IntervalSet) { - as.NextTokenWithinRule = v -} - -func (as *BaseATNState) Hash() int { - return as.stateNumber -} - -func (as *BaseATNState) String() string { - return strconv.Itoa(as.stateNumber) -} - -func (as *BaseATNState) Equals(other Collectable[ATNState]) bool { - if ot, ok := other.(ATNState); ok { - return as.stateNumber == ot.GetStateNumber() - } - - return false -} - -func (as *BaseATNState) isNonGreedyExitState() bool { - return false -} - -func (as *BaseATNState) AddTransition(trans Transition, index int) { - if len(as.transitions) == 0 { - as.epsilonOnlyTransitions = trans.getIsEpsilon() - } else if as.epsilonOnlyTransitions != trans.getIsEpsilon() { - _, _ = fmt.Fprintf(os.Stdin, "ATN state %d has both epsilon and non-epsilon transitions.\n", as.stateNumber) - as.epsilonOnlyTransitions = false - } - - // TODO: Check code for already present compared to the Java equivalent - //alreadyPresent := false - //for _, t := range as.transitions { - // if t.getTarget().GetStateNumber() == trans.getTarget().GetStateNumber() { - // if t.getLabel() != nil && trans.getLabel() != nil && trans.getLabel().Equals(t.getLabel()) { - // alreadyPresent = true - // break - // } - // } else if t.getIsEpsilon() && trans.getIsEpsilon() { - // alreadyPresent = true - // break - // } - //} - //if !alreadyPresent { - if index == -1 { - as.transitions = append(as.transitions, trans) - } else { - as.transitions = append(as.transitions[:index], append([]Transition{trans}, as.transitions[index:]...)...) - // TODO: as.transitions.splice(index, 1, trans) - } - //} else { - // _, _ = fmt.Fprintf(os.Stderr, "Transition already present in state %d\n", as.stateNumber) - //} -} - -type BasicState struct { - BaseATNState -} - -func NewBasicState() *BasicState { - return &BasicState{ - BaseATNState: BaseATNState{ - stateNumber: ATNStateInvalidStateNumber, - stateType: ATNStateBasic, - }, - } -} - -type DecisionState interface { - ATNState - - getDecision() int - setDecision(int) - - getNonGreedy() bool - setNonGreedy(bool) -} - -type BaseDecisionState struct { - BaseATNState - decision int - nonGreedy bool -} - -func NewBaseDecisionState() *BaseDecisionState { - return &BaseDecisionState{ - BaseATNState: BaseATNState{ - stateNumber: ATNStateInvalidStateNumber, - stateType: ATNStateBasic, - }, - decision: -1, - } -} - -func (s *BaseDecisionState) getDecision() int { - return s.decision -} - -func (s *BaseDecisionState) setDecision(b int) { - s.decision = b -} - -func (s *BaseDecisionState) getNonGreedy() bool { - return s.nonGreedy -} - -func (s *BaseDecisionState) setNonGreedy(b bool) { - s.nonGreedy = b -} - -type BlockStartState interface { - DecisionState - - getEndState() *BlockEndState - setEndState(*BlockEndState) -} - -// BaseBlockStartState is the start of a regular (...) block. -type BaseBlockStartState struct { - BaseDecisionState - endState *BlockEndState -} - -func NewBlockStartState() *BaseBlockStartState { - return &BaseBlockStartState{ - BaseDecisionState: BaseDecisionState{ - BaseATNState: BaseATNState{ - stateNumber: ATNStateInvalidStateNumber, - stateType: ATNStateBasic, - }, - decision: -1, - }, - } -} - -func (s *BaseBlockStartState) getEndState() *BlockEndState { - return s.endState -} - -func (s *BaseBlockStartState) setEndState(b *BlockEndState) { - s.endState = b -} - -type BasicBlockStartState struct { - BaseBlockStartState -} - -func NewBasicBlockStartState() *BasicBlockStartState { - return &BasicBlockStartState{ - BaseBlockStartState: BaseBlockStartState{ - BaseDecisionState: BaseDecisionState{ - BaseATNState: BaseATNState{ - stateNumber: ATNStateInvalidStateNumber, - stateType: ATNStateBlockStart, - }, - }, - }, - } -} - -var _ BlockStartState = &BasicBlockStartState{} - -// BlockEndState is a terminal node of a simple (a|b|c) block. -type BlockEndState struct { - BaseATNState - startState ATNState -} - -func NewBlockEndState() *BlockEndState { - return &BlockEndState{ - BaseATNState: BaseATNState{ - stateNumber: ATNStateInvalidStateNumber, - stateType: ATNStateBlockEnd, - }, - startState: nil, - } -} - -// RuleStopState is the last node in the ATN for a rule, unless that rule is the -// start symbol. In that case, there is one transition to EOF. Later, we might -// encode references to all calls to this rule to compute FOLLOW sets for error -// handling. -type RuleStopState struct { - BaseATNState -} - -func NewRuleStopState() *RuleStopState { - return &RuleStopState{ - BaseATNState: BaseATNState{ - stateNumber: ATNStateInvalidStateNumber, - stateType: ATNStateRuleStop, - }, - } -} - -type RuleStartState struct { - BaseATNState - stopState ATNState - isPrecedenceRule bool -} - -func NewRuleStartState() *RuleStartState { - return &RuleStartState{ - BaseATNState: BaseATNState{ - stateNumber: ATNStateInvalidStateNumber, - stateType: ATNStateRuleStart, - }, - } -} - -// PlusLoopbackState is a decision state for A+ and (A|B)+. It has two -// transitions: one to the loop back to start of the block, and one to exit. -type PlusLoopbackState struct { - BaseDecisionState -} - -func NewPlusLoopbackState() *PlusLoopbackState { - return &PlusLoopbackState{ - BaseDecisionState: BaseDecisionState{ - BaseATNState: BaseATNState{ - stateNumber: ATNStateInvalidStateNumber, - stateType: ATNStatePlusLoopBack, - }, - }, - } -} - -// PlusBlockStartState is the start of a (A|B|...)+ loop. Technically it is a -// decision state; we don't use it for code generation. Somebody might need it, -// it is included for completeness. In reality, PlusLoopbackState is the real -// decision-making node for A+. -type PlusBlockStartState struct { - BaseBlockStartState - loopBackState ATNState -} - -func NewPlusBlockStartState() *PlusBlockStartState { - return &PlusBlockStartState{ - BaseBlockStartState: BaseBlockStartState{ - BaseDecisionState: BaseDecisionState{ - BaseATNState: BaseATNState{ - stateNumber: ATNStateInvalidStateNumber, - stateType: ATNStatePlusBlockStart, - }, - }, - }, - } -} - -var _ BlockStartState = &PlusBlockStartState{} - -// StarBlockStartState is the block that begins a closure loop. -type StarBlockStartState struct { - BaseBlockStartState -} - -func NewStarBlockStartState() *StarBlockStartState { - return &StarBlockStartState{ - BaseBlockStartState: BaseBlockStartState{ - BaseDecisionState: BaseDecisionState{ - BaseATNState: BaseATNState{ - stateNumber: ATNStateInvalidStateNumber, - stateType: ATNStateStarBlockStart, - }, - }, - }, - } -} - -var _ BlockStartState = &StarBlockStartState{} - -type StarLoopbackState struct { - BaseATNState -} - -func NewStarLoopbackState() *StarLoopbackState { - return &StarLoopbackState{ - BaseATNState: BaseATNState{ - stateNumber: ATNStateInvalidStateNumber, - stateType: ATNStateStarLoopBack, - }, - } -} - -type StarLoopEntryState struct { - BaseDecisionState - loopBackState ATNState - precedenceRuleDecision bool -} - -func NewStarLoopEntryState() *StarLoopEntryState { - // False precedenceRuleDecision indicates whether s state can benefit from a precedence DFA during SLL decision making. - return &StarLoopEntryState{ - BaseDecisionState: BaseDecisionState{ - BaseATNState: BaseATNState{ - stateNumber: ATNStateInvalidStateNumber, - stateType: ATNStateStarLoopEntry, - }, - }, - } -} - -// LoopEndState marks the end of a * or + loop. -type LoopEndState struct { - BaseATNState - loopBackState ATNState -} - -func NewLoopEndState() *LoopEndState { - return &LoopEndState{ - BaseATNState: BaseATNState{ - stateNumber: ATNStateInvalidStateNumber, - stateType: ATNStateLoopEnd, - }, - } -} - -// TokensStartState is the Tokens rule start state linking to each lexer rule start state. -type TokensStartState struct { - BaseDecisionState -} - -func NewTokensStartState() *TokensStartState { - return &TokensStartState{ - BaseDecisionState: BaseDecisionState{ - BaseATNState: BaseATNState{ - stateNumber: ATNStateInvalidStateNumber, - stateType: ATNStateTokenStart, - }, - }, - } -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/atn_type.go b/vendor/github.com/antlr4-go/antlr/v4/atn_type.go deleted file mode 100644 index 3a515a145..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/atn_type.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -// Represent the type of recognizer an ATN applies to. -const ( - ATNTypeLexer = 0 - ATNTypeParser = 1 -) diff --git a/vendor/github.com/antlr4-go/antlr/v4/char_stream.go b/vendor/github.com/antlr4-go/antlr/v4/char_stream.go deleted file mode 100644 index bd8127b6b..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/char_stream.go +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -type CharStream interface { - IntStream - GetText(int, int) string - GetTextFromTokens(start, end Token) string - GetTextFromInterval(Interval) string -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/common_token_factory.go b/vendor/github.com/antlr4-go/antlr/v4/common_token_factory.go deleted file mode 100644 index 1bb0314ea..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/common_token_factory.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -// TokenFactory creates CommonToken objects. -type TokenFactory interface { - Create(source *TokenSourceCharStreamPair, ttype int, text string, channel, start, stop, line, column int) Token -} - -// CommonTokenFactory is the default TokenFactory implementation. -type CommonTokenFactory struct { - // copyText indicates whether CommonToken.setText should be called after - // constructing tokens to explicitly set the text. This is useful for cases - // where the input stream might not be able to provide arbitrary substrings of - // text from the input after the lexer creates a token (e.g. the - // implementation of CharStream.GetText in UnbufferedCharStream panics an - // UnsupportedOperationException). Explicitly setting the token text allows - // Token.GetText to be called at any time regardless of the input stream - // implementation. - // - // The default value is false to avoid the performance and memory overhead of - // copying text for every token unless explicitly requested. - copyText bool -} - -func NewCommonTokenFactory(copyText bool) *CommonTokenFactory { - return &CommonTokenFactory{copyText: copyText} -} - -// CommonTokenFactoryDEFAULT is the default CommonTokenFactory. It does not -// explicitly copy token text when constructing tokens. -var CommonTokenFactoryDEFAULT = NewCommonTokenFactory(false) - -func (c *CommonTokenFactory) Create(source *TokenSourceCharStreamPair, ttype int, text string, channel, start, stop, line, column int) Token { - t := NewCommonToken(source, ttype, channel, start, stop) - - t.line = line - t.column = column - - if text != "" { - t.SetText(text) - } else if c.copyText && source.charStream != nil { - t.SetText(source.charStream.GetTextFromInterval(NewInterval(start, stop))) - } - - return t -} - -func (c *CommonTokenFactory) createThin(ttype int, text string) Token { - t := NewCommonToken(nil, ttype, TokenDefaultChannel, -1, -1) - t.SetText(text) - - return t -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/common_token_stream.go b/vendor/github.com/antlr4-go/antlr/v4/common_token_stream.go deleted file mode 100644 index b75da9df0..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/common_token_stream.go +++ /dev/null @@ -1,450 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import ( - "strconv" -) - -// CommonTokenStream is an implementation of TokenStream that loads tokens from -// a TokenSource on-demand and places the tokens in a buffer to provide access -// to any previous token by index. This token stream ignores the value of -// Token.getChannel. If your parser requires the token stream filter tokens to -// only those on a particular channel, such as Token.DEFAULT_CHANNEL or -// Token.HIDDEN_CHANNEL, use a filtering token stream such a CommonTokenStream. -type CommonTokenStream struct { - channel int - - // fetchedEOF indicates whether the Token.EOF token has been fetched from - // tokenSource and added to tokens. This field improves performance for the - // following cases: - // - // consume: The lookahead check in consume to preven consuming the EOF symbol is - // optimized by checking the values of fetchedEOF and p instead of calling LA. - // - // fetch: The check to prevent adding multiple EOF symbols into tokens is - // trivial with bt field. - fetchedEOF bool - - // index into [tokens] of the current token (next token to consume). - // tokens[p] should be LT(1). It is set to -1 when the stream is first - // constructed or when SetTokenSource is called, indicating that the first token - // has not yet been fetched from the token source. For additional information, - // see the documentation of [IntStream] for a description of initializing methods. - index int - - // tokenSource is the [TokenSource] from which tokens for the bt stream are - // fetched. - tokenSource TokenSource - - // tokens contains all tokens fetched from the token source. The list is considered a - // complete view of the input once fetchedEOF is set to true. - tokens []Token -} - -// NewCommonTokenStream creates a new CommonTokenStream instance using the supplied lexer to produce -// tokens and will pull tokens from the given lexer channel. -func NewCommonTokenStream(lexer Lexer, channel int) *CommonTokenStream { - return &CommonTokenStream{ - channel: channel, - index: -1, - tokenSource: lexer, - tokens: make([]Token, 0), - } -} - -// GetAllTokens returns all tokens currently pulled from the token source. -func (c *CommonTokenStream) GetAllTokens() []Token { - return c.tokens -} - -func (c *CommonTokenStream) Mark() int { - return 0 -} - -func (c *CommonTokenStream) Release(_ int) {} - -func (c *CommonTokenStream) Reset() { - c.fetchedEOF = false - c.tokens = make([]Token, 0) - c.Seek(0) -} - -func (c *CommonTokenStream) Seek(index int) { - c.lazyInit() - c.index = c.adjustSeekIndex(index) -} - -func (c *CommonTokenStream) Get(index int) Token { - c.lazyInit() - - return c.tokens[index] -} - -func (c *CommonTokenStream) Consume() { - SkipEOFCheck := false - - if c.index >= 0 { - if c.fetchedEOF { - // The last token in tokens is EOF. Skip the check if p indexes any fetched. - // token except the last. - SkipEOFCheck = c.index < len(c.tokens)-1 - } else { - // No EOF token in tokens. Skip the check if p indexes a fetched token. - SkipEOFCheck = c.index < len(c.tokens) - } - } else { - // Not yet initialized - SkipEOFCheck = false - } - - if !SkipEOFCheck && c.LA(1) == TokenEOF { - panic("cannot consume EOF") - } - - if c.Sync(c.index + 1) { - c.index = c.adjustSeekIndex(c.index + 1) - } -} - -// Sync makes sure index i in tokens has a token and returns true if a token is -// located at index i and otherwise false. -func (c *CommonTokenStream) Sync(i int) bool { - n := i - len(c.tokens) + 1 // How many more elements do we need? - - if n > 0 { - fetched := c.fetch(n) - return fetched >= n - } - - return true -} - -// fetch adds n elements to buffer and returns the actual number of elements -// added to the buffer. -func (c *CommonTokenStream) fetch(n int) int { - if c.fetchedEOF { - return 0 - } - - for i := 0; i < n; i++ { - t := c.tokenSource.NextToken() - - t.SetTokenIndex(len(c.tokens)) - c.tokens = append(c.tokens, t) - - if t.GetTokenType() == TokenEOF { - c.fetchedEOF = true - - return i + 1 - } - } - - return n -} - -// GetTokens gets all tokens from start to stop inclusive. -func (c *CommonTokenStream) GetTokens(start int, stop int, types *IntervalSet) []Token { - if start < 0 || stop < 0 { - return nil - } - - c.lazyInit() - - subset := make([]Token, 0) - - if stop >= len(c.tokens) { - stop = len(c.tokens) - 1 - } - - for i := start; i < stop; i++ { - t := c.tokens[i] - - if t.GetTokenType() == TokenEOF { - break - } - - if types == nil || types.contains(t.GetTokenType()) { - subset = append(subset, t) - } - } - - return subset -} - -func (c *CommonTokenStream) LA(i int) int { - return c.LT(i).GetTokenType() -} - -func (c *CommonTokenStream) lazyInit() { - if c.index == -1 { - c.setup() - } -} - -func (c *CommonTokenStream) setup() { - c.Sync(0) - c.index = c.adjustSeekIndex(0) -} - -func (c *CommonTokenStream) GetTokenSource() TokenSource { - return c.tokenSource -} - -// SetTokenSource resets the c token stream by setting its token source. -func (c *CommonTokenStream) SetTokenSource(tokenSource TokenSource) { - c.tokenSource = tokenSource - c.tokens = make([]Token, 0) - c.index = -1 - c.fetchedEOF = false -} - -// NextTokenOnChannel returns the index of the next token on channel given a -// starting index. Returns i if tokens[i] is on channel. Returns -1 if there are -// no tokens on channel between 'i' and [TokenEOF]. -func (c *CommonTokenStream) NextTokenOnChannel(i, _ int) int { - c.Sync(i) - - if i >= len(c.tokens) { - return -1 - } - - token := c.tokens[i] - - for token.GetChannel() != c.channel { - if token.GetTokenType() == TokenEOF { - return -1 - } - - i++ - c.Sync(i) - token = c.tokens[i] - } - - return i -} - -// previousTokenOnChannel returns the index of the previous token on channel -// given a starting index. Returns i if tokens[i] is on channel. Returns -1 if -// there are no tokens on channel between i and 0. -func (c *CommonTokenStream) previousTokenOnChannel(i, channel int) int { - for i >= 0 && c.tokens[i].GetChannel() != channel { - i-- - } - - return i -} - -// GetHiddenTokensToRight collects all tokens on a specified channel to the -// right of the current token up until we see a token on DEFAULT_TOKEN_CHANNEL -// or EOF. If channel is -1, it finds any non-default channel token. -func (c *CommonTokenStream) GetHiddenTokensToRight(tokenIndex, channel int) []Token { - c.lazyInit() - - if tokenIndex < 0 || tokenIndex >= len(c.tokens) { - panic(strconv.Itoa(tokenIndex) + " not in 0.." + strconv.Itoa(len(c.tokens)-1)) - } - - nextOnChannel := c.NextTokenOnChannel(tokenIndex+1, LexerDefaultTokenChannel) - from := tokenIndex + 1 - - // If no onChannel to the right, then nextOnChannel == -1, so set 'to' to the last token - var to int - - if nextOnChannel == -1 { - to = len(c.tokens) - 1 - } else { - to = nextOnChannel - } - - return c.filterForChannel(from, to, channel) -} - -// GetHiddenTokensToLeft collects all tokens on channel to the left of the -// current token until we see a token on DEFAULT_TOKEN_CHANNEL. If channel is -// -1, it finds any non default channel token. -func (c *CommonTokenStream) GetHiddenTokensToLeft(tokenIndex, channel int) []Token { - c.lazyInit() - - if tokenIndex < 0 || tokenIndex >= len(c.tokens) { - panic(strconv.Itoa(tokenIndex) + " not in 0.." + strconv.Itoa(len(c.tokens)-1)) - } - - prevOnChannel := c.previousTokenOnChannel(tokenIndex-1, LexerDefaultTokenChannel) - - if prevOnChannel == tokenIndex-1 { - return nil - } - - // If there are none on channel to the left and prevOnChannel == -1 then from = 0 - from := prevOnChannel + 1 - to := tokenIndex - 1 - - return c.filterForChannel(from, to, channel) -} - -func (c *CommonTokenStream) filterForChannel(left, right, channel int) []Token { - hidden := make([]Token, 0) - - for i := left; i < right+1; i++ { - t := c.tokens[i] - - if channel == -1 { - if t.GetChannel() != LexerDefaultTokenChannel { - hidden = append(hidden, t) - } - } else if t.GetChannel() == channel { - hidden = append(hidden, t) - } - } - - if len(hidden) == 0 { - return nil - } - - return hidden -} - -func (c *CommonTokenStream) GetSourceName() string { - return c.tokenSource.GetSourceName() -} - -func (c *CommonTokenStream) Size() int { - return len(c.tokens) -} - -func (c *CommonTokenStream) Index() int { - return c.index -} - -func (c *CommonTokenStream) GetAllText() string { - c.Fill() - return c.GetTextFromInterval(NewInterval(0, len(c.tokens)-1)) -} - -func (c *CommonTokenStream) GetTextFromTokens(start, end Token) string { - if start == nil || end == nil { - return "" - } - - return c.GetTextFromInterval(NewInterval(start.GetTokenIndex(), end.GetTokenIndex())) -} - -func (c *CommonTokenStream) GetTextFromRuleContext(interval RuleContext) string { - return c.GetTextFromInterval(interval.GetSourceInterval()) -} - -func (c *CommonTokenStream) GetTextFromInterval(interval Interval) string { - c.lazyInit() - c.Sync(interval.Stop) - - start := interval.Start - stop := interval.Stop - - if start < 0 || stop < 0 { - return "" - } - - if stop >= len(c.tokens) { - stop = len(c.tokens) - 1 - } - - s := "" - - for i := start; i < stop+1; i++ { - t := c.tokens[i] - - if t.GetTokenType() == TokenEOF { - break - } - - s += t.GetText() - } - - return s -} - -// Fill gets all tokens from the lexer until EOF. -func (c *CommonTokenStream) Fill() { - c.lazyInit() - - for c.fetch(1000) == 1000 { - continue - } -} - -func (c *CommonTokenStream) adjustSeekIndex(i int) int { - return c.NextTokenOnChannel(i, c.channel) -} - -func (c *CommonTokenStream) LB(k int) Token { - if k == 0 || c.index-k < 0 { - return nil - } - - i := c.index - n := 1 - - // Find k good tokens looking backward - for n <= k { - // Skip off-channel tokens - i = c.previousTokenOnChannel(i-1, c.channel) - n++ - } - - if i < 0 { - return nil - } - - return c.tokens[i] -} - -func (c *CommonTokenStream) LT(k int) Token { - c.lazyInit() - - if k == 0 { - return nil - } - - if k < 0 { - return c.LB(-k) - } - - i := c.index - n := 1 // We know tokens[n] is valid - - // Find k good tokens - for n < k { - // Skip off-channel tokens, but make sure to not look past EOF - if c.Sync(i + 1) { - i = c.NextTokenOnChannel(i+1, c.channel) - } - - n++ - } - - return c.tokens[i] -} - -// getNumberOfOnChannelTokens counts EOF once. -func (c *CommonTokenStream) getNumberOfOnChannelTokens() int { - var n int - - c.Fill() - - for i := 0; i < len(c.tokens); i++ { - t := c.tokens[i] - - if t.GetChannel() == c.channel { - n++ - } - - if t.GetTokenType() == TokenEOF { - break - } - } - - return n -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/comparators.go b/vendor/github.com/antlr4-go/antlr/v4/comparators.go deleted file mode 100644 index 7467e9b43..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/comparators.go +++ /dev/null @@ -1,150 +0,0 @@ -package antlr - -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -// This file contains all the implementations of custom comparators used for generic collections when the -// Hash() and Equals() funcs supplied by the struct objects themselves need to be overridden. Normally, we would -// put the comparators in the source file for the struct themselves, but given the organization of this code is -// sorta kinda based upon the Java code, I found it confusing trying to find out which comparator was where and used by -// which instantiation of a collection. For instance, an Array2DHashSet in the Java source, when used with ATNConfig -// collections requires three different comparators depending on what the collection is being used for. Collecting - pun intended - -// all the comparators here, makes it much easier to see which implementation of hash and equals is used by which collection. -// It also makes it easy to verify that the Hash() and Equals() functions marry up with the Java implementations. - -// ObjEqComparator is the equivalent of the Java ObjectEqualityComparator, which is the default instance of -// Equality comparator. We do not have inheritance in Go, only interfaces, so we use generics to enforce some -// type safety and avoid having to implement this for every type that we want to perform comparison on. -// -// This comparator works by using the standard Hash() and Equals() methods of the type T that is being compared. Which -// allows us to use it in any collection instance that does not require a special hash or equals implementation. -type ObjEqComparator[T Collectable[T]] struct{} - -var ( - aStateEqInst = &ObjEqComparator[ATNState]{} - aConfEqInst = &ObjEqComparator[*ATNConfig]{} - - // aConfCompInst is the comparator used for the ATNConfigSet for the configLookup cache - aConfCompInst = &ATNConfigComparator[*ATNConfig]{} - atnConfCompInst = &BaseATNConfigComparator[*ATNConfig]{} - dfaStateEqInst = &ObjEqComparator[*DFAState]{} - semctxEqInst = &ObjEqComparator[SemanticContext]{} - atnAltCfgEqInst = &ATNAltConfigComparator[*ATNConfig]{} - pContextEqInst = &ObjEqComparator[*PredictionContext]{} -) - -// Equals2 delegates to the Equals() method of type T -func (c *ObjEqComparator[T]) Equals2(o1, o2 T) bool { - return o1.Equals(o2) -} - -// Hash1 delegates to the Hash() method of type T -func (c *ObjEqComparator[T]) Hash1(o T) int { - - return o.Hash() -} - -type SemCComparator[T Collectable[T]] struct{} - -// ATNConfigComparator is used as the comparator for the configLookup field of an ATNConfigSet -// and has a custom Equals() and Hash() implementation, because equality is not based on the -// standard Hash() and Equals() methods of the ATNConfig type. -type ATNConfigComparator[T Collectable[T]] struct { -} - -// Equals2 is a custom comparator for ATNConfigs specifically for configLookup -func (c *ATNConfigComparator[T]) Equals2(o1, o2 *ATNConfig) bool { - - // Same pointer, must be equal, even if both nil - // - if o1 == o2 { - return true - - } - - // If either are nil, but not both, then the result is false - // - if o1 == nil || o2 == nil { - return false - } - - return o1.GetState().GetStateNumber() == o2.GetState().GetStateNumber() && - o1.GetAlt() == o2.GetAlt() && - o1.GetSemanticContext().Equals(o2.GetSemanticContext()) -} - -// Hash1 is custom hash implementation for ATNConfigs specifically for configLookup -func (c *ATNConfigComparator[T]) Hash1(o *ATNConfig) int { - - hash := 7 - hash = 31*hash + o.GetState().GetStateNumber() - hash = 31*hash + o.GetAlt() - hash = 31*hash + o.GetSemanticContext().Hash() - return hash -} - -// ATNAltConfigComparator is used as the comparator for mapping configs to Alt Bitsets -type ATNAltConfigComparator[T Collectable[T]] struct { -} - -// Equals2 is a custom comparator for ATNConfigs specifically for configLookup -func (c *ATNAltConfigComparator[T]) Equals2(o1, o2 *ATNConfig) bool { - - // Same pointer, must be equal, even if both nil - // - if o1 == o2 { - return true - - } - - // If either are nil, but not both, then the result is false - // - if o1 == nil || o2 == nil { - return false - } - - return o1.GetState().GetStateNumber() == o2.GetState().GetStateNumber() && - o1.GetContext().Equals(o2.GetContext()) -} - -// Hash1 is custom hash implementation for ATNConfigs specifically for configLookup -func (c *ATNAltConfigComparator[T]) Hash1(o *ATNConfig) int { - h := murmurInit(7) - h = murmurUpdate(h, o.GetState().GetStateNumber()) - h = murmurUpdate(h, o.GetContext().Hash()) - return murmurFinish(h, 2) -} - -// BaseATNConfigComparator is used as the comparator for the configLookup field of a ATNConfigSet -// and has a custom Equals() and Hash() implementation, because equality is not based on the -// standard Hash() and Equals() methods of the ATNConfig type. -type BaseATNConfigComparator[T Collectable[T]] struct { -} - -// Equals2 is a custom comparator for ATNConfigs specifically for baseATNConfigSet -func (c *BaseATNConfigComparator[T]) Equals2(o1, o2 *ATNConfig) bool { - - // Same pointer, must be equal, even if both nil - // - if o1 == o2 { - return true - - } - - // If either are nil, but not both, then the result is false - // - if o1 == nil || o2 == nil { - return false - } - - return o1.GetState().GetStateNumber() == o2.GetState().GetStateNumber() && - o1.GetAlt() == o2.GetAlt() && - o1.GetSemanticContext().Equals(o2.GetSemanticContext()) -} - -// Hash1 is custom hash implementation for ATNConfigs specifically for configLookup, but in fact just -// delegates to the standard Hash() method of the ATNConfig type. -func (c *BaseATNConfigComparator[T]) Hash1(o *ATNConfig) int { - return o.Hash() -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/configuration.go b/vendor/github.com/antlr4-go/antlr/v4/configuration.go deleted file mode 100644 index c2b724514..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/configuration.go +++ /dev/null @@ -1,214 +0,0 @@ -package antlr - -type runtimeConfiguration struct { - statsTraceStacks bool - lexerATNSimulatorDebug bool - lexerATNSimulatorDFADebug bool - parserATNSimulatorDebug bool - parserATNSimulatorTraceATNSim bool - parserATNSimulatorDFADebug bool - parserATNSimulatorRetryDebug bool - lRLoopEntryBranchOpt bool - memoryManager bool -} - -// Global runtime configuration -var runtimeConfig = runtimeConfiguration{ - lRLoopEntryBranchOpt: true, -} - -type runtimeOption func(*runtimeConfiguration) error - -// ConfigureRuntime allows the runtime to be configured globally setting things like trace and statistics options. -// It uses the functional options pattern for go. This is a package global function as it operates on the runtime -// configuration regardless of the instantiation of anything higher up such as a parser or lexer. Generally this is -// used for debugging/tracing/statistics options, which are usually used by the runtime maintainers (or rather the -// only maintainer). However, it is possible that you might want to use this to set a global option concerning the -// memory allocation type used by the runtime such as sync.Pool or not. -// -// The options are applied in the order they are passed in, so the last option will override any previous options. -// -// For example, if you want to turn on the collection create point stack flag to true, you can do: -// -// antlr.ConfigureRuntime(antlr.WithStatsTraceStacks(true)) -// -// If you want to turn it off, you can do: -// -// antlr.ConfigureRuntime(antlr.WithStatsTraceStacks(false)) -func ConfigureRuntime(options ...runtimeOption) error { - for _, option := range options { - err := option(&runtimeConfig) - if err != nil { - return err - } - } - return nil -} - -// WithStatsTraceStacks sets the global flag indicating whether to collect stack traces at the create-point of -// certain structs, such as collections, or the use point of certain methods such as Put(). -// Because this can be expensive, it is turned off by default. However, it -// can be useful to track down exactly where memory is being created and used. -// -// Use: -// -// antlr.ConfigureRuntime(antlr.WithStatsTraceStacks(true)) -// -// You can turn it off at any time using: -// -// antlr.ConfigureRuntime(antlr.WithStatsTraceStacks(false)) -func WithStatsTraceStacks(trace bool) runtimeOption { - return func(config *runtimeConfiguration) error { - config.statsTraceStacks = trace - return nil - } -} - -// WithLexerATNSimulatorDebug sets the global flag indicating whether to log debug information from the lexer [ATN] -// simulator. This is useful for debugging lexer issues by comparing the output with the Java runtime. Only useful -// to the runtime maintainers. -// -// Use: -// -// antlr.ConfigureRuntime(antlr.WithLexerATNSimulatorDebug(true)) -// -// You can turn it off at any time using: -// -// antlr.ConfigureRuntime(antlr.WithLexerATNSimulatorDebug(false)) -func WithLexerATNSimulatorDebug(debug bool) runtimeOption { - return func(config *runtimeConfiguration) error { - config.lexerATNSimulatorDebug = debug - return nil - } -} - -// WithLexerATNSimulatorDFADebug sets the global flag indicating whether to log debug information from the lexer [ATN] [DFA] -// simulator. This is useful for debugging lexer issues by comparing the output with the Java runtime. Only useful -// to the runtime maintainers. -// -// Use: -// -// antlr.ConfigureRuntime(antlr.WithLexerATNSimulatorDFADebug(true)) -// -// You can turn it off at any time using: -// -// antlr.ConfigureRuntime(antlr.WithLexerATNSimulatorDFADebug(false)) -func WithLexerATNSimulatorDFADebug(debug bool) runtimeOption { - return func(config *runtimeConfiguration) error { - config.lexerATNSimulatorDFADebug = debug - return nil - } -} - -// WithParserATNSimulatorDebug sets the global flag indicating whether to log debug information from the parser [ATN] -// simulator. This is useful for debugging parser issues by comparing the output with the Java runtime. Only useful -// to the runtime maintainers. -// -// Use: -// -// antlr.ConfigureRuntime(antlr.WithParserATNSimulatorDebug(true)) -// -// You can turn it off at any time using: -// -// antlr.ConfigureRuntime(antlr.WithParserATNSimulatorDebug(false)) -func WithParserATNSimulatorDebug(debug bool) runtimeOption { - return func(config *runtimeConfiguration) error { - config.parserATNSimulatorDebug = debug - return nil - } -} - -// WithParserATNSimulatorTraceATNSim sets the global flag indicating whether to log trace information from the parser [ATN] simulator -// [DFA]. This is useful for debugging parser issues by comparing the output with the Java runtime. Only useful -// to the runtime maintainers. -// -// Use: -// -// antlr.ConfigureRuntime(antlr.WithParserATNSimulatorTraceATNSim(true)) -// -// You can turn it off at any time using: -// -// antlr.ConfigureRuntime(antlr.WithParserATNSimulatorTraceATNSim(false)) -func WithParserATNSimulatorTraceATNSim(trace bool) runtimeOption { - return func(config *runtimeConfiguration) error { - config.parserATNSimulatorTraceATNSim = trace - return nil - } -} - -// WithParserATNSimulatorDFADebug sets the global flag indicating whether to log debug information from the parser [ATN] [DFA] -// simulator. This is useful for debugging parser issues by comparing the output with the Java runtime. Only useful -// to the runtime maintainers. -// -// Use: -// -// antlr.ConfigureRuntime(antlr.WithParserATNSimulatorDFADebug(true)) -// -// You can turn it off at any time using: -// -// antlr.ConfigureRuntime(antlr.WithParserATNSimulatorDFADebug(false)) -func WithParserATNSimulatorDFADebug(debug bool) runtimeOption { - return func(config *runtimeConfiguration) error { - config.parserATNSimulatorDFADebug = debug - return nil - } -} - -// WithParserATNSimulatorRetryDebug sets the global flag indicating whether to log debug information from the parser [ATN] [DFA] -// simulator when retrying a decision. This is useful for debugging parser issues by comparing the output with the Java runtime. -// Only useful to the runtime maintainers. -// -// Use: -// -// antlr.ConfigureRuntime(antlr.WithParserATNSimulatorRetryDebug(true)) -// -// You can turn it off at any time using: -// -// antlr.ConfigureRuntime(antlr.WithParserATNSimulatorRetryDebug(false)) -func WithParserATNSimulatorRetryDebug(debug bool) runtimeOption { - return func(config *runtimeConfiguration) error { - config.parserATNSimulatorRetryDebug = debug - return nil - } -} - -// WithLRLoopEntryBranchOpt sets the global flag indicating whether let recursive loop operations should be -// optimized or not. This is useful for debugging parser issues by comparing the output with the Java runtime. -// It turns off the functionality of [canDropLoopEntryEdgeInLeftRecursiveRule] in [ParserATNSimulator]. -// -// Note that default is to use this optimization. -// -// Use: -// -// antlr.ConfigureRuntime(antlr.WithLRLoopEntryBranchOpt(true)) -// -// You can turn it off at any time using: -// -// antlr.ConfigureRuntime(antlr.WithLRLoopEntryBranchOpt(false)) -func WithLRLoopEntryBranchOpt(off bool) runtimeOption { - return func(config *runtimeConfiguration) error { - config.lRLoopEntryBranchOpt = off - return nil - } -} - -// WithMemoryManager sets the global flag indicating whether to use the memory manager or not. This is useful -// for poorly constructed grammars that create a lot of garbage. It turns on the functionality of [memoryManager], which -// will intercept garbage collection and cause available memory to be reused. At the end of the day, this is no substitute -// for fixing your grammar by ridding yourself of extreme ambiguity. BUt if you are just trying to reuse an opensource -// grammar, this may help make it more practical. -// -// Note that default is to use normal Go memory allocation and not pool memory. -// -// Use: -// -// antlr.ConfigureRuntime(antlr.WithMemoryManager(true)) -// -// Note that if you turn this on, you should probably leave it on. You should use only one memory strategy or the other -// and should remember to nil out any references to the parser or lexer when you are done with them. -func WithMemoryManager(use bool) runtimeOption { - return func(config *runtimeConfiguration) error { - config.memoryManager = use - return nil - } -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/dfa.go b/vendor/github.com/antlr4-go/antlr/v4/dfa.go deleted file mode 100644 index 6b63eb158..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/dfa.go +++ /dev/null @@ -1,175 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -// DFA represents the Deterministic Finite Automaton used by the recognizer, including all the states it can -// reach and the transitions between them. -type DFA struct { - // atnStartState is the ATN state in which this was created - atnStartState DecisionState - - decision int - - // states is all the DFA states. Use Map to get the old state back; Set can only - // indicate whether it is there. Go maps implement key hash collisions and so on and are very - // good, but the DFAState is an object and can't be used directly as the key as it can in say Java - // amd C#, whereby if the hashcode is the same for two objects, then Equals() is called against them - // to see if they really are the same object. Hence, we have our own map storage. - // - states *JStore[*DFAState, *ObjEqComparator[*DFAState]] - - numstates int - - s0 *DFAState - - // precedenceDfa is the backing field for isPrecedenceDfa and setPrecedenceDfa. - // True if the DFA is for a precedence decision and false otherwise. - precedenceDfa bool -} - -func NewDFA(atnStartState DecisionState, decision int) *DFA { - dfa := &DFA{ - atnStartState: atnStartState, - decision: decision, - states: nil, // Lazy initialize - } - if s, ok := atnStartState.(*StarLoopEntryState); ok && s.precedenceRuleDecision { - dfa.precedenceDfa = true - dfa.s0 = NewDFAState(-1, NewATNConfigSet(false)) - dfa.s0.isAcceptState = false - dfa.s0.requiresFullContext = false - } - return dfa -} - -// getPrecedenceStartState gets the start state for the current precedence and -// returns the start state corresponding to the specified precedence if a start -// state exists for the specified precedence and nil otherwise. d must be a -// precedence DFA. See also isPrecedenceDfa. -func (d *DFA) getPrecedenceStartState(precedence int) *DFAState { - if !d.getPrecedenceDfa() { - panic("only precedence DFAs may contain a precedence start state") - } - - // s0.edges is never nil for a precedence DFA - if precedence < 0 || precedence >= len(d.getS0().getEdges()) { - return nil - } - - return d.getS0().getIthEdge(precedence) -} - -// setPrecedenceStartState sets the start state for the current precedence. d -// must be a precedence DFA. See also isPrecedenceDfa. -func (d *DFA) setPrecedenceStartState(precedence int, startState *DFAState) { - if !d.getPrecedenceDfa() { - panic("only precedence DFAs may contain a precedence start state") - } - - if precedence < 0 { - return - } - - // Synchronization on s0 here is ok. When the DFA is turned into a - // precedence DFA, s0 will be initialized once and not updated again. s0.edges - // is never nil for a precedence DFA. - s0 := d.getS0() - if precedence >= s0.numEdges() { - edges := append(s0.getEdges(), make([]*DFAState, precedence+1-s0.numEdges())...) - s0.setEdges(edges) - d.setS0(s0) - } - - s0.setIthEdge(precedence, startState) -} - -func (d *DFA) getPrecedenceDfa() bool { - return d.precedenceDfa -} - -// setPrecedenceDfa sets whether d is a precedence DFA. If precedenceDfa differs -// from the current DFA configuration, then d.states is cleared, the initial -// state s0 is set to a new DFAState with an empty outgoing DFAState.edges to -// store the start states for individual precedence values if precedenceDfa is -// true or nil otherwise, and d.precedenceDfa is updated. -func (d *DFA) setPrecedenceDfa(precedenceDfa bool) { - if d.getPrecedenceDfa() != precedenceDfa { - d.states = nil // Lazy initialize - d.numstates = 0 - - if precedenceDfa { - precedenceState := NewDFAState(-1, NewATNConfigSet(false)) - precedenceState.setEdges(make([]*DFAState, 0)) - precedenceState.isAcceptState = false - precedenceState.requiresFullContext = false - d.setS0(precedenceState) - } else { - d.setS0(nil) - } - - d.precedenceDfa = precedenceDfa - } -} - -// Len returns the number of states in d. We use this instead of accessing states directly so that we can implement lazy -// instantiation of the states JMap. -func (d *DFA) Len() int { - if d.states == nil { - return 0 - } - return d.states.Len() -} - -// Get returns a state that matches s if it is present in the DFA state set. We defer to this -// function instead of accessing states directly so that we can implement lazy instantiation of the states JMap. -func (d *DFA) Get(s *DFAState) (*DFAState, bool) { - if d.states == nil { - return nil, false - } - return d.states.Get(s) -} - -func (d *DFA) Put(s *DFAState) (*DFAState, bool) { - if d.states == nil { - d.states = NewJStore[*DFAState, *ObjEqComparator[*DFAState]](dfaStateEqInst, DFAStateCollection, "DFA via DFA.Put") - } - return d.states.Put(s) -} - -func (d *DFA) getS0() *DFAState { - return d.s0 -} - -func (d *DFA) setS0(s *DFAState) { - d.s0 = s -} - -// sortedStates returns the states in d sorted by their state number, or an empty set if d.states is nil. -func (d *DFA) sortedStates() []*DFAState { - if d.states == nil { - return []*DFAState{} - } - vs := d.states.SortedSlice(func(i, j *DFAState) bool { - return i.stateNumber < j.stateNumber - }) - - return vs -} - -func (d *DFA) String(literalNames []string, symbolicNames []string) string { - if d.getS0() == nil { - return "" - } - - return NewDFASerializer(d, literalNames, symbolicNames).String() -} - -func (d *DFA) ToLexerString() string { - if d.getS0() == nil { - return "" - } - - return NewLexerDFASerializer(d).String() -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/dfa_serializer.go b/vendor/github.com/antlr4-go/antlr/v4/dfa_serializer.go deleted file mode 100644 index 0e1100989..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/dfa_serializer.go +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import ( - "fmt" - "strconv" - "strings" -) - -// DFASerializer is a DFA walker that knows how to dump the DFA states to serialized -// strings. -type DFASerializer struct { - dfa *DFA - literalNames []string - symbolicNames []string -} - -func NewDFASerializer(dfa *DFA, literalNames, symbolicNames []string) *DFASerializer { - if literalNames == nil { - literalNames = make([]string, 0) - } - - if symbolicNames == nil { - symbolicNames = make([]string, 0) - } - - return &DFASerializer{ - dfa: dfa, - literalNames: literalNames, - symbolicNames: symbolicNames, - } -} - -func (d *DFASerializer) String() string { - if d.dfa.getS0() == nil { - return "" - } - - buf := "" - states := d.dfa.sortedStates() - - for _, s := range states { - if s.edges != nil { - n := len(s.edges) - - for j := 0; j < n; j++ { - t := s.edges[j] - - if t != nil && t.stateNumber != 0x7FFFFFFF { - buf += d.GetStateString(s) - buf += "-" - buf += d.getEdgeLabel(j) - buf += "->" - buf += d.GetStateString(t) - buf += "\n" - } - } - } - } - - if len(buf) == 0 { - return "" - } - - return buf -} - -func (d *DFASerializer) getEdgeLabel(i int) string { - if i == 0 { - return "EOF" - } else if d.literalNames != nil && i-1 < len(d.literalNames) { - return d.literalNames[i-1] - } else if d.symbolicNames != nil && i-1 < len(d.symbolicNames) { - return d.symbolicNames[i-1] - } - - return strconv.Itoa(i - 1) -} - -func (d *DFASerializer) GetStateString(s *DFAState) string { - var a, b string - - if s.isAcceptState { - a = ":" - } - - if s.requiresFullContext { - b = "^" - } - - baseStateStr := a + "s" + strconv.Itoa(s.stateNumber) + b - - if s.isAcceptState { - if s.predicates != nil { - return baseStateStr + "=>" + fmt.Sprint(s.predicates) - } - - return baseStateStr + "=>" + fmt.Sprint(s.prediction) - } - - return baseStateStr -} - -type LexerDFASerializer struct { - *DFASerializer -} - -func NewLexerDFASerializer(dfa *DFA) *LexerDFASerializer { - return &LexerDFASerializer{DFASerializer: NewDFASerializer(dfa, nil, nil)} -} - -func (l *LexerDFASerializer) getEdgeLabel(i int) string { - var sb strings.Builder - sb.Grow(6) - sb.WriteByte('\'') - sb.WriteRune(rune(i)) - sb.WriteByte('\'') - return sb.String() -} - -func (l *LexerDFASerializer) String() string { - if l.dfa.getS0() == nil { - return "" - } - - buf := "" - states := l.dfa.sortedStates() - - for i := 0; i < len(states); i++ { - s := states[i] - - if s.edges != nil { - n := len(s.edges) - - for j := 0; j < n; j++ { - t := s.edges[j] - - if t != nil && t.stateNumber != 0x7FFFFFFF { - buf += l.GetStateString(s) - buf += "-" - buf += l.getEdgeLabel(j) - buf += "->" - buf += l.GetStateString(t) - buf += "\n" - } - } - } - } - - if len(buf) == 0 { - return "" - } - - return buf -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/dfa_state.go b/vendor/github.com/antlr4-go/antlr/v4/dfa_state.go deleted file mode 100644 index 654143074..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/dfa_state.go +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import ( - "fmt" -) - -// PredPrediction maps a predicate to a predicted alternative. -type PredPrediction struct { - alt int - pred SemanticContext -} - -func NewPredPrediction(pred SemanticContext, alt int) *PredPrediction { - return &PredPrediction{alt: alt, pred: pred} -} - -func (p *PredPrediction) String() string { - return "(" + fmt.Sprint(p.pred) + ", " + fmt.Sprint(p.alt) + ")" -} - -// DFAState represents a set of possible [ATN] configurations. As Aho, Sethi, -// Ullman p. 117 says: "The DFA uses its state to keep track of all possible -// states the ATN can be in after reading each input symbol. That is to say, -// after reading input a1, a2,..an, the DFA is in a state that represents the -// subset T of the states of the ATN that are reachable from the ATN's start -// state along some path labeled a1a2..an." -// -// In conventional NFA-to-DFA conversion, therefore, the subset T would be a bitset representing the set of -// states the [ATN] could be in. We need to track the alt predicted by each state -// as well, however. More importantly, we need to maintain a stack of states, -// tracking the closure operations as they jump from rule to rule, emulating -// rule invocations (method calls). I have to add a stack to simulate the proper -// lookahead sequences for the underlying LL grammar from which the ATN was -// derived. -// -// I use a set of [ATNConfig] objects, not simple states. An [ATNConfig] is both a -// state (ala normal conversion) and a [RuleContext] describing the chain of rules -// (if any) followed to arrive at that state. -// -// A [DFAState] may have multiple references to a particular state, but with -// different [ATN] contexts (with same or different alts) meaning that state was -// reached via a different set of rule invocations. -type DFAState struct { - stateNumber int - configs *ATNConfigSet - - // edges elements point to the target of the symbol. Shift up by 1 so (-1) - // Token.EOF maps to the first element. - edges []*DFAState - - isAcceptState bool - - // prediction is the 'ttype' we match or alt we predict if the state is 'accept'. - // Set to ATN.INVALID_ALT_NUMBER when predicates != nil or - // requiresFullContext. - prediction int - - lexerActionExecutor *LexerActionExecutor - - // requiresFullContext indicates it was created during an SLL prediction that - // discovered a conflict between the configurations in the state. Future - // ParserATNSimulator.execATN invocations immediately jump doing - // full context prediction if true. - requiresFullContext bool - - // predicates is the predicates associated with the ATN configurations of the - // DFA state during SLL parsing. When we have predicates, requiresFullContext - // is false, since full context prediction evaluates predicates on-the-fly. If - // d is - // not nil, then prediction is ATN.INVALID_ALT_NUMBER. - // - // We only use these for non-requiresFullContext but conflicting states. That - // means we know from the context (it's $ or we don't dip into outer context) - // that it's an ambiguity not a conflict. - // - // This list is computed by - // ParserATNSimulator.predicateDFAState. - predicates []*PredPrediction -} - -func NewDFAState(stateNumber int, configs *ATNConfigSet) *DFAState { - if configs == nil { - configs = NewATNConfigSet(false) - } - - return &DFAState{configs: configs, stateNumber: stateNumber} -} - -// GetAltSet gets the set of all alts mentioned by all ATN configurations in d. -func (d *DFAState) GetAltSet() []int { - var alts []int - - if d.configs != nil { - for _, c := range d.configs.configs { - alts = append(alts, c.GetAlt()) - } - } - - if len(alts) == 0 { - return nil - } - - return alts -} - -func (d *DFAState) getEdges() []*DFAState { - return d.edges -} - -func (d *DFAState) numEdges() int { - return len(d.edges) -} - -func (d *DFAState) getIthEdge(i int) *DFAState { - return d.edges[i] -} - -func (d *DFAState) setEdges(newEdges []*DFAState) { - d.edges = newEdges -} - -func (d *DFAState) setIthEdge(i int, edge *DFAState) { - d.edges[i] = edge -} - -func (d *DFAState) setPrediction(v int) { - d.prediction = v -} - -func (d *DFAState) String() string { - var s string - if d.isAcceptState { - if d.predicates != nil { - s = "=>" + fmt.Sprint(d.predicates) - } else { - s = "=>" + fmt.Sprint(d.prediction) - } - } - - return fmt.Sprintf("%d:%s%s", d.stateNumber, fmt.Sprint(d.configs), s) -} - -func (d *DFAState) Hash() int { - h := murmurInit(7) - h = murmurUpdate(h, d.configs.Hash()) - return murmurFinish(h, 1) -} - -// Equals returns whether d equals other. Two DFAStates are equal if their ATN -// configuration sets are the same. This method is used to see if a state -// already exists. -// -// Because the number of alternatives and number of ATN configurations are -// finite, there is a finite number of DFA states that can be processed. This is -// necessary to show that the algorithm terminates. -// -// Cannot test the DFA state numbers here because in -// ParserATNSimulator.addDFAState we need to know if any other state exists that -// has d exact set of ATN configurations. The stateNumber is irrelevant. -func (d *DFAState) Equals(o Collectable[*DFAState]) bool { - if d == o { - return true - } - - return d.configs.Equals(o.(*DFAState).configs) -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/diagnostic_error_listener.go b/vendor/github.com/antlr4-go/antlr/v4/diagnostic_error_listener.go deleted file mode 100644 index bd2cd8bc3..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/diagnostic_error_listener.go +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import ( - "strconv" -) - -// -// This implementation of {@link ANTLRErrorListener} can be used to identify -// certain potential correctness and performance problems in grammars. "reports" -// are made by calling {@link Parser//NotifyErrorListeners} with the appropriate -// message. -// -// - -type DiagnosticErrorListener struct { - *DefaultErrorListener - - exactOnly bool -} - -//goland:noinspection GoUnusedExportedFunction -func NewDiagnosticErrorListener(exactOnly bool) *DiagnosticErrorListener { - - n := new(DiagnosticErrorListener) - - // whether all ambiguities or only exact ambiguities are Reported. - n.exactOnly = exactOnly - return n -} - -func (d *DiagnosticErrorListener) ReportAmbiguity(recognizer Parser, dfa *DFA, startIndex, stopIndex int, exact bool, ambigAlts *BitSet, configs *ATNConfigSet) { - if d.exactOnly && !exact { - return - } - msg := "reportAmbiguity d=" + - d.getDecisionDescription(recognizer, dfa) + - ": ambigAlts=" + - d.getConflictingAlts(ambigAlts, configs).String() + - ", input='" + - recognizer.GetTokenStream().GetTextFromInterval(NewInterval(startIndex, stopIndex)) + "'" - recognizer.NotifyErrorListeners(msg, nil, nil) -} - -func (d *DiagnosticErrorListener) ReportAttemptingFullContext(recognizer Parser, dfa *DFA, startIndex, stopIndex int, _ *BitSet, _ *ATNConfigSet) { - - msg := "reportAttemptingFullContext d=" + - d.getDecisionDescription(recognizer, dfa) + - ", input='" + - recognizer.GetTokenStream().GetTextFromInterval(NewInterval(startIndex, stopIndex)) + "'" - recognizer.NotifyErrorListeners(msg, nil, nil) -} - -func (d *DiagnosticErrorListener) ReportContextSensitivity(recognizer Parser, dfa *DFA, startIndex, stopIndex, _ int, _ *ATNConfigSet) { - msg := "reportContextSensitivity d=" + - d.getDecisionDescription(recognizer, dfa) + - ", input='" + - recognizer.GetTokenStream().GetTextFromInterval(NewInterval(startIndex, stopIndex)) + "'" - recognizer.NotifyErrorListeners(msg, nil, nil) -} - -func (d *DiagnosticErrorListener) getDecisionDescription(recognizer Parser, dfa *DFA) string { - decision := dfa.decision - ruleIndex := dfa.atnStartState.GetRuleIndex() - - ruleNames := recognizer.GetRuleNames() - if ruleIndex < 0 || ruleIndex >= len(ruleNames) { - return strconv.Itoa(decision) - } - ruleName := ruleNames[ruleIndex] - if ruleName == "" { - return strconv.Itoa(decision) - } - return strconv.Itoa(decision) + " (" + ruleName + ")" -} - -// Computes the set of conflicting or ambiguous alternatives from a -// configuration set, if that information was not already provided by the -// parser. -// -// @param ReportedAlts The set of conflicting or ambiguous alternatives, as -// Reported by the parser. -// @param configs The conflicting or ambiguous configuration set. -// @return Returns {@code ReportedAlts} if it is not {@code nil}, otherwise -// returns the set of alternatives represented in {@code configs}. -func (d *DiagnosticErrorListener) getConflictingAlts(ReportedAlts *BitSet, set *ATNConfigSet) *BitSet { - if ReportedAlts != nil { - return ReportedAlts - } - result := NewBitSet() - for _, c := range set.configs { - result.add(c.GetAlt()) - } - - return result -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/error_listener.go b/vendor/github.com/antlr4-go/antlr/v4/error_listener.go deleted file mode 100644 index 21a021643..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/error_listener.go +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import ( - "fmt" - "os" - "strconv" -) - -// Provides an empty default implementation of {@link ANTLRErrorListener}. The -// default implementation of each method does nothing, but can be overridden as -// necessary. - -type ErrorListener interface { - SyntaxError(recognizer Recognizer, offendingSymbol interface{}, line, column int, msg string, e RecognitionException) - ReportAmbiguity(recognizer Parser, dfa *DFA, startIndex, stopIndex int, exact bool, ambigAlts *BitSet, configs *ATNConfigSet) - ReportAttemptingFullContext(recognizer Parser, dfa *DFA, startIndex, stopIndex int, conflictingAlts *BitSet, configs *ATNConfigSet) - ReportContextSensitivity(recognizer Parser, dfa *DFA, startIndex, stopIndex, prediction int, configs *ATNConfigSet) -} - -type DefaultErrorListener struct { -} - -//goland:noinspection GoUnusedExportedFunction -func NewDefaultErrorListener() *DefaultErrorListener { - return new(DefaultErrorListener) -} - -func (d *DefaultErrorListener) SyntaxError(_ Recognizer, _ interface{}, _, _ int, _ string, _ RecognitionException) { -} - -func (d *DefaultErrorListener) ReportAmbiguity(_ Parser, _ *DFA, _, _ int, _ bool, _ *BitSet, _ *ATNConfigSet) { -} - -func (d *DefaultErrorListener) ReportAttemptingFullContext(_ Parser, _ *DFA, _, _ int, _ *BitSet, _ *ATNConfigSet) { -} - -func (d *DefaultErrorListener) ReportContextSensitivity(_ Parser, _ *DFA, _, _, _ int, _ *ATNConfigSet) { -} - -type ConsoleErrorListener struct { - *DefaultErrorListener -} - -func NewConsoleErrorListener() *ConsoleErrorListener { - return new(ConsoleErrorListener) -} - -// ConsoleErrorListenerINSTANCE provides a default instance of {@link ConsoleErrorListener}. -var ConsoleErrorListenerINSTANCE = NewConsoleErrorListener() - -// SyntaxError prints messages to System.err containing the -// values of line, charPositionInLine, and msg using -// the following format: -// -// line : -func (c *ConsoleErrorListener) SyntaxError(_ Recognizer, _ interface{}, line, column int, msg string, _ RecognitionException) { - _, _ = fmt.Fprintln(os.Stderr, "line "+strconv.Itoa(line)+":"+strconv.Itoa(column)+" "+msg) -} - -type ProxyErrorListener struct { - *DefaultErrorListener - delegates []ErrorListener -} - -func NewProxyErrorListener(delegates []ErrorListener) *ProxyErrorListener { - if delegates == nil { - panic("delegates is not provided") - } - l := new(ProxyErrorListener) - l.delegates = delegates - return l -} - -func (p *ProxyErrorListener) SyntaxError(recognizer Recognizer, offendingSymbol interface{}, line, column int, msg string, e RecognitionException) { - for _, d := range p.delegates { - d.SyntaxError(recognizer, offendingSymbol, line, column, msg, e) - } -} - -func (p *ProxyErrorListener) ReportAmbiguity(recognizer Parser, dfa *DFA, startIndex, stopIndex int, exact bool, ambigAlts *BitSet, configs *ATNConfigSet) { - for _, d := range p.delegates { - d.ReportAmbiguity(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs) - } -} - -func (p *ProxyErrorListener) ReportAttemptingFullContext(recognizer Parser, dfa *DFA, startIndex, stopIndex int, conflictingAlts *BitSet, configs *ATNConfigSet) { - for _, d := range p.delegates { - d.ReportAttemptingFullContext(recognizer, dfa, startIndex, stopIndex, conflictingAlts, configs) - } -} - -func (p *ProxyErrorListener) ReportContextSensitivity(recognizer Parser, dfa *DFA, startIndex, stopIndex, prediction int, configs *ATNConfigSet) { - for _, d := range p.delegates { - d.ReportContextSensitivity(recognizer, dfa, startIndex, stopIndex, prediction, configs) - } -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/error_strategy.go b/vendor/github.com/antlr4-go/antlr/v4/error_strategy.go deleted file mode 100644 index 9db2be1c7..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/error_strategy.go +++ /dev/null @@ -1,702 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import ( - "fmt" - "reflect" - "strconv" - "strings" -) - -type ErrorStrategy interface { - reset(Parser) - RecoverInline(Parser) Token - Recover(Parser, RecognitionException) - Sync(Parser) - InErrorRecoveryMode(Parser) bool - ReportError(Parser, RecognitionException) - ReportMatch(Parser) -} - -// DefaultErrorStrategy is the default implementation of ANTLRErrorStrategy used for -// error reporting and recovery in ANTLR parsers. -type DefaultErrorStrategy struct { - errorRecoveryMode bool - lastErrorIndex int - lastErrorStates *IntervalSet -} - -var _ ErrorStrategy = &DefaultErrorStrategy{} - -func NewDefaultErrorStrategy() *DefaultErrorStrategy { - - d := new(DefaultErrorStrategy) - - // Indicates whether the error strategy is currently "recovering from an - // error". This is used to suppress Reporting multiple error messages while - // attempting to recover from a detected syntax error. - // - // @see //InErrorRecoveryMode - // - d.errorRecoveryMode = false - - // The index into the input stream where the last error occurred. - // This is used to prevent infinite loops where an error is found - // but no token is consumed during recovery...another error is found, - // ad nauseam. This is a failsafe mechanism to guarantee that at least - // one token/tree node is consumed for two errors. - // - d.lastErrorIndex = -1 - d.lastErrorStates = nil - return d -} - -//

The default implementation simply calls {@link //endErrorCondition} to -// ensure that the handler is not in error recovery mode.

-func (d *DefaultErrorStrategy) reset(recognizer Parser) { - d.endErrorCondition(recognizer) -} - -// This method is called to enter error recovery mode when a recognition -// exception is Reported. -func (d *DefaultErrorStrategy) beginErrorCondition(_ Parser) { - d.errorRecoveryMode = true -} - -func (d *DefaultErrorStrategy) InErrorRecoveryMode(_ Parser) bool { - return d.errorRecoveryMode -} - -// This method is called to leave error recovery mode after recovering from -// a recognition exception. -func (d *DefaultErrorStrategy) endErrorCondition(_ Parser) { - d.errorRecoveryMode = false - d.lastErrorStates = nil - d.lastErrorIndex = -1 -} - -// ReportMatch is the default implementation of error matching and simply calls endErrorCondition. -func (d *DefaultErrorStrategy) ReportMatch(recognizer Parser) { - d.endErrorCondition(recognizer) -} - -// ReportError is the default implementation of error reporting. -// It returns immediately if the handler is already -// in error recovery mode. Otherwise, it calls [beginErrorCondition] -// and dispatches the Reporting task based on the runtime type of e -// according to the following table. -// -// [NoViableAltException] : Dispatches the call to [ReportNoViableAlternative] -// [InputMisMatchException] : Dispatches the call to [ReportInputMisMatch] -// [FailedPredicateException] : Dispatches the call to [ReportFailedPredicate] -// All other types : Calls [NotifyErrorListeners] to Report the exception -func (d *DefaultErrorStrategy) ReportError(recognizer Parser, e RecognitionException) { - // if we've already Reported an error and have not Matched a token - // yet successfully, don't Report any errors. - if d.InErrorRecoveryMode(recognizer) { - return // don't Report spurious errors - } - d.beginErrorCondition(recognizer) - - switch t := e.(type) { - default: - fmt.Println("unknown recognition error type: " + reflect.TypeOf(e).Name()) - // fmt.Println(e.stack) - recognizer.NotifyErrorListeners(e.GetMessage(), e.GetOffendingToken(), e) - case *NoViableAltException: - d.ReportNoViableAlternative(recognizer, t) - case *InputMisMatchException: - d.ReportInputMisMatch(recognizer, t) - case *FailedPredicateException: - d.ReportFailedPredicate(recognizer, t) - } -} - -// Recover is the default recovery implementation. -// It reSynchronizes the parser by consuming tokens until we find one in the reSynchronization set - -// loosely the set of tokens that can follow the current rule. -func (d *DefaultErrorStrategy) Recover(recognizer Parser, _ RecognitionException) { - - if d.lastErrorIndex == recognizer.GetInputStream().Index() && - d.lastErrorStates != nil && d.lastErrorStates.contains(recognizer.GetState()) { - // uh oh, another error at same token index and previously-Visited - // state in ATN must be a case where LT(1) is in the recovery - // token set so nothing got consumed. Consume a single token - // at least to prevent an infinite loop d is a failsafe. - recognizer.Consume() - } - d.lastErrorIndex = recognizer.GetInputStream().Index() - if d.lastErrorStates == nil { - d.lastErrorStates = NewIntervalSet() - } - d.lastErrorStates.addOne(recognizer.GetState()) - followSet := d.GetErrorRecoverySet(recognizer) - d.consumeUntil(recognizer, followSet) -} - -// Sync is the default implementation of error strategy synchronization. -// -// This Sync makes sure that the current lookahead symbol is consistent with what were expecting -// at this point in the [ATN]. You can call this anytime but ANTLR only -// generates code to check before sub-rules/loops and each iteration. -// -// Implements [Jim Idle]'s magic Sync mechanism in closures and optional -// sub-rules. E.g.: -// -// a : Sync ( stuff Sync )* -// Sync : {consume to what can follow Sync} -// -// At the start of a sub-rule upon error, Sync performs single -// token deletion, if possible. If it can't do that, it bails on the current -// rule and uses the default error recovery, which consumes until the -// reSynchronization set of the current rule. -// -// If the sub-rule is optional -// -// ({@code (...)?}, {@code (...)*}, -// -// or a block with an empty alternative), then the expected set includes what follows -// the sub-rule. -// -// During loop iteration, it consumes until it sees a token that can start a -// sub-rule or what follows loop. Yes, that is pretty aggressive. We opt to -// stay in the loop as long as possible. -// -// # Origins -// -// Previous versions of ANTLR did a poor job of their recovery within loops. -// A single mismatch token or missing token would force the parser to bail -// out of the entire rules surrounding the loop. So, for rule: -// -// classfunc : 'class' ID '{' member* '}' -// -// input with an extra token between members would force the parser to -// consume until it found the next class definition rather than the next -// member definition of the current class. -// -// This functionality cost a bit of effort because the parser has to -// compare the token set at the start of the loop and at each iteration. If for -// some reason speed is suffering for you, you can turn off this -// functionality by simply overriding this method as empty: -// -// { } -// -// [Jim Idle]: https://github.com/jimidle -func (d *DefaultErrorStrategy) Sync(recognizer Parser) { - // If already recovering, don't try to Sync - if d.InErrorRecoveryMode(recognizer) { - return - } - - s := recognizer.GetInterpreter().atn.states[recognizer.GetState()] - la := recognizer.GetTokenStream().LA(1) - - // try cheaper subset first might get lucky. seems to shave a wee bit off - nextTokens := recognizer.GetATN().NextTokens(s, nil) - if nextTokens.contains(TokenEpsilon) || nextTokens.contains(la) { - return - } - - switch s.GetStateType() { - case ATNStateBlockStart, ATNStateStarBlockStart, ATNStatePlusBlockStart, ATNStateStarLoopEntry: - // Report error and recover if possible - if d.SingleTokenDeletion(recognizer) != nil { - return - } - recognizer.SetError(NewInputMisMatchException(recognizer)) - case ATNStatePlusLoopBack, ATNStateStarLoopBack: - d.ReportUnwantedToken(recognizer) - expecting := NewIntervalSet() - expecting.addSet(recognizer.GetExpectedTokens()) - whatFollowsLoopIterationOrRule := expecting.addSet(d.GetErrorRecoverySet(recognizer)) - d.consumeUntil(recognizer, whatFollowsLoopIterationOrRule) - default: - // do nothing if we can't identify the exact kind of ATN state - } -} - -// ReportNoViableAlternative is called by [ReportError] when the exception is a [NoViableAltException]. -// -// See also [ReportError] -func (d *DefaultErrorStrategy) ReportNoViableAlternative(recognizer Parser, e *NoViableAltException) { - tokens := recognizer.GetTokenStream() - var input string - if tokens != nil { - if e.startToken.GetTokenType() == TokenEOF { - input = "" - } else { - input = tokens.GetTextFromTokens(e.startToken, e.offendingToken) - } - } else { - input = "" - } - msg := "no viable alternative at input " + d.escapeWSAndQuote(input) - recognizer.NotifyErrorListeners(msg, e.offendingToken, e) -} - -// ReportInputMisMatch is called by [ReportError] when the exception is an [InputMisMatchException] -// -// See also: [ReportError] -func (d *DefaultErrorStrategy) ReportInputMisMatch(recognizer Parser, e *InputMisMatchException) { - msg := "mismatched input " + d.GetTokenErrorDisplay(e.offendingToken) + - " expecting " + e.getExpectedTokens().StringVerbose(recognizer.GetLiteralNames(), recognizer.GetSymbolicNames(), false) - recognizer.NotifyErrorListeners(msg, e.offendingToken, e) -} - -// ReportFailedPredicate is called by [ReportError] when the exception is a [FailedPredicateException]. -// -// See also: [ReportError] -func (d *DefaultErrorStrategy) ReportFailedPredicate(recognizer Parser, e *FailedPredicateException) { - ruleName := recognizer.GetRuleNames()[recognizer.GetParserRuleContext().GetRuleIndex()] - msg := "rule " + ruleName + " " + e.message - recognizer.NotifyErrorListeners(msg, e.offendingToken, e) -} - -// ReportUnwantedToken is called to report a syntax error that requires the removal -// of a token from the input stream. At the time d method is called, the -// erroneous symbol is the current LT(1) symbol and has not yet been -// removed from the input stream. When this method returns, -// recognizer is in error recovery mode. -// -// This method is called when singleTokenDeletion identifies -// single-token deletion as a viable recovery strategy for a mismatched -// input error. -// -// The default implementation simply returns if the handler is already in -// error recovery mode. Otherwise, it calls beginErrorCondition to -// enter error recovery mode, followed by calling -// [NotifyErrorListeners] -func (d *DefaultErrorStrategy) ReportUnwantedToken(recognizer Parser) { - if d.InErrorRecoveryMode(recognizer) { - return - } - d.beginErrorCondition(recognizer) - t := recognizer.GetCurrentToken() - tokenName := d.GetTokenErrorDisplay(t) - expecting := d.GetExpectedTokens(recognizer) - msg := "extraneous input " + tokenName + " expecting " + - expecting.StringVerbose(recognizer.GetLiteralNames(), recognizer.GetSymbolicNames(), false) - recognizer.NotifyErrorListeners(msg, t, nil) -} - -// ReportMissingToken is called to report a syntax error which requires the -// insertion of a missing token into the input stream. At the time this -// method is called, the missing token has not yet been inserted. When this -// method returns, recognizer is in error recovery mode. -// -// This method is called when singleTokenInsertion identifies -// single-token insertion as a viable recovery strategy for a mismatched -// input error. -// -// The default implementation simply returns if the handler is already in -// error recovery mode. Otherwise, it calls beginErrorCondition to -// enter error recovery mode, followed by calling [NotifyErrorListeners] -func (d *DefaultErrorStrategy) ReportMissingToken(recognizer Parser) { - if d.InErrorRecoveryMode(recognizer) { - return - } - d.beginErrorCondition(recognizer) - t := recognizer.GetCurrentToken() - expecting := d.GetExpectedTokens(recognizer) - msg := "missing " + expecting.StringVerbose(recognizer.GetLiteralNames(), recognizer.GetSymbolicNames(), false) + - " at " + d.GetTokenErrorDisplay(t) - recognizer.NotifyErrorListeners(msg, t, nil) -} - -// The RecoverInline default implementation attempts to recover from the mismatched input -// by using single token insertion and deletion as described below. If the -// recovery attempt fails, this method panics with [InputMisMatchException}. -// TODO: Not sure that panic() is the right thing to do here - JI -// -// # EXTRA TOKEN (single token deletion) -// -// LA(1) is not what we are looking for. If LA(2) has the -// right token, however, then assume LA(1) is some extra spurious -// token and delete it. Then consume and return the next token (which was -// the LA(2) token) as the successful result of the Match operation. -// -// # This recovery strategy is implemented by singleTokenDeletion -// -// # MISSING TOKEN (single token insertion) -// -// If current token -at LA(1) - is consistent with what could come -// after the expected LA(1) token, then assume the token is missing -// and use the parser's [TokenFactory] to create it on the fly. The -// “insertion” is performed by returning the created token as the successful -// result of the Match operation. -// -// This recovery strategy is implemented by [SingleTokenInsertion]. -// -// # Example -// -// For example, Input i=(3 is clearly missing the ')'. When -// the parser returns from the nested call to expr, it will have -// call the chain: -// -// stat → expr → atom -// -// and it will be trying to Match the ')' at this point in the -// derivation: -// -// : ID '=' '(' INT ')' ('+' atom)* ';' -// ^ -// -// The attempt to [Match] ')' will fail when it sees ';' and -// call [RecoverInline]. To recover, it sees that LA(1)==';' -// is in the set of tokens that can follow the ')' token reference -// in rule atom. It can assume that you forgot the ')'. -func (d *DefaultErrorStrategy) RecoverInline(recognizer Parser) Token { - // SINGLE TOKEN DELETION - MatchedSymbol := d.SingleTokenDeletion(recognizer) - if MatchedSymbol != nil { - // we have deleted the extra token. - // now, move past ttype token as if all were ok - recognizer.Consume() - return MatchedSymbol - } - // SINGLE TOKEN INSERTION - if d.SingleTokenInsertion(recognizer) { - return d.GetMissingSymbol(recognizer) - } - // even that didn't work must panic the exception - recognizer.SetError(NewInputMisMatchException(recognizer)) - return nil -} - -// SingleTokenInsertion implements the single-token insertion inline error recovery -// strategy. It is called by [RecoverInline] if the single-token -// deletion strategy fails to recover from the mismatched input. If this -// method returns {@code true}, {@code recognizer} will be in error recovery -// mode. -// -// This method determines whether single-token insertion is viable by -// checking if the LA(1) input symbol could be successfully Matched -// if it were instead the LA(2) symbol. If this method returns -// {@code true}, the caller is responsible for creating and inserting a -// token with the correct type to produce this behavior.

-// -// This func returns true if single-token insertion is a viable recovery -// strategy for the current mismatched input. -func (d *DefaultErrorStrategy) SingleTokenInsertion(recognizer Parser) bool { - currentSymbolType := recognizer.GetTokenStream().LA(1) - // if current token is consistent with what could come after current - // ATN state, then we know we're missing a token error recovery - // is free to conjure up and insert the missing token - atn := recognizer.GetInterpreter().atn - currentState := atn.states[recognizer.GetState()] - next := currentState.GetTransitions()[0].getTarget() - expectingAtLL2 := atn.NextTokens(next, recognizer.GetParserRuleContext()) - if expectingAtLL2.contains(currentSymbolType) { - d.ReportMissingToken(recognizer) - return true - } - - return false -} - -// SingleTokenDeletion implements the single-token deletion inline error recovery -// strategy. It is called by [RecoverInline] to attempt to recover -// from mismatched input. If this method returns nil, the parser and error -// handler state will not have changed. If this method returns non-nil, -// recognizer will not be in error recovery mode since the -// returned token was a successful Match. -// -// If the single-token deletion is successful, this method calls -// [ReportUnwantedToken] to Report the error, followed by -// [Consume] to actually “delete” the extraneous token. Then, -// before returning, [ReportMatch] is called to signal a successful -// Match. -// -// The func returns the successfully Matched [Token] instance if single-token -// deletion successfully recovers from the mismatched input, otherwise nil. -func (d *DefaultErrorStrategy) SingleTokenDeletion(recognizer Parser) Token { - NextTokenType := recognizer.GetTokenStream().LA(2) - expecting := d.GetExpectedTokens(recognizer) - if expecting.contains(NextTokenType) { - d.ReportUnwantedToken(recognizer) - // print("recoverFromMisMatchedToken deleting " \ - // + str(recognizer.GetTokenStream().LT(1)) \ - // + " since " + str(recognizer.GetTokenStream().LT(2)) \ - // + " is what we want", file=sys.stderr) - recognizer.Consume() // simply delete extra token - // we want to return the token we're actually Matching - MatchedSymbol := recognizer.GetCurrentToken() - d.ReportMatch(recognizer) // we know current token is correct - return MatchedSymbol - } - - return nil -} - -// GetMissingSymbol conjures up a missing token during error recovery. -// -// The recognizer attempts to recover from single missing -// symbols. But, actions might refer to that missing symbol. -// For example: -// -// x=ID {f($x)}. -// -// The action clearly assumes -// that there has been an identifier Matched previously and that -// $x points at that token. If that token is missing, but -// the next token in the stream is what we want we assume that -// this token is missing, and we keep going. Because we -// have to return some token to replace the missing token, -// we have to conjure one up. This method gives the user control -// over the tokens returned for missing tokens. Mostly, -// you will want to create something special for identifier -// tokens. For literals such as '{' and ',', the default -// action in the parser or tree parser works. It simply creates -// a [CommonToken] of the appropriate type. The text will be the token name. -// If you need to change which tokens must be created by the lexer, -// override this method to create the appropriate tokens. -func (d *DefaultErrorStrategy) GetMissingSymbol(recognizer Parser) Token { - currentSymbol := recognizer.GetCurrentToken() - expecting := d.GetExpectedTokens(recognizer) - expectedTokenType := expecting.first() - var tokenText string - - if expectedTokenType == TokenEOF { - tokenText = "" - } else { - ln := recognizer.GetLiteralNames() - if expectedTokenType > 0 && expectedTokenType < len(ln) { - tokenText = "" - } else { - tokenText = "" // TODO: matches the JS impl - } - } - current := currentSymbol - lookback := recognizer.GetTokenStream().LT(-1) - if current.GetTokenType() == TokenEOF && lookback != nil { - current = lookback - } - - tf := recognizer.GetTokenFactory() - - return tf.Create(current.GetSource(), expectedTokenType, tokenText, TokenDefaultChannel, -1, -1, current.GetLine(), current.GetColumn()) -} - -func (d *DefaultErrorStrategy) GetExpectedTokens(recognizer Parser) *IntervalSet { - return recognizer.GetExpectedTokens() -} - -// GetTokenErrorDisplay determines how a token should be displayed in an error message. -// The default is to display just the text, but during development you might -// want to have a lot of information spit out. Override this func in that case -// to use t.String() (which, for [CommonToken], dumps everything about -// the token). This is better than forcing you to override a method in -// your token objects because you don't have to go modify your lexer -// so that it creates a new type. -func (d *DefaultErrorStrategy) GetTokenErrorDisplay(t Token) string { - if t == nil { - return "" - } - s := t.GetText() - if s == "" { - if t.GetTokenType() == TokenEOF { - s = "" - } else { - s = "<" + strconv.Itoa(t.GetTokenType()) + ">" - } - } - return d.escapeWSAndQuote(s) -} - -func (d *DefaultErrorStrategy) escapeWSAndQuote(s string) string { - s = strings.Replace(s, "\t", "\\t", -1) - s = strings.Replace(s, "\n", "\\n", -1) - s = strings.Replace(s, "\r", "\\r", -1) - return "'" + s + "'" -} - -// GetErrorRecoverySet computes the error recovery set for the current rule. During -// rule invocation, the parser pushes the set of tokens that can -// follow that rule reference on the stack. This amounts to -// computing FIRST of what follows the rule reference in the -// enclosing rule. See LinearApproximator.FIRST(). -// -// This local follow set only includes tokens -// from within the rule i.e., the FIRST computation done by -// ANTLR stops at the end of a rule. -// -// # Example -// -// When you find a "no viable alt exception", the input is not -// consistent with any of the alternatives for rule r. The best -// thing to do is to consume tokens until you see something that -// can legally follow a call to r or any rule that called r. -// You don't want the exact set of viable next tokens because the -// input might just be missing a token--you might consume the -// rest of the input looking for one of the missing tokens. -// -// Consider the grammar: -// -// a : '[' b ']' -// | '(' b ')' -// ; -// -// b : c '^' INT -// ; -// -// c : ID -// | INT -// ; -// -// At each rule invocation, the set of tokens that could follow -// that rule is pushed on a stack. Here are the various -// context-sensitive follow sets: -// -// FOLLOW(b1_in_a) = FIRST(']') = ']' -// FOLLOW(b2_in_a) = FIRST(')') = ')' -// FOLLOW(c_in_b) = FIRST('^') = '^' -// -// Upon erroneous input “[]”, the call chain is -// -// a → b → c -// -// and, hence, the follow context stack is: -// -// Depth Follow set Start of rule execution -// 0 a (from main()) -// 1 ']' b -// 2 '^' c -// -// Notice that ')' is not included, because b would have to have -// been called from a different context in rule a for ')' to be -// included. -// -// For error recovery, we cannot consider FOLLOW(c) -// (context-sensitive or otherwise). We need the combined set of -// all context-sensitive FOLLOW sets - the set of all tokens that -// could follow any reference in the call chain. We need to -// reSync to one of those tokens. Note that FOLLOW(c)='^' and if -// we reSync'd to that token, we'd consume until EOF. We need to -// Sync to context-sensitive FOLLOWs for a, b, and c: -// -// {']','^'} -// -// In this case, for input "[]", LA(1) is ']' and in the set, so we would -// not consume anything. After printing an error, rule c would -// return normally. Rule b would not find the required '^' though. -// At this point, it gets a mismatched token error and panics an -// exception (since LA(1) is not in the viable following token -// set). The rule exception handler tries to recover, but finds -// the same recovery set and doesn't consume anything. Rule b -// exits normally returning to rule a. Now it finds the ']' (and -// with the successful Match exits errorRecovery mode). -// -// So, you can see that the parser walks up the call chain looking -// for the token that was a member of the recovery set. -// -// Errors are not generated in errorRecovery mode. -// -// ANTLR's error recovery mechanism is based upon original ideas: -// -// [Algorithms + Data Structures = Programs] by Niklaus Wirth and -// [A note on error recovery in recursive descent parsers]. -// -// Later, Josef Grosch had some good ideas in [Efficient and Comfortable Error Recovery in Recursive Descent -// Parsers] -// -// Like Grosch I implement context-sensitive FOLLOW sets that are combined at run-time upon error to avoid overhead -// during parsing. Later, the runtime Sync was improved for loops/sub-rules see [Sync] docs -// -// [A note on error recovery in recursive descent parsers]: http://portal.acm.org/citation.cfm?id=947902.947905 -// [Algorithms + Data Structures = Programs]: https://t.ly/5QzgE -// [Efficient and Comfortable Error Recovery in Recursive Descent Parsers]: ftp://www.cocolab.com/products/cocktail/doca4.ps/ell.ps.zip -func (d *DefaultErrorStrategy) GetErrorRecoverySet(recognizer Parser) *IntervalSet { - atn := recognizer.GetInterpreter().atn - ctx := recognizer.GetParserRuleContext() - recoverSet := NewIntervalSet() - for ctx != nil && ctx.GetInvokingState() >= 0 { - // compute what follows who invoked us - invokingState := atn.states[ctx.GetInvokingState()] - rt := invokingState.GetTransitions()[0] - follow := atn.NextTokens(rt.(*RuleTransition).followState, nil) - recoverSet.addSet(follow) - ctx = ctx.GetParent().(ParserRuleContext) - } - recoverSet.removeOne(TokenEpsilon) - return recoverSet -} - -// Consume tokens until one Matches the given token set.// -func (d *DefaultErrorStrategy) consumeUntil(recognizer Parser, set *IntervalSet) { - ttype := recognizer.GetTokenStream().LA(1) - for ttype != TokenEOF && !set.contains(ttype) { - recognizer.Consume() - ttype = recognizer.GetTokenStream().LA(1) - } -} - -// The BailErrorStrategy implementation of ANTLRErrorStrategy responds to syntax errors -// by immediately canceling the parse operation with a -// [ParseCancellationException]. The implementation ensures that the -// [ParserRuleContext//exception] field is set for all parse tree nodes -// that were not completed prior to encountering the error. -// -// This error strategy is useful in the following scenarios. -// -// - Two-stage parsing: This error strategy allows the first -// stage of two-stage parsing to immediately terminate if an error is -// encountered, and immediately fall back to the second stage. In addition to -// avoiding wasted work by attempting to recover from errors here, the empty -// implementation of [BailErrorStrategy.Sync] improves the performance of -// the first stage. -// -// - Silent validation: When syntax errors are not being -// Reported or logged, and the parse result is simply ignored if errors occur, -// the [BailErrorStrategy] avoids wasting work on recovering from errors -// when the result will be ignored either way. -// -// myparser.SetErrorHandler(NewBailErrorStrategy()) -// -// See also: [Parser.SetErrorHandler(ANTLRErrorStrategy)] -type BailErrorStrategy struct { - *DefaultErrorStrategy -} - -var _ ErrorStrategy = &BailErrorStrategy{} - -//goland:noinspection GoUnusedExportedFunction -func NewBailErrorStrategy() *BailErrorStrategy { - - b := new(BailErrorStrategy) - - b.DefaultErrorStrategy = NewDefaultErrorStrategy() - - return b -} - -// Recover Instead of recovering from exception e, re-panic it wrapped -// in a [ParseCancellationException] so it is not caught by the -// rule func catches. Use Exception.GetCause() to get the -// original [RecognitionException]. -func (b *BailErrorStrategy) Recover(recognizer Parser, e RecognitionException) { - context := recognizer.GetParserRuleContext() - for context != nil { - context.SetException(e) - if parent, ok := context.GetParent().(ParserRuleContext); ok { - context = parent - } else { - context = nil - } - } - recognizer.SetError(NewParseCancellationException()) // TODO: we don't emit e properly -} - -// RecoverInline makes sure we don't attempt to recover inline if the parser -// successfully recovers, it won't panic an exception. -func (b *BailErrorStrategy) RecoverInline(recognizer Parser) Token { - b.Recover(recognizer, NewInputMisMatchException(recognizer)) - - return nil -} - -// Sync makes sure we don't attempt to recover from problems in sub-rules. -func (b *BailErrorStrategy) Sync(_ Parser) { -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/errors.go b/vendor/github.com/antlr4-go/antlr/v4/errors.go deleted file mode 100644 index 8f0f2f601..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/errors.go +++ /dev/null @@ -1,259 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -// The root of the ANTLR exception hierarchy. In general, ANTLR tracks just -// 3 kinds of errors: prediction errors, failed predicate errors, and -// mismatched input errors. In each case, the parser knows where it is -// in the input, where it is in the ATN, the rule invocation stack, -// and what kind of problem occurred. - -type RecognitionException interface { - GetOffendingToken() Token - GetMessage() string - GetInputStream() IntStream -} - -type BaseRecognitionException struct { - message string - recognizer Recognizer - offendingToken Token - offendingState int - ctx RuleContext - input IntStream -} - -func NewBaseRecognitionException(message string, recognizer Recognizer, input IntStream, ctx RuleContext) *BaseRecognitionException { - - // todo - // Error.call(this) - // - // if (!!Error.captureStackTrace) { - // Error.captureStackTrace(this, RecognitionException) - // } else { - // stack := NewError().stack - // } - // TODO: may be able to use - "runtime" func Stack(buf []byte, all bool) int - - t := new(BaseRecognitionException) - - t.message = message - t.recognizer = recognizer - t.input = input - t.ctx = ctx - - // The current Token when an error occurred. Since not all streams - // support accessing symbols by index, we have to track the {@link Token} - // instance itself. - // - t.offendingToken = nil - - // Get the ATN state number the parser was in at the time the error - // occurred. For NoViableAltException and LexerNoViableAltException exceptions, this is the - // DecisionState number. For others, it is the state whose outgoing edge we couldn't Match. - // - t.offendingState = -1 - if t.recognizer != nil { - t.offendingState = t.recognizer.GetState() - } - - return t -} - -func (b *BaseRecognitionException) GetMessage() string { - return b.message -} - -func (b *BaseRecognitionException) GetOffendingToken() Token { - return b.offendingToken -} - -func (b *BaseRecognitionException) GetInputStream() IntStream { - return b.input -} - -//

If the state number is not known, b method returns -1.

- -// getExpectedTokens gets the set of input symbols which could potentially follow the -// previously Matched symbol at the time this exception was raised. -// -// If the set of expected tokens is not known and could not be computed, -// this method returns nil. -// -// The func returns the set of token types that could potentially follow the current -// state in the {ATN}, or nil if the information is not available. - -func (b *BaseRecognitionException) getExpectedTokens() *IntervalSet { - if b.recognizer != nil { - return b.recognizer.GetATN().getExpectedTokens(b.offendingState, b.ctx) - } - - return nil -} - -func (b *BaseRecognitionException) String() string { - return b.message -} - -type LexerNoViableAltException struct { - *BaseRecognitionException - - startIndex int - deadEndConfigs *ATNConfigSet -} - -func NewLexerNoViableAltException(lexer Lexer, input CharStream, startIndex int, deadEndConfigs *ATNConfigSet) *LexerNoViableAltException { - - l := new(LexerNoViableAltException) - - l.BaseRecognitionException = NewBaseRecognitionException("", lexer, input, nil) - - l.startIndex = startIndex - l.deadEndConfigs = deadEndConfigs - - return l -} - -func (l *LexerNoViableAltException) String() string { - symbol := "" - if l.startIndex >= 0 && l.startIndex < l.input.Size() { - symbol = l.input.(CharStream).GetTextFromInterval(NewInterval(l.startIndex, l.startIndex)) - } - return "LexerNoViableAltException" + symbol -} - -type NoViableAltException struct { - *BaseRecognitionException - - startToken Token - offendingToken Token - ctx ParserRuleContext - deadEndConfigs *ATNConfigSet -} - -// NewNoViableAltException creates an exception indicating that the parser could not decide which of two or more paths -// to take based upon the remaining input. It tracks the starting token -// of the offending input and also knows where the parser was -// in the various paths when the error. -// -// Reported by [ReportNoViableAlternative] -func NewNoViableAltException(recognizer Parser, input TokenStream, startToken Token, offendingToken Token, deadEndConfigs *ATNConfigSet, ctx ParserRuleContext) *NoViableAltException { - - if ctx == nil { - ctx = recognizer.GetParserRuleContext() - } - - if offendingToken == nil { - offendingToken = recognizer.GetCurrentToken() - } - - if startToken == nil { - startToken = recognizer.GetCurrentToken() - } - - if input == nil { - input = recognizer.GetInputStream().(TokenStream) - } - - n := new(NoViableAltException) - n.BaseRecognitionException = NewBaseRecognitionException("", recognizer, input, ctx) - - // Which configurations did we try at input.Index() that couldn't Match - // input.LT(1) - n.deadEndConfigs = deadEndConfigs - - // The token object at the start index the input stream might - // not be buffering tokens so get a reference to it. - // - // At the time the error occurred, of course the stream needs to keep a - // buffer of all the tokens, but later we might not have access to those. - n.startToken = startToken - n.offendingToken = offendingToken - - return n -} - -type InputMisMatchException struct { - *BaseRecognitionException -} - -// NewInputMisMatchException creates an exception that signifies any kind of mismatched input exceptions such as -// when the current input does not Match the expected token. -func NewInputMisMatchException(recognizer Parser) *InputMisMatchException { - - i := new(InputMisMatchException) - i.BaseRecognitionException = NewBaseRecognitionException("", recognizer, recognizer.GetInputStream(), recognizer.GetParserRuleContext()) - - i.offendingToken = recognizer.GetCurrentToken() - - return i - -} - -// FailedPredicateException indicates that a semantic predicate failed during validation. Validation of predicates -// occurs when normally parsing the alternative just like Matching a token. -// Disambiguating predicate evaluation occurs when we test a predicate during -// prediction. -type FailedPredicateException struct { - *BaseRecognitionException - - ruleIndex int - predicateIndex int - predicate string -} - -//goland:noinspection GoUnusedExportedFunction -func NewFailedPredicateException(recognizer Parser, predicate string, message string) *FailedPredicateException { - - f := new(FailedPredicateException) - - f.BaseRecognitionException = NewBaseRecognitionException(f.formatMessage(predicate, message), recognizer, recognizer.GetInputStream(), recognizer.GetParserRuleContext()) - - s := recognizer.GetInterpreter().atn.states[recognizer.GetState()] - trans := s.GetTransitions()[0] - if trans2, ok := trans.(*PredicateTransition); ok { - f.ruleIndex = trans2.ruleIndex - f.predicateIndex = trans2.predIndex - } else { - f.ruleIndex = 0 - f.predicateIndex = 0 - } - f.predicate = predicate - f.offendingToken = recognizer.GetCurrentToken() - - return f -} - -func (f *FailedPredicateException) formatMessage(predicate, message string) string { - if message != "" { - return message - } - - return "failed predicate: {" + predicate + "}?" -} - -type ParseCancellationException struct { -} - -func (p ParseCancellationException) GetOffendingToken() Token { - //TODO implement me - panic("implement me") -} - -func (p ParseCancellationException) GetMessage() string { - //TODO implement me - panic("implement me") -} - -func (p ParseCancellationException) GetInputStream() IntStream { - //TODO implement me - panic("implement me") -} - -func NewParseCancellationException() *ParseCancellationException { - // Error.call(this) - // Error.captureStackTrace(this, ParseCancellationException) - return new(ParseCancellationException) -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/file_stream.go b/vendor/github.com/antlr4-go/antlr/v4/file_stream.go deleted file mode 100644 index 5f65f809b..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/file_stream.go +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import ( - "bufio" - "os" -) - -// This is an InputStream that is loaded from a file all at once -// when you construct the object. - -type FileStream struct { - InputStream - filename string -} - -//goland:noinspection GoUnusedExportedFunction -func NewFileStream(fileName string) (*FileStream, error) { - - f, err := os.Open(fileName) - if err != nil { - return nil, err - } - - defer func(f *os.File) { - errF := f.Close() - if errF != nil { - } - }(f) - - reader := bufio.NewReader(f) - fInfo, err := f.Stat() - if err != nil { - return nil, err - } - - fs := &FileStream{ - InputStream: InputStream{ - index: 0, - name: fileName, - }, - filename: fileName, - } - - // Pre-build the buffer and read runes efficiently - // - fs.data = make([]rune, 0, fInfo.Size()) - for { - r, _, err := reader.ReadRune() - if err != nil { - break - } - fs.data = append(fs.data, r) - } - fs.size = len(fs.data) // Size in runes - - // All done. - // - return fs, nil -} - -func (f *FileStream) GetSourceName() string { - return f.filename -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/input_stream.go b/vendor/github.com/antlr4-go/antlr/v4/input_stream.go deleted file mode 100644 index b737fe85f..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/input_stream.go +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import ( - "bufio" - "io" -) - -type InputStream struct { - name string - index int - data []rune - size int -} - -// NewIoStream creates a new input stream from the given io.Reader reader. -// Note that the reader is read completely into memory and so it must actually -// have a stopping point - you cannot pass in a reader on an open-ended source such -// as a socket for instance. -func NewIoStream(reader io.Reader) *InputStream { - - rReader := bufio.NewReader(reader) - - is := &InputStream{ - name: "", - index: 0, - } - - // Pre-build the buffer and read runes reasonably efficiently given that - // we don't exactly know how big the input is. - // - is.data = make([]rune, 0, 512) - for { - r, _, err := rReader.ReadRune() - if err != nil { - break - } - is.data = append(is.data, r) - } - is.size = len(is.data) // number of runes - return is -} - -// NewInputStream creates a new input stream from the given string -func NewInputStream(data string) *InputStream { - - is := &InputStream{ - name: "", - index: 0, - data: []rune(data), // This is actually the most efficient way - } - is.size = len(is.data) // number of runes, but we could also use len(data), which is efficient too - return is -} - -func (is *InputStream) reset() { - is.index = 0 -} - -// Consume moves the input pointer to the next character in the input stream -func (is *InputStream) Consume() { - if is.index >= is.size { - // assert is.LA(1) == TokenEOF - panic("cannot consume EOF") - } - is.index++ -} - -// LA returns the character at the given offset from the start of the input stream -func (is *InputStream) LA(offset int) int { - - if offset == 0 { - return 0 // nil - } - if offset < 0 { - offset++ // e.g., translate LA(-1) to use offset=0 - } - pos := is.index + offset - 1 - - if pos < 0 || pos >= is.size { // invalid - return TokenEOF - } - - return int(is.data[pos]) -} - -// LT returns the character at the given offset from the start of the input stream -func (is *InputStream) LT(offset int) int { - return is.LA(offset) -} - -// Index returns the current offset in to the input stream -func (is *InputStream) Index() int { - return is.index -} - -// Size returns the total number of characters in the input stream -func (is *InputStream) Size() int { - return is.size -} - -// Mark does nothing here as we have entire buffer -func (is *InputStream) Mark() int { - return -1 -} - -// Release does nothing here as we have entire buffer -func (is *InputStream) Release(_ int) { -} - -// Seek the input point to the provided index offset -func (is *InputStream) Seek(index int) { - if index <= is.index { - is.index = index // just jump don't update stream state (line,...) - return - } - // seek forward - is.index = intMin(index, is.size) -} - -// GetText returns the text from the input stream from the start to the stop index -func (is *InputStream) GetText(start int, stop int) string { - if stop >= is.size { - stop = is.size - 1 - } - if start >= is.size { - return "" - } - - return string(is.data[start : stop+1]) -} - -// GetTextFromTokens returns the text from the input stream from the first character of the start token to the last -// character of the stop token -func (is *InputStream) GetTextFromTokens(start, stop Token) string { - if start != nil && stop != nil { - return is.GetTextFromInterval(NewInterval(start.GetTokenIndex(), stop.GetTokenIndex())) - } - - return "" -} - -func (is *InputStream) GetTextFromInterval(i Interval) string { - return is.GetText(i.Start, i.Stop) -} - -func (*InputStream) GetSourceName() string { - return "" -} - -// String returns the entire input stream as a string -func (is *InputStream) String() string { - return string(is.data) -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/int_stream.go b/vendor/github.com/antlr4-go/antlr/v4/int_stream.go deleted file mode 100644 index 4778878bd..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/int_stream.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -type IntStream interface { - Consume() - LA(int) int - Mark() int - Release(marker int) - Index() int - Seek(index int) - Size() int - GetSourceName() string -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/interval_set.go b/vendor/github.com/antlr4-go/antlr/v4/interval_set.go deleted file mode 100644 index cc5066067..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/interval_set.go +++ /dev/null @@ -1,330 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import ( - "strconv" - "strings" -) - -type Interval struct { - Start int - Stop int -} - -// NewInterval creates a new interval with the given start and stop values. -func NewInterval(start, stop int) Interval { - return Interval{ - Start: start, - Stop: stop, - } -} - -// Contains returns true if the given item is contained within the interval. -func (i Interval) Contains(item int) bool { - return item >= i.Start && item < i.Stop -} - -// String generates a string representation of the interval. -func (i Interval) String() string { - if i.Start == i.Stop-1 { - return strconv.Itoa(i.Start) - } - - return strconv.Itoa(i.Start) + ".." + strconv.Itoa(i.Stop-1) -} - -// Length returns the length of the interval. -func (i Interval) Length() int { - return i.Stop - i.Start -} - -// IntervalSet represents a collection of [Intervals], which may be read-only. -type IntervalSet struct { - intervals []Interval - readOnly bool -} - -// NewIntervalSet creates a new empty, writable, interval set. -func NewIntervalSet() *IntervalSet { - - i := new(IntervalSet) - - i.intervals = nil - i.readOnly = false - - return i -} - -func (i *IntervalSet) Equals(other *IntervalSet) bool { - if len(i.intervals) != len(other.intervals) { - return false - } - - for k, v := range i.intervals { - if v.Start != other.intervals[k].Start || v.Stop != other.intervals[k].Stop { - return false - } - } - - return true -} - -func (i *IntervalSet) first() int { - if len(i.intervals) == 0 { - return TokenInvalidType - } - - return i.intervals[0].Start -} - -func (i *IntervalSet) addOne(v int) { - i.addInterval(NewInterval(v, v+1)) -} - -func (i *IntervalSet) addRange(l, h int) { - i.addInterval(NewInterval(l, h+1)) -} - -func (i *IntervalSet) addInterval(v Interval) { - if i.intervals == nil { - i.intervals = make([]Interval, 0) - i.intervals = append(i.intervals, v) - } else { - // find insert pos - for k, interval := range i.intervals { - // distinct range -> insert - if v.Stop < interval.Start { - i.intervals = append(i.intervals[0:k], append([]Interval{v}, i.intervals[k:]...)...) - return - } else if v.Stop == interval.Start { - i.intervals[k].Start = v.Start - return - } else if v.Start <= interval.Stop { - i.intervals[k] = NewInterval(intMin(interval.Start, v.Start), intMax(interval.Stop, v.Stop)) - - // if not applying to end, merge potential overlaps - if k < len(i.intervals)-1 { - l := i.intervals[k] - r := i.intervals[k+1] - // if r contained in l - if l.Stop >= r.Stop { - i.intervals = append(i.intervals[0:k+1], i.intervals[k+2:]...) - } else if l.Stop >= r.Start { // partial overlap - i.intervals[k] = NewInterval(l.Start, r.Stop) - i.intervals = append(i.intervals[0:k+1], i.intervals[k+2:]...) - } - } - return - } - } - // greater than any exiting - i.intervals = append(i.intervals, v) - } -} - -func (i *IntervalSet) addSet(other *IntervalSet) *IntervalSet { - if other.intervals != nil { - for k := 0; k < len(other.intervals); k++ { - i2 := other.intervals[k] - i.addInterval(NewInterval(i2.Start, i2.Stop)) - } - } - return i -} - -func (i *IntervalSet) complement(start int, stop int) *IntervalSet { - result := NewIntervalSet() - result.addInterval(NewInterval(start, stop+1)) - for j := 0; j < len(i.intervals); j++ { - result.removeRange(i.intervals[j]) - } - return result -} - -func (i *IntervalSet) contains(item int) bool { - if i.intervals == nil { - return false - } - for k := 0; k < len(i.intervals); k++ { - if i.intervals[k].Contains(item) { - return true - } - } - return false -} - -func (i *IntervalSet) length() int { - iLen := 0 - - for _, v := range i.intervals { - iLen += v.Length() - } - - return iLen -} - -func (i *IntervalSet) removeRange(v Interval) { - if v.Start == v.Stop-1 { - i.removeOne(v.Start) - } else if i.intervals != nil { - k := 0 - for n := 0; n < len(i.intervals); n++ { - ni := i.intervals[k] - // intervals are ordered - if v.Stop <= ni.Start { - return - } else if v.Start > ni.Start && v.Stop < ni.Stop { - i.intervals[k] = NewInterval(ni.Start, v.Start) - x := NewInterval(v.Stop, ni.Stop) - // i.intervals.splice(k, 0, x) - i.intervals = append(i.intervals[0:k], append([]Interval{x}, i.intervals[k:]...)...) - return - } else if v.Start <= ni.Start && v.Stop >= ni.Stop { - // i.intervals.splice(k, 1) - i.intervals = append(i.intervals[0:k], i.intervals[k+1:]...) - k = k - 1 // need another pass - } else if v.Start < ni.Stop { - i.intervals[k] = NewInterval(ni.Start, v.Start) - } else if v.Stop < ni.Stop { - i.intervals[k] = NewInterval(v.Stop, ni.Stop) - } - k++ - } - } -} - -func (i *IntervalSet) removeOne(v int) { - if i.intervals != nil { - for k := 0; k < len(i.intervals); k++ { - ki := i.intervals[k] - // intervals i ordered - if v < ki.Start { - return - } else if v == ki.Start && v == ki.Stop-1 { - // i.intervals.splice(k, 1) - i.intervals = append(i.intervals[0:k], i.intervals[k+1:]...) - return - } else if v == ki.Start { - i.intervals[k] = NewInterval(ki.Start+1, ki.Stop) - return - } else if v == ki.Stop-1 { - i.intervals[k] = NewInterval(ki.Start, ki.Stop-1) - return - } else if v < ki.Stop-1 { - x := NewInterval(ki.Start, v) - ki.Start = v + 1 - // i.intervals.splice(k, 0, x) - i.intervals = append(i.intervals[0:k], append([]Interval{x}, i.intervals[k:]...)...) - return - } - } - } -} - -func (i *IntervalSet) String() string { - return i.StringVerbose(nil, nil, false) -} - -func (i *IntervalSet) StringVerbose(literalNames []string, symbolicNames []string, elemsAreChar bool) string { - - if i.intervals == nil { - return "{}" - } else if literalNames != nil || symbolicNames != nil { - return i.toTokenString(literalNames, symbolicNames) - } else if elemsAreChar { - return i.toCharString() - } - - return i.toIndexString() -} - -func (i *IntervalSet) GetIntervals() []Interval { - return i.intervals -} - -func (i *IntervalSet) toCharString() string { - names := make([]string, len(i.intervals)) - - var sb strings.Builder - - for j := 0; j < len(i.intervals); j++ { - v := i.intervals[j] - if v.Stop == v.Start+1 { - if v.Start == TokenEOF { - names = append(names, "") - } else { - sb.WriteByte('\'') - sb.WriteRune(rune(v.Start)) - sb.WriteByte('\'') - names = append(names, sb.String()) - sb.Reset() - } - } else { - sb.WriteByte('\'') - sb.WriteRune(rune(v.Start)) - sb.WriteString("'..'") - sb.WriteRune(rune(v.Stop - 1)) - sb.WriteByte('\'') - names = append(names, sb.String()) - sb.Reset() - } - } - if len(names) > 1 { - return "{" + strings.Join(names, ", ") + "}" - } - - return names[0] -} - -func (i *IntervalSet) toIndexString() string { - - names := make([]string, 0) - for j := 0; j < len(i.intervals); j++ { - v := i.intervals[j] - if v.Stop == v.Start+1 { - if v.Start == TokenEOF { - names = append(names, "") - } else { - names = append(names, strconv.Itoa(v.Start)) - } - } else { - names = append(names, strconv.Itoa(v.Start)+".."+strconv.Itoa(v.Stop-1)) - } - } - if len(names) > 1 { - return "{" + strings.Join(names, ", ") + "}" - } - - return names[0] -} - -func (i *IntervalSet) toTokenString(literalNames []string, symbolicNames []string) string { - names := make([]string, 0) - for _, v := range i.intervals { - for j := v.Start; j < v.Stop; j++ { - names = append(names, i.elementName(literalNames, symbolicNames, j)) - } - } - if len(names) > 1 { - return "{" + strings.Join(names, ", ") + "}" - } - - return names[0] -} - -func (i *IntervalSet) elementName(literalNames []string, symbolicNames []string, a int) string { - if a == TokenEOF { - return "" - } else if a == TokenEpsilon { - return "" - } else { - if a < len(literalNames) && literalNames[a] != "" { - return literalNames[a] - } - - return symbolicNames[a] - } -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/jcollect.go b/vendor/github.com/antlr4-go/antlr/v4/jcollect.go deleted file mode 100644 index ceccd96d2..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/jcollect.go +++ /dev/null @@ -1,685 +0,0 @@ -package antlr - -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -import ( - "container/list" - "runtime/debug" - "sort" - "sync" -) - -// Collectable is an interface that a struct should implement if it is to be -// usable as a key in these collections. -type Collectable[T any] interface { - Hash() int - Equals(other Collectable[T]) bool -} - -type Comparator[T any] interface { - Hash1(o T) int - Equals2(T, T) bool -} - -type CollectionSource int -type CollectionDescriptor struct { - SybolicName string - Description string -} - -const ( - UnknownCollection CollectionSource = iota - ATNConfigLookupCollection - ATNStateCollection - DFAStateCollection - ATNConfigCollection - PredictionContextCollection - SemanticContextCollection - ClosureBusyCollection - PredictionVisitedCollection - MergeCacheCollection - PredictionContextCacheCollection - AltSetCollection - ReachSetCollection -) - -var CollectionDescriptors = map[CollectionSource]CollectionDescriptor{ - UnknownCollection: { - SybolicName: "UnknownCollection", - Description: "Unknown collection type. Only used if the target author thought it was an unimportant collection.", - }, - ATNConfigCollection: { - SybolicName: "ATNConfigCollection", - Description: "ATNConfig collection. Used to store the ATNConfigs for a particular state in the ATN." + - "For instance, it is used to store the results of the closure() operation in the ATN.", - }, - ATNConfigLookupCollection: { - SybolicName: "ATNConfigLookupCollection", - Description: "ATNConfigLookup collection. Used to store the ATNConfigs for a particular state in the ATN." + - "This is used to prevent duplicating equivalent states in an ATNConfigurationSet.", - }, - ATNStateCollection: { - SybolicName: "ATNStateCollection", - Description: "ATNState collection. This is used to store the states of the ATN.", - }, - DFAStateCollection: { - SybolicName: "DFAStateCollection", - Description: "DFAState collection. This is used to store the states of the DFA.", - }, - PredictionContextCollection: { - SybolicName: "PredictionContextCollection", - Description: "PredictionContext collection. This is used to store the prediction contexts of the ATN and cache computes.", - }, - SemanticContextCollection: { - SybolicName: "SemanticContextCollection", - Description: "SemanticContext collection. This is used to store the semantic contexts of the ATN.", - }, - ClosureBusyCollection: { - SybolicName: "ClosureBusyCollection", - Description: "ClosureBusy collection. This is used to check and prevent infinite recursion right recursive rules." + - "It stores ATNConfigs that are currently being processed in the closure() operation.", - }, - PredictionVisitedCollection: { - SybolicName: "PredictionVisitedCollection", - Description: "A map that records whether we have visited a particular context when searching through cached entries.", - }, - MergeCacheCollection: { - SybolicName: "MergeCacheCollection", - Description: "A map that records whether we have already merged two particular contexts and can save effort by not repeating it.", - }, - PredictionContextCacheCollection: { - SybolicName: "PredictionContextCacheCollection", - Description: "A map that records whether we have already created a particular context and can save effort by not computing it again.", - }, - AltSetCollection: { - SybolicName: "AltSetCollection", - Description: "Used to eliminate duplicate alternatives in an ATN config set.", - }, - ReachSetCollection: { - SybolicName: "ReachSetCollection", - Description: "Used as merge cache to prevent us needing to compute the merge of two states if we have already done it.", - }, -} - -// JStore implements a container that allows the use of a struct to calculate the key -// for a collection of values akin to map. This is not meant to be a full-blown HashMap but just -// serve the needs of the ANTLR Go runtime. -// -// For ease of porting the logic of the runtime from the master target (Java), this collection -// operates in a similar way to Java, in that it can use any struct that supplies a Hash() and Equals() -// function as the key. The values are stored in a standard go map which internally is a form of hashmap -// itself, the key for the go map is the hash supplied by the key object. The collection is able to deal with -// hash conflicts by using a simple slice of values associated with the hash code indexed bucket. That isn't -// particularly efficient, but it is simple, and it works. As this is specifically for the ANTLR runtime, and -// we understand the requirements, then this is fine - this is not a general purpose collection. -type JStore[T any, C Comparator[T]] struct { - store map[int][]T - len int - comparator Comparator[T] - stats *JStatRec -} - -func NewJStore[T any, C Comparator[T]](comparator Comparator[T], cType CollectionSource, desc string) *JStore[T, C] { - - if comparator == nil { - panic("comparator cannot be nil") - } - - s := &JStore[T, C]{ - store: make(map[int][]T, 1), - comparator: comparator, - } - if collectStats { - s.stats = &JStatRec{ - Source: cType, - Description: desc, - } - - // Track where we created it from if we are being asked to do so - if runtimeConfig.statsTraceStacks { - s.stats.CreateStack = debug.Stack() - } - Statistics.AddJStatRec(s.stats) - } - return s -} - -// Put will store given value in the collection. Note that the key for storage is generated from -// the value itself - this is specifically because that is what ANTLR needs - this would not be useful -// as any kind of general collection. -// -// If the key has a hash conflict, then the value will be added to the slice of values associated with the -// hash, unless the value is already in the slice, in which case the existing value is returned. Value equivalence is -// tested by calling the equals() method on the key. -// -// # If the given value is already present in the store, then the existing value is returned as v and exists is set to true -// -// If the given value is not present in the store, then the value is added to the store and returned as v and exists is set to false. -func (s *JStore[T, C]) Put(value T) (v T, exists bool) { - - if collectStats { - s.stats.Puts++ - } - kh := s.comparator.Hash1(value) - - var hClash bool - for _, v1 := range s.store[kh] { - hClash = true - if s.comparator.Equals2(value, v1) { - if collectStats { - s.stats.PutHits++ - s.stats.PutHashConflicts++ - } - return v1, true - } - if collectStats { - s.stats.PutMisses++ - } - } - if collectStats && hClash { - s.stats.PutHashConflicts++ - } - s.store[kh] = append(s.store[kh], value) - - if collectStats { - if len(s.store[kh]) > s.stats.MaxSlotSize { - s.stats.MaxSlotSize = len(s.store[kh]) - } - } - s.len++ - if collectStats { - s.stats.CurSize = s.len - if s.len > s.stats.MaxSize { - s.stats.MaxSize = s.len - } - } - return value, false -} - -// Get will return the value associated with the key - the type of the key is the same type as the value -// which would not generally be useful, but this is a specific thing for ANTLR where the key is -// generated using the object we are going to store. -func (s *JStore[T, C]) Get(key T) (T, bool) { - if collectStats { - s.stats.Gets++ - } - kh := s.comparator.Hash1(key) - var hClash bool - for _, v := range s.store[kh] { - hClash = true - if s.comparator.Equals2(key, v) { - if collectStats { - s.stats.GetHits++ - s.stats.GetHashConflicts++ - } - return v, true - } - if collectStats { - s.stats.GetMisses++ - } - } - if collectStats { - if hClash { - s.stats.GetHashConflicts++ - } - s.stats.GetNoEnt++ - } - return key, false -} - -// Contains returns true if the given key is present in the store -func (s *JStore[T, C]) Contains(key T) bool { - _, present := s.Get(key) - return present -} - -func (s *JStore[T, C]) SortedSlice(less func(i, j T) bool) []T { - vs := make([]T, 0, len(s.store)) - for _, v := range s.store { - vs = append(vs, v...) - } - sort.Slice(vs, func(i, j int) bool { - return less(vs[i], vs[j]) - }) - - return vs -} - -func (s *JStore[T, C]) Each(f func(T) bool) { - for _, e := range s.store { - for _, v := range e { - f(v) - } - } -} - -func (s *JStore[T, C]) Len() int { - return s.len -} - -func (s *JStore[T, C]) Values() []T { - vs := make([]T, 0, len(s.store)) - for _, e := range s.store { - vs = append(vs, e...) - } - return vs -} - -type entry[K, V any] struct { - key K - val V -} - -type JMap[K, V any, C Comparator[K]] struct { - store map[int][]*entry[K, V] - len int - comparator Comparator[K] - stats *JStatRec -} - -func NewJMap[K, V any, C Comparator[K]](comparator Comparator[K], cType CollectionSource, desc string) *JMap[K, V, C] { - m := &JMap[K, V, C]{ - store: make(map[int][]*entry[K, V], 1), - comparator: comparator, - } - if collectStats { - m.stats = &JStatRec{ - Source: cType, - Description: desc, - } - // Track where we created it from if we are being asked to do so - if runtimeConfig.statsTraceStacks { - m.stats.CreateStack = debug.Stack() - } - Statistics.AddJStatRec(m.stats) - } - return m -} - -func (m *JMap[K, V, C]) Put(key K, val V) (V, bool) { - if collectStats { - m.stats.Puts++ - } - kh := m.comparator.Hash1(key) - - var hClash bool - for _, e := range m.store[kh] { - hClash = true - if m.comparator.Equals2(e.key, key) { - if collectStats { - m.stats.PutHits++ - m.stats.PutHashConflicts++ - } - return e.val, true - } - if collectStats { - m.stats.PutMisses++ - } - } - if collectStats { - if hClash { - m.stats.PutHashConflicts++ - } - } - m.store[kh] = append(m.store[kh], &entry[K, V]{key, val}) - if collectStats { - if len(m.store[kh]) > m.stats.MaxSlotSize { - m.stats.MaxSlotSize = len(m.store[kh]) - } - } - m.len++ - if collectStats { - m.stats.CurSize = m.len - if m.len > m.stats.MaxSize { - m.stats.MaxSize = m.len - } - } - return val, false -} - -func (m *JMap[K, V, C]) Values() []V { - vs := make([]V, 0, len(m.store)) - for _, e := range m.store { - for _, v := range e { - vs = append(vs, v.val) - } - } - return vs -} - -func (m *JMap[K, V, C]) Get(key K) (V, bool) { - if collectStats { - m.stats.Gets++ - } - var none V - kh := m.comparator.Hash1(key) - var hClash bool - for _, e := range m.store[kh] { - hClash = true - if m.comparator.Equals2(e.key, key) { - if collectStats { - m.stats.GetHits++ - m.stats.GetHashConflicts++ - } - return e.val, true - } - if collectStats { - m.stats.GetMisses++ - } - } - if collectStats { - if hClash { - m.stats.GetHashConflicts++ - } - m.stats.GetNoEnt++ - } - return none, false -} - -func (m *JMap[K, V, C]) Len() int { - return m.len -} - -func (m *JMap[K, V, C]) Delete(key K) { - kh := m.comparator.Hash1(key) - for i, e := range m.store[kh] { - if m.comparator.Equals2(e.key, key) { - m.store[kh] = append(m.store[kh][:i], m.store[kh][i+1:]...) - m.len-- - return - } - } -} - -func (m *JMap[K, V, C]) Clear() { - m.store = make(map[int][]*entry[K, V]) -} - -type JPCMap struct { - store *JMap[*PredictionContext, *JMap[*PredictionContext, *PredictionContext, *ObjEqComparator[*PredictionContext]], *ObjEqComparator[*PredictionContext]] - size int - stats *JStatRec -} - -func NewJPCMap(cType CollectionSource, desc string) *JPCMap { - m := &JPCMap{ - store: NewJMap[*PredictionContext, *JMap[*PredictionContext, *PredictionContext, *ObjEqComparator[*PredictionContext]], *ObjEqComparator[*PredictionContext]](pContextEqInst, cType, desc), - } - if collectStats { - m.stats = &JStatRec{ - Source: cType, - Description: desc, - } - // Track where we created it from if we are being asked to do so - if runtimeConfig.statsTraceStacks { - m.stats.CreateStack = debug.Stack() - } - Statistics.AddJStatRec(m.stats) - } - return m -} - -func (pcm *JPCMap) Get(k1, k2 *PredictionContext) (*PredictionContext, bool) { - if collectStats { - pcm.stats.Gets++ - } - // Do we have a map stored by k1? - // - m2, present := pcm.store.Get(k1) - if present { - if collectStats { - pcm.stats.GetHits++ - } - // We found a map of values corresponding to k1, so now we need to look up k2 in that map - // - return m2.Get(k2) - } - if collectStats { - pcm.stats.GetMisses++ - } - return nil, false -} - -func (pcm *JPCMap) Put(k1, k2, v *PredictionContext) { - - if collectStats { - pcm.stats.Puts++ - } - // First does a map already exist for k1? - // - if m2, present := pcm.store.Get(k1); present { - if collectStats { - pcm.stats.PutHits++ - } - _, present = m2.Put(k2, v) - if !present { - pcm.size++ - if collectStats { - pcm.stats.CurSize = pcm.size - if pcm.size > pcm.stats.MaxSize { - pcm.stats.MaxSize = pcm.size - } - } - } - } else { - // No map found for k1, so we create it, add in our value, then store is - // - if collectStats { - pcm.stats.PutMisses++ - m2 = NewJMap[*PredictionContext, *PredictionContext, *ObjEqComparator[*PredictionContext]](pContextEqInst, pcm.stats.Source, pcm.stats.Description+" map entry") - } else { - m2 = NewJMap[*PredictionContext, *PredictionContext, *ObjEqComparator[*PredictionContext]](pContextEqInst, PredictionContextCacheCollection, "map entry") - } - - m2.Put(k2, v) - pcm.store.Put(k1, m2) - pcm.size++ - } -} - -type JPCMap2 struct { - store map[int][]JPCEntry - size int - stats *JStatRec -} - -type JPCEntry struct { - k1, k2, v *PredictionContext -} - -func NewJPCMap2(cType CollectionSource, desc string) *JPCMap2 { - m := &JPCMap2{ - store: make(map[int][]JPCEntry, 1000), - } - if collectStats { - m.stats = &JStatRec{ - Source: cType, - Description: desc, - } - // Track where we created it from if we are being asked to do so - if runtimeConfig.statsTraceStacks { - m.stats.CreateStack = debug.Stack() - } - Statistics.AddJStatRec(m.stats) - } - return m -} - -func dHash(k1, k2 *PredictionContext) int { - return k1.cachedHash*31 + k2.cachedHash -} - -func (pcm *JPCMap2) Get(k1, k2 *PredictionContext) (*PredictionContext, bool) { - if collectStats { - pcm.stats.Gets++ - } - - h := dHash(k1, k2) - var hClash bool - for _, e := range pcm.store[h] { - hClash = true - if e.k1.Equals(k1) && e.k2.Equals(k2) { - if collectStats { - pcm.stats.GetHits++ - pcm.stats.GetHashConflicts++ - } - return e.v, true - } - if collectStats { - pcm.stats.GetMisses++ - } - } - if collectStats { - if hClash { - pcm.stats.GetHashConflicts++ - } - pcm.stats.GetNoEnt++ - } - return nil, false -} - -func (pcm *JPCMap2) Put(k1, k2, v *PredictionContext) (*PredictionContext, bool) { - if collectStats { - pcm.stats.Puts++ - } - h := dHash(k1, k2) - var hClash bool - for _, e := range pcm.store[h] { - hClash = true - if e.k1.Equals(k1) && e.k2.Equals(k2) { - if collectStats { - pcm.stats.PutHits++ - pcm.stats.PutHashConflicts++ - } - return e.v, true - } - if collectStats { - pcm.stats.PutMisses++ - } - } - if collectStats { - if hClash { - pcm.stats.PutHashConflicts++ - } - } - pcm.store[h] = append(pcm.store[h], JPCEntry{k1, k2, v}) - pcm.size++ - if collectStats { - pcm.stats.CurSize = pcm.size - if pcm.size > pcm.stats.MaxSize { - pcm.stats.MaxSize = pcm.size - } - } - return nil, false -} - -type VisitEntry struct { - k *PredictionContext - v *PredictionContext -} -type VisitRecord struct { - store map[*PredictionContext]*PredictionContext - len int - stats *JStatRec -} - -type VisitList struct { - cache *list.List - lock sync.RWMutex -} - -var visitListPool = VisitList{ - cache: list.New(), - lock: sync.RWMutex{}, -} - -// NewVisitRecord returns a new VisitRecord instance from the pool if available. -// Note that this "map" uses a pointer as a key because we are emulating the behavior of -// IdentityHashMap in Java, which uses the `==` operator to compare whether the keys are equal, -// which means is the key the same reference to an object rather than is it .equals() to another -// object. -func NewVisitRecord() *VisitRecord { - visitListPool.lock.Lock() - el := visitListPool.cache.Front() - defer visitListPool.lock.Unlock() - var vr *VisitRecord - if el == nil { - vr = &VisitRecord{ - store: make(map[*PredictionContext]*PredictionContext), - } - if collectStats { - vr.stats = &JStatRec{ - Source: PredictionContextCacheCollection, - Description: "VisitRecord", - } - // Track where we created it from if we are being asked to do so - if runtimeConfig.statsTraceStacks { - vr.stats.CreateStack = debug.Stack() - } - } - } else { - vr = el.Value.(*VisitRecord) - visitListPool.cache.Remove(el) - vr.store = make(map[*PredictionContext]*PredictionContext) - } - if collectStats { - Statistics.AddJStatRec(vr.stats) - } - return vr -} - -func (vr *VisitRecord) Release() { - vr.len = 0 - vr.store = nil - if collectStats { - vr.stats.MaxSize = 0 - vr.stats.CurSize = 0 - vr.stats.Gets = 0 - vr.stats.GetHits = 0 - vr.stats.GetMisses = 0 - vr.stats.GetHashConflicts = 0 - vr.stats.GetNoEnt = 0 - vr.stats.Puts = 0 - vr.stats.PutHits = 0 - vr.stats.PutMisses = 0 - vr.stats.PutHashConflicts = 0 - vr.stats.MaxSlotSize = 0 - } - visitListPool.lock.Lock() - visitListPool.cache.PushBack(vr) - visitListPool.lock.Unlock() -} - -func (vr *VisitRecord) Get(k *PredictionContext) (*PredictionContext, bool) { - if collectStats { - vr.stats.Gets++ - } - v := vr.store[k] - if v != nil { - if collectStats { - vr.stats.GetHits++ - } - return v, true - } - if collectStats { - vr.stats.GetNoEnt++ - } - return nil, false -} - -func (vr *VisitRecord) Put(k, v *PredictionContext) (*PredictionContext, bool) { - if collectStats { - vr.stats.Puts++ - } - vr.store[k] = v - vr.len++ - if collectStats { - vr.stats.CurSize = vr.len - if vr.len > vr.stats.MaxSize { - vr.stats.MaxSize = vr.len - } - } - return v, false -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/lexer.go b/vendor/github.com/antlr4-go/antlr/v4/lexer.go deleted file mode 100644 index 3c7896a91..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/lexer.go +++ /dev/null @@ -1,426 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import ( - "fmt" - "strconv" -) - -// A lexer is recognizer that draws input symbols from a character stream. -// lexer grammars result in a subclass of this object. A Lexer object -// uses simplified Match() and error recovery mechanisms in the interest -// of speed. -/// - -type Lexer interface { - TokenSource - Recognizer - - Emit() Token - - SetChannel(int) - PushMode(int) - PopMode() int - SetType(int) - SetMode(int) -} - -type BaseLexer struct { - *BaseRecognizer - - Interpreter ILexerATNSimulator - TokenStartCharIndex int - TokenStartLine int - TokenStartColumn int - ActionType int - Virt Lexer // The most derived lexer implementation. Allows virtual method calls. - - input CharStream - factory TokenFactory - tokenFactorySourcePair *TokenSourceCharStreamPair - token Token - hitEOF bool - channel int - thetype int - modeStack IntStack - mode int - text string -} - -func NewBaseLexer(input CharStream) *BaseLexer { - - lexer := new(BaseLexer) - - lexer.BaseRecognizer = NewBaseRecognizer() - - lexer.input = input - lexer.factory = CommonTokenFactoryDEFAULT - lexer.tokenFactorySourcePair = &TokenSourceCharStreamPair{lexer, input} - - lexer.Virt = lexer - - lexer.Interpreter = nil // child classes must populate it - - // The goal of all lexer rules/methods is to create a token object. - // l is an instance variable as multiple rules may collaborate to - // create a single token. NextToken will return l object after - // Matching lexer rule(s). If you subclass to allow multiple token - // emissions, then set l to the last token to be Matched or - // something non nil so that the auto token emit mechanism will not - // emit another token. - lexer.token = nil - - // What character index in the stream did the current token start at? - // Needed, for example, to get the text for current token. Set at - // the start of NextToken. - lexer.TokenStartCharIndex = -1 - - // The line on which the first character of the token resides/// - lexer.TokenStartLine = -1 - - // The character position of first character within the line/// - lexer.TokenStartColumn = -1 - - // Once we see EOF on char stream, next token will be EOF. - // If you have DONE : EOF then you see DONE EOF. - lexer.hitEOF = false - - // The channel number for the current token/// - lexer.channel = TokenDefaultChannel - - // The token type for the current token/// - lexer.thetype = TokenInvalidType - - lexer.modeStack = make([]int, 0) - lexer.mode = LexerDefaultMode - - // You can set the text for the current token to override what is in - // the input char buffer. Use setText() or can set l instance var. - // / - lexer.text = "" - - return lexer -} - -const ( - LexerDefaultMode = 0 - LexerMore = -2 - LexerSkip = -3 -) - -//goland:noinspection GoUnusedConst -const ( - LexerDefaultTokenChannel = TokenDefaultChannel - LexerHidden = TokenHiddenChannel - LexerMinCharValue = 0x0000 - LexerMaxCharValue = 0x10FFFF -) - -func (b *BaseLexer) Reset() { - // wack Lexer state variables - if b.input != nil { - b.input.Seek(0) // rewind the input - } - b.token = nil - b.thetype = TokenInvalidType - b.channel = TokenDefaultChannel - b.TokenStartCharIndex = -1 - b.TokenStartColumn = -1 - b.TokenStartLine = -1 - b.text = "" - - b.hitEOF = false - b.mode = LexerDefaultMode - b.modeStack = make([]int, 0) - - b.Interpreter.reset() -} - -func (b *BaseLexer) GetInterpreter() ILexerATNSimulator { - return b.Interpreter -} - -func (b *BaseLexer) GetInputStream() CharStream { - return b.input -} - -func (b *BaseLexer) GetSourceName() string { - return b.GrammarFileName -} - -func (b *BaseLexer) SetChannel(v int) { - b.channel = v -} - -func (b *BaseLexer) GetTokenFactory() TokenFactory { - return b.factory -} - -func (b *BaseLexer) setTokenFactory(f TokenFactory) { - b.factory = f -} - -func (b *BaseLexer) safeMatch() (ret int) { - defer func() { - if e := recover(); e != nil { - if re, ok := e.(RecognitionException); ok { - b.notifyListeners(re) // Report error - b.Recover(re) - ret = LexerSkip // default - } - } - }() - - return b.Interpreter.Match(b.input, b.mode) -} - -// NextToken returns a token from the lexer input source i.e., Match a token on the source char stream. -func (b *BaseLexer) NextToken() Token { - if b.input == nil { - panic("NextToken requires a non-nil input stream.") - } - - tokenStartMarker := b.input.Mark() - - // previously in finally block - defer func() { - // make sure we release marker after Match or - // unbuffered char stream will keep buffering - b.input.Release(tokenStartMarker) - }() - - for { - if b.hitEOF { - b.EmitEOF() - return b.token - } - b.token = nil - b.channel = TokenDefaultChannel - b.TokenStartCharIndex = b.input.Index() - b.TokenStartColumn = b.Interpreter.GetCharPositionInLine() - b.TokenStartLine = b.Interpreter.GetLine() - b.text = "" - continueOuter := false - for { - b.thetype = TokenInvalidType - - ttype := b.safeMatch() - - if b.input.LA(1) == TokenEOF { - b.hitEOF = true - } - if b.thetype == TokenInvalidType { - b.thetype = ttype - } - if b.thetype == LexerSkip { - continueOuter = true - break - } - if b.thetype != LexerMore { - break - } - } - - if continueOuter { - continue - } - if b.token == nil { - b.Virt.Emit() - } - return b.token - } -} - -// Skip instructs the lexer to Skip creating a token for current lexer rule -// and look for another token. [NextToken] knows to keep looking when -// a lexer rule finishes with token set to [SKIPTOKEN]. Recall that -// if token==nil at end of any token rule, it creates one for you -// and emits it. -func (b *BaseLexer) Skip() { - b.thetype = LexerSkip -} - -func (b *BaseLexer) More() { - b.thetype = LexerMore -} - -// SetMode changes the lexer to a new mode. The lexer will use this mode from hereon in and the rules for that mode -// will be in force. -func (b *BaseLexer) SetMode(m int) { - b.mode = m -} - -// PushMode saves the current lexer mode so that it can be restored later. See [PopMode], then sets the -// current lexer mode to the supplied mode m. -func (b *BaseLexer) PushMode(m int) { - if runtimeConfig.lexerATNSimulatorDebug { - fmt.Println("pushMode " + strconv.Itoa(m)) - } - b.modeStack.Push(b.mode) - b.mode = m -} - -// PopMode restores the lexer mode saved by a call to [PushMode]. It is a panic error if there is no saved mode to -// return to. -func (b *BaseLexer) PopMode() int { - if len(b.modeStack) == 0 { - panic("Empty Stack") - } - if runtimeConfig.lexerATNSimulatorDebug { - fmt.Println("popMode back to " + fmt.Sprint(b.modeStack[0:len(b.modeStack)-1])) - } - i, _ := b.modeStack.Pop() - b.mode = i - return b.mode -} - -func (b *BaseLexer) inputStream() CharStream { - return b.input -} - -// SetInputStream resets the lexer input stream and associated lexer state. -func (b *BaseLexer) SetInputStream(input CharStream) { - b.input = nil - b.tokenFactorySourcePair = &TokenSourceCharStreamPair{b, b.input} - b.Reset() - b.input = input - b.tokenFactorySourcePair = &TokenSourceCharStreamPair{b, b.input} -} - -func (b *BaseLexer) GetTokenSourceCharStreamPair() *TokenSourceCharStreamPair { - return b.tokenFactorySourcePair -} - -// EmitToken by default does not support multiple emits per [NextToken] invocation -// for efficiency reasons. Subclass and override this func, [NextToken], -// and [GetToken] (to push tokens into a list and pull from that list -// rather than a single variable as this implementation does). -func (b *BaseLexer) EmitToken(token Token) { - b.token = token -} - -// Emit is the standard method called to automatically emit a token at the -// outermost lexical rule. The token object should point into the -// char buffer start..stop. If there is a text override in 'text', -// use that to set the token's text. Override this method to emit -// custom [Token] objects or provide a new factory. -// / -func (b *BaseLexer) Emit() Token { - t := b.factory.Create(b.tokenFactorySourcePair, b.thetype, b.text, b.channel, b.TokenStartCharIndex, b.GetCharIndex()-1, b.TokenStartLine, b.TokenStartColumn) - b.EmitToken(t) - return t -} - -// EmitEOF emits an EOF token. By default, this is the last token emitted -func (b *BaseLexer) EmitEOF() Token { - cpos := b.GetCharPositionInLine() - lpos := b.GetLine() - eof := b.factory.Create(b.tokenFactorySourcePair, TokenEOF, "", TokenDefaultChannel, b.input.Index(), b.input.Index()-1, lpos, cpos) - b.EmitToken(eof) - return eof -} - -// GetCharPositionInLine returns the current position in the current line as far as the lexer is concerned. -func (b *BaseLexer) GetCharPositionInLine() int { - return b.Interpreter.GetCharPositionInLine() -} - -func (b *BaseLexer) GetLine() int { - return b.Interpreter.GetLine() -} - -func (b *BaseLexer) GetType() int { - return b.thetype -} - -func (b *BaseLexer) SetType(t int) { - b.thetype = t -} - -// GetCharIndex returns the index of the current character of lookahead -func (b *BaseLexer) GetCharIndex() int { - return b.input.Index() -} - -// GetText returns the text Matched so far for the current token or any text override. -func (b *BaseLexer) GetText() string { - if b.text != "" { - return b.text - } - - return b.Interpreter.GetText(b.input) -} - -// SetText sets the complete text of this token; it wipes any previous changes to the text. -func (b *BaseLexer) SetText(text string) { - b.text = text -} - -// GetATN returns the ATN used by the lexer. -func (b *BaseLexer) GetATN() *ATN { - return b.Interpreter.ATN() -} - -// GetAllTokens returns a list of all [Token] objects in input char stream. -// Forces a load of all tokens that can be made from the input char stream. -// -// Does not include EOF token. -func (b *BaseLexer) GetAllTokens() []Token { - vl := b.Virt - tokens := make([]Token, 0) - t := vl.NextToken() - for t.GetTokenType() != TokenEOF { - tokens = append(tokens, t) - t = vl.NextToken() - } - return tokens -} - -func (b *BaseLexer) notifyListeners(e RecognitionException) { - start := b.TokenStartCharIndex - stop := b.input.Index() - text := b.input.GetTextFromInterval(NewInterval(start, stop)) - msg := "token recognition error at: '" + text + "'" - listener := b.GetErrorListenerDispatch() - listener.SyntaxError(b, nil, b.TokenStartLine, b.TokenStartColumn, msg, e) -} - -func (b *BaseLexer) getErrorDisplayForChar(c rune) string { - if c == TokenEOF { - return "" - } else if c == '\n' { - return "\\n" - } else if c == '\t' { - return "\\t" - } else if c == '\r' { - return "\\r" - } else { - return string(c) - } -} - -func (b *BaseLexer) getCharErrorDisplay(c rune) string { - return "'" + b.getErrorDisplayForChar(c) + "'" -} - -// Recover can normally Match any char in its vocabulary after Matching -// a token, so here we do the easy thing and just kill a character and hope -// it all works out. You can instead use the rule invocation stack -// to do sophisticated error recovery if you are in a fragment rule. -// -// In general, lexers should not need to recover and should have rules that cover any eventuality, such as -// a character that makes no sense to the recognizer. -func (b *BaseLexer) Recover(re RecognitionException) { - if b.input.LA(1) != TokenEOF { - if _, ok := re.(*LexerNoViableAltException); ok { - // Skip a char and try again - b.Interpreter.Consume(b.input) - } else { - // TODO: Do we lose character or line position information? - b.input.Consume() - } - } -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/lexer_action.go b/vendor/github.com/antlr4-go/antlr/v4/lexer_action.go deleted file mode 100644 index eaa7393e0..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/lexer_action.go +++ /dev/null @@ -1,452 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import "strconv" - -const ( - // LexerActionTypeChannel represents a [LexerChannelAction] action. - LexerActionTypeChannel = 0 - - // LexerActionTypeCustom represents a [LexerCustomAction] action. - LexerActionTypeCustom = 1 - - // LexerActionTypeMode represents a [LexerModeAction] action. - LexerActionTypeMode = 2 - - // LexerActionTypeMore represents a [LexerMoreAction] action. - LexerActionTypeMore = 3 - - // LexerActionTypePopMode represents a [LexerPopModeAction] action. - LexerActionTypePopMode = 4 - - // LexerActionTypePushMode represents a [LexerPushModeAction] action. - LexerActionTypePushMode = 5 - - // LexerActionTypeSkip represents a [LexerSkipAction] action. - LexerActionTypeSkip = 6 - - // LexerActionTypeType represents a [LexerTypeAction] action. - LexerActionTypeType = 7 -) - -type LexerAction interface { - getActionType() int - getIsPositionDependent() bool - execute(lexer Lexer) - Hash() int - Equals(other LexerAction) bool -} - -type BaseLexerAction struct { - actionType int - isPositionDependent bool -} - -func NewBaseLexerAction(action int) *BaseLexerAction { - la := new(BaseLexerAction) - - la.actionType = action - la.isPositionDependent = false - - return la -} - -func (b *BaseLexerAction) execute(_ Lexer) { - panic("Not implemented") -} - -func (b *BaseLexerAction) getActionType() int { - return b.actionType -} - -func (b *BaseLexerAction) getIsPositionDependent() bool { - return b.isPositionDependent -} - -func (b *BaseLexerAction) Hash() int { - h := murmurInit(0) - h = murmurUpdate(h, b.actionType) - return murmurFinish(h, 1) -} - -func (b *BaseLexerAction) Equals(other LexerAction) bool { - return b.actionType == other.getActionType() -} - -// LexerSkipAction implements the [BaseLexerAction.Skip] lexer action by calling [Lexer.Skip]. -// -// The Skip command does not have any parameters, so this action is -// implemented as a singleton instance exposed by the [LexerSkipActionINSTANCE]. -type LexerSkipAction struct { - *BaseLexerAction -} - -func NewLexerSkipAction() *LexerSkipAction { - la := new(LexerSkipAction) - la.BaseLexerAction = NewBaseLexerAction(LexerActionTypeSkip) - return la -} - -// LexerSkipActionINSTANCE provides a singleton instance of this parameterless lexer action. -var LexerSkipActionINSTANCE = NewLexerSkipAction() - -func (l *LexerSkipAction) execute(lexer Lexer) { - lexer.Skip() -} - -// String returns a string representation of the current [LexerSkipAction]. -func (l *LexerSkipAction) String() string { - return "skip" -} - -func (b *LexerSkipAction) Equals(other LexerAction) bool { - return other.getActionType() == LexerActionTypeSkip -} - -// Implements the {@code type} lexer action by calling {@link Lexer//setType} -// -// with the assigned type. -type LexerTypeAction struct { - *BaseLexerAction - - thetype int -} - -func NewLexerTypeAction(thetype int) *LexerTypeAction { - l := new(LexerTypeAction) - l.BaseLexerAction = NewBaseLexerAction(LexerActionTypeType) - l.thetype = thetype - return l -} - -func (l *LexerTypeAction) execute(lexer Lexer) { - lexer.SetType(l.thetype) -} - -func (l *LexerTypeAction) Hash() int { - h := murmurInit(0) - h = murmurUpdate(h, l.actionType) - h = murmurUpdate(h, l.thetype) - return murmurFinish(h, 2) -} - -func (l *LexerTypeAction) Equals(other LexerAction) bool { - if l == other { - return true - } else if _, ok := other.(*LexerTypeAction); !ok { - return false - } else { - return l.thetype == other.(*LexerTypeAction).thetype - } -} - -func (l *LexerTypeAction) String() string { - return "actionType(" + strconv.Itoa(l.thetype) + ")" -} - -// LexerPushModeAction implements the pushMode lexer action by calling -// [Lexer.pushMode] with the assigned mode. -type LexerPushModeAction struct { - *BaseLexerAction - mode int -} - -func NewLexerPushModeAction(mode int) *LexerPushModeAction { - - l := new(LexerPushModeAction) - l.BaseLexerAction = NewBaseLexerAction(LexerActionTypePushMode) - - l.mode = mode - return l -} - -//

This action is implemented by calling {@link Lexer//pushMode} with the -// value provided by {@link //getMode}.

-func (l *LexerPushModeAction) execute(lexer Lexer) { - lexer.PushMode(l.mode) -} - -func (l *LexerPushModeAction) Hash() int { - h := murmurInit(0) - h = murmurUpdate(h, l.actionType) - h = murmurUpdate(h, l.mode) - return murmurFinish(h, 2) -} - -func (l *LexerPushModeAction) Equals(other LexerAction) bool { - if l == other { - return true - } else if _, ok := other.(*LexerPushModeAction); !ok { - return false - } else { - return l.mode == other.(*LexerPushModeAction).mode - } -} - -func (l *LexerPushModeAction) String() string { - return "pushMode(" + strconv.Itoa(l.mode) + ")" -} - -// LexerPopModeAction implements the popMode lexer action by calling [Lexer.popMode]. -// -// The popMode command does not have any parameters, so this action is -// implemented as a singleton instance exposed by [LexerPopModeActionINSTANCE] -type LexerPopModeAction struct { - *BaseLexerAction -} - -func NewLexerPopModeAction() *LexerPopModeAction { - - l := new(LexerPopModeAction) - - l.BaseLexerAction = NewBaseLexerAction(LexerActionTypePopMode) - - return l -} - -var LexerPopModeActionINSTANCE = NewLexerPopModeAction() - -//

This action is implemented by calling {@link Lexer//popMode}.

-func (l *LexerPopModeAction) execute(lexer Lexer) { - lexer.PopMode() -} - -func (l *LexerPopModeAction) String() string { - return "popMode" -} - -// Implements the {@code more} lexer action by calling {@link Lexer//more}. -// -//

The {@code more} command does not have any parameters, so l action is -// implemented as a singleton instance exposed by {@link //INSTANCE}.

- -type LexerMoreAction struct { - *BaseLexerAction -} - -func NewLexerMoreAction() *LexerMoreAction { - l := new(LexerMoreAction) - l.BaseLexerAction = NewBaseLexerAction(LexerActionTypeMore) - - return l -} - -var LexerMoreActionINSTANCE = NewLexerMoreAction() - -//

This action is implemented by calling {@link Lexer//popMode}.

-func (l *LexerMoreAction) execute(lexer Lexer) { - lexer.More() -} - -func (l *LexerMoreAction) String() string { - return "more" -} - -// LexerModeAction implements the mode lexer action by calling [Lexer.mode] with -// the assigned mode. -type LexerModeAction struct { - *BaseLexerAction - mode int -} - -func NewLexerModeAction(mode int) *LexerModeAction { - l := new(LexerModeAction) - l.BaseLexerAction = NewBaseLexerAction(LexerActionTypeMode) - l.mode = mode - return l -} - -//

This action is implemented by calling {@link Lexer//mode} with the -// value provided by {@link //getMode}.

-func (l *LexerModeAction) execute(lexer Lexer) { - lexer.SetMode(l.mode) -} - -func (l *LexerModeAction) Hash() int { - h := murmurInit(0) - h = murmurUpdate(h, l.actionType) - h = murmurUpdate(h, l.mode) - return murmurFinish(h, 2) -} - -func (l *LexerModeAction) Equals(other LexerAction) bool { - if l == other { - return true - } else if _, ok := other.(*LexerModeAction); !ok { - return false - } else { - return l.mode == other.(*LexerModeAction).mode - } -} - -func (l *LexerModeAction) String() string { - return "mode(" + strconv.Itoa(l.mode) + ")" -} - -// Executes a custom lexer action by calling {@link Recognizer//action} with the -// rule and action indexes assigned to the custom action. The implementation of -// a custom action is added to the generated code for the lexer in an override -// of {@link Recognizer//action} when the grammar is compiled. -// -//

This class may represent embedded actions created with the {...} -// syntax in ANTLR 4, as well as actions created for lexer commands where the -// command argument could not be evaluated when the grammar was compiled.

- -// Constructs a custom lexer action with the specified rule and action -// indexes. -// -// @param ruleIndex The rule index to use for calls to -// {@link Recognizer//action}. -// @param actionIndex The action index to use for calls to -// {@link Recognizer//action}. - -type LexerCustomAction struct { - *BaseLexerAction - ruleIndex, actionIndex int -} - -func NewLexerCustomAction(ruleIndex, actionIndex int) *LexerCustomAction { - l := new(LexerCustomAction) - l.BaseLexerAction = NewBaseLexerAction(LexerActionTypeCustom) - l.ruleIndex = ruleIndex - l.actionIndex = actionIndex - l.isPositionDependent = true - return l -} - -//

Custom actions are implemented by calling {@link Lexer//action} with the -// appropriate rule and action indexes.

-func (l *LexerCustomAction) execute(lexer Lexer) { - lexer.Action(nil, l.ruleIndex, l.actionIndex) -} - -func (l *LexerCustomAction) Hash() int { - h := murmurInit(0) - h = murmurUpdate(h, l.actionType) - h = murmurUpdate(h, l.ruleIndex) - h = murmurUpdate(h, l.actionIndex) - return murmurFinish(h, 3) -} - -func (l *LexerCustomAction) Equals(other LexerAction) bool { - if l == other { - return true - } else if _, ok := other.(*LexerCustomAction); !ok { - return false - } else { - return l.ruleIndex == other.(*LexerCustomAction).ruleIndex && - l.actionIndex == other.(*LexerCustomAction).actionIndex - } -} - -// LexerChannelAction implements the channel lexer action by calling -// [Lexer.setChannel] with the assigned channel. -// -// Constructs a new channel action with the specified channel value. -type LexerChannelAction struct { - *BaseLexerAction - channel int -} - -// NewLexerChannelAction creates a channel lexer action by calling -// [Lexer.setChannel] with the assigned channel. -// -// Constructs a new channel action with the specified channel value. -func NewLexerChannelAction(channel int) *LexerChannelAction { - l := new(LexerChannelAction) - l.BaseLexerAction = NewBaseLexerAction(LexerActionTypeChannel) - l.channel = channel - return l -} - -//

This action is implemented by calling {@link Lexer//setChannel} with the -// value provided by {@link //getChannel}.

-func (l *LexerChannelAction) execute(lexer Lexer) { - lexer.SetChannel(l.channel) -} - -func (l *LexerChannelAction) Hash() int { - h := murmurInit(0) - h = murmurUpdate(h, l.actionType) - h = murmurUpdate(h, l.channel) - return murmurFinish(h, 2) -} - -func (l *LexerChannelAction) Equals(other LexerAction) bool { - if l == other { - return true - } else if _, ok := other.(*LexerChannelAction); !ok { - return false - } else { - return l.channel == other.(*LexerChannelAction).channel - } -} - -func (l *LexerChannelAction) String() string { - return "channel(" + strconv.Itoa(l.channel) + ")" -} - -// This implementation of {@link LexerAction} is used for tracking input offsets -// for position-dependent actions within a {@link LexerActionExecutor}. -// -//

This action is not serialized as part of the ATN, and is only required for -// position-dependent lexer actions which appear at a location other than the -// end of a rule. For more information about DFA optimizations employed for -// lexer actions, see {@link LexerActionExecutor//append} and -// {@link LexerActionExecutor//fixOffsetBeforeMatch}.

- -type LexerIndexedCustomAction struct { - *BaseLexerAction - offset int - lexerAction LexerAction - isPositionDependent bool -} - -// NewLexerIndexedCustomAction constructs a new indexed custom action by associating a character offset -// with a [LexerAction]. -// -// Note: This class is only required for lexer actions for which -// [LexerAction.isPositionDependent] returns true. -// -// The offset points into the input [CharStream], relative to -// the token start index, at which the specified lexerAction should be -// executed. -func NewLexerIndexedCustomAction(offset int, lexerAction LexerAction) *LexerIndexedCustomAction { - - l := new(LexerIndexedCustomAction) - l.BaseLexerAction = NewBaseLexerAction(lexerAction.getActionType()) - - l.offset = offset - l.lexerAction = lexerAction - l.isPositionDependent = true - - return l -} - -//

This method calls {@link //execute} on the result of {@link //getAction} -// using the provided {@code lexer}.

-func (l *LexerIndexedCustomAction) execute(lexer Lexer) { - // assume the input stream position was properly set by the calling code - l.lexerAction.execute(lexer) -} - -func (l *LexerIndexedCustomAction) Hash() int { - h := murmurInit(0) - h = murmurUpdate(h, l.offset) - h = murmurUpdate(h, l.lexerAction.Hash()) - return murmurFinish(h, 2) -} - -func (l *LexerIndexedCustomAction) equals(other LexerAction) bool { - if l == other { - return true - } else if _, ok := other.(*LexerIndexedCustomAction); !ok { - return false - } else { - return l.offset == other.(*LexerIndexedCustomAction).offset && - l.lexerAction.Equals(other.(*LexerIndexedCustomAction).lexerAction) - } -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/lexer_action_executor.go b/vendor/github.com/antlr4-go/antlr/v4/lexer_action_executor.go deleted file mode 100644 index dfc28c32b..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/lexer_action_executor.go +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import "golang.org/x/exp/slices" - -// Represents an executor for a sequence of lexer actions which traversed during -// the Matching operation of a lexer rule (token). -// -//

The executor tracks position information for position-dependent lexer actions -// efficiently, ensuring that actions appearing only at the end of the rule do -// not cause bloating of the {@link DFA} created for the lexer.

- -type LexerActionExecutor struct { - lexerActions []LexerAction - cachedHash int -} - -func NewLexerActionExecutor(lexerActions []LexerAction) *LexerActionExecutor { - - if lexerActions == nil { - lexerActions = make([]LexerAction, 0) - } - - l := new(LexerActionExecutor) - - l.lexerActions = lexerActions - - // Caches the result of {@link //hashCode} since the hash code is an element - // of the performance-critical {@link ATNConfig//hashCode} operation. - l.cachedHash = murmurInit(0) - for _, a := range lexerActions { - l.cachedHash = murmurUpdate(l.cachedHash, a.Hash()) - } - l.cachedHash = murmurFinish(l.cachedHash, len(lexerActions)) - - return l -} - -// LexerActionExecutorappend creates a [LexerActionExecutor] which executes the actions for -// the input [LexerActionExecutor] followed by a specified -// [LexerAction]. -// TODO: This does not match the Java code -func LexerActionExecutorappend(lexerActionExecutor *LexerActionExecutor, lexerAction LexerAction) *LexerActionExecutor { - if lexerActionExecutor == nil { - return NewLexerActionExecutor([]LexerAction{lexerAction}) - } - - return NewLexerActionExecutor(append(lexerActionExecutor.lexerActions, lexerAction)) -} - -// fixOffsetBeforeMatch creates a [LexerActionExecutor] which encodes the current offset -// for position-dependent lexer actions. -// -// Normally, when the executor encounters lexer actions where -// [LexerAction.isPositionDependent] returns true, it calls -// [IntStream.Seek] on the input [CharStream] to set the input -// position to the end of the current token. This behavior provides -// for efficient [DFA] representation of lexer actions which appear at the end -// of a lexer rule, even when the lexer rule Matches a variable number of -// characters. -// -// Prior to traversing a Match transition in the [ATN], the current offset -// from the token start index is assigned to all position-dependent lexer -// actions which have not already been assigned a fixed offset. By storing -// the offsets relative to the token start index, the [DFA] representation of -// lexer actions which appear in the middle of tokens remains efficient due -// to sharing among tokens of the same Length, regardless of their absolute -// position in the input stream. -// -// If the current executor already has offsets assigned to all -// position-dependent lexer actions, the method returns this instance. -// -// The offset is assigned to all position-dependent -// lexer actions which do not already have offsets assigned. -// -// The func returns a [LexerActionExecutor] that stores input stream offsets -// for all position-dependent lexer actions. -func (l *LexerActionExecutor) fixOffsetBeforeMatch(offset int) *LexerActionExecutor { - var updatedLexerActions []LexerAction - for i := 0; i < len(l.lexerActions); i++ { - _, ok := l.lexerActions[i].(*LexerIndexedCustomAction) - if l.lexerActions[i].getIsPositionDependent() && !ok { - if updatedLexerActions == nil { - updatedLexerActions = make([]LexerAction, 0, len(l.lexerActions)) - updatedLexerActions = append(updatedLexerActions, l.lexerActions...) - } - updatedLexerActions[i] = NewLexerIndexedCustomAction(offset, l.lexerActions[i]) - } - } - if updatedLexerActions == nil { - return l - } - - return NewLexerActionExecutor(updatedLexerActions) -} - -// Execute the actions encapsulated by l executor within the context of a -// particular {@link Lexer}. -// -//

This method calls {@link IntStream//seek} to set the position of the -// {@code input} {@link CharStream} prior to calling -// {@link LexerAction//execute} on a position-dependent action. Before the -// method returns, the input position will be restored to the same position -// it was in when the method was invoked.

-// -// @param lexer The lexer instance. -// @param input The input stream which is the source for the current token. -// When l method is called, the current {@link IntStream//index} for -// {@code input} should be the start of the following token, i.e. 1 -// character past the end of the current token. -// @param startIndex The token start index. This value may be passed to -// {@link IntStream//seek} to set the {@code input} position to the beginning -// of the token. -// / -func (l *LexerActionExecutor) execute(lexer Lexer, input CharStream, startIndex int) { - requiresSeek := false - stopIndex := input.Index() - - defer func() { - if requiresSeek { - input.Seek(stopIndex) - } - }() - - for i := 0; i < len(l.lexerActions); i++ { - lexerAction := l.lexerActions[i] - if la, ok := lexerAction.(*LexerIndexedCustomAction); ok { - offset := la.offset - input.Seek(startIndex + offset) - lexerAction = la.lexerAction - requiresSeek = (startIndex + offset) != stopIndex - } else if lexerAction.getIsPositionDependent() { - input.Seek(stopIndex) - requiresSeek = false - } - lexerAction.execute(lexer) - } -} - -func (l *LexerActionExecutor) Hash() int { - if l == nil { - // TODO: Why is this here? l should not be nil - return 61 - } - - // TODO: This is created from the action itself when the struct is created - will this be an issue at some point? Java uses the runtime assign hashcode - return l.cachedHash -} - -func (l *LexerActionExecutor) Equals(other interface{}) bool { - if l == other { - return true - } - othert, ok := other.(*LexerActionExecutor) - if !ok { - return false - } - if othert == nil { - return false - } - if l.cachedHash != othert.cachedHash { - return false - } - if len(l.lexerActions) != len(othert.lexerActions) { - return false - } - return slices.EqualFunc(l.lexerActions, othert.lexerActions, func(i, j LexerAction) bool { - return i.Equals(j) - }) -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/lexer_atn_simulator.go b/vendor/github.com/antlr4-go/antlr/v4/lexer_atn_simulator.go deleted file mode 100644 index fe938b025..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/lexer_atn_simulator.go +++ /dev/null @@ -1,677 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import ( - "fmt" - "strconv" - "strings" -) - -//goland:noinspection GoUnusedGlobalVariable -var ( - LexerATNSimulatorMinDFAEdge = 0 - LexerATNSimulatorMaxDFAEdge = 127 // forces unicode to stay in ATN - - LexerATNSimulatorMatchCalls = 0 -) - -type ILexerATNSimulator interface { - IATNSimulator - - reset() - Match(input CharStream, mode int) int - GetCharPositionInLine() int - GetLine() int - GetText(input CharStream) string - Consume(input CharStream) -} - -type LexerATNSimulator struct { - BaseATNSimulator - - recog Lexer - predictionMode int - mergeCache *JPCMap2 - startIndex int - Line int - CharPositionInLine int - mode int - prevAccept *SimState - MatchCalls int -} - -func NewLexerATNSimulator(recog Lexer, atn *ATN, decisionToDFA []*DFA, sharedContextCache *PredictionContextCache) *LexerATNSimulator { - l := &LexerATNSimulator{ - BaseATNSimulator: BaseATNSimulator{ - atn: atn, - sharedContextCache: sharedContextCache, - }, - } - - l.decisionToDFA = decisionToDFA - l.recog = recog - - // The current token's starting index into the character stream. - // Shared across DFA to ATN simulation in case the ATN fails and the - // DFA did not have a previous accept state. In l case, we use the - // ATN-generated exception object. - l.startIndex = -1 - - // line number 1..n within the input - l.Line = 1 - - // The index of the character relative to the beginning of the line - // 0..n-1 - l.CharPositionInLine = 0 - - l.mode = LexerDefaultMode - - // Used during DFA/ATN exec to record the most recent accept configuration - // info - l.prevAccept = NewSimState() - - return l -} - -func (l *LexerATNSimulator) copyState(simulator *LexerATNSimulator) { - l.CharPositionInLine = simulator.CharPositionInLine - l.Line = simulator.Line - l.mode = simulator.mode - l.startIndex = simulator.startIndex -} - -func (l *LexerATNSimulator) Match(input CharStream, mode int) int { - l.MatchCalls++ - l.mode = mode - mark := input.Mark() - - defer func() { - input.Release(mark) - }() - - l.startIndex = input.Index() - l.prevAccept.reset() - - dfa := l.decisionToDFA[mode] - - var s0 *DFAState - l.atn.stateMu.RLock() - s0 = dfa.getS0() - l.atn.stateMu.RUnlock() - - if s0 == nil { - return l.MatchATN(input) - } - - return l.execATN(input, s0) -} - -func (l *LexerATNSimulator) reset() { - l.prevAccept.reset() - l.startIndex = -1 - l.Line = 1 - l.CharPositionInLine = 0 - l.mode = LexerDefaultMode -} - -func (l *LexerATNSimulator) MatchATN(input CharStream) int { - startState := l.atn.modeToStartState[l.mode] - - if runtimeConfig.lexerATNSimulatorDebug { - fmt.Println("MatchATN mode " + strconv.Itoa(l.mode) + " start: " + startState.String()) - } - oldMode := l.mode - s0Closure := l.computeStartState(input, startState) - suppressEdge := s0Closure.hasSemanticContext - s0Closure.hasSemanticContext = false - - next := l.addDFAState(s0Closure, suppressEdge) - - predict := l.execATN(input, next) - - if runtimeConfig.lexerATNSimulatorDebug { - fmt.Println("DFA after MatchATN: " + l.decisionToDFA[oldMode].ToLexerString()) - } - return predict -} - -func (l *LexerATNSimulator) execATN(input CharStream, ds0 *DFAState) int { - - if runtimeConfig.lexerATNSimulatorDebug { - fmt.Println("start state closure=" + ds0.configs.String()) - } - if ds0.isAcceptState { - // allow zero-Length tokens - l.captureSimState(l.prevAccept, input, ds0) - } - t := input.LA(1) - s := ds0 // s is current/from DFA state - - for { // while more work - if runtimeConfig.lexerATNSimulatorDebug { - fmt.Println("execATN loop starting closure: " + s.configs.String()) - } - - // As we move src->trg, src->trg, we keep track of the previous trg to - // avoid looking up the DFA state again, which is expensive. - // If the previous target was already part of the DFA, we might - // be able to avoid doing a reach operation upon t. If s!=nil, - // it means that semantic predicates didn't prevent us from - // creating a DFA state. Once we know s!=nil, we check to see if - // the DFA state has an edge already for t. If so, we can just reuse - // it's configuration set there's no point in re-computing it. - // This is kind of like doing DFA simulation within the ATN - // simulation because DFA simulation is really just a way to avoid - // computing reach/closure sets. Technically, once we know that - // we have a previously added DFA state, we could jump over to - // the DFA simulator. But, that would mean popping back and forth - // a lot and making things more complicated algorithmically. - // This optimization makes a lot of sense for loops within DFA. - // A character will take us back to an existing DFA state - // that already has lots of edges out of it. e.g., .* in comments. - target := l.getExistingTargetState(s, t) - if target == nil { - target = l.computeTargetState(input, s, t) - // print("Computed:" + str(target)) - } - if target == ATNSimulatorError { - break - } - // If l is a consumable input element, make sure to consume before - // capturing the accept state so the input index, line, and char - // position accurately reflect the state of the interpreter at the - // end of the token. - if t != TokenEOF { - l.Consume(input) - } - if target.isAcceptState { - l.captureSimState(l.prevAccept, input, target) - if t == TokenEOF { - break - } - } - t = input.LA(1) - s = target // flip current DFA target becomes new src/from state - } - - return l.failOrAccept(l.prevAccept, input, s.configs, t) -} - -// Get an existing target state for an edge in the DFA. If the target state -// for the edge has not yet been computed or is otherwise not available, -// l method returns {@code nil}. -// -// @param s The current DFA state -// @param t The next input symbol -// @return The existing target DFA state for the given input symbol -// {@code t}, or {@code nil} if the target state for l edge is not -// already cached -func (l *LexerATNSimulator) getExistingTargetState(s *DFAState, t int) *DFAState { - if t < LexerATNSimulatorMinDFAEdge || t > LexerATNSimulatorMaxDFAEdge { - return nil - } - - l.atn.edgeMu.RLock() - defer l.atn.edgeMu.RUnlock() - if s.getEdges() == nil { - return nil - } - target := s.getIthEdge(t - LexerATNSimulatorMinDFAEdge) - if runtimeConfig.lexerATNSimulatorDebug && target != nil { - fmt.Println("reuse state " + strconv.Itoa(s.stateNumber) + " edge to " + strconv.Itoa(target.stateNumber)) - } - return target -} - -// computeTargetState computes a target state for an edge in the [DFA], and attempt to add the -// computed state and corresponding edge to the [DFA]. -// -// The func returns the computed target [DFA] state for the given input symbol t. -// If this does not lead to a valid [DFA] state, this method -// returns ATNSimulatorError. -func (l *LexerATNSimulator) computeTargetState(input CharStream, s *DFAState, t int) *DFAState { - reach := NewOrderedATNConfigSet() - - // if we don't find an existing DFA state - // Fill reach starting from closure, following t transitions - l.getReachableConfigSet(input, s.configs, reach, t) - - if len(reach.configs) == 0 { // we got nowhere on t from s - if !reach.hasSemanticContext { - // we got nowhere on t, don't panic out l knowledge it'd - // cause a fail-over from DFA later. - l.addDFAEdge(s, t, ATNSimulatorError, nil) - } - // stop when we can't Match any more char - return ATNSimulatorError - } - // Add an edge from s to target DFA found/created for reach - return l.addDFAEdge(s, t, nil, reach) -} - -func (l *LexerATNSimulator) failOrAccept(prevAccept *SimState, input CharStream, reach *ATNConfigSet, t int) int { - if l.prevAccept.dfaState != nil { - lexerActionExecutor := prevAccept.dfaState.lexerActionExecutor - l.accept(input, lexerActionExecutor, l.startIndex, prevAccept.index, prevAccept.line, prevAccept.column) - return prevAccept.dfaState.prediction - } - - // if no accept and EOF is first char, return EOF - if t == TokenEOF && input.Index() == l.startIndex { - return TokenEOF - } - - panic(NewLexerNoViableAltException(l.recog, input, l.startIndex, reach)) -} - -// getReachableConfigSet when given a starting configuration set, figures out all [ATN] configurations -// we can reach upon input t. -// -// Parameter reach is a return parameter. -func (l *LexerATNSimulator) getReachableConfigSet(input CharStream, closure *ATNConfigSet, reach *ATNConfigSet, t int) { - // l is used to Skip processing for configs which have a lower priority - // than a runtimeConfig that already reached an accept state for the same rule - SkipAlt := ATNInvalidAltNumber - - for _, cfg := range closure.configs { - currentAltReachedAcceptState := cfg.GetAlt() == SkipAlt - if currentAltReachedAcceptState && cfg.passedThroughNonGreedyDecision { - continue - } - - if runtimeConfig.lexerATNSimulatorDebug { - - fmt.Printf("testing %s at %s\n", l.GetTokenName(t), cfg.String()) - } - - for _, trans := range cfg.GetState().GetTransitions() { - target := l.getReachableTarget(trans, t) - if target != nil { - lexerActionExecutor := cfg.lexerActionExecutor - if lexerActionExecutor != nil { - lexerActionExecutor = lexerActionExecutor.fixOffsetBeforeMatch(input.Index() - l.startIndex) - } - treatEOFAsEpsilon := t == TokenEOF - config := NewLexerATNConfig3(cfg, target, lexerActionExecutor) - if l.closure(input, config, reach, - currentAltReachedAcceptState, true, treatEOFAsEpsilon) { - // any remaining configs for l alt have a lower priority - // than the one that just reached an accept state. - SkipAlt = cfg.GetAlt() - } - } - } - } -} - -func (l *LexerATNSimulator) accept(input CharStream, lexerActionExecutor *LexerActionExecutor, startIndex, index, line, charPos int) { - if runtimeConfig.lexerATNSimulatorDebug { - fmt.Printf("ACTION %v\n", lexerActionExecutor) - } - // seek to after last char in token - input.Seek(index) - l.Line = line - l.CharPositionInLine = charPos - if lexerActionExecutor != nil && l.recog != nil { - lexerActionExecutor.execute(l.recog, input, startIndex) - } -} - -func (l *LexerATNSimulator) getReachableTarget(trans Transition, t int) ATNState { - if trans.Matches(t, 0, LexerMaxCharValue) { - return trans.getTarget() - } - - return nil -} - -func (l *LexerATNSimulator) computeStartState(input CharStream, p ATNState) *ATNConfigSet { - configs := NewOrderedATNConfigSet() - for i := 0; i < len(p.GetTransitions()); i++ { - target := p.GetTransitions()[i].getTarget() - cfg := NewLexerATNConfig6(target, i+1, BasePredictionContextEMPTY) - l.closure(input, cfg, configs, false, false, false) - } - - return configs -} - -// closure since the alternatives within any lexer decision are ordered by -// preference, this method stops pursuing the closure as soon as an accept -// state is reached. After the first accept state is reached by depth-first -// search from runtimeConfig, all other (potentially reachable) states for -// this rule would have a lower priority. -// -// The func returns true if an accept state is reached. -func (l *LexerATNSimulator) closure(input CharStream, config *ATNConfig, configs *ATNConfigSet, - currentAltReachedAcceptState, speculative, treatEOFAsEpsilon bool) bool { - - if runtimeConfig.lexerATNSimulatorDebug { - fmt.Println("closure(" + config.String() + ")") - } - - _, ok := config.state.(*RuleStopState) - if ok { - - if runtimeConfig.lexerATNSimulatorDebug { - if l.recog != nil { - fmt.Printf("closure at %s rule stop %s\n", l.recog.GetRuleNames()[config.state.GetRuleIndex()], config) - } else { - fmt.Printf("closure at rule stop %s\n", config) - } - } - - if config.context == nil || config.context.hasEmptyPath() { - if config.context == nil || config.context.isEmpty() { - configs.Add(config, nil) - return true - } - - configs.Add(NewLexerATNConfig2(config, config.state, BasePredictionContextEMPTY), nil) - currentAltReachedAcceptState = true - } - if config.context != nil && !config.context.isEmpty() { - for i := 0; i < config.context.length(); i++ { - if config.context.getReturnState(i) != BasePredictionContextEmptyReturnState { - newContext := config.context.GetParent(i) // "pop" return state - returnState := l.atn.states[config.context.getReturnState(i)] - cfg := NewLexerATNConfig2(config, returnState, newContext) - currentAltReachedAcceptState = l.closure(input, cfg, configs, currentAltReachedAcceptState, speculative, treatEOFAsEpsilon) - } - } - } - return currentAltReachedAcceptState - } - // optimization - if !config.state.GetEpsilonOnlyTransitions() { - if !currentAltReachedAcceptState || !config.passedThroughNonGreedyDecision { - configs.Add(config, nil) - } - } - for j := 0; j < len(config.state.GetTransitions()); j++ { - trans := config.state.GetTransitions()[j] - cfg := l.getEpsilonTarget(input, config, trans, configs, speculative, treatEOFAsEpsilon) - if cfg != nil { - currentAltReachedAcceptState = l.closure(input, cfg, configs, - currentAltReachedAcceptState, speculative, treatEOFAsEpsilon) - } - } - return currentAltReachedAcceptState -} - -// side-effect: can alter configs.hasSemanticContext -func (l *LexerATNSimulator) getEpsilonTarget(input CharStream, config *ATNConfig, trans Transition, - configs *ATNConfigSet, speculative, treatEOFAsEpsilon bool) *ATNConfig { - - var cfg *ATNConfig - - if trans.getSerializationType() == TransitionRULE { - - rt := trans.(*RuleTransition) - newContext := SingletonBasePredictionContextCreate(config.context, rt.followState.GetStateNumber()) - cfg = NewLexerATNConfig2(config, trans.getTarget(), newContext) - - } else if trans.getSerializationType() == TransitionPRECEDENCE { - panic("Precedence predicates are not supported in lexers.") - } else if trans.getSerializationType() == TransitionPREDICATE { - // Track traversing semantic predicates. If we traverse, - // we cannot add a DFA state for l "reach" computation - // because the DFA would not test the predicate again in the - // future. Rather than creating collections of semantic predicates - // like v3 and testing them on prediction, v4 will test them on the - // fly all the time using the ATN not the DFA. This is slower but - // semantically it's not used that often. One of the key elements to - // l predicate mechanism is not adding DFA states that see - // predicates immediately afterwards in the ATN. For example, - - // a : ID {p1}? | ID {p2}? - - // should create the start state for rule 'a' (to save start state - // competition), but should not create target of ID state. The - // collection of ATN states the following ID references includes - // states reached by traversing predicates. Since l is when we - // test them, we cannot cash the DFA state target of ID. - - pt := trans.(*PredicateTransition) - - if runtimeConfig.lexerATNSimulatorDebug { - fmt.Println("EVAL rule " + strconv.Itoa(trans.(*PredicateTransition).ruleIndex) + ":" + strconv.Itoa(pt.predIndex)) - } - configs.hasSemanticContext = true - if l.evaluatePredicate(input, pt.ruleIndex, pt.predIndex, speculative) { - cfg = NewLexerATNConfig4(config, trans.getTarget()) - } - } else if trans.getSerializationType() == TransitionACTION { - if config.context == nil || config.context.hasEmptyPath() { - // execute actions anywhere in the start rule for a token. - // - // TODO: if the entry rule is invoked recursively, some - // actions may be executed during the recursive call. The - // problem can appear when hasEmptyPath() is true but - // isEmpty() is false. In this case, the config needs to be - // split into two contexts - one with just the empty path - // and another with everything but the empty path. - // Unfortunately, the current algorithm does not allow - // getEpsilonTarget to return two configurations, so - // additional modifications are needed before we can support - // the split operation. - lexerActionExecutor := LexerActionExecutorappend(config.lexerActionExecutor, l.atn.lexerActions[trans.(*ActionTransition).actionIndex]) - cfg = NewLexerATNConfig3(config, trans.getTarget(), lexerActionExecutor) - } else { - // ignore actions in referenced rules - cfg = NewLexerATNConfig4(config, trans.getTarget()) - } - } else if trans.getSerializationType() == TransitionEPSILON { - cfg = NewLexerATNConfig4(config, trans.getTarget()) - } else if trans.getSerializationType() == TransitionATOM || - trans.getSerializationType() == TransitionRANGE || - trans.getSerializationType() == TransitionSET { - if treatEOFAsEpsilon { - if trans.Matches(TokenEOF, 0, LexerMaxCharValue) { - cfg = NewLexerATNConfig4(config, trans.getTarget()) - } - } - } - return cfg -} - -// evaluatePredicate eEvaluates a predicate specified in the lexer. -// -// If speculative is true, this method was called before -// [consume] for the Matched character. This method should call -// [consume] before evaluating the predicate to ensure position -// sensitive values, including [GetText], [GetLine], -// and [GetColumn], properly reflect the current -// lexer state. This method should restore input and the simulator -// to the original state before returning, i.e. undo the actions made by the -// call to [Consume]. -// -// The func returns true if the specified predicate evaluates to true. -func (l *LexerATNSimulator) evaluatePredicate(input CharStream, ruleIndex, predIndex int, speculative bool) bool { - // assume true if no recognizer was provided - if l.recog == nil { - return true - } - if !speculative { - return l.recog.Sempred(nil, ruleIndex, predIndex) - } - savedcolumn := l.CharPositionInLine - savedLine := l.Line - index := input.Index() - marker := input.Mark() - - defer func() { - l.CharPositionInLine = savedcolumn - l.Line = savedLine - input.Seek(index) - input.Release(marker) - }() - - l.Consume(input) - return l.recog.Sempred(nil, ruleIndex, predIndex) -} - -func (l *LexerATNSimulator) captureSimState(settings *SimState, input CharStream, dfaState *DFAState) { - settings.index = input.Index() - settings.line = l.Line - settings.column = l.CharPositionInLine - settings.dfaState = dfaState -} - -func (l *LexerATNSimulator) addDFAEdge(from *DFAState, tk int, to *DFAState, cfgs *ATNConfigSet) *DFAState { - if to == nil && cfgs != nil { - // leading to l call, ATNConfigSet.hasSemanticContext is used as a - // marker indicating dynamic predicate evaluation makes l edge - // dependent on the specific input sequence, so the static edge in the - // DFA should be omitted. The target DFAState is still created since - // execATN has the ability to reSynchronize with the DFA state cache - // following the predicate evaluation step. - // - // TJP notes: next time through the DFA, we see a pred again and eval. - // If that gets us to a previously created (but dangling) DFA - // state, we can continue in pure DFA mode from there. - // - suppressEdge := cfgs.hasSemanticContext - cfgs.hasSemanticContext = false - to = l.addDFAState(cfgs, true) - - if suppressEdge { - return to - } - } - // add the edge - if tk < LexerATNSimulatorMinDFAEdge || tk > LexerATNSimulatorMaxDFAEdge { - // Only track edges within the DFA bounds - return to - } - if runtimeConfig.lexerATNSimulatorDebug { - fmt.Println("EDGE " + from.String() + " -> " + to.String() + " upon " + strconv.Itoa(tk)) - } - l.atn.edgeMu.Lock() - defer l.atn.edgeMu.Unlock() - if from.getEdges() == nil { - // make room for tokens 1..n and -1 masquerading as index 0 - from.setEdges(make([]*DFAState, LexerATNSimulatorMaxDFAEdge-LexerATNSimulatorMinDFAEdge+1)) - } - from.setIthEdge(tk-LexerATNSimulatorMinDFAEdge, to) // connect - - return to -} - -// Add a NewDFA state if there isn't one with l set of -// configurations already. This method also detects the first -// configuration containing an ATN rule stop state. Later, when -// traversing the DFA, we will know which rule to accept. -func (l *LexerATNSimulator) addDFAState(configs *ATNConfigSet, suppressEdge bool) *DFAState { - - proposed := NewDFAState(-1, configs) - var firstConfigWithRuleStopState *ATNConfig - - for _, cfg := range configs.configs { - _, ok := cfg.GetState().(*RuleStopState) - - if ok { - firstConfigWithRuleStopState = cfg - break - } - } - if firstConfigWithRuleStopState != nil { - proposed.isAcceptState = true - proposed.lexerActionExecutor = firstConfigWithRuleStopState.lexerActionExecutor - proposed.setPrediction(l.atn.ruleToTokenType[firstConfigWithRuleStopState.GetState().GetRuleIndex()]) - } - dfa := l.decisionToDFA[l.mode] - - l.atn.stateMu.Lock() - defer l.atn.stateMu.Unlock() - existing, present := dfa.Get(proposed) - if present { - - // This state was already present, so just return it. - // - proposed = existing - } else { - - // We need to add the new state - // - proposed.stateNumber = dfa.Len() - configs.readOnly = true - configs.configLookup = nil // Not needed now - proposed.configs = configs - dfa.Put(proposed) - } - if !suppressEdge { - dfa.setS0(proposed) - } - return proposed -} - -func (l *LexerATNSimulator) getDFA(mode int) *DFA { - return l.decisionToDFA[mode] -} - -// GetText returns the text [Match]ed so far for the current token. -func (l *LexerATNSimulator) GetText(input CharStream) string { - // index is first lookahead char, don't include. - return input.GetTextFromInterval(NewInterval(l.startIndex, input.Index()-1)) -} - -func (l *LexerATNSimulator) Consume(input CharStream) { - curChar := input.LA(1) - if curChar == int('\n') { - l.Line++ - l.CharPositionInLine = 0 - } else { - l.CharPositionInLine++ - } - input.Consume() -} - -func (l *LexerATNSimulator) GetCharPositionInLine() int { - return l.CharPositionInLine -} - -func (l *LexerATNSimulator) GetLine() int { - return l.Line -} - -func (l *LexerATNSimulator) GetTokenName(tt int) string { - if tt == -1 { - return "EOF" - } - - var sb strings.Builder - sb.Grow(6) - sb.WriteByte('\'') - sb.WriteRune(rune(tt)) - sb.WriteByte('\'') - - return sb.String() -} - -func resetSimState(sim *SimState) { - sim.index = -1 - sim.line = 0 - sim.column = -1 - sim.dfaState = nil -} - -type SimState struct { - index int - line int - column int - dfaState *DFAState -} - -func NewSimState() *SimState { - s := new(SimState) - resetSimState(s) - return s -} - -func (s *SimState) reset() { - resetSimState(s) -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/ll1_analyzer.go b/vendor/github.com/antlr4-go/antlr/v4/ll1_analyzer.go deleted file mode 100644 index 4955ac876..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/ll1_analyzer.go +++ /dev/null @@ -1,218 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -type LL1Analyzer struct { - atn *ATN -} - -func NewLL1Analyzer(atn *ATN) *LL1Analyzer { - la := new(LL1Analyzer) - la.atn = atn - return la -} - -const ( - // LL1AnalyzerHitPred is a special value added to the lookahead sets to indicate that we hit - // a predicate during analysis if - // - // seeThruPreds==false - LL1AnalyzerHitPred = TokenInvalidType -) - -// * -// Calculates the SLL(1) expected lookahead set for each outgoing transition -// of an {@link ATNState}. The returned array has one element for each -// outgoing transition in {@code s}. If the closure from transition -// i leads to a semantic predicate before Matching a symbol, the -// element at index i of the result will be {@code nil}. -// -// @param s the ATN state -// @return the expected symbols for each outgoing transition of {@code s}. -func (la *LL1Analyzer) getDecisionLookahead(s ATNState) []*IntervalSet { - if s == nil { - return nil - } - count := len(s.GetTransitions()) - look := make([]*IntervalSet, count) - for alt := 0; alt < count; alt++ { - - look[alt] = NewIntervalSet() - lookBusy := NewJStore[*ATNConfig, Comparator[*ATNConfig]](aConfEqInst, ClosureBusyCollection, "LL1Analyzer.getDecisionLookahead for lookBusy") - la.look1(s.GetTransitions()[alt].getTarget(), nil, BasePredictionContextEMPTY, look[alt], lookBusy, NewBitSet(), false, false) - - // Wipe out lookahead for la alternative if we found nothing, - // or we had a predicate when we !seeThruPreds - if look[alt].length() == 0 || look[alt].contains(LL1AnalyzerHitPred) { - look[alt] = nil - } - } - return look -} - -// Look computes the set of tokens that can follow s in the [ATN] in the -// specified ctx. -// -// If ctx is nil and the end of the rule containing -// s is reached, [EPSILON] is added to the result set. -// -// If ctx is not nil and the end of the outermost rule is -// reached, [EOF] is added to the result set. -// -// Parameter s the ATN state, and stopState is the ATN state to stop at. This can be a -// [BlockEndState] to detect epsilon paths through a closure. -// -// Parameter ctx is the complete parser context, or nil if the context -// should be ignored -// -// The func returns the set of tokens that can follow s in the [ATN] in the -// specified ctx. -func (la *LL1Analyzer) Look(s, stopState ATNState, ctx RuleContext) *IntervalSet { - r := NewIntervalSet() - var lookContext *PredictionContext - if ctx != nil { - lookContext = predictionContextFromRuleContext(s.GetATN(), ctx) - } - la.look1(s, stopState, lookContext, r, NewJStore[*ATNConfig, Comparator[*ATNConfig]](aConfEqInst, ClosureBusyCollection, "LL1Analyzer.Look for la.look1()"), - NewBitSet(), true, true) - return r -} - -//* -// Compute set of tokens that can follow {@code s} in the ATN in the -// specified {@code ctx}. -// -//

If {@code ctx} is {@code nil} and {@code stopState} or the end of the -// rule containing {@code s} is reached, {@link Token//EPSILON} is added to -// the result set. If {@code ctx} is not {@code nil} and {@code addEOF} is -// {@code true} and {@code stopState} or the end of the outermost rule is -// reached, {@link Token//EOF} is added to the result set.

-// -// @param s the ATN state. -// @param stopState the ATN state to stop at. This can be a -// {@link BlockEndState} to detect epsilon paths through a closure. -// @param ctx The outer context, or {@code nil} if the outer context should -// not be used. -// @param look The result lookahead set. -// @param lookBusy A set used for preventing epsilon closures in the ATN -// from causing a stack overflow. Outside code should pass -// {@code NewSet} for la argument. -// @param calledRuleStack A set used for preventing left recursion in the -// ATN from causing a stack overflow. Outside code should pass -// {@code NewBitSet()} for la argument. -// @param seeThruPreds {@code true} to true semantic predicates as -// implicitly {@code true} and "see through them", otherwise {@code false} -// to treat semantic predicates as opaque and add {@link //HitPred} to the -// result if one is encountered. -// @param addEOF Add {@link Token//EOF} to the result if the end of the -// outermost context is reached. This parameter has no effect if {@code ctx} -// is {@code nil}. - -func (la *LL1Analyzer) look2(_, stopState ATNState, ctx *PredictionContext, look *IntervalSet, lookBusy *JStore[*ATNConfig, Comparator[*ATNConfig]], - calledRuleStack *BitSet, seeThruPreds, addEOF bool, i int) { - - returnState := la.atn.states[ctx.getReturnState(i)] - la.look1(returnState, stopState, ctx.GetParent(i), look, lookBusy, calledRuleStack, seeThruPreds, addEOF) - -} - -func (la *LL1Analyzer) look1(s, stopState ATNState, ctx *PredictionContext, look *IntervalSet, lookBusy *JStore[*ATNConfig, Comparator[*ATNConfig]], calledRuleStack *BitSet, seeThruPreds, addEOF bool) { - - c := NewATNConfig6(s, 0, ctx) - - if lookBusy.Contains(c) { - return - } - - _, present := lookBusy.Put(c) - if present { - return - - } - if s == stopState { - if ctx == nil { - look.addOne(TokenEpsilon) - return - } else if ctx.isEmpty() && addEOF { - look.addOne(TokenEOF) - return - } - } - - _, ok := s.(*RuleStopState) - - if ok { - if ctx == nil { - look.addOne(TokenEpsilon) - return - } else if ctx.isEmpty() && addEOF { - look.addOne(TokenEOF) - return - } - - if ctx.pcType != PredictionContextEmpty { - removed := calledRuleStack.contains(s.GetRuleIndex()) - defer func() { - if removed { - calledRuleStack.add(s.GetRuleIndex()) - } - }() - calledRuleStack.remove(s.GetRuleIndex()) - // run thru all possible stack tops in ctx - for i := 0; i < ctx.length(); i++ { - returnState := la.atn.states[ctx.getReturnState(i)] - la.look2(returnState, stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF, i) - } - return - } - } - - n := len(s.GetTransitions()) - - for i := 0; i < n; i++ { - t := s.GetTransitions()[i] - - if t1, ok := t.(*RuleTransition); ok { - if calledRuleStack.contains(t1.getTarget().GetRuleIndex()) { - continue - } - - newContext := SingletonBasePredictionContextCreate(ctx, t1.followState.GetStateNumber()) - la.look3(stopState, newContext, look, lookBusy, calledRuleStack, seeThruPreds, addEOF, t1) - } else if t2, ok := t.(AbstractPredicateTransition); ok { - if seeThruPreds { - la.look1(t2.getTarget(), stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF) - } else { - look.addOne(LL1AnalyzerHitPred) - } - } else if t.getIsEpsilon() { - la.look1(t.getTarget(), stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF) - } else if _, ok := t.(*WildcardTransition); ok { - look.addRange(TokenMinUserTokenType, la.atn.maxTokenType) - } else { - set := t.getLabel() - if set != nil { - if _, ok := t.(*NotSetTransition); ok { - set = set.complement(TokenMinUserTokenType, la.atn.maxTokenType) - } - look.addSet(set) - } - } - } -} - -func (la *LL1Analyzer) look3(stopState ATNState, ctx *PredictionContext, look *IntervalSet, lookBusy *JStore[*ATNConfig, Comparator[*ATNConfig]], - calledRuleStack *BitSet, seeThruPreds, addEOF bool, t1 *RuleTransition) { - - newContext := SingletonBasePredictionContextCreate(ctx, t1.followState.GetStateNumber()) - - defer func() { - calledRuleStack.remove(t1.getTarget().GetRuleIndex()) - }() - - calledRuleStack.add(t1.getTarget().GetRuleIndex()) - la.look1(t1.getTarget(), stopState, newContext, look, lookBusy, calledRuleStack, seeThruPreds, addEOF) - -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/nostatistics.go b/vendor/github.com/antlr4-go/antlr/v4/nostatistics.go deleted file mode 100644 index 923c7b52c..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/nostatistics.go +++ /dev/null @@ -1,47 +0,0 @@ -//go:build !antlr.stats - -package antlr - -// This file is compiled when the build configuration antlr.stats is not enabled. -// which then allows the compiler to optimize out all the code that is not used. -const collectStats = false - -// goRunStats is a dummy struct used when build configuration antlr.stats is not enabled. -type goRunStats struct { -} - -var Statistics = &goRunStats{} - -func (s *goRunStats) AddJStatRec(_ *JStatRec) { - // Do nothing - compiler will optimize this out (hopefully) -} - -func (s *goRunStats) CollectionAnomalies() { - // Do nothing - compiler will optimize this out (hopefully) -} - -func (s *goRunStats) Reset() { - // Do nothing - compiler will optimize this out (hopefully) -} - -func (s *goRunStats) Report(dir string, prefix string) error { - // Do nothing - compiler will optimize this out (hopefully) - return nil -} - -func (s *goRunStats) Analyze() { - // Do nothing - compiler will optimize this out (hopefully) -} - -type statsOption func(*goRunStats) error - -func (s *goRunStats) Configure(options ...statsOption) error { - // Do nothing - compiler will optimize this out (hopefully) - return nil -} - -func WithTopN(topN int) statsOption { - return func(s *goRunStats) error { - return nil - } -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/parser.go b/vendor/github.com/antlr4-go/antlr/v4/parser.go deleted file mode 100644 index fb57ac15d..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/parser.go +++ /dev/null @@ -1,700 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import ( - "fmt" - "strconv" -) - -type Parser interface { - Recognizer - - GetInterpreter() *ParserATNSimulator - - GetTokenStream() TokenStream - GetTokenFactory() TokenFactory - GetParserRuleContext() ParserRuleContext - SetParserRuleContext(ParserRuleContext) - Consume() Token - GetParseListeners() []ParseTreeListener - - GetErrorHandler() ErrorStrategy - SetErrorHandler(ErrorStrategy) - GetInputStream() IntStream - GetCurrentToken() Token - GetExpectedTokens() *IntervalSet - NotifyErrorListeners(string, Token, RecognitionException) - IsExpectedToken(int) bool - GetPrecedence() int - GetRuleInvocationStack(ParserRuleContext) []string -} - -type BaseParser struct { - *BaseRecognizer - - Interpreter *ParserATNSimulator - BuildParseTrees bool - - input TokenStream - errHandler ErrorStrategy - precedenceStack IntStack - ctx ParserRuleContext - - tracer *TraceListener - parseListeners []ParseTreeListener - _SyntaxErrors int -} - -// NewBaseParser contains all the parsing support code to embed in parsers. Essentially most of it is error -// recovery stuff. -// -//goland:noinspection GoUnusedExportedFunction -func NewBaseParser(input TokenStream) *BaseParser { - - p := new(BaseParser) - - p.BaseRecognizer = NewBaseRecognizer() - - // The input stream. - p.input = nil - - // The error handling strategy for the parser. The default value is a new - // instance of {@link DefaultErrorStrategy}. - p.errHandler = NewDefaultErrorStrategy() - p.precedenceStack = make([]int, 0) - p.precedenceStack.Push(0) - - // The ParserRuleContext object for the currently executing rule. - // p.is always non-nil during the parsing process. - p.ctx = nil - - // Specifies whether the parser should construct a parse tree during - // the parsing process. The default value is {@code true}. - p.BuildParseTrees = true - - // When setTrace(true) is called, a reference to the - // TraceListener is stored here, so it can be easily removed in a - // later call to setTrace(false). The listener itself is - // implemented as a parser listener so p.field is not directly used by - // other parser methods. - p.tracer = nil - - // The list of ParseTreeListener listeners registered to receive - // events during the parse. - p.parseListeners = nil - - // The number of syntax errors Reported during parsing. p.value is - // incremented each time NotifyErrorListeners is called. - p._SyntaxErrors = 0 - p.SetInputStream(input) - - return p -} - -// This field maps from the serialized ATN string to the deserialized [ATN] with -// bypass alternatives. -// -// [ATNDeserializationOptions.isGenerateRuleBypassTransitions] -// -//goland:noinspection GoUnusedGlobalVariable -var bypassAltsAtnCache = make(map[string]int) - -// reset the parser's state// -func (p *BaseParser) reset() { - if p.input != nil { - p.input.Seek(0) - } - p.errHandler.reset(p) - p.ctx = nil - p._SyntaxErrors = 0 - p.SetTrace(nil) - p.precedenceStack = make([]int, 0) - p.precedenceStack.Push(0) - if p.Interpreter != nil { - p.Interpreter.reset() - } -} - -func (p *BaseParser) GetErrorHandler() ErrorStrategy { - return p.errHandler -} - -func (p *BaseParser) SetErrorHandler(e ErrorStrategy) { - p.errHandler = e -} - -// Match current input symbol against {@code ttype}. If the symbol type -// Matches, {@link ANTLRErrorStrategy//ReportMatch} and {@link //consume} are -// called to complete the Match process. -// -//

If the symbol type does not Match, -// {@link ANTLRErrorStrategy//recoverInline} is called on the current error -// strategy to attempt recovery. If {@link //getBuildParseTree} is -// {@code true} and the token index of the symbol returned by -// {@link ANTLRErrorStrategy//recoverInline} is -1, the symbol is added to -// the parse tree by calling {@link ParserRuleContext//addErrorNode}.

-// -// @param ttype the token type to Match -// @return the Matched symbol -// @panics RecognitionException if the current input symbol did not Match -// {@code ttype} and the error strategy could not recover from the -// mismatched symbol - -func (p *BaseParser) Match(ttype int) Token { - - t := p.GetCurrentToken() - - if t.GetTokenType() == ttype { - p.errHandler.ReportMatch(p) - p.Consume() - } else { - t = p.errHandler.RecoverInline(p) - if p.HasError() { - return nil - } - if p.BuildParseTrees && t.GetTokenIndex() == -1 { - - // we must have conjured up a new token during single token - // insertion if it's not the current symbol - p.ctx.AddErrorNode(t) - } - } - - return t -} - -// Match current input symbol as a wildcard. If the symbol type Matches -// (i.e. has a value greater than 0), {@link ANTLRErrorStrategy//ReportMatch} -// and {@link //consume} are called to complete the Match process. -// -//

If the symbol type does not Match, -// {@link ANTLRErrorStrategy//recoverInline} is called on the current error -// strategy to attempt recovery. If {@link //getBuildParseTree} is -// {@code true} and the token index of the symbol returned by -// {@link ANTLRErrorStrategy//recoverInline} is -1, the symbol is added to -// the parse tree by calling {@link ParserRuleContext//addErrorNode}.

-// -// @return the Matched symbol -// @panics RecognitionException if the current input symbol did not Match -// a wildcard and the error strategy could not recover from the mismatched -// symbol - -func (p *BaseParser) MatchWildcard() Token { - t := p.GetCurrentToken() - if t.GetTokenType() > 0 { - p.errHandler.ReportMatch(p) - p.Consume() - } else { - t = p.errHandler.RecoverInline(p) - if p.BuildParseTrees && t.GetTokenIndex() == -1 { - // we must have conjured up a new token during single token - // insertion if it's not the current symbol - p.ctx.AddErrorNode(t) - } - } - return t -} - -func (p *BaseParser) GetParserRuleContext() ParserRuleContext { - return p.ctx -} - -func (p *BaseParser) SetParserRuleContext(v ParserRuleContext) { - p.ctx = v -} - -func (p *BaseParser) GetParseListeners() []ParseTreeListener { - if p.parseListeners == nil { - return make([]ParseTreeListener, 0) - } - return p.parseListeners -} - -// AddParseListener registers listener to receive events during the parsing process. -// -// To support output-preserving grammar transformations (including but not -// limited to left-recursion removal, automated left-factoring, and -// optimized code generation), calls to listener methods during the parse -// may differ substantially from calls made by -// [ParseTreeWalker.DEFAULT] used after the parse is complete. In -// particular, rule entry and exit events may occur in a different order -// during the parse than after the parser. In addition, calls to certain -// rule entry methods may be omitted. -// -// With the following specific exceptions, calls to listener events are -// deterministic, i.e. for identical input the calls to listener -// methods will be the same. -// -// - Alterations to the grammar used to generate code may change the -// behavior of the listener calls. -// - Alterations to the command line options passed to ANTLR 4 when -// generating the parser may change the behavior of the listener calls. -// - Changing the version of the ANTLR Tool used to generate the parser -// may change the behavior of the listener calls. -func (p *BaseParser) AddParseListener(listener ParseTreeListener) { - if listener == nil { - panic("listener") - } - if p.parseListeners == nil { - p.parseListeners = make([]ParseTreeListener, 0) - } - p.parseListeners = append(p.parseListeners, listener) -} - -// RemoveParseListener removes listener from the list of parse listeners. -// -// If listener is nil or has not been added as a parse -// listener, this func does nothing. -func (p *BaseParser) RemoveParseListener(listener ParseTreeListener) { - - if p.parseListeners != nil { - - idx := -1 - for i, v := range p.parseListeners { - if v == listener { - idx = i - break - } - } - - if idx == -1 { - return - } - - // remove the listener from the slice - p.parseListeners = append(p.parseListeners[0:idx], p.parseListeners[idx+1:]...) - - if len(p.parseListeners) == 0 { - p.parseListeners = nil - } - } -} - -// Remove all parse listeners. -func (p *BaseParser) removeParseListeners() { - p.parseListeners = nil -} - -// TriggerEnterRuleEvent notifies all parse listeners of an enter rule event. -func (p *BaseParser) TriggerEnterRuleEvent() { - if p.parseListeners != nil { - ctx := p.ctx - for _, listener := range p.parseListeners { - listener.EnterEveryRule(ctx) - ctx.EnterRule(listener) - } - } -} - -// TriggerExitRuleEvent notifies any parse listeners of an exit rule event. -func (p *BaseParser) TriggerExitRuleEvent() { - if p.parseListeners != nil { - // reverse order walk of listeners - ctx := p.ctx - l := len(p.parseListeners) - 1 - - for i := range p.parseListeners { - listener := p.parseListeners[l-i] - ctx.ExitRule(listener) - listener.ExitEveryRule(ctx) - } - } -} - -func (p *BaseParser) GetInterpreter() *ParserATNSimulator { - return p.Interpreter -} - -func (p *BaseParser) GetATN() *ATN { - return p.Interpreter.atn -} - -func (p *BaseParser) GetTokenFactory() TokenFactory { - return p.input.GetTokenSource().GetTokenFactory() -} - -// setTokenFactory is used to tell our token source and error strategy about a new way to create tokens. -func (p *BaseParser) setTokenFactory(factory TokenFactory) { - p.input.GetTokenSource().setTokenFactory(factory) -} - -// GetATNWithBypassAlts - the ATN with bypass alternatives is expensive to create, so we create it -// lazily. -func (p *BaseParser) GetATNWithBypassAlts() { - - // TODO - Implement this? - panic("Not implemented!") - - // serializedAtn := p.getSerializedATN() - // if (serializedAtn == nil) { - // panic("The current parser does not support an ATN with bypass alternatives.") - // } - // result := p.bypassAltsAtnCache[serializedAtn] - // if (result == nil) { - // deserializationOptions := NewATNDeserializationOptions(nil) - // deserializationOptions.generateRuleBypassTransitions = true - // result = NewATNDeserializer(deserializationOptions).deserialize(serializedAtn) - // p.bypassAltsAtnCache[serializedAtn] = result - // } - // return result -} - -// The preferred method of getting a tree pattern. For example, here's a -// sample use: -// -//
-// ParseTree t = parser.expr()
-// ParseTreePattern p = parser.compileParseTreePattern("<ID>+0",
-// MyParser.RULE_expr)
-// ParseTreeMatch m = p.Match(t)
-// String id = m.Get("ID")
-// 
- -//goland:noinspection GoUnusedParameter -func (p *BaseParser) compileParseTreePattern(pattern, patternRuleIndex, lexer Lexer) { - - panic("NewParseTreePatternMatcher not implemented!") - // - // if (lexer == nil) { - // if (p.GetTokenStream() != nil) { - // tokenSource := p.GetTokenStream().GetTokenSource() - // if _, ok := tokenSource.(ILexer); ok { - // lexer = tokenSource - // } - // } - // } - // if (lexer == nil) { - // panic("Parser can't discover a lexer to use") - // } - - // m := NewParseTreePatternMatcher(lexer, p) - // return m.compile(pattern, patternRuleIndex) -} - -func (p *BaseParser) GetInputStream() IntStream { - return p.GetTokenStream() -} - -func (p *BaseParser) SetInputStream(input TokenStream) { - p.SetTokenStream(input) -} - -func (p *BaseParser) GetTokenStream() TokenStream { - return p.input -} - -// SetTokenStream installs input as the token stream and resets the parser. -func (p *BaseParser) SetTokenStream(input TokenStream) { - p.input = nil - p.reset() - p.input = input -} - -// GetCurrentToken returns the current token at LT(1). -// -// [Match] needs to return the current input symbol, which gets put -// into the label for the associated token ref e.g., x=ID. -func (p *BaseParser) GetCurrentToken() Token { - return p.input.LT(1) -} - -func (p *BaseParser) NotifyErrorListeners(msg string, offendingToken Token, err RecognitionException) { - if offendingToken == nil { - offendingToken = p.GetCurrentToken() - } - p._SyntaxErrors++ - line := offendingToken.GetLine() - column := offendingToken.GetColumn() - listener := p.GetErrorListenerDispatch() - listener.SyntaxError(p, offendingToken, line, column, msg, err) -} - -func (p *BaseParser) Consume() Token { - o := p.GetCurrentToken() - if o.GetTokenType() != TokenEOF { - p.GetInputStream().Consume() - } - hasListener := p.parseListeners != nil && len(p.parseListeners) > 0 - if p.BuildParseTrees || hasListener { - if p.errHandler.InErrorRecoveryMode(p) { - node := p.ctx.AddErrorNode(o) - if p.parseListeners != nil { - for _, l := range p.parseListeners { - l.VisitErrorNode(node) - } - } - - } else { - node := p.ctx.AddTokenNode(o) - if p.parseListeners != nil { - for _, l := range p.parseListeners { - l.VisitTerminal(node) - } - } - } - // node.invokingState = p.state - } - - return o -} - -func (p *BaseParser) addContextToParseTree() { - // add current context to parent if we have a parent - if p.ctx.GetParent() != nil { - p.ctx.GetParent().(ParserRuleContext).AddChild(p.ctx) - } -} - -func (p *BaseParser) EnterRule(localctx ParserRuleContext, state, _ int) { - p.SetState(state) - p.ctx = localctx - p.ctx.SetStart(p.input.LT(1)) - if p.BuildParseTrees { - p.addContextToParseTree() - } - if p.parseListeners != nil { - p.TriggerEnterRuleEvent() - } -} - -func (p *BaseParser) ExitRule() { - p.ctx.SetStop(p.input.LT(-1)) - // trigger event on ctx, before it reverts to parent - if p.parseListeners != nil { - p.TriggerExitRuleEvent() - } - p.SetState(p.ctx.GetInvokingState()) - if p.ctx.GetParent() != nil { - p.ctx = p.ctx.GetParent().(ParserRuleContext) - } else { - p.ctx = nil - } -} - -func (p *BaseParser) EnterOuterAlt(localctx ParserRuleContext, altNum int) { - localctx.SetAltNumber(altNum) - // if we have a new localctx, make sure we replace existing ctx - // that is previous child of parse tree - if p.BuildParseTrees && p.ctx != localctx { - if p.ctx.GetParent() != nil { - p.ctx.GetParent().(ParserRuleContext).RemoveLastChild() - p.ctx.GetParent().(ParserRuleContext).AddChild(localctx) - } - } - p.ctx = localctx -} - -// Get the precedence level for the top-most precedence rule. -// -// @return The precedence level for the top-most precedence rule, or -1 if -// the parser context is not nested within a precedence rule. - -func (p *BaseParser) GetPrecedence() int { - if len(p.precedenceStack) == 0 { - return -1 - } - - return p.precedenceStack[len(p.precedenceStack)-1] -} - -func (p *BaseParser) EnterRecursionRule(localctx ParserRuleContext, state, _, precedence int) { - p.SetState(state) - p.precedenceStack.Push(precedence) - p.ctx = localctx - p.ctx.SetStart(p.input.LT(1)) - if p.parseListeners != nil { - p.TriggerEnterRuleEvent() // simulates rule entry for - // left-recursive rules - } -} - -// -// Like {@link //EnterRule} but for recursive rules. - -func (p *BaseParser) PushNewRecursionContext(localctx ParserRuleContext, state, _ int) { - previous := p.ctx - previous.SetParent(localctx) - previous.SetInvokingState(state) - previous.SetStop(p.input.LT(-1)) - - p.ctx = localctx - p.ctx.SetStart(previous.GetStart()) - if p.BuildParseTrees { - p.ctx.AddChild(previous) - } - if p.parseListeners != nil { - p.TriggerEnterRuleEvent() // simulates rule entry for - // left-recursive rules - } -} - -func (p *BaseParser) UnrollRecursionContexts(parentCtx ParserRuleContext) { - _, _ = p.precedenceStack.Pop() - p.ctx.SetStop(p.input.LT(-1)) - retCtx := p.ctx // save current ctx (return value) - // unroll so ctx is as it was before call to recursive method - if p.parseListeners != nil { - for p.ctx != parentCtx { - p.TriggerExitRuleEvent() - p.ctx = p.ctx.GetParent().(ParserRuleContext) - } - } else { - p.ctx = parentCtx - } - // hook into tree - retCtx.SetParent(parentCtx) - if p.BuildParseTrees && parentCtx != nil { - // add return ctx into invoking rule's tree - parentCtx.AddChild(retCtx) - } -} - -func (p *BaseParser) GetInvokingContext(ruleIndex int) ParserRuleContext { - ctx := p.ctx - for ctx != nil { - if ctx.GetRuleIndex() == ruleIndex { - return ctx - } - ctx = ctx.GetParent().(ParserRuleContext) - } - return nil -} - -func (p *BaseParser) Precpred(_ RuleContext, precedence int) bool { - return precedence >= p.precedenceStack[len(p.precedenceStack)-1] -} - -//goland:noinspection GoUnusedParameter -func (p *BaseParser) inContext(context ParserRuleContext) bool { - // TODO: useful in parser? - return false -} - -// IsExpectedToken checks whether symbol can follow the current state in the -// {ATN}. The behavior of p.method is equivalent to the following, but is -// implemented such that the complete context-sensitive follow set does not -// need to be explicitly constructed. -// -// return getExpectedTokens().contains(symbol) -func (p *BaseParser) IsExpectedToken(symbol int) bool { - atn := p.Interpreter.atn - ctx := p.ctx - s := atn.states[p.state] - following := atn.NextTokens(s, nil) - if following.contains(symbol) { - return true - } - if !following.contains(TokenEpsilon) { - return false - } - for ctx != nil && ctx.GetInvokingState() >= 0 && following.contains(TokenEpsilon) { - invokingState := atn.states[ctx.GetInvokingState()] - rt := invokingState.GetTransitions()[0] - following = atn.NextTokens(rt.(*RuleTransition).followState, nil) - if following.contains(symbol) { - return true - } - ctx = ctx.GetParent().(ParserRuleContext) - } - if following.contains(TokenEpsilon) && symbol == TokenEOF { - return true - } - - return false -} - -// GetExpectedTokens and returns the set of input symbols which could follow the current parser -// state and context, as given by [GetState] and [GetContext], -// respectively. -func (p *BaseParser) GetExpectedTokens() *IntervalSet { - return p.Interpreter.atn.getExpectedTokens(p.state, p.ctx) -} - -func (p *BaseParser) GetExpectedTokensWithinCurrentRule() *IntervalSet { - atn := p.Interpreter.atn - s := atn.states[p.state] - return atn.NextTokens(s, nil) -} - -// GetRuleIndex get a rule's index (i.e., RULE_ruleName field) or -1 if not found. -func (p *BaseParser) GetRuleIndex(ruleName string) int { - var ruleIndex, ok = p.GetRuleIndexMap()[ruleName] - if ok { - return ruleIndex - } - - return -1 -} - -// GetRuleInvocationStack returns a list of the rule names in your parser instance -// leading up to a call to the current rule. You could override if -// you want more details such as the file/line info of where -// in the ATN a rule is invoked. -func (p *BaseParser) GetRuleInvocationStack(c ParserRuleContext) []string { - if c == nil { - c = p.ctx - } - stack := make([]string, 0) - for c != nil { - // compute what follows who invoked us - ruleIndex := c.GetRuleIndex() - if ruleIndex < 0 { - stack = append(stack, "n/a") - } else { - stack = append(stack, p.GetRuleNames()[ruleIndex]) - } - - vp := c.GetParent() - - if vp == nil { - break - } - - c = vp.(ParserRuleContext) - } - return stack -} - -// GetDFAStrings returns a list of all DFA states used for debugging purposes -func (p *BaseParser) GetDFAStrings() string { - return fmt.Sprint(p.Interpreter.decisionToDFA) -} - -// DumpDFA prints the whole of the DFA for debugging -func (p *BaseParser) DumpDFA() { - seenOne := false - for _, dfa := range p.Interpreter.decisionToDFA { - if dfa.Len() > 0 { - if seenOne { - fmt.Println() - } - fmt.Println("Decision " + strconv.Itoa(dfa.decision) + ":") - fmt.Print(dfa.String(p.LiteralNames, p.SymbolicNames)) - seenOne = true - } - } -} - -func (p *BaseParser) GetSourceName() string { - return p.GrammarFileName -} - -// SetTrace installs a trace listener for the parse. -// -// During a parse it is sometimes useful to listen in on the rule entry and exit -// events as well as token Matches. This is for quick and dirty debugging. -func (p *BaseParser) SetTrace(trace *TraceListener) { - if trace == nil { - p.RemoveParseListener(p.tracer) - p.tracer = nil - } else { - if p.tracer != nil { - p.RemoveParseListener(p.tracer) - } - p.tracer = NewTraceListener(p) - p.AddParseListener(p.tracer) - } -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/parser_atn_simulator.go b/vendor/github.com/antlr4-go/antlr/v4/parser_atn_simulator.go deleted file mode 100644 index ae2869692..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/parser_atn_simulator.go +++ /dev/null @@ -1,1668 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import ( - "fmt" - "strconv" - "strings" -) - -var () - -// ClosureBusy is a store of ATNConfigs and is a tiny abstraction layer over -// a standard JStore so that we can use Lazy instantiation of the JStore, mostly -// to avoid polluting the stats module with a ton of JStore instances with nothing in them. -type ClosureBusy struct { - bMap *JStore[*ATNConfig, Comparator[*ATNConfig]] - desc string -} - -// NewClosureBusy creates a new ClosureBusy instance used to avoid infinite recursion for right-recursive rules -func NewClosureBusy(desc string) *ClosureBusy { - return &ClosureBusy{ - desc: desc, - } -} - -func (c *ClosureBusy) Put(config *ATNConfig) (*ATNConfig, bool) { - if c.bMap == nil { - c.bMap = NewJStore[*ATNConfig, Comparator[*ATNConfig]](aConfEqInst, ClosureBusyCollection, c.desc) - } - return c.bMap.Put(config) -} - -type ParserATNSimulator struct { - BaseATNSimulator - - parser Parser - predictionMode int - input TokenStream - startIndex int - dfa *DFA - mergeCache *JPCMap - outerContext ParserRuleContext -} - -//goland:noinspection GoUnusedExportedFunction -func NewParserATNSimulator(parser Parser, atn *ATN, decisionToDFA []*DFA, sharedContextCache *PredictionContextCache) *ParserATNSimulator { - - p := &ParserATNSimulator{ - BaseATNSimulator: BaseATNSimulator{ - atn: atn, - sharedContextCache: sharedContextCache, - }, - } - - p.parser = parser - p.decisionToDFA = decisionToDFA - // SLL, LL, or LL + exact ambig detection?// - p.predictionMode = PredictionModeLL - // LAME globals to avoid parameters!!!!! I need these down deep in predTransition - p.input = nil - p.startIndex = 0 - p.outerContext = nil - p.dfa = nil - // Each prediction operation uses a cache for merge of prediction contexts. - // Don't keep around as it wastes huge amounts of memory. [JPCMap] - // isn't Synchronized, but we're ok since two threads shouldn't reuse same - // parser/atn-simulator object because it can only handle one input at a time. - // This maps graphs a and b to merged result c. (a,b) -> c. We can avoid - // the merge if we ever see a and b again. Note that (b,a) -> c should - // also be examined during cache lookup. - // - p.mergeCache = nil - - return p -} - -func (p *ParserATNSimulator) GetPredictionMode() int { - return p.predictionMode -} - -func (p *ParserATNSimulator) SetPredictionMode(v int) { - p.predictionMode = v -} - -func (p *ParserATNSimulator) reset() { -} - -//goland:noinspection GoBoolExpressions -func (p *ParserATNSimulator) AdaptivePredict(parser *BaseParser, input TokenStream, decision int, outerContext ParserRuleContext) int { - if runtimeConfig.parserATNSimulatorDebug || runtimeConfig.parserATNSimulatorTraceATNSim { - fmt.Println("adaptivePredict decision " + strconv.Itoa(decision) + - " exec LA(1)==" + p.getLookaheadName(input) + - " line " + strconv.Itoa(input.LT(1).GetLine()) + ":" + - strconv.Itoa(input.LT(1).GetColumn())) - } - p.input = input - p.startIndex = input.Index() - p.outerContext = outerContext - - dfa := p.decisionToDFA[decision] - p.dfa = dfa - m := input.Mark() - index := input.Index() - - defer func() { - p.dfa = nil - p.mergeCache = nil // whack cache after each prediction - // Do not attempt to run a GC now that we're done with the cache as makes the - // GC overhead terrible for badly formed grammars and has little effect on well formed - // grammars. - // I have made some extra effort to try and reduce memory pressure by reusing allocations when - // possible. However, it can only have a limited effect. The real solution is to encourage grammar - // authors to think more carefully about their grammar and to use the new antlr.stats tag to inspect - // what is happening at runtime, along with using the error listener to report ambiguities. - - input.Seek(index) - input.Release(m) - }() - - // Now we are certain to have a specific decision's DFA - // But, do we still need an initial state? - var s0 *DFAState - p.atn.stateMu.RLock() - if dfa.getPrecedenceDfa() { - p.atn.edgeMu.RLock() - // the start state for a precedence DFA depends on the current - // parser precedence, and is provided by a DFA method. - s0 = dfa.getPrecedenceStartState(p.parser.GetPrecedence()) - p.atn.edgeMu.RUnlock() - } else { - // the start state for a "regular" DFA is just s0 - s0 = dfa.getS0() - } - p.atn.stateMu.RUnlock() - - if s0 == nil { - if outerContext == nil { - outerContext = ParserRuleContextEmpty - } - if runtimeConfig.parserATNSimulatorDebug { - fmt.Println("predictATN decision " + strconv.Itoa(dfa.decision) + - " exec LA(1)==" + p.getLookaheadName(input) + - ", outerContext=" + outerContext.String(p.parser.GetRuleNames(), nil)) - } - fullCtx := false - s0Closure := p.computeStartState(dfa.atnStartState, ParserRuleContextEmpty, fullCtx) - - p.atn.stateMu.Lock() - if dfa.getPrecedenceDfa() { - // If p is a precedence DFA, we use applyPrecedenceFilter - // to convert the computed start state to a precedence start - // state. We then use DFA.setPrecedenceStartState to set the - // appropriate start state for the precedence level rather - // than simply setting DFA.s0. - // - dfa.s0.configs = s0Closure - s0Closure = p.applyPrecedenceFilter(s0Closure) - s0 = p.addDFAState(dfa, NewDFAState(-1, s0Closure)) - p.atn.edgeMu.Lock() - dfa.setPrecedenceStartState(p.parser.GetPrecedence(), s0) - p.atn.edgeMu.Unlock() - } else { - s0 = p.addDFAState(dfa, NewDFAState(-1, s0Closure)) - dfa.setS0(s0) - } - p.atn.stateMu.Unlock() - } - - alt, re := p.execATN(dfa, s0, input, index, outerContext) - parser.SetError(re) - if runtimeConfig.parserATNSimulatorDebug { - fmt.Println("DFA after predictATN: " + dfa.String(p.parser.GetLiteralNames(), nil)) - } - return alt - -} - -// execATN performs ATN simulation to compute a predicted alternative based -// upon the remaining input, but also updates the DFA cache to avoid -// having to traverse the ATN again for the same input sequence. -// -// There are some key conditions we're looking for after computing a new -// set of ATN configs (proposed DFA state): -// -// - If the set is empty, there is no viable alternative for current symbol -// - Does the state uniquely predict an alternative? -// - Does the state have a conflict that would prevent us from -// putting it on the work list? -// -// We also have some key operations to do: -// -// - Add an edge from previous DFA state to potentially NewDFA state, D, -// - Upon current symbol but only if adding to work list, which means in all -// cases except no viable alternative (and possibly non-greedy decisions?) -// - Collecting predicates and adding semantic context to DFA accept states -// - adding rule context to context-sensitive DFA accept states -// - Consuming an input symbol -// - Reporting a conflict -// - Reporting an ambiguity -// - Reporting a context sensitivity -// - Reporting insufficient predicates -// -// Cover these cases: -// -// - dead end -// - single alt -// - single alt + predicates -// - conflict -// - conflict + predicates -// -//goland:noinspection GoBoolExpressions -func (p *ParserATNSimulator) execATN(dfa *DFA, s0 *DFAState, input TokenStream, startIndex int, outerContext ParserRuleContext) (int, RecognitionException) { - - if runtimeConfig.parserATNSimulatorDebug || runtimeConfig.parserATNSimulatorTraceATNSim { - fmt.Println("execATN decision " + strconv.Itoa(dfa.decision) + - ", DFA state " + s0.String() + - ", LA(1)==" + p.getLookaheadName(input) + - " line " + strconv.Itoa(input.LT(1).GetLine()) + ":" + strconv.Itoa(input.LT(1).GetColumn())) - } - - previousD := s0 - - if runtimeConfig.parserATNSimulatorDebug { - fmt.Println("s0 = " + s0.String()) - } - t := input.LA(1) - for { // for more work - D := p.getExistingTargetState(previousD, t) - if D == nil { - D = p.computeTargetState(dfa, previousD, t) - } - if D == ATNSimulatorError { - // if any configs in previous dipped into outer context, that - // means that input up to t actually finished entry rule - // at least for SLL decision. Full LL doesn't dip into outer - // so don't need special case. - // We will get an error no matter what so delay until after - // decision better error message. Also, no reachable target - // ATN states in SLL implies LL will also get nowhere. - // If conflict in states that dip out, choose min since we - // will get error no matter what. - e := p.noViableAlt(input, outerContext, previousD.configs, startIndex) - input.Seek(startIndex) - alt := p.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(previousD.configs, outerContext) - if alt != ATNInvalidAltNumber { - return alt, nil - } - p.parser.SetError(e) - return ATNInvalidAltNumber, e - } - if D.requiresFullContext && p.predictionMode != PredictionModeSLL { - // IF PREDS, MIGHT RESOLVE TO SINGLE ALT => SLL (or syntax error) - conflictingAlts := D.configs.conflictingAlts - if D.predicates != nil { - if runtimeConfig.parserATNSimulatorDebug { - fmt.Println("DFA state has preds in DFA sim LL fail-over") - } - conflictIndex := input.Index() - if conflictIndex != startIndex { - input.Seek(startIndex) - } - conflictingAlts = p.evalSemanticContext(D.predicates, outerContext, true) - if conflictingAlts.length() == 1 { - if runtimeConfig.parserATNSimulatorDebug { - fmt.Println("Full LL avoided") - } - return conflictingAlts.minValue(), nil - } - if conflictIndex != startIndex { - // restore the index so Reporting the fallback to full - // context occurs with the index at the correct spot - input.Seek(conflictIndex) - } - } - if runtimeConfig.parserATNSimulatorDFADebug { - fmt.Println("ctx sensitive state " + outerContext.String(nil, nil) + " in " + D.String()) - } - fullCtx := true - s0Closure := p.computeStartState(dfa.atnStartState, outerContext, fullCtx) - p.ReportAttemptingFullContext(dfa, conflictingAlts, D.configs, startIndex, input.Index()) - alt, re := p.execATNWithFullContext(dfa, D, s0Closure, input, startIndex, outerContext) - return alt, re - } - if D.isAcceptState { - if D.predicates == nil { - return D.prediction, nil - } - stopIndex := input.Index() - input.Seek(startIndex) - alts := p.evalSemanticContext(D.predicates, outerContext, true) - - switch alts.length() { - case 0: - return ATNInvalidAltNumber, p.noViableAlt(input, outerContext, D.configs, startIndex) - case 1: - return alts.minValue(), nil - default: - // Report ambiguity after predicate evaluation to make sure the correct set of ambig alts is Reported. - p.ReportAmbiguity(dfa, D, startIndex, stopIndex, false, alts, D.configs) - return alts.minValue(), nil - } - } - previousD = D - - if t != TokenEOF { - input.Consume() - t = input.LA(1) - } - } -} - -// Get an existing target state for an edge in the DFA. If the target state -// for the edge has not yet been computed or is otherwise not available, -// p method returns {@code nil}. -// -// @param previousD The current DFA state -// @param t The next input symbol -// @return The existing target DFA state for the given input symbol -// {@code t}, or {@code nil} if the target state for p edge is not -// already cached - -func (p *ParserATNSimulator) getExistingTargetState(previousD *DFAState, t int) *DFAState { - if t+1 < 0 { - return nil - } - - p.atn.edgeMu.RLock() - defer p.atn.edgeMu.RUnlock() - edges := previousD.getEdges() - if edges == nil || t+1 >= len(edges) { - return nil - } - return previousD.getIthEdge(t + 1) -} - -// Compute a target state for an edge in the DFA, and attempt to add the -// computed state and corresponding edge to the DFA. -// -// @param dfa The DFA -// @param previousD The current DFA state -// @param t The next input symbol -// -// @return The computed target DFA state for the given input symbol -// {@code t}. If {@code t} does not lead to a valid DFA state, p method -// returns {@link //ERROR}. -// -//goland:noinspection GoBoolExpressions -func (p *ParserATNSimulator) computeTargetState(dfa *DFA, previousD *DFAState, t int) *DFAState { - reach := p.computeReachSet(previousD.configs, t, false) - - if reach == nil { - p.addDFAEdge(dfa, previousD, t, ATNSimulatorError) - return ATNSimulatorError - } - // create new target state we'll add to DFA after it's complete - D := NewDFAState(-1, reach) - - predictedAlt := p.getUniqueAlt(reach) - - if runtimeConfig.parserATNSimulatorDebug { - altSubSets := PredictionModegetConflictingAltSubsets(reach) - fmt.Println("SLL altSubSets=" + fmt.Sprint(altSubSets) + - ", previous=" + previousD.configs.String() + - ", configs=" + reach.String() + - ", predict=" + strconv.Itoa(predictedAlt) + - ", allSubsetsConflict=" + - fmt.Sprint(PredictionModeallSubsetsConflict(altSubSets)) + - ", conflictingAlts=" + p.getConflictingAlts(reach).String()) - } - if predictedAlt != ATNInvalidAltNumber { - // NO CONFLICT, UNIQUELY PREDICTED ALT - D.isAcceptState = true - D.configs.uniqueAlt = predictedAlt - D.setPrediction(predictedAlt) - } else if PredictionModehasSLLConflictTerminatingPrediction(p.predictionMode, reach) { - // MORE THAN ONE VIABLE ALTERNATIVE - D.configs.conflictingAlts = p.getConflictingAlts(reach) - D.requiresFullContext = true - // in SLL-only mode, we will stop at p state and return the minimum alt - D.isAcceptState = true - D.setPrediction(D.configs.conflictingAlts.minValue()) - } - if D.isAcceptState && D.configs.hasSemanticContext { - p.predicateDFAState(D, p.atn.getDecisionState(dfa.decision)) - if D.predicates != nil { - D.setPrediction(ATNInvalidAltNumber) - } - } - // all adds to dfa are done after we've created full D state - D = p.addDFAEdge(dfa, previousD, t, D) - return D -} - -func (p *ParserATNSimulator) predicateDFAState(dfaState *DFAState, decisionState DecisionState) { - // We need to test all predicates, even in DFA states that - // uniquely predict alternative. - nalts := len(decisionState.GetTransitions()) - // Update DFA so reach becomes accept state with (predicate,alt) - // pairs if preds found for conflicting alts - altsToCollectPredsFrom := p.getConflictingAltsOrUniqueAlt(dfaState.configs) - altToPred := p.getPredsForAmbigAlts(altsToCollectPredsFrom, dfaState.configs, nalts) - if altToPred != nil { - dfaState.predicates = p.getPredicatePredictions(altsToCollectPredsFrom, altToPred) - dfaState.setPrediction(ATNInvalidAltNumber) // make sure we use preds - } else { - // There are preds in configs but they might go away - // when OR'd together like {p}? || NONE == NONE. If neither - // alt has preds, resolve to min alt - dfaState.setPrediction(altsToCollectPredsFrom.minValue()) - } -} - -// comes back with reach.uniqueAlt set to a valid alt -// -//goland:noinspection GoBoolExpressions -func (p *ParserATNSimulator) execATNWithFullContext(dfa *DFA, D *DFAState, s0 *ATNConfigSet, input TokenStream, startIndex int, outerContext ParserRuleContext) (int, RecognitionException) { - - if runtimeConfig.parserATNSimulatorDebug || runtimeConfig.parserATNSimulatorTraceATNSim { - fmt.Println("execATNWithFullContext " + s0.String()) - } - - fullCtx := true - foundExactAmbig := false - var reach *ATNConfigSet - previous := s0 - input.Seek(startIndex) - t := input.LA(1) - predictedAlt := -1 - - for { // for more work - reach = p.computeReachSet(previous, t, fullCtx) - if reach == nil { - // if any configs in previous dipped into outer context, that - // means that input up to t actually finished entry rule - // at least for LL decision. Full LL doesn't dip into outer - // so don't need special case. - // We will get an error no matter what so delay until after - // decision better error message. Also, no reachable target - // ATN states in SLL implies LL will also get nowhere. - // If conflict in states that dip out, choose min since we - // will get error no matter what. - input.Seek(startIndex) - alt := p.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(previous, outerContext) - if alt != ATNInvalidAltNumber { - return alt, nil - } - return alt, p.noViableAlt(input, outerContext, previous, startIndex) - } - altSubSets := PredictionModegetConflictingAltSubsets(reach) - if runtimeConfig.parserATNSimulatorDebug { - fmt.Println("LL altSubSets=" + fmt.Sprint(altSubSets) + ", predict=" + - strconv.Itoa(PredictionModegetUniqueAlt(altSubSets)) + ", resolvesToJustOneViableAlt=" + - fmt.Sprint(PredictionModeresolvesToJustOneViableAlt(altSubSets))) - } - reach.uniqueAlt = p.getUniqueAlt(reach) - // unique prediction? - if reach.uniqueAlt != ATNInvalidAltNumber { - predictedAlt = reach.uniqueAlt - break - } - if p.predictionMode != PredictionModeLLExactAmbigDetection { - predictedAlt = PredictionModeresolvesToJustOneViableAlt(altSubSets) - if predictedAlt != ATNInvalidAltNumber { - break - } - } else { - // In exact ambiguity mode, we never try to terminate early. - // Just keeps scarfing until we know what the conflict is - if PredictionModeallSubsetsConflict(altSubSets) && PredictionModeallSubsetsEqual(altSubSets) { - foundExactAmbig = true - predictedAlt = PredictionModegetSingleViableAlt(altSubSets) - break - } - // else there are multiple non-conflicting subsets or - // we're not sure what the ambiguity is yet. - // So, keep going. - } - previous = reach - if t != TokenEOF { - input.Consume() - t = input.LA(1) - } - } - // If the configuration set uniquely predicts an alternative, - // without conflict, then we know that it's a full LL decision - // not SLL. - if reach.uniqueAlt != ATNInvalidAltNumber { - p.ReportContextSensitivity(dfa, predictedAlt, reach, startIndex, input.Index()) - return predictedAlt, nil - } - // We do not check predicates here because we have checked them - // on-the-fly when doing full context prediction. - - // - // In non-exact ambiguity detection mode, we might actually be able to - // detect an exact ambiguity, but I'm not going to spend the cycles - // needed to check. We only emit ambiguity warnings in exact ambiguity - // mode. - // - // For example, we might know that we have conflicting configurations. - // But, that does not mean that there is no way forward without a - // conflict. It's possible to have non-conflicting alt subsets as in: - // - // altSubSets=[{1, 2}, {1, 2}, {1}, {1, 2}] - // - // from - // - // [(17,1,[5 $]), (13,1,[5 10 $]), (21,1,[5 10 $]), (11,1,[$]), - // (13,2,[5 10 $]), (21,2,[5 10 $]), (11,2,[$])] - // - // In p case, (17,1,[5 $]) indicates there is some next sequence that - // would resolve p without conflict to alternative 1. Any other viable - // next sequence, however, is associated with a conflict. We stop - // looking for input because no amount of further lookahead will alter - // the fact that we should predict alternative 1. We just can't say for - // sure that there is an ambiguity without looking further. - - p.ReportAmbiguity(dfa, D, startIndex, input.Index(), foundExactAmbig, reach.Alts(), reach) - - return predictedAlt, nil -} - -//goland:noinspection GoBoolExpressions -func (p *ParserATNSimulator) computeReachSet(closure *ATNConfigSet, t int, fullCtx bool) *ATNConfigSet { - if p.mergeCache == nil { - p.mergeCache = NewJPCMap(ReachSetCollection, "Merge cache for computeReachSet()") - } - intermediate := NewATNConfigSet(fullCtx) - - // Configurations already in a rule stop state indicate reaching the end - // of the decision rule (local context) or end of the start rule (full - // context). Once reached, these configurations are never updated by a - // closure operation, so they are handled separately for the performance - // advantage of having a smaller intermediate set when calling closure. - // - // For full-context reach operations, separate handling is required to - // ensure that the alternative Matching the longest overall sequence is - // chosen when multiple such configurations can Match the input. - - var skippedStopStates []*ATNConfig - - // First figure out where we can reach on input t - for _, c := range closure.configs { - if runtimeConfig.parserATNSimulatorDebug { - fmt.Println("testing " + p.GetTokenName(t) + " at " + c.String()) - } - - if _, ok := c.GetState().(*RuleStopState); ok { - if fullCtx || t == TokenEOF { - skippedStopStates = append(skippedStopStates, c) - if runtimeConfig.parserATNSimulatorDebug { - fmt.Println("added " + c.String() + " to SkippedStopStates") - } - } - continue - } - - for _, trans := range c.GetState().GetTransitions() { - target := p.getReachableTarget(trans, t) - if target != nil { - cfg := NewATNConfig4(c, target) - intermediate.Add(cfg, p.mergeCache) - if runtimeConfig.parserATNSimulatorDebug { - fmt.Println("added " + cfg.String() + " to intermediate") - } - } - } - } - - // Now figure out where the reach operation can take us... - var reach *ATNConfigSet - - // This block optimizes the reach operation for intermediate sets which - // trivially indicate a termination state for the overall - // AdaptivePredict operation. - // - // The conditions assume that intermediate - // contains all configurations relevant to the reach set, but p - // condition is not true when one or more configurations have been - // withheld in SkippedStopStates, or when the current symbol is EOF. - // - if skippedStopStates == nil && t != TokenEOF { - if len(intermediate.configs) == 1 { - // Don't pursue the closure if there is just one state. - // It can only have one alternative just add to result - // Also don't pursue the closure if there is unique alternative - // among the configurations. - reach = intermediate - } else if p.getUniqueAlt(intermediate) != ATNInvalidAltNumber { - // Also don't pursue the closure if there is unique alternative - // among the configurations. - reach = intermediate - } - } - // If the reach set could not be trivially determined, perform a closure - // operation on the intermediate set to compute its initial value. - // - if reach == nil { - reach = NewATNConfigSet(fullCtx) - closureBusy := NewClosureBusy("ParserATNSimulator.computeReachSet() make a closureBusy") - treatEOFAsEpsilon := t == TokenEOF - amount := len(intermediate.configs) - for k := 0; k < amount; k++ { - p.closure(intermediate.configs[k], reach, closureBusy, false, fullCtx, treatEOFAsEpsilon) - } - } - if t == TokenEOF { - // After consuming EOF no additional input is possible, so we are - // only interested in configurations which reached the end of the - // decision rule (local context) or end of the start rule (full - // context). Update reach to contain only these configurations. This - // handles both explicit EOF transitions in the grammar and implicit - // EOF transitions following the end of the decision or start rule. - // - // When reach==intermediate, no closure operation was performed. In - // p case, removeAllConfigsNotInRuleStopState needs to check for - // reachable rule stop states as well as configurations already in - // a rule stop state. - // - // This is handled before the configurations in SkippedStopStates, - // because any configurations potentially added from that list are - // already guaranteed to meet this condition whether it's - // required. - // - reach = p.removeAllConfigsNotInRuleStopState(reach, reach.Equals(intermediate)) - } - // If SkippedStopStates!=nil, then it contains at least one - // configuration. For full-context reach operations, these - // configurations reached the end of the start rule, in which case we - // only add them back to reach if no configuration during the current - // closure operation reached such a state. This ensures AdaptivePredict - // chooses an alternative Matching the longest overall sequence when - // multiple alternatives are viable. - // - if skippedStopStates != nil && ((!fullCtx) || (!PredictionModehasConfigInRuleStopState(reach))) { - for l := 0; l < len(skippedStopStates); l++ { - reach.Add(skippedStopStates[l], p.mergeCache) - } - } - - if runtimeConfig.parserATNSimulatorTraceATNSim { - fmt.Println("computeReachSet " + closure.String() + " -> " + reach.String()) - } - - if len(reach.configs) == 0 { - return nil - } - - return reach -} - -// removeAllConfigsNotInRuleStopState returns a configuration set containing only the configurations from -// configs which are in a [RuleStopState]. If all -// configurations in configs are already in a rule stop state, this -// method simply returns configs. -// -// When lookToEndOfRule is true, this method uses -// [ATN].[NextTokens] for each configuration in configs which is -// not already in a rule stop state to see if a rule stop state is reachable -// from the configuration via epsilon-only transitions. -// -// When lookToEndOfRule is true, this method checks for rule stop states -// reachable by epsilon-only transitions from each configuration in -// configs. -// -// The func returns configs if all configurations in configs are in a -// rule stop state, otherwise it returns a new configuration set containing only -// the configurations from configs which are in a rule stop state -func (p *ParserATNSimulator) removeAllConfigsNotInRuleStopState(configs *ATNConfigSet, lookToEndOfRule bool) *ATNConfigSet { - if PredictionModeallConfigsInRuleStopStates(configs) { - return configs - } - result := NewATNConfigSet(configs.fullCtx) - for _, config := range configs.configs { - if _, ok := config.GetState().(*RuleStopState); ok { - result.Add(config, p.mergeCache) - continue - } - if lookToEndOfRule && config.GetState().GetEpsilonOnlyTransitions() { - NextTokens := p.atn.NextTokens(config.GetState(), nil) - if NextTokens.contains(TokenEpsilon) { - endOfRuleState := p.atn.ruleToStopState[config.GetState().GetRuleIndex()] - result.Add(NewATNConfig4(config, endOfRuleState), p.mergeCache) - } - } - } - return result -} - -//goland:noinspection GoBoolExpressions -func (p *ParserATNSimulator) computeStartState(a ATNState, ctx RuleContext, fullCtx bool) *ATNConfigSet { - // always at least the implicit call to start rule - initialContext := predictionContextFromRuleContext(p.atn, ctx) - configs := NewATNConfigSet(fullCtx) - if runtimeConfig.parserATNSimulatorDebug || runtimeConfig.parserATNSimulatorTraceATNSim { - fmt.Println("computeStartState from ATN state " + a.String() + - " initialContext=" + initialContext.String()) - } - - for i := 0; i < len(a.GetTransitions()); i++ { - target := a.GetTransitions()[i].getTarget() - c := NewATNConfig6(target, i+1, initialContext) - closureBusy := NewClosureBusy("ParserATNSimulator.computeStartState() make a closureBusy") - p.closure(c, configs, closureBusy, true, fullCtx, false) - } - return configs -} - -// applyPrecedenceFilter transforms the start state computed by -// [computeStartState] to the special start state used by a -// precedence [DFA] for a particular precedence value. The transformation -// process applies the following changes to the start state's configuration -// set. -// -// 1. Evaluate the precedence predicates for each configuration using -// [SemanticContext].evalPrecedence. -// 2. Remove all configurations which predict an alternative greater than -// 1, for which another configuration that predicts alternative 1 is in the -// same ATN state with the same prediction context. -// -// Transformation 2 is valid for the following reasons: -// -// - The closure block cannot contain any epsilon transitions which bypass -// the body of the closure, so all states reachable via alternative 1 are -// part of the precedence alternatives of the transformed left-recursive -// rule. -// - The "primary" portion of a left recursive rule cannot contain an -// epsilon transition, so the only way an alternative other than 1 can exist -// in a state that is also reachable via alternative 1 is by nesting calls -// to the left-recursive rule, with the outer calls not being at the -// preferred precedence level. -// -// The prediction context must be considered by this filter to address -// situations like the following: -// -// grammar TA -// prog: statement* EOF -// statement: letterA | statement letterA 'b' -// letterA: 'a' -// -// In the above grammar, the [ATN] state immediately before the token -// reference 'a' in letterA is reachable from the left edge -// of both the primary and closure blocks of the left-recursive rule -// statement. The prediction context associated with each of these -// configurations distinguishes between them, and prevents the alternative -// which stepped out to prog, and then back in to statement -// from being eliminated by the filter. -// -// The func returns the transformed configuration set representing the start state -// for a precedence [DFA] at a particular precedence level (determined by -// calling [Parser].getPrecedence). -func (p *ParserATNSimulator) applyPrecedenceFilter(configs *ATNConfigSet) *ATNConfigSet { - - statesFromAlt1 := make(map[int]*PredictionContext) - configSet := NewATNConfigSet(configs.fullCtx) - - for _, config := range configs.configs { - // handle alt 1 first - if config.GetAlt() != 1 { - continue - } - updatedContext := config.GetSemanticContext().evalPrecedence(p.parser, p.outerContext) - if updatedContext == nil { - // the configuration was eliminated - continue - } - statesFromAlt1[config.GetState().GetStateNumber()] = config.GetContext() - if updatedContext != config.GetSemanticContext() { - configSet.Add(NewATNConfig2(config, updatedContext), p.mergeCache) - } else { - configSet.Add(config, p.mergeCache) - } - } - for _, config := range configs.configs { - - if config.GetAlt() == 1 { - // already handled - continue - } - // In the future, p elimination step could be updated to also - // filter the prediction context for alternatives predicting alt>1 - // (basically a graph subtraction algorithm). - if !config.getPrecedenceFilterSuppressed() { - context := statesFromAlt1[config.GetState().GetStateNumber()] - if context != nil && context.Equals(config.GetContext()) { - // eliminated - continue - } - } - configSet.Add(config, p.mergeCache) - } - return configSet -} - -func (p *ParserATNSimulator) getReachableTarget(trans Transition, ttype int) ATNState { - if trans.Matches(ttype, 0, p.atn.maxTokenType) { - return trans.getTarget() - } - - return nil -} - -//goland:noinspection GoBoolExpressions -func (p *ParserATNSimulator) getPredsForAmbigAlts(ambigAlts *BitSet, configs *ATNConfigSet, nalts int) []SemanticContext { - - altToPred := make([]SemanticContext, nalts+1) - for _, c := range configs.configs { - if ambigAlts.contains(c.GetAlt()) { - altToPred[c.GetAlt()] = SemanticContextorContext(altToPred[c.GetAlt()], c.GetSemanticContext()) - } - } - nPredAlts := 0 - for i := 1; i <= nalts; i++ { - pred := altToPred[i] - if pred == nil { - altToPred[i] = SemanticContextNone - } else if pred != SemanticContextNone { - nPredAlts++ - } - } - // unambiguous alts are nil in altToPred - if nPredAlts == 0 { - altToPred = nil - } - if runtimeConfig.parserATNSimulatorDebug { - fmt.Println("getPredsForAmbigAlts result " + fmt.Sprint(altToPred)) - } - return altToPred -} - -func (p *ParserATNSimulator) getPredicatePredictions(ambigAlts *BitSet, altToPred []SemanticContext) []*PredPrediction { - pairs := make([]*PredPrediction, 0) - containsPredicate := false - for i := 1; i < len(altToPred); i++ { - pred := altToPred[i] - // un-predicated is indicated by SemanticContextNONE - if ambigAlts != nil && ambigAlts.contains(i) { - pairs = append(pairs, NewPredPrediction(pred, i)) - } - if pred != SemanticContextNone { - containsPredicate = true - } - } - if !containsPredicate { - return nil - } - return pairs -} - -// getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule is used to improve the localization of error messages by -// choosing an alternative rather than panic a NoViableAltException in particular prediction scenarios where the -// Error state was reached during [ATN] simulation. -// -// The default implementation of this method uses the following -// algorithm to identify an [ATN] configuration which successfully parsed the -// decision entry rule. Choosing such an alternative ensures that the -// [ParserRuleContext] returned by the calling rule will be complete -// and valid, and the syntax error will be Reported later at a more -// localized location. -// -// - If a syntactically valid path or paths reach the end of the decision rule, and -// they are semantically valid if predicated, return the min associated alt. -// - Else, if a semantically invalid but syntactically valid path exist -// or paths exist, return the minimum associated alt. -// - Otherwise, return [ATNInvalidAltNumber]. -// -// In some scenarios, the algorithm described above could predict an -// alternative which will result in a [FailedPredicateException] in -// the parser. Specifically, this could occur if the only configuration -// capable of successfully parsing to the end of the decision rule is -// blocked by a semantic predicate. By choosing this alternative within -// [AdaptivePredict] instead of panic a [NoViableAltException], the resulting -// [FailedPredicateException] in the parser will identify the specific -// predicate which is preventing the parser from successfully parsing the -// decision rule, which helps developers identify and correct logic errors -// in semantic predicates. -// -// pass in the configs holding ATN configurations which were valid immediately before -// the ERROR state was reached, outerContext as the initial parser context from the paper -// or the parser stack at the instant before prediction commences. -// -// Teh func returns the value to return from [AdaptivePredict], or -// [ATNInvalidAltNumber] if a suitable alternative was not -// identified and [AdaptivePredict] should report an error instead. -func (p *ParserATNSimulator) getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(configs *ATNConfigSet, outerContext ParserRuleContext) int { - cfgs := p.splitAccordingToSemanticValidity(configs, outerContext) - semValidConfigs := cfgs[0] - semInvalidConfigs := cfgs[1] - alt := p.GetAltThatFinishedDecisionEntryRule(semValidConfigs) - if alt != ATNInvalidAltNumber { // semantically/syntactically viable path exists - return alt - } - // Is there a syntactically valid path with a failed pred? - if len(semInvalidConfigs.configs) > 0 { - alt = p.GetAltThatFinishedDecisionEntryRule(semInvalidConfigs) - if alt != ATNInvalidAltNumber { // syntactically viable path exists - return alt - } - } - return ATNInvalidAltNumber -} - -func (p *ParserATNSimulator) GetAltThatFinishedDecisionEntryRule(configs *ATNConfigSet) int { - alts := NewIntervalSet() - - for _, c := range configs.configs { - _, ok := c.GetState().(*RuleStopState) - - if c.GetReachesIntoOuterContext() > 0 || (ok && c.GetContext().hasEmptyPath()) { - alts.addOne(c.GetAlt()) - } - } - if alts.length() == 0 { - return ATNInvalidAltNumber - } - - return alts.first() -} - -// Walk the list of configurations and split them according to -// those that have preds evaluating to true/false. If no pred, assume -// true pred and include in succeeded set. Returns Pair of sets. -// -// Create a NewSet so as not to alter the incoming parameter. -// -// Assumption: the input stream has been restored to the starting point -// prediction, which is where predicates need to evaluate. - -type ATNConfigSetPair struct { - item0, item1 *ATNConfigSet -} - -func (p *ParserATNSimulator) splitAccordingToSemanticValidity(configs *ATNConfigSet, outerContext ParserRuleContext) []*ATNConfigSet { - succeeded := NewATNConfigSet(configs.fullCtx) - failed := NewATNConfigSet(configs.fullCtx) - - for _, c := range configs.configs { - if c.GetSemanticContext() != SemanticContextNone { - predicateEvaluationResult := c.GetSemanticContext().evaluate(p.parser, outerContext) - if predicateEvaluationResult { - succeeded.Add(c, nil) - } else { - failed.Add(c, nil) - } - } else { - succeeded.Add(c, nil) - } - } - return []*ATNConfigSet{succeeded, failed} -} - -// evalSemanticContext looks through a list of predicate/alt pairs, returning alts for the -// pairs that win. A [SemanticContextNone] predicate indicates an alt containing an -// un-predicated runtimeConfig which behaves as "always true." If !complete -// then we stop at the first predicate that evaluates to true. This -// includes pairs with nil predicates. -// -//goland:noinspection GoBoolExpressions -func (p *ParserATNSimulator) evalSemanticContext(predPredictions []*PredPrediction, outerContext ParserRuleContext, complete bool) *BitSet { - predictions := NewBitSet() - for i := 0; i < len(predPredictions); i++ { - pair := predPredictions[i] - if pair.pred == SemanticContextNone { - predictions.add(pair.alt) - if !complete { - break - } - continue - } - - predicateEvaluationResult := pair.pred.evaluate(p.parser, outerContext) - if runtimeConfig.parserATNSimulatorDebug || runtimeConfig.parserATNSimulatorDFADebug { - fmt.Println("eval pred " + pair.String() + "=" + fmt.Sprint(predicateEvaluationResult)) - } - if predicateEvaluationResult { - if runtimeConfig.parserATNSimulatorDebug || runtimeConfig.parserATNSimulatorDFADebug { - fmt.Println("PREDICT " + fmt.Sprint(pair.alt)) - } - predictions.add(pair.alt) - if !complete { - break - } - } - } - return predictions -} - -func (p *ParserATNSimulator) closure(config *ATNConfig, configs *ATNConfigSet, closureBusy *ClosureBusy, collectPredicates, fullCtx, treatEOFAsEpsilon bool) { - initialDepth := 0 - p.closureCheckingStopState(config, configs, closureBusy, collectPredicates, - fullCtx, initialDepth, treatEOFAsEpsilon) -} - -func (p *ParserATNSimulator) closureCheckingStopState(config *ATNConfig, configs *ATNConfigSet, closureBusy *ClosureBusy, collectPredicates, fullCtx bool, depth int, treatEOFAsEpsilon bool) { - if runtimeConfig.parserATNSimulatorTraceATNSim { - fmt.Println("closure(" + config.String() + ")") - } - - var stack []*ATNConfig - visited := make(map[*ATNConfig]bool) - - stack = append(stack, config) - - for len(stack) > 0 { - currConfig := stack[len(stack)-1] - stack = stack[:len(stack)-1] - - if _, ok := visited[currConfig]; ok { - continue - } - visited[currConfig] = true - - if _, ok := currConfig.GetState().(*RuleStopState); ok { - // We hit rule end. If we have context info, use it - // run thru all possible stack tops in ctx - if !currConfig.GetContext().isEmpty() { - for i := 0; i < currConfig.GetContext().length(); i++ { - if currConfig.GetContext().getReturnState(i) == BasePredictionContextEmptyReturnState { - if fullCtx { - nb := NewATNConfig1(currConfig, currConfig.GetState(), BasePredictionContextEMPTY) - configs.Add(nb, p.mergeCache) - continue - } else { - // we have no context info, just chase follow links (if greedy) - if runtimeConfig.parserATNSimulatorDebug { - fmt.Println("FALLING off rule " + p.getRuleName(currConfig.GetState().GetRuleIndex())) - } - p.closureWork(currConfig, configs, closureBusy, collectPredicates, fullCtx, depth, treatEOFAsEpsilon) - } - continue - } - returnState := p.atn.states[currConfig.GetContext().getReturnState(i)] - newContext := currConfig.GetContext().GetParent(i) // "pop" return state - - c := NewATNConfig5(returnState, currConfig.GetAlt(), newContext, currConfig.GetSemanticContext()) - // While we have context to pop back from, we may have - // gotten that context AFTER having falling off a rule. - // Make sure we track that we are now out of context. - c.SetReachesIntoOuterContext(currConfig.GetReachesIntoOuterContext()) - - stack = append(stack, c) - } - continue - } else if fullCtx { - // reached end of start rule - configs.Add(currConfig, p.mergeCache) - continue - } else { - // else if we have no context info, just chase follow links (if greedy) - if runtimeConfig.parserATNSimulatorDebug { - fmt.Println("FALLING off rule " + p.getRuleName(currConfig.GetState().GetRuleIndex())) - } - } - } - - p.closureWork(currConfig, configs, closureBusy, collectPredicates, fullCtx, depth, treatEOFAsEpsilon) - } -} - -//goland:noinspection GoBoolExpressions -func (p *ParserATNSimulator) closureCheckingStopStateRecursive(config *ATNConfig, configs *ATNConfigSet, closureBusy *ClosureBusy, collectPredicates, fullCtx bool, depth int, treatEOFAsEpsilon bool) { - if runtimeConfig.parserATNSimulatorTraceATNSim { - fmt.Println("closure(" + config.String() + ")") - } - - if _, ok := config.GetState().(*RuleStopState); ok { - // We hit rule end. If we have context info, use it - // run thru all possible stack tops in ctx - if !config.GetContext().isEmpty() { - for i := 0; i < config.GetContext().length(); i++ { - if config.GetContext().getReturnState(i) == BasePredictionContextEmptyReturnState { - if fullCtx { - nb := NewATNConfig1(config, config.GetState(), BasePredictionContextEMPTY) - configs.Add(nb, p.mergeCache) - continue - } else { - // we have no context info, just chase follow links (if greedy) - if runtimeConfig.parserATNSimulatorDebug { - fmt.Println("FALLING off rule " + p.getRuleName(config.GetState().GetRuleIndex())) - } - p.closureWork(config, configs, closureBusy, collectPredicates, fullCtx, depth, treatEOFAsEpsilon) - } - continue - } - returnState := p.atn.states[config.GetContext().getReturnState(i)] - newContext := config.GetContext().GetParent(i) // "pop" return state - - c := NewATNConfig5(returnState, config.GetAlt(), newContext, config.GetSemanticContext()) - // While we have context to pop back from, we may have - // gotten that context AFTER having falling off a rule. - // Make sure we track that we are now out of context. - c.SetReachesIntoOuterContext(config.GetReachesIntoOuterContext()) - p.closureCheckingStopState(c, configs, closureBusy, collectPredicates, fullCtx, depth-1, treatEOFAsEpsilon) - } - return - } else if fullCtx { - // reached end of start rule - configs.Add(config, p.mergeCache) - return - } else { - // else if we have no context info, just chase follow links (if greedy) - if runtimeConfig.parserATNSimulatorDebug { - fmt.Println("FALLING off rule " + p.getRuleName(config.GetState().GetRuleIndex())) - } - } - } - p.closureWork(config, configs, closureBusy, collectPredicates, fullCtx, depth, treatEOFAsEpsilon) -} - -// Do the actual work of walking epsilon edges -// -//goland:noinspection GoBoolExpressions -func (p *ParserATNSimulator) closureWork(config *ATNConfig, configs *ATNConfigSet, closureBusy *ClosureBusy, collectPredicates, fullCtx bool, depth int, treatEOFAsEpsilon bool) { - state := config.GetState() - // optimization - if !state.GetEpsilonOnlyTransitions() { - configs.Add(config, p.mergeCache) - // make sure to not return here, because EOF transitions can act as - // both epsilon transitions and non-epsilon transitions. - } - for i := 0; i < len(state.GetTransitions()); i++ { - if i == 0 && p.canDropLoopEntryEdgeInLeftRecursiveRule(config) { - continue - } - - t := state.GetTransitions()[i] - _, ok := t.(*ActionTransition) - continueCollecting := collectPredicates && !ok - c := p.getEpsilonTarget(config, t, continueCollecting, depth == 0, fullCtx, treatEOFAsEpsilon) - if c != nil { - newDepth := depth - - if _, ok := config.GetState().(*RuleStopState); ok { - // target fell off end of rule mark resulting c as having dipped into outer context - // We can't get here if incoming config was rule stop and we had context - // track how far we dip into outer context. Might - // come in handy and we avoid evaluating context dependent - // preds if this is > 0. - - if p.dfa != nil && p.dfa.getPrecedenceDfa() { - if t.(*EpsilonTransition).outermostPrecedenceReturn == p.dfa.atnStartState.GetRuleIndex() { - c.setPrecedenceFilterSuppressed(true) - } - } - - c.SetReachesIntoOuterContext(c.GetReachesIntoOuterContext() + 1) - - _, present := closureBusy.Put(c) - if present { - // avoid infinite recursion for right-recursive rules - continue - } - - configs.dipsIntoOuterContext = true // TODO: can remove? only care when we add to set per middle of this method - newDepth-- - if runtimeConfig.parserATNSimulatorDebug { - fmt.Println("dips into outer ctx: " + c.String()) - } - } else { - - if !t.getIsEpsilon() { - _, present := closureBusy.Put(c) - if present { - // avoid infinite recursion for EOF* and EOF+ - continue - } - } - if _, ok := t.(*RuleTransition); ok { - // latch when newDepth goes negative - once we step out of the entry context we can't return - if newDepth >= 0 { - newDepth++ - } - } - } - p.closureCheckingStopState(c, configs, closureBusy, continueCollecting, fullCtx, newDepth, treatEOFAsEpsilon) - } - } -} - -//goland:noinspection GoBoolExpressions -func (p *ParserATNSimulator) canDropLoopEntryEdgeInLeftRecursiveRule(config *ATNConfig) bool { - if !runtimeConfig.lRLoopEntryBranchOpt { - return false - } - - _p := config.GetState() - - // First check to see if we are in StarLoopEntryState generated during - // left-recursion elimination. For efficiency, also check if - // the context has an empty stack case. If so, it would mean - // global FOLLOW so we can't perform optimization - if _p.GetStateType() != ATNStateStarLoopEntry { - return false - } - startLoop, ok := _p.(*StarLoopEntryState) - if !ok { - return false - } - if !startLoop.precedenceRuleDecision || - config.GetContext().isEmpty() || - config.GetContext().hasEmptyPath() { - return false - } - - // Require all return states to return back to the same rule - // that p is in. - numCtxs := config.GetContext().length() - for i := 0; i < numCtxs; i++ { - returnState := p.atn.states[config.GetContext().getReturnState(i)] - if returnState.GetRuleIndex() != _p.GetRuleIndex() { - return false - } - } - x := _p.GetTransitions()[0].getTarget() - decisionStartState := x.(BlockStartState) - blockEndStateNum := decisionStartState.getEndState().stateNumber - blockEndState := p.atn.states[blockEndStateNum].(*BlockEndState) - - // Verify that the top of each stack context leads to loop entry/exit - // state through epsilon edges and w/o leaving rule. - - for i := 0; i < numCtxs; i++ { // for each stack context - returnStateNumber := config.GetContext().getReturnState(i) - returnState := p.atn.states[returnStateNumber] - - // all states must have single outgoing epsilon edge - if len(returnState.GetTransitions()) != 1 || !returnState.GetTransitions()[0].getIsEpsilon() { - return false - } - - // Look for prefix op case like 'not expr', (' type ')' expr - returnStateTarget := returnState.GetTransitions()[0].getTarget() - if returnState.GetStateType() == ATNStateBlockEnd && returnStateTarget == _p { - continue - } - - // Look for 'expr op expr' or case where expr's return state is block end - // of (...)* internal block; the block end points to loop back - // which points to p but we don't need to check that - if returnState == blockEndState { - continue - } - - // Look for ternary expr ? expr : expr. The return state points at block end, - // which points at loop entry state - if returnStateTarget == blockEndState { - continue - } - - // Look for complex prefix 'between expr and expr' case where 2nd expr's - // return state points at block end state of (...)* internal block - if returnStateTarget.GetStateType() == ATNStateBlockEnd && - len(returnStateTarget.GetTransitions()) == 1 && - returnStateTarget.GetTransitions()[0].getIsEpsilon() && - returnStateTarget.GetTransitions()[0].getTarget() == _p { - continue - } - - // anything else ain't conforming - return false - } - - return true -} - -func (p *ParserATNSimulator) getRuleName(index int) string { - if p.parser != nil && index >= 0 { - return p.parser.GetRuleNames()[index] - } - var sb strings.Builder - sb.Grow(32) - - sb.WriteString("') - return sb.String() -} - -func (p *ParserATNSimulator) getEpsilonTarget(config *ATNConfig, t Transition, collectPredicates, inContext, fullCtx, treatEOFAsEpsilon bool) *ATNConfig { - - switch t.getSerializationType() { - case TransitionRULE: - return p.ruleTransition(config, t.(*RuleTransition)) - case TransitionPRECEDENCE: - return p.precedenceTransition(config, t.(*PrecedencePredicateTransition), collectPredicates, inContext, fullCtx) - case TransitionPREDICATE: - return p.predTransition(config, t.(*PredicateTransition), collectPredicates, inContext, fullCtx) - case TransitionACTION: - return p.actionTransition(config, t.(*ActionTransition)) - case TransitionEPSILON: - return NewATNConfig4(config, t.getTarget()) - case TransitionATOM, TransitionRANGE, TransitionSET: - // EOF transitions act like epsilon transitions after the first EOF - // transition is traversed - if treatEOFAsEpsilon { - if t.Matches(TokenEOF, 0, 1) { - return NewATNConfig4(config, t.getTarget()) - } - } - return nil - default: - return nil - } -} - -//goland:noinspection GoBoolExpressions -func (p *ParserATNSimulator) actionTransition(config *ATNConfig, t *ActionTransition) *ATNConfig { - if runtimeConfig.parserATNSimulatorDebug { - fmt.Println("ACTION edge " + strconv.Itoa(t.ruleIndex) + ":" + strconv.Itoa(t.actionIndex)) - } - return NewATNConfig4(config, t.getTarget()) -} - -//goland:noinspection GoBoolExpressions -func (p *ParserATNSimulator) precedenceTransition(config *ATNConfig, - pt *PrecedencePredicateTransition, collectPredicates, inContext, fullCtx bool) *ATNConfig { - - if runtimeConfig.parserATNSimulatorDebug { - fmt.Println("PRED (collectPredicates=" + fmt.Sprint(collectPredicates) + ") " + - strconv.Itoa(pt.precedence) + ">=_p, ctx dependent=true") - if p.parser != nil { - fmt.Println("context surrounding pred is " + fmt.Sprint(p.parser.GetRuleInvocationStack(nil))) - } - } - var c *ATNConfig - if collectPredicates && inContext { - if fullCtx { - // In full context mode, we can evaluate predicates on-the-fly - // during closure, which dramatically reduces the size of - // the runtimeConfig sets. It also obviates the need to test predicates - // later during conflict resolution. - currentPosition := p.input.Index() - p.input.Seek(p.startIndex) - predSucceeds := pt.getPredicate().evaluate(p.parser, p.outerContext) - p.input.Seek(currentPosition) - if predSucceeds { - c = NewATNConfig4(config, pt.getTarget()) // no pred context - } - } else { - newSemCtx := SemanticContextandContext(config.GetSemanticContext(), pt.getPredicate()) - c = NewATNConfig3(config, pt.getTarget(), newSemCtx) - } - } else { - c = NewATNConfig4(config, pt.getTarget()) - } - if runtimeConfig.parserATNSimulatorDebug { - fmt.Println("runtimeConfig from pred transition=" + c.String()) - } - return c -} - -//goland:noinspection GoBoolExpressions -func (p *ParserATNSimulator) predTransition(config *ATNConfig, pt *PredicateTransition, collectPredicates, inContext, fullCtx bool) *ATNConfig { - - if runtimeConfig.parserATNSimulatorDebug { - fmt.Println("PRED (collectPredicates=" + fmt.Sprint(collectPredicates) + ") " + strconv.Itoa(pt.ruleIndex) + - ":" + strconv.Itoa(pt.predIndex) + ", ctx dependent=" + fmt.Sprint(pt.isCtxDependent)) - if p.parser != nil { - fmt.Println("context surrounding pred is " + fmt.Sprint(p.parser.GetRuleInvocationStack(nil))) - } - } - var c *ATNConfig - if collectPredicates && (!pt.isCtxDependent || inContext) { - if fullCtx { - // In full context mode, we can evaluate predicates on-the-fly - // during closure, which dramatically reduces the size of - // the config sets. It also obviates the need to test predicates - // later during conflict resolution. - currentPosition := p.input.Index() - p.input.Seek(p.startIndex) - predSucceeds := pt.getPredicate().evaluate(p.parser, p.outerContext) - p.input.Seek(currentPosition) - if predSucceeds { - c = NewATNConfig4(config, pt.getTarget()) // no pred context - } - } else { - newSemCtx := SemanticContextandContext(config.GetSemanticContext(), pt.getPredicate()) - c = NewATNConfig3(config, pt.getTarget(), newSemCtx) - } - } else { - c = NewATNConfig4(config, pt.getTarget()) - } - if runtimeConfig.parserATNSimulatorDebug { - fmt.Println("config from pred transition=" + c.String()) - } - return c -} - -//goland:noinspection GoBoolExpressions -func (p *ParserATNSimulator) ruleTransition(config *ATNConfig, t *RuleTransition) *ATNConfig { - if runtimeConfig.parserATNSimulatorDebug { - fmt.Println("CALL rule " + p.getRuleName(t.getTarget().GetRuleIndex()) + ", ctx=" + config.GetContext().String()) - } - returnState := t.followState - newContext := SingletonBasePredictionContextCreate(config.GetContext(), returnState.GetStateNumber()) - return NewATNConfig1(config, t.getTarget(), newContext) -} - -func (p *ParserATNSimulator) getConflictingAlts(configs *ATNConfigSet) *BitSet { - altsets := PredictionModegetConflictingAltSubsets(configs) - return PredictionModeGetAlts(altsets) -} - -// getConflictingAltsOrUniqueAlt Sam pointed out a problem with the previous definition, v3, of -// ambiguous states. If we have another state associated with conflicting -// alternatives, we should keep going. For example, the following grammar -// -// s : (ID | ID ID?) ; -// -// When the [ATN] simulation reaches the state before ;, it has a [DFA] -// state that looks like: -// -// [12|1|[], 6|2|[], 12|2|[]]. -// -// Naturally -// -// 12|1|[] and 12|2|[] -// -// conflict, but we cannot stop processing this node -// because alternative to has another way to continue, via -// -// [6|2|[]]. -// -// The key is that we have a single state that has config's only associated -// with a single alternative, 2, and crucially the state transitions -// among the configurations are all non-epsilon transitions. That means -// we don't consider any conflicts that include alternative 2. So, we -// ignore the conflict between alts 1 and 2. We ignore a set of -// conflicting alts when there is an intersection with an alternative -// associated with a single alt state in the state config-list map. -// -// It's also the case that we might have two conflicting configurations but -// also a 3rd non-conflicting configuration for a different alternative: -// -// [1|1|[], 1|2|[], 8|3|[]]. -// -// This can come about from grammar: -// -// a : A | A | A B -// -// After Matching input A, we reach the stop state for rule A, state 1. -// State 8 is the state right before B. Clearly alternatives 1 and 2 -// conflict and no amount of further lookahead will separate the two. -// However, alternative 3 will be able to continue, so we do not -// stop working on this state. -// -// In the previous example, we're concerned -// with states associated with the conflicting alternatives. Here alt -// 3 is not associated with the conflicting configs, but since we can continue -// looking for input reasonably, I don't declare the state done. We -// ignore a set of conflicting alts when we have an alternative -// that we still need to pursue. -func (p *ParserATNSimulator) getConflictingAltsOrUniqueAlt(configs *ATNConfigSet) *BitSet { - var conflictingAlts *BitSet - if configs.uniqueAlt != ATNInvalidAltNumber { - conflictingAlts = NewBitSet() - conflictingAlts.add(configs.uniqueAlt) - } else { - conflictingAlts = configs.conflictingAlts - } - return conflictingAlts -} - -func (p *ParserATNSimulator) GetTokenName(t int) string { - if t == TokenEOF { - return "EOF" - } - - if p.parser != nil && p.parser.GetLiteralNames() != nil && t < len(p.parser.GetLiteralNames()) { - return p.parser.GetLiteralNames()[t] + "<" + strconv.Itoa(t) + ">" - } - - if p.parser != nil && p.parser.GetLiteralNames() != nil && t < len(p.parser.GetSymbolicNames()) { - return p.parser.GetSymbolicNames()[t] + "<" + strconv.Itoa(t) + ">" - } - - return strconv.Itoa(t) -} - -func (p *ParserATNSimulator) getLookaheadName(input TokenStream) string { - return p.GetTokenName(input.LA(1)) -} - -// Used for debugging in [AdaptivePredict] around [execATN], but I cut -// it out for clarity now that alg. works well. We can leave this -// "dead" code for a bit. -func (p *ParserATNSimulator) dumpDeadEndConfigs(_ *NoViableAltException) { - - panic("Not implemented") - - // fmt.Println("dead end configs: ") - // var decs = nvae.deadEndConfigs - // - // for i:=0; i0) { - // var t = c.state.GetTransitions()[0] - // if t2, ok := t.(*AtomTransition); ok { - // trans = "Atom "+ p.GetTokenName(t2.label) - // } else if t3, ok := t.(SetTransition); ok { - // _, ok := t.(*NotSetTransition) - // - // var s string - // if (ok){ - // s = "~" - // } - // - // trans = s + "Set " + t3.set - // } - // } - // fmt.Errorf(c.String(p.parser, true) + ":" + trans) - // } -} - -func (p *ParserATNSimulator) noViableAlt(input TokenStream, outerContext ParserRuleContext, configs *ATNConfigSet, startIndex int) *NoViableAltException { - return NewNoViableAltException(p.parser, input, input.Get(startIndex), input.LT(1), configs, outerContext) -} - -func (p *ParserATNSimulator) getUniqueAlt(configs *ATNConfigSet) int { - alt := ATNInvalidAltNumber - for _, c := range configs.configs { - if alt == ATNInvalidAltNumber { - alt = c.GetAlt() // found first alt - } else if c.GetAlt() != alt { - return ATNInvalidAltNumber - } - } - return alt -} - -// Add an edge to the DFA, if possible. This method calls -// {@link //addDFAState} to ensure the {@code to} state is present in the -// DFA. If {@code from} is {@code nil}, or if {@code t} is outside the -// range of edges that can be represented in the DFA tables, p method -// returns without adding the edge to the DFA. -// -//

If {@code to} is {@code nil}, p method returns {@code nil}. -// Otherwise, p method returns the {@link DFAState} returned by calling -// {@link //addDFAState} for the {@code to} state.

-// -// @param dfa The DFA -// @param from The source state for the edge -// @param t The input symbol -// @param to The target state for the edge -// -// @return If {@code to} is {@code nil}, p method returns {@code nil} -// otherwise p method returns the result of calling {@link //addDFAState} -// on {@code to} -// -//goland:noinspection GoBoolExpressions -func (p *ParserATNSimulator) addDFAEdge(dfa *DFA, from *DFAState, t int, to *DFAState) *DFAState { - if runtimeConfig.parserATNSimulatorDebug { - fmt.Println("EDGE " + from.String() + " -> " + to.String() + " upon " + p.GetTokenName(t)) - } - if to == nil { - return nil - } - p.atn.stateMu.Lock() - to = p.addDFAState(dfa, to) // used existing if possible not incoming - p.atn.stateMu.Unlock() - if from == nil || t < -1 || t > p.atn.maxTokenType { - return to - } - p.atn.edgeMu.Lock() - if from.getEdges() == nil { - from.setEdges(make([]*DFAState, p.atn.maxTokenType+1+1)) - } - from.setIthEdge(t+1, to) // connect - p.atn.edgeMu.Unlock() - - if runtimeConfig.parserATNSimulatorDebug { - var names []string - if p.parser != nil { - names = p.parser.GetLiteralNames() - } - - fmt.Println("DFA=\n" + dfa.String(names, nil)) - } - return to -} - -// addDFAState adds state D to the [DFA] if it is not already present, and returns -// the actual instance stored in the [DFA]. If a state equivalent to D -// is already in the [DFA], the existing state is returned. Otherwise, this -// method returns D after adding it to the [DFA]. -// -// If D is [ATNSimulatorError], this method returns [ATNSimulatorError] and -// does not change the DFA. -// -//goland:noinspection GoBoolExpressions -func (p *ParserATNSimulator) addDFAState(dfa *DFA, d *DFAState) *DFAState { - if d == ATNSimulatorError { - return d - } - - existing, present := dfa.Get(d) - if present { - if runtimeConfig.parserATNSimulatorTraceATNSim { - fmt.Print("addDFAState " + d.String() + " exists") - } - return existing - } - - // The state will be added if not already there or we will be given back the existing state struct - // if it is present. - // - d.stateNumber = dfa.Len() - if !d.configs.readOnly { - d.configs.OptimizeConfigs(&p.BaseATNSimulator) - d.configs.readOnly = true - d.configs.configLookup = nil - } - dfa.Put(d) - - if runtimeConfig.parserATNSimulatorTraceATNSim { - fmt.Println("addDFAState new " + d.String()) - } - - return d -} - -//goland:noinspection GoBoolExpressions -func (p *ParserATNSimulator) ReportAttemptingFullContext(dfa *DFA, conflictingAlts *BitSet, configs *ATNConfigSet, startIndex, stopIndex int) { - if runtimeConfig.parserATNSimulatorDebug || runtimeConfig.parserATNSimulatorRetryDebug { - interval := NewInterval(startIndex, stopIndex+1) - fmt.Println("ReportAttemptingFullContext decision=" + strconv.Itoa(dfa.decision) + ":" + configs.String() + - ", input=" + p.parser.GetTokenStream().GetTextFromInterval(interval)) - } - if p.parser != nil { - p.parser.GetErrorListenerDispatch().ReportAttemptingFullContext(p.parser, dfa, startIndex, stopIndex, conflictingAlts, configs) - } -} - -//goland:noinspection GoBoolExpressions -func (p *ParserATNSimulator) ReportContextSensitivity(dfa *DFA, prediction int, configs *ATNConfigSet, startIndex, stopIndex int) { - if runtimeConfig.parserATNSimulatorDebug || runtimeConfig.parserATNSimulatorRetryDebug { - interval := NewInterval(startIndex, stopIndex+1) - fmt.Println("ReportContextSensitivity decision=" + strconv.Itoa(dfa.decision) + ":" + configs.String() + - ", input=" + p.parser.GetTokenStream().GetTextFromInterval(interval)) - } - if p.parser != nil { - p.parser.GetErrorListenerDispatch().ReportContextSensitivity(p.parser, dfa, startIndex, stopIndex, prediction, configs) - } -} - -// ReportAmbiguity reports and ambiguity in the parse, which shows that the parser will explore a different route. -// -// If context-sensitive parsing, we know it's an ambiguity not a conflict or error, but we can report it to the developer -// so that they can see that this is happening and can take action if they want to. -// -//goland:noinspection GoBoolExpressions -func (p *ParserATNSimulator) ReportAmbiguity(dfa *DFA, _ *DFAState, startIndex, stopIndex int, - exact bool, ambigAlts *BitSet, configs *ATNConfigSet) { - if runtimeConfig.parserATNSimulatorDebug || runtimeConfig.parserATNSimulatorRetryDebug { - interval := NewInterval(startIndex, stopIndex+1) - fmt.Println("ReportAmbiguity " + ambigAlts.String() + ":" + configs.String() + - ", input=" + p.parser.GetTokenStream().GetTextFromInterval(interval)) - } - if p.parser != nil { - p.parser.GetErrorListenerDispatch().ReportAmbiguity(p.parser, dfa, startIndex, stopIndex, exact, ambigAlts, configs) - } -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/parser_rule_context.go b/vendor/github.com/antlr4-go/antlr/v4/parser_rule_context.go deleted file mode 100644 index c249bc138..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/parser_rule_context.go +++ /dev/null @@ -1,421 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import ( - "reflect" - "strconv" -) - -type ParserRuleContext interface { - RuleContext - - SetException(RecognitionException) - - AddTokenNode(token Token) *TerminalNodeImpl - AddErrorNode(badToken Token) *ErrorNodeImpl - - EnterRule(listener ParseTreeListener) - ExitRule(listener ParseTreeListener) - - SetStart(Token) - GetStart() Token - - SetStop(Token) - GetStop() Token - - AddChild(child RuleContext) RuleContext - RemoveLastChild() -} - -type BaseParserRuleContext struct { - parentCtx RuleContext - invokingState int - RuleIndex int - - start, stop Token - exception RecognitionException - children []Tree -} - -func NewBaseParserRuleContext(parent ParserRuleContext, invokingStateNumber int) *BaseParserRuleContext { - prc := new(BaseParserRuleContext) - InitBaseParserRuleContext(prc, parent, invokingStateNumber) - return prc -} - -func InitBaseParserRuleContext(prc *BaseParserRuleContext, parent ParserRuleContext, invokingStateNumber int) { - // What context invoked b rule? - prc.parentCtx = parent - - // What state invoked the rule associated with b context? - // The "return address" is the followState of invokingState - // If parent is nil, b should be -1. - if parent == nil { - prc.invokingState = -1 - } else { - prc.invokingState = invokingStateNumber - } - - prc.RuleIndex = -1 - // * If we are debugging or building a parse tree for a Visitor, - // we need to track all of the tokens and rule invocations associated - // with prc rule's context. This is empty for parsing w/o tree constr. - // operation because we don't the need to track the details about - // how we parse prc rule. - // / - prc.children = nil - prc.start = nil - prc.stop = nil - // The exception that forced prc rule to return. If the rule successfully - // completed, prc is {@code nil}. - prc.exception = nil -} - -func (prc *BaseParserRuleContext) SetException(e RecognitionException) { - prc.exception = e -} - -func (prc *BaseParserRuleContext) GetChildren() []Tree { - return prc.children -} - -func (prc *BaseParserRuleContext) CopyFrom(ctx *BaseParserRuleContext) { - // from RuleContext - prc.parentCtx = ctx.parentCtx - prc.invokingState = ctx.invokingState - prc.children = nil - prc.start = ctx.start - prc.stop = ctx.stop -} - -func (prc *BaseParserRuleContext) GetText() string { - if prc.GetChildCount() == 0 { - return "" - } - - var s string - for _, child := range prc.children { - s += child.(ParseTree).GetText() - } - - return s -} - -// EnterRule is called when any rule is entered. -func (prc *BaseParserRuleContext) EnterRule(_ ParseTreeListener) { -} - -// ExitRule is called when any rule is exited. -func (prc *BaseParserRuleContext) ExitRule(_ ParseTreeListener) { -} - -// * Does not set parent link other add methods do that -func (prc *BaseParserRuleContext) addTerminalNodeChild(child TerminalNode) TerminalNode { - if prc.children == nil { - prc.children = make([]Tree, 0) - } - if child == nil { - panic("Child may not be null") - } - prc.children = append(prc.children, child) - return child -} - -func (prc *BaseParserRuleContext) AddChild(child RuleContext) RuleContext { - if prc.children == nil { - prc.children = make([]Tree, 0) - } - if child == nil { - panic("Child may not be null") - } - prc.children = append(prc.children, child) - return child -} - -// RemoveLastChild is used by [EnterOuterAlt] to toss out a [RuleContext] previously added as -// we entered a rule. If we have a label, we will need to remove -// the generic ruleContext object. -func (prc *BaseParserRuleContext) RemoveLastChild() { - if prc.children != nil && len(prc.children) > 0 { - prc.children = prc.children[0 : len(prc.children)-1] - } -} - -func (prc *BaseParserRuleContext) AddTokenNode(token Token) *TerminalNodeImpl { - - node := NewTerminalNodeImpl(token) - prc.addTerminalNodeChild(node) - node.parentCtx = prc - return node - -} - -func (prc *BaseParserRuleContext) AddErrorNode(badToken Token) *ErrorNodeImpl { - node := NewErrorNodeImpl(badToken) - prc.addTerminalNodeChild(node) - node.parentCtx = prc - return node -} - -func (prc *BaseParserRuleContext) GetChild(i int) Tree { - if prc.children != nil && len(prc.children) >= i { - return prc.children[i] - } - - return nil -} - -func (prc *BaseParserRuleContext) GetChildOfType(i int, childType reflect.Type) RuleContext { - if childType == nil { - return prc.GetChild(i).(RuleContext) - } - - for j := 0; j < len(prc.children); j++ { - child := prc.children[j] - if reflect.TypeOf(child) == childType { - if i == 0 { - return child.(RuleContext) - } - - i-- - } - } - - return nil -} - -func (prc *BaseParserRuleContext) ToStringTree(ruleNames []string, recog Recognizer) string { - return TreesStringTree(prc, ruleNames, recog) -} - -func (prc *BaseParserRuleContext) GetRuleContext() RuleContext { - return prc -} - -func (prc *BaseParserRuleContext) Accept(visitor ParseTreeVisitor) interface{} { - return visitor.VisitChildren(prc) -} - -func (prc *BaseParserRuleContext) SetStart(t Token) { - prc.start = t -} - -func (prc *BaseParserRuleContext) GetStart() Token { - return prc.start -} - -func (prc *BaseParserRuleContext) SetStop(t Token) { - prc.stop = t -} - -func (prc *BaseParserRuleContext) GetStop() Token { - return prc.stop -} - -func (prc *BaseParserRuleContext) GetToken(ttype int, i int) TerminalNode { - - for j := 0; j < len(prc.children); j++ { - child := prc.children[j] - if c2, ok := child.(TerminalNode); ok { - if c2.GetSymbol().GetTokenType() == ttype { - if i == 0 { - return c2 - } - - i-- - } - } - } - return nil -} - -func (prc *BaseParserRuleContext) GetTokens(ttype int) []TerminalNode { - if prc.children == nil { - return make([]TerminalNode, 0) - } - - tokens := make([]TerminalNode, 0) - - for j := 0; j < len(prc.children); j++ { - child := prc.children[j] - if tchild, ok := child.(TerminalNode); ok { - if tchild.GetSymbol().GetTokenType() == ttype { - tokens = append(tokens, tchild) - } - } - } - - return tokens -} - -func (prc *BaseParserRuleContext) GetPayload() interface{} { - return prc -} - -func (prc *BaseParserRuleContext) getChild(ctxType reflect.Type, i int) RuleContext { - if prc.children == nil || i < 0 || i >= len(prc.children) { - return nil - } - - j := -1 // what element have we found with ctxType? - for _, o := range prc.children { - - childType := reflect.TypeOf(o) - - if childType.Implements(ctxType) { - j++ - if j == i { - return o.(RuleContext) - } - } - } - return nil -} - -// Go lacks generics, so it's not possible for us to return the child with the correct type, but we do -// check for convertibility - -func (prc *BaseParserRuleContext) GetTypedRuleContext(ctxType reflect.Type, i int) RuleContext { - return prc.getChild(ctxType, i) -} - -func (prc *BaseParserRuleContext) GetTypedRuleContexts(ctxType reflect.Type) []RuleContext { - if prc.children == nil { - return make([]RuleContext, 0) - } - - contexts := make([]RuleContext, 0) - - for _, child := range prc.children { - childType := reflect.TypeOf(child) - - if childType.ConvertibleTo(ctxType) { - contexts = append(contexts, child.(RuleContext)) - } - } - return contexts -} - -func (prc *BaseParserRuleContext) GetChildCount() int { - if prc.children == nil { - return 0 - } - - return len(prc.children) -} - -func (prc *BaseParserRuleContext) GetSourceInterval() Interval { - if prc.start == nil || prc.stop == nil { - return TreeInvalidInterval - } - - return NewInterval(prc.start.GetTokenIndex(), prc.stop.GetTokenIndex()) -} - -//need to manage circular dependencies, so export now - -// Print out a whole tree, not just a node, in LISP format -// (root child1 .. childN). Print just a node if b is a leaf. -// - -func (prc *BaseParserRuleContext) String(ruleNames []string, stop RuleContext) string { - - var p ParserRuleContext = prc - s := "[" - for p != nil && p != stop { - if ruleNames == nil { - if !p.IsEmpty() { - s += strconv.Itoa(p.GetInvokingState()) - } - } else { - ri := p.GetRuleIndex() - var ruleName string - if ri >= 0 && ri < len(ruleNames) { - ruleName = ruleNames[ri] - } else { - ruleName = strconv.Itoa(ri) - } - s += ruleName - } - if p.GetParent() != nil && (ruleNames != nil || !p.GetParent().(ParserRuleContext).IsEmpty()) { - s += " " - } - pi := p.GetParent() - if pi != nil { - p = pi.(ParserRuleContext) - } else { - p = nil - } - } - s += "]" - return s -} - -func (prc *BaseParserRuleContext) SetParent(v Tree) { - if v == nil { - prc.parentCtx = nil - } else { - prc.parentCtx = v.(RuleContext) - } -} - -func (prc *BaseParserRuleContext) GetInvokingState() int { - return prc.invokingState -} - -func (prc *BaseParserRuleContext) SetInvokingState(t int) { - prc.invokingState = t -} - -func (prc *BaseParserRuleContext) GetRuleIndex() int { - return prc.RuleIndex -} - -func (prc *BaseParserRuleContext) GetAltNumber() int { - return ATNInvalidAltNumber -} - -func (prc *BaseParserRuleContext) SetAltNumber(_ int) {} - -// IsEmpty returns true if the context of b is empty. -// -// A context is empty if there is no invoking state, meaning nobody calls -// current context. -func (prc *BaseParserRuleContext) IsEmpty() bool { - return prc.invokingState == -1 -} - -// GetParent returns the combined text of all child nodes. This method only considers -// tokens which have been added to the parse tree. -// -// Since tokens on hidden channels (e.g. whitespace or comments) are not -// added to the parse trees, they will not appear in the output of this -// method. -func (prc *BaseParserRuleContext) GetParent() Tree { - return prc.parentCtx -} - -var ParserRuleContextEmpty = NewBaseParserRuleContext(nil, -1) - -type InterpreterRuleContext interface { - ParserRuleContext -} - -type BaseInterpreterRuleContext struct { - *BaseParserRuleContext -} - -//goland:noinspection GoUnusedExportedFunction -func NewBaseInterpreterRuleContext(parent BaseInterpreterRuleContext, invokingStateNumber, ruleIndex int) *BaseInterpreterRuleContext { - - prc := new(BaseInterpreterRuleContext) - - prc.BaseParserRuleContext = NewBaseParserRuleContext(parent, invokingStateNumber) - - prc.RuleIndex = ruleIndex - - return prc -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/prediction_context.go b/vendor/github.com/antlr4-go/antlr/v4/prediction_context.go deleted file mode 100644 index c1b80cc1f..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/prediction_context.go +++ /dev/null @@ -1,727 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import ( - "fmt" - "golang.org/x/exp/slices" - "strconv" -) - -var _emptyPredictionContextHash int - -func init() { - _emptyPredictionContextHash = murmurInit(1) - _emptyPredictionContextHash = murmurFinish(_emptyPredictionContextHash, 0) -} - -func calculateEmptyHash() int { - return _emptyPredictionContextHash -} - -const ( - // BasePredictionContextEmptyReturnState represents {@code $} in an array in full context mode, $ - // doesn't mean wildcard: - // - // $ + x = [$,x] - // - // Here, - // - // $ = EmptyReturnState - BasePredictionContextEmptyReturnState = 0x7FFFFFFF -) - -// TODO: JI These are meant to be atomics - this does not seem to match the Java runtime here -// -//goland:noinspection GoUnusedGlobalVariable -var ( - BasePredictionContextglobalNodeCount = 1 - BasePredictionContextid = BasePredictionContextglobalNodeCount -) - -const ( - PredictionContextEmpty = iota - PredictionContextSingleton - PredictionContextArray -) - -// PredictionContext is a go idiomatic implementation of PredictionContext that does not rty to -// emulate inheritance from Java, and can be used without an interface definition. An interface -// is not required because no user code will ever need to implement this interface. -type PredictionContext struct { - cachedHash int - pcType int - parentCtx *PredictionContext - returnState int - parents []*PredictionContext - returnStates []int -} - -func NewEmptyPredictionContext() *PredictionContext { - nep := &PredictionContext{} - nep.cachedHash = calculateEmptyHash() - nep.pcType = PredictionContextEmpty - nep.returnState = BasePredictionContextEmptyReturnState - return nep -} - -func NewBaseSingletonPredictionContext(parent *PredictionContext, returnState int) *PredictionContext { - pc := &PredictionContext{} - pc.pcType = PredictionContextSingleton - pc.returnState = returnState - pc.parentCtx = parent - if parent != nil { - pc.cachedHash = calculateHash(parent, returnState) - } else { - pc.cachedHash = calculateEmptyHash() - } - return pc -} - -func SingletonBasePredictionContextCreate(parent *PredictionContext, returnState int) *PredictionContext { - if returnState == BasePredictionContextEmptyReturnState && parent == nil { - // someone can pass in the bits of an array ctx that mean $ - return BasePredictionContextEMPTY - } - return NewBaseSingletonPredictionContext(parent, returnState) -} - -func NewArrayPredictionContext(parents []*PredictionContext, returnStates []int) *PredictionContext { - // Parent can be nil only if full ctx mode and we make an array - // from {@link //EMPTY} and non-empty. We merge {@link //EMPTY} by using - // nil parent and - // returnState == {@link //EmptyReturnState}. - hash := murmurInit(1) - for _, parent := range parents { - hash = murmurUpdate(hash, parent.Hash()) - } - for _, returnState := range returnStates { - hash = murmurUpdate(hash, returnState) - } - hash = murmurFinish(hash, len(parents)<<1) - - nec := &PredictionContext{} - nec.cachedHash = hash - nec.pcType = PredictionContextArray - nec.parents = parents - nec.returnStates = returnStates - return nec -} - -func (p *PredictionContext) Hash() int { - return p.cachedHash -} - -func (p *PredictionContext) Equals(other Collectable[*PredictionContext]) bool { - switch p.pcType { - case PredictionContextEmpty: - otherP := other.(*PredictionContext) - return other == nil || otherP == nil || otherP.isEmpty() - case PredictionContextSingleton: - return p.SingletonEquals(other) - case PredictionContextArray: - return p.ArrayEquals(other) - } - return false -} - -func (p *PredictionContext) ArrayEquals(o Collectable[*PredictionContext]) bool { - if o == nil { - return false - } - other := o.(*PredictionContext) - if other == nil || other.pcType != PredictionContextArray { - return false - } - if p.cachedHash != other.Hash() { - return false // can't be same if hash is different - } - - // Must compare the actual array elements and not just the array address - // - return slices.Equal(p.returnStates, other.returnStates) && - slices.EqualFunc(p.parents, other.parents, func(x, y *PredictionContext) bool { - return x.Equals(y) - }) -} - -func (p *PredictionContext) SingletonEquals(other Collectable[*PredictionContext]) bool { - if other == nil { - return false - } - otherP := other.(*PredictionContext) - if otherP == nil { - return false - } - - if p.cachedHash != otherP.Hash() { - return false // Can't be same if hash is different - } - - if p.returnState != otherP.getReturnState(0) { - return false - } - - // Both parents must be nil if one is - if p.parentCtx == nil { - return otherP.parentCtx == nil - } - - return p.parentCtx.Equals(otherP.parentCtx) -} - -func (p *PredictionContext) GetParent(i int) *PredictionContext { - switch p.pcType { - case PredictionContextEmpty: - return nil - case PredictionContextSingleton: - return p.parentCtx - case PredictionContextArray: - return p.parents[i] - } - return nil -} - -func (p *PredictionContext) getReturnState(i int) int { - switch p.pcType { - case PredictionContextArray: - return p.returnStates[i] - default: - return p.returnState - } -} - -func (p *PredictionContext) GetReturnStates() []int { - switch p.pcType { - case PredictionContextArray: - return p.returnStates - default: - return []int{p.returnState} - } -} - -func (p *PredictionContext) length() int { - switch p.pcType { - case PredictionContextArray: - return len(p.returnStates) - default: - return 1 - } -} - -func (p *PredictionContext) hasEmptyPath() bool { - switch p.pcType { - case PredictionContextSingleton: - return p.returnState == BasePredictionContextEmptyReturnState - } - return p.getReturnState(p.length()-1) == BasePredictionContextEmptyReturnState -} - -func (p *PredictionContext) String() string { - switch p.pcType { - case PredictionContextEmpty: - return "$" - case PredictionContextSingleton: - var up string - - if p.parentCtx == nil { - up = "" - } else { - up = p.parentCtx.String() - } - - if len(up) == 0 { - if p.returnState == BasePredictionContextEmptyReturnState { - return "$" - } - - return strconv.Itoa(p.returnState) - } - - return strconv.Itoa(p.returnState) + " " + up - case PredictionContextArray: - if p.isEmpty() { - return "[]" - } - - s := "[" - for i := 0; i < len(p.returnStates); i++ { - if i > 0 { - s = s + ", " - } - if p.returnStates[i] == BasePredictionContextEmptyReturnState { - s = s + "$" - continue - } - s = s + strconv.Itoa(p.returnStates[i]) - if !p.parents[i].isEmpty() { - s = s + " " + p.parents[i].String() - } else { - s = s + "nil" - } - } - return s + "]" - - default: - return "unknown" - } -} - -func (p *PredictionContext) isEmpty() bool { - switch p.pcType { - case PredictionContextEmpty: - return true - case PredictionContextArray: - // since EmptyReturnState can only appear in the last position, we - // don't need to verify that size==1 - return p.returnStates[0] == BasePredictionContextEmptyReturnState - default: - return false - } -} - -func (p *PredictionContext) Type() int { - return p.pcType -} - -func calculateHash(parent *PredictionContext, returnState int) int { - h := murmurInit(1) - h = murmurUpdate(h, parent.Hash()) - h = murmurUpdate(h, returnState) - return murmurFinish(h, 2) -} - -// Convert a {@link RuleContext} tree to a {@link BasePredictionContext} graph. -// Return {@link //EMPTY} if {@code outerContext} is empty or nil. -// / -func predictionContextFromRuleContext(a *ATN, outerContext RuleContext) *PredictionContext { - if outerContext == nil { - outerContext = ParserRuleContextEmpty - } - // if we are in RuleContext of start rule, s, then BasePredictionContext - // is EMPTY. Nobody called us. (if we are empty, return empty) - if outerContext.GetParent() == nil || outerContext == ParserRuleContextEmpty { - return BasePredictionContextEMPTY - } - // If we have a parent, convert it to a BasePredictionContext graph - parent := predictionContextFromRuleContext(a, outerContext.GetParent().(RuleContext)) - state := a.states[outerContext.GetInvokingState()] - transition := state.GetTransitions()[0] - - return SingletonBasePredictionContextCreate(parent, transition.(*RuleTransition).followState.GetStateNumber()) -} - -func merge(a, b *PredictionContext, rootIsWildcard bool, mergeCache *JPCMap) *PredictionContext { - - // Share same graph if both same - // - if a == b || a.Equals(b) { - return a - } - - if a.pcType == PredictionContextSingleton && b.pcType == PredictionContextSingleton { - return mergeSingletons(a, b, rootIsWildcard, mergeCache) - } - // At least one of a or b is array - // If one is $ and rootIsWildcard, return $ as wildcard - if rootIsWildcard { - if a.isEmpty() { - return a - } - if b.isEmpty() { - return b - } - } - - // Convert either Singleton or Empty to arrays, so that we can merge them - // - ara := convertToArray(a) - arb := convertToArray(b) - return mergeArrays(ara, arb, rootIsWildcard, mergeCache) -} - -func convertToArray(pc *PredictionContext) *PredictionContext { - switch pc.Type() { - case PredictionContextEmpty: - return NewArrayPredictionContext([]*PredictionContext{}, []int{}) - case PredictionContextSingleton: - return NewArrayPredictionContext([]*PredictionContext{pc.GetParent(0)}, []int{pc.getReturnState(0)}) - default: - // Already an array - } - return pc -} - -// mergeSingletons merges two Singleton [PredictionContext] instances. -// -// Stack tops equal, parents merge is same return left graph. -//

-// -//

Same stack top, parents differ merge parents giving array node, then -// remainders of those graphs. A new root node is created to point to the -// merged parents.
-//

-// -//

Different stack tops pointing to same parent. Make array node for the -// root where both element in the root point to the same (original) -// parent.
-//

-// -//

Different stack tops pointing to different parents. Make array node for -// the root where each element points to the corresponding original -// parent.
-//

-// -// @param a the first {@link SingletonBasePredictionContext} -// @param b the second {@link SingletonBasePredictionContext} -// @param rootIsWildcard {@code true} if this is a local-context merge, -// otherwise false to indicate a full-context merge -// @param mergeCache -// / -func mergeSingletons(a, b *PredictionContext, rootIsWildcard bool, mergeCache *JPCMap) *PredictionContext { - if mergeCache != nil { - previous, present := mergeCache.Get(a, b) - if present { - return previous - } - previous, present = mergeCache.Get(b, a) - if present { - return previous - } - } - - rootMerge := mergeRoot(a, b, rootIsWildcard) - if rootMerge != nil { - if mergeCache != nil { - mergeCache.Put(a, b, rootMerge) - } - return rootMerge - } - if a.returnState == b.returnState { - parent := merge(a.parentCtx, b.parentCtx, rootIsWildcard, mergeCache) - // if parent is same as existing a or b parent or reduced to a parent, - // return it - if parent.Equals(a.parentCtx) { - return a // ax + bx = ax, if a=b - } - if parent.Equals(b.parentCtx) { - return b // ax + bx = bx, if a=b - } - // else: ax + ay = a'[x,y] - // merge parents x and y, giving array node with x,y then remainders - // of those graphs. dup a, a' points at merged array. - // New joined parent so create a new singleton pointing to it, a' - spc := SingletonBasePredictionContextCreate(parent, a.returnState) - if mergeCache != nil { - mergeCache.Put(a, b, spc) - } - return spc - } - // a != b payloads differ - // see if we can collapse parents due to $+x parents if local ctx - var singleParent *PredictionContext - if a.Equals(b) || (a.parentCtx != nil && a.parentCtx.Equals(b.parentCtx)) { // ax + - // bx = - // [a,b]x - singleParent = a.parentCtx - } - if singleParent != nil { // parents are same - // sort payloads and use same parent - payloads := []int{a.returnState, b.returnState} - if a.returnState > b.returnState { - payloads[0] = b.returnState - payloads[1] = a.returnState - } - parents := []*PredictionContext{singleParent, singleParent} - apc := NewArrayPredictionContext(parents, payloads) - if mergeCache != nil { - mergeCache.Put(a, b, apc) - } - return apc - } - // parents differ and can't merge them. Just pack together - // into array can't merge. - // ax + by = [ax,by] - payloads := []int{a.returnState, b.returnState} - parents := []*PredictionContext{a.parentCtx, b.parentCtx} - if a.returnState > b.returnState { // sort by payload - payloads[0] = b.returnState - payloads[1] = a.returnState - parents = []*PredictionContext{b.parentCtx, a.parentCtx} - } - apc := NewArrayPredictionContext(parents, payloads) - if mergeCache != nil { - mergeCache.Put(a, b, apc) - } - return apc -} - -// Handle case where at least one of {@code a} or {@code b} is -// {@link //EMPTY}. In the following diagrams, the symbol {@code $} is used -// to represent {@link //EMPTY}. -// -//

Local-Context Merges

-// -//

These local-context merge operations are used when {@code rootIsWildcard} -// is true.

-// -//

{@link //EMPTY} is superset of any graph return {@link //EMPTY}.
-//

-// -//

{@link //EMPTY} and anything is {@code //EMPTY}, so merged parent is -// {@code //EMPTY} return left graph.
-//

-// -//

Special case of last merge if local context.
-//

-// -//

Full-Context Merges

-// -//

These full-context merge operations are used when {@code rootIsWildcard} -// is false.

-// -//

-// -//

Must keep all contexts {@link //EMPTY} in array is a special value (and -// nil parent).
-//

-// -//

-// -// @param a the first {@link SingletonBasePredictionContext} -// @param b the second {@link SingletonBasePredictionContext} -// @param rootIsWildcard {@code true} if this is a local-context merge, -// otherwise false to indicate a full-context merge -// / -func mergeRoot(a, b *PredictionContext, rootIsWildcard bool) *PredictionContext { - if rootIsWildcard { - if a.pcType == PredictionContextEmpty { - return BasePredictionContextEMPTY // // + b =// - } - if b.pcType == PredictionContextEmpty { - return BasePredictionContextEMPTY // a +// =// - } - } else { - if a.isEmpty() && b.isEmpty() { - return BasePredictionContextEMPTY // $ + $ = $ - } else if a.isEmpty() { // $ + x = [$,x] - payloads := []int{b.getReturnState(-1), BasePredictionContextEmptyReturnState} - parents := []*PredictionContext{b.GetParent(-1), nil} - return NewArrayPredictionContext(parents, payloads) - } else if b.isEmpty() { // x + $ = [$,x] ($ is always first if present) - payloads := []int{a.getReturnState(-1), BasePredictionContextEmptyReturnState} - parents := []*PredictionContext{a.GetParent(-1), nil} - return NewArrayPredictionContext(parents, payloads) - } - } - return nil -} - -// Merge two {@link ArrayBasePredictionContext} instances. -// -//

Different tops, different parents.
-//

-// -//

Shared top, same parents.
-//

-// -//

Shared top, different parents.
-//

-// -//

Shared top, all shared parents.
-//

-// -//

Equal tops, merge parents and reduce top to -// {@link SingletonBasePredictionContext}.
-//

-// -//goland:noinspection GoBoolExpressions -func mergeArrays(a, b *PredictionContext, rootIsWildcard bool, mergeCache *JPCMap) *PredictionContext { - if mergeCache != nil { - previous, present := mergeCache.Get(a, b) - if present { - if runtimeConfig.parserATNSimulatorTraceATNSim { - fmt.Println("mergeArrays a=" + a.String() + ",b=" + b.String() + " -> previous") - } - return previous - } - previous, present = mergeCache.Get(b, a) - if present { - if runtimeConfig.parserATNSimulatorTraceATNSim { - fmt.Println("mergeArrays a=" + a.String() + ",b=" + b.String() + " -> previous") - } - return previous - } - } - // merge sorted payloads a + b => M - i := 0 // walks a - j := 0 // walks b - k := 0 // walks target M array - - mergedReturnStates := make([]int, len(a.returnStates)+len(b.returnStates)) - mergedParents := make([]*PredictionContext, len(a.returnStates)+len(b.returnStates)) - // walk and merge to yield mergedParents, mergedReturnStates - for i < len(a.returnStates) && j < len(b.returnStates) { - aParent := a.parents[i] - bParent := b.parents[j] - if a.returnStates[i] == b.returnStates[j] { - // same payload (stack tops are equal), must yield merged singleton - payload := a.returnStates[i] - // $+$ = $ - bothDollars := payload == BasePredictionContextEmptyReturnState && aParent == nil && bParent == nil - axAX := aParent != nil && bParent != nil && aParent.Equals(bParent) // ax+ax - // -> - // ax - if bothDollars || axAX { - mergedParents[k] = aParent // choose left - mergedReturnStates[k] = payload - } else { // ax+ay -> a'[x,y] - mergedParent := merge(aParent, bParent, rootIsWildcard, mergeCache) - mergedParents[k] = mergedParent - mergedReturnStates[k] = payload - } - i++ // hop over left one as usual - j++ // but also Skip one in right side since we merge - } else if a.returnStates[i] < b.returnStates[j] { // copy a[i] to M - mergedParents[k] = aParent - mergedReturnStates[k] = a.returnStates[i] - i++ - } else { // b > a, copy b[j] to M - mergedParents[k] = bParent - mergedReturnStates[k] = b.returnStates[j] - j++ - } - k++ - } - // copy over any payloads remaining in either array - if i < len(a.returnStates) { - for p := i; p < len(a.returnStates); p++ { - mergedParents[k] = a.parents[p] - mergedReturnStates[k] = a.returnStates[p] - k++ - } - } else { - for p := j; p < len(b.returnStates); p++ { - mergedParents[k] = b.parents[p] - mergedReturnStates[k] = b.returnStates[p] - k++ - } - } - // trim merged if we combined a few that had same stack tops - if k < len(mergedParents) { // write index < last position trim - if k == 1 { // for just one merged element, return singleton top - pc := SingletonBasePredictionContextCreate(mergedParents[0], mergedReturnStates[0]) - if mergeCache != nil { - mergeCache.Put(a, b, pc) - } - return pc - } - mergedParents = mergedParents[0:k] - mergedReturnStates = mergedReturnStates[0:k] - } - - M := NewArrayPredictionContext(mergedParents, mergedReturnStates) - - // if we created same array as a or b, return that instead - // TODO: JI track whether this is possible above during merge sort for speed and possibly avoid an allocation - if M.Equals(a) { - if mergeCache != nil { - mergeCache.Put(a, b, a) - } - if runtimeConfig.parserATNSimulatorTraceATNSim { - fmt.Println("mergeArrays a=" + a.String() + ",b=" + b.String() + " -> a") - } - return a - } - if M.Equals(b) { - if mergeCache != nil { - mergeCache.Put(a, b, b) - } - if runtimeConfig.parserATNSimulatorTraceATNSim { - fmt.Println("mergeArrays a=" + a.String() + ",b=" + b.String() + " -> b") - } - return b - } - combineCommonParents(&mergedParents) - - if mergeCache != nil { - mergeCache.Put(a, b, M) - } - if runtimeConfig.parserATNSimulatorTraceATNSim { - fmt.Println("mergeArrays a=" + a.String() + ",b=" + b.String() + " -> " + M.String()) - } - return M -} - -// Make pass over all M parents and merge any Equals() ones. -// Note that we pass a pointer to the slice as we want to modify it in place. -// -//goland:noinspection GoUnusedFunction -func combineCommonParents(parents *[]*PredictionContext) { - uniqueParents := NewJStore[*PredictionContext, Comparator[*PredictionContext]](pContextEqInst, PredictionContextCollection, "combineCommonParents for PredictionContext") - - for p := 0; p < len(*parents); p++ { - parent := (*parents)[p] - _, _ = uniqueParents.Put(parent) - } - for q := 0; q < len(*parents); q++ { - pc, _ := uniqueParents.Get((*parents)[q]) - (*parents)[q] = pc - } -} - -func getCachedBasePredictionContext(context *PredictionContext, contextCache *PredictionContextCache, visited *VisitRecord) *PredictionContext { - if context.isEmpty() { - return context - } - existing, present := visited.Get(context) - if present { - return existing - } - - existing, present = contextCache.Get(context) - if present { - visited.Put(context, existing) - return existing - } - changed := false - parents := make([]*PredictionContext, context.length()) - for i := 0; i < len(parents); i++ { - parent := getCachedBasePredictionContext(context.GetParent(i), contextCache, visited) - if changed || !parent.Equals(context.GetParent(i)) { - if !changed { - parents = make([]*PredictionContext, context.length()) - for j := 0; j < context.length(); j++ { - parents[j] = context.GetParent(j) - } - changed = true - } - parents[i] = parent - } - } - if !changed { - contextCache.add(context) - visited.Put(context, context) - return context - } - var updated *PredictionContext - if len(parents) == 0 { - updated = BasePredictionContextEMPTY - } else if len(parents) == 1 { - updated = SingletonBasePredictionContextCreate(parents[0], context.getReturnState(0)) - } else { - updated = NewArrayPredictionContext(parents, context.GetReturnStates()) - } - contextCache.add(updated) - visited.Put(updated, updated) - visited.Put(context, updated) - - return updated -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/prediction_context_cache.go b/vendor/github.com/antlr4-go/antlr/v4/prediction_context_cache.go deleted file mode 100644 index 25dfb11e8..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/prediction_context_cache.go +++ /dev/null @@ -1,48 +0,0 @@ -package antlr - -var BasePredictionContextEMPTY = &PredictionContext{ - cachedHash: calculateEmptyHash(), - pcType: PredictionContextEmpty, - returnState: BasePredictionContextEmptyReturnState, -} - -// PredictionContextCache is Used to cache [PredictionContext] objects. It is used for the shared -// context cash associated with contexts in DFA states. This cache -// can be used for both lexers and parsers. -type PredictionContextCache struct { - cache *JMap[*PredictionContext, *PredictionContext, Comparator[*PredictionContext]] -} - -func NewPredictionContextCache() *PredictionContextCache { - return &PredictionContextCache{ - cache: NewJMap[*PredictionContext, *PredictionContext, Comparator[*PredictionContext]](pContextEqInst, PredictionContextCacheCollection, "NewPredictionContextCache()"), - } -} - -// Add a context to the cache and return it. If the context already exists, -// return that one instead and do not add a new context to the cache. -// Protect shared cache from unsafe thread access. -func (p *PredictionContextCache) add(ctx *PredictionContext) *PredictionContext { - if ctx.isEmpty() { - return BasePredictionContextEMPTY - } - - // Put will return the existing entry if it is present (note this is done via Equals, not whether it is - // the same pointer), otherwise it will add the new entry and return that. - // - existing, present := p.cache.Get(ctx) - if present { - return existing - } - p.cache.Put(ctx, ctx) - return ctx -} - -func (p *PredictionContextCache) Get(ctx *PredictionContext) (*PredictionContext, bool) { - pc, exists := p.cache.Get(ctx) - return pc, exists -} - -func (p *PredictionContextCache) length() int { - return p.cache.Len() -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/prediction_mode.go b/vendor/github.com/antlr4-go/antlr/v4/prediction_mode.go deleted file mode 100644 index 3f85a6a52..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/prediction_mode.go +++ /dev/null @@ -1,536 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -// This enumeration defines the prediction modes available in ANTLR 4 along with -// utility methods for analyzing configuration sets for conflicts and/or -// ambiguities. - -const ( - // PredictionModeSLL represents the SLL(*) prediction mode. - // This prediction mode ignores the current - // parser context when making predictions. This is the fastest prediction - // mode, and provides correct results for many grammars. This prediction - // mode is more powerful than the prediction mode provided by ANTLR 3, but - // may result in syntax errors for grammar and input combinations which are - // not SLL. - // - // When using this prediction mode, the parser will either return a correct - // parse tree (i.e. the same parse tree that would be returned with the - // [PredictionModeLL] prediction mode), or it will Report a syntax error. If a - // syntax error is encountered when using the SLL prediction mode, - // it may be due to either an actual syntax error in the input or indicate - // that the particular combination of grammar and input requires the more - // powerful LL prediction abilities to complete successfully. - // - // This prediction mode does not provide any guarantees for prediction - // behavior for syntactically-incorrect inputs. - // - PredictionModeSLL = 0 - - // PredictionModeLL represents the LL(*) prediction mode. - // This prediction mode allows the current parser - // context to be used for resolving SLL conflicts that occur during - // prediction. This is the fastest prediction mode that guarantees correct - // parse results for all combinations of grammars with syntactically correct - // inputs. - // - // When using this prediction mode, the parser will make correct decisions - // for all syntactically-correct grammar and input combinations. However, in - // cases where the grammar is truly ambiguous this prediction mode might not - // report a precise answer for exactly which alternatives are - // ambiguous. - // - // This prediction mode does not provide any guarantees for prediction - // behavior for syntactically-incorrect inputs. - // - PredictionModeLL = 1 - - // PredictionModeLLExactAmbigDetection represents the LL(*) prediction mode - // with exact ambiguity detection. - // - // In addition to the correctness guarantees provided by the [PredictionModeLL] prediction mode, - // this prediction mode instructs the prediction algorithm to determine the - // complete and exact set of ambiguous alternatives for every ambiguous - // decision encountered while parsing. - // - // This prediction mode may be used for diagnosing ambiguities during - // grammar development. Due to the performance overhead of calculating sets - // of ambiguous alternatives, this prediction mode should be avoided when - // the exact results are not necessary. - // - // This prediction mode does not provide any guarantees for prediction - // behavior for syntactically-incorrect inputs. - // - PredictionModeLLExactAmbigDetection = 2 -) - -// PredictionModehasSLLConflictTerminatingPrediction computes the SLL prediction termination condition. -// -// This method computes the SLL prediction termination condition for both of -// the following cases: -// -// - The usual SLL+LL fallback upon SLL conflict -// - Pure SLL without LL fallback -// -// # Combined SLL+LL Parsing -// -// When LL-fallback is enabled upon SLL conflict, correct predictions are -// ensured regardless of how the termination condition is computed by this -// method. Due to the substantially higher cost of LL prediction, the -// prediction should only fall back to LL when the additional lookahead -// cannot lead to a unique SLL prediction. -// -// Assuming combined SLL+LL parsing, an SLL configuration set with only -// conflicting subsets should fall back to full LL, even if the -// configuration sets don't resolve to the same alternative, e.g. -// -// {1,2} and {3,4} -// -// If there is at least one non-conflicting -// configuration, SLL could continue with the hopes that more lookahead will -// resolve via one of those non-conflicting configurations. -// -// Here's the prediction termination rule them: SLL (for SLL+LL parsing) -// stops when it sees only conflicting configuration subsets. In contrast, -// full LL keeps going when there is uncertainty. -// -// # Heuristic -// -// As a heuristic, we stop prediction when we see any conflicting subset -// unless we see a state that only has one alternative associated with it. -// The single-alt-state thing lets prediction continue upon rules like -// (otherwise, it would admit defeat too soon): -// -// [12|1|[], 6|2|[], 12|2|[]]. s : (ID | ID ID?) ; -// -// When the [ATN] simulation reaches the state before ';', it has a -// [DFA] state that looks like: -// -// [12|1|[], 6|2|[], 12|2|[]] -// -// Naturally -// -// 12|1|[] and 12|2|[] -// -// conflict, but we cannot stop processing this node because alternative to has another way to continue, -// via -// -// [6|2|[]] -// -// It also let's us continue for this rule: -// -// [1|1|[], 1|2|[], 8|3|[]] a : A | A | A B ; -// -// After Matching input A, we reach the stop state for rule A, state 1. -// State 8 is the state immediately before B. Clearly alternatives 1 and 2 -// conflict and no amount of further lookahead will separate the two. -// However, alternative 3 will be able to continue, and so we do not stop -// working on this state. In the previous example, we're concerned with -// states associated with the conflicting alternatives. Here alt 3 is not -// associated with the conflicting configs, but since we can continue -// looking for input reasonably, don't declare the state done. -// -// # Pure SLL Parsing -// -// To handle pure SLL parsing, all we have to do is make sure that we -// combine stack contexts for configurations that differ only by semantic -// predicate. From there, we can do the usual SLL termination heuristic. -// -// # Predicates in SLL+LL Parsing -// -// SLL decisions don't evaluate predicates until after they reach [DFA] stop -// states because they need to create the [DFA] cache that works in all -// semantic situations. In contrast, full LL evaluates predicates collected -// during start state computation, so it can ignore predicates thereafter. -// This means that SLL termination detection can totally ignore semantic -// predicates. -// -// Implementation-wise, [ATNConfigSet] combines stack contexts but not -// semantic predicate contexts, so we might see two configurations like the -// following: -// -// (s, 1, x, {}), (s, 1, x', {p}) -// -// Before testing these configurations against others, we have to merge -// x and x' (without modifying the existing configurations). -// For example, we test (x+x')==x” when looking for conflicts in -// the following configurations: -// -// (s, 1, x, {}), (s, 1, x', {p}), (s, 2, x”, {}) -// -// If the configuration set has predicates (as indicated by -// [ATNConfigSet.hasSemanticContext]), this algorithm makes a copy of -// the configurations to strip out all the predicates so that a standard -// [ATNConfigSet] will merge everything ignoring predicates. -func PredictionModehasSLLConflictTerminatingPrediction(mode int, configs *ATNConfigSet) bool { - - // Configs in rule stop states indicate reaching the end of the decision - // rule (local context) or end of start rule (full context). If all - // configs meet this condition, then none of the configurations is able - // to Match additional input, so we terminate prediction. - // - if PredictionModeallConfigsInRuleStopStates(configs) { - return true - } - - // pure SLL mode parsing - if mode == PredictionModeSLL { - // Don't bother with combining configs from different semantic - // contexts if we can fail over to full LL costs more time - // since we'll often fail over anyway. - if configs.hasSemanticContext { - // dup configs, tossing out semantic predicates - dup := NewATNConfigSet(false) - for _, c := range configs.configs { - - // NewATNConfig({semanticContext:}, c) - c = NewATNConfig2(c, SemanticContextNone) - dup.Add(c, nil) - } - configs = dup - } - // now we have combined contexts for configs with dissimilar predicates - } - // pure SLL or combined SLL+LL mode parsing - altsets := PredictionModegetConflictingAltSubsets(configs) - return PredictionModehasConflictingAltSet(altsets) && !PredictionModehasStateAssociatedWithOneAlt(configs) -} - -// PredictionModehasConfigInRuleStopState checks if any configuration in the given configs is in a -// [RuleStopState]. Configurations meeting this condition have reached -// the end of the decision rule (local context) or end of start rule (full -// context). -// -// The func returns true if any configuration in the supplied configs is in a [RuleStopState] -func PredictionModehasConfigInRuleStopState(configs *ATNConfigSet) bool { - for _, c := range configs.configs { - if _, ok := c.GetState().(*RuleStopState); ok { - return true - } - } - return false -} - -// PredictionModeallConfigsInRuleStopStates checks if all configurations in configs are in a -// [RuleStopState]. Configurations meeting this condition have reached -// the end of the decision rule (local context) or end of start rule (full -// context). -// -// the func returns true if all configurations in configs are in a -// [RuleStopState] -func PredictionModeallConfigsInRuleStopStates(configs *ATNConfigSet) bool { - - for _, c := range configs.configs { - if _, ok := c.GetState().(*RuleStopState); !ok { - return false - } - } - return true -} - -// PredictionModeresolvesToJustOneViableAlt checks full LL prediction termination. -// -// Can we stop looking ahead during [ATN] simulation or is there some -// uncertainty as to which alternative we will ultimately pick, after -// consuming more input? Even if there are partial conflicts, we might know -// that everything is going to resolve to the same minimum alternative. That -// means we can stop since no more lookahead will change that fact. On the -// other hand, there might be multiple conflicts that resolve to different -// minimums. That means we need more look ahead to decide which of those -// alternatives we should predict. -// -// The basic idea is to split the set of configurations 'C', into -// conflicting subsets (s, _, ctx, _) and singleton subsets with -// non-conflicting configurations. Two configurations conflict if they have -// identical [ATNConfig].state and [ATNConfig].context values -// but a different [ATNConfig].alt value, e.g. -// -// (s, i, ctx, _) -// -// and -// -// (s, j, ctx, _) ; for i != j -// -// Reduce these configuration subsets to the set of possible alternatives. -// You can compute the alternative subsets in one pass as follows: -// -// A_s,ctx = {i | (s, i, ctx, _)} -// -// for each configuration in C holding s and ctx fixed. -// -// Or in pseudo-code: -// -// for each configuration c in C: -// map[c] U = c.ATNConfig.alt alt // map hash/equals uses s and x, not alt and not pred -// -// The values in map are the set of -// -// A_s,ctx -// -// sets. -// -// If -// -// |A_s,ctx| = 1 -// -// then there is no conflict associated with s and ctx. -// -// Reduce the subsets to singletons by choosing a minimum of each subset. If -// the union of these alternative subsets is a singleton, then no amount of -// further lookahead will help us. We will always pick that alternative. If, -// however, there is more than one alternative, then we are uncertain which -// alternative to predict and must continue looking for resolution. We may -// or may not discover an ambiguity in the future, even if there are no -// conflicting subsets this round. -// -// The biggest sin is to terminate early because it means we've made a -// decision but were uncertain as to the eventual outcome. We haven't used -// enough lookahead. On the other hand, announcing a conflict too late is no -// big deal; you will still have the conflict. It's just inefficient. It -// might even look until the end of file. -// -// No special consideration for semantic predicates is required because -// predicates are evaluated on-the-fly for full LL prediction, ensuring that -// no configuration contains a semantic context during the termination -// check. -// -// # Conflicting Configs -// -// Two configurations: -// -// (s, i, x) and (s, j, x') -// -// conflict when i != j but x = x'. Because we merge all -// (s, i, _) configurations together, that means that there are at -// most n configurations associated with state s for -// n possible alternatives in the decision. The merged stacks -// complicate the comparison of configuration contexts x and x'. -// -// Sam checks to see if one is a subset of the other by calling -// merge and checking to see if the merged result is either x or x'. -// If the x associated with lowest alternative i -// is the superset, then i is the only possible prediction since the -// others resolve to min(i) as well. However, if x is -// associated with j > i then at least one stack configuration for -// j is not in conflict with alternative i. The algorithm -// should keep going, looking for more lookahead due to the uncertainty. -// -// For simplicity, I'm doing an equality check between x and -// x', which lets the algorithm continue to consume lookahead longer -// than necessary. The reason I like the equality is of course the -// simplicity but also because that is the test you need to detect the -// alternatives that are actually in conflict. -// -// # Continue/Stop Rule -// -// Continue if the union of resolved alternative sets from non-conflicting and -// conflicting alternative subsets has more than one alternative. We are -// uncertain about which alternative to predict. -// -// The complete set of alternatives, -// -// [i for (_, i, _)] -// -// tells us which alternatives are still in the running for the amount of input we've -// consumed at this point. The conflicting sets let us to strip away -// configurations that won't lead to more states because we resolve -// conflicts to the configuration with a minimum alternate for the -// conflicting set. -// -// Cases -// -// - no conflicts and more than 1 alternative in set => continue -// - (s, 1, x), (s, 2, x), (s, 3, z), (s', 1, y), (s', 2, y) yields non-conflicting set -// {3} ∪ conflicting sets min({1,2}) ∪ min({1,2}) = {1,3} => continue -// - (s, 1, x), (s, 2, x), (s', 1, y), (s', 2, y), (s”, 1, z) yields non-conflicting set -// {1} ∪ conflicting sets min({1,2}) ∪ min({1,2}) = {1} => stop and predict 1 -// - (s, 1, x), (s, 2, x), (s', 1, y), (s', 2, y) yields conflicting, reduced sets -// {1} ∪ {1} = {1} => stop and predict 1, can announce ambiguity {1,2} -// - (s, 1, x), (s, 2, x), (s', 2, y), (s', 3, y) yields conflicting, reduced sets -// {1} ∪ {2} = {1,2} => continue -// - (s, 1, x), (s, 2, x), (s', 2, y), (s', 3, y) yields conflicting, reduced sets -// {1} ∪ {2} = {1,2} => continue -// - (s, 1, x), (s, 2, x), (s', 3, y), (s', 4, y) yields conflicting, reduced sets -// {1} ∪ {3} = {1,3} => continue -// -// # Exact Ambiguity Detection -// -// If all states report the same conflicting set of alternatives, then we -// know we have the exact ambiguity set: -// -// |A_i| > 1 -// -// and -// -// A_i = A_j ; for all i, j -// -// In other words, we continue examining lookahead until all A_i -// have more than one alternative and all A_i are the same. If -// -// A={{1,2}, {1,3}} -// -// then regular LL prediction would terminate because the resolved set is {1}. -// To determine what the real ambiguity is, we have to know whether the ambiguity is between one and -// two or one and three so we keep going. We can only stop prediction when -// we need exact ambiguity detection when the sets look like: -// -// A={{1,2}} -// -// or -// -// {{1,2},{1,2}}, etc... -func PredictionModeresolvesToJustOneViableAlt(altsets []*BitSet) int { - return PredictionModegetSingleViableAlt(altsets) -} - -// PredictionModeallSubsetsConflict determines if every alternative subset in altsets contains more -// than one alternative. -// -// The func returns true if every [BitSet] in altsets has -// [BitSet].cardinality cardinality > 1 -func PredictionModeallSubsetsConflict(altsets []*BitSet) bool { - return !PredictionModehasNonConflictingAltSet(altsets) -} - -// PredictionModehasNonConflictingAltSet determines if any single alternative subset in altsets contains -// exactly one alternative. -// -// The func returns true if altsets contains at least one [BitSet] with -// [BitSet].cardinality cardinality 1 -func PredictionModehasNonConflictingAltSet(altsets []*BitSet) bool { - for i := 0; i < len(altsets); i++ { - alts := altsets[i] - if alts.length() == 1 { - return true - } - } - return false -} - -// PredictionModehasConflictingAltSet determines if any single alternative subset in altsets contains -// more than one alternative. -// -// The func returns true if altsets contains a [BitSet] with -// [BitSet].cardinality cardinality > 1, otherwise false -func PredictionModehasConflictingAltSet(altsets []*BitSet) bool { - for i := 0; i < len(altsets); i++ { - alts := altsets[i] - if alts.length() > 1 { - return true - } - } - return false -} - -// PredictionModeallSubsetsEqual determines if every alternative subset in altsets is equivalent. -// -// The func returns true if every member of altsets is equal to the others. -func PredictionModeallSubsetsEqual(altsets []*BitSet) bool { - var first *BitSet - - for i := 0; i < len(altsets); i++ { - alts := altsets[i] - if first == nil { - first = alts - } else if alts != first { - return false - } - } - - return true -} - -// PredictionModegetUniqueAlt returns the unique alternative predicted by all alternative subsets in -// altsets. If no such alternative exists, this method returns -// [ATNInvalidAltNumber]. -// -// @param altsets a collection of alternative subsets -func PredictionModegetUniqueAlt(altsets []*BitSet) int { - all := PredictionModeGetAlts(altsets) - if all.length() == 1 { - return all.minValue() - } - - return ATNInvalidAltNumber -} - -// PredictionModeGetAlts returns the complete set of represented alternatives for a collection of -// alternative subsets. This method returns the union of each [BitSet] -// in altsets, being the set of represented alternatives in altsets. -func PredictionModeGetAlts(altsets []*BitSet) *BitSet { - all := NewBitSet() - for _, alts := range altsets { - all.or(alts) - } - return all -} - -// PredictionModegetConflictingAltSubsets gets the conflicting alt subsets from a configuration set. -// -// for each configuration c in configs: -// map[c] U= c.ATNConfig.alt // map hash/equals uses s and x, not alt and not pred -func PredictionModegetConflictingAltSubsets(configs *ATNConfigSet) []*BitSet { - configToAlts := NewJMap[*ATNConfig, *BitSet, *ATNAltConfigComparator[*ATNConfig]](atnAltCfgEqInst, AltSetCollection, "PredictionModegetConflictingAltSubsets()") - - for _, c := range configs.configs { - - alts, ok := configToAlts.Get(c) - if !ok { - alts = NewBitSet() - configToAlts.Put(c, alts) - } - alts.add(c.GetAlt()) - } - - return configToAlts.Values() -} - -// PredictionModeGetStateToAltMap gets a map from state to alt subset from a configuration set. -// -// for each configuration c in configs: -// map[c.ATNConfig.state] U= c.ATNConfig.alt} -func PredictionModeGetStateToAltMap(configs *ATNConfigSet) *AltDict { - m := NewAltDict() - - for _, c := range configs.configs { - alts := m.Get(c.GetState().String()) - if alts == nil { - alts = NewBitSet() - m.put(c.GetState().String(), alts) - } - alts.(*BitSet).add(c.GetAlt()) - } - return m -} - -func PredictionModehasStateAssociatedWithOneAlt(configs *ATNConfigSet) bool { - values := PredictionModeGetStateToAltMap(configs).values() - for i := 0; i < len(values); i++ { - if values[i].(*BitSet).length() == 1 { - return true - } - } - return false -} - -// PredictionModegetSingleViableAlt gets the single alternative predicted by all alternative subsets in altsets -// if there is one. -// -// TODO: JI - Review this code - it does not seem to do the same thing as the Java code - maybe because [BitSet] is not like the Java utils BitSet -func PredictionModegetSingleViableAlt(altsets []*BitSet) int { - result := ATNInvalidAltNumber - - for i := 0; i < len(altsets); i++ { - alts := altsets[i] - minAlt := alts.minValue() - if result == ATNInvalidAltNumber { - result = minAlt - } else if result != minAlt { // more than 1 viable alt - return ATNInvalidAltNumber - } - } - return result -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/recognizer.go b/vendor/github.com/antlr4-go/antlr/v4/recognizer.go deleted file mode 100644 index 2e0b504fb..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/recognizer.go +++ /dev/null @@ -1,241 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import ( - "fmt" - "strings" - - "strconv" -) - -type Recognizer interface { - GetLiteralNames() []string - GetSymbolicNames() []string - GetRuleNames() []string - - Sempred(RuleContext, int, int) bool - Precpred(RuleContext, int) bool - - GetState() int - SetState(int) - Action(RuleContext, int, int) - AddErrorListener(ErrorListener) - RemoveErrorListeners() - GetATN() *ATN - GetErrorListenerDispatch() ErrorListener - HasError() bool - GetError() RecognitionException - SetError(RecognitionException) -} - -type BaseRecognizer struct { - listeners []ErrorListener - state int - - RuleNames []string - LiteralNames []string - SymbolicNames []string - GrammarFileName string - SynErr RecognitionException -} - -func NewBaseRecognizer() *BaseRecognizer { - rec := new(BaseRecognizer) - rec.listeners = []ErrorListener{ConsoleErrorListenerINSTANCE} - rec.state = -1 - return rec -} - -//goland:noinspection GoUnusedGlobalVariable -var tokenTypeMapCache = make(map[string]int) - -//goland:noinspection GoUnusedGlobalVariable -var ruleIndexMapCache = make(map[string]int) - -func (b *BaseRecognizer) checkVersion(toolVersion string) { - runtimeVersion := "4.12.0" - if runtimeVersion != toolVersion { - fmt.Println("ANTLR runtime and generated code versions disagree: " + runtimeVersion + "!=" + toolVersion) - } -} - -func (b *BaseRecognizer) SetError(err RecognitionException) { - b.SynErr = err -} - -func (b *BaseRecognizer) HasError() bool { - return b.SynErr != nil -} - -func (b *BaseRecognizer) GetError() RecognitionException { - return b.SynErr -} - -func (b *BaseRecognizer) Action(_ RuleContext, _, _ int) { - panic("action not implemented on Recognizer!") -} - -func (b *BaseRecognizer) AddErrorListener(listener ErrorListener) { - b.listeners = append(b.listeners, listener) -} - -func (b *BaseRecognizer) RemoveErrorListeners() { - b.listeners = make([]ErrorListener, 0) -} - -func (b *BaseRecognizer) GetRuleNames() []string { - return b.RuleNames -} - -func (b *BaseRecognizer) GetTokenNames() []string { - return b.LiteralNames -} - -func (b *BaseRecognizer) GetSymbolicNames() []string { - return b.SymbolicNames -} - -func (b *BaseRecognizer) GetLiteralNames() []string { - return b.LiteralNames -} - -func (b *BaseRecognizer) GetState() int { - return b.state -} - -func (b *BaseRecognizer) SetState(v int) { - b.state = v -} - -//func (b *Recognizer) GetTokenTypeMap() { -// var tokenNames = b.GetTokenNames() -// if (tokenNames==nil) { -// panic("The current recognizer does not provide a list of token names.") -// } -// var result = tokenTypeMapCache[tokenNames] -// if(result==nil) { -// result = tokenNames.reduce(function(o, k, i) { o[k] = i }) -// result.EOF = TokenEOF -// tokenTypeMapCache[tokenNames] = result -// } -// return result -//} - -// GetRuleIndexMap Get a map from rule names to rule indexes. -// -// Used for XPath and tree pattern compilation. -// -// TODO: JI This is not yet implemented in the Go runtime. Maybe not needed. -func (b *BaseRecognizer) GetRuleIndexMap() map[string]int { - - panic("Method not defined!") - // var ruleNames = b.GetRuleNames() - // if (ruleNames==nil) { - // panic("The current recognizer does not provide a list of rule names.") - // } - // - // var result = ruleIndexMapCache[ruleNames] - // if(result==nil) { - // result = ruleNames.reduce(function(o, k, i) { o[k] = i }) - // ruleIndexMapCache[ruleNames] = result - // } - // return result -} - -// GetTokenType get the token type based upon its name -func (b *BaseRecognizer) GetTokenType(_ string) int { - panic("Method not defined!") - // var ttype = b.GetTokenTypeMap()[tokenName] - // if (ttype !=nil) { - // return ttype - // } else { - // return TokenInvalidType - // } -} - -//func (b *Recognizer) GetTokenTypeMap() map[string]int { -// Vocabulary vocabulary = getVocabulary() -// -// Synchronized (tokenTypeMapCache) { -// Map result = tokenTypeMapCache.Get(vocabulary) -// if (result == null) { -// result = new HashMap() -// for (int i = 0; i < GetATN().maxTokenType; i++) { -// String literalName = vocabulary.getLiteralName(i) -// if (literalName != null) { -// result.put(literalName, i) -// } -// -// String symbolicName = vocabulary.GetSymbolicName(i) -// if (symbolicName != null) { -// result.put(symbolicName, i) -// } -// } -// -// result.put("EOF", Token.EOF) -// result = Collections.unmodifiableMap(result) -// tokenTypeMapCache.put(vocabulary, result) -// } -// -// return result -// } -//} - -// GetErrorHeader returns the error header, normally line/character position information. -// -// Can be overridden in sub structs embedding BaseRecognizer. -func (b *BaseRecognizer) GetErrorHeader(e RecognitionException) string { - line := e.GetOffendingToken().GetLine() - column := e.GetOffendingToken().GetColumn() - return "line " + strconv.Itoa(line) + ":" + strconv.Itoa(column) -} - -// GetTokenErrorDisplay shows how a token should be displayed in an error message. -// -// The default is to display just the text, but during development you might -// want to have a lot of information spit out. Override in that case -// to use t.String() (which, for CommonToken, dumps everything about -// the token). This is better than forcing you to override a method in -// your token objects because you don't have to go modify your lexer -// so that it creates a NewJava type. -// -// Deprecated: This method is not called by the ANTLR 4 Runtime. Specific -// implementations of [ANTLRErrorStrategy] may provide a similar -// feature when necessary. For example, see [DefaultErrorStrategy].GetTokenErrorDisplay() -func (b *BaseRecognizer) GetTokenErrorDisplay(t Token) string { - if t == nil { - return "" - } - s := t.GetText() - if s == "" { - if t.GetTokenType() == TokenEOF { - s = "" - } else { - s = "<" + strconv.Itoa(t.GetTokenType()) + ">" - } - } - s = strings.Replace(s, "\t", "\\t", -1) - s = strings.Replace(s, "\n", "\\n", -1) - s = strings.Replace(s, "\r", "\\r", -1) - - return "'" + s + "'" -} - -func (b *BaseRecognizer) GetErrorListenerDispatch() ErrorListener { - return NewProxyErrorListener(b.listeners) -} - -// Sempred embedding structs need to override this if there are sempreds or actions -// that the ATN interpreter needs to execute -func (b *BaseRecognizer) Sempred(_ RuleContext, _ int, _ int) bool { - return true -} - -// Precpred embedding structs need to override this if there are preceding predicates -// that the ATN interpreter needs to execute -func (b *BaseRecognizer) Precpred(_ RuleContext, _ int) bool { - return true -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/rule_context.go b/vendor/github.com/antlr4-go/antlr/v4/rule_context.go deleted file mode 100644 index f2ad04793..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/rule_context.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -// RuleContext is a record of a single rule invocation. It knows -// which context invoked it, if any. If there is no parent context, then -// naturally the invoking state is not valid. The parent link -// provides a chain upwards from the current rule invocation to the root -// of the invocation tree, forming a stack. -// -// We actually carry no information about the rule associated with this context (except -// when parsing). We keep only the state number of the invoking state from -// the [ATN] submachine that invoked this. Contrast this with the s -// pointer inside [ParserRuleContext] that tracks the current state -// being "executed" for the current rule. -// -// The parent contexts are useful for computing lookahead sets and -// getting error information. -// -// These objects are used during parsing and prediction. -// For the special case of parsers, we use the struct -// [ParserRuleContext], which embeds a RuleContext. -// -// @see ParserRuleContext -type RuleContext interface { - RuleNode - - GetInvokingState() int - SetInvokingState(int) - - GetRuleIndex() int - IsEmpty() bool - - GetAltNumber() int - SetAltNumber(altNumber int) - - String([]string, RuleContext) string -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/semantic_context.go b/vendor/github.com/antlr4-go/antlr/v4/semantic_context.go deleted file mode 100644 index 68cb9061e..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/semantic_context.go +++ /dev/null @@ -1,464 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import ( - "fmt" - "strconv" -) - -// SemanticContext is a tree structure used to record the semantic context in which -// -// an ATN configuration is valid. It's either a single predicate, -// a conjunction p1 && p2, or a sum of products p1 || p2. -// -// I have scoped the AND, OR, and Predicate subclasses of -// [SemanticContext] within the scope of this outer ``class'' -type SemanticContext interface { - Equals(other Collectable[SemanticContext]) bool - Hash() int - - evaluate(parser Recognizer, outerContext RuleContext) bool - evalPrecedence(parser Recognizer, outerContext RuleContext) SemanticContext - - String() string -} - -func SemanticContextandContext(a, b SemanticContext) SemanticContext { - if a == nil || a == SemanticContextNone { - return b - } - if b == nil || b == SemanticContextNone { - return a - } - result := NewAND(a, b) - if len(result.opnds) == 1 { - return result.opnds[0] - } - - return result -} - -func SemanticContextorContext(a, b SemanticContext) SemanticContext { - if a == nil { - return b - } - if b == nil { - return a - } - if a == SemanticContextNone || b == SemanticContextNone { - return SemanticContextNone - } - result := NewOR(a, b) - if len(result.opnds) == 1 { - return result.opnds[0] - } - - return result -} - -type Predicate struct { - ruleIndex int - predIndex int - isCtxDependent bool -} - -func NewPredicate(ruleIndex, predIndex int, isCtxDependent bool) *Predicate { - p := new(Predicate) - - p.ruleIndex = ruleIndex - p.predIndex = predIndex - p.isCtxDependent = isCtxDependent // e.g., $i ref in pred - return p -} - -//The default {@link SemanticContext}, which is semantically equivalent to -//a predicate of the form {@code {true}?}. - -var SemanticContextNone = NewPredicate(-1, -1, false) - -func (p *Predicate) evalPrecedence(_ Recognizer, _ RuleContext) SemanticContext { - return p -} - -func (p *Predicate) evaluate(parser Recognizer, outerContext RuleContext) bool { - - var localctx RuleContext - - if p.isCtxDependent { - localctx = outerContext - } - - return parser.Sempred(localctx, p.ruleIndex, p.predIndex) -} - -func (p *Predicate) Equals(other Collectable[SemanticContext]) bool { - if p == other { - return true - } else if _, ok := other.(*Predicate); !ok { - return false - } else { - return p.ruleIndex == other.(*Predicate).ruleIndex && - p.predIndex == other.(*Predicate).predIndex && - p.isCtxDependent == other.(*Predicate).isCtxDependent - } -} - -func (p *Predicate) Hash() int { - h := murmurInit(0) - h = murmurUpdate(h, p.ruleIndex) - h = murmurUpdate(h, p.predIndex) - if p.isCtxDependent { - h = murmurUpdate(h, 1) - } else { - h = murmurUpdate(h, 0) - } - return murmurFinish(h, 3) -} - -func (p *Predicate) String() string { - return "{" + strconv.Itoa(p.ruleIndex) + ":" + strconv.Itoa(p.predIndex) + "}?" -} - -type PrecedencePredicate struct { - precedence int -} - -func NewPrecedencePredicate(precedence int) *PrecedencePredicate { - - p := new(PrecedencePredicate) - p.precedence = precedence - - return p -} - -func (p *PrecedencePredicate) evaluate(parser Recognizer, outerContext RuleContext) bool { - return parser.Precpred(outerContext, p.precedence) -} - -func (p *PrecedencePredicate) evalPrecedence(parser Recognizer, outerContext RuleContext) SemanticContext { - if parser.Precpred(outerContext, p.precedence) { - return SemanticContextNone - } - - return nil -} - -func (p *PrecedencePredicate) compareTo(other *PrecedencePredicate) int { - return p.precedence - other.precedence -} - -func (p *PrecedencePredicate) Equals(other Collectable[SemanticContext]) bool { - - var op *PrecedencePredicate - var ok bool - if op, ok = other.(*PrecedencePredicate); !ok { - return false - } - - if p == op { - return true - } - - return p.precedence == other.(*PrecedencePredicate).precedence -} - -func (p *PrecedencePredicate) Hash() int { - h := uint32(1) - h = 31*h + uint32(p.precedence) - return int(h) -} - -func (p *PrecedencePredicate) String() string { - return "{" + strconv.Itoa(p.precedence) + ">=prec}?" -} - -func PrecedencePredicatefilterPrecedencePredicates(set *JStore[SemanticContext, Comparator[SemanticContext]]) []*PrecedencePredicate { - result := make([]*PrecedencePredicate, 0) - - set.Each(func(v SemanticContext) bool { - if c2, ok := v.(*PrecedencePredicate); ok { - result = append(result, c2) - } - return true - }) - - return result -} - -// A semantic context which is true whenever none of the contained contexts -// is false.` - -type AND struct { - opnds []SemanticContext -} - -func NewAND(a, b SemanticContext) *AND { - - operands := NewJStore[SemanticContext, Comparator[SemanticContext]](semctxEqInst, SemanticContextCollection, "NewAND() operands") - if aa, ok := a.(*AND); ok { - for _, o := range aa.opnds { - operands.Put(o) - } - } else { - operands.Put(a) - } - - if ba, ok := b.(*AND); ok { - for _, o := range ba.opnds { - operands.Put(o) - } - } else { - operands.Put(b) - } - precedencePredicates := PrecedencePredicatefilterPrecedencePredicates(operands) - if len(precedencePredicates) > 0 { - // interested in the transition with the lowest precedence - var reduced *PrecedencePredicate - - for _, p := range precedencePredicates { - if reduced == nil || p.precedence < reduced.precedence { - reduced = p - } - } - - operands.Put(reduced) - } - - vs := operands.Values() - opnds := make([]SemanticContext, len(vs)) - copy(opnds, vs) - - and := new(AND) - and.opnds = opnds - - return and -} - -func (a *AND) Equals(other Collectable[SemanticContext]) bool { - if a == other { - return true - } - if _, ok := other.(*AND); !ok { - return false - } else { - for i, v := range other.(*AND).opnds { - if !a.opnds[i].Equals(v) { - return false - } - } - return true - } -} - -// {@inheritDoc} -// -//

-// The evaluation of predicates by a context is short-circuiting, but -// unordered.

-func (a *AND) evaluate(parser Recognizer, outerContext RuleContext) bool { - for i := 0; i < len(a.opnds); i++ { - if !a.opnds[i].evaluate(parser, outerContext) { - return false - } - } - return true -} - -func (a *AND) evalPrecedence(parser Recognizer, outerContext RuleContext) SemanticContext { - differs := false - operands := make([]SemanticContext, 0) - - for i := 0; i < len(a.opnds); i++ { - context := a.opnds[i] - evaluated := context.evalPrecedence(parser, outerContext) - differs = differs || (evaluated != context) - if evaluated == nil { - // The AND context is false if any element is false - return nil - } else if evaluated != SemanticContextNone { - // Reduce the result by Skipping true elements - operands = append(operands, evaluated) - } - } - if !differs { - return a - } - - if len(operands) == 0 { - // all elements were true, so the AND context is true - return SemanticContextNone - } - - var result SemanticContext - - for _, o := range operands { - if result == nil { - result = o - } else { - result = SemanticContextandContext(result, o) - } - } - - return result -} - -func (a *AND) Hash() int { - h := murmurInit(37) // Init with a value different from OR - for _, op := range a.opnds { - h = murmurUpdate(h, op.Hash()) - } - return murmurFinish(h, len(a.opnds)) -} - -func (o *OR) Hash() int { - h := murmurInit(41) // Init with o value different from AND - for _, op := range o.opnds { - h = murmurUpdate(h, op.Hash()) - } - return murmurFinish(h, len(o.opnds)) -} - -func (a *AND) String() string { - s := "" - - for _, o := range a.opnds { - s += "&& " + fmt.Sprint(o) - } - - if len(s) > 3 { - return s[0:3] - } - - return s -} - -// -// A semantic context which is true whenever at least one of the contained -// contexts is true. -// - -type OR struct { - opnds []SemanticContext -} - -func NewOR(a, b SemanticContext) *OR { - - operands := NewJStore[SemanticContext, Comparator[SemanticContext]](semctxEqInst, SemanticContextCollection, "NewOR() operands") - if aa, ok := a.(*OR); ok { - for _, o := range aa.opnds { - operands.Put(o) - } - } else { - operands.Put(a) - } - - if ba, ok := b.(*OR); ok { - for _, o := range ba.opnds { - operands.Put(o) - } - } else { - operands.Put(b) - } - precedencePredicates := PrecedencePredicatefilterPrecedencePredicates(operands) - if len(precedencePredicates) > 0 { - // interested in the transition with the lowest precedence - var reduced *PrecedencePredicate - - for _, p := range precedencePredicates { - if reduced == nil || p.precedence > reduced.precedence { - reduced = p - } - } - - operands.Put(reduced) - } - - vs := operands.Values() - - opnds := make([]SemanticContext, len(vs)) - copy(opnds, vs) - - o := new(OR) - o.opnds = opnds - - return o -} - -func (o *OR) Equals(other Collectable[SemanticContext]) bool { - if o == other { - return true - } else if _, ok := other.(*OR); !ok { - return false - } else { - for i, v := range other.(*OR).opnds { - if !o.opnds[i].Equals(v) { - return false - } - } - return true - } -} - -//

-// The evaluation of predicates by o context is short-circuiting, but -// unordered.

-func (o *OR) evaluate(parser Recognizer, outerContext RuleContext) bool { - for i := 0; i < len(o.opnds); i++ { - if o.opnds[i].evaluate(parser, outerContext) { - return true - } - } - return false -} - -func (o *OR) evalPrecedence(parser Recognizer, outerContext RuleContext) SemanticContext { - differs := false - operands := make([]SemanticContext, 0) - for i := 0; i < len(o.opnds); i++ { - context := o.opnds[i] - evaluated := context.evalPrecedence(parser, outerContext) - differs = differs || (evaluated != context) - if evaluated == SemanticContextNone { - // The OR context is true if any element is true - return SemanticContextNone - } else if evaluated != nil { - // Reduce the result by Skipping false elements - operands = append(operands, evaluated) - } - } - if !differs { - return o - } - if len(operands) == 0 { - // all elements were false, so the OR context is false - return nil - } - var result SemanticContext - - for _, o := range operands { - if result == nil { - result = o - } else { - result = SemanticContextorContext(result, o) - } - } - - return result -} - -func (o *OR) String() string { - s := "" - - for _, o := range o.opnds { - s += "|| " + fmt.Sprint(o) - } - - if len(s) > 3 { - return s[0:3] - } - - return s -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/statistics.go b/vendor/github.com/antlr4-go/antlr/v4/statistics.go deleted file mode 100644 index 70c0673a0..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/statistics.go +++ /dev/null @@ -1,281 +0,0 @@ -//go:build antlr.stats - -package antlr - -import ( - "fmt" - "log" - "os" - "path/filepath" - "sort" - "strconv" - "sync" -) - -// This file allows the user to collect statistics about the runtime of the ANTLR runtime. It is not enabled by default -// and so incurs no time penalty. To enable it, you must build the runtime with the antlr.stats build tag. -// - -// Tells various components to collect statistics - because it is only true when this file is included, it will -// allow the compiler to completely eliminate all the code that is only used when collecting statistics. -const collectStats = true - -// goRunStats is a collection of all the various data the ANTLR runtime has collected about a particular run. -// It is exported so that it can be used by others to look for things that are not already looked for in the -// runtime statistics. -type goRunStats struct { - - // jStats is a slice of all the [JStatRec] records that have been created, which is one for EVERY collection created - // during a run. It is exported so that it can be used by others to look for things that are not already looked for - // within this package. - // - jStats []*JStatRec - jStatsLock sync.RWMutex - topN int - topNByMax []*JStatRec - topNByUsed []*JStatRec - unusedCollections map[CollectionSource]int - counts map[CollectionSource]int -} - -const ( - collectionsFile = "collections" -) - -var ( - Statistics = &goRunStats{ - topN: 10, - } -) - -type statsOption func(*goRunStats) error - -// Configure allows the statistics system to be configured as the user wants and override the defaults -func (s *goRunStats) Configure(options ...statsOption) error { - for _, option := range options { - err := option(s) - if err != nil { - return err - } - } - return nil -} - -// WithTopN sets the number of things to list in the report when we are concerned with the top N things. -// -// For example, if you want to see the top 20 collections by size, you can do: -// -// antlr.Statistics.Configure(antlr.WithTopN(20)) -func WithTopN(topN int) statsOption { - return func(s *goRunStats) error { - s.topN = topN - return nil - } -} - -// Analyze looks through all the statistical records and computes all the outputs that might be useful to the user. -// -// The function gathers and analyzes a number of statistics about any particular run of -// an ANTLR generated recognizer. In the vast majority of cases, the statistics are only -// useful to maintainers of ANTLR itself, but they can be useful to users as well. They may be -// especially useful in tracking down bugs or performance problems when an ANTLR user could -// supply the output from this package, but cannot supply the grammar file(s) they are using, even -// privately to the maintainers. -// -// The statistics are gathered by the runtime itself, and are not gathered by the parser or lexer, but the user -// must call this function their selves to analyze the statistics. This is because none of the infrastructure is -// extant unless the calling program is built with the antlr.stats tag like so: -// -// go build -tags antlr.stats . -// -// When a program is built with the antlr.stats tag, the Statistics object is created and available outside -// the package. The user can then call the [Statistics.Analyze] function to analyze the statistics and then call the -// [Statistics.Report] function to report the statistics. -// -// Please forward any questions about this package to the ANTLR discussion groups on GitHub or send to them to -// me [Jim Idle] directly at jimi@idle.ws -// -// [Jim Idle]: https:://github.com/jim-idle -func (s *goRunStats) Analyze() { - - // Look for anything that looks strange and record it in our local maps etc for the report to present it - // - s.CollectionAnomalies() - s.TopNCollections() -} - -// TopNCollections looks through all the statistical records and gathers the top ten collections by size. -func (s *goRunStats) TopNCollections() { - - // Let's sort the stat records by MaxSize - // - sort.Slice(s.jStats, func(i, j int) bool { - return s.jStats[i].MaxSize > s.jStats[j].MaxSize - }) - - for i := 0; i < len(s.jStats) && i < s.topN; i++ { - s.topNByMax = append(s.topNByMax, s.jStats[i]) - } - - // Sort by the number of times used - // - sort.Slice(s.jStats, func(i, j int) bool { - return s.jStats[i].Gets+s.jStats[i].Puts > s.jStats[j].Gets+s.jStats[j].Puts - }) - for i := 0; i < len(s.jStats) && i < s.topN; i++ { - s.topNByUsed = append(s.topNByUsed, s.jStats[i]) - } -} - -// Report dumps a markdown formatted report of all the statistics collected during a run to the given dir output -// path, which should represent a directory. Generated files will be prefixed with the given prefix and will be -// given a type name such as `anomalies` and a time stamp such as `2021-09-01T12:34:56` and a .md suffix. -func (s *goRunStats) Report(dir string, prefix string) error { - - isDir, err := isDirectory(dir) - switch { - case err != nil: - return err - case !isDir: - return fmt.Errorf("output directory `%s` is not a directory", dir) - } - s.reportCollections(dir, prefix) - - // Clean out any old data in case the user forgets - // - s.Reset() - return nil -} - -func (s *goRunStats) Reset() { - s.jStats = nil - s.topNByUsed = nil - s.topNByMax = nil -} - -func (s *goRunStats) reportCollections(dir, prefix string) { - cname := filepath.Join(dir, ".asciidoctor") - // If the file doesn't exist, create it, or append to the file - f, err := os.OpenFile(cname, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) - if err != nil { - log.Fatal(err) - } - _, _ = f.WriteString(`// .asciidoctorconfig -++++ - -++++`) - _ = f.Close() - - fname := filepath.Join(dir, prefix+"_"+"_"+collectionsFile+"_"+".adoc") - // If the file doesn't exist, create it, or append to the file - f, err = os.OpenFile(fname, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) - if err != nil { - log.Fatal(err) - } - defer func(f *os.File) { - err := f.Close() - if err != nil { - log.Fatal(err) - } - }(f) - _, _ = f.WriteString("= Collections for " + prefix + "\n\n") - - _, _ = f.WriteString("== Summary\n") - - if s.unusedCollections != nil { - _, _ = f.WriteString("=== Unused Collections\n") - _, _ = f.WriteString("Unused collections incur a penalty for allocation that makes them a candidate for either\n") - _, _ = f.WriteString(" removal or optimization. If you are using a collection that is not used, you should\n") - _, _ = f.WriteString(" consider removing it. If you are using a collection that is used, but not very often,\n") - _, _ = f.WriteString(" you should consider using lazy initialization to defer the allocation until it is\n") - _, _ = f.WriteString(" actually needed.\n\n") - - _, _ = f.WriteString("\n.Unused collections\n") - _, _ = f.WriteString(`[cols="<3,>1"]` + "\n\n") - _, _ = f.WriteString("|===\n") - _, _ = f.WriteString("| Type | Count\n") - - for k, v := range s.unusedCollections { - _, _ = f.WriteString("| " + CollectionDescriptors[k].SybolicName + " | " + strconv.Itoa(v) + "\n") - } - f.WriteString("|===\n\n") - } - - _, _ = f.WriteString("\n.Summary of Collections\n") - _, _ = f.WriteString(`[cols="<3,>1"]` + "\n\n") - _, _ = f.WriteString("|===\n") - _, _ = f.WriteString("| Type | Count\n") - for k, v := range s.counts { - _, _ = f.WriteString("| " + CollectionDescriptors[k].SybolicName + " | " + strconv.Itoa(v) + "\n") - } - _, _ = f.WriteString("| Total | " + strconv.Itoa(len(s.jStats)) + "\n") - _, _ = f.WriteString("|===\n\n") - - _, _ = f.WriteString("\n.Summary of Top " + strconv.Itoa(s.topN) + " Collections by MaxSize\n") - _, _ = f.WriteString(`[cols="<1,<3,>1,>1,>1,>1"]` + "\n\n") - _, _ = f.WriteString("|===\n") - _, _ = f.WriteString("| Source | Description | MaxSize | EndSize | Puts | Gets\n") - for _, c := range s.topNByMax { - _, _ = f.WriteString("| " + CollectionDescriptors[c.Source].SybolicName + "\n") - _, _ = f.WriteString("| " + c.Description + "\n") - _, _ = f.WriteString("| " + strconv.Itoa(c.MaxSize) + "\n") - _, _ = f.WriteString("| " + strconv.Itoa(c.CurSize) + "\n") - _, _ = f.WriteString("| " + strconv.Itoa(c.Puts) + "\n") - _, _ = f.WriteString("| " + strconv.Itoa(c.Gets) + "\n") - _, _ = f.WriteString("\n") - } - _, _ = f.WriteString("|===\n\n") - - _, _ = f.WriteString("\n.Summary of Top " + strconv.Itoa(s.topN) + " Collections by Access\n") - _, _ = f.WriteString(`[cols="<1,<3,>1,>1,>1,>1,>1"]` + "\n\n") - _, _ = f.WriteString("|===\n") - _, _ = f.WriteString("| Source | Description | MaxSize | EndSize | Puts | Gets | P+G\n") - for _, c := range s.topNByUsed { - _, _ = f.WriteString("| " + CollectionDescriptors[c.Source].SybolicName + "\n") - _, _ = f.WriteString("| " + c.Description + "\n") - _, _ = f.WriteString("| " + strconv.Itoa(c.MaxSize) + "\n") - _, _ = f.WriteString("| " + strconv.Itoa(c.CurSize) + "\n") - _, _ = f.WriteString("| " + strconv.Itoa(c.Puts) + "\n") - _, _ = f.WriteString("| " + strconv.Itoa(c.Gets) + "\n") - _, _ = f.WriteString("| " + strconv.Itoa(c.Gets+c.Puts) + "\n") - _, _ = f.WriteString("\n") - } - _, _ = f.WriteString("|===\n\n") -} - -// AddJStatRec adds a [JStatRec] record to the [goRunStats] collection when build runtimeConfig antlr.stats is enabled. -func (s *goRunStats) AddJStatRec(rec *JStatRec) { - s.jStatsLock.Lock() - defer s.jStatsLock.Unlock() - s.jStats = append(s.jStats, rec) -} - -// CollectionAnomalies looks through all the statistical records and gathers any anomalies that have been found. -func (s *goRunStats) CollectionAnomalies() { - s.jStatsLock.RLock() - defer s.jStatsLock.RUnlock() - s.counts = make(map[CollectionSource]int, len(s.jStats)) - for _, c := range s.jStats { - - // Accumlate raw counts - // - s.counts[c.Source]++ - - // Look for allocated but unused collections and count them - if c.MaxSize == 0 && c.Puts == 0 { - if s.unusedCollections == nil { - s.unusedCollections = make(map[CollectionSource]int) - } - s.unusedCollections[c.Source]++ - } - if c.MaxSize > 6000 { - fmt.Println("Collection ", c.Description, "accumulated a max size of ", c.MaxSize, " - this is probably too large and indicates a poorly formed grammar") - } - } - -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/stats_data.go b/vendor/github.com/antlr4-go/antlr/v4/stats_data.go deleted file mode 100644 index 4d9eb94e5..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/stats_data.go +++ /dev/null @@ -1,23 +0,0 @@ -package antlr - -// A JStatRec is a record of a particular use of a [JStore], [JMap] or JPCMap] collection. Typically, it will be -// used to look for unused collections that wre allocated anyway, problems with hash bucket clashes, and anomalies -// such as huge numbers of Gets with no entries found GetNoEnt. You can refer to the CollectionAnomalies() function -// for ideas on what can be gleaned from these statistics about collections. -type JStatRec struct { - Source CollectionSource - MaxSize int - CurSize int - Gets int - GetHits int - GetMisses int - GetHashConflicts int - GetNoEnt int - Puts int - PutHits int - PutMisses int - PutHashConflicts int - MaxSlotSize int - Description string - CreateStack []byte -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/token.go b/vendor/github.com/antlr4-go/antlr/v4/token.go deleted file mode 100644 index 9670efb82..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/token.go +++ /dev/null @@ -1,213 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import ( - "strconv" - "strings" -) - -type TokenSourceCharStreamPair struct { - tokenSource TokenSource - charStream CharStream -} - -// A token has properties: text, type, line, character position in the line -// (so we can ignore tabs), token channel, index, and source from which -// we obtained this token. - -type Token interface { - GetSource() *TokenSourceCharStreamPair - GetTokenType() int - GetChannel() int - GetStart() int - GetStop() int - GetLine() int - GetColumn() int - - GetText() string - SetText(s string) - - GetTokenIndex() int - SetTokenIndex(v int) - - GetTokenSource() TokenSource - GetInputStream() CharStream - - String() string -} - -type BaseToken struct { - source *TokenSourceCharStreamPair - tokenType int // token type of the token - channel int // The parser ignores everything not on DEFAULT_CHANNEL - start int // optional return -1 if not implemented. - stop int // optional return -1 if not implemented. - tokenIndex int // from 0..n-1 of the token object in the input stream - line int // line=1..n of the 1st character - column int // beginning of the line at which it occurs, 0..n-1 - text string // text of the token. - readOnly bool -} - -const ( - TokenInvalidType = 0 - - // TokenEpsilon - during lookahead operations, this "token" signifies we hit the rule end [ATN] state - // and did not follow it despite needing to. - TokenEpsilon = -2 - - TokenMinUserTokenType = 1 - - TokenEOF = -1 - - // TokenDefaultChannel is the default channel upon which tokens are sent to the parser. - // - // All tokens go to the parser (unless [Skip] is called in the lexer rule) - // on a particular "channel". The parser tunes to a particular channel - // so that whitespace etc... can go to the parser on a "hidden" channel. - TokenDefaultChannel = 0 - - // TokenHiddenChannel defines the normal hidden channel - the parser wil not see tokens that are not on [TokenDefaultChannel]. - // - // Anything on a different channel than TokenDefaultChannel is not parsed by parser. - TokenHiddenChannel = 1 -) - -func (b *BaseToken) GetChannel() int { - return b.channel -} - -func (b *BaseToken) GetStart() int { - return b.start -} - -func (b *BaseToken) GetStop() int { - return b.stop -} - -func (b *BaseToken) GetLine() int { - return b.line -} - -func (b *BaseToken) GetColumn() int { - return b.column -} - -func (b *BaseToken) GetTokenType() int { - return b.tokenType -} - -func (b *BaseToken) GetSource() *TokenSourceCharStreamPair { - return b.source -} - -func (b *BaseToken) GetTokenIndex() int { - return b.tokenIndex -} - -func (b *BaseToken) SetTokenIndex(v int) { - b.tokenIndex = v -} - -func (b *BaseToken) GetTokenSource() TokenSource { - return b.source.tokenSource -} - -func (b *BaseToken) GetInputStream() CharStream { - return b.source.charStream -} - -type CommonToken struct { - BaseToken -} - -func NewCommonToken(source *TokenSourceCharStreamPair, tokenType, channel, start, stop int) *CommonToken { - - t := &CommonToken{ - BaseToken: BaseToken{ - source: source, - tokenType: tokenType, - channel: channel, - start: start, - stop: stop, - tokenIndex: -1, - }, - } - - if t.source.tokenSource != nil { - t.line = source.tokenSource.GetLine() - t.column = source.tokenSource.GetCharPositionInLine() - } else { - t.column = -1 - } - return t -} - -// An empty {@link Pair} which is used as the default value of -// {@link //source} for tokens that do not have a source. - -//CommonToken.EMPTY_SOURCE = [ nil, nil ] - -// Constructs a New{@link CommonToken} as a copy of another {@link Token}. -// -//

-// If {@code oldToken} is also a {@link CommonToken} instance, the newly -// constructed token will share a reference to the {@link //text} field and -// the {@link Pair} stored in {@link //source}. Otherwise, {@link //text} will -// be assigned the result of calling {@link //GetText}, and {@link //source} -// will be constructed from the result of {@link Token//GetTokenSource} and -// {@link Token//GetInputStream}.

-// -// @param oldToken The token to copy. -func (c *CommonToken) clone() *CommonToken { - t := NewCommonToken(c.source, c.tokenType, c.channel, c.start, c.stop) - t.tokenIndex = c.GetTokenIndex() - t.line = c.GetLine() - t.column = c.GetColumn() - t.text = c.GetText() - return t -} - -func (c *CommonToken) GetText() string { - if c.text != "" { - return c.text - } - input := c.GetInputStream() - if input == nil { - return "" - } - n := input.Size() - if c.start < n && c.stop < n { - return input.GetTextFromInterval(NewInterval(c.start, c.stop)) - } - return "" -} - -func (c *CommonToken) SetText(text string) { - c.text = text -} - -func (c *CommonToken) String() string { - txt := c.GetText() - if txt != "" { - txt = strings.Replace(txt, "\n", "\\n", -1) - txt = strings.Replace(txt, "\r", "\\r", -1) - txt = strings.Replace(txt, "\t", "\\t", -1) - } else { - txt = "" - } - - var ch string - if c.channel > 0 { - ch = ",channel=" + strconv.Itoa(c.channel) - } else { - ch = "" - } - - return "[@" + strconv.Itoa(c.tokenIndex) + "," + strconv.Itoa(c.start) + ":" + strconv.Itoa(c.stop) + "='" + - txt + "',<" + strconv.Itoa(c.tokenType) + ">" + - ch + "," + strconv.Itoa(c.line) + ":" + strconv.Itoa(c.column) + "]" -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/token_source.go b/vendor/github.com/antlr4-go/antlr/v4/token_source.go deleted file mode 100644 index a3f36eaa6..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/token_source.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -type TokenSource interface { - NextToken() Token - Skip() - More() - GetLine() int - GetCharPositionInLine() int - GetInputStream() CharStream - GetSourceName() string - setTokenFactory(factory TokenFactory) - GetTokenFactory() TokenFactory -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/token_stream.go b/vendor/github.com/antlr4-go/antlr/v4/token_stream.go deleted file mode 100644 index bf4ff6633..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/token_stream.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -type TokenStream interface { - IntStream - - LT(k int) Token - Reset() - - Get(index int) Token - GetTokenSource() TokenSource - SetTokenSource(TokenSource) - - GetAllText() string - GetTextFromInterval(Interval) string - GetTextFromRuleContext(RuleContext) string - GetTextFromTokens(Token, Token) string -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/tokenstream_rewriter.go b/vendor/github.com/antlr4-go/antlr/v4/tokenstream_rewriter.go deleted file mode 100644 index ccf59b465..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/tokenstream_rewriter.go +++ /dev/null @@ -1,662 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import ( - "bytes" - "fmt" -) - -// -// Useful for rewriting out a buffered input token stream after doing some -// augmentation or other manipulations on it. - -//

-// You can insert stuff, replace, and delete chunks. Note that the operations -// are done lazily--only if you convert the buffer to a {@link String} with -// {@link TokenStream#getText()}. This is very efficient because you are not -// moving data around all the time. As the buffer of tokens is converted to -// strings, the {@link #getText()} method(s) scan the input token stream and -// check to see if there is an operation at the current index. If so, the -// operation is done and then normal {@link String} rendering continues on the -// buffer. This is like having multiple Turing machine instruction streams -// (programs) operating on a single input tape. :)

-//

- -// This rewriter makes no modifications to the token stream. It does not ask the -// stream to fill itself up nor does it advance the input cursor. The token -// stream {@link TokenStream#index()} will return the same value before and -// after any {@link #getText()} call.

- -//

-// The rewriter only works on tokens that you have in the buffer and ignores the -// current input cursor. If you are buffering tokens on-demand, calling -// {@link #getText()} halfway through the input will only do rewrites for those -// tokens in the first half of the file.

- -//

-// Since the operations are done lazily at {@link #getText}-time, operations do -// not screw up the token index values. That is, an insert operation at token -// index {@code i} does not change the index values for tokens -// {@code i}+1..n-1.

- -//

-// Because operations never actually alter the buffer, you may always get the -// original token stream back without undoing anything. Since the instructions -// are queued up, you can easily simulate transactions and roll back any changes -// if there is an error just by removing instructions. For example,

- -//
-// CharStream input = new ANTLRFileStream("input");
-// TLexer lex = new TLexer(input);
-// CommonTokenStream tokens = new CommonTokenStream(lex);
-// T parser = new T(tokens);
-// TokenStreamRewriter rewriter = new TokenStreamRewriter(tokens);
-// parser.startRule();
-// 
- -//

-// Then in the rules, you can execute (assuming rewriter is visible):

- -//
-// Token t,u;
-// ...
-// rewriter.insertAfter(t, "text to put after t");}
-// rewriter.insertAfter(u, "text after u");}
-// System.out.println(rewriter.getText());
-// 
- -//

-// You can also have multiple "instruction streams" and get multiple rewrites -// from a single pass over the input. Just name the instruction streams and use -// that name again when printing the buffer. This could be useful for generating -// a C file and also its header file--all from the same buffer:

- -//
-// rewriter.insertAfter("pass1", t, "text to put after t");}
-// rewriter.insertAfter("pass2", u, "text after u");}
-// System.out.println(rewriter.getText("pass1"));
-// System.out.println(rewriter.getText("pass2"));
-// 
- -//

-// If you don't use named rewrite streams, a "default" stream is used as the -// first example shows.

- -const ( - DefaultProgramName = "default" - ProgramInitSize = 100 - MinTokenIndex = 0 -) - -// Define the rewrite operation hierarchy - -type RewriteOperation interface { - - // Execute the rewrite operation by possibly adding to the buffer. - // Return the index of the next token to operate on. - Execute(buffer *bytes.Buffer) int - String() string - GetInstructionIndex() int - GetIndex() int - GetText() string - GetOpName() string - GetTokens() TokenStream - SetInstructionIndex(val int) - SetIndex(int) - SetText(string) - SetOpName(string) - SetTokens(TokenStream) -} - -type BaseRewriteOperation struct { - //Current index of rewrites list - instructionIndex int - //Token buffer index - index int - //Substitution text - text string - //Actual operation name - opName string - //Pointer to token steam - tokens TokenStream -} - -func (op *BaseRewriteOperation) GetInstructionIndex() int { - return op.instructionIndex -} - -func (op *BaseRewriteOperation) GetIndex() int { - return op.index -} - -func (op *BaseRewriteOperation) GetText() string { - return op.text -} - -func (op *BaseRewriteOperation) GetOpName() string { - return op.opName -} - -func (op *BaseRewriteOperation) GetTokens() TokenStream { - return op.tokens -} - -func (op *BaseRewriteOperation) SetInstructionIndex(val int) { - op.instructionIndex = val -} - -func (op *BaseRewriteOperation) SetIndex(val int) { - op.index = val -} - -func (op *BaseRewriteOperation) SetText(val string) { - op.text = val -} - -func (op *BaseRewriteOperation) SetOpName(val string) { - op.opName = val -} - -func (op *BaseRewriteOperation) SetTokens(val TokenStream) { - op.tokens = val -} - -func (op *BaseRewriteOperation) Execute(_ *bytes.Buffer) int { - return op.index -} - -func (op *BaseRewriteOperation) String() string { - return fmt.Sprintf("<%s@%d:\"%s\">", - op.opName, - op.tokens.Get(op.GetIndex()), - op.text, - ) - -} - -type InsertBeforeOp struct { - BaseRewriteOperation -} - -func NewInsertBeforeOp(index int, text string, stream TokenStream) *InsertBeforeOp { - return &InsertBeforeOp{BaseRewriteOperation: BaseRewriteOperation{ - index: index, - text: text, - opName: "InsertBeforeOp", - tokens: stream, - }} -} - -func (op *InsertBeforeOp) Execute(buffer *bytes.Buffer) int { - buffer.WriteString(op.text) - if op.tokens.Get(op.index).GetTokenType() != TokenEOF { - buffer.WriteString(op.tokens.Get(op.index).GetText()) - } - return op.index + 1 -} - -func (op *InsertBeforeOp) String() string { - return op.BaseRewriteOperation.String() -} - -// InsertAfterOp distinguishes between insert after/before to do the "insert after" instructions -// first and then the "insert before" instructions at same index. Implementation -// of "insert after" is "insert before index+1". -type InsertAfterOp struct { - BaseRewriteOperation -} - -func NewInsertAfterOp(index int, text string, stream TokenStream) *InsertAfterOp { - return &InsertAfterOp{ - BaseRewriteOperation: BaseRewriteOperation{ - index: index + 1, - text: text, - tokens: stream, - }, - } -} - -func (op *InsertAfterOp) Execute(buffer *bytes.Buffer) int { - buffer.WriteString(op.text) - if op.tokens.Get(op.index).GetTokenType() != TokenEOF { - buffer.WriteString(op.tokens.Get(op.index).GetText()) - } - return op.index + 1 -} - -func (op *InsertAfterOp) String() string { - return op.BaseRewriteOperation.String() -} - -// ReplaceOp tries to replace range from x..y with (y-x)+1 ReplaceOp -// instructions. -type ReplaceOp struct { - BaseRewriteOperation - LastIndex int -} - -func NewReplaceOp(from, to int, text string, stream TokenStream) *ReplaceOp { - return &ReplaceOp{ - BaseRewriteOperation: BaseRewriteOperation{ - index: from, - text: text, - opName: "ReplaceOp", - tokens: stream, - }, - LastIndex: to, - } -} - -func (op *ReplaceOp) Execute(buffer *bytes.Buffer) int { - if op.text != "" { - buffer.WriteString(op.text) - } - return op.LastIndex + 1 -} - -func (op *ReplaceOp) String() string { - if op.text == "" { - return fmt.Sprintf("", - op.tokens.Get(op.index), op.tokens.Get(op.LastIndex)) - } - return fmt.Sprintf("", - op.tokens.Get(op.index), op.tokens.Get(op.LastIndex), op.text) -} - -type TokenStreamRewriter struct { - //Our source stream - tokens TokenStream - // You may have multiple, named streams of rewrite operations. - // I'm calling these things "programs." - // Maps String (name) → rewrite (List) - programs map[string][]RewriteOperation - lastRewriteTokenIndexes map[string]int -} - -func NewTokenStreamRewriter(tokens TokenStream) *TokenStreamRewriter { - return &TokenStreamRewriter{ - tokens: tokens, - programs: map[string][]RewriteOperation{ - DefaultProgramName: make([]RewriteOperation, 0, ProgramInitSize), - }, - lastRewriteTokenIndexes: map[string]int{}, - } -} - -func (tsr *TokenStreamRewriter) GetTokenStream() TokenStream { - return tsr.tokens -} - -// Rollback the instruction stream for a program so that -// the indicated instruction (via instructionIndex) is no -// longer in the stream. UNTESTED! -func (tsr *TokenStreamRewriter) Rollback(programName string, instructionIndex int) { - is, ok := tsr.programs[programName] - if ok { - tsr.programs[programName] = is[MinTokenIndex:instructionIndex] - } -} - -func (tsr *TokenStreamRewriter) RollbackDefault(instructionIndex int) { - tsr.Rollback(DefaultProgramName, instructionIndex) -} - -// DeleteProgram Reset the program so that no instructions exist -func (tsr *TokenStreamRewriter) DeleteProgram(programName string) { - tsr.Rollback(programName, MinTokenIndex) //TODO: double test on that cause lower bound is not included -} - -func (tsr *TokenStreamRewriter) DeleteProgramDefault() { - tsr.DeleteProgram(DefaultProgramName) -} - -func (tsr *TokenStreamRewriter) InsertAfter(programName string, index int, text string) { - // to insert after, just insert before next index (even if past end) - var op RewriteOperation = NewInsertAfterOp(index, text, tsr.tokens) - rewrites := tsr.GetProgram(programName) - op.SetInstructionIndex(len(rewrites)) - tsr.AddToProgram(programName, op) -} - -func (tsr *TokenStreamRewriter) InsertAfterDefault(index int, text string) { - tsr.InsertAfter(DefaultProgramName, index, text) -} - -func (tsr *TokenStreamRewriter) InsertAfterToken(programName string, token Token, text string) { - tsr.InsertAfter(programName, token.GetTokenIndex(), text) -} - -func (tsr *TokenStreamRewriter) InsertBefore(programName string, index int, text string) { - var op RewriteOperation = NewInsertBeforeOp(index, text, tsr.tokens) - rewrites := tsr.GetProgram(programName) - op.SetInstructionIndex(len(rewrites)) - tsr.AddToProgram(programName, op) -} - -func (tsr *TokenStreamRewriter) InsertBeforeDefault(index int, text string) { - tsr.InsertBefore(DefaultProgramName, index, text) -} - -func (tsr *TokenStreamRewriter) InsertBeforeToken(programName string, token Token, text string) { - tsr.InsertBefore(programName, token.GetTokenIndex(), text) -} - -func (tsr *TokenStreamRewriter) Replace(programName string, from, to int, text string) { - if from > to || from < 0 || to < 0 || to >= tsr.tokens.Size() { - panic(fmt.Sprintf("replace: range invalid: %d..%d(size=%d)", - from, to, tsr.tokens.Size())) - } - var op RewriteOperation = NewReplaceOp(from, to, text, tsr.tokens) - rewrites := tsr.GetProgram(programName) - op.SetInstructionIndex(len(rewrites)) - tsr.AddToProgram(programName, op) -} - -func (tsr *TokenStreamRewriter) ReplaceDefault(from, to int, text string) { - tsr.Replace(DefaultProgramName, from, to, text) -} - -func (tsr *TokenStreamRewriter) ReplaceDefaultPos(index int, text string) { - tsr.ReplaceDefault(index, index, text) -} - -func (tsr *TokenStreamRewriter) ReplaceToken(programName string, from, to Token, text string) { - tsr.Replace(programName, from.GetTokenIndex(), to.GetTokenIndex(), text) -} - -func (tsr *TokenStreamRewriter) ReplaceTokenDefault(from, to Token, text string) { - tsr.ReplaceToken(DefaultProgramName, from, to, text) -} - -func (tsr *TokenStreamRewriter) ReplaceTokenDefaultPos(index Token, text string) { - tsr.ReplaceTokenDefault(index, index, text) -} - -func (tsr *TokenStreamRewriter) Delete(programName string, from, to int) { - tsr.Replace(programName, from, to, "") -} - -func (tsr *TokenStreamRewriter) DeleteDefault(from, to int) { - tsr.Delete(DefaultProgramName, from, to) -} - -func (tsr *TokenStreamRewriter) DeleteDefaultPos(index int) { - tsr.DeleteDefault(index, index) -} - -func (tsr *TokenStreamRewriter) DeleteToken(programName string, from, to Token) { - tsr.ReplaceToken(programName, from, to, "") -} - -func (tsr *TokenStreamRewriter) DeleteTokenDefault(from, to Token) { - tsr.DeleteToken(DefaultProgramName, from, to) -} - -func (tsr *TokenStreamRewriter) GetLastRewriteTokenIndex(programName string) int { - i, ok := tsr.lastRewriteTokenIndexes[programName] - if !ok { - return -1 - } - return i -} - -func (tsr *TokenStreamRewriter) GetLastRewriteTokenIndexDefault() int { - return tsr.GetLastRewriteTokenIndex(DefaultProgramName) -} - -func (tsr *TokenStreamRewriter) SetLastRewriteTokenIndex(programName string, i int) { - tsr.lastRewriteTokenIndexes[programName] = i -} - -func (tsr *TokenStreamRewriter) InitializeProgram(name string) []RewriteOperation { - is := make([]RewriteOperation, 0, ProgramInitSize) - tsr.programs[name] = is - return is -} - -func (tsr *TokenStreamRewriter) AddToProgram(name string, op RewriteOperation) { - is := tsr.GetProgram(name) - is = append(is, op) - tsr.programs[name] = is -} - -func (tsr *TokenStreamRewriter) GetProgram(name string) []RewriteOperation { - is, ok := tsr.programs[name] - if !ok { - is = tsr.InitializeProgram(name) - } - return is -} - -// GetTextDefault returns the text from the original tokens altered per the -// instructions given to this rewriter. -func (tsr *TokenStreamRewriter) GetTextDefault() string { - return tsr.GetText( - DefaultProgramName, - NewInterval(0, tsr.tokens.Size()-1)) -} - -// GetText returns the text from the original tokens altered per the -// instructions given to this rewriter. -func (tsr *TokenStreamRewriter) GetText(programName string, interval Interval) string { - rewrites := tsr.programs[programName] - start := interval.Start - stop := interval.Stop - // ensure start/end are in range - stop = min(stop, tsr.tokens.Size()-1) - start = max(start, 0) - if len(rewrites) == 0 { - return tsr.tokens.GetTextFromInterval(interval) // no instructions to execute - } - buf := bytes.Buffer{} - // First, optimize instruction stream - indexToOp := reduceToSingleOperationPerIndex(rewrites) - // Walk buffer, executing instructions and emitting tokens - for i := start; i <= stop && i < tsr.tokens.Size(); { - op := indexToOp[i] - delete(indexToOp, i) // remove so any left have index size-1 - t := tsr.tokens.Get(i) - if op == nil { - // no operation at that index, just dump token - if t.GetTokenType() != TokenEOF { - buf.WriteString(t.GetText()) - } - i++ // move to next token - } else { - i = op.Execute(&buf) // execute operation and skip - } - } - // include stuff after end if it's last index in buffer - // So, if they did an insertAfter(lastValidIndex, "foo"), include - // foo if end==lastValidIndex. - if stop == tsr.tokens.Size()-1 { - // Scan any remaining operations after last token - // should be included (they will be inserts). - for _, op := range indexToOp { - if op.GetIndex() >= tsr.tokens.Size()-1 { - buf.WriteString(op.GetText()) - } - } - } - return buf.String() -} - -// reduceToSingleOperationPerIndex combines operations and report invalid operations (like -// overlapping replaces that are not completed nested). Inserts to -// same index need to be combined etc... -// -// Here are the cases: -// -// I.i.u I.j.v leave alone, non-overlapping -// I.i.u I.i.v combine: Iivu -// -// R.i-j.u R.x-y.v | i-j in x-y delete first R -// R.i-j.u R.i-j.v delete first R -// R.i-j.u R.x-y.v | x-y in i-j ERROR -// R.i-j.u R.x-y.v | boundaries overlap ERROR -// -// Delete special case of replace (text==null): -// D.i-j.u D.x-y.v | boundaries overlap combine to max(min)..max(right) -// -// I.i.u R.x-y.v | i in (x+1)-y delete I (since insert before -// we're not deleting i) -// I.i.u R.x-y.v | i not in (x+1)-y leave alone, non-overlapping -// R.x-y.v I.i.u | i in x-y ERROR -// R.x-y.v I.x.u R.x-y.uv (combine, delete I) -// R.x-y.v I.i.u | i not in x-y leave alone, non-overlapping -// -// I.i.u = insert u before op @ index i -// R.x-y.u = replace x-y indexed tokens with u -// -// First we need to examine replaces. For any replace op: -// -// 1. wipe out any insertions before op within that range. -// 2. Drop any replace op before that is contained completely within -// that range. -// 3. Throw exception upon boundary overlap with any previous replace. -// -// Then we can deal with inserts: -// -// 1. for any inserts to same index, combine even if not adjacent. -// 2. for any prior replace with same left boundary, combine this -// insert with replace and delete this 'replace'. -// 3. throw exception if index in same range as previous replace -// -// Don't actually delete; make op null in list. Easier to walk list. -// Later we can throw as we add to index → op map. -// -// Note that I.2 R.2-2 will wipe out I.2 even though, technically, the -// inserted stuff would be before the 'replace' range. But, if you -// add tokens in front of a method body '{' and then delete the method -// body, I think the stuff before the '{' you added should disappear too. -// -// The func returns a map from token index to operation. -func reduceToSingleOperationPerIndex(rewrites []RewriteOperation) map[int]RewriteOperation { - // WALK REPLACES - for i := 0; i < len(rewrites); i++ { - op := rewrites[i] - if op == nil { - continue - } - rop, ok := op.(*ReplaceOp) - if !ok { - continue - } - // Wipe prior inserts within range - for j := 0; j < i && j < len(rewrites); j++ { - if iop, ok := rewrites[j].(*InsertBeforeOp); ok { - if iop.index == rop.index { - // E.g., insert before 2, delete 2..2; update replace - // text to include insert before, kill insert - rewrites[iop.instructionIndex] = nil - if rop.text != "" { - rop.text = iop.text + rop.text - } else { - rop.text = iop.text - } - } else if iop.index > rop.index && iop.index <= rop.LastIndex { - // delete insert as it's a no-op. - rewrites[iop.instructionIndex] = nil - } - } - } - // Drop any prior replaces contained within - for j := 0; j < i && j < len(rewrites); j++ { - if prevop, ok := rewrites[j].(*ReplaceOp); ok { - if prevop.index >= rop.index && prevop.LastIndex <= rop.LastIndex { - // delete replace as it's a no-op. - rewrites[prevop.instructionIndex] = nil - continue - } - // throw exception unless disjoint or identical - disjoint := prevop.LastIndex < rop.index || prevop.index > rop.LastIndex - // Delete special case of replace (text==null): - // D.i-j.u D.x-y.v | boundaries overlap combine to max(min)..max(right) - if prevop.text == "" && rop.text == "" && !disjoint { - rewrites[prevop.instructionIndex] = nil - rop.index = min(prevop.index, rop.index) - rop.LastIndex = max(prevop.LastIndex, rop.LastIndex) - } else if !disjoint { - panic("replace op boundaries of " + rop.String() + " overlap with previous " + prevop.String()) - } - } - } - } - // WALK INSERTS - for i := 0; i < len(rewrites); i++ { - op := rewrites[i] - if op == nil { - continue - } - //hack to replicate inheritance in composition - _, iok := rewrites[i].(*InsertBeforeOp) - _, aok := rewrites[i].(*InsertAfterOp) - if !iok && !aok { - continue - } - iop := rewrites[i] - // combine current insert with prior if any at same index - // deviating a bit from TokenStreamRewriter.java - hard to incorporate inheritance logic - for j := 0; j < i && j < len(rewrites); j++ { - if nextIop, ok := rewrites[j].(*InsertAfterOp); ok { - if nextIop.index == iop.GetIndex() { - iop.SetText(nextIop.text + iop.GetText()) - rewrites[j] = nil - } - } - if prevIop, ok := rewrites[j].(*InsertBeforeOp); ok { - if prevIop.index == iop.GetIndex() { - iop.SetText(iop.GetText() + prevIop.text) - rewrites[prevIop.instructionIndex] = nil - } - } - } - // look for replaces where iop.index is in range; error - for j := 0; j < i && j < len(rewrites); j++ { - if rop, ok := rewrites[j].(*ReplaceOp); ok { - if iop.GetIndex() == rop.index { - rop.text = iop.GetText() + rop.text - rewrites[i] = nil - continue - } - if iop.GetIndex() >= rop.index && iop.GetIndex() <= rop.LastIndex { - panic("insert op " + iop.String() + " within boundaries of previous " + rop.String()) - } - } - } - } - m := map[int]RewriteOperation{} - for i := 0; i < len(rewrites); i++ { - op := rewrites[i] - if op == nil { - continue - } - if _, ok := m[op.GetIndex()]; ok { - panic("should only be one op per index") - } - m[op.GetIndex()] = op - } - return m -} - -/* - Quick fixing Go lack of overloads -*/ - -func max(a, b int) int { - if a > b { - return a - } else { - return b - } -} -func min(a, b int) int { - if a < b { - return a - } else { - return b - } -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/trace_listener.go b/vendor/github.com/antlr4-go/antlr/v4/trace_listener.go deleted file mode 100644 index 7b663bf84..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/trace_listener.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import "fmt" - -type TraceListener struct { - parser *BaseParser -} - -func NewTraceListener(parser *BaseParser) *TraceListener { - tl := new(TraceListener) - tl.parser = parser - return tl -} - -func (t *TraceListener) VisitErrorNode(_ ErrorNode) { -} - -func (t *TraceListener) EnterEveryRule(ctx ParserRuleContext) { - fmt.Println("enter " + t.parser.GetRuleNames()[ctx.GetRuleIndex()] + ", LT(1)=" + t.parser.input.LT(1).GetText()) -} - -func (t *TraceListener) VisitTerminal(node TerminalNode) { - fmt.Println("consume " + fmt.Sprint(node.GetSymbol()) + " rule " + t.parser.GetRuleNames()[t.parser.ctx.GetRuleIndex()]) -} - -func (t *TraceListener) ExitEveryRule(ctx ParserRuleContext) { - fmt.Println("exit " + t.parser.GetRuleNames()[ctx.GetRuleIndex()] + ", LT(1)=" + t.parser.input.LT(1).GetText()) -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/transition.go b/vendor/github.com/antlr4-go/antlr/v4/transition.go deleted file mode 100644 index 313b0fc12..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/transition.go +++ /dev/null @@ -1,439 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import ( - "fmt" - "strconv" - "strings" -) - -// atom, set, epsilon, action, predicate, rule transitions. -// -//

This is a one way link. It emanates from a state (usually via a list of -// transitions) and has a target state.

-// -//

Since we never have to change the ATN transitions once we construct it, -// the states. We'll use the term Edge for the DFA to distinguish them from -// ATN transitions.

- -type Transition interface { - getTarget() ATNState - setTarget(ATNState) - getIsEpsilon() bool - getLabel() *IntervalSet - getSerializationType() int - Matches(int, int, int) bool -} - -type BaseTransition struct { - target ATNState - isEpsilon bool - label int - intervalSet *IntervalSet - serializationType int -} - -func NewBaseTransition(target ATNState) *BaseTransition { - - if target == nil { - panic("target cannot be nil.") - } - - t := new(BaseTransition) - - t.target = target - // Are we epsilon, action, sempred? - t.isEpsilon = false - t.intervalSet = nil - - return t -} - -func (t *BaseTransition) getTarget() ATNState { - return t.target -} - -func (t *BaseTransition) setTarget(s ATNState) { - t.target = s -} - -func (t *BaseTransition) getIsEpsilon() bool { - return t.isEpsilon -} - -func (t *BaseTransition) getLabel() *IntervalSet { - return t.intervalSet -} - -func (t *BaseTransition) getSerializationType() int { - return t.serializationType -} - -func (t *BaseTransition) Matches(_, _, _ int) bool { - panic("Not implemented") -} - -const ( - TransitionEPSILON = 1 - TransitionRANGE = 2 - TransitionRULE = 3 - TransitionPREDICATE = 4 // e.g., {isType(input.LT(1))}? - TransitionATOM = 5 - TransitionACTION = 6 - TransitionSET = 7 // ~(A|B) or ~atom, wildcard, which convert to next 2 - TransitionNOTSET = 8 - TransitionWILDCARD = 9 - TransitionPRECEDENCE = 10 -) - -//goland:noinspection GoUnusedGlobalVariable -var TransitionserializationNames = []string{ - "INVALID", - "EPSILON", - "RANGE", - "RULE", - "PREDICATE", - "ATOM", - "ACTION", - "SET", - "NOT_SET", - "WILDCARD", - "PRECEDENCE", -} - -//var TransitionserializationTypes struct { -// EpsilonTransition int -// RangeTransition int -// RuleTransition int -// PredicateTransition int -// AtomTransition int -// ActionTransition int -// SetTransition int -// NotSetTransition int -// WildcardTransition int -// PrecedencePredicateTransition int -//}{ -// TransitionEPSILON, -// TransitionRANGE, -// TransitionRULE, -// TransitionPREDICATE, -// TransitionATOM, -// TransitionACTION, -// TransitionSET, -// TransitionNOTSET, -// TransitionWILDCARD, -// TransitionPRECEDENCE -//} - -// AtomTransition -// TODO: make all transitions sets? no, should remove set edges -type AtomTransition struct { - BaseTransition -} - -func NewAtomTransition(target ATNState, intervalSet int) *AtomTransition { - t := &AtomTransition{ - BaseTransition: BaseTransition{ - target: target, - serializationType: TransitionATOM, - label: intervalSet, - isEpsilon: false, - }, - } - t.intervalSet = t.makeLabel() - - return t -} - -func (t *AtomTransition) makeLabel() *IntervalSet { - s := NewIntervalSet() - s.addOne(t.label) - return s -} - -func (t *AtomTransition) Matches(symbol, _, _ int) bool { - return t.label == symbol -} - -func (t *AtomTransition) String() string { - return strconv.Itoa(t.label) -} - -type RuleTransition struct { - BaseTransition - followState ATNState - ruleIndex, precedence int -} - -func NewRuleTransition(ruleStart ATNState, ruleIndex, precedence int, followState ATNState) *RuleTransition { - return &RuleTransition{ - BaseTransition: BaseTransition{ - target: ruleStart, - isEpsilon: true, - serializationType: TransitionRULE, - }, - ruleIndex: ruleIndex, - precedence: precedence, - followState: followState, - } -} - -func (t *RuleTransition) Matches(_, _, _ int) bool { - return false -} - -type EpsilonTransition struct { - BaseTransition - outermostPrecedenceReturn int -} - -func NewEpsilonTransition(target ATNState, outermostPrecedenceReturn int) *EpsilonTransition { - return &EpsilonTransition{ - BaseTransition: BaseTransition{ - target: target, - serializationType: TransitionEPSILON, - isEpsilon: true, - }, - outermostPrecedenceReturn: outermostPrecedenceReturn, - } -} - -func (t *EpsilonTransition) Matches(_, _, _ int) bool { - return false -} - -func (t *EpsilonTransition) String() string { - return "epsilon" -} - -type RangeTransition struct { - BaseTransition - start, stop int -} - -func NewRangeTransition(target ATNState, start, stop int) *RangeTransition { - t := &RangeTransition{ - BaseTransition: BaseTransition{ - target: target, - serializationType: TransitionRANGE, - isEpsilon: false, - }, - start: start, - stop: stop, - } - t.intervalSet = t.makeLabel() - return t -} - -func (t *RangeTransition) makeLabel() *IntervalSet { - s := NewIntervalSet() - s.addRange(t.start, t.stop) - return s -} - -func (t *RangeTransition) Matches(symbol, _, _ int) bool { - return symbol >= t.start && symbol <= t.stop -} - -func (t *RangeTransition) String() string { - var sb strings.Builder - sb.WriteByte('\'') - sb.WriteRune(rune(t.start)) - sb.WriteString("'..'") - sb.WriteRune(rune(t.stop)) - sb.WriteByte('\'') - return sb.String() -} - -type AbstractPredicateTransition interface { - Transition - IAbstractPredicateTransitionFoo() -} - -type BaseAbstractPredicateTransition struct { - BaseTransition -} - -func NewBasePredicateTransition(target ATNState) *BaseAbstractPredicateTransition { - return &BaseAbstractPredicateTransition{ - BaseTransition: BaseTransition{ - target: target, - }, - } -} - -func (a *BaseAbstractPredicateTransition) IAbstractPredicateTransitionFoo() {} - -type PredicateTransition struct { - BaseAbstractPredicateTransition - isCtxDependent bool - ruleIndex, predIndex int -} - -func NewPredicateTransition(target ATNState, ruleIndex, predIndex int, isCtxDependent bool) *PredicateTransition { - return &PredicateTransition{ - BaseAbstractPredicateTransition: BaseAbstractPredicateTransition{ - BaseTransition: BaseTransition{ - target: target, - serializationType: TransitionPREDICATE, - isEpsilon: true, - }, - }, - isCtxDependent: isCtxDependent, - ruleIndex: ruleIndex, - predIndex: predIndex, - } -} - -func (t *PredicateTransition) Matches(_, _, _ int) bool { - return false -} - -func (t *PredicateTransition) getPredicate() *Predicate { - return NewPredicate(t.ruleIndex, t.predIndex, t.isCtxDependent) -} - -func (t *PredicateTransition) String() string { - return "pred_" + strconv.Itoa(t.ruleIndex) + ":" + strconv.Itoa(t.predIndex) -} - -type ActionTransition struct { - BaseTransition - isCtxDependent bool - ruleIndex, actionIndex, predIndex int -} - -func NewActionTransition(target ATNState, ruleIndex, actionIndex int, isCtxDependent bool) *ActionTransition { - return &ActionTransition{ - BaseTransition: BaseTransition{ - target: target, - serializationType: TransitionACTION, - isEpsilon: true, - }, - isCtxDependent: isCtxDependent, - ruleIndex: ruleIndex, - actionIndex: actionIndex, - } -} - -func (t *ActionTransition) Matches(_, _, _ int) bool { - return false -} - -func (t *ActionTransition) String() string { - return "action_" + strconv.Itoa(t.ruleIndex) + ":" + strconv.Itoa(t.actionIndex) -} - -type SetTransition struct { - BaseTransition -} - -func NewSetTransition(target ATNState, set *IntervalSet) *SetTransition { - t := &SetTransition{ - BaseTransition: BaseTransition{ - target: target, - serializationType: TransitionSET, - }, - } - - if set != nil { - t.intervalSet = set - } else { - t.intervalSet = NewIntervalSet() - t.intervalSet.addOne(TokenInvalidType) - } - return t -} - -func (t *SetTransition) Matches(symbol, _, _ int) bool { - return t.intervalSet.contains(symbol) -} - -func (t *SetTransition) String() string { - return t.intervalSet.String() -} - -type NotSetTransition struct { - SetTransition -} - -func NewNotSetTransition(target ATNState, set *IntervalSet) *NotSetTransition { - t := &NotSetTransition{ - SetTransition: SetTransition{ - BaseTransition: BaseTransition{ - target: target, - serializationType: TransitionNOTSET, - }, - }, - } - if set != nil { - t.intervalSet = set - } else { - t.intervalSet = NewIntervalSet() - t.intervalSet.addOne(TokenInvalidType) - } - - return t -} - -func (t *NotSetTransition) Matches(symbol, minVocabSymbol, maxVocabSymbol int) bool { - return symbol >= minVocabSymbol && symbol <= maxVocabSymbol && !t.intervalSet.contains(symbol) -} - -func (t *NotSetTransition) String() string { - return "~" + t.intervalSet.String() -} - -type WildcardTransition struct { - BaseTransition -} - -func NewWildcardTransition(target ATNState) *WildcardTransition { - return &WildcardTransition{ - BaseTransition: BaseTransition{ - target: target, - serializationType: TransitionWILDCARD, - }, - } -} - -func (t *WildcardTransition) Matches(symbol, minVocabSymbol, maxVocabSymbol int) bool { - return symbol >= minVocabSymbol && symbol <= maxVocabSymbol -} - -func (t *WildcardTransition) String() string { - return "." -} - -type PrecedencePredicateTransition struct { - BaseAbstractPredicateTransition - precedence int -} - -func NewPrecedencePredicateTransition(target ATNState, precedence int) *PrecedencePredicateTransition { - return &PrecedencePredicateTransition{ - BaseAbstractPredicateTransition: BaseAbstractPredicateTransition{ - BaseTransition: BaseTransition{ - target: target, - serializationType: TransitionPRECEDENCE, - isEpsilon: true, - }, - }, - precedence: precedence, - } -} - -func (t *PrecedencePredicateTransition) Matches(_, _, _ int) bool { - return false -} - -func (t *PrecedencePredicateTransition) getPredicate() *PrecedencePredicate { - return NewPrecedencePredicate(t.precedence) -} - -func (t *PrecedencePredicateTransition) String() string { - return fmt.Sprint(t.precedence) + " >= _p" -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/tree.go b/vendor/github.com/antlr4-go/antlr/v4/tree.go deleted file mode 100644 index c288420fb..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/tree.go +++ /dev/null @@ -1,304 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -// The basic notion of a tree has a parent, a payload, and a list of children. -// It is the most abstract interface for all the trees used by ANTLR. -/// - -var TreeInvalidInterval = NewInterval(-1, -2) - -type Tree interface { - GetParent() Tree - SetParent(Tree) - GetPayload() interface{} - GetChild(i int) Tree - GetChildCount() int - GetChildren() []Tree -} - -type SyntaxTree interface { - Tree - GetSourceInterval() Interval -} - -type ParseTree interface { - SyntaxTree - Accept(Visitor ParseTreeVisitor) interface{} - GetText() string - ToStringTree([]string, Recognizer) string -} - -type RuleNode interface { - ParseTree - GetRuleContext() RuleContext -} - -type TerminalNode interface { - ParseTree - GetSymbol() Token -} - -type ErrorNode interface { - TerminalNode - - errorNode() -} - -type ParseTreeVisitor interface { - Visit(tree ParseTree) interface{} - VisitChildren(node RuleNode) interface{} - VisitTerminal(node TerminalNode) interface{} - VisitErrorNode(node ErrorNode) interface{} -} - -type BaseParseTreeVisitor struct{} - -var _ ParseTreeVisitor = &BaseParseTreeVisitor{} - -func (v *BaseParseTreeVisitor) Visit(tree ParseTree) interface{} { return tree.Accept(v) } -func (v *BaseParseTreeVisitor) VisitChildren(_ RuleNode) interface{} { return nil } -func (v *BaseParseTreeVisitor) VisitTerminal(_ TerminalNode) interface{} { return nil } -func (v *BaseParseTreeVisitor) VisitErrorNode(_ ErrorNode) interface{} { return nil } - -// TODO: Implement this? -//func (this ParseTreeVisitor) Visit(ctx) { -// if (Utils.isArray(ctx)) { -// self := this -// return ctx.map(function(child) { return VisitAtom(self, child)}) -// } else { -// return VisitAtom(this, ctx) -// } -//} -// -//func VisitAtom(Visitor, ctx) { -// if (ctx.parser == nil) { //is terminal -// return -// } -// -// name := ctx.parser.ruleNames[ctx.ruleIndex] -// funcName := "Visit" + Utils.titleCase(name) -// -// return Visitor[funcName](ctx) -//} - -type ParseTreeListener interface { - VisitTerminal(node TerminalNode) - VisitErrorNode(node ErrorNode) - EnterEveryRule(ctx ParserRuleContext) - ExitEveryRule(ctx ParserRuleContext) -} - -type BaseParseTreeListener struct{} - -var _ ParseTreeListener = &BaseParseTreeListener{} - -func (l *BaseParseTreeListener) VisitTerminal(_ TerminalNode) {} -func (l *BaseParseTreeListener) VisitErrorNode(_ ErrorNode) {} -func (l *BaseParseTreeListener) EnterEveryRule(_ ParserRuleContext) {} -func (l *BaseParseTreeListener) ExitEveryRule(_ ParserRuleContext) {} - -type TerminalNodeImpl struct { - parentCtx RuleContext - symbol Token -} - -var _ TerminalNode = &TerminalNodeImpl{} - -func NewTerminalNodeImpl(symbol Token) *TerminalNodeImpl { - tn := new(TerminalNodeImpl) - - tn.parentCtx = nil - tn.symbol = symbol - - return tn -} - -func (t *TerminalNodeImpl) GetChild(_ int) Tree { - return nil -} - -func (t *TerminalNodeImpl) GetChildren() []Tree { - return nil -} - -func (t *TerminalNodeImpl) SetChildren(_ []Tree) { - panic("Cannot set children on terminal node") -} - -func (t *TerminalNodeImpl) GetSymbol() Token { - return t.symbol -} - -func (t *TerminalNodeImpl) GetParent() Tree { - return t.parentCtx -} - -func (t *TerminalNodeImpl) SetParent(tree Tree) { - t.parentCtx = tree.(RuleContext) -} - -func (t *TerminalNodeImpl) GetPayload() interface{} { - return t.symbol -} - -func (t *TerminalNodeImpl) GetSourceInterval() Interval { - if t.symbol == nil { - return TreeInvalidInterval - } - tokenIndex := t.symbol.GetTokenIndex() - return NewInterval(tokenIndex, tokenIndex) -} - -func (t *TerminalNodeImpl) GetChildCount() int { - return 0 -} - -func (t *TerminalNodeImpl) Accept(v ParseTreeVisitor) interface{} { - return v.VisitTerminal(t) -} - -func (t *TerminalNodeImpl) GetText() string { - return t.symbol.GetText() -} - -func (t *TerminalNodeImpl) String() string { - if t.symbol.GetTokenType() == TokenEOF { - return "" - } - - return t.symbol.GetText() -} - -func (t *TerminalNodeImpl) ToStringTree(_ []string, _ Recognizer) string { - return t.String() -} - -// Represents a token that was consumed during reSynchronization -// rather than during a valid Match operation. For example, -// we will create this kind of a node during single token insertion -// and deletion as well as during "consume until error recovery set" -// upon no viable alternative exceptions. - -type ErrorNodeImpl struct { - *TerminalNodeImpl -} - -var _ ErrorNode = &ErrorNodeImpl{} - -func NewErrorNodeImpl(token Token) *ErrorNodeImpl { - en := new(ErrorNodeImpl) - en.TerminalNodeImpl = NewTerminalNodeImpl(token) - return en -} - -func (e *ErrorNodeImpl) errorNode() {} - -func (e *ErrorNodeImpl) Accept(v ParseTreeVisitor) interface{} { - return v.VisitErrorNode(e) -} - -type ParseTreeWalker struct { -} - -func NewParseTreeWalker() *ParseTreeWalker { - return new(ParseTreeWalker) -} - -// Walk performs a walk on the given parse tree starting at the root and going down recursively -// with depth-first search. On each node, [EnterRule] is called before -// recursively walking down into child nodes, then [ExitRule] is called after the recursive call to wind up. -func (p *ParseTreeWalker) Walk(listener ParseTreeListener, t Tree) { - switch tt := t.(type) { - case ErrorNode: - listener.VisitErrorNode(tt) - case TerminalNode: - listener.VisitTerminal(tt) - default: - p.EnterRule(listener, t.(RuleNode)) - for i := 0; i < t.GetChildCount(); i++ { - child := t.GetChild(i) - p.Walk(listener, child) - } - p.ExitRule(listener, t.(RuleNode)) - } -} - -// EnterRule enters a grammar rule by first triggering the generic event [ParseTreeListener].[EnterEveryRule] -// then by triggering the event specific to the given parse tree node -func (p *ParseTreeWalker) EnterRule(listener ParseTreeListener, r RuleNode) { - ctx := r.GetRuleContext().(ParserRuleContext) - listener.EnterEveryRule(ctx) - ctx.EnterRule(listener) -} - -// ExitRule exits a grammar rule by first triggering the event specific to the given parse tree node -// then by triggering the generic event [ParseTreeListener].ExitEveryRule -func (p *ParseTreeWalker) ExitRule(listener ParseTreeListener, r RuleNode) { - ctx := r.GetRuleContext().(ParserRuleContext) - ctx.ExitRule(listener) - listener.ExitEveryRule(ctx) -} - -//goland:noinspection GoUnusedGlobalVariable -var ParseTreeWalkerDefault = NewParseTreeWalker() - -type IterativeParseTreeWalker struct { - *ParseTreeWalker -} - -//goland:noinspection GoUnusedExportedFunction -func NewIterativeParseTreeWalker() *IterativeParseTreeWalker { - return new(IterativeParseTreeWalker) -} - -func (i *IterativeParseTreeWalker) Walk(listener ParseTreeListener, t Tree) { - var stack []Tree - var indexStack []int - currentNode := t - currentIndex := 0 - - for currentNode != nil { - // pre-order visit - switch tt := currentNode.(type) { - case ErrorNode: - listener.VisitErrorNode(tt) - case TerminalNode: - listener.VisitTerminal(tt) - default: - i.EnterRule(listener, currentNode.(RuleNode)) - } - // Move down to first child, if exists - if currentNode.GetChildCount() > 0 { - stack = append(stack, currentNode) - indexStack = append(indexStack, currentIndex) - currentIndex = 0 - currentNode = currentNode.GetChild(0) - continue - } - - for { - // post-order visit - if ruleNode, ok := currentNode.(RuleNode); ok { - i.ExitRule(listener, ruleNode) - } - // No parent, so no siblings - if len(stack) == 0 { - currentNode = nil - currentIndex = 0 - break - } - // Move to next sibling if possible - currentIndex++ - if stack[len(stack)-1].GetChildCount() > currentIndex { - currentNode = stack[len(stack)-1].GetChild(currentIndex) - break - } - // No next, sibling, so move up - currentNode, stack = stack[len(stack)-1], stack[:len(stack)-1] - currentIndex, indexStack = indexStack[len(indexStack)-1], indexStack[:len(indexStack)-1] - } - } -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/trees.go b/vendor/github.com/antlr4-go/antlr/v4/trees.go deleted file mode 100644 index f44c05d81..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/trees.go +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import "fmt" - -/** A set of utility routines useful for all kinds of ANTLR trees. */ - -// TreesStringTree prints out a whole tree in LISP form. [getNodeText] is used on the -// node payloads to get the text for the nodes. Detects parse trees and extracts data appropriately. -func TreesStringTree(tree Tree, ruleNames []string, recog Recognizer) string { - - if recog != nil { - ruleNames = recog.GetRuleNames() - } - - s := TreesGetNodeText(tree, ruleNames, nil) - - s = EscapeWhitespace(s, false) - c := tree.GetChildCount() - if c == 0 { - return s - } - res := "(" + s + " " - if c > 0 { - s = TreesStringTree(tree.GetChild(0), ruleNames, nil) - res += s - } - for i := 1; i < c; i++ { - s = TreesStringTree(tree.GetChild(i), ruleNames, nil) - res += " " + s - } - res += ")" - return res -} - -func TreesGetNodeText(t Tree, ruleNames []string, recog Parser) string { - if recog != nil { - ruleNames = recog.GetRuleNames() - } - - if ruleNames != nil { - switch t2 := t.(type) { - case RuleNode: - t3 := t2.GetRuleContext() - altNumber := t3.GetAltNumber() - - if altNumber != ATNInvalidAltNumber { - return fmt.Sprintf("%s:%d", ruleNames[t3.GetRuleIndex()], altNumber) - } - return ruleNames[t3.GetRuleIndex()] - case ErrorNode: - return fmt.Sprint(t2) - case TerminalNode: - if t2.GetSymbol() != nil { - return t2.GetSymbol().GetText() - } - } - } - - // no recognition for rule names - payload := t.GetPayload() - if p2, ok := payload.(Token); ok { - return p2.GetText() - } - - return fmt.Sprint(t.GetPayload()) -} - -// TreesGetChildren returns am ordered list of all children of this node -// -//goland:noinspection GoUnusedExportedFunction -func TreesGetChildren(t Tree) []Tree { - list := make([]Tree, 0) - for i := 0; i < t.GetChildCount(); i++ { - list = append(list, t.GetChild(i)) - } - return list -} - -// TreesgetAncestors returns a list of all ancestors of this node. The first node of list is the root -// and the last node is the parent of this node. -// -//goland:noinspection GoUnusedExportedFunction -func TreesgetAncestors(t Tree) []Tree { - ancestors := make([]Tree, 0) - t = t.GetParent() - for t != nil { - f := []Tree{t} - ancestors = append(f, ancestors...) - t = t.GetParent() - } - return ancestors -} - -//goland:noinspection GoUnusedExportedFunction -func TreesFindAllTokenNodes(t ParseTree, ttype int) []ParseTree { - return TreesfindAllNodes(t, ttype, true) -} - -//goland:noinspection GoUnusedExportedFunction -func TreesfindAllRuleNodes(t ParseTree, ruleIndex int) []ParseTree { - return TreesfindAllNodes(t, ruleIndex, false) -} - -func TreesfindAllNodes(t ParseTree, index int, findTokens bool) []ParseTree { - nodes := make([]ParseTree, 0) - treesFindAllNodes(t, index, findTokens, &nodes) - return nodes -} - -func treesFindAllNodes(t ParseTree, index int, findTokens bool, nodes *[]ParseTree) { - // check this node (the root) first - - t2, ok := t.(TerminalNode) - t3, ok2 := t.(ParserRuleContext) - - if findTokens && ok { - if t2.GetSymbol().GetTokenType() == index { - *nodes = append(*nodes, t2) - } - } else if !findTokens && ok2 { - if t3.GetRuleIndex() == index { - *nodes = append(*nodes, t3) - } - } - // check children - for i := 0; i < t.GetChildCount(); i++ { - treesFindAllNodes(t.GetChild(i).(ParseTree), index, findTokens, nodes) - } -} - -//goland:noinspection GoUnusedExportedFunction -func TreesDescendants(t ParseTree) []ParseTree { - nodes := []ParseTree{t} - for i := 0; i < t.GetChildCount(); i++ { - nodes = append(nodes, TreesDescendants(t.GetChild(i).(ParseTree))...) - } - return nodes -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/utils.go b/vendor/github.com/antlr4-go/antlr/v4/utils.go deleted file mode 100644 index 733d7df9d..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/utils.go +++ /dev/null @@ -1,328 +0,0 @@ -// Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. -// Use of this file is governed by the BSD 3-clause license that -// can be found in the LICENSE.txt file in the project root. - -package antlr - -import ( - "bytes" - "errors" - "fmt" - "math/bits" - "os" - "strconv" - "strings" - "syscall" -) - -func intMin(a, b int) int { - if a < b { - return a - } - return b -} - -func intMax(a, b int) int { - if a > b { - return a - } - return b -} - -// A simple integer stack - -type IntStack []int - -var ErrEmptyStack = errors.New("stack is empty") - -func (s *IntStack) Pop() (int, error) { - l := len(*s) - 1 - if l < 0 { - return 0, ErrEmptyStack - } - v := (*s)[l] - *s = (*s)[0:l] - return v, nil -} - -func (s *IntStack) Push(e int) { - *s = append(*s, e) -} - -const bitsPerWord = 64 - -func indexForBit(bit int) int { - return bit / bitsPerWord -} - -//goland:noinspection GoUnusedExportedFunction,GoUnusedFunction -func wordForBit(data []uint64, bit int) uint64 { - idx := indexForBit(bit) - if idx >= len(data) { - return 0 - } - return data[idx] -} - -func maskForBit(bit int) uint64 { - return uint64(1) << (bit % bitsPerWord) -} - -func wordsNeeded(bit int) int { - return indexForBit(bit) + 1 -} - -type BitSet struct { - data []uint64 -} - -// NewBitSet creates a new bitwise set -// TODO: See if we can replace with the standard library's BitSet -func NewBitSet() *BitSet { - return &BitSet{} -} - -func (b *BitSet) add(value int) { - idx := indexForBit(value) - if idx >= len(b.data) { - size := wordsNeeded(value) - data := make([]uint64, size) - copy(data, b.data) - b.data = data - } - b.data[idx] |= maskForBit(value) -} - -func (b *BitSet) clear(index int) { - idx := indexForBit(index) - if idx >= len(b.data) { - return - } - b.data[idx] &= ^maskForBit(index) -} - -func (b *BitSet) or(set *BitSet) { - // Get min size necessary to represent the bits in both sets. - bLen := b.minLen() - setLen := set.minLen() - maxLen := intMax(bLen, setLen) - if maxLen > len(b.data) { - // Increase the size of len(b.data) to represent the bits in both sets. - data := make([]uint64, maxLen) - copy(data, b.data) - b.data = data - } - // len(b.data) is at least setLen. - for i := 0; i < setLen; i++ { - b.data[i] |= set.data[i] - } -} - -func (b *BitSet) remove(value int) { - b.clear(value) -} - -func (b *BitSet) contains(value int) bool { - idx := indexForBit(value) - if idx >= len(b.data) { - return false - } - return (b.data[idx] & maskForBit(value)) != 0 -} - -func (b *BitSet) minValue() int { - for i, v := range b.data { - if v == 0 { - continue - } - return i*bitsPerWord + bits.TrailingZeros64(v) - } - return 2147483647 -} - -func (b *BitSet) equals(other interface{}) bool { - otherBitSet, ok := other.(*BitSet) - if !ok { - return false - } - - if b == otherBitSet { - return true - } - - // We only compare set bits, so we cannot rely on the two slices having the same size. Its - // possible for two BitSets to have different slice lengths but the same set bits. So we only - // compare the relevant words and ignore the trailing zeros. - bLen := b.minLen() - otherLen := otherBitSet.minLen() - - if bLen != otherLen { - return false - } - - for i := 0; i < bLen; i++ { - if b.data[i] != otherBitSet.data[i] { - return false - } - } - - return true -} - -func (b *BitSet) minLen() int { - for i := len(b.data); i > 0; i-- { - if b.data[i-1] != 0 { - return i - } - } - return 0 -} - -func (b *BitSet) length() int { - cnt := 0 - for _, val := range b.data { - cnt += bits.OnesCount64(val) - } - return cnt -} - -func (b *BitSet) String() string { - vals := make([]string, 0, b.length()) - - for i, v := range b.data { - for v != 0 { - n := bits.TrailingZeros64(v) - vals = append(vals, strconv.Itoa(i*bitsPerWord+n)) - v &= ^(uint64(1) << n) - } - } - - return "{" + strings.Join(vals, ", ") + "}" -} - -type AltDict struct { - data map[string]interface{} -} - -func NewAltDict() *AltDict { - d := new(AltDict) - d.data = make(map[string]interface{}) - return d -} - -func (a *AltDict) Get(key string) interface{} { - key = "k-" + key - return a.data[key] -} - -func (a *AltDict) put(key string, value interface{}) { - key = "k-" + key - a.data[key] = value -} - -func (a *AltDict) values() []interface{} { - vs := make([]interface{}, len(a.data)) - i := 0 - for _, v := range a.data { - vs[i] = v - i++ - } - return vs -} - -func EscapeWhitespace(s string, escapeSpaces bool) string { - - s = strings.Replace(s, "\t", "\\t", -1) - s = strings.Replace(s, "\n", "\\n", -1) - s = strings.Replace(s, "\r", "\\r", -1) - if escapeSpaces { - s = strings.Replace(s, " ", "\u00B7", -1) - } - return s -} - -//goland:noinspection GoUnusedExportedFunction -func TerminalNodeToStringArray(sa []TerminalNode) []string { - st := make([]string, len(sa)) - - for i, s := range sa { - st[i] = fmt.Sprintf("%v", s) - } - - return st -} - -//goland:noinspection GoUnusedExportedFunction -func PrintArrayJavaStyle(sa []string) string { - var buffer bytes.Buffer - - buffer.WriteString("[") - - for i, s := range sa { - buffer.WriteString(s) - if i != len(sa)-1 { - buffer.WriteString(", ") - } - } - - buffer.WriteString("]") - - return buffer.String() -} - -// murmur hash -func murmurInit(seed int) int { - return seed -} - -func murmurUpdate(h int, value int) int { - const c1 uint32 = 0xCC9E2D51 - const c2 uint32 = 0x1B873593 - const r1 uint32 = 15 - const r2 uint32 = 13 - const m uint32 = 5 - const n uint32 = 0xE6546B64 - - k := uint32(value) - k *= c1 - k = (k << r1) | (k >> (32 - r1)) - k *= c2 - - hash := uint32(h) ^ k - hash = (hash << r2) | (hash >> (32 - r2)) - hash = hash*m + n - return int(hash) -} - -func murmurFinish(h int, numberOfWords int) int { - var hash = uint32(h) - hash ^= uint32(numberOfWords) << 2 - hash ^= hash >> 16 - hash *= 0x85ebca6b - hash ^= hash >> 13 - hash *= 0xc2b2ae35 - hash ^= hash >> 16 - - return int(hash) -} - -func isDirectory(dir string) (bool, error) { - fileInfo, err := os.Stat(dir) - if err != nil { - switch { - case errors.Is(err, syscall.ENOENT): - // The given directory does not exist, so we will try to create it - // - err = os.MkdirAll(dir, 0755) - if err != nil { - return false, err - } - - return true, nil - case err != nil: - return false, err - default: - } - } - return fileInfo.IsDir(), err -} diff --git a/vendor/github.com/google/cel-go/LICENSE b/vendor/github.com/google/cel-go/LICENSE deleted file mode 100644 index 2493ed2eb..000000000 --- a/vendor/github.com/google/cel-go/LICENSE +++ /dev/null @@ -1,233 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -=========================================================================== -The common/types/pb/equal.go modification of proto.Equal logic -=========================================================================== -Copyright (c) 2018 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/google/cel-go/cel/BUILD.bazel b/vendor/github.com/google/cel-go/cel/BUILD.bazel deleted file mode 100644 index 33da21623..000000000 --- a/vendor/github.com/google/cel-go/cel/BUILD.bazel +++ /dev/null @@ -1,90 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -package( - licenses = ["notice"], # Apache 2.0 -) - -go_library( - name = "go_default_library", - srcs = [ - "cel.go", - "decls.go", - "env.go", - "folding.go", - "io.go", - "inlining.go", - "library.go", - "macro.go", - "optimizer.go", - "options.go", - "program.go", - "validator.go", - ], - importpath = "github.com/google/cel-go/cel", - visibility = ["//visibility:public"], - deps = [ - "//checker:go_default_library", - "//checker/decls:go_default_library", - "//common:go_default_library", - "//common/ast:go_default_library", - "//common/containers:go_default_library", - "//common/decls:go_default_library", - "//common/functions:go_default_library", - "//common/operators:go_default_library", - "//common/overloads:go_default_library", - "//common/stdlib:go_default_library", - "//common/types:go_default_library", - "//common/types/pb:go_default_library", - "//common/types/ref:go_default_library", - "//common/types/traits:go_default_library", - "//interpreter:go_default_library", - "//parser:go_default_library", - "@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library", - "@org_golang_google_protobuf//proto:go_default_library", - "@org_golang_google_protobuf//reflect/protodesc:go_default_library", - "@org_golang_google_protobuf//reflect/protoreflect:go_default_library", - "@org_golang_google_protobuf//reflect/protoregistry:go_default_library", - "@org_golang_google_protobuf//types/descriptorpb:go_default_library", - "@org_golang_google_protobuf//types/dynamicpb:go_default_library", - "@org_golang_google_protobuf//types/known/anypb:go_default_library", - "@org_golang_google_protobuf//types/known/durationpb:go_default_library", - "@org_golang_google_protobuf//types/known/timestamppb:go_default_library", - ], -) - -go_test( - name = "go_default_test", - srcs = [ - "cel_example_test.go", - "cel_test.go", - "decls_test.go", - "env_test.go", - "folding_test.go", - "io_test.go", - "inlining_test.go", - "optimizer_test.go", - "validator_test.go", - ], - data = [ - "//cel/testdata:gen_test_fds", - ], - embed = [ - ":go_default_library", - ], - deps = [ - "//common/operators:go_default_library", - "//common/overloads:go_default_library", - "//common/types:go_default_library", - "//common/types/ref:go_default_library", - "//common/types/traits:go_default_library", - "//test:go_default_library", - "//test/proto2pb:go_default_library", - "//test/proto3pb:go_default_library", - "@io_bazel_rules_go//proto/wkt:descriptor_go_proto", - "@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library", - "@org_golang_google_protobuf//proto:go_default_library", - "@org_golang_google_protobuf//encoding/prototext:go_default_library", - "@org_golang_google_protobuf//types/known/structpb:go_default_library", - "@org_golang_google_protobuf//types/known/wrapperspb:go_default_library", - ], -) diff --git a/vendor/github.com/google/cel-go/cel/cel.go b/vendor/github.com/google/cel-go/cel/cel.go deleted file mode 100644 index eb5a9f4cc..000000000 --- a/vendor/github.com/google/cel-go/cel/cel.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2019 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package cel defines the top-level interface for the Common Expression Language (CEL). -// -// CEL is a non-Turing complete expression language designed to parse, check, and evaluate -// expressions against user-defined environments. -package cel diff --git a/vendor/github.com/google/cel-go/cel/decls.go b/vendor/github.com/google/cel-go/cel/decls.go deleted file mode 100644 index b59e3708d..000000000 --- a/vendor/github.com/google/cel-go/cel/decls.go +++ /dev/null @@ -1,355 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package cel - -import ( - "fmt" - - "github.com/google/cel-go/common/ast" - "github.com/google/cel-go/common/decls" - "github.com/google/cel-go/common/functions" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/common/types/ref" - - exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1" -) - -// Kind indicates a CEL type's kind which is used to differentiate quickly between simple and complex types. -type Kind = types.Kind - -const ( - // DynKind represents a dynamic type. This kind only exists at type-check time. - DynKind Kind = types.DynKind - - // AnyKind represents a google.protobuf.Any type. This kind only exists at type-check time. - AnyKind = types.AnyKind - - // BoolKind represents a boolean type. - BoolKind = types.BoolKind - - // BytesKind represents a bytes type. - BytesKind = types.BytesKind - - // DoubleKind represents a double type. - DoubleKind = types.DoubleKind - - // DurationKind represents a CEL duration type. - DurationKind = types.DurationKind - - // IntKind represents an integer type. - IntKind = types.IntKind - - // ListKind represents a list type. - ListKind = types.ListKind - - // MapKind represents a map type. - MapKind = types.MapKind - - // NullTypeKind represents a null type. - NullTypeKind = types.NullTypeKind - - // OpaqueKind represents an abstract type which has no accessible fields. - OpaqueKind = types.OpaqueKind - - // StringKind represents a string type. - StringKind = types.StringKind - - // StructKind represents a structured object with typed fields. - StructKind = types.StructKind - - // TimestampKind represents a a CEL time type. - TimestampKind = types.TimestampKind - - // TypeKind represents the CEL type. - TypeKind = types.TypeKind - - // TypeParamKind represents a parameterized type whose type name will be resolved at type-check time, if possible. - TypeParamKind = types.TypeParamKind - - // UintKind represents a uint type. - UintKind = types.UintKind -) - -var ( - // AnyType represents the google.protobuf.Any type. - AnyType = types.AnyType - // BoolType represents the bool type. - BoolType = types.BoolType - // BytesType represents the bytes type. - BytesType = types.BytesType - // DoubleType represents the double type. - DoubleType = types.DoubleType - // DurationType represents the CEL duration type. - DurationType = types.DurationType - // DynType represents a dynamic CEL type whose type will be determined at runtime from context. - DynType = types.DynType - // IntType represents the int type. - IntType = types.IntType - // NullType represents the type of a null value. - NullType = types.NullType - // StringType represents the string type. - StringType = types.StringType - // TimestampType represents the time type. - TimestampType = types.TimestampType - // TypeType represents a CEL type - TypeType = types.TypeType - // UintType represents a uint type. - UintType = types.UintType - - // function references for instantiating new types. - - // ListType creates an instances of a list type value with the provided element type. - ListType = types.NewListType - // MapType creates an instance of a map type value with the provided key and value types. - MapType = types.NewMapType - // NullableType creates an instance of a nullable type with the provided wrapped type. - // - // Note: only primitive types are supported as wrapped types. - NullableType = types.NewNullableType - // OptionalType creates an abstract parameterized type instance corresponding to CEL's notion of optional. - OptionalType = types.NewOptionalType - // OpaqueType creates an abstract parameterized type with a given name. - OpaqueType = types.NewOpaqueType - // ObjectType creates a type references to an externally defined type, e.g. a protobuf message type. - ObjectType = types.NewObjectType - // TypeParamType creates a parameterized type instance. - TypeParamType = types.NewTypeParamType -) - -// Type holds a reference to a runtime type with an optional type-checked set of type parameters. -type Type = types.Type - -// Constant creates an instances of an identifier declaration with a variable name, type, and value. -func Constant(name string, t *Type, v ref.Val) EnvOption { - return func(e *Env) (*Env, error) { - e.variables = append(e.variables, decls.NewConstant(name, t, v)) - return e, nil - } -} - -// Variable creates an instance of a variable declaration with a variable name and type. -func Variable(name string, t *Type) EnvOption { - return func(e *Env) (*Env, error) { - e.variables = append(e.variables, decls.NewVariable(name, t)) - return e, nil - } -} - -// Function defines a function and overloads with optional singleton or per-overload bindings. -// -// Using Function is roughly equivalent to calling Declarations() to declare the function signatures -// and Functions() to define the function bindings, if they have been defined. Specifying the -// same function name more than once will result in the aggregation of the function overloads. If any -// signatures conflict between the existing and new function definition an error will be raised. -// However, if the signatures are identical and the overload ids are the same, the redefinition will -// be considered a no-op. -// -// One key difference with using Function() is that each FunctionDecl provided will handle dynamic -// dispatch based on the type-signatures of the overloads provided which means overload resolution at -// runtime is handled out of the box rather than via a custom binding for overload resolution via -// Functions(): -// -// - Overloads are searched in the order they are declared -// - Dynamic dispatch for lists and maps is limited by inspection of the list and map contents -// -// at runtime. Empty lists and maps will result in a 'default dispatch' -// -// - In the event that a default dispatch occurs, the first overload provided is the one invoked -// -// If you intend to use overloads which differentiate based on the key or element type of a list or -// map, consider using a generic function instead: e.g. func(list(T)) or func(map(K, V)) as this -// will allow your implementation to determine how best to handle dispatch and the default behavior -// for empty lists and maps whose contents cannot be inspected. -// -// For functions which use parameterized opaque types (abstract types), consider using a singleton -// function which is capable of inspecting the contents of the type and resolving the appropriate -// overload as CEL can only make inferences by type-name regarding such types. -func Function(name string, opts ...FunctionOpt) EnvOption { - return func(e *Env) (*Env, error) { - fn, err := decls.NewFunction(name, opts...) - if err != nil { - return nil, err - } - if existing, found := e.functions[fn.Name()]; found { - fn, err = existing.Merge(fn) - if err != nil { - return nil, err - } - } - e.functions[fn.Name()] = fn - return e, nil - } -} - -// FunctionOpt defines a functional option for configuring a function declaration. -type FunctionOpt = decls.FunctionOpt - -// SingletonUnaryBinding creates a singleton function definition to be used for all function overloads. -// -// Note, this approach works well if operand is expected to have a specific trait which it implements, -// e.g. traits.ContainerType. Otherwise, prefer per-overload function bindings. -func SingletonUnaryBinding(fn functions.UnaryOp, traits ...int) FunctionOpt { - return decls.SingletonUnaryBinding(fn, traits...) -} - -// SingletonBinaryImpl creates a singleton function definition to be used with all function overloads. -// -// Note, this approach works well if operand is expected to have a specific trait which it implements, -// e.g. traits.ContainerType. Otherwise, prefer per-overload function bindings. -// -// Deprecated: use SingletonBinaryBinding -func SingletonBinaryImpl(fn functions.BinaryOp, traits ...int) FunctionOpt { - return decls.SingletonBinaryBinding(fn, traits...) -} - -// SingletonBinaryBinding creates a singleton function definition to be used with all function overloads. -// -// Note, this approach works well if operand is expected to have a specific trait which it implements, -// e.g. traits.ContainerType. Otherwise, prefer per-overload function bindings. -func SingletonBinaryBinding(fn functions.BinaryOp, traits ...int) FunctionOpt { - return decls.SingletonBinaryBinding(fn, traits...) -} - -// SingletonFunctionImpl creates a singleton function definition to be used with all function overloads. -// -// Note, this approach works well if operand is expected to have a specific trait which it implements, -// e.g. traits.ContainerType. Otherwise, prefer per-overload function bindings. -// -// Deprecated: use SingletonFunctionBinding -func SingletonFunctionImpl(fn functions.FunctionOp, traits ...int) FunctionOpt { - return decls.SingletonFunctionBinding(fn, traits...) -} - -// SingletonFunctionBinding creates a singleton function definition to be used with all function overloads. -// -// Note, this approach works well if operand is expected to have a specific trait which it implements, -// e.g. traits.ContainerType. Otherwise, prefer per-overload function bindings. -func SingletonFunctionBinding(fn functions.FunctionOp, traits ...int) FunctionOpt { - return decls.SingletonFunctionBinding(fn, traits...) -} - -// DisableDeclaration disables the function signatures, effectively removing them from the type-check -// environment while preserving the runtime bindings. -func DisableDeclaration(value bool) FunctionOpt { - return decls.DisableDeclaration(value) -} - -// Overload defines a new global overload with an overload id, argument types, and result type. Through the -// use of OverloadOpt options, the overload may also be configured with a binding, an operand trait, and to -// be non-strict. -// -// Note: function bindings should be commonly configured with Overload instances whereas operand traits and -// strict-ness should be rare occurrences. -func Overload(overloadID string, args []*Type, resultType *Type, opts ...OverloadOpt) FunctionOpt { - return decls.Overload(overloadID, args, resultType, opts...) -} - -// MemberOverload defines a new receiver-style overload (or member function) with an overload id, argument types, -// and result type. Through the use of OverloadOpt options, the overload may also be configured with a binding, -// an operand trait, and to be non-strict. -// -// Note: function bindings should be commonly configured with Overload instances whereas operand traits and -// strict-ness should be rare occurrences. -func MemberOverload(overloadID string, args []*Type, resultType *Type, opts ...OverloadOpt) FunctionOpt { - return decls.MemberOverload(overloadID, args, resultType, opts...) -} - -// OverloadOpt is a functional option for configuring a function overload. -type OverloadOpt = decls.OverloadOpt - -// UnaryBinding provides the implementation of a unary overload. The provided function is protected by a runtime -// type-guard which ensures runtime type agreement between the overload signature and runtime argument types. -func UnaryBinding(binding functions.UnaryOp) OverloadOpt { - return decls.UnaryBinding(binding) -} - -// BinaryBinding provides the implementation of a binary overload. The provided function is protected by a runtime -// type-guard which ensures runtime type agreement between the overload signature and runtime argument types. -func BinaryBinding(binding functions.BinaryOp) OverloadOpt { - return decls.BinaryBinding(binding) -} - -// FunctionBinding provides the implementation of a variadic overload. The provided function is protected by a runtime -// type-guard which ensures runtime type agreement between the overload signature and runtime argument types. -func FunctionBinding(binding functions.FunctionOp) OverloadOpt { - return decls.FunctionBinding(binding) -} - -// OverloadIsNonStrict enables the function to be called with error and unknown argument values. -// -// Note: do not use this option unless absoluately necessary as it should be an uncommon feature. -func OverloadIsNonStrict() OverloadOpt { - return decls.OverloadIsNonStrict() -} - -// OverloadOperandTrait configures a set of traits which the first argument to the overload must implement in order to be -// successfully invoked. -func OverloadOperandTrait(trait int) OverloadOpt { - return decls.OverloadOperandTrait(trait) -} - -// TypeToExprType converts a CEL-native type representation to a protobuf CEL Type representation. -func TypeToExprType(t *Type) (*exprpb.Type, error) { - return types.TypeToExprType(t) -} - -// ExprTypeToType converts a protobuf CEL type representation to a CEL-native type representation. -func ExprTypeToType(t *exprpb.Type) (*Type, error) { - return types.ExprTypeToType(t) -} - -// ExprDeclToDeclaration converts a protobuf CEL declaration to a CEL-native declaration, either a Variable or Function. -func ExprDeclToDeclaration(d *exprpb.Decl) (EnvOption, error) { - switch d.GetDeclKind().(type) { - case *exprpb.Decl_Function: - overloads := d.GetFunction().GetOverloads() - opts := make([]FunctionOpt, len(overloads)) - for i, o := range overloads { - args := make([]*Type, len(o.GetParams())) - for j, p := range o.GetParams() { - a, err := types.ExprTypeToType(p) - if err != nil { - return nil, err - } - args[j] = a - } - res, err := types.ExprTypeToType(o.GetResultType()) - if err != nil { - return nil, err - } - if o.IsInstanceFunction { - opts[i] = decls.MemberOverload(o.GetOverloadId(), args, res) - } else { - opts[i] = decls.Overload(o.GetOverloadId(), args, res) - } - } - return Function(d.GetName(), opts...), nil - case *exprpb.Decl_Ident: - t, err := types.ExprTypeToType(d.GetIdent().GetType()) - if err != nil { - return nil, err - } - if d.GetIdent().GetValue() == nil { - return Variable(d.GetName(), t), nil - } - val, err := ast.ConstantToVal(d.GetIdent().GetValue()) - if err != nil { - return nil, err - } - return Constant(d.GetName(), t, val), nil - default: - return nil, fmt.Errorf("unsupported decl: %v", d) - } -} diff --git a/vendor/github.com/google/cel-go/cel/env.go b/vendor/github.com/google/cel-go/cel/env.go deleted file mode 100644 index 6568a8b80..000000000 --- a/vendor/github.com/google/cel-go/cel/env.go +++ /dev/null @@ -1,881 +0,0 @@ -// Copyright 2019 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package cel - -import ( - "errors" - "sync" - - "github.com/google/cel-go/checker" - chkdecls "github.com/google/cel-go/checker/decls" - "github.com/google/cel-go/common" - celast "github.com/google/cel-go/common/ast" - "github.com/google/cel-go/common/containers" - "github.com/google/cel-go/common/decls" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/common/types/ref" - "github.com/google/cel-go/interpreter" - "github.com/google/cel-go/parser" - - exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1" -) - -// Source interface representing a user-provided expression. -type Source = common.Source - -// Ast representing the checked or unchecked expression, its source, and related metadata such as -// source position information. -type Ast struct { - source Source - impl *celast.AST -} - -// NativeRep converts the AST to a Go-native representation. -func (ast *Ast) NativeRep() *celast.AST { - return ast.impl -} - -// Expr returns the proto serializable instance of the parsed/checked expression. -// -// Deprecated: prefer cel.AstToCheckedExpr() or cel.AstToParsedExpr() and call GetExpr() -// the result instead. -func (ast *Ast) Expr() *exprpb.Expr { - if ast == nil { - return nil - } - pbExpr, _ := celast.ExprToProto(ast.impl.Expr()) - return pbExpr -} - -// IsChecked returns whether the Ast value has been successfully type-checked. -func (ast *Ast) IsChecked() bool { - if ast == nil { - return false - } - return ast.impl.IsChecked() -} - -// SourceInfo returns character offset and newline position information about expression elements. -func (ast *Ast) SourceInfo() *exprpb.SourceInfo { - if ast == nil { - return nil - } - pbInfo, _ := celast.SourceInfoToProto(ast.impl.SourceInfo()) - return pbInfo -} - -// ResultType returns the output type of the expression if the Ast has been type-checked, else -// returns chkdecls.Dyn as the parse step cannot infer the type. -// -// Deprecated: use OutputType -func (ast *Ast) ResultType() *exprpb.Type { - out := ast.OutputType() - t, err := TypeToExprType(out) - if err != nil { - return chkdecls.Dyn - } - return t -} - -// OutputType returns the output type of the expression if the Ast has been type-checked, else -// returns cel.DynType as the parse step cannot infer types. -func (ast *Ast) OutputType() *Type { - if ast == nil { - return types.ErrorType - } - return ast.impl.GetType(ast.impl.Expr().ID()) -} - -// Source returns a view of the input used to create the Ast. This source may be complete or -// constructed from the SourceInfo. -func (ast *Ast) Source() Source { - if ast == nil { - return nil - } - return ast.source -} - -// FormatType converts a type message into a string representation. -// -// Deprecated: prefer FormatCELType -func FormatType(t *exprpb.Type) string { - return checker.FormatCheckedType(t) -} - -// FormatCELType formats a cel.Type value to a string representation. -// -// The type formatting is identical to FormatType. -func FormatCELType(t *Type) string { - return checker.FormatCELType(t) -} - -// Env encapsulates the context necessary to perform parsing, type checking, or generation of -// evaluable programs for different expressions. -type Env struct { - Container *containers.Container - variables []*decls.VariableDecl - functions map[string]*decls.FunctionDecl - macros []parser.Macro - adapter types.Adapter - provider types.Provider - features map[int]bool - appliedFeatures map[int]bool - libraries map[string]bool - validators []ASTValidator - costOptions []checker.CostOption - - // Internal parser representation - prsr *parser.Parser - prsrOpts []parser.Option - - // Internal checker representation - chkMutex sync.Mutex - chk *checker.Env - chkErr error - chkOnce sync.Once - chkOpts []checker.Option - - // Program options tied to the environment - progOpts []ProgramOption -} - -// NewEnv creates a program environment configured with the standard library of CEL functions and -// macros. The Env value returned can parse and check any CEL program which builds upon the core -// features documented in the CEL specification. -// -// See the EnvOption helper functions for the options that can be used to configure the -// environment. -func NewEnv(opts ...EnvOption) (*Env, error) { - // Extend the statically configured standard environment, disabling eager validation to ensure - // the cost of setup for the environment is still just as cheap as it is in v0.11.x and earlier - // releases. The user provided options can easily re-enable the eager validation as they are - // processed after this default option. - stdOpts := append([]EnvOption{EagerlyValidateDeclarations(false)}, opts...) - env, err := getStdEnv() - if err != nil { - return nil, err - } - return env.Extend(stdOpts...) -} - -// NewCustomEnv creates a custom program environment which is not automatically configured with the -// standard library of functions and macros documented in the CEL spec. -// -// The purpose for using a custom environment might be for subsetting the standard library produced -// by the cel.StdLib() function. Subsetting CEL is a core aspect of its design that allows users to -// limit the compute and memory impact of a CEL program by controlling the functions and macros -// that may appear in a given expression. -// -// See the EnvOption helper functions for the options that can be used to configure the -// environment. -func NewCustomEnv(opts ...EnvOption) (*Env, error) { - registry, err := types.NewRegistry() - if err != nil { - return nil, err - } - return (&Env{ - variables: []*decls.VariableDecl{}, - functions: map[string]*decls.FunctionDecl{}, - macros: []parser.Macro{}, - Container: containers.DefaultContainer, - adapter: registry, - provider: registry, - features: map[int]bool{}, - appliedFeatures: map[int]bool{}, - libraries: map[string]bool{}, - validators: []ASTValidator{}, - progOpts: []ProgramOption{}, - costOptions: []checker.CostOption{}, - }).configure(opts) -} - -// Check performs type-checking on the input Ast and yields a checked Ast and/or set of Issues. -// If any `ASTValidators` are configured on the environment, they will be applied after a valid -// type-check result. If any issues are detected, the validators will provide them on the -// output Issues object. -// -// Either checking or validation has failed if the returned Issues value and its Issues.Err() -// value are non-nil. Issues should be inspected if they are non-nil, but may not represent a -// fatal error. -// -// It is possible to have both non-nil Ast and Issues values returned from this call: however, -// the mere presence of an Ast does not imply that it is valid for use. -func (e *Env) Check(ast *Ast) (*Ast, *Issues) { - // Construct the internal checker env, erroring if there is an issue adding the declarations. - chk, err := e.initChecker() - if err != nil { - errs := common.NewErrors(ast.Source()) - errs.ReportError(common.NoLocation, err.Error()) - return nil, NewIssuesWithSourceInfo(errs, ast.impl.SourceInfo()) - } - - checked, errs := checker.Check(ast.impl, ast.Source(), chk) - if len(errs.GetErrors()) > 0 { - return nil, NewIssuesWithSourceInfo(errs, ast.impl.SourceInfo()) - } - // Manually create the Ast to ensure that the Ast source information (which may be more - // detailed than the information provided by Check), is returned to the caller. - ast = &Ast{ - source: ast.Source(), - impl: checked} - - // Avoid creating a validator config if it's not needed. - if len(e.validators) == 0 { - return ast, nil - } - - // Generate a validator configuration from the set of configured validators. - vConfig := newValidatorConfig() - for _, v := range e.validators { - if cv, ok := v.(ASTValidatorConfigurer); ok { - cv.Configure(vConfig) - } - } - // Apply additional validators on the type-checked result. - iss := NewIssuesWithSourceInfo(errs, ast.impl.SourceInfo()) - for _, v := range e.validators { - v.Validate(e, vConfig, checked, iss) - } - if iss.Err() != nil { - return nil, iss - } - return ast, nil -} - -// Compile combines the Parse and Check phases CEL program compilation to produce an Ast and -// associated issues. -// -// If an error is encountered during parsing the Compile step will not continue with the Check -// phase. If non-error issues are encountered during Parse, they may be combined with any issues -// discovered during Check. -// -// Note, for parse-only uses of CEL use Parse. -func (e *Env) Compile(txt string) (*Ast, *Issues) { - return e.CompileSource(common.NewTextSource(txt)) -} - -// CompileSource combines the Parse and Check phases CEL program compilation to produce an Ast and -// associated issues. -// -// If an error is encountered during parsing the CompileSource step will not continue with the -// Check phase. If non-error issues are encountered during Parse, they may be combined with any -// issues discovered during Check. -// -// Note, for parse-only uses of CEL use Parse. -func (e *Env) CompileSource(src Source) (*Ast, *Issues) { - ast, iss := e.ParseSource(src) - if iss.Err() != nil { - return nil, iss - } - checked, iss2 := e.Check(ast) - if iss2.Err() != nil { - return nil, iss2 - } - return checked, iss2 -} - -// Extend the current environment with additional options to produce a new Env. -// -// Note, the extended Env value should not share memory with the original. It is possible, however, -// that a CustomTypeAdapter or CustomTypeProvider options could provide values which are mutable. -// To ensure separation of state between extended environments either make sure the TypeAdapter and -// TypeProvider are immutable, or that their underlying implementations are based on the -// ref.TypeRegistry which provides a Copy method which will be invoked by this method. -func (e *Env) Extend(opts ...EnvOption) (*Env, error) { - chk, chkErr := e.getCheckerOrError() - if chkErr != nil { - return nil, chkErr - } - - prsrOptsCopy := make([]parser.Option, len(e.prsrOpts)) - copy(prsrOptsCopy, e.prsrOpts) - - // The type-checker is configured with Declarations. The declarations may either be provided - // as options which have not yet been validated, or may come from a previous checker instance - // whose types have already been validated. - chkOptsCopy := make([]checker.Option, len(e.chkOpts)) - copy(chkOptsCopy, e.chkOpts) - - // Copy the declarations if needed. - varsCopy := []*decls.VariableDecl{} - if chk != nil { - // If the type-checker has already been instantiated, then the e.declarations have been - // validated within the chk instance. - chkOptsCopy = append(chkOptsCopy, checker.ValidatedDeclarations(chk)) - } else { - // If the type-checker has not been instantiated, ensure the unvalidated declarations are - // provided to the extended Env instance. - varsCopy = make([]*decls.VariableDecl, len(e.variables)) - copy(varsCopy, e.variables) - } - - // Copy macros and program options - macsCopy := make([]parser.Macro, len(e.macros)) - progOptsCopy := make([]ProgramOption, len(e.progOpts)) - copy(macsCopy, e.macros) - copy(progOptsCopy, e.progOpts) - - // Copy the adapter / provider if they appear to be mutable. - adapter := e.adapter - provider := e.provider - adapterReg, isAdapterReg := e.adapter.(*types.Registry) - providerReg, isProviderReg := e.provider.(*types.Registry) - // In most cases the provider and adapter will be a ref.TypeRegistry; - // however, in the rare cases where they are not, they are assumed to - // be immutable. Since it is possible to set the TypeProvider separately - // from the TypeAdapter, the possible configurations which could use a - // TypeRegistry as the base implementation are captured below. - if isAdapterReg && isProviderReg { - reg := providerReg.Copy() - provider = reg - // If the adapter and provider are the same object, set the adapter - // to the same ref.TypeRegistry as the provider. - if adapterReg == providerReg { - adapter = reg - } else { - // Otherwise, make a copy of the adapter. - adapter = adapterReg.Copy() - } - } else if isProviderReg { - provider = providerReg.Copy() - } else if isAdapterReg { - adapter = adapterReg.Copy() - } - - featuresCopy := make(map[int]bool, len(e.features)) - for k, v := range e.features { - featuresCopy[k] = v - } - appliedFeaturesCopy := make(map[int]bool, len(e.appliedFeatures)) - for k, v := range e.appliedFeatures { - appliedFeaturesCopy[k] = v - } - funcsCopy := make(map[string]*decls.FunctionDecl, len(e.functions)) - for k, v := range e.functions { - funcsCopy[k] = v - } - libsCopy := make(map[string]bool, len(e.libraries)) - for k, v := range e.libraries { - libsCopy[k] = v - } - validatorsCopy := make([]ASTValidator, len(e.validators)) - copy(validatorsCopy, e.validators) - costOptsCopy := make([]checker.CostOption, len(e.costOptions)) - copy(costOptsCopy, e.costOptions) - - ext := &Env{ - Container: e.Container, - variables: varsCopy, - functions: funcsCopy, - macros: macsCopy, - progOpts: progOptsCopy, - adapter: adapter, - features: featuresCopy, - appliedFeatures: appliedFeaturesCopy, - libraries: libsCopy, - validators: validatorsCopy, - provider: provider, - chkOpts: chkOptsCopy, - prsrOpts: prsrOptsCopy, - costOptions: costOptsCopy, - } - return ext.configure(opts) -} - -// HasFeature checks whether the environment enables the given feature -// flag, as enumerated in options.go. -func (e *Env) HasFeature(flag int) bool { - enabled, has := e.features[flag] - return has && enabled -} - -// HasLibrary returns whether a specific SingletonLibrary has been configured in the environment. -func (e *Env) HasLibrary(libName string) bool { - configured, exists := e.libraries[libName] - return exists && configured -} - -// Libraries returns a list of SingletonLibrary that have been configured in the environment. -func (e *Env) Libraries() []string { - libraries := make([]string, 0, len(e.libraries)) - for libName := range e.libraries { - libraries = append(libraries, libName) - } - return libraries -} - -// HasValidator returns whether a specific ASTValidator has been configured in the environment. -func (e *Env) HasValidator(name string) bool { - for _, v := range e.validators { - if v.Name() == name { - return true - } - } - return false -} - -// Parse parses the input expression value `txt` to a Ast and/or a set of Issues. -// -// This form of Parse creates a Source value for the input `txt` and forwards to the -// ParseSource method. -func (e *Env) Parse(txt string) (*Ast, *Issues) { - src := common.NewTextSource(txt) - return e.ParseSource(src) -} - -// ParseSource parses the input source to an Ast and/or set of Issues. -// -// Parsing has failed if the returned Issues value and its Issues.Err() value is non-nil. -// Issues should be inspected if they are non-nil, but may not represent a fatal error. -// -// It is possible to have both non-nil Ast and Issues values returned from this call; however, -// the mere presence of an Ast does not imply that it is valid for use. -func (e *Env) ParseSource(src Source) (*Ast, *Issues) { - parsed, errs := e.prsr.Parse(src) - if len(errs.GetErrors()) > 0 { - return nil, &Issues{errs: errs} - } - return &Ast{source: src, impl: parsed}, nil -} - -// Program generates an evaluable instance of the Ast within the environment (Env). -func (e *Env) Program(ast *Ast, opts ...ProgramOption) (Program, error) { - optSet := e.progOpts - if len(opts) != 0 { - mergedOpts := []ProgramOption{} - mergedOpts = append(mergedOpts, e.progOpts...) - mergedOpts = append(mergedOpts, opts...) - optSet = mergedOpts - } - return newProgram(e, ast, optSet) -} - -// CELTypeAdapter returns the `types.Adapter` configured for the environment. -func (e *Env) CELTypeAdapter() types.Adapter { - return e.adapter -} - -// CELTypeProvider returns the `types.Provider` configured for the environment. -func (e *Env) CELTypeProvider() types.Provider { - return e.provider -} - -// TypeAdapter returns the `ref.TypeAdapter` configured for the environment. -// -// Deprecated: use CELTypeAdapter() -func (e *Env) TypeAdapter() ref.TypeAdapter { - return e.adapter -} - -// TypeProvider returns the `ref.TypeProvider` configured for the environment. -// -// Deprecated: use CELTypeProvider() -func (e *Env) TypeProvider() ref.TypeProvider { - if legacyProvider, ok := e.provider.(ref.TypeProvider); ok { - return legacyProvider - } - return &interopLegacyTypeProvider{Provider: e.provider} -} - -// UnknownVars returns an interpreter.PartialActivation which marks all variables declared in the -// Env as unknown AttributePattern values. -// -// Note, the UnknownVars will behave the same as an interpreter.EmptyActivation unless the -// PartialAttributes option is provided as a ProgramOption. -func (e *Env) UnknownVars() interpreter.PartialActivation { - act := interpreter.EmptyActivation() - part, _ := PartialVars(act, e.computeUnknownVars(act)...) - return part -} - -// PartialVars returns an interpreter.PartialActivation where all variables not in the input variable -// set, but which have been configured in the environment, are marked as unknown. -// -// The `vars` value may either be an interpreter.Activation or any valid input to the -// interpreter.NewActivation call. -// -// Note, this is equivalent to calling cel.PartialVars and manually configuring the set of unknown -// variables. For more advanced use cases of partial state where portions of an object graph, rather -// than top-level variables, are missing the PartialVars() method may be a more suitable choice. -// -// Note, the PartialVars will behave the same as an interpreter.EmptyActivation unless the -// PartialAttributes option is provided as a ProgramOption. -func (e *Env) PartialVars(vars any) (interpreter.PartialActivation, error) { - act, err := interpreter.NewActivation(vars) - if err != nil { - return nil, err - } - return PartialVars(act, e.computeUnknownVars(act)...) -} - -// ResidualAst takes an Ast and its EvalDetails to produce a new Ast which only contains the -// attribute references which are unknown. -// -// Residual expressions are beneficial in a few scenarios: -// -// - Optimizing constant expression evaluations away. -// - Indexing and pruning expressions based on known input arguments. -// - Surfacing additional requirements that are needed in order to complete an evaluation. -// - Sharing the evaluation of an expression across multiple machines/nodes. -// -// For example, if an expression targets a 'resource' and 'request' attribute and the possible -// values for the resource are known, a PartialActivation could mark the 'request' as an unknown -// interpreter.AttributePattern and the resulting ResidualAst would be reduced to only the parts -// of the expression that reference the 'request'. -// -// Note, the expression ids within the residual AST generated through this method have no -// correlation to the expression ids of the original AST. -// -// See the PartialVars helper for how to construct a PartialActivation. -// -// TODO: Consider adding an option to generate a Program.Residual to avoid round-tripping to an -// Ast format and then Program again. -func (e *Env) ResidualAst(a *Ast, details *EvalDetails) (*Ast, error) { - pruned := interpreter.PruneAst(a.impl.Expr(), a.impl.SourceInfo().MacroCalls(), details.State()) - newAST := &Ast{source: a.Source(), impl: pruned} - expr, err := AstToString(newAST) - if err != nil { - return nil, err - } - parsed, iss := e.Parse(expr) - if iss != nil && iss.Err() != nil { - return nil, iss.Err() - } - if !a.IsChecked() { - return parsed, nil - } - checked, iss := e.Check(parsed) - if iss != nil && iss.Err() != nil { - return nil, iss.Err() - } - return checked, nil -} - -// EstimateCost estimates the cost of a type checked CEL expression using the length estimates of input data and -// extension functions provided by estimator. -func (e *Env) EstimateCost(ast *Ast, estimator checker.CostEstimator, opts ...checker.CostOption) (checker.CostEstimate, error) { - extendedOpts := make([]checker.CostOption, 0, len(e.costOptions)) - extendedOpts = append(extendedOpts, opts...) - extendedOpts = append(extendedOpts, e.costOptions...) - return checker.Cost(ast.impl, estimator, extendedOpts...) -} - -// configure applies a series of EnvOptions to the current environment. -func (e *Env) configure(opts []EnvOption) (*Env, error) { - // Customized the environment using the provided EnvOption values. If an error is - // generated at any step this, will be returned as a nil Env with a non-nil error. - var err error - for _, opt := range opts { - e, err = opt(e) - if err != nil { - return nil, err - } - } - - // If the default UTC timezone fix has been enabled, make sure the library is configured - e, err = e.maybeApplyFeature(featureDefaultUTCTimeZone, Lib(timeUTCLibrary{})) - if err != nil { - return nil, err - } - - // Configure the parser. - prsrOpts := []parser.Option{} - prsrOpts = append(prsrOpts, e.prsrOpts...) - prsrOpts = append(prsrOpts, parser.Macros(e.macros...)) - - if e.HasFeature(featureEnableMacroCallTracking) { - prsrOpts = append(prsrOpts, parser.PopulateMacroCalls(true)) - } - if e.HasFeature(featureVariadicLogicalASTs) { - prsrOpts = append(prsrOpts, parser.EnableVariadicOperatorASTs(true)) - } - e.prsr, err = parser.NewParser(prsrOpts...) - if err != nil { - return nil, err - } - - // Ensure that the checker init happens eagerly rather than lazily. - if e.HasFeature(featureEagerlyValidateDeclarations) { - _, err := e.initChecker() - if err != nil { - return nil, err - } - } - - return e, nil -} - -func (e *Env) initChecker() (*checker.Env, error) { - e.chkOnce.Do(func() { - chkOpts := []checker.Option{} - chkOpts = append(chkOpts, e.chkOpts...) - chkOpts = append(chkOpts, - checker.CrossTypeNumericComparisons( - e.HasFeature(featureCrossTypeNumericComparisons))) - - ce, err := checker.NewEnv(e.Container, e.provider, chkOpts...) - if err != nil { - e.setCheckerOrError(nil, err) - return - } - // Add the statically configured declarations. - err = ce.AddIdents(e.variables...) - if err != nil { - e.setCheckerOrError(nil, err) - return - } - // Add the function declarations which are derived from the FunctionDecl instances. - for _, fn := range e.functions { - if fn.IsDeclarationDisabled() { - continue - } - err = ce.AddFunctions(fn) - if err != nil { - e.setCheckerOrError(nil, err) - return - } - } - // Add function declarations here separately. - e.setCheckerOrError(ce, nil) - }) - return e.getCheckerOrError() -} - -// setCheckerOrError sets the checker.Env or error state in a concurrency-safe manner -func (e *Env) setCheckerOrError(chk *checker.Env, chkErr error) { - e.chkMutex.Lock() - e.chk = chk - e.chkErr = chkErr - e.chkMutex.Unlock() -} - -// getCheckerOrError gets the checker.Env or error state in a concurrency-safe manner -func (e *Env) getCheckerOrError() (*checker.Env, error) { - e.chkMutex.Lock() - defer e.chkMutex.Unlock() - return e.chk, e.chkErr -} - -// maybeApplyFeature determines whether the feature-guarded option is enabled, and if so applies -// the feature if it has not already been enabled. -func (e *Env) maybeApplyFeature(feature int, option EnvOption) (*Env, error) { - if !e.HasFeature(feature) { - return e, nil - } - _, applied := e.appliedFeatures[feature] - if applied { - return e, nil - } - e, err := option(e) - if err != nil { - return nil, err - } - // record that the feature has been applied since it will generate declarations - // and functions which will be propagated on Extend() calls and which should only - // be registered once. - e.appliedFeatures[feature] = true - return e, nil -} - -// computeUnknownVars determines a set of missing variables based on the input activation and the -// environment's configured declaration set. -func (e *Env) computeUnknownVars(vars interpreter.Activation) []*interpreter.AttributePattern { - var unknownPatterns []*interpreter.AttributePattern - for _, v := range e.variables { - varName := v.Name() - if _, found := vars.ResolveName(varName); found { - continue - } - unknownPatterns = append(unknownPatterns, interpreter.NewAttributePattern(varName)) - } - return unknownPatterns -} - -// Error type which references an expression id, a location within source, and a message. -type Error = common.Error - -// Issues defines methods for inspecting the error details of parse and check calls. -// -// Note: in the future, non-fatal warnings and notices may be inspectable via the Issues struct. -type Issues struct { - errs *common.Errors - info *celast.SourceInfo -} - -// NewIssues returns an Issues struct from a common.Errors object. -func NewIssues(errs *common.Errors) *Issues { - return NewIssuesWithSourceInfo(errs, nil) -} - -// NewIssuesWithSourceInfo returns an Issues struct from a common.Errors object with SourceInfo metatata -// which can be used with the `ReportErrorAtID` method for additional error reports within the context -// information that's inferred from an expression id. -func NewIssuesWithSourceInfo(errs *common.Errors, info *celast.SourceInfo) *Issues { - return &Issues{ - errs: errs, - info: info, - } -} - -// Err returns an error value if the issues list contains one or more errors. -func (i *Issues) Err() error { - if i == nil { - return nil - } - if len(i.Errors()) > 0 { - return errors.New(i.String()) - } - return nil -} - -// Errors returns the collection of errors encountered in more granular detail. -func (i *Issues) Errors() []*Error { - if i == nil { - return []*Error{} - } - return i.errs.GetErrors() -} - -// Append collects the issues from another Issues struct into a new Issues object. -func (i *Issues) Append(other *Issues) *Issues { - if i == nil { - return other - } - if other == nil { - return i - } - return NewIssues(i.errs.Append(other.errs.GetErrors())) -} - -// String converts the issues to a suitable display string. -func (i *Issues) String() string { - if i == nil { - return "" - } - return i.errs.ToDisplayString() -} - -// ReportErrorAtID reports an error message with an optional set of formatting arguments. -// -// The source metadata for the expression at `id`, if present, is attached to the error report. -// To ensure that source metadata is attached to error reports, use NewIssuesWithSourceInfo. -func (i *Issues) ReportErrorAtID(id int64, message string, args ...any) { - i.errs.ReportErrorAtID(id, i.info.GetStartLocation(id), message, args...) -} - -// getStdEnv lazy initializes the CEL standard environment. -func getStdEnv() (*Env, error) { - stdEnvInit.Do(func() { - stdEnv, stdEnvErr = NewCustomEnv(StdLib(), EagerlyValidateDeclarations(true)) - }) - return stdEnv, stdEnvErr -} - -// interopCELTypeProvider layers support for the types.Provider interface on top of a ref.TypeProvider. -type interopCELTypeProvider struct { - ref.TypeProvider -} - -// FindStructType returns a types.Type instance for the given fully-qualified typeName if one exists. -// -// This method proxies to the underyling ref.TypeProvider's FindType method and converts protobuf type -// into a native type representation. If the conversion fails, the type is listed as not found. -func (p *interopCELTypeProvider) FindStructType(typeName string) (*types.Type, bool) { - if et, found := p.FindType(typeName); found { - t, err := types.ExprTypeToType(et) - if err != nil { - return nil, false - } - return t, true - } - return nil, false -} - -// FindStructFieldNames returns an empty set of field for the interop provider. -// -// To inspect the field names, migrate to a `types.Provider` implementation. -func (p *interopCELTypeProvider) FindStructFieldNames(typeName string) ([]string, bool) { - return []string{}, false -} - -// FindStructFieldType returns a types.FieldType instance for the given fully-qualified typeName and field -// name, if one exists. -// -// This method proxies to the underyling ref.TypeProvider's FindFieldType method and converts protobuf type -// into a native type representation. If the conversion fails, the type is listed as not found. -func (p *interopCELTypeProvider) FindStructFieldType(structType, fieldName string) (*types.FieldType, bool) { - if ft, found := p.FindFieldType(structType, fieldName); found { - t, err := types.ExprTypeToType(ft.Type) - if err != nil { - return nil, false - } - return &types.FieldType{ - Type: t, - IsSet: ft.IsSet, - GetFrom: ft.GetFrom, - }, true - } - return nil, false -} - -// interopLegacyTypeProvider layers support for the ref.TypeProvider interface on top of a types.Provider. -type interopLegacyTypeProvider struct { - types.Provider -} - -// FindType retruns the protobuf Type representation for the input type name if one exists. -// -// This method proxies to the underlying types.Provider FindStructType method and converts the types.Type -// value to a protobuf Type representation. -// -// Failure to convert the type will result in the type not being found. -func (p *interopLegacyTypeProvider) FindType(typeName string) (*exprpb.Type, bool) { - if t, found := p.FindStructType(typeName); found { - et, err := types.TypeToExprType(t) - if err != nil { - return nil, false - } - return et, true - } - return nil, false -} - -// FindFieldType returns the protobuf-based FieldType representation for the input type name and field, -// if one exists. -// -// This call proxies to the types.Provider FindStructFieldType method and converts the types.FIeldType -// value to a protobuf-based ref.FieldType representation if found. -// -// Failure to convert the FieldType will result in the field not being found. -func (p *interopLegacyTypeProvider) FindFieldType(structType, fieldName string) (*ref.FieldType, bool) { - if cft, found := p.FindStructFieldType(structType, fieldName); found { - et, err := types.TypeToExprType(cft.Type) - if err != nil { - return nil, false - } - return &ref.FieldType{ - Type: et, - IsSet: cft.IsSet, - GetFrom: cft.GetFrom, - }, true - } - return nil, false -} - -var ( - stdEnvInit sync.Once - stdEnv *Env - stdEnvErr error -) diff --git a/vendor/github.com/google/cel-go/cel/folding.go b/vendor/github.com/google/cel-go/cel/folding.go deleted file mode 100644 index d7060896d..000000000 --- a/vendor/github.com/google/cel-go/cel/folding.go +++ /dev/null @@ -1,559 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package cel - -import ( - "fmt" - - "github.com/google/cel-go/common/ast" - "github.com/google/cel-go/common/operators" - "github.com/google/cel-go/common/overloads" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/common/types/ref" - "github.com/google/cel-go/common/types/traits" -) - -// ConstantFoldingOption defines a functional option for configuring constant folding. -type ConstantFoldingOption func(opt *constantFoldingOptimizer) (*constantFoldingOptimizer, error) - -// MaxConstantFoldIterations limits the number of times literals may be folding during optimization. -// -// Defaults to 100 if not set. -func MaxConstantFoldIterations(limit int) ConstantFoldingOption { - return func(opt *constantFoldingOptimizer) (*constantFoldingOptimizer, error) { - opt.maxFoldIterations = limit - return opt, nil - } -} - -// NewConstantFoldingOptimizer creates an optimizer which inlines constant scalar an aggregate -// literal values within function calls and select statements with their evaluated result. -func NewConstantFoldingOptimizer(opts ...ConstantFoldingOption) (ASTOptimizer, error) { - folder := &constantFoldingOptimizer{ - maxFoldIterations: defaultMaxConstantFoldIterations, - } - var err error - for _, o := range opts { - folder, err = o(folder) - if err != nil { - return nil, err - } - } - return folder, nil -} - -type constantFoldingOptimizer struct { - maxFoldIterations int -} - -// Optimize queries the expression graph for scalar and aggregate literal expressions within call and -// select statements and then evaluates them and replaces the call site with the literal result. -// -// Note: only values which can be represented as literals in CEL syntax are supported. -func (opt *constantFoldingOptimizer) Optimize(ctx *OptimizerContext, a *ast.AST) *ast.AST { - root := ast.NavigateAST(a) - - // Walk the list of foldable expression and continue to fold until there are no more folds left. - // All of the fold candidates returned by the constantExprMatcher should succeed unless there's - // a logic bug with the selection of expressions. - foldableExprs := ast.MatchDescendants(root, constantExprMatcher) - foldCount := 0 - for len(foldableExprs) != 0 && foldCount < opt.maxFoldIterations { - for _, fold := range foldableExprs { - // If the expression could be folded because it's a non-strict call, and the - // branches are pruned, continue to the next fold. - if fold.Kind() == ast.CallKind && maybePruneBranches(ctx, fold) { - continue - } - // Otherwise, assume all context is needed to evaluate the expression. - err := tryFold(ctx, a, fold) - if err != nil { - ctx.ReportErrorAtID(fold.ID(), "constant-folding evaluation failed: %v", err.Error()) - return a - } - } - foldCount++ - foldableExprs = ast.MatchDescendants(root, constantExprMatcher) - } - // Once all of the constants have been folded, try to run through the remaining comprehensions - // one last time. In this case, there's no guarantee they'll run, so we only update the - // target comprehension node with the literal value if the evaluation succeeds. - for _, compre := range ast.MatchDescendants(root, ast.KindMatcher(ast.ComprehensionKind)) { - tryFold(ctx, a, compre) - } - - // If the output is a list, map, or struct which contains optional entries, then prune it - // to make sure that the optionals, if resolved, do not surface in the output literal. - pruneOptionalElements(ctx, root) - - // Ensure that all intermediate values in the folded expression can be represented as valid - // CEL literals within the AST structure. Use `PostOrderVisit` rather than `MatchDescendents` - // to avoid extra allocations during this final pass through the AST. - ast.PostOrderVisit(root, ast.NewExprVisitor(func(e ast.Expr) { - if e.Kind() != ast.LiteralKind { - return - } - val := e.AsLiteral() - adapted, err := adaptLiteral(ctx, val) - if err != nil { - ctx.ReportErrorAtID(root.ID(), "constant-folding evaluation failed: %v", err.Error()) - return - } - ctx.UpdateExpr(e, adapted) - })) - - return a -} - -// tryFold attempts to evaluate a sub-expression to a literal. -// -// If the evaluation succeeds, the input expr value will be modified to become a literal, otherwise -// the method will return an error. -func tryFold(ctx *OptimizerContext, a *ast.AST, expr ast.Expr) error { - // Assume all context is needed to evaluate the expression. - subAST := &Ast{ - impl: ast.NewCheckedAST(ast.NewAST(expr, a.SourceInfo()), a.TypeMap(), a.ReferenceMap()), - } - prg, err := ctx.Program(subAST) - if err != nil { - return err - } - out, _, err := prg.Eval(NoVars()) - if err != nil { - return err - } - // Update the fold expression to be a literal. - ctx.UpdateExpr(expr, ctx.NewLiteral(out)) - return nil -} - -// maybePruneBranches inspects the non-strict call expression to determine whether -// a branch can be removed. Evaluation will naturally prune logical and / or calls, -// but conditional will not be pruned cleanly, so this is one small area where the -// constant folding step reimplements a portion of the evaluator. -func maybePruneBranches(ctx *OptimizerContext, expr ast.NavigableExpr) bool { - call := expr.AsCall() - args := call.Args() - switch call.FunctionName() { - case operators.LogicalAnd, operators.LogicalOr: - return maybeShortcircuitLogic(ctx, call.FunctionName(), args, expr) - case operators.Conditional: - cond := args[0] - truthy := args[1] - falsy := args[2] - if cond.Kind() != ast.LiteralKind { - return false - } - if cond.AsLiteral() == types.True { - ctx.UpdateExpr(expr, truthy) - } else { - ctx.UpdateExpr(expr, falsy) - } - return true - case operators.In: - haystack := args[1] - if haystack.Kind() == ast.ListKind && haystack.AsList().Size() == 0 { - ctx.UpdateExpr(expr, ctx.NewLiteral(types.False)) - return true - } - needle := args[0] - if needle.Kind() == ast.LiteralKind && haystack.Kind() == ast.ListKind { - needleValue := needle.AsLiteral() - list := haystack.AsList() - for _, e := range list.Elements() { - if e.Kind() == ast.LiteralKind && e.AsLiteral().Equal(needleValue) == types.True { - ctx.UpdateExpr(expr, ctx.NewLiteral(types.True)) - return true - } - } - } - } - return false -} - -func maybeShortcircuitLogic(ctx *OptimizerContext, function string, args []ast.Expr, expr ast.NavigableExpr) bool { - shortcircuit := types.False - skip := types.True - if function == operators.LogicalOr { - shortcircuit = types.True - skip = types.False - } - newArgs := []ast.Expr{} - for _, arg := range args { - if arg.Kind() != ast.LiteralKind { - newArgs = append(newArgs, arg) - continue - } - if arg.AsLiteral() == skip { - continue - } - if arg.AsLiteral() == shortcircuit { - ctx.UpdateExpr(expr, arg) - return true - } - } - if len(newArgs) == 0 { - newArgs = append(newArgs, args[0]) - ctx.UpdateExpr(expr, newArgs[0]) - return true - } - if len(newArgs) == 1 { - ctx.UpdateExpr(expr, newArgs[0]) - return true - } - ctx.UpdateExpr(expr, ctx.NewCall(function, newArgs...)) - return true -} - -// pruneOptionalElements works from the bottom up to resolve optional elements within -// aggregate literals. -// -// Note, many aggregate literals will be resolved as arguments to functions or select -// statements, so this method exists to handle the case where the literal could not be -// fully resolved or exists outside of a call, select, or comprehension context. -func pruneOptionalElements(ctx *OptimizerContext, root ast.NavigableExpr) { - aggregateLiterals := ast.MatchDescendants(root, aggregateLiteralMatcher) - for _, lit := range aggregateLiterals { - switch lit.Kind() { - case ast.ListKind: - pruneOptionalListElements(ctx, lit) - case ast.MapKind: - pruneOptionalMapEntries(ctx, lit) - case ast.StructKind: - pruneOptionalStructFields(ctx, lit) - } - } -} - -func pruneOptionalListElements(ctx *OptimizerContext, e ast.Expr) { - l := e.AsList() - elems := l.Elements() - optIndices := l.OptionalIndices() - if len(optIndices) == 0 { - return - } - updatedElems := []ast.Expr{} - updatedIndices := []int32{} - newOptIndex := -1 - for _, e := range elems { - newOptIndex++ - if !l.IsOptional(int32(newOptIndex)) { - updatedElems = append(updatedElems, e) - continue - } - if e.Kind() != ast.LiteralKind { - updatedElems = append(updatedElems, e) - updatedIndices = append(updatedIndices, int32(newOptIndex)) - continue - } - optElemVal, ok := e.AsLiteral().(*types.Optional) - if !ok { - updatedElems = append(updatedElems, e) - updatedIndices = append(updatedIndices, int32(newOptIndex)) - continue - } - if !optElemVal.HasValue() { - newOptIndex-- // Skipping causes the list to get smaller. - continue - } - ctx.UpdateExpr(e, ctx.NewLiteral(optElemVal.GetValue())) - updatedElems = append(updatedElems, e) - } - ctx.UpdateExpr(e, ctx.NewList(updatedElems, updatedIndices)) -} - -func pruneOptionalMapEntries(ctx *OptimizerContext, e ast.Expr) { - m := e.AsMap() - entries := m.Entries() - updatedEntries := []ast.EntryExpr{} - modified := false - for _, e := range entries { - entry := e.AsMapEntry() - key := entry.Key() - val := entry.Value() - // If the entry is not optional, or the value-side of the optional hasn't - // been resolved to a literal, then preserve the entry as-is. - if !entry.IsOptional() || val.Kind() != ast.LiteralKind { - updatedEntries = append(updatedEntries, e) - continue - } - optElemVal, ok := val.AsLiteral().(*types.Optional) - if !ok { - updatedEntries = append(updatedEntries, e) - continue - } - // When the key is not a literal, but the value is, then it needs to be - // restored to an optional value. - if key.Kind() != ast.LiteralKind { - undoOptVal, err := adaptLiteral(ctx, optElemVal) - if err != nil { - ctx.ReportErrorAtID(val.ID(), "invalid map value literal %v: %v", optElemVal, err) - } - ctx.UpdateExpr(val, undoOptVal) - updatedEntries = append(updatedEntries, e) - continue - } - modified = true - if !optElemVal.HasValue() { - continue - } - ctx.UpdateExpr(val, ctx.NewLiteral(optElemVal.GetValue())) - updatedEntry := ctx.NewMapEntry(key, val, false) - updatedEntries = append(updatedEntries, updatedEntry) - } - if modified { - ctx.UpdateExpr(e, ctx.NewMap(updatedEntries)) - } -} - -func pruneOptionalStructFields(ctx *OptimizerContext, e ast.Expr) { - s := e.AsStruct() - fields := s.Fields() - updatedFields := []ast.EntryExpr{} - modified := false - for _, f := range fields { - field := f.AsStructField() - val := field.Value() - if !field.IsOptional() || val.Kind() != ast.LiteralKind { - updatedFields = append(updatedFields, f) - continue - } - optElemVal, ok := val.AsLiteral().(*types.Optional) - if !ok { - updatedFields = append(updatedFields, f) - continue - } - modified = true - if !optElemVal.HasValue() { - continue - } - ctx.UpdateExpr(val, ctx.NewLiteral(optElemVal.GetValue())) - updatedField := ctx.NewStructField(field.Name(), val, false) - updatedFields = append(updatedFields, updatedField) - } - if modified { - ctx.UpdateExpr(e, ctx.NewStruct(s.TypeName(), updatedFields)) - } -} - -// adaptLiteral converts a runtime CEL value to its equivalent literal expression. -// -// For strongly typed values, the type-provider will be used to reconstruct the fields -// which are present in the literal and their equivalent initialization values. -func adaptLiteral(ctx *OptimizerContext, val ref.Val) (ast.Expr, error) { - switch t := val.Type().(type) { - case *types.Type: - switch t { - case types.BoolType, types.BytesType, types.DoubleType, types.IntType, - types.NullType, types.StringType, types.UintType: - return ctx.NewLiteral(val), nil - case types.DurationType: - return ctx.NewCall( - overloads.TypeConvertDuration, - ctx.NewLiteral(val.ConvertToType(types.StringType)), - ), nil - case types.TimestampType: - return ctx.NewCall( - overloads.TypeConvertTimestamp, - ctx.NewLiteral(val.ConvertToType(types.StringType)), - ), nil - case types.OptionalType: - opt := val.(*types.Optional) - if !opt.HasValue() { - return ctx.NewCall("optional.none"), nil - } - target, err := adaptLiteral(ctx, opt.GetValue()) - if err != nil { - return nil, err - } - return ctx.NewCall("optional.of", target), nil - case types.TypeType: - return ctx.NewIdent(val.(*types.Type).TypeName()), nil - case types.ListType: - l, ok := val.(traits.Lister) - if !ok { - return nil, fmt.Errorf("failed to adapt %v to literal", val) - } - elems := make([]ast.Expr, l.Size().(types.Int)) - idx := 0 - it := l.Iterator() - for it.HasNext() == types.True { - elemVal := it.Next() - elemExpr, err := adaptLiteral(ctx, elemVal) - if err != nil { - return nil, err - } - elems[idx] = elemExpr - idx++ - } - return ctx.NewList(elems, []int32{}), nil - case types.MapType: - m, ok := val.(traits.Mapper) - if !ok { - return nil, fmt.Errorf("failed to adapt %v to literal", val) - } - entries := make([]ast.EntryExpr, m.Size().(types.Int)) - idx := 0 - it := m.Iterator() - for it.HasNext() == types.True { - keyVal := it.Next() - keyExpr, err := adaptLiteral(ctx, keyVal) - if err != nil { - return nil, err - } - valVal := m.Get(keyVal) - valExpr, err := adaptLiteral(ctx, valVal) - if err != nil { - return nil, err - } - entries[idx] = ctx.NewMapEntry(keyExpr, valExpr, false) - idx++ - } - return ctx.NewMap(entries), nil - default: - provider := ctx.CELTypeProvider() - fields, found := provider.FindStructFieldNames(t.TypeName()) - if !found { - return nil, fmt.Errorf("failed to adapt %v to literal", val) - } - tester := val.(traits.FieldTester) - indexer := val.(traits.Indexer) - fieldInits := []ast.EntryExpr{} - for _, f := range fields { - field := types.String(f) - if tester.IsSet(field) != types.True { - continue - } - fieldVal := indexer.Get(field) - fieldExpr, err := adaptLiteral(ctx, fieldVal) - if err != nil { - return nil, err - } - fieldInits = append(fieldInits, ctx.NewStructField(f, fieldExpr, false)) - } - return ctx.NewStruct(t.TypeName(), fieldInits), nil - } - } - return nil, fmt.Errorf("failed to adapt %v to literal", val) -} - -// constantExprMatcher matches calls, select statements, and comprehensions whose arguments -// are all constant scalar or aggregate literal values. -// -// Only comprehensions which are not nested are included as possible constant folds, and only -// if all variables referenced in the comprehension stack exist are only iteration or -// accumulation variables. -func constantExprMatcher(e ast.NavigableExpr) bool { - switch e.Kind() { - case ast.CallKind: - return constantCallMatcher(e) - case ast.SelectKind: - sel := e.AsSelect() // guaranteed to be a navigable value - return constantMatcher(sel.Operand().(ast.NavigableExpr)) - case ast.ComprehensionKind: - if isNestedComprehension(e) { - return false - } - vars := map[string]bool{} - constantExprs := true - visitor := ast.NewExprVisitor(func(e ast.Expr) { - if e.Kind() == ast.ComprehensionKind { - nested := e.AsComprehension() - vars[nested.AccuVar()] = true - vars[nested.IterVar()] = true - } - if e.Kind() == ast.IdentKind && !vars[e.AsIdent()] { - constantExprs = false - } - }) - ast.PreOrderVisit(e, visitor) - return constantExprs - default: - return false - } -} - -// constantCallMatcher identifies strict and non-strict calls which can be folded. -func constantCallMatcher(e ast.NavigableExpr) bool { - call := e.AsCall() - children := e.Children() - fnName := call.FunctionName() - if fnName == operators.LogicalAnd { - for _, child := range children { - if child.Kind() == ast.LiteralKind { - return true - } - } - } - if fnName == operators.LogicalOr { - for _, child := range children { - if child.Kind() == ast.LiteralKind { - return true - } - } - } - if fnName == operators.Conditional { - cond := children[0] - if cond.Kind() == ast.LiteralKind && cond.AsLiteral().Type() == types.BoolType { - return true - } - } - if fnName == operators.In { - haystack := children[1] - if haystack.Kind() == ast.ListKind && haystack.AsList().Size() == 0 { - return true - } - needle := children[0] - if needle.Kind() == ast.LiteralKind && haystack.Kind() == ast.ListKind { - needleValue := needle.AsLiteral() - list := haystack.AsList() - for _, e := range list.Elements() { - if e.Kind() == ast.LiteralKind && e.AsLiteral().Equal(needleValue) == types.True { - return true - } - } - } - } - // convert all other calls with constant arguments - for _, child := range children { - if !constantMatcher(child) { - return false - } - } - return true -} - -func isNestedComprehension(e ast.NavigableExpr) bool { - parent, found := e.Parent() - for found { - if parent.Kind() == ast.ComprehensionKind { - return true - } - parent, found = parent.Parent() - } - return false -} - -func aggregateLiteralMatcher(e ast.NavigableExpr) bool { - return e.Kind() == ast.ListKind || e.Kind() == ast.MapKind || e.Kind() == ast.StructKind -} - -var ( - constantMatcher = ast.ConstantValueMatcher() -) - -const ( - defaultMaxConstantFoldIterations = 100 -) diff --git a/vendor/github.com/google/cel-go/cel/inlining.go b/vendor/github.com/google/cel-go/cel/inlining.go deleted file mode 100644 index 8c8335d3b..000000000 --- a/vendor/github.com/google/cel-go/cel/inlining.go +++ /dev/null @@ -1,240 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package cel - -import ( - "github.com/google/cel-go/common/ast" - "github.com/google/cel-go/common/containers" - "github.com/google/cel-go/common/operators" - "github.com/google/cel-go/common/overloads" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/common/types/traits" -) - -// InlineVariable holds a variable name to be matched and an AST representing -// the expression graph which should be used to replace it. -type InlineVariable struct { - name string - alias string - def *ast.AST -} - -// Name returns the qualified variable or field selection to replace. -func (v *InlineVariable) Name() string { - return v.name -} - -// Alias returns the alias to use when performing cel.bind() calls during inlining. -func (v *InlineVariable) Alias() string { - return v.alias -} - -// Expr returns the inlined expression value. -func (v *InlineVariable) Expr() ast.Expr { - return v.def.Expr() -} - -// Type indicates the inlined expression type. -func (v *InlineVariable) Type() *Type { - return v.def.GetType(v.def.Expr().ID()) -} - -// NewInlineVariable declares a variable name to be replaced by a checked expression. -func NewInlineVariable(name string, definition *Ast) *InlineVariable { - return NewInlineVariableWithAlias(name, name, definition) -} - -// NewInlineVariableWithAlias declares a variable name to be replaced by a checked expression. -// If the variable occurs more than once, the provided alias will be used to replace the expressions -// where the variable name occurs. -func NewInlineVariableWithAlias(name, alias string, definition *Ast) *InlineVariable { - return &InlineVariable{name: name, alias: alias, def: definition.impl} -} - -// NewInliningOptimizer creates and optimizer which replaces variables with expression definitions. -// -// If a variable occurs one time, the variable is replaced by the inline definition. If the -// variable occurs more than once, the variable occurences are replaced by a cel.bind() call. -func NewInliningOptimizer(inlineVars ...*InlineVariable) ASTOptimizer { - return &inliningOptimizer{variables: inlineVars} -} - -type inliningOptimizer struct { - variables []*InlineVariable -} - -func (opt *inliningOptimizer) Optimize(ctx *OptimizerContext, a *ast.AST) *ast.AST { - root := ast.NavigateAST(a) - for _, inlineVar := range opt.variables { - matches := ast.MatchDescendants(root, opt.matchVariable(inlineVar.Name())) - // Skip cases where the variable isn't in the expression graph - if len(matches) == 0 { - continue - } - - // For a single match, do a direct replacement of the expression sub-graph. - if len(matches) == 1 || !isBindable(matches, inlineVar.Expr(), inlineVar.Type()) { - for _, match := range matches { - // Copy the inlined AST expr and source info. - copyExpr := copyASTAndMetadata(ctx, inlineVar.def) - opt.inlineExpr(ctx, match, copyExpr, inlineVar.Type()) - } - continue - } - - // For multiple matches, find the least common ancestor (lca) and insert the - // variable as a cel.bind() macro. - var lca ast.NavigableExpr = root - lcaAncestorCount := 0 - ancestors := map[int64]int{} - for _, match := range matches { - // Update the identifier matches with the provided alias. - parent, found := match, true - for found { - ancestorCount, hasAncestor := ancestors[parent.ID()] - if !hasAncestor { - ancestors[parent.ID()] = 1 - parent, found = parent.Parent() - continue - } - if lcaAncestorCount < ancestorCount || (lcaAncestorCount == ancestorCount && lca.Depth() < parent.Depth()) { - lca = parent - lcaAncestorCount = ancestorCount - } - ancestors[parent.ID()] = ancestorCount + 1 - parent, found = parent.Parent() - } - aliasExpr := ctx.NewIdent(inlineVar.Alias()) - opt.inlineExpr(ctx, match, aliasExpr, inlineVar.Type()) - } - - // Copy the inlined AST expr and source info. - copyExpr := copyASTAndMetadata(ctx, inlineVar.def) - // Update the least common ancestor by inserting a cel.bind() call to the alias. - inlined, bindMacro := ctx.NewBindMacro(lca.ID(), inlineVar.Alias(), copyExpr, lca) - opt.inlineExpr(ctx, lca, inlined, inlineVar.Type()) - ctx.sourceInfo.SetMacroCall(lca.ID(), bindMacro) - } - return a -} - -// copyASTAndMetadata copies the input AST and propagates the macro metadata into the AST being -// optimized. -func copyASTAndMetadata(ctx *OptimizerContext, a *ast.AST) ast.Expr { - copyExpr, copyInfo := ctx.CopyAST(a) - // Add in the macro calls from the inlined AST - for id, call := range copyInfo.MacroCalls() { - ctx.sourceInfo.SetMacroCall(id, call) - } - return copyExpr -} - -// inlineExpr replaces the current expression with the inlined one, unless the location of the inlining -// happens within a presence test, e.g. has(a.b.c) -> inline alpha for a.b.c in which case an attempt is -// made to determine whether the inlined value can be presence or existence tested. -func (opt *inliningOptimizer) inlineExpr(ctx *OptimizerContext, prev ast.NavigableExpr, inlined ast.Expr, inlinedType *Type) { - switch prev.Kind() { - case ast.SelectKind: - sel := prev.AsSelect() - if !sel.IsTestOnly() { - ctx.UpdateExpr(prev, inlined) - return - } - opt.rewritePresenceExpr(ctx, prev, inlined, inlinedType) - default: - ctx.UpdateExpr(prev, inlined) - } -} - -// rewritePresenceExpr converts the inlined expression, when it occurs within a has() macro, to type-safe -// expression appropriate for the inlined type, if possible. -// -// If the rewrite is not possible an error is reported at the inline expression site. -func (opt *inliningOptimizer) rewritePresenceExpr(ctx *OptimizerContext, prev, inlined ast.Expr, inlinedType *Type) { - // If the input inlined expression is not a select expression it won't work with the has() - // macro. Attempt to rewrite the presence test in terms of the typed input, otherwise error. - if inlined.Kind() == ast.SelectKind { - presenceTest, hasMacro := ctx.NewHasMacro(prev.ID(), inlined) - ctx.UpdateExpr(prev, presenceTest) - ctx.sourceInfo.SetMacroCall(prev.ID(), hasMacro) - return - } - - ctx.sourceInfo.ClearMacroCall(prev.ID()) - if inlinedType.IsAssignableType(NullType) { - ctx.UpdateExpr(prev, - ctx.NewCall(operators.NotEquals, - inlined, - ctx.NewLiteral(types.NullValue), - )) - return - } - if inlinedType.HasTrait(traits.SizerType) { - ctx.UpdateExpr(prev, - ctx.NewCall(operators.NotEquals, - ctx.NewMemberCall(overloads.Size, inlined), - ctx.NewLiteral(types.IntZero), - )) - return - } - ctx.ReportErrorAtID(prev.ID(), "unable to inline expression type %v into presence test", inlinedType) -} - -// isBindable indicates whether the inlined type can be used within a cel.bind() if the expression -// being replaced occurs within a presence test. Value types with a size() method or field selection -// support can be bound. -// -// In future iterations, support may also be added for indexer types which can be rewritten as an `in` -// expression; however, this would imply a rewrite of the inlined expression that may not be necessary -// in most cases. -func isBindable(matches []ast.NavigableExpr, inlined ast.Expr, inlinedType *Type) bool { - if inlinedType.IsAssignableType(NullType) || - inlinedType.HasTrait(traits.SizerType) || - inlinedType.HasTrait(traits.FieldTesterType) { - return true - } - for _, m := range matches { - if m.Kind() != ast.SelectKind { - continue - } - sel := m.AsSelect() - if sel.IsTestOnly() { - return false - } - } - return true -} - -// matchVariable matches simple identifiers, select expressions, and presence test expressions -// which match the (potentially) qualified variable name provided as input. -// -// Note, this function does not support inlining against select expressions which includes optional -// field selection. This may be a future refinement. -func (opt *inliningOptimizer) matchVariable(varName string) ast.ExprMatcher { - return func(e ast.NavigableExpr) bool { - if e.Kind() == ast.IdentKind && e.AsIdent() == varName { - return true - } - if e.Kind() == ast.SelectKind { - sel := e.AsSelect() - // While the `ToQualifiedName` call could take the select directly, this - // would skip presence tests from possible matches, which we would like - // to include. - qualName, found := containers.ToQualifiedName(sel.Operand()) - return found && qualName+"."+sel.FieldName() == varName - } - return false - } -} diff --git a/vendor/github.com/google/cel-go/cel/io.go b/vendor/github.com/google/cel-go/cel/io.go deleted file mode 100644 index 3133fb9d7..000000000 --- a/vendor/github.com/google/cel-go/cel/io.go +++ /dev/null @@ -1,252 +0,0 @@ -// Copyright 2019 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package cel - -import ( - "errors" - "fmt" - "reflect" - - "google.golang.org/protobuf/proto" - - "github.com/google/cel-go/common" - "github.com/google/cel-go/common/ast" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/common/types/ref" - "github.com/google/cel-go/common/types/traits" - "github.com/google/cel-go/parser" - - exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1" - anypb "google.golang.org/protobuf/types/known/anypb" -) - -// CheckedExprToAst converts a checked expression proto message to an Ast. -func CheckedExprToAst(checkedExpr *exprpb.CheckedExpr) *Ast { - checked, _ := CheckedExprToAstWithSource(checkedExpr, nil) - return checked -} - -// CheckedExprToAstWithSource converts a checked expression proto message to an Ast, -// using the provided Source as the textual contents. -// -// In general the source is not necessary unless the AST has been modified between the -// `Parse` and `Check` calls as an `Ast` created from the `Parse` step will carry the source -// through future calls. -// -// Prefer CheckedExprToAst if loading expressions from storage. -func CheckedExprToAstWithSource(checkedExpr *exprpb.CheckedExpr, src Source) (*Ast, error) { - checked, err := ast.ToAST(checkedExpr) - if err != nil { - return nil, err - } - return &Ast{source: src, impl: checked}, nil -} - -// AstToCheckedExpr converts an Ast to an protobuf CheckedExpr value. -// -// If the Ast.IsChecked() returns false, this conversion method will return an error. -func AstToCheckedExpr(a *Ast) (*exprpb.CheckedExpr, error) { - if !a.IsChecked() { - return nil, fmt.Errorf("cannot convert unchecked ast") - } - return ast.ToProto(a.impl) -} - -// ParsedExprToAst converts a parsed expression proto message to an Ast. -func ParsedExprToAst(parsedExpr *exprpb.ParsedExpr) *Ast { - return ParsedExprToAstWithSource(parsedExpr, nil) -} - -// ParsedExprToAstWithSource converts a parsed expression proto message to an Ast, -// using the provided Source as the textual contents. -// -// In general you only need this if you need to recheck a previously checked -// expression, or if you need to separately check a subset of an expression. -// -// Prefer ParsedExprToAst if loading expressions from storage. -func ParsedExprToAstWithSource(parsedExpr *exprpb.ParsedExpr, src Source) *Ast { - info, _ := ast.ProtoToSourceInfo(parsedExpr.GetSourceInfo()) - if src == nil { - src = common.NewInfoSource(parsedExpr.GetSourceInfo()) - } - e, _ := ast.ProtoToExpr(parsedExpr.GetExpr()) - return &Ast{source: src, impl: ast.NewAST(e, info)} -} - -// AstToParsedExpr converts an Ast to an protobuf ParsedExpr value. -func AstToParsedExpr(a *Ast) (*exprpb.ParsedExpr, error) { - return &exprpb.ParsedExpr{ - Expr: a.Expr(), - SourceInfo: a.SourceInfo(), - }, nil -} - -// AstToString converts an Ast back to a string if possible. -// -// Note, the conversion may not be an exact replica of the original expression, but will produce -// a string that is semantically equivalent and whose textual representation is stable. -func AstToString(a *Ast) (string, error) { - return parser.Unparse(a.impl.Expr(), a.impl.SourceInfo()) -} - -// RefValueToValue converts between ref.Val and api.expr.Value. -// The result Value is the serialized proto form. The ref.Val must not be error or unknown. -func RefValueToValue(res ref.Val) (*exprpb.Value, error) { - switch res.Type() { - case types.BoolType: - return &exprpb.Value{ - Kind: &exprpb.Value_BoolValue{BoolValue: res.Value().(bool)}}, nil - case types.BytesType: - return &exprpb.Value{ - Kind: &exprpb.Value_BytesValue{BytesValue: res.Value().([]byte)}}, nil - case types.DoubleType: - return &exprpb.Value{ - Kind: &exprpb.Value_DoubleValue{DoubleValue: res.Value().(float64)}}, nil - case types.IntType: - return &exprpb.Value{ - Kind: &exprpb.Value_Int64Value{Int64Value: res.Value().(int64)}}, nil - case types.ListType: - l := res.(traits.Lister) - sz := l.Size().(types.Int) - elts := make([]*exprpb.Value, 0, int64(sz)) - for i := types.Int(0); i < sz; i++ { - v, err := RefValueToValue(l.Get(i)) - if err != nil { - return nil, err - } - elts = append(elts, v) - } - return &exprpb.Value{ - Kind: &exprpb.Value_ListValue{ - ListValue: &exprpb.ListValue{Values: elts}}}, nil - case types.MapType: - mapper := res.(traits.Mapper) - sz := mapper.Size().(types.Int) - entries := make([]*exprpb.MapValue_Entry, 0, int64(sz)) - for it := mapper.Iterator(); it.HasNext().(types.Bool); { - k := it.Next() - v := mapper.Get(k) - kv, err := RefValueToValue(k) - if err != nil { - return nil, err - } - vv, err := RefValueToValue(v) - if err != nil { - return nil, err - } - entries = append(entries, &exprpb.MapValue_Entry{Key: kv, Value: vv}) - } - return &exprpb.Value{ - Kind: &exprpb.Value_MapValue{ - MapValue: &exprpb.MapValue{Entries: entries}}}, nil - case types.NullType: - return &exprpb.Value{ - Kind: &exprpb.Value_NullValue{}}, nil - case types.StringType: - return &exprpb.Value{ - Kind: &exprpb.Value_StringValue{StringValue: res.Value().(string)}}, nil - case types.TypeType: - typeName := res.(ref.Type).TypeName() - return &exprpb.Value{Kind: &exprpb.Value_TypeValue{TypeValue: typeName}}, nil - case types.UintType: - return &exprpb.Value{ - Kind: &exprpb.Value_Uint64Value{Uint64Value: res.Value().(uint64)}}, nil - default: - any, err := res.ConvertToNative(anyPbType) - if err != nil { - return nil, err - } - return &exprpb.Value{ - Kind: &exprpb.Value_ObjectValue{ObjectValue: any.(*anypb.Any)}}, nil - } -} - -var ( - typeNameToTypeValue = map[string]ref.Val{ - "bool": types.BoolType, - "bytes": types.BytesType, - "double": types.DoubleType, - "null_type": types.NullType, - "int": types.IntType, - "list": types.ListType, - "map": types.MapType, - "string": types.StringType, - "type": types.TypeType, - "uint": types.UintType, - } - - anyPbType = reflect.TypeOf(&anypb.Any{}) -) - -// ValueToRefValue converts between exprpb.Value and ref.Val. -func ValueToRefValue(adapter types.Adapter, v *exprpb.Value) (ref.Val, error) { - switch v.Kind.(type) { - case *exprpb.Value_NullValue: - return types.NullValue, nil - case *exprpb.Value_BoolValue: - return types.Bool(v.GetBoolValue()), nil - case *exprpb.Value_Int64Value: - return types.Int(v.GetInt64Value()), nil - case *exprpb.Value_Uint64Value: - return types.Uint(v.GetUint64Value()), nil - case *exprpb.Value_DoubleValue: - return types.Double(v.GetDoubleValue()), nil - case *exprpb.Value_StringValue: - return types.String(v.GetStringValue()), nil - case *exprpb.Value_BytesValue: - return types.Bytes(v.GetBytesValue()), nil - case *exprpb.Value_ObjectValue: - any := v.GetObjectValue() - msg, err := anypb.UnmarshalNew(any, proto.UnmarshalOptions{DiscardUnknown: true}) - if err != nil { - return nil, err - } - return adapter.NativeToValue(msg), nil - case *exprpb.Value_MapValue: - m := v.GetMapValue() - entries := make(map[ref.Val]ref.Val) - for _, entry := range m.Entries { - key, err := ValueToRefValue(adapter, entry.Key) - if err != nil { - return nil, err - } - pb, err := ValueToRefValue(adapter, entry.Value) - if err != nil { - return nil, err - } - entries[key] = pb - } - return adapter.NativeToValue(entries), nil - case *exprpb.Value_ListValue: - l := v.GetListValue() - elts := make([]ref.Val, len(l.Values)) - for i, e := range l.Values { - rv, err := ValueToRefValue(adapter, e) - if err != nil { - return nil, err - } - elts[i] = rv - } - return adapter.NativeToValue(elts), nil - case *exprpb.Value_TypeValue: - typeName := v.GetTypeValue() - tv, ok := typeNameToTypeValue[typeName] - if ok { - return tv, nil - } - return types.NewObjectTypeValue(typeName), nil - } - return nil, errors.New("unknown value") -} diff --git a/vendor/github.com/google/cel-go/cel/library.go b/vendor/github.com/google/cel-go/cel/library.go deleted file mode 100644 index deddc14e5..000000000 --- a/vendor/github.com/google/cel-go/cel/library.go +++ /dev/null @@ -1,784 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package cel - -import ( - "math" - "strconv" - "strings" - "time" - - "github.com/google/cel-go/common/ast" - "github.com/google/cel-go/common/operators" - "github.com/google/cel-go/common/overloads" - "github.com/google/cel-go/common/stdlib" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/common/types/ref" - "github.com/google/cel-go/common/types/traits" - "github.com/google/cel-go/interpreter" - "github.com/google/cel-go/parser" -) - -const ( - optMapMacro = "optMap" - optFlatMapMacro = "optFlatMap" - hasValueFunc = "hasValue" - optionalNoneFunc = "optional.none" - optionalOfFunc = "optional.of" - optionalOfNonZeroValueFunc = "optional.ofNonZeroValue" - valueFunc = "value" - unusedIterVar = "#unused" -) - -// Library provides a collection of EnvOption and ProgramOption values used to configure a CEL -// environment for a particular use case or with a related set of functionality. -// -// Note, the ProgramOption values provided by a library are expected to be static and not vary -// between calls to Env.Program(). If there is a need for such dynamic configuration, prefer to -// configure these options outside the Library and within the Env.Program() call directly. -type Library interface { - // CompileOptions returns a collection of functional options for configuring the Parse / Check - // environment. - CompileOptions() []EnvOption - - // ProgramOptions returns a collection of functional options which should be included in every - // Program generated from the Env.Program() call. - ProgramOptions() []ProgramOption -} - -// SingletonLibrary refines the Library interface to ensure that libraries in this format are only -// configured once within the environment. -type SingletonLibrary interface { - Library - - // LibraryName provides a namespaced name which is used to check whether the library has already - // been configured in the environment. - LibraryName() string -} - -// Lib creates an EnvOption out of a Library, allowing libraries to be provided as functional args, -// and to be linked to each other. -func Lib(l Library) EnvOption { - singleton, isSingleton := l.(SingletonLibrary) - return func(e *Env) (*Env, error) { - if isSingleton { - if e.HasLibrary(singleton.LibraryName()) { - return e, nil - } - e.libraries[singleton.LibraryName()] = true - } - var err error - for _, opt := range l.CompileOptions() { - e, err = opt(e) - if err != nil { - return nil, err - } - } - e.progOpts = append(e.progOpts, l.ProgramOptions()...) - return e, nil - } -} - -// StdLib returns an EnvOption for the standard library of CEL functions and macros. -func StdLib() EnvOption { - return Lib(stdLibrary{}) -} - -// stdLibrary implements the Library interface and provides functional options for the core CEL -// features documented in the specification. -type stdLibrary struct{} - -// LibraryName implements the SingletonLibrary interface method. -func (stdLibrary) LibraryName() string { - return "cel.lib.std" -} - -// CompileOptions returns options for the standard CEL function declarations and macros. -func (stdLibrary) CompileOptions() []EnvOption { - return []EnvOption{ - func(e *Env) (*Env, error) { - var err error - for _, fn := range stdlib.Functions() { - existing, found := e.functions[fn.Name()] - if found { - fn, err = existing.Merge(fn) - if err != nil { - return nil, err - } - } - e.functions[fn.Name()] = fn - } - return e, nil - }, - func(e *Env) (*Env, error) { - e.variables = append(e.variables, stdlib.Types()...) - return e, nil - }, - Macros(StandardMacros...), - } -} - -// ProgramOptions returns function implementations for the standard CEL functions. -func (stdLibrary) ProgramOptions() []ProgramOption { - return []ProgramOption{} -} - -// OptionalTypes enable support for optional syntax and types in CEL. -// -// The optional value type makes it possible to express whether variables have -// been provided, whether a result has been computed, and in the future whether -// an object field path, map key value, or list index has a value. -// -// # Syntax Changes -// -// OptionalTypes are unlike other CEL extensions because they modify the CEL -// syntax itself, notably through the use of a `?` preceding a field name or -// index value. -// -// ## Field Selection -// -// The optional syntax in field selection is denoted as `obj.?field`. In other -// words, if a field is set, return `optional.of(obj.field)“, else -// `optional.none()`. The optional field selection is viral in the sense that -// after the first optional selection all subsequent selections or indices -// are treated as optional, i.e. the following expressions are equivalent: -// -// obj.?field.subfield -// obj.?field.?subfield -// -// ## Indexing -// -// Similar to field selection, the optional syntax can be used in index -// expressions on maps and lists: -// -// list[?0] -// map[?key] -// -// ## Optional Field Setting -// -// When creating map or message literals, if a field may be optionally set -// based on its presence, then placing a `?` before the field name or key -// will ensure the type on the right-hand side must be optional(T) where T -// is the type of the field or key-value. -// -// The following returns a map with the key expression set only if the -// subfield is present, otherwise an empty map is created: -// -// {?key: obj.?field.subfield} -// -// ## Optional Element Setting -// -// When creating list literals, an element in the list may be optionally added -// when the element expression is preceded by a `?`: -// -// [a, ?b, ?c] // return a list with either [a], [a, b], [a, b, c], or [a, c] -// -// # Optional.Of -// -// Create an optional(T) value of a given value with type T. -// -// optional.of(10) -// -// # Optional.OfNonZeroValue -// -// Create an optional(T) value of a given value with type T if it is not a -// zero-value. A zero-value the default empty value for any given CEL type, -// including empty protobuf message types. If the value is empty, the result -// of this call will be optional.none(). -// -// optional.ofNonZeroValue([1, 2, 3]) // optional(list(int)) -// optional.ofNonZeroValue([]) // optional.none() -// optional.ofNonZeroValue(0) // optional.none() -// optional.ofNonZeroValue("") // optional.none() -// -// # Optional.None -// -// Create an empty optional value. -// -// # HasValue -// -// Determine whether the optional contains a value. -// -// optional.of(b'hello').hasValue() // true -// optional.ofNonZeroValue({}).hasValue() // false -// -// # Value -// -// Get the value contained by the optional. If the optional does not have a -// value, the result will be a CEL error. -// -// optional.of(b'hello').value() // b'hello' -// optional.ofNonZeroValue({}).value() // error -// -// # Or -// -// If the value on the left-hand side is optional.none(), the optional value -// on the right hand side is returned. If the value on the left-hand set is -// valued, then it is returned. This operation is short-circuiting and will -// only evaluate as many links in the `or` chain as are needed to return a -// non-empty optional value. -// -// obj.?field.or(m[?key]) -// l[?index].or(obj.?field.subfield).or(obj.?other) -// -// # OrValue -// -// Either return the value contained within the optional on the left-hand side -// or return the alternative value on the right hand side. -// -// m[?key].orValue("none") -// -// # OptMap -// -// Apply a transformation to the optional's underlying value if it is not empty -// and return an optional typed result based on the transformation. The -// transformation expression type must return a type T which is wrapped into -// an optional. -// -// msg.?elements.optMap(e, e.size()).orValue(0) -// -// # OptFlatMap -// -// Introduced in version: 1 -// -// Apply a transformation to the optional's underlying value if it is not empty -// and return the result. The transform expression must return an optional(T) -// rather than type T. This can be useful when dealing with zero values and -// conditionally generating an empty or non-empty result in ways which cannot -// be expressed with `optMap`. -// -// msg.?elements.optFlatMap(e, e[?0]) // return the first element if present. -func OptionalTypes(opts ...OptionalTypesOption) EnvOption { - lib := &optionalLib{version: math.MaxUint32} - for _, opt := range opts { - lib = opt(lib) - } - return Lib(lib) -} - -type optionalLib struct { - version uint32 -} - -// OptionalTypesOption is a functional interface for configuring the strings library. -type OptionalTypesOption func(*optionalLib) *optionalLib - -// OptionalTypesVersion configures the version of the optional type library. -// -// The version limits which functions are available. Only functions introduced -// below or equal to the given version included in the library. If this option -// is not set, all functions are available. -// -// See the library documentation to determine which version a function was introduced. -// If the documentation does not state which version a function was introduced, it can -// be assumed to be introduced at version 0, when the library was first created. -func OptionalTypesVersion(version uint32) OptionalTypesOption { - return func(lib *optionalLib) *optionalLib { - lib.version = version - return lib - } -} - -// LibraryName implements the SingletonLibrary interface method. -func (lib *optionalLib) LibraryName() string { - return "cel.lib.optional" -} - -// CompileOptions implements the Library interface method. -func (lib *optionalLib) CompileOptions() []EnvOption { - paramTypeK := TypeParamType("K") - paramTypeV := TypeParamType("V") - optionalTypeV := OptionalType(paramTypeV) - listTypeV := ListType(paramTypeV) - mapTypeKV := MapType(paramTypeK, paramTypeV) - - opts := []EnvOption{ - // Enable the optional syntax in the parser. - enableOptionalSyntax(), - - // Introduce the optional type. - Types(types.OptionalType), - - // Configure the optMap and optFlatMap macros. - Macros(ReceiverMacro(optMapMacro, 2, optMap)), - - // Global and member functions for working with optional values. - Function(optionalOfFunc, - Overload("optional_of", []*Type{paramTypeV}, optionalTypeV, - UnaryBinding(func(value ref.Val) ref.Val { - return types.OptionalOf(value) - }))), - Function(optionalOfNonZeroValueFunc, - Overload("optional_ofNonZeroValue", []*Type{paramTypeV}, optionalTypeV, - UnaryBinding(func(value ref.Val) ref.Val { - v, isZeroer := value.(traits.Zeroer) - if !isZeroer || !v.IsZeroValue() { - return types.OptionalOf(value) - } - return types.OptionalNone - }))), - Function(optionalNoneFunc, - Overload("optional_none", []*Type{}, optionalTypeV, - FunctionBinding(func(values ...ref.Val) ref.Val { - return types.OptionalNone - }))), - Function(valueFunc, - MemberOverload("optional_value", []*Type{optionalTypeV}, paramTypeV, - UnaryBinding(func(value ref.Val) ref.Val { - opt := value.(*types.Optional) - return opt.GetValue() - }))), - Function(hasValueFunc, - MemberOverload("optional_hasValue", []*Type{optionalTypeV}, BoolType, - UnaryBinding(func(value ref.Val) ref.Val { - opt := value.(*types.Optional) - return types.Bool(opt.HasValue()) - }))), - - // Implementation of 'or' and 'orValue' are special-cased to support short-circuiting in the - // evaluation chain. - Function("or", - MemberOverload("optional_or_optional", []*Type{optionalTypeV, optionalTypeV}, optionalTypeV)), - Function("orValue", - MemberOverload("optional_orValue_value", []*Type{optionalTypeV, paramTypeV}, paramTypeV)), - - // OptSelect is handled specially by the type-checker, so the receiver's field type is used to determine the - // optput type. - Function(operators.OptSelect, - Overload("select_optional_field", []*Type{DynType, StringType}, optionalTypeV)), - - // OptIndex is handled mostly like any other indexing operation on a list or map, so the type-checker can use - // these signatures to determine type-agreement without any special handling. - Function(operators.OptIndex, - Overload("list_optindex_optional_int", []*Type{listTypeV, IntType}, optionalTypeV), - Overload("optional_list_optindex_optional_int", []*Type{OptionalType(listTypeV), IntType}, optionalTypeV), - Overload("map_optindex_optional_value", []*Type{mapTypeKV, paramTypeK}, optionalTypeV), - Overload("optional_map_optindex_optional_value", []*Type{OptionalType(mapTypeKV), paramTypeK}, optionalTypeV)), - - // Index overloads to accommodate using an optional value as the operand. - Function(operators.Index, - Overload("optional_list_index_int", []*Type{OptionalType(listTypeV), IntType}, optionalTypeV), - Overload("optional_map_index_value", []*Type{OptionalType(mapTypeKV), paramTypeK}, optionalTypeV)), - } - if lib.version >= 1 { - opts = append(opts, Macros(ReceiverMacro(optFlatMapMacro, 2, optFlatMap))) - } - return opts -} - -// ProgramOptions implements the Library interface method. -func (lib *optionalLib) ProgramOptions() []ProgramOption { - return []ProgramOption{ - CustomDecorator(decorateOptionalOr), - } -} - -func optMap(meh MacroExprFactory, target ast.Expr, args []ast.Expr) (ast.Expr, *Error) { - varIdent := args[0] - varName := "" - switch varIdent.Kind() { - case ast.IdentKind: - varName = varIdent.AsIdent() - default: - return nil, meh.NewError(varIdent.ID(), "optMap() variable name must be a simple identifier") - } - mapExpr := args[1] - return meh.NewCall( - operators.Conditional, - meh.NewMemberCall(hasValueFunc, target), - meh.NewCall(optionalOfFunc, - meh.NewComprehension( - meh.NewList(), - unusedIterVar, - varName, - meh.NewMemberCall(valueFunc, target), - meh.NewLiteral(types.False), - meh.NewIdent(varName), - mapExpr, - ), - ), - meh.NewCall(optionalNoneFunc), - ), nil -} - -func optFlatMap(meh MacroExprFactory, target ast.Expr, args []ast.Expr) (ast.Expr, *Error) { - varIdent := args[0] - varName := "" - switch varIdent.Kind() { - case ast.IdentKind: - varName = varIdent.AsIdent() - default: - return nil, meh.NewError(varIdent.ID(), "optFlatMap() variable name must be a simple identifier") - } - mapExpr := args[1] - return meh.NewCall( - operators.Conditional, - meh.NewMemberCall(hasValueFunc, target), - meh.NewComprehension( - meh.NewList(), - unusedIterVar, - varName, - meh.NewMemberCall(valueFunc, target), - meh.NewLiteral(types.False), - meh.NewIdent(varName), - mapExpr, - ), - meh.NewCall(optionalNoneFunc), - ), nil -} - -func enableOptionalSyntax() EnvOption { - return func(e *Env) (*Env, error) { - e.prsrOpts = append(e.prsrOpts, parser.EnableOptionalSyntax(true)) - return e, nil - } -} - -func decorateOptionalOr(i interpreter.Interpretable) (interpreter.Interpretable, error) { - call, ok := i.(interpreter.InterpretableCall) - if !ok { - return i, nil - } - args := call.Args() - if len(args) != 2 { - return i, nil - } - switch call.Function() { - case "or": - if call.OverloadID() != "" && call.OverloadID() != "optional_or_optional" { - return i, nil - } - return &evalOptionalOr{ - id: call.ID(), - lhs: args[0], - rhs: args[1], - }, nil - case "orValue": - if call.OverloadID() != "" && call.OverloadID() != "optional_orValue_value" { - return i, nil - } - return &evalOptionalOrValue{ - id: call.ID(), - lhs: args[0], - rhs: args[1], - }, nil - default: - return i, nil - } -} - -// evalOptionalOr selects between two optional values, either the first if it has a value, or -// the second optional expression is evaluated and returned. -type evalOptionalOr struct { - id int64 - lhs interpreter.Interpretable - rhs interpreter.Interpretable -} - -// ID implements the Interpretable interface method. -func (opt *evalOptionalOr) ID() int64 { - return opt.id -} - -// Eval evaluates the left-hand side optional to determine whether it contains a value, else -// proceeds with the right-hand side evaluation. -func (opt *evalOptionalOr) Eval(ctx interpreter.Activation) ref.Val { - // short-circuit lhs. - optLHS := opt.lhs.Eval(ctx) - optVal, ok := optLHS.(*types.Optional) - if !ok { - return optLHS - } - if optVal.HasValue() { - return optVal - } - return opt.rhs.Eval(ctx) -} - -// evalOptionalOrValue selects between an optional or a concrete value. If the optional has a value, -// its value is returned, otherwise the alternative value expression is evaluated and returned. -type evalOptionalOrValue struct { - id int64 - lhs interpreter.Interpretable - rhs interpreter.Interpretable -} - -// ID implements the Interpretable interface method. -func (opt *evalOptionalOrValue) ID() int64 { - return opt.id -} - -// Eval evaluates the left-hand side optional to determine whether it contains a value, else -// proceeds with the right-hand side evaluation. -func (opt *evalOptionalOrValue) Eval(ctx interpreter.Activation) ref.Val { - // short-circuit lhs. - optLHS := opt.lhs.Eval(ctx) - optVal, ok := optLHS.(*types.Optional) - if !ok { - return optLHS - } - if optVal.HasValue() { - return optVal.GetValue() - } - return opt.rhs.Eval(ctx) -} - -type timeUTCLibrary struct{} - -func (timeUTCLibrary) CompileOptions() []EnvOption { - return timeOverloadDeclarations -} - -func (timeUTCLibrary) ProgramOptions() []ProgramOption { - return []ProgramOption{} -} - -// Declarations and functions which enable using UTC on time.Time inputs when the timezone is unspecified -// in the CEL expression. -var ( - utcTZ = types.String("UTC") - - timeOverloadDeclarations = []EnvOption{ - Function(overloads.TimeGetHours, - MemberOverload(overloads.DurationToHours, []*Type{DurationType}, IntType, - UnaryBinding(types.DurationGetHours))), - Function(overloads.TimeGetMinutes, - MemberOverload(overloads.DurationToMinutes, []*Type{DurationType}, IntType, - UnaryBinding(types.DurationGetMinutes))), - Function(overloads.TimeGetSeconds, - MemberOverload(overloads.DurationToSeconds, []*Type{DurationType}, IntType, - UnaryBinding(types.DurationGetSeconds))), - Function(overloads.TimeGetMilliseconds, - MemberOverload(overloads.DurationToMilliseconds, []*Type{DurationType}, IntType, - UnaryBinding(types.DurationGetMilliseconds))), - Function(overloads.TimeGetFullYear, - MemberOverload(overloads.TimestampToYear, []*Type{TimestampType}, IntType, - UnaryBinding(func(ts ref.Val) ref.Val { - return timestampGetFullYear(ts, utcTZ) - }), - ), - MemberOverload(overloads.TimestampToYearWithTz, []*Type{TimestampType, StringType}, IntType, - BinaryBinding(timestampGetFullYear), - ), - ), - Function(overloads.TimeGetMonth, - MemberOverload(overloads.TimestampToMonth, []*Type{TimestampType}, IntType, - UnaryBinding(func(ts ref.Val) ref.Val { - return timestampGetMonth(ts, utcTZ) - }), - ), - MemberOverload(overloads.TimestampToMonthWithTz, []*Type{TimestampType, StringType}, IntType, - BinaryBinding(timestampGetMonth), - ), - ), - Function(overloads.TimeGetDayOfYear, - MemberOverload(overloads.TimestampToDayOfYear, []*Type{TimestampType}, IntType, - UnaryBinding(func(ts ref.Val) ref.Val { - return timestampGetDayOfYear(ts, utcTZ) - }), - ), - MemberOverload(overloads.TimestampToDayOfYearWithTz, []*Type{TimestampType, StringType}, IntType, - BinaryBinding(func(ts, tz ref.Val) ref.Val { - return timestampGetDayOfYear(ts, tz) - }), - ), - ), - Function(overloads.TimeGetDayOfMonth, - MemberOverload(overloads.TimestampToDayOfMonthZeroBased, []*Type{TimestampType}, IntType, - UnaryBinding(func(ts ref.Val) ref.Val { - return timestampGetDayOfMonthZeroBased(ts, utcTZ) - }), - ), - MemberOverload(overloads.TimestampToDayOfMonthZeroBasedWithTz, []*Type{TimestampType, StringType}, IntType, - BinaryBinding(timestampGetDayOfMonthZeroBased), - ), - ), - Function(overloads.TimeGetDate, - MemberOverload(overloads.TimestampToDayOfMonthOneBased, []*Type{TimestampType}, IntType, - UnaryBinding(func(ts ref.Val) ref.Val { - return timestampGetDayOfMonthOneBased(ts, utcTZ) - }), - ), - MemberOverload(overloads.TimestampToDayOfMonthOneBasedWithTz, []*Type{TimestampType, StringType}, IntType, - BinaryBinding(timestampGetDayOfMonthOneBased), - ), - ), - Function(overloads.TimeGetDayOfWeek, - MemberOverload(overloads.TimestampToDayOfWeek, []*Type{TimestampType}, IntType, - UnaryBinding(func(ts ref.Val) ref.Val { - return timestampGetDayOfWeek(ts, utcTZ) - }), - ), - MemberOverload(overloads.TimestampToDayOfWeekWithTz, []*Type{TimestampType, StringType}, IntType, - BinaryBinding(timestampGetDayOfWeek), - ), - ), - Function(overloads.TimeGetHours, - MemberOverload(overloads.TimestampToHours, []*Type{TimestampType}, IntType, - UnaryBinding(func(ts ref.Val) ref.Val { - return timestampGetHours(ts, utcTZ) - }), - ), - MemberOverload(overloads.TimestampToHoursWithTz, []*Type{TimestampType, StringType}, IntType, - BinaryBinding(timestampGetHours), - ), - ), - Function(overloads.TimeGetMinutes, - MemberOverload(overloads.TimestampToMinutes, []*Type{TimestampType}, IntType, - UnaryBinding(func(ts ref.Val) ref.Val { - return timestampGetMinutes(ts, utcTZ) - }), - ), - MemberOverload(overloads.TimestampToMinutesWithTz, []*Type{TimestampType, StringType}, IntType, - BinaryBinding(timestampGetMinutes), - ), - ), - Function(overloads.TimeGetSeconds, - MemberOverload(overloads.TimestampToSeconds, []*Type{TimestampType}, IntType, - UnaryBinding(func(ts ref.Val) ref.Val { - return timestampGetSeconds(ts, utcTZ) - }), - ), - MemberOverload(overloads.TimestampToSecondsWithTz, []*Type{TimestampType, StringType}, IntType, - BinaryBinding(timestampGetSeconds), - ), - ), - Function(overloads.TimeGetMilliseconds, - MemberOverload(overloads.TimestampToMilliseconds, []*Type{TimestampType}, IntType, - UnaryBinding(func(ts ref.Val) ref.Val { - return timestampGetMilliseconds(ts, utcTZ) - }), - ), - MemberOverload(overloads.TimestampToMillisecondsWithTz, []*Type{TimestampType, StringType}, IntType, - BinaryBinding(timestampGetMilliseconds), - ), - ), - } -) - -func timestampGetFullYear(ts, tz ref.Val) ref.Val { - t, err := inTimeZone(ts, tz) - if err != nil { - return types.NewErr(err.Error()) - } - return types.Int(t.Year()) -} - -func timestampGetMonth(ts, tz ref.Val) ref.Val { - t, err := inTimeZone(ts, tz) - if err != nil { - return types.NewErr(err.Error()) - } - // CEL spec indicates that the month should be 0-based, but the Time value - // for Month() is 1-based. - return types.Int(t.Month() - 1) -} - -func timestampGetDayOfYear(ts, tz ref.Val) ref.Val { - t, err := inTimeZone(ts, tz) - if err != nil { - return types.NewErr(err.Error()) - } - return types.Int(t.YearDay() - 1) -} - -func timestampGetDayOfMonthZeroBased(ts, tz ref.Val) ref.Val { - t, err := inTimeZone(ts, tz) - if err != nil { - return types.NewErr(err.Error()) - } - return types.Int(t.Day() - 1) -} - -func timestampGetDayOfMonthOneBased(ts, tz ref.Val) ref.Val { - t, err := inTimeZone(ts, tz) - if err != nil { - return types.NewErr(err.Error()) - } - return types.Int(t.Day()) -} - -func timestampGetDayOfWeek(ts, tz ref.Val) ref.Val { - t, err := inTimeZone(ts, tz) - if err != nil { - return types.NewErr(err.Error()) - } - return types.Int(t.Weekday()) -} - -func timestampGetHours(ts, tz ref.Val) ref.Val { - t, err := inTimeZone(ts, tz) - if err != nil { - return types.NewErr(err.Error()) - } - return types.Int(t.Hour()) -} - -func timestampGetMinutes(ts, tz ref.Val) ref.Val { - t, err := inTimeZone(ts, tz) - if err != nil { - return types.NewErr(err.Error()) - } - return types.Int(t.Minute()) -} - -func timestampGetSeconds(ts, tz ref.Val) ref.Val { - t, err := inTimeZone(ts, tz) - if err != nil { - return types.NewErr(err.Error()) - } - return types.Int(t.Second()) -} - -func timestampGetMilliseconds(ts, tz ref.Val) ref.Val { - t, err := inTimeZone(ts, tz) - if err != nil { - return types.NewErr(err.Error()) - } - return types.Int(t.Nanosecond() / 1000000) -} - -func inTimeZone(ts, tz ref.Val) (time.Time, error) { - t := ts.(types.Timestamp) - val := string(tz.(types.String)) - ind := strings.Index(val, ":") - if ind == -1 { - loc, err := time.LoadLocation(val) - if err != nil { - return time.Time{}, err - } - return t.In(loc), nil - } - - // If the input is not the name of a timezone (for example, 'US/Central'), it should be a numerical offset from UTC - // in the format ^(+|-)(0[0-9]|1[0-4]):[0-5][0-9]$. The numerical input is parsed in terms of hours and minutes. - hr, err := strconv.Atoi(string(val[0:ind])) - if err != nil { - return time.Time{}, err - } - min, err := strconv.Atoi(string(val[ind+1:])) - if err != nil { - return time.Time{}, err - } - var offset int - if string(val[0]) == "-" { - offset = hr*60 - min - } else { - offset = hr*60 + min - } - secondsEastOfUTC := int((time.Duration(offset) * time.Minute).Seconds()) - timezone := time.FixedZone("", secondsEastOfUTC) - return t.In(timezone), nil -} diff --git a/vendor/github.com/google/cel-go/cel/macro.go b/vendor/github.com/google/cel-go/cel/macro.go deleted file mode 100644 index 4db1fd57a..000000000 --- a/vendor/github.com/google/cel-go/cel/macro.go +++ /dev/null @@ -1,576 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package cel - -import ( - "fmt" - - "github.com/google/cel-go/common" - "github.com/google/cel-go/common/ast" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/parser" - - exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1" -) - -// Macro describes a function signature to match and the MacroExpander to apply. -// -// Note: when a Macro should apply to multiple overloads (based on arg count) of a given function, -// a Macro should be created per arg-count or as a var arg macro. -type Macro = parser.Macro - -// MacroFactory defines an expansion function which converts a call and its arguments to a cel.Expr value. -type MacroFactory = parser.MacroExpander - -// MacroExprFactory assists with the creation of Expr values in a manner which is consistent -// the internal semantics and id generation behaviors of the parser and checker libraries. -type MacroExprFactory = parser.ExprHelper - -// MacroExpander converts a call and its associated arguments into a protobuf Expr representation. -// -// If the MacroExpander determines within the implementation that an expansion is not needed it may return -// a nil Expr value to indicate a non-match. However, if an expansion is to be performed, but the arguments -// are not well-formed, the result of the expansion will be an error. -// -// The MacroExpander accepts as arguments a MacroExprHelper as well as the arguments used in the function call -// and produces as output an Expr ast node. -// -// Note: when the Macro.IsReceiverStyle() method returns true, the target argument will be nil. -type MacroExpander func(eh MacroExprHelper, target *exprpb.Expr, args []*exprpb.Expr) (*exprpb.Expr, *Error) - -// MacroExprHelper exposes helper methods for creating new expressions within a CEL abstract syntax tree. -// ExprHelper assists with the manipulation of proto-based Expr values in a manner which is -// consistent with the source position and expression id generation code leveraged by both -// the parser and type-checker. -type MacroExprHelper interface { - // Copy the input expression with a brand new set of identifiers. - Copy(*exprpb.Expr) *exprpb.Expr - - // LiteralBool creates an Expr value for a bool literal. - LiteralBool(value bool) *exprpb.Expr - - // LiteralBytes creates an Expr value for a byte literal. - LiteralBytes(value []byte) *exprpb.Expr - - // LiteralDouble creates an Expr value for double literal. - LiteralDouble(value float64) *exprpb.Expr - - // LiteralInt creates an Expr value for an int literal. - LiteralInt(value int64) *exprpb.Expr - - // LiteralString creates am Expr value for a string literal. - LiteralString(value string) *exprpb.Expr - - // LiteralUint creates an Expr value for a uint literal. - LiteralUint(value uint64) *exprpb.Expr - - // NewList creates a CreateList instruction where the list is comprised of the optional set - // of elements provided as arguments. - NewList(elems ...*exprpb.Expr) *exprpb.Expr - - // NewMap creates a CreateStruct instruction for a map where the map is comprised of the - // optional set of key, value entries. - NewMap(entries ...*exprpb.Expr_CreateStruct_Entry) *exprpb.Expr - - // NewMapEntry creates a Map Entry for the key, value pair. - NewMapEntry(key *exprpb.Expr, val *exprpb.Expr, optional bool) *exprpb.Expr_CreateStruct_Entry - - // NewObject creates a CreateStruct instruction for an object with a given type name and - // optional set of field initializers. - NewObject(typeName string, fieldInits ...*exprpb.Expr_CreateStruct_Entry) *exprpb.Expr - - // NewObjectFieldInit creates a new Object field initializer from the field name and value. - NewObjectFieldInit(field string, init *exprpb.Expr, optional bool) *exprpb.Expr_CreateStruct_Entry - - // Fold creates a fold comprehension instruction. - // - // - iterVar is the iteration variable name. - // - iterRange represents the expression that resolves to a list or map where the elements or - // keys (respectively) will be iterated over. - // - accuVar is the accumulation variable name, typically parser.AccumulatorName. - // - accuInit is the initial expression whose value will be set for the accuVar prior to - // folding. - // - condition is the expression to test to determine whether to continue folding. - // - step is the expression to evaluation at the conclusion of a single fold iteration. - // - result is the computation to evaluate at the conclusion of the fold. - // - // The accuVar should not shadow variable names that you would like to reference within the - // environment in the step and condition expressions. Presently, the name __result__ is commonly - // used by built-in macros but this may change in the future. - Fold(iterVar string, - iterRange *exprpb.Expr, - accuVar string, - accuInit *exprpb.Expr, - condition *exprpb.Expr, - step *exprpb.Expr, - result *exprpb.Expr) *exprpb.Expr - - // Ident creates an identifier Expr value. - Ident(name string) *exprpb.Expr - - // AccuIdent returns an accumulator identifier for use with comprehension results. - AccuIdent() *exprpb.Expr - - // GlobalCall creates a function call Expr value for a global (free) function. - GlobalCall(function string, args ...*exprpb.Expr) *exprpb.Expr - - // ReceiverCall creates a function call Expr value for a receiver-style function. - ReceiverCall(function string, target *exprpb.Expr, args ...*exprpb.Expr) *exprpb.Expr - - // PresenceTest creates a Select TestOnly Expr value for modelling has() semantics. - PresenceTest(operand *exprpb.Expr, field string) *exprpb.Expr - - // Select create a field traversal Expr value. - Select(operand *exprpb.Expr, field string) *exprpb.Expr - - // OffsetLocation returns the Location of the expression identifier. - OffsetLocation(exprID int64) common.Location - - // NewError associates an error message with a given expression id. - NewError(exprID int64, message string) *Error -} - -// GlobalMacro creates a Macro for a global function with the specified arg count. -func GlobalMacro(function string, argCount int, factory MacroFactory) Macro { - return parser.NewGlobalMacro(function, argCount, factory) -} - -// ReceiverMacro creates a Macro for a receiver function matching the specified arg count. -func ReceiverMacro(function string, argCount int, factory MacroFactory) Macro { - return parser.NewReceiverMacro(function, argCount, factory) -} - -// GlobalVarArgMacro creates a Macro for a global function with a variable arg count. -func GlobalVarArgMacro(function string, factory MacroFactory) Macro { - return parser.NewGlobalVarArgMacro(function, factory) -} - -// ReceiverVarArgMacro creates a Macro for a receiver function matching a variable arg count. -func ReceiverVarArgMacro(function string, factory MacroFactory) Macro { - return parser.NewReceiverVarArgMacro(function, factory) -} - -// NewGlobalMacro creates a Macro for a global function with the specified arg count. -// -// Deprecated: use GlobalMacro -func NewGlobalMacro(function string, argCount int, expander MacroExpander) Macro { - expand := adaptingExpander{expander} - return parser.NewGlobalMacro(function, argCount, expand.Expander) -} - -// NewReceiverMacro creates a Macro for a receiver function matching the specified arg count. -// -// Deprecated: use ReceiverMacro -func NewReceiverMacro(function string, argCount int, expander MacroExpander) Macro { - expand := adaptingExpander{expander} - return parser.NewReceiverMacro(function, argCount, expand.Expander) -} - -// NewGlobalVarArgMacro creates a Macro for a global function with a variable arg count. -// -// Deprecated: use GlobalVarArgMacro -func NewGlobalVarArgMacro(function string, expander MacroExpander) Macro { - expand := adaptingExpander{expander} - return parser.NewGlobalVarArgMacro(function, expand.Expander) -} - -// NewReceiverVarArgMacro creates a Macro for a receiver function matching a variable arg count. -// -// Deprecated: use ReceiverVarArgMacro -func NewReceiverVarArgMacro(function string, expander MacroExpander) Macro { - expand := adaptingExpander{expander} - return parser.NewReceiverVarArgMacro(function, expand.Expander) -} - -// HasMacroExpander expands the input call arguments into a presence test, e.g. has(.field) -func HasMacroExpander(meh MacroExprHelper, target *exprpb.Expr, args []*exprpb.Expr) (*exprpb.Expr, *Error) { - ph, err := toParserHelper(meh) - if err != nil { - return nil, err - } - arg, err := adaptToExpr(args[0]) - if err != nil { - return nil, err - } - if arg.Kind() == ast.SelectKind { - s := arg.AsSelect() - return adaptToProto(ph.NewPresenceTest(s.Operand(), s.FieldName())) - } - return nil, ph.NewError(arg.ID(), "invalid argument to has() macro") -} - -// ExistsMacroExpander expands the input call arguments into a comprehension that returns true if any of the -// elements in the range match the predicate expressions: -// .exists(, ) -func ExistsMacroExpander(meh MacroExprHelper, target *exprpb.Expr, args []*exprpb.Expr) (*exprpb.Expr, *Error) { - ph, err := toParserHelper(meh) - if err != nil { - return nil, err - } - out, err := parser.MakeExists(ph, mustAdaptToExpr(target), mustAdaptToExprs(args)) - if err != nil { - return nil, err - } - return adaptToProto(out) -} - -// ExistsOneMacroExpander expands the input call arguments into a comprehension that returns true if exactly -// one of the elements in the range match the predicate expressions: -// .exists_one(, ) -func ExistsOneMacroExpander(meh MacroExprHelper, target *exprpb.Expr, args []*exprpb.Expr) (*exprpb.Expr, *Error) { - ph, err := toParserHelper(meh) - if err != nil { - return nil, err - } - out, err := parser.MakeExistsOne(ph, mustAdaptToExpr(target), mustAdaptToExprs(args)) - if err != nil { - return nil, err - } - return adaptToProto(out) -} - -// MapMacroExpander expands the input call arguments into a comprehension that transforms each element in the -// input to produce an output list. -// -// There are two call patterns supported by map: -// -// .map(, ) -// .map(, , ) -// -// In the second form only iterVar values which return true when provided to the predicate expression -// are transformed. -func MapMacroExpander(meh MacroExprHelper, target *exprpb.Expr, args []*exprpb.Expr) (*exprpb.Expr, *Error) { - ph, err := toParserHelper(meh) - if err != nil { - return nil, err - } - out, err := parser.MakeMap(ph, mustAdaptToExpr(target), mustAdaptToExprs(args)) - if err != nil { - return nil, err - } - return adaptToProto(out) -} - -// FilterMacroExpander expands the input call arguments into a comprehension which produces a list which contains -// only elements which match the provided predicate expression: -// .filter(, ) -func FilterMacroExpander(meh MacroExprHelper, target *exprpb.Expr, args []*exprpb.Expr) (*exprpb.Expr, *Error) { - ph, err := toParserHelper(meh) - if err != nil { - return nil, err - } - out, err := parser.MakeFilter(ph, mustAdaptToExpr(target), mustAdaptToExprs(args)) - if err != nil { - return nil, err - } - return adaptToProto(out) -} - -var ( - // Aliases to each macro in the CEL standard environment. - // Note: reassigning these macro variables may result in undefined behavior. - - // HasMacro expands "has(m.f)" which tests the presence of a field, avoiding the need to - // specify the field as a string. - HasMacro = parser.HasMacro - - // AllMacro expands "range.all(var, predicate)" into a comprehension which ensures that all - // elements in the range satisfy the predicate. - AllMacro = parser.AllMacro - - // ExistsMacro expands "range.exists(var, predicate)" into a comprehension which ensures that - // some element in the range satisfies the predicate. - ExistsMacro = parser.ExistsMacro - - // ExistsOneMacro expands "range.exists_one(var, predicate)", which is true if for exactly one - // element in range the predicate holds. - ExistsOneMacro = parser.ExistsOneMacro - - // MapMacro expands "range.map(var, function)" into a comprehension which applies the function - // to each element in the range to produce a new list. - MapMacro = parser.MapMacro - - // MapFilterMacro expands "range.map(var, predicate, function)" into a comprehension which - // first filters the elements in the range by the predicate, then applies the transform function - // to produce a new list. - MapFilterMacro = parser.MapFilterMacro - - // FilterMacro expands "range.filter(var, predicate)" into a comprehension which filters - // elements in the range, producing a new list from the elements that satisfy the predicate. - FilterMacro = parser.FilterMacro - - // StandardMacros provides an alias to all the CEL macros defined in the standard environment. - StandardMacros = []Macro{ - HasMacro, AllMacro, ExistsMacro, ExistsOneMacro, MapMacro, MapFilterMacro, FilterMacro, - } - - // NoMacros provides an alias to an empty list of macros - NoMacros = []Macro{} -) - -type adaptingExpander struct { - legacyExpander MacroExpander -} - -func (adapt *adaptingExpander) Expander(eh parser.ExprHelper, target ast.Expr, args []ast.Expr) (ast.Expr, *common.Error) { - var legacyTarget *exprpb.Expr = nil - var err *Error = nil - if target != nil { - legacyTarget, err = adaptToProto(target) - if err != nil { - return nil, err - } - } - legacyArgs := make([]*exprpb.Expr, len(args)) - for i, arg := range args { - legacyArgs[i], err = adaptToProto(arg) - if err != nil { - return nil, err - } - } - ah := &adaptingHelper{modernHelper: eh} - legacyExpr, err := adapt.legacyExpander(ah, legacyTarget, legacyArgs) - if err != nil { - return nil, err - } - ex, err := adaptToExpr(legacyExpr) - if err != nil { - return nil, err - } - return ex, nil -} - -func wrapErr(id int64, message string, err error) *common.Error { - return &common.Error{ - Location: common.NoLocation, - Message: fmt.Sprintf("%s: %v", message, err), - ExprID: id, - } -} - -type adaptingHelper struct { - modernHelper parser.ExprHelper -} - -// Copy the input expression with a brand new set of identifiers. -func (ah *adaptingHelper) Copy(e *exprpb.Expr) *exprpb.Expr { - return mustAdaptToProto(ah.modernHelper.Copy(mustAdaptToExpr(e))) -} - -// LiteralBool creates an Expr value for a bool literal. -func (ah *adaptingHelper) LiteralBool(value bool) *exprpb.Expr { - return mustAdaptToProto(ah.modernHelper.NewLiteral(types.Bool(value))) -} - -// LiteralBytes creates an Expr value for a byte literal. -func (ah *adaptingHelper) LiteralBytes(value []byte) *exprpb.Expr { - return mustAdaptToProto(ah.modernHelper.NewLiteral(types.Bytes(value))) -} - -// LiteralDouble creates an Expr value for double literal. -func (ah *adaptingHelper) LiteralDouble(value float64) *exprpb.Expr { - return mustAdaptToProto(ah.modernHelper.NewLiteral(types.Double(value))) -} - -// LiteralInt creates an Expr value for an int literal. -func (ah *adaptingHelper) LiteralInt(value int64) *exprpb.Expr { - return mustAdaptToProto(ah.modernHelper.NewLiteral(types.Int(value))) -} - -// LiteralString creates am Expr value for a string literal. -func (ah *adaptingHelper) LiteralString(value string) *exprpb.Expr { - return mustAdaptToProto(ah.modernHelper.NewLiteral(types.String(value))) -} - -// LiteralUint creates an Expr value for a uint literal. -func (ah *adaptingHelper) LiteralUint(value uint64) *exprpb.Expr { - return mustAdaptToProto(ah.modernHelper.NewLiteral(types.Uint(value))) -} - -// NewList creates a CreateList instruction where the list is comprised of the optional set -// of elements provided as arguments. -func (ah *adaptingHelper) NewList(elems ...*exprpb.Expr) *exprpb.Expr { - return mustAdaptToProto(ah.modernHelper.NewList(mustAdaptToExprs(elems)...)) -} - -// NewMap creates a CreateStruct instruction for a map where the map is comprised of the -// optional set of key, value entries. -func (ah *adaptingHelper) NewMap(entries ...*exprpb.Expr_CreateStruct_Entry) *exprpb.Expr { - adaptedEntries := make([]ast.EntryExpr, len(entries)) - for i, e := range entries { - adaptedEntries[i] = mustAdaptToEntryExpr(e) - } - return mustAdaptToProto(ah.modernHelper.NewMap(adaptedEntries...)) -} - -// NewMapEntry creates a Map Entry for the key, value pair. -func (ah *adaptingHelper) NewMapEntry(key *exprpb.Expr, val *exprpb.Expr, optional bool) *exprpb.Expr_CreateStruct_Entry { - return mustAdaptToProtoEntry( - ah.modernHelper.NewMapEntry(mustAdaptToExpr(key), mustAdaptToExpr(val), optional)) -} - -// NewObject creates a CreateStruct instruction for an object with a given type name and -// optional set of field initializers. -func (ah *adaptingHelper) NewObject(typeName string, fieldInits ...*exprpb.Expr_CreateStruct_Entry) *exprpb.Expr { - adaptedEntries := make([]ast.EntryExpr, len(fieldInits)) - for i, e := range fieldInits { - adaptedEntries[i] = mustAdaptToEntryExpr(e) - } - return mustAdaptToProto(ah.modernHelper.NewStruct(typeName, adaptedEntries...)) -} - -// NewObjectFieldInit creates a new Object field initializer from the field name and value. -func (ah *adaptingHelper) NewObjectFieldInit(field string, init *exprpb.Expr, optional bool) *exprpb.Expr_CreateStruct_Entry { - return mustAdaptToProtoEntry( - ah.modernHelper.NewStructField(field, mustAdaptToExpr(init), optional)) -} - -// Fold creates a fold comprehension instruction. -// -// - iterVar is the iteration variable name. -// - iterRange represents the expression that resolves to a list or map where the elements or -// keys (respectively) will be iterated over. -// - accuVar is the accumulation variable name, typically parser.AccumulatorName. -// - accuInit is the initial expression whose value will be set for the accuVar prior to -// folding. -// - condition is the expression to test to determine whether to continue folding. -// - step is the expression to evaluation at the conclusion of a single fold iteration. -// - result is the computation to evaluate at the conclusion of the fold. -// -// The accuVar should not shadow variable names that you would like to reference within the -// environment in the step and condition expressions. Presently, the name __result__ is commonly -// used by built-in macros but this may change in the future. -func (ah *adaptingHelper) Fold(iterVar string, - iterRange *exprpb.Expr, - accuVar string, - accuInit *exprpb.Expr, - condition *exprpb.Expr, - step *exprpb.Expr, - result *exprpb.Expr) *exprpb.Expr { - return mustAdaptToProto( - ah.modernHelper.NewComprehension( - mustAdaptToExpr(iterRange), - iterVar, - accuVar, - mustAdaptToExpr(accuInit), - mustAdaptToExpr(condition), - mustAdaptToExpr(step), - mustAdaptToExpr(result), - ), - ) -} - -// Ident creates an identifier Expr value. -func (ah *adaptingHelper) Ident(name string) *exprpb.Expr { - return mustAdaptToProto(ah.modernHelper.NewIdent(name)) -} - -// AccuIdent returns an accumulator identifier for use with comprehension results. -func (ah *adaptingHelper) AccuIdent() *exprpb.Expr { - return mustAdaptToProto(ah.modernHelper.NewAccuIdent()) -} - -// GlobalCall creates a function call Expr value for a global (free) function. -func (ah *adaptingHelper) GlobalCall(function string, args ...*exprpb.Expr) *exprpb.Expr { - return mustAdaptToProto(ah.modernHelper.NewCall(function, mustAdaptToExprs(args)...)) -} - -// ReceiverCall creates a function call Expr value for a receiver-style function. -func (ah *adaptingHelper) ReceiverCall(function string, target *exprpb.Expr, args ...*exprpb.Expr) *exprpb.Expr { - return mustAdaptToProto( - ah.modernHelper.NewMemberCall(function, mustAdaptToExpr(target), mustAdaptToExprs(args)...)) -} - -// PresenceTest creates a Select TestOnly Expr value for modelling has() semantics. -func (ah *adaptingHelper) PresenceTest(operand *exprpb.Expr, field string) *exprpb.Expr { - op := mustAdaptToExpr(operand) - return mustAdaptToProto(ah.modernHelper.NewPresenceTest(op, field)) -} - -// Select create a field traversal Expr value. -func (ah *adaptingHelper) Select(operand *exprpb.Expr, field string) *exprpb.Expr { - op := mustAdaptToExpr(operand) - return mustAdaptToProto(ah.modernHelper.NewSelect(op, field)) -} - -// OffsetLocation returns the Location of the expression identifier. -func (ah *adaptingHelper) OffsetLocation(exprID int64) common.Location { - return ah.modernHelper.OffsetLocation(exprID) -} - -// NewError associates an error message with a given expression id. -func (ah *adaptingHelper) NewError(exprID int64, message string) *Error { - return ah.modernHelper.NewError(exprID, message) -} - -func mustAdaptToExprs(exprs []*exprpb.Expr) []ast.Expr { - adapted := make([]ast.Expr, len(exprs)) - for i, e := range exprs { - adapted[i] = mustAdaptToExpr(e) - } - return adapted -} - -func mustAdaptToExpr(e *exprpb.Expr) ast.Expr { - out, _ := adaptToExpr(e) - return out -} - -func adaptToExpr(e *exprpb.Expr) (ast.Expr, *Error) { - if e == nil { - return nil, nil - } - out, err := ast.ProtoToExpr(e) - if err != nil { - return nil, wrapErr(e.GetId(), "proto conversion failure", err) - } - return out, nil -} - -func mustAdaptToEntryExpr(e *exprpb.Expr_CreateStruct_Entry) ast.EntryExpr { - out, _ := ast.ProtoToEntryExpr(e) - return out -} - -func mustAdaptToProto(e ast.Expr) *exprpb.Expr { - out, _ := adaptToProto(e) - return out -} - -func adaptToProto(e ast.Expr) (*exprpb.Expr, *Error) { - if e == nil { - return nil, nil - } - out, err := ast.ExprToProto(e) - if err != nil { - return nil, wrapErr(e.ID(), "expr conversion failure", err) - } - return out, nil -} - -func mustAdaptToProtoEntry(e ast.EntryExpr) *exprpb.Expr_CreateStruct_Entry { - out, _ := ast.EntryExprToProto(e) - return out -} - -func toParserHelper(meh MacroExprHelper) (parser.ExprHelper, *Error) { - ah, ok := meh.(*adaptingHelper) - if !ok { - return nil, common.NewError(0, - fmt.Sprintf("unsupported macro helper: %v (%T)", meh, meh), - common.NoLocation) - } - return ah.modernHelper, nil -} diff --git a/vendor/github.com/google/cel-go/cel/optimizer.go b/vendor/github.com/google/cel-go/cel/optimizer.go deleted file mode 100644 index 99aeeb815..000000000 --- a/vendor/github.com/google/cel-go/cel/optimizer.go +++ /dev/null @@ -1,482 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package cel - -import ( - "github.com/google/cel-go/common" - "github.com/google/cel-go/common/ast" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/common/types/ref" -) - -// StaticOptimizer contains a sequence of ASTOptimizer instances which will be applied in order. -// -// The static optimizer normalizes expression ids and type-checking run between optimization -// passes to ensure that the final optimized output is a valid expression with metadata consistent -// with what would have been generated from a parsed and checked expression. -// -// Note: source position information is best-effort and likely wrong, but optimized expressions -// should be suitable for calls to parser.Unparse. -type StaticOptimizer struct { - optimizers []ASTOptimizer -} - -// NewStaticOptimizer creates a StaticOptimizer with a sequence of ASTOptimizer's to be applied -// to a checked expression. -func NewStaticOptimizer(optimizers ...ASTOptimizer) *StaticOptimizer { - return &StaticOptimizer{ - optimizers: optimizers, - } -} - -// Optimize applies a sequence of optimizations to an Ast within a given environment. -// -// If issues are encountered, the Issues.Err() return value will be non-nil. -func (opt *StaticOptimizer) Optimize(env *Env, a *Ast) (*Ast, *Issues) { - // Make a copy of the AST to be optimized. - optimized := ast.Copy(a.impl) - ids := newIDGenerator(ast.MaxID(a.impl)) - - // Create the optimizer context, could be pooled in the future. - issues := NewIssues(common.NewErrors(a.Source())) - baseFac := ast.NewExprFactory() - exprFac := &optimizerExprFactory{ - idGenerator: ids, - fac: baseFac, - sourceInfo: optimized.SourceInfo(), - } - ctx := &OptimizerContext{ - optimizerExprFactory: exprFac, - Env: env, - Issues: issues, - } - - // Apply the optimizations sequentially. - for _, o := range opt.optimizers { - optimized = o.Optimize(ctx, optimized) - if issues.Err() != nil { - return nil, issues - } - // Normalize expression id metadata including coordination with macro call metadata. - freshIDGen := newIDGenerator(0) - info := optimized.SourceInfo() - expr := optimized.Expr() - normalizeIDs(freshIDGen.renumberStable, expr, info) - cleanupMacroRefs(expr, info) - - // Recheck the updated expression for any possible type-agreement or validation errors. - parsed := &Ast{ - source: a.Source(), - impl: ast.NewAST(expr, info)} - checked, iss := ctx.Check(parsed) - if iss.Err() != nil { - return nil, iss - } - optimized = checked.impl - } - - // Return the optimized result. - return &Ast{ - source: a.Source(), - impl: optimized, - }, nil -} - -// normalizeIDs ensures that the metadata present with an AST is reset in a manner such -// that the ids within the expression correspond to the ids within macros. -func normalizeIDs(idGen ast.IDGenerator, optimized ast.Expr, info *ast.SourceInfo) { - optimized.RenumberIDs(idGen) - - if len(info.MacroCalls()) == 0 { - return - } - - // First, update the macro call ids themselves. - callIDMap := map[int64]int64{} - for id := range info.MacroCalls() { - callIDMap[id] = idGen(id) - } - // Then update the macro call definitions which refer to these ids, but - // ensure that the updates don't collide and remove macro entries which haven't - // been visited / updated yet. - type macroUpdate struct { - id int64 - call ast.Expr - } - macroUpdates := []macroUpdate{} - for oldID, newID := range callIDMap { - call, found := info.GetMacroCall(oldID) - if !found { - continue - } - call.RenumberIDs(idGen) - macroUpdates = append(macroUpdates, macroUpdate{id: newID, call: call}) - info.ClearMacroCall(oldID) - } - for _, u := range macroUpdates { - info.SetMacroCall(u.id, u.call) - } -} - -func cleanupMacroRefs(expr ast.Expr, info *ast.SourceInfo) { - if len(info.MacroCalls()) == 0 { - return - } - // Sanitize the macro call references once the optimized expression has been computed - // and the ids normalized between the expression and the macros. - exprRefMap := make(map[int64]struct{}) - ast.PostOrderVisit(expr, ast.NewExprVisitor(func(e ast.Expr) { - if e.ID() == 0 { - return - } - exprRefMap[e.ID()] = struct{}{} - })) - // Update the macro call id references to ensure that macro pointers are - // updated consistently across macros. - for _, call := range info.MacroCalls() { - ast.PostOrderVisit(call, ast.NewExprVisitor(func(e ast.Expr) { - if e.ID() == 0 { - return - } - exprRefMap[e.ID()] = struct{}{} - })) - } - for id := range info.MacroCalls() { - if _, found := exprRefMap[id]; !found { - info.ClearMacroCall(id) - } - } -} - -// newIDGenerator ensures that new ids are only created the first time they are encountered. -func newIDGenerator(seed int64) *idGenerator { - return &idGenerator{ - idMap: make(map[int64]int64), - seed: seed, - } -} - -type idGenerator struct { - idMap map[int64]int64 - seed int64 -} - -func (gen *idGenerator) nextID() int64 { - gen.seed++ - return gen.seed -} - -func (gen *idGenerator) renumberStable(id int64) int64 { - if id == 0 { - return 0 - } - if newID, found := gen.idMap[id]; found { - return newID - } - nextID := gen.nextID() - gen.idMap[id] = nextID - return nextID -} - -// OptimizerContext embeds Env and Issues instances to make it easy to type-check and evaluate -// subexpressions and report any errors encountered along the way. The context also embeds the -// optimizerExprFactory which can be used to generate new sub-expressions with expression ids -// consistent with the expectations of a parsed expression. -type OptimizerContext struct { - *Env - *optimizerExprFactory - *Issues -} - -// ASTOptimizer applies an optimization over an AST and returns the optimized result. -type ASTOptimizer interface { - // Optimize optimizes a type-checked AST within an Environment and accumulates any issues. - Optimize(*OptimizerContext, *ast.AST) *ast.AST -} - -type optimizerExprFactory struct { - *idGenerator - fac ast.ExprFactory - sourceInfo *ast.SourceInfo -} - -// CopyAST creates a renumbered copy of `Expr` and `SourceInfo` values of the input AST, where the -// renumbering uses the same scheme as the core optimizer logic ensuring there are no collisions -// between copies. -// -// Use this method before attempting to merge the expression from AST into another. -func (opt *optimizerExprFactory) CopyAST(a *ast.AST) (ast.Expr, *ast.SourceInfo) { - idGen := newIDGenerator(opt.nextID()) - defer func() { opt.seed = idGen.nextID() }() - copyExpr := opt.fac.CopyExpr(a.Expr()) - copyInfo := ast.CopySourceInfo(a.SourceInfo()) - normalizeIDs(idGen.renumberStable, copyExpr, copyInfo) - return copyExpr, copyInfo -} - -// NewBindMacro creates an AST expression representing the expanded bind() macro, and a macro expression -// representing the unexpanded call signature to be inserted into the source info macro call metadata. -func (opt *optimizerExprFactory) NewBindMacro(macroID int64, varName string, varInit, remaining ast.Expr) (astExpr, macroExpr ast.Expr) { - varID := opt.nextID() - remainingID := opt.nextID() - remaining = opt.fac.CopyExpr(remaining) - remaining.RenumberIDs(func(id int64) int64 { - if id == macroID { - return remainingID - } - return id - }) - if call, exists := opt.sourceInfo.GetMacroCall(macroID); exists { - opt.sourceInfo.SetMacroCall(remainingID, opt.fac.CopyExpr(call)) - } - - astExpr = opt.fac.NewComprehension(macroID, - opt.fac.NewList(opt.nextID(), []ast.Expr{}, []int32{}), - "#unused", - varName, - opt.fac.CopyExpr(varInit), - opt.fac.NewLiteral(opt.nextID(), types.False), - opt.fac.NewIdent(varID, varName), - remaining) - - macroExpr = opt.fac.NewMemberCall(0, "bind", - opt.fac.NewIdent(opt.nextID(), "cel"), - opt.fac.NewIdent(varID, varName), - opt.fac.CopyExpr(varInit), - opt.fac.CopyExpr(remaining)) - opt.sanitizeMacro(macroID, macroExpr) - return -} - -// NewCall creates a global function call invocation expression. -// -// Example: -// -// countByField(list, fieldName) -// - function: countByField -// - args: [list, fieldName] -func (opt *optimizerExprFactory) NewCall(function string, args ...ast.Expr) ast.Expr { - return opt.fac.NewCall(opt.nextID(), function, args...) -} - -// NewMemberCall creates a member function call invocation expression where 'target' is the receiver of the call. -// -// Example: -// -// list.countByField(fieldName) -// - function: countByField -// - target: list -// - args: [fieldName] -func (opt *optimizerExprFactory) NewMemberCall(function string, target ast.Expr, args ...ast.Expr) ast.Expr { - return opt.fac.NewMemberCall(opt.nextID(), function, target, args...) -} - -// NewIdent creates a new identifier expression. -// -// Examples: -// -// - simple_var_name -// - qualified.subpackage.var_name -func (opt *optimizerExprFactory) NewIdent(name string) ast.Expr { - return opt.fac.NewIdent(opt.nextID(), name) -} - -// NewLiteral creates a new literal expression value. -// -// The range of valid values for a literal generated during optimization is different than for expressions -// generated via parsing / type-checking, as the ref.Val may be _any_ CEL value so long as the value can -// be converted back to a literal-like form. -func (opt *optimizerExprFactory) NewLiteral(value ref.Val) ast.Expr { - return opt.fac.NewLiteral(opt.nextID(), value) -} - -// NewList creates a list expression with a set of optional indices. -// -// Examples: -// -// [a, b] -// - elems: [a, b] -// - optIndices: [] -// -// [a, ?b, ?c] -// - elems: [a, b, c] -// - optIndices: [1, 2] -func (opt *optimizerExprFactory) NewList(elems []ast.Expr, optIndices []int32) ast.Expr { - return opt.fac.NewList(opt.nextID(), elems, optIndices) -} - -// NewMap creates a map from a set of entry expressions which contain a key and value expression. -func (opt *optimizerExprFactory) NewMap(entries []ast.EntryExpr) ast.Expr { - return opt.fac.NewMap(opt.nextID(), entries) -} - -// NewMapEntry creates a map entry with a key and value expression and a flag to indicate whether the -// entry is optional. -// -// Examples: -// -// {a: b} -// - key: a -// - value: b -// - optional: false -// -// {?a: ?b} -// - key: a -// - value: b -// - optional: true -func (opt *optimizerExprFactory) NewMapEntry(key, value ast.Expr, isOptional bool) ast.EntryExpr { - return opt.fac.NewMapEntry(opt.nextID(), key, value, isOptional) -} - -// NewHasMacro generates a test-only select expression to be included within an AST and an unexpanded -// has() macro call signature to be inserted into the source info macro call metadata. -func (opt *optimizerExprFactory) NewHasMacro(macroID int64, s ast.Expr) (astExpr, macroExpr ast.Expr) { - sel := s.AsSelect() - astExpr = opt.fac.NewPresenceTest(macroID, sel.Operand(), sel.FieldName()) - macroExpr = opt.fac.NewCall(0, "has", - opt.NewSelect(opt.fac.CopyExpr(sel.Operand()), sel.FieldName())) - opt.sanitizeMacro(macroID, macroExpr) - return -} - -// NewSelect creates a select expression where a field value is selected from an operand. -// -// Example: -// -// msg.field_name -// - operand: msg -// - field: field_name -func (opt *optimizerExprFactory) NewSelect(operand ast.Expr, field string) ast.Expr { - return opt.fac.NewSelect(opt.nextID(), operand, field) -} - -// NewStruct creates a new typed struct value with an set of field initializations. -// -// Example: -// -// pkg.TypeName{field: value} -// - typeName: pkg.TypeName -// - fields: [{field: value}] -func (opt *optimizerExprFactory) NewStruct(typeName string, fields []ast.EntryExpr) ast.Expr { - return opt.fac.NewStruct(opt.nextID(), typeName, fields) -} - -// NewStructField creates a struct field initialization. -// -// Examples: -// -// {count: 3u} -// - field: count -// - value: 3u -// - optional: false -// -// {?count: x} -// - field: count -// - value: x -// - optional: true -func (opt *optimizerExprFactory) NewStructField(field string, value ast.Expr, isOptional bool) ast.EntryExpr { - return opt.fac.NewStructField(opt.nextID(), field, value, isOptional) -} - -// UpdateExpr updates the target expression with the updated content while preserving macro metadata. -// -// There are four scenarios during the update to consider: -// 1. target is not macro, updated is not macro -// 2. target is macro, updated is not macro -// 3. target is macro, updated is macro -// 4. target is not macro, updated is macro -// -// When the target is a macro already, it may either be updated to a new macro function -// body if the update is also a macro, or it may be removed altogether if the update is -// a macro. -// -// When the update is a macro, then the target references within other macros must be -// updated to point to the new updated macro. Otherwise, other macros which pointed to -// the target body must be replaced with copies of the updated expression body. -func (opt *optimizerExprFactory) UpdateExpr(target, updated ast.Expr) { - // Update the expression - target.SetKindCase(updated) - - // Early return if there's no macros present sa the source info reflects the - // macro set from the target and updated expressions. - if len(opt.sourceInfo.MacroCalls()) == 0 { - return - } - // Determine whether the target expression was a macro. - _, targetIsMacro := opt.sourceInfo.GetMacroCall(target.ID()) - - // Determine whether the updated expression was a macro. - updatedMacro, updatedIsMacro := opt.sourceInfo.GetMacroCall(updated.ID()) - - if updatedIsMacro { - // If the updated call was a macro, then updated id maps to target id, - // and the updated macro moves into the target id slot. - opt.sourceInfo.ClearMacroCall(updated.ID()) - opt.sourceInfo.SetMacroCall(target.ID(), updatedMacro) - } else if targetIsMacro { - // Otherwise if the target expr was a macro, but is no longer, clear - // the macro reference. - opt.sourceInfo.ClearMacroCall(target.ID()) - } - - // Punch holes in the updated value where macros references exist. - macroExpr := opt.fac.CopyExpr(target) - macroRefVisitor := ast.NewExprVisitor(func(e ast.Expr) { - if _, exists := opt.sourceInfo.GetMacroCall(e.ID()); exists { - e.SetKindCase(nil) - } - }) - ast.PostOrderVisit(macroExpr, macroRefVisitor) - - // Update any references to the expression within a macro - macroVisitor := ast.NewExprVisitor(func(call ast.Expr) { - // Update the target expression to point to the macro expression which - // will be empty if the updated expression was a macro. - if call.ID() == target.ID() { - call.SetKindCase(opt.fac.CopyExpr(macroExpr)) - } - // Update the macro call expression if it refers to the updated expression - // id which has since been remapped to the target id. - if call.ID() == updated.ID() { - // Either ensure the expression is a macro reference or a populated with - // the relevant sub-expression if the updated expr was not a macro. - if updatedIsMacro { - call.SetKindCase(nil) - } else { - call.SetKindCase(opt.fac.CopyExpr(macroExpr)) - } - // Since SetKindCase does not renumber the id, ensure the references to - // the old 'updated' id are mapped to the target id. - call.RenumberIDs(func(id int64) int64 { - if id == updated.ID() { - return target.ID() - } - return id - }) - } - }) - for _, call := range opt.sourceInfo.MacroCalls() { - ast.PostOrderVisit(call, macroVisitor) - } -} - -func (opt *optimizerExprFactory) sanitizeMacro(macroID int64, macroExpr ast.Expr) { - macroRefVisitor := ast.NewExprVisitor(func(e ast.Expr) { - if _, exists := opt.sourceInfo.GetMacroCall(e.ID()); exists && e.ID() != macroID { - e.SetKindCase(nil) - } - }) - ast.PostOrderVisit(macroExpr, macroRefVisitor) -} diff --git a/vendor/github.com/google/cel-go/cel/options.go b/vendor/github.com/google/cel-go/cel/options.go deleted file mode 100644 index 3c53e21af..000000000 --- a/vendor/github.com/google/cel-go/cel/options.go +++ /dev/null @@ -1,661 +0,0 @@ -// Copyright 2019 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package cel - -import ( - "fmt" - - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/reflect/protodesc" - "google.golang.org/protobuf/reflect/protoreflect" - "google.golang.org/protobuf/reflect/protoregistry" - "google.golang.org/protobuf/types/dynamicpb" - - "github.com/google/cel-go/checker" - "github.com/google/cel-go/common/containers" - "github.com/google/cel-go/common/functions" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/common/types/pb" - "github.com/google/cel-go/common/types/ref" - "github.com/google/cel-go/interpreter" - "github.com/google/cel-go/parser" - - exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1" - descpb "google.golang.org/protobuf/types/descriptorpb" -) - -// These constants beginning with "Feature" enable optional behavior in -// the library. See the documentation for each constant to see its -// effects, compatibility restrictions, and standard conformance. -const ( - _ = iota - - // Enable the tracking of function call expressions replaced by macros. - featureEnableMacroCallTracking - - // Enable the use of cross-type numeric comparisons at the type-checker. - featureCrossTypeNumericComparisons - - // Enable eager validation of declarations to ensure that Env values created - // with `Extend` inherit a validated list of declarations from the parent Env. - featureEagerlyValidateDeclarations - - // Enable the use of the default UTC timezone when a timezone is not specified - // on a CEL timestamp operation. This fixes the scenario where the input time - // is not already in UTC. - featureDefaultUTCTimeZone - - // Enable the serialization of logical operator ASTs as variadic calls, thus - // compressing the logic graph to a single call when multiple like-operator - // expressions occur: e.g. a && b && c && d -> call(_&&_, [a, b, c, d]) - featureVariadicLogicalASTs -) - -// EnvOption is a functional interface for configuring the environment. -type EnvOption func(e *Env) (*Env, error) - -// ClearMacros options clears all parser macros. -// -// Clearing macros will ensure CEL expressions can only contain linear evaluation paths, as -// comprehensions such as `all` and `exists` are enabled only via macros. -func ClearMacros() EnvOption { - return func(e *Env) (*Env, error) { - e.macros = NoMacros - return e, nil - } -} - -// CustomTypeAdapter swaps the default types.Adapter implementation with a custom one. -// -// Note: This option must be specified before the Types and TypeDescs options when used together. -func CustomTypeAdapter(adapter types.Adapter) EnvOption { - return func(e *Env) (*Env, error) { - e.adapter = adapter - return e, nil - } -} - -// CustomTypeProvider replaces the types.Provider implementation with a custom one. -// -// The `provider` variable type may either be types.Provider or ref.TypeProvider (deprecated) -// -// Note: This option must be specified before the Types and TypeDescs options when used together. -func CustomTypeProvider(provider any) EnvOption { - return func(e *Env) (*Env, error) { - var err error - e.provider, err = maybeInteropProvider(provider) - return e, err - } -} - -// Declarations option extends the declaration set configured in the environment. -// -// Note: Declarations will by default be appended to the pre-existing declaration set configured -// for the environment. The NewEnv call builds on top of the standard CEL declarations. For a -// purely custom set of declarations use NewCustomEnv. -func Declarations(decls ...*exprpb.Decl) EnvOption { - declOpts := []EnvOption{} - var err error - var opt EnvOption - // Convert the declarations to `EnvOption` values ahead of time. - // Surface any errors in conversion when the options are applied. - for _, d := range decls { - opt, err = ExprDeclToDeclaration(d) - if err != nil { - break - } - declOpts = append(declOpts, opt) - } - return func(e *Env) (*Env, error) { - if err != nil { - return nil, err - } - for _, o := range declOpts { - e, err = o(e) - if err != nil { - return nil, err - } - } - return e, nil - } -} - -// EagerlyValidateDeclarations ensures that any collisions between configured declarations are caught -// at the time of the `NewEnv` call. -// -// Eagerly validating declarations is also useful for bootstrapping a base `cel.Env` value. -// Calls to base `Env.Extend()` will be significantly faster when declarations are eagerly validated -// as declarations will be collision-checked at most once and only incrementally by way of `Extend` -// -// Disabled by default as not all environments are used for type-checking. -func EagerlyValidateDeclarations(enabled bool) EnvOption { - return features(featureEagerlyValidateDeclarations, enabled) -} - -// HomogeneousAggregateLiterals disables mixed type list and map literal values. -// -// Note, it is still possible to have heterogeneous aggregates when provided as variables to the -// expression, as well as via conversion of well-known dynamic types, or with unchecked -// expressions. -func HomogeneousAggregateLiterals() EnvOption { - return ASTValidators(ValidateHomogeneousAggregateLiterals()) -} - -// variadicLogicalOperatorASTs flatten like-operator chained logical expressions into a single -// variadic call with N-terms. This behavior is useful when serializing to a protocol buffer as -// it will reduce the number of recursive calls needed to deserialize the AST later. -// -// For example, given the following expression the call graph will be rendered accordingly: -// -// expression: a && b && c && (d || e) -// ast: call(_&&_, [a, b, c, call(_||_, [d, e])]) -func variadicLogicalOperatorASTs() EnvOption { - return features(featureVariadicLogicalASTs, true) -} - -// Macros option extends the macro set configured in the environment. -// -// Note: This option must be specified after ClearMacros if used together. -func Macros(macros ...Macro) EnvOption { - return func(e *Env) (*Env, error) { - e.macros = append(e.macros, macros...) - return e, nil - } -} - -// Container sets the container for resolving variable names. Defaults to an empty container. -// -// If all references within an expression are relative to a protocol buffer package, then -// specifying a container of `google.type` would make it possible to write expressions such as -// `Expr{expression: 'a < b'}` instead of having to write `google.type.Expr{...}`. -func Container(name string) EnvOption { - return func(e *Env) (*Env, error) { - cont, err := e.Container.Extend(containers.Name(name)) - if err != nil { - return nil, err - } - e.Container = cont - return e, nil - } -} - -// Abbrevs configures a set of simple names as abbreviations for fully-qualified names. -// -// An abbreviation (abbrev for short) is a simple name that expands to a fully-qualified name. -// Abbreviations can be useful when working with variables, functions, and especially types from -// multiple namespaces: -// -// // CEL object construction -// qual.pkg.version.ObjTypeName{ -// field: alt.container.ver.FieldTypeName{value: ...} -// } -// -// Only one the qualified names above may be used as the CEL container, so at least one of these -// references must be a long qualified name within an otherwise short CEL program. Using the -// following abbreviations, the program becomes much simpler: -// -// // CEL Go option -// Abbrevs("qual.pkg.version.ObjTypeName", "alt.container.ver.FieldTypeName") -// // Simplified Object construction -// ObjTypeName{field: FieldTypeName{value: ...}} -// -// There are a few rules for the qualified names and the simple abbreviations generated from them: -// - Qualified names must be dot-delimited, e.g. `package.subpkg.name`. -// - The last element in the qualified name is the abbreviation. -// - Abbreviations must not collide with each other. -// - The abbreviation must not collide with unqualified names in use. -// -// Abbreviations are distinct from container-based references in the following important ways: -// - Abbreviations must expand to a fully-qualified name. -// - Expanded abbreviations do not participate in namespace resolution. -// - Abbreviation expansion is done instead of the container search for a matching identifier. -// - Containers follow C++ namespace resolution rules with searches from the most qualified name -// -// to the least qualified name. -// -// - Container references within the CEL program may be relative, and are resolved to fully -// -// qualified names at either type-check time or program plan time, whichever comes first. -// -// If there is ever a case where an identifier could be in both the container and as an -// abbreviation, the abbreviation wins as this will ensure that the meaning of a program is -// preserved between compilations even as the container evolves. -func Abbrevs(qualifiedNames ...string) EnvOption { - return func(e *Env) (*Env, error) { - cont, err := e.Container.Extend(containers.Abbrevs(qualifiedNames...)) - if err != nil { - return nil, err - } - e.Container = cont - return e, nil - } -} - -// Types adds one or more type declarations to the environment, allowing for construction of -// type-literals whose definitions are included in the common expression built-in set. -// -// The input types may either be instances of `proto.Message` or `ref.Type`. Any other type -// provided to this option will result in an error. -// -// Well-known protobuf types within the `google.protobuf.*` package are included in the standard -// environment by default. -// -// Note: This option must be specified after the CustomTypeProvider option when used together. -func Types(addTypes ...any) EnvOption { - return func(e *Env) (*Env, error) { - var reg ref.TypeRegistry - var isReg bool - reg, isReg = e.provider.(*types.Registry) - if !isReg { - reg, isReg = e.provider.(ref.TypeRegistry) - } - if !isReg { - return nil, fmt.Errorf("custom types not supported by provider: %T", e.provider) - } - for _, t := range addTypes { - switch v := t.(type) { - case proto.Message: - fdMap := pb.CollectFileDescriptorSet(v) - for _, fd := range fdMap { - err := reg.RegisterDescriptor(fd) - if err != nil { - return nil, err - } - } - case ref.Type: - err := reg.RegisterType(v) - if err != nil { - return nil, err - } - default: - return nil, fmt.Errorf("unsupported type: %T", t) - } - } - return e, nil - } -} - -// TypeDescs adds type declarations from any protoreflect.FileDescriptor, protoregistry.Files, -// google.protobuf.FileDescriptorProto or google.protobuf.FileDescriptorSet provided. -// -// Note that messages instantiated from these descriptors will be *dynamicpb.Message values -// rather than the concrete message type. -// -// TypeDescs are hermetic to a single Env object, but may be copied to other Env values via -// extension or by re-using the same EnvOption with another NewEnv() call. -func TypeDescs(descs ...any) EnvOption { - return func(e *Env) (*Env, error) { - reg, isReg := e.provider.(ref.TypeRegistry) - if !isReg { - return nil, fmt.Errorf("custom types not supported by provider: %T", e.provider) - } - // Scan the input descriptors for FileDescriptorProto messages and accumulate them into a - // synthetic FileDescriptorSet as the FileDescriptorProto messages may refer to each other - // and will not resolve properly unless they are part of the same set. - var fds *descpb.FileDescriptorSet - for _, d := range descs { - switch f := d.(type) { - case *descpb.FileDescriptorProto: - if fds == nil { - fds = &descpb.FileDescriptorSet{ - File: []*descpb.FileDescriptorProto{}, - } - } - fds.File = append(fds.File, f) - } - } - if fds != nil { - if err := registerFileSet(reg, fds); err != nil { - return nil, err - } - } - for _, d := range descs { - switch f := d.(type) { - case *protoregistry.Files: - if err := registerFiles(reg, f); err != nil { - return nil, err - } - case protoreflect.FileDescriptor: - if err := reg.RegisterDescriptor(f); err != nil { - return nil, err - } - case *descpb.FileDescriptorSet: - if err := registerFileSet(reg, f); err != nil { - return nil, err - } - case *descpb.FileDescriptorProto: - // skip, handled as a synthetic file descriptor set. - default: - return nil, fmt.Errorf("unsupported type descriptor: %T", d) - } - } - return e, nil - } -} - -func registerFileSet(reg ref.TypeRegistry, fileSet *descpb.FileDescriptorSet) error { - files, err := protodesc.NewFiles(fileSet) - if err != nil { - return fmt.Errorf("protodesc.NewFiles(%v) failed: %v", fileSet, err) - } - return registerFiles(reg, files) -} - -func registerFiles(reg ref.TypeRegistry, files *protoregistry.Files) error { - var err error - files.RangeFiles(func(fd protoreflect.FileDescriptor) bool { - err = reg.RegisterDescriptor(fd) - return err == nil - }) - return err -} - -// ProgramOption is a functional interface for configuring evaluation bindings and behaviors. -type ProgramOption func(p *prog) (*prog, error) - -// CustomDecorator appends an InterpreterDecorator to the program. -// -// InterpretableDecorators can be used to inspect, alter, or replace the Program plan. -func CustomDecorator(dec interpreter.InterpretableDecorator) ProgramOption { - return func(p *prog) (*prog, error) { - p.decorators = append(p.decorators, dec) - return p, nil - } -} - -// Functions adds function overloads that extend or override the set of CEL built-ins. -// -// Deprecated: use Function() instead to declare the function, its overload signatures, -// and the overload implementations. -func Functions(funcs ...*functions.Overload) ProgramOption { - return func(p *prog) (*prog, error) { - if err := p.dispatcher.Add(funcs...); err != nil { - return nil, err - } - return p, nil - } -} - -// Globals sets the global variable values for a given program. These values may be shadowed by -// variables with the same name provided to the Eval() call. If Globals is used in a Library with -// a Lib EnvOption, vars may shadow variables provided by previously added libraries. -// -// The vars value may either be an `interpreter.Activation` instance or a `map[string]any`. -func Globals(vars any) ProgramOption { - return func(p *prog) (*prog, error) { - defaultVars, err := interpreter.NewActivation(vars) - if err != nil { - return nil, err - } - if p.defaultVars != nil { - defaultVars = interpreter.NewHierarchicalActivation(p.defaultVars, defaultVars) - } - p.defaultVars = defaultVars - return p, nil - } -} - -// OptimizeRegex provides a way to replace the InterpretableCall for regex functions. This can be used -// to compile regex string constants at program creation time and report any errors and then use the -// compiled regex for all regex function invocations. -func OptimizeRegex(regexOptimizations ...*interpreter.RegexOptimization) ProgramOption { - return func(p *prog) (*prog, error) { - p.regexOptimizations = append(p.regexOptimizations, regexOptimizations...) - return p, nil - } -} - -// EvalOption indicates an evaluation option that may affect the evaluation behavior or information -// in the output result. -type EvalOption int - -const ( - // OptTrackState will cause the runtime to return an immutable EvalState value in the Result. - OptTrackState EvalOption = 1 << iota - - // OptExhaustiveEval causes the runtime to disable short-circuits and track state. - OptExhaustiveEval EvalOption = 1< 0 { - decorators = append(decorators, interpreter.InterruptableEval()) - } - // Enable constant folding first. - if p.evalOpts&OptOptimize == OptOptimize { - decorators = append(decorators, interpreter.Optimize()) - p.regexOptimizations = append(p.regexOptimizations, interpreter.MatchesRegexOptimization) - } - // Enable regex compilation of constants immediately after folding constants. - if len(p.regexOptimizations) > 0 { - decorators = append(decorators, interpreter.CompileRegexConstants(p.regexOptimizations...)) - } - - // Enable exhaustive eval, state tracking and cost tracking last since they require a factory. - if p.evalOpts&(OptExhaustiveEval|OptTrackState|OptTrackCost) != 0 { - factory := func(state interpreter.EvalState, costTracker *interpreter.CostTracker) (Program, error) { - costTracker.Estimator = p.callCostEstimator - costTracker.Limit = p.costLimit - for _, costOpt := range p.costOptions { - err := costOpt(costTracker) - if err != nil { - return nil, err - } - } - // Limit capacity to guarantee a reallocation when calling 'append(decs, ...)' below. This - // prevents the underlying memory from being shared between factory function calls causing - // undesired mutations. - decs := decorators[:len(decorators):len(decorators)] - var observers []interpreter.EvalObserver - - if p.evalOpts&(OptExhaustiveEval|OptTrackState) != 0 { - // EvalStateObserver is required for OptExhaustiveEval. - observers = append(observers, interpreter.EvalStateObserver(state)) - } - if p.evalOpts&OptTrackCost == OptTrackCost { - observers = append(observers, interpreter.CostObserver(costTracker)) - } - - // Enable exhaustive eval over a basic observer since it offers a superset of features. - if p.evalOpts&OptExhaustiveEval == OptExhaustiveEval { - decs = append(decs, interpreter.ExhaustiveEval(), interpreter.Observe(observers...)) - } else if len(observers) > 0 { - decs = append(decs, interpreter.Observe(observers...)) - } - - return p.clone().initInterpretable(a, decs) - } - return newProgGen(factory) - } - return p.initInterpretable(a, decorators) -} - -func (p *prog) initInterpretable(a *Ast, decs []interpreter.InterpretableDecorator) (*prog, error) { - // When the AST has been exprAST it contains metadata that can be used to speed up program execution. - interpretable, err := p.interpreter.NewInterpretable(a.impl, decs...) - if err != nil { - return nil, err - } - p.interpretable = interpretable - return p, nil -} - -// Eval implements the Program interface method. -func (p *prog) Eval(input any) (v ref.Val, det *EvalDetails, err error) { - // Configure error recovery for unexpected panics during evaluation. Note, the use of named - // return values makes it possible to modify the error response during the recovery - // function. - defer func() { - if r := recover(); r != nil { - switch t := r.(type) { - case interpreter.EvalCancelledError: - err = t - default: - err = fmt.Errorf("internal error: %v", r) - } - } - }() - // Build a hierarchical activation if there are default vars set. - var vars interpreter.Activation - switch v := input.(type) { - case interpreter.Activation: - vars = v - case map[string]any: - vars = activationPool.Setup(v) - defer activationPool.Put(vars) - default: - return nil, nil, fmt.Errorf("invalid input, wanted Activation or map[string]any, got: (%T)%v", input, input) - } - if p.defaultVars != nil { - vars = interpreter.NewHierarchicalActivation(p.defaultVars, vars) - } - v = p.interpretable.Eval(vars) - // The output of an internal Eval may have a value (`v`) that is a types.Err. This step - // translates the CEL value to a Go error response. This interface does not quite match the - // RPC signature which allows for multiple errors to be returned, but should be sufficient. - if types.IsError(v) { - err = v.(*types.Err) - } - return -} - -// ContextEval implements the Program interface. -func (p *prog) ContextEval(ctx context.Context, input any) (ref.Val, *EvalDetails, error) { - if ctx == nil { - return nil, nil, fmt.Errorf("context can not be nil") - } - // Configure the input, making sure to wrap Activation inputs in the special ctxActivation which - // exposes the #interrupted variable and manages rate-limited checks of the ctx.Done() state. - var vars interpreter.Activation - switch v := input.(type) { - case interpreter.Activation: - vars = ctxActivationPool.Setup(v, ctx.Done(), p.interruptCheckFrequency) - defer ctxActivationPool.Put(vars) - case map[string]any: - rawVars := activationPool.Setup(v) - defer activationPool.Put(rawVars) - vars = ctxActivationPool.Setup(rawVars, ctx.Done(), p.interruptCheckFrequency) - defer ctxActivationPool.Put(vars) - default: - return nil, nil, fmt.Errorf("invalid input, wanted Activation or map[string]any, got: (%T)%v", input, input) - } - return p.Eval(vars) -} - -// progFactory is a helper alias for marking a program creation factory function. -type progFactory func(interpreter.EvalState, *interpreter.CostTracker) (Program, error) - -// progGen holds a reference to a progFactory instance and implements the Program interface. -type progGen struct { - factory progFactory -} - -// newProgGen tests the factory object by calling it once and returns a factory-based Program if -// the test is successful. -func newProgGen(factory progFactory) (Program, error) { - // Test the factory to make sure that configuration errors are spotted at config - tracker, err := interpreter.NewCostTracker(nil) - if err != nil { - return nil, err - } - _, err = factory(interpreter.NewEvalState(), tracker) - if err != nil { - return nil, err - } - return &progGen{factory: factory}, nil -} - -// Eval implements the Program interface method. -func (gen *progGen) Eval(input any) (ref.Val, *EvalDetails, error) { - // The factory based Eval() differs from the standard evaluation model in that it generates a - // new EvalState instance for each call to ensure that unique evaluations yield unique stateful - // results. - state := interpreter.NewEvalState() - costTracker, err := interpreter.NewCostTracker(nil) - if err != nil { - return nil, nil, err - } - det := &EvalDetails{state: state, costTracker: costTracker} - - // Generate a new instance of the interpretable using the factory configured during the call to - // newProgram(). It is incredibly unlikely that the factory call will generate an error given - // the factory test performed within the Program() call. - p, err := gen.factory(state, costTracker) - if err != nil { - return nil, det, err - } - - // Evaluate the input, returning the result and the 'state' within EvalDetails. - v, _, err := p.Eval(input) - if err != nil { - return v, det, err - } - return v, det, nil -} - -// ContextEval implements the Program interface method. -func (gen *progGen) ContextEval(ctx context.Context, input any) (ref.Val, *EvalDetails, error) { - if ctx == nil { - return nil, nil, fmt.Errorf("context can not be nil") - } - // The factory based Eval() differs from the standard evaluation model in that it generates a - // new EvalState instance for each call to ensure that unique evaluations yield unique stateful - // results. - state := interpreter.NewEvalState() - costTracker, err := interpreter.NewCostTracker(nil) - if err != nil { - return nil, nil, err - } - det := &EvalDetails{state: state, costTracker: costTracker} - - // Generate a new instance of the interpretable using the factory configured during the call to - // newProgram(). It is incredibly unlikely that the factory call will generate an error given - // the factory test performed within the Program() call. - p, err := gen.factory(state, costTracker) - if err != nil { - return nil, det, err - } - - // Evaluate the input, returning the result and the 'state' within EvalDetails. - v, _, err := p.ContextEval(ctx, input) - if err != nil { - return v, det, err - } - return v, det, nil -} - -type ctxEvalActivation struct { - parent interpreter.Activation - interrupt <-chan struct{} - interruptCheckCount uint - interruptCheckFrequency uint -} - -// ResolveName implements the Activation interface method, but adds a special #interrupted variable -// which is capable of testing whether a 'done' signal is provided from a context.Context channel. -func (a *ctxEvalActivation) ResolveName(name string) (any, bool) { - if name == "#interrupted" { - a.interruptCheckCount++ - if a.interruptCheckCount%a.interruptCheckFrequency == 0 { - select { - case <-a.interrupt: - return true, true - default: - return nil, false - } - } - return nil, false - } - return a.parent.ResolveName(name) -} - -func (a *ctxEvalActivation) Parent() interpreter.Activation { - return a.parent -} - -func newCtxEvalActivationPool() *ctxEvalActivationPool { - return &ctxEvalActivationPool{ - Pool: sync.Pool{ - New: func() any { - return &ctxEvalActivation{} - }, - }, - } -} - -type ctxEvalActivationPool struct { - sync.Pool -} - -// Setup initializes a pooled Activation with the ability check for context.Context cancellation -func (p *ctxEvalActivationPool) Setup(vars interpreter.Activation, done <-chan struct{}, interruptCheckRate uint) *ctxEvalActivation { - a := p.Pool.Get().(*ctxEvalActivation) - a.parent = vars - a.interrupt = done - a.interruptCheckCount = 0 - a.interruptCheckFrequency = interruptCheckRate - return a -} - -type evalActivation struct { - vars map[string]any - lazyVars map[string]any -} - -// ResolveName looks up the value of the input variable name, if found. -// -// Lazy bindings may be supplied within the map-based input in either of the following forms: -// - func() any -// - func() ref.Val -// -// The lazy binding will only be invoked once per evaluation. -// -// Values which are not represented as ref.Val types on input may be adapted to a ref.Val using -// the types.Adapter configured in the environment. -func (a *evalActivation) ResolveName(name string) (any, bool) { - v, found := a.vars[name] - if !found { - return nil, false - } - switch obj := v.(type) { - case func() ref.Val: - if resolved, found := a.lazyVars[name]; found { - return resolved, true - } - lazy := obj() - a.lazyVars[name] = lazy - return lazy, true - case func() any: - if resolved, found := a.lazyVars[name]; found { - return resolved, true - } - lazy := obj() - a.lazyVars[name] = lazy - return lazy, true - default: - return obj, true - } -} - -// Parent implements the interpreter.Activation interface -func (a *evalActivation) Parent() interpreter.Activation { - return nil -} - -func newEvalActivationPool() *evalActivationPool { - return &evalActivationPool{ - Pool: sync.Pool{ - New: func() any { - return &evalActivation{lazyVars: make(map[string]any)} - }, - }, - } -} - -type evalActivationPool struct { - sync.Pool -} - -// Setup initializes a pooled Activation object with the map input. -func (p *evalActivationPool) Setup(vars map[string]any) *evalActivation { - a := p.Pool.Get().(*evalActivation) - a.vars = vars - return a -} - -func (p *evalActivationPool) Put(value any) { - a := value.(*evalActivation) - for k := range a.lazyVars { - delete(a.lazyVars, k) - } - p.Pool.Put(a) -} - -var ( - // activationPool is an internally managed pool of Activation values that wrap map[string]any inputs - activationPool = newEvalActivationPool() - - // ctxActivationPool is an internally managed pool of Activation values that expose a special #interrupted variable - ctxActivationPool = newCtxEvalActivationPool() -) diff --git a/vendor/github.com/google/cel-go/cel/validator.go b/vendor/github.com/google/cel-go/cel/validator.go deleted file mode 100644 index b50c67452..000000000 --- a/vendor/github.com/google/cel-go/cel/validator.go +++ /dev/null @@ -1,375 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package cel - -import ( - "fmt" - "reflect" - "regexp" - - "github.com/google/cel-go/common/ast" - "github.com/google/cel-go/common/overloads" -) - -const ( - homogeneousValidatorName = "cel.lib.std.validate.types.homogeneous" - - // HomogeneousAggregateLiteralExemptFunctions is the ValidatorConfig key used to configure - // the set of function names which are exempt from homogeneous type checks. The expected type - // is a string list of function names. - // - // As an example, the `.format([args])` call expects the input arguments list to be - // comprised of a variety of types which correspond to the types expected by the format control - // clauses; however, all other uses of a mixed element type list, would be unexpected. - HomogeneousAggregateLiteralExemptFunctions = homogeneousValidatorName + ".exempt" -) - -// ASTValidators configures a set of ASTValidator instances into the target environment. -// -// Validators are applied in the order in which the are specified and are treated as singletons. -// The same ASTValidator with a given name will not be applied more than once. -func ASTValidators(validators ...ASTValidator) EnvOption { - return func(e *Env) (*Env, error) { - for _, v := range validators { - if !e.HasValidator(v.Name()) { - e.validators = append(e.validators, v) - } - } - return e, nil - } -} - -// ASTValidator defines a singleton interface for validating a type-checked Ast against an environment. -// -// Note: the Issues argument is mutable in the sense that it is intended to collect errors which will be -// reported to the caller. -type ASTValidator interface { - // Name returns the name of the validator. Names must be unique. - Name() string - - // Validate validates a given Ast within an Environment and collects a set of potential issues. - // - // The ValidatorConfig is generated from the set of ASTValidatorConfigurer instances prior to - // the invocation of the Validate call. The expectation is that the validator configuration - // is created in sequence and immutable once provided to the Validate call. - // - // See individual validators for more information on their configuration keys and configuration - // properties. - Validate(*Env, ValidatorConfig, *ast.AST, *Issues) -} - -// ValidatorConfig provides an accessor method for querying validator configuration state. -type ValidatorConfig interface { - GetOrDefault(name string, value any) any -} - -// MutableValidatorConfig provides mutation methods for querying and updating validator configuration -// settings. -type MutableValidatorConfig interface { - ValidatorConfig - Set(name string, value any) error -} - -// ASTValidatorConfigurer indicates that this object, currently expected to be an ASTValidator, -// participates in validator configuration settings. -// -// This interface may be split from the expectation of being an ASTValidator instance in the future. -type ASTValidatorConfigurer interface { - Configure(MutableValidatorConfig) error -} - -// validatorConfig implements the ValidatorConfig and MutableValidatorConfig interfaces. -type validatorConfig struct { - data map[string]any -} - -// newValidatorConfig initializes the validator config with default values for core CEL validators. -func newValidatorConfig() *validatorConfig { - return &validatorConfig{ - data: map[string]any{ - HomogeneousAggregateLiteralExemptFunctions: []string{}, - }, - } -} - -// GetOrDefault returns the configured value for the name, if present, else the input default value. -// -// Note, the type-agreement between the input default and configured value is not checked on read. -func (config *validatorConfig) GetOrDefault(name string, value any) any { - v, found := config.data[name] - if !found { - return value - } - return v -} - -// Set configures a validator option with the given name and value. -// -// If the value had previously been set, the new value must have the same reflection type as the old one, -// or the call will error. -func (config *validatorConfig) Set(name string, value any) error { - v, found := config.data[name] - if found && reflect.TypeOf(v) != reflect.TypeOf(value) { - return fmt.Errorf("incompatible configuration type for %s, got %T, wanted %T", name, value, v) - } - config.data[name] = value - return nil -} - -// ExtendedValidations collects a set of common AST validations which reduce the likelihood of runtime errors. -// -// - Validate duration and timestamp literals -// - Ensure regex strings are valid -// - Disable mixed type list and map literals -func ExtendedValidations() EnvOption { - return ASTValidators( - ValidateDurationLiterals(), - ValidateTimestampLiterals(), - ValidateRegexLiterals(), - ValidateHomogeneousAggregateLiterals(), - ) -} - -// ValidateDurationLiterals ensures that duration literal arguments are valid immediately after type-check. -func ValidateDurationLiterals() ASTValidator { - return newFormatValidator(overloads.TypeConvertDuration, 0, evalCall) -} - -// ValidateTimestampLiterals ensures that timestamp literal arguments are valid immediately after type-check. -func ValidateTimestampLiterals() ASTValidator { - return newFormatValidator(overloads.TypeConvertTimestamp, 0, evalCall) -} - -// ValidateRegexLiterals ensures that regex patterns are validated after type-check. -func ValidateRegexLiterals() ASTValidator { - return newFormatValidator(overloads.Matches, 0, compileRegex) -} - -// ValidateHomogeneousAggregateLiterals checks that all list and map literals entries have the same types, i.e. -// no mixed list element types or mixed map key or map value types. -// -// Note: the string format call relies on a mixed element type list for ease of use, so this check skips all -// literals which occur within string format calls. -func ValidateHomogeneousAggregateLiterals() ASTValidator { - return homogeneousAggregateLiteralValidator{} -} - -// ValidateComprehensionNestingLimit ensures that comprehension nesting does not exceed the specified limit. -// -// This validator can be useful for preventing arbitrarily nested comprehensions which can take high polynomial -// time to complete. -// -// Note, this limit does not apply to comprehensions with an empty iteration range, as these comprehensions have -// no actual looping cost. The cel.bind() utilizes the comprehension structure to perform local variable -// assignments and supplies an empty iteration range, so they won't count against the nesting limit either. -func ValidateComprehensionNestingLimit(limit int) ASTValidator { - return nestingLimitValidator{limit: limit} -} - -type argChecker func(env *Env, call, arg ast.Expr) error - -func newFormatValidator(funcName string, argNum int, check argChecker) formatValidator { - return formatValidator{ - funcName: funcName, - check: check, - argNum: argNum, - } -} - -type formatValidator struct { - funcName string - argNum int - check argChecker -} - -// Name returns the unique name of this function format validator. -func (v formatValidator) Name() string { - return fmt.Sprintf("cel.lib.std.validate.functions.%s", v.funcName) -} - -// Validate searches the AST for uses of a given function name with a constant argument and performs a check -// on whether the argument is a valid literal value. -func (v formatValidator) Validate(e *Env, _ ValidatorConfig, a *ast.AST, iss *Issues) { - root := ast.NavigateAST(a) - funcCalls := ast.MatchDescendants(root, ast.FunctionMatcher(v.funcName)) - for _, call := range funcCalls { - callArgs := call.AsCall().Args() - if len(callArgs) <= v.argNum { - continue - } - litArg := callArgs[v.argNum] - if litArg.Kind() != ast.LiteralKind { - continue - } - if err := v.check(e, call, litArg); err != nil { - iss.ReportErrorAtID(litArg.ID(), "invalid %s argument", v.funcName) - } - } -} - -func evalCall(env *Env, call, arg ast.Expr) error { - ast := &Ast{impl: ast.NewAST(call, ast.NewSourceInfo(nil))} - prg, err := env.Program(ast) - if err != nil { - return err - } - _, _, err = prg.Eval(NoVars()) - return err -} - -func compileRegex(_ *Env, _, arg ast.Expr) error { - pattern := arg.AsLiteral().Value().(string) - _, err := regexp.Compile(pattern) - return err -} - -type homogeneousAggregateLiteralValidator struct{} - -// Name returns the unique name of the homogeneous type validator. -func (homogeneousAggregateLiteralValidator) Name() string { - return homogeneousValidatorName -} - -// Validate validates that all lists and map literals have homogeneous types, i.e. don't contain dyn types. -// -// This validator makes an exception for list and map literals which occur at any level of nesting within -// string format calls. -func (v homogeneousAggregateLiteralValidator) Validate(_ *Env, c ValidatorConfig, a *ast.AST, iss *Issues) { - var exemptedFunctions []string - exemptedFunctions = c.GetOrDefault(HomogeneousAggregateLiteralExemptFunctions, exemptedFunctions).([]string) - root := ast.NavigateAST(a) - listExprs := ast.MatchDescendants(root, ast.KindMatcher(ast.ListKind)) - for _, listExpr := range listExprs { - if inExemptFunction(listExpr, exemptedFunctions) { - continue - } - l := listExpr.AsList() - elements := l.Elements() - optIndices := l.OptionalIndices() - var elemType *Type - for i, e := range elements { - et := a.GetType(e.ID()) - if isOptionalIndex(i, optIndices) { - et = et.Parameters()[0] - } - if elemType == nil { - elemType = et - continue - } - if !elemType.IsEquivalentType(et) { - v.typeMismatch(iss, e.ID(), elemType, et) - break - } - } - } - mapExprs := ast.MatchDescendants(root, ast.KindMatcher(ast.MapKind)) - for _, mapExpr := range mapExprs { - if inExemptFunction(mapExpr, exemptedFunctions) { - continue - } - m := mapExpr.AsMap() - entries := m.Entries() - var keyType, valType *Type - for _, e := range entries { - mapEntry := e.AsMapEntry() - key, val := mapEntry.Key(), mapEntry.Value() - kt, vt := a.GetType(key.ID()), a.GetType(val.ID()) - if mapEntry.IsOptional() { - vt = vt.Parameters()[0] - } - if keyType == nil && valType == nil { - keyType, valType = kt, vt - continue - } - if !keyType.IsEquivalentType(kt) { - v.typeMismatch(iss, key.ID(), keyType, kt) - } - if !valType.IsEquivalentType(vt) { - v.typeMismatch(iss, val.ID(), valType, vt) - } - } - } -} - -func inExemptFunction(e ast.NavigableExpr, exemptFunctions []string) bool { - parent, found := e.Parent() - for found { - if parent.Kind() == ast.CallKind { - fnName := parent.AsCall().FunctionName() - for _, exempt := range exemptFunctions { - if exempt == fnName { - return true - } - } - } - parent, found = parent.Parent() - } - return false -} - -func isOptionalIndex(i int, optIndices []int32) bool { - for _, optInd := range optIndices { - if i == int(optInd) { - return true - } - } - return false -} - -func (homogeneousAggregateLiteralValidator) typeMismatch(iss *Issues, id int64, expected, actual *Type) { - iss.ReportErrorAtID(id, "expected type '%s' but found '%s'", FormatCELType(expected), FormatCELType(actual)) -} - -type nestingLimitValidator struct { - limit int -} - -func (v nestingLimitValidator) Name() string { - return "cel.lib.std.validate.comprehension_nesting_limit" -} - -func (v nestingLimitValidator) Validate(e *Env, _ ValidatorConfig, a *ast.AST, iss *Issues) { - root := ast.NavigateAST(a) - comprehensions := ast.MatchDescendants(root, ast.KindMatcher(ast.ComprehensionKind)) - if len(comprehensions) <= v.limit { - return - } - for _, comp := range comprehensions { - count := 0 - e := comp - hasParent := true - for hasParent { - // When the expression is not a comprehension, continue to the next ancestor. - if e.Kind() != ast.ComprehensionKind { - e, hasParent = e.Parent() - continue - } - // When the comprehension has an empty range, continue to the next ancestor - // as this comprehension does not have any associated cost. - iterRange := e.AsComprehension().IterRange() - if iterRange.Kind() == ast.ListKind && iterRange.AsList().Size() == 0 { - e, hasParent = e.Parent() - continue - } - // Otherwise check the nesting limit. - count++ - if count > v.limit { - iss.ReportErrorAtID(comp.ID(), "comprehension exceeds nesting limit") - break - } - e, hasParent = e.Parent() - } - } -} diff --git a/vendor/github.com/google/cel-go/checker/BUILD.bazel b/vendor/github.com/google/cel-go/checker/BUILD.bazel deleted file mode 100644 index 997fa91d1..000000000 --- a/vendor/github.com/google/cel-go/checker/BUILD.bazel +++ /dev/null @@ -1,65 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -package( - licenses = ["notice"], # Apache 2.0 -) - -go_library( - name = "go_default_library", - srcs = [ - "checker.go", - "cost.go", - "env.go", - "errors.go", - "format.go", - "mapping.go", - "options.go", - "printer.go", - "scopes.go", - "standard.go", - "types.go", - ], - importpath = "github.com/google/cel-go/checker", - visibility = ["//visibility:public"], - deps = [ - "//checker/decls:go_default_library", - "//common:go_default_library", - "//common/ast:go_default_library", - "//common/containers:go_default_library", - "//common/debug:go_default_library", - "//common/decls:go_default_library", - "//common/operators:go_default_library", - "//common/overloads:go_default_library", - "//common/stdlib:go_default_library", - "//common/types:go_default_library", - "//common/types/pb:go_default_library", - "//common/types/ref:go_default_library", - "//parser:go_default_library", - "@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library", - "@org_golang_google_protobuf//proto:go_default_library", - "@org_golang_google_protobuf//types/known/emptypb:go_default_library", - "@org_golang_google_protobuf//types/known/structpb:go_default_library", - ], -) - -go_test( - name = "go_default_test", - size = "small", - srcs = [ - "checker_test.go", - "cost_test.go", - "env_test.go", - "format_test.go", - ], - embed = [ - ":go_default_library", - ], - deps = [ - "//common/types:go_default_library", - "//parser:go_default_library", - "//test:go_default_library", - "//test/proto2pb:go_default_library", - "//test/proto3pb:go_default_library", - "@org_golang_google_protobuf//proto:go_default_library", - ], -) diff --git a/vendor/github.com/google/cel-go/checker/checker.go b/vendor/github.com/google/cel-go/checker/checker.go deleted file mode 100644 index 57fb3ce5e..000000000 --- a/vendor/github.com/google/cel-go/checker/checker.go +++ /dev/null @@ -1,696 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package checker defines functions to type-checked a parsed expression -// against a set of identifier and function declarations. -package checker - -import ( - "fmt" - "reflect" - - "github.com/google/cel-go/common" - "github.com/google/cel-go/common/ast" - "github.com/google/cel-go/common/containers" - "github.com/google/cel-go/common/decls" - "github.com/google/cel-go/common/operators" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/common/types/ref" -) - -type checker struct { - *ast.AST - ast.ExprFactory - env *Env - errors *typeErrors - mappings *mapping - freeTypeVarCounter int -} - -// Check performs type checking, giving a typed AST. -// -// The input is a parsed AST and an env which encapsulates type binding of variables, -// declarations of built-in functions, descriptions of protocol buffers, and a registry for -// errors. -// -// Returns a type-checked AST, which might not be usable if there are errors in the error -// registry. -func Check(parsed *ast.AST, source common.Source, env *Env) (*ast.AST, *common.Errors) { - errs := common.NewErrors(source) - typeMap := make(map[int64]*types.Type) - refMap := make(map[int64]*ast.ReferenceInfo) - c := checker{ - AST: ast.NewCheckedAST(parsed, typeMap, refMap), - ExprFactory: ast.NewExprFactory(), - env: env, - errors: &typeErrors{errs: errs}, - mappings: newMapping(), - freeTypeVarCounter: 0, - } - c.check(c.Expr()) - - // Walk over the final type map substituting any type parameters either by their bound value - // or by DYN. - for id, t := range c.TypeMap() { - c.SetType(id, substitute(c.mappings, t, true)) - } - return c.AST, errs -} - -func (c *checker) check(e ast.Expr) { - if e == nil { - return - } - switch e.Kind() { - case ast.LiteralKind: - literal := ref.Val(e.AsLiteral()) - switch literal.Type() { - case types.BoolType, types.BytesType, types.DoubleType, types.IntType, - types.NullType, types.StringType, types.UintType: - c.setType(e, literal.Type().(*types.Type)) - default: - c.errors.unexpectedASTType(e.ID(), c.location(e), "literal", literal.Type().TypeName()) - } - case ast.IdentKind: - c.checkIdent(e) - case ast.SelectKind: - c.checkSelect(e) - case ast.CallKind: - c.checkCall(e) - case ast.ListKind: - c.checkCreateList(e) - case ast.MapKind: - c.checkCreateMap(e) - case ast.StructKind: - c.checkCreateStruct(e) - case ast.ComprehensionKind: - c.checkComprehension(e) - default: - c.errors.unexpectedASTType(e.ID(), c.location(e), "unspecified", reflect.TypeOf(e).Name()) - } -} - -func (c *checker) checkIdent(e ast.Expr) { - identName := e.AsIdent() - // Check to see if the identifier is declared. - if ident := c.env.LookupIdent(identName); ident != nil { - c.setType(e, ident.Type()) - c.setReference(e, ast.NewIdentReference(ident.Name(), ident.Value())) - // Overwrite the identifier with its fully qualified name. - e.SetKindCase(c.NewIdent(e.ID(), ident.Name())) - return - } - - c.setType(e, types.ErrorType) - c.errors.undeclaredReference(e.ID(), c.location(e), c.env.container.Name(), identName) -} - -func (c *checker) checkSelect(e ast.Expr) { - sel := e.AsSelect() - // Before traversing down the tree, try to interpret as qualified name. - qname, found := containers.ToQualifiedName(e) - if found { - ident := c.env.LookupIdent(qname) - if ident != nil { - // We don't check for a TestOnly expression here since the `found` result is - // always going to be false for TestOnly expressions. - - // Rewrite the node to be a variable reference to the resolved fully-qualified - // variable name. - c.setType(e, ident.Type()) - c.setReference(e, ast.NewIdentReference(ident.Name(), ident.Value())) - e.SetKindCase(c.NewIdent(e.ID(), ident.Name())) - return - } - } - - resultType := c.checkSelectField(e, sel.Operand(), sel.FieldName(), false) - if sel.IsTestOnly() { - resultType = types.BoolType - } - c.setType(e, substitute(c.mappings, resultType, false)) -} - -func (c *checker) checkOptSelect(e ast.Expr) { - // Collect metadata related to the opt select call packaged by the parser. - call := e.AsCall() - operand := call.Args()[0] - field := call.Args()[1] - fieldName, isString := maybeUnwrapString(field) - if !isString { - c.errors.notAnOptionalFieldSelection(field.ID(), c.location(field), field) - return - } - - // Perform type-checking using the field selection logic. - resultType := c.checkSelectField(e, operand, fieldName, true) - c.setType(e, substitute(c.mappings, resultType, false)) - c.setReference(e, ast.NewFunctionReference("select_optional_field")) -} - -func (c *checker) checkSelectField(e, operand ast.Expr, field string, optional bool) *types.Type { - // Interpret as field selection, first traversing down the operand. - c.check(operand) - operandType := substitute(c.mappings, c.getType(operand), false) - - // If the target type is 'optional', unwrap it for the sake of this check. - targetType, isOpt := maybeUnwrapOptional(operandType) - - // Assume error type by default as most types do not support field selection. - resultType := types.ErrorType - switch targetType.Kind() { - case types.MapKind: - // Maps yield their value type as the selection result type. - resultType = targetType.Parameters()[1] - case types.StructKind: - // Objects yield their field type declaration as the selection result type, but only if - // the field is defined. - messageType := targetType - if fieldType, found := c.lookupFieldType(e.ID(), messageType.TypeName(), field); found { - resultType = fieldType - } - case types.TypeParamKind: - // Set the operand type to DYN to prevent assignment to a potentially incorrect type - // at a later point in type-checking. The isAssignable call will update the type - // substitutions for the type param under the covers. - c.isAssignable(types.DynType, targetType) - // Also, set the result type to DYN. - resultType = types.DynType - default: - // Dynamic / error values are treated as DYN type. Errors are handled this way as well - // in order to allow forward progress on the check. - if !isDynOrError(targetType) { - c.errors.typeDoesNotSupportFieldSelection(e.ID(), c.location(e), targetType) - } - resultType = types.DynType - } - - // If the target type was optional coming in, then the result must be optional going out. - if isOpt || optional { - return types.NewOptionalType(resultType) - } - return resultType -} - -func (c *checker) checkCall(e ast.Expr) { - // Note: similar logic exists within the `interpreter/planner.go`. If making changes here - // please consider the impact on planner.go and consolidate implementations or mirror code - // as appropriate. - call := e.AsCall() - fnName := call.FunctionName() - if fnName == operators.OptSelect { - c.checkOptSelect(e) - return - } - - args := call.Args() - // Traverse arguments. - for _, arg := range args { - c.check(arg) - } - - // Regular static call with simple name. - if !call.IsMemberFunction() { - // Check for the existence of the function. - fn := c.env.LookupFunction(fnName) - if fn == nil { - c.errors.undeclaredReference(e.ID(), c.location(e), c.env.container.Name(), fnName) - c.setType(e, types.ErrorType) - return - } - // Overwrite the function name with its fully qualified resolved name. - e.SetKindCase(c.NewCall(e.ID(), fn.Name(), args...)) - // Check to see whether the overload resolves. - c.resolveOverloadOrError(e, fn, nil, args) - return - } - - // If a receiver 'target' is present, it may either be a receiver function, or a namespaced - // function, but not both. Given a.b.c() either a.b.c is a function or c is a function with - // target a.b. - // - // Check whether the target is a namespaced function name. - target := call.Target() - qualifiedPrefix, maybeQualified := containers.ToQualifiedName(target) - if maybeQualified { - maybeQualifiedName := qualifiedPrefix + "." + fnName - fn := c.env.LookupFunction(maybeQualifiedName) - if fn != nil { - // The function name is namespaced and so preserving the target operand would - // be an inaccurate representation of the desired evaluation behavior. - // Overwrite with fully-qualified resolved function name sans receiver target. - e.SetKindCase(c.NewCall(e.ID(), fn.Name(), args...)) - c.resolveOverloadOrError(e, fn, nil, args) - return - } - } - - // Regular instance call. - c.check(target) - fn := c.env.LookupFunction(fnName) - // Function found, attempt overload resolution. - if fn != nil { - c.resolveOverloadOrError(e, fn, target, args) - return - } - // Function name not declared, record error. - c.setType(e, types.ErrorType) - c.errors.undeclaredReference(e.ID(), c.location(e), c.env.container.Name(), fnName) -} - -func (c *checker) resolveOverloadOrError( - e ast.Expr, fn *decls.FunctionDecl, target ast.Expr, args []ast.Expr) { - // Attempt to resolve the overload. - resolution := c.resolveOverload(e, fn, target, args) - // No such overload, error noted in the resolveOverload call, type recorded here. - if resolution == nil { - c.setType(e, types.ErrorType) - return - } - // Overload found. - c.setType(e, resolution.Type) - c.setReference(e, resolution.Reference) -} - -func (c *checker) resolveOverload( - call ast.Expr, fn *decls.FunctionDecl, target ast.Expr, args []ast.Expr) *overloadResolution { - - var argTypes []*types.Type - if target != nil { - argTypes = append(argTypes, c.getType(target)) - } - for _, arg := range args { - argTypes = append(argTypes, c.getType(arg)) - } - - var resultType *types.Type - var checkedRef *ast.ReferenceInfo - for _, overload := range fn.OverloadDecls() { - // Determine whether the overload is currently considered. - if c.env.isOverloadDisabled(overload.ID()) { - continue - } - - // Ensure the call style for the overload matches. - if (target == nil && overload.IsMemberFunction()) || - (target != nil && !overload.IsMemberFunction()) { - // not a compatible call style. - continue - } - - // Alternative type-checking behavior when the logical operators are compacted into - // variadic AST representations. - if fn.Name() == operators.LogicalAnd || fn.Name() == operators.LogicalOr { - checkedRef = ast.NewFunctionReference(overload.ID()) - for i, argType := range argTypes { - if !c.isAssignable(argType, types.BoolType) { - c.errors.typeMismatch( - args[i].ID(), - c.locationByID(args[i].ID()), - types.BoolType, - argType) - resultType = types.ErrorType - } - } - if isError(resultType) { - return nil - } - return newResolution(checkedRef, types.BoolType) - } - - overloadType := newFunctionType(overload.ResultType(), overload.ArgTypes()...) - typeParams := overload.TypeParams() - if len(typeParams) != 0 { - // Instantiate overload's type with fresh type variables. - substitutions := newMapping() - for _, typePar := range typeParams { - substitutions.add(types.NewTypeParamType(typePar), c.newTypeVar()) - } - overloadType = substitute(substitutions, overloadType, false) - } - - candidateArgTypes := overloadType.Parameters()[1:] - if c.isAssignableList(argTypes, candidateArgTypes) { - if checkedRef == nil { - checkedRef = ast.NewFunctionReference(overload.ID()) - } else { - checkedRef.AddOverload(overload.ID()) - } - - // First matching overload, determines result type. - fnResultType := substitute(c.mappings, overloadType.Parameters()[0], false) - if resultType == nil { - resultType = fnResultType - } else if !isDyn(resultType) && !fnResultType.IsExactType(resultType) { - resultType = types.DynType - } - } - } - - if resultType == nil { - for i, argType := range argTypes { - argTypes[i] = substitute(c.mappings, argType, true) - } - c.errors.noMatchingOverload(call.ID(), c.location(call), fn.Name(), argTypes, target != nil) - return nil - } - - return newResolution(checkedRef, resultType) -} - -func (c *checker) checkCreateList(e ast.Expr) { - create := e.AsList() - var elemsType *types.Type - optionalIndices := create.OptionalIndices() - optionals := make(map[int32]bool, len(optionalIndices)) - for _, optInd := range optionalIndices { - optionals[optInd] = true - } - for i, e := range create.Elements() { - c.check(e) - elemType := c.getType(e) - if optionals[int32(i)] { - var isOptional bool - elemType, isOptional = maybeUnwrapOptional(elemType) - if !isOptional && !isDyn(elemType) { - c.errors.typeMismatch(e.ID(), c.location(e), types.NewOptionalType(elemType), elemType) - } - } - elemsType = c.joinTypes(e, elemsType, elemType) - } - if elemsType == nil { - // If the list is empty, assign free type var to elem type. - elemsType = c.newTypeVar() - } - c.setType(e, types.NewListType(elemsType)) -} - -func (c *checker) checkCreateMap(e ast.Expr) { - mapVal := e.AsMap() - var mapKeyType *types.Type - var mapValueType *types.Type - for _, e := range mapVal.Entries() { - entry := e.AsMapEntry() - key := entry.Key() - c.check(key) - mapKeyType = c.joinTypes(key, mapKeyType, c.getType(key)) - - val := entry.Value() - c.check(val) - valType := c.getType(val) - if entry.IsOptional() { - var isOptional bool - valType, isOptional = maybeUnwrapOptional(valType) - if !isOptional && !isDyn(valType) { - c.errors.typeMismatch(val.ID(), c.location(val), types.NewOptionalType(valType), valType) - } - } - mapValueType = c.joinTypes(val, mapValueType, valType) - } - if mapKeyType == nil { - // If the map is empty, assign free type variables to typeKey and value type. - mapKeyType = c.newTypeVar() - mapValueType = c.newTypeVar() - } - c.setType(e, types.NewMapType(mapKeyType, mapValueType)) -} - -func (c *checker) checkCreateStruct(e ast.Expr) { - msgVal := e.AsStruct() - // Determine the type of the message. - resultType := types.ErrorType - ident := c.env.LookupIdent(msgVal.TypeName()) - if ident == nil { - c.errors.undeclaredReference( - e.ID(), c.location(e), c.env.container.Name(), msgVal.TypeName()) - c.setType(e, types.ErrorType) - return - } - // Ensure the type name is fully qualified in the AST. - typeName := ident.Name() - if msgVal.TypeName() != typeName { - e.SetKindCase(c.NewStruct(e.ID(), typeName, msgVal.Fields())) - msgVal = e.AsStruct() - } - c.setReference(e, ast.NewIdentReference(typeName, nil)) - identKind := ident.Type().Kind() - if identKind != types.ErrorKind { - if identKind != types.TypeKind { - c.errors.notAType(e.ID(), c.location(e), ident.Type().DeclaredTypeName()) - } else { - resultType = ident.Type().Parameters()[0] - // Backwards compatibility test between well-known types and message types - // In this context, the type is being instantiated by its protobuf name which - // is not ideal or recommended, but some users expect this to work. - if isWellKnownType(resultType) { - typeName = getWellKnownTypeName(resultType) - } else if resultType.Kind() == types.StructKind { - typeName = resultType.DeclaredTypeName() - } else { - c.errors.notAMessageType(e.ID(), c.location(e), resultType.DeclaredTypeName()) - resultType = types.ErrorType - } - } - } - c.setType(e, resultType) - - // Check the field initializers. - for _, f := range msgVal.Fields() { - field := f.AsStructField() - fieldName := field.Name() - value := field.Value() - c.check(value) - - fieldType := types.ErrorType - ft, found := c.lookupFieldType(f.ID(), typeName, fieldName) - if found { - fieldType = ft - } - - valType := c.getType(value) - if field.IsOptional() { - var isOptional bool - valType, isOptional = maybeUnwrapOptional(valType) - if !isOptional && !isDyn(valType) { - c.errors.typeMismatch(value.ID(), c.location(value), types.NewOptionalType(valType), valType) - } - } - if !c.isAssignable(fieldType, valType) { - c.errors.fieldTypeMismatch(f.ID(), c.locationByID(f.ID()), fieldName, fieldType, valType) - } - } -} - -func (c *checker) checkComprehension(e ast.Expr) { - comp := e.AsComprehension() - c.check(comp.IterRange()) - c.check(comp.AccuInit()) - accuType := c.getType(comp.AccuInit()) - rangeType := substitute(c.mappings, c.getType(comp.IterRange()), false) - var varType *types.Type - - switch rangeType.Kind() { - case types.ListKind: - varType = rangeType.Parameters()[0] - case types.MapKind: - // Ranges over the keys. - varType = rangeType.Parameters()[0] - case types.DynKind, types.ErrorKind, types.TypeParamKind: - // Set the range type to DYN to prevent assignment to a potentially incorrect type - // at a later point in type-checking. The isAssignable call will update the type - // substitutions for the type param under the covers. - c.isAssignable(types.DynType, rangeType) - // Set the range iteration variable to type DYN as well. - varType = types.DynType - default: - c.errors.notAComprehensionRange(comp.IterRange().ID(), c.location(comp.IterRange()), rangeType) - varType = types.ErrorType - } - - // Create a scope for the comprehension since it has a local accumulation variable. - // This scope will contain the accumulation variable used to compute the result. - c.env = c.env.enterScope() - c.env.AddIdents(decls.NewVariable(comp.AccuVar(), accuType)) - // Create a block scope for the loop. - c.env = c.env.enterScope() - c.env.AddIdents(decls.NewVariable(comp.IterVar(), varType)) - // Check the variable references in the condition and step. - c.check(comp.LoopCondition()) - c.assertType(comp.LoopCondition(), types.BoolType) - c.check(comp.LoopStep()) - c.assertType(comp.LoopStep(), accuType) - // Exit the loop's block scope before checking the result. - c.env = c.env.exitScope() - c.check(comp.Result()) - // Exit the comprehension scope. - c.env = c.env.exitScope() - c.setType(e, substitute(c.mappings, c.getType(comp.Result()), false)) -} - -// Checks compatibility of joined types, and returns the most general common type. -func (c *checker) joinTypes(e ast.Expr, previous, current *types.Type) *types.Type { - if previous == nil { - return current - } - if c.isAssignable(previous, current) { - return mostGeneral(previous, current) - } - if c.dynAggregateLiteralElementTypesEnabled() { - return types.DynType - } - c.errors.typeMismatch(e.ID(), c.location(e), previous, current) - return types.ErrorType -} - -func (c *checker) dynAggregateLiteralElementTypesEnabled() bool { - return c.env.aggLitElemType == dynElementType -} - -func (c *checker) newTypeVar() *types.Type { - id := c.freeTypeVarCounter - c.freeTypeVarCounter++ - return types.NewTypeParamType(fmt.Sprintf("_var%d", id)) -} - -func (c *checker) isAssignable(t1, t2 *types.Type) bool { - subs := isAssignable(c.mappings, t1, t2) - if subs != nil { - c.mappings = subs - return true - } - - return false -} - -func (c *checker) isAssignableList(l1, l2 []*types.Type) bool { - subs := isAssignableList(c.mappings, l1, l2) - if subs != nil { - c.mappings = subs - return true - } - - return false -} - -func maybeUnwrapString(e ast.Expr) (string, bool) { - switch e.Kind() { - case ast.LiteralKind: - literal := e.AsLiteral() - switch v := literal.(type) { - case types.String: - return string(v), true - } - } - return "", false -} - -func (c *checker) setType(e ast.Expr, t *types.Type) { - if old, found := c.TypeMap()[e.ID()]; found && !old.IsExactType(t) { - c.errors.incompatibleType(e.ID(), c.location(e), e, old, t) - return - } - c.SetType(e.ID(), t) -} - -func (c *checker) getType(e ast.Expr) *types.Type { - return c.TypeMap()[e.ID()] -} - -func (c *checker) setReference(e ast.Expr, r *ast.ReferenceInfo) { - if old, found := c.ReferenceMap()[e.ID()]; found && !old.Equals(r) { - c.errors.referenceRedefinition(e.ID(), c.location(e), e, old, r) - return - } - c.SetReference(e.ID(), r) -} - -func (c *checker) assertType(e ast.Expr, t *types.Type) { - if !c.isAssignable(t, c.getType(e)) { - c.errors.typeMismatch(e.ID(), c.location(e), t, c.getType(e)) - } -} - -type overloadResolution struct { - Type *types.Type - Reference *ast.ReferenceInfo -} - -func newResolution(r *ast.ReferenceInfo, t *types.Type) *overloadResolution { - return &overloadResolution{ - Reference: r, - Type: t, - } -} - -func (c *checker) location(e ast.Expr) common.Location { - return c.locationByID(e.ID()) -} - -func (c *checker) locationByID(id int64) common.Location { - return c.SourceInfo().GetStartLocation(id) -} - -func (c *checker) lookupFieldType(exprID int64, structType, fieldName string) (*types.Type, bool) { - if _, found := c.env.provider.FindStructType(structType); !found { - // This should not happen, anyway, report an error. - c.errors.unexpectedFailedResolution(exprID, c.locationByID(exprID), structType) - return nil, false - } - - if ft, found := c.env.provider.FindStructFieldType(structType, fieldName); found { - return ft.Type, found - } - - c.errors.undefinedField(exprID, c.locationByID(exprID), fieldName) - return nil, false -} - -func isWellKnownType(t *types.Type) bool { - switch t.Kind() { - case types.AnyKind, types.TimestampKind, types.DurationKind, types.DynKind, types.NullTypeKind: - return true - case types.BoolKind, types.BytesKind, types.DoubleKind, types.IntKind, types.StringKind, types.UintKind: - return t.IsAssignableType(types.NullType) - case types.ListKind: - return t.Parameters()[0] == types.DynType - case types.MapKind: - return t.Parameters()[0] == types.StringType && t.Parameters()[1] == types.DynType - } - return false -} - -func getWellKnownTypeName(t *types.Type) string { - if name, found := wellKnownTypes[t.Kind()]; found { - return name - } - return "" -} - -var ( - wellKnownTypes = map[types.Kind]string{ - types.AnyKind: "google.protobuf.Any", - types.BoolKind: "google.protobuf.BoolValue", - types.BytesKind: "google.protobuf.BytesValue", - types.DoubleKind: "google.protobuf.DoubleValue", - types.DurationKind: "google.protobuf.Duration", - types.DynKind: "google.protobuf.Value", - types.IntKind: "google.protobuf.Int64Value", - types.ListKind: "google.protobuf.ListValue", - types.NullTypeKind: "google.protobuf.NullValue", - types.MapKind: "google.protobuf.Struct", - types.StringKind: "google.protobuf.StringValue", - types.TimestampKind: "google.protobuf.Timestamp", - types.UintKind: "google.protobuf.UInt64Value", - } -) diff --git a/vendor/github.com/google/cel-go/checker/cost.go b/vendor/github.com/google/cel-go/checker/cost.go deleted file mode 100644 index 3470d0a3f..000000000 --- a/vendor/github.com/google/cel-go/checker/cost.go +++ /dev/null @@ -1,702 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package checker - -import ( - "math" - - "github.com/google/cel-go/common" - "github.com/google/cel-go/common/ast" - "github.com/google/cel-go/common/overloads" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/parser" -) - -// WARNING: Any changes to cost calculations in this file require a corresponding change in interpreter/runtimecost.go - -// CostEstimator estimates the sizes of variable length input data and the costs of functions. -type CostEstimator interface { - // EstimateSize returns a SizeEstimate for the given AstNode, or nil if - // the estimator has no estimate to provide. The size is equivalent to the result of the CEL `size()` function: - // length of strings and bytes, number of map entries or number of list items. - // EstimateSize is only called for AstNodes where - // CEL does not know the size; EstimateSize is not called for values defined inline in CEL where the size - // is already obvious to CEL. - EstimateSize(element AstNode) *SizeEstimate - // EstimateCallCost returns the estimated cost of an invocation, or nil if - // the estimator has no estimate to provide. - EstimateCallCost(function, overloadID string, target *AstNode, args []AstNode) *CallEstimate -} - -// CallEstimate includes a CostEstimate for the call, and an optional estimate of the result object size. -// The ResultSize should only be provided if the call results in a map, list, string or bytes. -type CallEstimate struct { - CostEstimate - ResultSize *SizeEstimate -} - -// AstNode represents an AST node for the purpose of cost estimations. -type AstNode interface { - // Path returns a field path through the provided type declarations to the type of the AstNode, or nil if the AstNode does not - // represent type directly reachable from the provided type declarations. - // The first path element is a variable. All subsequent path elements are one of: field name, '@items', '@keys', '@values'. - Path() []string - // Type returns the deduced type of the AstNode. - Type() *types.Type - // Expr returns the expression of the AstNode. - Expr() ast.Expr - // ComputedSize returns a size estimate of the AstNode derived from information available in the CEL expression. - // For constants and inline list and map declarations, the exact size is returned. For concatenated list, strings - // and bytes, the size is derived from the size estimates of the operands. nil is returned if there is no - // computed size available. - ComputedSize() *SizeEstimate -} - -type astNode struct { - path []string - t *types.Type - expr ast.Expr - derivedSize *SizeEstimate -} - -func (e astNode) Path() []string { - return e.path -} - -func (e astNode) Type() *types.Type { - return e.t -} - -func (e astNode) Expr() ast.Expr { - return e.expr -} - -func (e astNode) ComputedSize() *SizeEstimate { - if e.derivedSize != nil { - return e.derivedSize - } - var v uint64 - switch e.expr.Kind() { - case ast.LiteralKind: - switch ck := e.expr.AsLiteral().(type) { - case types.String: - // converting to runes here is an O(n) operation, but - // this is consistent with how size is computed at runtime, - // and how the language definition defines string size - v = uint64(len([]rune(ck))) - case types.Bytes: - v = uint64(len(ck)) - case types.Bool, types.Double, types.Duration, - types.Int, types.Timestamp, types.Uint, - types.Null: - v = uint64(1) - default: - return nil - } - case ast.ListKind: - v = uint64(e.expr.AsList().Size()) - case ast.MapKind: - v = uint64(e.expr.AsMap().Size()) - default: - return nil - } - - return &SizeEstimate{Min: v, Max: v} -} - -// SizeEstimate represents an estimated size of a variable length string, bytes, map or list. -type SizeEstimate struct { - Min, Max uint64 -} - -// Add adds to another SizeEstimate and returns the sum. -// If add would result in an uint64 overflow, the result is math.MaxUint64. -func (se SizeEstimate) Add(sizeEstimate SizeEstimate) SizeEstimate { - return SizeEstimate{ - addUint64NoOverflow(se.Min, sizeEstimate.Min), - addUint64NoOverflow(se.Max, sizeEstimate.Max), - } -} - -// Multiply multiplies by another SizeEstimate and returns the product. -// If multiply would result in an uint64 overflow, the result is math.MaxUint64. -func (se SizeEstimate) Multiply(sizeEstimate SizeEstimate) SizeEstimate { - return SizeEstimate{ - multiplyUint64NoOverflow(se.Min, sizeEstimate.Min), - multiplyUint64NoOverflow(se.Max, sizeEstimate.Max), - } -} - -// MultiplyByCostFactor multiplies a SizeEstimate by a cost factor and returns the CostEstimate with the -// nearest integer of the result, rounded up. -func (se SizeEstimate) MultiplyByCostFactor(costPerUnit float64) CostEstimate { - return CostEstimate{ - multiplyByCostFactor(se.Min, costPerUnit), - multiplyByCostFactor(se.Max, costPerUnit), - } -} - -// MultiplyByCost multiplies by the cost and returns the product. -// If multiply would result in an uint64 overflow, the result is math.MaxUint64. -func (se SizeEstimate) MultiplyByCost(cost CostEstimate) CostEstimate { - return CostEstimate{ - multiplyUint64NoOverflow(se.Min, cost.Min), - multiplyUint64NoOverflow(se.Max, cost.Max), - } -} - -// Union returns a SizeEstimate that encompasses both input the SizeEstimate. -func (se SizeEstimate) Union(size SizeEstimate) SizeEstimate { - result := se - if size.Min < result.Min { - result.Min = size.Min - } - if size.Max > result.Max { - result.Max = size.Max - } - return result -} - -// CostEstimate represents an estimated cost range and provides add and multiply operations -// that do not overflow. -type CostEstimate struct { - Min, Max uint64 -} - -// Add adds the costs and returns the sum. -// If add would result in an uint64 overflow for the min or max, the value is set to math.MaxUint64. -func (ce CostEstimate) Add(cost CostEstimate) CostEstimate { - return CostEstimate{ - addUint64NoOverflow(ce.Min, cost.Min), - addUint64NoOverflow(ce.Max, cost.Max), - } -} - -// Multiply multiplies by the cost and returns the product. -// If multiply would result in an uint64 overflow, the result is math.MaxUint64. -func (ce CostEstimate) Multiply(cost CostEstimate) CostEstimate { - return CostEstimate{ - multiplyUint64NoOverflow(ce.Min, cost.Min), - multiplyUint64NoOverflow(ce.Max, cost.Max), - } -} - -// MultiplyByCostFactor multiplies a CostEstimate by a cost factor and returns the CostEstimate with the -// nearest integer of the result, rounded up. -func (ce CostEstimate) MultiplyByCostFactor(costPerUnit float64) CostEstimate { - return CostEstimate{ - multiplyByCostFactor(ce.Min, costPerUnit), - multiplyByCostFactor(ce.Max, costPerUnit), - } -} - -// Union returns a CostEstimate that encompasses both input the CostEstimates. -func (ce CostEstimate) Union(size CostEstimate) CostEstimate { - result := ce - if size.Min < result.Min { - result.Min = size.Min - } - if size.Max > result.Max { - result.Max = size.Max - } - return result -} - -// addUint64NoOverflow adds non-negative ints. If the result is exceeds math.MaxUint64, math.MaxUint64 -// is returned. -func addUint64NoOverflow(x, y uint64) uint64 { - if y > 0 && x > math.MaxUint64-y { - return math.MaxUint64 - } - return x + y -} - -// multiplyUint64NoOverflow multiplies non-negative ints. If the result is exceeds math.MaxUint64, math.MaxUint64 -// is returned. -func multiplyUint64NoOverflow(x, y uint64) uint64 { - if y != 0 && x > math.MaxUint64/y { - return math.MaxUint64 - } - return x * y -} - -// multiplyByFactor multiplies an integer by a cost factor float and returns the nearest integer value, rounded up. -func multiplyByCostFactor(x uint64, y float64) uint64 { - xFloat := float64(x) - if xFloat > 0 && y > 0 && xFloat > math.MaxUint64/y { - return math.MaxUint64 - } - ceil := math.Ceil(xFloat * y) - if ceil >= doubleTwoTo64 { - return math.MaxUint64 - } - return uint64(ceil) -} - -var ( - selectAndIdentCost = CostEstimate{Min: common.SelectAndIdentCost, Max: common.SelectAndIdentCost} - constCost = CostEstimate{Min: common.ConstCost, Max: common.ConstCost} - - createListBaseCost = CostEstimate{Min: common.ListCreateBaseCost, Max: common.ListCreateBaseCost} - createMapBaseCost = CostEstimate{Min: common.MapCreateBaseCost, Max: common.MapCreateBaseCost} - createMessageBaseCost = CostEstimate{Min: common.StructCreateBaseCost, Max: common.StructCreateBaseCost} -) - -type coster struct { - // exprPath maps from Expr Id to field path. - exprPath map[int64][]string - // iterRanges tracks the iterRange of each iterVar. - iterRanges iterRangeScopes - // computedSizes tracks the computed sizes of call results. - computedSizes map[int64]SizeEstimate - checkedAST *ast.AST - estimator CostEstimator - overloadEstimators map[string]FunctionEstimator - // presenceTestCost will either be a zero or one based on whether has() macros count against cost computations. - presenceTestCost CostEstimate -} - -// Use a stack of iterVar -> iterRange Expr Ids to handle shadowed variable names. -type iterRangeScopes map[string][]int64 - -func (vs iterRangeScopes) push(varName string, expr ast.Expr) { - vs[varName] = append(vs[varName], expr.ID()) -} - -func (vs iterRangeScopes) pop(varName string) { - varStack := vs[varName] - vs[varName] = varStack[:len(varStack)-1] -} - -func (vs iterRangeScopes) peek(varName string) (int64, bool) { - varStack := vs[varName] - if len(varStack) > 0 { - return varStack[len(varStack)-1], true - } - return 0, false -} - -// CostOption configures flags which affect cost computations. -type CostOption func(*coster) error - -// PresenceTestHasCost determines whether presence testing has a cost of one or zero. -// -// Defaults to presence test has a cost of one. -func PresenceTestHasCost(hasCost bool) CostOption { - return func(c *coster) error { - if hasCost { - c.presenceTestCost = selectAndIdentCost - return nil - } - c.presenceTestCost = CostEstimate{Min: 0, Max: 0} - return nil - } -} - -// FunctionEstimator provides a CallEstimate given the target and arguments for a specific function, overload pair. -type FunctionEstimator func(estimator CostEstimator, target *AstNode, args []AstNode) *CallEstimate - -// OverloadCostEstimate binds a FunctionCoster to a specific function overload ID. -// -// When a OverloadCostEstimate is provided, it will override the cost calculation of the CostEstimator provided to -// the Cost() call. -func OverloadCostEstimate(overloadID string, functionCoster FunctionEstimator) CostOption { - return func(c *coster) error { - c.overloadEstimators[overloadID] = functionCoster - return nil - } -} - -// Cost estimates the cost of the parsed and type checked CEL expression. -func Cost(checked *ast.AST, estimator CostEstimator, opts ...CostOption) (CostEstimate, error) { - c := &coster{ - checkedAST: checked, - estimator: estimator, - overloadEstimators: map[string]FunctionEstimator{}, - exprPath: map[int64][]string{}, - iterRanges: map[string][]int64{}, - computedSizes: map[int64]SizeEstimate{}, - presenceTestCost: CostEstimate{Min: 1, Max: 1}, - } - for _, opt := range opts { - err := opt(c) - if err != nil { - return CostEstimate{}, err - } - } - return c.cost(checked.Expr()), nil -} - -func (c *coster) cost(e ast.Expr) CostEstimate { - if e == nil { - return CostEstimate{} - } - var cost CostEstimate - switch e.Kind() { - case ast.LiteralKind: - cost = constCost - case ast.IdentKind: - cost = c.costIdent(e) - case ast.SelectKind: - cost = c.costSelect(e) - case ast.CallKind: - cost = c.costCall(e) - case ast.ListKind: - cost = c.costCreateList(e) - case ast.MapKind: - cost = c.costCreateMap(e) - case ast.StructKind: - cost = c.costCreateStruct(e) - case ast.ComprehensionKind: - cost = c.costComprehension(e) - default: - return CostEstimate{} - } - return cost -} - -func (c *coster) costIdent(e ast.Expr) CostEstimate { - identName := e.AsIdent() - // build and track the field path - if iterRange, ok := c.iterRanges.peek(identName); ok { - switch c.checkedAST.GetType(iterRange).Kind() { - case types.ListKind: - c.addPath(e, append(c.exprPath[iterRange], "@items")) - case types.MapKind: - c.addPath(e, append(c.exprPath[iterRange], "@keys")) - } - } else { - c.addPath(e, []string{identName}) - } - - return selectAndIdentCost -} - -func (c *coster) costSelect(e ast.Expr) CostEstimate { - sel := e.AsSelect() - var sum CostEstimate - if sel.IsTestOnly() { - // recurse, but do not add any cost - // this is equivalent to how evalTestOnly increments the runtime cost counter - // but does not add any additional cost for the qualifier, except here we do - // the reverse (ident adds cost) - sum = sum.Add(c.presenceTestCost) - sum = sum.Add(c.cost(sel.Operand())) - return sum - } - sum = sum.Add(c.cost(sel.Operand())) - targetType := c.getType(sel.Operand()) - switch targetType.Kind() { - case types.MapKind, types.StructKind, types.TypeParamKind: - sum = sum.Add(selectAndIdentCost) - } - - // build and track the field path - c.addPath(e, append(c.getPath(sel.Operand()), sel.FieldName())) - - return sum -} - -func (c *coster) costCall(e ast.Expr) CostEstimate { - call := e.AsCall() - args := call.Args() - - var sum CostEstimate - - argTypes := make([]AstNode, len(args)) - argCosts := make([]CostEstimate, len(args)) - for i, arg := range args { - argCosts[i] = c.cost(arg) - argTypes[i] = c.newAstNode(arg) - } - - overloadIDs := c.checkedAST.GetOverloadIDs(e.ID()) - if len(overloadIDs) == 0 { - return CostEstimate{} - } - var targetType AstNode - if call.IsMemberFunction() { - sum = sum.Add(c.cost(call.Target())) - targetType = c.newAstNode(call.Target()) - } - // Pick a cost estimate range that covers all the overload cost estimation ranges - fnCost := CostEstimate{Min: uint64(math.MaxUint64), Max: 0} - var resultSize *SizeEstimate - for _, overload := range overloadIDs { - overloadCost := c.functionCost(call.FunctionName(), overload, &targetType, argTypes, argCosts) - fnCost = fnCost.Union(overloadCost.CostEstimate) - if overloadCost.ResultSize != nil { - if resultSize == nil { - resultSize = overloadCost.ResultSize - } else { - size := resultSize.Union(*overloadCost.ResultSize) - resultSize = &size - } - } - // build and track the field path for index operations - switch overload { - case overloads.IndexList: - if len(args) > 0 { - c.addPath(e, append(c.getPath(args[0]), "@items")) - } - case overloads.IndexMap: - if len(args) > 0 { - c.addPath(e, append(c.getPath(args[0]), "@values")) - } - } - } - if resultSize != nil { - c.computedSizes[e.ID()] = *resultSize - } - return sum.Add(fnCost) -} - -func (c *coster) costCreateList(e ast.Expr) CostEstimate { - create := e.AsList() - var sum CostEstimate - for _, e := range create.Elements() { - sum = sum.Add(c.cost(e)) - } - return sum.Add(createListBaseCost) -} - -func (c *coster) costCreateMap(e ast.Expr) CostEstimate { - mapVal := e.AsMap() - var sum CostEstimate - for _, ent := range mapVal.Entries() { - entry := ent.AsMapEntry() - sum = sum.Add(c.cost(entry.Key())) - sum = sum.Add(c.cost(entry.Value())) - } - return sum.Add(createMapBaseCost) -} - -func (c *coster) costCreateStruct(e ast.Expr) CostEstimate { - msgVal := e.AsStruct() - var sum CostEstimate - for _, ent := range msgVal.Fields() { - field := ent.AsStructField() - sum = sum.Add(c.cost(field.Value())) - } - return sum.Add(createMessageBaseCost) -} - -func (c *coster) costComprehension(e ast.Expr) CostEstimate { - comp := e.AsComprehension() - var sum CostEstimate - sum = sum.Add(c.cost(comp.IterRange())) - sum = sum.Add(c.cost(comp.AccuInit())) - - // Track the iterRange of each IterVar for field path construction - c.iterRanges.push(comp.IterVar(), comp.IterRange()) - loopCost := c.cost(comp.LoopCondition()) - stepCost := c.cost(comp.LoopStep()) - c.iterRanges.pop(comp.IterVar()) - sum = sum.Add(c.cost(comp.Result())) - rangeCnt := c.sizeEstimate(c.newAstNode(comp.IterRange())) - rangeCost := rangeCnt.MultiplyByCost(stepCost.Add(loopCost)) - sum = sum.Add(rangeCost) - - return sum -} - -func (c *coster) sizeEstimate(t AstNode) SizeEstimate { - if l := t.ComputedSize(); l != nil { - return *l - } - if l := c.estimator.EstimateSize(t); l != nil { - return *l - } - // return an estimate of 1 for return types of set - // lengths, since strings/bytes/more complex objects could be of - // variable length - if isScalar(t.Type()) { - // TODO: since the logic for size estimation is split between - // ComputedSize and isScalar, changing one will likely require changing - // the other, so they should be merged in the future if possible - return SizeEstimate{Min: 1, Max: 1} - } - return SizeEstimate{Min: 0, Max: math.MaxUint64} -} - -func (c *coster) functionCost(function, overloadID string, target *AstNode, args []AstNode, argCosts []CostEstimate) CallEstimate { - argCostSum := func() CostEstimate { - var sum CostEstimate - for _, a := range argCosts { - sum = sum.Add(a) - } - return sum - } - if len(c.overloadEstimators) != 0 { - if estimator, found := c.overloadEstimators[overloadID]; found { - if est := estimator(c.estimator, target, args); est != nil { - callEst := *est - return CallEstimate{CostEstimate: callEst.Add(argCostSum()), ResultSize: est.ResultSize} - } - } - } - if est := c.estimator.EstimateCallCost(function, overloadID, target, args); est != nil { - callEst := *est - return CallEstimate{CostEstimate: callEst.Add(argCostSum()), ResultSize: est.ResultSize} - } - switch overloadID { - // O(n) functions - case overloads.ExtFormatString: - if target != nil { - // ResultSize not calculated because we can't bound the max size. - return CallEstimate{CostEstimate: c.sizeEstimate(*target).MultiplyByCostFactor(common.StringTraversalCostFactor).Add(argCostSum())} - } - case overloads.StringToBytes: - if len(args) == 1 { - sz := c.sizeEstimate(args[0]) - // ResultSize max is when each char converts to 4 bytes. - return CallEstimate{CostEstimate: sz.MultiplyByCostFactor(common.StringTraversalCostFactor).Add(argCostSum()), ResultSize: &SizeEstimate{Min: sz.Min, Max: sz.Max * 4}} - } - case overloads.BytesToString: - if len(args) == 1 { - sz := c.sizeEstimate(args[0]) - // ResultSize min is when 4 bytes convert to 1 char. - return CallEstimate{CostEstimate: sz.MultiplyByCostFactor(common.StringTraversalCostFactor).Add(argCostSum()), ResultSize: &SizeEstimate{Min: sz.Min / 4, Max: sz.Max}} - } - case overloads.ExtQuoteString: - if len(args) == 1 { - sz := c.sizeEstimate(args[0]) - // ResultSize max is when each char is escaped. 2 quote chars always added. - return CallEstimate{CostEstimate: sz.MultiplyByCostFactor(common.StringTraversalCostFactor).Add(argCostSum()), ResultSize: &SizeEstimate{Min: sz.Min + 2, Max: sz.Max*2 + 2}} - } - case overloads.StartsWithString, overloads.EndsWithString: - if len(args) == 1 { - return CallEstimate{CostEstimate: c.sizeEstimate(args[0]).MultiplyByCostFactor(common.StringTraversalCostFactor).Add(argCostSum())} - } - case overloads.InList: - // If a list is composed entirely of constant values this is O(1), but we don't account for that here. - // We just assume all list containment checks are O(n). - if len(args) == 2 { - return CallEstimate{CostEstimate: c.sizeEstimate(args[1]).MultiplyByCostFactor(1).Add(argCostSum())} - } - // O(nm) functions - case overloads.MatchesString: - // https://swtch.com/~rsc/regexp/regexp1.html applies to RE2 implementation supported by CEL - if target != nil && len(args) == 1 { - // Add one to string length for purposes of cost calculation to prevent product of string and regex to be 0 - // in case where string is empty but regex is still expensive. - strCost := c.sizeEstimate(*target).Add(SizeEstimate{Min: 1, Max: 1}).MultiplyByCostFactor(common.StringTraversalCostFactor) - // We don't know how many expressions are in the regex, just the string length (a huge - // improvement here would be to somehow get a count the number of expressions in the regex or - // how many states are in the regex state machine and use that to measure regex cost). - // For now, we're making a guess that each expression in a regex is typically at least 4 chars - // in length. - regexCost := c.sizeEstimate(args[0]).MultiplyByCostFactor(common.RegexStringLengthCostFactor) - return CallEstimate{CostEstimate: strCost.Multiply(regexCost).Add(argCostSum())} - } - case overloads.ContainsString: - if target != nil && len(args) == 1 { - strCost := c.sizeEstimate(*target).MultiplyByCostFactor(common.StringTraversalCostFactor) - substrCost := c.sizeEstimate(args[0]).MultiplyByCostFactor(common.StringTraversalCostFactor) - return CallEstimate{CostEstimate: strCost.Multiply(substrCost).Add(argCostSum())} - } - case overloads.LogicalOr, overloads.LogicalAnd: - lhs := argCosts[0] - rhs := argCosts[1] - // min cost is min of LHS for short circuited && or || - argCost := CostEstimate{Min: lhs.Min, Max: lhs.Add(rhs).Max} - return CallEstimate{CostEstimate: argCost} - case overloads.Conditional: - size := c.sizeEstimate(args[1]).Union(c.sizeEstimate(args[2])) - conditionalCost := argCosts[0] - ifTrueCost := argCosts[1] - ifFalseCost := argCosts[2] - argCost := conditionalCost.Add(ifTrueCost.Union(ifFalseCost)) - return CallEstimate{CostEstimate: argCost, ResultSize: &size} - case overloads.AddString, overloads.AddBytes, overloads.AddList: - if len(args) == 2 { - lhsSize := c.sizeEstimate(args[0]) - rhsSize := c.sizeEstimate(args[1]) - resultSize := lhsSize.Add(rhsSize) - switch overloadID { - case overloads.AddList: - // list concatenation is O(1), but we handle it here to track size - return CallEstimate{CostEstimate: CostEstimate{Min: 1, Max: 1}.Add(argCostSum()), ResultSize: &resultSize} - default: - return CallEstimate{CostEstimate: resultSize.MultiplyByCostFactor(common.StringTraversalCostFactor).Add(argCostSum()), ResultSize: &resultSize} - } - } - case overloads.LessString, overloads.GreaterString, overloads.LessEqualsString, overloads.GreaterEqualsString, - overloads.LessBytes, overloads.GreaterBytes, overloads.LessEqualsBytes, overloads.GreaterEqualsBytes, - overloads.Equals, overloads.NotEquals: - lhsCost := c.sizeEstimate(args[0]) - rhsCost := c.sizeEstimate(args[1]) - min := uint64(0) - smallestMax := lhsCost.Max - if rhsCost.Max < smallestMax { - smallestMax = rhsCost.Max - } - if smallestMax > 0 { - min = 1 - } - // equality of 2 scalar values results in a cost of 1 - return CallEstimate{CostEstimate: CostEstimate{Min: min, Max: smallestMax}.MultiplyByCostFactor(common.StringTraversalCostFactor).Add(argCostSum())} - } - // O(1) functions - // See CostTracker.costCall for more details about O(1) cost calculations - - // Benchmarks suggest that most of the other operations take +/- 50% of a base cost unit - // which on an Intel xeon 2.20GHz CPU is 50ns. - return CallEstimate{CostEstimate: CostEstimate{Min: 1, Max: 1}.Add(argCostSum())} -} - -func (c *coster) getType(e ast.Expr) *types.Type { - return c.checkedAST.GetType(e.ID()) -} - -func (c *coster) getPath(e ast.Expr) []string { - return c.exprPath[e.ID()] -} - -func (c *coster) addPath(e ast.Expr, path []string) { - c.exprPath[e.ID()] = path -} - -func (c *coster) newAstNode(e ast.Expr) *astNode { - path := c.getPath(e) - if len(path) > 0 && path[0] == parser.AccumulatorName { - // only provide paths to root vars; omit accumulator vars - path = nil - } - var derivedSize *SizeEstimate - if size, ok := c.computedSizes[e.ID()]; ok { - derivedSize = &size - } - return &astNode{ - path: path, - t: c.getType(e), - expr: e, - derivedSize: derivedSize} -} - -// isScalar returns true if the given type is known to be of a constant size at -// compile time. isScalar will return false for strings (they are variable-width) -// in addition to protobuf.Any and protobuf.Value (their size is not knowable at compile time). -func isScalar(t *types.Type) bool { - switch t.Kind() { - case types.BoolKind, types.DoubleKind, types.DurationKind, types.IntKind, types.TimestampKind, types.UintKind: - return true - } - return false -} - -var ( - doubleTwoTo64 = math.Ldexp(1.0, 64) -) diff --git a/vendor/github.com/google/cel-go/checker/decls/BUILD.bazel b/vendor/github.com/google/cel-go/checker/decls/BUILD.bazel deleted file mode 100644 index a6b0be292..000000000 --- a/vendor/github.com/google/cel-go/checker/decls/BUILD.bazel +++ /dev/null @@ -1,19 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -package( - default_visibility = ["//visibility:public"], - licenses = ["notice"], # Apache 2.0 -) - -go_library( - name = "go_default_library", - srcs = [ - "decls.go", - ], - importpath = "github.com/google/cel-go/checker/decls", - deps = [ - "@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library", - "@org_golang_google_protobuf//types/known/emptypb:go_default_library", - "@org_golang_google_protobuf//types/known/structpb:go_default_library", - ], -) diff --git a/vendor/github.com/google/cel-go/checker/decls/decls.go b/vendor/github.com/google/cel-go/checker/decls/decls.go deleted file mode 100644 index 0d91bef51..000000000 --- a/vendor/github.com/google/cel-go/checker/decls/decls.go +++ /dev/null @@ -1,237 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package decls provides helpers for creating variable and function declarations. -package decls - -import ( - exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1" - emptypb "google.golang.org/protobuf/types/known/emptypb" - structpb "google.golang.org/protobuf/types/known/structpb" -) - -var ( - // Error type used to communicate issues during type-checking. - Error = &exprpb.Type{ - TypeKind: &exprpb.Type_Error{ - Error: &emptypb.Empty{}}} - - // Dyn is a top-type used to represent any value. - Dyn = &exprpb.Type{ - TypeKind: &exprpb.Type_Dyn{ - Dyn: &emptypb.Empty{}}} -) - -// Commonly used types. -var ( - Bool = NewPrimitiveType(exprpb.Type_BOOL) - Bytes = NewPrimitiveType(exprpb.Type_BYTES) - Double = NewPrimitiveType(exprpb.Type_DOUBLE) - Int = NewPrimitiveType(exprpb.Type_INT64) - Null = &exprpb.Type{ - TypeKind: &exprpb.Type_Null{ - Null: structpb.NullValue_NULL_VALUE}} - String = NewPrimitiveType(exprpb.Type_STRING) - Uint = NewPrimitiveType(exprpb.Type_UINT64) -) - -// Well-known types. -// TODO: Replace with an abstract type registry. -var ( - Any = NewWellKnownType(exprpb.Type_ANY) - Duration = NewWellKnownType(exprpb.Type_DURATION) - Timestamp = NewWellKnownType(exprpb.Type_TIMESTAMP) -) - -// NewAbstractType creates an abstract type declaration which references a proto -// message name and may also include type parameters. -func NewAbstractType(name string, paramTypes ...*exprpb.Type) *exprpb.Type { - return &exprpb.Type{ - TypeKind: &exprpb.Type_AbstractType_{ - AbstractType: &exprpb.Type_AbstractType{ - Name: name, - ParameterTypes: paramTypes}}} -} - -// NewOptionalType constructs an abstract type indicating that the parameterized type -// may be contained within the object. -func NewOptionalType(paramType *exprpb.Type) *exprpb.Type { - return NewAbstractType("optional", paramType) -} - -// NewFunctionType creates a function invocation contract, typically only used -// by type-checking steps after overload resolution. -func NewFunctionType(resultType *exprpb.Type, - argTypes ...*exprpb.Type) *exprpb.Type { - return &exprpb.Type{ - TypeKind: &exprpb.Type_Function{ - Function: &exprpb.Type_FunctionType{ - ResultType: resultType, - ArgTypes: argTypes}}} -} - -// NewFunction creates a named function declaration with one or more overloads. -func NewFunction(name string, - overloads ...*exprpb.Decl_FunctionDecl_Overload) *exprpb.Decl { - return &exprpb.Decl{ - Name: name, - DeclKind: &exprpb.Decl_Function{ - Function: &exprpb.Decl_FunctionDecl{ - Overloads: overloads}}} -} - -// NewIdent creates a named identifier declaration with an optional literal -// value. -// -// Literal values are typically only associated with enum identifiers. -// -// Deprecated: Use NewVar or NewConst instead. -func NewIdent(name string, t *exprpb.Type, v *exprpb.Constant) *exprpb.Decl { - return &exprpb.Decl{ - Name: name, - DeclKind: &exprpb.Decl_Ident{ - Ident: &exprpb.Decl_IdentDecl{ - Type: t, - Value: v}}} -} - -// NewConst creates a constant identifier with a CEL constant literal value. -func NewConst(name string, t *exprpb.Type, v *exprpb.Constant) *exprpb.Decl { - return NewIdent(name, t, v) -} - -// NewVar creates a variable identifier. -func NewVar(name string, t *exprpb.Type) *exprpb.Decl { - return NewIdent(name, t, nil) -} - -// NewInstanceOverload creates a instance function overload contract. -// First element of argTypes is instance. -func NewInstanceOverload(id string, argTypes []*exprpb.Type, - resultType *exprpb.Type) *exprpb.Decl_FunctionDecl_Overload { - return &exprpb.Decl_FunctionDecl_Overload{ - OverloadId: id, - ResultType: resultType, - Params: argTypes, - IsInstanceFunction: true} -} - -// NewListType generates a new list with elements of a certain type. -func NewListType(elem *exprpb.Type) *exprpb.Type { - return &exprpb.Type{ - TypeKind: &exprpb.Type_ListType_{ - ListType: &exprpb.Type_ListType{ - ElemType: elem}}} -} - -// NewMapType generates a new map with typed keys and values. -func NewMapType(key *exprpb.Type, value *exprpb.Type) *exprpb.Type { - return &exprpb.Type{ - TypeKind: &exprpb.Type_MapType_{ - MapType: &exprpb.Type_MapType{ - KeyType: key, - ValueType: value}}} -} - -// NewObjectType creates an object type for a qualified type name. -func NewObjectType(typeName string) *exprpb.Type { - return &exprpb.Type{ - TypeKind: &exprpb.Type_MessageType{ - MessageType: typeName}} -} - -// NewOverload creates a function overload declaration which contains a unique -// overload id as well as the expected argument and result types. Overloads -// must be aggregated within a Function declaration. -func NewOverload(id string, argTypes []*exprpb.Type, - resultType *exprpb.Type) *exprpb.Decl_FunctionDecl_Overload { - return &exprpb.Decl_FunctionDecl_Overload{ - OverloadId: id, - ResultType: resultType, - Params: argTypes, - IsInstanceFunction: false} -} - -// NewParameterizedInstanceOverload creates a parametric function instance overload type. -func NewParameterizedInstanceOverload(id string, - argTypes []*exprpb.Type, - resultType *exprpb.Type, - typeParams []string) *exprpb.Decl_FunctionDecl_Overload { - return &exprpb.Decl_FunctionDecl_Overload{ - OverloadId: id, - ResultType: resultType, - Params: argTypes, - TypeParams: typeParams, - IsInstanceFunction: true} -} - -// NewParameterizedOverload creates a parametric function overload type. -func NewParameterizedOverload(id string, - argTypes []*exprpb.Type, - resultType *exprpb.Type, - typeParams []string) *exprpb.Decl_FunctionDecl_Overload { - return &exprpb.Decl_FunctionDecl_Overload{ - OverloadId: id, - ResultType: resultType, - Params: argTypes, - TypeParams: typeParams, - IsInstanceFunction: false} -} - -// NewPrimitiveType creates a type for a primitive value. See the var declarations -// for Int, Uint, etc. -func NewPrimitiveType(primitive exprpb.Type_PrimitiveType) *exprpb.Type { - return &exprpb.Type{ - TypeKind: &exprpb.Type_Primitive{ - Primitive: primitive}} -} - -// NewTypeType creates a new type designating a type. -func NewTypeType(nested *exprpb.Type) *exprpb.Type { - if nested == nil { - // must set the nested field for a valid oneof option - nested = &exprpb.Type{} - } - return &exprpb.Type{ - TypeKind: &exprpb.Type_Type{ - Type: nested}} -} - -// NewTypeParamType creates a type corresponding to a named, contextual parameter. -func NewTypeParamType(name string) *exprpb.Type { - return &exprpb.Type{ - TypeKind: &exprpb.Type_TypeParam{ - TypeParam: name}} -} - -// NewWellKnownType creates a type corresponding to a protobuf well-known type -// value. -func NewWellKnownType(wellKnown exprpb.Type_WellKnownType) *exprpb.Type { - return &exprpb.Type{ - TypeKind: &exprpb.Type_WellKnown{ - WellKnown: wellKnown}} -} - -// NewWrapperType creates a wrapped primitive type instance. Wrapped types -// are roughly equivalent to a nullable, or optionally valued type. -func NewWrapperType(wrapped *exprpb.Type) *exprpb.Type { - primitive := wrapped.GetPrimitive() - if primitive == exprpb.Type_PRIMITIVE_TYPE_UNSPECIFIED { - // TODO: return an error - panic("Wrapped type must be a primitive") - } - return &exprpb.Type{ - TypeKind: &exprpb.Type_Wrapper{ - Wrapper: primitive}} -} diff --git a/vendor/github.com/google/cel-go/checker/env.go b/vendor/github.com/google/cel-go/checker/env.go deleted file mode 100644 index 70682b17c..000000000 --- a/vendor/github.com/google/cel-go/checker/env.go +++ /dev/null @@ -1,276 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package checker - -import ( - "fmt" - "strings" - - "github.com/google/cel-go/common/containers" - "github.com/google/cel-go/common/decls" - "github.com/google/cel-go/common/overloads" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/parser" -) - -type aggregateLiteralElementType int - -const ( - dynElementType aggregateLiteralElementType = iota - homogenousElementType aggregateLiteralElementType = 1 << iota -) - -var ( - crossTypeNumericComparisonOverloads = map[string]struct{}{ - // double <-> int | uint - overloads.LessDoubleInt64: {}, - overloads.LessDoubleUint64: {}, - overloads.LessEqualsDoubleInt64: {}, - overloads.LessEqualsDoubleUint64: {}, - overloads.GreaterDoubleInt64: {}, - overloads.GreaterDoubleUint64: {}, - overloads.GreaterEqualsDoubleInt64: {}, - overloads.GreaterEqualsDoubleUint64: {}, - // int <-> double | uint - overloads.LessInt64Double: {}, - overloads.LessInt64Uint64: {}, - overloads.LessEqualsInt64Double: {}, - overloads.LessEqualsInt64Uint64: {}, - overloads.GreaterInt64Double: {}, - overloads.GreaterInt64Uint64: {}, - overloads.GreaterEqualsInt64Double: {}, - overloads.GreaterEqualsInt64Uint64: {}, - // uint <-> double | int - overloads.LessUint64Double: {}, - overloads.LessUint64Int64: {}, - overloads.LessEqualsUint64Double: {}, - overloads.LessEqualsUint64Int64: {}, - overloads.GreaterUint64Double: {}, - overloads.GreaterUint64Int64: {}, - overloads.GreaterEqualsUint64Double: {}, - overloads.GreaterEqualsUint64Int64: {}, - } -) - -// Env is the environment for type checking. -// -// The Env is comprised of a container, type provider, declarations, and other related objects -// which can be used to assist with type-checking. -type Env struct { - container *containers.Container - provider types.Provider - declarations *Scopes - aggLitElemType aggregateLiteralElementType - filteredOverloadIDs map[string]struct{} -} - -// NewEnv returns a new *Env with the given parameters. -func NewEnv(container *containers.Container, provider types.Provider, opts ...Option) (*Env, error) { - declarations := newScopes() - declarations.Push() - - envOptions := &options{} - for _, opt := range opts { - if err := opt(envOptions); err != nil { - return nil, err - } - } - aggLitElemType := dynElementType - if envOptions.homogeneousAggregateLiterals { - aggLitElemType = homogenousElementType - } - filteredOverloadIDs := crossTypeNumericComparisonOverloads - if envOptions.crossTypeNumericComparisons { - filteredOverloadIDs = make(map[string]struct{}) - } - if envOptions.validatedDeclarations != nil { - declarations = envOptions.validatedDeclarations.Copy() - } - return &Env{ - container: container, - provider: provider, - declarations: declarations, - aggLitElemType: aggLitElemType, - filteredOverloadIDs: filteredOverloadIDs, - }, nil -} - -// AddIdents configures the checker with a list of variable declarations. -// -// If there are overlapping declarations, the method will error. -func (e *Env) AddIdents(declarations ...*decls.VariableDecl) error { - errMsgs := make([]errorMsg, 0) - for _, d := range declarations { - errMsgs = append(errMsgs, e.addIdent(d)) - } - return formatError(errMsgs) -} - -// AddFunctions configures the checker with a list of function declarations. -// -// If there are overlapping declarations, the method will error. -func (e *Env) AddFunctions(declarations ...*decls.FunctionDecl) error { - errMsgs := make([]errorMsg, 0) - for _, d := range declarations { - errMsgs = append(errMsgs, e.setFunction(d)...) - } - return formatError(errMsgs) -} - -// LookupIdent returns a Decl proto for typeName as an identifier in the Env. -// Returns nil if no such identifier is found in the Env. -func (e *Env) LookupIdent(name string) *decls.VariableDecl { - for _, candidate := range e.container.ResolveCandidateNames(name) { - if ident := e.declarations.FindIdent(candidate); ident != nil { - return ident - } - - // Next try to import the name as a reference to a message type. If found, - // the declaration is added to the outest (global) scope of the - // environment, so next time we can access it faster. - if t, found := e.provider.FindStructType(candidate); found { - decl := decls.NewVariable(candidate, t) - e.declarations.AddIdent(decl) - return decl - } - - // Next try to import this as an enum value by splitting the name in a type prefix and - // the enum inside. - if enumValue := e.provider.EnumValue(candidate); enumValue.Type() != types.ErrType { - decl := decls.NewConstant(candidate, types.IntType, enumValue) - e.declarations.AddIdent(decl) - return decl - } - } - return nil -} - -// LookupFunction returns a Decl proto for typeName as a function in env. -// Returns nil if no such function is found in env. -func (e *Env) LookupFunction(name string) *decls.FunctionDecl { - for _, candidate := range e.container.ResolveCandidateNames(name) { - if fn := e.declarations.FindFunction(candidate); fn != nil { - return fn - } - } - return nil -} - -// setFunction adds the function Decl to the Env. -// Adds a function decl if one doesn't already exist, then adds all overloads from the Decl. -// If overload overlaps with an existing overload, adds to the errors in the Env instead. -func (e *Env) setFunction(fn *decls.FunctionDecl) []errorMsg { - errMsgs := make([]errorMsg, 0) - current := e.declarations.FindFunction(fn.Name()) - if current != nil { - var err error - current, err = current.Merge(fn) - if err != nil { - return append(errMsgs, errorMsg(err.Error())) - } - } else { - current = fn - } - for _, overload := range current.OverloadDecls() { - for _, macro := range parser.AllMacros { - if macro.Function() == current.Name() && - macro.IsReceiverStyle() == overload.IsMemberFunction() && - macro.ArgCount() == len(overload.ArgTypes()) { - errMsgs = append(errMsgs, overlappingMacroError(current.Name(), macro.ArgCount())) - } - } - if len(errMsgs) > 0 { - return errMsgs - } - } - e.declarations.SetFunction(current) - return errMsgs -} - -// addIdent adds the Decl to the declarations in the Env. -// Returns a non-empty errorMsg if the identifier is already declared in the scope. -func (e *Env) addIdent(decl *decls.VariableDecl) errorMsg { - current := e.declarations.FindIdentInScope(decl.Name()) - if current != nil { - if current.DeclarationIsEquivalent(decl) { - return "" - } - return overlappingIdentifierError(decl.Name()) - } - e.declarations.AddIdent(decl) - return "" -} - -// isOverloadDisabled returns whether the overloadID is disabled in the current environment. -func (e *Env) isOverloadDisabled(overloadID string) bool { - _, found := e.filteredOverloadIDs[overloadID] - return found -} - -// validatedDeclarations returns a reference to the validated variable and function declaration scope stack. -// must be copied before use. -func (e *Env) validatedDeclarations() *Scopes { - return e.declarations -} - -// enterScope creates a new Env instance with a new innermost declaration scope. -func (e *Env) enterScope() *Env { - childDecls := e.declarations.Push() - return &Env{ - declarations: childDecls, - container: e.container, - provider: e.provider, - aggLitElemType: e.aggLitElemType, - } -} - -// exitScope creates a new Env instance with the nearest outer declaration scope. -func (e *Env) exitScope() *Env { - parentDecls := e.declarations.Pop() - return &Env{ - declarations: parentDecls, - container: e.container, - provider: e.provider, - aggLitElemType: e.aggLitElemType, - } -} - -// errorMsg is a type alias meant to represent error-based return values which -// may be accumulated into an error at a later point in execution. -type errorMsg string - -func overlappingIdentifierError(name string) errorMsg { - return errorMsg(fmt.Sprintf("overlapping identifier for name '%s'", name)) -} - -func overlappingMacroError(name string, argCount int) errorMsg { - return errorMsg(fmt.Sprintf( - "overlapping macro for name '%s' with %d args", name, argCount)) -} - -func formatError(errMsgs []errorMsg) error { - errStrs := make([]string, 0) - if len(errMsgs) > 0 { - for i := 0; i < len(errMsgs); i++ { - if errMsgs[i] != "" { - errStrs = append(errStrs, string(errMsgs[i])) - } - } - } - if len(errStrs) > 0 { - return fmt.Errorf("%s", strings.Join(errStrs, "\n")) - } - return nil -} diff --git a/vendor/github.com/google/cel-go/checker/errors.go b/vendor/github.com/google/cel-go/checker/errors.go deleted file mode 100644 index 8b3bf0b8b..000000000 --- a/vendor/github.com/google/cel-go/checker/errors.go +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package checker - -import ( - "github.com/google/cel-go/common" - "github.com/google/cel-go/common/ast" - "github.com/google/cel-go/common/types" -) - -// typeErrors is a specialization of Errors. -type typeErrors struct { - errs *common.Errors -} - -func (e *typeErrors) fieldTypeMismatch(id int64, l common.Location, name string, field, value *types.Type) { - e.errs.ReportErrorAtID(id, l, "expected type of field '%s' is '%s' but provided type is '%s'", - name, FormatCELType(field), FormatCELType(value)) -} - -func (e *typeErrors) incompatibleType(id int64, l common.Location, ex ast.Expr, prev, next *types.Type) { - e.errs.ReportErrorAtID(id, l, - "incompatible type already exists for expression: %v(%d) old:%v, new:%v", ex, ex.ID(), prev, next) -} - -func (e *typeErrors) noMatchingOverload(id int64, l common.Location, name string, args []*types.Type, isInstance bool) { - signature := formatFunctionDeclType(nil, args, isInstance) - e.errs.ReportErrorAtID(id, l, "found no matching overload for '%s' applied to '%s'", name, signature) -} - -func (e *typeErrors) notAComprehensionRange(id int64, l common.Location, t *types.Type) { - e.errs.ReportErrorAtID(id, l, "expression of type '%s' cannot be range of a comprehension (must be list, map, or dynamic)", - FormatCELType(t)) -} - -func (e *typeErrors) notAnOptionalFieldSelection(id int64, l common.Location, field ast.Expr) { - e.errs.ReportErrorAtID(id, l, "unsupported optional field selection: %v", field) -} - -func (e *typeErrors) notAType(id int64, l common.Location, typeName string) { - e.errs.ReportErrorAtID(id, l, "'%s' is not a type", typeName) -} - -func (e *typeErrors) notAMessageType(id int64, l common.Location, typeName string) { - e.errs.ReportErrorAtID(id, l, "'%s' is not a message type", typeName) -} - -func (e *typeErrors) referenceRedefinition(id int64, l common.Location, ex ast.Expr, prev, next *ast.ReferenceInfo) { - e.errs.ReportErrorAtID(id, l, - "reference already exists for expression: %v(%d) old:%v, new:%v", ex, ex.ID(), prev, next) -} - -func (e *typeErrors) typeDoesNotSupportFieldSelection(id int64, l common.Location, t *types.Type) { - e.errs.ReportErrorAtID(id, l, "type '%s' does not support field selection", FormatCELType(t)) -} - -func (e *typeErrors) typeMismatch(id int64, l common.Location, expected, actual *types.Type) { - e.errs.ReportErrorAtID(id, l, "expected type '%s' but found '%s'", - FormatCELType(expected), FormatCELType(actual)) -} - -func (e *typeErrors) undefinedField(id int64, l common.Location, field string) { - e.errs.ReportErrorAtID(id, l, "undefined field '%s'", field) -} - -func (e *typeErrors) undeclaredReference(id int64, l common.Location, container string, name string) { - e.errs.ReportErrorAtID(id, l, "undeclared reference to '%s' (in container '%s')", name, container) -} - -func (e *typeErrors) unexpectedFailedResolution(id int64, l common.Location, typeName string) { - e.errs.ReportErrorAtID(id, l, "unexpected failed resolution of '%s'", typeName) -} - -func (e *typeErrors) unexpectedASTType(id int64, l common.Location, kind, typeName string) { - e.errs.ReportErrorAtID(id, l, "unexpected %s type: %v", kind, typeName) -} diff --git a/vendor/github.com/google/cel-go/checker/format.go b/vendor/github.com/google/cel-go/checker/format.go deleted file mode 100644 index 95842905e..000000000 --- a/vendor/github.com/google/cel-go/checker/format.go +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package checker - -import ( - "fmt" - "strings" - - chkdecls "github.com/google/cel-go/checker/decls" - "github.com/google/cel-go/common/types" - - exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1" -) - -const ( - kindUnknown = iota + 1 - kindError - kindFunction - kindDyn - kindPrimitive - kindWellKnown - kindWrapper - kindNull - kindAbstract - kindType - kindList - kindMap - kindObject - kindTypeParam -) - -// FormatCheckedType converts a type message into a string representation. -func FormatCheckedType(t *exprpb.Type) string { - switch kindOf(t) { - case kindDyn: - return "dyn" - case kindFunction: - return formatFunctionExprType(t.GetFunction().GetResultType(), - t.GetFunction().GetArgTypes(), - false) - case kindList: - return fmt.Sprintf("list(%s)", FormatCheckedType(t.GetListType().GetElemType())) - case kindObject: - return t.GetMessageType() - case kindMap: - return fmt.Sprintf("map(%s, %s)", - FormatCheckedType(t.GetMapType().GetKeyType()), - FormatCheckedType(t.GetMapType().GetValueType())) - case kindNull: - return "null" - case kindPrimitive: - switch t.GetPrimitive() { - case exprpb.Type_UINT64: - return "uint" - case exprpb.Type_INT64: - return "int" - } - return strings.Trim(strings.ToLower(t.GetPrimitive().String()), " ") - case kindType: - if t.GetType() == nil || t.GetType().GetTypeKind() == nil { - return "type" - } - return fmt.Sprintf("type(%s)", FormatCheckedType(t.GetType())) - case kindWellKnown: - switch t.GetWellKnown() { - case exprpb.Type_ANY: - return "any" - case exprpb.Type_DURATION: - return "duration" - case exprpb.Type_TIMESTAMP: - return "timestamp" - } - case kindWrapper: - return fmt.Sprintf("wrapper(%s)", - FormatCheckedType(chkdecls.NewPrimitiveType(t.GetWrapper()))) - case kindError: - return "!error!" - case kindTypeParam: - return t.GetTypeParam() - case kindAbstract: - at := t.GetAbstractType() - params := at.GetParameterTypes() - paramStrs := make([]string, len(params)) - for i, p := range params { - paramStrs[i] = FormatCheckedType(p) - } - return fmt.Sprintf("%s(%s)", at.GetName(), strings.Join(paramStrs, ", ")) - } - return t.String() -} - -type formatter func(any) string - -// FormatCELType formats a types.Type value to a string representation. -// -// The type formatting is identical to FormatCheckedType. -func FormatCELType(t any) string { - dt := t.(*types.Type) - switch dt.Kind() { - case types.AnyKind: - return "any" - case types.DurationKind: - return "duration" - case types.ErrorKind: - return "!error!" - case types.NullTypeKind: - return "null" - case types.TimestampKind: - return "timestamp" - case types.TypeParamKind: - return dt.TypeName() - case types.OpaqueKind: - if dt.TypeName() == "function" { - // There is no explicit function type in the new types representation, so information like - // whether the function is a member function is absent. - return formatFunctionDeclType(dt.Parameters()[0], dt.Parameters()[1:], false) - } - case types.UnspecifiedKind: - return "" - } - if len(dt.Parameters()) == 0 { - return dt.DeclaredTypeName() - } - paramTypeNames := make([]string, 0, len(dt.Parameters())) - for _, p := range dt.Parameters() { - paramTypeNames = append(paramTypeNames, FormatCELType(p)) - } - return fmt.Sprintf("%s(%s)", dt.TypeName(), strings.Join(paramTypeNames, ", ")) -} - -func formatExprType(t any) string { - if t == nil { - return "" - } - return FormatCheckedType(t.(*exprpb.Type)) -} - -func formatFunctionExprType(resultType *exprpb.Type, argTypes []*exprpb.Type, isInstance bool) string { - return formatFunctionInternal[*exprpb.Type](resultType, argTypes, isInstance, formatExprType) -} - -func formatFunctionDeclType(resultType *types.Type, argTypes []*types.Type, isInstance bool) string { - return formatFunctionInternal[*types.Type](resultType, argTypes, isInstance, FormatCELType) -} - -func formatFunctionInternal[T any](resultType T, argTypes []T, isInstance bool, format formatter) string { - result := "" - if isInstance { - target := argTypes[0] - argTypes = argTypes[1:] - result += format(target) - result += "." - } - result += "(" - for i, arg := range argTypes { - if i > 0 { - result += ", " - } - result += format(arg) - } - result += ")" - rt := format(resultType) - if rt != "" { - result += " -> " - result += rt - } - return result -} - -// kindOf returns the kind of the type as defined in the checked.proto. -func kindOf(t *exprpb.Type) int { - if t == nil || t.TypeKind == nil { - return kindUnknown - } - switch t.GetTypeKind().(type) { - case *exprpb.Type_Error: - return kindError - case *exprpb.Type_Function: - return kindFunction - case *exprpb.Type_Dyn: - return kindDyn - case *exprpb.Type_Primitive: - return kindPrimitive - case *exprpb.Type_WellKnown: - return kindWellKnown - case *exprpb.Type_Wrapper: - return kindWrapper - case *exprpb.Type_Null: - return kindNull - case *exprpb.Type_Type: - return kindType - case *exprpb.Type_ListType_: - return kindList - case *exprpb.Type_MapType_: - return kindMap - case *exprpb.Type_MessageType: - return kindObject - case *exprpb.Type_TypeParam: - return kindTypeParam - case *exprpb.Type_AbstractType_: - return kindAbstract - } - return kindUnknown -} diff --git a/vendor/github.com/google/cel-go/checker/mapping.go b/vendor/github.com/google/cel-go/checker/mapping.go deleted file mode 100644 index 8163a908a..000000000 --- a/vendor/github.com/google/cel-go/checker/mapping.go +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package checker - -import ( - "github.com/google/cel-go/common/types" -) - -type mapping struct { - mapping map[string]*types.Type -} - -func newMapping() *mapping { - return &mapping{ - mapping: make(map[string]*types.Type), - } -} - -func (m *mapping) add(from, to *types.Type) { - m.mapping[FormatCELType(from)] = to -} - -func (m *mapping) find(from *types.Type) (*types.Type, bool) { - if r, found := m.mapping[FormatCELType(from)]; found { - return r, found - } - return nil, false -} - -func (m *mapping) copy() *mapping { - c := newMapping() - - for k, v := range m.mapping { - c.mapping[k] = v - } - return c -} diff --git a/vendor/github.com/google/cel-go/checker/options.go b/vendor/github.com/google/cel-go/checker/options.go deleted file mode 100644 index 0560c3813..000000000 --- a/vendor/github.com/google/cel-go/checker/options.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package checker - -type options struct { - crossTypeNumericComparisons bool - homogeneousAggregateLiterals bool - validatedDeclarations *Scopes -} - -// Option is a functional option for configuring the type-checker -type Option func(*options) error - -// CrossTypeNumericComparisons toggles type-checker support for numeric comparisons across type -// See https://github.com/google/cel-spec/wiki/proposal-210 for more details. -func CrossTypeNumericComparisons(enabled bool) Option { - return func(opts *options) error { - opts.crossTypeNumericComparisons = enabled - return nil - } -} - -// ValidatedDeclarations provides a references to validated declarations which will be copied -// into new checker instances. -func ValidatedDeclarations(env *Env) Option { - return func(opts *options) error { - opts.validatedDeclarations = env.validatedDeclarations() - return nil - } -} diff --git a/vendor/github.com/google/cel-go/checker/printer.go b/vendor/github.com/google/cel-go/checker/printer.go deleted file mode 100644 index 7a3984f02..000000000 --- a/vendor/github.com/google/cel-go/checker/printer.go +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package checker - -import ( - "sort" - - "github.com/google/cel-go/common/ast" - "github.com/google/cel-go/common/debug" -) - -type semanticAdorner struct { - checked *ast.AST -} - -var _ debug.Adorner = &semanticAdorner{} - -func (a *semanticAdorner) GetMetadata(elem any) string { - result := "" - e, isExpr := elem.(ast.Expr) - if !isExpr { - return result - } - t := a.checked.TypeMap()[e.ID()] - if t != nil { - result += "~" - result += FormatCELType(t) - } - - switch e.Kind() { - case ast.IdentKind, - ast.CallKind, - ast.ListKind, - ast.StructKind, - ast.SelectKind: - if ref, found := a.checked.ReferenceMap()[e.ID()]; found { - if len(ref.OverloadIDs) == 0 { - result += "^" + ref.Name - } else { - sort.Strings(ref.OverloadIDs) - for i, overload := range ref.OverloadIDs { - if i == 0 { - result += "^" - } else { - result += "|" - } - result += overload - } - } - } - } - - return result -} - -// Print returns a string representation of the Expr message, -// annotated with types from the CheckedExpr. The Expr must -// be a sub-expression embedded in the CheckedExpr. -func Print(e ast.Expr, checked *ast.AST) string { - a := &semanticAdorner{checked: checked} - return debug.ToAdornedDebugString(e, a) -} diff --git a/vendor/github.com/google/cel-go/checker/scopes.go b/vendor/github.com/google/cel-go/checker/scopes.go deleted file mode 100644 index 8bb73ddb6..000000000 --- a/vendor/github.com/google/cel-go/checker/scopes.go +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package checker - -import ( - "github.com/google/cel-go/common/decls" -) - -// Scopes represents nested Decl sets where the Scopes value contains a Groups containing all -// identifiers in scope and an optional parent representing outer scopes. -// Each Groups value is a mapping of names to Decls in the ident and function namespaces. -// Lookups are performed such that bindings in inner scopes shadow those in outer scopes. -type Scopes struct { - parent *Scopes - scopes *Group -} - -// newScopes creates a new, empty Scopes. -// Some operations can't be safely performed until a Group is added with Push. -func newScopes() *Scopes { - return &Scopes{ - scopes: newGroup(), - } -} - -// Copy creates a copy of the current Scopes values, including a copy of its parent if non-nil. -func (s *Scopes) Copy() *Scopes { - cpy := newScopes() - if s == nil { - return cpy - } - if s.parent != nil { - cpy.parent = s.parent.Copy() - } - cpy.scopes = s.scopes.copy() - return cpy -} - -// Push creates a new Scopes value which references the current Scope as its parent. -func (s *Scopes) Push() *Scopes { - return &Scopes{ - parent: s, - scopes: newGroup(), - } -} - -// Pop returns the parent Scopes value for the current scope, or the current scope if the parent -// is nil. -func (s *Scopes) Pop() *Scopes { - if s.parent != nil { - return s.parent - } - // TODO: Consider whether this should be an error / panic. - return s -} - -// AddIdent adds the ident Decl in the current scope. -// Note: If the name collides with an existing identifier in the scope, the Decl is overwritten. -func (s *Scopes) AddIdent(decl *decls.VariableDecl) { - s.scopes.idents[decl.Name()] = decl -} - -// FindIdent finds the first ident Decl with a matching name in Scopes, or nil if one cannot be -// found. -// Note: The search is performed from innermost to outermost. -func (s *Scopes) FindIdent(name string) *decls.VariableDecl { - if ident, found := s.scopes.idents[name]; found { - return ident - } - if s.parent != nil { - return s.parent.FindIdent(name) - } - return nil -} - -// FindIdentInScope finds the first ident Decl with a matching name in the current Scopes value, or -// nil if one does not exist. -// Note: The search is only performed on the current scope and does not search outer scopes. -func (s *Scopes) FindIdentInScope(name string) *decls.VariableDecl { - if ident, found := s.scopes.idents[name]; found { - return ident - } - return nil -} - -// SetFunction adds the function Decl to the current scope. -// Note: Any previous entry for a function in the current scope with the same name is overwritten. -func (s *Scopes) SetFunction(fn *decls.FunctionDecl) { - s.scopes.functions[fn.Name()] = fn -} - -// FindFunction finds the first function Decl with a matching name in Scopes. -// The search is performed from innermost to outermost. -// Returns nil if no such function in Scopes. -func (s *Scopes) FindFunction(name string) *decls.FunctionDecl { - if fn, found := s.scopes.functions[name]; found { - return fn - } - if s.parent != nil { - return s.parent.FindFunction(name) - } - return nil -} - -// Group is a set of Decls that is pushed on or popped off a Scopes as a unit. -// Contains separate namespaces for identifier and function Decls. -// (Should be named "Scope" perhaps?) -type Group struct { - idents map[string]*decls.VariableDecl - functions map[string]*decls.FunctionDecl -} - -// copy creates a new Group instance with a shallow copy of the variables and functions. -// If callers need to mutate the exprpb.Decl definitions for a Function, they should copy-on-write. -func (g *Group) copy() *Group { - cpy := &Group{ - idents: make(map[string]*decls.VariableDecl, len(g.idents)), - functions: make(map[string]*decls.FunctionDecl, len(g.functions)), - } - for n, id := range g.idents { - cpy.idents[n] = id - } - for n, fn := range g.functions { - cpy.functions[n] = fn - } - return cpy -} - -// newGroup creates a new Group with empty maps for identifiers and functions. -func newGroup() *Group { - return &Group{ - idents: make(map[string]*decls.VariableDecl), - functions: make(map[string]*decls.FunctionDecl), - } -} diff --git a/vendor/github.com/google/cel-go/checker/standard.go b/vendor/github.com/google/cel-go/checker/standard.go deleted file mode 100644 index 11b35b80e..000000000 --- a/vendor/github.com/google/cel-go/checker/standard.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package checker - -import ( - "github.com/google/cel-go/common/stdlib" - - exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1" -) - -// StandardFunctions returns the Decls for all functions in the evaluator. -// -// Deprecated: prefer stdlib.FunctionExprDecls() -func StandardFunctions() []*exprpb.Decl { - return stdlib.FunctionExprDecls() -} - -// StandardTypes returns the set of type identifiers for standard library types. -// -// Deprecated: prefer stdlib.TypeExprDecls() -func StandardTypes() []*exprpb.Decl { - return stdlib.TypeExprDecls() -} diff --git a/vendor/github.com/google/cel-go/checker/types.go b/vendor/github.com/google/cel-go/checker/types.go deleted file mode 100644 index e2373d1b7..000000000 --- a/vendor/github.com/google/cel-go/checker/types.go +++ /dev/null @@ -1,309 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package checker - -import ( - "github.com/google/cel-go/common/types" -) - -// isDyn returns true if the input t is either type DYN or a well-known ANY message. -func isDyn(t *types.Type) bool { - // Note: object type values that are well-known and map to a DYN value in practice - // are sanitized prior to being added to the environment. - switch t.Kind() { - case types.DynKind, types.AnyKind: - return true - default: - return false - } -} - -// isDynOrError returns true if the input is either an Error, DYN, or well-known ANY message. -func isDynOrError(t *types.Type) bool { - return isError(t) || isDyn(t) -} - -func isError(t *types.Type) bool { - return t.Kind() == types.ErrorKind -} - -func isOptional(t *types.Type) bool { - if t.Kind() == types.OpaqueKind { - return t.TypeName() == "optional" - } - return false -} - -func maybeUnwrapOptional(t *types.Type) (*types.Type, bool) { - if isOptional(t) { - return t.Parameters()[0], true - } - return t, false -} - -// isEqualOrLessSpecific checks whether one type is equal or less specific than the other one. -// A type is less specific if it matches the other type using the DYN type. -func isEqualOrLessSpecific(t1, t2 *types.Type) bool { - kind1, kind2 := t1.Kind(), t2.Kind() - // The first type is less specific. - if isDyn(t1) || kind1 == types.TypeParamKind { - return true - } - // The first type is not less specific. - if isDyn(t2) || kind2 == types.TypeParamKind { - return false - } - // Types must be of the same kind to be equal. - if kind1 != kind2 { - return false - } - - // With limited exceptions for ANY and JSON values, the types must agree and be equivalent in - // order to return true. - switch kind1 { - case types.OpaqueKind: - if t1.TypeName() != t2.TypeName() || - len(t1.Parameters()) != len(t2.Parameters()) { - return false - } - for i, p1 := range t1.Parameters() { - if !isEqualOrLessSpecific(p1, t2.Parameters()[i]) { - return false - } - } - return true - case types.ListKind: - return isEqualOrLessSpecific(t1.Parameters()[0], t2.Parameters()[0]) - case types.MapKind: - return isEqualOrLessSpecific(t1.Parameters()[0], t2.Parameters()[0]) && - isEqualOrLessSpecific(t1.Parameters()[1], t2.Parameters()[1]) - case types.TypeKind: - return true - default: - return t1.IsExactType(t2) - } -} - -// / internalIsAssignable returns true if t1 is assignable to t2. -func internalIsAssignable(m *mapping, t1, t2 *types.Type) bool { - // Process type parameters. - kind1, kind2 := t1.Kind(), t2.Kind() - if kind2 == types.TypeParamKind { - // If t2 is a valid type substitution for t1, return true. - valid, t2HasSub := isValidTypeSubstitution(m, t1, t2) - if valid { - return true - } - // If t2 is not a valid type sub for t1, and already has a known substitution return false - // since it is not possible for t1 to be a substitution for t2. - if !valid && t2HasSub { - return false - } - // Otherwise, fall through to check whether t1 is a possible substitution for t2. - } - if kind1 == types.TypeParamKind { - // Return whether t1 is a valid substitution for t2. If not, do no additional checks as the - // possible type substitutions have been searched in both directions. - valid, _ := isValidTypeSubstitution(m, t2, t1) - return valid - } - - // Next check for wildcard types. - if isDynOrError(t1) || isDynOrError(t2) { - return true - } - // Preserve the nullness checks of the legacy type-checker. - if kind1 == types.NullTypeKind { - return internalIsAssignableNull(t2) - } - if kind2 == types.NullTypeKind { - return internalIsAssignableNull(t1) - } - - // Test for when the types do not need to agree, but are more specific than dyn. - switch kind1 { - case types.BoolKind, types.BytesKind, types.DoubleKind, types.IntKind, types.StringKind, types.UintKind, - types.AnyKind, types.DurationKind, types.TimestampKind, - types.StructKind: - return t1.IsAssignableType(t2) - case types.TypeKind: - return kind2 == types.TypeKind - case types.OpaqueKind, types.ListKind, types.MapKind: - return t1.Kind() == t2.Kind() && t1.TypeName() == t2.TypeName() && - internalIsAssignableList(m, t1.Parameters(), t2.Parameters()) - default: - return false - } -} - -// isValidTypeSubstitution returns whether t2 (or its type substitution) is a valid type -// substitution for t1, and whether t2 has a type substitution in mapping m. -// -// The type t2 is a valid substitution for t1 if any of the following statements is true -// - t2 has a type substitution (t2sub) equal to t1 -// - t2 has a type substitution (t2sub) assignable to t1 -// - t2 does not occur within t1. -func isValidTypeSubstitution(m *mapping, t1, t2 *types.Type) (valid, hasSub bool) { - // Early return if the t1 and t2 are the same instance. - kind1, kind2 := t1.Kind(), t2.Kind() - if kind1 == kind2 && t1.IsExactType(t2) { - return true, true - } - if t2Sub, found := m.find(t2); found { - // Early return if t1 and t2Sub are the same instance as otherwise the mapping - // might mark a type as being a subtitution for itself. - if kind1 == t2Sub.Kind() && t1.IsExactType(t2Sub) { - return true, true - } - // If the types are compatible, pick the more general type and return true - if internalIsAssignable(m, t1, t2Sub) { - t2New := mostGeneral(t1, t2Sub) - // only update the type reference map if the target type does not occur within it. - if notReferencedIn(m, t2, t2New) { - m.add(t2, t2New) - } - // acknowledge the type agreement, and that the substitution is already tracked. - return true, true - } - return false, true - } - if notReferencedIn(m, t2, t1) { - m.add(t2, t1) - return true, false - } - return false, false -} - -// internalIsAssignableList returns true if the element types at each index in the list are -// assignable from l1[i] to l2[i]. The list lengths must also agree for the lists to be -// assignable. -func internalIsAssignableList(m *mapping, l1, l2 []*types.Type) bool { - if len(l1) != len(l2) { - return false - } - for i, t1 := range l1 { - if !internalIsAssignable(m, t1, l2[i]) { - return false - } - } - return true -} - -// internalIsAssignableNull returns true if the type is nullable. -func internalIsAssignableNull(t *types.Type) bool { - return isLegacyNullable(t) || t.IsAssignableType(types.NullType) -} - -// isLegacyNullable preserves the null-ness compatibility of the original type-checker implementation. -func isLegacyNullable(t *types.Type) bool { - switch t.Kind() { - case types.OpaqueKind, types.StructKind, types.AnyKind, types.DurationKind, types.TimestampKind: - return true - } - return false -} - -// isAssignable returns an updated type substitution mapping if t1 is assignable to t2. -func isAssignable(m *mapping, t1, t2 *types.Type) *mapping { - mCopy := m.copy() - if internalIsAssignable(mCopy, t1, t2) { - return mCopy - } - return nil -} - -// isAssignableList returns an updated type substitution mapping if l1 is assignable to l2. -func isAssignableList(m *mapping, l1, l2 []*types.Type) *mapping { - mCopy := m.copy() - if internalIsAssignableList(mCopy, l1, l2) { - return mCopy - } - return nil -} - -// mostGeneral returns the more general of two types which are known to unify. -func mostGeneral(t1, t2 *types.Type) *types.Type { - if isEqualOrLessSpecific(t1, t2) { - return t1 - } - return t2 -} - -// notReferencedIn checks whether the type doesn't appear directly or transitively within the other -// type. This is a standard requirement for type unification, commonly referred to as the "occurs -// check". -func notReferencedIn(m *mapping, t, withinType *types.Type) bool { - if t.IsExactType(withinType) { - return false - } - withinKind := withinType.Kind() - switch withinKind { - case types.TypeParamKind: - wtSub, found := m.find(withinType) - if !found { - return true - } - return notReferencedIn(m, t, wtSub) - case types.OpaqueKind, types.ListKind, types.MapKind: - for _, pt := range withinType.Parameters() { - if !notReferencedIn(m, t, pt) { - return false - } - } - return true - default: - return true - } -} - -// substitute replaces all direct and indirect occurrences of bound type parameters. Unbound type -// parameters are replaced by DYN if typeParamToDyn is true. -func substitute(m *mapping, t *types.Type, typeParamToDyn bool) *types.Type { - if tSub, found := m.find(t); found { - return substitute(m, tSub, typeParamToDyn) - } - kind := t.Kind() - if typeParamToDyn && kind == types.TypeParamKind { - return types.DynType - } - switch kind { - case types.OpaqueKind: - return types.NewOpaqueType(t.TypeName(), substituteParams(m, t.Parameters(), typeParamToDyn)...) - case types.ListKind: - return types.NewListType(substitute(m, t.Parameters()[0], typeParamToDyn)) - case types.MapKind: - return types.NewMapType(substitute(m, t.Parameters()[0], typeParamToDyn), - substitute(m, t.Parameters()[1], typeParamToDyn)) - case types.TypeKind: - if len(t.Parameters()) > 0 { - return types.NewTypeTypeWithParam(substitute(m, t.Parameters()[0], typeParamToDyn)) - } - return t - default: - return t - } -} - -func substituteParams(m *mapping, typeParams []*types.Type, typeParamToDyn bool) []*types.Type { - subParams := make([]*types.Type, len(typeParams)) - for i, tp := range typeParams { - subParams[i] = substitute(m, tp, typeParamToDyn) - } - return subParams -} - -func newFunctionType(resultType *types.Type, argTypes ...*types.Type) *types.Type { - return types.NewOpaqueType("function", append([]*types.Type{resultType}, argTypes...)...) -} diff --git a/vendor/github.com/google/cel-go/common/BUILD.bazel b/vendor/github.com/google/cel-go/common/BUILD.bazel deleted file mode 100644 index d6165b13a..000000000 --- a/vendor/github.com/google/cel-go/common/BUILD.bazel +++ /dev/null @@ -1,35 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -package( - default_visibility = ["//visibility:public"], - licenses = ["notice"], # Apache 2.0 -) - -go_library( - name = "go_default_library", - srcs = [ - "cost.go", - "error.go", - "errors.go", - "location.go", - "source.go", - ], - importpath = "github.com/google/cel-go/common", - deps = [ - "//common/runes:go_default_library", - "@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library", - "@org_golang_x_text//width:go_default_library", - ], -) - -go_test( - name = "go_default_test", - size = "small", - srcs = [ - "errors_test.go", - "source_test.go", - ], - embed = [ - ":go_default_library", - ], -) diff --git a/vendor/github.com/google/cel-go/common/ast/BUILD.bazel b/vendor/github.com/google/cel-go/common/ast/BUILD.bazel deleted file mode 100644 index c92a0f179..000000000 --- a/vendor/github.com/google/cel-go/common/ast/BUILD.bazel +++ /dev/null @@ -1,61 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -package( - default_visibility = [ - "//cel:__subpackages__", - "//checker:__subpackages__", - "//common:__subpackages__", - "//ext:__subpackages__", - "//interpreter:__subpackages__", - "//parser:__subpackages__", - ], - licenses = ["notice"], # Apache 2.0 -) - -go_library( - name = "go_default_library", - srcs = [ - "ast.go", - "conversion.go", - "expr.go", - "factory.go", - "navigable.go", - ], - importpath = "github.com/google/cel-go/common/ast", - deps = [ - "//common:go_default_library", - "//common/types:go_default_library", - "//common/types/ref:go_default_library", - "@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library", - "@org_golang_google_protobuf//types/known/structpb:go_default_library", - ], -) - -go_test( - name = "go_default_test", - srcs = [ - "ast_test.go", - "conversion_test.go", - "expr_test.go", - "navigable_test.go", - ], - embed = [ - ":go_default_library", - ], - deps = [ - "//checker:go_default_library", - "//checker/decls:go_default_library", - "//common:go_default_library", - "//common/containers:go_default_library", - "//common/decls:go_default_library", - "//common/overloads:go_default_library", - "//common/stdlib:go_default_library", - "//common/types:go_default_library", - "//common/types/ref:go_default_library", - "//parser:go_default_library", - "//test/proto3pb:go_default_library", - "@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library", - "@org_golang_google_protobuf//proto:go_default_library", - "@org_golang_google_protobuf//encoding/prototext:go_default_library", - ], -) \ No newline at end of file diff --git a/vendor/github.com/google/cel-go/common/ast/ast.go b/vendor/github.com/google/cel-go/common/ast/ast.go deleted file mode 100644 index 4feddaa3a..000000000 --- a/vendor/github.com/google/cel-go/common/ast/ast.go +++ /dev/null @@ -1,450 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package ast declares data structures useful for parsed and checked abstract syntax trees -package ast - -import ( - "github.com/google/cel-go/common" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/common/types/ref" -) - -// AST contains a protobuf expression and source info along with CEL-native type and reference information. -type AST struct { - expr Expr - sourceInfo *SourceInfo - typeMap map[int64]*types.Type - refMap map[int64]*ReferenceInfo -} - -// Expr returns the root ast.Expr value in the AST. -func (a *AST) Expr() Expr { - if a == nil { - return nilExpr - } - return a.expr -} - -// SourceInfo returns the source metadata associated with the parse / type-check passes. -func (a *AST) SourceInfo() *SourceInfo { - if a == nil { - return nil - } - return a.sourceInfo -} - -// GetType returns the type for the expression at the given id, if one exists, else types.DynType. -func (a *AST) GetType(id int64) *types.Type { - if t, found := a.TypeMap()[id]; found { - return t - } - return types.DynType -} - -// SetType sets the type of the expression node at the given id. -func (a *AST) SetType(id int64, t *types.Type) { - if a == nil { - return - } - a.typeMap[id] = t -} - -// TypeMap returns the map of expression ids to type-checked types. -// -// If the AST is not type-checked, the map will be empty. -func (a *AST) TypeMap() map[int64]*types.Type { - if a == nil { - return map[int64]*types.Type{} - } - return a.typeMap -} - -// GetOverloadIDs returns the set of overload function names for a given expression id. -// -// If the expression id is not a function call, or the AST is not type-checked, the result will be empty. -func (a *AST) GetOverloadIDs(id int64) []string { - if ref, found := a.ReferenceMap()[id]; found { - return ref.OverloadIDs - } - return []string{} -} - -// ReferenceMap returns the map of expression id to identifier, constant, and function references. -func (a *AST) ReferenceMap() map[int64]*ReferenceInfo { - if a == nil { - return map[int64]*ReferenceInfo{} - } - return a.refMap -} - -// SetReference adds a reference to the checked AST type map. -func (a *AST) SetReference(id int64, r *ReferenceInfo) { - if a == nil { - return - } - a.refMap[id] = r -} - -// IsChecked returns whether the AST is type-checked. -func (a *AST) IsChecked() bool { - return a != nil && len(a.TypeMap()) > 0 -} - -// NewAST creates a base AST instance with an ast.Expr and ast.SourceInfo value. -func NewAST(e Expr, sourceInfo *SourceInfo) *AST { - if e == nil { - e = nilExpr - } - return &AST{ - expr: e, - sourceInfo: sourceInfo, - typeMap: make(map[int64]*types.Type), - refMap: make(map[int64]*ReferenceInfo), - } -} - -// NewCheckedAST wraps an parsed AST and augments it with type and reference metadata. -func NewCheckedAST(parsed *AST, typeMap map[int64]*types.Type, refMap map[int64]*ReferenceInfo) *AST { - return &AST{ - expr: parsed.Expr(), - sourceInfo: parsed.SourceInfo(), - typeMap: typeMap, - refMap: refMap, - } -} - -// Copy creates a deep copy of the Expr and SourceInfo values in the input AST. -// -// Copies of the Expr value are generated using an internal default ExprFactory. -func Copy(a *AST) *AST { - if a == nil { - return nil - } - e := defaultFactory.CopyExpr(a.expr) - if !a.IsChecked() { - return NewAST(e, CopySourceInfo(a.SourceInfo())) - } - typesCopy := make(map[int64]*types.Type, len(a.typeMap)) - for id, t := range a.typeMap { - typesCopy[id] = t - } - refsCopy := make(map[int64]*ReferenceInfo, len(a.refMap)) - for id, r := range a.refMap { - refsCopy[id] = r - } - return NewCheckedAST(NewAST(e, CopySourceInfo(a.SourceInfo())), typesCopy, refsCopy) -} - -// MaxID returns the upper-bound, non-inclusive, of ids present within the AST's Expr value. -func MaxID(a *AST) int64 { - visitor := &maxIDVisitor{maxID: 1} - PostOrderVisit(a.Expr(), visitor) - return visitor.maxID + 1 -} - -// NewSourceInfo creates a simple SourceInfo object from an input common.Source value. -func NewSourceInfo(src common.Source) *SourceInfo { - var lineOffsets []int32 - var desc string - baseLine := int32(0) - baseCol := int32(0) - if src != nil { - desc = src.Description() - lineOffsets = src.LineOffsets() - // Determine whether the source metadata should be computed relative - // to a base line and column value. This can be determined by requesting - // the location for offset 0 from the source object. - if loc, found := src.OffsetLocation(0); found { - baseLine = int32(loc.Line()) - 1 - baseCol = int32(loc.Column()) - } - } - return &SourceInfo{ - desc: desc, - lines: lineOffsets, - baseLine: baseLine, - baseCol: baseCol, - offsetRanges: make(map[int64]OffsetRange), - macroCalls: make(map[int64]Expr), - } -} - -// CopySourceInfo creates a deep copy of the MacroCalls within the input SourceInfo. -// -// Copies of macro Expr values are generated using an internal default ExprFactory. -func CopySourceInfo(info *SourceInfo) *SourceInfo { - if info == nil { - return nil - } - rangesCopy := make(map[int64]OffsetRange, len(info.offsetRanges)) - for id, off := range info.offsetRanges { - rangesCopy[id] = off - } - callsCopy := make(map[int64]Expr, len(info.macroCalls)) - for id, call := range info.macroCalls { - callsCopy[id] = defaultFactory.CopyExpr(call) - } - return &SourceInfo{ - syntax: info.syntax, - desc: info.desc, - lines: info.lines, - baseLine: info.baseLine, - baseCol: info.baseCol, - offsetRanges: rangesCopy, - macroCalls: callsCopy, - } -} - -// SourceInfo records basic information about the expression as a textual input and -// as a parsed expression value. -type SourceInfo struct { - syntax string - desc string - lines []int32 - baseLine int32 - baseCol int32 - offsetRanges map[int64]OffsetRange - macroCalls map[int64]Expr -} - -// SyntaxVersion returns the syntax version associated with the text expression. -func (s *SourceInfo) SyntaxVersion() string { - if s == nil { - return "" - } - return s.syntax -} - -// Description provides information about where the expression came from. -func (s *SourceInfo) Description() string { - if s == nil { - return "" - } - return s.desc -} - -// LineOffsets returns a list of the 0-based character offsets in the input text where newlines appear. -func (s *SourceInfo) LineOffsets() []int32 { - if s == nil { - return []int32{} - } - return s.lines -} - -// MacroCalls returns a map of expression id to ast.Expr value where the id represents the expression -// node where the macro was inserted into the AST, and the ast.Expr value represents the original call -// signature which was replaced. -func (s *SourceInfo) MacroCalls() map[int64]Expr { - if s == nil { - return map[int64]Expr{} - } - return s.macroCalls -} - -// GetMacroCall returns the original ast.Expr value for the given expression if it was generated via -// a macro replacement. -// -// Note, parsing options must be enabled to track macro calls before this method will return a value. -func (s *SourceInfo) GetMacroCall(id int64) (Expr, bool) { - e, found := s.MacroCalls()[id] - return e, found -} - -// SetMacroCall records a macro call at a specific location. -func (s *SourceInfo) SetMacroCall(id int64, e Expr) { - if s != nil { - s.macroCalls[id] = e - } -} - -// ClearMacroCall removes the macro call at the given expression id. -func (s *SourceInfo) ClearMacroCall(id int64) { - if s != nil { - delete(s.macroCalls, id) - } -} - -// OffsetRanges returns a map of expression id to OffsetRange values where the range indicates either: -// the start and end position in the input stream where the expression occurs, or the start position -// only. If the range only captures start position, the stop position of the range will be equal to -// the start. -func (s *SourceInfo) OffsetRanges() map[int64]OffsetRange { - if s == nil { - return map[int64]OffsetRange{} - } - return s.offsetRanges -} - -// GetOffsetRange retrieves an OffsetRange for the given expression id if one exists. -func (s *SourceInfo) GetOffsetRange(id int64) (OffsetRange, bool) { - if s == nil { - return OffsetRange{}, false - } - o, found := s.offsetRanges[id] - return o, found -} - -// SetOffsetRange sets the OffsetRange for the given expression id. -func (s *SourceInfo) SetOffsetRange(id int64, o OffsetRange) { - if s == nil { - return - } - s.offsetRanges[id] = o -} - -// GetStartLocation calculates the human-readable 1-based line and 0-based column of the first character -// of the expression node at the id. -func (s *SourceInfo) GetStartLocation(id int64) common.Location { - if o, found := s.GetOffsetRange(id); found { - line := 1 - col := int(o.Start) - for _, lineOffset := range s.LineOffsets() { - if lineOffset < o.Start { - line++ - col = int(o.Start - lineOffset) - } else { - break - } - } - return common.NewLocation(line, col) - } - return common.NoLocation -} - -// GetStopLocation calculates the human-readable 1-based line and 0-based column of the last character for -// the expression node at the given id. -// -// If the SourceInfo was generated from a serialized protobuf representation, the stop location will -// be identical to the start location for the expression. -func (s *SourceInfo) GetStopLocation(id int64) common.Location { - if o, found := s.GetOffsetRange(id); found { - line := 1 - col := int(o.Stop) - for _, lineOffset := range s.LineOffsets() { - if lineOffset < o.Stop { - line++ - col = int(o.Stop - lineOffset) - } else { - break - } - } - return common.NewLocation(line, col) - } - return common.NoLocation -} - -// ComputeOffset calculates the 0-based character offset from a 1-based line and 0-based column. -func (s *SourceInfo) ComputeOffset(line, col int32) int32 { - if s != nil { - line = s.baseLine + line - col = s.baseCol + col - } - if line == 1 { - return col - } - if line < 1 || line > int32(len(s.LineOffsets())) { - return -1 - } - offset := s.LineOffsets()[line-2] - return offset + col -} - -// OffsetRange captures the start and stop positions of a section of text in the input expression. -type OffsetRange struct { - Start int32 - Stop int32 -} - -// ReferenceInfo contains a CEL native representation of an identifier reference which may refer to -// either a qualified identifier name, a set of overload ids, or a constant value from an enum. -type ReferenceInfo struct { - Name string - OverloadIDs []string - Value ref.Val -} - -// NewIdentReference creates a ReferenceInfo instance for an identifier with an optional constant value. -func NewIdentReference(name string, value ref.Val) *ReferenceInfo { - return &ReferenceInfo{Name: name, Value: value} -} - -// NewFunctionReference creates a ReferenceInfo instance for a set of function overloads. -func NewFunctionReference(overloads ...string) *ReferenceInfo { - info := &ReferenceInfo{} - for _, id := range overloads { - info.AddOverload(id) - } - return info -} - -// AddOverload appends a function overload ID to the ReferenceInfo. -func (r *ReferenceInfo) AddOverload(overloadID string) { - for _, id := range r.OverloadIDs { - if id == overloadID { - return - } - } - r.OverloadIDs = append(r.OverloadIDs, overloadID) -} - -// Equals returns whether two references are identical to each other. -func (r *ReferenceInfo) Equals(other *ReferenceInfo) bool { - if r.Name != other.Name { - return false - } - if len(r.OverloadIDs) != len(other.OverloadIDs) { - return false - } - if len(r.OverloadIDs) != 0 { - overloadMap := make(map[string]struct{}, len(r.OverloadIDs)) - for _, id := range r.OverloadIDs { - overloadMap[id] = struct{}{} - } - for _, id := range other.OverloadIDs { - _, found := overloadMap[id] - if !found { - return false - } - } - } - if r.Value == nil && other.Value == nil { - return true - } - if r.Value == nil && other.Value != nil || - r.Value != nil && other.Value == nil || - r.Value.Equal(other.Value) != types.True { - return false - } - return true -} - -type maxIDVisitor struct { - maxID int64 - *baseVisitor -} - -// VisitExpr updates the max identifier if the incoming expression id is greater than previously observed. -func (v *maxIDVisitor) VisitExpr(e Expr) { - if v.maxID < e.ID() { - v.maxID = e.ID() - } -} - -// VisitEntryExpr updates the max identifier if the incoming entry id is greater than previously observed. -func (v *maxIDVisitor) VisitEntryExpr(e EntryExpr) { - if v.maxID < e.ID() { - v.maxID = e.ID() - } -} diff --git a/vendor/github.com/google/cel-go/common/ast/conversion.go b/vendor/github.com/google/cel-go/common/ast/conversion.go deleted file mode 100644 index 8f2c4bd1e..000000000 --- a/vendor/github.com/google/cel-go/common/ast/conversion.go +++ /dev/null @@ -1,632 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ast - -import ( - "fmt" - - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/common/types/ref" - - structpb "google.golang.org/protobuf/types/known/structpb" - - exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1" -) - -// ToProto converts an AST to a CheckedExpr protobouf. -func ToProto(ast *AST) (*exprpb.CheckedExpr, error) { - refMap := make(map[int64]*exprpb.Reference, len(ast.ReferenceMap())) - for id, ref := range ast.ReferenceMap() { - r, err := ReferenceInfoToProto(ref) - if err != nil { - return nil, err - } - refMap[id] = r - } - typeMap := make(map[int64]*exprpb.Type, len(ast.TypeMap())) - for id, typ := range ast.TypeMap() { - t, err := types.TypeToExprType(typ) - if err != nil { - return nil, err - } - typeMap[id] = t - } - e, err := ExprToProto(ast.Expr()) - if err != nil { - return nil, err - } - info, err := SourceInfoToProto(ast.SourceInfo()) - if err != nil { - return nil, err - } - return &exprpb.CheckedExpr{ - Expr: e, - SourceInfo: info, - ReferenceMap: refMap, - TypeMap: typeMap, - }, nil -} - -// ToAST converts a CheckedExpr protobuf to an AST instance. -func ToAST(checked *exprpb.CheckedExpr) (*AST, error) { - refMap := make(map[int64]*ReferenceInfo, len(checked.GetReferenceMap())) - for id, ref := range checked.GetReferenceMap() { - r, err := ProtoToReferenceInfo(ref) - if err != nil { - return nil, err - } - refMap[id] = r - } - typeMap := make(map[int64]*types.Type, len(checked.GetTypeMap())) - for id, typ := range checked.GetTypeMap() { - t, err := types.ExprTypeToType(typ) - if err != nil { - return nil, err - } - typeMap[id] = t - } - info, err := ProtoToSourceInfo(checked.GetSourceInfo()) - if err != nil { - return nil, err - } - root, err := ProtoToExpr(checked.GetExpr()) - if err != nil { - return nil, err - } - ast := NewCheckedAST(NewAST(root, info), typeMap, refMap) - return ast, nil -} - -// ProtoToExpr converts a protobuf Expr value to an ast.Expr value. -func ProtoToExpr(e *exprpb.Expr) (Expr, error) { - factory := NewExprFactory() - return exprInternal(factory, e) -} - -// ProtoToEntryExpr converts a protobuf struct/map entry to an ast.EntryExpr -func ProtoToEntryExpr(e *exprpb.Expr_CreateStruct_Entry) (EntryExpr, error) { - factory := NewExprFactory() - switch e.GetKeyKind().(type) { - case *exprpb.Expr_CreateStruct_Entry_FieldKey: - return exprStructField(factory, e.GetId(), e) - case *exprpb.Expr_CreateStruct_Entry_MapKey: - return exprMapEntry(factory, e.GetId(), e) - } - return nil, fmt.Errorf("unsupported expr entry kind: %v", e) -} - -func exprInternal(factory ExprFactory, e *exprpb.Expr) (Expr, error) { - id := e.GetId() - switch e.GetExprKind().(type) { - case *exprpb.Expr_CallExpr: - return exprCall(factory, id, e.GetCallExpr()) - case *exprpb.Expr_ComprehensionExpr: - return exprComprehension(factory, id, e.GetComprehensionExpr()) - case *exprpb.Expr_ConstExpr: - return exprLiteral(factory, id, e.GetConstExpr()) - case *exprpb.Expr_IdentExpr: - return exprIdent(factory, id, e.GetIdentExpr()) - case *exprpb.Expr_ListExpr: - return exprList(factory, id, e.GetListExpr()) - case *exprpb.Expr_SelectExpr: - return exprSelect(factory, id, e.GetSelectExpr()) - case *exprpb.Expr_StructExpr: - s := e.GetStructExpr() - if s.GetMessageName() != "" { - return exprStruct(factory, id, s) - } - return exprMap(factory, id, s) - } - return factory.NewUnspecifiedExpr(id), nil -} - -func exprCall(factory ExprFactory, id int64, call *exprpb.Expr_Call) (Expr, error) { - var err error - args := make([]Expr, len(call.GetArgs())) - for i, a := range call.GetArgs() { - args[i], err = exprInternal(factory, a) - if err != nil { - return nil, err - } - } - if call.GetTarget() == nil { - return factory.NewCall(id, call.GetFunction(), args...), nil - } - - target, err := exprInternal(factory, call.GetTarget()) - if err != nil { - return nil, err - } - return factory.NewMemberCall(id, call.GetFunction(), target, args...), nil -} - -func exprComprehension(factory ExprFactory, id int64, comp *exprpb.Expr_Comprehension) (Expr, error) { - iterRange, err := exprInternal(factory, comp.GetIterRange()) - if err != nil { - return nil, err - } - accuInit, err := exprInternal(factory, comp.GetAccuInit()) - if err != nil { - return nil, err - } - loopCond, err := exprInternal(factory, comp.GetLoopCondition()) - if err != nil { - return nil, err - } - loopStep, err := exprInternal(factory, comp.GetLoopStep()) - if err != nil { - return nil, err - } - result, err := exprInternal(factory, comp.GetResult()) - if err != nil { - return nil, err - } - return factory.NewComprehension(id, - iterRange, - comp.GetIterVar(), - comp.GetAccuVar(), - accuInit, - loopCond, - loopStep, - result), nil -} - -func exprLiteral(factory ExprFactory, id int64, c *exprpb.Constant) (Expr, error) { - val, err := ConstantToVal(c) - if err != nil { - return nil, err - } - return factory.NewLiteral(id, val), nil -} - -func exprIdent(factory ExprFactory, id int64, i *exprpb.Expr_Ident) (Expr, error) { - return factory.NewIdent(id, i.GetName()), nil -} - -func exprList(factory ExprFactory, id int64, l *exprpb.Expr_CreateList) (Expr, error) { - elems := make([]Expr, len(l.GetElements())) - for i, e := range l.GetElements() { - elem, err := exprInternal(factory, e) - if err != nil { - return nil, err - } - elems[i] = elem - } - return factory.NewList(id, elems, l.GetOptionalIndices()), nil -} - -func exprMap(factory ExprFactory, id int64, s *exprpb.Expr_CreateStruct) (Expr, error) { - entries := make([]EntryExpr, len(s.GetEntries())) - var err error - for i, entry := range s.GetEntries() { - entries[i], err = exprMapEntry(factory, entry.GetId(), entry) - if err != nil { - return nil, err - } - } - return factory.NewMap(id, entries), nil -} - -func exprMapEntry(factory ExprFactory, id int64, e *exprpb.Expr_CreateStruct_Entry) (EntryExpr, error) { - k, err := exprInternal(factory, e.GetMapKey()) - if err != nil { - return nil, err - } - v, err := exprInternal(factory, e.GetValue()) - if err != nil { - return nil, err - } - return factory.NewMapEntry(id, k, v, e.GetOptionalEntry()), nil -} - -func exprSelect(factory ExprFactory, id int64, s *exprpb.Expr_Select) (Expr, error) { - op, err := exprInternal(factory, s.GetOperand()) - if err != nil { - return nil, err - } - if s.GetTestOnly() { - return factory.NewPresenceTest(id, op, s.GetField()), nil - } - return factory.NewSelect(id, op, s.GetField()), nil -} - -func exprStruct(factory ExprFactory, id int64, s *exprpb.Expr_CreateStruct) (Expr, error) { - fields := make([]EntryExpr, len(s.GetEntries())) - var err error - for i, field := range s.GetEntries() { - fields[i], err = exprStructField(factory, field.GetId(), field) - if err != nil { - return nil, err - } - } - return factory.NewStruct(id, s.GetMessageName(), fields), nil -} - -func exprStructField(factory ExprFactory, id int64, f *exprpb.Expr_CreateStruct_Entry) (EntryExpr, error) { - v, err := exprInternal(factory, f.GetValue()) - if err != nil { - return nil, err - } - return factory.NewStructField(id, f.GetFieldKey(), v, f.GetOptionalEntry()), nil -} - -// ExprToProto serializes an ast.Expr value to a protobuf Expr representation. -func ExprToProto(e Expr) (*exprpb.Expr, error) { - if e == nil { - return &exprpb.Expr{}, nil - } - switch e.Kind() { - case CallKind: - return protoCall(e.ID(), e.AsCall()) - case ComprehensionKind: - return protoComprehension(e.ID(), e.AsComprehension()) - case IdentKind: - return protoIdent(e.ID(), e.AsIdent()) - case ListKind: - return protoList(e.ID(), e.AsList()) - case LiteralKind: - return protoLiteral(e.ID(), e.AsLiteral()) - case MapKind: - return protoMap(e.ID(), e.AsMap()) - case SelectKind: - return protoSelect(e.ID(), e.AsSelect()) - case StructKind: - return protoStruct(e.ID(), e.AsStruct()) - case UnspecifiedExprKind: - // Handle the case where a macro reference may be getting translated. - // A nested macro 'pointer' is a non-zero expression id with no kind set. - if e.ID() != 0 { - return &exprpb.Expr{Id: e.ID()}, nil - } - return &exprpb.Expr{}, nil - } - return nil, fmt.Errorf("unsupported expr kind: %v", e) -} - -// EntryExprToProto converts an ast.EntryExpr to a protobuf CreateStruct entry -func EntryExprToProto(e EntryExpr) (*exprpb.Expr_CreateStruct_Entry, error) { - switch e.Kind() { - case MapEntryKind: - return protoMapEntry(e.ID(), e.AsMapEntry()) - case StructFieldKind: - return protoStructField(e.ID(), e.AsStructField()) - case UnspecifiedEntryExprKind: - return &exprpb.Expr_CreateStruct_Entry{}, nil - } - return nil, fmt.Errorf("unsupported expr entry kind: %v", e) -} - -func protoCall(id int64, call CallExpr) (*exprpb.Expr, error) { - var err error - var target *exprpb.Expr - if call.IsMemberFunction() { - target, err = ExprToProto(call.Target()) - if err != nil { - return nil, err - } - } - callArgs := call.Args() - args := make([]*exprpb.Expr, len(callArgs)) - for i, a := range callArgs { - args[i], err = ExprToProto(a) - if err != nil { - return nil, err - } - } - return &exprpb.Expr{ - Id: id, - ExprKind: &exprpb.Expr_CallExpr{ - CallExpr: &exprpb.Expr_Call{ - Function: call.FunctionName(), - Target: target, - Args: args, - }, - }, - }, nil -} - -func protoComprehension(id int64, comp ComprehensionExpr) (*exprpb.Expr, error) { - iterRange, err := ExprToProto(comp.IterRange()) - if err != nil { - return nil, err - } - accuInit, err := ExprToProto(comp.AccuInit()) - if err != nil { - return nil, err - } - loopCond, err := ExprToProto(comp.LoopCondition()) - if err != nil { - return nil, err - } - loopStep, err := ExprToProto(comp.LoopStep()) - if err != nil { - return nil, err - } - result, err := ExprToProto(comp.Result()) - if err != nil { - return nil, err - } - return &exprpb.Expr{ - Id: id, - ExprKind: &exprpb.Expr_ComprehensionExpr{ - ComprehensionExpr: &exprpb.Expr_Comprehension{ - IterVar: comp.IterVar(), - IterRange: iterRange, - AccuVar: comp.AccuVar(), - AccuInit: accuInit, - LoopCondition: loopCond, - LoopStep: loopStep, - Result: result, - }, - }, - }, nil -} - -func protoIdent(id int64, name string) (*exprpb.Expr, error) { - return &exprpb.Expr{ - Id: id, - ExprKind: &exprpb.Expr_IdentExpr{ - IdentExpr: &exprpb.Expr_Ident{ - Name: name, - }, - }, - }, nil -} - -func protoList(id int64, list ListExpr) (*exprpb.Expr, error) { - var err error - elems := make([]*exprpb.Expr, list.Size()) - for i, e := range list.Elements() { - elems[i], err = ExprToProto(e) - if err != nil { - return nil, err - } - } - return &exprpb.Expr{ - Id: id, - ExprKind: &exprpb.Expr_ListExpr{ - ListExpr: &exprpb.Expr_CreateList{ - Elements: elems, - OptionalIndices: list.OptionalIndices(), - }, - }, - }, nil -} - -func protoLiteral(id int64, val ref.Val) (*exprpb.Expr, error) { - c, err := ValToConstant(val) - if err != nil { - return nil, err - } - return &exprpb.Expr{ - Id: id, - ExprKind: &exprpb.Expr_ConstExpr{ - ConstExpr: c, - }, - }, nil -} - -func protoMap(id int64, m MapExpr) (*exprpb.Expr, error) { - entries := make([]*exprpb.Expr_CreateStruct_Entry, len(m.Entries())) - var err error - for i, e := range m.Entries() { - entries[i], err = EntryExprToProto(e) - if err != nil { - return nil, err - } - } - return &exprpb.Expr{ - Id: id, - ExprKind: &exprpb.Expr_StructExpr{ - StructExpr: &exprpb.Expr_CreateStruct{ - Entries: entries, - }, - }, - }, nil -} - -func protoMapEntry(id int64, e MapEntry) (*exprpb.Expr_CreateStruct_Entry, error) { - k, err := ExprToProto(e.Key()) - if err != nil { - return nil, err - } - v, err := ExprToProto(e.Value()) - if err != nil { - return nil, err - } - return &exprpb.Expr_CreateStruct_Entry{ - Id: id, - KeyKind: &exprpb.Expr_CreateStruct_Entry_MapKey{ - MapKey: k, - }, - Value: v, - OptionalEntry: e.IsOptional(), - }, nil -} - -func protoSelect(id int64, s SelectExpr) (*exprpb.Expr, error) { - op, err := ExprToProto(s.Operand()) - if err != nil { - return nil, err - } - return &exprpb.Expr{ - Id: id, - ExprKind: &exprpb.Expr_SelectExpr{ - SelectExpr: &exprpb.Expr_Select{ - Operand: op, - Field: s.FieldName(), - TestOnly: s.IsTestOnly(), - }, - }, - }, nil -} - -func protoStruct(id int64, s StructExpr) (*exprpb.Expr, error) { - entries := make([]*exprpb.Expr_CreateStruct_Entry, len(s.Fields())) - var err error - for i, e := range s.Fields() { - entries[i], err = EntryExprToProto(e) - if err != nil { - return nil, err - } - } - return &exprpb.Expr{ - Id: id, - ExprKind: &exprpb.Expr_StructExpr{ - StructExpr: &exprpb.Expr_CreateStruct{ - MessageName: s.TypeName(), - Entries: entries, - }, - }, - }, nil -} - -func protoStructField(id int64, f StructField) (*exprpb.Expr_CreateStruct_Entry, error) { - v, err := ExprToProto(f.Value()) - if err != nil { - return nil, err - } - return &exprpb.Expr_CreateStruct_Entry{ - Id: id, - KeyKind: &exprpb.Expr_CreateStruct_Entry_FieldKey{ - FieldKey: f.Name(), - }, - Value: v, - OptionalEntry: f.IsOptional(), - }, nil -} - -// SourceInfoToProto serializes an ast.SourceInfo value to a protobuf SourceInfo object. -func SourceInfoToProto(info *SourceInfo) (*exprpb.SourceInfo, error) { - if info == nil { - return &exprpb.SourceInfo{}, nil - } - sourceInfo := &exprpb.SourceInfo{ - SyntaxVersion: info.SyntaxVersion(), - Location: info.Description(), - LineOffsets: info.LineOffsets(), - Positions: make(map[int64]int32, len(info.OffsetRanges())), - MacroCalls: make(map[int64]*exprpb.Expr, len(info.MacroCalls())), - } - for id, offset := range info.OffsetRanges() { - sourceInfo.Positions[id] = offset.Start - } - for id, e := range info.MacroCalls() { - call, err := ExprToProto(e) - if err != nil { - return nil, err - } - sourceInfo.MacroCalls[id] = call - } - return sourceInfo, nil -} - -// ProtoToSourceInfo deserializes the protobuf into a native SourceInfo value. -func ProtoToSourceInfo(info *exprpb.SourceInfo) (*SourceInfo, error) { - sourceInfo := &SourceInfo{ - syntax: info.GetSyntaxVersion(), - desc: info.GetLocation(), - lines: info.GetLineOffsets(), - offsetRanges: make(map[int64]OffsetRange, len(info.GetPositions())), - macroCalls: make(map[int64]Expr, len(info.GetMacroCalls())), - } - for id, offset := range info.GetPositions() { - sourceInfo.SetOffsetRange(id, OffsetRange{Start: offset, Stop: offset}) - } - for id, e := range info.GetMacroCalls() { - call, err := ProtoToExpr(e) - if err != nil { - return nil, err - } - sourceInfo.SetMacroCall(id, call) - } - return sourceInfo, nil -} - -// ReferenceInfoToProto converts a ReferenceInfo instance to a protobuf Reference suitable for serialization. -func ReferenceInfoToProto(info *ReferenceInfo) (*exprpb.Reference, error) { - c, err := ValToConstant(info.Value) - if err != nil { - return nil, err - } - return &exprpb.Reference{ - Name: info.Name, - OverloadId: info.OverloadIDs, - Value: c, - }, nil -} - -// ProtoToReferenceInfo converts a protobuf Reference into a CEL-native ReferenceInfo instance. -func ProtoToReferenceInfo(ref *exprpb.Reference) (*ReferenceInfo, error) { - v, err := ConstantToVal(ref.GetValue()) - if err != nil { - return nil, err - } - return &ReferenceInfo{ - Name: ref.GetName(), - OverloadIDs: ref.GetOverloadId(), - Value: v, - }, nil -} - -// ValToConstant converts a CEL-native ref.Val to a protobuf Constant. -// -// Only simple scalar types are supported by this method. -func ValToConstant(v ref.Val) (*exprpb.Constant, error) { - if v == nil { - return nil, nil - } - switch v.Type() { - case types.BoolType: - return &exprpb.Constant{ConstantKind: &exprpb.Constant_BoolValue{BoolValue: v.Value().(bool)}}, nil - case types.BytesType: - return &exprpb.Constant{ConstantKind: &exprpb.Constant_BytesValue{BytesValue: v.Value().([]byte)}}, nil - case types.DoubleType: - return &exprpb.Constant{ConstantKind: &exprpb.Constant_DoubleValue{DoubleValue: v.Value().(float64)}}, nil - case types.IntType: - return &exprpb.Constant{ConstantKind: &exprpb.Constant_Int64Value{Int64Value: v.Value().(int64)}}, nil - case types.NullType: - return &exprpb.Constant{ConstantKind: &exprpb.Constant_NullValue{NullValue: structpb.NullValue_NULL_VALUE}}, nil - case types.StringType: - return &exprpb.Constant{ConstantKind: &exprpb.Constant_StringValue{StringValue: v.Value().(string)}}, nil - case types.UintType: - return &exprpb.Constant{ConstantKind: &exprpb.Constant_Uint64Value{Uint64Value: v.Value().(uint64)}}, nil - } - return nil, fmt.Errorf("unsupported constant kind: %v", v.Type()) -} - -// ConstantToVal converts a protobuf Constant to a CEL-native ref.Val. -func ConstantToVal(c *exprpb.Constant) (ref.Val, error) { - if c == nil { - return nil, nil - } - switch c.GetConstantKind().(type) { - case *exprpb.Constant_BoolValue: - return types.Bool(c.GetBoolValue()), nil - case *exprpb.Constant_BytesValue: - return types.Bytes(c.GetBytesValue()), nil - case *exprpb.Constant_DoubleValue: - return types.Double(c.GetDoubleValue()), nil - case *exprpb.Constant_Int64Value: - return types.Int(c.GetInt64Value()), nil - case *exprpb.Constant_NullValue: - return types.NullValue, nil - case *exprpb.Constant_StringValue: - return types.String(c.GetStringValue()), nil - case *exprpb.Constant_Uint64Value: - return types.Uint(c.GetUint64Value()), nil - } - return nil, fmt.Errorf("unsupported constant kind: %v", c.GetConstantKind()) -} diff --git a/vendor/github.com/google/cel-go/common/ast/expr.go b/vendor/github.com/google/cel-go/common/ast/expr.go deleted file mode 100644 index c9d88bbaa..000000000 --- a/vendor/github.com/google/cel-go/common/ast/expr.go +++ /dev/null @@ -1,860 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ast - -import ( - "github.com/google/cel-go/common/types/ref" -) - -// ExprKind represents the expression node kind. -type ExprKind int - -const ( - // UnspecifiedExprKind represents an unset expression with no specified properties. - UnspecifiedExprKind ExprKind = iota - - // CallKind represents a function call. - CallKind - - // ComprehensionKind represents a comprehension expression generated by a macro. - ComprehensionKind - - // IdentKind represents a simple variable, constant, or type identifier. - IdentKind - - // ListKind represents a list literal expression. - ListKind - - // LiteralKind represents a primitive scalar literal. - LiteralKind - - // MapKind represents a map literal expression. - MapKind - - // SelectKind represents a field selection expression. - SelectKind - - // StructKind represents a struct literal expression. - StructKind -) - -// Expr represents the base expression node in a CEL abstract syntax tree. -// -// Depending on the `Kind()` value, the Expr may be converted to a concrete expression types -// as indicated by the `As` methods. -type Expr interface { - // ID of the expression as it appears in the AST - ID() int64 - - // Kind of the expression node. See ExprKind for the valid enum values. - Kind() ExprKind - - // AsCall adapts the expr into a CallExpr - // - // The Kind() must be equal to a CallKind for the conversion to be well-defined. - AsCall() CallExpr - - // AsComprehension adapts the expr into a ComprehensionExpr. - // - // The Kind() must be equal to a ComprehensionKind for the conversion to be well-defined. - AsComprehension() ComprehensionExpr - - // AsIdent adapts the expr into an identifier string. - // - // The Kind() must be equal to an IdentKind for the conversion to be well-defined. - AsIdent() string - - // AsLiteral adapts the expr into a constant ref.Val. - // - // The Kind() must be equal to a LiteralKind for the conversion to be well-defined. - AsLiteral() ref.Val - - // AsList adapts the expr into a ListExpr. - // - // The Kind() must be equal to a ListKind for the conversion to be well-defined. - AsList() ListExpr - - // AsMap adapts the expr into a MapExpr. - // - // The Kind() must be equal to a MapKind for the conversion to be well-defined. - AsMap() MapExpr - - // AsSelect adapts the expr into a SelectExpr. - // - // The Kind() must be equal to a SelectKind for the conversion to be well-defined. - AsSelect() SelectExpr - - // AsStruct adapts the expr into a StructExpr. - // - // The Kind() must be equal to a StructKind for the conversion to be well-defined. - AsStruct() StructExpr - - // RenumberIDs performs an in-place update of the expression and all of its descendents numeric ids. - RenumberIDs(IDGenerator) - - // SetKindCase replaces the contents of the current expression with the contents of the other. - // - // The SetKindCase takes ownership of any expression instances references within the input Expr. - // A shallow copy is made of the Expr value itself, but not a deep one. - // - // This method should only be used during AST rewrites using temporary Expr values. - SetKindCase(Expr) - - // isExpr is a marker interface. - isExpr() -} - -// EntryExprKind represents the possible EntryExpr kinds. -type EntryExprKind int - -const ( - // UnspecifiedEntryExprKind indicates that the entry expr is not set. - UnspecifiedEntryExprKind EntryExprKind = iota - - // MapEntryKind indicates that the entry is a MapEntry type with key and value expressions. - MapEntryKind - - // StructFieldKind indicates that the entry is a StructField with a field name and initializer - // expression. - StructFieldKind -) - -// EntryExpr represents the base entry expression in a CEL map or struct literal. -type EntryExpr interface { - // ID of the entry as it appears in the AST. - ID() int64 - - // Kind of the entry expression node. See EntryExprKind for valid enum values. - Kind() EntryExprKind - - // AsMapEntry casts the EntryExpr to a MapEntry. - // - // The Kind() must be equal to MapEntryKind for the conversion to be well-defined. - AsMapEntry() MapEntry - - // AsStructField casts the EntryExpr to a StructField - // - // The Kind() must be equal to StructFieldKind for the conversion to be well-defined. - AsStructField() StructField - - // RenumberIDs performs an in-place update of the expression and all of its descendents numeric ids. - RenumberIDs(IDGenerator) - - isEntryExpr() -} - -// IDGenerator produces unique ids suitable for tagging expression nodes -type IDGenerator func(originalID int64) int64 - -// CallExpr defines an interface for inspecting a function call and its arugments. -type CallExpr interface { - // FunctionName returns the name of the function. - FunctionName() string - - // IsMemberFunction returns whether the call has a non-nil target indicating it is a member function - IsMemberFunction() bool - - // Target returns the target of the expression if one is present. - Target() Expr - - // Args returns the list of call arguments, excluding the target. - Args() []Expr - - // marker interface method - isExpr() -} - -// ListExpr defines an interface for inspecting a list literal expression. -type ListExpr interface { - // Elements returns the list elements as navigable expressions. - Elements() []Expr - - // OptionalIndicies returns the list of optional indices in the list literal. - OptionalIndices() []int32 - - // IsOptional indicates whether the given element index is optional. - IsOptional(int32) bool - - // Size returns the number of elements in the list. - Size() int - - // marker interface method - isExpr() -} - -// SelectExpr defines an interface for inspecting a select expression. -type SelectExpr interface { - // Operand returns the selection operand expression. - Operand() Expr - - // FieldName returns the field name being selected from the operand. - FieldName() string - - // IsTestOnly indicates whether the select expression is a presence test generated by a macro. - IsTestOnly() bool - - // marker interface method - isExpr() -} - -// MapExpr defines an interface for inspecting a map expression. -type MapExpr interface { - // Entries returns the map key value pairs as EntryExpr values. - Entries() []EntryExpr - - // Size returns the number of entries in the map. - Size() int - - // marker interface method - isExpr() -} - -// MapEntry defines an interface for inspecting a map entry. -type MapEntry interface { - // Key returns the map entry key expression. - Key() Expr - - // Value returns the map entry value expression. - Value() Expr - - // IsOptional returns whether the entry is optional. - IsOptional() bool - - // marker interface method - isEntryExpr() -} - -// StructExpr defines an interfaces for inspecting a struct and its field initializers. -type StructExpr interface { - // TypeName returns the struct type name. - TypeName() string - - // Fields returns the set of field initializers in the struct expression as EntryExpr values. - Fields() []EntryExpr - - // marker interface method - isExpr() -} - -// StructField defines an interface for inspecting a struct field initialization. -type StructField interface { - // Name returns the name of the field. - Name() string - - // Value returns the field initialization expression. - Value() Expr - - // IsOptional returns whether the field is optional. - IsOptional() bool - - // marker interface method - isEntryExpr() -} - -// ComprehensionExpr defines an interface for inspecting a comprehension expression. -type ComprehensionExpr interface { - // IterRange returns the iteration range expression. - IterRange() Expr - - // IterVar returns the iteration variable name. - IterVar() string - - // AccuVar returns the accumulation variable name. - AccuVar() string - - // AccuInit returns the accumulation variable initialization expression. - AccuInit() Expr - - // LoopCondition returns the loop condition expression. - LoopCondition() Expr - - // LoopStep returns the loop step expression. - LoopStep() Expr - - // Result returns the comprehension result expression. - Result() Expr - - // marker interface method - isExpr() -} - -var _ Expr = &expr{} - -type expr struct { - id int64 - exprKindCase -} - -type exprKindCase interface { - Kind() ExprKind - - renumberIDs(IDGenerator) - - isExpr() -} - -func (e *expr) ID() int64 { - if e == nil { - return 0 - } - return e.id -} - -func (e *expr) Kind() ExprKind { - if e == nil || e.exprKindCase == nil { - return UnspecifiedExprKind - } - return e.exprKindCase.Kind() -} - -func (e *expr) AsCall() CallExpr { - if e.Kind() != CallKind { - return nilCall - } - return e.exprKindCase.(CallExpr) -} - -func (e *expr) AsComprehension() ComprehensionExpr { - if e.Kind() != ComprehensionKind { - return nilCompre - } - return e.exprKindCase.(ComprehensionExpr) -} - -func (e *expr) AsIdent() string { - if e.Kind() != IdentKind { - return "" - } - return string(e.exprKindCase.(baseIdentExpr)) -} - -func (e *expr) AsLiteral() ref.Val { - if e.Kind() != LiteralKind { - return nil - } - return e.exprKindCase.(*baseLiteral).Val -} - -func (e *expr) AsList() ListExpr { - if e.Kind() != ListKind { - return nilList - } - return e.exprKindCase.(ListExpr) -} - -func (e *expr) AsMap() MapExpr { - if e.Kind() != MapKind { - return nilMap - } - return e.exprKindCase.(MapExpr) -} - -func (e *expr) AsSelect() SelectExpr { - if e.Kind() != SelectKind { - return nilSel - } - return e.exprKindCase.(SelectExpr) -} - -func (e *expr) AsStruct() StructExpr { - if e.Kind() != StructKind { - return nilStruct - } - return e.exprKindCase.(StructExpr) -} - -func (e *expr) SetKindCase(other Expr) { - if e == nil { - return - } - if other == nil { - e.exprKindCase = nil - return - } - switch other.Kind() { - case CallKind: - c := other.AsCall() - e.exprKindCase = &baseCallExpr{ - function: c.FunctionName(), - target: c.Target(), - args: c.Args(), - isMember: c.IsMemberFunction(), - } - case ComprehensionKind: - c := other.AsComprehension() - e.exprKindCase = &baseComprehensionExpr{ - iterRange: c.IterRange(), - iterVar: c.IterVar(), - accuVar: c.AccuVar(), - accuInit: c.AccuInit(), - loopCond: c.LoopCondition(), - loopStep: c.LoopStep(), - result: c.Result(), - } - case IdentKind: - e.exprKindCase = baseIdentExpr(other.AsIdent()) - case ListKind: - l := other.AsList() - optIndexMap := make(map[int32]struct{}, len(l.OptionalIndices())) - for _, idx := range l.OptionalIndices() { - optIndexMap[idx] = struct{}{} - } - e.exprKindCase = &baseListExpr{ - elements: l.Elements(), - optIndices: l.OptionalIndices(), - optIndexMap: optIndexMap, - } - case LiteralKind: - e.exprKindCase = &baseLiteral{Val: other.AsLiteral()} - case MapKind: - e.exprKindCase = &baseMapExpr{ - entries: other.AsMap().Entries(), - } - case SelectKind: - s := other.AsSelect() - e.exprKindCase = &baseSelectExpr{ - operand: s.Operand(), - field: s.FieldName(), - testOnly: s.IsTestOnly(), - } - case StructKind: - s := other.AsStruct() - e.exprKindCase = &baseStructExpr{ - typeName: s.TypeName(), - fields: s.Fields(), - } - case UnspecifiedExprKind: - e.exprKindCase = nil - } -} - -func (e *expr) RenumberIDs(idGen IDGenerator) { - if e == nil { - return - } - e.id = idGen(e.id) - if e.exprKindCase != nil { - e.exprKindCase.renumberIDs(idGen) - } -} - -type baseCallExpr struct { - function string - target Expr - args []Expr - isMember bool -} - -func (*baseCallExpr) Kind() ExprKind { - return CallKind -} - -func (e *baseCallExpr) FunctionName() string { - if e == nil { - return "" - } - return e.function -} - -func (e *baseCallExpr) IsMemberFunction() bool { - if e == nil { - return false - } - return e.isMember -} - -func (e *baseCallExpr) Target() Expr { - if e == nil || !e.IsMemberFunction() { - return nilExpr - } - return e.target -} - -func (e *baseCallExpr) Args() []Expr { - if e == nil { - return []Expr{} - } - return e.args -} - -func (e *baseCallExpr) renumberIDs(idGen IDGenerator) { - if e.IsMemberFunction() { - e.Target().RenumberIDs(idGen) - } - for _, arg := range e.Args() { - arg.RenumberIDs(idGen) - } -} - -func (*baseCallExpr) isExpr() {} - -var _ ComprehensionExpr = &baseComprehensionExpr{} - -type baseComprehensionExpr struct { - iterRange Expr - iterVar string - accuVar string - accuInit Expr - loopCond Expr - loopStep Expr - result Expr -} - -func (*baseComprehensionExpr) Kind() ExprKind { - return ComprehensionKind -} - -func (e *baseComprehensionExpr) IterRange() Expr { - if e == nil { - return nilExpr - } - return e.iterRange -} - -func (e *baseComprehensionExpr) IterVar() string { - return e.iterVar -} - -func (e *baseComprehensionExpr) AccuVar() string { - return e.accuVar -} - -func (e *baseComprehensionExpr) AccuInit() Expr { - if e == nil { - return nilExpr - } - return e.accuInit -} - -func (e *baseComprehensionExpr) LoopCondition() Expr { - if e == nil { - return nilExpr - } - return e.loopCond -} - -func (e *baseComprehensionExpr) LoopStep() Expr { - if e == nil { - return nilExpr - } - return e.loopStep -} - -func (e *baseComprehensionExpr) Result() Expr { - if e == nil { - return nilExpr - } - return e.result -} - -func (e *baseComprehensionExpr) renumberIDs(idGen IDGenerator) { - e.IterRange().RenumberIDs(idGen) - e.AccuInit().RenumberIDs(idGen) - e.LoopCondition().RenumberIDs(idGen) - e.LoopStep().RenumberIDs(idGen) - e.Result().RenumberIDs(idGen) -} - -func (*baseComprehensionExpr) isExpr() {} - -var _ exprKindCase = baseIdentExpr("") - -type baseIdentExpr string - -func (baseIdentExpr) Kind() ExprKind { - return IdentKind -} - -func (e baseIdentExpr) renumberIDs(IDGenerator) {} - -func (baseIdentExpr) isExpr() {} - -var _ exprKindCase = &baseLiteral{} -var _ ref.Val = &baseLiteral{} - -type baseLiteral struct { - ref.Val -} - -func (*baseLiteral) Kind() ExprKind { - return LiteralKind -} - -func (l *baseLiteral) renumberIDs(IDGenerator) {} - -func (*baseLiteral) isExpr() {} - -var _ ListExpr = &baseListExpr{} - -type baseListExpr struct { - elements []Expr - optIndices []int32 - optIndexMap map[int32]struct{} -} - -func (*baseListExpr) Kind() ExprKind { - return ListKind -} - -func (e *baseListExpr) Elements() []Expr { - if e == nil { - return []Expr{} - } - return e.elements -} - -func (e *baseListExpr) IsOptional(index int32) bool { - _, found := e.optIndexMap[index] - return found -} - -func (e *baseListExpr) OptionalIndices() []int32 { - if e == nil { - return []int32{} - } - return e.optIndices -} - -func (e *baseListExpr) Size() int { - return len(e.Elements()) -} - -func (e *baseListExpr) renumberIDs(idGen IDGenerator) { - for _, elem := range e.Elements() { - elem.RenumberIDs(idGen) - } -} - -func (*baseListExpr) isExpr() {} - -type baseMapExpr struct { - entries []EntryExpr -} - -func (*baseMapExpr) Kind() ExprKind { - return MapKind -} - -func (e *baseMapExpr) Entries() []EntryExpr { - if e == nil { - return []EntryExpr{} - } - return e.entries -} - -func (e *baseMapExpr) Size() int { - return len(e.Entries()) -} - -func (e *baseMapExpr) renumberIDs(idGen IDGenerator) { - for _, entry := range e.Entries() { - entry.RenumberIDs(idGen) - } -} - -func (*baseMapExpr) isExpr() {} - -type baseSelectExpr struct { - operand Expr - field string - testOnly bool -} - -func (*baseSelectExpr) Kind() ExprKind { - return SelectKind -} - -func (e *baseSelectExpr) Operand() Expr { - if e == nil || e.operand == nil { - return nilExpr - } - return e.operand -} - -func (e *baseSelectExpr) FieldName() string { - if e == nil { - return "" - } - return e.field -} - -func (e *baseSelectExpr) IsTestOnly() bool { - if e == nil { - return false - } - return e.testOnly -} - -func (e *baseSelectExpr) renumberIDs(idGen IDGenerator) { - e.Operand().RenumberIDs(idGen) -} - -func (*baseSelectExpr) isExpr() {} - -type baseStructExpr struct { - typeName string - fields []EntryExpr -} - -func (*baseStructExpr) Kind() ExprKind { - return StructKind -} - -func (e *baseStructExpr) TypeName() string { - if e == nil { - return "" - } - return e.typeName -} - -func (e *baseStructExpr) Fields() []EntryExpr { - if e == nil { - return []EntryExpr{} - } - return e.fields -} - -func (e *baseStructExpr) renumberIDs(idGen IDGenerator) { - for _, f := range e.Fields() { - f.RenumberIDs(idGen) - } -} - -func (*baseStructExpr) isExpr() {} - -type entryExprKindCase interface { - Kind() EntryExprKind - - renumberIDs(IDGenerator) - - isEntryExpr() -} - -var _ EntryExpr = &entryExpr{} - -type entryExpr struct { - id int64 - entryExprKindCase -} - -func (e *entryExpr) ID() int64 { - return e.id -} - -func (e *entryExpr) AsMapEntry() MapEntry { - if e.Kind() != MapEntryKind { - return nilMapEntry - } - return e.entryExprKindCase.(MapEntry) -} - -func (e *entryExpr) AsStructField() StructField { - if e.Kind() != StructFieldKind { - return nilStructField - } - return e.entryExprKindCase.(StructField) -} - -func (e *entryExpr) RenumberIDs(idGen IDGenerator) { - e.id = idGen(e.id) - e.entryExprKindCase.renumberIDs(idGen) -} - -type baseMapEntry struct { - key Expr - value Expr - isOptional bool -} - -func (e *baseMapEntry) Kind() EntryExprKind { - return MapEntryKind -} - -func (e *baseMapEntry) Key() Expr { - if e == nil { - return nilExpr - } - return e.key -} - -func (e *baseMapEntry) Value() Expr { - if e == nil { - return nilExpr - } - return e.value -} - -func (e *baseMapEntry) IsOptional() bool { - if e == nil { - return false - } - return e.isOptional -} - -func (e *baseMapEntry) renumberIDs(idGen IDGenerator) { - e.Key().RenumberIDs(idGen) - e.Value().RenumberIDs(idGen) -} - -func (*baseMapEntry) isEntryExpr() {} - -type baseStructField struct { - field string - value Expr - isOptional bool -} - -func (f *baseStructField) Kind() EntryExprKind { - return StructFieldKind -} - -func (f *baseStructField) Name() string { - if f == nil { - return "" - } - return f.field -} - -func (f *baseStructField) Value() Expr { - if f == nil { - return nilExpr - } - return f.value -} - -func (f *baseStructField) IsOptional() bool { - if f == nil { - return false - } - return f.isOptional -} - -func (f *baseStructField) renumberIDs(idGen IDGenerator) { - f.Value().RenumberIDs(idGen) -} - -func (*baseStructField) isEntryExpr() {} - -var ( - nilExpr *expr = nil - nilCall *baseCallExpr = nil - nilCompre *baseComprehensionExpr = nil - nilList *baseListExpr = nil - nilMap *baseMapExpr = nil - nilMapEntry *baseMapEntry = nil - nilSel *baseSelectExpr = nil - nilStruct *baseStructExpr = nil - nilStructField *baseStructField = nil -) diff --git a/vendor/github.com/google/cel-go/common/ast/factory.go b/vendor/github.com/google/cel-go/common/ast/factory.go deleted file mode 100644 index b7f36e72a..000000000 --- a/vendor/github.com/google/cel-go/common/ast/factory.go +++ /dev/null @@ -1,303 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ast - -import "github.com/google/cel-go/common/types/ref" - -// ExprFactory interfaces defines a set of methods necessary for building native expression values. -type ExprFactory interface { - // CopyExpr creates a deep copy of the input Expr value. - CopyExpr(Expr) Expr - - // CopyEntryExpr creates a deep copy of the input EntryExpr value. - CopyEntryExpr(EntryExpr) EntryExpr - - // NewCall creates an Expr value representing a global function call. - NewCall(id int64, function string, args ...Expr) Expr - - // NewComprehension creates an Expr value representing a comprehension over a value range. - NewComprehension(id int64, iterRange Expr, iterVar, accuVar string, accuInit, loopCondition, loopStep, result Expr) Expr - - // NewMemberCall creates an Expr value representing a member function call. - NewMemberCall(id int64, function string, receiver Expr, args ...Expr) Expr - - // NewIdent creates an Expr value representing an identifier. - NewIdent(id int64, name string) Expr - - // NewAccuIdent creates an Expr value representing an accumulator identifier within a - //comprehension. - NewAccuIdent(id int64) Expr - - // NewLiteral creates an Expr value representing a literal value, such as a string or integer. - NewLiteral(id int64, value ref.Val) Expr - - // NewList creates an Expr value representing a list literal expression with optional indices. - // - // Optional indicies will typically be empty unless the CEL optional types are enabled. - NewList(id int64, elems []Expr, optIndices []int32) Expr - - // NewMap creates an Expr value representing a map literal expression - NewMap(id int64, entries []EntryExpr) Expr - - // NewMapEntry creates a MapEntry with a given key, value, and a flag indicating whether - // the key is optionally set. - NewMapEntry(id int64, key, value Expr, isOptional bool) EntryExpr - - // NewPresenceTest creates an Expr representing a field presence test on an operand expression. - NewPresenceTest(id int64, operand Expr, field string) Expr - - // NewSelect creates an Expr representing a field selection on an operand expression. - NewSelect(id int64, operand Expr, field string) Expr - - // NewStruct creates an Expr value representing a struct literal with a given type name and a - // set of field initializers. - NewStruct(id int64, typeName string, fields []EntryExpr) Expr - - // NewStructField creates a StructField with a given field name, value, and a flag indicating - // whether the field is optionally set. - NewStructField(id int64, field string, value Expr, isOptional bool) EntryExpr - - // NewUnspecifiedExpr creates an empty expression node. - NewUnspecifiedExpr(id int64) Expr - - isExprFactory() -} - -type baseExprFactory struct{} - -// NewExprFactory creates an ExprFactory instance. -func NewExprFactory() ExprFactory { - return &baseExprFactory{} -} - -func (fac *baseExprFactory) NewCall(id int64, function string, args ...Expr) Expr { - if len(args) == 0 { - args = []Expr{} - } - return fac.newExpr( - id, - &baseCallExpr{ - function: function, - target: nilExpr, - args: args, - isMember: false, - }) -} - -func (fac *baseExprFactory) NewMemberCall(id int64, function string, target Expr, args ...Expr) Expr { - if len(args) == 0 { - args = []Expr{} - } - return fac.newExpr( - id, - &baseCallExpr{ - function: function, - target: target, - args: args, - isMember: true, - }) -} - -func (fac *baseExprFactory) NewComprehension(id int64, iterRange Expr, iterVar, accuVar string, accuInit, loopCond, loopStep, result Expr) Expr { - return fac.newExpr( - id, - &baseComprehensionExpr{ - iterRange: iterRange, - iterVar: iterVar, - accuVar: accuVar, - accuInit: accuInit, - loopCond: loopCond, - loopStep: loopStep, - result: result, - }) -} - -func (fac *baseExprFactory) NewIdent(id int64, name string) Expr { - return fac.newExpr(id, baseIdentExpr(name)) -} - -func (fac *baseExprFactory) NewAccuIdent(id int64) Expr { - return fac.NewIdent(id, "__result__") -} - -func (fac *baseExprFactory) NewLiteral(id int64, value ref.Val) Expr { - return fac.newExpr(id, &baseLiteral{Val: value}) -} - -func (fac *baseExprFactory) NewList(id int64, elems []Expr, optIndices []int32) Expr { - optIndexMap := make(map[int32]struct{}, len(optIndices)) - for _, idx := range optIndices { - optIndexMap[idx] = struct{}{} - } - return fac.newExpr(id, - &baseListExpr{ - elements: elems, - optIndices: optIndices, - optIndexMap: optIndexMap, - }) -} - -func (fac *baseExprFactory) NewMap(id int64, entries []EntryExpr) Expr { - return fac.newExpr(id, &baseMapExpr{entries: entries}) -} - -func (fac *baseExprFactory) NewMapEntry(id int64, key, value Expr, isOptional bool) EntryExpr { - return fac.newEntryExpr( - id, - &baseMapEntry{ - key: key, - value: value, - isOptional: isOptional, - }) -} - -func (fac *baseExprFactory) NewPresenceTest(id int64, operand Expr, field string) Expr { - return fac.newExpr( - id, - &baseSelectExpr{ - operand: operand, - field: field, - testOnly: true, - }) -} - -func (fac *baseExprFactory) NewSelect(id int64, operand Expr, field string) Expr { - return fac.newExpr( - id, - &baseSelectExpr{ - operand: operand, - field: field, - }) -} - -func (fac *baseExprFactory) NewStruct(id int64, typeName string, fields []EntryExpr) Expr { - return fac.newExpr( - id, - &baseStructExpr{ - typeName: typeName, - fields: fields, - }) -} - -func (fac *baseExprFactory) NewStructField(id int64, field string, value Expr, isOptional bool) EntryExpr { - return fac.newEntryExpr( - id, - &baseStructField{ - field: field, - value: value, - isOptional: isOptional, - }) -} - -func (fac *baseExprFactory) NewUnspecifiedExpr(id int64) Expr { - return fac.newExpr(id, nil) -} - -func (fac *baseExprFactory) CopyExpr(e Expr) Expr { - // unwrap navigable expressions to avoid unnecessary allocations during copying. - if nav, ok := e.(*navigableExprImpl); ok { - e = nav.Expr - } - switch e.Kind() { - case CallKind: - c := e.AsCall() - argsCopy := make([]Expr, len(c.Args())) - for i, arg := range c.Args() { - argsCopy[i] = fac.CopyExpr(arg) - } - if !c.IsMemberFunction() { - return fac.NewCall(e.ID(), c.FunctionName(), argsCopy...) - } - return fac.NewMemberCall(e.ID(), c.FunctionName(), fac.CopyExpr(c.Target()), argsCopy...) - case ComprehensionKind: - compre := e.AsComprehension() - return fac.NewComprehension(e.ID(), - fac.CopyExpr(compre.IterRange()), - compre.IterVar(), - compre.AccuVar(), - fac.CopyExpr(compre.AccuInit()), - fac.CopyExpr(compre.LoopCondition()), - fac.CopyExpr(compre.LoopStep()), - fac.CopyExpr(compre.Result())) - case IdentKind: - return fac.NewIdent(e.ID(), e.AsIdent()) - case ListKind: - l := e.AsList() - elemsCopy := make([]Expr, l.Size()) - for i, elem := range l.Elements() { - elemsCopy[i] = fac.CopyExpr(elem) - } - return fac.NewList(e.ID(), elemsCopy, l.OptionalIndices()) - case LiteralKind: - return fac.NewLiteral(e.ID(), e.AsLiteral()) - case MapKind: - m := e.AsMap() - entriesCopy := make([]EntryExpr, m.Size()) - for i, entry := range m.Entries() { - entriesCopy[i] = fac.CopyEntryExpr(entry) - } - return fac.NewMap(e.ID(), entriesCopy) - case SelectKind: - s := e.AsSelect() - if s.IsTestOnly() { - return fac.NewPresenceTest(e.ID(), fac.CopyExpr(s.Operand()), s.FieldName()) - } - return fac.NewSelect(e.ID(), fac.CopyExpr(s.Operand()), s.FieldName()) - case StructKind: - s := e.AsStruct() - fieldsCopy := make([]EntryExpr, len(s.Fields())) - for i, field := range s.Fields() { - fieldsCopy[i] = fac.CopyEntryExpr(field) - } - return fac.NewStruct(e.ID(), s.TypeName(), fieldsCopy) - default: - return fac.NewUnspecifiedExpr(e.ID()) - } -} - -func (fac *baseExprFactory) CopyEntryExpr(e EntryExpr) EntryExpr { - switch e.Kind() { - case MapEntryKind: - entry := e.AsMapEntry() - return fac.NewMapEntry(e.ID(), - fac.CopyExpr(entry.Key()), fac.CopyExpr(entry.Value()), entry.IsOptional()) - case StructFieldKind: - field := e.AsStructField() - return fac.NewStructField(e.ID(), - field.Name(), fac.CopyExpr(field.Value()), field.IsOptional()) - default: - return fac.newEntryExpr(e.ID(), nil) - } -} - -func (*baseExprFactory) isExprFactory() {} - -func (fac *baseExprFactory) newExpr(id int64, e exprKindCase) Expr { - return &expr{ - id: id, - exprKindCase: e, - } -} - -func (fac *baseExprFactory) newEntryExpr(id int64, e entryExprKindCase) EntryExpr { - return &entryExpr{ - id: id, - entryExprKindCase: e, - } -} - -var ( - defaultFactory = &baseExprFactory{} -) diff --git a/vendor/github.com/google/cel-go/common/ast/navigable.go b/vendor/github.com/google/cel-go/common/ast/navigable.go deleted file mode 100644 index f5ddf6aac..000000000 --- a/vendor/github.com/google/cel-go/common/ast/navigable.go +++ /dev/null @@ -1,652 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ast - -import ( - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/common/types/ref" -) - -// NavigableExpr represents the base navigable expression value with methods to inspect the -// parent and child expressions. -type NavigableExpr interface { - Expr - - // Type of the expression. - // - // If the expression is type-checked, the type check metadata is returned. If the expression - // has not been type-checked, the types.DynType value is returned. - Type() *types.Type - - // Parent returns the parent expression node, if one exists. - Parent() (NavigableExpr, bool) - - // Children returns a list of child expression nodes. - Children() []NavigableExpr - - // Depth indicates the depth in the expression tree. - // - // The root expression has depth 0. - Depth() int -} - -// NavigateAST converts an AST to a NavigableExpr -func NavigateAST(ast *AST) NavigableExpr { - return NavigateExpr(ast, ast.Expr()) -} - -// NavigateExpr creates a NavigableExpr whose type information is backed by the input AST. -// -// If the expression is already a NavigableExpr, the parent and depth information will be -// propagated on the new NavigableExpr value; otherwise, the expr value will be treated -// as though it is the root of the expression graph with a depth of 0. -func NavigateExpr(ast *AST, expr Expr) NavigableExpr { - depth := 0 - var parent NavigableExpr = nil - if nav, ok := expr.(NavigableExpr); ok { - depth = nav.Depth() - parent, _ = nav.Parent() - } - return newNavigableExpr(ast, parent, expr, depth) -} - -// ExprMatcher takes a NavigableExpr in and indicates whether the value is a match. -// -// This function type should be use with the `Match` and `MatchList` calls. -type ExprMatcher func(NavigableExpr) bool - -// ConstantValueMatcher returns an ExprMatcher which will return true if the input NavigableExpr -// is comprised of all constant values, such as a simple literal or even list and map literal. -func ConstantValueMatcher() ExprMatcher { - return matchIsConstantValue -} - -// KindMatcher returns an ExprMatcher which will return true if the input NavigableExpr.Kind() matches -// the specified `kind`. -func KindMatcher(kind ExprKind) ExprMatcher { - return func(e NavigableExpr) bool { - return e.Kind() == kind - } -} - -// FunctionMatcher returns an ExprMatcher which will match NavigableExpr nodes of CallKind type whose -// function name is equal to `funcName`. -func FunctionMatcher(funcName string) ExprMatcher { - return func(e NavigableExpr) bool { - if e.Kind() != CallKind { - return false - } - return e.AsCall().FunctionName() == funcName - } -} - -// AllMatcher returns true for all descendants of a NavigableExpr, effectively flattening them into a list. -// -// Such a result would work well with subsequent MatchList calls. -func AllMatcher() ExprMatcher { - return func(NavigableExpr) bool { - return true - } -} - -// MatchDescendants takes a NavigableExpr and ExprMatcher and produces a list of NavigableExpr values -// matching the input criteria in post-order (bottom up). -func MatchDescendants(expr NavigableExpr, matcher ExprMatcher) []NavigableExpr { - matches := []NavigableExpr{} - navVisitor := &baseVisitor{ - visitExpr: func(e Expr) { - nav := e.(NavigableExpr) - if matcher(nav) { - matches = append(matches, nav) - } - }, - } - visit(expr, navVisitor, postOrder, 0, 0) - return matches -} - -// MatchSubset applies an ExprMatcher to a list of NavigableExpr values and their descendants, producing a -// subset of NavigableExpr values which match. -func MatchSubset(exprs []NavigableExpr, matcher ExprMatcher) []NavigableExpr { - matches := []NavigableExpr{} - navVisitor := &baseVisitor{ - visitExpr: func(e Expr) { - nav := e.(NavigableExpr) - if matcher(nav) { - matches = append(matches, nav) - } - }, - } - for _, expr := range exprs { - visit(expr, navVisitor, postOrder, 0, 1) - } - return matches -} - -// Visitor defines an object for visiting Expr and EntryExpr nodes within an expression graph. -type Visitor interface { - // VisitExpr visits the input expression. - VisitExpr(Expr) - - // VisitEntryExpr visits the input entry expression, i.e. a struct field or map entry. - VisitEntryExpr(EntryExpr) -} - -type baseVisitor struct { - visitExpr func(Expr) - visitEntryExpr func(EntryExpr) -} - -// VisitExpr visits the Expr if the internal expr visitor has been configured. -func (v *baseVisitor) VisitExpr(e Expr) { - if v.visitExpr != nil { - v.visitExpr(e) - } -} - -// VisitEntryExpr visits the entry if the internal expr entry visitor has been configured. -func (v *baseVisitor) VisitEntryExpr(e EntryExpr) { - if v.visitEntryExpr != nil { - v.visitEntryExpr(e) - } -} - -// NewExprVisitor creates a visitor which only visits expression nodes. -func NewExprVisitor(v func(Expr)) Visitor { - return &baseVisitor{ - visitExpr: v, - visitEntryExpr: nil, - } -} - -// PostOrderVisit walks the expression graph and calls the visitor in post-order (bottom-up). -func PostOrderVisit(expr Expr, visitor Visitor) { - visit(expr, visitor, postOrder, 0, 0) -} - -// PreOrderVisit walks the expression graph and calls the visitor in pre-order (top-down). -func PreOrderVisit(expr Expr, visitor Visitor) { - visit(expr, visitor, preOrder, 0, 0) -} - -type visitOrder int - -const ( - preOrder = iota + 1 - postOrder -) - -// TODO: consider exposing a way to configure a limit for the max visit depth. -// It's possible that we could want to configure this on the NewExprVisitor() -// and through MatchDescendents() / MaxID(). -func visit(expr Expr, visitor Visitor, order visitOrder, depth, maxDepth int) { - if maxDepth > 0 && depth == maxDepth { - return - } - if order == preOrder { - visitor.VisitExpr(expr) - } - switch expr.Kind() { - case CallKind: - c := expr.AsCall() - if c.IsMemberFunction() { - visit(c.Target(), visitor, order, depth+1, maxDepth) - } - for _, arg := range c.Args() { - visit(arg, visitor, order, depth+1, maxDepth) - } - case ComprehensionKind: - c := expr.AsComprehension() - visit(c.IterRange(), visitor, order, depth+1, maxDepth) - visit(c.AccuInit(), visitor, order, depth+1, maxDepth) - visit(c.LoopCondition(), visitor, order, depth+1, maxDepth) - visit(c.LoopStep(), visitor, order, depth+1, maxDepth) - visit(c.Result(), visitor, order, depth+1, maxDepth) - case ListKind: - l := expr.AsList() - for _, elem := range l.Elements() { - visit(elem, visitor, order, depth+1, maxDepth) - } - case MapKind: - m := expr.AsMap() - for _, e := range m.Entries() { - if order == preOrder { - visitor.VisitEntryExpr(e) - } - entry := e.AsMapEntry() - visit(entry.Key(), visitor, order, depth+1, maxDepth) - visit(entry.Value(), visitor, order, depth+1, maxDepth) - if order == postOrder { - visitor.VisitEntryExpr(e) - } - } - case SelectKind: - visit(expr.AsSelect().Operand(), visitor, order, depth+1, maxDepth) - case StructKind: - s := expr.AsStruct() - for _, f := range s.Fields() { - visitor.VisitEntryExpr(f) - visit(f.AsStructField().Value(), visitor, order, depth+1, maxDepth) - } - } - if order == postOrder { - visitor.VisitExpr(expr) - } -} - -func matchIsConstantValue(e NavigableExpr) bool { - if e.Kind() == LiteralKind { - return true - } - if e.Kind() == StructKind || e.Kind() == MapKind || e.Kind() == ListKind { - for _, child := range e.Children() { - if !matchIsConstantValue(child) { - return false - } - } - return true - } - return false -} - -func newNavigableExpr(ast *AST, parent NavigableExpr, expr Expr, depth int) NavigableExpr { - // Reduce navigable expression nesting by unwrapping the embedded Expr value. - if nav, ok := expr.(*navigableExprImpl); ok { - expr = nav.Expr - } - nav := &navigableExprImpl{ - Expr: expr, - depth: depth, - ast: ast, - parent: parent, - createChildren: getChildFactory(expr), - } - return nav -} - -type navigableExprImpl struct { - Expr - depth int - ast *AST - parent NavigableExpr - createChildren childFactory -} - -func (nav *navigableExprImpl) Parent() (NavigableExpr, bool) { - if nav.parent != nil { - return nav.parent, true - } - return nil, false -} - -func (nav *navigableExprImpl) ID() int64 { - return nav.Expr.ID() -} - -func (nav *navigableExprImpl) Kind() ExprKind { - return nav.Expr.Kind() -} - -func (nav *navigableExprImpl) Type() *types.Type { - return nav.ast.GetType(nav.ID()) -} - -func (nav *navigableExprImpl) Children() []NavigableExpr { - return nav.createChildren(nav) -} - -func (nav *navigableExprImpl) Depth() int { - return nav.depth -} - -func (nav *navigableExprImpl) AsCall() CallExpr { - return navigableCallImpl{navigableExprImpl: nav} -} - -func (nav *navigableExprImpl) AsComprehension() ComprehensionExpr { - return navigableComprehensionImpl{navigableExprImpl: nav} -} - -func (nav *navigableExprImpl) AsIdent() string { - return nav.Expr.AsIdent() -} - -func (nav *navigableExprImpl) AsList() ListExpr { - return navigableListImpl{navigableExprImpl: nav} -} - -func (nav *navigableExprImpl) AsLiteral() ref.Val { - return nav.Expr.AsLiteral() -} - -func (nav *navigableExprImpl) AsMap() MapExpr { - return navigableMapImpl{navigableExprImpl: nav} -} - -func (nav *navigableExprImpl) AsSelect() SelectExpr { - return navigableSelectImpl{navigableExprImpl: nav} -} - -func (nav *navigableExprImpl) AsStruct() StructExpr { - return navigableStructImpl{navigableExprImpl: nav} -} - -func (nav *navigableExprImpl) createChild(e Expr) NavigableExpr { - return newNavigableExpr(nav.ast, nav, e, nav.depth+1) -} - -func (nav *navigableExprImpl) isExpr() {} - -type navigableCallImpl struct { - *navigableExprImpl -} - -func (call navigableCallImpl) FunctionName() string { - return call.Expr.AsCall().FunctionName() -} - -func (call navigableCallImpl) IsMemberFunction() bool { - return call.Expr.AsCall().IsMemberFunction() -} - -func (call navigableCallImpl) Target() Expr { - t := call.Expr.AsCall().Target() - if t != nil { - return call.createChild(t) - } - return nil -} - -func (call navigableCallImpl) Args() []Expr { - args := call.Expr.AsCall().Args() - navArgs := make([]Expr, len(args)) - for i, a := range args { - navArgs[i] = call.createChild(a) - } - return navArgs -} - -type navigableComprehensionImpl struct { - *navigableExprImpl -} - -func (comp navigableComprehensionImpl) IterRange() Expr { - return comp.createChild(comp.Expr.AsComprehension().IterRange()) -} - -func (comp navigableComprehensionImpl) IterVar() string { - return comp.Expr.AsComprehension().IterVar() -} - -func (comp navigableComprehensionImpl) AccuVar() string { - return comp.Expr.AsComprehension().AccuVar() -} - -func (comp navigableComprehensionImpl) AccuInit() Expr { - return comp.createChild(comp.Expr.AsComprehension().AccuInit()) -} - -func (comp navigableComprehensionImpl) LoopCondition() Expr { - return comp.createChild(comp.Expr.AsComprehension().LoopCondition()) -} - -func (comp navigableComprehensionImpl) LoopStep() Expr { - return comp.createChild(comp.Expr.AsComprehension().LoopStep()) -} - -func (comp navigableComprehensionImpl) Result() Expr { - return comp.createChild(comp.Expr.AsComprehension().Result()) -} - -type navigableListImpl struct { - *navigableExprImpl -} - -func (l navigableListImpl) Elements() []Expr { - pbElems := l.Expr.AsList().Elements() - elems := make([]Expr, len(pbElems)) - for i := 0; i < len(pbElems); i++ { - elems[i] = l.createChild(pbElems[i]) - } - return elems -} - -func (l navigableListImpl) IsOptional(index int32) bool { - return l.Expr.AsList().IsOptional(index) -} - -func (l navigableListImpl) OptionalIndices() []int32 { - return l.Expr.AsList().OptionalIndices() -} - -func (l navigableListImpl) Size() int { - return l.Expr.AsList().Size() -} - -type navigableMapImpl struct { - *navigableExprImpl -} - -func (m navigableMapImpl) Entries() []EntryExpr { - mapExpr := m.Expr.AsMap() - entries := make([]EntryExpr, len(mapExpr.Entries())) - for i, e := range mapExpr.Entries() { - entry := e.AsMapEntry() - entries[i] = &entryExpr{ - id: e.ID(), - entryExprKindCase: navigableEntryImpl{ - key: m.createChild(entry.Key()), - val: m.createChild(entry.Value()), - isOpt: entry.IsOptional(), - }, - } - } - return entries -} - -func (m navigableMapImpl) Size() int { - return m.Expr.AsMap().Size() -} - -type navigableEntryImpl struct { - key NavigableExpr - val NavigableExpr - isOpt bool -} - -func (e navigableEntryImpl) Kind() EntryExprKind { - return MapEntryKind -} - -func (e navigableEntryImpl) Key() Expr { - return e.key -} - -func (e navigableEntryImpl) Value() Expr { - return e.val -} - -func (e navigableEntryImpl) IsOptional() bool { - return e.isOpt -} - -func (e navigableEntryImpl) renumberIDs(IDGenerator) {} - -func (e navigableEntryImpl) isEntryExpr() {} - -type navigableSelectImpl struct { - *navigableExprImpl -} - -func (sel navigableSelectImpl) FieldName() string { - return sel.Expr.AsSelect().FieldName() -} - -func (sel navigableSelectImpl) IsTestOnly() bool { - return sel.Expr.AsSelect().IsTestOnly() -} - -func (sel navigableSelectImpl) Operand() Expr { - return sel.createChild(sel.Expr.AsSelect().Operand()) -} - -type navigableStructImpl struct { - *navigableExprImpl -} - -func (s navigableStructImpl) TypeName() string { - return s.Expr.AsStruct().TypeName() -} - -func (s navigableStructImpl) Fields() []EntryExpr { - fieldInits := s.Expr.AsStruct().Fields() - fields := make([]EntryExpr, len(fieldInits)) - for i, f := range fieldInits { - field := f.AsStructField() - fields[i] = &entryExpr{ - id: f.ID(), - entryExprKindCase: navigableFieldImpl{ - name: field.Name(), - val: s.createChild(field.Value()), - isOpt: field.IsOptional(), - }, - } - } - return fields -} - -type navigableFieldImpl struct { - name string - val NavigableExpr - isOpt bool -} - -func (f navigableFieldImpl) Kind() EntryExprKind { - return StructFieldKind -} - -func (f navigableFieldImpl) Name() string { - return f.name -} - -func (f navigableFieldImpl) Value() Expr { - return f.val -} - -func (f navigableFieldImpl) IsOptional() bool { - return f.isOpt -} - -func (f navigableFieldImpl) renumberIDs(IDGenerator) {} - -func (f navigableFieldImpl) isEntryExpr() {} - -func getChildFactory(expr Expr) childFactory { - if expr == nil { - return noopFactory - } - switch expr.Kind() { - case LiteralKind: - return noopFactory - case IdentKind: - return noopFactory - case SelectKind: - return selectFactory - case CallKind: - return callArgFactory - case ListKind: - return listElemFactory - case MapKind: - return mapEntryFactory - case StructKind: - return structEntryFactory - case ComprehensionKind: - return comprehensionFactory - default: - return noopFactory - } -} - -type childFactory func(*navigableExprImpl) []NavigableExpr - -func noopFactory(*navigableExprImpl) []NavigableExpr { - return nil -} - -func selectFactory(nav *navigableExprImpl) []NavigableExpr { - return []NavigableExpr{nav.createChild(nav.AsSelect().Operand())} -} - -func callArgFactory(nav *navigableExprImpl) []NavigableExpr { - call := nav.Expr.AsCall() - argCount := len(call.Args()) - if call.IsMemberFunction() { - argCount++ - } - navExprs := make([]NavigableExpr, argCount) - i := 0 - if call.IsMemberFunction() { - navExprs[i] = nav.createChild(call.Target()) - i++ - } - for _, arg := range call.Args() { - navExprs[i] = nav.createChild(arg) - i++ - } - return navExprs -} - -func listElemFactory(nav *navigableExprImpl) []NavigableExpr { - l := nav.Expr.AsList() - navExprs := make([]NavigableExpr, len(l.Elements())) - for i, e := range l.Elements() { - navExprs[i] = nav.createChild(e) - } - return navExprs -} - -func structEntryFactory(nav *navigableExprImpl) []NavigableExpr { - s := nav.Expr.AsStruct() - entries := make([]NavigableExpr, len(s.Fields())) - for i, e := range s.Fields() { - f := e.AsStructField() - entries[i] = nav.createChild(f.Value()) - } - return entries -} - -func mapEntryFactory(nav *navigableExprImpl) []NavigableExpr { - m := nav.Expr.AsMap() - entries := make([]NavigableExpr, len(m.Entries())*2) - j := 0 - for _, e := range m.Entries() { - mapEntry := e.AsMapEntry() - entries[j] = nav.createChild(mapEntry.Key()) - entries[j+1] = nav.createChild(mapEntry.Value()) - j += 2 - } - return entries -} - -func comprehensionFactory(nav *navigableExprImpl) []NavigableExpr { - compre := nav.Expr.AsComprehension() - return []NavigableExpr{ - nav.createChild(compre.IterRange()), - nav.createChild(compre.AccuInit()), - nav.createChild(compre.LoopCondition()), - nav.createChild(compre.LoopStep()), - nav.createChild(compre.Result()), - } -} diff --git a/vendor/github.com/google/cel-go/common/containers/BUILD.bazel b/vendor/github.com/google/cel-go/common/containers/BUILD.bazel deleted file mode 100644 index 81197f064..000000000 --- a/vendor/github.com/google/cel-go/common/containers/BUILD.bazel +++ /dev/null @@ -1,31 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -package( - default_visibility = ["//visibility:public"], - licenses = ["notice"], # Apache 2.0 -) - -go_library( - name = "go_default_library", - srcs = [ - "container.go", - ], - importpath = "github.com/google/cel-go/common/containers", - deps = [ - "//common/ast:go_default_library", - ], -) - -go_test( - name = "go_default_test", - size = "small", - srcs = [ - "container_test.go", - ], - embed = [ - ":go_default_library", - ], - deps = [ - "//common/ast:go_default_library", - ], -) diff --git a/vendor/github.com/google/cel-go/common/containers/container.go b/vendor/github.com/google/cel-go/common/containers/container.go deleted file mode 100644 index 52153d4cd..000000000 --- a/vendor/github.com/google/cel-go/common/containers/container.go +++ /dev/null @@ -1,316 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package containers defines types and functions for resolving qualified names within a namespace -// or type provided to CEL. -package containers - -import ( - "fmt" - "strings" - - "github.com/google/cel-go/common/ast" -) - -var ( - // DefaultContainer has an empty container name. - DefaultContainer *Container = nil - - // Empty map to search for aliases when needed. - noAliases = make(map[string]string) -) - -// NewContainer creates a new Container with the fully-qualified name. -func NewContainer(opts ...ContainerOption) (*Container, error) { - var c *Container - var err error - for _, opt := range opts { - c, err = opt(c) - if err != nil { - return nil, err - } - } - return c, nil -} - -// Container holds a reference to an optional qualified container name and set of aliases. -// -// The program container can be used to simplify variable, function, and type specification within -// CEL programs and behaves more or less like a C++ namespace. See ResolveCandidateNames for more -// details. -type Container struct { - name string - aliases map[string]string -} - -// Extend creates a new Container with the existing settings and applies a series of -// ContainerOptions to further configure the new container. -func (c *Container) Extend(opts ...ContainerOption) (*Container, error) { - if c == nil { - return NewContainer(opts...) - } - // Copy the name and aliases of the existing container. - ext := &Container{name: c.Name()} - if len(c.aliasSet()) > 0 { - aliasSet := make(map[string]string, len(c.aliasSet())) - for k, v := range c.aliasSet() { - aliasSet[k] = v - } - ext.aliases = aliasSet - } - // Apply the new options to the container. - var err error - for _, opt := range opts { - ext, err = opt(ext) - if err != nil { - return nil, err - } - } - return ext, nil -} - -// Name returns the fully-qualified name of the container. -// -// The name may conceptually be a namespace, package, or type. -func (c *Container) Name() string { - if c == nil { - return "" - } - return c.name -} - -// ResolveCandidateNames returns the candidates name of namespaced identifiers in C++ resolution -// order. -// -// Names which shadow other names are returned first. If a name includes a leading dot ('.'), -// the name is treated as an absolute identifier which cannot be shadowed. -// -// Given a container name a.b.c.M.N and a type name R.s, this will deliver in order: -// -// a.b.c.M.N.R.s -// a.b.c.M.R.s -// a.b.c.R.s -// a.b.R.s -// a.R.s -// R.s -// -// If aliases or abbreviations are configured for the container, then alias names will take -// precedence over containerized names. -func (c *Container) ResolveCandidateNames(name string) []string { - if strings.HasPrefix(name, ".") { - qn := name[1:] - alias, isAlias := c.findAlias(qn) - if isAlias { - return []string{alias} - } - return []string{qn} - } - alias, isAlias := c.findAlias(name) - if isAlias { - return []string{alias} - } - if c.Name() == "" { - return []string{name} - } - nextCont := c.Name() - candidates := []string{nextCont + "." + name} - for i := strings.LastIndex(nextCont, "."); i >= 0; i = strings.LastIndex(nextCont, ".") { - nextCont = nextCont[:i] - candidates = append(candidates, nextCont+"."+name) - } - return append(candidates, name) -} - -// aliasSet returns the alias to fully-qualified name mapping stored in the container. -func (c *Container) aliasSet() map[string]string { - if c == nil || c.aliases == nil { - return noAliases - } - return c.aliases -} - -// findAlias takes a name as input and returns an alias expansion if one exists. -// -// If the name is qualified, the first component of the qualified name is checked against known -// aliases. Any alias that is found in a qualified name is expanded in the result: -// -// alias: R -> my.alias.R -// name: R.S.T -// output: my.alias.R.S.T -// -// Note, the name must not have a leading dot. -func (c *Container) findAlias(name string) (string, bool) { - // If an alias exists for the name, ensure it is searched last. - simple := name - qualifier := "" - dot := strings.Index(name, ".") - if dot >= 0 { - simple = name[0:dot] - qualifier = name[dot:] - } - alias, found := c.aliasSet()[simple] - if !found { - return "", false - } - return alias + qualifier, true -} - -// ContainerOption specifies a functional configuration option for a Container. -// -// Note, ContainerOption implementations must be able to handle nil container inputs. -type ContainerOption func(*Container) (*Container, error) - -// Abbrevs configures a set of simple names as abbreviations for fully-qualified names. -// -// An abbreviation (abbrev for short) is a simple name that expands to a fully-qualified name. -// Abbreviations can be useful when working with variables, functions, and especially types from -// multiple namespaces: -// -// // CEL object construction -// qual.pkg.version.ObjTypeName{ -// field: alt.container.ver.FieldTypeName{value: ...} -// } -// -// Only one the qualified names above may be used as the CEL container, so at least one of these -// references must be a long qualified name within an otherwise short CEL program. Using the -// following abbreviations, the program becomes much simpler: -// -// // CEL Go option -// Abbrevs("qual.pkg.version.ObjTypeName", "alt.container.ver.FieldTypeName") -// // Simplified Object construction -// ObjTypeName{field: FieldTypeName{value: ...}} -// -// There are a few rules for the qualified names and the simple abbreviations generated from them: -// - Qualified names must be dot-delimited, e.g. `package.subpkg.name`. -// - The last element in the qualified name is the abbreviation. -// - Abbreviations must not collide with each other. -// - The abbreviation must not collide with unqualified names in use. -// -// Abbreviations are distinct from container-based references in the following important ways: -// - Abbreviations must expand to a fully-qualified name. -// - Expanded abbreviations do not participate in namespace resolution. -// - Abbreviation expansion is done instead of the container search for a matching identifier. -// - Containers follow C++ namespace resolution rules with searches from the most qualified name -// to the least qualified name. -// - Container references within the CEL program may be relative, and are resolved to fully -// qualified names at either type-check time or program plan time, whichever comes first. -// -// If there is ever a case where an identifier could be in both the container and as an -// abbreviation, the abbreviation wins as this will ensure that the meaning of a program is -// preserved between compilations even as the container evolves. -func Abbrevs(qualifiedNames ...string) ContainerOption { - return func(c *Container) (*Container, error) { - for _, qn := range qualifiedNames { - ind := strings.LastIndex(qn, ".") - if ind <= 0 || ind >= len(qn)-1 { - return nil, fmt.Errorf( - "invalid qualified name: %s, wanted name of the form 'qualified.name'", qn) - } - alias := qn[ind+1:] - var err error - c, err = aliasAs("abbreviation", qn, alias)(c) - if err != nil { - return nil, err - } - } - return c, nil - } -} - -// Alias associates a fully-qualified name with a user-defined alias. -// -// In general, Abbrevs is preferred to Alias since the names generated from the Abbrevs option -// are more easily traced back to source code. The Alias option is useful for propagating alias -// configuration from one Container instance to another, and may also be useful for remapping -// poorly chosen protobuf message / package names. -// -// Note: all of the rules that apply to Abbrevs also apply to Alias. -func Alias(qualifiedName, alias string) ContainerOption { - return aliasAs("alias", qualifiedName, alias) -} - -func aliasAs(kind, qualifiedName, alias string) ContainerOption { - return func(c *Container) (*Container, error) { - if len(alias) == 0 || strings.Contains(alias, ".") { - return nil, fmt.Errorf( - "%s must be non-empty and simple (not qualified): %s=%s", kind, kind, alias) - } - - if qualifiedName[0:1] == "." { - return nil, fmt.Errorf("qualified name must not begin with a leading '.': %s", - qualifiedName) - } - ind := strings.LastIndex(qualifiedName, ".") - if ind <= 0 || ind == len(qualifiedName)-1 { - return nil, fmt.Errorf("%s must refer to a valid qualified name: %s", - kind, qualifiedName) - } - aliasRef, found := c.aliasSet()[alias] - if found { - return nil, fmt.Errorf( - "%s collides with existing reference: name=%s, %s=%s, existing=%s", - kind, qualifiedName, kind, alias, aliasRef) - } - if strings.HasPrefix(c.Name(), alias+".") || c.Name() == alias { - return nil, fmt.Errorf( - "%s collides with container name: name=%s, %s=%s, container=%s", - kind, qualifiedName, kind, alias, c.Name()) - } - if c == nil { - c = &Container{} - } - if c.aliases == nil { - c.aliases = make(map[string]string) - } - c.aliases[alias] = qualifiedName - return c, nil - } -} - -// Name sets the fully-qualified name of the Container. -func Name(name string) ContainerOption { - return func(c *Container) (*Container, error) { - if len(name) > 0 && name[0:1] == "." { - return nil, fmt.Errorf("container name must not contain a leading '.': %s", name) - } - if c.Name() == name { - return c, nil - } - if c == nil { - return &Container{name: name}, nil - } - c.name = name - return c, nil - } -} - -// ToQualifiedName converts an expression AST into a qualified name if possible, with a boolean -// 'found' value that indicates if the conversion is successful. -func ToQualifiedName(e ast.Expr) (string, bool) { - switch e.Kind() { - case ast.IdentKind: - id := e.AsIdent() - return id, true - case ast.SelectKind: - sel := e.AsSelect() - // Test only expressions are not valid as qualified names. - if sel.IsTestOnly() { - return "", false - } - if qual, found := ToQualifiedName(sel.Operand()); found { - return qual + "." + sel.FieldName(), true - } - } - return "", false -} diff --git a/vendor/github.com/google/cel-go/common/cost.go b/vendor/github.com/google/cel-go/common/cost.go deleted file mode 100644 index 5e24bd0f4..000000000 --- a/vendor/github.com/google/cel-go/common/cost.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package common - -const ( - // SelectAndIdentCost is the cost of an operation that accesses an identifier or performs a select. - SelectAndIdentCost = 1 - - // ConstCost is the cost of an operation that accesses a constant. - ConstCost = 0 - - // ListCreateBaseCost is the base cost of any operation that creates a new list. - ListCreateBaseCost = 10 - - // MapCreateBaseCost is the base cost of any operation that creates a new map. - MapCreateBaseCost = 30 - - // StructCreateBaseCost is the base cost of any operation that creates a new struct. - StructCreateBaseCost = 40 - - // StringTraversalCostFactor is multiplied to a length of a string when computing the cost of traversing the entire - // string once. - StringTraversalCostFactor = 0.1 - - // RegexStringLengthCostFactor is multiplied ot the length of a regex string pattern when computing the cost of - // applying the regex to a string of unit cost. - RegexStringLengthCostFactor = 0.25 -) diff --git a/vendor/github.com/google/cel-go/common/debug/BUILD.bazel b/vendor/github.com/google/cel-go/common/debug/BUILD.bazel deleted file mode 100644 index 724ed3404..000000000 --- a/vendor/github.com/google/cel-go/common/debug/BUILD.bazel +++ /dev/null @@ -1,20 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -package( - default_visibility = ["//visibility:public"], - licenses = ["notice"], # Apache 2.0 -) - -go_library( - name = "go_default_library", - srcs = [ - "debug.go", - ], - importpath = "github.com/google/cel-go/common/debug", - deps = [ - "//common:go_default_library", - "//common/ast:go_default_library", - "//common/types:go_default_library", - "//common/types/ref:go_default_library", - ], -) diff --git a/vendor/github.com/google/cel-go/common/debug/debug.go b/vendor/github.com/google/cel-go/common/debug/debug.go deleted file mode 100644 index e4c01ac6e..000000000 --- a/vendor/github.com/google/cel-go/common/debug/debug.go +++ /dev/null @@ -1,309 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package debug provides tools to print a parsed expression graph and -// adorn each expression element with additional metadata. -package debug - -import ( - "bytes" - "fmt" - "strconv" - "strings" - - "github.com/google/cel-go/common/ast" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/common/types/ref" -) - -// Adorner returns debug metadata that will be tacked on to the string -// representation of an expression. -type Adorner interface { - // GetMetadata for the input context. - GetMetadata(ctx any) string -} - -// Writer manages writing expressions to an internal string. -type Writer interface { - fmt.Stringer - - // Buffer pushes an expression into an internal queue of expressions to - // write to a string. - Buffer(e ast.Expr) -} - -type emptyDebugAdorner struct { -} - -var emptyAdorner Adorner = &emptyDebugAdorner{} - -func (a *emptyDebugAdorner) GetMetadata(e any) string { - return "" -} - -// ToDebugString gives the unadorned string representation of the Expr. -func ToDebugString(e ast.Expr) string { - return ToAdornedDebugString(e, emptyAdorner) -} - -// ToAdornedDebugString gives the adorned string representation of the Expr. -func ToAdornedDebugString(e ast.Expr, adorner Adorner) string { - w := newDebugWriter(adorner) - w.Buffer(e) - return w.String() -} - -// debugWriter is used to print out pretty-printed debug strings. -type debugWriter struct { - adorner Adorner - buffer bytes.Buffer - indent int - lineStart bool -} - -func newDebugWriter(a Adorner) *debugWriter { - return &debugWriter{ - adorner: a, - indent: 0, - lineStart: true, - } -} - -func (w *debugWriter) Buffer(e ast.Expr) { - if e == nil { - return - } - switch e.Kind() { - case ast.LiteralKind: - w.append(formatLiteral(e.AsLiteral())) - case ast.IdentKind: - w.append(e.AsIdent()) - case ast.SelectKind: - w.appendSelect(e.AsSelect()) - case ast.CallKind: - w.appendCall(e.AsCall()) - case ast.ListKind: - w.appendList(e.AsList()) - case ast.MapKind: - w.appendMap(e.AsMap()) - case ast.StructKind: - w.appendStruct(e.AsStruct()) - case ast.ComprehensionKind: - w.appendComprehension(e.AsComprehension()) - } - w.adorn(e) -} - -func (w *debugWriter) appendSelect(sel ast.SelectExpr) { - w.Buffer(sel.Operand()) - w.append(".") - w.append(sel.FieldName()) - if sel.IsTestOnly() { - w.append("~test-only~") - } -} - -func (w *debugWriter) appendCall(call ast.CallExpr) { - if call.IsMemberFunction() { - w.Buffer(call.Target()) - w.append(".") - } - w.append(call.FunctionName()) - w.append("(") - if len(call.Args()) > 0 { - w.addIndent() - w.appendLine() - for i, arg := range call.Args() { - if i > 0 { - w.append(",") - w.appendLine() - } - w.Buffer(arg) - } - w.removeIndent() - w.appendLine() - } - w.append(")") -} - -func (w *debugWriter) appendList(list ast.ListExpr) { - w.append("[") - if len(list.Elements()) > 0 { - w.appendLine() - w.addIndent() - for i, elem := range list.Elements() { - if i > 0 { - w.append(",") - w.appendLine() - } - w.Buffer(elem) - } - w.removeIndent() - w.appendLine() - } - w.append("]") -} - -func (w *debugWriter) appendStruct(obj ast.StructExpr) { - w.append(obj.TypeName()) - w.append("{") - if len(obj.Fields()) > 0 { - w.appendLine() - w.addIndent() - for i, f := range obj.Fields() { - field := f.AsStructField() - if i > 0 { - w.append(",") - w.appendLine() - } - if field.IsOptional() { - w.append("?") - } - w.append(field.Name()) - w.append(":") - w.Buffer(field.Value()) - w.adorn(f) - } - w.removeIndent() - w.appendLine() - } - w.append("}") -} - -func (w *debugWriter) appendMap(m ast.MapExpr) { - w.append("{") - if m.Size() > 0 { - w.appendLine() - w.addIndent() - for i, e := range m.Entries() { - entry := e.AsMapEntry() - if i > 0 { - w.append(",") - w.appendLine() - } - if entry.IsOptional() { - w.append("?") - } - w.Buffer(entry.Key()) - w.append(":") - w.Buffer(entry.Value()) - w.adorn(e) - } - w.removeIndent() - w.appendLine() - } - w.append("}") -} - -func (w *debugWriter) appendComprehension(comprehension ast.ComprehensionExpr) { - w.append("__comprehension__(") - w.addIndent() - w.appendLine() - w.append("// Variable") - w.appendLine() - w.append(comprehension.IterVar()) - w.append(",") - w.appendLine() - w.append("// Target") - w.appendLine() - w.Buffer(comprehension.IterRange()) - w.append(",") - w.appendLine() - w.append("// Accumulator") - w.appendLine() - w.append(comprehension.AccuVar()) - w.append(",") - w.appendLine() - w.append("// Init") - w.appendLine() - w.Buffer(comprehension.AccuInit()) - w.append(",") - w.appendLine() - w.append("// LoopCondition") - w.appendLine() - w.Buffer(comprehension.LoopCondition()) - w.append(",") - w.appendLine() - w.append("// LoopStep") - w.appendLine() - w.Buffer(comprehension.LoopStep()) - w.append(",") - w.appendLine() - w.append("// Result") - w.appendLine() - w.Buffer(comprehension.Result()) - w.append(")") - w.removeIndent() -} - -func formatLiteral(c ref.Val) string { - switch v := c.(type) { - case types.Bool: - return fmt.Sprintf("%t", v) - case types.Bytes: - return fmt.Sprintf("b\"%s\"", string(v)) - case types.Double: - return fmt.Sprintf("%v", float64(v)) - case types.Int: - return fmt.Sprintf("%d", int64(v)) - case types.String: - return strconv.Quote(string(v)) - case types.Uint: - return fmt.Sprintf("%du", uint64(v)) - case types.Null: - return "null" - default: - panic("Unknown constant type") - } -} - -func (w *debugWriter) append(s string) { - w.doIndent() - w.buffer.WriteString(s) -} - -func (w *debugWriter) appendFormat(f string, args ...any) { - w.append(fmt.Sprintf(f, args...)) -} - -func (w *debugWriter) doIndent() { - if w.lineStart { - w.lineStart = false - w.buffer.WriteString(strings.Repeat(" ", w.indent)) - } -} - -func (w *debugWriter) adorn(e any) { - w.append(w.adorner.GetMetadata(e)) -} - -func (w *debugWriter) appendLine() { - w.buffer.WriteString("\n") - w.lineStart = true -} - -func (w *debugWriter) addIndent() { - w.indent++ -} - -func (w *debugWriter) removeIndent() { - w.indent-- - if w.indent < 0 { - panic("negative indent") - } -} - -func (w *debugWriter) String() string { - return w.buffer.String() -} diff --git a/vendor/github.com/google/cel-go/common/decls/BUILD.bazel b/vendor/github.com/google/cel-go/common/decls/BUILD.bazel deleted file mode 100644 index 17791dce6..000000000 --- a/vendor/github.com/google/cel-go/common/decls/BUILD.bazel +++ /dev/null @@ -1,39 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -package( - default_visibility = ["//visibility:public"], - licenses = ["notice"], # Apache 2.0 -) - -go_library( - name = "go_default_library", - srcs = [ - "decls.go", - ], - importpath = "github.com/google/cel-go/common/decls", - deps = [ - "//checker/decls:go_default_library", - "//common/functions:go_default_library", - "//common/types:go_default_library", - "//common/types/ref:go_default_library", - "//common/types/traits:go_default_library", - "@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library", - ], -) - -go_test( - name = "go_default_test", - srcs = [ - "decls_test.go", - ], - embed = [":go_default_library"], - deps = [ - "//checker/decls:go_default_library", - "//common/overloads:go_default_library", - "//common/types:go_default_library", - "//common/types/ref:go_default_library", - "//common/types/traits:go_default_library", - "@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library", - "@org_golang_google_protobuf//proto:go_default_library", - ], -) diff --git a/vendor/github.com/google/cel-go/common/decls/decls.go b/vendor/github.com/google/cel-go/common/decls/decls.go deleted file mode 100644 index 734ebe57e..000000000 --- a/vendor/github.com/google/cel-go/common/decls/decls.go +++ /dev/null @@ -1,844 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package decls contains function and variable declaration structs and helper methods. -package decls - -import ( - "fmt" - "strings" - - chkdecls "github.com/google/cel-go/checker/decls" - "github.com/google/cel-go/common/functions" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/common/types/ref" - - exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1" -) - -// NewFunction creates a new function declaration with a set of function options to configure overloads -// and function definitions (implementations). -// -// Functions are checked for name collisions and singleton redefinition. -func NewFunction(name string, opts ...FunctionOpt) (*FunctionDecl, error) { - fn := &FunctionDecl{ - name: name, - overloads: map[string]*OverloadDecl{}, - overloadOrdinals: []string{}, - } - var err error - for _, opt := range opts { - fn, err = opt(fn) - if err != nil { - return nil, err - } - } - if len(fn.overloads) == 0 { - return nil, fmt.Errorf("function %s must have at least one overload", name) - } - return fn, nil -} - -// FunctionDecl defines a function name, overload set, and optionally a singleton definition for all -// overload instances. -type FunctionDecl struct { - name string - - // overloads associated with the function name. - overloads map[string]*OverloadDecl - - // singleton implementation of the function for all overloads. - // - // If this option is set, an error will occur if any overloads specify a per-overload implementation - // or if another function with the same name attempts to redefine the singleton. - singleton *functions.Overload - - // disableTypeGuards is a performance optimization to disable detailed runtime type checks which could - // add overhead on common operations. Setting this option true leaves error checks and argument checks - // intact. - disableTypeGuards bool - - // state indicates that the binding should be provided as a declaration, as a runtime binding, or both. - state declarationState - - // overloadOrdinals indicates the order in which the overload was declared. - overloadOrdinals []string -} - -type declarationState int - -const ( - declarationStateUnset declarationState = iota - declarationDisabled - declarationEnabled -) - -// Name returns the function name in human-readable terms, e.g. 'contains' of 'math.least' -func (f *FunctionDecl) Name() string { - if f == nil { - return "" - } - return f.name -} - -// IsDeclarationDisabled indicates that the function implementation should be added to the dispatcher, but the -// declaration should not be exposed for use in expressions. -func (f *FunctionDecl) IsDeclarationDisabled() bool { - return f.state == declarationDisabled -} - -// Merge combines an existing function declaration with another. -// -// If a function is extended, by say adding new overloads to an existing function, then it is merged with the -// prior definition of the function at which point its overloads must not collide with pre-existing overloads -// and its bindings (singleton, or per-overload) must not conflict with previous definitions either. -func (f *FunctionDecl) Merge(other *FunctionDecl) (*FunctionDecl, error) { - if f == other { - return f, nil - } - if f.Name() != other.Name() { - return nil, fmt.Errorf("cannot merge unrelated functions. %s and %s", f.Name(), other.Name()) - } - merged := &FunctionDecl{ - name: f.Name(), - overloads: make(map[string]*OverloadDecl, len(f.overloads)), - singleton: f.singleton, - overloadOrdinals: make([]string, len(f.overloads)), - // if one function is expecting type-guards and the other is not, then they - // must not be disabled. - disableTypeGuards: f.disableTypeGuards && other.disableTypeGuards, - // default to the current functions declaration state. - state: f.state, - } - // If the other state indicates that the declaration should be explicitly enabled or - // disabled, then update the merged state with the most recent value. - if other.state != declarationStateUnset { - merged.state = other.state - } - // baseline copy of the overloads and their ordinals - copy(merged.overloadOrdinals, f.overloadOrdinals) - for oID, o := range f.overloads { - merged.overloads[oID] = o - } - // overloads and their ordinals are added from the left - for _, oID := range other.overloadOrdinals { - o := other.overloads[oID] - err := merged.AddOverload(o) - if err != nil { - return nil, fmt.Errorf("function declaration merge failed: %v", err) - } - } - if other.singleton != nil { - if merged.singleton != nil && merged.singleton != other.singleton { - return nil, fmt.Errorf("function already has a singleton binding: %s", f.Name()) - } - merged.singleton = other.singleton - } - return merged, nil -} - -// AddOverload ensures that the new overload does not collide with an existing overload signature; -// however, if the function signatures are identical, the implementation may be rewritten as its -// difficult to compare functions by object identity. -func (f *FunctionDecl) AddOverload(overload *OverloadDecl) error { - if f == nil { - return fmt.Errorf("nil function cannot add overload: %s", overload.ID()) - } - for oID, o := range f.overloads { - if oID != overload.ID() && o.SignatureOverlaps(overload) { - return fmt.Errorf("overload signature collision in function %s: %s collides with %s", f.Name(), oID, overload.ID()) - } - if oID == overload.ID() { - if o.SignatureEquals(overload) && o.IsNonStrict() == overload.IsNonStrict() { - // Allow redefinition of an overload implementation so long as the signatures match. - f.overloads[oID] = overload - return nil - } - return fmt.Errorf("overload redefinition in function. %s: %s has multiple definitions", f.Name(), oID) - } - } - f.overloadOrdinals = append(f.overloadOrdinals, overload.ID()) - f.overloads[overload.ID()] = overload - return nil -} - -// OverloadDecls returns the overload declarations in the order in which they were declared. -func (f *FunctionDecl) OverloadDecls() []*OverloadDecl { - if f == nil { - return []*OverloadDecl{} - } - overloads := make([]*OverloadDecl, 0, len(f.overloads)) - for _, oID := range f.overloadOrdinals { - overloads = append(overloads, f.overloads[oID]) - } - return overloads -} - -// Bindings produces a set of function bindings, if any are defined. -func (f *FunctionDecl) Bindings() ([]*functions.Overload, error) { - if f == nil { - return []*functions.Overload{}, nil - } - overloads := []*functions.Overload{} - nonStrict := false - for _, oID := range f.overloadOrdinals { - o := f.overloads[oID] - if o.hasBinding() { - overload := &functions.Overload{ - Operator: o.ID(), - Unary: o.guardedUnaryOp(f.Name(), f.disableTypeGuards), - Binary: o.guardedBinaryOp(f.Name(), f.disableTypeGuards), - Function: o.guardedFunctionOp(f.Name(), f.disableTypeGuards), - OperandTrait: o.OperandTrait(), - NonStrict: o.IsNonStrict(), - } - overloads = append(overloads, overload) - nonStrict = nonStrict || o.IsNonStrict() - } - } - if f.singleton != nil { - if len(overloads) != 0 { - return nil, fmt.Errorf("singleton function incompatible with specialized overloads: %s", f.Name()) - } - overloads = []*functions.Overload{ - { - Operator: f.Name(), - Unary: f.singleton.Unary, - Binary: f.singleton.Binary, - Function: f.singleton.Function, - OperandTrait: f.singleton.OperandTrait, - }, - } - // fall-through to return single overload case. - } - if len(overloads) == 0 { - return overloads, nil - } - // Single overload. Replicate an entry for it using the function name as well. - if len(overloads) == 1 { - if overloads[0].Operator == f.Name() { - return overloads, nil - } - return append(overloads, &functions.Overload{ - Operator: f.Name(), - Unary: overloads[0].Unary, - Binary: overloads[0].Binary, - Function: overloads[0].Function, - NonStrict: overloads[0].NonStrict, - OperandTrait: overloads[0].OperandTrait, - }), nil - } - // All of the defined overloads are wrapped into a top-level function which - // performs dynamic dispatch to the proper overload based on the argument types. - bindings := append([]*functions.Overload{}, overloads...) - funcDispatch := func(args ...ref.Val) ref.Val { - for _, oID := range f.overloadOrdinals { - o := f.overloads[oID] - // During dynamic dispatch over multiple functions, signature agreement checks - // are preserved in order to assist with the function resolution step. - switch len(args) { - case 1: - if o.unaryOp != nil && o.matchesRuntimeSignature( /* disableTypeGuards=*/ false, args...) { - return o.unaryOp(args[0]) - } - case 2: - if o.binaryOp != nil && o.matchesRuntimeSignature( /* disableTypeGuards=*/ false, args...) { - return o.binaryOp(args[0], args[1]) - } - } - if o.functionOp != nil && o.matchesRuntimeSignature( /* disableTypeGuards=*/ false, args...) { - return o.functionOp(args...) - } - // eventually this will fall through to the noSuchOverload below. - } - return MaybeNoSuchOverload(f.Name(), args...) - } - function := &functions.Overload{ - Operator: f.Name(), - Function: funcDispatch, - NonStrict: nonStrict, - } - return append(bindings, function), nil -} - -// MaybeNoSuchOverload determines whether to propagate an error if one is provided as an argument, or -// to return an unknown set, or to produce a new error for a missing function signature. -func MaybeNoSuchOverload(funcName string, args ...ref.Val) ref.Val { - argTypes := make([]string, len(args)) - var unk *types.Unknown = nil - for i, arg := range args { - if types.IsError(arg) { - return arg - } - if types.IsUnknown(arg) { - unk = types.MergeUnknowns(arg.(*types.Unknown), unk) - } - argTypes[i] = arg.Type().TypeName() - } - if unk != nil { - return unk - } - signature := strings.Join(argTypes, ", ") - return types.NewErr("no such overload: %s(%s)", funcName, signature) -} - -// FunctionOpt defines a functional option for mutating a function declaration. -type FunctionOpt func(*FunctionDecl) (*FunctionDecl, error) - -// DisableTypeGuards disables automatically generated function invocation guards on direct overload calls. -// Type guards remain on during dynamic dispatch for parsed-only expressions. -func DisableTypeGuards(value bool) FunctionOpt { - return func(fn *FunctionDecl) (*FunctionDecl, error) { - fn.disableTypeGuards = value - return fn, nil - } -} - -// DisableDeclaration indicates that the function declaration should be disabled, but the runtime function -// binding should be provided. Marking a function as runtime-only is a safe way to manage deprecations -// of function declarations while still preserving the runtime behavior for previously compiled expressions. -func DisableDeclaration(value bool) FunctionOpt { - return func(fn *FunctionDecl) (*FunctionDecl, error) { - if value { - fn.state = declarationDisabled - } else { - fn.state = declarationEnabled - } - return fn, nil - } -} - -// SingletonUnaryBinding creates a singleton function definition to be used for all function overloads. -// -// Note, this approach works well if operand is expected to have a specific trait which it implements, -// e.g. traits.ContainerType. Otherwise, prefer per-overload function bindings. -func SingletonUnaryBinding(fn functions.UnaryOp, traits ...int) FunctionOpt { - trait := 0 - for _, t := range traits { - trait = trait | t - } - return func(f *FunctionDecl) (*FunctionDecl, error) { - if f.singleton != nil { - return nil, fmt.Errorf("function already has a singleton binding: %s", f.Name()) - } - f.singleton = &functions.Overload{ - Operator: f.Name(), - Unary: fn, - OperandTrait: trait, - } - return f, nil - } -} - -// SingletonBinaryBinding creates a singleton function definition to be used with all function overloads. -// -// Note, this approach works well if operand is expected to have a specific trait which it implements, -// e.g. traits.ContainerType. Otherwise, prefer per-overload function bindings. -func SingletonBinaryBinding(fn functions.BinaryOp, traits ...int) FunctionOpt { - trait := 0 - for _, t := range traits { - trait = trait | t - } - return func(f *FunctionDecl) (*FunctionDecl, error) { - if f.singleton != nil { - return nil, fmt.Errorf("function already has a singleton binding: %s", f.Name()) - } - f.singleton = &functions.Overload{ - Operator: f.Name(), - Binary: fn, - OperandTrait: trait, - } - return f, nil - } -} - -// SingletonFunctionBinding creates a singleton function definition to be used with all function overloads. -// -// Note, this approach works well if operand is expected to have a specific trait which it implements, -// e.g. traits.ContainerType. Otherwise, prefer per-overload function bindings. -func SingletonFunctionBinding(fn functions.FunctionOp, traits ...int) FunctionOpt { - trait := 0 - for _, t := range traits { - trait = trait | t - } - return func(f *FunctionDecl) (*FunctionDecl, error) { - if f.singleton != nil { - return nil, fmt.Errorf("function already has a singleton binding: %s", f.Name()) - } - f.singleton = &functions.Overload{ - Operator: f.Name(), - Function: fn, - OperandTrait: trait, - } - return f, nil - } -} - -// Overload defines a new global overload with an overload id, argument types, and result type. Through the -// use of OverloadOpt options, the overload may also be configured with a binding, an operand trait, and to -// be non-strict. -// -// Note: function bindings should be commonly configured with Overload instances whereas operand traits and -// strict-ness should be rare occurrences. -func Overload(overloadID string, - args []*types.Type, resultType *types.Type, - opts ...OverloadOpt) FunctionOpt { - return newOverload(overloadID, false, args, resultType, opts...) -} - -// MemberOverload defines a new receiver-style overload (or member function) with an overload id, argument types, -// and result type. Through the use of OverloadOpt options, the overload may also be configured with a binding, -// an operand trait, and to be non-strict. -// -// Note: function bindings should be commonly configured with Overload instances whereas operand traits and -// strict-ness should be rare occurrences. -func MemberOverload(overloadID string, - args []*types.Type, resultType *types.Type, - opts ...OverloadOpt) FunctionOpt { - return newOverload(overloadID, true, args, resultType, opts...) -} - -func newOverload(overloadID string, - memberFunction bool, args []*types.Type, resultType *types.Type, - opts ...OverloadOpt) FunctionOpt { - return func(f *FunctionDecl) (*FunctionDecl, error) { - overload, err := newOverloadInternal(overloadID, memberFunction, args, resultType, opts...) - if err != nil { - return nil, err - } - err = f.AddOverload(overload) - if err != nil { - return nil, err - } - return f, nil - } -} - -func newOverloadInternal(overloadID string, - memberFunction bool, args []*types.Type, resultType *types.Type, - opts ...OverloadOpt) (*OverloadDecl, error) { - overload := &OverloadDecl{ - id: overloadID, - argTypes: args, - resultType: resultType, - isMemberFunction: memberFunction, - } - var err error - for _, opt := range opts { - overload, err = opt(overload) - if err != nil { - return nil, err - } - } - return overload, nil -} - -// OverloadDecl contains the definition of a single overload id with a specific signature, and an optional -// implementation. -type OverloadDecl struct { - id string - argTypes []*types.Type - resultType *types.Type - isMemberFunction bool - // nonStrict indicates that the function will accept error and unknown arguments as inputs. - nonStrict bool - // operandTrait indicates whether the member argument should have a specific type-trait. - // - // This is useful for creating overloads which operate on a type-interface rather than a concrete type. - operandTrait int - - // Function implementation options. Optional, but encouraged. - // unaryOp is a function binding that takes a single argument. - unaryOp functions.UnaryOp - // binaryOp is a function binding that takes two arguments. - binaryOp functions.BinaryOp - // functionOp is a catch-all for zero-arity and three-plus arity functions. - functionOp functions.FunctionOp -} - -// ID mirrors the overload signature and provides a unique id which may be referenced within the type-checker -// and interpreter to optimize performance. -// -// The ID format is usually one of two styles: -// global: __ -// member: ___ -func (o *OverloadDecl) ID() string { - if o == nil { - return "" - } - return o.id -} - -// ArgTypes contains the set of argument types expected by the overload. -// -// For member functions ArgTypes[0] represents the member operand type. -func (o *OverloadDecl) ArgTypes() []*types.Type { - if o == nil { - return emptyArgs - } - return o.argTypes -} - -// IsMemberFunction indicates whether the overload is a member function -func (o *OverloadDecl) IsMemberFunction() bool { - if o == nil { - return false - } - return o.isMemberFunction -} - -// IsNonStrict returns whether the overload accepts errors and unknown values as arguments. -func (o *OverloadDecl) IsNonStrict() bool { - if o == nil { - return false - } - return o.nonStrict -} - -// OperandTrait returns the trait mask of the first operand to the overload call, e.g. -// `traits.Indexer` -func (o *OverloadDecl) OperandTrait() int { - if o == nil { - return 0 - } - return o.operandTrait -} - -// ResultType indicates the output type from calling the function. -func (o *OverloadDecl) ResultType() *types.Type { - if o == nil { - // *types.Type is nil-safe - return nil - } - return o.resultType -} - -// TypeParams returns the type parameter names associated with the overload. -func (o *OverloadDecl) TypeParams() []string { - typeParams := map[string]struct{}{} - collectParamNames(typeParams, o.ResultType()) - for _, arg := range o.ArgTypes() { - collectParamNames(typeParams, arg) - } - params := make([]string, 0, len(typeParams)) - for param := range typeParams { - params = append(params, param) - } - return params -} - -// SignatureEquals determines whether the incoming overload declaration signature is equal to the current signature. -// -// Result type, operand trait, and strict-ness are not considered as part of signature equality. -func (o *OverloadDecl) SignatureEquals(other *OverloadDecl) bool { - if o == other { - return true - } - if o.ID() != other.ID() || o.IsMemberFunction() != other.IsMemberFunction() || len(o.ArgTypes()) != len(other.ArgTypes()) { - return false - } - for i, at := range o.ArgTypes() { - oat := other.ArgTypes()[i] - if !at.IsEquivalentType(oat) { - return false - } - } - return o.ResultType().IsEquivalentType(other.ResultType()) -} - -// SignatureOverlaps indicates whether two functions have non-equal, but overloapping function signatures. -// -// For example, list(dyn) collides with list(string) since the 'dyn' type can contain a 'string' type. -func (o *OverloadDecl) SignatureOverlaps(other *OverloadDecl) bool { - if o.IsMemberFunction() != other.IsMemberFunction() || len(o.ArgTypes()) != len(other.ArgTypes()) { - return false - } - argsOverlap := true - for i, argType := range o.ArgTypes() { - otherArgType := other.ArgTypes()[i] - argsOverlap = argsOverlap && - (argType.IsAssignableType(otherArgType) || - otherArgType.IsAssignableType(argType)) - } - return argsOverlap -} - -// hasBinding indicates whether the overload already has a definition. -func (o *OverloadDecl) hasBinding() bool { - return o != nil && (o.unaryOp != nil || o.binaryOp != nil || o.functionOp != nil) -} - -// guardedUnaryOp creates an invocation guard around the provided unary operator, if one is defined. -func (o *OverloadDecl) guardedUnaryOp(funcName string, disableTypeGuards bool) functions.UnaryOp { - if o.unaryOp == nil { - return nil - } - return func(arg ref.Val) ref.Val { - if !o.matchesRuntimeUnarySignature(disableTypeGuards, arg) { - return MaybeNoSuchOverload(funcName, arg) - } - return o.unaryOp(arg) - } -} - -// guardedBinaryOp creates an invocation guard around the provided binary operator, if one is defined. -func (o *OverloadDecl) guardedBinaryOp(funcName string, disableTypeGuards bool) functions.BinaryOp { - if o.binaryOp == nil { - return nil - } - return func(arg1, arg2 ref.Val) ref.Val { - if !o.matchesRuntimeBinarySignature(disableTypeGuards, arg1, arg2) { - return MaybeNoSuchOverload(funcName, arg1, arg2) - } - return o.binaryOp(arg1, arg2) - } -} - -// guardedFunctionOp creates an invocation guard around the provided variadic function binding, if one is provided. -func (o *OverloadDecl) guardedFunctionOp(funcName string, disableTypeGuards bool) functions.FunctionOp { - if o.functionOp == nil { - return nil - } - return func(args ...ref.Val) ref.Val { - if !o.matchesRuntimeSignature(disableTypeGuards, args...) { - return MaybeNoSuchOverload(funcName, args...) - } - return o.functionOp(args...) - } -} - -// matchesRuntimeUnarySignature indicates whether the argument type is runtime assiganble to the overload's expected argument. -func (o *OverloadDecl) matchesRuntimeUnarySignature(disableTypeGuards bool, arg ref.Val) bool { - return matchRuntimeArgType(o.IsNonStrict(), disableTypeGuards, o.ArgTypes()[0], arg) && - matchOperandTrait(o.OperandTrait(), arg) -} - -// matchesRuntimeBinarySignature indicates whether the argument types are runtime assiganble to the overload's expected arguments. -func (o *OverloadDecl) matchesRuntimeBinarySignature(disableTypeGuards bool, arg1, arg2 ref.Val) bool { - return matchRuntimeArgType(o.IsNonStrict(), disableTypeGuards, o.ArgTypes()[0], arg1) && - matchRuntimeArgType(o.IsNonStrict(), disableTypeGuards, o.ArgTypes()[1], arg2) && - matchOperandTrait(o.OperandTrait(), arg1) -} - -// matchesRuntimeSignature indicates whether the argument types are runtime assiganble to the overload's expected arguments. -func (o *OverloadDecl) matchesRuntimeSignature(disableTypeGuards bool, args ...ref.Val) bool { - if len(args) != len(o.ArgTypes()) { - return false - } - if len(args) == 0 { - return true - } - for i, arg := range args { - if !matchRuntimeArgType(o.IsNonStrict(), disableTypeGuards, o.ArgTypes()[i], arg) { - return false - } - } - return matchOperandTrait(o.OperandTrait(), args[0]) -} - -func matchRuntimeArgType(nonStrict, disableTypeGuards bool, argType *types.Type, arg ref.Val) bool { - if nonStrict && (disableTypeGuards || types.IsUnknownOrError(arg)) { - return true - } - if types.IsUnknownOrError(arg) { - return false - } - return disableTypeGuards || argType.IsAssignableRuntimeType(arg) -} - -func matchOperandTrait(trait int, arg ref.Val) bool { - return trait == 0 || arg.Type().HasTrait(trait) || types.IsUnknownOrError(arg) -} - -// OverloadOpt is a functional option for configuring a function overload. -type OverloadOpt func(*OverloadDecl) (*OverloadDecl, error) - -// UnaryBinding provides the implementation of a unary overload. The provided function is protected by a runtime -// type-guard which ensures runtime type agreement between the overload signature and runtime argument types. -func UnaryBinding(binding functions.UnaryOp) OverloadOpt { - return func(o *OverloadDecl) (*OverloadDecl, error) { - if o.hasBinding() { - return nil, fmt.Errorf("overload already has a binding: %s", o.ID()) - } - if len(o.ArgTypes()) != 1 { - return nil, fmt.Errorf("unary function bound to non-unary overload: %s", o.ID()) - } - o.unaryOp = binding - return o, nil - } -} - -// BinaryBinding provides the implementation of a binary overload. The provided function is protected by a runtime -// type-guard which ensures runtime type agreement between the overload signature and runtime argument types. -func BinaryBinding(binding functions.BinaryOp) OverloadOpt { - return func(o *OverloadDecl) (*OverloadDecl, error) { - if o.hasBinding() { - return nil, fmt.Errorf("overload already has a binding: %s", o.ID()) - } - if len(o.ArgTypes()) != 2 { - return nil, fmt.Errorf("binary function bound to non-binary overload: %s", o.ID()) - } - o.binaryOp = binding - return o, nil - } -} - -// FunctionBinding provides the implementation of a variadic overload. The provided function is protected by a runtime -// type-guard which ensures runtime type agreement between the overload signature and runtime argument types. -func FunctionBinding(binding functions.FunctionOp) OverloadOpt { - return func(o *OverloadDecl) (*OverloadDecl, error) { - if o.hasBinding() { - return nil, fmt.Errorf("overload already has a binding: %s", o.ID()) - } - o.functionOp = binding - return o, nil - } -} - -// OverloadIsNonStrict enables the function to be called with error and unknown argument values. -// -// Note: do not use this option unless absoluately necessary as it should be an uncommon feature. -func OverloadIsNonStrict() OverloadOpt { - return func(o *OverloadDecl) (*OverloadDecl, error) { - o.nonStrict = true - return o, nil - } -} - -// OverloadOperandTrait configures a set of traits which the first argument to the overload must implement in order to be -// successfully invoked. -func OverloadOperandTrait(trait int) OverloadOpt { - return func(o *OverloadDecl) (*OverloadDecl, error) { - o.operandTrait = trait - return o, nil - } -} - -// NewConstant creates a new constant declaration. -func NewConstant(name string, t *types.Type, v ref.Val) *VariableDecl { - return &VariableDecl{name: name, varType: t, value: v} -} - -// NewVariable creates a new variable declaration. -func NewVariable(name string, t *types.Type) *VariableDecl { - return &VariableDecl{name: name, varType: t} -} - -// VariableDecl defines a variable declaration which may optionally have a constant value. -type VariableDecl struct { - name string - varType *types.Type - value ref.Val -} - -// Name returns the fully-qualified variable name -func (v *VariableDecl) Name() string { - if v == nil { - return "" - } - return v.name -} - -// Type returns the types.Type value associated with the variable. -func (v *VariableDecl) Type() *types.Type { - if v == nil { - // types.Type is nil-safe - return nil - } - return v.varType -} - -// Value returns the constant value associated with the declaration. -func (v *VariableDecl) Value() ref.Val { - if v == nil { - return nil - } - return v.value -} - -// DeclarationIsEquivalent returns true if one variable declaration has the same name and same type as the input. -func (v *VariableDecl) DeclarationIsEquivalent(other *VariableDecl) bool { - if v == other { - return true - } - return v.Name() == other.Name() && v.Type().IsEquivalentType(other.Type()) -} - -// VariableDeclToExprDecl converts a go-native variable declaration into a protobuf-type variable declaration. -func VariableDeclToExprDecl(v *VariableDecl) (*exprpb.Decl, error) { - varType, err := types.TypeToExprType(v.Type()) - if err != nil { - return nil, err - } - return chkdecls.NewVar(v.Name(), varType), nil -} - -// TypeVariable creates a new type identifier for use within a types.Provider -func TypeVariable(t *types.Type) *VariableDecl { - return NewVariable(t.TypeName(), types.NewTypeTypeWithParam(t)) -} - -// FunctionDeclToExprDecl converts a go-native function declaration into a protobuf-typed function declaration. -func FunctionDeclToExprDecl(f *FunctionDecl) (*exprpb.Decl, error) { - overloads := make([]*exprpb.Decl_FunctionDecl_Overload, len(f.overloads)) - for i, oID := range f.overloadOrdinals { - o := f.overloads[oID] - paramNames := map[string]struct{}{} - argTypes := make([]*exprpb.Type, len(o.ArgTypes())) - for j, a := range o.ArgTypes() { - collectParamNames(paramNames, a) - at, err := types.TypeToExprType(a) - if err != nil { - return nil, err - } - argTypes[j] = at - } - collectParamNames(paramNames, o.ResultType()) - resultType, err := types.TypeToExprType(o.ResultType()) - if err != nil { - return nil, err - } - if len(paramNames) == 0 { - if o.IsMemberFunction() { - overloads[i] = chkdecls.NewInstanceOverload(oID, argTypes, resultType) - } else { - overloads[i] = chkdecls.NewOverload(oID, argTypes, resultType) - } - } else { - params := []string{} - for pn := range paramNames { - params = append(params, pn) - } - if o.IsMemberFunction() { - overloads[i] = chkdecls.NewParameterizedInstanceOverload(oID, argTypes, resultType, params) - } else { - overloads[i] = chkdecls.NewParameterizedOverload(oID, argTypes, resultType, params) - } - } - } - return chkdecls.NewFunction(f.Name(), overloads...), nil -} - -func collectParamNames(paramNames map[string]struct{}, arg *types.Type) { - if arg.Kind() == types.TypeParamKind { - paramNames[arg.TypeName()] = struct{}{} - } - for _, param := range arg.Parameters() { - collectParamNames(paramNames, param) - } -} - -var ( - emptyArgs = []*types.Type{} -) diff --git a/vendor/github.com/google/cel-go/common/doc.go b/vendor/github.com/google/cel-go/common/doc.go deleted file mode 100644 index 5362fdfe4..000000000 --- a/vendor/github.com/google/cel-go/common/doc.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package common defines types and utilities common to expression parsing, -// checking, and interpretation -package common diff --git a/vendor/github.com/google/cel-go/common/error.go b/vendor/github.com/google/cel-go/common/error.go deleted file mode 100644 index 774dcb5b4..000000000 --- a/vendor/github.com/google/cel-go/common/error.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package common - -import ( - "fmt" - "strings" - "unicode/utf8" - - "golang.org/x/text/width" -) - -// NewError creates an error associated with an expression id with the given message at the given location. -func NewError(id int64, message string, location Location) *Error { - return &Error{Message: message, Location: location, ExprID: id} -} - -// Error type which references an expression id, a location within source, and a message. -type Error struct { - Location Location - Message string - ExprID int64 -} - -const ( - dot = "." - ind = "^" - - // maxSnippetLength is the largest number of characters which can be rendered in an error message snippet. - maxSnippetLength = 16384 -) - -var ( - wideDot = width.Widen.String(dot) - wideInd = width.Widen.String(ind) -) - -// ToDisplayString decorates the error message with the source location. -func (e *Error) ToDisplayString(source Source) string { - var result = fmt.Sprintf("ERROR: %s:%d:%d: %s", - source.Description(), - e.Location.Line(), - e.Location.Column()+1, // add one to the 0-based column for display - e.Message) - if snippet, found := source.Snippet(e.Location.Line()); found && len(snippet) <= maxSnippetLength { - snippet := strings.Replace(snippet, "\t", " ", -1) - srcLine := "\n | " + snippet - var bytes = []byte(snippet) - var indLine = "\n | " - for i := 0; i < e.Location.Column() && len(bytes) > 0; i++ { - _, sz := utf8.DecodeRune(bytes) - bytes = bytes[sz:] - if sz > 1 { - indLine += wideDot - } else { - indLine += dot - } - } - if _, sz := utf8.DecodeRune(bytes); sz > 1 { - indLine += wideInd - } else { - indLine += ind - } - result += srcLine + indLine - } - return result -} diff --git a/vendor/github.com/google/cel-go/common/errors.go b/vendor/github.com/google/cel-go/common/errors.go deleted file mode 100644 index 25adc73d8..000000000 --- a/vendor/github.com/google/cel-go/common/errors.go +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package common - -import ( - "fmt" - "sort" - "strings" -) - -// Errors type which contains a list of errors observed during parsing. -type Errors struct { - errors []*Error - source Source - numErrors int - maxErrorsToReport int -} - -// NewErrors creates a new instance of the Errors type. -func NewErrors(source Source) *Errors { - return &Errors{ - errors: []*Error{}, - source: source, - maxErrorsToReport: 100, - } -} - -// ReportError records an error at a source location. -func (e *Errors) ReportError(l Location, format string, args ...any) { - e.ReportErrorAtID(0, l, format, args...) -} - -// ReportErrorAtID records an error at a source location and expression id. -func (e *Errors) ReportErrorAtID(id int64, l Location, format string, args ...any) { - e.numErrors++ - if e.numErrors > e.maxErrorsToReport { - return - } - err := &Error{ - ExprID: id, - Location: l, - Message: fmt.Sprintf(format, args...), - } - e.errors = append(e.errors, err) -} - -// GetErrors returns the list of observed errors. -func (e *Errors) GetErrors() []*Error { - return e.errors[:] -} - -// Append creates a new Errors object with the current and input errors. -func (e *Errors) Append(errs []*Error) *Errors { - return &Errors{ - errors: append(e.errors[:], errs...), - source: e.source, - numErrors: e.numErrors + len(errs), - maxErrorsToReport: e.maxErrorsToReport, - } -} - -// ToDisplayString returns the error set to a newline delimited string. -func (e *Errors) ToDisplayString() string { - errorsInString := e.maxErrorsToReport - if e.numErrors > e.maxErrorsToReport { - // add one more error to indicate the number of errors truncated. - errorsInString++ - } else { - // otherwise the error set will just contain the number of errors. - errorsInString = e.numErrors - } - - result := make([]string, errorsInString) - sort.SliceStable(e.errors, func(i, j int) bool { - ei := e.errors[i].Location - ej := e.errors[j].Location - return ei.Line() < ej.Line() || - (ei.Line() == ej.Line() && ei.Column() < ej.Column()) - }) - for i, err := range e.errors { - // This can happen during the append of two errors objects - if i >= e.maxErrorsToReport { - break - } - result[i] = err.ToDisplayString(e.source) - } - if e.numErrors > e.maxErrorsToReport { - result[e.maxErrorsToReport] = fmt.Sprintf("%d more errors were truncated", e.numErrors-e.maxErrorsToReport) - } - return strings.Join(result, "\n") -} diff --git a/vendor/github.com/google/cel-go/common/functions/BUILD.bazel b/vendor/github.com/google/cel-go/common/functions/BUILD.bazel deleted file mode 100644 index 3cc27d60c..000000000 --- a/vendor/github.com/google/cel-go/common/functions/BUILD.bazel +++ /dev/null @@ -1,17 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -package( - default_visibility = ["//visibility:public"], - licenses = ["notice"], # Apache 2.0 -) - -go_library( - name = "go_default_library", - srcs = [ - "functions.go", - ], - importpath = "github.com/google/cel-go/common/functions", - deps = [ - "//common/types/ref:go_default_library", - ], -) diff --git a/vendor/github.com/google/cel-go/common/functions/functions.go b/vendor/github.com/google/cel-go/common/functions/functions.go deleted file mode 100644 index 67f4a5944..000000000 --- a/vendor/github.com/google/cel-go/common/functions/functions.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package functions defines the standard builtin functions supported by the interpreter -package functions - -import "github.com/google/cel-go/common/types/ref" - -// Overload defines a named overload of a function, indicating an operand trait -// which must be present on the first argument to the overload as well as one -// of either a unary, binary, or function implementation. -// -// The majority of operators within the expression language are unary or binary -// and the specializations simplify the call contract for implementers of -// types with operator overloads. Any added complexity is assumed to be handled -// by the generic FunctionOp. -type Overload struct { - // Operator name as written in an expression or defined within - // operators.go. - Operator string - - // Operand trait used to dispatch the call. The zero-value indicates a - // global function overload or that one of the Unary / Binary / Function - // definitions should be used to execute the call. - OperandTrait int - - // Unary defines the overload with a UnaryOp implementation. May be nil. - Unary UnaryOp - - // Binary defines the overload with a BinaryOp implementation. May be nil. - Binary BinaryOp - - // Function defines the overload with a FunctionOp implementation. May be - // nil. - Function FunctionOp - - // NonStrict specifies whether the Overload will tolerate arguments that - // are types.Err or types.Unknown. - NonStrict bool -} - -// UnaryOp is a function that takes a single value and produces an output. -type UnaryOp func(value ref.Val) ref.Val - -// BinaryOp is a function that takes two values and produces an output. -type BinaryOp func(lhs ref.Val, rhs ref.Val) ref.Val - -// FunctionOp is a function with accepts zero or more arguments and produces -// a value or error as a result. -type FunctionOp func(values ...ref.Val) ref.Val diff --git a/vendor/github.com/google/cel-go/common/location.go b/vendor/github.com/google/cel-go/common/location.go deleted file mode 100644 index ec3fa7cb5..000000000 --- a/vendor/github.com/google/cel-go/common/location.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package common - -// Location interface to represent a location within Source. -type Location interface { - Line() int // 1-based line number within source. - Column() int // 0-based column number within source. -} - -// SourceLocation helper type to manually construct a location. -type SourceLocation struct { - line int - column int -} - -var ( - // Location implements the SourceLocation interface. - _ Location = &SourceLocation{} - // NoLocation is a particular illegal location. - NoLocation = &SourceLocation{-1, -1} -) - -// NewLocation creates a new location. -func NewLocation(line, column int) Location { - return &SourceLocation{ - line: line, - column: column} -} - -// Line returns the 1-based line of the location. -func (l *SourceLocation) Line() int { - return l.line -} - -// Column returns the 0-based column number of the location. -func (l *SourceLocation) Column() int { - return l.column -} diff --git a/vendor/github.com/google/cel-go/common/operators/BUILD.bazel b/vendor/github.com/google/cel-go/common/operators/BUILD.bazel deleted file mode 100644 index b5b67f062..000000000 --- a/vendor/github.com/google/cel-go/common/operators/BUILD.bazel +++ /dev/null @@ -1,14 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -package( - default_visibility = ["//visibility:public"], - licenses = ["notice"], # Apache 2.0 -) - -go_library( - name = "go_default_library", - srcs = [ - "operators.go", - ], - importpath = "github.com/google/cel-go/common/operators", -) diff --git a/vendor/github.com/google/cel-go/common/operators/operators.go b/vendor/github.com/google/cel-go/common/operators/operators.go deleted file mode 100644 index f9b39bda3..000000000 --- a/vendor/github.com/google/cel-go/common/operators/operators.go +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package operators defines the internal function names of operators. -// -// All operators in the expression language are modelled as function calls. -package operators - -// String "names" for CEL operators. -const ( - // Symbolic operators. - Conditional = "_?_:_" - LogicalAnd = "_&&_" - LogicalOr = "_||_" - LogicalNot = "!_" - Equals = "_==_" - NotEquals = "_!=_" - Less = "_<_" - LessEquals = "_<=_" - Greater = "_>_" - GreaterEquals = "_>=_" - Add = "_+_" - Subtract = "_-_" - Multiply = "_*_" - Divide = "_/_" - Modulo = "_%_" - Negate = "-_" - Index = "_[_]" - OptIndex = "_[?_]" - OptSelect = "_?._" - - // Macros, must have a valid identifier. - Has = "has" - All = "all" - Exists = "exists" - ExistsOne = "exists_one" - Map = "map" - Filter = "filter" - - // Named operators, must not have be valid identifiers. - NotStrictlyFalse = "@not_strictly_false" - In = "@in" - - // Deprecated: named operators with valid identifiers. - OldNotStrictlyFalse = "__not_strictly_false__" - OldIn = "_in_" -) - -var ( - operators = map[string]string{ - "+": Add, - "/": Divide, - "==": Equals, - ">": Greater, - ">=": GreaterEquals, - "in": In, - "<": Less, - "<=": LessEquals, - "%": Modulo, - "*": Multiply, - "!=": NotEquals, - "-": Subtract, - } - // operatorMap of the operator symbol which refers to a struct containing the display name, - // if applicable, the operator precedence, and the arity. - // - // If the symbol does not have a display name listed in the map, it is only because it requires - // special casing to render properly as text. - operatorMap = map[string]struct { - displayName string - precedence int - arity int - }{ - Conditional: {displayName: "", precedence: 8, arity: 3}, - LogicalOr: {displayName: "||", precedence: 7, arity: 2}, - LogicalAnd: {displayName: "&&", precedence: 6, arity: 2}, - Equals: {displayName: "==", precedence: 5, arity: 2}, - Greater: {displayName: ">", precedence: 5, arity: 2}, - GreaterEquals: {displayName: ">=", precedence: 5, arity: 2}, - In: {displayName: "in", precedence: 5, arity: 2}, - Less: {displayName: "<", precedence: 5, arity: 2}, - LessEquals: {displayName: "<=", precedence: 5, arity: 2}, - NotEquals: {displayName: "!=", precedence: 5, arity: 2}, - OldIn: {displayName: "in", precedence: 5, arity: 2}, - Add: {displayName: "+", precedence: 4, arity: 2}, - Subtract: {displayName: "-", precedence: 4, arity: 2}, - Divide: {displayName: "/", precedence: 3, arity: 2}, - Modulo: {displayName: "%", precedence: 3, arity: 2}, - Multiply: {displayName: "*", precedence: 3, arity: 2}, - LogicalNot: {displayName: "!", precedence: 2, arity: 1}, - Negate: {displayName: "-", precedence: 2, arity: 1}, - Index: {displayName: "", precedence: 1, arity: 2}, - OptIndex: {displayName: "", precedence: 1, arity: 2}, - OptSelect: {displayName: "", precedence: 1, arity: 2}, - } -) - -// Find the internal function name for an operator, if the input text is one. -func Find(text string) (string, bool) { - op, found := operators[text] - return op, found -} - -// FindReverse returns the unmangled, text representation of the operator. -func FindReverse(symbol string) (string, bool) { - op, found := operatorMap[symbol] - if !found { - return "", false - } - return op.displayName, true -} - -// FindReverseBinaryOperator returns the unmangled, text representation of a binary operator. -// -// If the symbol does refer to an operator, but the operator does not have a display name the -// result is false. -func FindReverseBinaryOperator(symbol string) (string, bool) { - op, found := operatorMap[symbol] - if !found || op.arity != 2 { - return "", false - } - if op.displayName == "" { - return "", false - } - return op.displayName, true -} - -// Precedence returns the operator precedence, where the higher the number indicates -// higher precedence operations. -func Precedence(symbol string) int { - op, found := operatorMap[symbol] - if !found { - return 0 - } - return op.precedence -} - -// Arity returns the number of argument the operator takes -// -1 is returned if an undefined symbol is provided -func Arity(symbol string) int { - op, found := operatorMap[symbol] - if !found { - return -1 - } - return op.arity -} diff --git a/vendor/github.com/google/cel-go/common/overloads/BUILD.bazel b/vendor/github.com/google/cel-go/common/overloads/BUILD.bazel deleted file mode 100644 index e46e2f483..000000000 --- a/vendor/github.com/google/cel-go/common/overloads/BUILD.bazel +++ /dev/null @@ -1,14 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -package( - default_visibility = ["//visibility:public"], - licenses = ["notice"], # Apache 2.0 -) - -go_library( - name = "go_default_library", - srcs = [ - "overloads.go", - ], - importpath = "github.com/google/cel-go/common/overloads", -) diff --git a/vendor/github.com/google/cel-go/common/overloads/overloads.go b/vendor/github.com/google/cel-go/common/overloads/overloads.go deleted file mode 100644 index 9d50f4367..000000000 --- a/vendor/github.com/google/cel-go/common/overloads/overloads.go +++ /dev/null @@ -1,327 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package overloads defines the internal overload identifiers for function and -// operator overloads. -package overloads - -// Boolean logic overloads -const ( - Conditional = "conditional" - LogicalAnd = "logical_and" - LogicalOr = "logical_or" - LogicalNot = "logical_not" - NotStrictlyFalse = "not_strictly_false" - Equals = "equals" - NotEquals = "not_equals" - LessBool = "less_bool" - LessInt64 = "less_int64" - LessInt64Double = "less_int64_double" - LessInt64Uint64 = "less_int64_uint64" - LessUint64 = "less_uint64" - LessUint64Double = "less_uint64_double" - LessUint64Int64 = "less_uint64_int64" - LessDouble = "less_double" - LessDoubleInt64 = "less_double_int64" - LessDoubleUint64 = "less_double_uint64" - LessString = "less_string" - LessBytes = "less_bytes" - LessTimestamp = "less_timestamp" - LessDuration = "less_duration" - LessEqualsBool = "less_equals_bool" - LessEqualsInt64 = "less_equals_int64" - LessEqualsInt64Double = "less_equals_int64_double" - LessEqualsInt64Uint64 = "less_equals_int64_uint64" - LessEqualsUint64 = "less_equals_uint64" - LessEqualsUint64Double = "less_equals_uint64_double" - LessEqualsUint64Int64 = "less_equals_uint64_int64" - LessEqualsDouble = "less_equals_double" - LessEqualsDoubleInt64 = "less_equals_double_int64" - LessEqualsDoubleUint64 = "less_equals_double_uint64" - LessEqualsString = "less_equals_string" - LessEqualsBytes = "less_equals_bytes" - LessEqualsTimestamp = "less_equals_timestamp" - LessEqualsDuration = "less_equals_duration" - GreaterBool = "greater_bool" - GreaterInt64 = "greater_int64" - GreaterInt64Double = "greater_int64_double" - GreaterInt64Uint64 = "greater_int64_uint64" - GreaterUint64 = "greater_uint64" - GreaterUint64Double = "greater_uint64_double" - GreaterUint64Int64 = "greater_uint64_int64" - GreaterDouble = "greater_double" - GreaterDoubleInt64 = "greater_double_int64" - GreaterDoubleUint64 = "greater_double_uint64" - GreaterString = "greater_string" - GreaterBytes = "greater_bytes" - GreaterTimestamp = "greater_timestamp" - GreaterDuration = "greater_duration" - GreaterEqualsBool = "greater_equals_bool" - GreaterEqualsInt64 = "greater_equals_int64" - GreaterEqualsInt64Double = "greater_equals_int64_double" - GreaterEqualsInt64Uint64 = "greater_equals_int64_uint64" - GreaterEqualsUint64 = "greater_equals_uint64" - GreaterEqualsUint64Double = "greater_equals_uint64_double" - GreaterEqualsUint64Int64 = "greater_equals_uint64_int64" - GreaterEqualsDouble = "greater_equals_double" - GreaterEqualsDoubleInt64 = "greater_equals_double_int64" - GreaterEqualsDoubleUint64 = "greater_equals_double_uint64" - GreaterEqualsString = "greater_equals_string" - GreaterEqualsBytes = "greater_equals_bytes" - GreaterEqualsTimestamp = "greater_equals_timestamp" - GreaterEqualsDuration = "greater_equals_duration" -) - -// Math overloads -const ( - AddInt64 = "add_int64" - AddUint64 = "add_uint64" - AddDouble = "add_double" - AddString = "add_string" - AddBytes = "add_bytes" - AddList = "add_list" - AddTimestampDuration = "add_timestamp_duration" - AddDurationTimestamp = "add_duration_timestamp" - AddDurationDuration = "add_duration_duration" - SubtractInt64 = "subtract_int64" - SubtractUint64 = "subtract_uint64" - SubtractDouble = "subtract_double" - SubtractTimestampTimestamp = "subtract_timestamp_timestamp" - SubtractTimestampDuration = "subtract_timestamp_duration" - SubtractDurationDuration = "subtract_duration_duration" - MultiplyInt64 = "multiply_int64" - MultiplyUint64 = "multiply_uint64" - MultiplyDouble = "multiply_double" - DivideInt64 = "divide_int64" - DivideUint64 = "divide_uint64" - DivideDouble = "divide_double" - ModuloInt64 = "modulo_int64" - ModuloUint64 = "modulo_uint64" - NegateInt64 = "negate_int64" - NegateDouble = "negate_double" -) - -// Index overloads -const ( - IndexList = "index_list" - IndexMap = "index_map" - IndexMessage = "index_message" // TODO: introduce concept of types.Message -) - -// In operators -const ( - DeprecatedIn = "in" - InList = "in_list" - InMap = "in_map" - InMessage = "in_message" // TODO: introduce concept of types.Message -) - -// Size overloads -const ( - Size = "size" - SizeString = "size_string" - SizeBytes = "size_bytes" - SizeList = "size_list" - SizeMap = "size_map" - SizeStringInst = "string_size" - SizeBytesInst = "bytes_size" - SizeListInst = "list_size" - SizeMapInst = "map_size" -) - -// String function names. -const ( - Contains = "contains" - EndsWith = "endsWith" - Matches = "matches" - StartsWith = "startsWith" -) - -// Extension function overloads with complex behaviors that need to be referenced in runtime and static analysis cost computations. -const ( - ExtQuoteString = "strings_quote" -) - -// String function overload names. -const ( - ContainsString = "contains_string" - EndsWithString = "ends_with_string" - MatchesString = "matches_string" - StartsWithString = "starts_with_string" -) - -// Extension function overloads with complex behaviors that need to be referenced in runtime and static analysis cost computations. -const ( - ExtFormatString = "string_format" -) - -// Time-based functions. -const ( - TimeGetFullYear = "getFullYear" - TimeGetMonth = "getMonth" - TimeGetDayOfYear = "getDayOfYear" - TimeGetDate = "getDate" - TimeGetDayOfMonth = "getDayOfMonth" - TimeGetDayOfWeek = "getDayOfWeek" - TimeGetHours = "getHours" - TimeGetMinutes = "getMinutes" - TimeGetSeconds = "getSeconds" - TimeGetMilliseconds = "getMilliseconds" -) - -// Timestamp overloads for time functions without timezones. -const ( - TimestampToYear = "timestamp_to_year" - TimestampToMonth = "timestamp_to_month" - TimestampToDayOfYear = "timestamp_to_day_of_year" - TimestampToDayOfMonthZeroBased = "timestamp_to_day_of_month" - TimestampToDayOfMonthOneBased = "timestamp_to_day_of_month_1_based" - TimestampToDayOfWeek = "timestamp_to_day_of_week" - TimestampToHours = "timestamp_to_hours" - TimestampToMinutes = "timestamp_to_minutes" - TimestampToSeconds = "timestamp_to_seconds" - TimestampToMilliseconds = "timestamp_to_milliseconds" -) - -// Timestamp overloads for time functions with timezones. -const ( - TimestampToYearWithTz = "timestamp_to_year_with_tz" - TimestampToMonthWithTz = "timestamp_to_month_with_tz" - TimestampToDayOfYearWithTz = "timestamp_to_day_of_year_with_tz" - TimestampToDayOfMonthZeroBasedWithTz = "timestamp_to_day_of_month_with_tz" - TimestampToDayOfMonthOneBasedWithTz = "timestamp_to_day_of_month_1_based_with_tz" - TimestampToDayOfWeekWithTz = "timestamp_to_day_of_week_with_tz" - TimestampToHoursWithTz = "timestamp_to_hours_with_tz" - TimestampToMinutesWithTz = "timestamp_to_minutes_with_tz" - TimestampToSecondsWithTz = "timestamp_to_seconds_tz" - TimestampToMillisecondsWithTz = "timestamp_to_milliseconds_with_tz" -) - -// Duration overloads for time functions. -const ( - DurationToHours = "duration_to_hours" - DurationToMinutes = "duration_to_minutes" - DurationToSeconds = "duration_to_seconds" - DurationToMilliseconds = "duration_to_milliseconds" -) - -// Type conversion methods and overloads -const ( - TypeConvertInt = "int" - TypeConvertUint = "uint" - TypeConvertDouble = "double" - TypeConvertBool = "bool" - TypeConvertString = "string" - TypeConvertBytes = "bytes" - TypeConvertTimestamp = "timestamp" - TypeConvertDuration = "duration" - TypeConvertType = "type" - TypeConvertDyn = "dyn" -) - -// Int conversion functions. -const ( - IntToInt = "int64_to_int64" - UintToInt = "uint64_to_int64" - DoubleToInt = "double_to_int64" - StringToInt = "string_to_int64" - TimestampToInt = "timestamp_to_int64" - DurationToInt = "duration_to_int64" -) - -// Uint conversion functions. -const ( - UintToUint = "uint64_to_uint64" - IntToUint = "int64_to_uint64" - DoubleToUint = "double_to_uint64" - StringToUint = "string_to_uint64" -) - -// Double conversion functions. -const ( - DoubleToDouble = "double_to_double" - IntToDouble = "int64_to_double" - UintToDouble = "uint64_to_double" - StringToDouble = "string_to_double" -) - -// Bool conversion functions. -const ( - BoolToBool = "bool_to_bool" - StringToBool = "string_to_bool" -) - -// Bytes conversion functions. -const ( - BytesToBytes = "bytes_to_bytes" - StringToBytes = "string_to_bytes" -) - -// String conversion functions. -const ( - StringToString = "string_to_string" - BoolToString = "bool_to_string" - IntToString = "int64_to_string" - UintToString = "uint64_to_string" - DoubleToString = "double_to_string" - BytesToString = "bytes_to_string" - TimestampToString = "timestamp_to_string" - DurationToString = "duration_to_string" -) - -// Timestamp conversion functions -const ( - TimestampToTimestamp = "timestamp_to_timestamp" - StringToTimestamp = "string_to_timestamp" - IntToTimestamp = "int64_to_timestamp" -) - -// Convert duration from string -const ( - DurationToDuration = "duration_to_duration" - StringToDuration = "string_to_duration" - IntToDuration = "int64_to_duration" -) - -// Convert to dyn -const ( - ToDyn = "to_dyn" -) - -// Comprehensions helper methods, not directly accessible via a developer. -const ( - Iterator = "@iterator" - HasNext = "@hasNext" - Next = "@next" -) - -// IsTypeConversionFunction returns whether the input function is a standard library type -// conversion function. -func IsTypeConversionFunction(function string) bool { - switch function { - case TypeConvertBool, - TypeConvertBytes, - TypeConvertDouble, - TypeConvertDuration, - TypeConvertDyn, - TypeConvertInt, - TypeConvertString, - TypeConvertTimestamp, - TypeConvertType, - TypeConvertUint: - return true - default: - return false - } -} diff --git a/vendor/github.com/google/cel-go/common/runes/BUILD.bazel b/vendor/github.com/google/cel-go/common/runes/BUILD.bazel deleted file mode 100644 index bb30242cf..000000000 --- a/vendor/github.com/google/cel-go/common/runes/BUILD.bazel +++ /dev/null @@ -1,25 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -package( - default_visibility = ["//visibility:public"], - licenses = ["notice"], # Apache 2.0 -) - -go_library( - name = "go_default_library", - srcs = [ - "buffer.go", - ], - importpath = "github.com/google/cel-go/common/runes", -) - -go_test( - name = "go_default_test", - size = "small", - srcs = [ - "buffer_test.go", - ], - embed = [ - ":go_default_library", - ], -) diff --git a/vendor/github.com/google/cel-go/common/runes/buffer.go b/vendor/github.com/google/cel-go/common/runes/buffer.go deleted file mode 100644 index 50aac0b27..000000000 --- a/vendor/github.com/google/cel-go/common/runes/buffer.go +++ /dev/null @@ -1,194 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package runes provides interfaces and utilities for working with runes. -package runes - -import ( - "strings" - "unicode/utf8" -) - -// Buffer is an interface for accessing a contiguous array of code points. -type Buffer interface { - Get(i int) rune - Slice(i, j int) string - Len() int -} - -type emptyBuffer struct{} - -func (e *emptyBuffer) Get(i int) rune { - panic("slice index out of bounds") -} - -func (e *emptyBuffer) Slice(i, j int) string { - if i != 0 || i != j { - panic("slice index out of bounds") - } - return "" -} - -func (e *emptyBuffer) Len() int { - return 0 -} - -var _ Buffer = &emptyBuffer{} - -// asciiBuffer is an implementation for an array of code points that contain code points only from -// the ASCII character set. -type asciiBuffer struct { - arr []byte -} - -func (a *asciiBuffer) Get(i int) rune { - return rune(uint32(a.arr[i])) -} - -func (a *asciiBuffer) Slice(i, j int) string { - return string(a.arr[i:j]) -} - -func (a *asciiBuffer) Len() int { - return len(a.arr) -} - -var _ Buffer = &asciiBuffer{} - -// basicBuffer is an implementation for an array of code points that contain code points from both -// the Latin-1 character set and Basic Multilingual Plane. -type basicBuffer struct { - arr []uint16 -} - -func (b *basicBuffer) Get(i int) rune { - return rune(uint32(b.arr[i])) -} - -func (b *basicBuffer) Slice(i, j int) string { - var str strings.Builder - str.Grow((j - i) * 3) // Worst case encoding size for 0xffff is 3. - for ; i < j; i++ { - str.WriteRune(rune(uint32(b.arr[i]))) - } - return str.String() -} - -func (b *basicBuffer) Len() int { - return len(b.arr) -} - -var _ Buffer = &basicBuffer{} - -// supplementalBuffer is an implementation for an array of code points that contain code points from -// the Latin-1 character set, Basic Multilingual Plane, or the Supplemental Multilingual Plane. -type supplementalBuffer struct { - arr []rune -} - -func (s *supplementalBuffer) Get(i int) rune { - return rune(uint32(s.arr[i])) -} - -func (s *supplementalBuffer) Slice(i, j int) string { - return string(s.arr[i:j]) -} - -func (s *supplementalBuffer) Len() int { - return len(s.arr) -} - -var _ Buffer = &supplementalBuffer{} - -var nilBuffer = &emptyBuffer{} - -// NewBuffer returns an efficient implementation of Buffer for the given text based on the ranges of -// the encoded code points contained within. -// -// Code points are represented as an array of byte, uint16, or rune. This approach ensures that -// each index represents a code point by itself without needing to use an array of rune. At first -// we assume all code points are less than or equal to '\u007f'. If this holds true, the -// underlying storage is a byte array containing only ASCII characters. If we encountered a code -// point above this range but less than or equal to '\uffff' we allocate a uint16 array, copy the -// elements of previous byte array to the uint16 array, and continue. If this holds true, the -// underlying storage is a uint16 array containing only Unicode characters in the Basic Multilingual -// Plane. If we encounter a code point above '\uffff' we allocate an rune array, copy the previous -// elements of the byte or uint16 array, and continue. The underlying storage is an rune array -// containing any Unicode character. -func NewBuffer(data string) Buffer { - if len(data) == 0 { - return nilBuffer - } - var ( - idx = 0 - buf8 = make([]byte, 0, len(data)) - buf16 []uint16 - buf32 []rune - ) - for idx < len(data) { - r, s := utf8.DecodeRuneInString(data[idx:]) - idx += s - if r < utf8.RuneSelf { - buf8 = append(buf8, byte(r)) - continue - } - if r <= 0xffff { - buf16 = make([]uint16, len(buf8), len(data)) - for i, v := range buf8 { - buf16[i] = uint16(v) - } - buf8 = nil - buf16 = append(buf16, uint16(r)) - goto copy16 - } - buf32 = make([]rune, len(buf8), len(data)) - for i, v := range buf8 { - buf32[i] = rune(uint32(v)) - } - buf8 = nil - buf32 = append(buf32, r) - goto copy32 - } - return &asciiBuffer{ - arr: buf8, - } -copy16: - for idx < len(data) { - r, s := utf8.DecodeRuneInString(data[idx:]) - idx += s - if r <= 0xffff { - buf16 = append(buf16, uint16(r)) - continue - } - buf32 = make([]rune, len(buf16), len(data)) - for i, v := range buf16 { - buf32[i] = rune(uint32(v)) - } - buf16 = nil - buf32 = append(buf32, r) - goto copy32 - } - return &basicBuffer{ - arr: buf16, - } -copy32: - for idx < len(data) { - r, s := utf8.DecodeRuneInString(data[idx:]) - idx += s - buf32 = append(buf32, r) - } - return &supplementalBuffer{ - arr: buf32, - } -} diff --git a/vendor/github.com/google/cel-go/common/source.go b/vendor/github.com/google/cel-go/common/source.go deleted file mode 100644 index acf22bdf1..000000000 --- a/vendor/github.com/google/cel-go/common/source.go +++ /dev/null @@ -1,183 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package common - -import ( - "strings" - "unicode/utf8" - - "github.com/google/cel-go/common/runes" - - exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1" -) - -// Source interface for filter source contents. -type Source interface { - // Content returns the source content represented as a string. - // Examples contents are the single file contents, textbox field, - // or url parameter. - Content() string - - // Description gives a brief description of the source. - // Example descriptions are a file name or ui element. - Description() string - - // LineOffsets gives the character offsets at which lines occur. - // The zero-th entry should refer to the break between the first - // and second line, or EOF if there is only one line of source. - LineOffsets() []int32 - - // LocationOffset translates a Location to an offset. - // Given the line and column of the Location returns the - // Location's character offset in the Source, and a bool - // indicating whether the Location was found. - LocationOffset(location Location) (int32, bool) - - // OffsetLocation translates a character offset to a Location, or - // false if the conversion was not feasible. - OffsetLocation(offset int32) (Location, bool) - - // NewLocation takes an input line and column and produces a Location. - // The default behavior is to treat the line and column as absolute, - // but concrete derivations may use this method to convert a relative - // line and column position into an absolute location. - NewLocation(line, col int) Location - - // Snippet returns a line of content and whether the line was found. - Snippet(line int) (string, bool) -} - -// The sourceImpl type implementation of the Source interface. -type sourceImpl struct { - runes.Buffer - description string - lineOffsets []int32 -} - -var _ runes.Buffer = &sourceImpl{} - -// TODO(jimlarson) "Character offsets" should index the code points -// within the UTF-8 encoded string. It currently indexes bytes. -// Can be accomplished by using rune[] instead of string for contents. - -// NewTextSource creates a new Source from the input text string. -func NewTextSource(text string) Source { - return NewStringSource(text, "") -} - -// NewStringSource creates a new Source from the given contents and description. -func NewStringSource(contents string, description string) Source { - // Compute line offsets up front as they are referred to frequently. - lines := strings.Split(contents, "\n") - offsets := make([]int32, len(lines)) - var offset int32 - for i, line := range lines { - offset = offset + int32(utf8.RuneCountInString(line)) + 1 - offsets[int32(i)] = offset - } - return &sourceImpl{ - Buffer: runes.NewBuffer(contents), - description: description, - lineOffsets: offsets, - } -} - -// NewInfoSource creates a new Source from a SourceInfo. -func NewInfoSource(info *exprpb.SourceInfo) Source { - return &sourceImpl{ - Buffer: runes.NewBuffer(""), - description: info.GetLocation(), - lineOffsets: info.GetLineOffsets(), - } -} - -// Content implements the Source interface method. -func (s *sourceImpl) Content() string { - return s.Slice(0, s.Len()) -} - -// Description implements the Source interface method. -func (s *sourceImpl) Description() string { - return s.description -} - -// LineOffsets implements the Source interface method. -func (s *sourceImpl) LineOffsets() []int32 { - return s.lineOffsets -} - -// LocationOffset implements the Source interface method. -func (s *sourceImpl) LocationOffset(location Location) (int32, bool) { - if lineOffset, found := s.findLineOffset(location.Line()); found { - return lineOffset + int32(location.Column()), true - } - return -1, false -} - -// NewLocation implements the Source interface method. -func (s *sourceImpl) NewLocation(line, col int) Location { - return NewLocation(line, col) -} - -// OffsetLocation implements the Source interface method. -func (s *sourceImpl) OffsetLocation(offset int32) (Location, bool) { - line, lineOffset := s.findLine(offset) - return NewLocation(int(line), int(offset-lineOffset)), true -} - -// Snippet implements the Source interface method. -func (s *sourceImpl) Snippet(line int) (string, bool) { - charStart, found := s.findLineOffset(line) - if !found || s.Len() == 0 { - return "", false - } - charEnd, found := s.findLineOffset(line + 1) - if found { - return s.Slice(int(charStart), int(charEnd-1)), true - } - return s.Slice(int(charStart), s.Len()), true -} - -// findLineOffset returns the offset where the (1-indexed) line begins, -// or false if line doesn't exist. -func (s *sourceImpl) findLineOffset(line int) (int32, bool) { - if line == 1 { - return 0, true - } - if line > 1 && line <= int(len(s.lineOffsets)) { - offset := s.lineOffsets[line-2] - return offset, true - } - return -1, false -} - -// findLine finds the line that contains the given character offset and -// returns the line number and offset of the beginning of that line. -// Note that the last line is treated as if it contains all offsets -// beyond the end of the actual source. -func (s *sourceImpl) findLine(characterOffset int32) (int32, int32) { - var line int32 = 1 - for _, lineOffset := range s.lineOffsets { - if lineOffset > characterOffset { - break - } else { - line++ - } - } - if line == 1 { - return line, 0 - } - return line, s.lineOffsets[line-2] -} diff --git a/vendor/github.com/google/cel-go/common/stdlib/BUILD.bazel b/vendor/github.com/google/cel-go/common/stdlib/BUILD.bazel deleted file mode 100644 index c130a93f6..000000000 --- a/vendor/github.com/google/cel-go/common/stdlib/BUILD.bazel +++ /dev/null @@ -1,25 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -package( - default_visibility = ["//visibility:public"], - licenses = ["notice"], # Apache 2.0 -) - -go_library( - name = "go_default_library", - srcs = [ - "standard.go", - ], - importpath = "github.com/google/cel-go/common/stdlib", - deps = [ - "//checker/decls:go_default_library", - "//common/decls:go_default_library", - "//common/functions:go_default_library", - "//common/operators:go_default_library", - "//common/overloads:go_default_library", - "//common/types:go_default_library", - "//common/types/ref:go_default_library", - "//common/types/traits:go_default_library", - "@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library", - ], -) \ No newline at end of file diff --git a/vendor/github.com/google/cel-go/common/stdlib/standard.go b/vendor/github.com/google/cel-go/common/stdlib/standard.go deleted file mode 100644 index d02cb64bf..000000000 --- a/vendor/github.com/google/cel-go/common/stdlib/standard.go +++ /dev/null @@ -1,661 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package stdlib contains all of the standard library function declarations and definitions for CEL. -package stdlib - -import ( - "github.com/google/cel-go/common/decls" - "github.com/google/cel-go/common/functions" - "github.com/google/cel-go/common/operators" - "github.com/google/cel-go/common/overloads" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/common/types/ref" - "github.com/google/cel-go/common/types/traits" - - exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1" -) - -var ( - stdFunctions []*decls.FunctionDecl - stdFnDecls []*exprpb.Decl - stdTypes []*decls.VariableDecl - stdTypeDecls []*exprpb.Decl -) - -func init() { - paramA := types.NewTypeParamType("A") - paramB := types.NewTypeParamType("B") - listOfA := types.NewListType(paramA) - mapOfAB := types.NewMapType(paramA, paramB) - - stdTypes = []*decls.VariableDecl{ - decls.TypeVariable(types.BoolType), - decls.TypeVariable(types.BytesType), - decls.TypeVariable(types.DoubleType), - decls.TypeVariable(types.DurationType), - decls.TypeVariable(types.IntType), - decls.TypeVariable(listOfA), - decls.TypeVariable(mapOfAB), - decls.TypeVariable(types.NullType), - decls.TypeVariable(types.StringType), - decls.TypeVariable(types.TimestampType), - decls.TypeVariable(types.TypeType), - decls.TypeVariable(types.UintType), - } - - stdTypeDecls = make([]*exprpb.Decl, 0, len(stdTypes)) - for _, stdType := range stdTypes { - typeVar, err := decls.VariableDeclToExprDecl(stdType) - if err != nil { - panic(err) - } - stdTypeDecls = append(stdTypeDecls, typeVar) - } - - stdFunctions = []*decls.FunctionDecl{ - // Logical operators. Special-cased within the interpreter. - // Note, the singleton binding prevents extensions from overriding the operator behavior. - function(operators.Conditional, - decls.Overload(overloads.Conditional, argTypes(types.BoolType, paramA, paramA), paramA, - decls.OverloadIsNonStrict()), - decls.SingletonFunctionBinding(noFunctionOverrides)), - function(operators.LogicalAnd, - decls.Overload(overloads.LogicalAnd, argTypes(types.BoolType, types.BoolType), types.BoolType, - decls.OverloadIsNonStrict()), - decls.SingletonBinaryBinding(noBinaryOverrides)), - function(operators.LogicalOr, - decls.Overload(overloads.LogicalOr, argTypes(types.BoolType, types.BoolType), types.BoolType, - decls.OverloadIsNonStrict()), - decls.SingletonBinaryBinding(noBinaryOverrides)), - function(operators.LogicalNot, - decls.Overload(overloads.LogicalNot, argTypes(types.BoolType), types.BoolType), - decls.SingletonUnaryBinding(func(val ref.Val) ref.Val { - b, ok := val.(types.Bool) - if !ok { - return types.MaybeNoSuchOverloadErr(val) - } - return b.Negate() - })), - - // Comprehension short-circuiting related function - function(operators.NotStrictlyFalse, - decls.Overload(overloads.NotStrictlyFalse, argTypes(types.BoolType), types.BoolType, - decls.OverloadIsNonStrict(), - decls.UnaryBinding(notStrictlyFalse))), - // Deprecated: __not_strictly_false__ - function(operators.OldNotStrictlyFalse, - decls.DisableDeclaration(true), // safe deprecation - decls.Overload(operators.OldNotStrictlyFalse, argTypes(types.BoolType), types.BoolType, - decls.OverloadIsNonStrict(), - decls.UnaryBinding(notStrictlyFalse))), - - // Equality / inequality. Special-cased in the interpreter - function(operators.Equals, - decls.Overload(overloads.Equals, argTypes(paramA, paramA), types.BoolType), - decls.SingletonBinaryBinding(noBinaryOverrides)), - function(operators.NotEquals, - decls.Overload(overloads.NotEquals, argTypes(paramA, paramA), types.BoolType), - decls.SingletonBinaryBinding(noBinaryOverrides)), - - // Mathematical operators - function(operators.Add, - decls.Overload(overloads.AddBytes, - argTypes(types.BytesType, types.BytesType), types.BytesType), - decls.Overload(overloads.AddDouble, - argTypes(types.DoubleType, types.DoubleType), types.DoubleType), - decls.Overload(overloads.AddDurationDuration, - argTypes(types.DurationType, types.DurationType), types.DurationType), - decls.Overload(overloads.AddDurationTimestamp, - argTypes(types.DurationType, types.TimestampType), types.TimestampType), - decls.Overload(overloads.AddTimestampDuration, - argTypes(types.TimestampType, types.DurationType), types.TimestampType), - decls.Overload(overloads.AddInt64, - argTypes(types.IntType, types.IntType), types.IntType), - decls.Overload(overloads.AddList, - argTypes(listOfA, listOfA), listOfA), - decls.Overload(overloads.AddString, - argTypes(types.StringType, types.StringType), types.StringType), - decls.Overload(overloads.AddUint64, - argTypes(types.UintType, types.UintType), types.UintType), - decls.SingletonBinaryBinding(func(lhs, rhs ref.Val) ref.Val { - return lhs.(traits.Adder).Add(rhs) - }, traits.AdderType)), - function(operators.Divide, - decls.Overload(overloads.DivideDouble, - argTypes(types.DoubleType, types.DoubleType), types.DoubleType), - decls.Overload(overloads.DivideInt64, - argTypes(types.IntType, types.IntType), types.IntType), - decls.Overload(overloads.DivideUint64, - argTypes(types.UintType, types.UintType), types.UintType), - decls.SingletonBinaryBinding(func(lhs, rhs ref.Val) ref.Val { - return lhs.(traits.Divider).Divide(rhs) - }, traits.DividerType)), - function(operators.Modulo, - decls.Overload(overloads.ModuloInt64, - argTypes(types.IntType, types.IntType), types.IntType), - decls.Overload(overloads.ModuloUint64, - argTypes(types.UintType, types.UintType), types.UintType), - decls.SingletonBinaryBinding(func(lhs, rhs ref.Val) ref.Val { - return lhs.(traits.Modder).Modulo(rhs) - }, traits.ModderType)), - function(operators.Multiply, - decls.Overload(overloads.MultiplyDouble, - argTypes(types.DoubleType, types.DoubleType), types.DoubleType), - decls.Overload(overloads.MultiplyInt64, - argTypes(types.IntType, types.IntType), types.IntType), - decls.Overload(overloads.MultiplyUint64, - argTypes(types.UintType, types.UintType), types.UintType), - decls.SingletonBinaryBinding(func(lhs, rhs ref.Val) ref.Val { - return lhs.(traits.Multiplier).Multiply(rhs) - }, traits.MultiplierType)), - function(operators.Negate, - decls.Overload(overloads.NegateDouble, argTypes(types.DoubleType), types.DoubleType), - decls.Overload(overloads.NegateInt64, argTypes(types.IntType), types.IntType), - decls.SingletonUnaryBinding(func(val ref.Val) ref.Val { - if types.IsBool(val) { - return types.MaybeNoSuchOverloadErr(val) - } - return val.(traits.Negater).Negate() - }, traits.NegatorType)), - function(operators.Subtract, - decls.Overload(overloads.SubtractDouble, - argTypes(types.DoubleType, types.DoubleType), types.DoubleType), - decls.Overload(overloads.SubtractDurationDuration, - argTypes(types.DurationType, types.DurationType), types.DurationType), - decls.Overload(overloads.SubtractInt64, - argTypes(types.IntType, types.IntType), types.IntType), - decls.Overload(overloads.SubtractTimestampDuration, - argTypes(types.TimestampType, types.DurationType), types.TimestampType), - decls.Overload(overloads.SubtractTimestampTimestamp, - argTypes(types.TimestampType, types.TimestampType), types.DurationType), - decls.Overload(overloads.SubtractUint64, - argTypes(types.UintType, types.UintType), types.UintType), - decls.SingletonBinaryBinding(func(lhs, rhs ref.Val) ref.Val { - return lhs.(traits.Subtractor).Subtract(rhs) - }, traits.SubtractorType)), - - // Relations operators - - function(operators.Less, - decls.Overload(overloads.LessBool, - argTypes(types.BoolType, types.BoolType), types.BoolType), - decls.Overload(overloads.LessInt64, - argTypes(types.IntType, types.IntType), types.BoolType), - decls.Overload(overloads.LessInt64Double, - argTypes(types.IntType, types.DoubleType), types.BoolType), - decls.Overload(overloads.LessInt64Uint64, - argTypes(types.IntType, types.UintType), types.BoolType), - decls.Overload(overloads.LessUint64, - argTypes(types.UintType, types.UintType), types.BoolType), - decls.Overload(overloads.LessUint64Double, - argTypes(types.UintType, types.DoubleType), types.BoolType), - decls.Overload(overloads.LessUint64Int64, - argTypes(types.UintType, types.IntType), types.BoolType), - decls.Overload(overloads.LessDouble, - argTypes(types.DoubleType, types.DoubleType), types.BoolType), - decls.Overload(overloads.LessDoubleInt64, - argTypes(types.DoubleType, types.IntType), types.BoolType), - decls.Overload(overloads.LessDoubleUint64, - argTypes(types.DoubleType, types.UintType), types.BoolType), - decls.Overload(overloads.LessString, - argTypes(types.StringType, types.StringType), types.BoolType), - decls.Overload(overloads.LessBytes, - argTypes(types.BytesType, types.BytesType), types.BoolType), - decls.Overload(overloads.LessTimestamp, - argTypes(types.TimestampType, types.TimestampType), types.BoolType), - decls.Overload(overloads.LessDuration, - argTypes(types.DurationType, types.DurationType), types.BoolType), - decls.SingletonBinaryBinding(func(lhs, rhs ref.Val) ref.Val { - cmp := lhs.(traits.Comparer).Compare(rhs) - if cmp == types.IntNegOne { - return types.True - } - if cmp == types.IntOne || cmp == types.IntZero { - return types.False - } - return cmp - }, traits.ComparerType)), - - function(operators.LessEquals, - decls.Overload(overloads.LessEqualsBool, - argTypes(types.BoolType, types.BoolType), types.BoolType), - decls.Overload(overloads.LessEqualsInt64, - argTypes(types.IntType, types.IntType), types.BoolType), - decls.Overload(overloads.LessEqualsInt64Double, - argTypes(types.IntType, types.DoubleType), types.BoolType), - decls.Overload(overloads.LessEqualsInt64Uint64, - argTypes(types.IntType, types.UintType), types.BoolType), - decls.Overload(overloads.LessEqualsUint64, - argTypes(types.UintType, types.UintType), types.BoolType), - decls.Overload(overloads.LessEqualsUint64Double, - argTypes(types.UintType, types.DoubleType), types.BoolType), - decls.Overload(overloads.LessEqualsUint64Int64, - argTypes(types.UintType, types.IntType), types.BoolType), - decls.Overload(overloads.LessEqualsDouble, - argTypes(types.DoubleType, types.DoubleType), types.BoolType), - decls.Overload(overloads.LessEqualsDoubleInt64, - argTypes(types.DoubleType, types.IntType), types.BoolType), - decls.Overload(overloads.LessEqualsDoubleUint64, - argTypes(types.DoubleType, types.UintType), types.BoolType), - decls.Overload(overloads.LessEqualsString, - argTypes(types.StringType, types.StringType), types.BoolType), - decls.Overload(overloads.LessEqualsBytes, - argTypes(types.BytesType, types.BytesType), types.BoolType), - decls.Overload(overloads.LessEqualsTimestamp, - argTypes(types.TimestampType, types.TimestampType), types.BoolType), - decls.Overload(overloads.LessEqualsDuration, - argTypes(types.DurationType, types.DurationType), types.BoolType), - decls.SingletonBinaryBinding(func(lhs, rhs ref.Val) ref.Val { - cmp := lhs.(traits.Comparer).Compare(rhs) - if cmp == types.IntNegOne || cmp == types.IntZero { - return types.True - } - if cmp == types.IntOne { - return types.False - } - return cmp - }, traits.ComparerType)), - - function(operators.Greater, - decls.Overload(overloads.GreaterBool, - argTypes(types.BoolType, types.BoolType), types.BoolType), - decls.Overload(overloads.GreaterInt64, - argTypes(types.IntType, types.IntType), types.BoolType), - decls.Overload(overloads.GreaterInt64Double, - argTypes(types.IntType, types.DoubleType), types.BoolType), - decls.Overload(overloads.GreaterInt64Uint64, - argTypes(types.IntType, types.UintType), types.BoolType), - decls.Overload(overloads.GreaterUint64, - argTypes(types.UintType, types.UintType), types.BoolType), - decls.Overload(overloads.GreaterUint64Double, - argTypes(types.UintType, types.DoubleType), types.BoolType), - decls.Overload(overloads.GreaterUint64Int64, - argTypes(types.UintType, types.IntType), types.BoolType), - decls.Overload(overloads.GreaterDouble, - argTypes(types.DoubleType, types.DoubleType), types.BoolType), - decls.Overload(overloads.GreaterDoubleInt64, - argTypes(types.DoubleType, types.IntType), types.BoolType), - decls.Overload(overloads.GreaterDoubleUint64, - argTypes(types.DoubleType, types.UintType), types.BoolType), - decls.Overload(overloads.GreaterString, - argTypes(types.StringType, types.StringType), types.BoolType), - decls.Overload(overloads.GreaterBytes, - argTypes(types.BytesType, types.BytesType), types.BoolType), - decls.Overload(overloads.GreaterTimestamp, - argTypes(types.TimestampType, types.TimestampType), types.BoolType), - decls.Overload(overloads.GreaterDuration, - argTypes(types.DurationType, types.DurationType), types.BoolType), - decls.SingletonBinaryBinding(func(lhs, rhs ref.Val) ref.Val { - cmp := lhs.(traits.Comparer).Compare(rhs) - if cmp == types.IntOne { - return types.True - } - if cmp == types.IntNegOne || cmp == types.IntZero { - return types.False - } - return cmp - }, traits.ComparerType)), - - function(operators.GreaterEquals, - decls.Overload(overloads.GreaterEqualsBool, - argTypes(types.BoolType, types.BoolType), types.BoolType), - decls.Overload(overloads.GreaterEqualsInt64, - argTypes(types.IntType, types.IntType), types.BoolType), - decls.Overload(overloads.GreaterEqualsInt64Double, - argTypes(types.IntType, types.DoubleType), types.BoolType), - decls.Overload(overloads.GreaterEqualsInt64Uint64, - argTypes(types.IntType, types.UintType), types.BoolType), - decls.Overload(overloads.GreaterEqualsUint64, - argTypes(types.UintType, types.UintType), types.BoolType), - decls.Overload(overloads.GreaterEqualsUint64Double, - argTypes(types.UintType, types.DoubleType), types.BoolType), - decls.Overload(overloads.GreaterEqualsUint64Int64, - argTypes(types.UintType, types.IntType), types.BoolType), - decls.Overload(overloads.GreaterEqualsDouble, - argTypes(types.DoubleType, types.DoubleType), types.BoolType), - decls.Overload(overloads.GreaterEqualsDoubleInt64, - argTypes(types.DoubleType, types.IntType), types.BoolType), - decls.Overload(overloads.GreaterEqualsDoubleUint64, - argTypes(types.DoubleType, types.UintType), types.BoolType), - decls.Overload(overloads.GreaterEqualsString, - argTypes(types.StringType, types.StringType), types.BoolType), - decls.Overload(overloads.GreaterEqualsBytes, - argTypes(types.BytesType, types.BytesType), types.BoolType), - decls.Overload(overloads.GreaterEqualsTimestamp, - argTypes(types.TimestampType, types.TimestampType), types.BoolType), - decls.Overload(overloads.GreaterEqualsDuration, - argTypes(types.DurationType, types.DurationType), types.BoolType), - decls.SingletonBinaryBinding(func(lhs, rhs ref.Val) ref.Val { - cmp := lhs.(traits.Comparer).Compare(rhs) - if cmp == types.IntOne || cmp == types.IntZero { - return types.True - } - if cmp == types.IntNegOne { - return types.False - } - return cmp - }, traits.ComparerType)), - - // Indexing - function(operators.Index, - decls.Overload(overloads.IndexList, argTypes(listOfA, types.IntType), paramA), - decls.Overload(overloads.IndexMap, argTypes(mapOfAB, paramA), paramB), - decls.SingletonBinaryBinding(func(lhs, rhs ref.Val) ref.Val { - return lhs.(traits.Indexer).Get(rhs) - }, traits.IndexerType)), - - // Collections operators - function(operators.In, - decls.Overload(overloads.InList, argTypes(paramA, listOfA), types.BoolType), - decls.Overload(overloads.InMap, argTypes(paramA, mapOfAB), types.BoolType), - decls.SingletonBinaryBinding(inAggregate)), - function(operators.OldIn, - decls.DisableDeclaration(true), // safe deprecation - decls.Overload(overloads.InList, argTypes(paramA, listOfA), types.BoolType), - decls.Overload(overloads.InMap, argTypes(paramA, mapOfAB), types.BoolType), - decls.SingletonBinaryBinding(inAggregate)), - function(overloads.DeprecatedIn, - decls.DisableDeclaration(true), // safe deprecation - decls.Overload(overloads.InList, argTypes(paramA, listOfA), types.BoolType), - decls.Overload(overloads.InMap, argTypes(paramA, mapOfAB), types.BoolType), - decls.SingletonBinaryBinding(inAggregate)), - function(overloads.Size, - decls.Overload(overloads.SizeBytes, argTypes(types.BytesType), types.IntType), - decls.MemberOverload(overloads.SizeBytesInst, argTypes(types.BytesType), types.IntType), - decls.Overload(overloads.SizeList, argTypes(listOfA), types.IntType), - decls.MemberOverload(overloads.SizeListInst, argTypes(listOfA), types.IntType), - decls.Overload(overloads.SizeMap, argTypes(mapOfAB), types.IntType), - decls.MemberOverload(overloads.SizeMapInst, argTypes(mapOfAB), types.IntType), - decls.Overload(overloads.SizeString, argTypes(types.StringType), types.IntType), - decls.MemberOverload(overloads.SizeStringInst, argTypes(types.StringType), types.IntType), - decls.SingletonUnaryBinding(func(val ref.Val) ref.Val { - return val.(traits.Sizer).Size() - }, traits.SizerType)), - - // Type conversions - function(overloads.TypeConvertType, - decls.Overload(overloads.TypeConvertType, argTypes(paramA), types.NewTypeTypeWithParam(paramA)), - decls.SingletonUnaryBinding(convertToType(types.TypeType))), - - // Bool conversions - function(overloads.TypeConvertBool, - decls.Overload(overloads.BoolToBool, argTypes(types.BoolType), types.BoolType, - decls.UnaryBinding(identity)), - decls.Overload(overloads.StringToBool, argTypes(types.StringType), types.BoolType, - decls.UnaryBinding(convertToType(types.BoolType)))), - - // Bytes conversions - function(overloads.TypeConvertBytes, - decls.Overload(overloads.BytesToBytes, argTypes(types.BytesType), types.BytesType, - decls.UnaryBinding(identity)), - decls.Overload(overloads.StringToBytes, argTypes(types.StringType), types.BytesType, - decls.UnaryBinding(convertToType(types.BytesType)))), - - // Double conversions - function(overloads.TypeConvertDouble, - decls.Overload(overloads.DoubleToDouble, argTypes(types.DoubleType), types.DoubleType, - decls.UnaryBinding(identity)), - decls.Overload(overloads.IntToDouble, argTypes(types.IntType), types.DoubleType, - decls.UnaryBinding(convertToType(types.DoubleType))), - decls.Overload(overloads.StringToDouble, argTypes(types.StringType), types.DoubleType, - decls.UnaryBinding(convertToType(types.DoubleType))), - decls.Overload(overloads.UintToDouble, argTypes(types.UintType), types.DoubleType, - decls.UnaryBinding(convertToType(types.DoubleType)))), - - // Duration conversions - function(overloads.TypeConvertDuration, - decls.Overload(overloads.DurationToDuration, argTypes(types.DurationType), types.DurationType, - decls.UnaryBinding(identity)), - decls.Overload(overloads.IntToDuration, argTypes(types.IntType), types.DurationType, - decls.UnaryBinding(convertToType(types.DurationType))), - decls.Overload(overloads.StringToDuration, argTypes(types.StringType), types.DurationType, - decls.UnaryBinding(convertToType(types.DurationType)))), - - // Dyn conversions - function(overloads.TypeConvertDyn, - decls.Overload(overloads.ToDyn, argTypes(paramA), types.DynType), - decls.SingletonUnaryBinding(identity)), - - // Int conversions - function(overloads.TypeConvertInt, - decls.Overload(overloads.IntToInt, argTypes(types.IntType), types.IntType, - decls.UnaryBinding(identity)), - decls.Overload(overloads.DoubleToInt, argTypes(types.DoubleType), types.IntType, - decls.UnaryBinding(convertToType(types.IntType))), - decls.Overload(overloads.DurationToInt, argTypes(types.DurationType), types.IntType, - decls.UnaryBinding(convertToType(types.IntType))), - decls.Overload(overloads.StringToInt, argTypes(types.StringType), types.IntType, - decls.UnaryBinding(convertToType(types.IntType))), - decls.Overload(overloads.TimestampToInt, argTypes(types.TimestampType), types.IntType, - decls.UnaryBinding(convertToType(types.IntType))), - decls.Overload(overloads.UintToInt, argTypes(types.UintType), types.IntType, - decls.UnaryBinding(convertToType(types.IntType))), - ), - - // String conversions - function(overloads.TypeConvertString, - decls.Overload(overloads.StringToString, argTypes(types.StringType), types.StringType, - decls.UnaryBinding(identity)), - decls.Overload(overloads.BoolToString, argTypes(types.BoolType), types.StringType, - decls.UnaryBinding(convertToType(types.StringType))), - decls.Overload(overloads.BytesToString, argTypes(types.BytesType), types.StringType, - decls.UnaryBinding(convertToType(types.StringType))), - decls.Overload(overloads.DoubleToString, argTypes(types.DoubleType), types.StringType, - decls.UnaryBinding(convertToType(types.StringType))), - decls.Overload(overloads.DurationToString, argTypes(types.DurationType), types.StringType, - decls.UnaryBinding(convertToType(types.StringType))), - decls.Overload(overloads.IntToString, argTypes(types.IntType), types.StringType, - decls.UnaryBinding(convertToType(types.StringType))), - decls.Overload(overloads.TimestampToString, argTypes(types.TimestampType), types.StringType, - decls.UnaryBinding(convertToType(types.StringType))), - decls.Overload(overloads.UintToString, argTypes(types.UintType), types.StringType, - decls.UnaryBinding(convertToType(types.StringType)))), - - // Timestamp conversions - function(overloads.TypeConvertTimestamp, - decls.Overload(overloads.TimestampToTimestamp, argTypes(types.TimestampType), types.TimestampType, - decls.UnaryBinding(identity)), - decls.Overload(overloads.IntToTimestamp, argTypes(types.IntType), types.TimestampType, - decls.UnaryBinding(convertToType(types.TimestampType))), - decls.Overload(overloads.StringToTimestamp, argTypes(types.StringType), types.TimestampType, - decls.UnaryBinding(convertToType(types.TimestampType)))), - - // Uint conversions - function(overloads.TypeConvertUint, - decls.Overload(overloads.UintToUint, argTypes(types.UintType), types.UintType, - decls.UnaryBinding(identity)), - decls.Overload(overloads.DoubleToUint, argTypes(types.DoubleType), types.UintType, - decls.UnaryBinding(convertToType(types.UintType))), - decls.Overload(overloads.IntToUint, argTypes(types.IntType), types.UintType, - decls.UnaryBinding(convertToType(types.UintType))), - decls.Overload(overloads.StringToUint, argTypes(types.StringType), types.UintType, - decls.UnaryBinding(convertToType(types.UintType)))), - - // String functions - function(overloads.Contains, - decls.MemberOverload(overloads.ContainsString, - argTypes(types.StringType, types.StringType), types.BoolType, - decls.BinaryBinding(types.StringContains)), - decls.DisableTypeGuards(true)), - function(overloads.EndsWith, - decls.MemberOverload(overloads.EndsWithString, - argTypes(types.StringType, types.StringType), types.BoolType, - decls.BinaryBinding(types.StringEndsWith)), - decls.DisableTypeGuards(true)), - function(overloads.StartsWith, - decls.MemberOverload(overloads.StartsWithString, - argTypes(types.StringType, types.StringType), types.BoolType, - decls.BinaryBinding(types.StringStartsWith)), - decls.DisableTypeGuards(true)), - function(overloads.Matches, - decls.Overload(overloads.Matches, argTypes(types.StringType, types.StringType), types.BoolType), - decls.MemberOverload(overloads.MatchesString, - argTypes(types.StringType, types.StringType), types.BoolType), - decls.SingletonBinaryBinding(func(str, pat ref.Val) ref.Val { - return str.(traits.Matcher).Match(pat) - }, traits.MatcherType)), - - // Timestamp / duration functions - function(overloads.TimeGetFullYear, - decls.MemberOverload(overloads.TimestampToYear, - argTypes(types.TimestampType), types.IntType), - decls.MemberOverload(overloads.TimestampToYearWithTz, - argTypes(types.TimestampType, types.StringType), types.IntType)), - - function(overloads.TimeGetMonth, - decls.MemberOverload(overloads.TimestampToMonth, - argTypes(types.TimestampType), types.IntType), - decls.MemberOverload(overloads.TimestampToMonthWithTz, - argTypes(types.TimestampType, types.StringType), types.IntType)), - - function(overloads.TimeGetDayOfYear, - decls.MemberOverload(overloads.TimestampToDayOfYear, - argTypes(types.TimestampType), types.IntType), - decls.MemberOverload(overloads.TimestampToDayOfYearWithTz, - argTypes(types.TimestampType, types.StringType), types.IntType)), - - function(overloads.TimeGetDayOfMonth, - decls.MemberOverload(overloads.TimestampToDayOfMonthZeroBased, - argTypes(types.TimestampType), types.IntType), - decls.MemberOverload(overloads.TimestampToDayOfMonthZeroBasedWithTz, - argTypes(types.TimestampType, types.StringType), types.IntType)), - - function(overloads.TimeGetDate, - decls.MemberOverload(overloads.TimestampToDayOfMonthOneBased, - argTypes(types.TimestampType), types.IntType), - decls.MemberOverload(overloads.TimestampToDayOfMonthOneBasedWithTz, - argTypes(types.TimestampType, types.StringType), types.IntType)), - - function(overloads.TimeGetDayOfWeek, - decls.MemberOverload(overloads.TimestampToDayOfWeek, - argTypes(types.TimestampType), types.IntType), - decls.MemberOverload(overloads.TimestampToDayOfWeekWithTz, - argTypes(types.TimestampType, types.StringType), types.IntType)), - - function(overloads.TimeGetHours, - decls.MemberOverload(overloads.TimestampToHours, - argTypes(types.TimestampType), types.IntType), - decls.MemberOverload(overloads.TimestampToHoursWithTz, - argTypes(types.TimestampType, types.StringType), types.IntType), - decls.MemberOverload(overloads.DurationToHours, - argTypes(types.DurationType), types.IntType)), - - function(overloads.TimeGetMinutes, - decls.MemberOverload(overloads.TimestampToMinutes, - argTypes(types.TimestampType), types.IntType), - decls.MemberOverload(overloads.TimestampToMinutesWithTz, - argTypes(types.TimestampType, types.StringType), types.IntType), - decls.MemberOverload(overloads.DurationToMinutes, - argTypes(types.DurationType), types.IntType)), - - function(overloads.TimeGetSeconds, - decls.MemberOverload(overloads.TimestampToSeconds, - argTypes(types.TimestampType), types.IntType), - decls.MemberOverload(overloads.TimestampToSecondsWithTz, - argTypes(types.TimestampType, types.StringType), types.IntType), - decls.MemberOverload(overloads.DurationToSeconds, - argTypes(types.DurationType), types.IntType)), - - function(overloads.TimeGetMilliseconds, - decls.MemberOverload(overloads.TimestampToMilliseconds, - argTypes(types.TimestampType), types.IntType), - decls.MemberOverload(overloads.TimestampToMillisecondsWithTz, - argTypes(types.TimestampType, types.StringType), types.IntType), - decls.MemberOverload(overloads.DurationToMilliseconds, - argTypes(types.DurationType), types.IntType)), - } - - stdFnDecls = make([]*exprpb.Decl, 0, len(stdFunctions)) - for _, fn := range stdFunctions { - if fn.IsDeclarationDisabled() { - continue - } - ed, err := decls.FunctionDeclToExprDecl(fn) - if err != nil { - panic(err) - } - stdFnDecls = append(stdFnDecls, ed) - } -} - -// Functions returns the set of standard library function declarations and definitions for CEL. -func Functions() []*decls.FunctionDecl { - return stdFunctions -} - -// FunctionExprDecls returns the legacy style protobuf-typed declarations for all functions and overloads -// in the CEL standard environment. -// -// Deprecated: use Functions -func FunctionExprDecls() []*exprpb.Decl { - return stdFnDecls -} - -// Types returns the set of standard library types for CEL. -func Types() []*decls.VariableDecl { - return stdTypes -} - -// TypeExprDecls returns the legacy style protobuf-typed declarations for all types in the CEL -// standard environment. -// -// Deprecated: use Types -func TypeExprDecls() []*exprpb.Decl { - return stdTypeDecls -} - -func notStrictlyFalse(value ref.Val) ref.Val { - if types.IsBool(value) { - return value - } - return types.True -} - -func inAggregate(lhs ref.Val, rhs ref.Val) ref.Val { - if rhs.Type().HasTrait(traits.ContainerType) { - return rhs.(traits.Container).Contains(lhs) - } - return types.ValOrErr(rhs, "no such overload") -} - -func function(name string, opts ...decls.FunctionOpt) *decls.FunctionDecl { - fn, err := decls.NewFunction(name, opts...) - if err != nil { - panic(err) - } - return fn -} - -func argTypes(args ...*types.Type) []*types.Type { - return args -} - -func noBinaryOverrides(rhs, lhs ref.Val) ref.Val { - return types.NoSuchOverloadErr() -} - -func noFunctionOverrides(args ...ref.Val) ref.Val { - return types.NoSuchOverloadErr() -} - -func identity(val ref.Val) ref.Val { - return val -} - -func convertToType(t ref.Type) functions.UnaryOp { - return func(val ref.Val) ref.Val { - return val.ConvertToType(t) - } -} diff --git a/vendor/github.com/google/cel-go/common/types/BUILD.bazel b/vendor/github.com/google/cel-go/common/types/BUILD.bazel deleted file mode 100644 index b5e44ffbf..000000000 --- a/vendor/github.com/google/cel-go/common/types/BUILD.bazel +++ /dev/null @@ -1,90 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -package( - default_visibility = ["//visibility:public"], - licenses = ["notice"], # Apache 2.0 -) - -go_library( - name = "go_default_library", - srcs = [ - "any_value.go", - "bool.go", - "bytes.go", - "compare.go", - "double.go", - "duration.go", - "err.go", - "int.go", - "iterator.go", - "json_value.go", - "list.go", - "map.go", - "null.go", - "object.go", - "optional.go", - "overflow.go", - "provider.go", - "string.go", - "timestamp.go", - "types.go", - "uint.go", - "unknown.go", - "util.go", - ], - importpath = "github.com/google/cel-go/common/types", - deps = [ - "//checker/decls:go_default_library", - "//common/overloads:go_default_library", - "//common/types/pb:go_default_library", - "//common/types/ref:go_default_library", - "//common/types/traits:go_default_library", - "@com_github_stoewer_go_strcase//:go_default_library", - "@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library", - "@org_golang_google_protobuf//encoding/protojson:go_default_library", - "@org_golang_google_protobuf//proto:go_default_library", - "@org_golang_google_protobuf//reflect/protoreflect:go_default_library", - "@org_golang_google_protobuf//types/known/anypb:go_default_library", - "@org_golang_google_protobuf//types/known/durationpb:go_default_library", - "@org_golang_google_protobuf//types/known/structpb:go_default_library", - "@org_golang_google_protobuf//types/known/timestamppb:go_default_library", - "@org_golang_google_protobuf//types/known/wrapperspb:go_default_library", - ], -) - -go_test( - name = "go_default_test", - size = "small", - srcs = [ - "bool_test.go", - "bytes_test.go", - "double_test.go", - "duration_test.go", - "int_test.go", - "json_list_test.go", - "json_struct_test.go", - "list_test.go", - "map_test.go", - "null_test.go", - "object_test.go", - "optional_test.go", - "provider_test.go", - "string_test.go", - "timestamp_test.go", - "types_test.go", - "uint_test.go", - "unknown_test.go", - "util_test.go", - ], - embed = [":go_default_library"], - deps = [ - "//common/types/ref:go_default_library", - "//test:go_default_library", - "//test/proto3pb:test_all_types_go_proto", - "@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library", - "@org_golang_google_protobuf//encoding/protojson:go_default_library", - "@org_golang_google_protobuf//types/known/anypb:go_default_library", - "@org_golang_google_protobuf//types/known/durationpb:go_default_library", - "@org_golang_google_protobuf//types/known/timestamppb:go_default_library", - ], -) diff --git a/vendor/github.com/google/cel-go/common/types/any_value.go b/vendor/github.com/google/cel-go/common/types/any_value.go deleted file mode 100644 index cda0f13ac..000000000 --- a/vendor/github.com/google/cel-go/common/types/any_value.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "reflect" - - anypb "google.golang.org/protobuf/types/known/anypb" -) - -// anyValueType constant representing the reflected type of google.protobuf.Any. -var anyValueType = reflect.TypeOf(&anypb.Any{}) diff --git a/vendor/github.com/google/cel-go/common/types/bool.go b/vendor/github.com/google/cel-go/common/types/bool.go deleted file mode 100644 index 565734f3f..000000000 --- a/vendor/github.com/google/cel-go/common/types/bool.go +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - "reflect" - "strconv" - - "github.com/google/cel-go/common/types/ref" - - anypb "google.golang.org/protobuf/types/known/anypb" - structpb "google.golang.org/protobuf/types/known/structpb" - wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" -) - -// Bool type that implements ref.Val and supports comparison and negation. -type Bool bool - -var ( - // boolWrapperType golang reflected type for protobuf bool wrapper type. - boolWrapperType = reflect.TypeOf(&wrapperspb.BoolValue{}) -) - -// Boolean constants -const ( - False = Bool(false) - True = Bool(true) -) - -// Compare implements the traits.Comparer interface method. -func (b Bool) Compare(other ref.Val) ref.Val { - otherBool, ok := other.(Bool) - if !ok { - return ValOrErr(other, "no such overload") - } - if b == otherBool { - return IntZero - } - if !b && otherBool { - return IntNegOne - } - return IntOne -} - -// ConvertToNative implements the ref.Val interface method. -func (b Bool) ConvertToNative(typeDesc reflect.Type) (any, error) { - switch typeDesc.Kind() { - case reflect.Bool: - return reflect.ValueOf(b).Convert(typeDesc).Interface(), nil - case reflect.Ptr: - switch typeDesc { - case anyValueType: - // Primitives must be wrapped to a wrapperspb.BoolValue before being packed into an Any. - return anypb.New(wrapperspb.Bool(bool(b))) - case boolWrapperType: - // Convert the bool to a wrapperspb.BoolValue. - return wrapperspb.Bool(bool(b)), nil - case jsonValueType: - // Return the bool as a new structpb.Value. - return structpb.NewBoolValue(bool(b)), nil - default: - if typeDesc.Elem().Kind() == reflect.Bool { - p := bool(b) - return &p, nil - } - } - case reflect.Interface: - bv := b.Value() - if reflect.TypeOf(bv).Implements(typeDesc) { - return bv, nil - } - if reflect.TypeOf(b).Implements(typeDesc) { - return b, nil - } - } - return nil, fmt.Errorf("type conversion error from bool to '%v'", typeDesc) -} - -// ConvertToType implements the ref.Val interface method. -func (b Bool) ConvertToType(typeVal ref.Type) ref.Val { - switch typeVal { - case StringType: - return String(strconv.FormatBool(bool(b))) - case BoolType: - return b - case TypeType: - return BoolType - } - return NewErr("type conversion error from '%v' to '%v'", BoolType, typeVal) -} - -// Equal implements the ref.Val interface method. -func (b Bool) Equal(other ref.Val) ref.Val { - otherBool, ok := other.(Bool) - return Bool(ok && b == otherBool) -} - -// IsZeroValue returns true if the boolean value is false. -func (b Bool) IsZeroValue() bool { - return b == False -} - -// Negate implements the traits.Negater interface method. -func (b Bool) Negate() ref.Val { - return !b -} - -// Type implements the ref.Val interface method. -func (b Bool) Type() ref.Type { - return BoolType -} - -// Value implements the ref.Val interface method. -func (b Bool) Value() any { - return bool(b) -} - -// IsBool returns whether the input ref.Val or ref.Type is equal to BoolType. -func IsBool(elem ref.Val) bool { - switch v := elem.(type) { - case Bool: - return true - case ref.Val: - return v.Type() == BoolType - default: - return false - } -} diff --git a/vendor/github.com/google/cel-go/common/types/bytes.go b/vendor/github.com/google/cel-go/common/types/bytes.go deleted file mode 100644 index 5838755f8..000000000 --- a/vendor/github.com/google/cel-go/common/types/bytes.go +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "bytes" - "encoding/base64" - "fmt" - "reflect" - "unicode/utf8" - - "github.com/google/cel-go/common/types/ref" - - anypb "google.golang.org/protobuf/types/known/anypb" - structpb "google.golang.org/protobuf/types/known/structpb" - wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" -) - -// Bytes type that implements ref.Val and supports add, compare, and size -// operations. -type Bytes []byte - -var ( - // byteWrapperType golang reflected type for protobuf bytes wrapper type. - byteWrapperType = reflect.TypeOf(&wrapperspb.BytesValue{}) -) - -// Add implements traits.Adder interface method by concatenating byte sequences. -func (b Bytes) Add(other ref.Val) ref.Val { - otherBytes, ok := other.(Bytes) - if !ok { - return ValOrErr(other, "no such overload") - } - return append(b, otherBytes...) -} - -// Compare implements traits.Comparer interface method by lexicographic ordering. -func (b Bytes) Compare(other ref.Val) ref.Val { - otherBytes, ok := other.(Bytes) - if !ok { - return ValOrErr(other, "no such overload") - } - return Int(bytes.Compare(b, otherBytes)) -} - -// ConvertToNative implements the ref.Val interface method. -func (b Bytes) ConvertToNative(typeDesc reflect.Type) (any, error) { - switch typeDesc.Kind() { - case reflect.Array, reflect.Slice: - return reflect.ValueOf(b).Convert(typeDesc).Interface(), nil - case reflect.Ptr: - switch typeDesc { - case anyValueType: - // Primitives must be wrapped before being set on an Any field. - return anypb.New(wrapperspb.Bytes([]byte(b))) - case byteWrapperType: - // Convert the bytes to a wrapperspb.BytesValue. - return wrapperspb.Bytes([]byte(b)), nil - case jsonValueType: - // CEL follows the proto3 to JSON conversion by encoding bytes to a string via base64. - // The encoding below matches the golang 'encoding/json' behavior during marshaling, - // which uses base64.StdEncoding. - str := base64.StdEncoding.EncodeToString([]byte(b)) - return structpb.NewStringValue(str), nil - } - case reflect.Interface: - bv := b.Value() - if reflect.TypeOf(bv).Implements(typeDesc) { - return bv, nil - } - if reflect.TypeOf(b).Implements(typeDesc) { - return b, nil - } - } - return nil, fmt.Errorf("type conversion error from Bytes to '%v'", typeDesc) -} - -// ConvertToType implements the ref.Val interface method. -func (b Bytes) ConvertToType(typeVal ref.Type) ref.Val { - switch typeVal { - case StringType: - if !utf8.Valid(b) { - return NewErr("invalid UTF-8 in bytes, cannot convert to string") - } - return String(b) - case BytesType: - return b - case TypeType: - return BytesType - } - return NewErr("type conversion error from '%s' to '%s'", BytesType, typeVal) -} - -// Equal implements the ref.Val interface method. -func (b Bytes) Equal(other ref.Val) ref.Val { - otherBytes, ok := other.(Bytes) - return Bool(ok && bytes.Equal(b, otherBytes)) -} - -// IsZeroValue returns true if the byte array is empty. -func (b Bytes) IsZeroValue() bool { - return len(b) == 0 -} - -// Size implements the traits.Sizer interface method. -func (b Bytes) Size() ref.Val { - return Int(len(b)) -} - -// Type implements the ref.Val interface method. -func (b Bytes) Type() ref.Type { - return BytesType -} - -// Value implements the ref.Val interface method. -func (b Bytes) Value() any { - return []byte(b) -} diff --git a/vendor/github.com/google/cel-go/common/types/compare.go b/vendor/github.com/google/cel-go/common/types/compare.go deleted file mode 100644 index e19682618..000000000 --- a/vendor/github.com/google/cel-go/common/types/compare.go +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "math" - - "github.com/google/cel-go/common/types/ref" -) - -func compareDoubleInt(d Double, i Int) Int { - if d < math.MinInt64 { - return IntNegOne - } - if d > math.MaxInt64 { - return IntOne - } - return compareDouble(d, Double(i)) -} - -func compareIntDouble(i Int, d Double) Int { - return -compareDoubleInt(d, i) -} - -func compareDoubleUint(d Double, u Uint) Int { - if d < 0 { - return IntNegOne - } - if d > math.MaxUint64 { - return IntOne - } - return compareDouble(d, Double(u)) -} - -func compareUintDouble(u Uint, d Double) Int { - return -compareDoubleUint(d, u) -} - -func compareIntUint(i Int, u Uint) Int { - if i < 0 || u > math.MaxInt64 { - return IntNegOne - } - cmp := i - Int(u) - if cmp < 0 { - return IntNegOne - } - if cmp > 0 { - return IntOne - } - return IntZero -} - -func compareUintInt(u Uint, i Int) Int { - return -compareIntUint(i, u) -} - -func compareDouble(a, b Double) Int { - if a < b { - return IntNegOne - } - if a > b { - return IntOne - } - return IntZero -} - -func compareInt(a, b Int) ref.Val { - if a < b { - return IntNegOne - } - if a > b { - return IntOne - } - return IntZero -} - -func compareUint(a, b Uint) ref.Val { - if a < b { - return IntNegOne - } - if a > b { - return IntOne - } - return IntZero -} diff --git a/vendor/github.com/google/cel-go/common/types/doc.go b/vendor/github.com/google/cel-go/common/types/doc.go deleted file mode 100644 index 5f641d704..000000000 --- a/vendor/github.com/google/cel-go/common/types/doc.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package types contains the types, traits, and utilities common to all -// components of expression handling. -package types diff --git a/vendor/github.com/google/cel-go/common/types/double.go b/vendor/github.com/google/cel-go/common/types/double.go deleted file mode 100644 index 027e78978..000000000 --- a/vendor/github.com/google/cel-go/common/types/double.go +++ /dev/null @@ -1,211 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - "math" - "reflect" - - "github.com/google/cel-go/common/types/ref" - - anypb "google.golang.org/protobuf/types/known/anypb" - structpb "google.golang.org/protobuf/types/known/structpb" - wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" -) - -// Double type that implements ref.Val, comparison, and mathematical -// operations. -type Double float64 - -var ( - // doubleWrapperType reflected type for protobuf double wrapper type. - doubleWrapperType = reflect.TypeOf(&wrapperspb.DoubleValue{}) - - // floatWrapperType reflected type for protobuf float wrapper type. - floatWrapperType = reflect.TypeOf(&wrapperspb.FloatValue{}) -) - -// Add implements traits.Adder.Add. -func (d Double) Add(other ref.Val) ref.Val { - otherDouble, ok := other.(Double) - if !ok { - return MaybeNoSuchOverloadErr(other) - } - return d + otherDouble -} - -// Compare implements traits.Comparer.Compare. -func (d Double) Compare(other ref.Val) ref.Val { - if math.IsNaN(float64(d)) { - return NewErr("NaN values cannot be ordered") - } - switch ov := other.(type) { - case Double: - if math.IsNaN(float64(ov)) { - return NewErr("NaN values cannot be ordered") - } - return compareDouble(d, ov) - case Int: - return compareDoubleInt(d, ov) - case Uint: - return compareDoubleUint(d, ov) - default: - return MaybeNoSuchOverloadErr(other) - } -} - -// ConvertToNative implements ref.Val.ConvertToNative. -func (d Double) ConvertToNative(typeDesc reflect.Type) (any, error) { - switch typeDesc.Kind() { - case reflect.Float32: - v := float32(d) - return reflect.ValueOf(v).Convert(typeDesc).Interface(), nil - case reflect.Float64: - v := float64(d) - return reflect.ValueOf(v).Convert(typeDesc).Interface(), nil - case reflect.Ptr: - switch typeDesc { - case anyValueType: - // Primitives must be wrapped before being set on an Any field. - return anypb.New(wrapperspb.Double(float64(d))) - case doubleWrapperType: - // Convert to a wrapperspb.DoubleValue - return wrapperspb.Double(float64(d)), nil - case floatWrapperType: - // Convert to a wrapperspb.FloatValue (with truncation). - return wrapperspb.Float(float32(d)), nil - case jsonValueType: - // Note, there are special cases for proto3 to json conversion that - // expect the floating point value to be converted to a NaN, - // Infinity, or -Infinity string values, but the jsonpb string - // marshaling of the protobuf.Value will handle this conversion. - return structpb.NewNumberValue(float64(d)), nil - } - switch typeDesc.Elem().Kind() { - case reflect.Float32: - v := float32(d) - p := reflect.New(typeDesc.Elem()) - p.Elem().Set(reflect.ValueOf(v).Convert(typeDesc.Elem())) - return p.Interface(), nil - case reflect.Float64: - v := float64(d) - p := reflect.New(typeDesc.Elem()) - p.Elem().Set(reflect.ValueOf(v).Convert(typeDesc.Elem())) - return p.Interface(), nil - } - case reflect.Interface: - dv := d.Value() - if reflect.TypeOf(dv).Implements(typeDesc) { - return dv, nil - } - if reflect.TypeOf(d).Implements(typeDesc) { - return d, nil - } - } - return nil, fmt.Errorf("type conversion error from Double to '%v'", typeDesc) -} - -// ConvertToType implements ref.Val.ConvertToType. -func (d Double) ConvertToType(typeVal ref.Type) ref.Val { - switch typeVal { - case IntType: - i, err := doubleToInt64Checked(float64(d)) - if err != nil { - return WrapErr(err) - } - return Int(i) - case UintType: - i, err := doubleToUint64Checked(float64(d)) - if err != nil { - return WrapErr(err) - } - return Uint(i) - case DoubleType: - return d - case StringType: - return String(fmt.Sprintf("%g", float64(d))) - case TypeType: - return DoubleType - } - return NewErr("type conversion error from '%s' to '%s'", DoubleType, typeVal) -} - -// Divide implements traits.Divider.Divide. -func (d Double) Divide(other ref.Val) ref.Val { - otherDouble, ok := other.(Double) - if !ok { - return MaybeNoSuchOverloadErr(other) - } - return d / otherDouble -} - -// Equal implements ref.Val.Equal. -func (d Double) Equal(other ref.Val) ref.Val { - if math.IsNaN(float64(d)) { - return False - } - switch ov := other.(type) { - case Double: - if math.IsNaN(float64(ov)) { - return False - } - return Bool(d == ov) - case Int: - return Bool(compareDoubleInt(d, ov) == 0) - case Uint: - return Bool(compareDoubleUint(d, ov) == 0) - default: - return False - } -} - -// IsZeroValue returns true if double value is 0.0 -func (d Double) IsZeroValue() bool { - return float64(d) == 0.0 -} - -// Multiply implements traits.Multiplier.Multiply. -func (d Double) Multiply(other ref.Val) ref.Val { - otherDouble, ok := other.(Double) - if !ok { - return MaybeNoSuchOverloadErr(other) - } - return d * otherDouble -} - -// Negate implements traits.Negater.Negate. -func (d Double) Negate() ref.Val { - return -d -} - -// Subtract implements traits.Subtractor.Subtract. -func (d Double) Subtract(subtrahend ref.Val) ref.Val { - subtraDouble, ok := subtrahend.(Double) - if !ok { - return MaybeNoSuchOverloadErr(subtrahend) - } - return d - subtraDouble -} - -// Type implements ref.Val.Type. -func (d Double) Type() ref.Type { - return DoubleType -} - -// Value implements ref.Val.Value. -func (d Double) Value() any { - return float64(d) -} diff --git a/vendor/github.com/google/cel-go/common/types/duration.go b/vendor/github.com/google/cel-go/common/types/duration.go deleted file mode 100644 index 596e56d6b..000000000 --- a/vendor/github.com/google/cel-go/common/types/duration.go +++ /dev/null @@ -1,222 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - "reflect" - "strconv" - "time" - - "github.com/google/cel-go/common/overloads" - "github.com/google/cel-go/common/types/ref" - - anypb "google.golang.org/protobuf/types/known/anypb" - dpb "google.golang.org/protobuf/types/known/durationpb" - structpb "google.golang.org/protobuf/types/known/structpb" -) - -// Duration type that implements ref.Val and supports add, compare, negate, -// and subtract operators. This type is also a receiver which means it can -// participate in dispatch to receiver functions. -type Duration struct { - time.Duration -} - -func durationOf(d time.Duration) Duration { - return Duration{Duration: d} -} - -var ( - durationValueType = reflect.TypeOf(&dpb.Duration{}) - - durationZeroArgOverloads = map[string]func(ref.Val) ref.Val{ - overloads.TimeGetHours: DurationGetHours, - overloads.TimeGetMinutes: DurationGetMinutes, - overloads.TimeGetSeconds: DurationGetSeconds, - overloads.TimeGetMilliseconds: DurationGetMilliseconds, - } -) - -// Add implements traits.Adder.Add. -func (d Duration) Add(other ref.Val) ref.Val { - switch other.Type() { - case DurationType: - dur2 := other.(Duration) - val, err := addDurationChecked(d.Duration, dur2.Duration) - if err != nil { - return WrapErr(err) - } - return durationOf(val) - case TimestampType: - ts := other.(Timestamp).Time - val, err := addTimeDurationChecked(ts, d.Duration) - if err != nil { - return WrapErr(err) - } - return timestampOf(val) - } - return MaybeNoSuchOverloadErr(other) -} - -// Compare implements traits.Comparer.Compare. -func (d Duration) Compare(other ref.Val) ref.Val { - otherDur, ok := other.(Duration) - if !ok { - return MaybeNoSuchOverloadErr(other) - } - d1 := d.Duration - d2 := otherDur.Duration - switch { - case d1 < d2: - return IntNegOne - case d1 > d2: - return IntOne - default: - return IntZero - } -} - -// ConvertToNative implements ref.Val.ConvertToNative. -func (d Duration) ConvertToNative(typeDesc reflect.Type) (any, error) { - // If the duration is already assignable to the desired type return it. - if reflect.TypeOf(d.Duration).AssignableTo(typeDesc) { - return d.Duration, nil - } - if reflect.TypeOf(d).AssignableTo(typeDesc) { - return d, nil - } - switch typeDesc { - case anyValueType: - // Pack the duration as a dpb.Duration into an Any value. - return anypb.New(dpb.New(d.Duration)) - case durationValueType: - // Unwrap the CEL value to its underlying proto value. - return dpb.New(d.Duration), nil - case jsonValueType: - // CEL follows the proto3 to JSON conversion. - // Note, using jsonpb would wrap the result in extra double quotes. - v := d.ConvertToType(StringType) - if IsError(v) { - return nil, v.(*Err) - } - return structpb.NewStringValue(string(v.(String))), nil - } - return nil, fmt.Errorf("type conversion error from 'Duration' to '%v'", typeDesc) -} - -// ConvertToType implements ref.Val.ConvertToType. -func (d Duration) ConvertToType(typeVal ref.Type) ref.Val { - switch typeVal { - case StringType: - return String(strconv.FormatFloat(d.Seconds(), 'f', -1, 64) + "s") - case IntType: - return Int(d.Duration) - case DurationType: - return d - case TypeType: - return DurationType - } - return NewErr("type conversion error from '%s' to '%s'", DurationType, typeVal) -} - -// Equal implements ref.Val.Equal. -func (d Duration) Equal(other ref.Val) ref.Val { - otherDur, ok := other.(Duration) - return Bool(ok && d.Duration == otherDur.Duration) -} - -// IsZeroValue returns true if the duration value is zero -func (d Duration) IsZeroValue() bool { - return d.Duration == 0 -} - -// Negate implements traits.Negater.Negate. -func (d Duration) Negate() ref.Val { - val, err := negateDurationChecked(d.Duration) - if err != nil { - return WrapErr(err) - } - return durationOf(val) -} - -// Receive implements traits.Receiver.Receive. -func (d Duration) Receive(function string, overload string, args []ref.Val) ref.Val { - if len(args) == 0 { - if f, found := durationZeroArgOverloads[function]; found { - return f(d) - } - } - return NoSuchOverloadErr() -} - -// Subtract implements traits.Subtractor.Subtract. -func (d Duration) Subtract(subtrahend ref.Val) ref.Val { - subtraDur, ok := subtrahend.(Duration) - if !ok { - return MaybeNoSuchOverloadErr(subtrahend) - } - val, err := subtractDurationChecked(d.Duration, subtraDur.Duration) - if err != nil { - return WrapErr(err) - } - return durationOf(val) -} - -// Type implements ref.Val.Type. -func (d Duration) Type() ref.Type { - return DurationType -} - -// Value implements ref.Val.Value. -func (d Duration) Value() any { - return d.Duration -} - -// DurationGetHours returns the duration in hours. -func DurationGetHours(val ref.Val) ref.Val { - dur, ok := val.(Duration) - if !ok { - return MaybeNoSuchOverloadErr(val) - } - return Int(dur.Hours()) -} - -// DurationGetMinutes returns duration in minutes. -func DurationGetMinutes(val ref.Val) ref.Val { - dur, ok := val.(Duration) - if !ok { - return MaybeNoSuchOverloadErr(val) - } - return Int(dur.Minutes()) -} - -// DurationGetSeconds returns duration in seconds. -func DurationGetSeconds(val ref.Val) ref.Val { - dur, ok := val.(Duration) - if !ok { - return MaybeNoSuchOverloadErr(val) - } - return Int(dur.Seconds()) -} - -// DurationGetMilliseconds returns duration in milliseconds. -func DurationGetMilliseconds(val ref.Val) ref.Val { - dur, ok := val.(Duration) - if !ok { - return MaybeNoSuchOverloadErr(val) - } - return Int(dur.Milliseconds()) -} diff --git a/vendor/github.com/google/cel-go/common/types/err.go b/vendor/github.com/google/cel-go/common/types/err.go deleted file mode 100644 index aa8f94b4f..000000000 --- a/vendor/github.com/google/cel-go/common/types/err.go +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "errors" - "fmt" - "reflect" - - "github.com/google/cel-go/common/types/ref" -) - -// Error interface which allows types types.Err values to be treated as error values. -type Error interface { - error - ref.Val -} - -// Err type which extends the built-in go error and implements ref.Val. -type Err struct { - error -} - -var ( - // ErrType singleton. - ErrType = NewOpaqueType("error") - - // errDivideByZero is an error indicating a division by zero of an integer value. - errDivideByZero = errors.New("division by zero") - // errModulusByZero is an error indicating a modulus by zero of an integer value. - errModulusByZero = errors.New("modulus by zero") - // errIntOverflow is an error representing integer overflow. - errIntOverflow = errors.New("integer overflow") - // errUintOverflow is an error representing unsigned integer overflow. - errUintOverflow = errors.New("unsigned integer overflow") - // errDurationOverflow is an error representing duration overflow. - errDurationOverflow = errors.New("duration overflow") - // errTimestampOverflow is an error representing timestamp overflow. - errTimestampOverflow = errors.New("timestamp overflow") - celErrTimestampOverflow = &Err{error: errTimestampOverflow} - - // celErrNoSuchOverload indicates that the call arguments did not match a supported method signature. - celErrNoSuchOverload = NewErr("no such overload") -) - -// NewErr creates a new Err described by the format string and args. -// TODO: Audit the use of this function and standardize the error messages and codes. -func NewErr(format string, args ...any) ref.Val { - return &Err{fmt.Errorf(format, args...)} -} - -// NoSuchOverloadErr returns a new types.Err instance with a no such overload message. -func NoSuchOverloadErr() ref.Val { - return celErrNoSuchOverload -} - -// UnsupportedRefValConversionErr returns a types.NewErr instance with a no such conversion -// message that indicates that the native value could not be converted to a CEL ref.Val. -func UnsupportedRefValConversionErr(val any) ref.Val { - return NewErr("unsupported conversion to ref.Val: (%T)%v", val, val) -} - -// MaybeNoSuchOverloadErr returns the error or unknown if the input ref.Val is one of these types, -// else a new no such overload error. -func MaybeNoSuchOverloadErr(val ref.Val) ref.Val { - return ValOrErr(val, "no such overload") -} - -// ValOrErr either returns the existing error or creates a new one. -// TODO: Audit the use of this function and standardize the error messages and codes. -func ValOrErr(val ref.Val, format string, args ...any) ref.Val { - if val == nil || !IsUnknownOrError(val) { - return NewErr(format, args...) - } - return val -} - -// WrapErr wraps an existing Go error value into a CEL Err value. -func WrapErr(err error) ref.Val { - return &Err{error: err} -} - -// ConvertToNative implements ref.Val.ConvertToNative. -func (e *Err) ConvertToNative(typeDesc reflect.Type) (any, error) { - return nil, e.error -} - -// ConvertToType implements ref.Val.ConvertToType. -func (e *Err) ConvertToType(typeVal ref.Type) ref.Val { - // Errors are not convertible to other representations. - return e -} - -// Equal implements ref.Val.Equal. -func (e *Err) Equal(other ref.Val) ref.Val { - // An error cannot be equal to any other value, so it returns itself. - return e -} - -// String implements fmt.Stringer. -func (e *Err) String() string { - return e.error.Error() -} - -// Type implements ref.Val.Type. -func (e *Err) Type() ref.Type { - return ErrType -} - -// Value implements ref.Val.Value. -func (e *Err) Value() any { - return e.error -} - -// Is implements errors.Is. -func (e *Err) Is(target error) bool { - return e.error.Error() == target.Error() -} - -// Unwrap implements errors.Unwrap. -func (e *Err) Unwrap() error { - return e.error -} - -// IsError returns whether the input element ref.Type or ref.Val is equal to -// the ErrType singleton. -func IsError(val ref.Val) bool { - switch val.(type) { - case *Err: - return true - default: - return false - } -} diff --git a/vendor/github.com/google/cel-go/common/types/int.go b/vendor/github.com/google/cel-go/common/types/int.go deleted file mode 100644 index 940772aed..000000000 --- a/vendor/github.com/google/cel-go/common/types/int.go +++ /dev/null @@ -1,291 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - "math" - "reflect" - "strconv" - "time" - - "github.com/google/cel-go/common/types/ref" - - anypb "google.golang.org/protobuf/types/known/anypb" - structpb "google.golang.org/protobuf/types/known/structpb" - wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" -) - -// Int type that implements ref.Val as well as comparison and math operators. -type Int int64 - -// Int constants used for comparison results. -const ( - // IntZero is the zero-value for Int - IntZero = Int(0) - IntOne = Int(1) - IntNegOne = Int(-1) -) - -var ( - // int32WrapperType reflected type for protobuf int32 wrapper type. - int32WrapperType = reflect.TypeOf(&wrapperspb.Int32Value{}) - - // int64WrapperType reflected type for protobuf int64 wrapper type. - int64WrapperType = reflect.TypeOf(&wrapperspb.Int64Value{}) -) - -// Add implements traits.Adder.Add. -func (i Int) Add(other ref.Val) ref.Val { - otherInt, ok := other.(Int) - if !ok { - return MaybeNoSuchOverloadErr(other) - } - val, err := addInt64Checked(int64(i), int64(otherInt)) - if err != nil { - return WrapErr(err) - } - return Int(val) -} - -// Compare implements traits.Comparer.Compare. -func (i Int) Compare(other ref.Val) ref.Val { - switch ov := other.(type) { - case Double: - if math.IsNaN(float64(ov)) { - return NewErr("NaN values cannot be ordered") - } - return compareIntDouble(i, ov) - case Int: - return compareInt(i, ov) - case Uint: - return compareIntUint(i, ov) - default: - return MaybeNoSuchOverloadErr(other) - } -} - -// ConvertToNative implements ref.Val.ConvertToNative. -func (i Int) ConvertToNative(typeDesc reflect.Type) (any, error) { - switch typeDesc.Kind() { - case reflect.Int, reflect.Int32: - // Enums are also mapped as int32 derivations. - // Note, the code doesn't convert to the enum value directly since this is not known, but - // the net effect with respect to proto-assignment is handled correctly by the reflection - // Convert method. - v, err := int64ToInt32Checked(int64(i)) - if err != nil { - return nil, err - } - return reflect.ValueOf(v).Convert(typeDesc).Interface(), nil - case reflect.Int64: - return reflect.ValueOf(i).Convert(typeDesc).Interface(), nil - case reflect.Ptr: - switch typeDesc { - case anyValueType: - // Primitives must be wrapped before being set on an Any field. - return anypb.New(wrapperspb.Int64(int64(i))) - case int32WrapperType: - // Convert the value to a wrapperspb.Int32Value, error on overflow. - v, err := int64ToInt32Checked(int64(i)) - if err != nil { - return nil, err - } - return wrapperspb.Int32(v), nil - case int64WrapperType: - // Convert the value to a wrapperspb.Int64Value. - return wrapperspb.Int64(int64(i)), nil - case jsonValueType: - // The proto-to-JSON conversion rules would convert all 64-bit integer values to JSON - // decimal strings. Because CEL ints might come from the automatic widening of 32-bit - // values in protos, the JSON type is chosen dynamically based on the value. - // - // - Integers -2^53-1 < n < 2^53-1 are encoded as JSON numbers. - // - Integers outside this range are encoded as JSON strings. - // - // The integer to float range represents the largest interval where such a conversion - // can round-trip accurately. Thus, conversions from a 32-bit source can expect a JSON - // number as with protobuf. Those consuming JSON from a 64-bit source must be able to - // handle either a JSON number or a JSON decimal string. To handle these cases safely - // the string values must be explicitly converted to int() within a CEL expression; - // however, it is best to simply stay within the JSON number range when building JSON - // objects in CEL. - if i.isJSONSafe() { - return structpb.NewNumberValue(float64(i)), nil - } - // Proto3 to JSON conversion requires string-formatted int64 values - // since the conversion to floating point would result in truncation. - return structpb.NewStringValue(strconv.FormatInt(int64(i), 10)), nil - } - switch typeDesc.Elem().Kind() { - case reflect.Int32: - // Convert the value to a wrapperspb.Int32Value, error on overflow. - v, err := int64ToInt32Checked(int64(i)) - if err != nil { - return nil, err - } - p := reflect.New(typeDesc.Elem()) - p.Elem().Set(reflect.ValueOf(v).Convert(typeDesc.Elem())) - return p.Interface(), nil - case reflect.Int64: - v := int64(i) - p := reflect.New(typeDesc.Elem()) - p.Elem().Set(reflect.ValueOf(v).Convert(typeDesc.Elem())) - return p.Interface(), nil - } - case reflect.Interface: - iv := i.Value() - if reflect.TypeOf(iv).Implements(typeDesc) { - return iv, nil - } - if reflect.TypeOf(i).Implements(typeDesc) { - return i, nil - } - } - return nil, fmt.Errorf("unsupported type conversion from 'int' to %v", typeDesc) -} - -// ConvertToType implements ref.Val.ConvertToType. -func (i Int) ConvertToType(typeVal ref.Type) ref.Val { - switch typeVal { - case IntType: - return i - case UintType: - u, err := int64ToUint64Checked(int64(i)) - if err != nil { - return WrapErr(err) - } - return Uint(u) - case DoubleType: - return Double(i) - case StringType: - return String(fmt.Sprintf("%d", int64(i))) - case TimestampType: - // The maximum positive value that can be passed to time.Unix is math.MaxInt64 minus the number - // of seconds between year 1 and year 1970. See comments on unixToInternal. - if int64(i) < minUnixTime || int64(i) > maxUnixTime { - return celErrTimestampOverflow - } - return timestampOf(time.Unix(int64(i), 0).UTC()) - case TypeType: - return IntType - } - return NewErr("type conversion error from '%s' to '%s'", IntType, typeVal) -} - -// Divide implements traits.Divider.Divide. -func (i Int) Divide(other ref.Val) ref.Val { - otherInt, ok := other.(Int) - if !ok { - return MaybeNoSuchOverloadErr(other) - } - val, err := divideInt64Checked(int64(i), int64(otherInt)) - if err != nil { - return WrapErr(err) - } - return Int(val) -} - -// Equal implements ref.Val.Equal. -func (i Int) Equal(other ref.Val) ref.Val { - switch ov := other.(type) { - case Double: - if math.IsNaN(float64(ov)) { - return False - } - return Bool(compareIntDouble(i, ov) == 0) - case Int: - return Bool(i == ov) - case Uint: - return Bool(compareIntUint(i, ov) == 0) - default: - return False - } -} - -// IsZeroValue returns true if integer is equal to 0 -func (i Int) IsZeroValue() bool { - return i == IntZero -} - -// Modulo implements traits.Modder.Modulo. -func (i Int) Modulo(other ref.Val) ref.Val { - otherInt, ok := other.(Int) - if !ok { - return MaybeNoSuchOverloadErr(other) - } - val, err := moduloInt64Checked(int64(i), int64(otherInt)) - if err != nil { - return WrapErr(err) - } - return Int(val) -} - -// Multiply implements traits.Multiplier.Multiply. -func (i Int) Multiply(other ref.Val) ref.Val { - otherInt, ok := other.(Int) - if !ok { - return MaybeNoSuchOverloadErr(other) - } - val, err := multiplyInt64Checked(int64(i), int64(otherInt)) - if err != nil { - return WrapErr(err) - } - return Int(val) -} - -// Negate implements traits.Negater.Negate. -func (i Int) Negate() ref.Val { - val, err := negateInt64Checked(int64(i)) - if err != nil { - return WrapErr(err) - } - return Int(val) -} - -// Subtract implements traits.Subtractor.Subtract. -func (i Int) Subtract(subtrahend ref.Val) ref.Val { - subtraInt, ok := subtrahend.(Int) - if !ok { - return MaybeNoSuchOverloadErr(subtrahend) - } - val, err := subtractInt64Checked(int64(i), int64(subtraInt)) - if err != nil { - return WrapErr(err) - } - return Int(val) -} - -// Type implements ref.Val.Type. -func (i Int) Type() ref.Type { - return IntType -} - -// Value implements ref.Val.Value. -func (i Int) Value() any { - return int64(i) -} - -// isJSONSafe indicates whether the int is safely representable as a floating point value in JSON. -func (i Int) isJSONSafe() bool { - return i >= minIntJSON && i <= maxIntJSON -} - -const ( - // maxIntJSON is defined as the Number.MAX_SAFE_INTEGER value per EcmaScript 6. - maxIntJSON = 1<<53 - 1 - // minIntJSON is defined as the Number.MIN_SAFE_INTEGER value per EcmaScript 6. - minIntJSON = -maxIntJSON -) diff --git a/vendor/github.com/google/cel-go/common/types/iterator.go b/vendor/github.com/google/cel-go/common/types/iterator.go deleted file mode 100644 index 98e9147b6..000000000 --- a/vendor/github.com/google/cel-go/common/types/iterator.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - "reflect" - - "github.com/google/cel-go/common/types/ref" - "github.com/google/cel-go/common/types/traits" -) - -var ( - // IteratorType singleton. - IteratorType = NewObjectType("iterator", traits.IteratorType) -) - -// baseIterator is the basis for list, map, and object iterators. -// -// An iterator in and of itself should not be a valid value for comparison, but must implement the -// `ref.Val` methods in order to be well-supported within instruction arguments processed by the -// interpreter. -type baseIterator struct{} - -func (*baseIterator) ConvertToNative(typeDesc reflect.Type) (any, error) { - return nil, fmt.Errorf("type conversion on iterators not supported") -} - -func (*baseIterator) ConvertToType(typeVal ref.Type) ref.Val { - return NewErr("no such overload") -} - -func (*baseIterator) Equal(other ref.Val) ref.Val { - return NewErr("no such overload") -} - -func (*baseIterator) Type() ref.Type { - return IteratorType -} - -func (*baseIterator) Value() any { - return nil -} diff --git a/vendor/github.com/google/cel-go/common/types/json_value.go b/vendor/github.com/google/cel-go/common/types/json_value.go deleted file mode 100644 index 13a4efe7a..000000000 --- a/vendor/github.com/google/cel-go/common/types/json_value.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "reflect" - - structpb "google.golang.org/protobuf/types/known/structpb" -) - -// JSON type constants representing the reflected types of protobuf JSON values. -var ( - jsonValueType = reflect.TypeOf(&structpb.Value{}) - jsonListValueType = reflect.TypeOf(&structpb.ListValue{}) - jsonStructType = reflect.TypeOf(&structpb.Struct{}) - jsonNullType = reflect.TypeOf(structpb.NullValue_NULL_VALUE) -) diff --git a/vendor/github.com/google/cel-go/common/types/list.go b/vendor/github.com/google/cel-go/common/types/list.go deleted file mode 100644 index d4932b4a9..000000000 --- a/vendor/github.com/google/cel-go/common/types/list.go +++ /dev/null @@ -1,523 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - "reflect" - "strings" - - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/reflect/protoreflect" - - "github.com/google/cel-go/common/types/ref" - "github.com/google/cel-go/common/types/traits" - - anypb "google.golang.org/protobuf/types/known/anypb" - structpb "google.golang.org/protobuf/types/known/structpb" -) - -// NewDynamicList returns a traits.Lister with heterogenous elements. -// value should be an array of "native" types, i.e. any type that -// NativeToValue() can convert to a ref.Val. -func NewDynamicList(adapter Adapter, value any) traits.Lister { - refValue := reflect.ValueOf(value) - return &baseList{ - Adapter: adapter, - value: value, - size: refValue.Len(), - get: func(i int) any { - return refValue.Index(i).Interface() - }, - } -} - -// NewStringList returns a traits.Lister containing only strings. -func NewStringList(adapter Adapter, elems []string) traits.Lister { - return &baseList{ - Adapter: adapter, - value: elems, - size: len(elems), - get: func(i int) any { return elems[i] }, - } -} - -// NewRefValList returns a traits.Lister with ref.Val elements. -// -// This type specialization is used with list literals within CEL expressions. -func NewRefValList(adapter Adapter, elems []ref.Val) traits.Lister { - return &baseList{ - Adapter: adapter, - value: elems, - size: len(elems), - get: func(i int) any { return elems[i] }, - } -} - -// NewProtoList returns a traits.Lister based on a pb.List instance. -func NewProtoList(adapter Adapter, list protoreflect.List) traits.Lister { - return &baseList{ - Adapter: adapter, - value: list, - size: list.Len(), - get: func(i int) any { return list.Get(i).Interface() }, - } -} - -// NewJSONList returns a traits.Lister based on structpb.ListValue instance. -func NewJSONList(adapter Adapter, l *structpb.ListValue) traits.Lister { - vals := l.GetValues() - return &baseList{ - Adapter: adapter, - value: l, - size: len(vals), - get: func(i int) any { return vals[i] }, - } -} - -// NewMutableList creates a new mutable list whose internal state can be modified. -func NewMutableList(adapter Adapter) traits.MutableLister { - var mutableValues []ref.Val - l := &mutableList{ - baseList: &baseList{ - Adapter: adapter, - value: mutableValues, - size: 0, - }, - mutableValues: mutableValues, - } - l.get = func(i int) any { - return l.mutableValues[i] - } - return l -} - -// baseList points to a list containing elements of any type. -// The `value` is an array of native values, and refValue is its reflection object. -// The `Adapter` enables native type to CEL type conversions. -type baseList struct { - Adapter - value any - - // size indicates the number of elements within the list. - // Since objects are immutable the size of a list is static. - size int - - // get returns a value at the specified integer index. - // The index is guaranteed to be checked against the list index range. - get func(int) any -} - -// Add implements the traits.Adder interface method. -func (l *baseList) Add(other ref.Val) ref.Val { - otherList, ok := other.(traits.Lister) - if !ok { - return MaybeNoSuchOverloadErr(other) - } - if l.Size() == IntZero { - return other - } - if otherList.Size() == IntZero { - return l - } - return &concatList{ - Adapter: l.Adapter, - prevList: l, - nextList: otherList} -} - -// Contains implements the traits.Container interface method. -func (l *baseList) Contains(elem ref.Val) ref.Val { - for i := 0; i < l.size; i++ { - val := l.NativeToValue(l.get(i)) - cmp := elem.Equal(val) - b, ok := cmp.(Bool) - if ok && b == True { - return True - } - } - return False -} - -// ConvertToNative implements the ref.Val interface method. -func (l *baseList) ConvertToNative(typeDesc reflect.Type) (any, error) { - // If the underlying list value is assignable to the reflected type return it. - if reflect.TypeOf(l.value).AssignableTo(typeDesc) { - return l.value, nil - } - // If the list wrapper is assignable to the desired type return it. - if reflect.TypeOf(l).AssignableTo(typeDesc) { - return l, nil - } - // Attempt to convert the list to a set of well known protobuf types. - switch typeDesc { - case anyValueType: - json, err := l.ConvertToNative(jsonListValueType) - if err != nil { - return nil, err - } - return anypb.New(json.(proto.Message)) - case jsonValueType, jsonListValueType: - jsonValues, err := - l.ConvertToNative(reflect.TypeOf([]*structpb.Value{})) - if err != nil { - return nil, err - } - jsonList := &structpb.ListValue{Values: jsonValues.([]*structpb.Value)} - if typeDesc == jsonListValueType { - return jsonList, nil - } - return structpb.NewListValue(jsonList), nil - } - // Non-list conversion. - if typeDesc.Kind() != reflect.Slice && typeDesc.Kind() != reflect.Array { - return nil, fmt.Errorf("type conversion error from list to '%v'", typeDesc) - } - - // List conversion. - // Allow the element ConvertToNative() function to determine whether conversion is possible. - otherElemType := typeDesc.Elem() - elemCount := l.size - nativeList := reflect.MakeSlice(typeDesc, elemCount, elemCount) - for i := 0; i < elemCount; i++ { - elem := l.NativeToValue(l.get(i)) - nativeElemVal, err := elem.ConvertToNative(otherElemType) - if err != nil { - return nil, err - } - nativeList.Index(i).Set(reflect.ValueOf(nativeElemVal)) - } - return nativeList.Interface(), nil -} - -// ConvertToType implements the ref.Val interface method. -func (l *baseList) ConvertToType(typeVal ref.Type) ref.Val { - switch typeVal { - case ListType: - return l - case TypeType: - return ListType - } - return NewErr("type conversion error from '%s' to '%s'", ListType, typeVal) -} - -// Equal implements the ref.Val interface method. -func (l *baseList) Equal(other ref.Val) ref.Val { - otherList, ok := other.(traits.Lister) - if !ok { - return False - } - if l.Size() != otherList.Size() { - return False - } - for i := IntZero; i < l.Size().(Int); i++ { - thisElem := l.Get(i) - otherElem := otherList.Get(i) - elemEq := Equal(thisElem, otherElem) - if elemEq == False { - return False - } - } - return True -} - -// Get implements the traits.Indexer interface method. -func (l *baseList) Get(index ref.Val) ref.Val { - ind, err := IndexOrError(index) - if err != nil { - return ValOrErr(index, err.Error()) - } - if ind < 0 || ind >= l.size { - return NewErr("index '%d' out of range in list size '%d'", ind, l.Size()) - } - return l.NativeToValue(l.get(ind)) -} - -// IsZeroValue returns true if the list is empty. -func (l *baseList) IsZeroValue() bool { - return l.size == 0 -} - -// Iterator implements the traits.Iterable interface method. -func (l *baseList) Iterator() traits.Iterator { - return newListIterator(l) -} - -// Size implements the traits.Sizer interface method. -func (l *baseList) Size() ref.Val { - return Int(l.size) -} - -// Type implements the ref.Val interface method. -func (l *baseList) Type() ref.Type { - return ListType -} - -// Value implements the ref.Val interface method. -func (l *baseList) Value() any { - return l.value -} - -// String converts the list to a human readable string form. -func (l *baseList) String() string { - var sb strings.Builder - sb.WriteString("[") - for i := 0; i < l.size; i++ { - sb.WriteString(fmt.Sprintf("%v", l.get(i))) - if i != l.size-1 { - sb.WriteString(", ") - } - } - sb.WriteString("]") - return sb.String() -} - -// mutableList aggregates values into its internal storage. For use with internal CEL variables only. -type mutableList struct { - *baseList - mutableValues []ref.Val -} - -// Add copies elements from the other list into the internal storage of the mutable list. -// The ref.Val returned by Add is the receiver. -func (l *mutableList) Add(other ref.Val) ref.Val { - switch otherList := other.(type) { - case *mutableList: - l.mutableValues = append(l.mutableValues, otherList.mutableValues...) - l.size += len(otherList.mutableValues) - case traits.Lister: - for i := IntZero; i < otherList.Size().(Int); i++ { - l.size++ - l.mutableValues = append(l.mutableValues, otherList.Get(i)) - } - default: - return MaybeNoSuchOverloadErr(otherList) - } - return l -} - -// ToImmutableList returns an immutable list based on the internal storage of the mutable list. -func (l *mutableList) ToImmutableList() traits.Lister { - // The reference to internal state is guaranteed to be safe as this call is only performed - // when mutations have been completed. - return NewRefValList(l.Adapter, l.mutableValues) -} - -// concatList combines two list implementations together into a view. -// The `Adapter` enables native type to CEL type conversions. -type concatList struct { - Adapter - value any - prevList traits.Lister - nextList traits.Lister -} - -// Add implements the traits.Adder interface method. -func (l *concatList) Add(other ref.Val) ref.Val { - otherList, ok := other.(traits.Lister) - if !ok { - return MaybeNoSuchOverloadErr(other) - } - if l.Size() == IntZero { - return other - } - if otherList.Size() == IntZero { - return l - } - return &concatList{ - Adapter: l.Adapter, - prevList: l, - nextList: otherList} -} - -// Contains implements the traits.Container interface method. -func (l *concatList) Contains(elem ref.Val) ref.Val { - // The concat list relies on the IsErrorOrUnknown checks against the input element to be - // performed by the `prevList` and/or `nextList`. - prev := l.prevList.Contains(elem) - // Short-circuit the return if the elem was found in the prev list. - if prev == True { - return prev - } - // Return if the elem was found in the next list. - next := l.nextList.Contains(elem) - if next == True { - return next - } - // Handle the case where an error or unknown was encountered before checking next. - if IsUnknownOrError(prev) { - return prev - } - // Otherwise, rely on the next value as the representative result. - return next -} - -// ConvertToNative implements the ref.Val interface method. -func (l *concatList) ConvertToNative(typeDesc reflect.Type) (any, error) { - combined := NewDynamicList(l.Adapter, l.Value().([]any)) - return combined.ConvertToNative(typeDesc) -} - -// ConvertToType implements the ref.Val interface method. -func (l *concatList) ConvertToType(typeVal ref.Type) ref.Val { - switch typeVal { - case ListType: - return l - case TypeType: - return ListType - } - return NewErr("type conversion error from '%s' to '%s'", ListType, typeVal) -} - -// Equal implements the ref.Val interface method. -func (l *concatList) Equal(other ref.Val) ref.Val { - otherList, ok := other.(traits.Lister) - if !ok { - return False - } - if l.Size() != otherList.Size() { - return False - } - var maybeErr ref.Val - for i := IntZero; i < l.Size().(Int); i++ { - thisElem := l.Get(i) - otherElem := otherList.Get(i) - elemEq := Equal(thisElem, otherElem) - if elemEq == False { - return False - } - if maybeErr == nil && IsUnknownOrError(elemEq) { - maybeErr = elemEq - } - } - if maybeErr != nil { - return maybeErr - } - return True -} - -// Get implements the traits.Indexer interface method. -func (l *concatList) Get(index ref.Val) ref.Val { - ind, err := IndexOrError(index) - if err != nil { - return ValOrErr(index, err.Error()) - } - i := Int(ind) - if i < l.prevList.Size().(Int) { - return l.prevList.Get(i) - } - offset := i - l.prevList.Size().(Int) - return l.nextList.Get(offset) -} - -// IsZeroValue returns true if the list is empty. -func (l *concatList) IsZeroValue() bool { - return l.Size().(Int) == 0 -} - -// Iterator implements the traits.Iterable interface method. -func (l *concatList) Iterator() traits.Iterator { - return newListIterator(l) -} - -// Size implements the traits.Sizer interface method. -func (l *concatList) Size() ref.Val { - return l.prevList.Size().(Int).Add(l.nextList.Size()) -} - -// String converts the concatenated list to a human-readable string. -func (l *concatList) String() string { - var sb strings.Builder - sb.WriteString("[") - for i := Int(0); i < l.Size().(Int); i++ { - sb.WriteString(fmt.Sprintf("%v", l.Get(i))) - if i != l.Size().(Int)-1 { - sb.WriteString(", ") - } - } - sb.WriteString("]") - return sb.String() -} - -// Type implements the ref.Val interface method. -func (l *concatList) Type() ref.Type { - return ListType -} - -// Value implements the ref.Val interface method. -func (l *concatList) Value() any { - if l.value == nil { - merged := make([]any, l.Size().(Int)) - prevLen := l.prevList.Size().(Int) - for i := Int(0); i < prevLen; i++ { - merged[i] = l.prevList.Get(i).Value() - } - nextLen := l.nextList.Size().(Int) - for j := Int(0); j < nextLen; j++ { - merged[prevLen+j] = l.nextList.Get(j).Value() - } - l.value = merged - } - return l.value -} - -func newListIterator(listValue traits.Lister) traits.Iterator { - return &listIterator{ - listValue: listValue, - len: listValue.Size().(Int), - } -} - -type listIterator struct { - *baseIterator - listValue traits.Lister - cursor Int - len Int -} - -// HasNext implements the traits.Iterator interface method. -func (it *listIterator) HasNext() ref.Val { - return Bool(it.cursor < it.len) -} - -// Next implements the traits.Iterator interface method. -func (it *listIterator) Next() ref.Val { - if it.HasNext() == True { - index := it.cursor - it.cursor++ - return it.listValue.Get(index) - } - return nil -} - -// IndexOrError converts an input index value into either a lossless integer index or an error. -func IndexOrError(index ref.Val) (int, error) { - switch iv := index.(type) { - case Int: - return int(iv), nil - case Double: - if ik, ok := doubleToInt64Lossless(float64(iv)); ok { - return int(ik), nil - } - return -1, fmt.Errorf("unsupported index value %v in list", index) - case Uint: - if ik, ok := uint64ToInt64Lossless(uint64(iv)); ok { - return int(ik), nil - } - return -1, fmt.Errorf("unsupported index value %v in list", index) - default: - return -1, fmt.Errorf("unsupported index type '%s' in list", index.Type()) - } -} diff --git a/vendor/github.com/google/cel-go/common/types/map.go b/vendor/github.com/google/cel-go/common/types/map.go deleted file mode 100644 index 739b7aab0..000000000 --- a/vendor/github.com/google/cel-go/common/types/map.go +++ /dev/null @@ -1,854 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - "reflect" - "strings" - - "github.com/stoewer/go-strcase" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/reflect/protoreflect" - - "github.com/google/cel-go/common/types/pb" - "github.com/google/cel-go/common/types/ref" - "github.com/google/cel-go/common/types/traits" - - anypb "google.golang.org/protobuf/types/known/anypb" - structpb "google.golang.org/protobuf/types/known/structpb" -) - -// NewDynamicMap returns a traits.Mapper value with dynamic key, value pairs. -func NewDynamicMap(adapter Adapter, value any) traits.Mapper { - refValue := reflect.ValueOf(value) - return &baseMap{ - Adapter: adapter, - mapAccessor: newReflectMapAccessor(adapter, refValue), - value: value, - size: refValue.Len(), - } -} - -// NewJSONStruct creates a traits.Mapper implementation backed by a JSON struct that has been -// encoded in protocol buffer form. -// -// The `adapter` argument provides type adaptation capabilities from proto to CEL. -func NewJSONStruct(adapter Adapter, value *structpb.Struct) traits.Mapper { - fields := value.GetFields() - return &baseMap{ - Adapter: adapter, - mapAccessor: newJSONStructAccessor(adapter, fields), - value: value, - size: len(fields), - } -} - -// NewRefValMap returns a specialized traits.Mapper with CEL valued keys and values. -func NewRefValMap(adapter Adapter, value map[ref.Val]ref.Val) traits.Mapper { - return &baseMap{ - Adapter: adapter, - mapAccessor: newRefValMapAccessor(value), - value: value, - size: len(value), - } -} - -// NewStringInterfaceMap returns a specialized traits.Mapper with string keys and interface values. -func NewStringInterfaceMap(adapter Adapter, value map[string]any) traits.Mapper { - return &baseMap{ - Adapter: adapter, - mapAccessor: newStringIfaceMapAccessor(adapter, value), - value: value, - size: len(value), - } -} - -// NewStringStringMap returns a specialized traits.Mapper with string keys and values. -func NewStringStringMap(adapter Adapter, value map[string]string) traits.Mapper { - return &baseMap{ - Adapter: adapter, - mapAccessor: newStringMapAccessor(value), - value: value, - size: len(value), - } -} - -// NewProtoMap returns a specialized traits.Mapper for handling protobuf map values. -func NewProtoMap(adapter Adapter, value *pb.Map) traits.Mapper { - return &protoMap{ - Adapter: adapter, - value: value, - } -} - -// mapAccessor is a private interface for finding values within a map and iterating over the keys. -// This interface implements portions of the API surface area required by the traits.Mapper -// interface. -type mapAccessor interface { - // Find returns a value, if one exists, for the input key. - // - // If the key is not found the function returns (nil, false). - Find(ref.Val) (ref.Val, bool) - - // Iterator returns an Iterator over the map key set. - Iterator() traits.Iterator -} - -// baseMap is a reflection based map implementation designed to handle a variety of map-like types. -// -// Since CEL is side-effect free, the base map represents an immutable object. -type baseMap struct { - // TypeAdapter used to convert keys and values accessed within the map. - Adapter - - // mapAccessor interface implementation used to find and iterate over map keys. - mapAccessor - - // value is the native Go value upon which the map type operators. - value any - - // size is the number of entries in the map. - size int -} - -// Contains implements the traits.Container interface method. -func (m *baseMap) Contains(index ref.Val) ref.Val { - _, found := m.Find(index) - return Bool(found) -} - -// ConvertToNative implements the ref.Val interface method. -func (m *baseMap) ConvertToNative(typeDesc reflect.Type) (any, error) { - // If the map is already assignable to the desired type return it, e.g. interfaces and - // maps with the same key value types. - if reflect.TypeOf(m.value).AssignableTo(typeDesc) { - return m.value, nil - } - if reflect.TypeOf(m).AssignableTo(typeDesc) { - return m, nil - } - switch typeDesc { - case anyValueType: - json, err := m.ConvertToNative(jsonStructType) - if err != nil { - return nil, err - } - return anypb.New(json.(proto.Message)) - case jsonValueType, jsonStructType: - jsonEntries, err := - m.ConvertToNative(reflect.TypeOf(map[string]*structpb.Value{})) - if err != nil { - return nil, err - } - jsonMap := &structpb.Struct{Fields: jsonEntries.(map[string]*structpb.Value)} - if typeDesc == jsonStructType { - return jsonMap, nil - } - return structpb.NewStructValue(jsonMap), nil - } - - // Unwrap pointers, but track their use. - isPtr := false - if typeDesc.Kind() == reflect.Ptr { - tk := typeDesc - typeDesc = typeDesc.Elem() - if typeDesc.Kind() == reflect.Ptr { - return nil, fmt.Errorf("unsupported type conversion to '%v'", tk) - } - isPtr = true - } - switch typeDesc.Kind() { - // Map conversion. - case reflect.Map: - otherKey := typeDesc.Key() - otherElem := typeDesc.Elem() - nativeMap := reflect.MakeMapWithSize(typeDesc, m.size) - it := m.Iterator() - for it.HasNext() == True { - key := it.Next() - refKeyValue, err := key.ConvertToNative(otherKey) - if err != nil { - return nil, err - } - refElemValue, err := m.Get(key).ConvertToNative(otherElem) - if err != nil { - return nil, err - } - nativeMap.SetMapIndex(reflect.ValueOf(refKeyValue), reflect.ValueOf(refElemValue)) - } - return nativeMap.Interface(), nil - case reflect.Struct: - nativeStructPtr := reflect.New(typeDesc) - nativeStruct := nativeStructPtr.Elem() - it := m.Iterator() - for it.HasNext() == True { - key := it.Next() - // Ensure the field name being referenced is exported. - // Only exported (public) field names can be set by reflection, where the name - // must be at least one character in length and start with an upper-case letter. - fieldName := key.ConvertToType(StringType) - if IsError(fieldName) { - return nil, fieldName.(*Err) - } - name := string(fieldName.(String)) - name = strcase.UpperCamelCase(name) - fieldRef := nativeStruct.FieldByName(name) - if !fieldRef.IsValid() { - return nil, fmt.Errorf("type conversion error, no such field '%s' in type '%v'", name, typeDesc) - } - fieldValue, err := m.Get(key).ConvertToNative(fieldRef.Type()) - if err != nil { - return nil, err - } - fieldRef.Set(reflect.ValueOf(fieldValue)) - } - if isPtr { - return nativeStructPtr.Interface(), nil - } - return nativeStruct.Interface(), nil - } - return nil, fmt.Errorf("type conversion error from map to '%v'", typeDesc) -} - -// ConvertToType implements the ref.Val interface method. -func (m *baseMap) ConvertToType(typeVal ref.Type) ref.Val { - switch typeVal { - case MapType: - return m - case TypeType: - return MapType - } - return NewErr("type conversion error from '%s' to '%s'", MapType, typeVal) -} - -// Equal implements the ref.Val interface method. -func (m *baseMap) Equal(other ref.Val) ref.Val { - otherMap, ok := other.(traits.Mapper) - if !ok { - return False - } - if m.Size() != otherMap.Size() { - return False - } - it := m.Iterator() - for it.HasNext() == True { - key := it.Next() - thisVal, _ := m.Find(key) - otherVal, found := otherMap.Find(key) - if !found { - return False - } - valEq := Equal(thisVal, otherVal) - if valEq == False { - return False - } - } - return True -} - -// Get implements the traits.Indexer interface method. -func (m *baseMap) Get(key ref.Val) ref.Val { - v, found := m.Find(key) - if !found { - return ValOrErr(v, "no such key: %v", key) - } - return v -} - -// IsZeroValue returns true if the map is empty. -func (m *baseMap) IsZeroValue() bool { - return m.size == 0 -} - -// Size implements the traits.Sizer interface method. -func (m *baseMap) Size() ref.Val { - return Int(m.size) -} - -// String converts the map into a human-readable string. -func (m *baseMap) String() string { - var sb strings.Builder - sb.WriteString("{") - it := m.Iterator() - i := 0 - for it.HasNext() == True { - k := it.Next() - v, _ := m.Find(k) - sb.WriteString(fmt.Sprintf("%v: %v", k, v)) - if i != m.size-1 { - sb.WriteString(", ") - } - i++ - } - sb.WriteString("}") - return sb.String() -} - -// Type implements the ref.Val interface method. -func (m *baseMap) Type() ref.Type { - return MapType -} - -// Value implements the ref.Val interface method. -func (m *baseMap) Value() any { - return m.value -} - -func newJSONStructAccessor(adapter Adapter, st map[string]*structpb.Value) mapAccessor { - return &jsonStructAccessor{ - Adapter: adapter, - st: st, - } -} - -type jsonStructAccessor struct { - Adapter - st map[string]*structpb.Value -} - -// Find searches the json struct field map for the input key value and returns (value, true) if -// found. -// -// If the key is not found the function returns (nil, false). -func (a *jsonStructAccessor) Find(key ref.Val) (ref.Val, bool) { - strKey, ok := key.(String) - if !ok { - return nil, false - } - keyVal, found := a.st[string(strKey)] - if !found { - return nil, false - } - return a.NativeToValue(keyVal), true -} - -// Iterator creates a new traits.Iterator from the set of JSON struct field names. -func (a *jsonStructAccessor) Iterator() traits.Iterator { - // Copy the keys to make their order stable. - mapKeys := make([]string, len(a.st)) - i := 0 - for k := range a.st { - mapKeys[i] = k - i++ - } - return &stringKeyIterator{ - mapKeys: mapKeys, - len: len(mapKeys), - } -} - -func newReflectMapAccessor(adapter Adapter, value reflect.Value) mapAccessor { - keyType := value.Type().Key() - return &reflectMapAccessor{ - Adapter: adapter, - refValue: value, - keyType: keyType, - } -} - -type reflectMapAccessor struct { - Adapter - refValue reflect.Value - keyType reflect.Type -} - -// Find converts the input key to a native Golang type and then uses reflection to find the key, -// returning (value, true) if present. -// -// If the key is not found the function returns (nil, false). -func (m *reflectMapAccessor) Find(key ref.Val) (ref.Val, bool) { - if m.refValue.Len() == 0 { - return nil, false - } - if keyVal, found := m.findInternal(key); found { - return keyVal, true - } - switch k := key.(type) { - // Double is not a valid proto map key type, so check for the key as an int or uint. - case Double: - if ik, ok := doubleToInt64Lossless(float64(k)); ok { - if keyVal, found := m.findInternal(Int(ik)); found { - return keyVal, true - } - } - if uk, ok := doubleToUint64Lossless(float64(k)); ok { - return m.findInternal(Uint(uk)) - } - // map keys of type double are not supported. - case Int: - if uk, ok := int64ToUint64Lossless(int64(k)); ok { - return m.findInternal(Uint(uk)) - } - case Uint: - if ik, ok := uint64ToInt64Lossless(uint64(k)); ok { - return m.findInternal(Int(ik)) - } - } - return nil, false -} - -// findInternal attempts to convert the incoming key to the map's internal native type -// and then returns the value, if found. -func (m *reflectMapAccessor) findInternal(key ref.Val) (ref.Val, bool) { - k, err := key.ConvertToNative(m.keyType) - if err != nil { - return nil, false - } - refKey := reflect.ValueOf(k) - val := m.refValue.MapIndex(refKey) - if val.IsValid() { - return m.NativeToValue(val.Interface()), true - } - return nil, false -} - -// Iterator creates a Golang reflection based traits.Iterator. -func (m *reflectMapAccessor) Iterator() traits.Iterator { - return &mapIterator{ - Adapter: m.Adapter, - mapKeys: m.refValue.MapRange(), - len: m.refValue.Len(), - } -} - -func newRefValMapAccessor(mapVal map[ref.Val]ref.Val) mapAccessor { - return &refValMapAccessor{mapVal: mapVal} -} - -type refValMapAccessor struct { - mapVal map[ref.Val]ref.Val -} - -// Find uses native map accesses to find the key, returning (value, true) if present. -// -// If the key is not found the function returns (nil, false). -func (a *refValMapAccessor) Find(key ref.Val) (ref.Val, bool) { - if len(a.mapVal) == 0 { - return nil, false - } - if keyVal, found := a.mapVal[key]; found { - return keyVal, true - } - switch k := key.(type) { - case Double: - if ik, ok := doubleToInt64Lossless(float64(k)); ok { - if keyVal, found := a.mapVal[Int(ik)]; found { - return keyVal, found - } - } - if uk, ok := doubleToUint64Lossless(float64(k)); ok { - keyVal, found := a.mapVal[Uint(uk)] - return keyVal, found - } - // map keys of type double are not supported. - case Int: - if uk, ok := int64ToUint64Lossless(int64(k)); ok { - keyVal, found := a.mapVal[Uint(uk)] - return keyVal, found - } - case Uint: - if ik, ok := uint64ToInt64Lossless(uint64(k)); ok { - keyVal, found := a.mapVal[Int(ik)] - return keyVal, found - } - } - return nil, false -} - -// Iterator produces a new traits.Iterator which iterates over the map keys via Golang reflection. -func (a *refValMapAccessor) Iterator() traits.Iterator { - return &mapIterator{ - Adapter: DefaultTypeAdapter, - mapKeys: reflect.ValueOf(a.mapVal).MapRange(), - len: len(a.mapVal), - } -} - -func newStringMapAccessor(strMap map[string]string) mapAccessor { - return &stringMapAccessor{mapVal: strMap} -} - -type stringMapAccessor struct { - mapVal map[string]string -} - -// Find uses native map accesses to find the key, returning (value, true) if present. -// -// If the key is not found the function returns (nil, false). -func (a *stringMapAccessor) Find(key ref.Val) (ref.Val, bool) { - strKey, ok := key.(String) - if !ok { - return nil, false - } - keyVal, found := a.mapVal[string(strKey)] - if !found { - return nil, false - } - return String(keyVal), true -} - -// Iterator creates a new traits.Iterator from the string key set of the map. -func (a *stringMapAccessor) Iterator() traits.Iterator { - // Copy the keys to make their order stable. - mapKeys := make([]string, len(a.mapVal)) - i := 0 - for k := range a.mapVal { - mapKeys[i] = k - i++ - } - return &stringKeyIterator{ - mapKeys: mapKeys, - len: len(mapKeys), - } -} - -func newStringIfaceMapAccessor(adapter Adapter, mapVal map[string]any) mapAccessor { - return &stringIfaceMapAccessor{ - Adapter: adapter, - mapVal: mapVal, - } -} - -type stringIfaceMapAccessor struct { - Adapter - mapVal map[string]any -} - -// Find uses native map accesses to find the key, returning (value, true) if present. -// -// If the key is not found the function returns (nil, false). -func (a *stringIfaceMapAccessor) Find(key ref.Val) (ref.Val, bool) { - strKey, ok := key.(String) - if !ok { - return nil, false - } - keyVal, found := a.mapVal[string(strKey)] - if !found { - return nil, false - } - return a.NativeToValue(keyVal), true -} - -// Iterator creates a new traits.Iterator from the string key set of the map. -func (a *stringIfaceMapAccessor) Iterator() traits.Iterator { - // Copy the keys to make their order stable. - mapKeys := make([]string, len(a.mapVal)) - i := 0 - for k := range a.mapVal { - mapKeys[i] = k - i++ - } - return &stringKeyIterator{ - mapKeys: mapKeys, - len: len(mapKeys), - } -} - -// protoMap is a specialized, separate implementation of the traits.Mapper interfaces tailored to -// accessing protoreflect.Map values. -type protoMap struct { - Adapter - value *pb.Map -} - -// Contains returns whether the map contains the given key. -func (m *protoMap) Contains(key ref.Val) ref.Val { - _, found := m.Find(key) - return Bool(found) -} - -// ConvertToNative implements the ref.Val interface method. -// -// Note, assignment to Golang struct types is not yet supported. -func (m *protoMap) ConvertToNative(typeDesc reflect.Type) (any, error) { - // If the map is already assignable to the desired type return it, e.g. interfaces and - // maps with the same key value types. - switch typeDesc { - case anyValueType: - json, err := m.ConvertToNative(jsonStructType) - if err != nil { - return nil, err - } - return anypb.New(json.(proto.Message)) - case jsonValueType, jsonStructType: - jsonEntries, err := - m.ConvertToNative(reflect.TypeOf(map[string]*structpb.Value{})) - if err != nil { - return nil, err - } - jsonMap := &structpb.Struct{ - Fields: jsonEntries.(map[string]*structpb.Value)} - if typeDesc == jsonStructType { - return jsonMap, nil - } - return structpb.NewStructValue(jsonMap), nil - } - switch typeDesc.Kind() { - case reflect.Struct, reflect.Ptr: - if reflect.TypeOf(m.value).AssignableTo(typeDesc) { - return m.value, nil - } - if reflect.TypeOf(m).AssignableTo(typeDesc) { - return m, nil - } - } - if typeDesc.Kind() != reflect.Map { - return nil, fmt.Errorf("unsupported type conversion: %v to map", typeDesc) - } - - keyType := m.value.KeyType.ReflectType() - valType := m.value.ValueType.ReflectType() - otherKeyType := typeDesc.Key() - otherValType := typeDesc.Elem() - mapVal := reflect.MakeMapWithSize(typeDesc, m.value.Len()) - var err error - m.value.Range(func(key protoreflect.MapKey, val protoreflect.Value) bool { - ntvKey := key.Interface() - ntvVal := val.Interface() - switch pv := ntvVal.(type) { - case protoreflect.Message: - ntvVal = pv.Interface() - } - if keyType == otherKeyType && valType == otherValType { - mapVal.SetMapIndex(reflect.ValueOf(ntvKey), reflect.ValueOf(ntvVal)) - return true - } - celKey := m.NativeToValue(ntvKey) - celVal := m.NativeToValue(ntvVal) - ntvKey, err = celKey.ConvertToNative(otherKeyType) - if err != nil { - // early terminate the range loop. - return false - } - ntvVal, err = celVal.ConvertToNative(otherValType) - if err != nil { - // early terminate the range loop. - return false - } - mapVal.SetMapIndex(reflect.ValueOf(ntvKey), reflect.ValueOf(ntvVal)) - return true - }) - if err != nil { - return nil, err - } - return mapVal.Interface(), nil -} - -// ConvertToType implements the ref.Val interface method. -func (m *protoMap) ConvertToType(typeVal ref.Type) ref.Val { - switch typeVal { - case MapType: - return m - case TypeType: - return MapType - } - return NewErr("type conversion error from '%s' to '%s'", MapType, typeVal) -} - -// Equal implements the ref.Val interface method. -func (m *protoMap) Equal(other ref.Val) ref.Val { - otherMap, ok := other.(traits.Mapper) - if !ok { - return False - } - if m.value.Map.Len() != int(otherMap.Size().(Int)) { - return False - } - var retVal ref.Val = True - m.value.Range(func(key protoreflect.MapKey, val protoreflect.Value) bool { - keyVal := m.NativeToValue(key.Interface()) - valVal := m.NativeToValue(val) - otherVal, found := otherMap.Find(keyVal) - if !found { - retVal = False - return false - } - valEq := Equal(valVal, otherVal) - if valEq != True { - retVal = valEq - return false - } - return true - }) - return retVal -} - -// Find returns whether the protoreflect.Map contains the input key. -// -// If the key is not found the function returns (nil, false). -func (m *protoMap) Find(key ref.Val) (ref.Val, bool) { - if keyVal, found := m.findInternal(key); found { - return keyVal, true - } - switch k := key.(type) { - // Double is not a valid proto map key type, so check for the key as an int or uint. - case Double: - if ik, ok := doubleToInt64Lossless(float64(k)); ok { - if keyVal, found := m.findInternal(Int(ik)); found { - return keyVal, true - } - } - if uk, ok := doubleToUint64Lossless(float64(k)); ok { - return m.findInternal(Uint(uk)) - } - // map keys of type double are not supported. - case Int: - if uk, ok := int64ToUint64Lossless(int64(k)); ok { - return m.findInternal(Uint(uk)) - } - case Uint: - if ik, ok := uint64ToInt64Lossless(uint64(k)); ok { - return m.findInternal(Int(ik)) - } - } - return nil, false -} - -// findInternal attempts to convert the incoming key to the map's internal native type -// and then returns the value, if found. -func (m *protoMap) findInternal(key ref.Val) (ref.Val, bool) { - // Convert the input key to the expected protobuf key type. - ntvKey, err := key.ConvertToNative(m.value.KeyType.ReflectType()) - if err != nil { - return nil, false - } - // Use protoreflection to get the key value. - val := m.value.Get(protoreflect.ValueOf(ntvKey).MapKey()) - if !val.IsValid() { - return nil, false - } - // Perform nominal type unwrapping from the input value. - switch v := val.Interface().(type) { - case protoreflect.List, protoreflect.Map: - // Maps do not support list or map values - return nil, false - default: - return m.NativeToValue(v), true - } -} - -// Get implements the traits.Indexer interface method. -func (m *protoMap) Get(key ref.Val) ref.Val { - v, found := m.Find(key) - if !found { - return ValOrErr(v, "no such key: %v", key) - } - return v -} - -// IsZeroValue returns true if the map is empty. -func (m *protoMap) IsZeroValue() bool { - return m.value.Len() == 0 -} - -// Iterator implements the traits.Iterable interface method. -func (m *protoMap) Iterator() traits.Iterator { - // Copy the keys to make their order stable. - mapKeys := make([]protoreflect.MapKey, 0, m.value.Len()) - m.value.Range(func(k protoreflect.MapKey, v protoreflect.Value) bool { - mapKeys = append(mapKeys, k) - return true - }) - return &protoMapIterator{ - Adapter: m.Adapter, - mapKeys: mapKeys, - len: m.value.Len(), - } -} - -// Size returns the number of entries in the protoreflect.Map. -func (m *protoMap) Size() ref.Val { - return Int(m.value.Len()) -} - -// Type implements the ref.Val interface method. -func (m *protoMap) Type() ref.Type { - return MapType -} - -// Value implements the ref.Val interface method. -func (m *protoMap) Value() any { - return m.value -} - -type mapIterator struct { - *baseIterator - Adapter - mapKeys *reflect.MapIter - cursor int - len int -} - -// HasNext implements the traits.Iterator interface method. -func (it *mapIterator) HasNext() ref.Val { - return Bool(it.cursor < it.len) -} - -// Next implements the traits.Iterator interface method. -func (it *mapIterator) Next() ref.Val { - if it.HasNext() == True && it.mapKeys.Next() { - it.cursor++ - refKey := it.mapKeys.Key() - return it.NativeToValue(refKey.Interface()) - } - return nil -} - -type protoMapIterator struct { - *baseIterator - Adapter - mapKeys []protoreflect.MapKey - cursor int - len int -} - -// HasNext implements the traits.Iterator interface method. -func (it *protoMapIterator) HasNext() ref.Val { - return Bool(it.cursor < it.len) -} - -// Next implements the traits.Iterator interface method. -func (it *protoMapIterator) Next() ref.Val { - if it.HasNext() == True { - index := it.cursor - it.cursor++ - refKey := it.mapKeys[index] - return it.NativeToValue(refKey.Interface()) - } - return nil -} - -type stringKeyIterator struct { - *baseIterator - mapKeys []string - cursor int - len int -} - -// HasNext implements the traits.Iterator interface method. -func (it *stringKeyIterator) HasNext() ref.Val { - return Bool(it.cursor < it.len) -} - -// Next implements the traits.Iterator interface method. -func (it *stringKeyIterator) Next() ref.Val { - if it.HasNext() == True { - index := it.cursor - it.cursor++ - return String(it.mapKeys[index]) - } - return nil -} diff --git a/vendor/github.com/google/cel-go/common/types/null.go b/vendor/github.com/google/cel-go/common/types/null.go deleted file mode 100644 index 926ca3dc9..000000000 --- a/vendor/github.com/google/cel-go/common/types/null.go +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - "reflect" - - "google.golang.org/protobuf/proto" - - "github.com/google/cel-go/common/types/ref" - - anypb "google.golang.org/protobuf/types/known/anypb" - structpb "google.golang.org/protobuf/types/known/structpb" -) - -// Null type implementation. -type Null structpb.NullValue - -var ( - // NullValue singleton. - NullValue = Null(structpb.NullValue_NULL_VALUE) - - // golang reflect type for Null values. - nullReflectType = reflect.TypeOf(NullValue) -) - -// ConvertToNative implements ref.Val.ConvertToNative. -func (n Null) ConvertToNative(typeDesc reflect.Type) (any, error) { - switch typeDesc.Kind() { - case reflect.Int32: - switch typeDesc { - case jsonNullType: - return structpb.NullValue_NULL_VALUE, nil - case nullReflectType: - return n, nil - } - case reflect.Ptr: - switch typeDesc { - case anyValueType: - // Convert to a JSON-null before packing to an Any field since the enum value for JSON - // null cannot be packed directly. - pb, err := n.ConvertToNative(jsonValueType) - if err != nil { - return nil, err - } - return anypb.New(pb.(proto.Message)) - case jsonValueType: - return structpb.NewNullValue(), nil - case boolWrapperType, byteWrapperType, doubleWrapperType, floatWrapperType, - int32WrapperType, int64WrapperType, stringWrapperType, uint32WrapperType, - uint64WrapperType: - return nil, nil - } - case reflect.Interface: - nv := n.Value() - if reflect.TypeOf(nv).Implements(typeDesc) { - return nv, nil - } - if reflect.TypeOf(n).Implements(typeDesc) { - return n, nil - } - } - // If the type conversion isn't supported return an error. - return nil, fmt.Errorf("type conversion error from '%v' to '%v'", NullType, typeDesc) -} - -// ConvertToType implements ref.Val.ConvertToType. -func (n Null) ConvertToType(typeVal ref.Type) ref.Val { - switch typeVal { - case StringType: - return String("null") - case NullType: - return n - case TypeType: - return NullType - } - return NewErr("type conversion error from '%s' to '%s'", NullType, typeVal) -} - -// Equal implements ref.Val.Equal. -func (n Null) Equal(other ref.Val) ref.Val { - return Bool(NullType == other.Type()) -} - -// IsZeroValue returns true as null always represents an absent value. -func (n Null) IsZeroValue() bool { - return true -} - -// Type implements ref.Val.Type. -func (n Null) Type() ref.Type { - return NullType -} - -// Value implements ref.Val.Value. -func (n Null) Value() any { - return structpb.NullValue_NULL_VALUE -} diff --git a/vendor/github.com/google/cel-go/common/types/object.go b/vendor/github.com/google/cel-go/common/types/object.go deleted file mode 100644 index 8ba0af9fb..000000000 --- a/vendor/github.com/google/cel-go/common/types/object.go +++ /dev/null @@ -1,165 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - "reflect" - - "google.golang.org/protobuf/encoding/protojson" - "google.golang.org/protobuf/proto" - - "github.com/google/cel-go/common/types/pb" - "github.com/google/cel-go/common/types/ref" - - anypb "google.golang.org/protobuf/types/known/anypb" - structpb "google.golang.org/protobuf/types/known/structpb" -) - -type protoObj struct { - Adapter - value proto.Message - typeDesc *pb.TypeDescription - typeValue ref.Val -} - -// NewObject returns an object based on a proto.Message value which handles -// conversion between protobuf type values and expression type values. -// Objects support indexing and iteration. -// -// Note: the type value is pulled from the list of registered types within the -// type provider. If the proto type is not registered within the type provider, -// then this will result in an error within the type adapter / provider. -func NewObject(adapter Adapter, - typeDesc *pb.TypeDescription, - typeValue ref.Val, - value proto.Message) ref.Val { - return &protoObj{ - Adapter: adapter, - value: value, - typeDesc: typeDesc, - typeValue: typeValue} -} - -func (o *protoObj) ConvertToNative(typeDesc reflect.Type) (any, error) { - srcPB := o.value - if reflect.TypeOf(srcPB).AssignableTo(typeDesc) { - return srcPB, nil - } - if reflect.TypeOf(o).AssignableTo(typeDesc) { - return o, nil - } - switch typeDesc { - case anyValueType: - _, isAny := srcPB.(*anypb.Any) - if isAny { - return srcPB, nil - } - return anypb.New(srcPB) - case jsonValueType: - // Marshal the proto to JSON first, and then rehydrate as protobuf.Value as there is no - // support for direct conversion from proto.Message to protobuf.Value. - bytes, err := protojson.Marshal(srcPB) - if err != nil { - return nil, err - } - json := &structpb.Value{} - err = protojson.Unmarshal(bytes, json) - if err != nil { - return nil, err - } - return json, nil - default: - if typeDesc == o.typeDesc.ReflectType() { - return o.value, nil - } - if typeDesc.Kind() == reflect.Ptr { - val := reflect.New(typeDesc.Elem()).Interface() - dstPB, ok := val.(proto.Message) - if ok { - err := pb.Merge(dstPB, srcPB) - if err != nil { - return nil, fmt.Errorf("type conversion error: %v", err) - } - return dstPB, nil - } - } - } - return nil, fmt.Errorf("type conversion error from '%T' to '%v'", o.value, typeDesc) -} - -func (o *protoObj) ConvertToType(typeVal ref.Type) ref.Val { - switch typeVal { - default: - if o.Type().TypeName() == typeVal.TypeName() { - return o - } - case TypeType: - return o.typeValue - } - return NewErr("type conversion error from '%s' to '%s'", o.typeDesc.Name(), typeVal) -} - -func (o *protoObj) Equal(other ref.Val) ref.Val { - otherPB, ok := other.Value().(proto.Message) - return Bool(ok && pb.Equal(o.value, otherPB)) -} - -// IsSet tests whether a field which is defined is set to a non-default value. -func (o *protoObj) IsSet(field ref.Val) ref.Val { - protoFieldName, ok := field.(String) - if !ok { - return MaybeNoSuchOverloadErr(field) - } - protoFieldStr := string(protoFieldName) - fd, found := o.typeDesc.FieldByName(protoFieldStr) - if !found { - return NewErr("no such field '%s'", field) - } - if fd.IsSet(o.value) { - return True - } - return False -} - -// IsZeroValue returns true if the protobuf object is empty. -func (o *protoObj) IsZeroValue() bool { - return proto.Equal(o.value, o.typeDesc.Zero()) -} - -func (o *protoObj) Get(index ref.Val) ref.Val { - protoFieldName, ok := index.(String) - if !ok { - return MaybeNoSuchOverloadErr(index) - } - protoFieldStr := string(protoFieldName) - fd, found := o.typeDesc.FieldByName(protoFieldStr) - if !found { - return NewErr("no such field '%s'", index) - } - fv, err := fd.GetFrom(o.value) - if err != nil { - return NewErr(err.Error()) - } - return o.NativeToValue(fv) -} - -func (o *protoObj) Type() ref.Type { - return o.typeValue.(ref.Type) -} - -func (o *protoObj) Value() any { - return o.value -} diff --git a/vendor/github.com/google/cel-go/common/types/optional.go b/vendor/github.com/google/cel-go/common/types/optional.go deleted file mode 100644 index a9f30aed0..000000000 --- a/vendor/github.com/google/cel-go/common/types/optional.go +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "errors" - "fmt" - "reflect" - - "github.com/google/cel-go/common/types/ref" -) - -var ( - // OptionalType indicates the runtime type of an optional value. - OptionalType = NewOpaqueType("optional") - - // OptionalNone is a sentinel value which is used to indicate an empty optional value. - OptionalNone = &Optional{} -) - -// OptionalOf returns an optional value which wraps a concrete CEL value. -func OptionalOf(value ref.Val) *Optional { - return &Optional{value: value} -} - -// Optional value which points to a value if non-empty. -type Optional struct { - value ref.Val -} - -// HasValue returns true if the optional has a value. -func (o *Optional) HasValue() bool { - return o.value != nil -} - -// GetValue returns the wrapped value contained in the optional. -func (o *Optional) GetValue() ref.Val { - if !o.HasValue() { - return NewErr("optional.none() dereference") - } - return o.value -} - -// ConvertToNative implements the ref.Val interface method. -func (o *Optional) ConvertToNative(typeDesc reflect.Type) (any, error) { - if !o.HasValue() { - return nil, errors.New("optional.none() dereference") - } - return o.value.ConvertToNative(typeDesc) -} - -// ConvertToType implements the ref.Val interface method. -func (o *Optional) ConvertToType(typeVal ref.Type) ref.Val { - switch typeVal { - case OptionalType: - return o - case TypeType: - return OptionalType - } - return NewErr("type conversion error from '%s' to '%s'", OptionalType, typeVal) -} - -// Equal determines whether the values contained by two optional values are equal. -func (o *Optional) Equal(other ref.Val) ref.Val { - otherOpt, isOpt := other.(*Optional) - if !isOpt { - return False - } - if !o.HasValue() { - return Bool(!otherOpt.HasValue()) - } - if !otherOpt.HasValue() { - return False - } - return o.value.Equal(otherOpt.value) -} - -func (o *Optional) String() string { - if o.HasValue() { - return fmt.Sprintf("optional(%v)", o.GetValue()) - } - return "optional.none()" -} - -// Type implements the ref.Val interface method. -func (o *Optional) Type() ref.Type { - return OptionalType -} - -// Value returns the underlying 'Value()' of the wrapped value, if present. -func (o *Optional) Value() any { - if o.value == nil { - return nil - } - return o.value.Value() -} diff --git a/vendor/github.com/google/cel-go/common/types/overflow.go b/vendor/github.com/google/cel-go/common/types/overflow.go deleted file mode 100644 index c68a92182..000000000 --- a/vendor/github.com/google/cel-go/common/types/overflow.go +++ /dev/null @@ -1,389 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "math" - "time" -) - -var ( - doubleTwoTo64 = math.Ldexp(1.0, 64) -) - -// addInt64Checked performs addition with overflow detection of two int64 values. -// -// If the operation fails the error return value will be non-nil. -func addInt64Checked(x, y int64) (int64, error) { - if (y > 0 && x > math.MaxInt64-y) || (y < 0 && x < math.MinInt64-y) { - return 0, errIntOverflow - } - return x + y, nil -} - -// subtractInt64Checked performs subtraction with overflow detection of two int64 values. -// -// If the operation fails the error return value will be non-nil. -func subtractInt64Checked(x, y int64) (int64, error) { - if (y < 0 && x > math.MaxInt64+y) || (y > 0 && x < math.MinInt64+y) { - return 0, errIntOverflow - } - return x - y, nil -} - -// negateInt64Checked performs negation with overflow detection of an int64. -// -// If the operation fails the error return value will be non-nil. -func negateInt64Checked(x int64) (int64, error) { - // In twos complement, negating MinInt64 would result in a valid of MaxInt64+1. - if x == math.MinInt64 { - return 0, errIntOverflow - } - return -x, nil -} - -// multiplyInt64Checked performs multiplication with overflow detection of two int64 value. -// -// If the operation fails the error return value will be non-nil. -func multiplyInt64Checked(x, y int64) (int64, error) { - // Detecting multiplication overflow is more complicated than the others. The first two detect - // attempting to negate MinInt64, which would result in MaxInt64+1. The other four detect normal - // overflow conditions. - if (x == -1 && y == math.MinInt64) || (y == -1 && x == math.MinInt64) || - // x is positive, y is positive - (x > 0 && y > 0 && x > math.MaxInt64/y) || - // x is positive, y is negative - (x > 0 && y < 0 && y < math.MinInt64/x) || - // x is negative, y is positive - (x < 0 && y > 0 && x < math.MinInt64/y) || - // x is negative, y is negative - (x < 0 && y < 0 && y < math.MaxInt64/x) { - return 0, errIntOverflow - } - return x * y, nil -} - -// divideInt64Checked performs division with overflow detection of two int64 values, -// as well as a division by zero check. -// -// If the operation fails the error return value will be non-nil. -func divideInt64Checked(x, y int64) (int64, error) { - // Division by zero. - if y == 0 { - return 0, errDivideByZero - } - // In twos complement, negating MinInt64 would result in a valid of MaxInt64+1. - if x == math.MinInt64 && y == -1 { - return 0, errIntOverflow - } - return x / y, nil -} - -// moduloInt64Checked performs modulo with overflow detection of two int64 values -// as well as a modulus by zero check. -// -// If the operation fails the error return value will be non-nil. -func moduloInt64Checked(x, y int64) (int64, error) { - // Modulus by zero. - if y == 0 { - return 0, errModulusByZero - } - // In twos complement, negating MinInt64 would result in a valid of MaxInt64+1. - if x == math.MinInt64 && y == -1 { - return 0, errIntOverflow - } - return x % y, nil -} - -// addUint64Checked performs addition with overflow detection of two uint64 values. -// -// If the operation fails due to overflow the error return value will be non-nil. -func addUint64Checked(x, y uint64) (uint64, error) { - if y > 0 && x > math.MaxUint64-y { - return 0, errUintOverflow - } - return x + y, nil -} - -// subtractUint64Checked performs subtraction with overflow detection of two uint64 values. -// -// If the operation fails due to overflow the error return value will be non-nil. -func subtractUint64Checked(x, y uint64) (uint64, error) { - if y > x { - return 0, errUintOverflow - } - return x - y, nil -} - -// multiplyUint64Checked performs multiplication with overflow detection of two uint64 values. -// -// If the operation fails due to overflow the error return value will be non-nil. -func multiplyUint64Checked(x, y uint64) (uint64, error) { - if y != 0 && x > math.MaxUint64/y { - return 0, errUintOverflow - } - return x * y, nil -} - -// divideUint64Checked performs division with a test for division by zero. -// -// If the operation fails the error return value will be non-nil. -func divideUint64Checked(x, y uint64) (uint64, error) { - if y == 0 { - return 0, errDivideByZero - } - return x / y, nil -} - -// moduloUint64Checked performs modulo with a test for modulus by zero. -// -// If the operation fails the error return value will be non-nil. -func moduloUint64Checked(x, y uint64) (uint64, error) { - if y == 0 { - return 0, errModulusByZero - } - return x % y, nil -} - -// addDurationChecked performs addition with overflow detection of two time.Durations. -// -// If the operation fails due to overflow the error return value will be non-nil. -func addDurationChecked(x, y time.Duration) (time.Duration, error) { - val, err := addInt64Checked(int64(x), int64(y)) - if err != nil { - return time.Duration(0), err - } - return time.Duration(val), nil -} - -// subtractDurationChecked performs subtraction with overflow detection of two time.Durations. -// -// If the operation fails due to overflow the error return value will be non-nil. -func subtractDurationChecked(x, y time.Duration) (time.Duration, error) { - val, err := subtractInt64Checked(int64(x), int64(y)) - if err != nil { - return time.Duration(0), err - } - return time.Duration(val), nil -} - -// negateDurationChecked performs negation with overflow detection of a time.Duration. -// -// If the operation fails due to overflow the error return value will be non-nil. -func negateDurationChecked(x time.Duration) (time.Duration, error) { - val, err := negateInt64Checked(int64(x)) - if err != nil { - return time.Duration(0), err - } - return time.Duration(val), nil -} - -// addDurationChecked performs addition with overflow detection of a time.Time and time.Duration. -// -// If the operation fails due to overflow the error return value will be non-nil. -func addTimeDurationChecked(x time.Time, y time.Duration) (time.Time, error) { - // This is tricky. A time is represented as (int64, int32) where the first is seconds and second - // is nanoseconds. A duration is int64 representing nanoseconds. We cannot normalize time to int64 - // as it could potentially overflow. The only way to proceed is to break time and duration into - // second and nanosecond components. - - // First we break time into its components by truncating and subtracting. - sec1 := x.Truncate(time.Second).Unix() // Truncate to seconds. - nsec1 := x.Sub(x.Truncate(time.Second)).Nanoseconds() // Get nanoseconds by truncating and subtracting. - - // Second we break duration into its components by dividing and modulo. - sec2 := int64(y) / int64(time.Second) // Truncate to seconds. - nsec2 := int64(y) % int64(time.Second) // Get remainder. - - // Add seconds first, detecting any overflow. - sec, err := addInt64Checked(sec1, sec2) - if err != nil { - return time.Time{}, err - } - // Nanoseconds cannot overflow as time.Time normalizes them to [0, 999999999]. - nsec := nsec1 + nsec2 - - // We need to normalize nanoseconds to be positive and carry extra nanoseconds to seconds. - // Adapted from time.Unix(int64, int64). - if nsec < 0 || nsec >= int64(time.Second) { - // Add seconds. - sec, err = addInt64Checked(sec, nsec/int64(time.Second)) - if err != nil { - return time.Time{}, err - } - - nsec -= (nsec / int64(time.Second)) * int64(time.Second) - if nsec < 0 { - // Subtract an extra second - sec, err = addInt64Checked(sec, -1) - if err != nil { - return time.Time{}, err - } - nsec += int64(time.Second) - } - } - - // Check if the the number of seconds from Unix epoch is within our acceptable range. - if sec < minUnixTime || sec > maxUnixTime { - return time.Time{}, errTimestampOverflow - } - - // Return resulting time and propagate time zone. - return time.Unix(sec, nsec).In(x.Location()), nil -} - -// subtractTimeChecked performs subtraction with overflow detection of two time.Time. -// -// If the operation fails due to overflow the error return value will be non-nil. -func subtractTimeChecked(x, y time.Time) (time.Duration, error) { - // Similar to addTimeDurationOverflow() above. - - // First we break time into its components by truncating and subtracting. - sec1 := x.Truncate(time.Second).Unix() // Truncate to seconds. - nsec1 := x.Sub(x.Truncate(time.Second)).Nanoseconds() // Get nanoseconds by truncating and subtracting. - - // Second we break duration into its components by truncating and subtracting. - sec2 := y.Truncate(time.Second).Unix() // Truncate to seconds. - nsec2 := y.Sub(y.Truncate(time.Second)).Nanoseconds() // Get nanoseconds by truncating and subtracting. - - // Subtract seconds first, detecting any overflow. - sec, err := subtractInt64Checked(sec1, sec2) - if err != nil { - return time.Duration(0), err - } - - // Nanoseconds cannot overflow as time.Time normalizes them to [0, 999999999]. - nsec := nsec1 - nsec2 - - // Scale seconds to nanoseconds detecting overflow. - tsec, err := multiplyInt64Checked(sec, int64(time.Second)) - if err != nil { - return time.Duration(0), err - } - - // Lastly we need to add the two nanoseconds together. - val, err := addInt64Checked(tsec, nsec) - if err != nil { - return time.Duration(0), err - } - - return time.Duration(val), nil -} - -// subtractTimeDurationChecked performs subtraction with overflow detection of a time.Time and -// time.Duration. -// -// If the operation fails due to overflow the error return value will be non-nil. -func subtractTimeDurationChecked(x time.Time, y time.Duration) (time.Time, error) { - // The easiest way to implement this is to negate y and add them. - // x - y = x + -y - val, err := negateDurationChecked(y) - if err != nil { - return time.Time{}, err - } - return addTimeDurationChecked(x, val) -} - -// doubleToInt64Checked converts a double to an int64 value. -// -// If the conversion fails due to overflow the error return value will be non-nil. -func doubleToInt64Checked(v float64) (int64, error) { - if math.IsInf(v, 0) || math.IsNaN(v) || v <= float64(math.MinInt64) || v >= float64(math.MaxInt64) { - return 0, errIntOverflow - } - return int64(v), nil -} - -// doubleToInt64Checked converts a double to a uint64 value. -// -// If the conversion fails due to overflow the error return value will be non-nil. -func doubleToUint64Checked(v float64) (uint64, error) { - if math.IsInf(v, 0) || math.IsNaN(v) || v < 0 || v >= doubleTwoTo64 { - return 0, errUintOverflow - } - return uint64(v), nil -} - -// int64ToUint64Checked converts an int64 to a uint64 value. -// -// If the conversion fails due to overflow the error return value will be non-nil. -func int64ToUint64Checked(v int64) (uint64, error) { - if v < 0 { - return 0, errUintOverflow - } - return uint64(v), nil -} - -// int64ToInt32Checked converts an int64 to an int32 value. -// -// If the conversion fails due to overflow the error return value will be non-nil. -func int64ToInt32Checked(v int64) (int32, error) { - if v < math.MinInt32 || v > math.MaxInt32 { - return 0, errIntOverflow - } - return int32(v), nil -} - -// uint64ToUint32Checked converts a uint64 to a uint32 value. -// -// If the conversion fails due to overflow the error return value will be non-nil. -func uint64ToUint32Checked(v uint64) (uint32, error) { - if v > math.MaxUint32 { - return 0, errUintOverflow - } - return uint32(v), nil -} - -// uint64ToInt64Checked converts a uint64 to an int64 value. -// -// If the conversion fails due to overflow the error return value will be non-nil. -func uint64ToInt64Checked(v uint64) (int64, error) { - if v > math.MaxInt64 { - return 0, errIntOverflow - } - return int64(v), nil -} - -func doubleToUint64Lossless(v float64) (uint64, bool) { - u, err := doubleToUint64Checked(v) - if err != nil { - return 0, false - } - if float64(u) != v { - return 0, false - } - return u, true -} - -func doubleToInt64Lossless(v float64) (int64, bool) { - i, err := doubleToInt64Checked(v) - if err != nil { - return 0, false - } - if float64(i) != v { - return 0, false - } - return i, true -} - -func int64ToUint64Lossless(v int64) (uint64, bool) { - u, err := int64ToUint64Checked(v) - return u, err == nil -} - -func uint64ToInt64Lossless(v uint64) (int64, bool) { - i, err := uint64ToInt64Checked(v) - return i, err == nil -} diff --git a/vendor/github.com/google/cel-go/common/types/pb/BUILD.bazel b/vendor/github.com/google/cel-go/common/types/pb/BUILD.bazel deleted file mode 100644 index e2b9d37b5..000000000 --- a/vendor/github.com/google/cel-go/common/types/pb/BUILD.bazel +++ /dev/null @@ -1,53 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -package( - default_visibility = ["//visibility:public"], - licenses = ["notice"], # Apache 2.0 -) - -go_library( - name = "go_default_library", - srcs = [ - "checked.go", - "enum.go", - "equal.go", - "file.go", - "pb.go", - "type.go", - ], - importpath = "github.com/google/cel-go/common/types/pb", - deps = [ - "@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library", - "@org_golang_google_protobuf//encoding/protowire:go_default_library", - "@org_golang_google_protobuf//proto:go_default_library", - "@org_golang_google_protobuf//reflect/protoreflect:go_default_library", - "@org_golang_google_protobuf//reflect/protoregistry:go_default_library", - "@org_golang_google_protobuf//types/dynamicpb:go_default_library", - "@org_golang_google_protobuf//types/known/anypb:go_default_library", - "@org_golang_google_protobuf//types/known/durationpb:go_default_library", - "@org_golang_google_protobuf//types/known/emptypb:go_default_library", - "@org_golang_google_protobuf//types/known/structpb:go_default_library", - "@org_golang_google_protobuf//types/known/timestamppb:go_default_library", - "@org_golang_google_protobuf//types/known/wrapperspb:go_default_library", - ], -) - -go_test( - name = "go_default_test", - size = "small", - srcs = [ - "equal_test.go", - "file_test.go", - "pb_test.go", - "type_test.go", - ], - embed = [":go_default_library"], - deps = [ - "//checker/decls:go_default_library", - "//test/proto2pb:test_all_types_go_proto", - "//test/proto3pb:test_all_types_go_proto", - "@org_golang_google_protobuf//reflect/protodesc:go_default_library", - "@org_golang_google_protobuf//reflect/protoreflect:go_default_library", - "@org_golang_google_protobuf//types/descriptorpb:go_default_library", - ], -) diff --git a/vendor/github.com/google/cel-go/common/types/pb/checked.go b/vendor/github.com/google/cel-go/common/types/pb/checked.go deleted file mode 100644 index 312a6a072..000000000 --- a/vendor/github.com/google/cel-go/common/types/pb/checked.go +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package pb - -import ( - "google.golang.org/protobuf/reflect/protoreflect" - - exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1" - emptypb "google.golang.org/protobuf/types/known/emptypb" - structpb "google.golang.org/protobuf/types/known/structpb" -) - -var ( - // CheckedPrimitives map from proto field descriptor type to expr.Type. - CheckedPrimitives = map[protoreflect.Kind]*exprpb.Type{ - protoreflect.BoolKind: checkedBool, - protoreflect.BytesKind: checkedBytes, - protoreflect.DoubleKind: checkedDouble, - protoreflect.FloatKind: checkedDouble, - protoreflect.Int32Kind: checkedInt, - protoreflect.Int64Kind: checkedInt, - protoreflect.Sint32Kind: checkedInt, - protoreflect.Sint64Kind: checkedInt, - protoreflect.Uint32Kind: checkedUint, - protoreflect.Uint64Kind: checkedUint, - protoreflect.Fixed32Kind: checkedUint, - protoreflect.Fixed64Kind: checkedUint, - protoreflect.Sfixed32Kind: checkedInt, - protoreflect.Sfixed64Kind: checkedInt, - protoreflect.StringKind: checkedString} - - // CheckedWellKnowns map from qualified proto type name to expr.Type for - // well-known proto types. - CheckedWellKnowns = map[string]*exprpb.Type{ - // Wrapper types. - "google.protobuf.BoolValue": checkedWrap(checkedBool), - "google.protobuf.BytesValue": checkedWrap(checkedBytes), - "google.protobuf.DoubleValue": checkedWrap(checkedDouble), - "google.protobuf.FloatValue": checkedWrap(checkedDouble), - "google.protobuf.Int64Value": checkedWrap(checkedInt), - "google.protobuf.Int32Value": checkedWrap(checkedInt), - "google.protobuf.UInt64Value": checkedWrap(checkedUint), - "google.protobuf.UInt32Value": checkedWrap(checkedUint), - "google.protobuf.StringValue": checkedWrap(checkedString), - // Well-known types. - "google.protobuf.Any": checkedAny, - "google.protobuf.Duration": checkedDuration, - "google.protobuf.Timestamp": checkedTimestamp, - // Json types. - "google.protobuf.ListValue": checkedListDyn, - "google.protobuf.NullValue": checkedNull, - "google.protobuf.Struct": checkedMapStringDyn, - "google.protobuf.Value": checkedDyn, - } - - // common types - checkedDyn = &exprpb.Type{TypeKind: &exprpb.Type_Dyn{Dyn: &emptypb.Empty{}}} - // Wrapper and primitive types. - checkedBool = checkedPrimitive(exprpb.Type_BOOL) - checkedBytes = checkedPrimitive(exprpb.Type_BYTES) - checkedDouble = checkedPrimitive(exprpb.Type_DOUBLE) - checkedInt = checkedPrimitive(exprpb.Type_INT64) - checkedString = checkedPrimitive(exprpb.Type_STRING) - checkedUint = checkedPrimitive(exprpb.Type_UINT64) - // Well-known type equivalents. - checkedAny = checkedWellKnown(exprpb.Type_ANY) - checkedDuration = checkedWellKnown(exprpb.Type_DURATION) - checkedTimestamp = checkedWellKnown(exprpb.Type_TIMESTAMP) - // Json-based type equivalents. - checkedNull = &exprpb.Type{ - TypeKind: &exprpb.Type_Null{ - Null: structpb.NullValue_NULL_VALUE}} - checkedListDyn = &exprpb.Type{ - TypeKind: &exprpb.Type_ListType_{ - ListType: &exprpb.Type_ListType{ElemType: checkedDyn}}} - checkedMapStringDyn = &exprpb.Type{ - TypeKind: &exprpb.Type_MapType_{ - MapType: &exprpb.Type_MapType{ - KeyType: checkedString, - ValueType: checkedDyn}}} -) diff --git a/vendor/github.com/google/cel-go/common/types/pb/enum.go b/vendor/github.com/google/cel-go/common/types/pb/enum.go deleted file mode 100644 index 09a154630..000000000 --- a/vendor/github.com/google/cel-go/common/types/pb/enum.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package pb - -import ( - "google.golang.org/protobuf/reflect/protoreflect" -) - -// newEnumValueDescription produces an enum value description with the fully qualified enum value -// name and the enum value descriptor. -func newEnumValueDescription(name string, desc protoreflect.EnumValueDescriptor) *EnumValueDescription { - return &EnumValueDescription{ - enumValueName: name, - desc: desc, - } -} - -// EnumValueDescription maps a fully-qualified enum value name to its numeric value. -type EnumValueDescription struct { - enumValueName string - desc protoreflect.EnumValueDescriptor -} - -// Name returns the fully-qualified identifier name for the enum value. -func (ed *EnumValueDescription) Name() string { - return ed.enumValueName -} - -// Value returns the (numeric) value of the enum. -func (ed *EnumValueDescription) Value() int32 { - return int32(ed.desc.Number()) -} diff --git a/vendor/github.com/google/cel-go/common/types/pb/equal.go b/vendor/github.com/google/cel-go/common/types/pb/equal.go deleted file mode 100644 index 76893d85e..000000000 --- a/vendor/github.com/google/cel-go/common/types/pb/equal.go +++ /dev/null @@ -1,206 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package pb - -import ( - "bytes" - "reflect" - - "google.golang.org/protobuf/encoding/protowire" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/reflect/protoreflect" - - anypb "google.golang.org/protobuf/types/known/anypb" -) - -// Equal returns whether two proto.Message instances are equal using the following criteria: -// -// - Messages must share the same instance of the type descriptor -// - Known set fields are compared using semantics equality -// - Bytes are compared using bytes.Equal -// - Scalar values are compared with operator == -// - List and map types are equal if they have the same length and all elements are equal -// - Messages are equal if they share the same descriptor and all set fields are equal -// - Unknown fields are compared using byte equality -// - NaN values are not equal to each other -// - google.protobuf.Any values are unpacked before comparison -// - If the type descriptor for a protobuf.Any cannot be found, byte equality is used rather than -// semantic equality. -// -// This method of proto equality mirrors the behavior of the C++ protobuf MessageDifferencer -// whereas the golang proto.Equal implementation mirrors the Java protobuf equals() methods -// behaviors which needed to treat NaN values as equal due to Java semantics. -func Equal(x, y proto.Message) bool { - if x == nil || y == nil { - return x == nil && y == nil - } - xRef := x.ProtoReflect() - yRef := y.ProtoReflect() - return equalMessage(xRef, yRef) -} - -func equalMessage(mx, my protoreflect.Message) bool { - // Note, the original proto.Equal upon which this implementation is based does not specifically handle the - // case when both messages are invalid. It is assumed that the descriptors will be equal and that byte-wise - // comparison will be used, though the semantics of validity are neither clear, nor promised within the - // proto.Equal implementation. - if mx.IsValid() != my.IsValid() || mx.Descriptor() != my.Descriptor() { - return false - } - - // This is an innovation on the default proto.Equal where protobuf.Any values are unpacked before comparison - // as otherwise the Any values are compared by bytes rather than structurally. - if isAny(mx) && isAny(my) { - ax := mx.Interface().(*anypb.Any) - ay := my.Interface().(*anypb.Any) - // If the values are not the same type url, return false. - if ax.GetTypeUrl() != ay.GetTypeUrl() { - return false - } - // If the values are byte equal, then return true. - if bytes.Equal(ax.GetValue(), ay.GetValue()) { - return true - } - // Otherwise fall through to the semantic comparison of the any values. - x, err := ax.UnmarshalNew() - if err != nil { - return false - } - y, err := ay.UnmarshalNew() - if err != nil { - return false - } - // Recursively compare the unwrapped messages to ensure nested Any values are unwrapped accordingly. - return equalMessage(x.ProtoReflect(), y.ProtoReflect()) - } - - // Walk the set fields to determine field-wise equality - nx := 0 - equal := true - mx.Range(func(fd protoreflect.FieldDescriptor, vx protoreflect.Value) bool { - nx++ - equal = my.Has(fd) && equalField(fd, vx, my.Get(fd)) - return equal - }) - if !equal { - return false - } - // Establish the count of set fields on message y - ny := 0 - my.Range(func(protoreflect.FieldDescriptor, protoreflect.Value) bool { - ny++ - return true - }) - // If the number of set fields is not equal return false. - if nx != ny { - return false - } - - return equalUnknown(mx.GetUnknown(), my.GetUnknown()) -} - -func equalField(fd protoreflect.FieldDescriptor, x, y protoreflect.Value) bool { - switch { - case fd.IsMap(): - return equalMap(fd, x.Map(), y.Map()) - case fd.IsList(): - return equalList(fd, x.List(), y.List()) - default: - return equalValue(fd, x, y) - } -} - -func equalMap(fd protoreflect.FieldDescriptor, x, y protoreflect.Map) bool { - if x.Len() != y.Len() { - return false - } - equal := true - x.Range(func(k protoreflect.MapKey, vx protoreflect.Value) bool { - vy := y.Get(k) - equal = y.Has(k) && equalValue(fd.MapValue(), vx, vy) - return equal - }) - return equal -} - -func equalList(fd protoreflect.FieldDescriptor, x, y protoreflect.List) bool { - if x.Len() != y.Len() { - return false - } - for i := x.Len() - 1; i >= 0; i-- { - if !equalValue(fd, x.Get(i), y.Get(i)) { - return false - } - } - return true -} - -func equalValue(fd protoreflect.FieldDescriptor, x, y protoreflect.Value) bool { - switch fd.Kind() { - case protoreflect.BoolKind: - return x.Bool() == y.Bool() - case protoreflect.EnumKind: - return x.Enum() == y.Enum() - case protoreflect.Int32Kind, protoreflect.Sint32Kind, - protoreflect.Int64Kind, protoreflect.Sint64Kind, - protoreflect.Sfixed32Kind, protoreflect.Sfixed64Kind: - return x.Int() == y.Int() - case protoreflect.Uint32Kind, protoreflect.Uint64Kind, - protoreflect.Fixed32Kind, protoreflect.Fixed64Kind: - return x.Uint() == y.Uint() - case protoreflect.FloatKind, protoreflect.DoubleKind: - return x.Float() == y.Float() - case protoreflect.StringKind: - return x.String() == y.String() - case protoreflect.BytesKind: - return bytes.Equal(x.Bytes(), y.Bytes()) - case protoreflect.MessageKind, protoreflect.GroupKind: - return equalMessage(x.Message(), y.Message()) - default: - return x.Interface() == y.Interface() - } -} - -func equalUnknown(x, y protoreflect.RawFields) bool { - lenX := len(x) - lenY := len(y) - if lenX != lenY { - return false - } - if lenX == 0 { - return true - } - if bytes.Equal([]byte(x), []byte(y)) { - return true - } - - mx := make(map[protoreflect.FieldNumber]protoreflect.RawFields) - my := make(map[protoreflect.FieldNumber]protoreflect.RawFields) - for len(x) > 0 { - fnum, _, n := protowire.ConsumeField(x) - mx[fnum] = append(mx[fnum], x[:n]...) - x = x[n:] - } - for len(y) > 0 { - fnum, _, n := protowire.ConsumeField(y) - my[fnum] = append(my[fnum], y[:n]...) - y = y[n:] - } - return reflect.DeepEqual(mx, my) -} - -func isAny(m protoreflect.Message) bool { - return string(m.Descriptor().FullName()) == "google.protobuf.Any" -} diff --git a/vendor/github.com/google/cel-go/common/types/pb/file.go b/vendor/github.com/google/cel-go/common/types/pb/file.go deleted file mode 100644 index e323afb1d..000000000 --- a/vendor/github.com/google/cel-go/common/types/pb/file.go +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package pb - -import ( - "fmt" - - "google.golang.org/protobuf/reflect/protoreflect" - - dynamicpb "google.golang.org/protobuf/types/dynamicpb" -) - -// newFileDescription returns a FileDescription instance with a complete listing of all the message -// types and enum values, as well as a map of extensions declared within any scope in the file. -func newFileDescription(fileDesc protoreflect.FileDescriptor, pbdb *Db) (*FileDescription, extensionMap) { - metadata := collectFileMetadata(fileDesc) - enums := make(map[string]*EnumValueDescription) - for name, enumVal := range metadata.enumValues { - enums[name] = newEnumValueDescription(name, enumVal) - } - types := make(map[string]*TypeDescription) - for name, msgType := range metadata.msgTypes { - types[name] = newTypeDescription(name, msgType, pbdb.extensions) - } - fileExtMap := make(extensionMap) - for typeName, extensions := range metadata.msgExtensionMap { - messageExtMap, found := fileExtMap[typeName] - if !found { - messageExtMap = make(map[string]*FieldDescription) - } - for _, ext := range extensions { - extDesc := dynamicpb.NewExtensionType(ext).TypeDescriptor() - messageExtMap[string(ext.FullName())] = newFieldDescription(extDesc) - } - fileExtMap[typeName] = messageExtMap - } - return &FileDescription{ - name: fileDesc.Path(), - types: types, - enums: enums, - }, fileExtMap -} - -// FileDescription holds a map of all types and enum values declared within a proto file. -type FileDescription struct { - name string - types map[string]*TypeDescription - enums map[string]*EnumValueDescription -} - -// Copy creates a copy of the FileDescription with updated Db references within its types. -func (fd *FileDescription) Copy(pbdb *Db) *FileDescription { - typesCopy := make(map[string]*TypeDescription, len(fd.types)) - for k, v := range fd.types { - typesCopy[k] = v.Copy(pbdb) - } - return &FileDescription{ - name: fd.name, - types: typesCopy, - enums: fd.enums, - } -} - -// GetName returns the fully qualified file path for the file. -func (fd *FileDescription) GetName() string { - return fd.name -} - -// GetEnumDescription returns an EnumDescription for a qualified enum value -// name declared within the .proto file. -func (fd *FileDescription) GetEnumDescription(enumName string) (*EnumValueDescription, bool) { - ed, found := fd.enums[sanitizeProtoName(enumName)] - return ed, found -} - -// GetEnumNames returns the string names of all enum values in the file. -func (fd *FileDescription) GetEnumNames() []string { - enumNames := make([]string, len(fd.enums)) - i := 0 - for _, e := range fd.enums { - enumNames[i] = e.Name() - i++ - } - return enumNames -} - -// GetTypeDescription returns a TypeDescription for a qualified protobuf message type name -// declared within the .proto file. -func (fd *FileDescription) GetTypeDescription(typeName string) (*TypeDescription, bool) { - td, found := fd.types[sanitizeProtoName(typeName)] - return td, found -} - -// GetTypeNames returns the list of all type names contained within the file. -func (fd *FileDescription) GetTypeNames() []string { - typeNames := make([]string, len(fd.types)) - i := 0 - for _, t := range fd.types { - typeNames[i] = t.Name() - i++ - } - return typeNames -} - -// sanitizeProtoName strips the leading '.' from the proto message name. -func sanitizeProtoName(name string) string { - if name != "" && name[0] == '.' { - return name[1:] - } - return name -} - -// fileMetadata is a flattened view of message types and enum values within a file descriptor. -type fileMetadata struct { - // msgTypes maps from fully-qualified message name to descriptor. - msgTypes map[string]protoreflect.MessageDescriptor - // enumValues maps from fully-qualified enum value to enum value descriptor. - enumValues map[string]protoreflect.EnumValueDescriptor - // msgExtensionMap maps from the protobuf message name being extended to a set of extensions - // for the type. - msgExtensionMap map[string][]protoreflect.ExtensionDescriptor - - // TODO: support enum type definitions for use in future type-check enhancements. -} - -// collectFileMetadata traverses the proto file object graph to collect message types and enum -// values and index them by their fully qualified names. -func collectFileMetadata(fileDesc protoreflect.FileDescriptor) *fileMetadata { - msgTypes := make(map[string]protoreflect.MessageDescriptor) - enumValues := make(map[string]protoreflect.EnumValueDescriptor) - msgExtensionMap := make(map[string][]protoreflect.ExtensionDescriptor) - collectMsgTypes(fileDesc.Messages(), msgTypes, enumValues, msgExtensionMap) - collectEnumValues(fileDesc.Enums(), enumValues) - collectExtensions(fileDesc.Extensions(), msgExtensionMap) - return &fileMetadata{ - msgTypes: msgTypes, - enumValues: enumValues, - msgExtensionMap: msgExtensionMap, - } -} - -// collectMsgTypes recursively collects messages, nested messages, and nested enums into a map of -// fully qualified protobuf names to descriptors. -func collectMsgTypes(msgTypes protoreflect.MessageDescriptors, - msgTypeMap map[string]protoreflect.MessageDescriptor, - enumValueMap map[string]protoreflect.EnumValueDescriptor, - msgExtensionMap map[string][]protoreflect.ExtensionDescriptor) { - for i := 0; i < msgTypes.Len(); i++ { - msgType := msgTypes.Get(i) - msgTypeMap[string(msgType.FullName())] = msgType - nestedMsgTypes := msgType.Messages() - if nestedMsgTypes.Len() != 0 { - collectMsgTypes(nestedMsgTypes, msgTypeMap, enumValueMap, msgExtensionMap) - } - nestedEnumTypes := msgType.Enums() - if nestedEnumTypes.Len() != 0 { - collectEnumValues(nestedEnumTypes, enumValueMap) - } - nestedExtensions := msgType.Extensions() - if nestedExtensions.Len() != 0 { - collectExtensions(nestedExtensions, msgExtensionMap) - } - } -} - -// collectEnumValues accumulates the enum values within an enum declaration. -func collectEnumValues(enumTypes protoreflect.EnumDescriptors, enumValueMap map[string]protoreflect.EnumValueDescriptor) { - for i := 0; i < enumTypes.Len(); i++ { - enumType := enumTypes.Get(i) - enumTypeValues := enumType.Values() - for j := 0; j < enumTypeValues.Len(); j++ { - enumValue := enumTypeValues.Get(j) - enumValueName := fmt.Sprintf("%s.%s", string(enumType.FullName()), string(enumValue.Name())) - enumValueMap[enumValueName] = enumValue - } - } -} - -func collectExtensions(extensions protoreflect.ExtensionDescriptors, msgExtensionMap map[string][]protoreflect.ExtensionDescriptor) { - for i := 0; i < extensions.Len(); i++ { - ext := extensions.Get(i) - extendsMsg := string(ext.ContainingMessage().FullName()) - msgExts, found := msgExtensionMap[extendsMsg] - if !found { - msgExts = []protoreflect.ExtensionDescriptor{} - } - msgExts = append(msgExts, ext) - msgExtensionMap[extendsMsg] = msgExts - } -} diff --git a/vendor/github.com/google/cel-go/common/types/pb/pb.go b/vendor/github.com/google/cel-go/common/types/pb/pb.go deleted file mode 100644 index eadebcb04..000000000 --- a/vendor/github.com/google/cel-go/common/types/pb/pb.go +++ /dev/null @@ -1,258 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package pb reflects over protocol buffer descriptors to generate objects -// that simplify type, enum, and field lookup. -package pb - -import ( - "fmt" - - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/reflect/protoreflect" - "google.golang.org/protobuf/reflect/protoregistry" - - anypb "google.golang.org/protobuf/types/known/anypb" - durpb "google.golang.org/protobuf/types/known/durationpb" - emptypb "google.golang.org/protobuf/types/known/emptypb" - structpb "google.golang.org/protobuf/types/known/structpb" - tspb "google.golang.org/protobuf/types/known/timestamppb" - wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" -) - -// Db maps from file / message / enum name to file description. -// -// Each Db is isolated from each other, and while information about protobuf descriptors may be -// fetched from the global protobuf registry, no descriptors are added to this registry, else -// the isolation guarantees of the Db object would be violated. -type Db struct { - revFileDescriptorMap map[string]*FileDescription - // files contains the deduped set of FileDescriptions whose types are contained in the pb.Db. - files []*FileDescription - // extensions contains the mapping between a given type name, extension name and its FieldDescription - extensions map[string]map[string]*FieldDescription -} - -// extensionsMap is a type alias to a map[typeName]map[extensionName]*FieldDescription -type extensionMap = map[string]map[string]*FieldDescription - -var ( - // DefaultDb used at evaluation time or unless overridden at check time. - DefaultDb = &Db{ - revFileDescriptorMap: make(map[string]*FileDescription), - files: []*FileDescription{}, - extensions: make(extensionMap), - } -) - -// Merge will copy the source proto message into the destination, or error if the merge cannot be completed. -// -// Unlike the proto.Merge, this method will fallback to proto.Marshal/Unmarshal of the two proto messages do not -// share the same instance of their type descriptor. -func Merge(dstPB, srcPB proto.Message) error { - src, dst := srcPB.ProtoReflect(), dstPB.ProtoReflect() - if src.Descriptor() == dst.Descriptor() { - proto.Merge(dstPB, srcPB) - return nil - } - if src.Descriptor().FullName() != dst.Descriptor().FullName() { - return fmt.Errorf("pb.Merge() arguments must be the same type. got: %v, %v", - dst.Descriptor().FullName(), src.Descriptor().FullName()) - } - bytes, err := proto.Marshal(srcPB) - if err != nil { - return fmt.Errorf("pb.Merge(dstPB, srcPB) failed to marshal source proto: %v", err) - } - err = proto.Unmarshal(bytes, dstPB) - if err != nil { - return fmt.Errorf("pb.Merge(dstPB, srcPB) failed to unmarshal to dest proto: %v", err) - } - return nil -} - -// NewDb creates a new `pb.Db` with an empty type name to file description map. -func NewDb() *Db { - pbdb := &Db{ - revFileDescriptorMap: make(map[string]*FileDescription), - files: []*FileDescription{}, - extensions: make(extensionMap), - } - // The FileDescription objects in the default db contain lazily initialized TypeDescription - // values which may point to the state contained in the DefaultDb irrespective of this shallow - // copy; however, the type graph for a field is idempotently computed, and is guaranteed to - // only be initialized once thanks to atomic values within the TypeDescription objects, so it - // is safe to share these values across instances. - for k, v := range DefaultDb.revFileDescriptorMap { - pbdb.revFileDescriptorMap[k] = v - } - pbdb.files = append(pbdb.files, DefaultDb.files...) - return pbdb -} - -// Copy creates a copy of the current database with its own internal descriptor mapping. -func (pbdb *Db) Copy() *Db { - copy := NewDb() - for _, fd := range pbdb.files { - hasFile := false - for _, fd2 := range copy.files { - if fd2 == fd { - hasFile = true - } - } - if !hasFile { - fd = fd.Copy(copy) - copy.files = append(copy.files, fd) - } - for _, enumValName := range fd.GetEnumNames() { - copy.revFileDescriptorMap[enumValName] = fd - } - for _, msgTypeName := range fd.GetTypeNames() { - copy.revFileDescriptorMap[msgTypeName] = fd - } - copy.revFileDescriptorMap[fd.GetName()] = fd - } - for typeName, extFieldMap := range pbdb.extensions { - copyExtFieldMap, found := copy.extensions[typeName] - if !found { - copyExtFieldMap = make(map[string]*FieldDescription, len(extFieldMap)) - } - for extFieldName, fd := range extFieldMap { - copyExtFieldMap[extFieldName] = fd - } - copy.extensions[typeName] = copyExtFieldMap - } - return copy -} - -// FileDescriptions returns the set of file descriptions associated with this db. -func (pbdb *Db) FileDescriptions() []*FileDescription { - return pbdb.files -} - -// RegisterDescriptor produces a `FileDescription` from a `FileDescriptor` and registers the -// message and enum types into the `pb.Db`. -func (pbdb *Db) RegisterDescriptor(fileDesc protoreflect.FileDescriptor) (*FileDescription, error) { - fd, found := pbdb.revFileDescriptorMap[fileDesc.Path()] - if found { - return fd, nil - } - // Make sure to search the global registry to see if a protoreflect.FileDescriptor for - // the file specified has been linked into the binary. If so, use the copy of the descriptor - // from the global cache. - // - // Note: Proto reflection relies on descriptor values being object equal rather than object - // equivalence. This choice means that a FieldDescriptor generated from a FileDescriptorProto - // will be incompatible with the FieldDescriptor in the global registry and any message created - // from that global registry. - globalFD, err := protoregistry.GlobalFiles.FindFileByPath(fileDesc.Path()) - if err == nil { - fileDesc = globalFD - } - var fileExtMap extensionMap - fd, fileExtMap = newFileDescription(fileDesc, pbdb) - for _, enumValName := range fd.GetEnumNames() { - pbdb.revFileDescriptorMap[enumValName] = fd - } - for _, msgTypeName := range fd.GetTypeNames() { - pbdb.revFileDescriptorMap[msgTypeName] = fd - } - pbdb.revFileDescriptorMap[fd.GetName()] = fd - - // Return the specific file descriptor registered. - pbdb.files = append(pbdb.files, fd) - - // Index the protobuf message extensions from the file into the pbdb - for typeName, extMap := range fileExtMap { - typeExtMap, found := pbdb.extensions[typeName] - if !found { - pbdb.extensions[typeName] = extMap - continue - } - for extName, field := range extMap { - typeExtMap[extName] = field - } - } - return fd, nil -} - -// RegisterMessage produces a `FileDescription` from a `message` and registers the message and all -// other definitions within the message file into the `pb.Db`. -func (pbdb *Db) RegisterMessage(message proto.Message) (*FileDescription, error) { - msgDesc := message.ProtoReflect().Descriptor() - msgName := msgDesc.FullName() - typeName := sanitizeProtoName(string(msgName)) - if fd, found := pbdb.revFileDescriptorMap[typeName]; found { - return fd, nil - } - return pbdb.RegisterDescriptor(msgDesc.ParentFile()) -} - -// DescribeEnum takes a qualified enum name and returns an `EnumDescription` if it exists in the -// `pb.Db`. -func (pbdb *Db) DescribeEnum(enumName string) (*EnumValueDescription, bool) { - enumName = sanitizeProtoName(enumName) - if fd, found := pbdb.revFileDescriptorMap[enumName]; found { - return fd.GetEnumDescription(enumName) - } - return nil, false -} - -// DescribeType returns a `TypeDescription` for the `typeName` if it exists in the `pb.Db`. -func (pbdb *Db) DescribeType(typeName string) (*TypeDescription, bool) { - typeName = sanitizeProtoName(typeName) - if fd, found := pbdb.revFileDescriptorMap[typeName]; found { - return fd.GetTypeDescription(typeName) - } - return nil, false -} - -// CollectFileDescriptorSet builds a file descriptor set associated with the file where the input -// message is declared. -func CollectFileDescriptorSet(message proto.Message) map[string]protoreflect.FileDescriptor { - fdMap := map[string]protoreflect.FileDescriptor{} - parentFile := message.ProtoReflect().Descriptor().ParentFile() - fdMap[parentFile.Path()] = parentFile - // Initialize list of dependencies - deps := make([]protoreflect.FileImport, parentFile.Imports().Len()) - for i := 0; i < parentFile.Imports().Len(); i++ { - deps[i] = parentFile.Imports().Get(i) - } - // Expand list for new dependencies - for i := 0; i < len(deps); i++ { - dep := deps[i] - if _, found := fdMap[dep.Path()]; found { - continue - } - fdMap[dep.Path()] = dep.FileDescriptor - for j := 0; j < dep.FileDescriptor.Imports().Len(); j++ { - deps = append(deps, dep.FileDescriptor.Imports().Get(j)) - } - } - return fdMap -} - -func init() { - // Describe well-known types to ensure they can always be resolved by the check and interpret - // execution phases. - // - // The following subset of message types is enough to ensure that all well-known types can - // resolved in the runtime, since describing the value results in describing the whole file - // where the message is declared. - DefaultDb.RegisterMessage(&anypb.Any{}) - DefaultDb.RegisterMessage(&durpb.Duration{}) - DefaultDb.RegisterMessage(&emptypb.Empty{}) - DefaultDb.RegisterMessage(&tspb.Timestamp{}) - DefaultDb.RegisterMessage(&structpb.Value{}) - DefaultDb.RegisterMessage(&wrapperspb.BoolValue{}) -} diff --git a/vendor/github.com/google/cel-go/common/types/pb/type.go b/vendor/github.com/google/cel-go/common/types/pb/type.go deleted file mode 100644 index 6cc95c276..000000000 --- a/vendor/github.com/google/cel-go/common/types/pb/type.go +++ /dev/null @@ -1,587 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package pb - -import ( - "fmt" - "reflect" - - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/reflect/protoreflect" - - exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1" - dynamicpb "google.golang.org/protobuf/types/dynamicpb" - anypb "google.golang.org/protobuf/types/known/anypb" - dpb "google.golang.org/protobuf/types/known/durationpb" - structpb "google.golang.org/protobuf/types/known/structpb" - tpb "google.golang.org/protobuf/types/known/timestamppb" - wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" -) - -// description is a private interface used to make it convenient to perform type unwrapping at -// the TypeDescription or FieldDescription level. -type description interface { - // Zero returns an empty immutable protobuf message when the description is a protobuf message - // type. - Zero() proto.Message -} - -// newTypeDescription produces a TypeDescription value for the fully-qualified proto type name -// with a given descriptor. -func newTypeDescription(typeName string, desc protoreflect.MessageDescriptor, extensions extensionMap) *TypeDescription { - msgType := dynamicpb.NewMessageType(desc) - msgZero := dynamicpb.NewMessage(desc) - fieldMap := map[string]*FieldDescription{} - fields := desc.Fields() - for i := 0; i < fields.Len(); i++ { - f := fields.Get(i) - fieldMap[string(f.Name())] = newFieldDescription(f) - } - return &TypeDescription{ - typeName: typeName, - desc: desc, - msgType: msgType, - fieldMap: fieldMap, - extensions: extensions, - reflectType: reflectTypeOf(msgZero), - zeroMsg: zeroValueOf(msgZero), - } -} - -// TypeDescription is a collection of type metadata relevant to expression -// checking and evaluation. -type TypeDescription struct { - typeName string - desc protoreflect.MessageDescriptor - msgType protoreflect.MessageType - fieldMap map[string]*FieldDescription - extensions extensionMap - reflectType reflect.Type - zeroMsg proto.Message -} - -// Copy copies the type description with updated references to the Db. -func (td *TypeDescription) Copy(pbdb *Db) *TypeDescription { - return &TypeDescription{ - typeName: td.typeName, - desc: td.desc, - msgType: td.msgType, - fieldMap: td.fieldMap, - extensions: pbdb.extensions, - reflectType: td.reflectType, - zeroMsg: td.zeroMsg, - } -} - -// FieldMap returns a string field name to FieldDescription map. -func (td *TypeDescription) FieldMap() map[string]*FieldDescription { - return td.fieldMap -} - -// FieldByName returns (FieldDescription, true) if the field name is declared within the type. -func (td *TypeDescription) FieldByName(name string) (*FieldDescription, bool) { - fd, found := td.fieldMap[name] - if found { - return fd, true - } - extFieldMap, found := td.extensions[td.typeName] - if !found { - return nil, false - } - fd, found = extFieldMap[name] - return fd, found -} - -// MaybeUnwrap accepts a proto message as input and unwraps it to a primitive CEL type if possible. -// -// This method returns the unwrapped value and 'true', else the original value and 'false'. -func (td *TypeDescription) MaybeUnwrap(msg proto.Message) (any, bool, error) { - return unwrap(td, msg) -} - -// Name returns the fully-qualified name of the type. -func (td *TypeDescription) Name() string { - return string(td.desc.FullName()) -} - -// New returns a mutable proto message -func (td *TypeDescription) New() protoreflect.Message { - return td.msgType.New() -} - -// ReflectType returns the Golang reflect.Type for this type. -func (td *TypeDescription) ReflectType() reflect.Type { - return td.reflectType -} - -// Zero returns the zero proto.Message value for this type. -func (td *TypeDescription) Zero() proto.Message { - return td.zeroMsg -} - -// newFieldDescription creates a new field description from a protoreflect.FieldDescriptor. -func newFieldDescription(fieldDesc protoreflect.FieldDescriptor) *FieldDescription { - var reflectType reflect.Type - var zeroMsg proto.Message - switch fieldDesc.Kind() { - case protoreflect.EnumKind: - reflectType = reflectTypeOf(protoreflect.EnumNumber(0)) - case protoreflect.GroupKind, protoreflect.MessageKind: - zeroMsg = dynamicpb.NewMessage(fieldDesc.Message()) - reflectType = reflectTypeOf(zeroMsg) - default: - reflectType = reflectTypeOf(fieldDesc.Default().Interface()) - if fieldDesc.IsList() { - var elemValue protoreflect.Value - if fieldDesc.IsExtension() { - et := dynamicpb.NewExtensionType(fieldDesc) - elemValue = et.New().List().NewElement() - } else { - parentMsgType := fieldDesc.ContainingMessage() - parentMsg := dynamicpb.NewMessage(parentMsgType) - listField := parentMsg.NewField(fieldDesc).List() - elemValue = listField.NewElement() - } - elem := elemValue.Interface() - switch elemType := elem.(type) { - case protoreflect.Message: - elem = elemType.Interface() - } - reflectType = reflectTypeOf(elem) - } - } - // Ensure the list type is appropriately reflected as a Go-native list. - if fieldDesc.IsList() { - reflectType = reflect.SliceOf(reflectType) - } - var keyType, valType *FieldDescription - if fieldDesc.IsMap() { - keyType = newFieldDescription(fieldDesc.MapKey()) - valType = newFieldDescription(fieldDesc.MapValue()) - } - return &FieldDescription{ - desc: fieldDesc, - KeyType: keyType, - ValueType: valType, - reflectType: reflectType, - zeroMsg: zeroValueOf(zeroMsg), - } -} - -// FieldDescription holds metadata related to fields declared within a type. -type FieldDescription struct { - // KeyType holds the key FieldDescription for map fields. - KeyType *FieldDescription - // ValueType holds the value FieldDescription for map fields. - ValueType *FieldDescription - - desc protoreflect.FieldDescriptor - reflectType reflect.Type - zeroMsg proto.Message -} - -// CheckedType returns the type-definition used at type-check time. -func (fd *FieldDescription) CheckedType() *exprpb.Type { - if fd.desc.IsMap() { - return &exprpb.Type{ - TypeKind: &exprpb.Type_MapType_{ - MapType: &exprpb.Type_MapType{ - KeyType: fd.KeyType.typeDefToType(), - ValueType: fd.ValueType.typeDefToType(), - }, - }, - } - } - if fd.desc.IsList() { - return &exprpb.Type{ - TypeKind: &exprpb.Type_ListType_{ - ListType: &exprpb.Type_ListType{ - ElemType: fd.typeDefToType()}}} - } - return fd.typeDefToType() -} - -// Descriptor returns the protoreflect.FieldDescriptor for this type. -func (fd *FieldDescription) Descriptor() protoreflect.FieldDescriptor { - return fd.desc -} - -// IsSet returns whether the field is set on the target value, per the proto presence conventions -// of proto2 or proto3 accordingly. -// -// This function implements the FieldType.IsSet function contract which can be used to operate on -// more than just protobuf field accesses; however, the target here must be a protobuf.Message. -func (fd *FieldDescription) IsSet(target any) bool { - switch v := target.(type) { - case proto.Message: - pbRef := v.ProtoReflect() - pbDesc := pbRef.Descriptor() - if pbDesc == fd.desc.ContainingMessage() { - // When the target protobuf shares the same message descriptor instance as the field - // descriptor, use the cached field descriptor value. - return pbRef.Has(fd.desc) - } - // Otherwise, fallback to a dynamic lookup of the field descriptor from the target - // instance as an attempt to use the cached field descriptor will result in a panic. - return pbRef.Has(pbDesc.Fields().ByName(protoreflect.Name(fd.Name()))) - default: - return false - } -} - -// GetFrom returns the accessor method associated with the field on the proto generated struct. -// -// If the field is not set, the proto default value is returned instead. -// -// This function implements the FieldType.GetFrom function contract which can be used to operate -// on more than just protobuf field accesses; however, the target here must be a protobuf.Message. -func (fd *FieldDescription) GetFrom(target any) (any, error) { - v, ok := target.(proto.Message) - if !ok { - return nil, fmt.Errorf("unsupported field selection target: (%T)%v", target, target) - } - pbRef := v.ProtoReflect() - pbDesc := pbRef.Descriptor() - var fieldVal any - if pbDesc == fd.desc.ContainingMessage() { - // When the target protobuf shares the same message descriptor instance as the field - // descriptor, use the cached field descriptor value. - fieldVal = pbRef.Get(fd.desc).Interface() - } else { - // Otherwise, fallback to a dynamic lookup of the field descriptor from the target - // instance as an attempt to use the cached field descriptor will result in a panic. - fieldVal = pbRef.Get(pbDesc.Fields().ByName(protoreflect.Name(fd.Name()))).Interface() - } - switch fv := fieldVal.(type) { - // Fast-path return for primitive types. - case bool, []byte, float32, float64, int32, int64, string, uint32, uint64, protoreflect.List: - return fv, nil - case protoreflect.EnumNumber: - return int64(fv), nil - case protoreflect.Map: - // Return a wrapper around the protobuf-reflected Map types which carries additional - // information about the key and value definitions of the map. - return &Map{Map: fv, KeyType: fd.KeyType, ValueType: fd.ValueType}, nil - case protoreflect.Message: - // Make sure to unwrap well-known protobuf types before returning. - unwrapped, _, err := fd.MaybeUnwrapDynamic(fv) - return unwrapped, err - default: - return fv, nil - } -} - -// IsEnum returns true if the field type refers to an enum value. -func (fd *FieldDescription) IsEnum() bool { - return fd.ProtoKind() == protoreflect.EnumKind -} - -// IsMap returns true if the field is of map type. -func (fd *FieldDescription) IsMap() bool { - return fd.desc.IsMap() -} - -// IsMessage returns true if the field is of message type. -func (fd *FieldDescription) IsMessage() bool { - kind := fd.ProtoKind() - return kind == protoreflect.MessageKind || kind == protoreflect.GroupKind -} - -// IsOneof returns true if the field is declared within a oneof block. -func (fd *FieldDescription) IsOneof() bool { - return fd.desc.ContainingOneof() != nil -} - -// IsList returns true if the field is a repeated value. -// -// This method will also return true for map values, so check whether the -// field is also a map. -func (fd *FieldDescription) IsList() bool { - return fd.desc.IsList() -} - -// MaybeUnwrapDynamic takes the reflected protoreflect.Message and determines whether the -// value can be unwrapped to a more primitive CEL type. -// -// This function returns the unwrapped value and 'true' on success, or the original value -// and 'false' otherwise. -func (fd *FieldDescription) MaybeUnwrapDynamic(msg protoreflect.Message) (any, bool, error) { - return unwrapDynamic(fd, msg) -} - -// Name returns the CamelCase name of the field within the proto-based struct. -func (fd *FieldDescription) Name() string { - return string(fd.desc.Name()) -} - -// ProtoKind returns the protobuf reflected kind of the field. -func (fd *FieldDescription) ProtoKind() protoreflect.Kind { - return fd.desc.Kind() -} - -// ReflectType returns the Golang reflect.Type for this field. -func (fd *FieldDescription) ReflectType() reflect.Type { - return fd.reflectType -} - -// String returns the fully qualified name of the field within its type as well as whether the -// field occurs within a oneof. -func (fd *FieldDescription) String() string { - return fmt.Sprintf("%v.%s `oneof=%t`", fd.desc.ContainingMessage().FullName(), fd.Name(), fd.IsOneof()) -} - -// Zero returns the zero value for the protobuf message represented by this field. -// -// If the field is not a proto.Message type, the zero value is nil. -func (fd *FieldDescription) Zero() proto.Message { - return fd.zeroMsg -} - -func (fd *FieldDescription) typeDefToType() *exprpb.Type { - if fd.IsMessage() { - msgType := string(fd.desc.Message().FullName()) - if wk, found := CheckedWellKnowns[msgType]; found { - return wk - } - return checkedMessageType(msgType) - } - if fd.IsEnum() { - return checkedInt - } - return CheckedPrimitives[fd.ProtoKind()] -} - -// Map wraps the protoreflect.Map object with a key and value FieldDescription for use in -// retrieving individual elements within CEL value data types. -type Map struct { - protoreflect.Map - KeyType *FieldDescription - ValueType *FieldDescription -} - -func checkedMessageType(name string) *exprpb.Type { - return &exprpb.Type{ - TypeKind: &exprpb.Type_MessageType{MessageType: name}} -} - -func checkedPrimitive(primitive exprpb.Type_PrimitiveType) *exprpb.Type { - return &exprpb.Type{ - TypeKind: &exprpb.Type_Primitive{Primitive: primitive}} -} - -func checkedWellKnown(wellKnown exprpb.Type_WellKnownType) *exprpb.Type { - return &exprpb.Type{ - TypeKind: &exprpb.Type_WellKnown{WellKnown: wellKnown}} -} - -func checkedWrap(t *exprpb.Type) *exprpb.Type { - return &exprpb.Type{ - TypeKind: &exprpb.Type_Wrapper{Wrapper: t.GetPrimitive()}} -} - -// unwrap unwraps the provided proto.Message value, potentially based on the description if the -// input message is a *dynamicpb.Message which obscures the typing information from Go. -// -// Returns the unwrapped value and 'true' if unwrapped, otherwise the input value and 'false'. -func unwrap(desc description, msg proto.Message) (any, bool, error) { - switch v := msg.(type) { - case *anypb.Any: - dynMsg, err := v.UnmarshalNew() - if err != nil { - return v, false, err - } - return unwrapDynamic(desc, dynMsg.ProtoReflect()) - case *dynamicpb.Message: - return unwrapDynamic(desc, v) - case *dpb.Duration: - return v.AsDuration(), true, nil - case *tpb.Timestamp: - return v.AsTime(), true, nil - case *structpb.Value: - switch v.GetKind().(type) { - case *structpb.Value_BoolValue: - return v.GetBoolValue(), true, nil - case *structpb.Value_ListValue: - return v.GetListValue(), true, nil - case *structpb.Value_NullValue: - return structpb.NullValue_NULL_VALUE, true, nil - case *structpb.Value_NumberValue: - return v.GetNumberValue(), true, nil - case *structpb.Value_StringValue: - return v.GetStringValue(), true, nil - case *structpb.Value_StructValue: - return v.GetStructValue(), true, nil - default: - return structpb.NullValue_NULL_VALUE, true, nil - } - case *wrapperspb.BoolValue: - return v.GetValue(), true, nil - case *wrapperspb.BytesValue: - return v.GetValue(), true, nil - case *wrapperspb.DoubleValue: - return v.GetValue(), true, nil - case *wrapperspb.FloatValue: - return float64(v.GetValue()), true, nil - case *wrapperspb.Int32Value: - return int64(v.GetValue()), true, nil - case *wrapperspb.Int64Value: - return v.GetValue(), true, nil - case *wrapperspb.StringValue: - return v.GetValue(), true, nil - case *wrapperspb.UInt32Value: - return uint64(v.GetValue()), true, nil - case *wrapperspb.UInt64Value: - return v.GetValue(), true, nil - } - return msg, false, nil -} - -// unwrapDynamic unwraps a reflected protobuf Message value. -// -// Returns the unwrapped value and 'true' if unwrapped, otherwise the input value and 'false'. -func unwrapDynamic(desc description, refMsg protoreflect.Message) (any, bool, error) { - msg := refMsg.Interface() - if !refMsg.IsValid() { - msg = desc.Zero() - } - // In order to ensure that these wrapped types match the expectations of the CEL type system - // the dynamicpb.Message must be merged with an protobuf instance of the well-known type value. - typeName := string(refMsg.Descriptor().FullName()) - switch typeName { - case "google.protobuf.Any": - // Note, Any values require further unwrapping; however, this unwrapping may or may not - // be to a well-known type. If the unwrapped value is a well-known type it will be further - // unwrapped before being returned to the caller. Otherwise, the dynamic protobuf object - // represented by the Any will be returned. - unwrappedAny := &anypb.Any{} - err := Merge(unwrappedAny, msg) - if err != nil { - return nil, false, fmt.Errorf("unwrap dynamic field failed: %v", err) - } - dynMsg, err := unwrappedAny.UnmarshalNew() - if err != nil { - // Allow the error to move further up the stack as it should result in an type - // conversion error if the caller does not recover it somehow. - return nil, false, fmt.Errorf("unmarshal dynamic any failed: %v", err) - } - // Attempt to unwrap the dynamic type, otherwise return the dynamic message. - unwrapped, nested, err := unwrapDynamic(desc, dynMsg.ProtoReflect()) - if err == nil && nested { - return unwrapped, true, nil - } - return dynMsg, true, err - case "google.protobuf.BoolValue", - "google.protobuf.BytesValue", - "google.protobuf.DoubleValue", - "google.protobuf.FloatValue", - "google.protobuf.Int32Value", - "google.protobuf.Int64Value", - "google.protobuf.StringValue", - "google.protobuf.UInt32Value", - "google.protobuf.UInt64Value": - // The msg value is ignored when dealing with wrapper types as they have a null or value - // behavior, rather than the standard zero value behavior of other proto message types. - if !refMsg.IsValid() { - return structpb.NullValue_NULL_VALUE, true, nil - } - valueField := refMsg.Descriptor().Fields().ByName("value") - return refMsg.Get(valueField).Interface(), true, nil - case "google.protobuf.Duration": - unwrapped := &dpb.Duration{} - err := Merge(unwrapped, msg) - if err != nil { - return nil, false, err - } - return unwrapped.AsDuration(), true, nil - case "google.protobuf.ListValue": - unwrapped := &structpb.ListValue{} - err := Merge(unwrapped, msg) - if err != nil { - return nil, false, err - } - return unwrapped, true, nil - case "google.protobuf.NullValue": - return structpb.NullValue_NULL_VALUE, true, nil - case "google.protobuf.Struct": - unwrapped := &structpb.Struct{} - err := Merge(unwrapped, msg) - if err != nil { - return nil, false, err - } - return unwrapped, true, nil - case "google.protobuf.Timestamp": - unwrapped := &tpb.Timestamp{} - err := Merge(unwrapped, msg) - if err != nil { - return nil, false, err - } - return unwrapped.AsTime(), true, nil - case "google.protobuf.Value": - unwrapped := &structpb.Value{} - err := Merge(unwrapped, msg) - if err != nil { - return nil, false, err - } - return unwrap(desc, unwrapped) - } - return msg, false, nil -} - -// reflectTypeOf intercepts the reflect.Type call to ensure that dynamicpb.Message types preserve -// well-known protobuf reflected types expected by the CEL type system. -func reflectTypeOf(val any) reflect.Type { - switch v := val.(type) { - case proto.Message: - return reflect.TypeOf(zeroValueOf(v)) - default: - return reflect.TypeOf(v) - } -} - -// zeroValueOf will return the strongest possible proto.Message representing the default protobuf -// message value of the input msg type. -func zeroValueOf(msg proto.Message) proto.Message { - if msg == nil { - return nil - } - typeName := string(msg.ProtoReflect().Descriptor().FullName()) - zeroVal, found := zeroValueMap[typeName] - if found { - return zeroVal - } - return msg -} - -var ( - jsonValueTypeURL = "types.googleapis.com/google.protobuf.Value" - - zeroValueMap = map[string]proto.Message{ - "google.protobuf.Any": &anypb.Any{TypeUrl: jsonValueTypeURL}, - "google.protobuf.Duration": &dpb.Duration{}, - "google.protobuf.ListValue": &structpb.ListValue{}, - "google.protobuf.Struct": &structpb.Struct{}, - "google.protobuf.Timestamp": &tpb.Timestamp{}, - "google.protobuf.Value": &structpb.Value{}, - "google.protobuf.BoolValue": wrapperspb.Bool(false), - "google.protobuf.BytesValue": wrapperspb.Bytes([]byte{}), - "google.protobuf.DoubleValue": wrapperspb.Double(0.0), - "google.protobuf.FloatValue": wrapperspb.Float(0.0), - "google.protobuf.Int32Value": wrapperspb.Int32(0), - "google.protobuf.Int64Value": wrapperspb.Int64(0), - "google.protobuf.StringValue": wrapperspb.String(""), - "google.protobuf.UInt32Value": wrapperspb.UInt32(0), - "google.protobuf.UInt64Value": wrapperspb.UInt64(0), - } -) diff --git a/vendor/github.com/google/cel-go/common/types/provider.go b/vendor/github.com/google/cel-go/common/types/provider.go deleted file mode 100644 index d301aa38a..000000000 --- a/vendor/github.com/google/cel-go/common/types/provider.go +++ /dev/null @@ -1,734 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - "reflect" - "time" - - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/reflect/protoreflect" - - "github.com/google/cel-go/common/types/pb" - "github.com/google/cel-go/common/types/ref" - "github.com/google/cel-go/common/types/traits" - - exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1" - anypb "google.golang.org/protobuf/types/known/anypb" - dpb "google.golang.org/protobuf/types/known/durationpb" - structpb "google.golang.org/protobuf/types/known/structpb" - tpb "google.golang.org/protobuf/types/known/timestamppb" -) - -// Adapter converts native Go values of varying type and complexity to equivalent CEL values. -type Adapter = ref.TypeAdapter - -// Provider specifies functions for creating new object instances and for resolving -// enum values by name. -type Provider interface { - // EnumValue returns the numeric value of the given enum value name. - EnumValue(enumName string) ref.Val - - // FindIdent takes a qualified identifier name and returns a ref.Val if one exists. - FindIdent(identName string) (ref.Val, bool) - - // FindStructType returns the Type give a qualified type name. - // - // For historical reasons, only struct types are expected to be returned through this - // method, and the type values are expected to be wrapped in a TypeType instance using - // TypeTypeWithParam(). - // - // Returns false if not found. - FindStructType(structType string) (*Type, bool) - - // FindStructFieldNames returns thet field names associated with the type, if the type - // is found. - FindStructFieldNames(structType string) ([]string, bool) - - // FieldStructFieldType returns the field type for a checked type value. Returns - // false if the field could not be found. - FindStructFieldType(structType, fieldName string) (*FieldType, bool) - - // NewValue creates a new type value from a qualified name and map of field - // name to value. - // - // Note, for each value, the Val.ConvertToNative function will be invoked - // to convert the Val to the field's native type. If an error occurs during - // conversion, the NewValue will be a types.Err. - NewValue(structType string, fields map[string]ref.Val) ref.Val -} - -// FieldType represents a field's type value and whether that field supports presence detection. -type FieldType struct { - // Type of the field as a CEL native type value. - Type *Type - - // IsSet indicates whether the field is set on an input object. - IsSet ref.FieldTester - - // GetFrom retrieves the field value on the input object, if set. - GetFrom ref.FieldGetter -} - -// Registry provides type information for a set of registered types. -type Registry struct { - revTypeMap map[string]*Type - pbdb *pb.Db -} - -// NewRegistry accepts a list of proto message instances and returns a type -// provider which can create new instances of the provided message or any -// message that proto depends upon in its FileDescriptor. -func NewRegistry(types ...proto.Message) (*Registry, error) { - p := &Registry{ - revTypeMap: make(map[string]*Type), - pbdb: pb.NewDb(), - } - err := p.RegisterType( - BoolType, - BytesType, - DoubleType, - DurationType, - IntType, - ListType, - MapType, - NullType, - StringType, - TimestampType, - TypeType, - UintType) - if err != nil { - return nil, err - } - // This block ensures that the well-known protobuf types are registered by default. - for _, fd := range p.pbdb.FileDescriptions() { - err = p.registerAllTypes(fd) - if err != nil { - return nil, err - } - } - for _, msgType := range types { - err = p.RegisterMessage(msgType) - if err != nil { - return nil, err - } - } - return p, nil -} - -// NewEmptyRegistry returns a registry which is completely unconfigured. -func NewEmptyRegistry() *Registry { - return &Registry{ - revTypeMap: make(map[string]*Type), - pbdb: pb.NewDb(), - } -} - -// Copy copies the current state of the registry into its own memory space. -func (p *Registry) Copy() *Registry { - copy := &Registry{ - revTypeMap: make(map[string]*Type), - pbdb: p.pbdb.Copy(), - } - for k, v := range p.revTypeMap { - copy.revTypeMap[k] = v - } - return copy -} - -// EnumValue returns the numeric value of the given enum value name. -func (p *Registry) EnumValue(enumName string) ref.Val { - enumVal, found := p.pbdb.DescribeEnum(enumName) - if !found { - return NewErr("unknown enum name '%s'", enumName) - } - return Int(enumVal.Value()) -} - -// FindFieldType returns the field type for a checked type value. Returns false if -// the field could not be found. -// -// Deprecated: use FindStructFieldType -func (p *Registry) FindFieldType(structType, fieldName string) (*ref.FieldType, bool) { - msgType, found := p.pbdb.DescribeType(structType) - if !found { - return nil, false - } - field, found := msgType.FieldByName(fieldName) - if !found { - return nil, false - } - return &ref.FieldType{ - Type: field.CheckedType(), - IsSet: field.IsSet, - GetFrom: field.GetFrom}, true -} - -// FindStructFieldNames returns the set of field names for the given struct type, -// if the type exists in the registry. -func (p *Registry) FindStructFieldNames(structType string) ([]string, bool) { - msgType, found := p.pbdb.DescribeType(structType) - if !found { - return []string{}, false - } - fieldMap := msgType.FieldMap() - fields := make([]string, len(fieldMap)) - idx := 0 - for f := range fieldMap { - fields[idx] = f - idx++ - } - return fields, true -} - -// FindStructFieldType returns the field type for a checked type value. Returns -// false if the field could not be found. -func (p *Registry) FindStructFieldType(structType, fieldName string) (*FieldType, bool) { - msgType, found := p.pbdb.DescribeType(structType) - if !found { - return nil, false - } - field, found := msgType.FieldByName(fieldName) - if !found { - return nil, false - } - return &FieldType{ - Type: fieldDescToCELType(field), - IsSet: field.IsSet, - GetFrom: field.GetFrom}, true -} - -// FindIdent takes a qualified identifier name and returns a ref.Val if one exists. -func (p *Registry) FindIdent(identName string) (ref.Val, bool) { - if t, found := p.revTypeMap[identName]; found { - return t, true - } - if enumVal, found := p.pbdb.DescribeEnum(identName); found { - return Int(enumVal.Value()), true - } - return nil, false -} - -// FindType looks up the Type given a qualified typeName. Returns false if not found. -// -// Deprecated: use FindStructType -func (p *Registry) FindType(structType string) (*exprpb.Type, bool) { - if _, found := p.pbdb.DescribeType(structType); !found { - return nil, false - } - if structType != "" && structType[0] == '.' { - structType = structType[1:] - } - return &exprpb.Type{ - TypeKind: &exprpb.Type_Type{ - Type: &exprpb.Type{ - TypeKind: &exprpb.Type_MessageType{ - MessageType: structType}}}}, true -} - -// FindStructType returns the Type give a qualified type name. -// -// For historical reasons, only struct types are expected to be returned through this -// method, and the type values are expected to be wrapped in a TypeType instance using -// TypeTypeWithParam(). -// -// Returns false if not found. -func (p *Registry) FindStructType(structType string) (*Type, bool) { - if _, found := p.pbdb.DescribeType(structType); !found { - return nil, false - } - if structType != "" && structType[0] == '.' { - structType = structType[1:] - } - return NewTypeTypeWithParam(NewObjectType(structType)), true -} - -// NewValue creates a new type value from a qualified name and map of field -// name to value. -// -// Note, for each value, the Val.ConvertToNative function will be invoked -// to convert the Val to the field's native type. If an error occurs during -// conversion, the NewValue will be a types.Err. -func (p *Registry) NewValue(structType string, fields map[string]ref.Val) ref.Val { - td, found := p.pbdb.DescribeType(structType) - if !found { - return NewErr("unknown type '%s'", structType) - } - msg := td.New() - fieldMap := td.FieldMap() - for name, value := range fields { - field, found := fieldMap[name] - if !found { - return NewErr("no such field: %s", name) - } - err := msgSetField(msg, field, value) - if err != nil { - return &Err{err} - } - } - return p.NativeToValue(msg.Interface()) -} - -// RegisterDescriptor registers the contents of a protocol buffer `FileDescriptor`. -func (p *Registry) RegisterDescriptor(fileDesc protoreflect.FileDescriptor) error { - fd, err := p.pbdb.RegisterDescriptor(fileDesc) - if err != nil { - return err - } - return p.registerAllTypes(fd) -} - -// RegisterMessage registers a protocol buffer message and its dependencies. -func (p *Registry) RegisterMessage(message proto.Message) error { - fd, err := p.pbdb.RegisterMessage(message) - if err != nil { - return err - } - return p.registerAllTypes(fd) -} - -// RegisterType registers a type value with the provider which ensures the provider is aware of how to -// map the type to an identifier. -// -// If the `ref.Type` value is a `*types.Type` it will be registered directly by its runtime type name. -// If the `ref.Type` value is not a `*types.Type` instance, a `*types.Type` instance which reflects the -// traits present on the input and the runtime type name. By default this foreign type will be treated -// as a types.StructKind. To avoid potential issues where the `ref.Type` values does not match the -// generated `*types.Type` instance, consider always using the `*types.Type` to represent type extensions -// to CEL, even when they're not based on protobuf types. -func (p *Registry) RegisterType(types ...ref.Type) error { - for _, t := range types { - celType := maybeForeignType(t) - existing, found := p.revTypeMap[t.TypeName()] - if !found { - p.revTypeMap[t.TypeName()] = celType - continue - } - if !existing.IsEquivalentType(celType) { - return fmt.Errorf("type registration conflict. found: %v, input: %v", existing, celType) - } - if existing.traitMask != celType.traitMask { - return fmt.Errorf( - "type registered with conflicting traits: %v with traits %v, input: %v", - existing.TypeName(), existing.traitMask, celType.traitMask) - } - } - return nil -} - -// NativeToValue converts various "native" types to ref.Val with this specific implementation -// providing support for custom proto-based types. -// -// This method should be the inverse of ref.Val.ConvertToNative. -func (p *Registry) NativeToValue(value any) ref.Val { - if val, found := nativeToValue(p, value); found { - return val - } - switch v := value.(type) { - case proto.Message: - typeName := string(v.ProtoReflect().Descriptor().FullName()) - td, found := p.pbdb.DescribeType(typeName) - if !found { - return NewErr("unknown type: '%s'", typeName) - } - unwrapped, isUnwrapped, err := td.MaybeUnwrap(v) - if err != nil { - return UnsupportedRefValConversionErr(v) - } - if isUnwrapped { - return p.NativeToValue(unwrapped) - } - typeVal, found := p.FindIdent(typeName) - if !found { - return NewErr("unknown type: '%s'", typeName) - } - return NewObject(p, td, typeVal, v) - case *pb.Map: - return NewProtoMap(p, v) - case protoreflect.List: - return NewProtoList(p, v) - case protoreflect.Message: - return p.NativeToValue(v.Interface()) - case protoreflect.Value: - return p.NativeToValue(v.Interface()) - } - return UnsupportedRefValConversionErr(value) -} - -func (p *Registry) registerAllTypes(fd *pb.FileDescription) error { - for _, typeName := range fd.GetTypeNames() { - // skip well-known type names since they're automatically sanitized - // during NewObjectType() calls. - if _, found := checkedWellKnowns[typeName]; found { - continue - } - err := p.RegisterType(NewObjectTypeValue(typeName)) - if err != nil { - return err - } - } - return nil -} - -func fieldDescToCELType(field *pb.FieldDescription) *Type { - if field.IsMap() { - return NewMapType( - singularFieldDescToCELType(field.KeyType), - singularFieldDescToCELType(field.ValueType)) - } - if field.IsList() { - return NewListType(singularFieldDescToCELType(field)) - } - return singularFieldDescToCELType(field) -} - -func singularFieldDescToCELType(field *pb.FieldDescription) *Type { - if field.IsMessage() { - return NewObjectType(string(field.Descriptor().Message().FullName())) - } - if field.IsEnum() { - return IntType - } - return ProtoCELPrimitives[field.ProtoKind()] -} - -// defaultTypeAdapter converts go native types to CEL values. -type defaultTypeAdapter struct{} - -var ( - // DefaultTypeAdapter adapts canonical CEL types from their equivalent Go values. - DefaultTypeAdapter = &defaultTypeAdapter{} -) - -// NativeToValue implements the ref.TypeAdapter interface. -func (a *defaultTypeAdapter) NativeToValue(value any) ref.Val { - if val, found := nativeToValue(a, value); found { - return val - } - return UnsupportedRefValConversionErr(value) -} - -// nativeToValue returns the converted (ref.Val, true) of a conversion is found, -// otherwise (nil, false) -func nativeToValue(a Adapter, value any) (ref.Val, bool) { - switch v := value.(type) { - case nil: - return NullValue, true - case *Bool: - if v != nil { - return *v, true - } - case *Bytes: - if v != nil { - return *v, true - } - case *Double: - if v != nil { - return *v, true - } - case *Int: - if v != nil { - return *v, true - } - case *String: - if v != nil { - return *v, true - } - case *Uint: - if v != nil { - return *v, true - } - case bool: - return Bool(v), true - case int: - return Int(v), true - case int32: - return Int(v), true - case int64: - return Int(v), true - case uint: - return Uint(v), true - case uint32: - return Uint(v), true - case uint64: - return Uint(v), true - case float32: - return Double(v), true - case float64: - return Double(v), true - case string: - return String(v), true - case *dpb.Duration: - return Duration{Duration: v.AsDuration()}, true - case time.Duration: - return Duration{Duration: v}, true - case *tpb.Timestamp: - return Timestamp{Time: v.AsTime()}, true - case time.Time: - return Timestamp{Time: v}, true - case *bool: - if v != nil { - return Bool(*v), true - } - case *float32: - if v != nil { - return Double(*v), true - } - case *float64: - if v != nil { - return Double(*v), true - } - case *int: - if v != nil { - return Int(*v), true - } - case *int32: - if v != nil { - return Int(*v), true - } - case *int64: - if v != nil { - return Int(*v), true - } - case *string: - if v != nil { - return String(*v), true - } - case *uint: - if v != nil { - return Uint(*v), true - } - case *uint32: - if v != nil { - return Uint(*v), true - } - case *uint64: - if v != nil { - return Uint(*v), true - } - case []byte: - return Bytes(v), true - // specializations for common lists types. - case []string: - return NewStringList(a, v), true - case []ref.Val: - return NewRefValList(a, v), true - // specializations for common map types. - case map[string]string: - return NewStringStringMap(a, v), true - case map[string]any: - return NewStringInterfaceMap(a, v), true - case map[ref.Val]ref.Val: - return NewRefValMap(a, v), true - // additional specializations may be added upon request / need. - case *anypb.Any: - if v == nil { - return UnsupportedRefValConversionErr(v), true - } - unpackedAny, err := v.UnmarshalNew() - if err != nil { - return NewErr("anypb.UnmarshalNew() failed for type %q: %v", v.GetTypeUrl(), err), true - } - return a.NativeToValue(unpackedAny), true - case *structpb.NullValue, structpb.NullValue: - return NullValue, true - case *structpb.ListValue: - return NewJSONList(a, v), true - case *structpb.Struct: - return NewJSONStruct(a, v), true - case ref.Val: - return v, true - case protoreflect.EnumNumber: - return Int(v), true - case proto.Message: - if v == nil { - return UnsupportedRefValConversionErr(v), true - } - typeName := string(v.ProtoReflect().Descriptor().FullName()) - td, found := pb.DefaultDb.DescribeType(typeName) - if !found { - return nil, false - } - val, unwrapped, err := td.MaybeUnwrap(v) - if err != nil { - return UnsupportedRefValConversionErr(v), true - } - if !unwrapped { - return nil, false - } - return a.NativeToValue(val), true - // Note: dynamicpb.Message implements the proto.Message _and_ protoreflect.Message interfaces - // which means that this case must appear after handling a proto.Message type. - case protoreflect.Message: - return a.NativeToValue(v.Interface()), true - default: - refValue := reflect.ValueOf(v) - if refValue.Kind() == reflect.Ptr { - if refValue.IsNil() { - return UnsupportedRefValConversionErr(v), true - } - refValue = refValue.Elem() - } - refKind := refValue.Kind() - switch refKind { - case reflect.Array, reflect.Slice: - return NewDynamicList(a, v), true - case reflect.Map: - return NewDynamicMap(a, v), true - // type aliases of primitive types cannot be asserted as that type, but rather need - // to be downcast to int32 before being converted to a CEL representation. - case reflect.Int32: - intType := reflect.TypeOf(int32(0)) - return Int(refValue.Convert(intType).Interface().(int32)), true - case reflect.Int64: - intType := reflect.TypeOf(int64(0)) - return Int(refValue.Convert(intType).Interface().(int64)), true - case reflect.Uint32: - uintType := reflect.TypeOf(uint32(0)) - return Uint(refValue.Convert(uintType).Interface().(uint32)), true - case reflect.Uint64: - uintType := reflect.TypeOf(uint64(0)) - return Uint(refValue.Convert(uintType).Interface().(uint64)), true - case reflect.Float32: - doubleType := reflect.TypeOf(float32(0)) - return Double(refValue.Convert(doubleType).Interface().(float32)), true - case reflect.Float64: - doubleType := reflect.TypeOf(float64(0)) - return Double(refValue.Convert(doubleType).Interface().(float64)), true - } - } - return nil, false -} - -func msgSetField(target protoreflect.Message, field *pb.FieldDescription, val ref.Val) error { - if field.IsList() { - lv := target.NewField(field.Descriptor()) - list, ok := val.(traits.Lister) - if !ok { - return unsupportedTypeConversionError(field, val) - } - err := msgSetListField(lv.List(), field, list) - if err != nil { - return err - } - target.Set(field.Descriptor(), lv) - return nil - } - if field.IsMap() { - mv := target.NewField(field.Descriptor()) - mp, ok := val.(traits.Mapper) - if !ok { - return unsupportedTypeConversionError(field, val) - } - err := msgSetMapField(mv.Map(), field, mp) - if err != nil { - return err - } - target.Set(field.Descriptor(), mv) - return nil - } - v, err := val.ConvertToNative(field.ReflectType()) - if err != nil { - return fieldTypeConversionError(field, err) - } - if v == nil { - return nil - } - switch pv := v.(type) { - case proto.Message: - v = pv.ProtoReflect() - } - target.Set(field.Descriptor(), protoreflect.ValueOf(v)) - return nil -} - -func msgSetListField(target protoreflect.List, listField *pb.FieldDescription, listVal traits.Lister) error { - elemReflectType := listField.ReflectType().Elem() - for i := Int(0); i < listVal.Size().(Int); i++ { - elem := listVal.Get(i) - elemVal, err := elem.ConvertToNative(elemReflectType) - if err != nil { - return fieldTypeConversionError(listField, err) - } - if elemVal == nil { - continue - } - switch ev := elemVal.(type) { - case proto.Message: - elemVal = ev.ProtoReflect() - } - target.Append(protoreflect.ValueOf(elemVal)) - } - return nil -} - -func msgSetMapField(target protoreflect.Map, mapField *pb.FieldDescription, mapVal traits.Mapper) error { - targetKeyType := mapField.KeyType.ReflectType() - targetValType := mapField.ValueType.ReflectType() - it := mapVal.Iterator() - for it.HasNext() == True { - key := it.Next() - val := mapVal.Get(key) - k, err := key.ConvertToNative(targetKeyType) - if err != nil { - return fieldTypeConversionError(mapField, err) - } - v, err := val.ConvertToNative(targetValType) - if err != nil { - return fieldTypeConversionError(mapField, err) - } - if v == nil { - continue - } - switch pv := v.(type) { - case proto.Message: - v = pv.ProtoReflect() - } - target.Set(protoreflect.ValueOf(k).MapKey(), protoreflect.ValueOf(v)) - } - return nil -} - -func unsupportedTypeConversionError(field *pb.FieldDescription, val ref.Val) error { - msgName := field.Descriptor().ContainingMessage().FullName() - return fmt.Errorf("unsupported field type for %v.%v: %v", msgName, field.Name(), val.Type()) -} - -func fieldTypeConversionError(field *pb.FieldDescription, err error) error { - msgName := field.Descriptor().ContainingMessage().FullName() - return fmt.Errorf("field type conversion error for %v.%v value type: %v", msgName, field.Name(), err) -} - -var ( - // ProtoCELPrimitives provides a map from the protoreflect Kind to the equivalent CEL type. - ProtoCELPrimitives = map[protoreflect.Kind]*Type{ - protoreflect.BoolKind: BoolType, - protoreflect.BytesKind: BytesType, - protoreflect.DoubleKind: DoubleType, - protoreflect.FloatKind: DoubleType, - protoreflect.Int32Kind: IntType, - protoreflect.Int64Kind: IntType, - protoreflect.Sint32Kind: IntType, - protoreflect.Sint64Kind: IntType, - protoreflect.Uint32Kind: UintType, - protoreflect.Uint64Kind: UintType, - protoreflect.Fixed32Kind: UintType, - protoreflect.Fixed64Kind: UintType, - protoreflect.Sfixed32Kind: IntType, - protoreflect.Sfixed64Kind: IntType, - protoreflect.StringKind: StringType, - } -) diff --git a/vendor/github.com/google/cel-go/common/types/ref/BUILD.bazel b/vendor/github.com/google/cel-go/common/types/ref/BUILD.bazel deleted file mode 100644 index 79330c332..000000000 --- a/vendor/github.com/google/cel-go/common/types/ref/BUILD.bazel +++ /dev/null @@ -1,20 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -package( - default_visibility = ["//visibility:public"], - licenses = ["notice"], # Apache 2.0 -) - -go_library( - name = "go_default_library", - srcs = [ - "provider.go", - "reference.go", - ], - importpath = "github.com/google/cel-go/common/types/ref", - deps = [ - "@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library", - "@org_golang_google_protobuf//proto:go_default_library", - "@org_golang_google_protobuf//reflect/protoreflect:go_default_library", - ], -) diff --git a/vendor/github.com/google/cel-go/common/types/ref/provider.go b/vendor/github.com/google/cel-go/common/types/ref/provider.go deleted file mode 100644 index b9820023d..000000000 --- a/vendor/github.com/google/cel-go/common/types/ref/provider.go +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ref - -import ( - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/reflect/protoreflect" - - exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1" -) - -// TypeProvider specifies functions for creating new object instances and for -// resolving enum values by name. -// -// Deprecated: use types.Provider -type TypeProvider interface { - // EnumValue returns the numeric value of the given enum value name. - EnumValue(enumName string) Val - - // FindIdent takes a qualified identifier name and returns a Value if one exists. - FindIdent(identName string) (Val, bool) - - // FindType looks up the Type given a qualified typeName. Returns false if not found. - FindType(typeName string) (*exprpb.Type, bool) - - // FieldFieldType returns the field type for a checked type value. Returns false if - // the field could not be found. - FindFieldType(messageType, fieldName string) (*FieldType, bool) - - // NewValue creates a new type value from a qualified name and map of field name - // to value. - // - // Note, for each value, the Val.ConvertToNative function will be invoked to convert - // the Val to the field's native type. If an error occurs during conversion, the - // NewValue will be a types.Err. - NewValue(typeName string, fields map[string]Val) Val -} - -// TypeAdapter converts native Go values of varying type and complexity to equivalent CEL values. -// -// Deprecated: use types.Adapter -type TypeAdapter interface { - // NativeToValue converts the input `value` to a CEL `ref.Val`. - NativeToValue(value any) Val -} - -// TypeRegistry allows third-parties to add custom types to CEL. Not all `TypeProvider` -// implementations support type-customization, so these features are optional. However, a -// `TypeRegistry` should be a `TypeProvider` and a `TypeAdapter` to ensure that types -// which are registered can be converted to CEL representations. -// -// Deprecated: use types.Registry -type TypeRegistry interface { - TypeAdapter - TypeProvider - - // RegisterDescriptor registers the contents of a protocol buffer `FileDescriptor`. - RegisterDescriptor(fileDesc protoreflect.FileDescriptor) error - - // RegisterMessage registers a protocol buffer message and its dependencies. - RegisterMessage(message proto.Message) error - - // RegisterType registers a type value with the provider which ensures the - // provider is aware of how to map the type to an identifier. - // - // If a type is provided more than once with an alternative definition, the - // call will result in an error. - RegisterType(types ...Type) error -} - -// FieldType represents a field's type value and whether that field supports -// presence detection. -// -// Deprecated: use types.FieldType -type FieldType struct { - // Type of the field as a protobuf type value. - Type *exprpb.Type - - // IsSet indicates whether the field is set on an input object. - IsSet FieldTester - - // GetFrom retrieves the field value on the input object, if set. - GetFrom FieldGetter -} - -// FieldTester is used to test field presence on an input object. -type FieldTester func(target any) bool - -// FieldGetter is used to get the field value from an input object, if set. -type FieldGetter func(target any) (any, error) diff --git a/vendor/github.com/google/cel-go/common/types/ref/reference.go b/vendor/github.com/google/cel-go/common/types/ref/reference.go deleted file mode 100644 index e0d58145c..000000000 --- a/vendor/github.com/google/cel-go/common/types/ref/reference.go +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package ref contains the reference interfaces used throughout the types components. -package ref - -import ( - "reflect" -) - -// Type interface indicate the name of a given type. -type Type interface { - // HasTrait returns whether the type has a given trait associated with it. - // - // See common/types/traits/traits.go for a list of supported traits. - HasTrait(trait int) bool - - // TypeName returns the qualified type name of the type. - // - // The type name is also used as the type's identifier name at type-check and interpretation time. - TypeName() string -} - -// Val interface defines the functions supported by all expression values. -// Val implementations may specialize the behavior of the value through the addition of traits. -type Val interface { - // ConvertToNative converts the Value to a native Go struct according to the - // reflected type description, or error if the conversion is not feasible. - // - // The ConvertToNative method is intended to be used to support conversion between CEL types - // and native types during object creation expressions or by clients who need to adapt the, - // returned CEL value into an equivalent Go value instance. - // - // When implementing or using ConvertToNative, the following guidelines apply: - // - Use ConvertToNative when marshalling CEL evaluation results to native types. - // - Do not use ConvertToNative within CEL extension functions. - // - Document whether your implementation supports non-CEL field types, such as Go or Protobuf. - ConvertToNative(typeDesc reflect.Type) (any, error) - - // ConvertToType supports type conversions between CEL value types supported by the expression language. - ConvertToType(typeValue Type) Val - - // Equal returns true if the `other` value has the same type and content as the implementing struct. - Equal(other Val) Val - - // Type returns the TypeValue of the value. - Type() Type - - // Value returns the raw value of the instance which may not be directly compatible with the expression - // language types. - Value() any -} diff --git a/vendor/github.com/google/cel-go/common/types/string.go b/vendor/github.com/google/cel-go/common/types/string.go deleted file mode 100644 index 028e6824d..000000000 --- a/vendor/github.com/google/cel-go/common/types/string.go +++ /dev/null @@ -1,229 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - "reflect" - "regexp" - "strconv" - "strings" - "time" - - "github.com/google/cel-go/common/overloads" - "github.com/google/cel-go/common/types/ref" - - anypb "google.golang.org/protobuf/types/known/anypb" - structpb "google.golang.org/protobuf/types/known/structpb" - wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" -) - -// String type implementation which supports addition, comparison, matching, -// and size functions. -type String string - -var ( - stringOneArgOverloads = map[string]func(ref.Val, ref.Val) ref.Val{ - overloads.Contains: StringContains, - overloads.EndsWith: StringEndsWith, - overloads.StartsWith: StringStartsWith, - } - - stringWrapperType = reflect.TypeOf(&wrapperspb.StringValue{}) -) - -// Add implements traits.Adder.Add. -func (s String) Add(other ref.Val) ref.Val { - otherString, ok := other.(String) - if !ok { - return MaybeNoSuchOverloadErr(other) - } - return s + otherString -} - -// Compare implements traits.Comparer.Compare. -func (s String) Compare(other ref.Val) ref.Val { - otherString, ok := other.(String) - if !ok { - return MaybeNoSuchOverloadErr(other) - } - return Int(strings.Compare(s.Value().(string), otherString.Value().(string))) -} - -// ConvertToNative implements ref.Val.ConvertToNative. -func (s String) ConvertToNative(typeDesc reflect.Type) (any, error) { - switch typeDesc.Kind() { - case reflect.String: - if reflect.TypeOf(s).AssignableTo(typeDesc) { - return s, nil - } - return s.Value(), nil - case reflect.Ptr: - switch typeDesc { - case anyValueType: - // Primitives must be wrapped before being set on an Any field. - return anypb.New(wrapperspb.String(string(s))) - case jsonValueType: - // Convert to a protobuf representation of a JSON String. - return structpb.NewStringValue(string(s)), nil - case stringWrapperType: - // Convert to a wrapperspb.StringValue. - return wrapperspb.String(string(s)), nil - } - if typeDesc.Elem().Kind() == reflect.String { - p := s.Value().(string) - return &p, nil - } - case reflect.Interface: - sv := s.Value() - if reflect.TypeOf(sv).Implements(typeDesc) { - return sv, nil - } - if reflect.TypeOf(s).Implements(typeDesc) { - return s, nil - } - } - return nil, fmt.Errorf( - "unsupported native conversion from string to '%v'", typeDesc) -} - -// ConvertToType implements ref.Val.ConvertToType. -func (s String) ConvertToType(typeVal ref.Type) ref.Val { - switch typeVal { - case IntType: - if n, err := strconv.ParseInt(s.Value().(string), 10, 64); err == nil { - return Int(n) - } - case UintType: - if n, err := strconv.ParseUint(s.Value().(string), 10, 64); err == nil { - return Uint(n) - } - case DoubleType: - if n, err := strconv.ParseFloat(s.Value().(string), 64); err == nil { - return Double(n) - } - case BoolType: - if b, err := strconv.ParseBool(s.Value().(string)); err == nil { - return Bool(b) - } - case BytesType: - return Bytes(s) - case DurationType: - if d, err := time.ParseDuration(s.Value().(string)); err == nil { - return durationOf(d) - } - case TimestampType: - if t, err := time.Parse(time.RFC3339, s.Value().(string)); err == nil { - if t.Unix() < minUnixTime || t.Unix() > maxUnixTime { - return celErrTimestampOverflow - } - return timestampOf(t) - } - case StringType: - return s - case TypeType: - return StringType - } - return NewErr("type conversion error from '%s' to '%s'", StringType, typeVal) -} - -// Equal implements ref.Val.Equal. -func (s String) Equal(other ref.Val) ref.Val { - otherString, ok := other.(String) - return Bool(ok && s == otherString) -} - -// IsZeroValue returns true if the string is empty. -func (s String) IsZeroValue() bool { - return len(s) == 0 -} - -// Match implements traits.Matcher.Match. -func (s String) Match(pattern ref.Val) ref.Val { - pat, ok := pattern.(String) - if !ok { - return MaybeNoSuchOverloadErr(pattern) - } - matched, err := regexp.MatchString(pat.Value().(string), s.Value().(string)) - if err != nil { - return &Err{err} - } - return Bool(matched) -} - -// Receive implements traits.Receiver.Receive. -func (s String) Receive(function string, overload string, args []ref.Val) ref.Val { - switch len(args) { - case 1: - if f, found := stringOneArgOverloads[function]; found { - return f(s, args[0]) - } - } - return NoSuchOverloadErr() -} - -// Size implements traits.Sizer.Size. -func (s String) Size() ref.Val { - return Int(len([]rune(s.Value().(string)))) -} - -// Type implements ref.Val.Type. -func (s String) Type() ref.Type { - return StringType -} - -// Value implements ref.Val.Value. -func (s String) Value() any { - return string(s) -} - -// StringContains returns whether the string contains a substring. -func StringContains(s, sub ref.Val) ref.Val { - str, ok := s.(String) - if !ok { - return MaybeNoSuchOverloadErr(s) - } - subStr, ok := sub.(String) - if !ok { - return MaybeNoSuchOverloadErr(sub) - } - return Bool(strings.Contains(string(str), string(subStr))) -} - -// StringEndsWith returns whether the target string contains the input suffix. -func StringEndsWith(s, suf ref.Val) ref.Val { - str, ok := s.(String) - if !ok { - return MaybeNoSuchOverloadErr(s) - } - sufStr, ok := suf.(String) - if !ok { - return MaybeNoSuchOverloadErr(suf) - } - return Bool(strings.HasSuffix(string(str), string(sufStr))) -} - -// StringStartsWith returns whether the target string contains the input prefix. -func StringStartsWith(s, pre ref.Val) ref.Val { - str, ok := s.(String) - if !ok { - return MaybeNoSuchOverloadErr(s) - } - preStr, ok := pre.(String) - if !ok { - return MaybeNoSuchOverloadErr(pre) - } - return Bool(strings.HasPrefix(string(str), string(preStr))) -} diff --git a/vendor/github.com/google/cel-go/common/types/timestamp.go b/vendor/github.com/google/cel-go/common/types/timestamp.go deleted file mode 100644 index 33acdea8e..000000000 --- a/vendor/github.com/google/cel-go/common/types/timestamp.go +++ /dev/null @@ -1,311 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - "reflect" - "strconv" - "strings" - "time" - - "github.com/google/cel-go/common/overloads" - "github.com/google/cel-go/common/types/ref" - - anypb "google.golang.org/protobuf/types/known/anypb" - structpb "google.golang.org/protobuf/types/known/structpb" - tpb "google.golang.org/protobuf/types/known/timestamppb" -) - -// Timestamp type implementation which supports add, compare, and subtract -// operations. Timestamps are also capable of participating in dynamic -// function dispatch to instance methods. -type Timestamp struct { - time.Time -} - -func timestampOf(t time.Time) Timestamp { - // Note that this function does not validate that time.Time is in our supported range. - return Timestamp{Time: t} -} - -const ( - // The number of seconds between year 1 and year 1970. This is borrowed from - // https://golang.org/src/time/time.go. - unixToInternal int64 = (1969*365 + 1969/4 - 1969/100 + 1969/400) * (60 * 60 * 24) - - // Number of seconds between `0001-01-01T00:00:00Z` and the Unix epoch. - minUnixTime int64 = -62135596800 - // Number of seconds between `9999-12-31T23:59:59.999999999Z` and the Unix epoch. - maxUnixTime int64 = 253402300799 -) - -// Add implements traits.Adder.Add. -func (t Timestamp) Add(other ref.Val) ref.Val { - switch other.Type() { - case DurationType: - return other.(Duration).Add(t) - } - return MaybeNoSuchOverloadErr(other) -} - -// Compare implements traits.Comparer.Compare. -func (t Timestamp) Compare(other ref.Val) ref.Val { - if TimestampType != other.Type() { - return MaybeNoSuchOverloadErr(other) - } - ts1 := t.Time - ts2 := other.(Timestamp).Time - switch { - case ts1.Before(ts2): - return IntNegOne - case ts1.After(ts2): - return IntOne - default: - return IntZero - } -} - -// ConvertToNative implements ref.Val.ConvertToNative. -func (t Timestamp) ConvertToNative(typeDesc reflect.Type) (any, error) { - // If the timestamp is already assignable to the desired type return it. - if reflect.TypeOf(t.Time).AssignableTo(typeDesc) { - return t.Time, nil - } - if reflect.TypeOf(t).AssignableTo(typeDesc) { - return t, nil - } - switch typeDesc { - case anyValueType: - // Pack the underlying time as a tpb.Timestamp into an Any value. - return anypb.New(tpb.New(t.Time)) - case jsonValueType: - // CEL follows the proto3 to JSON conversion which formats as an RFC 3339 encoded JSON - // string. - v := t.ConvertToType(StringType) - if IsError(v) { - return nil, v.(*Err) - } - return structpb.NewStringValue(string(v.(String))), nil - case timestampValueType: - // Unwrap the underlying tpb.Timestamp. - return tpb.New(t.Time), nil - } - return nil, fmt.Errorf("type conversion error from 'Timestamp' to '%v'", typeDesc) -} - -// ConvertToType implements ref.Val.ConvertToType. -func (t Timestamp) ConvertToType(typeVal ref.Type) ref.Val { - switch typeVal { - case StringType: - return String(t.Format(time.RFC3339Nano)) - case IntType: - // Return the Unix time in seconds since 1970 - return Int(t.Unix()) - case TimestampType: - return t - case TypeType: - return TimestampType - } - return NewErr("type conversion error from '%s' to '%s'", TimestampType, typeVal) -} - -// Equal implements ref.Val.Equal. -func (t Timestamp) Equal(other ref.Val) ref.Val { - otherTime, ok := other.(Timestamp) - return Bool(ok && t.Time.Equal(otherTime.Time)) -} - -// IsZeroValue returns true if the timestamp is epoch 0. -func (t Timestamp) IsZeroValue() bool { - return t.IsZero() -} - -// Receive implements traits.Receiver.Receive. -func (t Timestamp) Receive(function string, overload string, args []ref.Val) ref.Val { - switch len(args) { - case 0: - if f, found := timestampZeroArgOverloads[function]; found { - return f(t.Time) - } - case 1: - if f, found := timestampOneArgOverloads[function]; found { - return f(t.Time, args[0]) - } - } - return NoSuchOverloadErr() -} - -// Subtract implements traits.Subtractor.Subtract. -func (t Timestamp) Subtract(subtrahend ref.Val) ref.Val { - switch subtrahend.Type() { - case DurationType: - dur := subtrahend.(Duration) - val, err := subtractTimeDurationChecked(t.Time, dur.Duration) - if err != nil { - return WrapErr(err) - } - return timestampOf(val) - case TimestampType: - t2 := subtrahend.(Timestamp).Time - val, err := subtractTimeChecked(t.Time, t2) - if err != nil { - return WrapErr(err) - } - return durationOf(val) - } - return MaybeNoSuchOverloadErr(subtrahend) -} - -// Type implements ref.Val.Type. -func (t Timestamp) Type() ref.Type { - return TimestampType -} - -// Value implements ref.Val.Value. -func (t Timestamp) Value() any { - return t.Time -} - -var ( - timestampValueType = reflect.TypeOf(&tpb.Timestamp{}) - - timestampZeroArgOverloads = map[string]func(time.Time) ref.Val{ - overloads.TimeGetFullYear: timestampGetFullYear, - overloads.TimeGetMonth: timestampGetMonth, - overloads.TimeGetDayOfYear: timestampGetDayOfYear, - overloads.TimeGetDate: timestampGetDayOfMonthOneBased, - overloads.TimeGetDayOfMonth: timestampGetDayOfMonthZeroBased, - overloads.TimeGetDayOfWeek: timestampGetDayOfWeek, - overloads.TimeGetHours: timestampGetHours, - overloads.TimeGetMinutes: timestampGetMinutes, - overloads.TimeGetSeconds: timestampGetSeconds, - overloads.TimeGetMilliseconds: timestampGetMilliseconds} - - timestampOneArgOverloads = map[string]func(time.Time, ref.Val) ref.Val{ - overloads.TimeGetFullYear: timestampGetFullYearWithTz, - overloads.TimeGetMonth: timestampGetMonthWithTz, - overloads.TimeGetDayOfYear: timestampGetDayOfYearWithTz, - overloads.TimeGetDate: timestampGetDayOfMonthOneBasedWithTz, - overloads.TimeGetDayOfMonth: timestampGetDayOfMonthZeroBasedWithTz, - overloads.TimeGetDayOfWeek: timestampGetDayOfWeekWithTz, - overloads.TimeGetHours: timestampGetHoursWithTz, - overloads.TimeGetMinutes: timestampGetMinutesWithTz, - overloads.TimeGetSeconds: timestampGetSecondsWithTz, - overloads.TimeGetMilliseconds: timestampGetMillisecondsWithTz} -) - -type timestampVisitor func(time.Time) ref.Val - -func timestampGetFullYear(t time.Time) ref.Val { - return Int(t.Year()) -} -func timestampGetMonth(t time.Time) ref.Val { - // CEL spec indicates that the month should be 0-based, but the Time value - // for Month() is 1-based. - return Int(t.Month() - 1) -} -func timestampGetDayOfYear(t time.Time) ref.Val { - return Int(t.YearDay() - 1) -} -func timestampGetDayOfMonthZeroBased(t time.Time) ref.Val { - return Int(t.Day() - 1) -} -func timestampGetDayOfMonthOneBased(t time.Time) ref.Val { - return Int(t.Day()) -} -func timestampGetDayOfWeek(t time.Time) ref.Val { - return Int(t.Weekday()) -} -func timestampGetHours(t time.Time) ref.Val { - return Int(t.Hour()) -} -func timestampGetMinutes(t time.Time) ref.Val { - return Int(t.Minute()) -} -func timestampGetSeconds(t time.Time) ref.Val { - return Int(t.Second()) -} -func timestampGetMilliseconds(t time.Time) ref.Val { - return Int(t.Nanosecond() / 1000000) -} - -func timestampGetFullYearWithTz(t time.Time, tz ref.Val) ref.Val { - return timeZone(tz, timestampGetFullYear)(t) -} -func timestampGetMonthWithTz(t time.Time, tz ref.Val) ref.Val { - return timeZone(tz, timestampGetMonth)(t) -} -func timestampGetDayOfYearWithTz(t time.Time, tz ref.Val) ref.Val { - return timeZone(tz, timestampGetDayOfYear)(t) -} -func timestampGetDayOfMonthZeroBasedWithTz(t time.Time, tz ref.Val) ref.Val { - return timeZone(tz, timestampGetDayOfMonthZeroBased)(t) -} -func timestampGetDayOfMonthOneBasedWithTz(t time.Time, tz ref.Val) ref.Val { - return timeZone(tz, timestampGetDayOfMonthOneBased)(t) -} -func timestampGetDayOfWeekWithTz(t time.Time, tz ref.Val) ref.Val { - return timeZone(tz, timestampGetDayOfWeek)(t) -} -func timestampGetHoursWithTz(t time.Time, tz ref.Val) ref.Val { - return timeZone(tz, timestampGetHours)(t) -} -func timestampGetMinutesWithTz(t time.Time, tz ref.Val) ref.Val { - return timeZone(tz, timestampGetMinutes)(t) -} -func timestampGetSecondsWithTz(t time.Time, tz ref.Val) ref.Val { - return timeZone(tz, timestampGetSeconds)(t) -} -func timestampGetMillisecondsWithTz(t time.Time, tz ref.Val) ref.Val { - return timeZone(tz, timestampGetMilliseconds)(t) -} - -func timeZone(tz ref.Val, visitor timestampVisitor) timestampVisitor { - return func(t time.Time) ref.Val { - if StringType != tz.Type() { - return MaybeNoSuchOverloadErr(tz) - } - val := string(tz.(String)) - ind := strings.Index(val, ":") - if ind == -1 { - loc, err := time.LoadLocation(val) - if err != nil { - return WrapErr(err) - } - return visitor(t.In(loc)) - } - - // If the input is not the name of a timezone (for example, 'US/Central'), it should be a numerical offset from UTC - // in the format ^(+|-)(0[0-9]|1[0-4]):[0-5][0-9]$. The numerical input is parsed in terms of hours and minutes. - hr, err := strconv.Atoi(string(val[0:ind])) - if err != nil { - return WrapErr(err) - } - min, err := strconv.Atoi(string(val[ind+1:])) - if err != nil { - return WrapErr(err) - } - var offset int - if string(val[0]) == "-" { - offset = hr*60 - min - } else { - offset = hr*60 + min - } - secondsEastOfUTC := int((time.Duration(offset) * time.Minute).Seconds()) - timezone := time.FixedZone("", secondsEastOfUTC) - return visitor(t.In(timezone)) - } -} diff --git a/vendor/github.com/google/cel-go/common/types/traits/BUILD.bazel b/vendor/github.com/google/cel-go/common/types/traits/BUILD.bazel deleted file mode 100644 index b19eb8301..000000000 --- a/vendor/github.com/google/cel-go/common/types/traits/BUILD.bazel +++ /dev/null @@ -1,29 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -package( - default_visibility = ["//visibility:public"], - licenses = ["notice"], # Apache 2.0 -) - -go_library( - name = "go_default_library", - srcs = [ - "comparer.go", - "container.go", - "field_tester.go", - "indexer.go", - "iterator.go", - "lister.go", - "mapper.go", - "matcher.go", - "math.go", - "receiver.go", - "sizer.go", - "traits.go", - "zeroer.go", - ], - importpath = "github.com/google/cel-go/common/types/traits", - deps = [ - "//common/types/ref:go_default_library", - ], -) diff --git a/vendor/github.com/google/cel-go/common/types/traits/comparer.go b/vendor/github.com/google/cel-go/common/types/traits/comparer.go deleted file mode 100644 index b531d9ae2..000000000 --- a/vendor/github.com/google/cel-go/common/types/traits/comparer.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package traits - -import ( - "github.com/google/cel-go/common/types/ref" -) - -// Comparer interface for ordering comparisons between values in order to -// support '<', '<=', '>=', '>' overloads. -type Comparer interface { - // Compare this value to the input other value, returning an Int: - // - // this < other -> Int(-1) - // this == other -> Int(0) - // this > other -> Int(1) - // - // If the comparison cannot be made or is not supported, an error should - // be returned. - Compare(other ref.Val) ref.Val -} diff --git a/vendor/github.com/google/cel-go/common/types/traits/container.go b/vendor/github.com/google/cel-go/common/types/traits/container.go deleted file mode 100644 index cf5c621ae..000000000 --- a/vendor/github.com/google/cel-go/common/types/traits/container.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package traits - -import "github.com/google/cel-go/common/types/ref" - -// Container interface which permits containment tests such as 'a in b'. -type Container interface { - // Contains returns true if the value exists within the object. - Contains(value ref.Val) ref.Val -} diff --git a/vendor/github.com/google/cel-go/common/types/traits/field_tester.go b/vendor/github.com/google/cel-go/common/types/traits/field_tester.go deleted file mode 100644 index 816a95652..000000000 --- a/vendor/github.com/google/cel-go/common/types/traits/field_tester.go +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package traits - -import ( - "github.com/google/cel-go/common/types/ref" -) - -// FieldTester indicates if a defined field on an object type is set to a -// non-default value. -// -// For use with the `has()` macro. -type FieldTester interface { - // IsSet returns true if the field is defined and set to a non-default - // value. The method will return false if defined and not set, and an error - // if the field is not defined. - IsSet(field ref.Val) ref.Val -} diff --git a/vendor/github.com/google/cel-go/common/types/traits/indexer.go b/vendor/github.com/google/cel-go/common/types/traits/indexer.go deleted file mode 100644 index 662c6836c..000000000 --- a/vendor/github.com/google/cel-go/common/types/traits/indexer.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package traits - -import ( - "github.com/google/cel-go/common/types/ref" -) - -// Indexer permits random access of elements by index 'a[b()]'. -type Indexer interface { - // Get the value at the specified index or error. - Get(index ref.Val) ref.Val -} diff --git a/vendor/github.com/google/cel-go/common/types/traits/iterator.go b/vendor/github.com/google/cel-go/common/types/traits/iterator.go deleted file mode 100644 index 42dd371aa..000000000 --- a/vendor/github.com/google/cel-go/common/types/traits/iterator.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package traits - -import ( - "github.com/google/cel-go/common/types/ref" -) - -// Iterable aggregate types permit traversal over their elements. -type Iterable interface { - // Iterator returns a new iterator view of the struct. - Iterator() Iterator -} - -// Iterator permits safe traversal over the contents of an aggregate type. -type Iterator interface { - ref.Val - - // HasNext returns true if there are unvisited elements in the Iterator. - HasNext() ref.Val - - // Next returns the next element. - Next() ref.Val -} diff --git a/vendor/github.com/google/cel-go/common/types/traits/lister.go b/vendor/github.com/google/cel-go/common/types/traits/lister.go deleted file mode 100644 index 5cf2593f3..000000000 --- a/vendor/github.com/google/cel-go/common/types/traits/lister.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package traits - -import "github.com/google/cel-go/common/types/ref" - -// Lister interface which aggregates the traits of a list. -type Lister interface { - ref.Val - Adder - Container - Indexer - Iterable - Sizer -} - -// MutableLister interface which emits an immutable result after an intermediate computation. -type MutableLister interface { - Lister - ToImmutableList() Lister -} diff --git a/vendor/github.com/google/cel-go/common/types/traits/mapper.go b/vendor/github.com/google/cel-go/common/types/traits/mapper.go deleted file mode 100644 index 2f7c919a8..000000000 --- a/vendor/github.com/google/cel-go/common/types/traits/mapper.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package traits - -import "github.com/google/cel-go/common/types/ref" - -// Mapper interface which aggregates the traits of a maps. -type Mapper interface { - ref.Val - Container - Indexer - Iterable - Sizer - - // Find returns a value, if one exists, for the input key. - // - // If the key is not found the function returns (nil, false). - // If the input key is not valid for the map, or is Err or Unknown the function returns - // (Unknown|Err, false). - Find(key ref.Val) (ref.Val, bool) -} diff --git a/vendor/github.com/google/cel-go/common/types/traits/matcher.go b/vendor/github.com/google/cel-go/common/types/traits/matcher.go deleted file mode 100644 index 085dc94ff..000000000 --- a/vendor/github.com/google/cel-go/common/types/traits/matcher.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package traits - -import "github.com/google/cel-go/common/types/ref" - -// Matcher interface for supporting 'matches()' overloads. -type Matcher interface { - // Match returns true if the pattern matches the current value. - Match(pattern ref.Val) ref.Val -} diff --git a/vendor/github.com/google/cel-go/common/types/traits/math.go b/vendor/github.com/google/cel-go/common/types/traits/math.go deleted file mode 100644 index 86d5b9137..000000000 --- a/vendor/github.com/google/cel-go/common/types/traits/math.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package traits - -import "github.com/google/cel-go/common/types/ref" - -// Adder interface to support '+' operator overloads. -type Adder interface { - // Add returns a combination of the current value and other value. - // - // If the other value is an unsupported type, an error is returned. - Add(other ref.Val) ref.Val -} - -// Divider interface to support '/' operator overloads. -type Divider interface { - // Divide returns the result of dividing the current value by the input - // denominator. - // - // A denominator value of zero results in an error. - Divide(denominator ref.Val) ref.Val -} - -// Modder interface to support '%' operator overloads. -type Modder interface { - // Modulo returns the result of taking the modulus of the current value - // by the denominator. - // - // A denominator value of zero results in an error. - Modulo(denominator ref.Val) ref.Val -} - -// Multiplier interface to support '*' operator overloads. -type Multiplier interface { - // Multiply returns the result of multiplying the current and input value. - Multiply(other ref.Val) ref.Val -} - -// Negater interface to support unary '-' and '!' operator overloads. -type Negater interface { - // Negate returns the complement of the current value. - Negate() ref.Val -} - -// Subtractor interface to support binary '-' operator overloads. -type Subtractor interface { - // Subtract returns the result of subtracting the input from the current - // value. - Subtract(subtrahend ref.Val) ref.Val -} diff --git a/vendor/github.com/google/cel-go/common/types/traits/receiver.go b/vendor/github.com/google/cel-go/common/types/traits/receiver.go deleted file mode 100644 index 8f41db45e..000000000 --- a/vendor/github.com/google/cel-go/common/types/traits/receiver.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package traits - -import "github.com/google/cel-go/common/types/ref" - -// Receiver interface for routing instance method calls within a value. -type Receiver interface { - // Receive accepts a function name, overload id, and arguments and returns - // a value. - Receive(function string, overload string, args []ref.Val) ref.Val -} diff --git a/vendor/github.com/google/cel-go/common/types/traits/sizer.go b/vendor/github.com/google/cel-go/common/types/traits/sizer.go deleted file mode 100644 index b80d25137..000000000 --- a/vendor/github.com/google/cel-go/common/types/traits/sizer.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package traits - -import ( - "github.com/google/cel-go/common/types/ref" -) - -// Sizer interface for supporting 'size()' overloads. -type Sizer interface { - // Size returns the number of elements or length of the value. - Size() ref.Val -} diff --git a/vendor/github.com/google/cel-go/common/types/traits/traits.go b/vendor/github.com/google/cel-go/common/types/traits/traits.go deleted file mode 100644 index 6da3e6a3e..000000000 --- a/vendor/github.com/google/cel-go/common/types/traits/traits.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package traits defines interfaces that a type may implement to participate -// in operator overloads and function dispatch. -package traits - -const ( - // AdderType types provide a '+' operator overload. - AdderType = 1 << iota - - // ComparerType types support ordering comparisons '<', '<=', '>', '>='. - ComparerType - - // ContainerType types support 'in' operations. - ContainerType - - // DividerType types support '/' operations. - DividerType - - // FieldTesterType types support the detection of field value presence. - FieldTesterType - - // IndexerType types support index access with dynamic values. - IndexerType - - // IterableType types can be iterated over in comprehensions. - IterableType - - // IteratorType types support iterator semantics. - IteratorType - - // MatcherType types support pattern matching via 'matches' method. - MatcherType - - // ModderType types support modulus operations '%' - ModderType - - // MultiplierType types support '*' operations. - MultiplierType - - // NegatorType types support either negation via '!' or '-' - NegatorType - - // ReceiverType types support dynamic dispatch to instance methods. - ReceiverType - - // SizerType types support the size() method. - SizerType - - // SubtractorType type support '-' operations. - SubtractorType -) diff --git a/vendor/github.com/google/cel-go/common/types/traits/zeroer.go b/vendor/github.com/google/cel-go/common/types/traits/zeroer.go deleted file mode 100644 index 0b7c830a2..000000000 --- a/vendor/github.com/google/cel-go/common/types/traits/zeroer.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package traits - -// Zeroer interface for testing whether a CEL value is a zero value for its type. -type Zeroer interface { - // IsZeroValue indicates whether the object is the zero value for the type. - IsZeroValue() bool -} diff --git a/vendor/github.com/google/cel-go/common/types/types.go b/vendor/github.com/google/cel-go/common/types/types.go deleted file mode 100644 index 76624eefd..000000000 --- a/vendor/github.com/google/cel-go/common/types/types.go +++ /dev/null @@ -1,806 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - "reflect" - "strings" - - chkdecls "github.com/google/cel-go/checker/decls" - "github.com/google/cel-go/common/types/ref" - "github.com/google/cel-go/common/types/traits" - - exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1" -) - -// Kind indicates a CEL type's kind which is used to differentiate quickly between simple -// and complex types. -type Kind uint - -const ( - // UnspecifiedKind is returned when the type is nil or its kind is not specified. - UnspecifiedKind Kind = iota - - // DynKind represents a dynamic type. This kind only exists at type-check time. - DynKind - - // AnyKind represents a google.protobuf.Any type. This kind only exists at type-check time. - // Prefer DynKind to AnyKind as AnyKind has a specific meaning which is based on protobuf - // well-known types. - AnyKind - - // BoolKind represents a boolean type. - BoolKind - - // BytesKind represents a bytes type. - BytesKind - - // DoubleKind represents a double type. - DoubleKind - - // DurationKind represents a CEL duration type. - DurationKind - - // ErrorKind represents a CEL error type. - ErrorKind - - // IntKind represents an integer type. - IntKind - - // ListKind represents a list type. - ListKind - - // MapKind represents a map type. - MapKind - - // NullTypeKind represents a null type. - NullTypeKind - - // OpaqueKind represents an abstract type which has no accessible fields. - OpaqueKind - - // StringKind represents a string type. - StringKind - - // StructKind represents a structured object with typed fields. - StructKind - - // TimestampKind represents a a CEL time type. - TimestampKind - - // TypeKind represents the CEL type. - TypeKind - - // TypeParamKind represents a parameterized type whose type name will be resolved at type-check time, if possible. - TypeParamKind - - // UintKind represents a uint type. - UintKind - - // UnknownKind represents an unknown value type. - UnknownKind -) - -var ( - // AnyType represents the google.protobuf.Any type. - AnyType = &Type{ - kind: AnyKind, - runtimeTypeName: "google.protobuf.Any", - traitMask: traits.FieldTesterType | - traits.IndexerType, - } - // BoolType represents the bool type. - BoolType = &Type{ - kind: BoolKind, - runtimeTypeName: "bool", - traitMask: traits.ComparerType | - traits.NegatorType, - } - // BytesType represents the bytes type. - BytesType = &Type{ - kind: BytesKind, - runtimeTypeName: "bytes", - traitMask: traits.AdderType | - traits.ComparerType | - traits.SizerType, - } - // DoubleType represents the double type. - DoubleType = &Type{ - kind: DoubleKind, - runtimeTypeName: "double", - traitMask: traits.AdderType | - traits.ComparerType | - traits.DividerType | - traits.MultiplierType | - traits.NegatorType | - traits.SubtractorType, - } - // DurationType represents the CEL duration type. - DurationType = &Type{ - kind: DurationKind, - runtimeTypeName: "google.protobuf.Duration", - traitMask: traits.AdderType | - traits.ComparerType | - traits.NegatorType | - traits.ReceiverType | - traits.SubtractorType, - } - // DynType represents a dynamic CEL type whose type will be determined at runtime from context. - DynType = &Type{ - kind: DynKind, - runtimeTypeName: "dyn", - } - // ErrorType represents a CEL error value. - ErrorType = &Type{ - kind: ErrorKind, - runtimeTypeName: "error", - } - // IntType represents the int type. - IntType = &Type{ - kind: IntKind, - runtimeTypeName: "int", - traitMask: traits.AdderType | - traits.ComparerType | - traits.DividerType | - traits.ModderType | - traits.MultiplierType | - traits.NegatorType | - traits.SubtractorType, - } - // ListType represents the runtime list type. - ListType = NewListType(nil) - // MapType represents the runtime map type. - MapType = NewMapType(nil, nil) - // NullType represents the type of a null value. - NullType = &Type{ - kind: NullTypeKind, - runtimeTypeName: "null_type", - } - // StringType represents the string type. - StringType = &Type{ - kind: StringKind, - runtimeTypeName: "string", - traitMask: traits.AdderType | - traits.ComparerType | - traits.MatcherType | - traits.ReceiverType | - traits.SizerType, - } - // TimestampType represents the time type. - TimestampType = &Type{ - kind: TimestampKind, - runtimeTypeName: "google.protobuf.Timestamp", - traitMask: traits.AdderType | - traits.ComparerType | - traits.ReceiverType | - traits.SubtractorType, - } - // TypeType represents a CEL type - TypeType = &Type{ - kind: TypeKind, - runtimeTypeName: "type", - } - // UintType represents a uint type. - UintType = &Type{ - kind: UintKind, - runtimeTypeName: "uint", - traitMask: traits.AdderType | - traits.ComparerType | - traits.DividerType | - traits.ModderType | - traits.MultiplierType | - traits.SubtractorType, - } - // UnknownType represents an unknown value type. - UnknownType = &Type{ - kind: UnknownKind, - runtimeTypeName: "unknown", - } -) - -var _ ref.Type = &Type{} -var _ ref.Val = &Type{} - -// Type holds a reference to a runtime type with an optional type-checked set of type parameters. -type Type struct { - // kind indicates general category of the type. - kind Kind - - // parameters holds the optional type-checked set of type Parameters that are used during static analysis. - parameters []*Type - - // runtimeTypeName indicates the runtime type name of the type. - runtimeTypeName string - - // isAssignableType function determines whether one type is assignable to this type. - // A nil value for the isAssignableType function falls back to equality of kind, runtimeType, and parameters. - isAssignableType func(other *Type) bool - - // isAssignableRuntimeType function determines whether the runtime type (with erasure) is assignable to this type. - // A nil value for the isAssignableRuntimeType function falls back to the equality of the type or type name. - isAssignableRuntimeType func(other ref.Val) bool - - // traitMask is a mask of flags which indicate the capabilities of the type. - traitMask int -} - -// ConvertToNative implements ref.Val.ConvertToNative. -func (t *Type) ConvertToNative(typeDesc reflect.Type) (any, error) { - return nil, fmt.Errorf("type conversion not supported for 'type'") -} - -// ConvertToType implements ref.Val.ConvertToType. -func (t *Type) ConvertToType(typeVal ref.Type) ref.Val { - switch typeVal { - case TypeType: - return TypeType - case StringType: - return String(t.TypeName()) - } - return NewErr("type conversion error from '%s' to '%s'", TypeType, typeVal) -} - -// Equal indicates whether two types have the same runtime type name. -// -// The name Equal is a bit of a misnomer, but for historical reasons, this is the -// runtime behavior. For a more accurate definition see IsType(). -func (t *Type) Equal(other ref.Val) ref.Val { - otherType, ok := other.(ref.Type) - return Bool(ok && t.TypeName() == otherType.TypeName()) -} - -// HasTrait implements the ref.Type interface method. -func (t *Type) HasTrait(trait int) bool { - return trait&t.traitMask == trait -} - -// IsExactType indicates whether the two types are exactly the same. This check also verifies type parameter type names. -func (t *Type) IsExactType(other *Type) bool { - return t.isTypeInternal(other, true) -} - -// IsEquivalentType indicates whether two types are equivalent. This check ignores type parameter type names. -func (t *Type) IsEquivalentType(other *Type) bool { - return t.isTypeInternal(other, false) -} - -// Kind indicates general category of the type. -func (t *Type) Kind() Kind { - if t == nil { - return UnspecifiedKind - } - return t.kind -} - -// isTypeInternal checks whether the two types are equivalent or exactly the same based on the checkTypeParamName flag. -func (t *Type) isTypeInternal(other *Type, checkTypeParamName bool) bool { - if t == nil { - return false - } - if t == other { - return true - } - if t.Kind() != other.Kind() || len(t.Parameters()) != len(other.Parameters()) { - return false - } - if (checkTypeParamName || t.Kind() != TypeParamKind) && t.TypeName() != other.TypeName() { - return false - } - for i, p := range t.Parameters() { - if !p.isTypeInternal(other.Parameters()[i], checkTypeParamName) { - return false - } - } - return true -} - -// IsAssignableType determines whether the current type is type-check assignable from the input fromType. -func (t *Type) IsAssignableType(fromType *Type) bool { - if t == nil { - return false - } - if t.isAssignableType != nil { - return t.isAssignableType(fromType) - } - return t.defaultIsAssignableType(fromType) -} - -// IsAssignableRuntimeType determines whether the current type is runtime assignable from the input runtimeType. -// -// At runtime, parameterized types are erased and so a function which type-checks to support a map(string, string) -// will have a runtime assignable type of a map. -func (t *Type) IsAssignableRuntimeType(val ref.Val) bool { - if t == nil { - return false - } - if t.isAssignableRuntimeType != nil { - return t.isAssignableRuntimeType(val) - } - return t.defaultIsAssignableRuntimeType(val) -} - -// Parameters returns the list of type parameters if set. -// -// For ListKind, Parameters()[0] represents the list element type -// For MapKind, Parameters()[0] represents the map key type, and Parameters()[1] represents the map -// value type. -func (t *Type) Parameters() []*Type { - if t == nil { - return emptyParams - } - return t.parameters -} - -// DeclaredTypeName indicates the fully qualified and parameterized type-check type name. -func (t *Type) DeclaredTypeName() string { - // if the type itself is neither null, nor dyn, but is assignable to null, then it's a wrapper type. - if t.Kind() != NullTypeKind && !t.isDyn() && t.IsAssignableType(NullType) { - return fmt.Sprintf("wrapper(%s)", t.TypeName()) - } - return t.TypeName() -} - -// Type implements the ref.Val interface method. -func (t *Type) Type() ref.Type { - return TypeType -} - -// Value implements the ref.Val interface method. -func (t *Type) Value() any { - return t.TypeName() -} - -// TypeName returns the type-erased fully qualified runtime type name. -// -// TypeName implements the ref.Type interface method. -func (t *Type) TypeName() string { - if t == nil { - return "" - } - return t.runtimeTypeName -} - -// String returns a human-readable definition of the type name. -func (t *Type) String() string { - if len(t.Parameters()) == 0 { - return t.DeclaredTypeName() - } - params := make([]string, len(t.Parameters())) - for i, p := range t.Parameters() { - params[i] = p.String() - } - return fmt.Sprintf("%s(%s)", t.DeclaredTypeName(), strings.Join(params, ", ")) -} - -// isDyn indicates whether the type is dynamic in any way. -func (t *Type) isDyn() bool { - k := t.Kind() - return k == DynKind || k == AnyKind || k == TypeParamKind -} - -// defaultIsAssignableType provides the standard definition of what it means for one type to be assignable to another -// where any of the following may return a true result: -// - The from types are the same instance -// - The target type is dynamic -// - The fromType has the same kind and type name as the target type, and all parameters of the target type -// -// are IsAssignableType() from the parameters of the fromType. -func (t *Type) defaultIsAssignableType(fromType *Type) bool { - if t == fromType || t.isDyn() { - return true - } - if t.Kind() != fromType.Kind() || - t.TypeName() != fromType.TypeName() || - len(t.Parameters()) != len(fromType.Parameters()) { - return false - } - for i, tp := range t.Parameters() { - fp := fromType.Parameters()[i] - if !tp.IsAssignableType(fp) { - return false - } - } - return true -} - -// defaultIsAssignableRuntimeType inspects the type and in the case of list and map elements, the key and element types -// to determine whether a ref.Val is assignable to the declared type for a function signature. -func (t *Type) defaultIsAssignableRuntimeType(val ref.Val) bool { - valType := val.Type() - // If the current type and value type don't agree, then return - if !(t.isDyn() || t.TypeName() == valType.TypeName()) { - return false - } - switch t.Kind() { - case ListKind: - elemType := t.Parameters()[0] - l := val.(traits.Lister) - if l.Size() == IntZero { - return true - } - it := l.Iterator() - elemVal := it.Next() - return elemType.IsAssignableRuntimeType(elemVal) - case MapKind: - keyType := t.Parameters()[0] - elemType := t.Parameters()[1] - m := val.(traits.Mapper) - if m.Size() == IntZero { - return true - } - it := m.Iterator() - keyVal := it.Next() - elemVal := m.Get(keyVal) - return keyType.IsAssignableRuntimeType(keyVal) && elemType.IsAssignableRuntimeType(elemVal) - } - return true -} - -// NewListType creates an instances of a list type value with the provided element type. -func NewListType(elemType *Type) *Type { - return &Type{ - kind: ListKind, - parameters: []*Type{elemType}, - runtimeTypeName: "list", - traitMask: traits.AdderType | - traits.ContainerType | - traits.IndexerType | - traits.IterableType | - traits.SizerType, - } -} - -// NewMapType creates an instance of a map type value with the provided key and value types. -func NewMapType(keyType, valueType *Type) *Type { - return &Type{ - kind: MapKind, - parameters: []*Type{keyType, valueType}, - runtimeTypeName: "map", - traitMask: traits.ContainerType | - traits.IndexerType | - traits.IterableType | - traits.SizerType, - } -} - -// NewNullableType creates an instance of a nullable type with the provided wrapped type. -// -// Note: only primitive types are supported as wrapped types. -func NewNullableType(wrapped *Type) *Type { - return &Type{ - kind: wrapped.Kind(), - parameters: wrapped.Parameters(), - runtimeTypeName: wrapped.TypeName(), - traitMask: wrapped.traitMask, - isAssignableType: func(other *Type) bool { - return NullType.IsAssignableType(other) || wrapped.IsAssignableType(other) - }, - isAssignableRuntimeType: func(other ref.Val) bool { - return NullType.IsAssignableRuntimeType(other) || wrapped.IsAssignableRuntimeType(other) - }, - } -} - -// NewOptionalType creates an abstract parameterized type instance corresponding to CEL's notion of optional. -func NewOptionalType(param *Type) *Type { - return NewOpaqueType("optional", param) -} - -// NewOpaqueType creates an abstract parameterized type with a given name. -func NewOpaqueType(name string, params ...*Type) *Type { - return &Type{ - kind: OpaqueKind, - parameters: params, - runtimeTypeName: name, - } -} - -// NewObjectType creates a type reference to an externally defined type, e.g. a protobuf message type. -// -// An object type is assumed to support field presence testing and field indexing. Additionally, the -// type may also indicate additional traits through the use of the optional traits vararg argument. -func NewObjectType(typeName string, traits ...int) *Type { - // Function sanitizes object types on the fly - if wkt, found := checkedWellKnowns[typeName]; found { - return wkt - } - traitMask := 0 - for _, trait := range traits { - traitMask |= trait - } - return &Type{ - kind: StructKind, - parameters: emptyParams, - runtimeTypeName: typeName, - traitMask: structTypeTraitMask | traitMask, - } -} - -// NewObjectTypeValue creates a type reference to an externally defined type. -// -// Deprecated: use cel.ObjectType(typeName) -func NewObjectTypeValue(typeName string) *Type { - return NewObjectType(typeName) -} - -// NewTypeValue creates an opaque type which has a set of optional type traits as defined in -// the common/types/traits package. -// -// Deprecated: use cel.ObjectType(typeName, traits) -func NewTypeValue(typeName string, traits ...int) *Type { - traitMask := 0 - for _, trait := range traits { - traitMask |= trait - } - return &Type{ - kind: StructKind, - parameters: emptyParams, - runtimeTypeName: typeName, - traitMask: traitMask, - } -} - -// NewTypeParamType creates a parameterized type instance. -func NewTypeParamType(paramName string) *Type { - return &Type{ - kind: TypeParamKind, - runtimeTypeName: paramName, - } -} - -// NewTypeTypeWithParam creates a type with a type parameter. -// Used for type-checking purposes, but equivalent to TypeType otherwise. -func NewTypeTypeWithParam(param *Type) *Type { - return &Type{ - kind: TypeKind, - runtimeTypeName: "type", - parameters: []*Type{param}, - } -} - -// TypeToExprType converts a CEL-native type representation to a protobuf CEL Type representation. -func TypeToExprType(t *Type) (*exprpb.Type, error) { - switch t.Kind() { - case AnyKind: - return chkdecls.Any, nil - case BoolKind: - return maybeWrapper(t, chkdecls.Bool), nil - case BytesKind: - return maybeWrapper(t, chkdecls.Bytes), nil - case DoubleKind: - return maybeWrapper(t, chkdecls.Double), nil - case DurationKind: - return chkdecls.Duration, nil - case DynKind: - return chkdecls.Dyn, nil - case ErrorKind: - return chkdecls.Error, nil - case IntKind: - return maybeWrapper(t, chkdecls.Int), nil - case ListKind: - if len(t.Parameters()) != 1 { - return nil, fmt.Errorf("invalid list, got %d parameters, wanted one", len(t.Parameters())) - } - et, err := TypeToExprType(t.Parameters()[0]) - if err != nil { - return nil, err - } - return chkdecls.NewListType(et), nil - case MapKind: - if len(t.Parameters()) != 2 { - return nil, fmt.Errorf("invalid map, got %d parameters, wanted two", len(t.Parameters())) - } - kt, err := TypeToExprType(t.Parameters()[0]) - if err != nil { - return nil, err - } - vt, err := TypeToExprType(t.Parameters()[1]) - if err != nil { - return nil, err - } - return chkdecls.NewMapType(kt, vt), nil - case NullTypeKind: - return chkdecls.Null, nil - case OpaqueKind: - params := make([]*exprpb.Type, len(t.Parameters())) - for i, p := range t.Parameters() { - pt, err := TypeToExprType(p) - if err != nil { - return nil, err - } - params[i] = pt - } - return chkdecls.NewAbstractType(t.TypeName(), params...), nil - case StringKind: - return maybeWrapper(t, chkdecls.String), nil - case StructKind: - return chkdecls.NewObjectType(t.TypeName()), nil - case TimestampKind: - return chkdecls.Timestamp, nil - case TypeParamKind: - return chkdecls.NewTypeParamType(t.TypeName()), nil - case TypeKind: - if len(t.Parameters()) == 1 { - p, err := TypeToExprType(t.Parameters()[0]) - if err != nil { - return nil, err - } - return chkdecls.NewTypeType(p), nil - } - return chkdecls.NewTypeType(nil), nil - case UintKind: - return maybeWrapper(t, chkdecls.Uint), nil - } - return nil, fmt.Errorf("missing type conversion to proto: %v", t) -} - -// ExprTypeToType converts a protobuf CEL type representation to a CEL-native type representation. -func ExprTypeToType(t *exprpb.Type) (*Type, error) { - switch t.GetTypeKind().(type) { - case *exprpb.Type_Dyn: - return DynType, nil - case *exprpb.Type_AbstractType_: - paramTypes := make([]*Type, len(t.GetAbstractType().GetParameterTypes())) - for i, p := range t.GetAbstractType().GetParameterTypes() { - pt, err := ExprTypeToType(p) - if err != nil { - return nil, err - } - paramTypes[i] = pt - } - return NewOpaqueType(t.GetAbstractType().GetName(), paramTypes...), nil - case *exprpb.Type_ListType_: - et, err := ExprTypeToType(t.GetListType().GetElemType()) - if err != nil { - return nil, err - } - return NewListType(et), nil - case *exprpb.Type_MapType_: - kt, err := ExprTypeToType(t.GetMapType().GetKeyType()) - if err != nil { - return nil, err - } - vt, err := ExprTypeToType(t.GetMapType().GetValueType()) - if err != nil { - return nil, err - } - return NewMapType(kt, vt), nil - case *exprpb.Type_MessageType: - return NewObjectType(t.GetMessageType()), nil - case *exprpb.Type_Null: - return NullType, nil - case *exprpb.Type_Primitive: - switch t.GetPrimitive() { - case exprpb.Type_BOOL: - return BoolType, nil - case exprpb.Type_BYTES: - return BytesType, nil - case exprpb.Type_DOUBLE: - return DoubleType, nil - case exprpb.Type_INT64: - return IntType, nil - case exprpb.Type_STRING: - return StringType, nil - case exprpb.Type_UINT64: - return UintType, nil - default: - return nil, fmt.Errorf("unsupported primitive type: %v", t) - } - case *exprpb.Type_TypeParam: - return NewTypeParamType(t.GetTypeParam()), nil - case *exprpb.Type_Type: - if t.GetType().GetTypeKind() != nil { - p, err := ExprTypeToType(t.GetType()) - if err != nil { - return nil, err - } - return NewTypeTypeWithParam(p), nil - } - return TypeType, nil - case *exprpb.Type_WellKnown: - switch t.GetWellKnown() { - case exprpb.Type_ANY: - return AnyType, nil - case exprpb.Type_DURATION: - return DurationType, nil - case exprpb.Type_TIMESTAMP: - return TimestampType, nil - default: - return nil, fmt.Errorf("unsupported well-known type: %v", t) - } - case *exprpb.Type_Wrapper: - t, err := ExprTypeToType(&exprpb.Type{TypeKind: &exprpb.Type_Primitive{Primitive: t.GetWrapper()}}) - if err != nil { - return nil, err - } - return NewNullableType(t), nil - case *exprpb.Type_Error: - return ErrorType, nil - default: - return nil, fmt.Errorf("unsupported type: %v", t) - } -} - -func maybeWrapper(t *Type, pbType *exprpb.Type) *exprpb.Type { - if t.IsAssignableType(NullType) { - return chkdecls.NewWrapperType(pbType) - } - return pbType -} - -func maybeForeignType(t ref.Type) *Type { - if celType, ok := t.(*Type); ok { - return celType - } - // Inspect the incoming type to determine its traits. The assumption will be that the incoming - // type does not have any field values; however, if the trait mask indicates that field testing - // and indexing are supported, the foreign type is marked as a struct. - traitMask := 0 - for _, trait := range allTraits { - if t.HasTrait(trait) { - traitMask |= trait - } - } - // Treat the value like a struct. If it has no fields, this is harmless to denote the type - // as such since it basically becomes an opaque type by convention. - return NewObjectType(t.TypeName(), traitMask) -} - -var ( - checkedWellKnowns = map[string]*Type{ - // Wrapper types. - "google.protobuf.BoolValue": NewNullableType(BoolType), - "google.protobuf.BytesValue": NewNullableType(BytesType), - "google.protobuf.DoubleValue": NewNullableType(DoubleType), - "google.protobuf.FloatValue": NewNullableType(DoubleType), - "google.protobuf.Int64Value": NewNullableType(IntType), - "google.protobuf.Int32Value": NewNullableType(IntType), - "google.protobuf.UInt64Value": NewNullableType(UintType), - "google.protobuf.UInt32Value": NewNullableType(UintType), - "google.protobuf.StringValue": NewNullableType(StringType), - // Well-known types. - "google.protobuf.Any": AnyType, - "google.protobuf.Duration": DurationType, - "google.protobuf.Timestamp": TimestampType, - // Json types. - "google.protobuf.ListValue": NewListType(DynType), - "google.protobuf.NullValue": NullType, - "google.protobuf.Struct": NewMapType(StringType, DynType), - "google.protobuf.Value": DynType, - } - - emptyParams = []*Type{} - - allTraits = []int{ - traits.AdderType, - traits.ComparerType, - traits.ContainerType, - traits.DividerType, - traits.FieldTesterType, - traits.IndexerType, - traits.IterableType, - traits.IteratorType, - traits.MatcherType, - traits.ModderType, - traits.MultiplierType, - traits.NegatorType, - traits.ReceiverType, - traits.SizerType, - traits.SubtractorType, - } - - structTypeTraitMask = traits.FieldTesterType | traits.IndexerType -) diff --git a/vendor/github.com/google/cel-go/common/types/uint.go b/vendor/github.com/google/cel-go/common/types/uint.go deleted file mode 100644 index 3257f9ade..000000000 --- a/vendor/github.com/google/cel-go/common/types/uint.go +++ /dev/null @@ -1,244 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - "math" - "reflect" - "strconv" - - "github.com/google/cel-go/common/types/ref" - - anypb "google.golang.org/protobuf/types/known/anypb" - structpb "google.golang.org/protobuf/types/known/structpb" - wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" -) - -// Uint type implementation which supports comparison and math operators. -type Uint uint64 - -var ( - uint32WrapperType = reflect.TypeOf(&wrapperspb.UInt32Value{}) - - uint64WrapperType = reflect.TypeOf(&wrapperspb.UInt64Value{}) -) - -// Uint constants -const ( - uintZero = Uint(0) -) - -// Add implements traits.Adder.Add. -func (i Uint) Add(other ref.Val) ref.Val { - otherUint, ok := other.(Uint) - if !ok { - return MaybeNoSuchOverloadErr(other) - } - val, err := addUint64Checked(uint64(i), uint64(otherUint)) - if err != nil { - return WrapErr(err) - } - return Uint(val) -} - -// Compare implements traits.Comparer.Compare. -func (i Uint) Compare(other ref.Val) ref.Val { - switch ov := other.(type) { - case Double: - if math.IsNaN(float64(ov)) { - return NewErr("NaN values cannot be ordered") - } - return compareUintDouble(i, ov) - case Int: - return compareUintInt(i, ov) - case Uint: - return compareUint(i, ov) - default: - return MaybeNoSuchOverloadErr(other) - } -} - -// ConvertToNative implements ref.Val.ConvertToNative. -func (i Uint) ConvertToNative(typeDesc reflect.Type) (any, error) { - switch typeDesc.Kind() { - case reflect.Uint, reflect.Uint32: - v, err := uint64ToUint32Checked(uint64(i)) - if err != nil { - return 0, err - } - return reflect.ValueOf(v).Convert(typeDesc).Interface(), nil - case reflect.Uint64: - return reflect.ValueOf(i).Convert(typeDesc).Interface(), nil - case reflect.Ptr: - switch typeDesc { - case anyValueType: - // Primitives must be wrapped before being set on an Any field. - return anypb.New(wrapperspb.UInt64(uint64(i))) - case jsonValueType: - // JSON can accurately represent 32-bit uints as floating point values. - if i.isJSONSafe() { - return structpb.NewNumberValue(float64(i)), nil - } - // Proto3 to JSON conversion requires string-formatted uint64 values - // since the conversion to floating point would result in truncation. - return structpb.NewStringValue(strconv.FormatUint(uint64(i), 10)), nil - case uint32WrapperType: - // Convert the value to a wrapperspb.UInt32Value, error on overflow. - v, err := uint64ToUint32Checked(uint64(i)) - if err != nil { - return 0, err - } - return wrapperspb.UInt32(v), nil - case uint64WrapperType: - // Convert the value to a wrapperspb.UInt64Value. - return wrapperspb.UInt64(uint64(i)), nil - } - switch typeDesc.Elem().Kind() { - case reflect.Uint32: - v, err := uint64ToUint32Checked(uint64(i)) - if err != nil { - return 0, err - } - p := reflect.New(typeDesc.Elem()) - p.Elem().Set(reflect.ValueOf(v).Convert(typeDesc.Elem())) - return p.Interface(), nil - case reflect.Uint64: - v := uint64(i) - p := reflect.New(typeDesc.Elem()) - p.Elem().Set(reflect.ValueOf(v).Convert(typeDesc.Elem())) - return p.Interface(), nil - } - case reflect.Interface: - iv := i.Value() - if reflect.TypeOf(iv).Implements(typeDesc) { - return iv, nil - } - if reflect.TypeOf(i).Implements(typeDesc) { - return i, nil - } - } - return nil, fmt.Errorf("unsupported type conversion from 'uint' to %v", typeDesc) -} - -// ConvertToType implements ref.Val.ConvertToType. -func (i Uint) ConvertToType(typeVal ref.Type) ref.Val { - switch typeVal { - case IntType: - v, err := uint64ToInt64Checked(uint64(i)) - if err != nil { - return WrapErr(err) - } - return Int(v) - case UintType: - return i - case DoubleType: - return Double(i) - case StringType: - return String(fmt.Sprintf("%d", uint64(i))) - case TypeType: - return UintType - } - return NewErr("type conversion error from '%s' to '%s'", UintType, typeVal) -} - -// Divide implements traits.Divider.Divide. -func (i Uint) Divide(other ref.Val) ref.Val { - otherUint, ok := other.(Uint) - if !ok { - return MaybeNoSuchOverloadErr(other) - } - div, err := divideUint64Checked(uint64(i), uint64(otherUint)) - if err != nil { - return WrapErr(err) - } - return Uint(div) -} - -// Equal implements ref.Val.Equal. -func (i Uint) Equal(other ref.Val) ref.Val { - switch ov := other.(type) { - case Double: - if math.IsNaN(float64(ov)) { - return False - } - return Bool(compareUintDouble(i, ov) == 0) - case Int: - return Bool(compareUintInt(i, ov) == 0) - case Uint: - return Bool(i == ov) - default: - return False - } -} - -// IsZeroValue returns true if the uint is zero. -func (i Uint) IsZeroValue() bool { - return i == 0 -} - -// Modulo implements traits.Modder.Modulo. -func (i Uint) Modulo(other ref.Val) ref.Val { - otherUint, ok := other.(Uint) - if !ok { - return MaybeNoSuchOverloadErr(other) - } - mod, err := moduloUint64Checked(uint64(i), uint64(otherUint)) - if err != nil { - return WrapErr(err) - } - return Uint(mod) -} - -// Multiply implements traits.Multiplier.Multiply. -func (i Uint) Multiply(other ref.Val) ref.Val { - otherUint, ok := other.(Uint) - if !ok { - return MaybeNoSuchOverloadErr(other) - } - val, err := multiplyUint64Checked(uint64(i), uint64(otherUint)) - if err != nil { - return WrapErr(err) - } - return Uint(val) -} - -// Subtract implements traits.Subtractor.Subtract. -func (i Uint) Subtract(subtrahend ref.Val) ref.Val { - subtraUint, ok := subtrahend.(Uint) - if !ok { - return MaybeNoSuchOverloadErr(subtrahend) - } - val, err := subtractUint64Checked(uint64(i), uint64(subtraUint)) - if err != nil { - return WrapErr(err) - } - return Uint(val) -} - -// Type implements ref.Val.Type. -func (i Uint) Type() ref.Type { - return UintType -} - -// Value implements ref.Val.Value. -func (i Uint) Value() any { - return uint64(i) -} - -// isJSONSafe indicates whether the uint is safely representable as a floating point value in JSON. -func (i Uint) isJSONSafe() bool { - return i <= maxIntJSON -} diff --git a/vendor/github.com/google/cel-go/common/types/unknown.go b/vendor/github.com/google/cel-go/common/types/unknown.go deleted file mode 100644 index 9dd2b2579..000000000 --- a/vendor/github.com/google/cel-go/common/types/unknown.go +++ /dev/null @@ -1,326 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "fmt" - "math" - "reflect" - "sort" - "strings" - "unicode" - - "github.com/google/cel-go/common/types/ref" -) - -var ( - unspecifiedAttribute = &AttributeTrail{qualifierPath: []any{}} -) - -// NewAttributeTrail creates a new simple attribute from a variable name. -func NewAttributeTrail(variable string) *AttributeTrail { - if variable == "" { - return unspecifiedAttribute - } - return &AttributeTrail{variable: variable} -} - -// AttributeTrail specifies a variable with an optional qualifier path. An attribute value is expected to -// correspond to an AbsoluteAttribute, meaning a field selection which starts with a top-level variable. -// -// The qualifer path elements adhere to the AttributeQualifier type constraint. -type AttributeTrail struct { - variable string - qualifierPath []any -} - -// Equal returns whether two attribute values have the same variable name and qualifier paths. -func (a *AttributeTrail) Equal(other *AttributeTrail) bool { - if a.Variable() != other.Variable() || len(a.QualifierPath()) != len(other.QualifierPath()) { - return false - } - for i, q := range a.QualifierPath() { - qual := other.QualifierPath()[i] - if !qualifiersEqual(q, qual) { - return false - } - } - return true -} - -func qualifiersEqual(a, b any) bool { - if a == b { - return true - } - switch numA := a.(type) { - case int64: - numB, ok := b.(uint64) - if !ok { - return false - } - return intUintEqual(numA, numB) - case uint64: - numB, ok := b.(int64) - if !ok { - return false - } - return intUintEqual(numB, numA) - default: - return false - } -} - -func intUintEqual(i int64, u uint64) bool { - if i < 0 || u > math.MaxInt64 { - return false - } - return i == int64(u) -} - -// Variable returns the variable name associated with the attribute. -func (a *AttributeTrail) Variable() string { - return a.variable -} - -// QualifierPath returns the optional set of qualifying fields or indices applied to the variable. -func (a *AttributeTrail) QualifierPath() []any { - return a.qualifierPath -} - -// String returns the string representation of the Attribute. -func (a *AttributeTrail) String() string { - if a.variable == "" { - return "" - } - var str strings.Builder - str.WriteString(a.variable) - for _, q := range a.qualifierPath { - switch q := q.(type) { - case bool, int64: - str.WriteString(fmt.Sprintf("[%v]", q)) - case uint64: - str.WriteString(fmt.Sprintf("[%vu]", q)) - case string: - if isIdentifierCharacter(q) { - str.WriteString(fmt.Sprintf(".%v", q)) - } else { - str.WriteString(fmt.Sprintf("[%q]", q)) - } - } - } - return str.String() -} - -func isIdentifierCharacter(str string) bool { - for _, c := range str { - if unicode.IsLetter(c) || unicode.IsDigit(c) || string(c) == "_" { - continue - } - return false - } - return true -} - -// AttributeQualifier constrains the possible types which may be used to qualify an attribute. -type AttributeQualifier interface { - bool | int64 | uint64 | string -} - -// QualifyAttribute qualifies an attribute using a valid AttributeQualifier type. -func QualifyAttribute[T AttributeQualifier](attr *AttributeTrail, qualifier T) *AttributeTrail { - attr.qualifierPath = append(attr.qualifierPath, qualifier) - return attr -} - -// Unknown type which collects expression ids which caused the current value to become unknown. -type Unknown struct { - attributeTrails map[int64][]*AttributeTrail -} - -// NewUnknown creates a new unknown at a given expression id for an attribute. -// -// If the attribute is nil, the attribute value will be the `unspecifiedAttribute`. -func NewUnknown(id int64, attr *AttributeTrail) *Unknown { - if attr == nil { - attr = unspecifiedAttribute - } - return &Unknown{ - attributeTrails: map[int64][]*AttributeTrail{id: {attr}}, - } -} - -// IDs returns the set of unknown expression ids contained by this value. -// -// Numeric identifiers are guaranteed to be in sorted order. -func (u *Unknown) IDs() []int64 { - ids := make(int64Slice, len(u.attributeTrails)) - i := 0 - for id := range u.attributeTrails { - ids[i] = id - i++ - } - ids.Sort() - return ids -} - -// GetAttributeTrails returns the attribute trails, if present, missing for a given expression id. -func (u *Unknown) GetAttributeTrails(id int64) ([]*AttributeTrail, bool) { - trails, found := u.attributeTrails[id] - return trails, found -} - -// Contains returns true if the input unknown is a subset of the current unknown. -func (u *Unknown) Contains(other *Unknown) bool { - for id, otherTrails := range other.attributeTrails { - trails, found := u.attributeTrails[id] - if !found || len(otherTrails) != len(trails) { - return false - } - for _, ot := range otherTrails { - found := false - for _, t := range trails { - if t.Equal(ot) { - found = true - break - } - } - if !found { - return false - } - } - } - return true -} - -// ConvertToNative implements ref.Val.ConvertToNative. -func (u *Unknown) ConvertToNative(typeDesc reflect.Type) (any, error) { - return u.Value(), nil -} - -// ConvertToType is an identity function since unknown values cannot be modified. -func (u *Unknown) ConvertToType(typeVal ref.Type) ref.Val { - return u -} - -// Equal is an identity function since unknown values cannot be modified. -func (u *Unknown) Equal(other ref.Val) ref.Val { - return u -} - -// String implements the Stringer interface -func (u *Unknown) String() string { - var str strings.Builder - for id, attrs := range u.attributeTrails { - if str.Len() != 0 { - str.WriteString(", ") - } - if len(attrs) == 1 { - str.WriteString(fmt.Sprintf("%v (%d)", attrs[0], id)) - } else { - str.WriteString(fmt.Sprintf("%v (%d)", attrs, id)) - } - } - return str.String() -} - -// Type implements ref.Val.Type. -func (u *Unknown) Type() ref.Type { - return UnknownType -} - -// Value implements ref.Val.Value. -func (u *Unknown) Value() any { - return u -} - -// IsUnknown returns whether the element ref.Val is in instance of *types.Unknown -func IsUnknown(val ref.Val) bool { - switch val.(type) { - case *Unknown: - return true - default: - return false - } -} - -// MaybeMergeUnknowns determines whether an input value and another, possibly nil, unknown will produce -// an unknown result. -// -// If the input `val` is another Unknown, then the result will be the merge of the `val` and the input -// `unk`. If the `val` is not unknown, then the result will depend on whether the input `unk` is nil. -// If both values are non-nil and unknown, then the return value will be a merge of both unknowns. -func MaybeMergeUnknowns(val ref.Val, unk *Unknown) (*Unknown, bool) { - src, isUnk := val.(*Unknown) - if !isUnk { - if unk != nil { - return unk, true - } - return unk, false - } - return MergeUnknowns(src, unk), true -} - -// MergeUnknowns combines two unknown values into a new unknown value. -func MergeUnknowns(unk1, unk2 *Unknown) *Unknown { - if unk1 == nil { - return unk2 - } - if unk2 == nil { - return unk1 - } - out := &Unknown{ - attributeTrails: make(map[int64][]*AttributeTrail, len(unk1.attributeTrails)+len(unk2.attributeTrails)), - } - for id, ats := range unk1.attributeTrails { - out.attributeTrails[id] = ats - } - for id, ats := range unk2.attributeTrails { - existing, found := out.attributeTrails[id] - if !found { - out.attributeTrails[id] = ats - continue - } - - for _, at := range ats { - found := false - for _, et := range existing { - if at.Equal(et) { - found = true - break - } - } - if !found { - existing = append(existing, at) - } - } - out.attributeTrails[id] = existing - } - return out -} - -// int64Slice is an implementation of the sort.Interface -type int64Slice []int64 - -// Len returns the number of elements in the slice. -func (x int64Slice) Len() int { return len(x) } - -// Less indicates whether the value at index i is less than the value at index j. -func (x int64Slice) Less(i, j int) bool { return x[i] < x[j] } - -// Swap swaps the values at indices i and j in place. -func (x int64Slice) Swap(i, j int) { x[i], x[j] = x[j], x[i] } - -// Sort is a convenience method: x.Sort() calls Sort(x). -func (x int64Slice) Sort() { sort.Sort(x) } diff --git a/vendor/github.com/google/cel-go/common/types/util.go b/vendor/github.com/google/cel-go/common/types/util.go deleted file mode 100644 index 71662eee3..000000000 --- a/vendor/github.com/google/cel-go/common/types/util.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "github.com/google/cel-go/common/types/ref" -) - -// IsUnknownOrError returns whether the input element ref.Val is an ErrType or UnknownType. -func IsUnknownOrError(val ref.Val) bool { - switch val.(type) { - case *Unknown, *Err: - return true - } - return false -} - -// IsPrimitiveType returns whether the input element ref.Val is a primitive type. -// Note, primitive types do not include well-known types such as Duration and Timestamp. -func IsPrimitiveType(val ref.Val) bool { - switch val.Type() { - case BoolType, BytesType, DoubleType, IntType, StringType, UintType: - return true - } - return false -} - -// Equal returns whether the two ref.Value are heterogeneously equivalent. -func Equal(lhs ref.Val, rhs ref.Val) ref.Val { - lNull := lhs == NullValue - rNull := rhs == NullValue - if lNull || rNull { - return Bool(lNull == rNull) - } - return lhs.Equal(rhs) -} diff --git a/vendor/github.com/google/cel-go/interpreter/BUILD.bazel b/vendor/github.com/google/cel-go/interpreter/BUILD.bazel deleted file mode 100644 index 220e23d47..000000000 --- a/vendor/github.com/google/cel-go/interpreter/BUILD.bazel +++ /dev/null @@ -1,74 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -package( - default_visibility = ["//visibility:public"], - licenses = ["notice"], # Apache 2.0 -) - -go_library( - name = "go_default_library", - srcs = [ - "activation.go", - "attribute_patterns.go", - "attributes.go", - "decorators.go", - "dispatcher.go", - "evalstate.go", - "interpretable.go", - "interpreter.go", - "optimizations.go", - "planner.go", - "prune.go", - "runtimecost.go", - ], - importpath = "github.com/google/cel-go/interpreter", - deps = [ - "//common:go_default_library", - "//common/ast:go_default_library", - "//common/containers:go_default_library", - "//common/functions:go_default_library", - "//common/operators:go_default_library", - "//common/overloads:go_default_library", - "//common/types:go_default_library", - "//common/types/ref:go_default_library", - "//common/types/traits:go_default_library", - "@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library", - "@org_golang_google_protobuf//proto:go_default_library", - "@org_golang_google_protobuf//types/known/durationpb:go_default_library", - "@org_golang_google_protobuf//types/known/structpb:go_default_library", - "@org_golang_google_protobuf//types/known/timestamppb:go_default_library", - "@org_golang_google_protobuf//types/known/wrapperspb:go_default_library", - ], -) - -go_test( - name = "go_default_test", - srcs = [ - "activation_test.go", - "attribute_patterns_test.go", - "attributes_test.go", - "interpreter_test.go", - "prune_test.go", - "runtimecost_test.go", - ], - embed = [ - ":go_default_library", - ], - deps = [ - "//checker:go_default_library", - "//common/containers:go_default_library", - "//common/debug:go_default_library", - "//common/decls:go_default_library", - "//common/functions:go_default_library", - "//common/operators:go_default_library", - "//common/stdlib:go_default_library", - "//common/types:go_default_library", - "//parser:go_default_library", - "//test:go_default_library", - "//test/proto2pb:go_default_library", - "//test/proto3pb:go_default_library", - "@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library", - "@org_golang_google_protobuf//proto:go_default_library", - "@org_golang_google_protobuf//types/known/anypb:go_default_library", - ], -) diff --git a/vendor/github.com/google/cel-go/interpreter/activation.go b/vendor/github.com/google/cel-go/interpreter/activation.go deleted file mode 100644 index a80264451..000000000 --- a/vendor/github.com/google/cel-go/interpreter/activation.go +++ /dev/null @@ -1,201 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package interpreter - -import ( - "errors" - "fmt" - "sync" - - "github.com/google/cel-go/common/types/ref" -) - -// Activation used to resolve identifiers by name and references by id. -// -// An Activation is the primary mechanism by which a caller supplies input into a CEL program. -type Activation interface { - // ResolveName returns a value from the activation by qualified name, or false if the name - // could not be found. - ResolveName(name string) (any, bool) - - // Parent returns the parent of the current activation, may be nil. - // If non-nil, the parent will be searched during resolve calls. - Parent() Activation -} - -// EmptyActivation returns a variable-free activation. -func EmptyActivation() Activation { - return emptyActivation{} -} - -// emptyActivation is a variable-free activation. -type emptyActivation struct{} - -func (emptyActivation) ResolveName(string) (any, bool) { return nil, false } -func (emptyActivation) Parent() Activation { return nil } - -// NewActivation returns an activation based on a map-based binding where the map keys are -// expected to be qualified names used with ResolveName calls. -// -// The input `bindings` may either be of type `Activation` or `map[string]any`. -// -// Lazy bindings may be supplied within the map-based input in either of the following forms: -// - func() any -// - func() ref.Val -// -// The output of the lazy binding will overwrite the variable reference in the internal map. -// -// Values which are not represented as ref.Val types on input may be adapted to a ref.Val using -// the types.Adapter configured in the environment. -func NewActivation(bindings any) (Activation, error) { - if bindings == nil { - return nil, errors.New("bindings must be non-nil") - } - a, isActivation := bindings.(Activation) - if isActivation { - return a, nil - } - m, isMap := bindings.(map[string]any) - if !isMap { - return nil, fmt.Errorf( - "activation input must be an activation or map[string]interface: got %T", - bindings) - } - return &mapActivation{bindings: m}, nil -} - -// mapActivation which implements Activation and maps of named values. -// -// Named bindings may lazily supply values by providing a function which accepts no arguments and -// produces an interface value. -type mapActivation struct { - bindings map[string]any -} - -// Parent implements the Activation interface method. -func (a *mapActivation) Parent() Activation { - return nil -} - -// ResolveName implements the Activation interface method. -func (a *mapActivation) ResolveName(name string) (any, bool) { - obj, found := a.bindings[name] - if !found { - return nil, false - } - fn, isLazy := obj.(func() ref.Val) - if isLazy { - obj = fn() - a.bindings[name] = obj - } - fnRaw, isLazy := obj.(func() any) - if isLazy { - obj = fnRaw() - a.bindings[name] = obj - } - return obj, found -} - -// hierarchicalActivation which implements Activation and contains a parent and -// child activation. -type hierarchicalActivation struct { - parent Activation - child Activation -} - -// Parent implements the Activation interface method. -func (a *hierarchicalActivation) Parent() Activation { - return a.parent -} - -// ResolveName implements the Activation interface method. -func (a *hierarchicalActivation) ResolveName(name string) (any, bool) { - if object, found := a.child.ResolveName(name); found { - return object, found - } - return a.parent.ResolveName(name) -} - -// NewHierarchicalActivation takes two activations and produces a new one which prioritizes -// resolution in the child first and parent(s) second. -func NewHierarchicalActivation(parent Activation, child Activation) Activation { - return &hierarchicalActivation{parent, child} -} - -// NewPartialActivation returns an Activation which contains a list of AttributePattern values -// representing field and index operations that should result in a 'types.Unknown' result. -// -// The `bindings` value may be any value type supported by the interpreter.NewActivation call, -// but is typically either an existing Activation or map[string]any. -func NewPartialActivation(bindings any, - unknowns ...*AttributePattern) (PartialActivation, error) { - a, err := NewActivation(bindings) - if err != nil { - return nil, err - } - return &partActivation{Activation: a, unknowns: unknowns}, nil -} - -// PartialActivation extends the Activation interface with a set of UnknownAttributePatterns. -type PartialActivation interface { - Activation - - // UnknownAttributePaths returns a set of AttributePattern values which match Attribute - // expressions for data accesses whose values are not yet known. - UnknownAttributePatterns() []*AttributePattern -} - -// partActivation is the default implementations of the PartialActivation interface. -type partActivation struct { - Activation - unknowns []*AttributePattern -} - -// UnknownAttributePatterns implements the PartialActivation interface method. -func (a *partActivation) UnknownAttributePatterns() []*AttributePattern { - return a.unknowns -} - -// varActivation represents a single mutable variable binding. -// -// This activation type should only be used within folds as the fold loop controls the object -// life-cycle. -type varActivation struct { - parent Activation - name string - val ref.Val -} - -// Parent implements the Activation interface method. -func (v *varActivation) Parent() Activation { - return v.parent -} - -// ResolveName implements the Activation interface method. -func (v *varActivation) ResolveName(name string) (any, bool) { - if name == v.name { - return v.val, true - } - return v.parent.ResolveName(name) -} - -var ( - // pool of var activations to reduce allocations during folds. - varActivationPool = &sync.Pool{ - New: func() any { - return &varActivation{} - }, - } -) diff --git a/vendor/github.com/google/cel-go/interpreter/attribute_patterns.go b/vendor/github.com/google/cel-go/interpreter/attribute_patterns.go deleted file mode 100644 index 1fbaaf17e..000000000 --- a/vendor/github.com/google/cel-go/interpreter/attribute_patterns.go +++ /dev/null @@ -1,399 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package interpreter - -import ( - "fmt" - - "github.com/google/cel-go/common/containers" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/common/types/ref" -) - -// AttributePattern represents a top-level variable with an optional set of qualifier patterns. -// -// When using a CEL expression within a container, e.g. a package or namespace, the variable name -// in the pattern must match the qualified name produced during the variable namespace resolution. -// For example, if variable `c` appears in an expression whose container is `a.b`, the variable -// name supplied to the pattern must be `a.b.c` -// -// The qualifier patterns for attribute matching must be one of the following: -// -// - valid map key type: string, int, uint, bool -// - wildcard (*) -// -// Examples: -// -// 1. ns.myvar["complex-value"] -// 2. ns.myvar["complex-value"][0] -// 3. ns.myvar["complex-value"].*.name -// -// The first example is simple: match an attribute where the variable is 'ns.myvar' with a -// field access on 'complex-value'. The second example expands the match to indicate that only -// a specific index `0` should match. And lastly, the third example matches any indexed access -// that later selects the 'name' field. -type AttributePattern struct { - variable string - qualifierPatterns []*AttributeQualifierPattern -} - -// NewAttributePattern produces a new mutable AttributePattern based on a variable name. -func NewAttributePattern(variable string) *AttributePattern { - return &AttributePattern{ - variable: variable, - qualifierPatterns: []*AttributeQualifierPattern{}, - } -} - -// QualString adds a string qualifier pattern to the AttributePattern. The string may be a valid -// identifier, or string map key including empty string. -func (apat *AttributePattern) QualString(pattern string) *AttributePattern { - apat.qualifierPatterns = append(apat.qualifierPatterns, - &AttributeQualifierPattern{value: pattern}) - return apat -} - -// QualInt adds an int qualifier pattern to the AttributePattern. The index may be either a map or -// list index. -func (apat *AttributePattern) QualInt(pattern int64) *AttributePattern { - apat.qualifierPatterns = append(apat.qualifierPatterns, - &AttributeQualifierPattern{value: pattern}) - return apat -} - -// QualUint adds an uint qualifier pattern for a map index operation to the AttributePattern. -func (apat *AttributePattern) QualUint(pattern uint64) *AttributePattern { - apat.qualifierPatterns = append(apat.qualifierPatterns, - &AttributeQualifierPattern{value: pattern}) - return apat -} - -// QualBool adds a bool qualifier pattern for a map index operation to the AttributePattern. -func (apat *AttributePattern) QualBool(pattern bool) *AttributePattern { - apat.qualifierPatterns = append(apat.qualifierPatterns, - &AttributeQualifierPattern{value: pattern}) - return apat -} - -// Wildcard adds a special sentinel qualifier pattern that will match any single qualifier. -func (apat *AttributePattern) Wildcard() *AttributePattern { - apat.qualifierPatterns = append(apat.qualifierPatterns, - &AttributeQualifierPattern{wildcard: true}) - return apat -} - -// VariableMatches returns true if the fully qualified variable matches the AttributePattern -// fully qualified variable name. -func (apat *AttributePattern) VariableMatches(variable string) bool { - return apat.variable == variable -} - -// QualifierPatterns returns the set of AttributeQualifierPattern values on the AttributePattern. -func (apat *AttributePattern) QualifierPatterns() []*AttributeQualifierPattern { - return apat.qualifierPatterns -} - -// AttributeQualifierPattern holds a wildcard or valued qualifier pattern. -type AttributeQualifierPattern struct { - wildcard bool - value any -} - -// Matches returns true if the qualifier pattern is a wildcard, or the Qualifier implements the -// qualifierValueEquator interface and its IsValueEqualTo returns true for the qualifier pattern. -func (qpat *AttributeQualifierPattern) Matches(q Qualifier) bool { - if qpat.wildcard { - return true - } - qve, ok := q.(qualifierValueEquator) - return ok && qve.QualifierValueEquals(qpat.value) -} - -// qualifierValueEquator defines an interface for determining if an input value, of valid map key -// type, is equal to the value held in the Qualifier. This interface is used by the -// AttributeQualifierPattern to determine pattern matches for non-wildcard qualifier patterns. -// -// Note: Attribute values are also Qualifier values; however, Attributes are resolved before -// qualification happens. This is an implementation detail, but one relevant to why the Attribute -// types do not surface in the list of implementations. -// -// See: partialAttributeFactory.matchesUnknownPatterns for more details on how this interface is -// used. -type qualifierValueEquator interface { - // QualifierValueEquals returns true if the input value is equal to the value held in the - // Qualifier. - QualifierValueEquals(value any) bool -} - -// QualifierValueEquals implementation for boolean qualifiers. -func (q *boolQualifier) QualifierValueEquals(value any) bool { - bval, ok := value.(bool) - return ok && q.value == bval -} - -// QualifierValueEquals implementation for field qualifiers. -func (q *fieldQualifier) QualifierValueEquals(value any) bool { - sval, ok := value.(string) - return ok && q.Name == sval -} - -// QualifierValueEquals implementation for string qualifiers. -func (q *stringQualifier) QualifierValueEquals(value any) bool { - sval, ok := value.(string) - return ok && q.value == sval -} - -// QualifierValueEquals implementation for int qualifiers. -func (q *intQualifier) QualifierValueEquals(value any) bool { - return numericValueEquals(value, q.celValue) -} - -// QualifierValueEquals implementation for uint qualifiers. -func (q *uintQualifier) QualifierValueEquals(value any) bool { - return numericValueEquals(value, q.celValue) -} - -// QualifierValueEquals implementation for double qualifiers. -func (q *doubleQualifier) QualifierValueEquals(value any) bool { - return numericValueEquals(value, q.celValue) -} - -// numericValueEquals uses CEL equality to determine whether two number values are -func numericValueEquals(value any, celValue ref.Val) bool { - val := types.DefaultTypeAdapter.NativeToValue(value) - return celValue.Equal(val) == types.True -} - -// NewPartialAttributeFactory returns an AttributeFactory implementation capable of performing -// AttributePattern matches with PartialActivation inputs. -func NewPartialAttributeFactory(container *containers.Container, - adapter types.Adapter, - provider types.Provider) AttributeFactory { - fac := NewAttributeFactory(container, adapter, provider) - return &partialAttributeFactory{ - AttributeFactory: fac, - container: container, - adapter: adapter, - provider: provider, - } -} - -type partialAttributeFactory struct { - AttributeFactory - container *containers.Container - adapter types.Adapter - provider types.Provider -} - -// AbsoluteAttribute implementation of the AttributeFactory interface which wraps the -// NamespacedAttribute resolution in an internal attributeMatcher object to dynamically match -// unknown patterns from PartialActivation inputs if given. -func (fac *partialAttributeFactory) AbsoluteAttribute(id int64, names ...string) NamespacedAttribute { - attr := fac.AttributeFactory.AbsoluteAttribute(id, names...) - return &attributeMatcher{fac: fac, NamespacedAttribute: attr} -} - -// MaybeAttribute implementation of the AttributeFactory interface which ensure that the set of -// 'maybe' NamespacedAttribute values are produced using the partialAttributeFactory rather than -// the base AttributeFactory implementation. -func (fac *partialAttributeFactory) MaybeAttribute(id int64, name string) Attribute { - return &maybeAttribute{ - id: id, - attrs: []NamespacedAttribute{ - fac.AbsoluteAttribute(id, fac.container.ResolveCandidateNames(name)...), - }, - adapter: fac.adapter, - provider: fac.provider, - fac: fac, - } -} - -// matchesUnknownPatterns returns true if the variable names and qualifiers for a given -// Attribute value match any of the ActivationPattern objects in the set of unknown activation -// patterns on the given PartialActivation. -// -// For example, in the expression `a.b`, the Attribute is composed of variable `a`, with string -// qualifier `b`. When a PartialActivation is supplied, it indicates that some or all of the data -// provided in the input is unknown by specifying unknown AttributePatterns. An AttributePattern -// that refers to variable `a` with a string qualifier of `c` will not match `a.b`; however, any -// of the following patterns will match Attribute `a.b`: -// -// - `AttributePattern("a")` -// - `AttributePattern("a").Wildcard()` -// - `AttributePattern("a").QualString("b")` -// - `AttributePattern("a").QualString("b").QualInt(0)` -// -// Any AttributePattern which overlaps an Attribute or vice-versa will produce an Unknown result -// for the last pattern matched variable or qualifier in the Attribute. In the first matching -// example, the expression id representing variable `a` would be listed in the Unknown result, -// whereas in the other pattern examples, the qualifier `b` would be returned as the Unknown. -func (fac *partialAttributeFactory) matchesUnknownPatterns( - vars PartialActivation, - attrID int64, - variableNames []string, - qualifiers []Qualifier) (*types.Unknown, error) { - patterns := vars.UnknownAttributePatterns() - candidateIndices := map[int]struct{}{} - for _, variable := range variableNames { - for i, pat := range patterns { - if pat.VariableMatches(variable) { - if len(qualifiers) == 0 { - return types.NewUnknown(attrID, types.NewAttributeTrail(variable)), nil - } - candidateIndices[i] = struct{}{} - } - } - } - // Determine whether to return early if there are no candidate unknown patterns. - if len(candidateIndices) == 0 { - return nil, nil - } - // Resolve the attribute qualifiers into a static set. This prevents more dynamic - // Attribute resolutions than necessary when there are multiple unknown patterns - // that traverse the same Attribute-based qualifier field. - newQuals := make([]Qualifier, len(qualifiers)) - for i, qual := range qualifiers { - attr, isAttr := qual.(Attribute) - if isAttr { - val, err := attr.Resolve(vars) - if err != nil { - return nil, err - } - // If this resolution behavior ever changes, new implementations of the - // qualifierValueEquator may be required to handle proper resolution. - qual, err = fac.NewQualifier(nil, qual.ID(), val, attr.IsOptional()) - if err != nil { - return nil, err - } - } - newQuals[i] = qual - } - // Determine whether any of the unknown patterns match. - for patIdx := range candidateIndices { - pat := patterns[patIdx] - isUnk := true - matchExprID := attrID - qualPats := pat.QualifierPatterns() - for i, qual := range newQuals { - if i >= len(qualPats) { - break - } - matchExprID = qual.ID() - qualPat := qualPats[i] - // Note, the AttributeQualifierPattern relies on the input Qualifier not being an - // Attribute, since there is no way to resolve the Attribute with the information - // provided to the Matches call. - if !qualPat.Matches(qual) { - isUnk = false - break - } - } - if isUnk { - attr := types.NewAttributeTrail(pat.variable) - for i := 0; i < len(qualPats) && i < len(newQuals); i++ { - if qual, ok := newQuals[i].(ConstantQualifier); ok { - switch v := qual.Value().Value().(type) { - case bool: - types.QualifyAttribute[bool](attr, v) - case float64: - types.QualifyAttribute[int64](attr, int64(v)) - case int64: - types.QualifyAttribute[int64](attr, v) - case string: - types.QualifyAttribute[string](attr, v) - case uint64: - types.QualifyAttribute[uint64](attr, v) - default: - types.QualifyAttribute[string](attr, fmt.Sprintf("%v", v)) - } - } else { - types.QualifyAttribute[string](attr, "*") - } - } - return types.NewUnknown(matchExprID, attr), nil - } - } - return nil, nil -} - -// attributeMatcher embeds the NamespacedAttribute interface which allows it to participate in -// AttributePattern matching against Attribute values without having to modify the code paths that -// identify Attributes in expressions. -type attributeMatcher struct { - NamespacedAttribute - qualifiers []Qualifier - fac *partialAttributeFactory -} - -// AddQualifier implements the Attribute interface method. -func (m *attributeMatcher) AddQualifier(qual Qualifier) (Attribute, error) { - // Add the qualifier to the embedded NamespacedAttribute. If the input to the Resolve - // method is not a PartialActivation, or does not match an unknown attribute pattern, the - // Resolve method is directly invoked on the underlying NamespacedAttribute. - _, err := m.NamespacedAttribute.AddQualifier(qual) - if err != nil { - return nil, err - } - // The attributeMatcher overloads TryResolve and will attempt to match unknown patterns against - // the variable name and qualifier set contained within the Attribute. These values are not - // directly inspectable on the top-level NamespacedAttribute interface and so are tracked within - // the attributeMatcher. - m.qualifiers = append(m.qualifiers, qual) - return m, nil -} - -// Resolve is an implementation of the NamespacedAttribute interface method which tests -// for matching unknown attribute patterns and returns types.Unknown if present. Otherwise, -// the standard Resolve logic applies. -func (m *attributeMatcher) Resolve(vars Activation) (any, error) { - id := m.NamespacedAttribute.ID() - // Bug in how partial activation is resolved, should search parents as well. - partial, isPartial := toPartialActivation(vars) - if isPartial { - unk, err := m.fac.matchesUnknownPatterns( - partial, - id, - m.CandidateVariableNames(), - m.qualifiers) - if err != nil { - return nil, err - } - if unk != nil { - return unk, nil - } - } - return m.NamespacedAttribute.Resolve(vars) -} - -// Qualify is an implementation of the Qualifier interface method. -func (m *attributeMatcher) Qualify(vars Activation, obj any) (any, error) { - return attrQualify(m.fac, vars, obj, m) -} - -// QualifyIfPresent is an implementation of the Qualifier interface method. -func (m *attributeMatcher) QualifyIfPresent(vars Activation, obj any, presenceOnly bool) (any, bool, error) { - return attrQualifyIfPresent(m.fac, vars, obj, m, presenceOnly) -} - -func toPartialActivation(vars Activation) (PartialActivation, bool) { - pv, ok := vars.(PartialActivation) - if ok { - return pv, true - } - if vars.Parent() != nil { - return toPartialActivation(vars.Parent()) - } - return nil, false -} diff --git a/vendor/github.com/google/cel-go/interpreter/attributes.go b/vendor/github.com/google/cel-go/interpreter/attributes.go deleted file mode 100644 index ca97bdfcf..000000000 --- a/vendor/github.com/google/cel-go/interpreter/attributes.go +++ /dev/null @@ -1,1337 +0,0 @@ -// Copyright 2019 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package interpreter - -import ( - "fmt" - "strings" - - "github.com/google/cel-go/common/containers" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/common/types/ref" - "github.com/google/cel-go/common/types/traits" -) - -// AttributeFactory provides methods creating Attribute and Qualifier values. -type AttributeFactory interface { - // AbsoluteAttribute creates an attribute that refers to a top-level variable name. - // - // Checked expressions generate absolute attribute with a single name. - // Parse-only expressions may have more than one possible absolute identifier when the - // expression is created within a container, e.g. package or namespace. - // - // When there is more than one name supplied to the AbsoluteAttribute call, the names - // must be in CEL's namespace resolution order. The name arguments provided here are - // returned in the same order as they were provided by the NamespacedAttribute - // CandidateVariableNames method. - AbsoluteAttribute(id int64, names ...string) NamespacedAttribute - - // ConditionalAttribute creates an attribute with two Attribute branches, where the Attribute - // that is resolved depends on the boolean evaluation of the input 'expr'. - ConditionalAttribute(id int64, expr Interpretable, t, f Attribute) Attribute - - // MaybeAttribute creates an attribute that refers to either a field selection or a namespaced - // variable name. - // - // Only expressions which have not been type-checked may generate oneof attributes. - MaybeAttribute(id int64, name string) Attribute - - // RelativeAttribute creates an attribute whose value is a qualification of a dynamic - // computation rather than a static variable reference. - RelativeAttribute(id int64, operand Interpretable) Attribute - - // NewQualifier creates a qualifier on the target object with a given value. - // - // The 'val' may be an Attribute or any proto-supported map key type: bool, int, string, uint. - // - // The qualifier may consider the object type being qualified, if present. If absent, the - // qualification should be considered dynamic and the qualification should still work, though - // it may be sub-optimal. - NewQualifier(objType *types.Type, qualID int64, val any, opt bool) (Qualifier, error) -} - -// Qualifier marker interface for designating different qualifier values and where they appear -// within field selections and index call expressions (`_[_]`). -type Qualifier interface { - // ID where the qualifier appears within an expression. - ID() int64 - - // IsOptional specifies whether the qualifier is optional. - // Instead of a direct qualification, an optional qualifier will be resolved via QualifyIfPresent - // rather than Qualify. A non-optional qualifier may also be resolved through QualifyIfPresent if - // the object to qualify is itself optional. - IsOptional() bool - - // Qualify performs a qualification, e.g. field selection, on the input object and returns - // the value of the access and whether the value was set. A non-nil value with a false presence - // test result indicates that the value being returned is the default value. - Qualify(vars Activation, obj any) (any, error) - - // QualifyIfPresent qualifies the object if the qualifier is declared or defined on the object. - // The 'presenceOnly' flag indicates that the value is not necessary, just a boolean status as - // to whether the qualifier is present. - QualifyIfPresent(vars Activation, obj any, presenceOnly bool) (any, bool, error) -} - -// ConstantQualifier interface embeds the Qualifier interface and provides an option to inspect the -// qualifier's constant value. -// -// Non-constant qualifiers are of Attribute type. -type ConstantQualifier interface { - Qualifier - - // Value returns the constant value associated with the qualifier. - Value() ref.Val -} - -// Attribute values are a variable or value with an optional set of qualifiers, such as field, key, -// or index accesses. -type Attribute interface { - Qualifier - - // AddQualifier adds a qualifier on the Attribute or error if the qualification is not a valid qualifier type. - AddQualifier(Qualifier) (Attribute, error) - - // Resolve returns the value of the Attribute and whether it was present given an Activation. - // For objects which support safe traversal, the value may be non-nil and the presence flag be false. - // - // If an error is encountered during attribute resolution, it will be returned immediately. - // If the attribute cannot be resolved within the Activation, the result must be: `nil`, `error` - // with the error indicating which variable was missing. - Resolve(Activation) (any, error) -} - -// NamespacedAttribute values are a variable within a namespace, and an optional set of qualifiers -// such as field, key, or index accesses. -type NamespacedAttribute interface { - Attribute - - // CandidateVariableNames returns the possible namespaced variable names for this Attribute in - // the CEL namespace resolution order. - CandidateVariableNames() []string - - // Qualifiers returns the list of qualifiers associated with the Attribute. - Qualifiers() []Qualifier -} - -// NewAttributeFactory returns a default AttributeFactory which is produces Attribute values -// capable of resolving types by simple names and qualify the values using the supported qualifier -// types: bool, int, string, and uint. -func NewAttributeFactory(cont *containers.Container, a types.Adapter, p types.Provider) AttributeFactory { - return &attrFactory{ - container: cont, - adapter: a, - provider: p, - } -} - -type attrFactory struct { - container *containers.Container - adapter types.Adapter - provider types.Provider -} - -// AbsoluteAttribute refers to a variable value and an optional qualifier path. -// -// The namespaceNames represent the names the variable could have based on namespace -// resolution rules. -func (r *attrFactory) AbsoluteAttribute(id int64, names ...string) NamespacedAttribute { - return &absoluteAttribute{ - id: id, - namespaceNames: names, - qualifiers: []Qualifier{}, - adapter: r.adapter, - provider: r.provider, - fac: r, - } -} - -// ConditionalAttribute supports the case where an attribute selection may occur on a conditional -// expression, e.g. (cond ? a : b).c -func (r *attrFactory) ConditionalAttribute(id int64, expr Interpretable, t, f Attribute) Attribute { - return &conditionalAttribute{ - id: id, - expr: expr, - truthy: t, - falsy: f, - adapter: r.adapter, - fac: r, - } -} - -// MaybeAttribute collects variants of unchecked AbsoluteAttribute values which could either be -// direct variable accesses or some combination of variable access with qualification. -func (r *attrFactory) MaybeAttribute(id int64, name string) Attribute { - return &maybeAttribute{ - id: id, - attrs: []NamespacedAttribute{ - r.AbsoluteAttribute(id, r.container.ResolveCandidateNames(name)...), - }, - adapter: r.adapter, - provider: r.provider, - fac: r, - } -} - -// RelativeAttribute refers to an expression and an optional qualifier path. -func (r *attrFactory) RelativeAttribute(id int64, operand Interpretable) Attribute { - return &relativeAttribute{ - id: id, - operand: operand, - qualifiers: []Qualifier{}, - adapter: r.adapter, - fac: r, - } -} - -// NewQualifier is an implementation of the AttributeFactory interface. -func (r *attrFactory) NewQualifier(objType *types.Type, qualID int64, val any, opt bool) (Qualifier, error) { - // Before creating a new qualifier check to see if this is a protobuf message field access. - // If so, use the precomputed GetFrom qualification method rather than the standard - // stringQualifier. - str, isStr := val.(string) - if isStr && objType != nil && objType.Kind() == types.StructKind { - ft, found := r.provider.FindStructFieldType(objType.TypeName(), str) - if found && ft.IsSet != nil && ft.GetFrom != nil { - return &fieldQualifier{ - id: qualID, - Name: str, - FieldType: ft, - adapter: r.adapter, - optional: opt, - }, nil - } - } - return newQualifier(r.adapter, qualID, val, opt) -} - -type absoluteAttribute struct { - id int64 - // namespaceNames represent the names the variable could have based on declared container - // (package) of the expression. - namespaceNames []string - qualifiers []Qualifier - adapter types.Adapter - provider types.Provider - fac AttributeFactory -} - -// ID implements the Attribute interface method. -func (a *absoluteAttribute) ID() int64 { - qualCount := len(a.qualifiers) - if qualCount == 0 { - return a.id - } - return a.qualifiers[qualCount-1].ID() -} - -// IsOptional returns trivially false for an attribute as the attribute represents a fully -// qualified variable name. If the attribute is used in an optional manner, then an attrQualifier -// is created and marks the attribute as optional. -func (a *absoluteAttribute) IsOptional() bool { - return false -} - -// AddQualifier implements the Attribute interface method. -func (a *absoluteAttribute) AddQualifier(qual Qualifier) (Attribute, error) { - a.qualifiers = append(a.qualifiers, qual) - return a, nil -} - -// CandidateVariableNames implements the NamespaceAttribute interface method. -func (a *absoluteAttribute) CandidateVariableNames() []string { - return a.namespaceNames -} - -// Qualifiers returns the list of Qualifier instances associated with the namespaced attribute. -func (a *absoluteAttribute) Qualifiers() []Qualifier { - return a.qualifiers -} - -// Qualify is an implementation of the Qualifier interface method. -func (a *absoluteAttribute) Qualify(vars Activation, obj any) (any, error) { - return attrQualify(a.fac, vars, obj, a) -} - -// QualifyIfPresent is an implementation of the Qualifier interface method. -func (a *absoluteAttribute) QualifyIfPresent(vars Activation, obj any, presenceOnly bool) (any, bool, error) { - return attrQualifyIfPresent(a.fac, vars, obj, a, presenceOnly) -} - -// String implements the Stringer interface method. -func (a *absoluteAttribute) String() string { - return fmt.Sprintf("id: %v, names: %v", a.id, a.namespaceNames) -} - -// Resolve returns the resolved Attribute value given the Activation, or error if the Attribute -// variable is not found, or if its Qualifiers cannot be applied successfully. -// -// If the variable name cannot be found as an Activation variable or in the TypeProvider as -// a type, then the result is `nil`, `error` with the error indicating the name of the first -// variable searched as missing. -func (a *absoluteAttribute) Resolve(vars Activation) (any, error) { - for _, nm := range a.namespaceNames { - // If the variable is found, process it. Otherwise, wait until the checks to - // determine whether the type is unknown before returning. - obj, found := vars.ResolveName(nm) - if found { - obj, isOpt, err := applyQualifiers(vars, obj, a.qualifiers) - if err != nil { - return nil, err - } - if isOpt { - val := a.adapter.NativeToValue(obj) - if types.IsUnknown(val) { - return val, nil - } - return types.OptionalOf(val), nil - } - return obj, nil - } - // Attempt to resolve the qualified type name if the name is not a variable identifier. - typ, found := a.provider.FindIdent(nm) - if found { - if len(a.qualifiers) == 0 { - return typ, nil - } - } - } - var attrNames strings.Builder - for i, nm := range a.namespaceNames { - if i != 0 { - attrNames.WriteString(", ") - } - attrNames.WriteString(nm) - } - return nil, missingAttribute(attrNames.String()) -} - -type conditionalAttribute struct { - id int64 - expr Interpretable - truthy Attribute - falsy Attribute - adapter types.Adapter - fac AttributeFactory -} - -// ID is an implementation of the Attribute interface method. -func (a *conditionalAttribute) ID() int64 { - // There's a field access after the conditional. - if a.truthy.ID() == a.falsy.ID() { - return a.truthy.ID() - } - // Otherwise return the conditional id as the consistent id being tracked. - return a.id -} - -// IsOptional returns trivially false for an attribute as the attribute represents a fully -// qualified variable name. If the attribute is used in an optional manner, then an attrQualifier -// is created and marks the attribute as optional. -func (a *conditionalAttribute) IsOptional() bool { - return false -} - -// AddQualifier appends the same qualifier to both sides of the conditional, in effect managing -// the qualification of alternate attributes. -func (a *conditionalAttribute) AddQualifier(qual Qualifier) (Attribute, error) { - _, err := a.truthy.AddQualifier(qual) - if err != nil { - return nil, err - } - _, err = a.falsy.AddQualifier(qual) - if err != nil { - return nil, err - } - return a, nil -} - -// Qualify is an implementation of the Qualifier interface method. -func (a *conditionalAttribute) Qualify(vars Activation, obj any) (any, error) { - return attrQualify(a.fac, vars, obj, a) -} - -// QualifyIfPresent is an implementation of the Qualifier interface method. -func (a *conditionalAttribute) QualifyIfPresent(vars Activation, obj any, presenceOnly bool) (any, bool, error) { - return attrQualifyIfPresent(a.fac, vars, obj, a, presenceOnly) -} - -// Resolve evaluates the condition, and then resolves the truthy or falsy branch accordingly. -func (a *conditionalAttribute) Resolve(vars Activation) (any, error) { - val := a.expr.Eval(vars) - if val == types.True { - return a.truthy.Resolve(vars) - } - if val == types.False { - return a.falsy.Resolve(vars) - } - if types.IsUnknown(val) { - return val, nil - } - return nil, types.MaybeNoSuchOverloadErr(val).(*types.Err) -} - -// String is an implementation of the Stringer interface method. -func (a *conditionalAttribute) String() string { - return fmt.Sprintf("id: %v, truthy attribute: %v, falsy attribute: %v", a.id, a.truthy, a.falsy) -} - -type maybeAttribute struct { - id int64 - attrs []NamespacedAttribute - adapter types.Adapter - provider types.Provider - fac AttributeFactory -} - -// ID is an implementation of the Attribute interface method. -func (a *maybeAttribute) ID() int64 { - return a.attrs[0].ID() -} - -// IsOptional returns trivially false for an attribute as the attribute represents a fully -// qualified variable name. If the attribute is used in an optional manner, then an attrQualifier -// is created and marks the attribute as optional. -func (a *maybeAttribute) IsOptional() bool { - return false -} - -// AddQualifier adds a qualifier to each possible attribute variant, and also creates -// a new namespaced variable from the qualified value. -// -// The algorithm for building the maybe attribute is as follows: -// -// 1. Create a maybe attribute from a simple identifier when it occurs in a parsed-only expression -// -// mb = MaybeAttribute(, "a") -// -// Initializing the maybe attribute creates an absolute attribute internally which includes the -// possible namespaced names of the attribute. In this example, let's assume we are in namespace -// 'ns', then the maybe is either one of the following variable names: -// -// possible variables names -- ns.a, a -// -// 2. Adding a qualifier to the maybe means that the variable name could be a longer qualified -// name, or a field selection on one of the possible variable names produced earlier: -// -// mb.AddQualifier("b") -// -// possible variables names -- ns.a.b, a.b -// possible field selection -- ns.a['b'], a['b'] -// -// If none of the attributes within the maybe resolves a value, the result is an error. -func (a *maybeAttribute) AddQualifier(qual Qualifier) (Attribute, error) { - str := "" - isStr := false - cq, isConst := qual.(ConstantQualifier) - if isConst { - str, isStr = cq.Value().Value().(string) - } - var augmentedNames []string - // First add the qualifier to all existing attributes in the oneof. - for _, attr := range a.attrs { - if isStr && len(attr.Qualifiers()) == 0 { - candidateVars := attr.CandidateVariableNames() - augmentedNames = make([]string, len(candidateVars)) - for i, name := range candidateVars { - augmentedNames[i] = fmt.Sprintf("%s.%s", name, str) - } - } - _, err := attr.AddQualifier(qual) - if err != nil { - return nil, err - } - } - // Next, ensure the most specific variable / type reference is searched first. - if len(augmentedNames) != 0 { - a.attrs = append([]NamespacedAttribute{a.fac.AbsoluteAttribute(qual.ID(), augmentedNames...)}, a.attrs...) - } - return a, nil -} - -// Qualify is an implementation of the Qualifier interface method. -func (a *maybeAttribute) Qualify(vars Activation, obj any) (any, error) { - return attrQualify(a.fac, vars, obj, a) -} - -// QualifyIfPresent is an implementation of the Qualifier interface method. -func (a *maybeAttribute) QualifyIfPresent(vars Activation, obj any, presenceOnly bool) (any, bool, error) { - return attrQualifyIfPresent(a.fac, vars, obj, a, presenceOnly) -} - -// Resolve follows the variable resolution rules to determine whether the attribute is a variable -// or a field selection. -func (a *maybeAttribute) Resolve(vars Activation) (any, error) { - var maybeErr error - for _, attr := range a.attrs { - obj, err := attr.Resolve(vars) - // Return an error if one is encountered. - if err != nil { - resErr, ok := err.(*resolutionError) - if !ok { - return nil, err - } - // If this was not a missing variable error, return it. - if !resErr.isMissingAttribute() { - return nil, err - } - // When the variable is missing in a maybe attribute we defer erroring. - if maybeErr == nil { - maybeErr = resErr - } - // Continue attempting to resolve possible variables. - continue - } - return obj, nil - } - // Else, produce a no such attribute error. - return nil, maybeErr -} - -// String is an implementation of the Stringer interface method. -func (a *maybeAttribute) String() string { - return fmt.Sprintf("id: %v, attributes: %v", a.id, a.attrs) -} - -type relativeAttribute struct { - id int64 - operand Interpretable - qualifiers []Qualifier - adapter types.Adapter - fac AttributeFactory -} - -// ID is an implementation of the Attribute interface method. -func (a *relativeAttribute) ID() int64 { - qualCount := len(a.qualifiers) - if qualCount == 0 { - return a.id - } - return a.qualifiers[qualCount-1].ID() -} - -// IsOptional returns trivially false for an attribute as the attribute represents a fully -// qualified variable name. If the attribute is used in an optional manner, then an attrQualifier -// is created and marks the attribute as optional. -func (a *relativeAttribute) IsOptional() bool { - return false -} - -// AddQualifier implements the Attribute interface method. -func (a *relativeAttribute) AddQualifier(qual Qualifier) (Attribute, error) { - a.qualifiers = append(a.qualifiers, qual) - return a, nil -} - -// Qualify is an implementation of the Qualifier interface method. -func (a *relativeAttribute) Qualify(vars Activation, obj any) (any, error) { - return attrQualify(a.fac, vars, obj, a) -} - -// QualifyIfPresent is an implementation of the Qualifier interface method. -func (a *relativeAttribute) QualifyIfPresent(vars Activation, obj any, presenceOnly bool) (any, bool, error) { - return attrQualifyIfPresent(a.fac, vars, obj, a, presenceOnly) -} - -// Resolve expression value and qualifier relative to the expression result. -func (a *relativeAttribute) Resolve(vars Activation) (any, error) { - // First, evaluate the operand. - v := a.operand.Eval(vars) - if types.IsError(v) { - return nil, v.(*types.Err) - } - if types.IsUnknown(v) { - return v, nil - } - obj, isOpt, err := applyQualifiers(vars, v, a.qualifiers) - if err != nil { - return nil, err - } - if isOpt { - val := a.adapter.NativeToValue(obj) - if types.IsUnknown(val) { - return val, nil - } - return types.OptionalOf(val), nil - } - return obj, nil -} - -// String is an implementation of the Stringer interface method. -func (a *relativeAttribute) String() string { - return fmt.Sprintf("id: %v, operand: %v", a.id, a.operand) -} - -func newQualifier(adapter types.Adapter, id int64, v any, opt bool) (Qualifier, error) { - var qual Qualifier - switch val := v.(type) { - case Attribute: - // Note, attributes are initially identified as non-optional since they represent a top-level - // field access; however, when used as a relative qualifier, e.g. a[?b.c], then an attrQualifier - // is created which intercepts the IsOptional check for the attribute in order to return the - // correct result. - return &attrQualifier{ - id: id, - Attribute: val, - optional: opt, - }, nil - case string: - qual = &stringQualifier{ - id: id, - value: val, - celValue: types.String(val), - adapter: adapter, - optional: opt, - } - case int: - qual = &intQualifier{ - id: id, value: int64(val), celValue: types.Int(val), adapter: adapter, optional: opt, - } - case int32: - qual = &intQualifier{ - id: id, value: int64(val), celValue: types.Int(val), adapter: adapter, optional: opt, - } - case int64: - qual = &intQualifier{ - id: id, value: val, celValue: types.Int(val), adapter: adapter, optional: opt, - } - case uint: - qual = &uintQualifier{ - id: id, value: uint64(val), celValue: types.Uint(val), adapter: adapter, optional: opt, - } - case uint32: - qual = &uintQualifier{ - id: id, value: uint64(val), celValue: types.Uint(val), adapter: adapter, optional: opt, - } - case uint64: - qual = &uintQualifier{ - id: id, value: val, celValue: types.Uint(val), adapter: adapter, optional: opt, - } - case bool: - qual = &boolQualifier{ - id: id, value: val, celValue: types.Bool(val), adapter: adapter, optional: opt, - } - case float32: - qual = &doubleQualifier{ - id: id, - value: float64(val), - celValue: types.Double(val), - adapter: adapter, - optional: opt, - } - case float64: - qual = &doubleQualifier{ - id: id, value: val, celValue: types.Double(val), adapter: adapter, optional: opt, - } - case types.String: - qual = &stringQualifier{ - id: id, value: string(val), celValue: val, adapter: adapter, optional: opt, - } - case types.Int: - qual = &intQualifier{ - id: id, value: int64(val), celValue: val, adapter: adapter, optional: opt, - } - case types.Uint: - qual = &uintQualifier{ - id: id, value: uint64(val), celValue: val, adapter: adapter, optional: opt, - } - case types.Bool: - qual = &boolQualifier{ - id: id, value: bool(val), celValue: val, adapter: adapter, optional: opt, - } - case types.Double: - qual = &doubleQualifier{ - id: id, value: float64(val), celValue: val, adapter: adapter, optional: opt, - } - case *types.Unknown: - qual = &unknownQualifier{id: id, value: val} - default: - if q, ok := v.(Qualifier); ok { - return q, nil - } - return nil, fmt.Errorf("invalid qualifier type: %T", v) - } - return qual, nil -} - -type attrQualifier struct { - id int64 - Attribute - optional bool -} - -// ID implements the Qualifier interface method and returns the qualification instruction id -// rather than the attribute id. -func (q *attrQualifier) ID() int64 { - return q.id -} - -// IsOptional implements the Qualifier interface method. -func (q *attrQualifier) IsOptional() bool { - return q.optional -} - -type stringQualifier struct { - id int64 - value string - celValue ref.Val - adapter types.Adapter - optional bool -} - -// ID is an implementation of the Qualifier interface method. -func (q *stringQualifier) ID() int64 { - return q.id -} - -// IsOptional implements the Qualifier interface method. -func (q *stringQualifier) IsOptional() bool { - return q.optional -} - -// Qualify implements the Qualifier interface method. -func (q *stringQualifier) Qualify(vars Activation, obj any) (any, error) { - val, _, err := q.qualifyInternal(vars, obj, false, false) - return val, err -} - -// QualifyIfPresent is an implementation of the Qualifier interface method. -func (q *stringQualifier) QualifyIfPresent(vars Activation, obj any, presenceOnly bool) (any, bool, error) { - return q.qualifyInternal(vars, obj, true, presenceOnly) -} - -func (q *stringQualifier) qualifyInternal(vars Activation, obj any, presenceTest, presenceOnly bool) (any, bool, error) { - s := q.value - switch o := obj.(type) { - case map[string]any: - obj, isKey := o[s] - if isKey { - return obj, true, nil - } - case map[string]string: - obj, isKey := o[s] - if isKey { - return obj, true, nil - } - case map[string]int: - obj, isKey := o[s] - if isKey { - return obj, true, nil - } - case map[string]int32: - obj, isKey := o[s] - if isKey { - return obj, true, nil - } - case map[string]int64: - obj, isKey := o[s] - if isKey { - return obj, true, nil - } - case map[string]uint: - obj, isKey := o[s] - if isKey { - return obj, true, nil - } - case map[string]uint32: - obj, isKey := o[s] - if isKey { - return obj, true, nil - } - case map[string]uint64: - obj, isKey := o[s] - if isKey { - return obj, true, nil - } - case map[string]float32: - obj, isKey := o[s] - if isKey { - return obj, true, nil - } - case map[string]float64: - obj, isKey := o[s] - if isKey { - return obj, true, nil - } - case map[string]bool: - obj, isKey := o[s] - if isKey { - return obj, true, nil - } - default: - return refQualify(q.adapter, obj, q.celValue, presenceTest, presenceOnly) - } - if presenceTest { - return nil, false, nil - } - return nil, false, missingKey(q.celValue) -} - -// Value implements the ConstantQualifier interface -func (q *stringQualifier) Value() ref.Val { - return q.celValue -} - -type intQualifier struct { - id int64 - value int64 - celValue ref.Val - adapter types.Adapter - optional bool -} - -// ID is an implementation of the Qualifier interface method. -func (q *intQualifier) ID() int64 { - return q.id -} - -// IsOptional implements the Qualifier interface method. -func (q *intQualifier) IsOptional() bool { - return q.optional -} - -// Qualify implements the Qualifier interface method. -func (q *intQualifier) Qualify(vars Activation, obj any) (any, error) { - val, _, err := q.qualifyInternal(vars, obj, false, false) - return val, err -} - -// QualifyIfPresent is an implementation of the Qualifier interface method. -func (q *intQualifier) QualifyIfPresent(vars Activation, obj any, presenceOnly bool) (any, bool, error) { - return q.qualifyInternal(vars, obj, true, presenceOnly) -} - -func (q *intQualifier) qualifyInternal(vars Activation, obj any, presenceTest, presenceOnly bool) (any, bool, error) { - i := q.value - var isMap bool - switch o := obj.(type) { - // The specialized map types supported by an int qualifier are considerably fewer than the set - // of specialized map types supported by string qualifiers since they are less frequently used - // than string-based map keys. Additional specializations may be added in the future if - // desired. - case map[int]any: - isMap = true - obj, isKey := o[int(i)] - if isKey { - return obj, true, nil - } - case map[int32]any: - isMap = true - obj, isKey := o[int32(i)] - if isKey { - return obj, true, nil - } - case map[int64]any: - isMap = true - obj, isKey := o[i] - if isKey { - return obj, true, nil - } - case []any: - isIndex := i >= 0 && i < int64(len(o)) - if isIndex { - return o[i], true, nil - } - case []string: - isIndex := i >= 0 && i < int64(len(o)) - if isIndex { - return o[i], true, nil - } - case []int: - isIndex := i >= 0 && i < int64(len(o)) - if isIndex { - return o[i], true, nil - } - case []int32: - isIndex := i >= 0 && i < int64(len(o)) - if isIndex { - return o[i], true, nil - } - case []int64: - isIndex := i >= 0 && i < int64(len(o)) - if isIndex { - return o[i], true, nil - } - case []uint: - isIndex := i >= 0 && i < int64(len(o)) - if isIndex { - return o[i], true, nil - } - case []uint32: - isIndex := i >= 0 && i < int64(len(o)) - if isIndex { - return o[i], true, nil - } - case []uint64: - isIndex := i >= 0 && i < int64(len(o)) - if isIndex { - return o[i], true, nil - } - case []float32: - isIndex := i >= 0 && i < int64(len(o)) - if isIndex { - return o[i], true, nil - } - case []float64: - isIndex := i >= 0 && i < int64(len(o)) - if isIndex { - return o[i], true, nil - } - case []bool: - isIndex := i >= 0 && i < int64(len(o)) - if isIndex { - return o[i], true, nil - } - default: - return refQualify(q.adapter, obj, q.celValue, presenceTest, presenceOnly) - } - if presenceTest { - return nil, false, nil - } - if isMap { - return nil, false, missingKey(q.celValue) - } - return nil, false, missingIndex(q.celValue) -} - -// Value implements the ConstantQualifier interface -func (q *intQualifier) Value() ref.Val { - return q.celValue -} - -type uintQualifier struct { - id int64 - value uint64 - celValue ref.Val - adapter types.Adapter - optional bool -} - -// ID is an implementation of the Qualifier interface method. -func (q *uintQualifier) ID() int64 { - return q.id -} - -// IsOptional implements the Qualifier interface method. -func (q *uintQualifier) IsOptional() bool { - return q.optional -} - -// Qualify implements the Qualifier interface method. -func (q *uintQualifier) Qualify(vars Activation, obj any) (any, error) { - val, _, err := q.qualifyInternal(vars, obj, false, false) - return val, err -} - -// QualifyIfPresent is an implementation of the Qualifier interface method. -func (q *uintQualifier) QualifyIfPresent(vars Activation, obj any, presenceOnly bool) (any, bool, error) { - return q.qualifyInternal(vars, obj, true, presenceOnly) -} - -func (q *uintQualifier) qualifyInternal(vars Activation, obj any, presenceTest, presenceOnly bool) (any, bool, error) { - u := q.value - switch o := obj.(type) { - // The specialized map types supported by a uint qualifier are considerably fewer than the set - // of specialized map types supported by string qualifiers since they are less frequently used - // than string-based map keys. Additional specializations may be added in the future if - // desired. - case map[uint]any: - obj, isKey := o[uint(u)] - if isKey { - return obj, true, nil - } - case map[uint32]any: - obj, isKey := o[uint32(u)] - if isKey { - return obj, true, nil - } - case map[uint64]any: - obj, isKey := o[u] - if isKey { - return obj, true, nil - } - default: - return refQualify(q.adapter, obj, q.celValue, presenceTest, presenceOnly) - } - if presenceTest { - return nil, false, nil - } - return nil, false, missingKey(q.celValue) -} - -// Value implements the ConstantQualifier interface -func (q *uintQualifier) Value() ref.Val { - return q.celValue -} - -type boolQualifier struct { - id int64 - value bool - celValue ref.Val - adapter types.Adapter - optional bool -} - -// ID is an implementation of the Qualifier interface method. -func (q *boolQualifier) ID() int64 { - return q.id -} - -// IsOptional implements the Qualifier interface method. -func (q *boolQualifier) IsOptional() bool { - return q.optional -} - -// Qualify implements the Qualifier interface method. -func (q *boolQualifier) Qualify(vars Activation, obj any) (any, error) { - val, _, err := q.qualifyInternal(vars, obj, false, false) - return val, err -} - -// QualifyIfPresent is an implementation of the Qualifier interface method. -func (q *boolQualifier) QualifyIfPresent(vars Activation, obj any, presenceOnly bool) (any, bool, error) { - return q.qualifyInternal(vars, obj, true, presenceOnly) -} - -func (q *boolQualifier) qualifyInternal(vars Activation, obj any, presenceTest, presenceOnly bool) (any, bool, error) { - b := q.value - switch o := obj.(type) { - case map[bool]any: - obj, isKey := o[b] - if isKey { - return obj, true, nil - } - default: - return refQualify(q.adapter, obj, q.celValue, presenceTest, presenceOnly) - } - if presenceTest { - return nil, false, nil - } - return nil, false, missingKey(q.celValue) -} - -// Value implements the ConstantQualifier interface -func (q *boolQualifier) Value() ref.Val { - return q.celValue -} - -// fieldQualifier indicates that the qualification is a well-defined field with a known -// field type. When the field type is known this can be used to improve the speed and -// efficiency of field resolution. -type fieldQualifier struct { - id int64 - Name string - FieldType *types.FieldType - adapter types.Adapter - optional bool -} - -// ID is an implementation of the Qualifier interface method. -func (q *fieldQualifier) ID() int64 { - return q.id -} - -// IsOptional implements the Qualifier interface method. -func (q *fieldQualifier) IsOptional() bool { - return q.optional -} - -// Qualify implements the Qualifier interface method. -func (q *fieldQualifier) Qualify(vars Activation, obj any) (any, error) { - if rv, ok := obj.(ref.Val); ok { - obj = rv.Value() - } - val, err := q.FieldType.GetFrom(obj) - if err != nil { - return nil, err - } - return val, nil -} - -// QualifyIfPresent is an implementation of the Qualifier interface method. -func (q *fieldQualifier) QualifyIfPresent(vars Activation, obj any, presenceOnly bool) (any, bool, error) { - if rv, ok := obj.(ref.Val); ok { - obj = rv.Value() - } - if !q.FieldType.IsSet(obj) { - return nil, false, nil - } - if presenceOnly { - return nil, true, nil - } - val, err := q.FieldType.GetFrom(obj) - if err != nil { - return nil, false, err - } - return val, true, nil -} - -// Value implements the ConstantQualifier interface -func (q *fieldQualifier) Value() ref.Val { - return types.String(q.Name) -} - -// doubleQualifier qualifies a CEL object, map, or list using a double value. -// -// This qualifier is used for working with dynamic data like JSON or protobuf.Any where the value -// type may not be known ahead of time and may not conform to the standard types supported as valid -// protobuf map key types. -type doubleQualifier struct { - id int64 - value float64 - celValue ref.Val - adapter types.Adapter - optional bool -} - -// ID is an implementation of the Qualifier interface method. -func (q *doubleQualifier) ID() int64 { - return q.id -} - -// IsOptional implements the Qualifier interface method. -func (q *doubleQualifier) IsOptional() bool { - return q.optional -} - -// Qualify implements the Qualifier interface method. -func (q *doubleQualifier) Qualify(vars Activation, obj any) (any, error) { - val, _, err := q.qualifyInternal(vars, obj, false, false) - return val, err -} - -func (q *doubleQualifier) QualifyIfPresent(vars Activation, obj any, presenceOnly bool) (any, bool, error) { - return q.qualifyInternal(vars, obj, true, presenceOnly) -} - -func (q *doubleQualifier) qualifyInternal(vars Activation, obj any, presenceTest, presenceOnly bool) (any, bool, error) { - return refQualify(q.adapter, obj, q.celValue, presenceTest, presenceOnly) -} - -// Value implements the ConstantQualifier interface -func (q *doubleQualifier) Value() ref.Val { - return q.celValue -} - -// unknownQualifier is a simple qualifier which always returns a preconfigured set of unknown values -// for any value subject to qualification. This is consistent with CEL's unknown handling elsewhere. -type unknownQualifier struct { - id int64 - value *types.Unknown -} - -// ID is an implementation of the Qualifier interface method. -func (q *unknownQualifier) ID() int64 { - return q.id -} - -// IsOptional returns trivially false as an the unknown value is always returned. -func (q *unknownQualifier) IsOptional() bool { - return false -} - -// Qualify returns the unknown value associated with this qualifier. -func (q *unknownQualifier) Qualify(vars Activation, obj any) (any, error) { - return q.value, nil -} - -// QualifyIfPresent is an implementation of the Qualifier interface method. -func (q *unknownQualifier) QualifyIfPresent(vars Activation, obj any, presenceOnly bool) (any, bool, error) { - return q.value, true, nil -} - -// Value implements the ConstantQualifier interface -func (q *unknownQualifier) Value() ref.Val { - return q.value -} - -func applyQualifiers(vars Activation, obj any, qualifiers []Qualifier) (any, bool, error) { - optObj, isOpt := obj.(*types.Optional) - if isOpt { - if !optObj.HasValue() { - return optObj, false, nil - } - obj = optObj.GetValue().Value() - } - - var err error - for _, qual := range qualifiers { - var qualObj any - isOpt = isOpt || qual.IsOptional() - if isOpt { - var present bool - qualObj, present, err = qual.QualifyIfPresent(vars, obj, false) - if err != nil { - return nil, false, err - } - if !present { - // We return optional none here with a presence of 'false' as the layers - // above will attempt to call types.OptionalOf() on a present value if any - // of the qualifiers is optional. - return types.OptionalNone, false, nil - } - } else { - qualObj, err = qual.Qualify(vars, obj) - if err != nil { - return nil, false, err - } - } - obj = qualObj - } - return obj, isOpt, nil -} - -// attrQualify performs a qualification using the result of an attribute evaluation. -func attrQualify(fac AttributeFactory, vars Activation, obj any, qualAttr Attribute) (any, error) { - val, err := qualAttr.Resolve(vars) - if err != nil { - return nil, err - } - qual, err := fac.NewQualifier(nil, qualAttr.ID(), val, qualAttr.IsOptional()) - if err != nil { - return nil, err - } - return qual.Qualify(vars, obj) -} - -// attrQualifyIfPresent conditionally performs the qualification of the result of attribute is present -// on the target object. -func attrQualifyIfPresent(fac AttributeFactory, vars Activation, obj any, qualAttr Attribute, - presenceOnly bool) (any, bool, error) { - val, err := qualAttr.Resolve(vars) - if err != nil { - return nil, false, err - } - qual, err := fac.NewQualifier(nil, qualAttr.ID(), val, qualAttr.IsOptional()) - if err != nil { - return nil, false, err - } - return qual.QualifyIfPresent(vars, obj, presenceOnly) -} - -// refQualify attempts to convert the value to a CEL value and then uses reflection methods to try and -// apply the qualifier with the option to presence test field accesses before retrieving field values. -func refQualify(adapter types.Adapter, obj any, idx ref.Val, presenceTest, presenceOnly bool) (ref.Val, bool, error) { - celVal := adapter.NativeToValue(obj) - switch v := celVal.(type) { - case *types.Unknown: - return v, true, nil - case *types.Err: - return nil, false, v - case traits.Mapper: - val, found := v.Find(idx) - // If the index is of the wrong type for the map, then it is possible - // for the Find call to produce an error. - if types.IsError(val) { - return nil, false, val.(*types.Err) - } - if found { - return val, true, nil - } - if presenceTest { - return nil, false, nil - } - return nil, false, missingKey(idx) - case traits.Lister: - // If the index argument is not a valid numeric type, then it is possible - // for the index operation to produce an error. - i, err := types.IndexOrError(idx) - if err != nil { - return nil, false, err - } - celIndex := types.Int(i) - if i >= 0 && celIndex < v.Size().(types.Int) { - return v.Get(idx), true, nil - } - if presenceTest { - return nil, false, nil - } - return nil, false, missingIndex(idx) - case traits.Indexer: - if presenceTest { - ft, ok := v.(traits.FieldTester) - if ok { - presence := ft.IsSet(idx) - if types.IsError(presence) { - return nil, false, presence.(*types.Err) - } - // If not found or presence only test, then return. - // Otherwise, if found, obtain the value later on. - if presenceOnly || presence == types.False { - return nil, presence == types.True, nil - } - } - } - val := v.Get(idx) - if types.IsError(val) { - return nil, false, val.(*types.Err) - } - return val, true, nil - default: - if presenceTest { - return nil, false, nil - } - return nil, false, missingKey(idx) - } -} - -// resolutionError is a custom error type which encodes the different error states which may -// occur during attribute resolution. -type resolutionError struct { - missingAttribute string - missingIndex ref.Val - missingKey ref.Val -} - -func (e *resolutionError) isMissingAttribute() bool { - return e.missingAttribute != "" -} - -func missingIndex(missing ref.Val) *resolutionError { - return &resolutionError{ - missingIndex: missing, - } -} - -func missingKey(missing ref.Val) *resolutionError { - return &resolutionError{ - missingKey: missing, - } -} - -func missingAttribute(attr string) *resolutionError { - return &resolutionError{ - missingAttribute: attr, - } -} - -// Error implements the error interface method. -func (e *resolutionError) Error() string { - if e.missingKey != nil { - return fmt.Sprintf("no such key: %v", e.missingKey) - } - if e.missingIndex != nil { - return fmt.Sprintf("index out of bounds: %v", e.missingIndex) - } - if e.missingAttribute != "" { - return fmt.Sprintf("no such attribute(s): %s", e.missingAttribute) - } - return "invalid attribute" -} - -// Is implements the errors.Is() method used by more recent versions of Go. -func (e *resolutionError) Is(err error) bool { - return err.Error() == e.Error() -} diff --git a/vendor/github.com/google/cel-go/interpreter/decorators.go b/vendor/github.com/google/cel-go/interpreter/decorators.go deleted file mode 100644 index 502db35fc..000000000 --- a/vendor/github.com/google/cel-go/interpreter/decorators.go +++ /dev/null @@ -1,272 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package interpreter - -import ( - "github.com/google/cel-go/common/overloads" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/common/types/ref" - "github.com/google/cel-go/common/types/traits" -) - -// InterpretableDecorator is a functional interface for decorating or replacing -// Interpretable expression nodes at construction time. -type InterpretableDecorator func(Interpretable) (Interpretable, error) - -// decObserveEval records evaluation state into an EvalState object. -func decObserveEval(observer EvalObserver) InterpretableDecorator { - return func(i Interpretable) (Interpretable, error) { - switch inst := i.(type) { - case *evalWatch, *evalWatchAttr, *evalWatchConst, *evalWatchConstructor: - // these instruction are already watching, return straight-away. - return i, nil - case InterpretableAttribute: - return &evalWatchAttr{ - InterpretableAttribute: inst, - observer: observer, - }, nil - case InterpretableConst: - return &evalWatchConst{ - InterpretableConst: inst, - observer: observer, - }, nil - case InterpretableConstructor: - return &evalWatchConstructor{ - constructor: inst, - observer: observer, - }, nil - default: - return &evalWatch{ - Interpretable: i, - observer: observer, - }, nil - } - } -} - -// decInterruptFolds creates an intepretable decorator which marks comprehensions as interruptable -// where the interrupt state is communicated via a hidden variable on the Activation. -func decInterruptFolds() InterpretableDecorator { - return func(i Interpretable) (Interpretable, error) { - fold, ok := i.(*evalFold) - if !ok { - return i, nil - } - fold.interruptable = true - return fold, nil - } -} - -// decDisableShortcircuits ensures that all branches of an expression will be evaluated, no short-circuiting. -func decDisableShortcircuits() InterpretableDecorator { - return func(i Interpretable) (Interpretable, error) { - switch expr := i.(type) { - case *evalOr: - return &evalExhaustiveOr{ - id: expr.id, - terms: expr.terms, - }, nil - case *evalAnd: - return &evalExhaustiveAnd{ - id: expr.id, - terms: expr.terms, - }, nil - case *evalFold: - expr.exhaustive = true - return expr, nil - case InterpretableAttribute: - cond, isCond := expr.Attr().(*conditionalAttribute) - if isCond { - return &evalExhaustiveConditional{ - id: cond.id, - attr: cond, - adapter: expr.Adapter(), - }, nil - } - } - return i, nil - } -} - -// decOptimize optimizes the program plan by looking for common evaluation patterns and -// conditionally precomputing the result. -// - build list and map values with constant elements. -// - convert 'in' operations to set membership tests if possible. -func decOptimize() InterpretableDecorator { - return func(i Interpretable) (Interpretable, error) { - switch inst := i.(type) { - case *evalList: - return maybeBuildListLiteral(i, inst) - case *evalMap: - return maybeBuildMapLiteral(i, inst) - case InterpretableCall: - if inst.OverloadID() == overloads.InList { - return maybeOptimizeSetMembership(i, inst) - } - if overloads.IsTypeConversionFunction(inst.Function()) { - return maybeOptimizeConstUnary(i, inst) - } - } - return i, nil - } -} - -// decRegexOptimizer compiles regex pattern string constants. -func decRegexOptimizer(regexOptimizations ...*RegexOptimization) InterpretableDecorator { - functionMatchMap := make(map[string]*RegexOptimization) - overloadMatchMap := make(map[string]*RegexOptimization) - for _, m := range regexOptimizations { - functionMatchMap[m.Function] = m - if m.OverloadID != "" { - overloadMatchMap[m.OverloadID] = m - } - } - - return func(i Interpretable) (Interpretable, error) { - call, ok := i.(InterpretableCall) - if !ok { - return i, nil - } - - var matcher *RegexOptimization - var found bool - if call.OverloadID() != "" { - matcher, found = overloadMatchMap[call.OverloadID()] - } - if !found { - matcher, found = functionMatchMap[call.Function()] - } - if !found || matcher.RegexIndex >= len(call.Args()) { - return i, nil - } - args := call.Args() - regexArg := args[matcher.RegexIndex] - regexStr, isConst := regexArg.(InterpretableConst) - if !isConst { - return i, nil - } - pattern, ok := regexStr.Value().(types.String) - if !ok { - return i, nil - } - return matcher.Factory(call, string(pattern)) - } -} - -func maybeOptimizeConstUnary(i Interpretable, call InterpretableCall) (Interpretable, error) { - args := call.Args() - if len(args) != 1 { - return i, nil - } - _, isConst := args[0].(InterpretableConst) - if !isConst { - return i, nil - } - val := call.Eval(EmptyActivation()) - if types.IsError(val) { - return nil, val.(*types.Err) - } - return NewConstValue(call.ID(), val), nil -} - -func maybeBuildListLiteral(i Interpretable, l *evalList) (Interpretable, error) { - for _, elem := range l.elems { - _, isConst := elem.(InterpretableConst) - if !isConst { - return i, nil - } - } - return NewConstValue(l.ID(), l.Eval(EmptyActivation())), nil -} - -func maybeBuildMapLiteral(i Interpretable, mp *evalMap) (Interpretable, error) { - for idx, key := range mp.keys { - _, isConst := key.(InterpretableConst) - if !isConst { - return i, nil - } - _, isConst = mp.vals[idx].(InterpretableConst) - if !isConst { - return i, nil - } - } - return NewConstValue(mp.ID(), mp.Eval(EmptyActivation())), nil -} - -// maybeOptimizeSetMembership may convert an 'in' operation against a list to map key membership -// test if the following conditions are true: -// - the list is a constant with homogeneous element types. -// - the elements are all of primitive type. -func maybeOptimizeSetMembership(i Interpretable, inlist InterpretableCall) (Interpretable, error) { - args := inlist.Args() - lhs := args[0] - rhs := args[1] - l, isConst := rhs.(InterpretableConst) - if !isConst { - return i, nil - } - // When the incoming binary call is flagged with as the InList overload, the value will - // always be convertible to a `traits.Lister` type. - list := l.Value().(traits.Lister) - if list.Size() == types.IntZero { - return NewConstValue(inlist.ID(), types.False), nil - } - it := list.Iterator() - valueSet := make(map[ref.Val]ref.Val) - for it.HasNext() == types.True { - elem := it.Next() - if !types.IsPrimitiveType(elem) || elem.Type() == types.BytesType { - // Note, non-primitive type are not yet supported, and []byte isn't hashable. - return i, nil - } - valueSet[elem] = types.True - switch ev := elem.(type) { - case types.Double: - iv := ev.ConvertToType(types.IntType) - // Ensure that only lossless conversions are added to the set - if !types.IsError(iv) && iv.Equal(ev) == types.True { - valueSet[iv] = types.True - } - // Ensure that only lossless conversions are added to the set - uv := ev.ConvertToType(types.UintType) - if !types.IsError(uv) && uv.Equal(ev) == types.True { - valueSet[uv] = types.True - } - case types.Int: - dv := ev.ConvertToType(types.DoubleType) - if !types.IsError(dv) { - valueSet[dv] = types.True - } - uv := ev.ConvertToType(types.UintType) - if !types.IsError(uv) { - valueSet[uv] = types.True - } - case types.Uint: - dv := ev.ConvertToType(types.DoubleType) - if !types.IsError(dv) { - valueSet[dv] = types.True - } - iv := ev.ConvertToType(types.IntType) - if !types.IsError(iv) { - valueSet[iv] = types.True - } - } - } - return &evalSetMembership{ - inst: inlist, - arg: lhs, - valueSet: valueSet, - }, nil -} diff --git a/vendor/github.com/google/cel-go/interpreter/dispatcher.go b/vendor/github.com/google/cel-go/interpreter/dispatcher.go deleted file mode 100644 index 8f0bdb7b8..000000000 --- a/vendor/github.com/google/cel-go/interpreter/dispatcher.go +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package interpreter - -import ( - "fmt" - - "github.com/google/cel-go/common/functions" -) - -// Dispatcher resolves function calls to their appropriate overload. -type Dispatcher interface { - // Add one or more overloads, returning an error if any Overload has the same Overload#Name. - Add(overloads ...*functions.Overload) error - - // FindOverload returns an Overload definition matching the provided name. - FindOverload(overload string) (*functions.Overload, bool) - - // OverloadIds returns the set of all overload identifiers configured for dispatch. - OverloadIds() []string -} - -// NewDispatcher returns an empty Dispatcher instance. -func NewDispatcher() Dispatcher { - return &defaultDispatcher{ - overloads: make(map[string]*functions.Overload)} -} - -// ExtendDispatcher returns a Dispatcher which inherits the overloads of its parent, and -// provides an isolation layer between built-ins and extension functions which is useful -// for forward compatibility. -func ExtendDispatcher(parent Dispatcher) Dispatcher { - return &defaultDispatcher{ - parent: parent, - overloads: make(map[string]*functions.Overload)} -} - -// overloadMap helper type for indexing overloads by function name. -type overloadMap map[string]*functions.Overload - -// defaultDispatcher struct which contains an overload map. -type defaultDispatcher struct { - parent Dispatcher - overloads overloadMap -} - -// Add implements the Dispatcher.Add interface method. -func (d *defaultDispatcher) Add(overloads ...*functions.Overload) error { - for _, o := range overloads { - // add the overload unless an overload of the same name has already been provided. - if _, found := d.overloads[o.Operator]; found { - return fmt.Errorf("overload already exists '%s'", o.Operator) - } - // index the overload by function name. - d.overloads[o.Operator] = o - } - return nil -} - -// FindOverload implements the Dispatcher.FindOverload interface method. -func (d *defaultDispatcher) FindOverload(overload string) (*functions.Overload, bool) { - o, found := d.overloads[overload] - // Attempt to dispatch to an overload defined in the parent. - if !found && d.parent != nil { - return d.parent.FindOverload(overload) - } - return o, found -} - -// OverloadIds implements the Dispatcher interface method. -func (d *defaultDispatcher) OverloadIds() []string { - i := 0 - overloads := make([]string, len(d.overloads)) - for name := range d.overloads { - overloads[i] = name - i++ - } - if d.parent == nil { - return overloads - } - parentOverloads := d.parent.OverloadIds() - for _, pName := range parentOverloads { - if _, found := d.overloads[pName]; !found { - overloads = append(overloads, pName) - } - } - return overloads -} diff --git a/vendor/github.com/google/cel-go/interpreter/evalstate.go b/vendor/github.com/google/cel-go/interpreter/evalstate.go deleted file mode 100644 index 4bdd1fdc7..000000000 --- a/vendor/github.com/google/cel-go/interpreter/evalstate.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package interpreter - -import ( - "github.com/google/cel-go/common/types/ref" -) - -// EvalState tracks the values associated with expression ids during execution. -type EvalState interface { - // IDs returns the list of ids with recorded values. - IDs() []int64 - - // Value returns the observed value of the given expression id if found, and a nil false - // result if not. - Value(int64) (ref.Val, bool) - - // SetValue sets the observed value of the expression id. - SetValue(int64, ref.Val) - - // Reset clears the previously recorded expression values. - Reset() -} - -// evalState permits the mutation of evaluation state for a given expression id. -type evalState struct { - values map[int64]ref.Val -} - -// NewEvalState returns an EvalState instanced used to observe the intermediate -// evaluations of an expression. -func NewEvalState() EvalState { - return &evalState{ - values: make(map[int64]ref.Val), - } -} - -// IDs implements the EvalState interface method. -func (s *evalState) IDs() []int64 { - var ids []int64 - for k, v := range s.values { - if v != nil { - ids = append(ids, k) - } - } - return ids -} - -// Value is an implementation of the EvalState interface method. -func (s *evalState) Value(exprID int64) (ref.Val, bool) { - val, found := s.values[exprID] - return val, found -} - -// SetValue is an implementation of the EvalState interface method. -func (s *evalState) SetValue(exprID int64, val ref.Val) { - if val == nil { - delete(s.values, exprID) - } else { - s.values[exprID] = val - } -} - -// Reset implements the EvalState interface method. -func (s *evalState) Reset() { - s.values = map[int64]ref.Val{} -} diff --git a/vendor/github.com/google/cel-go/interpreter/functions/BUILD.bazel b/vendor/github.com/google/cel-go/interpreter/functions/BUILD.bazel deleted file mode 100644 index 4a80c3ea0..000000000 --- a/vendor/github.com/google/cel-go/interpreter/functions/BUILD.bazel +++ /dev/null @@ -1,17 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -package( - default_visibility = ["//visibility:public"], - licenses = ["notice"], # Apache 2.0 -) - -go_library( - name = "go_default_library", - srcs = [ - "functions.go", - ], - importpath = "github.com/google/cel-go/interpreter/functions", - deps = [ - "//common/functions:go_default_library", - ], -) diff --git a/vendor/github.com/google/cel-go/interpreter/functions/functions.go b/vendor/github.com/google/cel-go/interpreter/functions/functions.go deleted file mode 100644 index 21ffb6924..000000000 --- a/vendor/github.com/google/cel-go/interpreter/functions/functions.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package functions defines the standard builtin functions supported by the -// interpreter and as declared within the checker#StandardDeclarations. -package functions - -import fn "github.com/google/cel-go/common/functions" - -// Overload defines a named overload of a function, indicating an operand trait -// which must be present on the first argument to the overload as well as one -// of either a unary, binary, or function implementation. -// -// The majority of operators within the expression language are unary or binary -// and the specializations simplify the call contract for implementers of -// types with operator overloads. Any added complexity is assumed to be handled -// by the generic FunctionOp. -type Overload = fn.Overload - -// UnaryOp is a function that takes a single value and produces an output. -type UnaryOp = fn.UnaryOp - -// BinaryOp is a function that takes two values and produces an output. -type BinaryOp = fn.BinaryOp - -// FunctionOp is a function with accepts zero or more arguments and produces -// a value or error as a result. -type FunctionOp = fn.FunctionOp diff --git a/vendor/github.com/google/cel-go/interpreter/interpretable.go b/vendor/github.com/google/cel-go/interpreter/interpretable.go deleted file mode 100644 index c4598dfa7..000000000 --- a/vendor/github.com/google/cel-go/interpreter/interpretable.go +++ /dev/null @@ -1,1262 +0,0 @@ -// Copyright 2019 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package interpreter - -import ( - "fmt" - - "github.com/google/cel-go/common/functions" - "github.com/google/cel-go/common/operators" - "github.com/google/cel-go/common/overloads" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/common/types/ref" - "github.com/google/cel-go/common/types/traits" -) - -// Interpretable can accept a given Activation and produce a value along with -// an accompanying EvalState which can be used to inspect whether additional -// data might be necessary to complete the evaluation. -type Interpretable interface { - // ID value corresponding to the expression node. - ID() int64 - - // Eval an Activation to produce an output. - Eval(activation Activation) ref.Val -} - -// InterpretableConst interface for tracking whether the Interpretable is a constant value. -type InterpretableConst interface { - Interpretable - - // Value returns the constant value of the instruction. - Value() ref.Val -} - -// InterpretableAttribute interface for tracking whether the Interpretable is an attribute. -type InterpretableAttribute interface { - Interpretable - - // Attr returns the Attribute value. - Attr() Attribute - - // Adapter returns the type adapter to be used for adapting resolved Attribute values. - Adapter() types.Adapter - - // AddQualifier proxies the Attribute.AddQualifier method. - // - // Note, this method may mutate the current attribute state. If the desire is to clone the - // Attribute, the Attribute should first be copied before adding the qualifier. Attributes - // are not copyable by default, so this is a capable that would need to be added to the - // AttributeFactory or specifically to the underlying Attribute implementation. - AddQualifier(Qualifier) (Attribute, error) - - // Qualify replicates the Attribute.Qualify method to permit extension and interception - // of object qualification. - Qualify(vars Activation, obj any) (any, error) - - // QualifyIfPresent qualifies the object if the qualifier is declared or defined on the object. - // The 'presenceOnly' flag indicates that the value is not necessary, just a boolean status as - // to whether the qualifier is present. - QualifyIfPresent(vars Activation, obj any, presenceOnly bool) (any, bool, error) - - // IsOptional indicates whether the resulting value is an optional type. - IsOptional() bool - - // Resolve returns the value of the Attribute given the current Activation. - Resolve(Activation) (any, error) -} - -// InterpretableCall interface for inspecting Interpretable instructions related to function calls. -type InterpretableCall interface { - Interpretable - - // Function returns the function name as it appears in text or mangled operator name as it - // appears in the operators.go file. - Function() string - - // OverloadID returns the overload id associated with the function specialization. - // Overload ids are stable across language boundaries and can be treated as synonymous with a - // unique function signature. - OverloadID() string - - // Args returns the normalized arguments to the function overload. - // For receiver-style functions, the receiver target is arg 0. - Args() []Interpretable -} - -// InterpretableConstructor interface for inspecting Interpretable instructions that initialize a list, map -// or struct. -type InterpretableConstructor interface { - Interpretable - - // InitVals returns all the list elements, map key and values or struct field values. - InitVals() []Interpretable - - // Type returns the type constructed. - Type() ref.Type -} - -// Core Interpretable implementations used during the program planning phase. - -type evalTestOnly struct { - id int64 - InterpretableAttribute -} - -// ID implements the Interpretable interface method. -func (test *evalTestOnly) ID() int64 { - return test.id -} - -// Eval implements the Interpretable interface method. -func (test *evalTestOnly) Eval(ctx Activation) ref.Val { - val, err := test.Resolve(ctx) - // Return an error if the resolve step fails - if err != nil { - return types.WrapErr(err) - } - if optVal, isOpt := val.(*types.Optional); isOpt { - return types.Bool(optVal.HasValue()) - } - return test.Adapter().NativeToValue(val) -} - -// AddQualifier appends a qualifier that will always and only perform a presence test. -func (test *evalTestOnly) AddQualifier(q Qualifier) (Attribute, error) { - cq, ok := q.(ConstantQualifier) - if !ok { - return nil, fmt.Errorf("test only expressions must have constant qualifiers: %v", q) - } - return test.InterpretableAttribute.AddQualifier(&testOnlyQualifier{ConstantQualifier: cq}) -} - -type testOnlyQualifier struct { - ConstantQualifier -} - -// Qualify determines whether the test-only qualifier is present on the input object. -func (q *testOnlyQualifier) Qualify(vars Activation, obj any) (any, error) { - out, present, err := q.ConstantQualifier.QualifyIfPresent(vars, obj, true) - if err != nil { - return nil, err - } - if unk, isUnk := out.(types.Unknown); isUnk { - return unk, nil - } - if opt, isOpt := out.(types.Optional); isOpt { - return opt.HasValue(), nil - } - return present, nil -} - -// QualifyIfPresent returns whether the target field in the test-only expression is present. -func (q *testOnlyQualifier) QualifyIfPresent(vars Activation, obj any, presenceOnly bool) (any, bool, error) { - // Only ever test for presence. - return q.ConstantQualifier.QualifyIfPresent(vars, obj, true) -} - -// QualifierValueEquals determines whether the test-only constant qualifier equals the input value. -func (q *testOnlyQualifier) QualifierValueEquals(value any) bool { - // The input qualifier will always be of type string - return q.ConstantQualifier.Value().Value() == value -} - -// NewConstValue creates a new constant valued Interpretable. -func NewConstValue(id int64, val ref.Val) InterpretableConst { - return &evalConst{ - id: id, - val: val, - } -} - -type evalConst struct { - id int64 - val ref.Val -} - -// ID implements the Interpretable interface method. -func (cons *evalConst) ID() int64 { - return cons.id -} - -// Eval implements the Interpretable interface method. -func (cons *evalConst) Eval(ctx Activation) ref.Val { - return cons.val -} - -// Value implements the InterpretableConst interface method. -func (cons *evalConst) Value() ref.Val { - return cons.val -} - -type evalOr struct { - id int64 - terms []Interpretable -} - -// ID implements the Interpretable interface method. -func (or *evalOr) ID() int64 { - return or.id -} - -// Eval implements the Interpretable interface method. -func (or *evalOr) Eval(ctx Activation) ref.Val { - var err ref.Val = nil - var unk *types.Unknown - for _, term := range or.terms { - val := term.Eval(ctx) - boolVal, ok := val.(types.Bool) - // short-circuit on true. - if ok && boolVal == types.True { - return types.True - } - if !ok { - isUnk := false - unk, isUnk = types.MaybeMergeUnknowns(val, unk) - if !isUnk && err == nil { - if types.IsError(val) { - err = val - } else { - err = types.MaybeNoSuchOverloadErr(val) - } - } - } - } - if unk != nil { - return unk - } - if err != nil { - return err - } - return types.False -} - -type evalAnd struct { - id int64 - terms []Interpretable -} - -// ID implements the Interpretable interface method. -func (and *evalAnd) ID() int64 { - return and.id -} - -// Eval implements the Interpretable interface method. -func (and *evalAnd) Eval(ctx Activation) ref.Val { - var err ref.Val = nil - var unk *types.Unknown - for _, term := range and.terms { - val := term.Eval(ctx) - boolVal, ok := val.(types.Bool) - // short-circuit on false. - if ok && boolVal == types.False { - return types.False - } - if !ok { - isUnk := false - unk, isUnk = types.MaybeMergeUnknowns(val, unk) - if !isUnk && err == nil { - if types.IsError(val) { - err = val - } else { - err = types.MaybeNoSuchOverloadErr(val) - } - } - } - } - if unk != nil { - return unk - } - if err != nil { - return err - } - return types.True -} - -type evalEq struct { - id int64 - lhs Interpretable - rhs Interpretable -} - -// ID implements the Interpretable interface method. -func (eq *evalEq) ID() int64 { - return eq.id -} - -// Eval implements the Interpretable interface method. -func (eq *evalEq) Eval(ctx Activation) ref.Val { - lVal := eq.lhs.Eval(ctx) - rVal := eq.rhs.Eval(ctx) - if types.IsUnknownOrError(lVal) { - return lVal - } - if types.IsUnknownOrError(rVal) { - return rVal - } - return types.Equal(lVal, rVal) -} - -// Function implements the InterpretableCall interface method. -func (*evalEq) Function() string { - return operators.Equals -} - -// OverloadID implements the InterpretableCall interface method. -func (*evalEq) OverloadID() string { - return overloads.Equals -} - -// Args implements the InterpretableCall interface method. -func (eq *evalEq) Args() []Interpretable { - return []Interpretable{eq.lhs, eq.rhs} -} - -type evalNe struct { - id int64 - lhs Interpretable - rhs Interpretable -} - -// ID implements the Interpretable interface method. -func (ne *evalNe) ID() int64 { - return ne.id -} - -// Eval implements the Interpretable interface method. -func (ne *evalNe) Eval(ctx Activation) ref.Val { - lVal := ne.lhs.Eval(ctx) - rVal := ne.rhs.Eval(ctx) - if types.IsUnknownOrError(lVal) { - return lVal - } - if types.IsUnknownOrError(rVal) { - return rVal - } - return types.Bool(types.Equal(lVal, rVal) != types.True) -} - -// Function implements the InterpretableCall interface method. -func (*evalNe) Function() string { - return operators.NotEquals -} - -// OverloadID implements the InterpretableCall interface method. -func (*evalNe) OverloadID() string { - return overloads.NotEquals -} - -// Args implements the InterpretableCall interface method. -func (ne *evalNe) Args() []Interpretable { - return []Interpretable{ne.lhs, ne.rhs} -} - -type evalZeroArity struct { - id int64 - function string - overload string - impl functions.FunctionOp -} - -// ID implements the Interpretable interface method. -func (zero *evalZeroArity) ID() int64 { - return zero.id -} - -// Eval implements the Interpretable interface method. -func (zero *evalZeroArity) Eval(ctx Activation) ref.Val { - return zero.impl() -} - -// Function implements the InterpretableCall interface method. -func (zero *evalZeroArity) Function() string { - return zero.function -} - -// OverloadID implements the InterpretableCall interface method. -func (zero *evalZeroArity) OverloadID() string { - return zero.overload -} - -// Args returns the argument to the unary function. -func (zero *evalZeroArity) Args() []Interpretable { - return []Interpretable{} -} - -type evalUnary struct { - id int64 - function string - overload string - arg Interpretable - trait int - impl functions.UnaryOp - nonStrict bool -} - -// ID implements the Interpretable interface method. -func (un *evalUnary) ID() int64 { - return un.id -} - -// Eval implements the Interpretable interface method. -func (un *evalUnary) Eval(ctx Activation) ref.Val { - argVal := un.arg.Eval(ctx) - // Early return if the argument to the function is unknown or error. - strict := !un.nonStrict - if strict && types.IsUnknownOrError(argVal) { - return argVal - } - // If the implementation is bound and the argument value has the right traits required to - // invoke it, then call the implementation. - if un.impl != nil && (un.trait == 0 || (!strict && types.IsUnknownOrError(argVal)) || argVal.Type().HasTrait(un.trait)) { - return un.impl(argVal) - } - // Otherwise, if the argument is a ReceiverType attempt to invoke the receiver method on the - // operand (arg0). - if argVal.Type().HasTrait(traits.ReceiverType) { - return argVal.(traits.Receiver).Receive(un.function, un.overload, []ref.Val{}) - } - return types.NewErr("no such overload: %s", un.function) -} - -// Function implements the InterpretableCall interface method. -func (un *evalUnary) Function() string { - return un.function -} - -// OverloadID implements the InterpretableCall interface method. -func (un *evalUnary) OverloadID() string { - return un.overload -} - -// Args returns the argument to the unary function. -func (un *evalUnary) Args() []Interpretable { - return []Interpretable{un.arg} -} - -type evalBinary struct { - id int64 - function string - overload string - lhs Interpretable - rhs Interpretable - trait int - impl functions.BinaryOp - nonStrict bool -} - -// ID implements the Interpretable interface method. -func (bin *evalBinary) ID() int64 { - return bin.id -} - -// Eval implements the Interpretable interface method. -func (bin *evalBinary) Eval(ctx Activation) ref.Val { - lVal := bin.lhs.Eval(ctx) - rVal := bin.rhs.Eval(ctx) - // Early return if any argument to the function is unknown or error. - strict := !bin.nonStrict - if strict { - if types.IsUnknownOrError(lVal) { - return lVal - } - if types.IsUnknownOrError(rVal) { - return rVal - } - } - // If the implementation is bound and the argument value has the right traits required to - // invoke it, then call the implementation. - if bin.impl != nil && (bin.trait == 0 || (!strict && types.IsUnknownOrError(lVal)) || lVal.Type().HasTrait(bin.trait)) { - return bin.impl(lVal, rVal) - } - // Otherwise, if the argument is a ReceiverType attempt to invoke the receiver method on the - // operand (arg0). - if lVal.Type().HasTrait(traits.ReceiverType) { - return lVal.(traits.Receiver).Receive(bin.function, bin.overload, []ref.Val{rVal}) - } - return types.NewErr("no such overload: %s", bin.function) -} - -// Function implements the InterpretableCall interface method. -func (bin *evalBinary) Function() string { - return bin.function -} - -// OverloadID implements the InterpretableCall interface method. -func (bin *evalBinary) OverloadID() string { - return bin.overload -} - -// Args returns the argument to the unary function. -func (bin *evalBinary) Args() []Interpretable { - return []Interpretable{bin.lhs, bin.rhs} -} - -type evalVarArgs struct { - id int64 - function string - overload string - args []Interpretable - trait int - impl functions.FunctionOp - nonStrict bool -} - -// NewCall creates a new call Interpretable. -func NewCall(id int64, function, overload string, args []Interpretable, impl functions.FunctionOp) InterpretableCall { - return &evalVarArgs{ - id: id, - function: function, - overload: overload, - args: args, - impl: impl, - } -} - -// ID implements the Interpretable interface method. -func (fn *evalVarArgs) ID() int64 { - return fn.id -} - -// Eval implements the Interpretable interface method. -func (fn *evalVarArgs) Eval(ctx Activation) ref.Val { - argVals := make([]ref.Val, len(fn.args)) - // Early return if any argument to the function is unknown or error. - strict := !fn.nonStrict - for i, arg := range fn.args { - argVals[i] = arg.Eval(ctx) - if strict && types.IsUnknownOrError(argVals[i]) { - return argVals[i] - } - } - // If the implementation is bound and the argument value has the right traits required to - // invoke it, then call the implementation. - arg0 := argVals[0] - if fn.impl != nil && (fn.trait == 0 || (!strict && types.IsUnknownOrError(arg0)) || arg0.Type().HasTrait(fn.trait)) { - return fn.impl(argVals...) - } - // Otherwise, if the argument is a ReceiverType attempt to invoke the receiver method on the - // operand (arg0). - if arg0.Type().HasTrait(traits.ReceiverType) { - return arg0.(traits.Receiver).Receive(fn.function, fn.overload, argVals[1:]) - } - return types.NewErr("no such overload: %s", fn.function) -} - -// Function implements the InterpretableCall interface method. -func (fn *evalVarArgs) Function() string { - return fn.function -} - -// OverloadID implements the InterpretableCall interface method. -func (fn *evalVarArgs) OverloadID() string { - return fn.overload -} - -// Args returns the argument to the unary function. -func (fn *evalVarArgs) Args() []Interpretable { - return fn.args -} - -type evalList struct { - id int64 - elems []Interpretable - optionals []bool - hasOptionals bool - adapter types.Adapter -} - -// ID implements the Interpretable interface method. -func (l *evalList) ID() int64 { - return l.id -} - -// Eval implements the Interpretable interface method. -func (l *evalList) Eval(ctx Activation) ref.Val { - elemVals := make([]ref.Val, 0, len(l.elems)) - // If any argument is unknown or error early terminate. - for i, elem := range l.elems { - elemVal := elem.Eval(ctx) - if types.IsUnknownOrError(elemVal) { - return elemVal - } - if l.hasOptionals && l.optionals[i] { - optVal, ok := elemVal.(*types.Optional) - if !ok { - return invalidOptionalElementInit(elemVal) - } - if !optVal.HasValue() { - continue - } - elemVal = optVal.GetValue() - } - elemVals = append(elemVals, elemVal) - } - return l.adapter.NativeToValue(elemVals) -} - -func (l *evalList) InitVals() []Interpretable { - return l.elems -} - -func (l *evalList) Type() ref.Type { - return types.ListType -} - -type evalMap struct { - id int64 - keys []Interpretable - vals []Interpretable - optionals []bool - hasOptionals bool - adapter types.Adapter -} - -// ID implements the Interpretable interface method. -func (m *evalMap) ID() int64 { - return m.id -} - -// Eval implements the Interpretable interface method. -func (m *evalMap) Eval(ctx Activation) ref.Val { - entries := make(map[ref.Val]ref.Val) - // If any argument is unknown or error early terminate. - for i, key := range m.keys { - keyVal := key.Eval(ctx) - if types.IsUnknownOrError(keyVal) { - return keyVal - } - valVal := m.vals[i].Eval(ctx) - if types.IsUnknownOrError(valVal) { - return valVal - } - if m.hasOptionals && m.optionals[i] { - optVal, ok := valVal.(*types.Optional) - if !ok { - return invalidOptionalEntryInit(keyVal, valVal) - } - if !optVal.HasValue() { - delete(entries, keyVal) - continue - } - valVal = optVal.GetValue() - } - entries[keyVal] = valVal - } - return m.adapter.NativeToValue(entries) -} - -func (m *evalMap) InitVals() []Interpretable { - if len(m.keys) != len(m.vals) { - return nil - } - result := make([]Interpretable, len(m.keys)+len(m.vals)) - idx := 0 - for i, k := range m.keys { - v := m.vals[i] - result[idx] = k - idx++ - result[idx] = v - idx++ - } - return result -} - -func (m *evalMap) Type() ref.Type { - return types.MapType -} - -type evalObj struct { - id int64 - typeName string - fields []string - vals []Interpretable - optionals []bool - hasOptionals bool - provider types.Provider -} - -// ID implements the Interpretable interface method. -func (o *evalObj) ID() int64 { - return o.id -} - -// Eval implements the Interpretable interface method. -func (o *evalObj) Eval(ctx Activation) ref.Val { - fieldVals := make(map[string]ref.Val) - // If any argument is unknown or error early terminate. - for i, field := range o.fields { - val := o.vals[i].Eval(ctx) - if types.IsUnknownOrError(val) { - return val - } - if o.hasOptionals && o.optionals[i] { - optVal, ok := val.(*types.Optional) - if !ok { - return invalidOptionalEntryInit(field, val) - } - if !optVal.HasValue() { - delete(fieldVals, field) - continue - } - val = optVal.GetValue() - } - fieldVals[field] = val - } - return o.provider.NewValue(o.typeName, fieldVals) -} - -func (o *evalObj) InitVals() []Interpretable { - return o.vals -} - -func (o *evalObj) Type() ref.Type { - return types.NewObjectTypeValue(o.typeName) -} - -type evalFold struct { - id int64 - accuVar string - iterVar string - iterRange Interpretable - accu Interpretable - cond Interpretable - step Interpretable - result Interpretable - adapter types.Adapter - exhaustive bool - interruptable bool -} - -// ID implements the Interpretable interface method. -func (fold *evalFold) ID() int64 { - return fold.id -} - -// Eval implements the Interpretable interface method. -func (fold *evalFold) Eval(ctx Activation) ref.Val { - foldRange := fold.iterRange.Eval(ctx) - if !foldRange.Type().HasTrait(traits.IterableType) { - return types.ValOrErr(foldRange, "got '%T', expected iterable type", foldRange) - } - // Configure the fold activation with the accumulator initial value. - accuCtx := varActivationPool.Get().(*varActivation) - accuCtx.parent = ctx - accuCtx.name = fold.accuVar - accuCtx.val = fold.accu.Eval(ctx) - // If the accumulator starts as an empty list, then the comprehension will build a list - // so create a mutable list to optimize the cost of the inner loop. - l, ok := accuCtx.val.(traits.Lister) - buildingList := false - if !fold.exhaustive && ok && l.Size() == types.IntZero { - buildingList = true - accuCtx.val = types.NewMutableList(fold.adapter) - } - iterCtx := varActivationPool.Get().(*varActivation) - iterCtx.parent = accuCtx - iterCtx.name = fold.iterVar - - interrupted := false - it := foldRange.(traits.Iterable).Iterator() - for it.HasNext() == types.True { - // Modify the iter var in the fold activation. - iterCtx.val = it.Next() - - // Evaluate the condition, terminate the loop if false. - cond := fold.cond.Eval(iterCtx) - condBool, ok := cond.(types.Bool) - if !fold.exhaustive && ok && condBool != types.True { - break - } - // Evaluate the evaluation step into accu var. - accuCtx.val = fold.step.Eval(iterCtx) - if fold.interruptable { - if stop, found := ctx.ResolveName("#interrupted"); found && stop == true { - interrupted = true - break - } - } - } - varActivationPool.Put(iterCtx) - if interrupted { - varActivationPool.Put(accuCtx) - return types.NewErr("operation interrupted") - } - - // Compute the result. - res := fold.result.Eval(accuCtx) - varActivationPool.Put(accuCtx) - // Convert a mutable list to an immutable one, if the comprehension has generated a list as a result. - if !types.IsUnknownOrError(res) && buildingList { - if _, ok := res.(traits.MutableLister); ok { - res = res.(traits.MutableLister).ToImmutableList() - } - } - return res -} - -// Optional Interpretable implementations that specialize, subsume, or extend the core evaluation -// plan via decorators. - -// evalSetMembership is an Interpretable implementation which tests whether an input value -// exists within the set of map keys used to model a set. -type evalSetMembership struct { - inst Interpretable - arg Interpretable - valueSet map[ref.Val]ref.Val -} - -// ID implements the Interpretable interface method. -func (e *evalSetMembership) ID() int64 { - return e.inst.ID() -} - -// Eval implements the Interpretable interface method. -func (e *evalSetMembership) Eval(ctx Activation) ref.Val { - val := e.arg.Eval(ctx) - if types.IsUnknownOrError(val) { - return val - } - if ret, found := e.valueSet[val]; found { - return ret - } - return types.False -} - -// evalWatch is an Interpretable implementation that wraps the execution of a given -// expression so that it may observe the computed value and send it to an observer. -type evalWatch struct { - Interpretable - observer EvalObserver -} - -// Eval implements the Interpretable interface method. -func (e *evalWatch) Eval(ctx Activation) ref.Val { - val := e.Interpretable.Eval(ctx) - e.observer(e.ID(), e.Interpretable, val) - return val -} - -// evalWatchAttr describes a watcher of an InterpretableAttribute Interpretable. -// -// Since the watcher may be selected against at a later stage in program planning, the watcher -// must implement the InterpretableAttribute interface by proxy. -type evalWatchAttr struct { - InterpretableAttribute - observer EvalObserver -} - -// AddQualifier creates a wrapper over the incoming qualifier which observes the qualification -// result. -func (e *evalWatchAttr) AddQualifier(q Qualifier) (Attribute, error) { - switch qual := q.(type) { - // By default, the qualifier is either a constant or an attribute - // There may be some custom cases where the attribute is neither. - case ConstantQualifier: - // Expose a method to test whether the qualifier matches the input pattern. - q = &evalWatchConstQual{ - ConstantQualifier: qual, - observer: e.observer, - adapter: e.Adapter(), - } - case *evalWatchAttr: - // Unwrap the evalWatchAttr since the observation will be applied during Qualify or - // QualifyIfPresent rather than Eval. - q = &evalWatchAttrQual{ - Attribute: qual.InterpretableAttribute, - observer: e.observer, - adapter: e.Adapter(), - } - case Attribute: - // Expose methods which intercept the qualification prior to being applied as a qualifier. - // Using this interface ensures that the qualifier is converted to a constant value one - // time during attribute pattern matching as the method embeds the Attribute interface - // needed to trip the conversion to a constant. - q = &evalWatchAttrQual{ - Attribute: qual, - observer: e.observer, - adapter: e.Adapter(), - } - default: - // This is likely a custom qualifier type. - q = &evalWatchQual{ - Qualifier: qual, - observer: e.observer, - adapter: e.Adapter(), - } - } - _, err := e.InterpretableAttribute.AddQualifier(q) - return e, err -} - -// Eval implements the Interpretable interface method. -func (e *evalWatchAttr) Eval(vars Activation) ref.Val { - val := e.InterpretableAttribute.Eval(vars) - e.observer(e.ID(), e.InterpretableAttribute, val) - return val -} - -// evalWatchConstQual observes the qualification of an object using a constant boolean, int, -// string, or uint. -type evalWatchConstQual struct { - ConstantQualifier - observer EvalObserver - adapter types.Adapter -} - -// Qualify observes the qualification of a object via a constant boolean, int, string, or uint. -func (e *evalWatchConstQual) Qualify(vars Activation, obj any) (any, error) { - out, err := e.ConstantQualifier.Qualify(vars, obj) - var val ref.Val - if err != nil { - val = types.WrapErr(err) - } else { - val = e.adapter.NativeToValue(out) - } - e.observer(e.ID(), e.ConstantQualifier, val) - return out, err -} - -// QualifyIfPresent conditionally qualifies the variable and only records a value if one is present. -func (e *evalWatchConstQual) QualifyIfPresent(vars Activation, obj any, presenceOnly bool) (any, bool, error) { - out, present, err := e.ConstantQualifier.QualifyIfPresent(vars, obj, presenceOnly) - var val ref.Val - if err != nil { - val = types.WrapErr(err) - } else if out != nil { - val = e.adapter.NativeToValue(out) - } else if presenceOnly { - val = types.Bool(present) - } - if present || presenceOnly { - e.observer(e.ID(), e.ConstantQualifier, val) - } - return out, present, err -} - -// QualifierValueEquals tests whether the incoming value is equal to the qualifying constant. -func (e *evalWatchConstQual) QualifierValueEquals(value any) bool { - qve, ok := e.ConstantQualifier.(qualifierValueEquator) - return ok && qve.QualifierValueEquals(value) -} - -// evalWatchAttrQual observes the qualification of an object by a value computed at runtime. -type evalWatchAttrQual struct { - Attribute - observer EvalObserver - adapter ref.TypeAdapter -} - -// Qualify observes the qualification of a object via a value computed at runtime. -func (e *evalWatchAttrQual) Qualify(vars Activation, obj any) (any, error) { - out, err := e.Attribute.Qualify(vars, obj) - var val ref.Val - if err != nil { - val = types.WrapErr(err) - } else { - val = e.adapter.NativeToValue(out) - } - e.observer(e.ID(), e.Attribute, val) - return out, err -} - -// QualifyIfPresent conditionally qualifies the variable and only records a value if one is present. -func (e *evalWatchAttrQual) QualifyIfPresent(vars Activation, obj any, presenceOnly bool) (any, bool, error) { - out, present, err := e.Attribute.QualifyIfPresent(vars, obj, presenceOnly) - var val ref.Val - if err != nil { - val = types.WrapErr(err) - } else if out != nil { - val = e.adapter.NativeToValue(out) - } else if presenceOnly { - val = types.Bool(present) - } - if present || presenceOnly { - e.observer(e.ID(), e.Attribute, val) - } - return out, present, err -} - -// evalWatchQual observes the qualification of an object by a value computed at runtime. -type evalWatchQual struct { - Qualifier - observer EvalObserver - adapter types.Adapter -} - -// Qualify observes the qualification of a object via a value computed at runtime. -func (e *evalWatchQual) Qualify(vars Activation, obj any) (any, error) { - out, err := e.Qualifier.Qualify(vars, obj) - var val ref.Val - if err != nil { - val = types.WrapErr(err) - } else { - val = e.adapter.NativeToValue(out) - } - e.observer(e.ID(), e.Qualifier, val) - return out, err -} - -// QualifyIfPresent conditionally qualifies the variable and only records a value if one is present. -func (e *evalWatchQual) QualifyIfPresent(vars Activation, obj any, presenceOnly bool) (any, bool, error) { - out, present, err := e.Qualifier.QualifyIfPresent(vars, obj, presenceOnly) - var val ref.Val - if err != nil { - val = types.WrapErr(err) - } else if out != nil { - val = e.adapter.NativeToValue(out) - } else if presenceOnly { - val = types.Bool(present) - } - if present || presenceOnly { - e.observer(e.ID(), e.Qualifier, val) - } - return out, present, err -} - -// evalWatchConst describes a watcher of an instConst Interpretable. -type evalWatchConst struct { - InterpretableConst - observer EvalObserver -} - -// Eval implements the Interpretable interface method. -func (e *evalWatchConst) Eval(vars Activation) ref.Val { - val := e.Value() - e.observer(e.ID(), e.InterpretableConst, val) - return val -} - -// evalExhaustiveOr is just like evalOr, but does not short-circuit argument evaluation. -type evalExhaustiveOr struct { - id int64 - terms []Interpretable -} - -// ID implements the Interpretable interface method. -func (or *evalExhaustiveOr) ID() int64 { - return or.id -} - -// Eval implements the Interpretable interface method. -func (or *evalExhaustiveOr) Eval(ctx Activation) ref.Val { - var err ref.Val = nil - var unk *types.Unknown - isTrue := false - for _, term := range or.terms { - val := term.Eval(ctx) - boolVal, ok := val.(types.Bool) - // flag the result as true - if ok && boolVal == types.True { - isTrue = true - } - if !ok && !isTrue { - isUnk := false - unk, isUnk = types.MaybeMergeUnknowns(val, unk) - if !isUnk && err == nil { - if types.IsError(val) { - err = val - } else { - err = types.MaybeNoSuchOverloadErr(val) - } - } - } - } - if isTrue { - return types.True - } - if unk != nil { - return unk - } - if err != nil { - return err - } - return types.False -} - -// evalExhaustiveAnd is just like evalAnd, but does not short-circuit argument evaluation. -type evalExhaustiveAnd struct { - id int64 - terms []Interpretable -} - -// ID implements the Interpretable interface method. -func (and *evalExhaustiveAnd) ID() int64 { - return and.id -} - -// Eval implements the Interpretable interface method. -func (and *evalExhaustiveAnd) Eval(ctx Activation) ref.Val { - var err ref.Val = nil - var unk *types.Unknown - isFalse := false - for _, term := range and.terms { - val := term.Eval(ctx) - boolVal, ok := val.(types.Bool) - // short-circuit on false. - if ok && boolVal == types.False { - isFalse = true - } - if !ok && !isFalse { - isUnk := false - unk, isUnk = types.MaybeMergeUnknowns(val, unk) - if !isUnk && err == nil { - if types.IsError(val) { - err = val - } else { - err = types.MaybeNoSuchOverloadErr(val) - } - } - } - } - if isFalse { - return types.False - } - if unk != nil { - return unk - } - if err != nil { - return err - } - return types.True -} - -// evalExhaustiveConditional is like evalConditional, but does not short-circuit argument -// evaluation. -type evalExhaustiveConditional struct { - id int64 - adapter types.Adapter - attr *conditionalAttribute -} - -// ID implements the Interpretable interface method. -func (cond *evalExhaustiveConditional) ID() int64 { - return cond.id -} - -// Eval implements the Interpretable interface method. -func (cond *evalExhaustiveConditional) Eval(ctx Activation) ref.Val { - cVal := cond.attr.expr.Eval(ctx) - tVal, tErr := cond.attr.truthy.Resolve(ctx) - fVal, fErr := cond.attr.falsy.Resolve(ctx) - cBool, ok := cVal.(types.Bool) - if !ok { - return types.ValOrErr(cVal, "no such overload") - } - if cBool { - if tErr != nil { - return types.WrapErr(tErr) - } - return cond.adapter.NativeToValue(tVal) - } - if fErr != nil { - return types.WrapErr(fErr) - } - return cond.adapter.NativeToValue(fVal) -} - -// evalAttr evaluates an Attribute value. -type evalAttr struct { - adapter types.Adapter - attr Attribute - optional bool -} - -var _ InterpretableAttribute = &evalAttr{} - -// ID of the attribute instruction. -func (a *evalAttr) ID() int64 { - return a.attr.ID() -} - -// AddQualifier implements the InterpretableAttribute interface method. -func (a *evalAttr) AddQualifier(qual Qualifier) (Attribute, error) { - attr, err := a.attr.AddQualifier(qual) - a.attr = attr - return attr, err -} - -// Attr implements the InterpretableAttribute interface method. -func (a *evalAttr) Attr() Attribute { - return a.attr -} - -// Adapter implements the InterpretableAttribute interface method. -func (a *evalAttr) Adapter() types.Adapter { - return a.adapter -} - -// Eval implements the Interpretable interface method. -func (a *evalAttr) Eval(ctx Activation) ref.Val { - v, err := a.attr.Resolve(ctx) - if err != nil { - return types.WrapErr(err) - } - return a.adapter.NativeToValue(v) -} - -// Qualify proxies to the Attribute's Qualify method. -func (a *evalAttr) Qualify(ctx Activation, obj any) (any, error) { - return a.attr.Qualify(ctx, obj) -} - -// QualifyIfPresent proxies to the Attribute's QualifyIfPresent method. -func (a *evalAttr) QualifyIfPresent(ctx Activation, obj any, presenceOnly bool) (any, bool, error) { - return a.attr.QualifyIfPresent(ctx, obj, presenceOnly) -} - -func (a *evalAttr) IsOptional() bool { - return a.optional -} - -// Resolve proxies to the Attribute's Resolve method. -func (a *evalAttr) Resolve(ctx Activation) (any, error) { - return a.attr.Resolve(ctx) -} - -type evalWatchConstructor struct { - constructor InterpretableConstructor - observer EvalObserver -} - -// InitVals implements the InterpretableConstructor InitVals function. -func (c *evalWatchConstructor) InitVals() []Interpretable { - return c.constructor.InitVals() -} - -// Type implements the InterpretableConstructor Type function. -func (c *evalWatchConstructor) Type() ref.Type { - return c.constructor.Type() -} - -// ID implements the Interpretable ID function. -func (c *evalWatchConstructor) ID() int64 { - return c.constructor.ID() -} - -// Eval implements the Interpretable Eval function. -func (c *evalWatchConstructor) Eval(ctx Activation) ref.Val { - val := c.constructor.Eval(ctx) - c.observer(c.ID(), c.constructor, val) - return val -} - -func invalidOptionalEntryInit(field any, value ref.Val) ref.Val { - return types.NewErr("cannot initialize optional entry '%v' from non-optional value %v", field, value) -} - -func invalidOptionalElementInit(value ref.Val) ref.Val { - return types.NewErr("cannot initialize optional list element from non-optional value %v", value) -} diff --git a/vendor/github.com/google/cel-go/interpreter/interpreter.go b/vendor/github.com/google/cel-go/interpreter/interpreter.go deleted file mode 100644 index 0aca74d88..000000000 --- a/vendor/github.com/google/cel-go/interpreter/interpreter.go +++ /dev/null @@ -1,185 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package interpreter provides functions to evaluate parsed expressions with -// the option to augment the evaluation with inputs and functions supplied at -// evaluation time. -package interpreter - -import ( - "github.com/google/cel-go/common/ast" - "github.com/google/cel-go/common/containers" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/common/types/ref" -) - -// Interpreter generates a new Interpretable from a checked or unchecked expression. -type Interpreter interface { - // NewInterpretable creates an Interpretable from a checked expression and an - // optional list of InterpretableDecorator values. - NewInterpretable(exprAST *ast.AST, decorators ...InterpretableDecorator) (Interpretable, error) -} - -// EvalObserver is a functional interface that accepts an expression id and an observed value. -// The id identifies the expression that was evaluated, the programStep is the Interpretable or Qualifier that -// was evaluated and value is the result of the evaluation. -type EvalObserver func(id int64, programStep any, value ref.Val) - -// Observe constructs a decorator that calls all the provided observers in order after evaluating each Interpretable -// or Qualifier during program evaluation. -func Observe(observers ...EvalObserver) InterpretableDecorator { - if len(observers) == 1 { - return decObserveEval(observers[0]) - } - observeFn := func(id int64, programStep any, val ref.Val) { - for _, observer := range observers { - observer(id, programStep, val) - } - } - return decObserveEval(observeFn) -} - -// EvalCancelledError represents a cancelled program evaluation operation. -type EvalCancelledError struct { - Message string - // Type identifies the cause of the cancellation. - Cause CancellationCause -} - -func (e EvalCancelledError) Error() string { - return e.Message -} - -// CancellationCause enumerates the ways a program evaluation operation can be cancelled. -type CancellationCause int - -const ( - // ContextCancelled indicates that the operation was cancelled in response to a Golang context cancellation. - ContextCancelled CancellationCause = iota - - // CostLimitExceeded indicates that the operation was cancelled in response to the actual cost limit being - // exceeded. - CostLimitExceeded -) - -// TODO: Replace all usages of TrackState with EvalStateObserver - -// TrackState decorates each expression node with an observer which records the value -// associated with the given expression id. EvalState must be provided to the decorator. -// This decorator is not thread-safe, and the EvalState must be reset between Eval() -// calls. -// DEPRECATED: Please use EvalStateObserver instead. It composes gracefully with additional observers. -func TrackState(state EvalState) InterpretableDecorator { - return Observe(EvalStateObserver(state)) -} - -// EvalStateObserver provides an observer which records the value -// associated with the given expression id. EvalState must be provided to the observer. -// This decorator is not thread-safe, and the EvalState must be reset between Eval() -// calls. -func EvalStateObserver(state EvalState) EvalObserver { - return func(id int64, programStep any, val ref.Val) { - state.SetValue(id, val) - } -} - -// ExhaustiveEval replaces operations that short-circuit with versions that evaluate -// expressions and couples this behavior with the TrackState() decorator to provide -// insight into the evaluation state of the entire expression. EvalState must be -// provided to the decorator. This decorator is not thread-safe, and the EvalState -// must be reset between Eval() calls. -func ExhaustiveEval() InterpretableDecorator { - ex := decDisableShortcircuits() - return func(i Interpretable) (Interpretable, error) { - return ex(i) - } -} - -// InterruptableEval annotates comprehension loops with information that indicates they -// should check the `#interrupted` state within a custom Activation. -// -// The custom activation is currently managed higher up in the stack within the 'cel' package -// and should not require any custom support on behalf of callers. -func InterruptableEval() InterpretableDecorator { - return decInterruptFolds() -} - -// Optimize will pre-compute operations such as list and map construction and optimize -// call arguments to set membership tests. The set of optimizations will increase over time. -func Optimize() InterpretableDecorator { - return decOptimize() -} - -// RegexOptimization provides a way to replace an InterpretableCall for a regex function when the -// RegexIndex argument is a string constant. Typically, the Factory would compile the regex pattern at -// RegexIndex and report any errors (at program creation time) and then use the compiled regex for -// all regex function invocations. -type RegexOptimization struct { - // Function is the name of the function to optimize. - Function string - // OverloadID is the ID of the overload to optimize. - OverloadID string - // RegexIndex is the index position of the regex pattern argument. Only calls to the function where this argument is - // a string constant will be delegated to this optimizer. - RegexIndex int - // Factory constructs a replacement InterpretableCall node that optimizes the regex function call. Factory is - // provided with the unoptimized regex call and the string constant at the RegexIndex argument. - // The Factory may compile the regex for use across all invocations of the call, return any errors and - // return an interpreter.NewCall with the desired regex optimized function impl. - Factory func(call InterpretableCall, regexPattern string) (InterpretableCall, error) -} - -// CompileRegexConstants compiles regex pattern string constants at program creation time and reports any regex pattern -// compile errors. -func CompileRegexConstants(regexOptimizations ...*RegexOptimization) InterpretableDecorator { - return decRegexOptimizer(regexOptimizations...) -} - -type exprInterpreter struct { - dispatcher Dispatcher - container *containers.Container - provider types.Provider - adapter types.Adapter - attrFactory AttributeFactory -} - -// NewInterpreter builds an Interpreter from a Dispatcher and TypeProvider which will be used -// throughout the Eval of all Interpretable instances generated from it. -func NewInterpreter(dispatcher Dispatcher, - container *containers.Container, - provider types.Provider, - adapter types.Adapter, - attrFactory AttributeFactory) Interpreter { - return &exprInterpreter{ - dispatcher: dispatcher, - container: container, - provider: provider, - adapter: adapter, - attrFactory: attrFactory} -} - -// NewIntepretable implements the Interpreter interface method. -func (i *exprInterpreter) NewInterpretable( - checked *ast.AST, - decorators ...InterpretableDecorator) (Interpretable, error) { - p := newPlanner( - i.dispatcher, - i.provider, - i.adapter, - i.attrFactory, - i.container, - checked, - decorators...) - return p.Plan(checked.Expr()) -} diff --git a/vendor/github.com/google/cel-go/interpreter/optimizations.go b/vendor/github.com/google/cel-go/interpreter/optimizations.go deleted file mode 100644 index 2fc87e693..000000000 --- a/vendor/github.com/google/cel-go/interpreter/optimizations.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package interpreter - -import ( - "regexp" - - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/common/types/ref" -) - -// MatchesRegexOptimization optimizes the 'matches' standard library function by compiling the regex pattern and -// reporting any compilation errors at program creation time, and using the compiled regex pattern for all function -// call invocations. -var MatchesRegexOptimization = &RegexOptimization{ - Function: "matches", - RegexIndex: 1, - Factory: func(call InterpretableCall, regexPattern string) (InterpretableCall, error) { - compiledRegex, err := regexp.Compile(regexPattern) - if err != nil { - return nil, err - } - return NewCall(call.ID(), call.Function(), call.OverloadID(), call.Args(), func(values ...ref.Val) ref.Val { - if len(values) != 2 { - return types.NoSuchOverloadErr() - } - in, ok := values[0].Value().(string) - if !ok { - return types.NoSuchOverloadErr() - } - return types.Bool(compiledRegex.MatchString(in)) - }), nil - }, -} diff --git a/vendor/github.com/google/cel-go/interpreter/planner.go b/vendor/github.com/google/cel-go/interpreter/planner.go deleted file mode 100644 index cf371f95d..000000000 --- a/vendor/github.com/google/cel-go/interpreter/planner.go +++ /dev/null @@ -1,756 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package interpreter - -import ( - "fmt" - "strings" - - "github.com/google/cel-go/common/ast" - "github.com/google/cel-go/common/containers" - "github.com/google/cel-go/common/functions" - "github.com/google/cel-go/common/operators" - "github.com/google/cel-go/common/types" -) - -// interpretablePlanner creates an Interpretable evaluation plan from a proto Expr value. -type interpretablePlanner interface { - // Plan generates an Interpretable value (or error) from the input proto Expr. - Plan(expr ast.Expr) (Interpretable, error) -} - -// newPlanner creates an interpretablePlanner which references a Dispatcher, TypeProvider, -// TypeAdapter, Container, and CheckedExpr value. These pieces of data are used to resolve -// functions, types, and namespaced identifiers at plan time rather than at runtime since -// it only needs to be done once and may be semi-expensive to compute. -func newPlanner(disp Dispatcher, - provider types.Provider, - adapter types.Adapter, - attrFactory AttributeFactory, - cont *containers.Container, - exprAST *ast.AST, - decorators ...InterpretableDecorator) interpretablePlanner { - return &planner{ - disp: disp, - provider: provider, - adapter: adapter, - attrFactory: attrFactory, - container: cont, - refMap: exprAST.ReferenceMap(), - typeMap: exprAST.TypeMap(), - decorators: decorators, - } -} - -// planner is an implementation of the interpretablePlanner interface. -type planner struct { - disp Dispatcher - provider types.Provider - adapter types.Adapter - attrFactory AttributeFactory - container *containers.Container - refMap map[int64]*ast.ReferenceInfo - typeMap map[int64]*types.Type - decorators []InterpretableDecorator -} - -// Plan implements the interpretablePlanner interface. This implementation of the Plan method also -// applies decorators to each Interpretable generated as part of the overall plan. Decorators are -// useful for layering functionality into the evaluation that is not natively understood by CEL, -// such as state-tracking, expression re-write, and possibly efficient thread-safe memoization of -// repeated expressions. -func (p *planner) Plan(expr ast.Expr) (Interpretable, error) { - switch expr.Kind() { - case ast.CallKind: - return p.decorate(p.planCall(expr)) - case ast.IdentKind: - return p.decorate(p.planIdent(expr)) - case ast.LiteralKind: - return p.decorate(p.planConst(expr)) - case ast.SelectKind: - return p.decorate(p.planSelect(expr)) - case ast.ListKind: - return p.decorate(p.planCreateList(expr)) - case ast.MapKind: - return p.decorate(p.planCreateMap(expr)) - case ast.StructKind: - return p.decorate(p.planCreateStruct(expr)) - case ast.ComprehensionKind: - return p.decorate(p.planComprehension(expr)) - } - return nil, fmt.Errorf("unsupported expr: %v", expr) -} - -// decorate applies the InterpretableDecorator functions to the given Interpretable. -// Both the Interpretable and error generated by a Plan step are accepted as arguments -// for convenience. -func (p *planner) decorate(i Interpretable, err error) (Interpretable, error) { - if err != nil { - return nil, err - } - for _, dec := range p.decorators { - i, err = dec(i) - if err != nil { - return nil, err - } - } - return i, nil -} - -// planIdent creates an Interpretable that resolves an identifier from an Activation. -func (p *planner) planIdent(expr ast.Expr) (Interpretable, error) { - // Establish whether the identifier is in the reference map. - if identRef, found := p.refMap[expr.ID()]; found { - return p.planCheckedIdent(expr.ID(), identRef) - } - // Create the possible attribute list for the unresolved reference. - ident := expr.AsIdent() - return &evalAttr{ - adapter: p.adapter, - attr: p.attrFactory.MaybeAttribute(expr.ID(), ident), - }, nil -} - -func (p *planner) planCheckedIdent(id int64, identRef *ast.ReferenceInfo) (Interpretable, error) { - // Plan a constant reference if this is the case for this simple identifier. - if identRef.Value != nil { - return NewConstValue(id, identRef.Value), nil - } - - // Check to see whether the type map indicates this is a type name. All types should be - // registered with the provider. - cType := p.typeMap[id] - if cType.Kind() == types.TypeKind { - cVal, found := p.provider.FindIdent(identRef.Name) - if !found { - return nil, fmt.Errorf("reference to undefined type: %s", identRef.Name) - } - return NewConstValue(id, cVal), nil - } - - // Otherwise, return the attribute for the resolved identifier name. - return &evalAttr{ - adapter: p.adapter, - attr: p.attrFactory.AbsoluteAttribute(id, identRef.Name), - }, nil -} - -// planSelect creates an Interpretable with either: -// -// a) selects a field from a map or proto. -// b) creates a field presence test for a select within a has() macro. -// c) resolves the select expression to a namespaced identifier. -func (p *planner) planSelect(expr ast.Expr) (Interpretable, error) { - // If the Select id appears in the reference map from the CheckedExpr proto then it is either - // a namespaced identifier or enum value. - if identRef, found := p.refMap[expr.ID()]; found { - return p.planCheckedIdent(expr.ID(), identRef) - } - - sel := expr.AsSelect() - // Plan the operand evaluation. - op, err := p.Plan(sel.Operand()) - if err != nil { - return nil, err - } - opType := p.typeMap[sel.Operand().ID()] - - // If the Select was marked TestOnly, this is a presence test. - // - // Note: presence tests are defined for structured (e.g. proto) and dynamic values (map, json) - // as follows: - // - True if the object field has a non-default value, e.g. obj.str != "" - // - True if the dynamic value has the field defined, e.g. key in map - // - // However, presence tests are not defined for qualified identifier names with primitive types. - // If a string named 'a.b.c' is declared in the environment and referenced within `has(a.b.c)`, - // it is not clear whether has should error or follow the convention defined for structured - // values. - - // Establish the attribute reference. - attr, isAttr := op.(InterpretableAttribute) - if !isAttr { - attr, err = p.relativeAttr(op.ID(), op, false) - if err != nil { - return nil, err - } - } - - // Build a qualifier for the attribute. - qual, err := p.attrFactory.NewQualifier(opType, expr.ID(), sel.FieldName(), false) - if err != nil { - return nil, err - } - // Modify the attribute to be test-only. - if sel.IsTestOnly() { - attr = &evalTestOnly{ - id: expr.ID(), - InterpretableAttribute: attr, - } - } - // Append the qualifier on the attribute. - _, err = attr.AddQualifier(qual) - return attr, err -} - -// planCall creates a callable Interpretable while specializing for common functions and invocation -// patterns. Specifically, conditional operators &&, ||, ?:, and (in)equality functions result in -// optimized Interpretable values. -func (p *planner) planCall(expr ast.Expr) (Interpretable, error) { - call := expr.AsCall() - target, fnName, oName := p.resolveFunction(expr) - argCount := len(call.Args()) - var offset int - if target != nil { - argCount++ - offset++ - } - - args := make([]Interpretable, argCount) - if target != nil { - arg, err := p.Plan(target) - if err != nil { - return nil, err - } - args[0] = arg - } - for i, argExpr := range call.Args() { - arg, err := p.Plan(argExpr) - if err != nil { - return nil, err - } - args[i+offset] = arg - } - - // Generate specialized Interpretable operators by function name if possible. - switch fnName { - case operators.LogicalAnd: - return p.planCallLogicalAnd(expr, args) - case operators.LogicalOr: - return p.planCallLogicalOr(expr, args) - case operators.Conditional: - return p.planCallConditional(expr, args) - case operators.Equals: - return p.planCallEqual(expr, args) - case operators.NotEquals: - return p.planCallNotEqual(expr, args) - case operators.Index: - return p.planCallIndex(expr, args, false) - case operators.OptSelect, operators.OptIndex: - return p.planCallIndex(expr, args, true) - } - - // Otherwise, generate Interpretable calls specialized by argument count. - // Try to find the specific function by overload id. - var fnDef *functions.Overload - if oName != "" { - fnDef, _ = p.disp.FindOverload(oName) - } - // If the overload id couldn't resolve the function, try the simple function name. - if fnDef == nil { - fnDef, _ = p.disp.FindOverload(fnName) - } - switch argCount { - case 0: - return p.planCallZero(expr, fnName, oName, fnDef) - case 1: - // If the FunctionOp has been used, then use it as it may exist for the purposes - // of dynamic dispatch within a singleton function implementation. - if fnDef != nil && fnDef.Unary == nil && fnDef.Function != nil { - return p.planCallVarArgs(expr, fnName, oName, fnDef, args) - } - return p.planCallUnary(expr, fnName, oName, fnDef, args) - case 2: - // If the FunctionOp has been used, then use it as it may exist for the purposes - // of dynamic dispatch within a singleton function implementation. - if fnDef != nil && fnDef.Binary == nil && fnDef.Function != nil { - return p.planCallVarArgs(expr, fnName, oName, fnDef, args) - } - return p.planCallBinary(expr, fnName, oName, fnDef, args) - default: - return p.planCallVarArgs(expr, fnName, oName, fnDef, args) - } -} - -// planCallZero generates a zero-arity callable Interpretable. -func (p *planner) planCallZero(expr ast.Expr, - function string, - overload string, - impl *functions.Overload) (Interpretable, error) { - if impl == nil || impl.Function == nil { - return nil, fmt.Errorf("no such overload: %s()", function) - } - return &evalZeroArity{ - id: expr.ID(), - function: function, - overload: overload, - impl: impl.Function, - }, nil -} - -// planCallUnary generates a unary callable Interpretable. -func (p *planner) planCallUnary(expr ast.Expr, - function string, - overload string, - impl *functions.Overload, - args []Interpretable) (Interpretable, error) { - var fn functions.UnaryOp - var trait int - var nonStrict bool - if impl != nil { - if impl.Unary == nil { - return nil, fmt.Errorf("no such overload: %s(arg)", function) - } - fn = impl.Unary - trait = impl.OperandTrait - nonStrict = impl.NonStrict - } - return &evalUnary{ - id: expr.ID(), - function: function, - overload: overload, - arg: args[0], - trait: trait, - impl: fn, - nonStrict: nonStrict, - }, nil -} - -// planCallBinary generates a binary callable Interpretable. -func (p *planner) planCallBinary(expr ast.Expr, - function string, - overload string, - impl *functions.Overload, - args []Interpretable) (Interpretable, error) { - var fn functions.BinaryOp - var trait int - var nonStrict bool - if impl != nil { - if impl.Binary == nil { - return nil, fmt.Errorf("no such overload: %s(lhs, rhs)", function) - } - fn = impl.Binary - trait = impl.OperandTrait - nonStrict = impl.NonStrict - } - return &evalBinary{ - id: expr.ID(), - function: function, - overload: overload, - lhs: args[0], - rhs: args[1], - trait: trait, - impl: fn, - nonStrict: nonStrict, - }, nil -} - -// planCallVarArgs generates a variable argument callable Interpretable. -func (p *planner) planCallVarArgs(expr ast.Expr, - function string, - overload string, - impl *functions.Overload, - args []Interpretable) (Interpretable, error) { - var fn functions.FunctionOp - var trait int - var nonStrict bool - if impl != nil { - if impl.Function == nil { - return nil, fmt.Errorf("no such overload: %s(...)", function) - } - fn = impl.Function - trait = impl.OperandTrait - nonStrict = impl.NonStrict - } - return &evalVarArgs{ - id: expr.ID(), - function: function, - overload: overload, - args: args, - trait: trait, - impl: fn, - nonStrict: nonStrict, - }, nil -} - -// planCallEqual generates an equals (==) Interpretable. -func (p *planner) planCallEqual(expr ast.Expr, args []Interpretable) (Interpretable, error) { - return &evalEq{ - id: expr.ID(), - lhs: args[0], - rhs: args[1], - }, nil -} - -// planCallNotEqual generates a not equals (!=) Interpretable. -func (p *planner) planCallNotEqual(expr ast.Expr, args []Interpretable) (Interpretable, error) { - return &evalNe{ - id: expr.ID(), - lhs: args[0], - rhs: args[1], - }, nil -} - -// planCallLogicalAnd generates a logical and (&&) Interpretable. -func (p *planner) planCallLogicalAnd(expr ast.Expr, args []Interpretable) (Interpretable, error) { - return &evalAnd{ - id: expr.ID(), - terms: args, - }, nil -} - -// planCallLogicalOr generates a logical or (||) Interpretable. -func (p *planner) planCallLogicalOr(expr ast.Expr, args []Interpretable) (Interpretable, error) { - return &evalOr{ - id: expr.ID(), - terms: args, - }, nil -} - -// planCallConditional generates a conditional / ternary (c ? t : f) Interpretable. -func (p *planner) planCallConditional(expr ast.Expr, args []Interpretable) (Interpretable, error) { - cond := args[0] - t := args[1] - var tAttr Attribute - truthyAttr, isTruthyAttr := t.(InterpretableAttribute) - if isTruthyAttr { - tAttr = truthyAttr.Attr() - } else { - tAttr = p.attrFactory.RelativeAttribute(t.ID(), t) - } - - f := args[2] - var fAttr Attribute - falsyAttr, isFalsyAttr := f.(InterpretableAttribute) - if isFalsyAttr { - fAttr = falsyAttr.Attr() - } else { - fAttr = p.attrFactory.RelativeAttribute(f.ID(), f) - } - - return &evalAttr{ - adapter: p.adapter, - attr: p.attrFactory.ConditionalAttribute(expr.ID(), cond, tAttr, fAttr), - }, nil -} - -// planCallIndex either extends an attribute with the argument to the index operation, or creates -// a relative attribute based on the return of a function call or operation. -func (p *planner) planCallIndex(expr ast.Expr, args []Interpretable, optional bool) (Interpretable, error) { - op := args[0] - ind := args[1] - opType := p.typeMap[op.ID()] - - // Establish the attribute reference. - var err error - attr, isAttr := op.(InterpretableAttribute) - if !isAttr { - attr, err = p.relativeAttr(op.ID(), op, false) - if err != nil { - return nil, err - } - } - - // Construct the qualifier type. - var qual Qualifier - switch ind := ind.(type) { - case InterpretableConst: - qual, err = p.attrFactory.NewQualifier(opType, expr.ID(), ind.Value(), optional) - case InterpretableAttribute: - qual, err = p.attrFactory.NewQualifier(opType, expr.ID(), ind, optional) - default: - qual, err = p.relativeAttr(expr.ID(), ind, optional) - } - if err != nil { - return nil, err - } - - // Add the qualifier to the attribute - _, err = attr.AddQualifier(qual) - return attr, err -} - -// planCreateList generates a list construction Interpretable. -func (p *planner) planCreateList(expr ast.Expr) (Interpretable, error) { - list := expr.AsList() - optionalIndices := list.OptionalIndices() - elements := list.Elements() - optionals := make([]bool, len(elements)) - for _, index := range optionalIndices { - if index < 0 || index >= int32(len(elements)) { - return nil, fmt.Errorf("optional index %d out of element bounds [0, %d]", index, len(elements)) - } - optionals[index] = true - } - elems := make([]Interpretable, len(elements)) - for i, elem := range elements { - elemVal, err := p.Plan(elem) - if err != nil { - return nil, err - } - elems[i] = elemVal - } - return &evalList{ - id: expr.ID(), - elems: elems, - optionals: optionals, - hasOptionals: len(optionals) != 0, - adapter: p.adapter, - }, nil -} - -// planCreateStruct generates a map or object construction Interpretable. -func (p *planner) planCreateMap(expr ast.Expr) (Interpretable, error) { - m := expr.AsMap() - entries := m.Entries() - optionals := make([]bool, len(entries)) - keys := make([]Interpretable, len(entries)) - vals := make([]Interpretable, len(entries)) - for i, e := range entries { - entry := e.AsMapEntry() - keyVal, err := p.Plan(entry.Key()) - if err != nil { - return nil, err - } - keys[i] = keyVal - - valVal, err := p.Plan(entry.Value()) - if err != nil { - return nil, err - } - vals[i] = valVal - optionals[i] = entry.IsOptional() - } - return &evalMap{ - id: expr.ID(), - keys: keys, - vals: vals, - optionals: optionals, - hasOptionals: len(optionals) != 0, - adapter: p.adapter, - }, nil -} - -// planCreateObj generates an object construction Interpretable. -func (p *planner) planCreateStruct(expr ast.Expr) (Interpretable, error) { - obj := expr.AsStruct() - typeName, defined := p.resolveTypeName(obj.TypeName()) - if !defined { - return nil, fmt.Errorf("unknown type: %s", obj.TypeName()) - } - objFields := obj.Fields() - optionals := make([]bool, len(objFields)) - fields := make([]string, len(objFields)) - vals := make([]Interpretable, len(objFields)) - for i, f := range objFields { - field := f.AsStructField() - fields[i] = field.Name() - val, err := p.Plan(field.Value()) - if err != nil { - return nil, err - } - vals[i] = val - optionals[i] = field.IsOptional() - } - return &evalObj{ - id: expr.ID(), - typeName: typeName, - fields: fields, - vals: vals, - optionals: optionals, - hasOptionals: len(optionals) != 0, - provider: p.provider, - }, nil -} - -// planComprehension generates an Interpretable fold operation. -func (p *planner) planComprehension(expr ast.Expr) (Interpretable, error) { - fold := expr.AsComprehension() - accu, err := p.Plan(fold.AccuInit()) - if err != nil { - return nil, err - } - iterRange, err := p.Plan(fold.IterRange()) - if err != nil { - return nil, err - } - cond, err := p.Plan(fold.LoopCondition()) - if err != nil { - return nil, err - } - step, err := p.Plan(fold.LoopStep()) - if err != nil { - return nil, err - } - result, err := p.Plan(fold.Result()) - if err != nil { - return nil, err - } - return &evalFold{ - id: expr.ID(), - accuVar: fold.AccuVar(), - accu: accu, - iterVar: fold.IterVar(), - iterRange: iterRange, - cond: cond, - step: step, - result: result, - adapter: p.adapter, - }, nil -} - -// planConst generates a constant valued Interpretable. -func (p *planner) planConst(expr ast.Expr) (Interpretable, error) { - return NewConstValue(expr.ID(), expr.AsLiteral()), nil -} - -// resolveTypeName takes a qualified string constructed at parse time, applies the proto -// namespace resolution rules to it in a scan over possible matching types in the TypeProvider. -func (p *planner) resolveTypeName(typeName string) (string, bool) { - for _, qualifiedTypeName := range p.container.ResolveCandidateNames(typeName) { - if _, found := p.provider.FindStructType(qualifiedTypeName); found { - return qualifiedTypeName, true - } - } - return "", false -} - -// resolveFunction determines the call target, function name, and overload name from a given Expr -// value. -// -// The resolveFunction resolves ambiguities where a function may either be a receiver-style -// invocation or a qualified global function name. -// - The target expression may only consist of ident and select expressions. -// - The function is declared in the environment using its fully-qualified name. -// - The fully-qualified function name matches the string serialized target value. -func (p *planner) resolveFunction(expr ast.Expr) (ast.Expr, string, string) { - // Note: similar logic exists within the `checker/checker.go`. If making changes here - // please consider the impact on checker.go and consolidate implementations or mirror code - // as appropriate. - call := expr.AsCall() - var target ast.Expr = nil - if call.IsMemberFunction() { - target = call.Target() - } - fnName := call.FunctionName() - - // Checked expressions always have a reference map entry, and _should_ have the fully qualified - // function name as the fnName value. - oRef, hasOverload := p.refMap[expr.ID()] - if hasOverload { - if len(oRef.OverloadIDs) == 1 { - return target, fnName, oRef.OverloadIDs[0] - } - // Note, this namespaced function name will not appear as a fully qualified name in ASTs - // built and stored before cel-go v0.5.0; however, this functionality did not work at all - // before the v0.5.0 release. - return target, fnName, "" - } - - // Parse-only expressions need to handle the same logic as is normally performed at check time, - // but with potentially much less information. The only reliable source of information about - // which functions are configured is the dispatcher. - if target == nil { - // If the user has a parse-only expression, then it should have been configured as such in - // the interpreter dispatcher as it may have been omitted from the checker environment. - for _, qualifiedName := range p.container.ResolveCandidateNames(fnName) { - _, found := p.disp.FindOverload(qualifiedName) - if found { - return nil, qualifiedName, "" - } - } - // It's possible that the overload was not found, but this situation is accounted for in - // the planCall phase; however, the leading dot used for denoting fully-qualified - // namespaced identifiers must be stripped, as all declarations already use fully-qualified - // names. This stripping behavior is handled automatically by the ResolveCandidateNames - // call. - return target, stripLeadingDot(fnName), "" - } - - // Handle the situation where the function target actually indicates a qualified function name. - qualifiedPrefix, maybeQualified := p.toQualifiedName(target) - if maybeQualified { - maybeQualifiedName := qualifiedPrefix + "." + fnName - for _, qualifiedName := range p.container.ResolveCandidateNames(maybeQualifiedName) { - _, found := p.disp.FindOverload(qualifiedName) - if found { - // Clear the target to ensure the proper arity is used for finding the - // implementation. - return nil, qualifiedName, "" - } - } - } - // In the default case, the function is exactly as it was advertised: a receiver call on with - // an expression-based target with the given simple function name. - return target, fnName, "" -} - -// relativeAttr indicates that the attribute in this case acts as a qualifier and as such needs to -// be observed to ensure that it's evaluation value is properly recorded for state tracking. -func (p *planner) relativeAttr(id int64, eval Interpretable, opt bool) (InterpretableAttribute, error) { - eAttr, ok := eval.(InterpretableAttribute) - if !ok { - eAttr = &evalAttr{ - adapter: p.adapter, - attr: p.attrFactory.RelativeAttribute(id, eval), - optional: opt, - } - } - // This looks like it should either decorate the new evalAttr node, or early return the InterpretableAttribute - decAttr, err := p.decorate(eAttr, nil) - if err != nil { - return nil, err - } - eAttr, ok = decAttr.(InterpretableAttribute) - if !ok { - return nil, fmt.Errorf("invalid attribute decoration: %v(%T)", decAttr, decAttr) - } - return eAttr, nil -} - -// toQualifiedName converts an expression AST into a qualified name if possible, with a boolean -// 'found' value that indicates if the conversion is successful. -func (p *planner) toQualifiedName(operand ast.Expr) (string, bool) { - // If the checker identified the expression as an attribute by the type-checker, then it can't - // possibly be part of qualified name in a namespace. - _, isAttr := p.refMap[operand.ID()] - if isAttr { - return "", false - } - // Since functions cannot be both namespaced and receiver functions, if the operand is not an - // qualified variable name, return the (possibly) qualified name given the expressions. - switch operand.Kind() { - case ast.IdentKind: - id := operand.AsIdent() - return id, true - case ast.SelectKind: - sel := operand.AsSelect() - // Test only expressions are not valid as qualified names. - if sel.IsTestOnly() { - return "", false - } - if qual, found := p.toQualifiedName(sel.Operand()); found { - return qual + "." + sel.FieldName(), true - } - } - return "", false -} - -func stripLeadingDot(name string) string { - if strings.HasPrefix(name, ".") { - return name[1:] - } - return name -} diff --git a/vendor/github.com/google/cel-go/interpreter/prune.go b/vendor/github.com/google/cel-go/interpreter/prune.go deleted file mode 100644 index 410d80dc4..000000000 --- a/vendor/github.com/google/cel-go/interpreter/prune.go +++ /dev/null @@ -1,543 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package interpreter - -import ( - "github.com/google/cel-go/common/ast" - "github.com/google/cel-go/common/operators" - "github.com/google/cel-go/common/overloads" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/common/types/ref" - "github.com/google/cel-go/common/types/traits" -) - -type astPruner struct { - ast.ExprFactory - expr ast.Expr - macroCalls map[int64]ast.Expr - state EvalState - nextExprID int64 -} - -// TODO Consider having a separate walk of the AST that finds common -// subexpressions. This can be called before or after constant folding to find -// common subexpressions. - -// PruneAst prunes the given AST based on the given EvalState and generates a new AST. -// Given AST is copied on write and a new AST is returned. -// Couple of typical use cases this interface would be: -// -// A) -// 1) Evaluate expr with some unknowns, -// 2) If result is unknown: -// -// a) PruneAst -// b) Goto 1 -// -// Functional call results which are known would be effectively cached across -// iterations. -// -// B) -// 1) Compile the expression (maybe via a service and maybe after checking a -// -// compiled expression does not exists in local cache) -// -// 2) Prepare the environment and the interpreter. Activation might be empty. -// 3) Eval the expression. This might return unknown or error or a concrete -// -// value. -// -// 4) PruneAst -// 4) Maybe cache the expression -// This is effectively constant folding the expression. How the environment is -// prepared in step 2 is flexible. For example, If the caller caches the -// compiled and constant folded expressions, but is not willing to constant -// fold(and thus cache results of) some external calls, then they can prepare -// the overloads accordingly. -func PruneAst(expr ast.Expr, macroCalls map[int64]ast.Expr, state EvalState) *ast.AST { - pruneState := NewEvalState() - for _, id := range state.IDs() { - v, _ := state.Value(id) - pruneState.SetValue(id, v) - } - pruner := &astPruner{ - ExprFactory: ast.NewExprFactory(), - expr: expr, - macroCalls: macroCalls, - state: pruneState, - nextExprID: getMaxID(expr)} - newExpr, _ := pruner.maybePrune(expr) - newInfo := ast.NewSourceInfo(nil) - for id, call := range pruner.macroCalls { - newInfo.SetMacroCall(id, call) - } - return ast.NewAST(newExpr, newInfo) -} - -func (p *astPruner) maybeCreateLiteral(id int64, val ref.Val) (ast.Expr, bool) { - switch v := val.(type) { - case types.Bool, types.Bytes, types.Double, types.Int, types.Null, types.String, types.Uint: - p.state.SetValue(id, val) - return p.NewLiteral(id, val), true - case types.Duration: - p.state.SetValue(id, val) - durationString := v.ConvertToType(types.StringType).(types.String) - return p.NewCall(id, overloads.TypeConvertDuration, p.NewLiteral(p.nextID(), durationString)), true - case types.Timestamp: - timestampString := v.ConvertToType(types.StringType).(types.String) - return p.NewCall(id, overloads.TypeConvertTimestamp, p.NewLiteral(p.nextID(), timestampString)), true - } - - // Attempt to build a list literal. - if list, isList := val.(traits.Lister); isList { - sz := list.Size().(types.Int) - elemExprs := make([]ast.Expr, sz) - for i := types.Int(0); i < sz; i++ { - elem := list.Get(i) - if types.IsUnknownOrError(elem) { - return nil, false - } - elemExpr, ok := p.maybeCreateLiteral(p.nextID(), elem) - if !ok { - return nil, false - } - elemExprs[i] = elemExpr - } - p.state.SetValue(id, val) - return p.NewList(id, elemExprs, []int32{}), true - } - - // Create a map literal if possible. - if mp, isMap := val.(traits.Mapper); isMap { - it := mp.Iterator() - entries := make([]ast.EntryExpr, mp.Size().(types.Int)) - i := 0 - for it.HasNext() != types.False { - key := it.Next() - val := mp.Get(key) - if types.IsUnknownOrError(key) || types.IsUnknownOrError(val) { - return nil, false - } - keyExpr, ok := p.maybeCreateLiteral(p.nextID(), key) - if !ok { - return nil, false - } - valExpr, ok := p.maybeCreateLiteral(p.nextID(), val) - if !ok { - return nil, false - } - entry := p.NewMapEntry(p.nextID(), keyExpr, valExpr, false) - entries[i] = entry - i++ - } - p.state.SetValue(id, val) - return p.NewMap(id, entries), true - } - - // TODO(issues/377) To construct message literals, the type provider will need to support - // the enumeration the fields for a given message. - return nil, false -} - -func (p *astPruner) maybePruneOptional(elem ast.Expr) (ast.Expr, bool) { - elemVal, found := p.value(elem.ID()) - if found && elemVal.Type() == types.OptionalType { - opt := elemVal.(*types.Optional) - if !opt.HasValue() { - return nil, true - } - if newElem, pruned := p.maybeCreateLiteral(elem.ID(), opt.GetValue()); pruned { - return newElem, true - } - } - return elem, false -} - -func (p *astPruner) maybePruneIn(node ast.Expr) (ast.Expr, bool) { - // elem in list - call := node.AsCall() - val, exists := p.maybeValue(call.Args()[1].ID()) - if !exists { - return nil, false - } - if sz, ok := val.(traits.Sizer); ok && sz.Size() == types.IntZero { - return p.maybeCreateLiteral(node.ID(), types.False) - } - return nil, false -} - -func (p *astPruner) maybePruneLogicalNot(node ast.Expr) (ast.Expr, bool) { - call := node.AsCall() - arg := call.Args()[0] - val, exists := p.maybeValue(arg.ID()) - if !exists { - return nil, false - } - if b, ok := val.(types.Bool); ok { - return p.maybeCreateLiteral(node.ID(), !b) - } - return nil, false -} - -func (p *astPruner) maybePruneOr(node ast.Expr) (ast.Expr, bool) { - call := node.AsCall() - // We know result is unknown, so we have at least one unknown arg - // and if one side is a known value, we know we can ignore it. - if v, exists := p.maybeValue(call.Args()[0].ID()); exists { - if v == types.True { - return p.maybeCreateLiteral(node.ID(), types.True) - } - return call.Args()[1], true - } - if v, exists := p.maybeValue(call.Args()[1].ID()); exists { - if v == types.True { - return p.maybeCreateLiteral(node.ID(), types.True) - } - return call.Args()[0], true - } - return nil, false -} - -func (p *astPruner) maybePruneAnd(node ast.Expr) (ast.Expr, bool) { - call := node.AsCall() - // We know result is unknown, so we have at least one unknown arg - // and if one side is a known value, we know we can ignore it. - if v, exists := p.maybeValue(call.Args()[0].ID()); exists { - if v == types.False { - return p.maybeCreateLiteral(node.ID(), types.False) - } - return call.Args()[1], true - } - if v, exists := p.maybeValue(call.Args()[1].ID()); exists { - if v == types.False { - return p.maybeCreateLiteral(node.ID(), types.False) - } - return call.Args()[0], true - } - return nil, false -} - -func (p *astPruner) maybePruneConditional(node ast.Expr) (ast.Expr, bool) { - call := node.AsCall() - cond, exists := p.maybeValue(call.Args()[0].ID()) - if !exists { - return nil, false - } - if cond.Value().(bool) { - return call.Args()[1], true - } - return call.Args()[2], true -} - -func (p *astPruner) maybePruneFunction(node ast.Expr) (ast.Expr, bool) { - if _, exists := p.value(node.ID()); !exists { - return nil, false - } - call := node.AsCall() - if call.FunctionName() == operators.LogicalOr { - return p.maybePruneOr(node) - } - if call.FunctionName() == operators.LogicalAnd { - return p.maybePruneAnd(node) - } - if call.FunctionName() == operators.Conditional { - return p.maybePruneConditional(node) - } - if call.FunctionName() == operators.In { - return p.maybePruneIn(node) - } - if call.FunctionName() == operators.LogicalNot { - return p.maybePruneLogicalNot(node) - } - return nil, false -} - -func (p *astPruner) maybePrune(node ast.Expr) (ast.Expr, bool) { - return p.prune(node) -} - -func (p *astPruner) prune(node ast.Expr) (ast.Expr, bool) { - if node == nil { - return node, false - } - val, valueExists := p.maybeValue(node.ID()) - if valueExists { - if newNode, ok := p.maybeCreateLiteral(node.ID(), val); ok { - delete(p.macroCalls, node.ID()) - return newNode, true - } - } - if macro, found := p.macroCalls[node.ID()]; found { - // Ensure that intermediate values for the comprehension are cleared during pruning - if node.Kind() == ast.ComprehensionKind { - compre := node.AsComprehension() - visit(macro, clearIterVarVisitor(compre.IterVar(), p.state)) - } - // prune the expression in terms of the macro call instead of the expanded form. - if newMacro, pruned := p.prune(macro); pruned { - p.macroCalls[node.ID()] = newMacro - } - } - - // We have either an unknown/error value, or something we don't want to - // transform, or expression was not evaluated. If possible, drill down - // more. - switch node.Kind() { - case ast.SelectKind: - sel := node.AsSelect() - if operand, isPruned := p.maybePrune(sel.Operand()); isPruned { - if sel.IsTestOnly() { - return p.NewPresenceTest(node.ID(), operand, sel.FieldName()), true - } - return p.NewSelect(node.ID(), operand, sel.FieldName()), true - } - case ast.CallKind: - argsPruned := false - call := node.AsCall() - args := call.Args() - newArgs := make([]ast.Expr, len(args)) - for i, a := range args { - newArgs[i] = a - if arg, isPruned := p.maybePrune(a); isPruned { - argsPruned = true - newArgs[i] = arg - } - } - if !call.IsMemberFunction() { - newCall := p.NewCall(node.ID(), call.FunctionName(), newArgs...) - if prunedCall, isPruned := p.maybePruneFunction(newCall); isPruned { - return prunedCall, true - } - return newCall, argsPruned - } - newTarget := call.Target() - targetPruned := false - if prunedTarget, isPruned := p.maybePrune(call.Target()); isPruned { - targetPruned = true - newTarget = prunedTarget - } - newCall := p.NewMemberCall(node.ID(), call.FunctionName(), newTarget, newArgs...) - if prunedCall, isPruned := p.maybePruneFunction(newCall); isPruned { - return prunedCall, true - } - return newCall, targetPruned || argsPruned - case ast.ListKind: - l := node.AsList() - elems := l.Elements() - optIndices := l.OptionalIndices() - optIndexMap := map[int32]bool{} - for _, i := range optIndices { - optIndexMap[i] = true - } - newOptIndexMap := make(map[int32]bool, len(optIndexMap)) - newElems := make([]ast.Expr, 0, len(elems)) - var listPruned bool - prunedIdx := 0 - for i, elem := range elems { - _, isOpt := optIndexMap[int32(i)] - if isOpt { - newElem, pruned := p.maybePruneOptional(elem) - if pruned { - listPruned = true - if newElem != nil { - newElems = append(newElems, newElem) - prunedIdx++ - } - continue - } - newOptIndexMap[int32(prunedIdx)] = true - } - if newElem, prunedElem := p.maybePrune(elem); prunedElem { - newElems = append(newElems, newElem) - listPruned = true - } else { - newElems = append(newElems, elem) - } - prunedIdx++ - } - optIndices = make([]int32, len(newOptIndexMap)) - idx := 0 - for i := range newOptIndexMap { - optIndices[idx] = i - idx++ - } - if listPruned { - return p.NewList(node.ID(), newElems, optIndices), true - } - case ast.MapKind: - var mapPruned bool - m := node.AsMap() - entries := m.Entries() - newEntries := make([]ast.EntryExpr, len(entries)) - for i, entry := range entries { - newEntries[i] = entry - e := entry.AsMapEntry() - newKey, keyPruned := p.maybePrune(e.Key()) - newValue, valuePruned := p.maybePrune(e.Value()) - if !keyPruned && !valuePruned { - continue - } - mapPruned = true - newEntry := p.NewMapEntry(entry.ID(), newKey, newValue, e.IsOptional()) - newEntries[i] = newEntry - } - if mapPruned { - return p.NewMap(node.ID(), newEntries), true - } - case ast.StructKind: - var structPruned bool - obj := node.AsStruct() - fields := obj.Fields() - newFields := make([]ast.EntryExpr, len(fields)) - for i, field := range fields { - newFields[i] = field - f := field.AsStructField() - newValue, prunedValue := p.maybePrune(f.Value()) - if !prunedValue { - continue - } - structPruned = true - newEntry := p.NewStructField(field.ID(), f.Name(), newValue, f.IsOptional()) - newFields[i] = newEntry - } - if structPruned { - return p.NewStruct(node.ID(), obj.TypeName(), newFields), true - } - case ast.ComprehensionKind: - compre := node.AsComprehension() - // Only the range of the comprehension is pruned since the state tracking only records - // the last iteration of the comprehension and not each step in the evaluation which - // means that the any residuals computed in between might be inaccurate. - if newRange, pruned := p.maybePrune(compre.IterRange()); pruned { - return p.NewComprehension( - node.ID(), - newRange, - compre.IterVar(), - compre.AccuVar(), - compre.AccuInit(), - compre.LoopCondition(), - compre.LoopStep(), - compre.Result(), - ), true - } - } - return node, false -} - -func (p *astPruner) value(id int64) (ref.Val, bool) { - val, found := p.state.Value(id) - return val, (found && val != nil) -} - -func (p *astPruner) maybeValue(id int64) (ref.Val, bool) { - val, found := p.value(id) - if !found || types.IsUnknownOrError(val) { - return nil, false - } - return val, true -} - -func (p *astPruner) nextID() int64 { - next := p.nextExprID - p.nextExprID++ - return next -} - -type astVisitor struct { - // visitEntry is called on every expr node, including those within a map/struct entry. - visitExpr func(expr ast.Expr) - // visitEntry is called before entering the key, value of a map/struct entry. - visitEntry func(entry ast.EntryExpr) -} - -func getMaxID(expr ast.Expr) int64 { - maxID := int64(1) - visit(expr, maxIDVisitor(&maxID)) - return maxID -} - -func clearIterVarVisitor(varName string, state EvalState) astVisitor { - return astVisitor{ - visitExpr: func(e ast.Expr) { - if e.Kind() == ast.IdentKind && e.AsIdent() == varName { - state.SetValue(e.ID(), nil) - } - }, - } -} - -func maxIDVisitor(maxID *int64) astVisitor { - return astVisitor{ - visitExpr: func(e ast.Expr) { - if e.ID() >= *maxID { - *maxID = e.ID() + 1 - } - }, - visitEntry: func(e ast.EntryExpr) { - if e.ID() >= *maxID { - *maxID = e.ID() + 1 - } - }, - } -} - -func visit(expr ast.Expr, visitor astVisitor) { - exprs := []ast.Expr{expr} - for len(exprs) != 0 { - e := exprs[0] - if visitor.visitExpr != nil { - visitor.visitExpr(e) - } - exprs = exprs[1:] - switch e.Kind() { - case ast.SelectKind: - exprs = append(exprs, e.AsSelect().Operand()) - case ast.CallKind: - call := e.AsCall() - if call.Target() != nil { - exprs = append(exprs, call.Target()) - } - exprs = append(exprs, call.Args()...) - case ast.ComprehensionKind: - compre := e.AsComprehension() - exprs = append(exprs, - compre.IterRange(), - compre.AccuInit(), - compre.LoopCondition(), - compre.LoopStep(), - compre.Result()) - case ast.ListKind: - list := e.AsList() - exprs = append(exprs, list.Elements()...) - case ast.MapKind: - for _, entry := range e.AsMap().Entries() { - e := entry.AsMapEntry() - if visitor.visitEntry != nil { - visitor.visitEntry(entry) - } - exprs = append(exprs, e.Key()) - exprs = append(exprs, e.Value()) - } - case ast.StructKind: - for _, entry := range e.AsStruct().Fields() { - f := entry.AsStructField() - if visitor.visitEntry != nil { - visitor.visitEntry(entry) - } - exprs = append(exprs, f.Value()) - } - } - } -} diff --git a/vendor/github.com/google/cel-go/interpreter/runtimecost.go b/vendor/github.com/google/cel-go/interpreter/runtimecost.go deleted file mode 100644 index b9b307c15..000000000 --- a/vendor/github.com/google/cel-go/interpreter/runtimecost.go +++ /dev/null @@ -1,316 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package interpreter - -import ( - "math" - - "github.com/google/cel-go/common" - "github.com/google/cel-go/common/overloads" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/common/types/ref" - "github.com/google/cel-go/common/types/traits" -) - -// WARNING: Any changes to cost calculations in this file require a corresponding change in checker/cost.go - -// ActualCostEstimator provides function call cost estimations at runtime -// CallCost returns an estimated cost for the function overload invocation with the given args, or nil if it has no -// estimate to provide. CEL attempts to provide reasonable estimates for its standard function library, so CallCost -// should typically not need to provide an estimate for CELs standard function. -type ActualCostEstimator interface { - CallCost(function, overloadID string, args []ref.Val, result ref.Val) *uint64 -} - -// CostObserver provides an observer that tracks runtime cost. -func CostObserver(tracker *CostTracker) EvalObserver { - observer := func(id int64, programStep any, val ref.Val) { - switch t := programStep.(type) { - case ConstantQualifier: - // TODO: Push identifiers on to the stack before observing constant qualifiers that apply to them - // and enable the below pop. Once enabled this can case can be collapsed into the Qualifier case. - tracker.cost++ - case InterpretableConst: - // zero cost - case InterpretableAttribute: - switch a := t.Attr().(type) { - case *conditionalAttribute: - // Ternary has no direct cost. All cost is from the conditional and the true/false branch expressions. - tracker.stack.drop(a.falsy.ID(), a.truthy.ID(), a.expr.ID()) - default: - tracker.stack.drop(t.Attr().ID()) - tracker.cost += common.SelectAndIdentCost - } - if !tracker.presenceTestHasCost { - if _, isTestOnly := programStep.(*evalTestOnly); isTestOnly { - tracker.cost -= common.SelectAndIdentCost - } - } - case *evalExhaustiveConditional: - // Ternary has no direct cost. All cost is from the conditional and the true/false branch expressions. - tracker.stack.drop(t.attr.falsy.ID(), t.attr.truthy.ID(), t.attr.expr.ID()) - - // While the field names are identical, the boolean operation eval structs do not share an interface and so - // must be handled individually. - case *evalOr: - for _, term := range t.terms { - tracker.stack.drop(term.ID()) - } - case *evalAnd: - for _, term := range t.terms { - tracker.stack.drop(term.ID()) - } - case *evalExhaustiveOr: - for _, term := range t.terms { - tracker.stack.drop(term.ID()) - } - case *evalExhaustiveAnd: - for _, term := range t.terms { - tracker.stack.drop(term.ID()) - } - case *evalFold: - tracker.stack.drop(t.iterRange.ID()) - case Qualifier: - tracker.cost++ - case InterpretableCall: - if argVals, ok := tracker.stack.dropArgs(t.Args()); ok { - tracker.cost += tracker.costCall(t, argVals, val) - } - case InterpretableConstructor: - tracker.stack.dropArgs(t.InitVals()) - switch t.Type() { - case types.ListType: - tracker.cost += common.ListCreateBaseCost - case types.MapType: - tracker.cost += common.MapCreateBaseCost - default: - tracker.cost += common.StructCreateBaseCost - } - } - tracker.stack.push(val, id) - - if tracker.Limit != nil && tracker.cost > *tracker.Limit { - panic(EvalCancelledError{Cause: CostLimitExceeded, Message: "operation cancelled: actual cost limit exceeded"}) - } - } - return observer -} - -// CostTrackerOption configures the behavior of CostTracker objects. -type CostTrackerOption func(*CostTracker) error - -// CostTrackerLimit sets the runtime limit on the evaluation cost during execution and will terminate the expression -// evaluation if the limit is exceeded. -func CostTrackerLimit(limit uint64) CostTrackerOption { - return func(tracker *CostTracker) error { - tracker.Limit = &limit - return nil - } -} - -// PresenceTestHasCost determines whether presence testing has a cost of one or zero. -// Defaults to presence test has a cost of one. -func PresenceTestHasCost(hasCost bool) CostTrackerOption { - return func(tracker *CostTracker) error { - tracker.presenceTestHasCost = hasCost - return nil - } -} - -// NewCostTracker creates a new CostTracker with a given estimator and a set of functional CostTrackerOption values. -func NewCostTracker(estimator ActualCostEstimator, opts ...CostTrackerOption) (*CostTracker, error) { - tracker := &CostTracker{ - Estimator: estimator, - overloadTrackers: map[string]FunctionTracker{}, - presenceTestHasCost: true, - } - for _, opt := range opts { - err := opt(tracker) - if err != nil { - return nil, err - } - } - return tracker, nil -} - -// OverloadCostTracker binds an overload ID to a runtime FunctionTracker implementation. -// -// OverloadCostTracker instances augment or override ActualCostEstimator decisions, allowing for versioned and/or -// optional cost tracking changes. -func OverloadCostTracker(overloadID string, fnTracker FunctionTracker) CostTrackerOption { - return func(tracker *CostTracker) error { - tracker.overloadTrackers[overloadID] = fnTracker - return nil - } -} - -// FunctionTracker computes the actual cost of evaluating the functions with the given arguments and result. -type FunctionTracker func(args []ref.Val, result ref.Val) *uint64 - -// CostTracker represents the information needed for tracking runtime cost. -type CostTracker struct { - Estimator ActualCostEstimator - overloadTrackers map[string]FunctionTracker - Limit *uint64 - presenceTestHasCost bool - - cost uint64 - stack refValStack -} - -// ActualCost returns the runtime cost -func (c *CostTracker) ActualCost() uint64 { - return c.cost -} - -func (c *CostTracker) costCall(call InterpretableCall, args []ref.Val, result ref.Val) uint64 { - var cost uint64 - if len(c.overloadTrackers) != 0 { - if tracker, found := c.overloadTrackers[call.OverloadID()]; found { - callCost := tracker(args, result) - if callCost != nil { - cost += *callCost - return cost - } - } - } - if c.Estimator != nil { - callCost := c.Estimator.CallCost(call.Function(), call.OverloadID(), args, result) - if callCost != nil { - cost += *callCost - return cost - } - } - // if user didn't specify, the default way of calculating runtime cost would be used. - // if user has their own implementation of ActualCostEstimator, make sure to cover the mapping between overloadId and cost calculation - switch call.OverloadID() { - // O(n) functions - case overloads.StartsWithString, overloads.EndsWithString, overloads.StringToBytes, overloads.BytesToString, overloads.ExtQuoteString, overloads.ExtFormatString: - cost += uint64(math.Ceil(float64(c.actualSize(args[0])) * common.StringTraversalCostFactor)) - case overloads.InList: - // If a list is composed entirely of constant values this is O(1), but we don't account for that here. - // We just assume all list containment checks are O(n). - cost += c.actualSize(args[1]) - // O(min(m, n)) functions - case overloads.LessString, overloads.GreaterString, overloads.LessEqualsString, overloads.GreaterEqualsString, - overloads.LessBytes, overloads.GreaterBytes, overloads.LessEqualsBytes, overloads.GreaterEqualsBytes, - overloads.Equals, overloads.NotEquals: - // When we check the equality of 2 scalar values (e.g. 2 integers, 2 floating-point numbers, 2 booleans etc.), - // the CostTracker.actualSize() function by definition returns 1 for each operand, resulting in an overall cost - // of 1. - lhsSize := c.actualSize(args[0]) - rhsSize := c.actualSize(args[1]) - minSize := lhsSize - if rhsSize < minSize { - minSize = rhsSize - } - cost += uint64(math.Ceil(float64(minSize) * common.StringTraversalCostFactor)) - // O(m+n) functions - case overloads.AddString, overloads.AddBytes: - // In the worst case scenario, we would need to reallocate a new backing store and copy both operands over. - cost += uint64(math.Ceil(float64(c.actualSize(args[0])+c.actualSize(args[1])) * common.StringTraversalCostFactor)) - // O(nm) functions - case overloads.MatchesString: - // https://swtch.com/~rsc/regexp/regexp1.html applies to RE2 implementation supported by CEL - // Add one to string length for purposes of cost calculation to prevent product of string and regex to be 0 - // in case where string is empty but regex is still expensive. - strCost := uint64(math.Ceil((1.0 + float64(c.actualSize(args[0]))) * common.StringTraversalCostFactor)) - // We don't know how many expressions are in the regex, just the string length (a huge - // improvement here would be to somehow get a count the number of expressions in the regex or - // how many states are in the regex state machine and use that to measure regex cost). - // For now, we're making a guess that each expression in a regex is typically at least 4 chars - // in length. - regexCost := uint64(math.Ceil(float64(c.actualSize(args[1])) * common.RegexStringLengthCostFactor)) - cost += strCost * regexCost - case overloads.ContainsString: - strCost := uint64(math.Ceil(float64(c.actualSize(args[0])) * common.StringTraversalCostFactor)) - substrCost := uint64(math.Ceil(float64(c.actualSize(args[1])) * common.StringTraversalCostFactor)) - cost += strCost * substrCost - - default: - // The following operations are assumed to have O(1) complexity. - // - AddList due to the implementation. Index lookup can be O(c) the - // number of concatenated lists, but we don't track that is cost calculations. - // - Conversions, since none perform a traversal of a type of unbound length. - // - Computing the size of strings, byte sequences, lists and maps. - // - Logical operations and all operators on fixed width scalars (comparisons, equality) - // - Any functions that don't have a declared cost either here or in provided ActualCostEstimator. - cost++ - - } - return cost -} - -// actualSize returns the size of value -func (c *CostTracker) actualSize(value ref.Val) uint64 { - if sz, ok := value.(traits.Sizer); ok { - return uint64(sz.Size().(types.Int)) - } - return 1 -} - -type stackVal struct { - Val ref.Val - ID int64 -} - -// refValStack keeps track of values of the stack for cost calculation purposes -type refValStack []stackVal - -func (s *refValStack) push(val ref.Val, id int64) { - value := stackVal{Val: val, ID: id} - *s = append(*s, value) -} - -// TODO: Allowing drop and dropArgs to remove stack items above the IDs they are provided is a workaround. drop and dropArgs -// should find and remove only the stack items matching the provided IDs once all attributes are properly pushed and popped from stack. - -// drop searches the stack for each ID and removes the ID and all stack items above it. -// If none of the IDs are found, the stack is not modified. -// WARNING: It is possible for multiple expressions with the same ID to exist (due to how macros are implemented) so it's -// possible that a dropped ID will remain on the stack. They should be removed when IDs on the stack are popped. -func (s *refValStack) drop(ids ...int64) { - for _, id := range ids { - for idx := len(*s) - 1; idx >= 0; idx-- { - if (*s)[idx].ID == id { - *s = (*s)[:idx] - break - } - } - } -} - -// dropArgs searches the stack for all the args by their IDs, accumulates their associated ref.Vals and drops any -// stack items above any of the arg IDs. If any of the IDs are not found the stack, false is returned. -// Args are assumed to be found in the stack in reverse order, i.e. the last arg is expected to be found highest in -// the stack. -// WARNING: It is possible for multiple expressions with the same ID to exist (due to how macros are implemented) so it's -// possible that a dropped ID will remain on the stack. They should be removed when IDs on the stack are popped. -func (s *refValStack) dropArgs(args []Interpretable) ([]ref.Val, bool) { - result := make([]ref.Val, len(args)) -argloop: - for nIdx := len(args) - 1; nIdx >= 0; nIdx-- { - for idx := len(*s) - 1; idx >= 0; idx-- { - if (*s)[idx].ID == args[nIdx].ID() { - el := (*s)[idx] - *s = (*s)[:idx] - result[nIdx] = el.Val - continue argloop - } - } - return nil, false - } - return result, true -} diff --git a/vendor/github.com/google/cel-go/parser/BUILD.bazel b/vendor/github.com/google/cel-go/parser/BUILD.bazel deleted file mode 100644 index 97bc9bd43..000000000 --- a/vendor/github.com/google/cel-go/parser/BUILD.bazel +++ /dev/null @@ -1,58 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -package( - licenses = ["notice"], # Apache 2.0 -) - -go_library( - name = "go_default_library", - srcs = [ - "errors.go", - "helper.go", - "input.go", - "macro.go", - "options.go", - "parser.go", - "unescape.go", - "unparser.go", - ], - importpath = "github.com/google/cel-go/parser", - visibility = ["//visibility:public"], - deps = [ - "//common:go_default_library", - "//common/ast:go_default_library", - "//common/operators:go_default_library", - "//common/runes:go_default_library", - "//common/types:go_default_library", - "//common/types/ref:go_default_library", - "//parser/gen:go_default_library", - "@com_github_antlr4_go_antlr_v4//:go_default_library", - "@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library", - "@org_golang_google_protobuf//proto:go_default_library", - "@org_golang_google_protobuf//types/known/structpb:go_default_library", - ], -) - -go_test( - name = "go_default_test", - size = "small", - srcs = [ - "helper_test.go", - "parser_test.go", - "unescape_test.go", - "unparser_test.go", - ], - embed = [ - ":go_default_library", - ], - deps = [ - "//common/ast:go_default_library", - "//common/debug:go_default_library", - "//common/types:go_default_library", - "//parser/gen:go_default_library", - "//test:go_default_library", - "@com_github_antlr4_go_antlr_v4//:go_default_library", - "@org_golang_google_protobuf//proto:go_default_library", - "@org_golang_google_protobuf//testing/protocmp:go_default_library", - ], -) diff --git a/vendor/github.com/google/cel-go/parser/errors.go b/vendor/github.com/google/cel-go/parser/errors.go deleted file mode 100644 index 93ae7a3ad..000000000 --- a/vendor/github.com/google/cel-go/parser/errors.go +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package parser - -import ( - "fmt" - - "github.com/google/cel-go/common" -) - -// parseErrors is a specialization of Errors. -type parseErrors struct { - errs *common.Errors -} - -// errorCount indicates the number of errors reported. -func (e *parseErrors) errorCount() int { - return len(e.errs.GetErrors()) -} - -func (e *parseErrors) internalError(message string) { - e.errs.ReportErrorAtID(0, common.NoLocation, message) -} - -func (e *parseErrors) syntaxError(l common.Location, message string) { - e.errs.ReportErrorAtID(0, l, fmt.Sprintf("Syntax error: %s", message)) -} - -func (e *parseErrors) reportErrorAtID(id int64, l common.Location, message string, args ...any) { - e.errs.ReportErrorAtID(id, l, message, args...) -} diff --git a/vendor/github.com/google/cel-go/parser/gen/BUILD.bazel b/vendor/github.com/google/cel-go/parser/gen/BUILD.bazel deleted file mode 100644 index e70433483..000000000 --- a/vendor/github.com/google/cel-go/parser/gen/BUILD.bazel +++ /dev/null @@ -1,26 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -package( - default_visibility = ["//parser:__subpackages__"], - licenses = ["notice"], # Apache 2.0 -) - -go_library( - name = "go_default_library", - srcs = [ - "cel_base_listener.go", - "cel_base_visitor.go", - "cel_lexer.go", - "cel_listener.go", - "cel_parser.go", - "cel_visitor.go", - ], - data = [ - "CEL.tokens", - "CELLexer.tokens", - ], - importpath = "github.com/google/cel-go/parser/gen", - deps = [ - "@com_github_antlr4_go_antlr_v4//:go_default_library", - ], -) diff --git a/vendor/github.com/google/cel-go/parser/gen/CEL.g4 b/vendor/github.com/google/cel-go/parser/gen/CEL.g4 deleted file mode 100644 index b011da803..000000000 --- a/vendor/github.com/google/cel-go/parser/gen/CEL.g4 +++ /dev/null @@ -1,200 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -grammar CEL; - -// Grammar Rules -// ============= - -start - : e=expr EOF - ; - -expr - : e=conditionalOr (op='?' e1=conditionalOr ':' e2=expr)? - ; - -conditionalOr - : e=conditionalAnd (ops+='||' e1+=conditionalAnd)* - ; - -conditionalAnd - : e=relation (ops+='&&' e1+=relation)* - ; - -relation - : calc - | relation op=('<'|'<='|'>='|'>'|'=='|'!='|'in') relation - ; - -calc - : unary - | calc op=('*'|'/'|'%') calc - | calc op=('+'|'-') calc - ; - -unary - : member # MemberExpr - | (ops+='!')+ member # LogicalNot - | (ops+='-')+ member # Negate - ; - -member - : primary # PrimaryExpr - | member op='.' (opt='?')? id=IDENTIFIER # Select - | member op='.' id=IDENTIFIER open='(' args=exprList? ')' # MemberCall - | member op='[' (opt='?')? index=expr ']' # Index - ; - -primary - : leadingDot='.'? id=IDENTIFIER (op='(' args=exprList? ')')? # IdentOrGlobalCall - | '(' e=expr ')' # Nested - | op='[' elems=listInit? ','? ']' # CreateList - | op='{' entries=mapInitializerList? ','? '}' # CreateStruct - | leadingDot='.'? ids+=IDENTIFIER (ops+='.' ids+=IDENTIFIER)* - op='{' entries=fieldInitializerList? ','? '}' # CreateMessage - | literal # ConstantLiteral - ; - -exprList - : e+=expr (',' e+=expr)* - ; - -listInit - : elems+=optExpr (',' elems+=optExpr)* - ; - -fieldInitializerList - : fields+=optField cols+=':' values+=expr (',' fields+=optField cols+=':' values+=expr)* - ; - -optField - : (opt='?')? IDENTIFIER - ; - -mapInitializerList - : keys+=optExpr cols+=':' values+=expr (',' keys+=optExpr cols+=':' values+=expr)* - ; - -optExpr - : (opt='?')? e=expr - ; - -literal - : sign=MINUS? tok=NUM_INT # Int - | tok=NUM_UINT # Uint - | sign=MINUS? tok=NUM_FLOAT # Double - | tok=STRING # String - | tok=BYTES # Bytes - | tok=CEL_TRUE # BoolTrue - | tok=CEL_FALSE # BoolFalse - | tok=NUL # Null - ; - -// Lexer Rules -// =========== - -EQUALS : '=='; -NOT_EQUALS : '!='; -IN: 'in'; -LESS : '<'; -LESS_EQUALS : '<='; -GREATER_EQUALS : '>='; -GREATER : '>'; -LOGICAL_AND : '&&'; -LOGICAL_OR : '||'; - -LBRACKET : '['; -RPRACKET : ']'; -LBRACE : '{'; -RBRACE : '}'; -LPAREN : '('; -RPAREN : ')'; -DOT : '.'; -COMMA : ','; -MINUS : '-'; -EXCLAM : '!'; -QUESTIONMARK : '?'; -COLON : ':'; -PLUS : '+'; -STAR : '*'; -SLASH : '/'; -PERCENT : '%'; -CEL_TRUE : 'true'; -CEL_FALSE : 'false'; -NUL : 'null'; - -fragment BACKSLASH : '\\'; -fragment LETTER : 'A'..'Z' | 'a'..'z' ; -fragment DIGIT : '0'..'9' ; -fragment EXPONENT : ('e' | 'E') ( '+' | '-' )? DIGIT+ ; -fragment HEXDIGIT : ('0'..'9'|'a'..'f'|'A'..'F') ; -fragment RAW : 'r' | 'R'; - -fragment ESC_SEQ - : ESC_CHAR_SEQ - | ESC_BYTE_SEQ - | ESC_UNI_SEQ - | ESC_OCT_SEQ - ; - -fragment ESC_CHAR_SEQ - : BACKSLASH ('a'|'b'|'f'|'n'|'r'|'t'|'v'|'"'|'\''|'\\'|'?'|'`') - ; - -fragment ESC_OCT_SEQ - : BACKSLASH ('0'..'3') ('0'..'7') ('0'..'7') - ; - -fragment ESC_BYTE_SEQ - : BACKSLASH ( 'x' | 'X' ) HEXDIGIT HEXDIGIT - ; - -fragment ESC_UNI_SEQ - : BACKSLASH 'u' HEXDIGIT HEXDIGIT HEXDIGIT HEXDIGIT - | BACKSLASH 'U' HEXDIGIT HEXDIGIT HEXDIGIT HEXDIGIT HEXDIGIT HEXDIGIT HEXDIGIT HEXDIGIT - ; - -WHITESPACE : ( '\t' | ' ' | '\r' | '\n'| '\u000C' )+ -> channel(HIDDEN) ; -COMMENT : '//' (~'\n')* -> channel(HIDDEN) ; - -NUM_FLOAT - : ( DIGIT+ ('.' DIGIT+) EXPONENT? - | DIGIT+ EXPONENT - | '.' DIGIT+ EXPONENT? - ) - ; - -NUM_INT - : ( DIGIT+ | '0x' HEXDIGIT+ ); - -NUM_UINT - : DIGIT+ ( 'u' | 'U' ) - | '0x' HEXDIGIT+ ( 'u' | 'U' ) - ; - -STRING - : '"' (ESC_SEQ | ~('\\'|'"'|'\n'|'\r'))* '"' - | '\'' (ESC_SEQ | ~('\\'|'\''|'\n'|'\r'))* '\'' - | '"""' (ESC_SEQ | ~('\\'))*? '"""' - | '\'\'\'' (ESC_SEQ | ~('\\'))*? '\'\'\'' - | RAW '"' ~('"'|'\n'|'\r')* '"' - | RAW '\'' ~('\''|'\n'|'\r')* '\'' - | RAW '"""' .*? '"""' - | RAW '\'\'\'' .*? '\'\'\'' - ; - -BYTES : ('b' | 'B') STRING; - -IDENTIFIER : (LETTER | '_') ( LETTER | DIGIT | '_')*; diff --git a/vendor/github.com/google/cel-go/parser/gen/CEL.interp b/vendor/github.com/google/cel-go/parser/gen/CEL.interp deleted file mode 100644 index 75b8bb3e2..000000000 --- a/vendor/github.com/google/cel-go/parser/gen/CEL.interp +++ /dev/null @@ -1,99 +0,0 @@ -token literal names: -null -'==' -'!=' -'in' -'<' -'<=' -'>=' -'>' -'&&' -'||' -'[' -']' -'{' -'}' -'(' -')' -'.' -',' -'-' -'!' -'?' -':' -'+' -'*' -'/' -'%' -'true' -'false' -'null' -null -null -null -null -null -null -null -null - -token symbolic names: -null -EQUALS -NOT_EQUALS -IN -LESS -LESS_EQUALS -GREATER_EQUALS -GREATER -LOGICAL_AND -LOGICAL_OR -LBRACKET -RPRACKET -LBRACE -RBRACE -LPAREN -RPAREN -DOT -COMMA -MINUS -EXCLAM -QUESTIONMARK -COLON -PLUS -STAR -SLASH -PERCENT -CEL_TRUE -CEL_FALSE -NUL -WHITESPACE -COMMENT -NUM_FLOAT -NUM_INT -NUM_UINT -STRING -BYTES -IDENTIFIER - -rule names: -start -expr -conditionalOr -conditionalAnd -relation -calc -unary -member -primary -exprList -listInit -fieldInitializerList -optField -mapInitializerList -optExpr -literal - - -atn: -[4, 1, 36, 251, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 42, 8, 1, 1, 2, 1, 2, 1, 2, 5, 2, 47, 8, 2, 10, 2, 12, 2, 50, 9, 2, 1, 3, 1, 3, 1, 3, 5, 3, 55, 8, 3, 10, 3, 12, 3, 58, 9, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 5, 4, 66, 8, 4, 10, 4, 12, 4, 69, 9, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 5, 5, 80, 8, 5, 10, 5, 12, 5, 83, 9, 5, 1, 6, 1, 6, 4, 6, 87, 8, 6, 11, 6, 12, 6, 88, 1, 6, 1, 6, 4, 6, 93, 8, 6, 11, 6, 12, 6, 94, 1, 6, 3, 6, 98, 8, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 106, 8, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 114, 8, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 120, 8, 7, 1, 7, 1, 7, 1, 7, 5, 7, 125, 8, 7, 10, 7, 12, 7, 128, 9, 7, 1, 8, 3, 8, 131, 8, 8, 1, 8, 1, 8, 1, 8, 3, 8, 136, 8, 8, 1, 8, 3, 8, 139, 8, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 3, 8, 147, 8, 8, 1, 8, 3, 8, 150, 8, 8, 1, 8, 1, 8, 1, 8, 3, 8, 155, 8, 8, 1, 8, 3, 8, 158, 8, 8, 1, 8, 1, 8, 3, 8, 162, 8, 8, 1, 8, 1, 8, 1, 8, 5, 8, 167, 8, 8, 10, 8, 12, 8, 170, 9, 8, 1, 8, 1, 8, 3, 8, 174, 8, 8, 1, 8, 3, 8, 177, 8, 8, 1, 8, 1, 8, 3, 8, 181, 8, 8, 1, 9, 1, 9, 1, 9, 5, 9, 186, 8, 9, 10, 9, 12, 9, 189, 9, 9, 1, 10, 1, 10, 1, 10, 5, 10, 194, 8, 10, 10, 10, 12, 10, 197, 9, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 5, 11, 207, 8, 11, 10, 11, 12, 11, 210, 9, 11, 1, 12, 3, 12, 213, 8, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 5, 13, 225, 8, 13, 10, 13, 12, 13, 228, 9, 13, 1, 14, 3, 14, 231, 8, 14, 1, 14, 1, 14, 1, 15, 3, 15, 236, 8, 15, 1, 15, 1, 15, 1, 15, 3, 15, 241, 8, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 3, 15, 249, 8, 15, 1, 15, 0, 3, 8, 10, 14, 16, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 0, 3, 1, 0, 1, 7, 1, 0, 23, 25, 2, 0, 18, 18, 22, 22, 281, 0, 32, 1, 0, 0, 0, 2, 35, 1, 0, 0, 0, 4, 43, 1, 0, 0, 0, 6, 51, 1, 0, 0, 0, 8, 59, 1, 0, 0, 0, 10, 70, 1, 0, 0, 0, 12, 97, 1, 0, 0, 0, 14, 99, 1, 0, 0, 0, 16, 180, 1, 0, 0, 0, 18, 182, 1, 0, 0, 0, 20, 190, 1, 0, 0, 0, 22, 198, 1, 0, 0, 0, 24, 212, 1, 0, 0, 0, 26, 216, 1, 0, 0, 0, 28, 230, 1, 0, 0, 0, 30, 248, 1, 0, 0, 0, 32, 33, 3, 2, 1, 0, 33, 34, 5, 0, 0, 1, 34, 1, 1, 0, 0, 0, 35, 41, 3, 4, 2, 0, 36, 37, 5, 20, 0, 0, 37, 38, 3, 4, 2, 0, 38, 39, 5, 21, 0, 0, 39, 40, 3, 2, 1, 0, 40, 42, 1, 0, 0, 0, 41, 36, 1, 0, 0, 0, 41, 42, 1, 0, 0, 0, 42, 3, 1, 0, 0, 0, 43, 48, 3, 6, 3, 0, 44, 45, 5, 9, 0, 0, 45, 47, 3, 6, 3, 0, 46, 44, 1, 0, 0, 0, 47, 50, 1, 0, 0, 0, 48, 46, 1, 0, 0, 0, 48, 49, 1, 0, 0, 0, 49, 5, 1, 0, 0, 0, 50, 48, 1, 0, 0, 0, 51, 56, 3, 8, 4, 0, 52, 53, 5, 8, 0, 0, 53, 55, 3, 8, 4, 0, 54, 52, 1, 0, 0, 0, 55, 58, 1, 0, 0, 0, 56, 54, 1, 0, 0, 0, 56, 57, 1, 0, 0, 0, 57, 7, 1, 0, 0, 0, 58, 56, 1, 0, 0, 0, 59, 60, 6, 4, -1, 0, 60, 61, 3, 10, 5, 0, 61, 67, 1, 0, 0, 0, 62, 63, 10, 1, 0, 0, 63, 64, 7, 0, 0, 0, 64, 66, 3, 8, 4, 2, 65, 62, 1, 0, 0, 0, 66, 69, 1, 0, 0, 0, 67, 65, 1, 0, 0, 0, 67, 68, 1, 0, 0, 0, 68, 9, 1, 0, 0, 0, 69, 67, 1, 0, 0, 0, 70, 71, 6, 5, -1, 0, 71, 72, 3, 12, 6, 0, 72, 81, 1, 0, 0, 0, 73, 74, 10, 2, 0, 0, 74, 75, 7, 1, 0, 0, 75, 80, 3, 10, 5, 3, 76, 77, 10, 1, 0, 0, 77, 78, 7, 2, 0, 0, 78, 80, 3, 10, 5, 2, 79, 73, 1, 0, 0, 0, 79, 76, 1, 0, 0, 0, 80, 83, 1, 0, 0, 0, 81, 79, 1, 0, 0, 0, 81, 82, 1, 0, 0, 0, 82, 11, 1, 0, 0, 0, 83, 81, 1, 0, 0, 0, 84, 98, 3, 14, 7, 0, 85, 87, 5, 19, 0, 0, 86, 85, 1, 0, 0, 0, 87, 88, 1, 0, 0, 0, 88, 86, 1, 0, 0, 0, 88, 89, 1, 0, 0, 0, 89, 90, 1, 0, 0, 0, 90, 98, 3, 14, 7, 0, 91, 93, 5, 18, 0, 0, 92, 91, 1, 0, 0, 0, 93, 94, 1, 0, 0, 0, 94, 92, 1, 0, 0, 0, 94, 95, 1, 0, 0, 0, 95, 96, 1, 0, 0, 0, 96, 98, 3, 14, 7, 0, 97, 84, 1, 0, 0, 0, 97, 86, 1, 0, 0, 0, 97, 92, 1, 0, 0, 0, 98, 13, 1, 0, 0, 0, 99, 100, 6, 7, -1, 0, 100, 101, 3, 16, 8, 0, 101, 126, 1, 0, 0, 0, 102, 103, 10, 3, 0, 0, 103, 105, 5, 16, 0, 0, 104, 106, 5, 20, 0, 0, 105, 104, 1, 0, 0, 0, 105, 106, 1, 0, 0, 0, 106, 107, 1, 0, 0, 0, 107, 125, 5, 36, 0, 0, 108, 109, 10, 2, 0, 0, 109, 110, 5, 16, 0, 0, 110, 111, 5, 36, 0, 0, 111, 113, 5, 14, 0, 0, 112, 114, 3, 18, 9, 0, 113, 112, 1, 0, 0, 0, 113, 114, 1, 0, 0, 0, 114, 115, 1, 0, 0, 0, 115, 125, 5, 15, 0, 0, 116, 117, 10, 1, 0, 0, 117, 119, 5, 10, 0, 0, 118, 120, 5, 20, 0, 0, 119, 118, 1, 0, 0, 0, 119, 120, 1, 0, 0, 0, 120, 121, 1, 0, 0, 0, 121, 122, 3, 2, 1, 0, 122, 123, 5, 11, 0, 0, 123, 125, 1, 0, 0, 0, 124, 102, 1, 0, 0, 0, 124, 108, 1, 0, 0, 0, 124, 116, 1, 0, 0, 0, 125, 128, 1, 0, 0, 0, 126, 124, 1, 0, 0, 0, 126, 127, 1, 0, 0, 0, 127, 15, 1, 0, 0, 0, 128, 126, 1, 0, 0, 0, 129, 131, 5, 16, 0, 0, 130, 129, 1, 0, 0, 0, 130, 131, 1, 0, 0, 0, 131, 132, 1, 0, 0, 0, 132, 138, 5, 36, 0, 0, 133, 135, 5, 14, 0, 0, 134, 136, 3, 18, 9, 0, 135, 134, 1, 0, 0, 0, 135, 136, 1, 0, 0, 0, 136, 137, 1, 0, 0, 0, 137, 139, 5, 15, 0, 0, 138, 133, 1, 0, 0, 0, 138, 139, 1, 0, 0, 0, 139, 181, 1, 0, 0, 0, 140, 141, 5, 14, 0, 0, 141, 142, 3, 2, 1, 0, 142, 143, 5, 15, 0, 0, 143, 181, 1, 0, 0, 0, 144, 146, 5, 10, 0, 0, 145, 147, 3, 20, 10, 0, 146, 145, 1, 0, 0, 0, 146, 147, 1, 0, 0, 0, 147, 149, 1, 0, 0, 0, 148, 150, 5, 17, 0, 0, 149, 148, 1, 0, 0, 0, 149, 150, 1, 0, 0, 0, 150, 151, 1, 0, 0, 0, 151, 181, 5, 11, 0, 0, 152, 154, 5, 12, 0, 0, 153, 155, 3, 26, 13, 0, 154, 153, 1, 0, 0, 0, 154, 155, 1, 0, 0, 0, 155, 157, 1, 0, 0, 0, 156, 158, 5, 17, 0, 0, 157, 156, 1, 0, 0, 0, 157, 158, 1, 0, 0, 0, 158, 159, 1, 0, 0, 0, 159, 181, 5, 13, 0, 0, 160, 162, 5, 16, 0, 0, 161, 160, 1, 0, 0, 0, 161, 162, 1, 0, 0, 0, 162, 163, 1, 0, 0, 0, 163, 168, 5, 36, 0, 0, 164, 165, 5, 16, 0, 0, 165, 167, 5, 36, 0, 0, 166, 164, 1, 0, 0, 0, 167, 170, 1, 0, 0, 0, 168, 166, 1, 0, 0, 0, 168, 169, 1, 0, 0, 0, 169, 171, 1, 0, 0, 0, 170, 168, 1, 0, 0, 0, 171, 173, 5, 12, 0, 0, 172, 174, 3, 22, 11, 0, 173, 172, 1, 0, 0, 0, 173, 174, 1, 0, 0, 0, 174, 176, 1, 0, 0, 0, 175, 177, 5, 17, 0, 0, 176, 175, 1, 0, 0, 0, 176, 177, 1, 0, 0, 0, 177, 178, 1, 0, 0, 0, 178, 181, 5, 13, 0, 0, 179, 181, 3, 30, 15, 0, 180, 130, 1, 0, 0, 0, 180, 140, 1, 0, 0, 0, 180, 144, 1, 0, 0, 0, 180, 152, 1, 0, 0, 0, 180, 161, 1, 0, 0, 0, 180, 179, 1, 0, 0, 0, 181, 17, 1, 0, 0, 0, 182, 187, 3, 2, 1, 0, 183, 184, 5, 17, 0, 0, 184, 186, 3, 2, 1, 0, 185, 183, 1, 0, 0, 0, 186, 189, 1, 0, 0, 0, 187, 185, 1, 0, 0, 0, 187, 188, 1, 0, 0, 0, 188, 19, 1, 0, 0, 0, 189, 187, 1, 0, 0, 0, 190, 195, 3, 28, 14, 0, 191, 192, 5, 17, 0, 0, 192, 194, 3, 28, 14, 0, 193, 191, 1, 0, 0, 0, 194, 197, 1, 0, 0, 0, 195, 193, 1, 0, 0, 0, 195, 196, 1, 0, 0, 0, 196, 21, 1, 0, 0, 0, 197, 195, 1, 0, 0, 0, 198, 199, 3, 24, 12, 0, 199, 200, 5, 21, 0, 0, 200, 208, 3, 2, 1, 0, 201, 202, 5, 17, 0, 0, 202, 203, 3, 24, 12, 0, 203, 204, 5, 21, 0, 0, 204, 205, 3, 2, 1, 0, 205, 207, 1, 0, 0, 0, 206, 201, 1, 0, 0, 0, 207, 210, 1, 0, 0, 0, 208, 206, 1, 0, 0, 0, 208, 209, 1, 0, 0, 0, 209, 23, 1, 0, 0, 0, 210, 208, 1, 0, 0, 0, 211, 213, 5, 20, 0, 0, 212, 211, 1, 0, 0, 0, 212, 213, 1, 0, 0, 0, 213, 214, 1, 0, 0, 0, 214, 215, 5, 36, 0, 0, 215, 25, 1, 0, 0, 0, 216, 217, 3, 28, 14, 0, 217, 218, 5, 21, 0, 0, 218, 226, 3, 2, 1, 0, 219, 220, 5, 17, 0, 0, 220, 221, 3, 28, 14, 0, 221, 222, 5, 21, 0, 0, 222, 223, 3, 2, 1, 0, 223, 225, 1, 0, 0, 0, 224, 219, 1, 0, 0, 0, 225, 228, 1, 0, 0, 0, 226, 224, 1, 0, 0, 0, 226, 227, 1, 0, 0, 0, 227, 27, 1, 0, 0, 0, 228, 226, 1, 0, 0, 0, 229, 231, 5, 20, 0, 0, 230, 229, 1, 0, 0, 0, 230, 231, 1, 0, 0, 0, 231, 232, 1, 0, 0, 0, 232, 233, 3, 2, 1, 0, 233, 29, 1, 0, 0, 0, 234, 236, 5, 18, 0, 0, 235, 234, 1, 0, 0, 0, 235, 236, 1, 0, 0, 0, 236, 237, 1, 0, 0, 0, 237, 249, 5, 32, 0, 0, 238, 249, 5, 33, 0, 0, 239, 241, 5, 18, 0, 0, 240, 239, 1, 0, 0, 0, 240, 241, 1, 0, 0, 0, 241, 242, 1, 0, 0, 0, 242, 249, 5, 31, 0, 0, 243, 249, 5, 34, 0, 0, 244, 249, 5, 35, 0, 0, 245, 249, 5, 26, 0, 0, 246, 249, 5, 27, 0, 0, 247, 249, 5, 28, 0, 0, 248, 235, 1, 0, 0, 0, 248, 238, 1, 0, 0, 0, 248, 240, 1, 0, 0, 0, 248, 243, 1, 0, 0, 0, 248, 244, 1, 0, 0, 0, 248, 245, 1, 0, 0, 0, 248, 246, 1, 0, 0, 0, 248, 247, 1, 0, 0, 0, 249, 31, 1, 0, 0, 0, 35, 41, 48, 56, 67, 79, 81, 88, 94, 97, 105, 113, 119, 124, 126, 130, 135, 138, 146, 149, 154, 157, 161, 168, 173, 176, 180, 187, 195, 208, 212, 226, 230, 235, 240, 248] \ No newline at end of file diff --git a/vendor/github.com/google/cel-go/parser/gen/CEL.tokens b/vendor/github.com/google/cel-go/parser/gen/CEL.tokens deleted file mode 100644 index b305bdad3..000000000 --- a/vendor/github.com/google/cel-go/parser/gen/CEL.tokens +++ /dev/null @@ -1,64 +0,0 @@ -EQUALS=1 -NOT_EQUALS=2 -IN=3 -LESS=4 -LESS_EQUALS=5 -GREATER_EQUALS=6 -GREATER=7 -LOGICAL_AND=8 -LOGICAL_OR=9 -LBRACKET=10 -RPRACKET=11 -LBRACE=12 -RBRACE=13 -LPAREN=14 -RPAREN=15 -DOT=16 -COMMA=17 -MINUS=18 -EXCLAM=19 -QUESTIONMARK=20 -COLON=21 -PLUS=22 -STAR=23 -SLASH=24 -PERCENT=25 -CEL_TRUE=26 -CEL_FALSE=27 -NUL=28 -WHITESPACE=29 -COMMENT=30 -NUM_FLOAT=31 -NUM_INT=32 -NUM_UINT=33 -STRING=34 -BYTES=35 -IDENTIFIER=36 -'=='=1 -'!='=2 -'in'=3 -'<'=4 -'<='=5 -'>='=6 -'>'=7 -'&&'=8 -'||'=9 -'['=10 -']'=11 -'{'=12 -'}'=13 -'('=14 -')'=15 -'.'=16 -','=17 -'-'=18 -'!'=19 -'?'=20 -':'=21 -'+'=22 -'*'=23 -'/'=24 -'%'=25 -'true'=26 -'false'=27 -'null'=28 diff --git a/vendor/github.com/google/cel-go/parser/gen/CELLexer.interp b/vendor/github.com/google/cel-go/parser/gen/CELLexer.interp deleted file mode 100644 index 26e7f471e..000000000 --- a/vendor/github.com/google/cel-go/parser/gen/CELLexer.interp +++ /dev/null @@ -1,136 +0,0 @@ -token literal names: -null -'==' -'!=' -'in' -'<' -'<=' -'>=' -'>' -'&&' -'||' -'[' -']' -'{' -'}' -'(' -')' -'.' -',' -'-' -'!' -'?' -':' -'+' -'*' -'/' -'%' -'true' -'false' -'null' -null -null -null -null -null -null -null -null - -token symbolic names: -null -EQUALS -NOT_EQUALS -IN -LESS -LESS_EQUALS -GREATER_EQUALS -GREATER -LOGICAL_AND -LOGICAL_OR -LBRACKET -RPRACKET -LBRACE -RBRACE -LPAREN -RPAREN -DOT -COMMA -MINUS -EXCLAM -QUESTIONMARK -COLON -PLUS -STAR -SLASH -PERCENT -CEL_TRUE -CEL_FALSE -NUL -WHITESPACE -COMMENT -NUM_FLOAT -NUM_INT -NUM_UINT -STRING -BYTES -IDENTIFIER - -rule names: -EQUALS -NOT_EQUALS -IN -LESS -LESS_EQUALS -GREATER_EQUALS -GREATER -LOGICAL_AND -LOGICAL_OR -LBRACKET -RPRACKET -LBRACE -RBRACE -LPAREN -RPAREN -DOT -COMMA -MINUS -EXCLAM -QUESTIONMARK -COLON -PLUS -STAR -SLASH -PERCENT -CEL_TRUE -CEL_FALSE -NUL -BACKSLASH -LETTER -DIGIT -EXPONENT -HEXDIGIT -RAW -ESC_SEQ -ESC_CHAR_SEQ -ESC_OCT_SEQ -ESC_BYTE_SEQ -ESC_UNI_SEQ -WHITESPACE -COMMENT -NUM_FLOAT -NUM_INT -NUM_UINT -STRING -BYTES -IDENTIFIER - -channel names: -DEFAULT_TOKEN_CHANNEL -HIDDEN - -mode names: -DEFAULT_MODE - -atn: -[4, 0, 36, 423, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 19, 1, 19, 1, 20, 1, 20, 1, 21, 1, 21, 1, 22, 1, 22, 1, 23, 1, 23, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 1, 25, 1, 25, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 28, 1, 28, 1, 29, 1, 29, 1, 30, 1, 30, 1, 31, 1, 31, 3, 31, 177, 8, 31, 1, 31, 4, 31, 180, 8, 31, 11, 31, 12, 31, 181, 1, 32, 1, 32, 1, 33, 1, 33, 1, 34, 1, 34, 1, 34, 1, 34, 3, 34, 192, 8, 34, 1, 35, 1, 35, 1, 35, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 37, 1, 37, 1, 37, 1, 37, 1, 37, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 3, 38, 225, 8, 38, 1, 39, 4, 39, 228, 8, 39, 11, 39, 12, 39, 229, 1, 39, 1, 39, 1, 40, 1, 40, 1, 40, 1, 40, 5, 40, 238, 8, 40, 10, 40, 12, 40, 241, 9, 40, 1, 40, 1, 40, 1, 41, 4, 41, 246, 8, 41, 11, 41, 12, 41, 247, 1, 41, 1, 41, 4, 41, 252, 8, 41, 11, 41, 12, 41, 253, 1, 41, 3, 41, 257, 8, 41, 1, 41, 4, 41, 260, 8, 41, 11, 41, 12, 41, 261, 1, 41, 1, 41, 1, 41, 1, 41, 4, 41, 268, 8, 41, 11, 41, 12, 41, 269, 1, 41, 3, 41, 273, 8, 41, 3, 41, 275, 8, 41, 1, 42, 4, 42, 278, 8, 42, 11, 42, 12, 42, 279, 1, 42, 1, 42, 1, 42, 1, 42, 4, 42, 286, 8, 42, 11, 42, 12, 42, 287, 3, 42, 290, 8, 42, 1, 43, 4, 43, 293, 8, 43, 11, 43, 12, 43, 294, 1, 43, 1, 43, 1, 43, 1, 43, 1, 43, 1, 43, 4, 43, 303, 8, 43, 11, 43, 12, 43, 304, 1, 43, 1, 43, 3, 43, 309, 8, 43, 1, 44, 1, 44, 1, 44, 5, 44, 314, 8, 44, 10, 44, 12, 44, 317, 9, 44, 1, 44, 1, 44, 1, 44, 1, 44, 5, 44, 323, 8, 44, 10, 44, 12, 44, 326, 9, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 5, 44, 335, 8, 44, 10, 44, 12, 44, 338, 9, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 5, 44, 349, 8, 44, 10, 44, 12, 44, 352, 9, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 5, 44, 360, 8, 44, 10, 44, 12, 44, 363, 9, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 5, 44, 370, 8, 44, 10, 44, 12, 44, 373, 9, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 5, 44, 383, 8, 44, 10, 44, 12, 44, 386, 9, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 5, 44, 398, 8, 44, 10, 44, 12, 44, 401, 9, 44, 1, 44, 1, 44, 1, 44, 1, 44, 3, 44, 407, 8, 44, 1, 45, 1, 45, 1, 45, 1, 46, 1, 46, 3, 46, 414, 8, 46, 1, 46, 1, 46, 1, 46, 5, 46, 419, 8, 46, 10, 46, 12, 46, 422, 9, 46, 4, 336, 350, 384, 399, 0, 47, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 25, 51, 26, 53, 27, 55, 28, 57, 0, 59, 0, 61, 0, 63, 0, 65, 0, 67, 0, 69, 0, 71, 0, 73, 0, 75, 0, 77, 0, 79, 29, 81, 30, 83, 31, 85, 32, 87, 33, 89, 34, 91, 35, 93, 36, 1, 0, 16, 2, 0, 65, 90, 97, 122, 2, 0, 69, 69, 101, 101, 2, 0, 43, 43, 45, 45, 3, 0, 48, 57, 65, 70, 97, 102, 2, 0, 82, 82, 114, 114, 10, 0, 34, 34, 39, 39, 63, 63, 92, 92, 96, 98, 102, 102, 110, 110, 114, 114, 116, 116, 118, 118, 2, 0, 88, 88, 120, 120, 3, 0, 9, 10, 12, 13, 32, 32, 1, 0, 10, 10, 2, 0, 85, 85, 117, 117, 4, 0, 10, 10, 13, 13, 34, 34, 92, 92, 4, 0, 10, 10, 13, 13, 39, 39, 92, 92, 1, 0, 92, 92, 3, 0, 10, 10, 13, 13, 34, 34, 3, 0, 10, 10, 13, 13, 39, 39, 2, 0, 66, 66, 98, 98, 456, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 55, 1, 0, 0, 0, 0, 79, 1, 0, 0, 0, 0, 81, 1, 0, 0, 0, 0, 83, 1, 0, 0, 0, 0, 85, 1, 0, 0, 0, 0, 87, 1, 0, 0, 0, 0, 89, 1, 0, 0, 0, 0, 91, 1, 0, 0, 0, 0, 93, 1, 0, 0, 0, 1, 95, 1, 0, 0, 0, 3, 98, 1, 0, 0, 0, 5, 101, 1, 0, 0, 0, 7, 104, 1, 0, 0, 0, 9, 106, 1, 0, 0, 0, 11, 109, 1, 0, 0, 0, 13, 112, 1, 0, 0, 0, 15, 114, 1, 0, 0, 0, 17, 117, 1, 0, 0, 0, 19, 120, 1, 0, 0, 0, 21, 122, 1, 0, 0, 0, 23, 124, 1, 0, 0, 0, 25, 126, 1, 0, 0, 0, 27, 128, 1, 0, 0, 0, 29, 130, 1, 0, 0, 0, 31, 132, 1, 0, 0, 0, 33, 134, 1, 0, 0, 0, 35, 136, 1, 0, 0, 0, 37, 138, 1, 0, 0, 0, 39, 140, 1, 0, 0, 0, 41, 142, 1, 0, 0, 0, 43, 144, 1, 0, 0, 0, 45, 146, 1, 0, 0, 0, 47, 148, 1, 0, 0, 0, 49, 150, 1, 0, 0, 0, 51, 152, 1, 0, 0, 0, 53, 157, 1, 0, 0, 0, 55, 163, 1, 0, 0, 0, 57, 168, 1, 0, 0, 0, 59, 170, 1, 0, 0, 0, 61, 172, 1, 0, 0, 0, 63, 174, 1, 0, 0, 0, 65, 183, 1, 0, 0, 0, 67, 185, 1, 0, 0, 0, 69, 191, 1, 0, 0, 0, 71, 193, 1, 0, 0, 0, 73, 196, 1, 0, 0, 0, 75, 201, 1, 0, 0, 0, 77, 224, 1, 0, 0, 0, 79, 227, 1, 0, 0, 0, 81, 233, 1, 0, 0, 0, 83, 274, 1, 0, 0, 0, 85, 289, 1, 0, 0, 0, 87, 308, 1, 0, 0, 0, 89, 406, 1, 0, 0, 0, 91, 408, 1, 0, 0, 0, 93, 413, 1, 0, 0, 0, 95, 96, 5, 61, 0, 0, 96, 97, 5, 61, 0, 0, 97, 2, 1, 0, 0, 0, 98, 99, 5, 33, 0, 0, 99, 100, 5, 61, 0, 0, 100, 4, 1, 0, 0, 0, 101, 102, 5, 105, 0, 0, 102, 103, 5, 110, 0, 0, 103, 6, 1, 0, 0, 0, 104, 105, 5, 60, 0, 0, 105, 8, 1, 0, 0, 0, 106, 107, 5, 60, 0, 0, 107, 108, 5, 61, 0, 0, 108, 10, 1, 0, 0, 0, 109, 110, 5, 62, 0, 0, 110, 111, 5, 61, 0, 0, 111, 12, 1, 0, 0, 0, 112, 113, 5, 62, 0, 0, 113, 14, 1, 0, 0, 0, 114, 115, 5, 38, 0, 0, 115, 116, 5, 38, 0, 0, 116, 16, 1, 0, 0, 0, 117, 118, 5, 124, 0, 0, 118, 119, 5, 124, 0, 0, 119, 18, 1, 0, 0, 0, 120, 121, 5, 91, 0, 0, 121, 20, 1, 0, 0, 0, 122, 123, 5, 93, 0, 0, 123, 22, 1, 0, 0, 0, 124, 125, 5, 123, 0, 0, 125, 24, 1, 0, 0, 0, 126, 127, 5, 125, 0, 0, 127, 26, 1, 0, 0, 0, 128, 129, 5, 40, 0, 0, 129, 28, 1, 0, 0, 0, 130, 131, 5, 41, 0, 0, 131, 30, 1, 0, 0, 0, 132, 133, 5, 46, 0, 0, 133, 32, 1, 0, 0, 0, 134, 135, 5, 44, 0, 0, 135, 34, 1, 0, 0, 0, 136, 137, 5, 45, 0, 0, 137, 36, 1, 0, 0, 0, 138, 139, 5, 33, 0, 0, 139, 38, 1, 0, 0, 0, 140, 141, 5, 63, 0, 0, 141, 40, 1, 0, 0, 0, 142, 143, 5, 58, 0, 0, 143, 42, 1, 0, 0, 0, 144, 145, 5, 43, 0, 0, 145, 44, 1, 0, 0, 0, 146, 147, 5, 42, 0, 0, 147, 46, 1, 0, 0, 0, 148, 149, 5, 47, 0, 0, 149, 48, 1, 0, 0, 0, 150, 151, 5, 37, 0, 0, 151, 50, 1, 0, 0, 0, 152, 153, 5, 116, 0, 0, 153, 154, 5, 114, 0, 0, 154, 155, 5, 117, 0, 0, 155, 156, 5, 101, 0, 0, 156, 52, 1, 0, 0, 0, 157, 158, 5, 102, 0, 0, 158, 159, 5, 97, 0, 0, 159, 160, 5, 108, 0, 0, 160, 161, 5, 115, 0, 0, 161, 162, 5, 101, 0, 0, 162, 54, 1, 0, 0, 0, 163, 164, 5, 110, 0, 0, 164, 165, 5, 117, 0, 0, 165, 166, 5, 108, 0, 0, 166, 167, 5, 108, 0, 0, 167, 56, 1, 0, 0, 0, 168, 169, 5, 92, 0, 0, 169, 58, 1, 0, 0, 0, 170, 171, 7, 0, 0, 0, 171, 60, 1, 0, 0, 0, 172, 173, 2, 48, 57, 0, 173, 62, 1, 0, 0, 0, 174, 176, 7, 1, 0, 0, 175, 177, 7, 2, 0, 0, 176, 175, 1, 0, 0, 0, 176, 177, 1, 0, 0, 0, 177, 179, 1, 0, 0, 0, 178, 180, 3, 61, 30, 0, 179, 178, 1, 0, 0, 0, 180, 181, 1, 0, 0, 0, 181, 179, 1, 0, 0, 0, 181, 182, 1, 0, 0, 0, 182, 64, 1, 0, 0, 0, 183, 184, 7, 3, 0, 0, 184, 66, 1, 0, 0, 0, 185, 186, 7, 4, 0, 0, 186, 68, 1, 0, 0, 0, 187, 192, 3, 71, 35, 0, 188, 192, 3, 75, 37, 0, 189, 192, 3, 77, 38, 0, 190, 192, 3, 73, 36, 0, 191, 187, 1, 0, 0, 0, 191, 188, 1, 0, 0, 0, 191, 189, 1, 0, 0, 0, 191, 190, 1, 0, 0, 0, 192, 70, 1, 0, 0, 0, 193, 194, 3, 57, 28, 0, 194, 195, 7, 5, 0, 0, 195, 72, 1, 0, 0, 0, 196, 197, 3, 57, 28, 0, 197, 198, 2, 48, 51, 0, 198, 199, 2, 48, 55, 0, 199, 200, 2, 48, 55, 0, 200, 74, 1, 0, 0, 0, 201, 202, 3, 57, 28, 0, 202, 203, 7, 6, 0, 0, 203, 204, 3, 65, 32, 0, 204, 205, 3, 65, 32, 0, 205, 76, 1, 0, 0, 0, 206, 207, 3, 57, 28, 0, 207, 208, 5, 117, 0, 0, 208, 209, 3, 65, 32, 0, 209, 210, 3, 65, 32, 0, 210, 211, 3, 65, 32, 0, 211, 212, 3, 65, 32, 0, 212, 225, 1, 0, 0, 0, 213, 214, 3, 57, 28, 0, 214, 215, 5, 85, 0, 0, 215, 216, 3, 65, 32, 0, 216, 217, 3, 65, 32, 0, 217, 218, 3, 65, 32, 0, 218, 219, 3, 65, 32, 0, 219, 220, 3, 65, 32, 0, 220, 221, 3, 65, 32, 0, 221, 222, 3, 65, 32, 0, 222, 223, 3, 65, 32, 0, 223, 225, 1, 0, 0, 0, 224, 206, 1, 0, 0, 0, 224, 213, 1, 0, 0, 0, 225, 78, 1, 0, 0, 0, 226, 228, 7, 7, 0, 0, 227, 226, 1, 0, 0, 0, 228, 229, 1, 0, 0, 0, 229, 227, 1, 0, 0, 0, 229, 230, 1, 0, 0, 0, 230, 231, 1, 0, 0, 0, 231, 232, 6, 39, 0, 0, 232, 80, 1, 0, 0, 0, 233, 234, 5, 47, 0, 0, 234, 235, 5, 47, 0, 0, 235, 239, 1, 0, 0, 0, 236, 238, 8, 8, 0, 0, 237, 236, 1, 0, 0, 0, 238, 241, 1, 0, 0, 0, 239, 237, 1, 0, 0, 0, 239, 240, 1, 0, 0, 0, 240, 242, 1, 0, 0, 0, 241, 239, 1, 0, 0, 0, 242, 243, 6, 40, 0, 0, 243, 82, 1, 0, 0, 0, 244, 246, 3, 61, 30, 0, 245, 244, 1, 0, 0, 0, 246, 247, 1, 0, 0, 0, 247, 245, 1, 0, 0, 0, 247, 248, 1, 0, 0, 0, 248, 249, 1, 0, 0, 0, 249, 251, 5, 46, 0, 0, 250, 252, 3, 61, 30, 0, 251, 250, 1, 0, 0, 0, 252, 253, 1, 0, 0, 0, 253, 251, 1, 0, 0, 0, 253, 254, 1, 0, 0, 0, 254, 256, 1, 0, 0, 0, 255, 257, 3, 63, 31, 0, 256, 255, 1, 0, 0, 0, 256, 257, 1, 0, 0, 0, 257, 275, 1, 0, 0, 0, 258, 260, 3, 61, 30, 0, 259, 258, 1, 0, 0, 0, 260, 261, 1, 0, 0, 0, 261, 259, 1, 0, 0, 0, 261, 262, 1, 0, 0, 0, 262, 263, 1, 0, 0, 0, 263, 264, 3, 63, 31, 0, 264, 275, 1, 0, 0, 0, 265, 267, 5, 46, 0, 0, 266, 268, 3, 61, 30, 0, 267, 266, 1, 0, 0, 0, 268, 269, 1, 0, 0, 0, 269, 267, 1, 0, 0, 0, 269, 270, 1, 0, 0, 0, 270, 272, 1, 0, 0, 0, 271, 273, 3, 63, 31, 0, 272, 271, 1, 0, 0, 0, 272, 273, 1, 0, 0, 0, 273, 275, 1, 0, 0, 0, 274, 245, 1, 0, 0, 0, 274, 259, 1, 0, 0, 0, 274, 265, 1, 0, 0, 0, 275, 84, 1, 0, 0, 0, 276, 278, 3, 61, 30, 0, 277, 276, 1, 0, 0, 0, 278, 279, 1, 0, 0, 0, 279, 277, 1, 0, 0, 0, 279, 280, 1, 0, 0, 0, 280, 290, 1, 0, 0, 0, 281, 282, 5, 48, 0, 0, 282, 283, 5, 120, 0, 0, 283, 285, 1, 0, 0, 0, 284, 286, 3, 65, 32, 0, 285, 284, 1, 0, 0, 0, 286, 287, 1, 0, 0, 0, 287, 285, 1, 0, 0, 0, 287, 288, 1, 0, 0, 0, 288, 290, 1, 0, 0, 0, 289, 277, 1, 0, 0, 0, 289, 281, 1, 0, 0, 0, 290, 86, 1, 0, 0, 0, 291, 293, 3, 61, 30, 0, 292, 291, 1, 0, 0, 0, 293, 294, 1, 0, 0, 0, 294, 292, 1, 0, 0, 0, 294, 295, 1, 0, 0, 0, 295, 296, 1, 0, 0, 0, 296, 297, 7, 9, 0, 0, 297, 309, 1, 0, 0, 0, 298, 299, 5, 48, 0, 0, 299, 300, 5, 120, 0, 0, 300, 302, 1, 0, 0, 0, 301, 303, 3, 65, 32, 0, 302, 301, 1, 0, 0, 0, 303, 304, 1, 0, 0, 0, 304, 302, 1, 0, 0, 0, 304, 305, 1, 0, 0, 0, 305, 306, 1, 0, 0, 0, 306, 307, 7, 9, 0, 0, 307, 309, 1, 0, 0, 0, 308, 292, 1, 0, 0, 0, 308, 298, 1, 0, 0, 0, 309, 88, 1, 0, 0, 0, 310, 315, 5, 34, 0, 0, 311, 314, 3, 69, 34, 0, 312, 314, 8, 10, 0, 0, 313, 311, 1, 0, 0, 0, 313, 312, 1, 0, 0, 0, 314, 317, 1, 0, 0, 0, 315, 313, 1, 0, 0, 0, 315, 316, 1, 0, 0, 0, 316, 318, 1, 0, 0, 0, 317, 315, 1, 0, 0, 0, 318, 407, 5, 34, 0, 0, 319, 324, 5, 39, 0, 0, 320, 323, 3, 69, 34, 0, 321, 323, 8, 11, 0, 0, 322, 320, 1, 0, 0, 0, 322, 321, 1, 0, 0, 0, 323, 326, 1, 0, 0, 0, 324, 322, 1, 0, 0, 0, 324, 325, 1, 0, 0, 0, 325, 327, 1, 0, 0, 0, 326, 324, 1, 0, 0, 0, 327, 407, 5, 39, 0, 0, 328, 329, 5, 34, 0, 0, 329, 330, 5, 34, 0, 0, 330, 331, 5, 34, 0, 0, 331, 336, 1, 0, 0, 0, 332, 335, 3, 69, 34, 0, 333, 335, 8, 12, 0, 0, 334, 332, 1, 0, 0, 0, 334, 333, 1, 0, 0, 0, 335, 338, 1, 0, 0, 0, 336, 337, 1, 0, 0, 0, 336, 334, 1, 0, 0, 0, 337, 339, 1, 0, 0, 0, 338, 336, 1, 0, 0, 0, 339, 340, 5, 34, 0, 0, 340, 341, 5, 34, 0, 0, 341, 407, 5, 34, 0, 0, 342, 343, 5, 39, 0, 0, 343, 344, 5, 39, 0, 0, 344, 345, 5, 39, 0, 0, 345, 350, 1, 0, 0, 0, 346, 349, 3, 69, 34, 0, 347, 349, 8, 12, 0, 0, 348, 346, 1, 0, 0, 0, 348, 347, 1, 0, 0, 0, 349, 352, 1, 0, 0, 0, 350, 351, 1, 0, 0, 0, 350, 348, 1, 0, 0, 0, 351, 353, 1, 0, 0, 0, 352, 350, 1, 0, 0, 0, 353, 354, 5, 39, 0, 0, 354, 355, 5, 39, 0, 0, 355, 407, 5, 39, 0, 0, 356, 357, 3, 67, 33, 0, 357, 361, 5, 34, 0, 0, 358, 360, 8, 13, 0, 0, 359, 358, 1, 0, 0, 0, 360, 363, 1, 0, 0, 0, 361, 359, 1, 0, 0, 0, 361, 362, 1, 0, 0, 0, 362, 364, 1, 0, 0, 0, 363, 361, 1, 0, 0, 0, 364, 365, 5, 34, 0, 0, 365, 407, 1, 0, 0, 0, 366, 367, 3, 67, 33, 0, 367, 371, 5, 39, 0, 0, 368, 370, 8, 14, 0, 0, 369, 368, 1, 0, 0, 0, 370, 373, 1, 0, 0, 0, 371, 369, 1, 0, 0, 0, 371, 372, 1, 0, 0, 0, 372, 374, 1, 0, 0, 0, 373, 371, 1, 0, 0, 0, 374, 375, 5, 39, 0, 0, 375, 407, 1, 0, 0, 0, 376, 377, 3, 67, 33, 0, 377, 378, 5, 34, 0, 0, 378, 379, 5, 34, 0, 0, 379, 380, 5, 34, 0, 0, 380, 384, 1, 0, 0, 0, 381, 383, 9, 0, 0, 0, 382, 381, 1, 0, 0, 0, 383, 386, 1, 0, 0, 0, 384, 385, 1, 0, 0, 0, 384, 382, 1, 0, 0, 0, 385, 387, 1, 0, 0, 0, 386, 384, 1, 0, 0, 0, 387, 388, 5, 34, 0, 0, 388, 389, 5, 34, 0, 0, 389, 390, 5, 34, 0, 0, 390, 407, 1, 0, 0, 0, 391, 392, 3, 67, 33, 0, 392, 393, 5, 39, 0, 0, 393, 394, 5, 39, 0, 0, 394, 395, 5, 39, 0, 0, 395, 399, 1, 0, 0, 0, 396, 398, 9, 0, 0, 0, 397, 396, 1, 0, 0, 0, 398, 401, 1, 0, 0, 0, 399, 400, 1, 0, 0, 0, 399, 397, 1, 0, 0, 0, 400, 402, 1, 0, 0, 0, 401, 399, 1, 0, 0, 0, 402, 403, 5, 39, 0, 0, 403, 404, 5, 39, 0, 0, 404, 405, 5, 39, 0, 0, 405, 407, 1, 0, 0, 0, 406, 310, 1, 0, 0, 0, 406, 319, 1, 0, 0, 0, 406, 328, 1, 0, 0, 0, 406, 342, 1, 0, 0, 0, 406, 356, 1, 0, 0, 0, 406, 366, 1, 0, 0, 0, 406, 376, 1, 0, 0, 0, 406, 391, 1, 0, 0, 0, 407, 90, 1, 0, 0, 0, 408, 409, 7, 15, 0, 0, 409, 410, 3, 89, 44, 0, 410, 92, 1, 0, 0, 0, 411, 414, 3, 59, 29, 0, 412, 414, 5, 95, 0, 0, 413, 411, 1, 0, 0, 0, 413, 412, 1, 0, 0, 0, 414, 420, 1, 0, 0, 0, 415, 419, 3, 59, 29, 0, 416, 419, 3, 61, 30, 0, 417, 419, 5, 95, 0, 0, 418, 415, 1, 0, 0, 0, 418, 416, 1, 0, 0, 0, 418, 417, 1, 0, 0, 0, 419, 422, 1, 0, 0, 0, 420, 418, 1, 0, 0, 0, 420, 421, 1, 0, 0, 0, 421, 94, 1, 0, 0, 0, 422, 420, 1, 0, 0, 0, 36, 0, 176, 181, 191, 224, 229, 239, 247, 253, 256, 261, 269, 272, 274, 279, 287, 289, 294, 304, 308, 313, 315, 322, 324, 334, 336, 348, 350, 361, 371, 384, 399, 406, 413, 418, 420, 1, 0, 1, 0] \ No newline at end of file diff --git a/vendor/github.com/google/cel-go/parser/gen/CELLexer.tokens b/vendor/github.com/google/cel-go/parser/gen/CELLexer.tokens deleted file mode 100644 index b305bdad3..000000000 --- a/vendor/github.com/google/cel-go/parser/gen/CELLexer.tokens +++ /dev/null @@ -1,64 +0,0 @@ -EQUALS=1 -NOT_EQUALS=2 -IN=3 -LESS=4 -LESS_EQUALS=5 -GREATER_EQUALS=6 -GREATER=7 -LOGICAL_AND=8 -LOGICAL_OR=9 -LBRACKET=10 -RPRACKET=11 -LBRACE=12 -RBRACE=13 -LPAREN=14 -RPAREN=15 -DOT=16 -COMMA=17 -MINUS=18 -EXCLAM=19 -QUESTIONMARK=20 -COLON=21 -PLUS=22 -STAR=23 -SLASH=24 -PERCENT=25 -CEL_TRUE=26 -CEL_FALSE=27 -NUL=28 -WHITESPACE=29 -COMMENT=30 -NUM_FLOAT=31 -NUM_INT=32 -NUM_UINT=33 -STRING=34 -BYTES=35 -IDENTIFIER=36 -'=='=1 -'!='=2 -'in'=3 -'<'=4 -'<='=5 -'>='=6 -'>'=7 -'&&'=8 -'||'=9 -'['=10 -']'=11 -'{'=12 -'}'=13 -'('=14 -')'=15 -'.'=16 -','=17 -'-'=18 -'!'=19 -'?'=20 -':'=21 -'+'=22 -'*'=23 -'/'=24 -'%'=25 -'true'=26 -'false'=27 -'null'=28 diff --git a/vendor/github.com/google/cel-go/parser/gen/cel_base_listener.go b/vendor/github.com/google/cel-go/parser/gen/cel_base_listener.go deleted file mode 100644 index c49d03867..000000000 --- a/vendor/github.com/google/cel-go/parser/gen/cel_base_listener.go +++ /dev/null @@ -1,219 +0,0 @@ -// Code generated from /usr/local/google/home/tswadell/go/src/github.com/google/cel-go/parser/gen/CEL.g4 by ANTLR 4.13.1. DO NOT EDIT. - -package gen // CEL -import "github.com/antlr4-go/antlr/v4" - -// BaseCELListener is a complete listener for a parse tree produced by CELParser. -type BaseCELListener struct{} - -var _ CELListener = &BaseCELListener{} - -// VisitTerminal is called when a terminal node is visited. -func (s *BaseCELListener) VisitTerminal(node antlr.TerminalNode) {} - -// VisitErrorNode is called when an error node is visited. -func (s *BaseCELListener) VisitErrorNode(node antlr.ErrorNode) {} - -// EnterEveryRule is called when any rule is entered. -func (s *BaseCELListener) EnterEveryRule(ctx antlr.ParserRuleContext) {} - -// ExitEveryRule is called when any rule is exited. -func (s *BaseCELListener) ExitEveryRule(ctx antlr.ParserRuleContext) {} - -// EnterStart is called when production start is entered. -func (s *BaseCELListener) EnterStart(ctx *StartContext) {} - -// ExitStart is called when production start is exited. -func (s *BaseCELListener) ExitStart(ctx *StartContext) {} - -// EnterExpr is called when production expr is entered. -func (s *BaseCELListener) EnterExpr(ctx *ExprContext) {} - -// ExitExpr is called when production expr is exited. -func (s *BaseCELListener) ExitExpr(ctx *ExprContext) {} - -// EnterConditionalOr is called when production conditionalOr is entered. -func (s *BaseCELListener) EnterConditionalOr(ctx *ConditionalOrContext) {} - -// ExitConditionalOr is called when production conditionalOr is exited. -func (s *BaseCELListener) ExitConditionalOr(ctx *ConditionalOrContext) {} - -// EnterConditionalAnd is called when production conditionalAnd is entered. -func (s *BaseCELListener) EnterConditionalAnd(ctx *ConditionalAndContext) {} - -// ExitConditionalAnd is called when production conditionalAnd is exited. -func (s *BaseCELListener) ExitConditionalAnd(ctx *ConditionalAndContext) {} - -// EnterRelation is called when production relation is entered. -func (s *BaseCELListener) EnterRelation(ctx *RelationContext) {} - -// ExitRelation is called when production relation is exited. -func (s *BaseCELListener) ExitRelation(ctx *RelationContext) {} - -// EnterCalc is called when production calc is entered. -func (s *BaseCELListener) EnterCalc(ctx *CalcContext) {} - -// ExitCalc is called when production calc is exited. -func (s *BaseCELListener) ExitCalc(ctx *CalcContext) {} - -// EnterMemberExpr is called when production MemberExpr is entered. -func (s *BaseCELListener) EnterMemberExpr(ctx *MemberExprContext) {} - -// ExitMemberExpr is called when production MemberExpr is exited. -func (s *BaseCELListener) ExitMemberExpr(ctx *MemberExprContext) {} - -// EnterLogicalNot is called when production LogicalNot is entered. -func (s *BaseCELListener) EnterLogicalNot(ctx *LogicalNotContext) {} - -// ExitLogicalNot is called when production LogicalNot is exited. -func (s *BaseCELListener) ExitLogicalNot(ctx *LogicalNotContext) {} - -// EnterNegate is called when production Negate is entered. -func (s *BaseCELListener) EnterNegate(ctx *NegateContext) {} - -// ExitNegate is called when production Negate is exited. -func (s *BaseCELListener) ExitNegate(ctx *NegateContext) {} - -// EnterMemberCall is called when production MemberCall is entered. -func (s *BaseCELListener) EnterMemberCall(ctx *MemberCallContext) {} - -// ExitMemberCall is called when production MemberCall is exited. -func (s *BaseCELListener) ExitMemberCall(ctx *MemberCallContext) {} - -// EnterSelect is called when production Select is entered. -func (s *BaseCELListener) EnterSelect(ctx *SelectContext) {} - -// ExitSelect is called when production Select is exited. -func (s *BaseCELListener) ExitSelect(ctx *SelectContext) {} - -// EnterPrimaryExpr is called when production PrimaryExpr is entered. -func (s *BaseCELListener) EnterPrimaryExpr(ctx *PrimaryExprContext) {} - -// ExitPrimaryExpr is called when production PrimaryExpr is exited. -func (s *BaseCELListener) ExitPrimaryExpr(ctx *PrimaryExprContext) {} - -// EnterIndex is called when production Index is entered. -func (s *BaseCELListener) EnterIndex(ctx *IndexContext) {} - -// ExitIndex is called when production Index is exited. -func (s *BaseCELListener) ExitIndex(ctx *IndexContext) {} - -// EnterIdentOrGlobalCall is called when production IdentOrGlobalCall is entered. -func (s *BaseCELListener) EnterIdentOrGlobalCall(ctx *IdentOrGlobalCallContext) {} - -// ExitIdentOrGlobalCall is called when production IdentOrGlobalCall is exited. -func (s *BaseCELListener) ExitIdentOrGlobalCall(ctx *IdentOrGlobalCallContext) {} - -// EnterNested is called when production Nested is entered. -func (s *BaseCELListener) EnterNested(ctx *NestedContext) {} - -// ExitNested is called when production Nested is exited. -func (s *BaseCELListener) ExitNested(ctx *NestedContext) {} - -// EnterCreateList is called when production CreateList is entered. -func (s *BaseCELListener) EnterCreateList(ctx *CreateListContext) {} - -// ExitCreateList is called when production CreateList is exited. -func (s *BaseCELListener) ExitCreateList(ctx *CreateListContext) {} - -// EnterCreateStruct is called when production CreateStruct is entered. -func (s *BaseCELListener) EnterCreateStruct(ctx *CreateStructContext) {} - -// ExitCreateStruct is called when production CreateStruct is exited. -func (s *BaseCELListener) ExitCreateStruct(ctx *CreateStructContext) {} - -// EnterCreateMessage is called when production CreateMessage is entered. -func (s *BaseCELListener) EnterCreateMessage(ctx *CreateMessageContext) {} - -// ExitCreateMessage is called when production CreateMessage is exited. -func (s *BaseCELListener) ExitCreateMessage(ctx *CreateMessageContext) {} - -// EnterConstantLiteral is called when production ConstantLiteral is entered. -func (s *BaseCELListener) EnterConstantLiteral(ctx *ConstantLiteralContext) {} - -// ExitConstantLiteral is called when production ConstantLiteral is exited. -func (s *BaseCELListener) ExitConstantLiteral(ctx *ConstantLiteralContext) {} - -// EnterExprList is called when production exprList is entered. -func (s *BaseCELListener) EnterExprList(ctx *ExprListContext) {} - -// ExitExprList is called when production exprList is exited. -func (s *BaseCELListener) ExitExprList(ctx *ExprListContext) {} - -// EnterListInit is called when production listInit is entered. -func (s *BaseCELListener) EnterListInit(ctx *ListInitContext) {} - -// ExitListInit is called when production listInit is exited. -func (s *BaseCELListener) ExitListInit(ctx *ListInitContext) {} - -// EnterFieldInitializerList is called when production fieldInitializerList is entered. -func (s *BaseCELListener) EnterFieldInitializerList(ctx *FieldInitializerListContext) {} - -// ExitFieldInitializerList is called when production fieldInitializerList is exited. -func (s *BaseCELListener) ExitFieldInitializerList(ctx *FieldInitializerListContext) {} - -// EnterOptField is called when production optField is entered. -func (s *BaseCELListener) EnterOptField(ctx *OptFieldContext) {} - -// ExitOptField is called when production optField is exited. -func (s *BaseCELListener) ExitOptField(ctx *OptFieldContext) {} - -// EnterMapInitializerList is called when production mapInitializerList is entered. -func (s *BaseCELListener) EnterMapInitializerList(ctx *MapInitializerListContext) {} - -// ExitMapInitializerList is called when production mapInitializerList is exited. -func (s *BaseCELListener) ExitMapInitializerList(ctx *MapInitializerListContext) {} - -// EnterOptExpr is called when production optExpr is entered. -func (s *BaseCELListener) EnterOptExpr(ctx *OptExprContext) {} - -// ExitOptExpr is called when production optExpr is exited. -func (s *BaseCELListener) ExitOptExpr(ctx *OptExprContext) {} - -// EnterInt is called when production Int is entered. -func (s *BaseCELListener) EnterInt(ctx *IntContext) {} - -// ExitInt is called when production Int is exited. -func (s *BaseCELListener) ExitInt(ctx *IntContext) {} - -// EnterUint is called when production Uint is entered. -func (s *BaseCELListener) EnterUint(ctx *UintContext) {} - -// ExitUint is called when production Uint is exited. -func (s *BaseCELListener) ExitUint(ctx *UintContext) {} - -// EnterDouble is called when production Double is entered. -func (s *BaseCELListener) EnterDouble(ctx *DoubleContext) {} - -// ExitDouble is called when production Double is exited. -func (s *BaseCELListener) ExitDouble(ctx *DoubleContext) {} - -// EnterString is called when production String is entered. -func (s *BaseCELListener) EnterString(ctx *StringContext) {} - -// ExitString is called when production String is exited. -func (s *BaseCELListener) ExitString(ctx *StringContext) {} - -// EnterBytes is called when production Bytes is entered. -func (s *BaseCELListener) EnterBytes(ctx *BytesContext) {} - -// ExitBytes is called when production Bytes is exited. -func (s *BaseCELListener) ExitBytes(ctx *BytesContext) {} - -// EnterBoolTrue is called when production BoolTrue is entered. -func (s *BaseCELListener) EnterBoolTrue(ctx *BoolTrueContext) {} - -// ExitBoolTrue is called when production BoolTrue is exited. -func (s *BaseCELListener) ExitBoolTrue(ctx *BoolTrueContext) {} - -// EnterBoolFalse is called when production BoolFalse is entered. -func (s *BaseCELListener) EnterBoolFalse(ctx *BoolFalseContext) {} - -// ExitBoolFalse is called when production BoolFalse is exited. -func (s *BaseCELListener) ExitBoolFalse(ctx *BoolFalseContext) {} - -// EnterNull is called when production Null is entered. -func (s *BaseCELListener) EnterNull(ctx *NullContext) {} - -// ExitNull is called when production Null is exited. -func (s *BaseCELListener) ExitNull(ctx *NullContext) {} diff --git a/vendor/github.com/google/cel-go/parser/gen/cel_base_visitor.go b/vendor/github.com/google/cel-go/parser/gen/cel_base_visitor.go deleted file mode 100644 index b2c0783d3..000000000 --- a/vendor/github.com/google/cel-go/parser/gen/cel_base_visitor.go +++ /dev/null @@ -1,141 +0,0 @@ -// Code generated from /usr/local/google/home/tswadell/go/src/github.com/google/cel-go/parser/gen/CEL.g4 by ANTLR 4.13.1. DO NOT EDIT. - -package gen // CEL -import "github.com/antlr4-go/antlr/v4" - - -type BaseCELVisitor struct { - *antlr.BaseParseTreeVisitor -} - -func (v *BaseCELVisitor) VisitStart(ctx *StartContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitExpr(ctx *ExprContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitConditionalOr(ctx *ConditionalOrContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitConditionalAnd(ctx *ConditionalAndContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitRelation(ctx *RelationContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitCalc(ctx *CalcContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitMemberExpr(ctx *MemberExprContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitLogicalNot(ctx *LogicalNotContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitNegate(ctx *NegateContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitMemberCall(ctx *MemberCallContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitSelect(ctx *SelectContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitPrimaryExpr(ctx *PrimaryExprContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitIndex(ctx *IndexContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitIdentOrGlobalCall(ctx *IdentOrGlobalCallContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitNested(ctx *NestedContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitCreateList(ctx *CreateListContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitCreateStruct(ctx *CreateStructContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitCreateMessage(ctx *CreateMessageContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitConstantLiteral(ctx *ConstantLiteralContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitExprList(ctx *ExprListContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitListInit(ctx *ListInitContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitFieldInitializerList(ctx *FieldInitializerListContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitOptField(ctx *OptFieldContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitMapInitializerList(ctx *MapInitializerListContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitOptExpr(ctx *OptExprContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitInt(ctx *IntContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitUint(ctx *UintContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitDouble(ctx *DoubleContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitString(ctx *StringContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitBytes(ctx *BytesContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitBoolTrue(ctx *BoolTrueContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitBoolFalse(ctx *BoolFalseContext) interface{} { - return v.VisitChildren(ctx) -} - -func (v *BaseCELVisitor) VisitNull(ctx *NullContext) interface{} { - return v.VisitChildren(ctx) -} diff --git a/vendor/github.com/google/cel-go/parser/gen/cel_lexer.go b/vendor/github.com/google/cel-go/parser/gen/cel_lexer.go deleted file mode 100644 index e026cc46f..000000000 --- a/vendor/github.com/google/cel-go/parser/gen/cel_lexer.go +++ /dev/null @@ -1,344 +0,0 @@ -// Code generated from /usr/local/google/home/tswadell/go/src/github.com/google/cel-go/parser/gen/CEL.g4 by ANTLR 4.13.1. DO NOT EDIT. - -package gen -import ( - "fmt" - "sync" - "unicode" - "github.com/antlr4-go/antlr/v4" -) -// Suppress unused import error -var _ = fmt.Printf -var _ = sync.Once{} -var _ = unicode.IsLetter - - -type CELLexer struct { - *antlr.BaseLexer - channelNames []string - modeNames []string - // TODO: EOF string -} - -var CELLexerLexerStaticData struct { - once sync.Once - serializedATN []int32 - ChannelNames []string - ModeNames []string - LiteralNames []string - SymbolicNames []string - RuleNames []string - PredictionContextCache *antlr.PredictionContextCache - atn *antlr.ATN - decisionToDFA []*antlr.DFA -} - -func cellexerLexerInit() { - staticData := &CELLexerLexerStaticData - staticData.ChannelNames = []string{ - "DEFAULT_TOKEN_CHANNEL", "HIDDEN", - } - staticData.ModeNames = []string{ - "DEFAULT_MODE", - } - staticData.LiteralNames = []string{ - "", "'=='", "'!='", "'in'", "'<'", "'<='", "'>='", "'>'", "'&&'", "'||'", - "'['", "']'", "'{'", "'}'", "'('", "')'", "'.'", "','", "'-'", "'!'", - "'?'", "':'", "'+'", "'*'", "'/'", "'%'", "'true'", "'false'", "'null'", - } - staticData.SymbolicNames = []string{ - "", "EQUALS", "NOT_EQUALS", "IN", "LESS", "LESS_EQUALS", "GREATER_EQUALS", - "GREATER", "LOGICAL_AND", "LOGICAL_OR", "LBRACKET", "RPRACKET", "LBRACE", - "RBRACE", "LPAREN", "RPAREN", "DOT", "COMMA", "MINUS", "EXCLAM", "QUESTIONMARK", - "COLON", "PLUS", "STAR", "SLASH", "PERCENT", "CEL_TRUE", "CEL_FALSE", - "NUL", "WHITESPACE", "COMMENT", "NUM_FLOAT", "NUM_INT", "NUM_UINT", - "STRING", "BYTES", "IDENTIFIER", - } - staticData.RuleNames = []string{ - "EQUALS", "NOT_EQUALS", "IN", "LESS", "LESS_EQUALS", "GREATER_EQUALS", - "GREATER", "LOGICAL_AND", "LOGICAL_OR", "LBRACKET", "RPRACKET", "LBRACE", - "RBRACE", "LPAREN", "RPAREN", "DOT", "COMMA", "MINUS", "EXCLAM", "QUESTIONMARK", - "COLON", "PLUS", "STAR", "SLASH", "PERCENT", "CEL_TRUE", "CEL_FALSE", - "NUL", "BACKSLASH", "LETTER", "DIGIT", "EXPONENT", "HEXDIGIT", "RAW", - "ESC_SEQ", "ESC_CHAR_SEQ", "ESC_OCT_SEQ", "ESC_BYTE_SEQ", "ESC_UNI_SEQ", - "WHITESPACE", "COMMENT", "NUM_FLOAT", "NUM_INT", "NUM_UINT", "STRING", - "BYTES", "IDENTIFIER", - } - staticData.PredictionContextCache = antlr.NewPredictionContextCache() - staticData.serializedATN = []int32{ - 4, 0, 36, 423, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, - 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, - 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, - 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, - 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, - 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, - 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, - 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, - 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, - 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, - 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, - 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 13, 1, 13, - 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, - 19, 1, 19, 1, 20, 1, 20, 1, 21, 1, 21, 1, 22, 1, 22, 1, 23, 1, 23, 1, 24, - 1, 24, 1, 25, 1, 25, 1, 25, 1, 25, 1, 25, 1, 26, 1, 26, 1, 26, 1, 26, 1, - 26, 1, 26, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 28, 1, 28, 1, 29, 1, 29, - 1, 30, 1, 30, 1, 31, 1, 31, 3, 31, 177, 8, 31, 1, 31, 4, 31, 180, 8, 31, - 11, 31, 12, 31, 181, 1, 32, 1, 32, 1, 33, 1, 33, 1, 34, 1, 34, 1, 34, 1, - 34, 3, 34, 192, 8, 34, 1, 35, 1, 35, 1, 35, 1, 36, 1, 36, 1, 36, 1, 36, - 1, 36, 1, 37, 1, 37, 1, 37, 1, 37, 1, 37, 1, 38, 1, 38, 1, 38, 1, 38, 1, - 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, - 1, 38, 1, 38, 1, 38, 3, 38, 225, 8, 38, 1, 39, 4, 39, 228, 8, 39, 11, 39, - 12, 39, 229, 1, 39, 1, 39, 1, 40, 1, 40, 1, 40, 1, 40, 5, 40, 238, 8, 40, - 10, 40, 12, 40, 241, 9, 40, 1, 40, 1, 40, 1, 41, 4, 41, 246, 8, 41, 11, - 41, 12, 41, 247, 1, 41, 1, 41, 4, 41, 252, 8, 41, 11, 41, 12, 41, 253, - 1, 41, 3, 41, 257, 8, 41, 1, 41, 4, 41, 260, 8, 41, 11, 41, 12, 41, 261, - 1, 41, 1, 41, 1, 41, 1, 41, 4, 41, 268, 8, 41, 11, 41, 12, 41, 269, 1, - 41, 3, 41, 273, 8, 41, 3, 41, 275, 8, 41, 1, 42, 4, 42, 278, 8, 42, 11, - 42, 12, 42, 279, 1, 42, 1, 42, 1, 42, 1, 42, 4, 42, 286, 8, 42, 11, 42, - 12, 42, 287, 3, 42, 290, 8, 42, 1, 43, 4, 43, 293, 8, 43, 11, 43, 12, 43, - 294, 1, 43, 1, 43, 1, 43, 1, 43, 1, 43, 1, 43, 4, 43, 303, 8, 43, 11, 43, - 12, 43, 304, 1, 43, 1, 43, 3, 43, 309, 8, 43, 1, 44, 1, 44, 1, 44, 5, 44, - 314, 8, 44, 10, 44, 12, 44, 317, 9, 44, 1, 44, 1, 44, 1, 44, 1, 44, 5, - 44, 323, 8, 44, 10, 44, 12, 44, 326, 9, 44, 1, 44, 1, 44, 1, 44, 1, 44, - 1, 44, 1, 44, 1, 44, 5, 44, 335, 8, 44, 10, 44, 12, 44, 338, 9, 44, 1, - 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 5, 44, 349, - 8, 44, 10, 44, 12, 44, 352, 9, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, - 44, 5, 44, 360, 8, 44, 10, 44, 12, 44, 363, 9, 44, 1, 44, 1, 44, 1, 44, - 1, 44, 1, 44, 5, 44, 370, 8, 44, 10, 44, 12, 44, 373, 9, 44, 1, 44, 1, - 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 5, 44, 383, 8, 44, 10, 44, - 12, 44, 386, 9, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, - 44, 1, 44, 1, 44, 5, 44, 398, 8, 44, 10, 44, 12, 44, 401, 9, 44, 1, 44, - 1, 44, 1, 44, 1, 44, 3, 44, 407, 8, 44, 1, 45, 1, 45, 1, 45, 1, 46, 1, - 46, 3, 46, 414, 8, 46, 1, 46, 1, 46, 1, 46, 5, 46, 419, 8, 46, 10, 46, - 12, 46, 422, 9, 46, 4, 336, 350, 384, 399, 0, 47, 1, 1, 3, 2, 5, 3, 7, - 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, - 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, - 23, 47, 24, 49, 25, 51, 26, 53, 27, 55, 28, 57, 0, 59, 0, 61, 0, 63, 0, - 65, 0, 67, 0, 69, 0, 71, 0, 73, 0, 75, 0, 77, 0, 79, 29, 81, 30, 83, 31, - 85, 32, 87, 33, 89, 34, 91, 35, 93, 36, 1, 0, 16, 2, 0, 65, 90, 97, 122, - 2, 0, 69, 69, 101, 101, 2, 0, 43, 43, 45, 45, 3, 0, 48, 57, 65, 70, 97, - 102, 2, 0, 82, 82, 114, 114, 10, 0, 34, 34, 39, 39, 63, 63, 92, 92, 96, - 98, 102, 102, 110, 110, 114, 114, 116, 116, 118, 118, 2, 0, 88, 88, 120, - 120, 3, 0, 9, 10, 12, 13, 32, 32, 1, 0, 10, 10, 2, 0, 85, 85, 117, 117, - 4, 0, 10, 10, 13, 13, 34, 34, 92, 92, 4, 0, 10, 10, 13, 13, 39, 39, 92, - 92, 1, 0, 92, 92, 3, 0, 10, 10, 13, 13, 34, 34, 3, 0, 10, 10, 13, 13, 39, - 39, 2, 0, 66, 66, 98, 98, 456, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, - 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, - 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, - 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, - 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, - 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, - 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, - 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 55, 1, 0, 0, 0, 0, 79, 1, 0, 0, 0, 0, 81, - 1, 0, 0, 0, 0, 83, 1, 0, 0, 0, 0, 85, 1, 0, 0, 0, 0, 87, 1, 0, 0, 0, 0, - 89, 1, 0, 0, 0, 0, 91, 1, 0, 0, 0, 0, 93, 1, 0, 0, 0, 1, 95, 1, 0, 0, 0, - 3, 98, 1, 0, 0, 0, 5, 101, 1, 0, 0, 0, 7, 104, 1, 0, 0, 0, 9, 106, 1, 0, - 0, 0, 11, 109, 1, 0, 0, 0, 13, 112, 1, 0, 0, 0, 15, 114, 1, 0, 0, 0, 17, - 117, 1, 0, 0, 0, 19, 120, 1, 0, 0, 0, 21, 122, 1, 0, 0, 0, 23, 124, 1, - 0, 0, 0, 25, 126, 1, 0, 0, 0, 27, 128, 1, 0, 0, 0, 29, 130, 1, 0, 0, 0, - 31, 132, 1, 0, 0, 0, 33, 134, 1, 0, 0, 0, 35, 136, 1, 0, 0, 0, 37, 138, - 1, 0, 0, 0, 39, 140, 1, 0, 0, 0, 41, 142, 1, 0, 0, 0, 43, 144, 1, 0, 0, - 0, 45, 146, 1, 0, 0, 0, 47, 148, 1, 0, 0, 0, 49, 150, 1, 0, 0, 0, 51, 152, - 1, 0, 0, 0, 53, 157, 1, 0, 0, 0, 55, 163, 1, 0, 0, 0, 57, 168, 1, 0, 0, - 0, 59, 170, 1, 0, 0, 0, 61, 172, 1, 0, 0, 0, 63, 174, 1, 0, 0, 0, 65, 183, - 1, 0, 0, 0, 67, 185, 1, 0, 0, 0, 69, 191, 1, 0, 0, 0, 71, 193, 1, 0, 0, - 0, 73, 196, 1, 0, 0, 0, 75, 201, 1, 0, 0, 0, 77, 224, 1, 0, 0, 0, 79, 227, - 1, 0, 0, 0, 81, 233, 1, 0, 0, 0, 83, 274, 1, 0, 0, 0, 85, 289, 1, 0, 0, - 0, 87, 308, 1, 0, 0, 0, 89, 406, 1, 0, 0, 0, 91, 408, 1, 0, 0, 0, 93, 413, - 1, 0, 0, 0, 95, 96, 5, 61, 0, 0, 96, 97, 5, 61, 0, 0, 97, 2, 1, 0, 0, 0, - 98, 99, 5, 33, 0, 0, 99, 100, 5, 61, 0, 0, 100, 4, 1, 0, 0, 0, 101, 102, - 5, 105, 0, 0, 102, 103, 5, 110, 0, 0, 103, 6, 1, 0, 0, 0, 104, 105, 5, - 60, 0, 0, 105, 8, 1, 0, 0, 0, 106, 107, 5, 60, 0, 0, 107, 108, 5, 61, 0, - 0, 108, 10, 1, 0, 0, 0, 109, 110, 5, 62, 0, 0, 110, 111, 5, 61, 0, 0, 111, - 12, 1, 0, 0, 0, 112, 113, 5, 62, 0, 0, 113, 14, 1, 0, 0, 0, 114, 115, 5, - 38, 0, 0, 115, 116, 5, 38, 0, 0, 116, 16, 1, 0, 0, 0, 117, 118, 5, 124, - 0, 0, 118, 119, 5, 124, 0, 0, 119, 18, 1, 0, 0, 0, 120, 121, 5, 91, 0, - 0, 121, 20, 1, 0, 0, 0, 122, 123, 5, 93, 0, 0, 123, 22, 1, 0, 0, 0, 124, - 125, 5, 123, 0, 0, 125, 24, 1, 0, 0, 0, 126, 127, 5, 125, 0, 0, 127, 26, - 1, 0, 0, 0, 128, 129, 5, 40, 0, 0, 129, 28, 1, 0, 0, 0, 130, 131, 5, 41, - 0, 0, 131, 30, 1, 0, 0, 0, 132, 133, 5, 46, 0, 0, 133, 32, 1, 0, 0, 0, - 134, 135, 5, 44, 0, 0, 135, 34, 1, 0, 0, 0, 136, 137, 5, 45, 0, 0, 137, - 36, 1, 0, 0, 0, 138, 139, 5, 33, 0, 0, 139, 38, 1, 0, 0, 0, 140, 141, 5, - 63, 0, 0, 141, 40, 1, 0, 0, 0, 142, 143, 5, 58, 0, 0, 143, 42, 1, 0, 0, - 0, 144, 145, 5, 43, 0, 0, 145, 44, 1, 0, 0, 0, 146, 147, 5, 42, 0, 0, 147, - 46, 1, 0, 0, 0, 148, 149, 5, 47, 0, 0, 149, 48, 1, 0, 0, 0, 150, 151, 5, - 37, 0, 0, 151, 50, 1, 0, 0, 0, 152, 153, 5, 116, 0, 0, 153, 154, 5, 114, - 0, 0, 154, 155, 5, 117, 0, 0, 155, 156, 5, 101, 0, 0, 156, 52, 1, 0, 0, - 0, 157, 158, 5, 102, 0, 0, 158, 159, 5, 97, 0, 0, 159, 160, 5, 108, 0, - 0, 160, 161, 5, 115, 0, 0, 161, 162, 5, 101, 0, 0, 162, 54, 1, 0, 0, 0, - 163, 164, 5, 110, 0, 0, 164, 165, 5, 117, 0, 0, 165, 166, 5, 108, 0, 0, - 166, 167, 5, 108, 0, 0, 167, 56, 1, 0, 0, 0, 168, 169, 5, 92, 0, 0, 169, - 58, 1, 0, 0, 0, 170, 171, 7, 0, 0, 0, 171, 60, 1, 0, 0, 0, 172, 173, 2, - 48, 57, 0, 173, 62, 1, 0, 0, 0, 174, 176, 7, 1, 0, 0, 175, 177, 7, 2, 0, - 0, 176, 175, 1, 0, 0, 0, 176, 177, 1, 0, 0, 0, 177, 179, 1, 0, 0, 0, 178, - 180, 3, 61, 30, 0, 179, 178, 1, 0, 0, 0, 180, 181, 1, 0, 0, 0, 181, 179, - 1, 0, 0, 0, 181, 182, 1, 0, 0, 0, 182, 64, 1, 0, 0, 0, 183, 184, 7, 3, - 0, 0, 184, 66, 1, 0, 0, 0, 185, 186, 7, 4, 0, 0, 186, 68, 1, 0, 0, 0, 187, - 192, 3, 71, 35, 0, 188, 192, 3, 75, 37, 0, 189, 192, 3, 77, 38, 0, 190, - 192, 3, 73, 36, 0, 191, 187, 1, 0, 0, 0, 191, 188, 1, 0, 0, 0, 191, 189, - 1, 0, 0, 0, 191, 190, 1, 0, 0, 0, 192, 70, 1, 0, 0, 0, 193, 194, 3, 57, - 28, 0, 194, 195, 7, 5, 0, 0, 195, 72, 1, 0, 0, 0, 196, 197, 3, 57, 28, - 0, 197, 198, 2, 48, 51, 0, 198, 199, 2, 48, 55, 0, 199, 200, 2, 48, 55, - 0, 200, 74, 1, 0, 0, 0, 201, 202, 3, 57, 28, 0, 202, 203, 7, 6, 0, 0, 203, - 204, 3, 65, 32, 0, 204, 205, 3, 65, 32, 0, 205, 76, 1, 0, 0, 0, 206, 207, - 3, 57, 28, 0, 207, 208, 5, 117, 0, 0, 208, 209, 3, 65, 32, 0, 209, 210, - 3, 65, 32, 0, 210, 211, 3, 65, 32, 0, 211, 212, 3, 65, 32, 0, 212, 225, - 1, 0, 0, 0, 213, 214, 3, 57, 28, 0, 214, 215, 5, 85, 0, 0, 215, 216, 3, - 65, 32, 0, 216, 217, 3, 65, 32, 0, 217, 218, 3, 65, 32, 0, 218, 219, 3, - 65, 32, 0, 219, 220, 3, 65, 32, 0, 220, 221, 3, 65, 32, 0, 221, 222, 3, - 65, 32, 0, 222, 223, 3, 65, 32, 0, 223, 225, 1, 0, 0, 0, 224, 206, 1, 0, - 0, 0, 224, 213, 1, 0, 0, 0, 225, 78, 1, 0, 0, 0, 226, 228, 7, 7, 0, 0, - 227, 226, 1, 0, 0, 0, 228, 229, 1, 0, 0, 0, 229, 227, 1, 0, 0, 0, 229, - 230, 1, 0, 0, 0, 230, 231, 1, 0, 0, 0, 231, 232, 6, 39, 0, 0, 232, 80, - 1, 0, 0, 0, 233, 234, 5, 47, 0, 0, 234, 235, 5, 47, 0, 0, 235, 239, 1, - 0, 0, 0, 236, 238, 8, 8, 0, 0, 237, 236, 1, 0, 0, 0, 238, 241, 1, 0, 0, - 0, 239, 237, 1, 0, 0, 0, 239, 240, 1, 0, 0, 0, 240, 242, 1, 0, 0, 0, 241, - 239, 1, 0, 0, 0, 242, 243, 6, 40, 0, 0, 243, 82, 1, 0, 0, 0, 244, 246, - 3, 61, 30, 0, 245, 244, 1, 0, 0, 0, 246, 247, 1, 0, 0, 0, 247, 245, 1, - 0, 0, 0, 247, 248, 1, 0, 0, 0, 248, 249, 1, 0, 0, 0, 249, 251, 5, 46, 0, - 0, 250, 252, 3, 61, 30, 0, 251, 250, 1, 0, 0, 0, 252, 253, 1, 0, 0, 0, - 253, 251, 1, 0, 0, 0, 253, 254, 1, 0, 0, 0, 254, 256, 1, 0, 0, 0, 255, - 257, 3, 63, 31, 0, 256, 255, 1, 0, 0, 0, 256, 257, 1, 0, 0, 0, 257, 275, - 1, 0, 0, 0, 258, 260, 3, 61, 30, 0, 259, 258, 1, 0, 0, 0, 260, 261, 1, - 0, 0, 0, 261, 259, 1, 0, 0, 0, 261, 262, 1, 0, 0, 0, 262, 263, 1, 0, 0, - 0, 263, 264, 3, 63, 31, 0, 264, 275, 1, 0, 0, 0, 265, 267, 5, 46, 0, 0, - 266, 268, 3, 61, 30, 0, 267, 266, 1, 0, 0, 0, 268, 269, 1, 0, 0, 0, 269, - 267, 1, 0, 0, 0, 269, 270, 1, 0, 0, 0, 270, 272, 1, 0, 0, 0, 271, 273, - 3, 63, 31, 0, 272, 271, 1, 0, 0, 0, 272, 273, 1, 0, 0, 0, 273, 275, 1, - 0, 0, 0, 274, 245, 1, 0, 0, 0, 274, 259, 1, 0, 0, 0, 274, 265, 1, 0, 0, - 0, 275, 84, 1, 0, 0, 0, 276, 278, 3, 61, 30, 0, 277, 276, 1, 0, 0, 0, 278, - 279, 1, 0, 0, 0, 279, 277, 1, 0, 0, 0, 279, 280, 1, 0, 0, 0, 280, 290, - 1, 0, 0, 0, 281, 282, 5, 48, 0, 0, 282, 283, 5, 120, 0, 0, 283, 285, 1, - 0, 0, 0, 284, 286, 3, 65, 32, 0, 285, 284, 1, 0, 0, 0, 286, 287, 1, 0, - 0, 0, 287, 285, 1, 0, 0, 0, 287, 288, 1, 0, 0, 0, 288, 290, 1, 0, 0, 0, - 289, 277, 1, 0, 0, 0, 289, 281, 1, 0, 0, 0, 290, 86, 1, 0, 0, 0, 291, 293, - 3, 61, 30, 0, 292, 291, 1, 0, 0, 0, 293, 294, 1, 0, 0, 0, 294, 292, 1, - 0, 0, 0, 294, 295, 1, 0, 0, 0, 295, 296, 1, 0, 0, 0, 296, 297, 7, 9, 0, - 0, 297, 309, 1, 0, 0, 0, 298, 299, 5, 48, 0, 0, 299, 300, 5, 120, 0, 0, - 300, 302, 1, 0, 0, 0, 301, 303, 3, 65, 32, 0, 302, 301, 1, 0, 0, 0, 303, - 304, 1, 0, 0, 0, 304, 302, 1, 0, 0, 0, 304, 305, 1, 0, 0, 0, 305, 306, - 1, 0, 0, 0, 306, 307, 7, 9, 0, 0, 307, 309, 1, 0, 0, 0, 308, 292, 1, 0, - 0, 0, 308, 298, 1, 0, 0, 0, 309, 88, 1, 0, 0, 0, 310, 315, 5, 34, 0, 0, - 311, 314, 3, 69, 34, 0, 312, 314, 8, 10, 0, 0, 313, 311, 1, 0, 0, 0, 313, - 312, 1, 0, 0, 0, 314, 317, 1, 0, 0, 0, 315, 313, 1, 0, 0, 0, 315, 316, - 1, 0, 0, 0, 316, 318, 1, 0, 0, 0, 317, 315, 1, 0, 0, 0, 318, 407, 5, 34, - 0, 0, 319, 324, 5, 39, 0, 0, 320, 323, 3, 69, 34, 0, 321, 323, 8, 11, 0, - 0, 322, 320, 1, 0, 0, 0, 322, 321, 1, 0, 0, 0, 323, 326, 1, 0, 0, 0, 324, - 322, 1, 0, 0, 0, 324, 325, 1, 0, 0, 0, 325, 327, 1, 0, 0, 0, 326, 324, - 1, 0, 0, 0, 327, 407, 5, 39, 0, 0, 328, 329, 5, 34, 0, 0, 329, 330, 5, - 34, 0, 0, 330, 331, 5, 34, 0, 0, 331, 336, 1, 0, 0, 0, 332, 335, 3, 69, - 34, 0, 333, 335, 8, 12, 0, 0, 334, 332, 1, 0, 0, 0, 334, 333, 1, 0, 0, - 0, 335, 338, 1, 0, 0, 0, 336, 337, 1, 0, 0, 0, 336, 334, 1, 0, 0, 0, 337, - 339, 1, 0, 0, 0, 338, 336, 1, 0, 0, 0, 339, 340, 5, 34, 0, 0, 340, 341, - 5, 34, 0, 0, 341, 407, 5, 34, 0, 0, 342, 343, 5, 39, 0, 0, 343, 344, 5, - 39, 0, 0, 344, 345, 5, 39, 0, 0, 345, 350, 1, 0, 0, 0, 346, 349, 3, 69, - 34, 0, 347, 349, 8, 12, 0, 0, 348, 346, 1, 0, 0, 0, 348, 347, 1, 0, 0, - 0, 349, 352, 1, 0, 0, 0, 350, 351, 1, 0, 0, 0, 350, 348, 1, 0, 0, 0, 351, - 353, 1, 0, 0, 0, 352, 350, 1, 0, 0, 0, 353, 354, 5, 39, 0, 0, 354, 355, - 5, 39, 0, 0, 355, 407, 5, 39, 0, 0, 356, 357, 3, 67, 33, 0, 357, 361, 5, - 34, 0, 0, 358, 360, 8, 13, 0, 0, 359, 358, 1, 0, 0, 0, 360, 363, 1, 0, - 0, 0, 361, 359, 1, 0, 0, 0, 361, 362, 1, 0, 0, 0, 362, 364, 1, 0, 0, 0, - 363, 361, 1, 0, 0, 0, 364, 365, 5, 34, 0, 0, 365, 407, 1, 0, 0, 0, 366, - 367, 3, 67, 33, 0, 367, 371, 5, 39, 0, 0, 368, 370, 8, 14, 0, 0, 369, 368, - 1, 0, 0, 0, 370, 373, 1, 0, 0, 0, 371, 369, 1, 0, 0, 0, 371, 372, 1, 0, - 0, 0, 372, 374, 1, 0, 0, 0, 373, 371, 1, 0, 0, 0, 374, 375, 5, 39, 0, 0, - 375, 407, 1, 0, 0, 0, 376, 377, 3, 67, 33, 0, 377, 378, 5, 34, 0, 0, 378, - 379, 5, 34, 0, 0, 379, 380, 5, 34, 0, 0, 380, 384, 1, 0, 0, 0, 381, 383, - 9, 0, 0, 0, 382, 381, 1, 0, 0, 0, 383, 386, 1, 0, 0, 0, 384, 385, 1, 0, - 0, 0, 384, 382, 1, 0, 0, 0, 385, 387, 1, 0, 0, 0, 386, 384, 1, 0, 0, 0, - 387, 388, 5, 34, 0, 0, 388, 389, 5, 34, 0, 0, 389, 390, 5, 34, 0, 0, 390, - 407, 1, 0, 0, 0, 391, 392, 3, 67, 33, 0, 392, 393, 5, 39, 0, 0, 393, 394, - 5, 39, 0, 0, 394, 395, 5, 39, 0, 0, 395, 399, 1, 0, 0, 0, 396, 398, 9, - 0, 0, 0, 397, 396, 1, 0, 0, 0, 398, 401, 1, 0, 0, 0, 399, 400, 1, 0, 0, - 0, 399, 397, 1, 0, 0, 0, 400, 402, 1, 0, 0, 0, 401, 399, 1, 0, 0, 0, 402, - 403, 5, 39, 0, 0, 403, 404, 5, 39, 0, 0, 404, 405, 5, 39, 0, 0, 405, 407, - 1, 0, 0, 0, 406, 310, 1, 0, 0, 0, 406, 319, 1, 0, 0, 0, 406, 328, 1, 0, - 0, 0, 406, 342, 1, 0, 0, 0, 406, 356, 1, 0, 0, 0, 406, 366, 1, 0, 0, 0, - 406, 376, 1, 0, 0, 0, 406, 391, 1, 0, 0, 0, 407, 90, 1, 0, 0, 0, 408, 409, - 7, 15, 0, 0, 409, 410, 3, 89, 44, 0, 410, 92, 1, 0, 0, 0, 411, 414, 3, - 59, 29, 0, 412, 414, 5, 95, 0, 0, 413, 411, 1, 0, 0, 0, 413, 412, 1, 0, - 0, 0, 414, 420, 1, 0, 0, 0, 415, 419, 3, 59, 29, 0, 416, 419, 3, 61, 30, - 0, 417, 419, 5, 95, 0, 0, 418, 415, 1, 0, 0, 0, 418, 416, 1, 0, 0, 0, 418, - 417, 1, 0, 0, 0, 419, 422, 1, 0, 0, 0, 420, 418, 1, 0, 0, 0, 420, 421, - 1, 0, 0, 0, 421, 94, 1, 0, 0, 0, 422, 420, 1, 0, 0, 0, 36, 0, 176, 181, - 191, 224, 229, 239, 247, 253, 256, 261, 269, 272, 274, 279, 287, 289, 294, - 304, 308, 313, 315, 322, 324, 334, 336, 348, 350, 361, 371, 384, 399, 406, - 413, 418, 420, 1, 0, 1, 0, -} - deserializer := antlr.NewATNDeserializer(nil) - staticData.atn = deserializer.Deserialize(staticData.serializedATN) - atn := staticData.atn - staticData.decisionToDFA = make([]*antlr.DFA, len(atn.DecisionToState)) - decisionToDFA := staticData.decisionToDFA - for index, state := range atn.DecisionToState { - decisionToDFA[index] = antlr.NewDFA(state, index) - } -} - -// CELLexerInit initializes any static state used to implement CELLexer. By default the -// static state used to implement the lexer is lazily initialized during the first call to -// NewCELLexer(). You can call this function if you wish to initialize the static state ahead -// of time. -func CELLexerInit() { - staticData := &CELLexerLexerStaticData - staticData.once.Do(cellexerLexerInit) -} - -// NewCELLexer produces a new lexer instance for the optional input antlr.CharStream. -func NewCELLexer(input antlr.CharStream) *CELLexer { - CELLexerInit() - l := new(CELLexer) - l.BaseLexer = antlr.NewBaseLexer(input) - staticData := &CELLexerLexerStaticData - l.Interpreter = antlr.NewLexerATNSimulator(l, staticData.atn, staticData.decisionToDFA, staticData.PredictionContextCache) - l.channelNames = staticData.ChannelNames - l.modeNames = staticData.ModeNames - l.RuleNames = staticData.RuleNames - l.LiteralNames = staticData.LiteralNames - l.SymbolicNames = staticData.SymbolicNames - l.GrammarFileName = "CEL.g4" - // TODO: l.EOF = antlr.TokenEOF - - return l -} - -// CELLexer tokens. -const ( - CELLexerEQUALS = 1 - CELLexerNOT_EQUALS = 2 - CELLexerIN = 3 - CELLexerLESS = 4 - CELLexerLESS_EQUALS = 5 - CELLexerGREATER_EQUALS = 6 - CELLexerGREATER = 7 - CELLexerLOGICAL_AND = 8 - CELLexerLOGICAL_OR = 9 - CELLexerLBRACKET = 10 - CELLexerRPRACKET = 11 - CELLexerLBRACE = 12 - CELLexerRBRACE = 13 - CELLexerLPAREN = 14 - CELLexerRPAREN = 15 - CELLexerDOT = 16 - CELLexerCOMMA = 17 - CELLexerMINUS = 18 - CELLexerEXCLAM = 19 - CELLexerQUESTIONMARK = 20 - CELLexerCOLON = 21 - CELLexerPLUS = 22 - CELLexerSTAR = 23 - CELLexerSLASH = 24 - CELLexerPERCENT = 25 - CELLexerCEL_TRUE = 26 - CELLexerCEL_FALSE = 27 - CELLexerNUL = 28 - CELLexerWHITESPACE = 29 - CELLexerCOMMENT = 30 - CELLexerNUM_FLOAT = 31 - CELLexerNUM_INT = 32 - CELLexerNUM_UINT = 33 - CELLexerSTRING = 34 - CELLexerBYTES = 35 - CELLexerIDENTIFIER = 36 -) - diff --git a/vendor/github.com/google/cel-go/parser/gen/cel_listener.go b/vendor/github.com/google/cel-go/parser/gen/cel_listener.go deleted file mode 100644 index 22dc99789..000000000 --- a/vendor/github.com/google/cel-go/parser/gen/cel_listener.go +++ /dev/null @@ -1,208 +0,0 @@ -// Code generated from /usr/local/google/home/tswadell/go/src/github.com/google/cel-go/parser/gen/CEL.g4 by ANTLR 4.13.1. DO NOT EDIT. - -package gen // CEL -import "github.com/antlr4-go/antlr/v4" - - -// CELListener is a complete listener for a parse tree produced by CELParser. -type CELListener interface { - antlr.ParseTreeListener - - // EnterStart is called when entering the start production. - EnterStart(c *StartContext) - - // EnterExpr is called when entering the expr production. - EnterExpr(c *ExprContext) - - // EnterConditionalOr is called when entering the conditionalOr production. - EnterConditionalOr(c *ConditionalOrContext) - - // EnterConditionalAnd is called when entering the conditionalAnd production. - EnterConditionalAnd(c *ConditionalAndContext) - - // EnterRelation is called when entering the relation production. - EnterRelation(c *RelationContext) - - // EnterCalc is called when entering the calc production. - EnterCalc(c *CalcContext) - - // EnterMemberExpr is called when entering the MemberExpr production. - EnterMemberExpr(c *MemberExprContext) - - // EnterLogicalNot is called when entering the LogicalNot production. - EnterLogicalNot(c *LogicalNotContext) - - // EnterNegate is called when entering the Negate production. - EnterNegate(c *NegateContext) - - // EnterMemberCall is called when entering the MemberCall production. - EnterMemberCall(c *MemberCallContext) - - // EnterSelect is called when entering the Select production. - EnterSelect(c *SelectContext) - - // EnterPrimaryExpr is called when entering the PrimaryExpr production. - EnterPrimaryExpr(c *PrimaryExprContext) - - // EnterIndex is called when entering the Index production. - EnterIndex(c *IndexContext) - - // EnterIdentOrGlobalCall is called when entering the IdentOrGlobalCall production. - EnterIdentOrGlobalCall(c *IdentOrGlobalCallContext) - - // EnterNested is called when entering the Nested production. - EnterNested(c *NestedContext) - - // EnterCreateList is called when entering the CreateList production. - EnterCreateList(c *CreateListContext) - - // EnterCreateStruct is called when entering the CreateStruct production. - EnterCreateStruct(c *CreateStructContext) - - // EnterCreateMessage is called when entering the CreateMessage production. - EnterCreateMessage(c *CreateMessageContext) - - // EnterConstantLiteral is called when entering the ConstantLiteral production. - EnterConstantLiteral(c *ConstantLiteralContext) - - // EnterExprList is called when entering the exprList production. - EnterExprList(c *ExprListContext) - - // EnterListInit is called when entering the listInit production. - EnterListInit(c *ListInitContext) - - // EnterFieldInitializerList is called when entering the fieldInitializerList production. - EnterFieldInitializerList(c *FieldInitializerListContext) - - // EnterOptField is called when entering the optField production. - EnterOptField(c *OptFieldContext) - - // EnterMapInitializerList is called when entering the mapInitializerList production. - EnterMapInitializerList(c *MapInitializerListContext) - - // EnterOptExpr is called when entering the optExpr production. - EnterOptExpr(c *OptExprContext) - - // EnterInt is called when entering the Int production. - EnterInt(c *IntContext) - - // EnterUint is called when entering the Uint production. - EnterUint(c *UintContext) - - // EnterDouble is called when entering the Double production. - EnterDouble(c *DoubleContext) - - // EnterString is called when entering the String production. - EnterString(c *StringContext) - - // EnterBytes is called when entering the Bytes production. - EnterBytes(c *BytesContext) - - // EnterBoolTrue is called when entering the BoolTrue production. - EnterBoolTrue(c *BoolTrueContext) - - // EnterBoolFalse is called when entering the BoolFalse production. - EnterBoolFalse(c *BoolFalseContext) - - // EnterNull is called when entering the Null production. - EnterNull(c *NullContext) - - // ExitStart is called when exiting the start production. - ExitStart(c *StartContext) - - // ExitExpr is called when exiting the expr production. - ExitExpr(c *ExprContext) - - // ExitConditionalOr is called when exiting the conditionalOr production. - ExitConditionalOr(c *ConditionalOrContext) - - // ExitConditionalAnd is called when exiting the conditionalAnd production. - ExitConditionalAnd(c *ConditionalAndContext) - - // ExitRelation is called when exiting the relation production. - ExitRelation(c *RelationContext) - - // ExitCalc is called when exiting the calc production. - ExitCalc(c *CalcContext) - - // ExitMemberExpr is called when exiting the MemberExpr production. - ExitMemberExpr(c *MemberExprContext) - - // ExitLogicalNot is called when exiting the LogicalNot production. - ExitLogicalNot(c *LogicalNotContext) - - // ExitNegate is called when exiting the Negate production. - ExitNegate(c *NegateContext) - - // ExitMemberCall is called when exiting the MemberCall production. - ExitMemberCall(c *MemberCallContext) - - // ExitSelect is called when exiting the Select production. - ExitSelect(c *SelectContext) - - // ExitPrimaryExpr is called when exiting the PrimaryExpr production. - ExitPrimaryExpr(c *PrimaryExprContext) - - // ExitIndex is called when exiting the Index production. - ExitIndex(c *IndexContext) - - // ExitIdentOrGlobalCall is called when exiting the IdentOrGlobalCall production. - ExitIdentOrGlobalCall(c *IdentOrGlobalCallContext) - - // ExitNested is called when exiting the Nested production. - ExitNested(c *NestedContext) - - // ExitCreateList is called when exiting the CreateList production. - ExitCreateList(c *CreateListContext) - - // ExitCreateStruct is called when exiting the CreateStruct production. - ExitCreateStruct(c *CreateStructContext) - - // ExitCreateMessage is called when exiting the CreateMessage production. - ExitCreateMessage(c *CreateMessageContext) - - // ExitConstantLiteral is called when exiting the ConstantLiteral production. - ExitConstantLiteral(c *ConstantLiteralContext) - - // ExitExprList is called when exiting the exprList production. - ExitExprList(c *ExprListContext) - - // ExitListInit is called when exiting the listInit production. - ExitListInit(c *ListInitContext) - - // ExitFieldInitializerList is called when exiting the fieldInitializerList production. - ExitFieldInitializerList(c *FieldInitializerListContext) - - // ExitOptField is called when exiting the optField production. - ExitOptField(c *OptFieldContext) - - // ExitMapInitializerList is called when exiting the mapInitializerList production. - ExitMapInitializerList(c *MapInitializerListContext) - - // ExitOptExpr is called when exiting the optExpr production. - ExitOptExpr(c *OptExprContext) - - // ExitInt is called when exiting the Int production. - ExitInt(c *IntContext) - - // ExitUint is called when exiting the Uint production. - ExitUint(c *UintContext) - - // ExitDouble is called when exiting the Double production. - ExitDouble(c *DoubleContext) - - // ExitString is called when exiting the String production. - ExitString(c *StringContext) - - // ExitBytes is called when exiting the Bytes production. - ExitBytes(c *BytesContext) - - // ExitBoolTrue is called when exiting the BoolTrue production. - ExitBoolTrue(c *BoolTrueContext) - - // ExitBoolFalse is called when exiting the BoolFalse production. - ExitBoolFalse(c *BoolFalseContext) - - // ExitNull is called when exiting the Null production. - ExitNull(c *NullContext) -} diff --git a/vendor/github.com/google/cel-go/parser/gen/cel_parser.go b/vendor/github.com/google/cel-go/parser/gen/cel_parser.go deleted file mode 100644 index 35334af61..000000000 --- a/vendor/github.com/google/cel-go/parser/gen/cel_parser.go +++ /dev/null @@ -1,6274 +0,0 @@ -// Code generated from /usr/local/google/home/tswadell/go/src/github.com/google/cel-go/parser/gen/CEL.g4 by ANTLR 4.13.1. DO NOT EDIT. - -package gen // CEL -import ( - "fmt" - "strconv" - "sync" - - "github.com/antlr4-go/antlr/v4" -) - -// Suppress unused import errors -var _ = fmt.Printf -var _ = strconv.Itoa -var _ = sync.Once{} - - -type CELParser struct { - *antlr.BaseParser -} - -var CELParserStaticData struct { - once sync.Once - serializedATN []int32 - LiteralNames []string - SymbolicNames []string - RuleNames []string - PredictionContextCache *antlr.PredictionContextCache - atn *antlr.ATN - decisionToDFA []*antlr.DFA -} - -func celParserInit() { - staticData := &CELParserStaticData - staticData.LiteralNames = []string{ - "", "'=='", "'!='", "'in'", "'<'", "'<='", "'>='", "'>'", "'&&'", "'||'", - "'['", "']'", "'{'", "'}'", "'('", "')'", "'.'", "','", "'-'", "'!'", - "'?'", "':'", "'+'", "'*'", "'/'", "'%'", "'true'", "'false'", "'null'", - } - staticData.SymbolicNames = []string{ - "", "EQUALS", "NOT_EQUALS", "IN", "LESS", "LESS_EQUALS", "GREATER_EQUALS", - "GREATER", "LOGICAL_AND", "LOGICAL_OR", "LBRACKET", "RPRACKET", "LBRACE", - "RBRACE", "LPAREN", "RPAREN", "DOT", "COMMA", "MINUS", "EXCLAM", "QUESTIONMARK", - "COLON", "PLUS", "STAR", "SLASH", "PERCENT", "CEL_TRUE", "CEL_FALSE", - "NUL", "WHITESPACE", "COMMENT", "NUM_FLOAT", "NUM_INT", "NUM_UINT", - "STRING", "BYTES", "IDENTIFIER", - } - staticData.RuleNames = []string{ - "start", "expr", "conditionalOr", "conditionalAnd", "relation", "calc", - "unary", "member", "primary", "exprList", "listInit", "fieldInitializerList", - "optField", "mapInitializerList", "optExpr", "literal", - } - staticData.PredictionContextCache = antlr.NewPredictionContextCache() - staticData.serializedATN = []int32{ - 4, 1, 36, 251, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, - 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, - 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, - 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 42, 8, 1, 1, - 2, 1, 2, 1, 2, 5, 2, 47, 8, 2, 10, 2, 12, 2, 50, 9, 2, 1, 3, 1, 3, 1, 3, - 5, 3, 55, 8, 3, 10, 3, 12, 3, 58, 9, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, - 4, 5, 4, 66, 8, 4, 10, 4, 12, 4, 69, 9, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, - 1, 5, 1, 5, 1, 5, 1, 5, 5, 5, 80, 8, 5, 10, 5, 12, 5, 83, 9, 5, 1, 6, 1, - 6, 4, 6, 87, 8, 6, 11, 6, 12, 6, 88, 1, 6, 1, 6, 4, 6, 93, 8, 6, 11, 6, - 12, 6, 94, 1, 6, 3, 6, 98, 8, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, - 7, 106, 8, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 114, 8, 7, 1, 7, - 1, 7, 1, 7, 1, 7, 3, 7, 120, 8, 7, 1, 7, 1, 7, 1, 7, 5, 7, 125, 8, 7, 10, - 7, 12, 7, 128, 9, 7, 1, 8, 3, 8, 131, 8, 8, 1, 8, 1, 8, 1, 8, 3, 8, 136, - 8, 8, 1, 8, 3, 8, 139, 8, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 3, 8, - 147, 8, 8, 1, 8, 3, 8, 150, 8, 8, 1, 8, 1, 8, 1, 8, 3, 8, 155, 8, 8, 1, - 8, 3, 8, 158, 8, 8, 1, 8, 1, 8, 3, 8, 162, 8, 8, 1, 8, 1, 8, 1, 8, 5, 8, - 167, 8, 8, 10, 8, 12, 8, 170, 9, 8, 1, 8, 1, 8, 3, 8, 174, 8, 8, 1, 8, - 3, 8, 177, 8, 8, 1, 8, 1, 8, 3, 8, 181, 8, 8, 1, 9, 1, 9, 1, 9, 5, 9, 186, - 8, 9, 10, 9, 12, 9, 189, 9, 9, 1, 10, 1, 10, 1, 10, 5, 10, 194, 8, 10, - 10, 10, 12, 10, 197, 9, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, - 11, 1, 11, 5, 11, 207, 8, 11, 10, 11, 12, 11, 210, 9, 11, 1, 12, 3, 12, - 213, 8, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, - 13, 1, 13, 5, 13, 225, 8, 13, 10, 13, 12, 13, 228, 9, 13, 1, 14, 3, 14, - 231, 8, 14, 1, 14, 1, 14, 1, 15, 3, 15, 236, 8, 15, 1, 15, 1, 15, 1, 15, - 3, 15, 241, 8, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 3, 15, 249, - 8, 15, 1, 15, 0, 3, 8, 10, 14, 16, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, - 22, 24, 26, 28, 30, 0, 3, 1, 0, 1, 7, 1, 0, 23, 25, 2, 0, 18, 18, 22, 22, - 281, 0, 32, 1, 0, 0, 0, 2, 35, 1, 0, 0, 0, 4, 43, 1, 0, 0, 0, 6, 51, 1, - 0, 0, 0, 8, 59, 1, 0, 0, 0, 10, 70, 1, 0, 0, 0, 12, 97, 1, 0, 0, 0, 14, - 99, 1, 0, 0, 0, 16, 180, 1, 0, 0, 0, 18, 182, 1, 0, 0, 0, 20, 190, 1, 0, - 0, 0, 22, 198, 1, 0, 0, 0, 24, 212, 1, 0, 0, 0, 26, 216, 1, 0, 0, 0, 28, - 230, 1, 0, 0, 0, 30, 248, 1, 0, 0, 0, 32, 33, 3, 2, 1, 0, 33, 34, 5, 0, - 0, 1, 34, 1, 1, 0, 0, 0, 35, 41, 3, 4, 2, 0, 36, 37, 5, 20, 0, 0, 37, 38, - 3, 4, 2, 0, 38, 39, 5, 21, 0, 0, 39, 40, 3, 2, 1, 0, 40, 42, 1, 0, 0, 0, - 41, 36, 1, 0, 0, 0, 41, 42, 1, 0, 0, 0, 42, 3, 1, 0, 0, 0, 43, 48, 3, 6, - 3, 0, 44, 45, 5, 9, 0, 0, 45, 47, 3, 6, 3, 0, 46, 44, 1, 0, 0, 0, 47, 50, - 1, 0, 0, 0, 48, 46, 1, 0, 0, 0, 48, 49, 1, 0, 0, 0, 49, 5, 1, 0, 0, 0, - 50, 48, 1, 0, 0, 0, 51, 56, 3, 8, 4, 0, 52, 53, 5, 8, 0, 0, 53, 55, 3, - 8, 4, 0, 54, 52, 1, 0, 0, 0, 55, 58, 1, 0, 0, 0, 56, 54, 1, 0, 0, 0, 56, - 57, 1, 0, 0, 0, 57, 7, 1, 0, 0, 0, 58, 56, 1, 0, 0, 0, 59, 60, 6, 4, -1, - 0, 60, 61, 3, 10, 5, 0, 61, 67, 1, 0, 0, 0, 62, 63, 10, 1, 0, 0, 63, 64, - 7, 0, 0, 0, 64, 66, 3, 8, 4, 2, 65, 62, 1, 0, 0, 0, 66, 69, 1, 0, 0, 0, - 67, 65, 1, 0, 0, 0, 67, 68, 1, 0, 0, 0, 68, 9, 1, 0, 0, 0, 69, 67, 1, 0, - 0, 0, 70, 71, 6, 5, -1, 0, 71, 72, 3, 12, 6, 0, 72, 81, 1, 0, 0, 0, 73, - 74, 10, 2, 0, 0, 74, 75, 7, 1, 0, 0, 75, 80, 3, 10, 5, 3, 76, 77, 10, 1, - 0, 0, 77, 78, 7, 2, 0, 0, 78, 80, 3, 10, 5, 2, 79, 73, 1, 0, 0, 0, 79, - 76, 1, 0, 0, 0, 80, 83, 1, 0, 0, 0, 81, 79, 1, 0, 0, 0, 81, 82, 1, 0, 0, - 0, 82, 11, 1, 0, 0, 0, 83, 81, 1, 0, 0, 0, 84, 98, 3, 14, 7, 0, 85, 87, - 5, 19, 0, 0, 86, 85, 1, 0, 0, 0, 87, 88, 1, 0, 0, 0, 88, 86, 1, 0, 0, 0, - 88, 89, 1, 0, 0, 0, 89, 90, 1, 0, 0, 0, 90, 98, 3, 14, 7, 0, 91, 93, 5, - 18, 0, 0, 92, 91, 1, 0, 0, 0, 93, 94, 1, 0, 0, 0, 94, 92, 1, 0, 0, 0, 94, - 95, 1, 0, 0, 0, 95, 96, 1, 0, 0, 0, 96, 98, 3, 14, 7, 0, 97, 84, 1, 0, - 0, 0, 97, 86, 1, 0, 0, 0, 97, 92, 1, 0, 0, 0, 98, 13, 1, 0, 0, 0, 99, 100, - 6, 7, -1, 0, 100, 101, 3, 16, 8, 0, 101, 126, 1, 0, 0, 0, 102, 103, 10, - 3, 0, 0, 103, 105, 5, 16, 0, 0, 104, 106, 5, 20, 0, 0, 105, 104, 1, 0, - 0, 0, 105, 106, 1, 0, 0, 0, 106, 107, 1, 0, 0, 0, 107, 125, 5, 36, 0, 0, - 108, 109, 10, 2, 0, 0, 109, 110, 5, 16, 0, 0, 110, 111, 5, 36, 0, 0, 111, - 113, 5, 14, 0, 0, 112, 114, 3, 18, 9, 0, 113, 112, 1, 0, 0, 0, 113, 114, - 1, 0, 0, 0, 114, 115, 1, 0, 0, 0, 115, 125, 5, 15, 0, 0, 116, 117, 10, - 1, 0, 0, 117, 119, 5, 10, 0, 0, 118, 120, 5, 20, 0, 0, 119, 118, 1, 0, - 0, 0, 119, 120, 1, 0, 0, 0, 120, 121, 1, 0, 0, 0, 121, 122, 3, 2, 1, 0, - 122, 123, 5, 11, 0, 0, 123, 125, 1, 0, 0, 0, 124, 102, 1, 0, 0, 0, 124, - 108, 1, 0, 0, 0, 124, 116, 1, 0, 0, 0, 125, 128, 1, 0, 0, 0, 126, 124, - 1, 0, 0, 0, 126, 127, 1, 0, 0, 0, 127, 15, 1, 0, 0, 0, 128, 126, 1, 0, - 0, 0, 129, 131, 5, 16, 0, 0, 130, 129, 1, 0, 0, 0, 130, 131, 1, 0, 0, 0, - 131, 132, 1, 0, 0, 0, 132, 138, 5, 36, 0, 0, 133, 135, 5, 14, 0, 0, 134, - 136, 3, 18, 9, 0, 135, 134, 1, 0, 0, 0, 135, 136, 1, 0, 0, 0, 136, 137, - 1, 0, 0, 0, 137, 139, 5, 15, 0, 0, 138, 133, 1, 0, 0, 0, 138, 139, 1, 0, - 0, 0, 139, 181, 1, 0, 0, 0, 140, 141, 5, 14, 0, 0, 141, 142, 3, 2, 1, 0, - 142, 143, 5, 15, 0, 0, 143, 181, 1, 0, 0, 0, 144, 146, 5, 10, 0, 0, 145, - 147, 3, 20, 10, 0, 146, 145, 1, 0, 0, 0, 146, 147, 1, 0, 0, 0, 147, 149, - 1, 0, 0, 0, 148, 150, 5, 17, 0, 0, 149, 148, 1, 0, 0, 0, 149, 150, 1, 0, - 0, 0, 150, 151, 1, 0, 0, 0, 151, 181, 5, 11, 0, 0, 152, 154, 5, 12, 0, - 0, 153, 155, 3, 26, 13, 0, 154, 153, 1, 0, 0, 0, 154, 155, 1, 0, 0, 0, - 155, 157, 1, 0, 0, 0, 156, 158, 5, 17, 0, 0, 157, 156, 1, 0, 0, 0, 157, - 158, 1, 0, 0, 0, 158, 159, 1, 0, 0, 0, 159, 181, 5, 13, 0, 0, 160, 162, - 5, 16, 0, 0, 161, 160, 1, 0, 0, 0, 161, 162, 1, 0, 0, 0, 162, 163, 1, 0, - 0, 0, 163, 168, 5, 36, 0, 0, 164, 165, 5, 16, 0, 0, 165, 167, 5, 36, 0, - 0, 166, 164, 1, 0, 0, 0, 167, 170, 1, 0, 0, 0, 168, 166, 1, 0, 0, 0, 168, - 169, 1, 0, 0, 0, 169, 171, 1, 0, 0, 0, 170, 168, 1, 0, 0, 0, 171, 173, - 5, 12, 0, 0, 172, 174, 3, 22, 11, 0, 173, 172, 1, 0, 0, 0, 173, 174, 1, - 0, 0, 0, 174, 176, 1, 0, 0, 0, 175, 177, 5, 17, 0, 0, 176, 175, 1, 0, 0, - 0, 176, 177, 1, 0, 0, 0, 177, 178, 1, 0, 0, 0, 178, 181, 5, 13, 0, 0, 179, - 181, 3, 30, 15, 0, 180, 130, 1, 0, 0, 0, 180, 140, 1, 0, 0, 0, 180, 144, - 1, 0, 0, 0, 180, 152, 1, 0, 0, 0, 180, 161, 1, 0, 0, 0, 180, 179, 1, 0, - 0, 0, 181, 17, 1, 0, 0, 0, 182, 187, 3, 2, 1, 0, 183, 184, 5, 17, 0, 0, - 184, 186, 3, 2, 1, 0, 185, 183, 1, 0, 0, 0, 186, 189, 1, 0, 0, 0, 187, - 185, 1, 0, 0, 0, 187, 188, 1, 0, 0, 0, 188, 19, 1, 0, 0, 0, 189, 187, 1, - 0, 0, 0, 190, 195, 3, 28, 14, 0, 191, 192, 5, 17, 0, 0, 192, 194, 3, 28, - 14, 0, 193, 191, 1, 0, 0, 0, 194, 197, 1, 0, 0, 0, 195, 193, 1, 0, 0, 0, - 195, 196, 1, 0, 0, 0, 196, 21, 1, 0, 0, 0, 197, 195, 1, 0, 0, 0, 198, 199, - 3, 24, 12, 0, 199, 200, 5, 21, 0, 0, 200, 208, 3, 2, 1, 0, 201, 202, 5, - 17, 0, 0, 202, 203, 3, 24, 12, 0, 203, 204, 5, 21, 0, 0, 204, 205, 3, 2, - 1, 0, 205, 207, 1, 0, 0, 0, 206, 201, 1, 0, 0, 0, 207, 210, 1, 0, 0, 0, - 208, 206, 1, 0, 0, 0, 208, 209, 1, 0, 0, 0, 209, 23, 1, 0, 0, 0, 210, 208, - 1, 0, 0, 0, 211, 213, 5, 20, 0, 0, 212, 211, 1, 0, 0, 0, 212, 213, 1, 0, - 0, 0, 213, 214, 1, 0, 0, 0, 214, 215, 5, 36, 0, 0, 215, 25, 1, 0, 0, 0, - 216, 217, 3, 28, 14, 0, 217, 218, 5, 21, 0, 0, 218, 226, 3, 2, 1, 0, 219, - 220, 5, 17, 0, 0, 220, 221, 3, 28, 14, 0, 221, 222, 5, 21, 0, 0, 222, 223, - 3, 2, 1, 0, 223, 225, 1, 0, 0, 0, 224, 219, 1, 0, 0, 0, 225, 228, 1, 0, - 0, 0, 226, 224, 1, 0, 0, 0, 226, 227, 1, 0, 0, 0, 227, 27, 1, 0, 0, 0, - 228, 226, 1, 0, 0, 0, 229, 231, 5, 20, 0, 0, 230, 229, 1, 0, 0, 0, 230, - 231, 1, 0, 0, 0, 231, 232, 1, 0, 0, 0, 232, 233, 3, 2, 1, 0, 233, 29, 1, - 0, 0, 0, 234, 236, 5, 18, 0, 0, 235, 234, 1, 0, 0, 0, 235, 236, 1, 0, 0, - 0, 236, 237, 1, 0, 0, 0, 237, 249, 5, 32, 0, 0, 238, 249, 5, 33, 0, 0, - 239, 241, 5, 18, 0, 0, 240, 239, 1, 0, 0, 0, 240, 241, 1, 0, 0, 0, 241, - 242, 1, 0, 0, 0, 242, 249, 5, 31, 0, 0, 243, 249, 5, 34, 0, 0, 244, 249, - 5, 35, 0, 0, 245, 249, 5, 26, 0, 0, 246, 249, 5, 27, 0, 0, 247, 249, 5, - 28, 0, 0, 248, 235, 1, 0, 0, 0, 248, 238, 1, 0, 0, 0, 248, 240, 1, 0, 0, - 0, 248, 243, 1, 0, 0, 0, 248, 244, 1, 0, 0, 0, 248, 245, 1, 0, 0, 0, 248, - 246, 1, 0, 0, 0, 248, 247, 1, 0, 0, 0, 249, 31, 1, 0, 0, 0, 35, 41, 48, - 56, 67, 79, 81, 88, 94, 97, 105, 113, 119, 124, 126, 130, 135, 138, 146, - 149, 154, 157, 161, 168, 173, 176, 180, 187, 195, 208, 212, 226, 230, 235, - 240, 248, -} - deserializer := antlr.NewATNDeserializer(nil) - staticData.atn = deserializer.Deserialize(staticData.serializedATN) - atn := staticData.atn - staticData.decisionToDFA = make([]*antlr.DFA, len(atn.DecisionToState)) - decisionToDFA := staticData.decisionToDFA - for index, state := range atn.DecisionToState { - decisionToDFA[index] = antlr.NewDFA(state, index) - } -} - -// CELParserInit initializes any static state used to implement CELParser. By default the -// static state used to implement the parser is lazily initialized during the first call to -// NewCELParser(). You can call this function if you wish to initialize the static state ahead -// of time. -func CELParserInit() { - staticData := &CELParserStaticData - staticData.once.Do(celParserInit) -} - -// NewCELParser produces a new parser instance for the optional input antlr.TokenStream. -func NewCELParser(input antlr.TokenStream) *CELParser { - CELParserInit() - this := new(CELParser) - this.BaseParser = antlr.NewBaseParser(input) - staticData := &CELParserStaticData - this.Interpreter = antlr.NewParserATNSimulator(this, staticData.atn, staticData.decisionToDFA, staticData.PredictionContextCache) - this.RuleNames = staticData.RuleNames - this.LiteralNames = staticData.LiteralNames - this.SymbolicNames = staticData.SymbolicNames - this.GrammarFileName = "CEL.g4" - - return this -} - - -// CELParser tokens. -const ( - CELParserEOF = antlr.TokenEOF - CELParserEQUALS = 1 - CELParserNOT_EQUALS = 2 - CELParserIN = 3 - CELParserLESS = 4 - CELParserLESS_EQUALS = 5 - CELParserGREATER_EQUALS = 6 - CELParserGREATER = 7 - CELParserLOGICAL_AND = 8 - CELParserLOGICAL_OR = 9 - CELParserLBRACKET = 10 - CELParserRPRACKET = 11 - CELParserLBRACE = 12 - CELParserRBRACE = 13 - CELParserLPAREN = 14 - CELParserRPAREN = 15 - CELParserDOT = 16 - CELParserCOMMA = 17 - CELParserMINUS = 18 - CELParserEXCLAM = 19 - CELParserQUESTIONMARK = 20 - CELParserCOLON = 21 - CELParserPLUS = 22 - CELParserSTAR = 23 - CELParserSLASH = 24 - CELParserPERCENT = 25 - CELParserCEL_TRUE = 26 - CELParserCEL_FALSE = 27 - CELParserNUL = 28 - CELParserWHITESPACE = 29 - CELParserCOMMENT = 30 - CELParserNUM_FLOAT = 31 - CELParserNUM_INT = 32 - CELParserNUM_UINT = 33 - CELParserSTRING = 34 - CELParserBYTES = 35 - CELParserIDENTIFIER = 36 -) - -// CELParser rules. -const ( - CELParserRULE_start = 0 - CELParserRULE_expr = 1 - CELParserRULE_conditionalOr = 2 - CELParserRULE_conditionalAnd = 3 - CELParserRULE_relation = 4 - CELParserRULE_calc = 5 - CELParserRULE_unary = 6 - CELParserRULE_member = 7 - CELParserRULE_primary = 8 - CELParserRULE_exprList = 9 - CELParserRULE_listInit = 10 - CELParserRULE_fieldInitializerList = 11 - CELParserRULE_optField = 12 - CELParserRULE_mapInitializerList = 13 - CELParserRULE_optExpr = 14 - CELParserRULE_literal = 15 -) - -// IStartContext is an interface to support dynamic dispatch. -type IStartContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // GetE returns the e rule contexts. - GetE() IExprContext - - - // SetE sets the e rule contexts. - SetE(IExprContext) - - - // Getter signatures - EOF() antlr.TerminalNode - Expr() IExprContext - - // IsStartContext differentiates from other interfaces. - IsStartContext() -} - -type StartContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser - e IExprContext -} - -func NewEmptyStartContext() *StartContext { - var p = new(StartContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_start - return p -} - -func InitEmptyStartContext(p *StartContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_start -} - -func (*StartContext) IsStartContext() {} - -func NewStartContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *StartContext { - var p = new(StartContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = CELParserRULE_start - - return p -} - -func (s *StartContext) GetParser() antlr.Parser { return s.parser } - -func (s *StartContext) GetE() IExprContext { return s.e } - - -func (s *StartContext) SetE(v IExprContext) { s.e = v } - - -func (s *StartContext) EOF() antlr.TerminalNode { - return s.GetToken(CELParserEOF, 0) -} - -func (s *StartContext) Expr() IExprContext { - var t antlr.RuleContext; - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IExprContext); ok { - t = ctx.(antlr.RuleContext); - break - } - } - - if t == nil { - return nil - } - - return t.(IExprContext) -} - -func (s *StartContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *StartContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - - -func (s *StartContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterStart(s) - } -} - -func (s *StartContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitStart(s) - } -} - -func (s *StartContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitStart(s) - - default: - return t.VisitChildren(s) - } -} - - - - -func (p *CELParser) Start_() (localctx IStartContext) { - localctx = NewStartContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 0, CELParserRULE_start) - p.EnterOuterAlt(localctx, 1) - { - p.SetState(32) - - var _x = p.Expr() - - - localctx.(*StartContext).e = _x - } - { - p.SetState(33) - p.Match(CELParserEOF) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - - -errorExit: - if p.HasError() { - v := p.GetError() - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - p.SetError(nil) - } - p.ExitRule() - return localctx - goto errorExit // Trick to prevent compiler error if the label is not used -} - - -// IExprContext is an interface to support dynamic dispatch. -type IExprContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // GetOp returns the op token. - GetOp() antlr.Token - - - // SetOp sets the op token. - SetOp(antlr.Token) - - - // GetE returns the e rule contexts. - GetE() IConditionalOrContext - - // GetE1 returns the e1 rule contexts. - GetE1() IConditionalOrContext - - // GetE2 returns the e2 rule contexts. - GetE2() IExprContext - - - // SetE sets the e rule contexts. - SetE(IConditionalOrContext) - - // SetE1 sets the e1 rule contexts. - SetE1(IConditionalOrContext) - - // SetE2 sets the e2 rule contexts. - SetE2(IExprContext) - - - // Getter signatures - AllConditionalOr() []IConditionalOrContext - ConditionalOr(i int) IConditionalOrContext - COLON() antlr.TerminalNode - QUESTIONMARK() antlr.TerminalNode - Expr() IExprContext - - // IsExprContext differentiates from other interfaces. - IsExprContext() -} - -type ExprContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser - e IConditionalOrContext - op antlr.Token - e1 IConditionalOrContext - e2 IExprContext -} - -func NewEmptyExprContext() *ExprContext { - var p = new(ExprContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_expr - return p -} - -func InitEmptyExprContext(p *ExprContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_expr -} - -func (*ExprContext) IsExprContext() {} - -func NewExprContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ExprContext { - var p = new(ExprContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = CELParserRULE_expr - - return p -} - -func (s *ExprContext) GetParser() antlr.Parser { return s.parser } - -func (s *ExprContext) GetOp() antlr.Token { return s.op } - - -func (s *ExprContext) SetOp(v antlr.Token) { s.op = v } - - -func (s *ExprContext) GetE() IConditionalOrContext { return s.e } - -func (s *ExprContext) GetE1() IConditionalOrContext { return s.e1 } - -func (s *ExprContext) GetE2() IExprContext { return s.e2 } - - -func (s *ExprContext) SetE(v IConditionalOrContext) { s.e = v } - -func (s *ExprContext) SetE1(v IConditionalOrContext) { s.e1 = v } - -func (s *ExprContext) SetE2(v IExprContext) { s.e2 = v } - - -func (s *ExprContext) AllConditionalOr() []IConditionalOrContext { - children := s.GetChildren() - len := 0 - for _, ctx := range children { - if _, ok := ctx.(IConditionalOrContext); ok { - len++ - } - } - - tst := make([]IConditionalOrContext, len) - i := 0 - for _, ctx := range children { - if t, ok := ctx.(IConditionalOrContext); ok { - tst[i] = t.(IConditionalOrContext) - i++ - } - } - - return tst -} - -func (s *ExprContext) ConditionalOr(i int) IConditionalOrContext { - var t antlr.RuleContext; - j := 0 - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IConditionalOrContext); ok { - if j == i { - t = ctx.(antlr.RuleContext); - break - } - j++ - } - } - - if t == nil { - return nil - } - - return t.(IConditionalOrContext) -} - -func (s *ExprContext) COLON() antlr.TerminalNode { - return s.GetToken(CELParserCOLON, 0) -} - -func (s *ExprContext) QUESTIONMARK() antlr.TerminalNode { - return s.GetToken(CELParserQUESTIONMARK, 0) -} - -func (s *ExprContext) Expr() IExprContext { - var t antlr.RuleContext; - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IExprContext); ok { - t = ctx.(antlr.RuleContext); - break - } - } - - if t == nil { - return nil - } - - return t.(IExprContext) -} - -func (s *ExprContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *ExprContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - - -func (s *ExprContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterExpr(s) - } -} - -func (s *ExprContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitExpr(s) - } -} - -func (s *ExprContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitExpr(s) - - default: - return t.VisitChildren(s) - } -} - - - - -func (p *CELParser) Expr() (localctx IExprContext) { - localctx = NewExprContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 2, CELParserRULE_expr) - var _la int - - p.EnterOuterAlt(localctx, 1) - { - p.SetState(35) - - var _x = p.ConditionalOr() - - - localctx.(*ExprContext).e = _x - } - p.SetState(41) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - - if _la == CELParserQUESTIONMARK { - { - p.SetState(36) - - var _m = p.Match(CELParserQUESTIONMARK) - - localctx.(*ExprContext).op = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - { - p.SetState(37) - - var _x = p.ConditionalOr() - - - localctx.(*ExprContext).e1 = _x - } - { - p.SetState(38) - p.Match(CELParserCOLON) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - { - p.SetState(39) - - var _x = p.Expr() - - - localctx.(*ExprContext).e2 = _x - } - - } - - - -errorExit: - if p.HasError() { - v := p.GetError() - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - p.SetError(nil) - } - p.ExitRule() - return localctx - goto errorExit // Trick to prevent compiler error if the label is not used -} - - -// IConditionalOrContext is an interface to support dynamic dispatch. -type IConditionalOrContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // GetS9 returns the s9 token. - GetS9() antlr.Token - - - // SetS9 sets the s9 token. - SetS9(antlr.Token) - - - // GetOps returns the ops token list. - GetOps() []antlr.Token - - - // SetOps sets the ops token list. - SetOps([]antlr.Token) - - - // GetE returns the e rule contexts. - GetE() IConditionalAndContext - - // Get_conditionalAnd returns the _conditionalAnd rule contexts. - Get_conditionalAnd() IConditionalAndContext - - - // SetE sets the e rule contexts. - SetE(IConditionalAndContext) - - // Set_conditionalAnd sets the _conditionalAnd rule contexts. - Set_conditionalAnd(IConditionalAndContext) - - - // GetE1 returns the e1 rule context list. - GetE1() []IConditionalAndContext - - - // SetE1 sets the e1 rule context list. - SetE1([]IConditionalAndContext) - - - // Getter signatures - AllConditionalAnd() []IConditionalAndContext - ConditionalAnd(i int) IConditionalAndContext - AllLOGICAL_OR() []antlr.TerminalNode - LOGICAL_OR(i int) antlr.TerminalNode - - // IsConditionalOrContext differentiates from other interfaces. - IsConditionalOrContext() -} - -type ConditionalOrContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser - e IConditionalAndContext - s9 antlr.Token - ops []antlr.Token - _conditionalAnd IConditionalAndContext - e1 []IConditionalAndContext -} - -func NewEmptyConditionalOrContext() *ConditionalOrContext { - var p = new(ConditionalOrContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_conditionalOr - return p -} - -func InitEmptyConditionalOrContext(p *ConditionalOrContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_conditionalOr -} - -func (*ConditionalOrContext) IsConditionalOrContext() {} - -func NewConditionalOrContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ConditionalOrContext { - var p = new(ConditionalOrContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = CELParserRULE_conditionalOr - - return p -} - -func (s *ConditionalOrContext) GetParser() antlr.Parser { return s.parser } - -func (s *ConditionalOrContext) GetS9() antlr.Token { return s.s9 } - - -func (s *ConditionalOrContext) SetS9(v antlr.Token) { s.s9 = v } - - -func (s *ConditionalOrContext) GetOps() []antlr.Token { return s.ops } - - -func (s *ConditionalOrContext) SetOps(v []antlr.Token) { s.ops = v } - - -func (s *ConditionalOrContext) GetE() IConditionalAndContext { return s.e } - -func (s *ConditionalOrContext) Get_conditionalAnd() IConditionalAndContext { return s._conditionalAnd } - - -func (s *ConditionalOrContext) SetE(v IConditionalAndContext) { s.e = v } - -func (s *ConditionalOrContext) Set_conditionalAnd(v IConditionalAndContext) { s._conditionalAnd = v } - - -func (s *ConditionalOrContext) GetE1() []IConditionalAndContext { return s.e1 } - - -func (s *ConditionalOrContext) SetE1(v []IConditionalAndContext) { s.e1 = v } - - -func (s *ConditionalOrContext) AllConditionalAnd() []IConditionalAndContext { - children := s.GetChildren() - len := 0 - for _, ctx := range children { - if _, ok := ctx.(IConditionalAndContext); ok { - len++ - } - } - - tst := make([]IConditionalAndContext, len) - i := 0 - for _, ctx := range children { - if t, ok := ctx.(IConditionalAndContext); ok { - tst[i] = t.(IConditionalAndContext) - i++ - } - } - - return tst -} - -func (s *ConditionalOrContext) ConditionalAnd(i int) IConditionalAndContext { - var t antlr.RuleContext; - j := 0 - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IConditionalAndContext); ok { - if j == i { - t = ctx.(antlr.RuleContext); - break - } - j++ - } - } - - if t == nil { - return nil - } - - return t.(IConditionalAndContext) -} - -func (s *ConditionalOrContext) AllLOGICAL_OR() []antlr.TerminalNode { - return s.GetTokens(CELParserLOGICAL_OR) -} - -func (s *ConditionalOrContext) LOGICAL_OR(i int) antlr.TerminalNode { - return s.GetToken(CELParserLOGICAL_OR, i) -} - -func (s *ConditionalOrContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *ConditionalOrContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - - -func (s *ConditionalOrContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterConditionalOr(s) - } -} - -func (s *ConditionalOrContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitConditionalOr(s) - } -} - -func (s *ConditionalOrContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitConditionalOr(s) - - default: - return t.VisitChildren(s) - } -} - - - - -func (p *CELParser) ConditionalOr() (localctx IConditionalOrContext) { - localctx = NewConditionalOrContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 4, CELParserRULE_conditionalOr) - var _la int - - p.EnterOuterAlt(localctx, 1) - { - p.SetState(43) - - var _x = p.ConditionalAnd() - - - localctx.(*ConditionalOrContext).e = _x - } - p.SetState(48) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - - for _la == CELParserLOGICAL_OR { - { - p.SetState(44) - - var _m = p.Match(CELParserLOGICAL_OR) - - localctx.(*ConditionalOrContext).s9 = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - localctx.(*ConditionalOrContext).ops = append(localctx.(*ConditionalOrContext).ops, localctx.(*ConditionalOrContext).s9) - { - p.SetState(45) - - var _x = p.ConditionalAnd() - - - localctx.(*ConditionalOrContext)._conditionalAnd = _x - } - localctx.(*ConditionalOrContext).e1 = append(localctx.(*ConditionalOrContext).e1, localctx.(*ConditionalOrContext)._conditionalAnd) - - - p.SetState(50) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - } - - - -errorExit: - if p.HasError() { - v := p.GetError() - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - p.SetError(nil) - } - p.ExitRule() - return localctx - goto errorExit // Trick to prevent compiler error if the label is not used -} - - -// IConditionalAndContext is an interface to support dynamic dispatch. -type IConditionalAndContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // GetS8 returns the s8 token. - GetS8() antlr.Token - - - // SetS8 sets the s8 token. - SetS8(antlr.Token) - - - // GetOps returns the ops token list. - GetOps() []antlr.Token - - - // SetOps sets the ops token list. - SetOps([]antlr.Token) - - - // GetE returns the e rule contexts. - GetE() IRelationContext - - // Get_relation returns the _relation rule contexts. - Get_relation() IRelationContext - - - // SetE sets the e rule contexts. - SetE(IRelationContext) - - // Set_relation sets the _relation rule contexts. - Set_relation(IRelationContext) - - - // GetE1 returns the e1 rule context list. - GetE1() []IRelationContext - - - // SetE1 sets the e1 rule context list. - SetE1([]IRelationContext) - - - // Getter signatures - AllRelation() []IRelationContext - Relation(i int) IRelationContext - AllLOGICAL_AND() []antlr.TerminalNode - LOGICAL_AND(i int) antlr.TerminalNode - - // IsConditionalAndContext differentiates from other interfaces. - IsConditionalAndContext() -} - -type ConditionalAndContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser - e IRelationContext - s8 antlr.Token - ops []antlr.Token - _relation IRelationContext - e1 []IRelationContext -} - -func NewEmptyConditionalAndContext() *ConditionalAndContext { - var p = new(ConditionalAndContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_conditionalAnd - return p -} - -func InitEmptyConditionalAndContext(p *ConditionalAndContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_conditionalAnd -} - -func (*ConditionalAndContext) IsConditionalAndContext() {} - -func NewConditionalAndContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ConditionalAndContext { - var p = new(ConditionalAndContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = CELParserRULE_conditionalAnd - - return p -} - -func (s *ConditionalAndContext) GetParser() antlr.Parser { return s.parser } - -func (s *ConditionalAndContext) GetS8() antlr.Token { return s.s8 } - - -func (s *ConditionalAndContext) SetS8(v antlr.Token) { s.s8 = v } - - -func (s *ConditionalAndContext) GetOps() []antlr.Token { return s.ops } - - -func (s *ConditionalAndContext) SetOps(v []antlr.Token) { s.ops = v } - - -func (s *ConditionalAndContext) GetE() IRelationContext { return s.e } - -func (s *ConditionalAndContext) Get_relation() IRelationContext { return s._relation } - - -func (s *ConditionalAndContext) SetE(v IRelationContext) { s.e = v } - -func (s *ConditionalAndContext) Set_relation(v IRelationContext) { s._relation = v } - - -func (s *ConditionalAndContext) GetE1() []IRelationContext { return s.e1 } - - -func (s *ConditionalAndContext) SetE1(v []IRelationContext) { s.e1 = v } - - -func (s *ConditionalAndContext) AllRelation() []IRelationContext { - children := s.GetChildren() - len := 0 - for _, ctx := range children { - if _, ok := ctx.(IRelationContext); ok { - len++ - } - } - - tst := make([]IRelationContext, len) - i := 0 - for _, ctx := range children { - if t, ok := ctx.(IRelationContext); ok { - tst[i] = t.(IRelationContext) - i++ - } - } - - return tst -} - -func (s *ConditionalAndContext) Relation(i int) IRelationContext { - var t antlr.RuleContext; - j := 0 - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IRelationContext); ok { - if j == i { - t = ctx.(antlr.RuleContext); - break - } - j++ - } - } - - if t == nil { - return nil - } - - return t.(IRelationContext) -} - -func (s *ConditionalAndContext) AllLOGICAL_AND() []antlr.TerminalNode { - return s.GetTokens(CELParserLOGICAL_AND) -} - -func (s *ConditionalAndContext) LOGICAL_AND(i int) antlr.TerminalNode { - return s.GetToken(CELParserLOGICAL_AND, i) -} - -func (s *ConditionalAndContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *ConditionalAndContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - - -func (s *ConditionalAndContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterConditionalAnd(s) - } -} - -func (s *ConditionalAndContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitConditionalAnd(s) - } -} - -func (s *ConditionalAndContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitConditionalAnd(s) - - default: - return t.VisitChildren(s) - } -} - - - - -func (p *CELParser) ConditionalAnd() (localctx IConditionalAndContext) { - localctx = NewConditionalAndContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 6, CELParserRULE_conditionalAnd) - var _la int - - p.EnterOuterAlt(localctx, 1) - { - p.SetState(51) - - var _x = p.relation(0) - - localctx.(*ConditionalAndContext).e = _x - } - p.SetState(56) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - - for _la == CELParserLOGICAL_AND { - { - p.SetState(52) - - var _m = p.Match(CELParserLOGICAL_AND) - - localctx.(*ConditionalAndContext).s8 = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - localctx.(*ConditionalAndContext).ops = append(localctx.(*ConditionalAndContext).ops, localctx.(*ConditionalAndContext).s8) - { - p.SetState(53) - - var _x = p.relation(0) - - localctx.(*ConditionalAndContext)._relation = _x - } - localctx.(*ConditionalAndContext).e1 = append(localctx.(*ConditionalAndContext).e1, localctx.(*ConditionalAndContext)._relation) - - - p.SetState(58) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - } - - - -errorExit: - if p.HasError() { - v := p.GetError() - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - p.SetError(nil) - } - p.ExitRule() - return localctx - goto errorExit // Trick to prevent compiler error if the label is not used -} - - -// IRelationContext is an interface to support dynamic dispatch. -type IRelationContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // GetOp returns the op token. - GetOp() antlr.Token - - - // SetOp sets the op token. - SetOp(antlr.Token) - - - // Getter signatures - Calc() ICalcContext - AllRelation() []IRelationContext - Relation(i int) IRelationContext - LESS() antlr.TerminalNode - LESS_EQUALS() antlr.TerminalNode - GREATER_EQUALS() antlr.TerminalNode - GREATER() antlr.TerminalNode - EQUALS() antlr.TerminalNode - NOT_EQUALS() antlr.TerminalNode - IN() antlr.TerminalNode - - // IsRelationContext differentiates from other interfaces. - IsRelationContext() -} - -type RelationContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser - op antlr.Token -} - -func NewEmptyRelationContext() *RelationContext { - var p = new(RelationContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_relation - return p -} - -func InitEmptyRelationContext(p *RelationContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_relation -} - -func (*RelationContext) IsRelationContext() {} - -func NewRelationContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *RelationContext { - var p = new(RelationContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = CELParserRULE_relation - - return p -} - -func (s *RelationContext) GetParser() antlr.Parser { return s.parser } - -func (s *RelationContext) GetOp() antlr.Token { return s.op } - - -func (s *RelationContext) SetOp(v antlr.Token) { s.op = v } - - -func (s *RelationContext) Calc() ICalcContext { - var t antlr.RuleContext; - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(ICalcContext); ok { - t = ctx.(antlr.RuleContext); - break - } - } - - if t == nil { - return nil - } - - return t.(ICalcContext) -} - -func (s *RelationContext) AllRelation() []IRelationContext { - children := s.GetChildren() - len := 0 - for _, ctx := range children { - if _, ok := ctx.(IRelationContext); ok { - len++ - } - } - - tst := make([]IRelationContext, len) - i := 0 - for _, ctx := range children { - if t, ok := ctx.(IRelationContext); ok { - tst[i] = t.(IRelationContext) - i++ - } - } - - return tst -} - -func (s *RelationContext) Relation(i int) IRelationContext { - var t antlr.RuleContext; - j := 0 - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IRelationContext); ok { - if j == i { - t = ctx.(antlr.RuleContext); - break - } - j++ - } - } - - if t == nil { - return nil - } - - return t.(IRelationContext) -} - -func (s *RelationContext) LESS() antlr.TerminalNode { - return s.GetToken(CELParserLESS, 0) -} - -func (s *RelationContext) LESS_EQUALS() antlr.TerminalNode { - return s.GetToken(CELParserLESS_EQUALS, 0) -} - -func (s *RelationContext) GREATER_EQUALS() antlr.TerminalNode { - return s.GetToken(CELParserGREATER_EQUALS, 0) -} - -func (s *RelationContext) GREATER() antlr.TerminalNode { - return s.GetToken(CELParserGREATER, 0) -} - -func (s *RelationContext) EQUALS() antlr.TerminalNode { - return s.GetToken(CELParserEQUALS, 0) -} - -func (s *RelationContext) NOT_EQUALS() antlr.TerminalNode { - return s.GetToken(CELParserNOT_EQUALS, 0) -} - -func (s *RelationContext) IN() antlr.TerminalNode { - return s.GetToken(CELParserIN, 0) -} - -func (s *RelationContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *RelationContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - - -func (s *RelationContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterRelation(s) - } -} - -func (s *RelationContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitRelation(s) - } -} - -func (s *RelationContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitRelation(s) - - default: - return t.VisitChildren(s) - } -} - - - - - -func (p *CELParser) Relation() (localctx IRelationContext) { - return p.relation(0) -} - -func (p *CELParser) relation(_p int) (localctx IRelationContext) { - var _parentctx antlr.ParserRuleContext = p.GetParserRuleContext() - - _parentState := p.GetState() - localctx = NewRelationContext(p, p.GetParserRuleContext(), _parentState) - var _prevctx IRelationContext = localctx - var _ antlr.ParserRuleContext = _prevctx // TODO: To prevent unused variable warning. - _startState := 8 - p.EnterRecursionRule(localctx, 8, CELParserRULE_relation, _p) - var _la int - - var _alt int - - p.EnterOuterAlt(localctx, 1) - { - p.SetState(60) - p.calc(0) - } - - p.GetParserRuleContext().SetStop(p.GetTokenStream().LT(-1)) - p.SetState(67) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 3, p.GetParserRuleContext()) - if p.HasError() { - goto errorExit - } - for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { - if _alt == 1 { - if p.GetParseListeners() != nil { - p.TriggerExitRuleEvent() - } - _prevctx = localctx - localctx = NewRelationContext(p, _parentctx, _parentState) - p.PushNewRecursionContext(localctx, _startState, CELParserRULE_relation) - p.SetState(62) - - if !(p.Precpred(p.GetParserRuleContext(), 1)) { - p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 1)", "")) - goto errorExit - } - { - p.SetState(63) - - var _lt = p.GetTokenStream().LT(1) - - localctx.(*RelationContext).op = _lt - - _la = p.GetTokenStream().LA(1) - - if !(((int64(_la) & ^0x3f) == 0 && ((int64(1) << _la) & 254) != 0)) { - var _ri = p.GetErrorHandler().RecoverInline(p) - - localctx.(*RelationContext).op = _ri - } else { - p.GetErrorHandler().ReportMatch(p) - p.Consume() - } - } - { - p.SetState(64) - p.relation(2) - } - - - } - p.SetState(69) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 3, p.GetParserRuleContext()) - if p.HasError() { - goto errorExit - } - } - - - - errorExit: - if p.HasError() { - v := p.GetError() - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - p.SetError(nil) - } - p.UnrollRecursionContexts(_parentctx) - return localctx - goto errorExit // Trick to prevent compiler error if the label is not used -} - - -// ICalcContext is an interface to support dynamic dispatch. -type ICalcContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // GetOp returns the op token. - GetOp() antlr.Token - - - // SetOp sets the op token. - SetOp(antlr.Token) - - - // Getter signatures - Unary() IUnaryContext - AllCalc() []ICalcContext - Calc(i int) ICalcContext - STAR() antlr.TerminalNode - SLASH() antlr.TerminalNode - PERCENT() antlr.TerminalNode - PLUS() antlr.TerminalNode - MINUS() antlr.TerminalNode - - // IsCalcContext differentiates from other interfaces. - IsCalcContext() -} - -type CalcContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser - op antlr.Token -} - -func NewEmptyCalcContext() *CalcContext { - var p = new(CalcContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_calc - return p -} - -func InitEmptyCalcContext(p *CalcContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_calc -} - -func (*CalcContext) IsCalcContext() {} - -func NewCalcContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *CalcContext { - var p = new(CalcContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = CELParserRULE_calc - - return p -} - -func (s *CalcContext) GetParser() antlr.Parser { return s.parser } - -func (s *CalcContext) GetOp() antlr.Token { return s.op } - - -func (s *CalcContext) SetOp(v antlr.Token) { s.op = v } - - -func (s *CalcContext) Unary() IUnaryContext { - var t antlr.RuleContext; - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IUnaryContext); ok { - t = ctx.(antlr.RuleContext); - break - } - } - - if t == nil { - return nil - } - - return t.(IUnaryContext) -} - -func (s *CalcContext) AllCalc() []ICalcContext { - children := s.GetChildren() - len := 0 - for _, ctx := range children { - if _, ok := ctx.(ICalcContext); ok { - len++ - } - } - - tst := make([]ICalcContext, len) - i := 0 - for _, ctx := range children { - if t, ok := ctx.(ICalcContext); ok { - tst[i] = t.(ICalcContext) - i++ - } - } - - return tst -} - -func (s *CalcContext) Calc(i int) ICalcContext { - var t antlr.RuleContext; - j := 0 - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(ICalcContext); ok { - if j == i { - t = ctx.(antlr.RuleContext); - break - } - j++ - } - } - - if t == nil { - return nil - } - - return t.(ICalcContext) -} - -func (s *CalcContext) STAR() antlr.TerminalNode { - return s.GetToken(CELParserSTAR, 0) -} - -func (s *CalcContext) SLASH() antlr.TerminalNode { - return s.GetToken(CELParserSLASH, 0) -} - -func (s *CalcContext) PERCENT() antlr.TerminalNode { - return s.GetToken(CELParserPERCENT, 0) -} - -func (s *CalcContext) PLUS() antlr.TerminalNode { - return s.GetToken(CELParserPLUS, 0) -} - -func (s *CalcContext) MINUS() antlr.TerminalNode { - return s.GetToken(CELParserMINUS, 0) -} - -func (s *CalcContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *CalcContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - - -func (s *CalcContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterCalc(s) - } -} - -func (s *CalcContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitCalc(s) - } -} - -func (s *CalcContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitCalc(s) - - default: - return t.VisitChildren(s) - } -} - - - - - -func (p *CELParser) Calc() (localctx ICalcContext) { - return p.calc(0) -} - -func (p *CELParser) calc(_p int) (localctx ICalcContext) { - var _parentctx antlr.ParserRuleContext = p.GetParserRuleContext() - - _parentState := p.GetState() - localctx = NewCalcContext(p, p.GetParserRuleContext(), _parentState) - var _prevctx ICalcContext = localctx - var _ antlr.ParserRuleContext = _prevctx // TODO: To prevent unused variable warning. - _startState := 10 - p.EnterRecursionRule(localctx, 10, CELParserRULE_calc, _p) - var _la int - - var _alt int - - p.EnterOuterAlt(localctx, 1) - { - p.SetState(71) - p.Unary() - } - - p.GetParserRuleContext().SetStop(p.GetTokenStream().LT(-1)) - p.SetState(81) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 5, p.GetParserRuleContext()) - if p.HasError() { - goto errorExit - } - for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { - if _alt == 1 { - if p.GetParseListeners() != nil { - p.TriggerExitRuleEvent() - } - _prevctx = localctx - p.SetState(79) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - - switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 4, p.GetParserRuleContext()) { - case 1: - localctx = NewCalcContext(p, _parentctx, _parentState) - p.PushNewRecursionContext(localctx, _startState, CELParserRULE_calc) - p.SetState(73) - - if !(p.Precpred(p.GetParserRuleContext(), 2)) { - p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 2)", "")) - goto errorExit - } - { - p.SetState(74) - - var _lt = p.GetTokenStream().LT(1) - - localctx.(*CalcContext).op = _lt - - _la = p.GetTokenStream().LA(1) - - if !(((int64(_la) & ^0x3f) == 0 && ((int64(1) << _la) & 58720256) != 0)) { - var _ri = p.GetErrorHandler().RecoverInline(p) - - localctx.(*CalcContext).op = _ri - } else { - p.GetErrorHandler().ReportMatch(p) - p.Consume() - } - } - { - p.SetState(75) - p.calc(3) - } - - - case 2: - localctx = NewCalcContext(p, _parentctx, _parentState) - p.PushNewRecursionContext(localctx, _startState, CELParserRULE_calc) - p.SetState(76) - - if !(p.Precpred(p.GetParserRuleContext(), 1)) { - p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 1)", "")) - goto errorExit - } - { - p.SetState(77) - - var _lt = p.GetTokenStream().LT(1) - - localctx.(*CalcContext).op = _lt - - _la = p.GetTokenStream().LA(1) - - if !(_la == CELParserMINUS || _la == CELParserPLUS) { - var _ri = p.GetErrorHandler().RecoverInline(p) - - localctx.(*CalcContext).op = _ri - } else { - p.GetErrorHandler().ReportMatch(p) - p.Consume() - } - } - { - p.SetState(78) - p.calc(2) - } - - case antlr.ATNInvalidAltNumber: - goto errorExit - } - - } - p.SetState(83) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 5, p.GetParserRuleContext()) - if p.HasError() { - goto errorExit - } - } - - - - errorExit: - if p.HasError() { - v := p.GetError() - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - p.SetError(nil) - } - p.UnrollRecursionContexts(_parentctx) - return localctx - goto errorExit // Trick to prevent compiler error if the label is not used -} - - -// IUnaryContext is an interface to support dynamic dispatch. -type IUnaryContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - // IsUnaryContext differentiates from other interfaces. - IsUnaryContext() -} - -type UnaryContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser -} - -func NewEmptyUnaryContext() *UnaryContext { - var p = new(UnaryContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_unary - return p -} - -func InitEmptyUnaryContext(p *UnaryContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_unary -} - -func (*UnaryContext) IsUnaryContext() {} - -func NewUnaryContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *UnaryContext { - var p = new(UnaryContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = CELParserRULE_unary - - return p -} - -func (s *UnaryContext) GetParser() antlr.Parser { return s.parser } - -func (s *UnaryContext) CopyAll(ctx *UnaryContext) { - s.CopyFrom(&ctx.BaseParserRuleContext) -} - -func (s *UnaryContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *UnaryContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - - - - -type LogicalNotContext struct { - UnaryContext - s19 antlr.Token - ops []antlr.Token -} - -func NewLogicalNotContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *LogicalNotContext { - var p = new(LogicalNotContext) - - InitEmptyUnaryContext(&p.UnaryContext) - p.parser = parser - p.CopyAll(ctx.(*UnaryContext)) - - return p -} - - -func (s *LogicalNotContext) GetS19() antlr.Token { return s.s19 } - - -func (s *LogicalNotContext) SetS19(v antlr.Token) { s.s19 = v } - - -func (s *LogicalNotContext) GetOps() []antlr.Token { return s.ops } - - -func (s *LogicalNotContext) SetOps(v []antlr.Token) { s.ops = v } - -func (s *LogicalNotContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *LogicalNotContext) Member() IMemberContext { - var t antlr.RuleContext; - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IMemberContext); ok { - t = ctx.(antlr.RuleContext); - break - } - } - - if t == nil { - return nil - } - - return t.(IMemberContext) -} - -func (s *LogicalNotContext) AllEXCLAM() []antlr.TerminalNode { - return s.GetTokens(CELParserEXCLAM) -} - -func (s *LogicalNotContext) EXCLAM(i int) antlr.TerminalNode { - return s.GetToken(CELParserEXCLAM, i) -} - - -func (s *LogicalNotContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterLogicalNot(s) - } -} - -func (s *LogicalNotContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitLogicalNot(s) - } -} - -func (s *LogicalNotContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitLogicalNot(s) - - default: - return t.VisitChildren(s) - } -} - - -type MemberExprContext struct { - UnaryContext -} - -func NewMemberExprContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *MemberExprContext { - var p = new(MemberExprContext) - - InitEmptyUnaryContext(&p.UnaryContext) - p.parser = parser - p.CopyAll(ctx.(*UnaryContext)) - - return p -} - -func (s *MemberExprContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *MemberExprContext) Member() IMemberContext { - var t antlr.RuleContext; - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IMemberContext); ok { - t = ctx.(antlr.RuleContext); - break - } - } - - if t == nil { - return nil - } - - return t.(IMemberContext) -} - - -func (s *MemberExprContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterMemberExpr(s) - } -} - -func (s *MemberExprContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitMemberExpr(s) - } -} - -func (s *MemberExprContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitMemberExpr(s) - - default: - return t.VisitChildren(s) - } -} - - -type NegateContext struct { - UnaryContext - s18 antlr.Token - ops []antlr.Token -} - -func NewNegateContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *NegateContext { - var p = new(NegateContext) - - InitEmptyUnaryContext(&p.UnaryContext) - p.parser = parser - p.CopyAll(ctx.(*UnaryContext)) - - return p -} - - -func (s *NegateContext) GetS18() antlr.Token { return s.s18 } - - -func (s *NegateContext) SetS18(v antlr.Token) { s.s18 = v } - - -func (s *NegateContext) GetOps() []antlr.Token { return s.ops } - - -func (s *NegateContext) SetOps(v []antlr.Token) { s.ops = v } - -func (s *NegateContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *NegateContext) Member() IMemberContext { - var t antlr.RuleContext; - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IMemberContext); ok { - t = ctx.(antlr.RuleContext); - break - } - } - - if t == nil { - return nil - } - - return t.(IMemberContext) -} - -func (s *NegateContext) AllMINUS() []antlr.TerminalNode { - return s.GetTokens(CELParserMINUS) -} - -func (s *NegateContext) MINUS(i int) antlr.TerminalNode { - return s.GetToken(CELParserMINUS, i) -} - - -func (s *NegateContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterNegate(s) - } -} - -func (s *NegateContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitNegate(s) - } -} - -func (s *NegateContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitNegate(s) - - default: - return t.VisitChildren(s) - } -} - - - -func (p *CELParser) Unary() (localctx IUnaryContext) { - localctx = NewUnaryContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 12, CELParserRULE_unary) - var _la int - - var _alt int - - p.SetState(97) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - - switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 8, p.GetParserRuleContext()) { - case 1: - localctx = NewMemberExprContext(p, localctx) - p.EnterOuterAlt(localctx, 1) - { - p.SetState(84) - p.member(0) - } - - - case 2: - localctx = NewLogicalNotContext(p, localctx) - p.EnterOuterAlt(localctx, 2) - p.SetState(86) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - - for ok := true; ok; ok = _la == CELParserEXCLAM { - { - p.SetState(85) - - var _m = p.Match(CELParserEXCLAM) - - localctx.(*LogicalNotContext).s19 = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - localctx.(*LogicalNotContext).ops = append(localctx.(*LogicalNotContext).ops, localctx.(*LogicalNotContext).s19) - - - p.SetState(88) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(90) - p.member(0) - } - - - case 3: - localctx = NewNegateContext(p, localctx) - p.EnterOuterAlt(localctx, 3) - p.SetState(92) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _alt = 1 - for ok := true; ok; ok = _alt != 2 && _alt != antlr.ATNInvalidAltNumber { - switch _alt { - case 1: - { - p.SetState(91) - - var _m = p.Match(CELParserMINUS) - - localctx.(*NegateContext).s18 = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - localctx.(*NegateContext).ops = append(localctx.(*NegateContext).ops, localctx.(*NegateContext).s18) - - - - - default: - p.SetError(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) - goto errorExit - } - - p.SetState(94) - p.GetErrorHandler().Sync(p) - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 7, p.GetParserRuleContext()) - if p.HasError() { - goto errorExit - } - } - { - p.SetState(96) - p.member(0) - } - - case antlr.ATNInvalidAltNumber: - goto errorExit - } - - -errorExit: - if p.HasError() { - v := p.GetError() - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - p.SetError(nil) - } - p.ExitRule() - return localctx - goto errorExit // Trick to prevent compiler error if the label is not used -} - - -// IMemberContext is an interface to support dynamic dispatch. -type IMemberContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - // IsMemberContext differentiates from other interfaces. - IsMemberContext() -} - -type MemberContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser -} - -func NewEmptyMemberContext() *MemberContext { - var p = new(MemberContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_member - return p -} - -func InitEmptyMemberContext(p *MemberContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_member -} - -func (*MemberContext) IsMemberContext() {} - -func NewMemberContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *MemberContext { - var p = new(MemberContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = CELParserRULE_member - - return p -} - -func (s *MemberContext) GetParser() antlr.Parser { return s.parser } - -func (s *MemberContext) CopyAll(ctx *MemberContext) { - s.CopyFrom(&ctx.BaseParserRuleContext) -} - -func (s *MemberContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *MemberContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - - - - - -type MemberCallContext struct { - MemberContext - op antlr.Token - id antlr.Token - open antlr.Token - args IExprListContext -} - -func NewMemberCallContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *MemberCallContext { - var p = new(MemberCallContext) - - InitEmptyMemberContext(&p.MemberContext) - p.parser = parser - p.CopyAll(ctx.(*MemberContext)) - - return p -} - - -func (s *MemberCallContext) GetOp() antlr.Token { return s.op } - -func (s *MemberCallContext) GetId() antlr.Token { return s.id } - -func (s *MemberCallContext) GetOpen() antlr.Token { return s.open } - - -func (s *MemberCallContext) SetOp(v antlr.Token) { s.op = v } - -func (s *MemberCallContext) SetId(v antlr.Token) { s.id = v } - -func (s *MemberCallContext) SetOpen(v antlr.Token) { s.open = v } - - -func (s *MemberCallContext) GetArgs() IExprListContext { return s.args } - - -func (s *MemberCallContext) SetArgs(v IExprListContext) { s.args = v } - -func (s *MemberCallContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *MemberCallContext) Member() IMemberContext { - var t antlr.RuleContext; - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IMemberContext); ok { - t = ctx.(antlr.RuleContext); - break - } - } - - if t == nil { - return nil - } - - return t.(IMemberContext) -} - -func (s *MemberCallContext) RPAREN() antlr.TerminalNode { - return s.GetToken(CELParserRPAREN, 0) -} - -func (s *MemberCallContext) DOT() antlr.TerminalNode { - return s.GetToken(CELParserDOT, 0) -} - -func (s *MemberCallContext) IDENTIFIER() antlr.TerminalNode { - return s.GetToken(CELParserIDENTIFIER, 0) -} - -func (s *MemberCallContext) LPAREN() antlr.TerminalNode { - return s.GetToken(CELParserLPAREN, 0) -} - -func (s *MemberCallContext) ExprList() IExprListContext { - var t antlr.RuleContext; - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IExprListContext); ok { - t = ctx.(antlr.RuleContext); - break - } - } - - if t == nil { - return nil - } - - return t.(IExprListContext) -} - - -func (s *MemberCallContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterMemberCall(s) - } -} - -func (s *MemberCallContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitMemberCall(s) - } -} - -func (s *MemberCallContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitMemberCall(s) - - default: - return t.VisitChildren(s) - } -} - - -type SelectContext struct { - MemberContext - op antlr.Token - opt antlr.Token - id antlr.Token -} - -func NewSelectContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *SelectContext { - var p = new(SelectContext) - - InitEmptyMemberContext(&p.MemberContext) - p.parser = parser - p.CopyAll(ctx.(*MemberContext)) - - return p -} - - -func (s *SelectContext) GetOp() antlr.Token { return s.op } - -func (s *SelectContext) GetOpt() antlr.Token { return s.opt } - -func (s *SelectContext) GetId() antlr.Token { return s.id } - - -func (s *SelectContext) SetOp(v antlr.Token) { s.op = v } - -func (s *SelectContext) SetOpt(v antlr.Token) { s.opt = v } - -func (s *SelectContext) SetId(v antlr.Token) { s.id = v } - -func (s *SelectContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *SelectContext) Member() IMemberContext { - var t antlr.RuleContext; - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IMemberContext); ok { - t = ctx.(antlr.RuleContext); - break - } - } - - if t == nil { - return nil - } - - return t.(IMemberContext) -} - -func (s *SelectContext) DOT() antlr.TerminalNode { - return s.GetToken(CELParserDOT, 0) -} - -func (s *SelectContext) IDENTIFIER() antlr.TerminalNode { - return s.GetToken(CELParserIDENTIFIER, 0) -} - -func (s *SelectContext) QUESTIONMARK() antlr.TerminalNode { - return s.GetToken(CELParserQUESTIONMARK, 0) -} - - -func (s *SelectContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterSelect(s) - } -} - -func (s *SelectContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitSelect(s) - } -} - -func (s *SelectContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitSelect(s) - - default: - return t.VisitChildren(s) - } -} - - -type PrimaryExprContext struct { - MemberContext -} - -func NewPrimaryExprContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *PrimaryExprContext { - var p = new(PrimaryExprContext) - - InitEmptyMemberContext(&p.MemberContext) - p.parser = parser - p.CopyAll(ctx.(*MemberContext)) - - return p -} - -func (s *PrimaryExprContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *PrimaryExprContext) Primary() IPrimaryContext { - var t antlr.RuleContext; - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IPrimaryContext); ok { - t = ctx.(antlr.RuleContext); - break - } - } - - if t == nil { - return nil - } - - return t.(IPrimaryContext) -} - - -func (s *PrimaryExprContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterPrimaryExpr(s) - } -} - -func (s *PrimaryExprContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitPrimaryExpr(s) - } -} - -func (s *PrimaryExprContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitPrimaryExpr(s) - - default: - return t.VisitChildren(s) - } -} - - -type IndexContext struct { - MemberContext - op antlr.Token - opt antlr.Token - index IExprContext -} - -func NewIndexContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *IndexContext { - var p = new(IndexContext) - - InitEmptyMemberContext(&p.MemberContext) - p.parser = parser - p.CopyAll(ctx.(*MemberContext)) - - return p -} - - -func (s *IndexContext) GetOp() antlr.Token { return s.op } - -func (s *IndexContext) GetOpt() antlr.Token { return s.opt } - - -func (s *IndexContext) SetOp(v antlr.Token) { s.op = v } - -func (s *IndexContext) SetOpt(v antlr.Token) { s.opt = v } - - -func (s *IndexContext) GetIndex() IExprContext { return s.index } - - -func (s *IndexContext) SetIndex(v IExprContext) { s.index = v } - -func (s *IndexContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *IndexContext) Member() IMemberContext { - var t antlr.RuleContext; - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IMemberContext); ok { - t = ctx.(antlr.RuleContext); - break - } - } - - if t == nil { - return nil - } - - return t.(IMemberContext) -} - -func (s *IndexContext) RPRACKET() antlr.TerminalNode { - return s.GetToken(CELParserRPRACKET, 0) -} - -func (s *IndexContext) LBRACKET() antlr.TerminalNode { - return s.GetToken(CELParserLBRACKET, 0) -} - -func (s *IndexContext) Expr() IExprContext { - var t antlr.RuleContext; - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IExprContext); ok { - t = ctx.(antlr.RuleContext); - break - } - } - - if t == nil { - return nil - } - - return t.(IExprContext) -} - -func (s *IndexContext) QUESTIONMARK() antlr.TerminalNode { - return s.GetToken(CELParserQUESTIONMARK, 0) -} - - -func (s *IndexContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterIndex(s) - } -} - -func (s *IndexContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitIndex(s) - } -} - -func (s *IndexContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitIndex(s) - - default: - return t.VisitChildren(s) - } -} - - - -func (p *CELParser) Member() (localctx IMemberContext) { - return p.member(0) -} - -func (p *CELParser) member(_p int) (localctx IMemberContext) { - var _parentctx antlr.ParserRuleContext = p.GetParserRuleContext() - - _parentState := p.GetState() - localctx = NewMemberContext(p, p.GetParserRuleContext(), _parentState) - var _prevctx IMemberContext = localctx - var _ antlr.ParserRuleContext = _prevctx // TODO: To prevent unused variable warning. - _startState := 14 - p.EnterRecursionRule(localctx, 14, CELParserRULE_member, _p) - var _la int - - var _alt int - - p.EnterOuterAlt(localctx, 1) - localctx = NewPrimaryExprContext(p, localctx) - p.SetParserRuleContext(localctx) - _prevctx = localctx - - { - p.SetState(100) - p.Primary() - } - - p.GetParserRuleContext().SetStop(p.GetTokenStream().LT(-1)) - p.SetState(126) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 13, p.GetParserRuleContext()) - if p.HasError() { - goto errorExit - } - for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { - if _alt == 1 { - if p.GetParseListeners() != nil { - p.TriggerExitRuleEvent() - } - _prevctx = localctx - p.SetState(124) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - - switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 12, p.GetParserRuleContext()) { - case 1: - localctx = NewSelectContext(p, NewMemberContext(p, _parentctx, _parentState)) - p.PushNewRecursionContext(localctx, _startState, CELParserRULE_member) - p.SetState(102) - - if !(p.Precpred(p.GetParserRuleContext(), 3)) { - p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 3)", "")) - goto errorExit - } - { - p.SetState(103) - - var _m = p.Match(CELParserDOT) - - localctx.(*SelectContext).op = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - p.SetState(105) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - - if _la == CELParserQUESTIONMARK { - { - p.SetState(104) - - var _m = p.Match(CELParserQUESTIONMARK) - - localctx.(*SelectContext).opt = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - } - { - p.SetState(107) - - var _m = p.Match(CELParserIDENTIFIER) - - localctx.(*SelectContext).id = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - - case 2: - localctx = NewMemberCallContext(p, NewMemberContext(p, _parentctx, _parentState)) - p.PushNewRecursionContext(localctx, _startState, CELParserRULE_member) - p.SetState(108) - - if !(p.Precpred(p.GetParserRuleContext(), 2)) { - p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 2)", "")) - goto errorExit - } - { - p.SetState(109) - - var _m = p.Match(CELParserDOT) - - localctx.(*MemberCallContext).op = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - { - p.SetState(110) - - var _m = p.Match(CELParserIDENTIFIER) - - localctx.(*MemberCallContext).id = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - { - p.SetState(111) - - var _m = p.Match(CELParserLPAREN) - - localctx.(*MemberCallContext).open = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - p.SetState(113) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - - if ((int64(_la) & ^0x3f) == 0 && ((int64(1) << _la) & 135762105344) != 0) { - { - p.SetState(112) - - var _x = p.ExprList() - - - localctx.(*MemberCallContext).args = _x - } - - } - { - p.SetState(115) - p.Match(CELParserRPAREN) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - - case 3: - localctx = NewIndexContext(p, NewMemberContext(p, _parentctx, _parentState)) - p.PushNewRecursionContext(localctx, _startState, CELParserRULE_member) - p.SetState(116) - - if !(p.Precpred(p.GetParserRuleContext(), 1)) { - p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 1)", "")) - goto errorExit - } - { - p.SetState(117) - - var _m = p.Match(CELParserLBRACKET) - - localctx.(*IndexContext).op = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - p.SetState(119) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - - if _la == CELParserQUESTIONMARK { - { - p.SetState(118) - - var _m = p.Match(CELParserQUESTIONMARK) - - localctx.(*IndexContext).opt = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - } - { - p.SetState(121) - - var _x = p.Expr() - - - localctx.(*IndexContext).index = _x - } - { - p.SetState(122) - p.Match(CELParserRPRACKET) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - case antlr.ATNInvalidAltNumber: - goto errorExit - } - - } - p.SetState(128) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 13, p.GetParserRuleContext()) - if p.HasError() { - goto errorExit - } - } - - - - errorExit: - if p.HasError() { - v := p.GetError() - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - p.SetError(nil) - } - p.UnrollRecursionContexts(_parentctx) - return localctx - goto errorExit // Trick to prevent compiler error if the label is not used -} - - -// IPrimaryContext is an interface to support dynamic dispatch. -type IPrimaryContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - // IsPrimaryContext differentiates from other interfaces. - IsPrimaryContext() -} - -type PrimaryContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser -} - -func NewEmptyPrimaryContext() *PrimaryContext { - var p = new(PrimaryContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_primary - return p -} - -func InitEmptyPrimaryContext(p *PrimaryContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_primary -} - -func (*PrimaryContext) IsPrimaryContext() {} - -func NewPrimaryContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *PrimaryContext { - var p = new(PrimaryContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = CELParserRULE_primary - - return p -} - -func (s *PrimaryContext) GetParser() antlr.Parser { return s.parser } - -func (s *PrimaryContext) CopyAll(ctx *PrimaryContext) { - s.CopyFrom(&ctx.BaseParserRuleContext) -} - -func (s *PrimaryContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *PrimaryContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - - - - -type CreateListContext struct { - PrimaryContext - op antlr.Token - elems IListInitContext -} - -func NewCreateListContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *CreateListContext { - var p = new(CreateListContext) - - InitEmptyPrimaryContext(&p.PrimaryContext) - p.parser = parser - p.CopyAll(ctx.(*PrimaryContext)) - - return p -} - - -func (s *CreateListContext) GetOp() antlr.Token { return s.op } - - -func (s *CreateListContext) SetOp(v antlr.Token) { s.op = v } - - -func (s *CreateListContext) GetElems() IListInitContext { return s.elems } - - -func (s *CreateListContext) SetElems(v IListInitContext) { s.elems = v } - -func (s *CreateListContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *CreateListContext) RPRACKET() antlr.TerminalNode { - return s.GetToken(CELParserRPRACKET, 0) -} - -func (s *CreateListContext) LBRACKET() antlr.TerminalNode { - return s.GetToken(CELParserLBRACKET, 0) -} - -func (s *CreateListContext) COMMA() antlr.TerminalNode { - return s.GetToken(CELParserCOMMA, 0) -} - -func (s *CreateListContext) ListInit() IListInitContext { - var t antlr.RuleContext; - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IListInitContext); ok { - t = ctx.(antlr.RuleContext); - break - } - } - - if t == nil { - return nil - } - - return t.(IListInitContext) -} - - -func (s *CreateListContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterCreateList(s) - } -} - -func (s *CreateListContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitCreateList(s) - } -} - -func (s *CreateListContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitCreateList(s) - - default: - return t.VisitChildren(s) - } -} - - -type CreateStructContext struct { - PrimaryContext - op antlr.Token - entries IMapInitializerListContext -} - -func NewCreateStructContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *CreateStructContext { - var p = new(CreateStructContext) - - InitEmptyPrimaryContext(&p.PrimaryContext) - p.parser = parser - p.CopyAll(ctx.(*PrimaryContext)) - - return p -} - - -func (s *CreateStructContext) GetOp() antlr.Token { return s.op } - - -func (s *CreateStructContext) SetOp(v antlr.Token) { s.op = v } - - -func (s *CreateStructContext) GetEntries() IMapInitializerListContext { return s.entries } - - -func (s *CreateStructContext) SetEntries(v IMapInitializerListContext) { s.entries = v } - -func (s *CreateStructContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *CreateStructContext) RBRACE() antlr.TerminalNode { - return s.GetToken(CELParserRBRACE, 0) -} - -func (s *CreateStructContext) LBRACE() antlr.TerminalNode { - return s.GetToken(CELParserLBRACE, 0) -} - -func (s *CreateStructContext) COMMA() antlr.TerminalNode { - return s.GetToken(CELParserCOMMA, 0) -} - -func (s *CreateStructContext) MapInitializerList() IMapInitializerListContext { - var t antlr.RuleContext; - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IMapInitializerListContext); ok { - t = ctx.(antlr.RuleContext); - break - } - } - - if t == nil { - return nil - } - - return t.(IMapInitializerListContext) -} - - -func (s *CreateStructContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterCreateStruct(s) - } -} - -func (s *CreateStructContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitCreateStruct(s) - } -} - -func (s *CreateStructContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitCreateStruct(s) - - default: - return t.VisitChildren(s) - } -} - - -type ConstantLiteralContext struct { - PrimaryContext -} - -func NewConstantLiteralContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *ConstantLiteralContext { - var p = new(ConstantLiteralContext) - - InitEmptyPrimaryContext(&p.PrimaryContext) - p.parser = parser - p.CopyAll(ctx.(*PrimaryContext)) - - return p -} - -func (s *ConstantLiteralContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *ConstantLiteralContext) Literal() ILiteralContext { - var t antlr.RuleContext; - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(ILiteralContext); ok { - t = ctx.(antlr.RuleContext); - break - } - } - - if t == nil { - return nil - } - - return t.(ILiteralContext) -} - - -func (s *ConstantLiteralContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterConstantLiteral(s) - } -} - -func (s *ConstantLiteralContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitConstantLiteral(s) - } -} - -func (s *ConstantLiteralContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitConstantLiteral(s) - - default: - return t.VisitChildren(s) - } -} - - -type NestedContext struct { - PrimaryContext - e IExprContext -} - -func NewNestedContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *NestedContext { - var p = new(NestedContext) - - InitEmptyPrimaryContext(&p.PrimaryContext) - p.parser = parser - p.CopyAll(ctx.(*PrimaryContext)) - - return p -} - - -func (s *NestedContext) GetE() IExprContext { return s.e } - - -func (s *NestedContext) SetE(v IExprContext) { s.e = v } - -func (s *NestedContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *NestedContext) LPAREN() antlr.TerminalNode { - return s.GetToken(CELParserLPAREN, 0) -} - -func (s *NestedContext) RPAREN() antlr.TerminalNode { - return s.GetToken(CELParserRPAREN, 0) -} - -func (s *NestedContext) Expr() IExprContext { - var t antlr.RuleContext; - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IExprContext); ok { - t = ctx.(antlr.RuleContext); - break - } - } - - if t == nil { - return nil - } - - return t.(IExprContext) -} - - -func (s *NestedContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterNested(s) - } -} - -func (s *NestedContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitNested(s) - } -} - -func (s *NestedContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitNested(s) - - default: - return t.VisitChildren(s) - } -} - - -type CreateMessageContext struct { - PrimaryContext - leadingDot antlr.Token - _IDENTIFIER antlr.Token - ids []antlr.Token - s16 antlr.Token - ops []antlr.Token - op antlr.Token - entries IFieldInitializerListContext -} - -func NewCreateMessageContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *CreateMessageContext { - var p = new(CreateMessageContext) - - InitEmptyPrimaryContext(&p.PrimaryContext) - p.parser = parser - p.CopyAll(ctx.(*PrimaryContext)) - - return p -} - - -func (s *CreateMessageContext) GetLeadingDot() antlr.Token { return s.leadingDot } - -func (s *CreateMessageContext) Get_IDENTIFIER() antlr.Token { return s._IDENTIFIER } - -func (s *CreateMessageContext) GetS16() antlr.Token { return s.s16 } - -func (s *CreateMessageContext) GetOp() antlr.Token { return s.op } - - -func (s *CreateMessageContext) SetLeadingDot(v antlr.Token) { s.leadingDot = v } - -func (s *CreateMessageContext) Set_IDENTIFIER(v antlr.Token) { s._IDENTIFIER = v } - -func (s *CreateMessageContext) SetS16(v antlr.Token) { s.s16 = v } - -func (s *CreateMessageContext) SetOp(v antlr.Token) { s.op = v } - - -func (s *CreateMessageContext) GetIds() []antlr.Token { return s.ids } - -func (s *CreateMessageContext) GetOps() []antlr.Token { return s.ops } - - -func (s *CreateMessageContext) SetIds(v []antlr.Token) { s.ids = v } - -func (s *CreateMessageContext) SetOps(v []antlr.Token) { s.ops = v } - - -func (s *CreateMessageContext) GetEntries() IFieldInitializerListContext { return s.entries } - - -func (s *CreateMessageContext) SetEntries(v IFieldInitializerListContext) { s.entries = v } - -func (s *CreateMessageContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *CreateMessageContext) RBRACE() antlr.TerminalNode { - return s.GetToken(CELParserRBRACE, 0) -} - -func (s *CreateMessageContext) AllIDENTIFIER() []antlr.TerminalNode { - return s.GetTokens(CELParserIDENTIFIER) -} - -func (s *CreateMessageContext) IDENTIFIER(i int) antlr.TerminalNode { - return s.GetToken(CELParserIDENTIFIER, i) -} - -func (s *CreateMessageContext) LBRACE() antlr.TerminalNode { - return s.GetToken(CELParserLBRACE, 0) -} - -func (s *CreateMessageContext) COMMA() antlr.TerminalNode { - return s.GetToken(CELParserCOMMA, 0) -} - -func (s *CreateMessageContext) AllDOT() []antlr.TerminalNode { - return s.GetTokens(CELParserDOT) -} - -func (s *CreateMessageContext) DOT(i int) antlr.TerminalNode { - return s.GetToken(CELParserDOT, i) -} - -func (s *CreateMessageContext) FieldInitializerList() IFieldInitializerListContext { - var t antlr.RuleContext; - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IFieldInitializerListContext); ok { - t = ctx.(antlr.RuleContext); - break - } - } - - if t == nil { - return nil - } - - return t.(IFieldInitializerListContext) -} - - -func (s *CreateMessageContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterCreateMessage(s) - } -} - -func (s *CreateMessageContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitCreateMessage(s) - } -} - -func (s *CreateMessageContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitCreateMessage(s) - - default: - return t.VisitChildren(s) - } -} - - -type IdentOrGlobalCallContext struct { - PrimaryContext - leadingDot antlr.Token - id antlr.Token - op antlr.Token - args IExprListContext -} - -func NewIdentOrGlobalCallContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *IdentOrGlobalCallContext { - var p = new(IdentOrGlobalCallContext) - - InitEmptyPrimaryContext(&p.PrimaryContext) - p.parser = parser - p.CopyAll(ctx.(*PrimaryContext)) - - return p -} - - -func (s *IdentOrGlobalCallContext) GetLeadingDot() antlr.Token { return s.leadingDot } - -func (s *IdentOrGlobalCallContext) GetId() antlr.Token { return s.id } - -func (s *IdentOrGlobalCallContext) GetOp() antlr.Token { return s.op } - - -func (s *IdentOrGlobalCallContext) SetLeadingDot(v antlr.Token) { s.leadingDot = v } - -func (s *IdentOrGlobalCallContext) SetId(v antlr.Token) { s.id = v } - -func (s *IdentOrGlobalCallContext) SetOp(v antlr.Token) { s.op = v } - - -func (s *IdentOrGlobalCallContext) GetArgs() IExprListContext { return s.args } - - -func (s *IdentOrGlobalCallContext) SetArgs(v IExprListContext) { s.args = v } - -func (s *IdentOrGlobalCallContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *IdentOrGlobalCallContext) IDENTIFIER() antlr.TerminalNode { - return s.GetToken(CELParserIDENTIFIER, 0) -} - -func (s *IdentOrGlobalCallContext) RPAREN() antlr.TerminalNode { - return s.GetToken(CELParserRPAREN, 0) -} - -func (s *IdentOrGlobalCallContext) DOT() antlr.TerminalNode { - return s.GetToken(CELParserDOT, 0) -} - -func (s *IdentOrGlobalCallContext) LPAREN() antlr.TerminalNode { - return s.GetToken(CELParserLPAREN, 0) -} - -func (s *IdentOrGlobalCallContext) ExprList() IExprListContext { - var t antlr.RuleContext; - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IExprListContext); ok { - t = ctx.(antlr.RuleContext); - break - } - } - - if t == nil { - return nil - } - - return t.(IExprListContext) -} - - -func (s *IdentOrGlobalCallContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterIdentOrGlobalCall(s) - } -} - -func (s *IdentOrGlobalCallContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitIdentOrGlobalCall(s) - } -} - -func (s *IdentOrGlobalCallContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitIdentOrGlobalCall(s) - - default: - return t.VisitChildren(s) - } -} - - - -func (p *CELParser) Primary() (localctx IPrimaryContext) { - localctx = NewPrimaryContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 16, CELParserRULE_primary) - var _la int - - p.SetState(180) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - - switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 25, p.GetParserRuleContext()) { - case 1: - localctx = NewIdentOrGlobalCallContext(p, localctx) - p.EnterOuterAlt(localctx, 1) - p.SetState(130) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - - if _la == CELParserDOT { - { - p.SetState(129) - - var _m = p.Match(CELParserDOT) - - localctx.(*IdentOrGlobalCallContext).leadingDot = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - } - { - p.SetState(132) - - var _m = p.Match(CELParserIDENTIFIER) - - localctx.(*IdentOrGlobalCallContext).id = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - p.SetState(138) - p.GetErrorHandler().Sync(p) - - - if p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 16, p.GetParserRuleContext()) == 1 { - { - p.SetState(133) - - var _m = p.Match(CELParserLPAREN) - - localctx.(*IdentOrGlobalCallContext).op = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - p.SetState(135) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - - if ((int64(_la) & ^0x3f) == 0 && ((int64(1) << _la) & 135762105344) != 0) { - { - p.SetState(134) - - var _x = p.ExprList() - - - localctx.(*IdentOrGlobalCallContext).args = _x - } - - } - { - p.SetState(137) - p.Match(CELParserRPAREN) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - } else if p.HasError() { // JIM - goto errorExit - } - - - case 2: - localctx = NewNestedContext(p, localctx) - p.EnterOuterAlt(localctx, 2) - { - p.SetState(140) - p.Match(CELParserLPAREN) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - { - p.SetState(141) - - var _x = p.Expr() - - - localctx.(*NestedContext).e = _x - } - { - p.SetState(142) - p.Match(CELParserRPAREN) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - - case 3: - localctx = NewCreateListContext(p, localctx) - p.EnterOuterAlt(localctx, 3) - { - p.SetState(144) - - var _m = p.Match(CELParserLBRACKET) - - localctx.(*CreateListContext).op = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - p.SetState(146) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - - if ((int64(_la) & ^0x3f) == 0 && ((int64(1) << _la) & 135763153920) != 0) { - { - p.SetState(145) - - var _x = p.ListInit() - - - localctx.(*CreateListContext).elems = _x - } - - } - p.SetState(149) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - - if _la == CELParserCOMMA { - { - p.SetState(148) - p.Match(CELParserCOMMA) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - } - { - p.SetState(151) - p.Match(CELParserRPRACKET) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - - case 4: - localctx = NewCreateStructContext(p, localctx) - p.EnterOuterAlt(localctx, 4) - { - p.SetState(152) - - var _m = p.Match(CELParserLBRACE) - - localctx.(*CreateStructContext).op = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - p.SetState(154) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - - if ((int64(_la) & ^0x3f) == 0 && ((int64(1) << _la) & 135763153920) != 0) { - { - p.SetState(153) - - var _x = p.MapInitializerList() - - - localctx.(*CreateStructContext).entries = _x - } - - } - p.SetState(157) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - - if _la == CELParserCOMMA { - { - p.SetState(156) - p.Match(CELParserCOMMA) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - } - { - p.SetState(159) - p.Match(CELParserRBRACE) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - - case 5: - localctx = NewCreateMessageContext(p, localctx) - p.EnterOuterAlt(localctx, 5) - p.SetState(161) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - - if _la == CELParserDOT { - { - p.SetState(160) - - var _m = p.Match(CELParserDOT) - - localctx.(*CreateMessageContext).leadingDot = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - } - { - p.SetState(163) - - var _m = p.Match(CELParserIDENTIFIER) - - localctx.(*CreateMessageContext)._IDENTIFIER = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - localctx.(*CreateMessageContext).ids = append(localctx.(*CreateMessageContext).ids, localctx.(*CreateMessageContext)._IDENTIFIER) - p.SetState(168) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - - for _la == CELParserDOT { - { - p.SetState(164) - - var _m = p.Match(CELParserDOT) - - localctx.(*CreateMessageContext).s16 = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - localctx.(*CreateMessageContext).ops = append(localctx.(*CreateMessageContext).ops, localctx.(*CreateMessageContext).s16) - { - p.SetState(165) - - var _m = p.Match(CELParserIDENTIFIER) - - localctx.(*CreateMessageContext)._IDENTIFIER = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - localctx.(*CreateMessageContext).ids = append(localctx.(*CreateMessageContext).ids, localctx.(*CreateMessageContext)._IDENTIFIER) - - - p.SetState(170) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(171) - - var _m = p.Match(CELParserLBRACE) - - localctx.(*CreateMessageContext).op = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - p.SetState(173) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - - if _la == CELParserQUESTIONMARK || _la == CELParserIDENTIFIER { - { - p.SetState(172) - - var _x = p.FieldInitializerList() - - - localctx.(*CreateMessageContext).entries = _x - } - - } - p.SetState(176) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - - if _la == CELParserCOMMA { - { - p.SetState(175) - p.Match(CELParserCOMMA) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - } - { - p.SetState(178) - p.Match(CELParserRBRACE) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - - case 6: - localctx = NewConstantLiteralContext(p, localctx) - p.EnterOuterAlt(localctx, 6) - { - p.SetState(179) - p.Literal() - } - - case antlr.ATNInvalidAltNumber: - goto errorExit - } - - -errorExit: - if p.HasError() { - v := p.GetError() - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - p.SetError(nil) - } - p.ExitRule() - return localctx - goto errorExit // Trick to prevent compiler error if the label is not used -} - - -// IExprListContext is an interface to support dynamic dispatch. -type IExprListContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // Get_expr returns the _expr rule contexts. - Get_expr() IExprContext - - - // Set_expr sets the _expr rule contexts. - Set_expr(IExprContext) - - - // GetE returns the e rule context list. - GetE() []IExprContext - - - // SetE sets the e rule context list. - SetE([]IExprContext) - - - // Getter signatures - AllExpr() []IExprContext - Expr(i int) IExprContext - AllCOMMA() []antlr.TerminalNode - COMMA(i int) antlr.TerminalNode - - // IsExprListContext differentiates from other interfaces. - IsExprListContext() -} - -type ExprListContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser - _expr IExprContext - e []IExprContext -} - -func NewEmptyExprListContext() *ExprListContext { - var p = new(ExprListContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_exprList - return p -} - -func InitEmptyExprListContext(p *ExprListContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_exprList -} - -func (*ExprListContext) IsExprListContext() {} - -func NewExprListContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ExprListContext { - var p = new(ExprListContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = CELParserRULE_exprList - - return p -} - -func (s *ExprListContext) GetParser() antlr.Parser { return s.parser } - -func (s *ExprListContext) Get_expr() IExprContext { return s._expr } - - -func (s *ExprListContext) Set_expr(v IExprContext) { s._expr = v } - - -func (s *ExprListContext) GetE() []IExprContext { return s.e } - - -func (s *ExprListContext) SetE(v []IExprContext) { s.e = v } - - -func (s *ExprListContext) AllExpr() []IExprContext { - children := s.GetChildren() - len := 0 - for _, ctx := range children { - if _, ok := ctx.(IExprContext); ok { - len++ - } - } - - tst := make([]IExprContext, len) - i := 0 - for _, ctx := range children { - if t, ok := ctx.(IExprContext); ok { - tst[i] = t.(IExprContext) - i++ - } - } - - return tst -} - -func (s *ExprListContext) Expr(i int) IExprContext { - var t antlr.RuleContext; - j := 0 - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IExprContext); ok { - if j == i { - t = ctx.(antlr.RuleContext); - break - } - j++ - } - } - - if t == nil { - return nil - } - - return t.(IExprContext) -} - -func (s *ExprListContext) AllCOMMA() []antlr.TerminalNode { - return s.GetTokens(CELParserCOMMA) -} - -func (s *ExprListContext) COMMA(i int) antlr.TerminalNode { - return s.GetToken(CELParserCOMMA, i) -} - -func (s *ExprListContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *ExprListContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - - -func (s *ExprListContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterExprList(s) - } -} - -func (s *ExprListContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitExprList(s) - } -} - -func (s *ExprListContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitExprList(s) - - default: - return t.VisitChildren(s) - } -} - - - - -func (p *CELParser) ExprList() (localctx IExprListContext) { - localctx = NewExprListContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 18, CELParserRULE_exprList) - var _la int - - p.EnterOuterAlt(localctx, 1) - { - p.SetState(182) - - var _x = p.Expr() - - - localctx.(*ExprListContext)._expr = _x - } - localctx.(*ExprListContext).e = append(localctx.(*ExprListContext).e, localctx.(*ExprListContext)._expr) - p.SetState(187) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - - for _la == CELParserCOMMA { - { - p.SetState(183) - p.Match(CELParserCOMMA) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - { - p.SetState(184) - - var _x = p.Expr() - - - localctx.(*ExprListContext)._expr = _x - } - localctx.(*ExprListContext).e = append(localctx.(*ExprListContext).e, localctx.(*ExprListContext)._expr) - - - p.SetState(189) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - } - - - -errorExit: - if p.HasError() { - v := p.GetError() - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - p.SetError(nil) - } - p.ExitRule() - return localctx - goto errorExit // Trick to prevent compiler error if the label is not used -} - - -// IListInitContext is an interface to support dynamic dispatch. -type IListInitContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // Get_optExpr returns the _optExpr rule contexts. - Get_optExpr() IOptExprContext - - - // Set_optExpr sets the _optExpr rule contexts. - Set_optExpr(IOptExprContext) - - - // GetElems returns the elems rule context list. - GetElems() []IOptExprContext - - - // SetElems sets the elems rule context list. - SetElems([]IOptExprContext) - - - // Getter signatures - AllOptExpr() []IOptExprContext - OptExpr(i int) IOptExprContext - AllCOMMA() []antlr.TerminalNode - COMMA(i int) antlr.TerminalNode - - // IsListInitContext differentiates from other interfaces. - IsListInitContext() -} - -type ListInitContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser - _optExpr IOptExprContext - elems []IOptExprContext -} - -func NewEmptyListInitContext() *ListInitContext { - var p = new(ListInitContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_listInit - return p -} - -func InitEmptyListInitContext(p *ListInitContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_listInit -} - -func (*ListInitContext) IsListInitContext() {} - -func NewListInitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ListInitContext { - var p = new(ListInitContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = CELParserRULE_listInit - - return p -} - -func (s *ListInitContext) GetParser() antlr.Parser { return s.parser } - -func (s *ListInitContext) Get_optExpr() IOptExprContext { return s._optExpr } - - -func (s *ListInitContext) Set_optExpr(v IOptExprContext) { s._optExpr = v } - - -func (s *ListInitContext) GetElems() []IOptExprContext { return s.elems } - - -func (s *ListInitContext) SetElems(v []IOptExprContext) { s.elems = v } - - -func (s *ListInitContext) AllOptExpr() []IOptExprContext { - children := s.GetChildren() - len := 0 - for _, ctx := range children { - if _, ok := ctx.(IOptExprContext); ok { - len++ - } - } - - tst := make([]IOptExprContext, len) - i := 0 - for _, ctx := range children { - if t, ok := ctx.(IOptExprContext); ok { - tst[i] = t.(IOptExprContext) - i++ - } - } - - return tst -} - -func (s *ListInitContext) OptExpr(i int) IOptExprContext { - var t antlr.RuleContext; - j := 0 - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IOptExprContext); ok { - if j == i { - t = ctx.(antlr.RuleContext); - break - } - j++ - } - } - - if t == nil { - return nil - } - - return t.(IOptExprContext) -} - -func (s *ListInitContext) AllCOMMA() []antlr.TerminalNode { - return s.GetTokens(CELParserCOMMA) -} - -func (s *ListInitContext) COMMA(i int) antlr.TerminalNode { - return s.GetToken(CELParserCOMMA, i) -} - -func (s *ListInitContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *ListInitContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - - -func (s *ListInitContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterListInit(s) - } -} - -func (s *ListInitContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitListInit(s) - } -} - -func (s *ListInitContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitListInit(s) - - default: - return t.VisitChildren(s) - } -} - - - - -func (p *CELParser) ListInit() (localctx IListInitContext) { - localctx = NewListInitContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 20, CELParserRULE_listInit) - var _alt int - - p.EnterOuterAlt(localctx, 1) - { - p.SetState(190) - - var _x = p.OptExpr() - - - localctx.(*ListInitContext)._optExpr = _x - } - localctx.(*ListInitContext).elems = append(localctx.(*ListInitContext).elems, localctx.(*ListInitContext)._optExpr) - p.SetState(195) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 27, p.GetParserRuleContext()) - if p.HasError() { - goto errorExit - } - for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { - if _alt == 1 { - { - p.SetState(191) - p.Match(CELParserCOMMA) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - { - p.SetState(192) - - var _x = p.OptExpr() - - - localctx.(*ListInitContext)._optExpr = _x - } - localctx.(*ListInitContext).elems = append(localctx.(*ListInitContext).elems, localctx.(*ListInitContext)._optExpr) - - - } - p.SetState(197) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 27, p.GetParserRuleContext()) - if p.HasError() { - goto errorExit - } - } - - - -errorExit: - if p.HasError() { - v := p.GetError() - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - p.SetError(nil) - } - p.ExitRule() - return localctx - goto errorExit // Trick to prevent compiler error if the label is not used -} - - -// IFieldInitializerListContext is an interface to support dynamic dispatch. -type IFieldInitializerListContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // GetS21 returns the s21 token. - GetS21() antlr.Token - - - // SetS21 sets the s21 token. - SetS21(antlr.Token) - - - // GetCols returns the cols token list. - GetCols() []antlr.Token - - - // SetCols sets the cols token list. - SetCols([]antlr.Token) - - - // Get_optField returns the _optField rule contexts. - Get_optField() IOptFieldContext - - // Get_expr returns the _expr rule contexts. - Get_expr() IExprContext - - - // Set_optField sets the _optField rule contexts. - Set_optField(IOptFieldContext) - - // Set_expr sets the _expr rule contexts. - Set_expr(IExprContext) - - - // GetFields returns the fields rule context list. - GetFields() []IOptFieldContext - - // GetValues returns the values rule context list. - GetValues() []IExprContext - - - // SetFields sets the fields rule context list. - SetFields([]IOptFieldContext) - - // SetValues sets the values rule context list. - SetValues([]IExprContext) - - - // Getter signatures - AllOptField() []IOptFieldContext - OptField(i int) IOptFieldContext - AllCOLON() []antlr.TerminalNode - COLON(i int) antlr.TerminalNode - AllExpr() []IExprContext - Expr(i int) IExprContext - AllCOMMA() []antlr.TerminalNode - COMMA(i int) antlr.TerminalNode - - // IsFieldInitializerListContext differentiates from other interfaces. - IsFieldInitializerListContext() -} - -type FieldInitializerListContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser - _optField IOptFieldContext - fields []IOptFieldContext - s21 antlr.Token - cols []antlr.Token - _expr IExprContext - values []IExprContext -} - -func NewEmptyFieldInitializerListContext() *FieldInitializerListContext { - var p = new(FieldInitializerListContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_fieldInitializerList - return p -} - -func InitEmptyFieldInitializerListContext(p *FieldInitializerListContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_fieldInitializerList -} - -func (*FieldInitializerListContext) IsFieldInitializerListContext() {} - -func NewFieldInitializerListContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *FieldInitializerListContext { - var p = new(FieldInitializerListContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = CELParserRULE_fieldInitializerList - - return p -} - -func (s *FieldInitializerListContext) GetParser() antlr.Parser { return s.parser } - -func (s *FieldInitializerListContext) GetS21() antlr.Token { return s.s21 } - - -func (s *FieldInitializerListContext) SetS21(v antlr.Token) { s.s21 = v } - - -func (s *FieldInitializerListContext) GetCols() []antlr.Token { return s.cols } - - -func (s *FieldInitializerListContext) SetCols(v []antlr.Token) { s.cols = v } - - -func (s *FieldInitializerListContext) Get_optField() IOptFieldContext { return s._optField } - -func (s *FieldInitializerListContext) Get_expr() IExprContext { return s._expr } - - -func (s *FieldInitializerListContext) Set_optField(v IOptFieldContext) { s._optField = v } - -func (s *FieldInitializerListContext) Set_expr(v IExprContext) { s._expr = v } - - -func (s *FieldInitializerListContext) GetFields() []IOptFieldContext { return s.fields } - -func (s *FieldInitializerListContext) GetValues() []IExprContext { return s.values } - - -func (s *FieldInitializerListContext) SetFields(v []IOptFieldContext) { s.fields = v } - -func (s *FieldInitializerListContext) SetValues(v []IExprContext) { s.values = v } - - -func (s *FieldInitializerListContext) AllOptField() []IOptFieldContext { - children := s.GetChildren() - len := 0 - for _, ctx := range children { - if _, ok := ctx.(IOptFieldContext); ok { - len++ - } - } - - tst := make([]IOptFieldContext, len) - i := 0 - for _, ctx := range children { - if t, ok := ctx.(IOptFieldContext); ok { - tst[i] = t.(IOptFieldContext) - i++ - } - } - - return tst -} - -func (s *FieldInitializerListContext) OptField(i int) IOptFieldContext { - var t antlr.RuleContext; - j := 0 - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IOptFieldContext); ok { - if j == i { - t = ctx.(antlr.RuleContext); - break - } - j++ - } - } - - if t == nil { - return nil - } - - return t.(IOptFieldContext) -} - -func (s *FieldInitializerListContext) AllCOLON() []antlr.TerminalNode { - return s.GetTokens(CELParserCOLON) -} - -func (s *FieldInitializerListContext) COLON(i int) antlr.TerminalNode { - return s.GetToken(CELParserCOLON, i) -} - -func (s *FieldInitializerListContext) AllExpr() []IExprContext { - children := s.GetChildren() - len := 0 - for _, ctx := range children { - if _, ok := ctx.(IExprContext); ok { - len++ - } - } - - tst := make([]IExprContext, len) - i := 0 - for _, ctx := range children { - if t, ok := ctx.(IExprContext); ok { - tst[i] = t.(IExprContext) - i++ - } - } - - return tst -} - -func (s *FieldInitializerListContext) Expr(i int) IExprContext { - var t antlr.RuleContext; - j := 0 - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IExprContext); ok { - if j == i { - t = ctx.(antlr.RuleContext); - break - } - j++ - } - } - - if t == nil { - return nil - } - - return t.(IExprContext) -} - -func (s *FieldInitializerListContext) AllCOMMA() []antlr.TerminalNode { - return s.GetTokens(CELParserCOMMA) -} - -func (s *FieldInitializerListContext) COMMA(i int) antlr.TerminalNode { - return s.GetToken(CELParserCOMMA, i) -} - -func (s *FieldInitializerListContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *FieldInitializerListContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - - -func (s *FieldInitializerListContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterFieldInitializerList(s) - } -} - -func (s *FieldInitializerListContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitFieldInitializerList(s) - } -} - -func (s *FieldInitializerListContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitFieldInitializerList(s) - - default: - return t.VisitChildren(s) - } -} - - - - -func (p *CELParser) FieldInitializerList() (localctx IFieldInitializerListContext) { - localctx = NewFieldInitializerListContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 22, CELParserRULE_fieldInitializerList) - var _alt int - - p.EnterOuterAlt(localctx, 1) - { - p.SetState(198) - - var _x = p.OptField() - - - localctx.(*FieldInitializerListContext)._optField = _x - } - localctx.(*FieldInitializerListContext).fields = append(localctx.(*FieldInitializerListContext).fields, localctx.(*FieldInitializerListContext)._optField) - { - p.SetState(199) - - var _m = p.Match(CELParserCOLON) - - localctx.(*FieldInitializerListContext).s21 = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - localctx.(*FieldInitializerListContext).cols = append(localctx.(*FieldInitializerListContext).cols, localctx.(*FieldInitializerListContext).s21) - { - p.SetState(200) - - var _x = p.Expr() - - - localctx.(*FieldInitializerListContext)._expr = _x - } - localctx.(*FieldInitializerListContext).values = append(localctx.(*FieldInitializerListContext).values, localctx.(*FieldInitializerListContext)._expr) - p.SetState(208) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 28, p.GetParserRuleContext()) - if p.HasError() { - goto errorExit - } - for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { - if _alt == 1 { - { - p.SetState(201) - p.Match(CELParserCOMMA) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - { - p.SetState(202) - - var _x = p.OptField() - - - localctx.(*FieldInitializerListContext)._optField = _x - } - localctx.(*FieldInitializerListContext).fields = append(localctx.(*FieldInitializerListContext).fields, localctx.(*FieldInitializerListContext)._optField) - { - p.SetState(203) - - var _m = p.Match(CELParserCOLON) - - localctx.(*FieldInitializerListContext).s21 = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - localctx.(*FieldInitializerListContext).cols = append(localctx.(*FieldInitializerListContext).cols, localctx.(*FieldInitializerListContext).s21) - { - p.SetState(204) - - var _x = p.Expr() - - - localctx.(*FieldInitializerListContext)._expr = _x - } - localctx.(*FieldInitializerListContext).values = append(localctx.(*FieldInitializerListContext).values, localctx.(*FieldInitializerListContext)._expr) - - - } - p.SetState(210) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 28, p.GetParserRuleContext()) - if p.HasError() { - goto errorExit - } - } - - - -errorExit: - if p.HasError() { - v := p.GetError() - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - p.SetError(nil) - } - p.ExitRule() - return localctx - goto errorExit // Trick to prevent compiler error if the label is not used -} - - -// IOptFieldContext is an interface to support dynamic dispatch. -type IOptFieldContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // GetOpt returns the opt token. - GetOpt() antlr.Token - - - // SetOpt sets the opt token. - SetOpt(antlr.Token) - - - // Getter signatures - IDENTIFIER() antlr.TerminalNode - QUESTIONMARK() antlr.TerminalNode - - // IsOptFieldContext differentiates from other interfaces. - IsOptFieldContext() -} - -type OptFieldContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser - opt antlr.Token -} - -func NewEmptyOptFieldContext() *OptFieldContext { - var p = new(OptFieldContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_optField - return p -} - -func InitEmptyOptFieldContext(p *OptFieldContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_optField -} - -func (*OptFieldContext) IsOptFieldContext() {} - -func NewOptFieldContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *OptFieldContext { - var p = new(OptFieldContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = CELParserRULE_optField - - return p -} - -func (s *OptFieldContext) GetParser() antlr.Parser { return s.parser } - -func (s *OptFieldContext) GetOpt() antlr.Token { return s.opt } - - -func (s *OptFieldContext) SetOpt(v antlr.Token) { s.opt = v } - - -func (s *OptFieldContext) IDENTIFIER() antlr.TerminalNode { - return s.GetToken(CELParserIDENTIFIER, 0) -} - -func (s *OptFieldContext) QUESTIONMARK() antlr.TerminalNode { - return s.GetToken(CELParserQUESTIONMARK, 0) -} - -func (s *OptFieldContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *OptFieldContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - - -func (s *OptFieldContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterOptField(s) - } -} - -func (s *OptFieldContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitOptField(s) - } -} - -func (s *OptFieldContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitOptField(s) - - default: - return t.VisitChildren(s) - } -} - - - - -func (p *CELParser) OptField() (localctx IOptFieldContext) { - localctx = NewOptFieldContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 24, CELParserRULE_optField) - var _la int - - p.EnterOuterAlt(localctx, 1) - p.SetState(212) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - - if _la == CELParserQUESTIONMARK { - { - p.SetState(211) - - var _m = p.Match(CELParserQUESTIONMARK) - - localctx.(*OptFieldContext).opt = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - } - { - p.SetState(214) - p.Match(CELParserIDENTIFIER) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - - -errorExit: - if p.HasError() { - v := p.GetError() - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - p.SetError(nil) - } - p.ExitRule() - return localctx - goto errorExit // Trick to prevent compiler error if the label is not used -} - - -// IMapInitializerListContext is an interface to support dynamic dispatch. -type IMapInitializerListContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // GetS21 returns the s21 token. - GetS21() antlr.Token - - - // SetS21 sets the s21 token. - SetS21(antlr.Token) - - - // GetCols returns the cols token list. - GetCols() []antlr.Token - - - // SetCols sets the cols token list. - SetCols([]antlr.Token) - - - // Get_optExpr returns the _optExpr rule contexts. - Get_optExpr() IOptExprContext - - // Get_expr returns the _expr rule contexts. - Get_expr() IExprContext - - - // Set_optExpr sets the _optExpr rule contexts. - Set_optExpr(IOptExprContext) - - // Set_expr sets the _expr rule contexts. - Set_expr(IExprContext) - - - // GetKeys returns the keys rule context list. - GetKeys() []IOptExprContext - - // GetValues returns the values rule context list. - GetValues() []IExprContext - - - // SetKeys sets the keys rule context list. - SetKeys([]IOptExprContext) - - // SetValues sets the values rule context list. - SetValues([]IExprContext) - - - // Getter signatures - AllOptExpr() []IOptExprContext - OptExpr(i int) IOptExprContext - AllCOLON() []antlr.TerminalNode - COLON(i int) antlr.TerminalNode - AllExpr() []IExprContext - Expr(i int) IExprContext - AllCOMMA() []antlr.TerminalNode - COMMA(i int) antlr.TerminalNode - - // IsMapInitializerListContext differentiates from other interfaces. - IsMapInitializerListContext() -} - -type MapInitializerListContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser - _optExpr IOptExprContext - keys []IOptExprContext - s21 antlr.Token - cols []antlr.Token - _expr IExprContext - values []IExprContext -} - -func NewEmptyMapInitializerListContext() *MapInitializerListContext { - var p = new(MapInitializerListContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_mapInitializerList - return p -} - -func InitEmptyMapInitializerListContext(p *MapInitializerListContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_mapInitializerList -} - -func (*MapInitializerListContext) IsMapInitializerListContext() {} - -func NewMapInitializerListContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *MapInitializerListContext { - var p = new(MapInitializerListContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = CELParserRULE_mapInitializerList - - return p -} - -func (s *MapInitializerListContext) GetParser() antlr.Parser { return s.parser } - -func (s *MapInitializerListContext) GetS21() antlr.Token { return s.s21 } - - -func (s *MapInitializerListContext) SetS21(v antlr.Token) { s.s21 = v } - - -func (s *MapInitializerListContext) GetCols() []antlr.Token { return s.cols } - - -func (s *MapInitializerListContext) SetCols(v []antlr.Token) { s.cols = v } - - -func (s *MapInitializerListContext) Get_optExpr() IOptExprContext { return s._optExpr } - -func (s *MapInitializerListContext) Get_expr() IExprContext { return s._expr } - - -func (s *MapInitializerListContext) Set_optExpr(v IOptExprContext) { s._optExpr = v } - -func (s *MapInitializerListContext) Set_expr(v IExprContext) { s._expr = v } - - -func (s *MapInitializerListContext) GetKeys() []IOptExprContext { return s.keys } - -func (s *MapInitializerListContext) GetValues() []IExprContext { return s.values } - - -func (s *MapInitializerListContext) SetKeys(v []IOptExprContext) { s.keys = v } - -func (s *MapInitializerListContext) SetValues(v []IExprContext) { s.values = v } - - -func (s *MapInitializerListContext) AllOptExpr() []IOptExprContext { - children := s.GetChildren() - len := 0 - for _, ctx := range children { - if _, ok := ctx.(IOptExprContext); ok { - len++ - } - } - - tst := make([]IOptExprContext, len) - i := 0 - for _, ctx := range children { - if t, ok := ctx.(IOptExprContext); ok { - tst[i] = t.(IOptExprContext) - i++ - } - } - - return tst -} - -func (s *MapInitializerListContext) OptExpr(i int) IOptExprContext { - var t antlr.RuleContext; - j := 0 - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IOptExprContext); ok { - if j == i { - t = ctx.(antlr.RuleContext); - break - } - j++ - } - } - - if t == nil { - return nil - } - - return t.(IOptExprContext) -} - -func (s *MapInitializerListContext) AllCOLON() []antlr.TerminalNode { - return s.GetTokens(CELParserCOLON) -} - -func (s *MapInitializerListContext) COLON(i int) antlr.TerminalNode { - return s.GetToken(CELParserCOLON, i) -} - -func (s *MapInitializerListContext) AllExpr() []IExprContext { - children := s.GetChildren() - len := 0 - for _, ctx := range children { - if _, ok := ctx.(IExprContext); ok { - len++ - } - } - - tst := make([]IExprContext, len) - i := 0 - for _, ctx := range children { - if t, ok := ctx.(IExprContext); ok { - tst[i] = t.(IExprContext) - i++ - } - } - - return tst -} - -func (s *MapInitializerListContext) Expr(i int) IExprContext { - var t antlr.RuleContext; - j := 0 - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IExprContext); ok { - if j == i { - t = ctx.(antlr.RuleContext); - break - } - j++ - } - } - - if t == nil { - return nil - } - - return t.(IExprContext) -} - -func (s *MapInitializerListContext) AllCOMMA() []antlr.TerminalNode { - return s.GetTokens(CELParserCOMMA) -} - -func (s *MapInitializerListContext) COMMA(i int) antlr.TerminalNode { - return s.GetToken(CELParserCOMMA, i) -} - -func (s *MapInitializerListContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *MapInitializerListContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - - -func (s *MapInitializerListContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterMapInitializerList(s) - } -} - -func (s *MapInitializerListContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitMapInitializerList(s) - } -} - -func (s *MapInitializerListContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitMapInitializerList(s) - - default: - return t.VisitChildren(s) - } -} - - - - -func (p *CELParser) MapInitializerList() (localctx IMapInitializerListContext) { - localctx = NewMapInitializerListContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 26, CELParserRULE_mapInitializerList) - var _alt int - - p.EnterOuterAlt(localctx, 1) - { - p.SetState(216) - - var _x = p.OptExpr() - - - localctx.(*MapInitializerListContext)._optExpr = _x - } - localctx.(*MapInitializerListContext).keys = append(localctx.(*MapInitializerListContext).keys, localctx.(*MapInitializerListContext)._optExpr) - { - p.SetState(217) - - var _m = p.Match(CELParserCOLON) - - localctx.(*MapInitializerListContext).s21 = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - localctx.(*MapInitializerListContext).cols = append(localctx.(*MapInitializerListContext).cols, localctx.(*MapInitializerListContext).s21) - { - p.SetState(218) - - var _x = p.Expr() - - - localctx.(*MapInitializerListContext)._expr = _x - } - localctx.(*MapInitializerListContext).values = append(localctx.(*MapInitializerListContext).values, localctx.(*MapInitializerListContext)._expr) - p.SetState(226) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 30, p.GetParserRuleContext()) - if p.HasError() { - goto errorExit - } - for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { - if _alt == 1 { - { - p.SetState(219) - p.Match(CELParserCOMMA) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - { - p.SetState(220) - - var _x = p.OptExpr() - - - localctx.(*MapInitializerListContext)._optExpr = _x - } - localctx.(*MapInitializerListContext).keys = append(localctx.(*MapInitializerListContext).keys, localctx.(*MapInitializerListContext)._optExpr) - { - p.SetState(221) - - var _m = p.Match(CELParserCOLON) - - localctx.(*MapInitializerListContext).s21 = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - localctx.(*MapInitializerListContext).cols = append(localctx.(*MapInitializerListContext).cols, localctx.(*MapInitializerListContext).s21) - { - p.SetState(222) - - var _x = p.Expr() - - - localctx.(*MapInitializerListContext)._expr = _x - } - localctx.(*MapInitializerListContext).values = append(localctx.(*MapInitializerListContext).values, localctx.(*MapInitializerListContext)._expr) - - - } - p.SetState(228) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 30, p.GetParserRuleContext()) - if p.HasError() { - goto errorExit - } - } - - - -errorExit: - if p.HasError() { - v := p.GetError() - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - p.SetError(nil) - } - p.ExitRule() - return localctx - goto errorExit // Trick to prevent compiler error if the label is not used -} - - -// IOptExprContext is an interface to support dynamic dispatch. -type IOptExprContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // GetOpt returns the opt token. - GetOpt() antlr.Token - - - // SetOpt sets the opt token. - SetOpt(antlr.Token) - - - // GetE returns the e rule contexts. - GetE() IExprContext - - - // SetE sets the e rule contexts. - SetE(IExprContext) - - - // Getter signatures - Expr() IExprContext - QUESTIONMARK() antlr.TerminalNode - - // IsOptExprContext differentiates from other interfaces. - IsOptExprContext() -} - -type OptExprContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser - opt antlr.Token - e IExprContext -} - -func NewEmptyOptExprContext() *OptExprContext { - var p = new(OptExprContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_optExpr - return p -} - -func InitEmptyOptExprContext(p *OptExprContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_optExpr -} - -func (*OptExprContext) IsOptExprContext() {} - -func NewOptExprContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *OptExprContext { - var p = new(OptExprContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = CELParserRULE_optExpr - - return p -} - -func (s *OptExprContext) GetParser() antlr.Parser { return s.parser } - -func (s *OptExprContext) GetOpt() antlr.Token { return s.opt } - - -func (s *OptExprContext) SetOpt(v antlr.Token) { s.opt = v } - - -func (s *OptExprContext) GetE() IExprContext { return s.e } - - -func (s *OptExprContext) SetE(v IExprContext) { s.e = v } - - -func (s *OptExprContext) Expr() IExprContext { - var t antlr.RuleContext; - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IExprContext); ok { - t = ctx.(antlr.RuleContext); - break - } - } - - if t == nil { - return nil - } - - return t.(IExprContext) -} - -func (s *OptExprContext) QUESTIONMARK() antlr.TerminalNode { - return s.GetToken(CELParserQUESTIONMARK, 0) -} - -func (s *OptExprContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *OptExprContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - - -func (s *OptExprContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterOptExpr(s) - } -} - -func (s *OptExprContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitOptExpr(s) - } -} - -func (s *OptExprContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitOptExpr(s) - - default: - return t.VisitChildren(s) - } -} - - - - -func (p *CELParser) OptExpr() (localctx IOptExprContext) { - localctx = NewOptExprContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 28, CELParserRULE_optExpr) - var _la int - - p.EnterOuterAlt(localctx, 1) - p.SetState(230) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - - if _la == CELParserQUESTIONMARK { - { - p.SetState(229) - - var _m = p.Match(CELParserQUESTIONMARK) - - localctx.(*OptExprContext).opt = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - } - { - p.SetState(232) - - var _x = p.Expr() - - - localctx.(*OptExprContext).e = _x - } - - - -errorExit: - if p.HasError() { - v := p.GetError() - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - p.SetError(nil) - } - p.ExitRule() - return localctx - goto errorExit // Trick to prevent compiler error if the label is not used -} - - -// ILiteralContext is an interface to support dynamic dispatch. -type ILiteralContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - // IsLiteralContext differentiates from other interfaces. - IsLiteralContext() -} - -type LiteralContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser -} - -func NewEmptyLiteralContext() *LiteralContext { - var p = new(LiteralContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_literal - return p -} - -func InitEmptyLiteralContext(p *LiteralContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = CELParserRULE_literal -} - -func (*LiteralContext) IsLiteralContext() {} - -func NewLiteralContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *LiteralContext { - var p = new(LiteralContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = CELParserRULE_literal - - return p -} - -func (s *LiteralContext) GetParser() antlr.Parser { return s.parser } - -func (s *LiteralContext) CopyAll(ctx *LiteralContext) { - s.CopyFrom(&ctx.BaseParserRuleContext) -} - -func (s *LiteralContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *LiteralContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - - - - -type BytesContext struct { - LiteralContext - tok antlr.Token -} - -func NewBytesContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BytesContext { - var p = new(BytesContext) - - InitEmptyLiteralContext(&p.LiteralContext) - p.parser = parser - p.CopyAll(ctx.(*LiteralContext)) - - return p -} - - -func (s *BytesContext) GetTok() antlr.Token { return s.tok } - - -func (s *BytesContext) SetTok(v antlr.Token) { s.tok = v } - -func (s *BytesContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *BytesContext) BYTES() antlr.TerminalNode { - return s.GetToken(CELParserBYTES, 0) -} - - -func (s *BytesContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterBytes(s) - } -} - -func (s *BytesContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitBytes(s) - } -} - -func (s *BytesContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitBytes(s) - - default: - return t.VisitChildren(s) - } -} - - -type UintContext struct { - LiteralContext - tok antlr.Token -} - -func NewUintContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *UintContext { - var p = new(UintContext) - - InitEmptyLiteralContext(&p.LiteralContext) - p.parser = parser - p.CopyAll(ctx.(*LiteralContext)) - - return p -} - - -func (s *UintContext) GetTok() antlr.Token { return s.tok } - - -func (s *UintContext) SetTok(v antlr.Token) { s.tok = v } - -func (s *UintContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *UintContext) NUM_UINT() antlr.TerminalNode { - return s.GetToken(CELParserNUM_UINT, 0) -} - - -func (s *UintContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterUint(s) - } -} - -func (s *UintContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitUint(s) - } -} - -func (s *UintContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitUint(s) - - default: - return t.VisitChildren(s) - } -} - - -type NullContext struct { - LiteralContext - tok antlr.Token -} - -func NewNullContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *NullContext { - var p = new(NullContext) - - InitEmptyLiteralContext(&p.LiteralContext) - p.parser = parser - p.CopyAll(ctx.(*LiteralContext)) - - return p -} - - -func (s *NullContext) GetTok() antlr.Token { return s.tok } - - -func (s *NullContext) SetTok(v antlr.Token) { s.tok = v } - -func (s *NullContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *NullContext) NUL() antlr.TerminalNode { - return s.GetToken(CELParserNUL, 0) -} - - -func (s *NullContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterNull(s) - } -} - -func (s *NullContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitNull(s) - } -} - -func (s *NullContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitNull(s) - - default: - return t.VisitChildren(s) - } -} - - -type BoolFalseContext struct { - LiteralContext - tok antlr.Token -} - -func NewBoolFalseContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BoolFalseContext { - var p = new(BoolFalseContext) - - InitEmptyLiteralContext(&p.LiteralContext) - p.parser = parser - p.CopyAll(ctx.(*LiteralContext)) - - return p -} - - -func (s *BoolFalseContext) GetTok() antlr.Token { return s.tok } - - -func (s *BoolFalseContext) SetTok(v antlr.Token) { s.tok = v } - -func (s *BoolFalseContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *BoolFalseContext) CEL_FALSE() antlr.TerminalNode { - return s.GetToken(CELParserCEL_FALSE, 0) -} - - -func (s *BoolFalseContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterBoolFalse(s) - } -} - -func (s *BoolFalseContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitBoolFalse(s) - } -} - -func (s *BoolFalseContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitBoolFalse(s) - - default: - return t.VisitChildren(s) - } -} - - -type StringContext struct { - LiteralContext - tok antlr.Token -} - -func NewStringContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *StringContext { - var p = new(StringContext) - - InitEmptyLiteralContext(&p.LiteralContext) - p.parser = parser - p.CopyAll(ctx.(*LiteralContext)) - - return p -} - - -func (s *StringContext) GetTok() antlr.Token { return s.tok } - - -func (s *StringContext) SetTok(v antlr.Token) { s.tok = v } - -func (s *StringContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *StringContext) STRING() antlr.TerminalNode { - return s.GetToken(CELParserSTRING, 0) -} - - -func (s *StringContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterString(s) - } -} - -func (s *StringContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitString(s) - } -} - -func (s *StringContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitString(s) - - default: - return t.VisitChildren(s) - } -} - - -type DoubleContext struct { - LiteralContext - sign antlr.Token - tok antlr.Token -} - -func NewDoubleContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *DoubleContext { - var p = new(DoubleContext) - - InitEmptyLiteralContext(&p.LiteralContext) - p.parser = parser - p.CopyAll(ctx.(*LiteralContext)) - - return p -} - - -func (s *DoubleContext) GetSign() antlr.Token { return s.sign } - -func (s *DoubleContext) GetTok() antlr.Token { return s.tok } - - -func (s *DoubleContext) SetSign(v antlr.Token) { s.sign = v } - -func (s *DoubleContext) SetTok(v antlr.Token) { s.tok = v } - -func (s *DoubleContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *DoubleContext) NUM_FLOAT() antlr.TerminalNode { - return s.GetToken(CELParserNUM_FLOAT, 0) -} - -func (s *DoubleContext) MINUS() antlr.TerminalNode { - return s.GetToken(CELParserMINUS, 0) -} - - -func (s *DoubleContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterDouble(s) - } -} - -func (s *DoubleContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitDouble(s) - } -} - -func (s *DoubleContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitDouble(s) - - default: - return t.VisitChildren(s) - } -} - - -type BoolTrueContext struct { - LiteralContext - tok antlr.Token -} - -func NewBoolTrueContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BoolTrueContext { - var p = new(BoolTrueContext) - - InitEmptyLiteralContext(&p.LiteralContext) - p.parser = parser - p.CopyAll(ctx.(*LiteralContext)) - - return p -} - - -func (s *BoolTrueContext) GetTok() antlr.Token { return s.tok } - - -func (s *BoolTrueContext) SetTok(v antlr.Token) { s.tok = v } - -func (s *BoolTrueContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *BoolTrueContext) CEL_TRUE() antlr.TerminalNode { - return s.GetToken(CELParserCEL_TRUE, 0) -} - - -func (s *BoolTrueContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterBoolTrue(s) - } -} - -func (s *BoolTrueContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitBoolTrue(s) - } -} - -func (s *BoolTrueContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitBoolTrue(s) - - default: - return t.VisitChildren(s) - } -} - - -type IntContext struct { - LiteralContext - sign antlr.Token - tok antlr.Token -} - -func NewIntContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *IntContext { - var p = new(IntContext) - - InitEmptyLiteralContext(&p.LiteralContext) - p.parser = parser - p.CopyAll(ctx.(*LiteralContext)) - - return p -} - - -func (s *IntContext) GetSign() antlr.Token { return s.sign } - -func (s *IntContext) GetTok() antlr.Token { return s.tok } - - -func (s *IntContext) SetSign(v antlr.Token) { s.sign = v } - -func (s *IntContext) SetTok(v antlr.Token) { s.tok = v } - -func (s *IntContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *IntContext) NUM_INT() antlr.TerminalNode { - return s.GetToken(CELParserNUM_INT, 0) -} - -func (s *IntContext) MINUS() antlr.TerminalNode { - return s.GetToken(CELParserMINUS, 0) -} - - -func (s *IntContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.EnterInt(s) - } -} - -func (s *IntContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(CELListener); ok { - listenerT.ExitInt(s) - } -} - -func (s *IntContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { - switch t := visitor.(type) { - case CELVisitor: - return t.VisitInt(s) - - default: - return t.VisitChildren(s) - } -} - - - -func (p *CELParser) Literal() (localctx ILiteralContext) { - localctx = NewLiteralContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 30, CELParserRULE_literal) - var _la int - - p.SetState(248) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - - switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 34, p.GetParserRuleContext()) { - case 1: - localctx = NewIntContext(p, localctx) - p.EnterOuterAlt(localctx, 1) - p.SetState(235) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - - if _la == CELParserMINUS { - { - p.SetState(234) - - var _m = p.Match(CELParserMINUS) - - localctx.(*IntContext).sign = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - } - { - p.SetState(237) - - var _m = p.Match(CELParserNUM_INT) - - localctx.(*IntContext).tok = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - - case 2: - localctx = NewUintContext(p, localctx) - p.EnterOuterAlt(localctx, 2) - { - p.SetState(238) - - var _m = p.Match(CELParserNUM_UINT) - - localctx.(*UintContext).tok = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - - case 3: - localctx = NewDoubleContext(p, localctx) - p.EnterOuterAlt(localctx, 3) - p.SetState(240) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - - if _la == CELParserMINUS { - { - p.SetState(239) - - var _m = p.Match(CELParserMINUS) - - localctx.(*DoubleContext).sign = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - } - { - p.SetState(242) - - var _m = p.Match(CELParserNUM_FLOAT) - - localctx.(*DoubleContext).tok = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - - case 4: - localctx = NewStringContext(p, localctx) - p.EnterOuterAlt(localctx, 4) - { - p.SetState(243) - - var _m = p.Match(CELParserSTRING) - - localctx.(*StringContext).tok = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - - case 5: - localctx = NewBytesContext(p, localctx) - p.EnterOuterAlt(localctx, 5) - { - p.SetState(244) - - var _m = p.Match(CELParserBYTES) - - localctx.(*BytesContext).tok = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - - case 6: - localctx = NewBoolTrueContext(p, localctx) - p.EnterOuterAlt(localctx, 6) - { - p.SetState(245) - - var _m = p.Match(CELParserCEL_TRUE) - - localctx.(*BoolTrueContext).tok = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - - case 7: - localctx = NewBoolFalseContext(p, localctx) - p.EnterOuterAlt(localctx, 7) - { - p.SetState(246) - - var _m = p.Match(CELParserCEL_FALSE) - - localctx.(*BoolFalseContext).tok = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - - case 8: - localctx = NewNullContext(p, localctx) - p.EnterOuterAlt(localctx, 8) - { - p.SetState(247) - - var _m = p.Match(CELParserNUL) - - localctx.(*NullContext).tok = _m - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - case antlr.ATNInvalidAltNumber: - goto errorExit - } - - -errorExit: - if p.HasError() { - v := p.GetError() - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - p.SetError(nil) - } - p.ExitRule() - return localctx - goto errorExit // Trick to prevent compiler error if the label is not used -} - - -func (p *CELParser) Sempred(localctx antlr.RuleContext, ruleIndex, predIndex int) bool { - switch ruleIndex { - case 4: - var t *RelationContext = nil - if localctx != nil { t = localctx.(*RelationContext) } - return p.Relation_Sempred(t, predIndex) - - case 5: - var t *CalcContext = nil - if localctx != nil { t = localctx.(*CalcContext) } - return p.Calc_Sempred(t, predIndex) - - case 7: - var t *MemberContext = nil - if localctx != nil { t = localctx.(*MemberContext) } - return p.Member_Sempred(t, predIndex) - - - default: - panic("No predicate with index: " + fmt.Sprint(ruleIndex)) - } -} - -func (p *CELParser) Relation_Sempred(localctx antlr.RuleContext, predIndex int) bool { - switch predIndex { - case 0: - return p.Precpred(p.GetParserRuleContext(), 1) - - default: - panic("No predicate with index: " + fmt.Sprint(predIndex)) - } -} - -func (p *CELParser) Calc_Sempred(localctx antlr.RuleContext, predIndex int) bool { - switch predIndex { - case 1: - return p.Precpred(p.GetParserRuleContext(), 2) - - case 2: - return p.Precpred(p.GetParserRuleContext(), 1) - - default: - panic("No predicate with index: " + fmt.Sprint(predIndex)) - } -} - -func (p *CELParser) Member_Sempred(localctx antlr.RuleContext, predIndex int) bool { - switch predIndex { - case 3: - return p.Precpred(p.GetParserRuleContext(), 3) - - case 4: - return p.Precpred(p.GetParserRuleContext(), 2) - - case 5: - return p.Precpred(p.GetParserRuleContext(), 1) - - default: - panic("No predicate with index: " + fmt.Sprint(predIndex)) - } -} - diff --git a/vendor/github.com/google/cel-go/parser/gen/cel_visitor.go b/vendor/github.com/google/cel-go/parser/gen/cel_visitor.go deleted file mode 100644 index d2fbd563a..000000000 --- a/vendor/github.com/google/cel-go/parser/gen/cel_visitor.go +++ /dev/null @@ -1,110 +0,0 @@ -// Code generated from /usr/local/google/home/tswadell/go/src/github.com/google/cel-go/parser/gen/CEL.g4 by ANTLR 4.13.1. DO NOT EDIT. - -package gen // CEL -import "github.com/antlr4-go/antlr/v4" - - -// A complete Visitor for a parse tree produced by CELParser. -type CELVisitor interface { - antlr.ParseTreeVisitor - - // Visit a parse tree produced by CELParser#start. - VisitStart(ctx *StartContext) interface{} - - // Visit a parse tree produced by CELParser#expr. - VisitExpr(ctx *ExprContext) interface{} - - // Visit a parse tree produced by CELParser#conditionalOr. - VisitConditionalOr(ctx *ConditionalOrContext) interface{} - - // Visit a parse tree produced by CELParser#conditionalAnd. - VisitConditionalAnd(ctx *ConditionalAndContext) interface{} - - // Visit a parse tree produced by CELParser#relation. - VisitRelation(ctx *RelationContext) interface{} - - // Visit a parse tree produced by CELParser#calc. - VisitCalc(ctx *CalcContext) interface{} - - // Visit a parse tree produced by CELParser#MemberExpr. - VisitMemberExpr(ctx *MemberExprContext) interface{} - - // Visit a parse tree produced by CELParser#LogicalNot. - VisitLogicalNot(ctx *LogicalNotContext) interface{} - - // Visit a parse tree produced by CELParser#Negate. - VisitNegate(ctx *NegateContext) interface{} - - // Visit a parse tree produced by CELParser#MemberCall. - VisitMemberCall(ctx *MemberCallContext) interface{} - - // Visit a parse tree produced by CELParser#Select. - VisitSelect(ctx *SelectContext) interface{} - - // Visit a parse tree produced by CELParser#PrimaryExpr. - VisitPrimaryExpr(ctx *PrimaryExprContext) interface{} - - // Visit a parse tree produced by CELParser#Index. - VisitIndex(ctx *IndexContext) interface{} - - // Visit a parse tree produced by CELParser#IdentOrGlobalCall. - VisitIdentOrGlobalCall(ctx *IdentOrGlobalCallContext) interface{} - - // Visit a parse tree produced by CELParser#Nested. - VisitNested(ctx *NestedContext) interface{} - - // Visit a parse tree produced by CELParser#CreateList. - VisitCreateList(ctx *CreateListContext) interface{} - - // Visit a parse tree produced by CELParser#CreateStruct. - VisitCreateStruct(ctx *CreateStructContext) interface{} - - // Visit a parse tree produced by CELParser#CreateMessage. - VisitCreateMessage(ctx *CreateMessageContext) interface{} - - // Visit a parse tree produced by CELParser#ConstantLiteral. - VisitConstantLiteral(ctx *ConstantLiteralContext) interface{} - - // Visit a parse tree produced by CELParser#exprList. - VisitExprList(ctx *ExprListContext) interface{} - - // Visit a parse tree produced by CELParser#listInit. - VisitListInit(ctx *ListInitContext) interface{} - - // Visit a parse tree produced by CELParser#fieldInitializerList. - VisitFieldInitializerList(ctx *FieldInitializerListContext) interface{} - - // Visit a parse tree produced by CELParser#optField. - VisitOptField(ctx *OptFieldContext) interface{} - - // Visit a parse tree produced by CELParser#mapInitializerList. - VisitMapInitializerList(ctx *MapInitializerListContext) interface{} - - // Visit a parse tree produced by CELParser#optExpr. - VisitOptExpr(ctx *OptExprContext) interface{} - - // Visit a parse tree produced by CELParser#Int. - VisitInt(ctx *IntContext) interface{} - - // Visit a parse tree produced by CELParser#Uint. - VisitUint(ctx *UintContext) interface{} - - // Visit a parse tree produced by CELParser#Double. - VisitDouble(ctx *DoubleContext) interface{} - - // Visit a parse tree produced by CELParser#String. - VisitString(ctx *StringContext) interface{} - - // Visit a parse tree produced by CELParser#Bytes. - VisitBytes(ctx *BytesContext) interface{} - - // Visit a parse tree produced by CELParser#BoolTrue. - VisitBoolTrue(ctx *BoolTrueContext) interface{} - - // Visit a parse tree produced by CELParser#BoolFalse. - VisitBoolFalse(ctx *BoolFalseContext) interface{} - - // Visit a parse tree produced by CELParser#Null. - VisitNull(ctx *NullContext) interface{} - -} \ No newline at end of file diff --git a/vendor/github.com/google/cel-go/parser/gen/doc.go b/vendor/github.com/google/cel-go/parser/gen/doc.go deleted file mode 100644 index 57edd4434..000000000 --- a/vendor/github.com/google/cel-go/parser/gen/doc.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package gen contains all of the ANTLR-generated sources used by the cel-go parser. -package gen diff --git a/vendor/github.com/google/cel-go/parser/gen/generate.sh b/vendor/github.com/google/cel-go/parser/gen/generate.sh deleted file mode 100644 index 27a9559f7..000000000 --- a/vendor/github.com/google/cel-go/parser/gen/generate.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -eu -# -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# To regenerate the CEL lexer/parser statically do the following: -# 1. Download the latest anltr tool from https://www.antlr.org/download.html -# 2. Copy the downloaded jar to the gen directory. It will have a name -# like antlr--complete.jar. -# 3. Modify the script below to refer to the current ANTLR version. -# 4. Execute the generation script from the gen directory. -# 5. Delete the jar and commit the regenerated sources. - -#!/bin/sh - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -# Generate AntLR artifacts. -java -Xmx500M -cp ${DIR}/antlr-4.13.1-complete.jar org.antlr.v4.Tool \ - -Dlanguage=Go \ - -package gen \ - -o ${DIR} \ - -visitor ${DIR}/CEL.g4 - diff --git a/vendor/github.com/google/cel-go/parser/helper.go b/vendor/github.com/google/cel-go/parser/helper.go deleted file mode 100644 index 182ff034c..000000000 --- a/vendor/github.com/google/cel-go/parser/helper.go +++ /dev/null @@ -1,474 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package parser - -import ( - "sync" - - antlr "github.com/antlr4-go/antlr/v4" - - "github.com/google/cel-go/common" - "github.com/google/cel-go/common/ast" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/common/types/ref" -) - -type parserHelper struct { - exprFactory ast.ExprFactory - source common.Source - sourceInfo *ast.SourceInfo - nextID int64 -} - -func newParserHelper(source common.Source, fac ast.ExprFactory) *parserHelper { - return &parserHelper{ - exprFactory: fac, - source: source, - sourceInfo: ast.NewSourceInfo(source), - nextID: 1, - } -} - -func (p *parserHelper) getSourceInfo() *ast.SourceInfo { - return p.sourceInfo -} - -func (p *parserHelper) newLiteral(ctx any, value ref.Val) ast.Expr { - return p.exprFactory.NewLiteral(p.newID(ctx), value) -} - -func (p *parserHelper) newLiteralBool(ctx any, value bool) ast.Expr { - return p.newLiteral(ctx, types.Bool(value)) -} - -func (p *parserHelper) newLiteralString(ctx any, value string) ast.Expr { - return p.newLiteral(ctx, types.String(value)) -} - -func (p *parserHelper) newLiteralBytes(ctx any, value []byte) ast.Expr { - return p.newLiteral(ctx, types.Bytes(value)) -} - -func (p *parserHelper) newLiteralInt(ctx any, value int64) ast.Expr { - return p.newLiteral(ctx, types.Int(value)) -} - -func (p *parserHelper) newLiteralUint(ctx any, value uint64) ast.Expr { - return p.newLiteral(ctx, types.Uint(value)) -} - -func (p *parserHelper) newLiteralDouble(ctx any, value float64) ast.Expr { - return p.newLiteral(ctx, types.Double(value)) -} - -func (p *parserHelper) newIdent(ctx any, name string) ast.Expr { - return p.exprFactory.NewIdent(p.newID(ctx), name) -} - -func (p *parserHelper) newSelect(ctx any, operand ast.Expr, field string) ast.Expr { - return p.exprFactory.NewSelect(p.newID(ctx), operand, field) -} - -func (p *parserHelper) newPresenceTest(ctx any, operand ast.Expr, field string) ast.Expr { - return p.exprFactory.NewPresenceTest(p.newID(ctx), operand, field) -} - -func (p *parserHelper) newGlobalCall(ctx any, function string, args ...ast.Expr) ast.Expr { - return p.exprFactory.NewCall(p.newID(ctx), function, args...) -} - -func (p *parserHelper) newReceiverCall(ctx any, function string, target ast.Expr, args ...ast.Expr) ast.Expr { - return p.exprFactory.NewMemberCall(p.newID(ctx), function, target, args...) -} - -func (p *parserHelper) newList(ctx any, elements []ast.Expr, optionals ...int32) ast.Expr { - return p.exprFactory.NewList(p.newID(ctx), elements, optionals) -} - -func (p *parserHelper) newMap(ctx any, entries ...ast.EntryExpr) ast.Expr { - return p.exprFactory.NewMap(p.newID(ctx), entries) -} - -func (p *parserHelper) newMapEntry(entryID int64, key ast.Expr, value ast.Expr, optional bool) ast.EntryExpr { - return p.exprFactory.NewMapEntry(entryID, key, value, optional) -} - -func (p *parserHelper) newObject(ctx any, typeName string, fields ...ast.EntryExpr) ast.Expr { - return p.exprFactory.NewStruct(p.newID(ctx), typeName, fields) -} - -func (p *parserHelper) newObjectField(fieldID int64, field string, value ast.Expr, optional bool) ast.EntryExpr { - return p.exprFactory.NewStructField(fieldID, field, value, optional) -} - -func (p *parserHelper) newComprehension(ctx any, - iterRange ast.Expr, - iterVar string, - accuVar string, - accuInit ast.Expr, - condition ast.Expr, - step ast.Expr, - result ast.Expr) ast.Expr { - return p.exprFactory.NewComprehension( - p.newID(ctx), iterRange, iterVar, accuVar, accuInit, condition, step, result) -} - -func (p *parserHelper) newID(ctx any) int64 { - if id, isID := ctx.(int64); isID { - return id - } - return p.id(ctx) -} - -func (p *parserHelper) newExpr(ctx any) ast.Expr { - return p.exprFactory.NewUnspecifiedExpr(p.newID(ctx)) -} - -func (p *parserHelper) id(ctx any) int64 { - var offset ast.OffsetRange - switch c := ctx.(type) { - case antlr.ParserRuleContext: - start, stop := c.GetStart(), c.GetStop() - if stop == nil { - stop = start - } - offset.Start = p.sourceInfo.ComputeOffset(int32(start.GetLine()), int32(start.GetColumn())) - offset.Stop = p.sourceInfo.ComputeOffset(int32(stop.GetLine()), int32(stop.GetColumn())) - case antlr.Token: - offset.Start = p.sourceInfo.ComputeOffset(int32(c.GetLine()), int32(c.GetColumn())) - offset.Stop = offset.Start - case common.Location: - offset.Start = p.sourceInfo.ComputeOffset(int32(c.Line()), int32(c.Column())) - offset.Stop = offset.Start - case ast.OffsetRange: - offset = c - default: - // This should only happen if the ctx is nil - return -1 - } - id := p.nextID - p.sourceInfo.SetOffsetRange(id, offset) - p.nextID++ - return id -} - -func (p *parserHelper) getLocation(id int64) common.Location { - return p.sourceInfo.GetStartLocation(id) -} - -// buildMacroCallArg iterates the expression and returns a new expression -// where all macros have been replaced by their IDs in MacroCalls -func (p *parserHelper) buildMacroCallArg(expr ast.Expr) ast.Expr { - if _, found := p.sourceInfo.GetMacroCall(expr.ID()); found { - return p.exprFactory.NewUnspecifiedExpr(expr.ID()) - } - - switch expr.Kind() { - case ast.CallKind: - // Iterate the AST from `expr` recursively looking for macros. Because we are at most - // starting from the top level macro, this recursion is bounded by the size of the AST. This - // means that the depth check on the AST during parsing will catch recursion overflows - // before we get to here. - call := expr.AsCall() - macroArgs := make([]ast.Expr, len(call.Args())) - for index, arg := range call.Args() { - macroArgs[index] = p.buildMacroCallArg(arg) - } - if !call.IsMemberFunction() { - return p.exprFactory.NewCall(expr.ID(), call.FunctionName(), macroArgs...) - } - macroTarget := p.buildMacroCallArg(call.Target()) - return p.exprFactory.NewMemberCall(expr.ID(), call.FunctionName(), macroTarget, macroArgs...) - case ast.ListKind: - list := expr.AsList() - macroListArgs := make([]ast.Expr, list.Size()) - for i, elem := range list.Elements() { - macroListArgs[i] = p.buildMacroCallArg(elem) - } - return p.exprFactory.NewList(expr.ID(), macroListArgs, list.OptionalIndices()) - } - return expr -} - -// addMacroCall adds the macro the the MacroCalls map in source info. If a macro has args/subargs/target -// that are macros, their ID will be stored instead for later self-lookups. -func (p *parserHelper) addMacroCall(exprID int64, function string, target ast.Expr, args ...ast.Expr) { - macroArgs := make([]ast.Expr, len(args)) - for index, arg := range args { - macroArgs[index] = p.buildMacroCallArg(arg) - } - if target == nil { - p.sourceInfo.SetMacroCall(exprID, p.exprFactory.NewCall(0, function, macroArgs...)) - return - } - macroTarget := target - if _, found := p.sourceInfo.GetMacroCall(target.ID()); found { - macroTarget = p.exprFactory.NewUnspecifiedExpr(target.ID()) - } else { - macroTarget = p.buildMacroCallArg(target) - } - p.sourceInfo.SetMacroCall(exprID, p.exprFactory.NewMemberCall(0, function, macroTarget, macroArgs...)) -} - -// logicManager compacts logical trees into a more efficient structure which is semantically -// equivalent with how the logic graph is constructed by the ANTLR parser. -// -// The purpose of the logicManager is to ensure a compact serialization format for the logical &&, || -// operators which have a tendency to create long DAGs which are skewed in one direction. Since the -// operators are commutative re-ordering the terms *must not* affect the evaluation result. -// -// The logic manager will either render the terms to N-chained && / || operators as a single logical -// call with N-terms, or will rebalance the tree. Rebalancing the terms is a safe, if somewhat -// controversial choice as it alters the traditional order of execution assumptions present in most -// expressions. -type logicManager struct { - exprFactory ast.ExprFactory - function string - terms []ast.Expr - ops []int64 - variadicASTs bool -} - -// newVariadicLogicManager creates a logic manager instance bound to a specific function and its first term. -func newVariadicLogicManager(fac ast.ExprFactory, function string, term ast.Expr) *logicManager { - return &logicManager{ - exprFactory: fac, - function: function, - terms: []ast.Expr{term}, - ops: []int64{}, - variadicASTs: true, - } -} - -// newBalancingLogicManager creates a logic manager instance bound to a specific function and its first term. -func newBalancingLogicManager(fac ast.ExprFactory, function string, term ast.Expr) *logicManager { - return &logicManager{ - exprFactory: fac, - function: function, - terms: []ast.Expr{term}, - ops: []int64{}, - variadicASTs: false, - } -} - -// addTerm adds an operation identifier and term to the set of terms to be balanced. -func (l *logicManager) addTerm(op int64, term ast.Expr) { - l.terms = append(l.terms, term) - l.ops = append(l.ops, op) -} - -// toExpr renders the logic graph into an Expr value, either balancing a tree of logical -// operations or creating a variadic representation of the logical operator. -func (l *logicManager) toExpr() ast.Expr { - if len(l.terms) == 1 { - return l.terms[0] - } - if l.variadicASTs { - return l.exprFactory.NewCall(l.ops[0], l.function, l.terms...) - } - return l.balancedTree(0, len(l.ops)-1) -} - -// balancedTree recursively balances the terms provided to a commutative operator. -func (l *logicManager) balancedTree(lo, hi int) ast.Expr { - mid := (lo + hi + 1) / 2 - - var left ast.Expr - if mid == lo { - left = l.terms[mid] - } else { - left = l.balancedTree(lo, mid-1) - } - - var right ast.Expr - if mid == hi { - right = l.terms[mid+1] - } else { - right = l.balancedTree(mid+1, hi) - } - return l.exprFactory.NewCall(l.ops[mid], l.function, left, right) -} - -type exprHelper struct { - *parserHelper - id int64 -} - -func (e *exprHelper) nextMacroID() int64 { - return e.parserHelper.id(e.parserHelper.getLocation(e.id)) -} - -// Copy implements the ExprHelper interface method by producing a copy of the input Expr value -// with a fresh set of numeric identifiers the Expr and all its descendants. -func (e *exprHelper) Copy(expr ast.Expr) ast.Expr { - offsetRange, _ := e.parserHelper.sourceInfo.GetOffsetRange(expr.ID()) - copyID := e.parserHelper.newID(offsetRange) - switch expr.Kind() { - case ast.LiteralKind: - return e.exprFactory.NewLiteral(copyID, expr.AsLiteral()) - case ast.IdentKind: - return e.exprFactory.NewIdent(copyID, expr.AsIdent()) - case ast.SelectKind: - sel := expr.AsSelect() - op := e.Copy(sel.Operand()) - if sel.IsTestOnly() { - return e.exprFactory.NewPresenceTest(copyID, op, sel.FieldName()) - } - return e.exprFactory.NewSelect(copyID, op, sel.FieldName()) - case ast.CallKind: - call := expr.AsCall() - args := call.Args() - argsCopy := make([]ast.Expr, len(args)) - for i, arg := range args { - argsCopy[i] = e.Copy(arg) - } - if !call.IsMemberFunction() { - return e.exprFactory.NewCall(copyID, call.FunctionName(), argsCopy...) - } - return e.exprFactory.NewMemberCall(copyID, call.FunctionName(), e.Copy(call.Target()), argsCopy...) - case ast.ListKind: - list := expr.AsList() - elems := list.Elements() - elemsCopy := make([]ast.Expr, len(elems)) - for i, elem := range elems { - elemsCopy[i] = e.Copy(elem) - } - return e.exprFactory.NewList(copyID, elemsCopy, list.OptionalIndices()) - case ast.MapKind: - m := expr.AsMap() - entries := m.Entries() - entriesCopy := make([]ast.EntryExpr, len(entries)) - for i, en := range entries { - entry := en.AsMapEntry() - entryID := e.nextMacroID() - entriesCopy[i] = e.exprFactory.NewMapEntry(entryID, - e.Copy(entry.Key()), e.Copy(entry.Value()), entry.IsOptional()) - } - return e.exprFactory.NewMap(copyID, entriesCopy) - case ast.StructKind: - s := expr.AsStruct() - fields := s.Fields() - fieldsCopy := make([]ast.EntryExpr, len(fields)) - for i, f := range fields { - field := f.AsStructField() - fieldID := e.nextMacroID() - fieldsCopy[i] = e.exprFactory.NewStructField(fieldID, - field.Name(), e.Copy(field.Value()), field.IsOptional()) - } - return e.exprFactory.NewStruct(copyID, s.TypeName(), fieldsCopy) - case ast.ComprehensionKind: - compre := expr.AsComprehension() - iterRange := e.Copy(compre.IterRange()) - accuInit := e.Copy(compre.AccuInit()) - cond := e.Copy(compre.LoopCondition()) - step := e.Copy(compre.LoopStep()) - result := e.Copy(compre.Result()) - return e.exprFactory.NewComprehension(copyID, - iterRange, compre.IterVar(), compre.AccuVar(), accuInit, cond, step, result) - } - return e.exprFactory.NewUnspecifiedExpr(copyID) -} - -// NewLiteral implements the ExprHelper interface method. -func (e *exprHelper) NewLiteral(value ref.Val) ast.Expr { - return e.exprFactory.NewLiteral(e.nextMacroID(), value) -} - -// NewList implements the ExprHelper interface method. -func (e *exprHelper) NewList(elems ...ast.Expr) ast.Expr { - return e.exprFactory.NewList(e.nextMacroID(), elems, []int32{}) -} - -// NewMap implements the ExprHelper interface method. -func (e *exprHelper) NewMap(entries ...ast.EntryExpr) ast.Expr { - return e.exprFactory.NewMap(e.nextMacroID(), entries) -} - -// NewMapEntry implements the ExprHelper interface method. -func (e *exprHelper) NewMapEntry(key ast.Expr, val ast.Expr, optional bool) ast.EntryExpr { - return e.exprFactory.NewMapEntry(e.nextMacroID(), key, val, optional) -} - -// NewStruct implements the ExprHelper interface method. -func (e *exprHelper) NewStruct(typeName string, fieldInits ...ast.EntryExpr) ast.Expr { - return e.exprFactory.NewStruct(e.nextMacroID(), typeName, fieldInits) -} - -// NewStructField implements the ExprHelper interface method. -func (e *exprHelper) NewStructField(field string, init ast.Expr, optional bool) ast.EntryExpr { - return e.exprFactory.NewStructField(e.nextMacroID(), field, init, optional) -} - -// NewComprehension implements the ExprHelper interface method. -func (e *exprHelper) NewComprehension( - iterRange ast.Expr, - iterVar string, - accuVar string, - accuInit ast.Expr, - condition ast.Expr, - step ast.Expr, - result ast.Expr) ast.Expr { - return e.exprFactory.NewComprehension( - e.nextMacroID(), iterRange, iterVar, accuVar, accuInit, condition, step, result) -} - -// NewIdent implements the ExprHelper interface method. -func (e *exprHelper) NewIdent(name string) ast.Expr { - return e.exprFactory.NewIdent(e.nextMacroID(), name) -} - -// NewAccuIdent implements the ExprHelper interface method. -func (e *exprHelper) NewAccuIdent() ast.Expr { - return e.exprFactory.NewAccuIdent(e.nextMacroID()) -} - -// NewGlobalCall implements the ExprHelper interface method. -func (e *exprHelper) NewCall(function string, args ...ast.Expr) ast.Expr { - return e.exprFactory.NewCall(e.nextMacroID(), function, args...) -} - -// NewMemberCall implements the ExprHelper interface method. -func (e *exprHelper) NewMemberCall(function string, target ast.Expr, args ...ast.Expr) ast.Expr { - return e.exprFactory.NewMemberCall(e.nextMacroID(), function, target, args...) -} - -// NewPresenceTest implements the ExprHelper interface method. -func (e *exprHelper) NewPresenceTest(operand ast.Expr, field string) ast.Expr { - return e.exprFactory.NewPresenceTest(e.nextMacroID(), operand, field) -} - -// NewSelect implements the ExprHelper interface method. -func (e *exprHelper) NewSelect(operand ast.Expr, field string) ast.Expr { - return e.exprFactory.NewSelect(e.nextMacroID(), operand, field) -} - -// OffsetLocation implements the ExprHelper interface method. -func (e *exprHelper) OffsetLocation(exprID int64) common.Location { - return e.parserHelper.sourceInfo.GetStartLocation(exprID) -} - -// NewError associates an error message with a given expression id, populating the source offset location of the error if possible. -func (e *exprHelper) NewError(exprID int64, message string) *common.Error { - return common.NewError(exprID, message, e.OffsetLocation(exprID)) -} - -var ( - // Thread-safe pool of ExprHelper values to minimize alloc overhead of ExprHelper creations. - exprHelperPool = &sync.Pool{ - New: func() any { - return &exprHelper{} - }, - } -) diff --git a/vendor/github.com/google/cel-go/parser/input.go b/vendor/github.com/google/cel-go/parser/input.go deleted file mode 100644 index 44792455d..000000000 --- a/vendor/github.com/google/cel-go/parser/input.go +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package parser - -import ( - antlr "github.com/antlr4-go/antlr/v4" - - "github.com/google/cel-go/common/runes" -) - -type charStream struct { - buf runes.Buffer - pos int - src string -} - -// Consume implements (antlr.CharStream).Consume. -func (c *charStream) Consume() { - if c.pos >= c.buf.Len() { - panic("cannot consume EOF") - } - c.pos++ -} - -// LA implements (antlr.CharStream).LA. -func (c *charStream) LA(offset int) int { - if offset == 0 { - return 0 - } - if offset < 0 { - offset++ - } - pos := c.pos + offset - 1 - if pos < 0 || pos >= c.buf.Len() { - return antlr.TokenEOF - } - return int(c.buf.Get(pos)) -} - -// LT mimics (*antlr.InputStream).LT. -func (c *charStream) LT(offset int) int { - return c.LA(offset) -} - -// Mark implements (antlr.CharStream).Mark. -func (c *charStream) Mark() int { - return -1 -} - -// Release implements (antlr.CharStream).Release. -func (c *charStream) Release(marker int) {} - -// Index implements (antlr.CharStream).Index. -func (c *charStream) Index() int { - return c.pos -} - -// Seek implements (antlr.CharStream).Seek. -func (c *charStream) Seek(index int) { - if index <= c.pos { - c.pos = index - return - } - if index < c.buf.Len() { - c.pos = index - } else { - c.pos = c.buf.Len() - } -} - -// Size implements (antlr.CharStream).Size. -func (c *charStream) Size() int { - return c.buf.Len() -} - -// GetSourceName implements (antlr.CharStream).GetSourceName. -func (c *charStream) GetSourceName() string { - return c.src -} - -// GetText implements (antlr.CharStream).GetText. -func (c *charStream) GetText(start, stop int) string { - if stop >= c.buf.Len() { - stop = c.buf.Len() - 1 - } - if start >= c.buf.Len() { - return "" - } - return c.buf.Slice(start, stop+1) -} - -// GetTextFromTokens implements (antlr.CharStream).GetTextFromTokens. -func (c *charStream) GetTextFromTokens(start, stop antlr.Token) string { - if start != nil && stop != nil { - return c.GetText(start.GetTokenIndex(), stop.GetTokenIndex()) - } - return "" -} - -// GetTextFromInterval implements (antlr.CharStream).GetTextFromInterval. -func (c *charStream) GetTextFromInterval(i antlr.Interval) string { - return c.GetText(i.Start, i.Stop) -} - -// String mimics (*antlr.InputStream).String. -func (c *charStream) String() string { - return c.buf.Slice(0, c.buf.Len()) -} - -var _ antlr.CharStream = &charStream{} - -func newCharStream(buf runes.Buffer, desc string) antlr.CharStream { - return &charStream{ - buf: buf, - src: desc, - } -} diff --git a/vendor/github.com/google/cel-go/parser/macro.go b/vendor/github.com/google/cel-go/parser/macro.go deleted file mode 100644 index 5b1775bed..000000000 --- a/vendor/github.com/google/cel-go/parser/macro.go +++ /dev/null @@ -1,406 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package parser - -import ( - "fmt" - - "github.com/google/cel-go/common" - "github.com/google/cel-go/common/ast" - "github.com/google/cel-go/common/operators" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/common/types/ref" -) - -// NewGlobalMacro creates a Macro for a global function with the specified arg count. -func NewGlobalMacro(function string, argCount int, expander MacroExpander) Macro { - return ¯o{ - function: function, - argCount: argCount, - expander: expander} -} - -// NewReceiverMacro creates a Macro for a receiver function matching the specified arg count. -func NewReceiverMacro(function string, argCount int, expander MacroExpander) Macro { - return ¯o{ - function: function, - argCount: argCount, - expander: expander, - receiverStyle: true} -} - -// NewGlobalVarArgMacro creates a Macro for a global function with a variable arg count. -func NewGlobalVarArgMacro(function string, expander MacroExpander) Macro { - return ¯o{ - function: function, - expander: expander, - varArgStyle: true} -} - -// NewReceiverVarArgMacro creates a Macro for a receiver function matching a variable arg count. -func NewReceiverVarArgMacro(function string, expander MacroExpander) Macro { - return ¯o{ - function: function, - expander: expander, - receiverStyle: true, - varArgStyle: true} -} - -// Macro interface for describing the function signature to match and the MacroExpander to apply. -// -// Note: when a Macro should apply to multiple overloads (based on arg count) of a given function, -// a Macro should be created per arg-count. -type Macro interface { - // Function name to match. - Function() string - - // ArgCount for the function call. - // - // When the macro is a var-arg style macro, the return value will be zero, but the MacroKey - // will contain a `*` where the arg count would have been. - ArgCount() int - - // IsReceiverStyle returns true if the macro matches a receiver style call. - IsReceiverStyle() bool - - // MacroKey returns the macro signatures accepted by this macro. - // - // Format: `::`. - // - // When the macros is a var-arg style macro, the `arg-count` value is represented as a `*`. - MacroKey() string - - // Expander returns the MacroExpander to apply when the macro key matches the parsed call - // signature. - Expander() MacroExpander -} - -// Macro type which declares the function name and arg count expected for the -// macro, as well as a macro expansion function. -type macro struct { - function string - receiverStyle bool - varArgStyle bool - argCount int - expander MacroExpander -} - -// Function returns the macro's function name (i.e. the function whose syntax it mimics). -func (m *macro) Function() string { - return m.function -} - -// ArgCount returns the number of arguments the macro expects. -func (m *macro) ArgCount() int { - return m.argCount -} - -// IsReceiverStyle returns whether the macro is receiver style. -func (m *macro) IsReceiverStyle() bool { - return m.receiverStyle -} - -// Expander implements the Macro interface method. -func (m *macro) Expander() MacroExpander { - return m.expander -} - -// MacroKey implements the Macro interface method. -func (m *macro) MacroKey() string { - if m.varArgStyle { - return makeVarArgMacroKey(m.function, m.receiverStyle) - } - return makeMacroKey(m.function, m.argCount, m.receiverStyle) -} - -func makeMacroKey(name string, args int, receiverStyle bool) string { - return fmt.Sprintf("%s:%d:%v", name, args, receiverStyle) -} - -func makeVarArgMacroKey(name string, receiverStyle bool) string { - return fmt.Sprintf("%s:*:%v", name, receiverStyle) -} - -// MacroExpander converts a call and its associated arguments into a new CEL abstract syntax tree. -// -// If the MacroExpander determines within the implementation that an expansion is not needed it may return -// a nil Expr value to indicate a non-match. However, if an expansion is to be performed, but the arguments -// are not well-formed, the result of the expansion will be an error. -// -// The MacroExpander accepts as arguments a MacroExprHelper as well as the arguments used in the function call -// and produces as output an Expr ast node. -// -// Note: when the Macro.IsReceiverStyle() method returns true, the target argument will be nil. -type MacroExpander func(eh ExprHelper, target ast.Expr, args []ast.Expr) (ast.Expr, *common.Error) - -// ExprHelper assists with the creation of Expr values in a manner which is consistent -// the internal semantics and id generation behaviors of the parser and checker libraries. -type ExprHelper interface { - // Copy the input expression with a brand new set of identifiers. - Copy(ast.Expr) ast.Expr - - // Literal creates an Expr value for a scalar literal value. - NewLiteral(value ref.Val) ast.Expr - - // NewList creates a list literal instruction with an optional set of elements. - NewList(elems ...ast.Expr) ast.Expr - - // NewMap creates a CreateStruct instruction for a map where the map is comprised of the - // optional set of key, value entries. - NewMap(entries ...ast.EntryExpr) ast.Expr - - // NewMapEntry creates a Map Entry for the key, value pair. - NewMapEntry(key ast.Expr, val ast.Expr, optional bool) ast.EntryExpr - - // NewStruct creates a struct literal expression with an optional set of field initializers. - NewStruct(typeName string, fieldInits ...ast.EntryExpr) ast.Expr - - // NewStructField creates a new struct field initializer from the field name and value. - NewStructField(field string, init ast.Expr, optional bool) ast.EntryExpr - - // NewComprehension creates a new comprehension instruction. - // - // - iterRange represents the expression that resolves to a list or map where the elements or - // keys (respectively) will be iterated over. - // - iterVar is the iteration variable name. - // - accuVar is the accumulation variable name, typically parser.AccumulatorName. - // - accuInit is the initial expression whose value will be set for the accuVar prior to - // folding. - // - condition is the expression to test to determine whether to continue folding. - // - step is the expression to evaluation at the conclusion of a single fold iteration. - // - result is the computation to evaluate at the conclusion of the fold. - // - // The accuVar should not shadow variable names that you would like to reference within the - // environment in the step and condition expressions. Presently, the name __result__ is commonly - // used by built-in macros but this may change in the future. - NewComprehension(iterRange ast.Expr, - iterVar string, - accuVar string, - accuInit ast.Expr, - condition ast.Expr, - step ast.Expr, - result ast.Expr) ast.Expr - - // NewIdent creates an identifier Expr value. - NewIdent(name string) ast.Expr - - // NewAccuIdent returns an accumulator identifier for use with comprehension results. - NewAccuIdent() ast.Expr - - // NewCall creates a function call Expr value for a global (free) function. - NewCall(function string, args ...ast.Expr) ast.Expr - - // NewMemberCall creates a function call Expr value for a receiver-style function. - NewMemberCall(function string, target ast.Expr, args ...ast.Expr) ast.Expr - - // NewPresenceTest creates a Select TestOnly Expr value for modelling has() semantics. - NewPresenceTest(operand ast.Expr, field string) ast.Expr - - // NewSelect create a field traversal Expr value. - NewSelect(operand ast.Expr, field string) ast.Expr - - // OffsetLocation returns the Location of the expression identifier. - OffsetLocation(exprID int64) common.Location - - // NewError associates an error message with a given expression id. - NewError(exprID int64, message string) *common.Error -} - -var ( - // HasMacro expands "has(m.f)" which tests the presence of a field, avoiding the need to - // specify the field as a string. - HasMacro = NewGlobalMacro(operators.Has, 1, MakeHas) - - // AllMacro expands "range.all(var, predicate)" into a comprehension which ensures that all - // elements in the range satisfy the predicate. - AllMacro = NewReceiverMacro(operators.All, 2, MakeAll) - - // ExistsMacro expands "range.exists(var, predicate)" into a comprehension which ensures that - // some element in the range satisfies the predicate. - ExistsMacro = NewReceiverMacro(operators.Exists, 2, MakeExists) - - // ExistsOneMacro expands "range.exists_one(var, predicate)", which is true if for exactly one - // element in range the predicate holds. - ExistsOneMacro = NewReceiverMacro(operators.ExistsOne, 2, MakeExistsOne) - - // MapMacro expands "range.map(var, function)" into a comprehension which applies the function - // to each element in the range to produce a new list. - MapMacro = NewReceiverMacro(operators.Map, 2, MakeMap) - - // MapFilterMacro expands "range.map(var, predicate, function)" into a comprehension which - // first filters the elements in the range by the predicate, then applies the transform function - // to produce a new list. - MapFilterMacro = NewReceiverMacro(operators.Map, 3, MakeMap) - - // FilterMacro expands "range.filter(var, predicate)" into a comprehension which filters - // elements in the range, producing a new list from the elements that satisfy the predicate. - FilterMacro = NewReceiverMacro(operators.Filter, 2, MakeFilter) - - // AllMacros includes the list of all spec-supported macros. - AllMacros = []Macro{ - HasMacro, - AllMacro, - ExistsMacro, - ExistsOneMacro, - MapMacro, - MapFilterMacro, - FilterMacro, - } - - // NoMacros list. - NoMacros = []Macro{} -) - -// AccumulatorName is the traditional variable name assigned to the fold accumulator variable. -const AccumulatorName = "__result__" - -type quantifierKind int - -const ( - quantifierAll quantifierKind = iota - quantifierExists - quantifierExistsOne -) - -// MakeAll expands the input call arguments into a comprehension that returns true if all of the -// elements in the range match the predicate expressions: -// .all(, ) -func MakeAll(eh ExprHelper, target ast.Expr, args []ast.Expr) (ast.Expr, *common.Error) { - return makeQuantifier(quantifierAll, eh, target, args) -} - -// MakeExists expands the input call arguments into a comprehension that returns true if any of the -// elements in the range match the predicate expressions: -// .exists(, ) -func MakeExists(eh ExprHelper, target ast.Expr, args []ast.Expr) (ast.Expr, *common.Error) { - return makeQuantifier(quantifierExists, eh, target, args) -} - -// MakeExistsOne expands the input call arguments into a comprehension that returns true if exactly -// one of the elements in the range match the predicate expressions: -// .exists_one(, ) -func MakeExistsOne(eh ExprHelper, target ast.Expr, args []ast.Expr) (ast.Expr, *common.Error) { - return makeQuantifier(quantifierExistsOne, eh, target, args) -} - -// MakeMap expands the input call arguments into a comprehension that transforms each element in the -// input to produce an output list. -// -// There are two call patterns supported by map: -// -// .map(, ) -// .map(, , ) -// -// In the second form only iterVar values which return true when provided to the predicate expression -// are transformed. -func MakeMap(eh ExprHelper, target ast.Expr, args []ast.Expr) (ast.Expr, *common.Error) { - v, found := extractIdent(args[0]) - if !found { - return nil, eh.NewError(args[0].ID(), "argument is not an identifier") - } - - var fn ast.Expr - var filter ast.Expr - - if len(args) == 3 { - filter = args[1] - fn = args[2] - } else { - filter = nil - fn = args[1] - } - - accuExpr := eh.NewAccuIdent() - init := eh.NewList() - condition := eh.NewLiteral(types.True) - step := eh.NewCall(operators.Add, accuExpr, eh.NewList(fn)) - - if filter != nil { - step = eh.NewCall(operators.Conditional, filter, step, accuExpr) - } - return eh.NewComprehension(target, v, AccumulatorName, init, condition, step, accuExpr), nil -} - -// MakeFilter expands the input call arguments into a comprehension which produces a list which contains -// only elements which match the provided predicate expression: -// .filter(, ) -func MakeFilter(eh ExprHelper, target ast.Expr, args []ast.Expr) (ast.Expr, *common.Error) { - v, found := extractIdent(args[0]) - if !found { - return nil, eh.NewError(args[0].ID(), "argument is not an identifier") - } - - filter := args[1] - accuExpr := eh.NewAccuIdent() - init := eh.NewList() - condition := eh.NewLiteral(types.True) - step := eh.NewCall(operators.Add, accuExpr, eh.NewList(args[0])) - step = eh.NewCall(operators.Conditional, filter, step, accuExpr) - return eh.NewComprehension(target, v, AccumulatorName, init, condition, step, accuExpr), nil -} - -// MakeHas expands the input call arguments into a presence test, e.g. has(.field) -func MakeHas(eh ExprHelper, target ast.Expr, args []ast.Expr) (ast.Expr, *common.Error) { - if args[0].Kind() == ast.SelectKind { - s := args[0].AsSelect() - return eh.NewPresenceTest(s.Operand(), s.FieldName()), nil - } - return nil, eh.NewError(args[0].ID(), "invalid argument to has() macro") -} - -func makeQuantifier(kind quantifierKind, eh ExprHelper, target ast.Expr, args []ast.Expr) (ast.Expr, *common.Error) { - v, found := extractIdent(args[0]) - if !found { - return nil, eh.NewError(args[0].ID(), "argument must be a simple name") - } - - var init ast.Expr - var condition ast.Expr - var step ast.Expr - var result ast.Expr - switch kind { - case quantifierAll: - init = eh.NewLiteral(types.True) - condition = eh.NewCall(operators.NotStrictlyFalse, eh.NewAccuIdent()) - step = eh.NewCall(operators.LogicalAnd, eh.NewAccuIdent(), args[1]) - result = eh.NewAccuIdent() - case quantifierExists: - init = eh.NewLiteral(types.False) - condition = eh.NewCall( - operators.NotStrictlyFalse, - eh.NewCall(operators.LogicalNot, eh.NewAccuIdent())) - step = eh.NewCall(operators.LogicalOr, eh.NewAccuIdent(), args[1]) - result = eh.NewAccuIdent() - case quantifierExistsOne: - zeroExpr := eh.NewLiteral(types.Int(0)) - oneExpr := eh.NewLiteral(types.Int(1)) - init = zeroExpr - condition = eh.NewLiteral(types.True) - step = eh.NewCall(operators.Conditional, args[1], - eh.NewCall(operators.Add, eh.NewAccuIdent(), oneExpr), eh.NewAccuIdent()) - result = eh.NewCall(operators.Equals, eh.NewAccuIdent(), oneExpr) - default: - return nil, eh.NewError(args[0].ID(), fmt.Sprintf("unrecognized quantifier '%v'", kind)) - } - return eh.NewComprehension(target, v, AccumulatorName, init, condition, step, result), nil -} - -func extractIdent(e ast.Expr) (string, bool) { - switch e.Kind() { - case ast.IdentKind: - return e.AsIdent(), true - } - return "", false -} diff --git a/vendor/github.com/google/cel-go/parser/options.go b/vendor/github.com/google/cel-go/parser/options.go deleted file mode 100644 index 61fc3adec..000000000 --- a/vendor/github.com/google/cel-go/parser/options.go +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package parser - -import "fmt" - -type options struct { - maxRecursionDepth int - errorReportingLimit int - errorRecoveryTokenLookaheadLimit int - errorRecoveryLimit int - expressionSizeCodePointLimit int - macros map[string]Macro - populateMacroCalls bool - enableOptionalSyntax bool - enableVariadicOperatorASTs bool -} - -// Option configures the behavior of the parser. -type Option func(*options) error - -// MaxRecursionDepth limits the maximum depth the parser will attempt to parse the expression before giving up. -func MaxRecursionDepth(limit int) Option { - return func(opts *options) error { - if limit < -1 { - return fmt.Errorf("max recursion depth must be greater than or equal to -1: %d", limit) - } - opts.maxRecursionDepth = limit - return nil - } -} - -// ErrorRecoveryLookaheadTokenLimit limits the number of lexer tokens that may be considered during error recovery. -// -// Error recovery often involves looking ahead in the input to determine if there's a point at which parsing may -// successfully resume. In some pathological cases, the parser can look through quite a large set of input which -// in turn generates a lot of back-tracking and performance degredation. -// -// The limit must be >= 1, and is recommended to be less than the default of 256. -func ErrorRecoveryLookaheadTokenLimit(limit int) Option { - return func(opts *options) error { - if limit < 1 { - return fmt.Errorf("error recovery lookahead token limit must be at least 1: %d", limit) - } - opts.errorRecoveryTokenLookaheadLimit = limit - return nil - } -} - -// ErrorRecoveryLimit limits the number of attempts the parser will perform to recover from an error. -func ErrorRecoveryLimit(limit int) Option { - return func(opts *options) error { - if limit < -1 { - return fmt.Errorf("error recovery limit must be greater than or equal to -1: %d", limit) - } - opts.errorRecoveryLimit = limit - return nil - } -} - -// ErrorReportingLimit limits the number of syntax error reports before terminating parsing. -// -// The limit must be at least 1. If unset, the limit will be 100. -func ErrorReportingLimit(limit int) Option { - return func(opts *options) error { - if limit < 1 { - return fmt.Errorf("error reporting limit must be at least 1: %d", limit) - } - opts.errorReportingLimit = limit - return nil - } -} - -// ExpressionSizeCodePointLimit is an option which limits the maximum code point count of an -// expression. -func ExpressionSizeCodePointLimit(expressionSizeCodePointLimit int) Option { - return func(opts *options) error { - if expressionSizeCodePointLimit < -1 { - return fmt.Errorf("expression size code point limit must be greater than or equal to -1: %d", expressionSizeCodePointLimit) - } - opts.expressionSizeCodePointLimit = expressionSizeCodePointLimit - return nil - } -} - -// Macros adds the given macros to the parser. -func Macros(macros ...Macro) Option { - return func(opts *options) error { - for _, m := range macros { - if m != nil { - if opts.macros == nil { - opts.macros = make(map[string]Macro) - } - opts.macros[m.MacroKey()] = m - } - } - return nil - } -} - -// PopulateMacroCalls ensures that the original call signatures replaced by expanded macros -// are preserved in the `SourceInfo` of parse result. -func PopulateMacroCalls(populateMacroCalls bool) Option { - return func(opts *options) error { - opts.populateMacroCalls = populateMacroCalls - return nil - } -} - -// EnableOptionalSyntax enables syntax for optional field and index selection. -func EnableOptionalSyntax(optionalSyntax bool) Option { - return func(opts *options) error { - opts.enableOptionalSyntax = optionalSyntax - return nil - } -} - -// EnableVariadicOperatorASTs enables a compact representation of chained like-kind commutative -// operators. e.g. `a || b || c || d` -> `call(op='||', args=[a, b, c, d])` -// -// The benefit of enabling variadic operators ASTs is a more compact representation deeply nested -// logic graphs. -func EnableVariadicOperatorASTs(varArgASTs bool) Option { - return func(opts *options) error { - opts.enableVariadicOperatorASTs = varArgASTs - return nil - } -} diff --git a/vendor/github.com/google/cel-go/parser/parser.go b/vendor/github.com/google/cel-go/parser/parser.go deleted file mode 100644 index cb753df73..000000000 --- a/vendor/github.com/google/cel-go/parser/parser.go +++ /dev/null @@ -1,1008 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package parser declares an expression parser with support for macro -// expansion. -package parser - -import ( - "fmt" - "regexp" - "strconv" - "strings" - - antlr "github.com/antlr4-go/antlr/v4" - - "github.com/google/cel-go/common" - "github.com/google/cel-go/common/ast" - "github.com/google/cel-go/common/operators" - "github.com/google/cel-go/common/runes" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/parser/gen" -) - -// Parser encapsulates the context necessary to perform parsing for different expressions. -type Parser struct { - options -} - -// NewParser builds and returns a new Parser using the provided options. -func NewParser(opts ...Option) (*Parser, error) { - p := &Parser{} - for _, opt := range opts { - if err := opt(&p.options); err != nil { - return nil, err - } - } - if p.errorReportingLimit == 0 { - p.errorReportingLimit = 100 - } - if p.maxRecursionDepth == 0 { - p.maxRecursionDepth = 250 - } - if p.maxRecursionDepth == -1 { - p.maxRecursionDepth = int((^uint(0)) >> 1) - } - if p.errorRecoveryTokenLookaheadLimit == 0 { - p.errorRecoveryTokenLookaheadLimit = 256 - } - if p.errorRecoveryLimit == 0 { - p.errorRecoveryLimit = 30 - } - if p.errorRecoveryLimit == -1 { - p.errorRecoveryLimit = int((^uint(0)) >> 1) - } - if p.expressionSizeCodePointLimit == 0 { - p.expressionSizeCodePointLimit = 100_000 - } - if p.expressionSizeCodePointLimit == -1 { - p.expressionSizeCodePointLimit = int((^uint(0)) >> 1) - } - // Bool is false by default, so populateMacroCalls will be false by default - return p, nil -} - -// mustNewParser does the work of NewParser and panics if an error occurs. -// -// This function is only intended for internal use and is for backwards compatibility in Parse and -// ParseWithMacros, where we know the options will result in an error. -func mustNewParser(opts ...Option) *Parser { - p, err := NewParser(opts...) - if err != nil { - panic(err) - } - return p -} - -// Parse parses the expression represented by source and returns the result. -func (p *Parser) Parse(source common.Source) (*ast.AST, *common.Errors) { - errs := common.NewErrors(source) - fac := ast.NewExprFactory() - impl := parser{ - errors: &parseErrors{errs}, - exprFactory: fac, - helper: newParserHelper(source, fac), - macros: p.macros, - maxRecursionDepth: p.maxRecursionDepth, - errorReportingLimit: p.errorReportingLimit, - errorRecoveryLimit: p.errorRecoveryLimit, - errorRecoveryLookaheadTokenLimit: p.errorRecoveryTokenLookaheadLimit, - populateMacroCalls: p.populateMacroCalls, - enableOptionalSyntax: p.enableOptionalSyntax, - enableVariadicOperatorASTs: p.enableVariadicOperatorASTs, - } - buf, ok := source.(runes.Buffer) - if !ok { - buf = runes.NewBuffer(source.Content()) - } - var out ast.Expr - if buf.Len() > p.expressionSizeCodePointLimit { - out = impl.reportError(common.NoLocation, - "expression code point size exceeds limit: size: %d, limit %d", - buf.Len(), p.expressionSizeCodePointLimit) - } else { - out = impl.parse(buf, source.Description()) - } - return ast.NewAST(out, impl.helper.getSourceInfo()), errs -} - -// reservedIds are not legal to use as variables. We exclude them post-parse, as they *are* valid -// field names for protos, and it would complicate the grammar to distinguish the cases. -var reservedIds = map[string]struct{}{ - "as": {}, - "break": {}, - "const": {}, - "continue": {}, - "else": {}, - "false": {}, - "for": {}, - "function": {}, - "if": {}, - "import": {}, - "in": {}, - "let": {}, - "loop": {}, - "package": {}, - "namespace": {}, - "null": {}, - "return": {}, - "true": {}, - "var": {}, - "void": {}, - "while": {}, -} - -// Parse converts a source input a parsed expression. -// This function calls ParseWithMacros with AllMacros. -// -// Deprecated: Use NewParser().Parse() instead. -func Parse(source common.Source) (*ast.AST, *common.Errors) { - return mustNewParser(Macros(AllMacros...)).Parse(source) -} - -type recursionError struct { - message string -} - -// Error implements error. -func (re *recursionError) Error() string { - return re.message -} - -var _ error = &recursionError{} - -type recursionListener struct { - maxDepth int - ruleTypeDepth map[int]*int -} - -func (rl *recursionListener) VisitTerminal(node antlr.TerminalNode) {} - -func (rl *recursionListener) VisitErrorNode(node antlr.ErrorNode) {} - -func (rl *recursionListener) EnterEveryRule(ctx antlr.ParserRuleContext) { - if ctx == nil { - return - } - ruleIndex := ctx.GetRuleIndex() - depth, found := rl.ruleTypeDepth[ruleIndex] - if !found { - var counter = 1 - rl.ruleTypeDepth[ruleIndex] = &counter - depth = &counter - } else { - *depth++ - } - if *depth > rl.maxDepth { - panic(&recursionError{ - message: fmt.Sprintf("expression recursion limit exceeded: %d", rl.maxDepth), - }) - } -} - -func (rl *recursionListener) ExitEveryRule(ctx antlr.ParserRuleContext) { - if ctx == nil { - return - } - ruleIndex := ctx.GetRuleIndex() - if depth, found := rl.ruleTypeDepth[ruleIndex]; found && *depth > 0 { - *depth-- - } -} - -var _ antlr.ParseTreeListener = &recursionListener{} - -type tooManyErrors struct { - errorReportingLimit int -} - -func (t *tooManyErrors) Error() string { - return fmt.Sprintf("More than %d syntax errors", t.errorReportingLimit) -} - -var _ error = &tooManyErrors{} - -type recoveryLimitError struct { - message string -} - -// Error implements error. -func (rl *recoveryLimitError) Error() string { - return rl.message -} - -type lookaheadLimitError struct { - message string -} - -func (ll *lookaheadLimitError) Error() string { - return ll.message -} - -var _ error = &recoveryLimitError{} - -type recoveryLimitErrorStrategy struct { - *antlr.DefaultErrorStrategy - errorRecoveryLimit int - errorRecoveryTokenLookaheadLimit int - recoveryAttempts int -} - -type lookaheadConsumer struct { - antlr.Parser - errorRecoveryTokenLookaheadLimit int - lookaheadAttempts int -} - -func (lc *lookaheadConsumer) Consume() antlr.Token { - if lc.lookaheadAttempts >= lc.errorRecoveryTokenLookaheadLimit { - panic(&lookaheadLimitError{ - message: fmt.Sprintf("error recovery token lookahead limit exceeded: %d", lc.errorRecoveryTokenLookaheadLimit), - }) - } - lc.lookaheadAttempts++ - return lc.Parser.Consume() -} - -func (rl *recoveryLimitErrorStrategy) Recover(recognizer antlr.Parser, e antlr.RecognitionException) { - rl.checkAttempts(recognizer) - lc := &lookaheadConsumer{Parser: recognizer, errorRecoveryTokenLookaheadLimit: rl.errorRecoveryTokenLookaheadLimit} - rl.DefaultErrorStrategy.Recover(lc, e) -} - -func (rl *recoveryLimitErrorStrategy) RecoverInline(recognizer antlr.Parser) antlr.Token { - rl.checkAttempts(recognizer) - lc := &lookaheadConsumer{Parser: recognizer, errorRecoveryTokenLookaheadLimit: rl.errorRecoveryTokenLookaheadLimit} - return rl.DefaultErrorStrategy.RecoverInline(lc) -} - -func (rl *recoveryLimitErrorStrategy) checkAttempts(recognizer antlr.Parser) { - if rl.recoveryAttempts == rl.errorRecoveryLimit { - rl.recoveryAttempts++ - msg := fmt.Sprintf("error recovery attempt limit exceeded: %d", rl.errorRecoveryLimit) - recognizer.NotifyErrorListeners(msg, nil, nil) - panic(&recoveryLimitError{ - message: msg, - }) - } - rl.recoveryAttempts++ -} - -var _ antlr.ErrorStrategy = &recoveryLimitErrorStrategy{} - -type parser struct { - gen.BaseCELVisitor - errors *parseErrors - exprFactory ast.ExprFactory - helper *parserHelper - macros map[string]Macro - recursionDepth int - errorReports int - maxRecursionDepth int - errorReportingLimit int - errorRecoveryLimit int - errorRecoveryLookaheadTokenLimit int - populateMacroCalls bool - enableOptionalSyntax bool - enableVariadicOperatorASTs bool -} - -var _ gen.CELVisitor = (*parser)(nil) - -func (p *parser) parse(expr runes.Buffer, desc string) ast.Expr { - lexer := gen.NewCELLexer(newCharStream(expr, desc)) - lexer.RemoveErrorListeners() - lexer.AddErrorListener(p) - - prsr := gen.NewCELParser(antlr.NewCommonTokenStream(lexer, 0)) - prsr.RemoveErrorListeners() - - prsrListener := &recursionListener{ - maxDepth: p.maxRecursionDepth, - ruleTypeDepth: map[int]*int{}, - } - - prsr.AddErrorListener(p) - prsr.AddParseListener(prsrListener) - - prsr.SetErrorHandler(&recoveryLimitErrorStrategy{ - DefaultErrorStrategy: antlr.NewDefaultErrorStrategy(), - errorRecoveryLimit: p.errorRecoveryLimit, - errorRecoveryTokenLookaheadLimit: p.errorRecoveryLookaheadTokenLimit, - }) - - defer func() { - if val := recover(); val != nil { - switch err := val.(type) { - case *lookaheadLimitError: - p.errors.internalError(err.Error()) - case *recursionError: - p.errors.internalError(err.Error()) - case *tooManyErrors: - // do nothing - case *recoveryLimitError: - // do nothing, listeners already notified and error reported. - default: - panic(val) - } - } - }() - - return p.Visit(prsr.Start_()).(ast.Expr) -} - -// Visitor implementations. -func (p *parser) Visit(tree antlr.ParseTree) any { - t := unnest(tree) - switch tree := t.(type) { - case *gen.StartContext: - return p.VisitStart(tree) - case *gen.ExprContext: - p.checkAndIncrementRecursionDepth() - out := p.VisitExpr(tree) - p.decrementRecursionDepth() - return out - case *gen.ConditionalAndContext: - return p.VisitConditionalAnd(tree) - case *gen.ConditionalOrContext: - return p.VisitConditionalOr(tree) - case *gen.RelationContext: - p.checkAndIncrementRecursionDepth() - out := p.VisitRelation(tree) - p.decrementRecursionDepth() - return out - case *gen.CalcContext: - p.checkAndIncrementRecursionDepth() - out := p.VisitCalc(tree) - p.decrementRecursionDepth() - return out - case *gen.LogicalNotContext: - return p.VisitLogicalNot(tree) - case *gen.IdentOrGlobalCallContext: - return p.VisitIdentOrGlobalCall(tree) - case *gen.SelectContext: - p.checkAndIncrementRecursionDepth() - out := p.VisitSelect(tree) - p.decrementRecursionDepth() - return out - case *gen.MemberCallContext: - p.checkAndIncrementRecursionDepth() - out := p.VisitMemberCall(tree) - p.decrementRecursionDepth() - return out - case *gen.MapInitializerListContext: - return p.VisitMapInitializerList(tree) - case *gen.NegateContext: - return p.VisitNegate(tree) - case *gen.IndexContext: - p.checkAndIncrementRecursionDepth() - out := p.VisitIndex(tree) - p.decrementRecursionDepth() - return out - case *gen.UnaryContext: - return p.VisitUnary(tree) - case *gen.CreateListContext: - return p.VisitCreateList(tree) - case *gen.CreateMessageContext: - return p.VisitCreateMessage(tree) - case *gen.CreateStructContext: - return p.VisitCreateStruct(tree) - case *gen.IntContext: - return p.VisitInt(tree) - case *gen.UintContext: - return p.VisitUint(tree) - case *gen.DoubleContext: - return p.VisitDouble(tree) - case *gen.StringContext: - return p.VisitString(tree) - case *gen.BytesContext: - return p.VisitBytes(tree) - case *gen.BoolFalseContext: - return p.VisitBoolFalse(tree) - case *gen.BoolTrueContext: - return p.VisitBoolTrue(tree) - case *gen.NullContext: - return p.VisitNull(tree) - } - - // Report at least one error if the parser reaches an unknown parse element. - // Typically, this happens if the parser has already encountered a syntax error elsewhere. - if p.errors.errorCount() == 0 { - txt := "<>" - if t != nil { - txt = fmt.Sprintf("<<%T>>", t) - } - return p.reportError(common.NoLocation, "unknown parse element encountered: %s", txt) - } - return p.helper.newExpr(common.NoLocation) - -} - -// Visit a parse tree produced by CELParser#start. -func (p *parser) VisitStart(ctx *gen.StartContext) any { - return p.Visit(ctx.Expr()) -} - -// Visit a parse tree produced by CELParser#expr. -func (p *parser) VisitExpr(ctx *gen.ExprContext) any { - result := p.Visit(ctx.GetE()).(ast.Expr) - if ctx.GetOp() == nil { - return result - } - opID := p.helper.id(ctx.GetOp()) - ifTrue := p.Visit(ctx.GetE1()).(ast.Expr) - ifFalse := p.Visit(ctx.GetE2()).(ast.Expr) - return p.globalCallOrMacro(opID, operators.Conditional, result, ifTrue, ifFalse) -} - -// Visit a parse tree produced by CELParser#conditionalOr. -func (p *parser) VisitConditionalOr(ctx *gen.ConditionalOrContext) any { - result := p.Visit(ctx.GetE()).(ast.Expr) - l := p.newLogicManager(operators.LogicalOr, result) - rest := ctx.GetE1() - for i, op := range ctx.GetOps() { - if i >= len(rest) { - return p.reportError(ctx, "unexpected character, wanted '||'") - } - next := p.Visit(rest[i]).(ast.Expr) - opID := p.helper.id(op) - l.addTerm(opID, next) - } - return l.toExpr() -} - -// Visit a parse tree produced by CELParser#conditionalAnd. -func (p *parser) VisitConditionalAnd(ctx *gen.ConditionalAndContext) any { - result := p.Visit(ctx.GetE()).(ast.Expr) - l := p.newLogicManager(operators.LogicalAnd, result) - rest := ctx.GetE1() - for i, op := range ctx.GetOps() { - if i >= len(rest) { - return p.reportError(ctx, "unexpected character, wanted '&&'") - } - next := p.Visit(rest[i]).(ast.Expr) - opID := p.helper.id(op) - l.addTerm(opID, next) - } - return l.toExpr() -} - -// Visit a parse tree produced by CELParser#relation. -func (p *parser) VisitRelation(ctx *gen.RelationContext) any { - opText := "" - if ctx.GetOp() != nil { - opText = ctx.GetOp().GetText() - } - if op, found := operators.Find(opText); found { - lhs := p.Visit(ctx.Relation(0)).(ast.Expr) - opID := p.helper.id(ctx.GetOp()) - rhs := p.Visit(ctx.Relation(1)).(ast.Expr) - return p.globalCallOrMacro(opID, op, lhs, rhs) - } - return p.reportError(ctx, "operator not found") -} - -// Visit a parse tree produced by CELParser#calc. -func (p *parser) VisitCalc(ctx *gen.CalcContext) any { - opText := "" - if ctx.GetOp() != nil { - opText = ctx.GetOp().GetText() - } - if op, found := operators.Find(opText); found { - lhs := p.Visit(ctx.Calc(0)).(ast.Expr) - opID := p.helper.id(ctx.GetOp()) - rhs := p.Visit(ctx.Calc(1)).(ast.Expr) - return p.globalCallOrMacro(opID, op, lhs, rhs) - } - return p.reportError(ctx, "operator not found") -} - -func (p *parser) VisitUnary(ctx *gen.UnaryContext) any { - return p.helper.newLiteralString(ctx, "<>") -} - -// Visit a parse tree produced by CELParser#LogicalNot. -func (p *parser) VisitLogicalNot(ctx *gen.LogicalNotContext) any { - if len(ctx.GetOps())%2 == 0 { - return p.Visit(ctx.Member()) - } - opID := p.helper.id(ctx.GetOps()[0]) - target := p.Visit(ctx.Member()).(ast.Expr) - return p.globalCallOrMacro(opID, operators.LogicalNot, target) -} - -func (p *parser) VisitNegate(ctx *gen.NegateContext) any { - if len(ctx.GetOps())%2 == 0 { - return p.Visit(ctx.Member()) - } - opID := p.helper.id(ctx.GetOps()[0]) - target := p.Visit(ctx.Member()).(ast.Expr) - return p.globalCallOrMacro(opID, operators.Negate, target) -} - -// VisitSelect visits a parse tree produced by CELParser#Select. -func (p *parser) VisitSelect(ctx *gen.SelectContext) any { - operand := p.Visit(ctx.Member()).(ast.Expr) - // Handle the error case where no valid identifier is specified. - if ctx.GetId() == nil || ctx.GetOp() == nil { - return p.helper.newExpr(ctx) - } - id := ctx.GetId().GetText() - if ctx.GetOpt() != nil { - if !p.enableOptionalSyntax { - return p.reportError(ctx.GetOp(), "unsupported syntax '.?'") - } - return p.helper.newGlobalCall( - ctx.GetOp(), - operators.OptSelect, - operand, - p.helper.newLiteralString(ctx.GetId(), id)) - } - return p.helper.newSelect(ctx.GetOp(), operand, id) -} - -// VisitMemberCall visits a parse tree produced by CELParser#MemberCall. -func (p *parser) VisitMemberCall(ctx *gen.MemberCallContext) any { - operand := p.Visit(ctx.Member()).(ast.Expr) - // Handle the error case where no valid identifier is specified. - if ctx.GetId() == nil { - return p.helper.newExpr(ctx) - } - id := ctx.GetId().GetText() - opID := p.helper.id(ctx.GetOpen()) - return p.receiverCallOrMacro(opID, id, operand, p.visitExprList(ctx.GetArgs())...) -} - -// Visit a parse tree produced by CELParser#Index. -func (p *parser) VisitIndex(ctx *gen.IndexContext) any { - target := p.Visit(ctx.Member()).(ast.Expr) - // Handle the error case where no valid identifier is specified. - if ctx.GetOp() == nil { - return p.helper.newExpr(ctx) - } - opID := p.helper.id(ctx.GetOp()) - index := p.Visit(ctx.GetIndex()).(ast.Expr) - operator := operators.Index - if ctx.GetOpt() != nil { - if !p.enableOptionalSyntax { - return p.reportError(ctx.GetOp(), "unsupported syntax '[?'") - } - operator = operators.OptIndex - } - return p.globalCallOrMacro(opID, operator, target, index) -} - -// Visit a parse tree produced by CELParser#CreateMessage. -func (p *parser) VisitCreateMessage(ctx *gen.CreateMessageContext) any { - messageName := "" - for _, id := range ctx.GetIds() { - if len(messageName) != 0 { - messageName += "." - } - messageName += id.GetText() - } - if ctx.GetLeadingDot() != nil { - messageName = "." + messageName - } - objID := p.helper.id(ctx.GetOp()) - entries := p.VisitIFieldInitializerList(ctx.GetEntries()).([]ast.EntryExpr) - return p.helper.newObject(objID, messageName, entries...) -} - -// Visit a parse tree of field initializers. -func (p *parser) VisitIFieldInitializerList(ctx gen.IFieldInitializerListContext) any { - if ctx == nil || ctx.GetFields() == nil { - // This is the result of a syntax error handled elswhere, return empty. - return []ast.EntryExpr{} - } - - result := make([]ast.EntryExpr, len(ctx.GetFields())) - cols := ctx.GetCols() - vals := ctx.GetValues() - for i, f := range ctx.GetFields() { - if i >= len(cols) || i >= len(vals) { - // This is the result of a syntax error detected elsewhere. - return []ast.EntryExpr{} - } - initID := p.helper.id(cols[i]) - optField := f.(*gen.OptFieldContext) - optional := optField.GetOpt() != nil - if !p.enableOptionalSyntax && optional { - p.reportError(optField, "unsupported syntax '?'") - continue - } - // The field may be empty due to a prior error. - id := optField.IDENTIFIER() - if id == nil { - return []ast.EntryExpr{} - } - fieldName := id.GetText() - value := p.Visit(vals[i]).(ast.Expr) - field := p.helper.newObjectField(initID, fieldName, value, optional) - result[i] = field - } - return result -} - -// Visit a parse tree produced by CELParser#IdentOrGlobalCall. -func (p *parser) VisitIdentOrGlobalCall(ctx *gen.IdentOrGlobalCallContext) any { - identName := "" - if ctx.GetLeadingDot() != nil { - identName = "." - } - // Handle the error case where no valid identifier is specified. - if ctx.GetId() == nil { - return p.helper.newExpr(ctx) - } - // Handle reserved identifiers. - id := ctx.GetId().GetText() - if _, ok := reservedIds[id]; ok { - return p.reportError(ctx, "reserved identifier: %s", id) - } - identName += id - if ctx.GetOp() != nil { - opID := p.helper.id(ctx.GetOp()) - return p.globalCallOrMacro(opID, identName, p.visitExprList(ctx.GetArgs())...) - } - return p.helper.newIdent(ctx.GetId(), identName) -} - -// Visit a parse tree produced by CELParser#CreateList. -func (p *parser) VisitCreateList(ctx *gen.CreateListContext) any { - listID := p.helper.id(ctx.GetOp()) - elems, optionals := p.visitListInit(ctx.GetElems()) - return p.helper.newList(listID, elems, optionals...) -} - -// Visit a parse tree produced by CELParser#CreateStruct. -func (p *parser) VisitCreateStruct(ctx *gen.CreateStructContext) any { - structID := p.helper.id(ctx.GetOp()) - entries := []ast.EntryExpr{} - if ctx.GetEntries() != nil { - entries = p.Visit(ctx.GetEntries()).([]ast.EntryExpr) - } - return p.helper.newMap(structID, entries...) -} - -// Visit a parse tree produced by CELParser#mapInitializerList. -func (p *parser) VisitMapInitializerList(ctx *gen.MapInitializerListContext) any { - if ctx == nil || ctx.GetKeys() == nil { - // This is the result of a syntax error handled elswhere, return empty. - return []ast.EntryExpr{} - } - - result := make([]ast.EntryExpr, len(ctx.GetCols())) - keys := ctx.GetKeys() - vals := ctx.GetValues() - for i, col := range ctx.GetCols() { - colID := p.helper.id(col) - if i >= len(keys) || i >= len(vals) { - // This is the result of a syntax error detected elsewhere. - return []ast.EntryExpr{} - } - optKey := keys[i] - optional := optKey.GetOpt() != nil - if !p.enableOptionalSyntax && optional { - p.reportError(optKey, "unsupported syntax '?'") - continue - } - key := p.Visit(optKey.GetE()).(ast.Expr) - value := p.Visit(vals[i]).(ast.Expr) - entry := p.helper.newMapEntry(colID, key, value, optional) - result[i] = entry - } - return result -} - -// Visit a parse tree produced by CELParser#Int. -func (p *parser) VisitInt(ctx *gen.IntContext) any { - text := ctx.GetTok().GetText() - base := 10 - if strings.HasPrefix(text, "0x") { - base = 16 - text = text[2:] - } - if ctx.GetSign() != nil { - text = ctx.GetSign().GetText() + text - } - i, err := strconv.ParseInt(text, base, 64) - if err != nil { - return p.reportError(ctx, "invalid int literal") - } - return p.helper.newLiteralInt(ctx, i) -} - -// Visit a parse tree produced by CELParser#Uint. -func (p *parser) VisitUint(ctx *gen.UintContext) any { - text := ctx.GetTok().GetText() - // trim the 'u' designator included in the uint literal. - text = text[:len(text)-1] - base := 10 - if strings.HasPrefix(text, "0x") { - base = 16 - text = text[2:] - } - i, err := strconv.ParseUint(text, base, 64) - if err != nil { - return p.reportError(ctx, "invalid uint literal") - } - return p.helper.newLiteralUint(ctx, i) -} - -// Visit a parse tree produced by CELParser#Double. -func (p *parser) VisitDouble(ctx *gen.DoubleContext) any { - txt := ctx.GetTok().GetText() - if ctx.GetSign() != nil { - txt = ctx.GetSign().GetText() + txt - } - f, err := strconv.ParseFloat(txt, 64) - if err != nil { - return p.reportError(ctx, "invalid double literal") - } - return p.helper.newLiteralDouble(ctx, f) - -} - -// Visit a parse tree produced by CELParser#String. -func (p *parser) VisitString(ctx *gen.StringContext) any { - s := p.unquote(ctx, ctx.GetText(), false) - return p.helper.newLiteralString(ctx, s) -} - -// Visit a parse tree produced by CELParser#Bytes. -func (p *parser) VisitBytes(ctx *gen.BytesContext) any { - b := []byte(p.unquote(ctx, ctx.GetTok().GetText()[1:], true)) - return p.helper.newLiteralBytes(ctx, b) -} - -// Visit a parse tree produced by CELParser#BoolTrue. -func (p *parser) VisitBoolTrue(ctx *gen.BoolTrueContext) any { - return p.helper.newLiteralBool(ctx, true) -} - -// Visit a parse tree produced by CELParser#BoolFalse. -func (p *parser) VisitBoolFalse(ctx *gen.BoolFalseContext) any { - return p.helper.newLiteralBool(ctx, false) -} - -// Visit a parse tree produced by CELParser#Null. -func (p *parser) VisitNull(ctx *gen.NullContext) any { - return p.helper.exprFactory.NewLiteral(p.helper.newID(ctx), types.NullValue) -} - -func (p *parser) visitExprList(ctx gen.IExprListContext) []ast.Expr { - if ctx == nil { - return []ast.Expr{} - } - return p.visitSlice(ctx.GetE()) -} - -func (p *parser) visitListInit(ctx gen.IListInitContext) ([]ast.Expr, []int32) { - if ctx == nil { - return []ast.Expr{}, []int32{} - } - elements := ctx.GetElems() - result := make([]ast.Expr, len(elements)) - optionals := []int32{} - for i, e := range elements { - ex := p.Visit(e.GetE()).(ast.Expr) - if ex == nil { - return []ast.Expr{}, []int32{} - } - result[i] = ex - if e.GetOpt() != nil { - if !p.enableOptionalSyntax { - p.reportError(e.GetOpt(), "unsupported syntax '?'") - continue - } - optionals = append(optionals, int32(i)) - } - } - return result, optionals -} - -func (p *parser) visitSlice(expressions []gen.IExprContext) []ast.Expr { - if expressions == nil { - return []ast.Expr{} - } - result := make([]ast.Expr, len(expressions)) - for i, e := range expressions { - ex := p.Visit(e).(ast.Expr) - result[i] = ex - } - return result -} - -func (p *parser) unquote(ctx any, value string, isBytes bool) string { - text, err := unescape(value, isBytes) - if err != nil { - p.reportError(ctx, "%s", err.Error()) - return value - } - return text -} - -func (p *parser) newLogicManager(function string, term ast.Expr) *logicManager { - if p.enableVariadicOperatorASTs { - return newVariadicLogicManager(p.exprFactory, function, term) - } - return newBalancingLogicManager(p.exprFactory, function, term) -} - -func (p *parser) reportError(ctx any, format string, args ...any) ast.Expr { - var location common.Location - err := p.helper.newExpr(ctx) - switch c := ctx.(type) { - case common.Location: - location = c - case antlr.Token, antlr.ParserRuleContext: - location = p.helper.getLocation(err.ID()) - } - // Provide arguments to the report error. - p.errors.reportErrorAtID(err.ID(), location, format, args...) - return err -} - -// ANTLR Parse listener implementations -func (p *parser) SyntaxError(recognizer antlr.Recognizer, offendingSymbol any, line, column int, msg string, e antlr.RecognitionException) { - l := p.helper.source.NewLocation(line, column) - // Hack to keep existing error messages consistent with previous versions of CEL when a reserved word - // is used as an identifier. This behavior needs to be overhauled to provide consistent, normalized error - // messages out of ANTLR to prevent future breaking changes related to error message content. - if strings.Contains(msg, "no viable alternative") { - msg = reservedIdentifier.ReplaceAllString(msg, mismatchedReservedIdentifier) - } - // Ensure that no more than 100 syntax errors are reported as this will halt attempts to recover from a - // seriously broken expression. - if p.errorReports < p.errorReportingLimit { - p.errorReports++ - p.errors.syntaxError(l, msg) - } else { - tme := &tooManyErrors{errorReportingLimit: p.errorReportingLimit} - p.errors.syntaxError(l, tme.Error()) - panic(tme) - } -} - -func (p *parser) ReportAmbiguity(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex int, exact bool, ambigAlts *antlr.BitSet, configs *antlr.ATNConfigSet) { - // Intentional -} - -func (p *parser) ReportAttemptingFullContext(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex int, conflictingAlts *antlr.BitSet, configs *antlr.ATNConfigSet) { - // Intentional -} - -func (p *parser) ReportContextSensitivity(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex, prediction int, configs *antlr.ATNConfigSet) { - // Intentional -} - -func (p *parser) globalCallOrMacro(exprID int64, function string, args ...ast.Expr) ast.Expr { - if expr, found := p.expandMacro(exprID, function, nil, args...); found { - return expr - } - return p.helper.newGlobalCall(exprID, function, args...) -} - -func (p *parser) receiverCallOrMacro(exprID int64, function string, target ast.Expr, args ...ast.Expr) ast.Expr { - if expr, found := p.expandMacro(exprID, function, target, args...); found { - return expr - } - return p.helper.newReceiverCall(exprID, function, target, args...) -} - -func (p *parser) expandMacro(exprID int64, function string, target ast.Expr, args ...ast.Expr) (ast.Expr, bool) { - macro, found := p.macros[makeMacroKey(function, len(args), target != nil)] - if !found { - macro, found = p.macros[makeVarArgMacroKey(function, target != nil)] - if !found { - return nil, false - } - } - eh := exprHelperPool.Get().(*exprHelper) - defer exprHelperPool.Put(eh) - eh.parserHelper = p.helper - eh.id = exprID - expr, err := macro.Expander()(eh, target, args) - // An error indicates that the macro was matched, but the arguments were not well-formed. - if err != nil { - if err.Location != nil { - return p.reportError(err.Location, err.Message), true - } - return p.reportError(p.helper.getLocation(exprID), err.Message), true - } - // A nil value from the macro indicates that the macro implementation decided that - // an expansion should not be performed. - if expr == nil { - return nil, false - } - if p.populateMacroCalls { - p.helper.addMacroCall(expr.ID(), function, target, args...) - } - return expr, true -} - -func (p *parser) checkAndIncrementRecursionDepth() { - p.recursionDepth++ - if p.recursionDepth > p.maxRecursionDepth { - panic(&recursionError{message: "max recursion depth exceeded"}) - } -} - -func (p *parser) decrementRecursionDepth() { - p.recursionDepth-- -} - -// unnest traverses down the left-hand side of the parse graph until it encounters the first compound -// parse node or the first leaf in the parse graph. -func unnest(tree antlr.ParseTree) antlr.ParseTree { - for tree != nil { - switch t := tree.(type) { - case *gen.ExprContext: - // conditionalOr op='?' conditionalOr : expr - if t.GetOp() != nil { - return t - } - // conditionalOr - tree = t.GetE() - case *gen.ConditionalOrContext: - // conditionalAnd (ops=|| conditionalAnd)* - if t.GetOps() != nil && len(t.GetOps()) > 0 { - return t - } - // conditionalAnd - tree = t.GetE() - case *gen.ConditionalAndContext: - // relation (ops=&& relation)* - if t.GetOps() != nil && len(t.GetOps()) > 0 { - return t - } - // relation - tree = t.GetE() - case *gen.RelationContext: - // relation op relation - if t.GetOp() != nil { - return t - } - // calc - tree = t.Calc() - case *gen.CalcContext: - // calc op calc - if t.GetOp() != nil { - return t - } - // unary - tree = t.Unary() - case *gen.MemberExprContext: - // member expands to one of: primary, select, index, or create message - tree = t.Member() - case *gen.PrimaryExprContext: - // primary expands to one of identifier, nested, create list, create struct, literal - tree = t.Primary() - case *gen.NestedContext: - // contains a nested 'expr' - tree = t.GetE() - case *gen.ConstantLiteralContext: - // expands to a primitive literal - tree = t.Literal() - default: - return t - } - } - return tree -} - -var ( - reservedIdentifier = regexp.MustCompile("no viable alternative at input '.(true|false|null)'") - mismatchedReservedIdentifier = "mismatched input '$1' expecting IDENTIFIER" -) diff --git a/vendor/github.com/google/cel-go/parser/unescape.go b/vendor/github.com/google/cel-go/parser/unescape.go deleted file mode 100644 index 27c57a9f3..000000000 --- a/vendor/github.com/google/cel-go/parser/unescape.go +++ /dev/null @@ -1,237 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package parser - -import ( - "fmt" - "strings" - "unicode/utf8" -) - -// Unescape takes a quoted string, unquotes, and unescapes it. -// -// This function performs escaping compatible with GoogleSQL. -func unescape(value string, isBytes bool) (string, error) { - // All strings normalize newlines to the \n representation. - value = newlineNormalizer.Replace(value) - n := len(value) - - // Nothing to unescape / decode. - if n < 2 { - return value, fmt.Errorf("unable to unescape string") - } - - // Raw string preceded by the 'r|R' prefix. - isRawLiteral := false - if value[0] == 'r' || value[0] == 'R' { - value = value[1:] - n = len(value) - isRawLiteral = true - } - - // Quoted string of some form, must have same first and last char. - if value[0] != value[n-1] || (value[0] != '"' && value[0] != '\'') { - return value, fmt.Errorf("unable to unescape string") - } - - // Normalize the multi-line CEL string representation to a standard - // Go quoted string. - if n >= 6 { - if strings.HasPrefix(value, "'''") { - if !strings.HasSuffix(value, "'''") { - return value, fmt.Errorf("unable to unescape string") - } - value = "\"" + value[3:n-3] + "\"" - } else if strings.HasPrefix(value, `"""`) { - if !strings.HasSuffix(value, `"""`) { - return value, fmt.Errorf("unable to unescape string") - } - value = "\"" + value[3:n-3] + "\"" - } - n = len(value) - } - value = value[1 : n-1] - // If there is nothing to escape, then return. - if isRawLiteral || !strings.ContainsRune(value, '\\') { - return value, nil - } - - // Otherwise the string contains escape characters. - // The following logic is adapted from `strconv/quote.go` - var runeTmp [utf8.UTFMax]byte - buf := make([]byte, 0, 3*n/2) - for len(value) > 0 { - c, encode, rest, err := unescapeChar(value, isBytes) - if err != nil { - return "", err - } - value = rest - if c < utf8.RuneSelf || !encode { - buf = append(buf, byte(c)) - } else { - n := utf8.EncodeRune(runeTmp[:], c) - buf = append(buf, runeTmp[:n]...) - } - } - return string(buf), nil -} - -// unescapeChar takes a string input and returns the following info: -// -// value - the escaped unicode rune at the front of the string. -// encode - the value should be unicode-encoded -// tail - the remainder of the input string. -// err - error value, if the character could not be unescaped. -// -// When encode is true the return value may still fit within a single byte, -// but unicode encoding is attempted which is more expensive than when the -// value is known to self-represent as a single byte. -// -// If isBytes is set, unescape as a bytes literal so octal and hex escapes -// represent byte values, not unicode code points. -func unescapeChar(s string, isBytes bool) (value rune, encode bool, tail string, err error) { - // 1. Character is not an escape sequence. - switch c := s[0]; { - case c >= utf8.RuneSelf: - r, size := utf8.DecodeRuneInString(s) - return r, true, s[size:], nil - case c != '\\': - return rune(s[0]), false, s[1:], nil - } - - // 2. Last character is the start of an escape sequence. - if len(s) <= 1 { - err = fmt.Errorf("unable to unescape string, found '\\' as last character") - return - } - - c := s[1] - s = s[2:] - // 3. Common escape sequences shared with Google SQL - switch c { - case 'a': - value = '\a' - case 'b': - value = '\b' - case 'f': - value = '\f' - case 'n': - value = '\n' - case 'r': - value = '\r' - case 't': - value = '\t' - case 'v': - value = '\v' - case '\\': - value = '\\' - case '\'': - value = '\'' - case '"': - value = '"' - case '`': - value = '`' - case '?': - value = '?' - - // 4. Unicode escape sequences, reproduced from `strconv/quote.go` - case 'x', 'X', 'u', 'U': - n := 0 - encode = true - switch c { - case 'x', 'X': - n = 2 - encode = !isBytes - case 'u': - n = 4 - if isBytes { - err = fmt.Errorf("unable to unescape string") - return - } - case 'U': - n = 8 - if isBytes { - err = fmt.Errorf("unable to unescape string") - return - } - } - var v rune - if len(s) < n { - err = fmt.Errorf("unable to unescape string") - return - } - for j := 0; j < n; j++ { - x, ok := unhex(s[j]) - if !ok { - err = fmt.Errorf("unable to unescape string") - return - } - v = v<<4 | x - } - s = s[n:] - if !isBytes && v > utf8.MaxRune { - err = fmt.Errorf("unable to unescape string") - return - } - value = v - - // 5. Octal escape sequences, must be three digits \[0-3][0-7][0-7] - case '0', '1', '2', '3': - if len(s) < 2 { - err = fmt.Errorf("unable to unescape octal sequence in string") - return - } - v := rune(c - '0') - for j := 0; j < 2; j++ { - x := s[j] - if x < '0' || x > '7' { - err = fmt.Errorf("unable to unescape octal sequence in string") - return - } - v = v*8 + rune(x-'0') - } - if !isBytes && v > utf8.MaxRune { - err = fmt.Errorf("unable to unescape string") - return - } - value = v - s = s[2:] - encode = !isBytes - - // Unknown escape sequence. - default: - err = fmt.Errorf("unable to unescape string") - } - - tail = s - return -} - -func unhex(b byte) (rune, bool) { - c := rune(b) - switch { - case '0' <= c && c <= '9': - return c - '0', true - case 'a' <= c && c <= 'f': - return c - 'a' + 10, true - case 'A' <= c && c <= 'F': - return c - 'A' + 10, true - } - return 0, false -} - -var ( - newlineNormalizer = strings.NewReplacer("\r\n", "\n", "\r", "\n") -) diff --git a/vendor/github.com/google/cel-go/parser/unparser.go b/vendor/github.com/google/cel-go/parser/unparser.go deleted file mode 100644 index 91cf72944..000000000 --- a/vendor/github.com/google/cel-go/parser/unparser.go +++ /dev/null @@ -1,629 +0,0 @@ -// Copyright 2019 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package parser - -import ( - "errors" - "fmt" - "strconv" - "strings" - - "github.com/google/cel-go/common/ast" - "github.com/google/cel-go/common/operators" - "github.com/google/cel-go/common/types" -) - -// Unparse takes an input expression and source position information and generates a human-readable -// expression. -// -// Note, unparsing an AST will often generate the same expression as was originally parsed, but some -// formatting may be lost in translation, notably: -// -// - All quoted literals are doubled quoted. -// - Byte literals are represented as octal escapes (same as Google SQL). -// - Floating point values are converted to the small number of digits needed to represent the value. -// - Spacing around punctuation marks may be lost. -// - Parentheses will only be applied when they affect operator precedence. -// -// This function optionally takes in one or more UnparserOption to alter the unparsing behavior, such as -// performing word wrapping on expressions. -func Unparse(expr ast.Expr, info *ast.SourceInfo, opts ...UnparserOption) (string, error) { - unparserOpts := &unparserOption{ - wrapOnColumn: defaultWrapOnColumn, - wrapAfterColumnLimit: defaultWrapAfterColumnLimit, - operatorsToWrapOn: defaultOperatorsToWrapOn, - } - - var err error - for _, opt := range opts { - unparserOpts, err = opt(unparserOpts) - if err != nil { - return "", err - } - } - - un := &unparser{ - info: info, - options: unparserOpts, - } - err = un.visit(expr) - if err != nil { - return "", err - } - return un.str.String(), nil -} - -// unparser visits an expression to reconstruct a human-readable string from an AST. -type unparser struct { - str strings.Builder - info *ast.SourceInfo - options *unparserOption - lastWrappedIndex int -} - -func (un *unparser) visit(expr ast.Expr) error { - if expr == nil { - return errors.New("unsupported expression") - } - visited, err := un.visitMaybeMacroCall(expr) - if visited || err != nil { - return err - } - switch expr.Kind() { - case ast.CallKind: - return un.visitCall(expr) - case ast.LiteralKind: - return un.visitConst(expr) - case ast.IdentKind: - return un.visitIdent(expr) - case ast.ListKind: - return un.visitList(expr) - case ast.MapKind: - return un.visitStructMap(expr) - case ast.SelectKind: - return un.visitSelect(expr) - case ast.StructKind: - return un.visitStructMsg(expr) - default: - return fmt.Errorf("unsupported expression: %v", expr) - } -} - -func (un *unparser) visitCall(expr ast.Expr) error { - c := expr.AsCall() - fun := c.FunctionName() - switch fun { - // ternary operator - case operators.Conditional: - return un.visitCallConditional(expr) - // optional select operator - case operators.OptSelect: - return un.visitOptSelect(expr) - // index operator - case operators.Index: - return un.visitCallIndex(expr) - // optional index operator - case operators.OptIndex: - return un.visitCallOptIndex(expr) - // unary operators - case operators.LogicalNot, operators.Negate: - return un.visitCallUnary(expr) - // binary operators - case operators.Add, - operators.Divide, - operators.Equals, - operators.Greater, - operators.GreaterEquals, - operators.In, - operators.Less, - operators.LessEquals, - operators.LogicalAnd, - operators.LogicalOr, - operators.Modulo, - operators.Multiply, - operators.NotEquals, - operators.OldIn, - operators.Subtract: - return un.visitCallBinary(expr) - // standard function calls. - default: - return un.visitCallFunc(expr) - } -} - -func (un *unparser) visitCallBinary(expr ast.Expr) error { - c := expr.AsCall() - fun := c.FunctionName() - args := c.Args() - lhs := args[0] - // add parens if the current operator is lower precedence than the lhs expr operator. - lhsParen := isComplexOperatorWithRespectTo(fun, lhs) - rhs := args[1] - // add parens if the current operator is lower precedence than the rhs expr operator, - // or the same precedence and the operator is left recursive. - rhsParen := isComplexOperatorWithRespectTo(fun, rhs) - if !rhsParen && isLeftRecursive(fun) { - rhsParen = isSamePrecedence(fun, rhs) - } - err := un.visitMaybeNested(lhs, lhsParen) - if err != nil { - return err - } - unmangled, found := operators.FindReverseBinaryOperator(fun) - if !found { - return fmt.Errorf("cannot unmangle operator: %s", fun) - } - - un.writeOperatorWithWrapping(fun, unmangled) - return un.visitMaybeNested(rhs, rhsParen) -} - -func (un *unparser) visitCallConditional(expr ast.Expr) error { - c := expr.AsCall() - args := c.Args() - // add parens if operand is a conditional itself. - nested := isSamePrecedence(operators.Conditional, args[0]) || - isComplexOperator(args[0]) - err := un.visitMaybeNested(args[0], nested) - if err != nil { - return err - } - un.writeOperatorWithWrapping(operators.Conditional, "?") - - // add parens if operand is a conditional itself. - nested = isSamePrecedence(operators.Conditional, args[1]) || - isComplexOperator(args[1]) - err = un.visitMaybeNested(args[1], nested) - if err != nil { - return err - } - - un.str.WriteString(" : ") - // add parens if operand is a conditional itself. - nested = isSamePrecedence(operators.Conditional, args[2]) || - isComplexOperator(args[2]) - - return un.visitMaybeNested(args[2], nested) -} - -func (un *unparser) visitCallFunc(expr ast.Expr) error { - c := expr.AsCall() - fun := c.FunctionName() - args := c.Args() - if c.IsMemberFunction() { - nested := isBinaryOrTernaryOperator(c.Target()) - err := un.visitMaybeNested(c.Target(), nested) - if err != nil { - return err - } - un.str.WriteString(".") - } - un.str.WriteString(fun) - un.str.WriteString("(") - for i, arg := range args { - err := un.visit(arg) - if err != nil { - return err - } - if i < len(args)-1 { - un.str.WriteString(", ") - } - } - un.str.WriteString(")") - return nil -} - -func (un *unparser) visitCallIndex(expr ast.Expr) error { - return un.visitCallIndexInternal(expr, "[") -} - -func (un *unparser) visitCallOptIndex(expr ast.Expr) error { - return un.visitCallIndexInternal(expr, "[?") -} - -func (un *unparser) visitCallIndexInternal(expr ast.Expr, op string) error { - c := expr.AsCall() - args := c.Args() - nested := isBinaryOrTernaryOperator(args[0]) - err := un.visitMaybeNested(args[0], nested) - if err != nil { - return err - } - un.str.WriteString(op) - err = un.visit(args[1]) - if err != nil { - return err - } - un.str.WriteString("]") - return nil -} - -func (un *unparser) visitCallUnary(expr ast.Expr) error { - c := expr.AsCall() - fun := c.FunctionName() - args := c.Args() - unmangled, found := operators.FindReverse(fun) - if !found { - return fmt.Errorf("cannot unmangle operator: %s", fun) - } - un.str.WriteString(unmangled) - nested := isComplexOperator(args[0]) - return un.visitMaybeNested(args[0], nested) -} - -func (un *unparser) visitConst(expr ast.Expr) error { - val := expr.AsLiteral() - switch val := val.(type) { - case types.Bool: - un.str.WriteString(strconv.FormatBool(bool(val))) - case types.Bytes: - // bytes constants are surrounded with b"" - un.str.WriteString(`b"`) - un.str.WriteString(bytesToOctets([]byte(val))) - un.str.WriteString(`"`) - case types.Double: - // represent the float using the minimum required digits - d := strconv.FormatFloat(float64(val), 'g', -1, 64) - un.str.WriteString(d) - if !strings.Contains(d, ".") { - un.str.WriteString(".0") - } - case types.Int: - i := strconv.FormatInt(int64(val), 10) - un.str.WriteString(i) - case types.Null: - un.str.WriteString("null") - case types.String: - // strings will be double quoted with quotes escaped. - un.str.WriteString(strconv.Quote(string(val))) - case types.Uint: - // uint literals have a 'u' suffix. - ui := strconv.FormatUint(uint64(val), 10) - un.str.WriteString(ui) - un.str.WriteString("u") - default: - return fmt.Errorf("unsupported constant: %v", expr) - } - return nil -} - -func (un *unparser) visitIdent(expr ast.Expr) error { - un.str.WriteString(expr.AsIdent()) - return nil -} - -func (un *unparser) visitList(expr ast.Expr) error { - l := expr.AsList() - elems := l.Elements() - optIndices := make(map[int]bool, len(elems)) - for _, idx := range l.OptionalIndices() { - optIndices[int(idx)] = true - } - un.str.WriteString("[") - for i, elem := range elems { - if optIndices[i] { - un.str.WriteString("?") - } - err := un.visit(elem) - if err != nil { - return err - } - if i < len(elems)-1 { - un.str.WriteString(", ") - } - } - un.str.WriteString("]") - return nil -} - -func (un *unparser) visitOptSelect(expr ast.Expr) error { - c := expr.AsCall() - args := c.Args() - operand := args[0] - field := args[1].AsLiteral().(types.String) - return un.visitSelectInternal(operand, false, ".?", string(field)) -} - -func (un *unparser) visitSelect(expr ast.Expr) error { - sel := expr.AsSelect() - return un.visitSelectInternal(sel.Operand(), sel.IsTestOnly(), ".", sel.FieldName()) -} - -func (un *unparser) visitSelectInternal(operand ast.Expr, testOnly bool, op string, field string) error { - // handle the case when the select expression was generated by the has() macro. - if testOnly { - un.str.WriteString("has(") - } - nested := !testOnly && isBinaryOrTernaryOperator(operand) - err := un.visitMaybeNested(operand, nested) - if err != nil { - return err - } - un.str.WriteString(op) - un.str.WriteString(field) - if testOnly { - un.str.WriteString(")") - } - return nil -} - -func (un *unparser) visitStructMsg(expr ast.Expr) error { - m := expr.AsStruct() - fields := m.Fields() - un.str.WriteString(m.TypeName()) - un.str.WriteString("{") - for i, f := range fields { - field := f.AsStructField() - f := field.Name() - if field.IsOptional() { - un.str.WriteString("?") - } - un.str.WriteString(f) - un.str.WriteString(": ") - v := field.Value() - err := un.visit(v) - if err != nil { - return err - } - if i < len(fields)-1 { - un.str.WriteString(", ") - } - } - un.str.WriteString("}") - return nil -} - -func (un *unparser) visitStructMap(expr ast.Expr) error { - m := expr.AsMap() - entries := m.Entries() - un.str.WriteString("{") - for i, e := range entries { - entry := e.AsMapEntry() - k := entry.Key() - if entry.IsOptional() { - un.str.WriteString("?") - } - err := un.visit(k) - if err != nil { - return err - } - un.str.WriteString(": ") - v := entry.Value() - err = un.visit(v) - if err != nil { - return err - } - if i < len(entries)-1 { - un.str.WriteString(", ") - } - } - un.str.WriteString("}") - return nil -} - -func (un *unparser) visitMaybeMacroCall(expr ast.Expr) (bool, error) { - call, found := un.info.GetMacroCall(expr.ID()) - if !found { - return false, nil - } - return true, un.visit(call) -} - -func (un *unparser) visitMaybeNested(expr ast.Expr, nested bool) error { - if nested { - un.str.WriteString("(") - } - err := un.visit(expr) - if err != nil { - return err - } - if nested { - un.str.WriteString(")") - } - return nil -} - -// isLeftRecursive indicates whether the parser resolves the call in a left-recursive manner as -// this can have an effect of how parentheses affect the order of operations in the AST. -func isLeftRecursive(op string) bool { - return op != operators.LogicalAnd && op != operators.LogicalOr -} - -// isSamePrecedence indicates whether the precedence of the input operator is the same as the -// precedence of the (possible) operation represented in the input Expr. -// -// If the expr is not a Call, the result is false. -func isSamePrecedence(op string, expr ast.Expr) bool { - if expr.Kind() != ast.CallKind { - return false - } - c := expr.AsCall() - other := c.FunctionName() - return operators.Precedence(op) == operators.Precedence(other) -} - -// isLowerPrecedence indicates whether the precedence of the input operator is lower precedence -// than the (possible) operation represented in the input Expr. -// -// If the expr is not a Call, the result is false. -func isLowerPrecedence(op string, expr ast.Expr) bool { - c := expr.AsCall() - other := c.FunctionName() - return operators.Precedence(op) < operators.Precedence(other) -} - -// Indicates whether the expr is a complex operator, i.e., a call expression -// with 2 or more arguments. -func isComplexOperator(expr ast.Expr) bool { - if expr.Kind() == ast.CallKind && len(expr.AsCall().Args()) >= 2 { - return true - } - return false -} - -// Indicates whether it is a complex operation compared to another. -// expr is *not* considered complex if it is not a call expression or has -// less than two arguments, or if it has a higher precedence than op. -func isComplexOperatorWithRespectTo(op string, expr ast.Expr) bool { - if expr.Kind() != ast.CallKind || len(expr.AsCall().Args()) < 2 { - return false - } - return isLowerPrecedence(op, expr) -} - -// Indicate whether this is a binary or ternary operator. -func isBinaryOrTernaryOperator(expr ast.Expr) bool { - if expr.Kind() != ast.CallKind || len(expr.AsCall().Args()) < 2 { - return false - } - _, isBinaryOp := operators.FindReverseBinaryOperator(expr.AsCall().FunctionName()) - return isBinaryOp || isSamePrecedence(operators.Conditional, expr) -} - -// bytesToOctets converts byte sequences to a string using a three digit octal encoded value -// per byte. -func bytesToOctets(byteVal []byte) string { - var b strings.Builder - for _, c := range byteVal { - fmt.Fprintf(&b, "\\%03o", c) - } - return b.String() -} - -// writeOperatorWithWrapping outputs the operator and inserts a newline for operators configured -// in the unparser options. -func (un *unparser) writeOperatorWithWrapping(fun string, unmangled string) bool { - _, wrapOperatorExists := un.options.operatorsToWrapOn[fun] - lineLength := un.str.Len() - un.lastWrappedIndex + len(fun) - - if wrapOperatorExists && lineLength >= un.options.wrapOnColumn { - un.lastWrappedIndex = un.str.Len() - // wrapAfterColumnLimit flag dictates whether the newline is placed - // before or after the operator - if un.options.wrapAfterColumnLimit { - // Input: a && b - // Output: a &&\nb - un.str.WriteString(" ") - un.str.WriteString(unmangled) - un.str.WriteString("\n") - } else { - // Input: a && b - // Output: a\n&& b - un.str.WriteString("\n") - un.str.WriteString(unmangled) - un.str.WriteString(" ") - } - return true - } - un.str.WriteString(" ") - un.str.WriteString(unmangled) - un.str.WriteString(" ") - return false -} - -// Defined defaults for the unparser options -var ( - defaultWrapOnColumn = 80 - defaultWrapAfterColumnLimit = true - defaultOperatorsToWrapOn = map[string]bool{ - operators.LogicalAnd: true, - operators.LogicalOr: true, - } -) - -// UnparserOption is a functional option for configuring the output formatting -// of the Unparse function. -type UnparserOption func(*unparserOption) (*unparserOption, error) - -// Internal representation of the UnparserOption type -type unparserOption struct { - wrapOnColumn int - operatorsToWrapOn map[string]bool - wrapAfterColumnLimit bool -} - -// WrapOnColumn wraps the output expression when its string length exceeds a specified limit -// for operators set by WrapOnOperators function or by default, "&&" and "||" will be wrapped. -// -// Example usage: -// -// Unparse(expr, sourceInfo, WrapOnColumn(40), WrapOnOperators(Operators.LogicalAnd)) -// -// This will insert a newline immediately after the logical AND operator for the below example input: -// -// Input: -// 'my-principal-group' in request.auth.claims && request.auth.claims.iat > now - duration('5m') -// -// Output: -// 'my-principal-group' in request.auth.claims && -// request.auth.claims.iat > now - duration('5m') -func WrapOnColumn(col int) UnparserOption { - return func(opt *unparserOption) (*unparserOption, error) { - if col < 1 { - return nil, fmt.Errorf("Invalid unparser option. Wrap column value must be greater than or equal to 1. Got %v instead", col) - } - opt.wrapOnColumn = col - return opt, nil - } -} - -// WrapOnOperators specifies which operators to perform word wrapping on an output expression when its string length -// exceeds the column limit set by WrapOnColumn function. -// -// Word wrapping is supported on non-unary symbolic operators. Refer to operators.go for the full list -// -// This will replace any previously supplied operators instead of merging them. -func WrapOnOperators(symbols ...string) UnparserOption { - return func(opt *unparserOption) (*unparserOption, error) { - opt.operatorsToWrapOn = make(map[string]bool) - for _, symbol := range symbols { - _, found := operators.FindReverse(symbol) - if !found { - return nil, fmt.Errorf("Invalid unparser option. Unsupported operator: %s", symbol) - } - arity := operators.Arity(symbol) - if arity < 2 { - return nil, fmt.Errorf("Invalid unparser option. Unary operators are unsupported: %s", symbol) - } - - opt.operatorsToWrapOn[symbol] = true - } - - return opt, nil - } -} - -// WrapAfterColumnLimit dictates whether to insert a newline before or after the specified operator -// when word wrapping is performed. -// -// Example usage: -// -// Unparse(expr, sourceInfo, WrapOnColumn(40), WrapOnOperators(Operators.LogicalAnd), WrapAfterColumnLimit(false)) -// -// This will insert a newline immediately before the logical AND operator for the below example input, ensuring -// that the length of a line never exceeds the specified column limit: -// -// Input: -// 'my-principal-group' in request.auth.claims && request.auth.claims.iat > now - duration('5m') -// -// Output: -// 'my-principal-group' in request.auth.claims -// && request.auth.claims.iat > now - duration('5m') -func WrapAfterColumnLimit(wrapAfter bool) UnparserOption { - return func(opt *unparserOption) (*unparserOption, error) { - opt.wrapAfterColumnLimit = wrapAfter - return opt, nil - } -} diff --git a/vendor/github.com/h2non/filetype/.editorconfig b/vendor/github.com/h2non/filetype/.editorconfig deleted file mode 100644 index 000dc0a7a..000000000 --- a/vendor/github.com/h2non/filetype/.editorconfig +++ /dev/null @@ -1,12 +0,0 @@ -root = true - -[*] -indent_style = tabs -indent_size = 2 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -[*.md] -trim_trailing_whitespace = false diff --git a/vendor/github.com/h2non/filetype/.gitignore b/vendor/github.com/h2non/filetype/.gitignore deleted file mode 100644 index 6fefe6cce..000000000 --- a/vendor/github.com/h2non/filetype/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -bin -.DS_Store diff --git a/vendor/github.com/h2non/filetype/.travis.yml b/vendor/github.com/h2non/filetype/.travis.yml deleted file mode 100644 index c9cdbc8da..000000000 --- a/vendor/github.com/h2non/filetype/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -language: go -arch: - - AMD64 - - ppc64le -go: - - "1.13" - - "1.14" - -before_install: - - go get -u -v golang.org/x/lint/golint - -script: - - diff -u <(echo -n) <(gofmt -s -d ./) - - diff -u <(echo -n) <(go vet ./...) - - diff -u <(echo -n) <(golint) - - go test -v -race ./... diff --git a/vendor/github.com/h2non/filetype/History.md b/vendor/github.com/h2non/filetype/History.md deleted file mode 100644 index f53f3d241..000000000 --- a/vendor/github.com/h2non/filetype/History.md +++ /dev/null @@ -1,163 +0,0 @@ - -v1.0.3 / 2021-11-21 -=================== - - * fix(#108): add application file matchers - * Merge pull request #106 from hannesbraun/aiff-support - * Add AIFF support - * fix(archive): format issue indentation - * feat(version): bump patch - * Merge pull request #100 from da2018/master - * Enhance Zstd support - * Merge pull request #98 from cfergeau/zstd - * Add zstd support - * Merge pull request #99 from cfergeau/byteprefixmatcher - * Introduce bytePrefixMatcher helper - -v1.1.0 / 2020-06-06 -=================== - - * feat: version bump v1.10 - * feat(ci): add go 1.14 - * Merge pull request #82 from andrewstucki/sqlite-update - * Merge pull request #84 from evanoberholster/master - * Better differentiation: between image/x-canon-cr2 and image/tiff - * Merge pull request #1 from h2non/master - * Update ico filetype per https://www.iana.org/assignments/media-types/image/vnd.microsoft.icon - * Update rar filetype per https://www.iana.org/assignments/media-types/application/vnd.rar - * Update exe filetype per https://www.iana.org/assignments/media-types/application/vnd.microsoft.portable-executable - * Update deb filetype per https://www.iana.org/assignments/media-types/application/vnd.debian.binary-package - * Update sqlite filetype per https://www.iana.org/assignments/media-types/application/vnd.sqlite3 - * Merge pull request #72 from turn88/master - * Update document.go - * Update document.go - * Update document.go - * add matchers for office 2003 - -v1.0.10 / 2019-08-06 -==================== - - * Merge pull request #76 from lex-r/fix-matroska-detection - * fix: mkv and webm types detection - -v1.0.9 / 2019-07-25 -=================== - - * Merge pull request #75 from Trane9991/master - * add video/3gpp support - * fix: use proper iso file mime type - * feat: add iso image format - * Merge pull request #65 from Fentonz/master - * Merge pull request #70 from fanpei91/master - * add image/vnd.dwg to README - * add image/vnd.dwg support - * Added support for .iso files - -v1.0.8 / 2019-02-10 -=================== - - * refactor(images): heic -> heif - * feat(docs): add heif format - * Merge pull request #60 from rikonor/master - * add heif/heic support - * fix(docs): dicom -> dcm - * feat: add dicom type - * Merge pull request #58 from Fentonz/master - * Merge pull request #59 from kmanley/master - * fix example; related to h2non/filetype#43 - * Added DICOM type to archive - - -v1.0.7 / 2019-02-09 -=================== - - * Merge pull request #56 from akupila/wasm - * add wasm to readme - * detect wasm file type - -v1.0.6 / 2019-01-22 -=================== - - * Merge pull request #55 from ivanlemeshev/master - * Added ftypmp4v to MP4 matcher - * Merge pull request #54 from aofei/master - * chore: add support for Go modules - * feat: add support for AAC (audio/aac) - * Merge pull request #53 from lynxbyorion/check-for-docoments - * Added checks for documents. - * Merge pull request #51 from eriken/master - * fixed bad mime and import paths - * Merge pull request #50 from eriken/jpeg2000_support - * fix import paths - * jpeg2000 support - * Merge pull request #47 from Ma124/master - * Merge pull request #49 from amoore614/master - * more robust check for .mov files - * bugfix: reverse order of matcher key list so user registered matchers appear first - * bugfix: store ptr to MatcherKeys in case user registered matchers are used. - * update comment - * Bump buffer size to 8K to allow for more custom file matching - * refactor(readme): update package import path - * Merge pull request #48 from kumakichi/support_msooxml - * do not use v1 - * ok, master already changed travis - * add fixtures, but MatchReader may not work for some msooxml files, 4096 bytes maybe not enough - * support ms ooxml, #40 - * Fixed misspells - * fix(travis): use string notation for matrix items - * Merge pull request #42 from bruth/patch-2 - * refactor(travis): remove Go 1.6, add Go 1.10 - * Change maximum bytes required for detection - * Merge pull request #36 from yiiTT/patch-1 - * Add MP4 dash and additional ISO formats - * Merge pull request #34 from RangelReale/fix-mp4-case - * Merge pull request #32 from yiiTT/fix-m4v - * Fixed mp4 detection case-sensitivity according to http://www.ftyps.com/ - * Fix M4v matcher - -v1.0.5 / 2017-12-12 -=================== - - * Merge pull request #30 from RangelReale/fix_mp4 - * Fix duplicated item in mp4 fix - * Fix MP4 matcher, with information from http://www.file-recovery.com/mp4-signature-format.htm - * Merge pull request #28 from ikovic/master - * Updated file header example. - -v1.0.4 / 2017-11-29 -=================== - - * fix: tests and document types matchers - * refactor(docs): remove codesponsor - * Merge pull request #26 from bienkma/master - * Add support check file type: .doc, .docx, .pptx, .ppt, .xls, .xlsx - * feat(docs): add code sponsor banner - * feat(travis): add go 1.9 - * Merge pull request #24 from strazzere/patch-1 - * Fix typo in unknown - -v1.0.3 / 2017-08-03 -=================== - - * Merge pull request #21 from elemeta/master - * Add Elf file as supported matcher archive type - -v1.0.2 / 2017-07-26 -=================== - - * Merge pull request #20 from marshyski/master - * Added RedHat RPM as supported matcher archive type - * Merge pull request #19 from nlamirault/patch-1 - * Fix typo in documentation - -v1.0.1 / 2017-02-24 -=================== - - * Merge pull request #18 from Impyy/enable-webm - * Enable the webm matcher - * feat(docs): add Go version badge - -1.0.0 / 2016-12-11 -================== - -- Initial stable version (v1.0.0). diff --git a/vendor/github.com/h2non/filetype/LICENSE b/vendor/github.com/h2non/filetype/LICENSE deleted file mode 100644 index 30ede59b6..000000000 --- a/vendor/github.com/h2non/filetype/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -The MIT License - -Copyright (c) Tomas Aparicio - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/h2non/filetype/README.md b/vendor/github.com/h2non/filetype/README.md deleted file mode 100644 index 64033e903..000000000 --- a/vendor/github.com/h2non/filetype/README.md +++ /dev/null @@ -1,294 +0,0 @@ -# filetype [![Build Status](https://travis-ci.org/h2non/filetype.svg)](https://travis-ci.org/h2non/filetype) [![GoDoc](https://godoc.org/github.com/h2non/filetype?status.svg)](https://godoc.org/github.com/h2non/filetype) [![Go Report Card](http://goreportcard.com/badge/h2non/filetype)](http://goreportcard.com/report/h2non/filetype) [![Go Version](https://img.shields.io/badge/go-v1.0+-green.svg?style=flat)](https://github.com/h2non/gentleman) - -Small and dependency free [Go](https://golang.org) package to infer file and MIME type checking the [magic numbers]() signature. - -For SVG file type checking, see [go-is-svg](https://github.com/h2non/go-is-svg) package. Python port: [filetype.py](https://github.com/h2non/filetype.py). - -## Features - -- Supports a [wide range](#supported-types) of file types -- Provides file extension and proper MIME type -- File discovery by extension or MIME type -- File discovery by class (image, video, audio...) -- Provides a bunch of helpers and file matching shortcuts -- [Pluggable](#add-additional-file-type-matchers): add custom new types and matchers -- Simple and semantic API -- [Blazing fast](#benchmarks), even processing large files -- Only first 262 bytes representing the max file header is required, so you can just [pass a slice](#file-header) -- Dependency free (just Go code, no C compilation needed) -- Cross-platform file recognition - -## Installation - -```bash -go get github.com/h2non/filetype -``` - -## API - -See [Godoc](https://godoc.org/github.com/h2non/filetype) reference. - -### Subpackages - -- [`github.com/h2non/filetype/types`](https://godoc.org/github.com/h2non/filetype/types) -- [`github.com/h2non/filetype/matchers`](https://godoc.org/github.com/h2non/filetype/matchers) - -## Examples - -#### Simple file type checking - -```go -package main - -import ( - "fmt" - "io/ioutil" - - "github.com/h2non/filetype" -) - -func main() { - buf, _ := ioutil.ReadFile("sample.jpg") - - kind, _ := filetype.Match(buf) - if kind == filetype.Unknown { - fmt.Println("Unknown file type") - return - } - - fmt.Printf("File type: %s. MIME: %s\n", kind.Extension, kind.MIME.Value) -} -``` - -#### Check type class - -```go -package main - -import ( - "fmt" - "io/ioutil" - - "github.com/h2non/filetype" -) - -func main() { - buf, _ := ioutil.ReadFile("sample.jpg") - - if filetype.IsImage(buf) { - fmt.Println("File is an image") - } else { - fmt.Println("Not an image") - } -} -``` - -#### Supported type - -```go -package main - -import ( - "fmt" - - "github.com/h2non/filetype" -) - -func main() { - // Check if file is supported by extension - if filetype.IsSupported("jpg") { - fmt.Println("Extension supported") - } else { - fmt.Println("Extension not supported") - } - - // Check if file is supported by extension - if filetype.IsMIMESupported("image/jpeg") { - fmt.Println("MIME type supported") - } else { - fmt.Println("MIME type not supported") - } -} -``` - -#### File header - -```go -package main - -import ( - "fmt" - "io/ioutil" - - "github.com/h2non/filetype" -) - -func main() { - // Open a file descriptor - file, _ := os.Open("movie.mp4") - - // We only have to pass the file header = first 261 bytes - head := make([]byte, 261) - file.Read(head) - - if filetype.IsImage(head) { - fmt.Println("File is an image") - } else { - fmt.Println("Not an image") - } -} -``` - -#### Add additional file type matchers - -```go -package main - -import ( - "fmt" - - "github.com/h2non/filetype" -) - -var fooType = filetype.NewType("foo", "foo/foo") - -func fooMatcher(buf []byte) bool { - return len(buf) > 1 && buf[0] == 0x01 && buf[1] == 0x02 -} - -func main() { - // Register the new matcher and its type - filetype.AddMatcher(fooType, fooMatcher) - - // Check if the new type is supported by extension - if filetype.IsSupported("foo") { - fmt.Println("New supported type: foo") - } - - // Check if the new type is supported by MIME - if filetype.IsMIMESupported("foo/foo") { - fmt.Println("New supported MIME type: foo/foo") - } - - // Try to match the file - fooFile := []byte{0x01, 0x02} - kind, _ := filetype.Match(fooFile) - if kind == filetype.Unknown { - fmt.Println("Unknown file type") - } else { - fmt.Printf("File type matched: %s\n", kind.Extension) - } -} -``` - -## Supported types - -#### Image - -- **jpg** - `image/jpeg` -- **png** - `image/png` -- **gif** - `image/gif` -- **webp** - `image/webp` -- **cr2** - `image/x-canon-cr2` -- **tif** - `image/tiff` -- **bmp** - `image/bmp` -- **heif** - `image/heif` -- **jxr** - `image/vnd.ms-photo` -- **psd** - `image/vnd.adobe.photoshop` -- **ico** - `image/vnd.microsoft.icon` -- **dwg** - `image/vnd.dwg` - -#### Video - -- **mp4** - `video/mp4` -- **m4v** - `video/x-m4v` -- **mkv** - `video/x-matroska` -- **webm** - `video/webm` -- **mov** - `video/quicktime` -- **avi** - `video/x-msvideo` -- **wmv** - `video/x-ms-wmv` -- **mpg** - `video/mpeg` -- **flv** - `video/x-flv` -- **3gp** - `video/3gpp` - -#### Audio - -- **mid** - `audio/midi` -- **mp3** - `audio/mpeg` -- **m4a** - `audio/m4a` -- **ogg** - `audio/ogg` -- **flac** - `audio/x-flac` -- **wav** - `audio/x-wav` -- **amr** - `audio/amr` -- **aac** - `audio/aac` -- **aiff** - `audio/x-aiff` - -#### Archive - -- **epub** - `application/epub+zip` -- **zip** - `application/zip` -- **tar** - `application/x-tar` -- **rar** - `application/vnd.rar` -- **gz** - `application/gzip` -- **bz2** - `application/x-bzip2` -- **7z** - `application/x-7z-compressed` -- **xz** - `application/x-xz` -- **zstd** - `application/zstd` -- **pdf** - `application/pdf` -- **exe** - `application/vnd.microsoft.portable-executable` -- **swf** - `application/x-shockwave-flash` -- **rtf** - `application/rtf` -- **iso** - `application/x-iso9660-image` -- **eot** - `application/octet-stream` -- **ps** - `application/postscript` -- **sqlite** - `application/vnd.sqlite3` -- **nes** - `application/x-nintendo-nes-rom` -- **crx** - `application/x-google-chrome-extension` -- **cab** - `application/vnd.ms-cab-compressed` -- **deb** - `application/vnd.debian.binary-package` -- **ar** - `application/x-unix-archive` -- **Z** - `application/x-compress` -- **lz** - `application/x-lzip` -- **rpm** - `application/x-rpm` -- **elf** - `application/x-executable` -- **dcm** - `application/dicom` - -#### Documents - -- **doc** - `application/msword` -- **docx** - `application/vnd.openxmlformats-officedocument.wordprocessingml.document` -- **xls** - `application/vnd.ms-excel` -- **xlsx** - `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet` -- **ppt** - `application/vnd.ms-powerpoint` -- **pptx** - `application/vnd.openxmlformats-officedocument.presentationml.presentation` - -#### Font - -- **woff** - `application/font-woff` -- **woff2** - `application/font-woff` -- **ttf** - `application/font-sfnt` -- **otf** - `application/font-sfnt` - -#### Application - -- **wasm** - `application/wasm` -- **dex** - `application/vnd.android.dex` -- **dey** - `application/vnd.android.dey` - -## Benchmarks - -Measured using [real files](https://github.com/h2non/filetype/tree/master/fixtures). - -Environment: OSX x64 i7 2.7 Ghz - -```bash -BenchmarkMatchTar-8 1000000 1083 ns/op -BenchmarkMatchZip-8 1000000 1162 ns/op -BenchmarkMatchJpeg-8 1000000 1280 ns/op -BenchmarkMatchGif-8 1000000 1315 ns/op -BenchmarkMatchPng-8 1000000 1121 ns/op -``` - -## License - -MIT - Tomas Aparicio diff --git a/vendor/github.com/h2non/filetype/filetype.go b/vendor/github.com/h2non/filetype/filetype.go deleted file mode 100644 index c99691e5f..000000000 --- a/vendor/github.com/h2non/filetype/filetype.go +++ /dev/null @@ -1,102 +0,0 @@ -package filetype - -import ( - "errors" - - "github.com/h2non/filetype/matchers" - "github.com/h2non/filetype/types" -) - -// Types stores a map of supported types -var Types = types.Types - -// NewType creates and registers a new type -var NewType = types.NewType - -// Unknown represents an unknown file type -var Unknown = types.Unknown - -// ErrEmptyBuffer represents an empty buffer error -var ErrEmptyBuffer = errors.New("Empty buffer") - -// ErrUnknownBuffer represents a unknown buffer error -var ErrUnknownBuffer = errors.New("Unknown buffer type") - -// AddType registers a new file type -func AddType(ext, mime string) types.Type { - return types.NewType(ext, mime) -} - -// Is checks if a given buffer matches with the given file type extension -func Is(buf []byte, ext string) bool { - kind := types.Get(ext) - if kind != types.Unknown { - return IsType(buf, kind) - } - return false -} - -// IsExtension semantic alias to Is() -func IsExtension(buf []byte, ext string) bool { - return Is(buf, ext) -} - -// IsType checks if a given buffer matches with the given file type -func IsType(buf []byte, kind types.Type) bool { - matcher := matchers.Matchers[kind] - if matcher == nil { - return false - } - return matcher(buf) != types.Unknown -} - -// IsMIME checks if a given buffer matches with the given MIME type -func IsMIME(buf []byte, mime string) bool { - result := false - types.Types.Range(func(k, v interface{}) bool { - kind := v.(types.Type) - if kind.MIME.Value == mime { - matcher := matchers.Matchers[kind] - result = matcher(buf) != types.Unknown - return false - } - return true - }) - - return result -} - -// IsSupported checks if a given file extension is supported -func IsSupported(ext string) bool { - result := false - types.Types.Range(func(k, v interface{}) bool { - key := k.(string) - if key == ext { - result = true - return false - } - return true - }) - - return result -} - -// IsMIMESupported checks if a given MIME type is supported -func IsMIMESupported(mime string) bool { - result := false - types.Types.Range(func(k, v interface{}) bool { - kind := v.(types.Type) - if kind.MIME.Value == mime { - result = true - return false - } - return true - }) - - return result -} - -// GetType retrieves a Type by file extension -func GetType(ext string) types.Type { - return types.Get(ext) -} diff --git a/vendor/github.com/h2non/filetype/kind.go b/vendor/github.com/h2non/filetype/kind.go deleted file mode 100644 index 9608b0a7a..000000000 --- a/vendor/github.com/h2non/filetype/kind.go +++ /dev/null @@ -1,91 +0,0 @@ -package filetype - -import ( - "github.com/h2non/filetype/matchers" - "github.com/h2non/filetype/types" -) - -// Image tries to match a file as image type -func Image(buf []byte) (types.Type, error) { - return doMatchMap(buf, matchers.Image) -} - -// IsImage checks if the given buffer is an image type -func IsImage(buf []byte) bool { - kind, _ := Image(buf) - return kind != types.Unknown -} - -// Audio tries to match a file as audio type -func Audio(buf []byte) (types.Type, error) { - return doMatchMap(buf, matchers.Audio) -} - -// IsAudio checks if the given buffer is an audio type -func IsAudio(buf []byte) bool { - kind, _ := Audio(buf) - return kind != types.Unknown -} - -// Video tries to match a file as video type -func Video(buf []byte) (types.Type, error) { - return doMatchMap(buf, matchers.Video) -} - -// IsVideo checks if the given buffer is a video type -func IsVideo(buf []byte) bool { - kind, _ := Video(buf) - return kind != types.Unknown -} - -// Font tries to match a file as text font type -func Font(buf []byte) (types.Type, error) { - return doMatchMap(buf, matchers.Font) -} - -// IsFont checks if the given buffer is a font type -func IsFont(buf []byte) bool { - kind, _ := Font(buf) - return kind != types.Unknown -} - -// Archive tries to match a file as generic archive type -func Archive(buf []byte) (types.Type, error) { - return doMatchMap(buf, matchers.Archive) -} - -// IsArchive checks if the given buffer is an archive type -func IsArchive(buf []byte) bool { - kind, _ := Archive(buf) - return kind != types.Unknown -} - -// Document tries to match a file as document type -func Document(buf []byte) (types.Type, error) { - return doMatchMap(buf, matchers.Document) -} - -// IsDocument checks if the given buffer is an document type -func IsDocument(buf []byte) bool { - kind, _ := Document(buf) - return kind != types.Unknown -} - -// Application tries to match a file as an application type -func Application(buf []byte) (types.Type, error) { - return doMatchMap(buf, matchers.Application) -} - -// IsApplication checks if the given buffer is an application type -func IsApplication(buf []byte) bool { - kind, _ := Application(buf) - return kind != types.Unknown -} - -func doMatchMap(buf []byte, machers matchers.Map) (types.Type, error) { - kind := MatchMap(buf, machers) - if kind != types.Unknown { - return kind, nil - } - return kind, ErrUnknownBuffer -} diff --git a/vendor/github.com/h2non/filetype/match.go b/vendor/github.com/h2non/filetype/match.go deleted file mode 100644 index 82cf80468..000000000 --- a/vendor/github.com/h2non/filetype/match.go +++ /dev/null @@ -1,90 +0,0 @@ -package filetype - -import ( - "io" - "os" - - "github.com/h2non/filetype/matchers" - "github.com/h2non/filetype/types" -) - -// Matchers is an alias to matchers.Matchers -var Matchers = matchers.Matchers - -// MatcherKeys is an alias to matchers.MatcherKeys -var MatcherKeys = &matchers.MatcherKeys - -// NewMatcher is an alias to matchers.NewMatcher -var NewMatcher = matchers.NewMatcher - -// Match infers the file type of a given buffer inspecting its magic numbers signature -func Match(buf []byte) (types.Type, error) { - length := len(buf) - if length == 0 { - return types.Unknown, ErrEmptyBuffer - } - - for _, kind := range *MatcherKeys { - checker := Matchers[kind] - match := checker(buf) - if match != types.Unknown && match.Extension != "" { - return match, nil - } - } - - return types.Unknown, nil -} - -// Get is an alias to Match() -func Get(buf []byte) (types.Type, error) { - return Match(buf) -} - -// MatchFile infers a file type for a file -func MatchFile(filepath string) (types.Type, error) { - file, err := os.Open(filepath) - if err != nil { - return types.Unknown, err - } - defer file.Close() - - return MatchReader(file) -} - -// MatchReader is convenient wrapper to Match() any Reader -func MatchReader(reader io.Reader) (types.Type, error) { - buffer := make([]byte, 8192) // 8K makes msooxml tests happy and allows for expanded custom file checks - - _, err := reader.Read(buffer) - if err != nil && err != io.EOF { - return types.Unknown, err - } - - return Match(buffer) -} - -// AddMatcher registers a new matcher type -func AddMatcher(fileType types.Type, matcher matchers.Matcher) matchers.TypeMatcher { - return matchers.NewMatcher(fileType, matcher) -} - -// Matches checks if the given buffer matches with some supported file type -func Matches(buf []byte) bool { - kind, _ := Match(buf) - return kind != types.Unknown -} - -// MatchMap performs a file matching against a map of match functions -func MatchMap(buf []byte, matchers matchers.Map) types.Type { - for kind, matcher := range matchers { - if matcher(buf) { - return kind - } - } - return types.Unknown -} - -// MatchesMap is an alias to Matches() but using matching against a map of match functions -func MatchesMap(buf []byte, matchers matchers.Map) bool { - return MatchMap(buf, matchers) != types.Unknown -} diff --git a/vendor/github.com/h2non/filetype/matchers/application.go b/vendor/github.com/h2non/filetype/matchers/application.go deleted file mode 100644 index 67fdab3d8..000000000 --- a/vendor/github.com/h2non/filetype/matchers/application.go +++ /dev/null @@ -1,43 +0,0 @@ -package matchers - -var ( - TypeWasm = newType("wasm", "application/wasm") - TypeDex = newType("dex", "application/vnd.android.dex") - TypeDey = newType("dey", "application/vnd.android.dey") -) - -var Application = Map{ - TypeWasm: Wasm, - TypeDex: Dex, - TypeDey: Dey, -} - -// Wasm detects a Web Assembly 1.0 filetype. -func Wasm(buf []byte) bool { - // WASM has starts with `\0asm`, followed by the version. - // http://webassembly.github.io/spec/core/binary/modules.html#binary-magic - return len(buf) >= 8 && - buf[0] == 0x00 && buf[1] == 0x61 && - buf[2] == 0x73 && buf[3] == 0x6D && - buf[4] == 0x01 && buf[5] == 0x00 && - buf[6] == 0x00 && buf[7] == 0x00 -} - -// Dex detects dalvik executable(DEX) -func Dex(buf []byte) bool { - // https://source.android.com/devices/tech/dalvik/dex-format#dex-file-magic - return len(buf) > 36 && - // magic - buf[0] == 0x64 && buf[1] == 0x65 && buf[2] == 0x78 && buf[3] == 0x0A && - // file sise - buf[36] == 0x70 -} - -// Dey Optimized Dalvik Executable(ODEX) -func Dey(buf []byte) bool { - return len(buf) > 100 && - // dey magic - buf[0] == 0x64 && buf[1] == 0x65 && buf[2] == 0x79 && buf[3] == 0x0A && - // dex - Dex(buf[40:100]) -} diff --git a/vendor/github.com/h2non/filetype/matchers/archive.go b/vendor/github.com/h2non/filetype/matchers/archive.go deleted file mode 100644 index ee618a925..000000000 --- a/vendor/github.com/h2non/filetype/matchers/archive.go +++ /dev/null @@ -1,211 +0,0 @@ -package matchers - -import "encoding/binary" - -const ( - ZstdMagicSkippableStart = 0x184D2A50 - ZstdMagicSkippableMask = 0xFFFFFFF0 -) - -var ( - TypeEpub = newType("epub", "application/epub+zip") - TypeZip = newType("zip", "application/zip") - TypeTar = newType("tar", "application/x-tar") - TypeRar = newType("rar", "application/vnd.rar") - TypeGz = newType("gz", "application/gzip") - TypeBz2 = newType("bz2", "application/x-bzip2") - Type7z = newType("7z", "application/x-7z-compressed") - TypeXz = newType("xz", "application/x-xz") - TypeZstd = newType("zst", "application/zstd") - TypePdf = newType("pdf", "application/pdf") - TypeExe = newType("exe", "application/vnd.microsoft.portable-executable") - TypeSwf = newType("swf", "application/x-shockwave-flash") - TypeRtf = newType("rtf", "application/rtf") - TypeEot = newType("eot", "application/octet-stream") - TypePs = newType("ps", "application/postscript") - TypeSqlite = newType("sqlite", "application/vnd.sqlite3") - TypeNes = newType("nes", "application/x-nintendo-nes-rom") - TypeCrx = newType("crx", "application/x-google-chrome-extension") - TypeCab = newType("cab", "application/vnd.ms-cab-compressed") - TypeDeb = newType("deb", "application/vnd.debian.binary-package") - TypeAr = newType("ar", "application/x-unix-archive") - TypeZ = newType("Z", "application/x-compress") - TypeLz = newType("lz", "application/x-lzip") - TypeRpm = newType("rpm", "application/x-rpm") - TypeElf = newType("elf", "application/x-executable") - TypeDcm = newType("dcm", "application/dicom") - TypeIso = newType("iso", "application/x-iso9660-image") - TypeMachO = newType("macho", "application/x-mach-binary") // Mach-O binaries have no common extension. -) - -var Archive = Map{ - TypeEpub: bytePrefixMatcher(epubMagic), - TypeZip: Zip, - TypeTar: Tar, - TypeRar: Rar, - TypeGz: bytePrefixMatcher(gzMagic), - TypeBz2: bytePrefixMatcher(bz2Magic), - Type7z: bytePrefixMatcher(sevenzMagic), - TypeXz: bytePrefixMatcher(xzMagic), - TypeZstd: Zst, - TypePdf: bytePrefixMatcher(pdfMagic), - TypeExe: bytePrefixMatcher(exeMagic), - TypeSwf: Swf, - TypeRtf: bytePrefixMatcher(rtfMagic), - TypeEot: Eot, - TypePs: bytePrefixMatcher(psMagic), - TypeSqlite: bytePrefixMatcher(sqliteMagic), - TypeNes: bytePrefixMatcher(nesMagic), - TypeCrx: bytePrefixMatcher(crxMagic), - TypeCab: Cab, - TypeDeb: bytePrefixMatcher(debMagic), - TypeAr: bytePrefixMatcher(arMagic), - TypeZ: Z, - TypeLz: bytePrefixMatcher(lzMagic), - TypeRpm: Rpm, - TypeElf: Elf, - TypeDcm: Dcm, - TypeIso: Iso, - TypeMachO: MachO, -} - -var ( - epubMagic = []byte{ - 0x50, 0x4B, 0x03, 0x04, 0x6D, 0x69, 0x6D, 0x65, - 0x74, 0x79, 0x70, 0x65, 0x61, 0x70, 0x70, 0x6C, - 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x2F, - 0x65, 0x70, 0x75, 0x62, 0x2B, 0x7A, 0x69, 0x70, - } - gzMagic = []byte{0x1F, 0x8B, 0x08} - bz2Magic = []byte{0x42, 0x5A, 0x68} - sevenzMagic = []byte{0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C} - pdfMagic = []byte{0x25, 0x50, 0x44, 0x46} - exeMagic = []byte{0x4D, 0x5A} - rtfMagic = []byte{0x7B, 0x5C, 0x72, 0x74, 0x66} - nesMagic = []byte{0x4E, 0x45, 0x53, 0x1A} - crxMagic = []byte{0x43, 0x72, 0x32, 0x34} - psMagic = []byte{0x25, 0x21} - xzMagic = []byte{0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00} - sqliteMagic = []byte{0x53, 0x51, 0x4C, 0x69} - debMagic = []byte{ - 0x21, 0x3C, 0x61, 0x72, 0x63, 0x68, 0x3E, 0x0A, - 0x64, 0x65, 0x62, 0x69, 0x61, 0x6E, 0x2D, 0x62, - 0x69, 0x6E, 0x61, 0x72, 0x79, - } - arMagic = []byte{0x21, 0x3C, 0x61, 0x72, 0x63, 0x68, 0x3E} - zstdMagic = []byte{0x28, 0xB5, 0x2F, 0xFD} - lzMagic = []byte{0x4C, 0x5A, 0x49, 0x50} -) - -func bytePrefixMatcher(magicPattern []byte) Matcher { - return func(data []byte) bool { - return compareBytes(data, magicPattern, 0) - } -} - -func Zip(buf []byte) bool { - return len(buf) > 3 && - buf[0] == 0x50 && buf[1] == 0x4B && - (buf[2] == 0x3 || buf[2] == 0x5 || buf[2] == 0x7) && - (buf[3] == 0x4 || buf[3] == 0x6 || buf[3] == 0x8) -} - -func Tar(buf []byte) bool { - return len(buf) > 261 && - buf[257] == 0x75 && buf[258] == 0x73 && - buf[259] == 0x74 && buf[260] == 0x61 && - buf[261] == 0x72 -} - -func Rar(buf []byte) bool { - return len(buf) > 6 && - buf[0] == 0x52 && buf[1] == 0x61 && buf[2] == 0x72 && - buf[3] == 0x21 && buf[4] == 0x1A && buf[5] == 0x7 && - (buf[6] == 0x0 || buf[6] == 0x1) -} - -func Swf(buf []byte) bool { - return len(buf) > 2 && - (buf[0] == 0x43 || buf[0] == 0x46) && - buf[1] == 0x57 && buf[2] == 0x53 -} - -func Cab(buf []byte) bool { - return len(buf) > 3 && - ((buf[0] == 0x4D && buf[1] == 0x53 && buf[2] == 0x43 && buf[3] == 0x46) || - (buf[0] == 0x49 && buf[1] == 0x53 && buf[2] == 0x63 && buf[3] == 0x28)) -} - -func Eot(buf []byte) bool { - return len(buf) > 35 && - buf[34] == 0x4C && buf[35] == 0x50 && - ((buf[8] == 0x02 && buf[9] == 0x00 && - buf[10] == 0x01) || (buf[8] == 0x01 && - buf[9] == 0x00 && buf[10] == 0x00) || - (buf[8] == 0x02 && buf[9] == 0x00 && - buf[10] == 0x02)) -} - -func Z(buf []byte) bool { - return len(buf) > 1 && - ((buf[0] == 0x1F && buf[1] == 0xA0) || - (buf[0] == 0x1F && buf[1] == 0x9D)) -} - -func Rpm(buf []byte) bool { - return len(buf) > 96 && - buf[0] == 0xED && buf[1] == 0xAB && - buf[2] == 0xEE && buf[3] == 0xDB -} - -func Elf(buf []byte) bool { - return len(buf) > 52 && - buf[0] == 0x7F && buf[1] == 0x45 && - buf[2] == 0x4C && buf[3] == 0x46 -} - -func Dcm(buf []byte) bool { - return len(buf) > 131 && - buf[128] == 0x44 && buf[129] == 0x49 && - buf[130] == 0x43 && buf[131] == 0x4D -} - -func Iso(buf []byte) bool { - return len(buf) > 32773 && - buf[32769] == 0x43 && buf[32770] == 0x44 && - buf[32771] == 0x30 && buf[32772] == 0x30 && - buf[32773] == 0x31 -} - -func MachO(buf []byte) bool { - return len(buf) > 3 && ((buf[0] == 0xFE && buf[1] == 0xED && buf[2] == 0xFA && buf[3] == 0xCF) || - (buf[0] == 0xFE && buf[1] == 0xED && buf[2] == 0xFA && buf[3] == 0xCE) || - (buf[0] == 0xBE && buf[1] == 0xBA && buf[2] == 0xFE && buf[3] == 0xCA) || - // Big endian versions below here... - (buf[0] == 0xCF && buf[1] == 0xFA && buf[2] == 0xED && buf[3] == 0xFE) || - (buf[0] == 0xCE && buf[1] == 0xFA && buf[2] == 0xED && buf[3] == 0xFE) || - (buf[0] == 0xCA && buf[1] == 0xFE && buf[2] == 0xBA && buf[3] == 0xBE)) -} - -// Zstandard compressed data is made of one or more frames. -// There are two frame formats defined by Zstandard: Zstandard frames and Skippable frames. -// See more details from https://tools.ietf.org/id/draft-kucherawy-dispatch-zstd-00.html#rfc.section.2 -func Zst(buf []byte) bool { - if compareBytes(buf, zstdMagic, 0) { - return true - } else { - // skippable frames - if len(buf) < 8 { - return false - } - if binary.LittleEndian.Uint32(buf[:4]) & ZstdMagicSkippableMask == ZstdMagicSkippableStart { - userDataLength := binary.LittleEndian.Uint32(buf[4:8]) - if len(buf) < 8 + int(userDataLength) { - return false - } - nextFrame := buf[8+userDataLength:] - return Zst(nextFrame) - } - return false - } -} diff --git a/vendor/github.com/h2non/filetype/matchers/audio.go b/vendor/github.com/h2non/filetype/matchers/audio.go deleted file mode 100644 index b34605aec..000000000 --- a/vendor/github.com/h2non/filetype/matchers/audio.go +++ /dev/null @@ -1,85 +0,0 @@ -package matchers - -var ( - TypeMidi = newType("mid", "audio/midi") - TypeMp3 = newType("mp3", "audio/mpeg") - TypeM4a = newType("m4a", "audio/m4a") - TypeOgg = newType("ogg", "audio/ogg") - TypeFlac = newType("flac", "audio/x-flac") - TypeWav = newType("wav", "audio/x-wav") - TypeAmr = newType("amr", "audio/amr") - TypeAac = newType("aac", "audio/aac") - TypeAiff = newType("aiff", "audio/x-aiff") -) - -var Audio = Map{ - TypeMidi: Midi, - TypeMp3: Mp3, - TypeM4a: M4a, - TypeOgg: Ogg, - TypeFlac: Flac, - TypeWav: Wav, - TypeAmr: Amr, - TypeAac: Aac, - TypeAiff: Aiff, -} - -func Midi(buf []byte) bool { - return len(buf) > 3 && - buf[0] == 0x4D && buf[1] == 0x54 && - buf[2] == 0x68 && buf[3] == 0x64 -} - -func Mp3(buf []byte) bool { - return len(buf) > 2 && - ((buf[0] == 0x49 && buf[1] == 0x44 && buf[2] == 0x33) || - (buf[0] == 0xFF && buf[1] == 0xfb)) -} - -func M4a(buf []byte) bool { - return len(buf) > 10 && - ((buf[4] == 0x66 && buf[5] == 0x74 && buf[6] == 0x79 && - buf[7] == 0x70 && buf[8] == 0x4D && buf[9] == 0x34 && buf[10] == 0x41) || - (buf[0] == 0x4D && buf[1] == 0x34 && buf[2] == 0x41 && buf[3] == 0x20)) -} - -func Ogg(buf []byte) bool { - return len(buf) > 3 && - buf[0] == 0x4F && buf[1] == 0x67 && - buf[2] == 0x67 && buf[3] == 0x53 -} - -func Flac(buf []byte) bool { - return len(buf) > 3 && - buf[0] == 0x66 && buf[1] == 0x4C && - buf[2] == 0x61 && buf[3] == 0x43 -} - -func Wav(buf []byte) bool { - return len(buf) > 11 && - buf[0] == 0x52 && buf[1] == 0x49 && - buf[2] == 0x46 && buf[3] == 0x46 && - buf[8] == 0x57 && buf[9] == 0x41 && - buf[10] == 0x56 && buf[11] == 0x45 -} - -func Amr(buf []byte) bool { - return len(buf) > 11 && - buf[0] == 0x23 && buf[1] == 0x21 && - buf[2] == 0x41 && buf[3] == 0x4D && - buf[4] == 0x52 && buf[5] == 0x0A -} - -func Aac(buf []byte) bool { - return len(buf) > 1 && - ((buf[0] == 0xFF && buf[1] == 0xF1) || - (buf[0] == 0xFF && buf[1] == 0xF9)) -} - -func Aiff(buf []byte) bool { - return len(buf) > 11 && - buf[0] == 0x46 && buf[1] == 0x4F && - buf[2] == 0x52 && buf[3] == 0x4D && - buf[8] == 0x41 && buf[9] == 0x49 && - buf[10] == 0x46 && buf[11] == 0x46 -} diff --git a/vendor/github.com/h2non/filetype/matchers/document.go b/vendor/github.com/h2non/filetype/matchers/document.go deleted file mode 100644 index b898c0ff7..000000000 --- a/vendor/github.com/h2non/filetype/matchers/document.go +++ /dev/null @@ -1,197 +0,0 @@ -package matchers - -import ( - "bytes" - "encoding/binary" -) - -var ( - TypeDoc = newType("doc", "application/msword") - TypeDocx = newType("docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document") - TypeXls = newType("xls", "application/vnd.ms-excel") - TypeXlsx = newType("xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") - TypePpt = newType("ppt", "application/vnd.ms-powerpoint") - TypePptx = newType("pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation") -) - -var Document = Map{ - TypeDoc: Doc, - TypeDocx: Docx, - TypeXls: Xls, - TypeXlsx: Xlsx, - TypePpt: Ppt, - TypePptx: Pptx, -} - -type docType int - -const ( - TYPE_DOC docType = iota - TYPE_DOCX - TYPE_XLS - TYPE_XLSX - TYPE_PPT - TYPE_PPTX - TYPE_OOXML -) - -//reference: https://bz.apache.org/ooo/show_bug.cgi?id=111457 -func Doc(buf []byte) bool { - if len(buf) > 513 { - return buf[0] == 0xD0 && buf[1] == 0xCF && - buf[2] == 0x11 && buf[3] == 0xE0 && - buf[512] == 0xEC && buf[513] == 0xA5 - } else { - return len(buf) > 3 && - buf[0] == 0xD0 && buf[1] == 0xCF && - buf[2] == 0x11 && buf[3] == 0xE0 - } -} - -func Docx(buf []byte) bool { - typ, ok := msooxml(buf) - return ok && typ == TYPE_DOCX -} - -func Xls(buf []byte) bool { - if len(buf) > 513 { - return buf[0] == 0xD0 && buf[1] == 0xCF && - buf[2] == 0x11 && buf[3] == 0xE0 && - buf[512] == 0x09 && buf[513] == 0x08 - } else { - return len(buf) > 3 && - buf[0] == 0xD0 && buf[1] == 0xCF && - buf[2] == 0x11 && buf[3] == 0xE0 - } -} - -func Xlsx(buf []byte) bool { - typ, ok := msooxml(buf) - return ok && typ == TYPE_XLSX -} - -func Ppt(buf []byte) bool { - if len(buf) > 513 { - return buf[0] == 0xD0 && buf[1] == 0xCF && - buf[2] == 0x11 && buf[3] == 0xE0 && - buf[512] == 0xA0 && buf[513] == 0x46 - } else { - return len(buf) > 3 && - buf[0] == 0xD0 && buf[1] == 0xCF && - buf[2] == 0x11 && buf[3] == 0xE0 - } -} - -func Pptx(buf []byte) bool { - typ, ok := msooxml(buf) - return ok && typ == TYPE_PPTX -} - -func msooxml(buf []byte) (typ docType, found bool) { - signature := []byte{'P', 'K', 0x03, 0x04} - - // start by checking for ZIP local file header signature - if ok := compareBytes(buf, signature, 0); !ok { - return - } - - // make sure the first file is correct - if v, ok := checkMSOoml(buf, 0x1E); ok { - return v, ok - } - - if !compareBytes(buf, []byte("[Content_Types].xml"), 0x1E) && - !compareBytes(buf, []byte("_rels/.rels"), 0x1E) && - !compareBytes(buf, []byte("docProps"), 0x1E) { - return - } - - // skip to the second local file header - // since some documents include a 520-byte extra field following the file - // header, we need to scan for the next header - startOffset := int(binary.LittleEndian.Uint32(buf[18:22]) + 49) - idx := search(buf, startOffset, 6000) - if idx == -1 { - return - } - - // now skip to the *third* local file header; again, we need to scan due to a - // 520-byte extra field following the file header - startOffset += idx + 4 + 26 - idx = search(buf, startOffset, 6000) - if idx == -1 { - return - } - - // and check the subdirectory name to determine which type of OOXML - // file we have. Correct the mimetype with the registered ones: - // http://technet.microsoft.com/en-us/library/cc179224.aspx - startOffset += idx + 4 + 26 - if typ, ok := checkMSOoml(buf, startOffset); ok { - return typ, ok - } - - // OpenOffice/Libreoffice orders ZIP entry differently, so check the 4th file - startOffset += 26 - idx = search(buf, startOffset, 6000) - if idx == -1 { - return TYPE_OOXML, true - } - - startOffset += idx + 4 + 26 - if typ, ok := checkMSOoml(buf, startOffset); ok { - return typ, ok - } else { - return TYPE_OOXML, true - } -} - -func compareBytes(slice, subSlice []byte, startOffset int) bool { - sl := len(subSlice) - - if startOffset+sl > len(slice) { - return false - } - - s := slice[startOffset : startOffset+sl] - for i := range s { - if subSlice[i] != s[i] { - return false - } - } - - return true -} - -func checkMSOoml(buf []byte, offset int) (typ docType, ok bool) { - ok = true - - switch { - case compareBytes(buf, []byte("word/"), offset): - typ = TYPE_DOCX - case compareBytes(buf, []byte("ppt/"), offset): - typ = TYPE_PPTX - case compareBytes(buf, []byte("xl/"), offset): - typ = TYPE_XLSX - default: - ok = false - } - - return -} - -func search(buf []byte, start, rangeNum int) int { - length := len(buf) - end := start + rangeNum - signature := []byte{'P', 'K', 0x03, 0x04} - - if end > length { - end = length - } - - if start >= end { - return -1 - } - - return bytes.Index(buf[start:end], signature) -} diff --git a/vendor/github.com/h2non/filetype/matchers/font.go b/vendor/github.com/h2non/filetype/matchers/font.go deleted file mode 100644 index f39171675..000000000 --- a/vendor/github.com/h2non/filetype/matchers/font.go +++ /dev/null @@ -1,45 +0,0 @@ -package matchers - -var ( - TypeWoff = newType("woff", "application/font-woff") - TypeWoff2 = newType("woff2", "application/font-woff") - TypeTtf = newType("ttf", "application/font-sfnt") - TypeOtf = newType("otf", "application/font-sfnt") -) - -var Font = Map{ - TypeWoff: Woff, - TypeWoff2: Woff2, - TypeTtf: Ttf, - TypeOtf: Otf, -} - -func Woff(buf []byte) bool { - return len(buf) > 7 && - buf[0] == 0x77 && buf[1] == 0x4F && - buf[2] == 0x46 && buf[3] == 0x46 && - buf[4] == 0x00 && buf[5] == 0x01 && - buf[6] == 0x00 && buf[7] == 0x00 -} - -func Woff2(buf []byte) bool { - return len(buf) > 7 && - buf[0] == 0x77 && buf[1] == 0x4F && - buf[2] == 0x46 && buf[3] == 0x32 && - buf[4] == 0x00 && buf[5] == 0x01 && - buf[6] == 0x00 && buf[7] == 0x00 -} - -func Ttf(buf []byte) bool { - return len(buf) > 4 && - buf[0] == 0x00 && buf[1] == 0x01 && - buf[2] == 0x00 && buf[3] == 0x00 && - buf[4] == 0x00 -} - -func Otf(buf []byte) bool { - return len(buf) > 4 && - buf[0] == 0x4F && buf[1] == 0x54 && - buf[2] == 0x54 && buf[3] == 0x4F && - buf[4] == 0x00 -} diff --git a/vendor/github.com/h2non/filetype/matchers/image.go b/vendor/github.com/h2non/filetype/matchers/image.go deleted file mode 100644 index 0465d0d68..000000000 --- a/vendor/github.com/h2non/filetype/matchers/image.go +++ /dev/null @@ -1,143 +0,0 @@ -package matchers - -import "github.com/h2non/filetype/matchers/isobmff" - -var ( - TypeJpeg = newType("jpg", "image/jpeg") - TypeJpeg2000 = newType("jp2", "image/jp2") - TypePng = newType("png", "image/png") - TypeGif = newType("gif", "image/gif") - TypeWebp = newType("webp", "image/webp") - TypeCR2 = newType("cr2", "image/x-canon-cr2") - TypeTiff = newType("tif", "image/tiff") - TypeBmp = newType("bmp", "image/bmp") - TypeJxr = newType("jxr", "image/vnd.ms-photo") - TypePsd = newType("psd", "image/vnd.adobe.photoshop") - TypeIco = newType("ico", "image/vnd.microsoft.icon") - TypeHeif = newType("heif", "image/heif") - TypeDwg = newType("dwg", "image/vnd.dwg") -) - -var Image = Map{ - TypeJpeg: Jpeg, - TypeJpeg2000: Jpeg2000, - TypePng: Png, - TypeGif: Gif, - TypeWebp: Webp, - TypeCR2: CR2, - TypeTiff: Tiff, - TypeBmp: Bmp, - TypeJxr: Jxr, - TypePsd: Psd, - TypeIco: Ico, - TypeHeif: Heif, - TypeDwg: Dwg, -} - -func Jpeg(buf []byte) bool { - return len(buf) > 2 && - buf[0] == 0xFF && - buf[1] == 0xD8 && - buf[2] == 0xFF -} - -func Jpeg2000(buf []byte) bool { - return len(buf) > 12 && - buf[0] == 0x0 && - buf[1] == 0x0 && - buf[2] == 0x0 && - buf[3] == 0xC && - buf[4] == 0x6A && - buf[5] == 0x50 && - buf[6] == 0x20 && - buf[7] == 0x20 && - buf[8] == 0xD && - buf[9] == 0xA && - buf[10] == 0x87 && - buf[11] == 0xA && - buf[12] == 0x0 -} - -func Png(buf []byte) bool { - return len(buf) > 3 && - buf[0] == 0x89 && buf[1] == 0x50 && - buf[2] == 0x4E && buf[3] == 0x47 -} - -func Gif(buf []byte) bool { - return len(buf) > 2 && - buf[0] == 0x47 && buf[1] == 0x49 && buf[2] == 0x46 -} - -func Webp(buf []byte) bool { - return len(buf) > 11 && - buf[8] == 0x57 && buf[9] == 0x45 && - buf[10] == 0x42 && buf[11] == 0x50 -} - -func CR2(buf []byte) bool { - return len(buf) > 10 && - ((buf[0] == 0x49 && buf[1] == 0x49 && buf[2] == 0x2A && buf[3] == 0x0) || // Little Endian - (buf[0] == 0x4D && buf[1] == 0x4D && buf[2] == 0x0 && buf[3] == 0x2A)) && // Big Endian - buf[8] == 0x43 && buf[9] == 0x52 && // CR2 magic word - buf[10] == 0x02 // CR2 major version -} - -func Tiff(buf []byte) bool { - return len(buf) > 10 && - ((buf[0] == 0x49 && buf[1] == 0x49 && buf[2] == 0x2A && buf[3] == 0x0) || // Little Endian - (buf[0] == 0x4D && buf[1] == 0x4D && buf[2] == 0x0 && buf[3] == 0x2A)) && // Big Endian - !CR2(buf) // To avoid conflicts differentiate Tiff from CR2 -} - -func Bmp(buf []byte) bool { - return len(buf) > 1 && - buf[0] == 0x42 && - buf[1] == 0x4D -} - -func Jxr(buf []byte) bool { - return len(buf) > 2 && - buf[0] == 0x49 && - buf[1] == 0x49 && - buf[2] == 0xBC -} - -func Psd(buf []byte) bool { - return len(buf) > 3 && - buf[0] == 0x38 && buf[1] == 0x42 && - buf[2] == 0x50 && buf[3] == 0x53 -} - -func Ico(buf []byte) bool { - return len(buf) > 3 && - buf[0] == 0x00 && buf[1] == 0x00 && - buf[2] == 0x01 && buf[3] == 0x00 -} - -func Heif(buf []byte) bool { - if !isobmff.IsISOBMFF(buf) { - return false - } - - majorBrand, _, compatibleBrands := isobmff.GetFtyp(buf) - if majorBrand == "heic" { - return true - } - - if majorBrand == "mif1" || majorBrand == "msf1" { - for _, compatibleBrand := range compatibleBrands { - if compatibleBrand == "heic" { - return true - } - } - } - - return false -} - -func Dwg(buf []byte) bool { - return len(buf) > 3 && - buf[0] == 0x41 && buf[1] == 0x43 && - buf[2] == 0x31 && buf[3] == 0x30 -} diff --git a/vendor/github.com/h2non/filetype/matchers/isobmff/isobmff.go b/vendor/github.com/h2non/filetype/matchers/isobmff/isobmff.go deleted file mode 100644 index b3e39bf59..000000000 --- a/vendor/github.com/h2non/filetype/matchers/isobmff/isobmff.go +++ /dev/null @@ -1,37 +0,0 @@ -package isobmff - -import "encoding/binary" - -// IsISOBMFF checks whether the given buffer represents ISO Base Media File Format data -func IsISOBMFF(buf []byte) bool { - if len(buf) < 16 || string(buf[4:8]) != "ftyp" { - return false - } - - if ftypLength := binary.BigEndian.Uint32(buf[0:4]); len(buf) < int(ftypLength) { - return false - } - - return true -} - -// GetFtyp returns the major brand, minor version and compatible brands of the ISO-BMFF data -func GetFtyp(buf []byte) (string, string, []string) { - if len(buf) < 17 { - return "", "", []string{""} - } - - ftypLength := binary.BigEndian.Uint32(buf[0:4]) - - majorBrand := string(buf[8:12]) - minorVersion := string(buf[12:16]) - - compatibleBrands := []string{} - for i := 16; i < int(ftypLength); i += 4 { - if len(buf) >= (i + 4) { - compatibleBrands = append(compatibleBrands, string(buf[i:i+4])) - } - } - - return majorBrand, minorVersion, compatibleBrands -} diff --git a/vendor/github.com/h2non/filetype/matchers/matchers.go b/vendor/github.com/h2non/filetype/matchers/matchers.go deleted file mode 100644 index 20d74d080..000000000 --- a/vendor/github.com/h2non/filetype/matchers/matchers.go +++ /dev/null @@ -1,51 +0,0 @@ -package matchers - -import ( - "github.com/h2non/filetype/types" -) - -// Internal shortcut to NewType -var newType = types.NewType - -// Matcher function interface as type alias -type Matcher func([]byte) bool - -// Type interface to store pairs of type with its matcher function -type Map map[types.Type]Matcher - -// Type specific matcher function interface -type TypeMatcher func([]byte) types.Type - -// Store registered file type matchers -var Matchers = make(map[types.Type]TypeMatcher) -var MatcherKeys []types.Type - -// Create and register a new type matcher function -func NewMatcher(kind types.Type, fn Matcher) TypeMatcher { - matcher := func(buf []byte) types.Type { - if fn(buf) { - return kind - } - return types.Unknown - } - - Matchers[kind] = matcher - // prepend here so any user defined matchers get added first - MatcherKeys = append([]types.Type{kind}, MatcherKeys...) - return matcher -} - -func register(matchers ...Map) { - MatcherKeys = MatcherKeys[:0] - for _, m := range matchers { - for kind, matcher := range m { - NewMatcher(kind, matcher) - } - } -} - -func init() { - // Arguments order is intentional - // Archive files will be checked last due to prepend above in func NewMatcher - register(Archive, Document, Font, Audio, Video, Image, Application) -} diff --git a/vendor/github.com/h2non/filetype/matchers/video.go b/vendor/github.com/h2non/filetype/matchers/video.go deleted file mode 100644 index e97cf28a1..000000000 --- a/vendor/github.com/h2non/filetype/matchers/video.go +++ /dev/null @@ -1,145 +0,0 @@ -package matchers - -import "bytes" - -var ( - TypeMp4 = newType("mp4", "video/mp4") - TypeM4v = newType("m4v", "video/x-m4v") - TypeMkv = newType("mkv", "video/x-matroska") - TypeWebm = newType("webm", "video/webm") - TypeMov = newType("mov", "video/quicktime") - TypeAvi = newType("avi", "video/x-msvideo") - TypeWmv = newType("wmv", "video/x-ms-wmv") - TypeMpeg = newType("mpg", "video/mpeg") - TypeFlv = newType("flv", "video/x-flv") - Type3gp = newType("3gp", "video/3gpp") -) - -var Video = Map{ - TypeMp4: Mp4, - TypeM4v: M4v, - TypeMkv: Mkv, - TypeWebm: Webm, - TypeMov: Mov, - TypeAvi: Avi, - TypeWmv: Wmv, - TypeMpeg: Mpeg, - TypeFlv: Flv, - Type3gp: Match3gp, -} - -func M4v(buf []byte) bool { - return len(buf) > 10 && - buf[4] == 0x66 && buf[5] == 0x74 && - buf[6] == 0x79 && buf[7] == 0x70 && - buf[8] == 0x4D && buf[9] == 0x34 && - buf[10] == 0x56 -} - -func Mkv(buf []byte) bool { - return len(buf) > 3 && - buf[0] == 0x1A && buf[1] == 0x45 && - buf[2] == 0xDF && buf[3] == 0xA3 && - containsMatroskaSignature(buf, []byte{'m', 'a', 't', 'r', 'o', 's', 'k', 'a'}) -} - -func Webm(buf []byte) bool { - return len(buf) > 3 && - buf[0] == 0x1A && buf[1] == 0x45 && - buf[2] == 0xDF && buf[3] == 0xA3 && - containsMatroskaSignature(buf, []byte{'w', 'e', 'b', 'm'}) -} - -func Mov(buf []byte) bool { - return len(buf) > 15 && ((buf[0] == 0x0 && buf[1] == 0x0 && - buf[2] == 0x0 && buf[3] == 0x14 && - buf[4] == 0x66 && buf[5] == 0x74 && - buf[6] == 0x79 && buf[7] == 0x70) || - (buf[4] == 0x6d && buf[5] == 0x6f && buf[6] == 0x6f && buf[7] == 0x76) || - (buf[4] == 0x6d && buf[5] == 0x64 && buf[6] == 0x61 && buf[7] == 0x74) || - (buf[12] == 0x6d && buf[13] == 0x64 && buf[14] == 0x61 && buf[15] == 0x74)) -} - -func Avi(buf []byte) bool { - return len(buf) > 10 && - buf[0] == 0x52 && buf[1] == 0x49 && - buf[2] == 0x46 && buf[3] == 0x46 && - buf[8] == 0x41 && buf[9] == 0x56 && - buf[10] == 0x49 -} - -func Wmv(buf []byte) bool { - return len(buf) > 9 && - buf[0] == 0x30 && buf[1] == 0x26 && - buf[2] == 0xB2 && buf[3] == 0x75 && - buf[4] == 0x8E && buf[5] == 0x66 && - buf[6] == 0xCF && buf[7] == 0x11 && - buf[8] == 0xA6 && buf[9] == 0xD9 -} - -func Mpeg(buf []byte) bool { - return len(buf) > 3 && - buf[0] == 0x0 && buf[1] == 0x0 && - buf[2] == 0x1 && buf[3] >= 0xb0 && - buf[3] <= 0xbf -} - -func Flv(buf []byte) bool { - return len(buf) > 3 && - buf[0] == 0x46 && buf[1] == 0x4C && - buf[2] == 0x56 && buf[3] == 0x01 -} - -func Mp4(buf []byte) bool { - return len(buf) > 11 && - (buf[4] == 'f' && buf[5] == 't' && buf[6] == 'y' && buf[7] == 'p') && - ((buf[8] == 'a' && buf[9] == 'v' && buf[10] == 'c' && buf[11] == '1') || - (buf[8] == 'd' && buf[9] == 'a' && buf[10] == 's' && buf[11] == 'h') || - (buf[8] == 'i' && buf[9] == 's' && buf[10] == 'o' && buf[11] == '2') || - (buf[8] == 'i' && buf[9] == 's' && buf[10] == 'o' && buf[11] == '3') || - (buf[8] == 'i' && buf[9] == 's' && buf[10] == 'o' && buf[11] == '4') || - (buf[8] == 'i' && buf[9] == 's' && buf[10] == 'o' && buf[11] == '5') || - (buf[8] == 'i' && buf[9] == 's' && buf[10] == 'o' && buf[11] == '6') || - (buf[8] == 'i' && buf[9] == 's' && buf[10] == 'o' && buf[11] == 'm') || - (buf[8] == 'm' && buf[9] == 'm' && buf[10] == 'p' && buf[11] == '4') || - (buf[8] == 'm' && buf[9] == 'p' && buf[10] == '4' && buf[11] == '1') || - (buf[8] == 'm' && buf[9] == 'p' && buf[10] == '4' && buf[11] == '2') || - (buf[8] == 'm' && buf[9] == 'p' && buf[10] == '4' && buf[11] == 'v') || - (buf[8] == 'm' && buf[9] == 'p' && buf[10] == '7' && buf[11] == '1') || - (buf[8] == 'M' && buf[9] == 'S' && buf[10] == 'N' && buf[11] == 'V') || - (buf[8] == 'N' && buf[9] == 'D' && buf[10] == 'A' && buf[11] == 'S') || - (buf[8] == 'N' && buf[9] == 'D' && buf[10] == 'S' && buf[11] == 'C') || - (buf[8] == 'N' && buf[9] == 'S' && buf[10] == 'D' && buf[11] == 'C') || - (buf[8] == 'N' && buf[9] == 'D' && buf[10] == 'S' && buf[11] == 'H') || - (buf[8] == 'N' && buf[9] == 'D' && buf[10] == 'S' && buf[11] == 'M') || - (buf[8] == 'N' && buf[9] == 'D' && buf[10] == 'S' && buf[11] == 'P') || - (buf[8] == 'N' && buf[9] == 'D' && buf[10] == 'S' && buf[11] == 'S') || - (buf[8] == 'N' && buf[9] == 'D' && buf[10] == 'X' && buf[11] == 'C') || - (buf[8] == 'N' && buf[9] == 'D' && buf[10] == 'X' && buf[11] == 'H') || - (buf[8] == 'N' && buf[9] == 'D' && buf[10] == 'X' && buf[11] == 'M') || - (buf[8] == 'N' && buf[9] == 'D' && buf[10] == 'X' && buf[11] == 'P') || - (buf[8] == 'N' && buf[9] == 'D' && buf[10] == 'X' && buf[11] == 'S') || - (buf[8] == 'F' && buf[9] == '4' && buf[10] == 'V' && buf[11] == ' ') || - (buf[8] == 'F' && buf[9] == '4' && buf[10] == 'P' && buf[11] == ' ')) -} - -func Match3gp(buf []byte) bool { - return len(buf) > 10 && - buf[4] == 0x66 && buf[5] == 0x74 && buf[6] == 0x79 && - buf[7] == 0x70 && buf[8] == 0x33 && buf[9] == 0x67 && - buf[10] == 0x70 -} - -func containsMatroskaSignature(buf, subType []byte) bool { - limit := 4096 - if len(buf) < limit { - limit = len(buf) - } - - index := bytes.Index(buf[:limit], subType) - if index < 3 { - return false - } - - return buf[index-3] == 0x42 && buf[index-2] == 0x82 -} diff --git a/vendor/github.com/h2non/filetype/types/defaults.go b/vendor/github.com/h2non/filetype/types/defaults.go deleted file mode 100644 index 0d985a05d..000000000 --- a/vendor/github.com/h2non/filetype/types/defaults.go +++ /dev/null @@ -1,4 +0,0 @@ -package types - -// Unknown default type -var Unknown = NewType("unknown", "") diff --git a/vendor/github.com/h2non/filetype/types/mime.go b/vendor/github.com/h2non/filetype/types/mime.go deleted file mode 100644 index fe8ea822e..000000000 --- a/vendor/github.com/h2non/filetype/types/mime.go +++ /dev/null @@ -1,14 +0,0 @@ -package types - -// MIME stores the file MIME type values -type MIME struct { - Type string - Subtype string - Value string -} - -// Creates a new MIME type -func NewMIME(mime string) MIME { - kind, subtype := splitMime(mime) - return MIME{Type: kind, Subtype: subtype, Value: mime} -} diff --git a/vendor/github.com/h2non/filetype/types/split.go b/vendor/github.com/h2non/filetype/types/split.go deleted file mode 100644 index 68a5a8b3b..000000000 --- a/vendor/github.com/h2non/filetype/types/split.go +++ /dev/null @@ -1,11 +0,0 @@ -package types - -import "strings" - -func splitMime(s string) (string, string) { - x := strings.Split(s, "/") - if len(x) > 1 { - return x[0], x[1] - } - return x[0], "" -} diff --git a/vendor/github.com/h2non/filetype/types/type.go b/vendor/github.com/h2non/filetype/types/type.go deleted file mode 100644 index 5cf7dfc4b..000000000 --- a/vendor/github.com/h2non/filetype/types/type.go +++ /dev/null @@ -1,16 +0,0 @@ -package types - -// Type represents a file MIME type and its extension -type Type struct { - MIME MIME - Extension string -} - -// NewType creates a new Type -func NewType(ext, mime string) Type { - t := Type{ - MIME: NewMIME(mime), - Extension: ext, - } - return Add(t) -} diff --git a/vendor/github.com/h2non/filetype/types/types.go b/vendor/github.com/h2non/filetype/types/types.go deleted file mode 100644 index f59e256f0..000000000 --- a/vendor/github.com/h2non/filetype/types/types.go +++ /dev/null @@ -1,23 +0,0 @@ -package types - -import "sync" - -// Types Support concurrent map writes -var Types sync.Map - -// Add registers a new type in the package -func Add(t Type) Type { - Types.Store(t.Extension, t) - return t -} - -// Get retrieves a Type by extension -func Get(ext string) Type { - if tmp, ok := Types.Load(ext); ok { - kind := tmp.(Type) - if kind.Extension != "" { - return kind - } - } - return Unknown -} diff --git a/vendor/github.com/h2non/filetype/version.go b/vendor/github.com/h2non/filetype/version.go deleted file mode 100644 index d3730313f..000000000 --- a/vendor/github.com/h2non/filetype/version.go +++ /dev/null @@ -1,4 +0,0 @@ -package filetype - -// Version exposes the current package version. -const Version = "1.1.3" diff --git a/vendor/github.com/h2non/go-is-svg/.editorconfig b/vendor/github.com/h2non/go-is-svg/.editorconfig deleted file mode 100644 index 000dc0a7a..000000000 --- a/vendor/github.com/h2non/go-is-svg/.editorconfig +++ /dev/null @@ -1,12 +0,0 @@ -root = true - -[*] -indent_style = tabs -indent_size = 2 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -[*.md] -trim_trailing_whitespace = false diff --git a/vendor/github.com/h2non/go-is-svg/.gitignore b/vendor/github.com/h2non/go-is-svg/.gitignore deleted file mode 100644 index 3cf256521..000000000 --- a/vendor/github.com/h2non/go-is-svg/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -/bimg -/bundle -bin -/*.jpg -/*.png -/*.webp -/fixtures/*_out.* diff --git a/vendor/github.com/h2non/go-is-svg/.travis.yml b/vendor/github.com/h2non/go-is-svg/.travis.yml deleted file mode 100644 index d5a81534a..000000000 --- a/vendor/github.com/h2non/go-is-svg/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: go - -go: - - 1.5 - - 1.6 - - 1.7 - - tip - -before_install: - - go get github.com/nbio/st - - go get -u -v github.com/axw/gocov/gocov - - go get -u -v github.com/mattn/goveralls - - go get -u -v github.com/golang/lint/golint - -script: - - diff -u <(echo -n) <(gofmt -s -d ./) - - diff -u <(echo -n) <(go vet ./...) - - diff -u <(echo -n) <(golint ./...) - - go test -v -race ./... - - go test -v -race -covermode=atomic -coverprofile=coverage.out - -after_success: - - goveralls -coverprofile=coverage.out -service=travis-ci diff --git a/vendor/github.com/h2non/go-is-svg/LICENSE b/vendor/github.com/h2non/go-is-svg/LICENSE deleted file mode 100644 index f67807d00..000000000 --- a/vendor/github.com/h2non/go-is-svg/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -The MIT License - -Copyright (c) 2016 Tomas Aparicio - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/h2non/go-is-svg/README.md b/vendor/github.com/h2non/go-is-svg/README.md deleted file mode 100644 index d4a0ee6c0..000000000 --- a/vendor/github.com/h2non/go-is-svg/README.md +++ /dev/null @@ -1,47 +0,0 @@ -# go-is-svg [![Build Status](https://travis-ci.org/h2non/go-is-svg.png)](https://travis-ci.org/h2non/go-is-svg) [![GoDoc](https://godoc.org/github.com/h2non/go-is-svg?status.svg)](https://godoc.org/github.com/h2non/go-is-svg) [![Coverage Status](https://coveralls.io/repos/github/h2non/go-is-svg/badge.svg?branch=master)](https://coveralls.io/github/h2non/go-is-svg?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/h2non/go-is-svg)](https://goreportcard.com/report/github.com/h2non/go-is-svg) - -Tiny package to verify if a given file buffer is an SVG image in Go (golang). - -See also [filetype](https://github.com/h2non/filetype) package for binary files type inference. - -## Installation - -```bash -go get -u github.com/h2non/go-is-svg -``` - -## Example - -```go -package main - -import ( - "fmt" - "io/ioutil" - - svg "github.com/h2non/go-is-svg" -) - -func main() { - buf, err := ioutil.ReadFile("_example/example.svg") - if err != nil { - fmt.Printf("Error: %s\n", err) - return - } - - if svg.Is(buf) { - fmt.Println("File is an SVG") - } else { - fmt.Println("File is NOT an SVG") - } -} -``` - -Run example: -```bash -go run _example/example.go -``` - -## License - -MIT - Tomas Aparicio diff --git a/vendor/github.com/h2non/go-is-svg/svg.go b/vendor/github.com/h2non/go-is-svg/svg.go deleted file mode 100644 index 062f6e1f6..000000000 --- a/vendor/github.com/h2non/go-is-svg/svg.go +++ /dev/null @@ -1,36 +0,0 @@ -package issvg - -import ( - "regexp" - "unicode/utf8" -) - -var ( - htmlCommentRegex = regexp.MustCompile("(?i)") - svgRegex = regexp.MustCompile(`(?i)^\s*(?:<\?xml[^>]*>\s*)?(?:]*>\s*)?]*>[^*]*<\/svg>\s*$`) -) - -// isBinary checks if the given buffer is a binary file. -func isBinary(buf []byte) bool { - if len(buf) < 24 { - return false - } - for i := 0; i < 24; i++ { - charCode, _ := utf8.DecodeRuneInString(string(buf[i])) - if charCode == 65533 || charCode <= 8 { - return true - } - } - return false -} - -// Is returns true if the given buffer is a valid SVG image. -func Is(buf []byte) bool { - return !isBinary(buf) && svgRegex.Match(htmlCommentRegex.ReplaceAll(buf, []byte{})) -} - -// IsSVG returns true if the given buffer is a valid SVG image. -// Alias to: Is() -func IsSVG(buf []byte) bool { - return Is(buf) -} diff --git a/vendor/github.com/onsi/gomega/gstruct/errors/nested_types.go b/vendor/github.com/onsi/gomega/gstruct/errors/nested_types.go deleted file mode 100644 index 188492b21..000000000 --- a/vendor/github.com/onsi/gomega/gstruct/errors/nested_types.go +++ /dev/null @@ -1,72 +0,0 @@ -package errors - -import ( - "fmt" - "strings" - - "github.com/onsi/gomega/types" -) - -// A stateful matcher that nests other matchers within it and preserves the error types of the -// nested matcher failures. -type NestingMatcher interface { - types.GomegaMatcher - - // Returns the failures of nested matchers. - Failures() []error -} - -// An error type for labeling errors on deeply nested matchers. -type NestedError struct { - Path string - Err error -} - -func (e *NestedError) Error() string { - // Indent Errors. - indented := strings.Replace(e.Err.Error(), "\n", "\n\t", -1) - return fmt.Sprintf("%s:\n\t%v", e.Path, indented) -} - -// Create a NestedError with the given path. -// If err is a NestedError, prepend the path to it. -// If err is an AggregateError, recursively Nest each error. -func Nest(path string, err error) error { - if ag, ok := err.(AggregateError); ok { - var errs AggregateError - for _, e := range ag { - errs = append(errs, Nest(path, e)) - } - return errs - } - if ne, ok := err.(*NestedError); ok { - return &NestedError{ - Path: path + ne.Path, - Err: ne.Err, - } - } - return &NestedError{ - Path: path, - Err: err, - } -} - -// An error type for treating multiple errors as a single error. -type AggregateError []error - -// Error is part of the error interface. -func (err AggregateError) Error() string { - if len(err) == 0 { - // This should never happen, really. - return "" - } - if len(err) == 1 { - return err[0].Error() - } - result := fmt.Sprintf("[%s", err[0].Error()) - for i := 1; i < len(err); i++ { - result += fmt.Sprintf(", %s", err[i].Error()) - } - result += "]" - return result -} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/clients/clients.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/clients/clients.go index 1868911aa..9bde88076 100644 --- a/vendor/github.com/openshift-kni/eco-goinfra/pkg/clients/clients.go +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/clients/clients.go @@ -27,11 +27,6 @@ import ( v1security "github.com/openshift/client-go/security/clientset/versioned/typed/security/v1" mcv1 "github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1" ptpV1 "github.com/openshift/ptp-operator/pkg/client/clientset/versioned/typed/ptp/v1" - olmv1 "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1" - olm "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1" - - pkgManifestV1 "github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1" - clientPkgManifestV1 "github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/typed/operators/v1" apiExt "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/runtime" @@ -132,13 +127,10 @@ type Settings struct { runtimeClient.Client ptpV1.PtpV1Interface v1security.SecurityV1Interface - olm.OperatorsV1alpha1Interface clientNetAttDefV1.K8sCniCncfIoV1Interface dynamic.Interface - olmv1.OperatorsV1Interface MultiNetworkPolicyClient multinetpolicyclientv1.K8sCniCncfIoV1beta1Interface multinetpolicyclientv1.K8sCniCncfIoV1beta1Interface - PackageManifestInterface clientPkgManifestV1.OperatorsV1Interface operatorv1alpha1.OperatorV1alpha1Interface grafanaV4V1Alpha1.Grafana LocalVolumeInterface lsov1alpha1.LocalVolumeSet @@ -193,11 +185,8 @@ func New(kubeconfig string) *Settings { clientSet.NetworkingV1Interface = networkV1Client.NewForConfigOrDie(config) clientSet.PtpV1Interface = ptpV1.NewForConfigOrDie(config) clientSet.RbacV1Interface = rbacV1Client.NewForConfigOrDie(config) - clientSet.OperatorsV1alpha1Interface = olm.NewForConfigOrDie(config) clientSet.K8sCniCncfIoV1Interface = clientNetAttDefV1.NewForConfigOrDie(config) clientSet.Interface = dynamic.NewForConfigOrDie(config) - clientSet.OperatorsV1Interface = olmv1.NewForConfigOrDie(config) - clientSet.PackageManifestInterface = clientPkgManifestV1.NewForConfigOrDie(config) clientSet.SecurityV1Interface = v1security.NewForConfigOrDie(config) clientSet.OperatorV1alpha1Interface = operatorv1alpha1.NewForConfigOrDie(config) clientSet.MachineV1beta1Interface = machinev1beta1client.NewForConfigOrDie(config) @@ -326,10 +315,6 @@ func SetScheme(crScheme *runtime.Scheme) error { return err } - if err := pkgManifestV1.AddToScheme(crScheme); err != nil { - return err - } - if err := nmstatev1.AddToScheme(crScheme); err != nil { return err } @@ -673,7 +658,6 @@ func GetModifiableTestClients(tcp TestClientParams) (*Settings, *fakeRuntimeClie return nil, nil } } - // Add fake runtime client to clientSet runtime client clientBuilder := fakeRuntimeClient.NewClientBuilder().WithScheme(clientSet.scheme). WithRuntimeObjects(genericClientObjects...) diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/packagemanifest.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/packagemanifest.go index c84ad63ba..aec256b26 100644 --- a/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/packagemanifest.go +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/packagemanifest.go @@ -4,12 +4,16 @@ import ( "context" "fmt" + "k8s.io/apimachinery/pkg/fields" + "k8s.io/apimachinery/pkg/labels" + "github.com/golang/glog" "github.com/openshift-kni/eco-goinfra/pkg/clients" "github.com/openshift-kni/eco-goinfra/pkg/msg" - pkgManifestV1 "github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1" + operatorv1 "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1" k8serrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtimeClient "sigs.k8s.io/controller-runtime/pkg/client" ) // PackageManifestBuilder provides a struct for PackageManifest object from the cluster @@ -17,11 +21,11 @@ import ( type PackageManifestBuilder struct { // PackageManifest definition. Used to create // PackageManifest object with minimum set of required elements. - Definition *pkgManifestV1.PackageManifest + Definition *operatorv1.PackageManifest // Created PackageManifest object on the cluster. - Object *pkgManifestV1.PackageManifest + Object *operatorv1.PackageManifest // api client to interact with the cluster. - apiClient *clients.Settings + apiClient runtimeClient.Client // errorMsg is processed before PackageManifest object is created. errorMsg string } @@ -30,9 +34,23 @@ type PackageManifestBuilder struct { func PullPackageManifest(apiClient *clients.Settings, name, nsname string) (*PackageManifestBuilder, error) { glog.V(100).Infof("Pulling existing PackageManifest name %s in namespace %s", name, nsname) + if apiClient == nil { + glog.V(100).Infof("The apiClient cannot be nil") + + return nil, fmt.Errorf("packagemanifest 'apiClient' cannot be empty") + } + + err := apiClient.AttachScheme(operatorv1.AddToScheme) + + if err != nil { + glog.V(100).Infof("Failed to add operatorv1 scheme to client schemes") + + return nil, err + } + builder := &PackageManifestBuilder{ - apiClient: apiClient, - Definition: &pkgManifestV1.PackageManifest{ + apiClient: apiClient.Client, + Definition: &operatorv1.PackageManifest{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: nsname, @@ -43,17 +61,17 @@ func PullPackageManifest(apiClient *clients.Settings, name, nsname string) (*Pac if name == "" { glog.V(100).Infof("The Name of the PackageManifest is empty") - builder.errorMsg = "PackageManifest 'name' cannot be empty" + return nil, fmt.Errorf("packageManifest 'name' cannot be empty") } if nsname == "" { glog.V(100).Infof("The Namespace of the PackageManifest is empty") - builder.errorMsg = "PackageManifest 'nsname' cannot be empty" + return nil, fmt.Errorf("packageManifest 'nsname' cannot be empty") } if !builder.Exists() { - return nil, fmt.Errorf("PackageManifest object %s does not exist in namespace %s", name, nsname) + return nil, fmt.Errorf("packageManifest object %s does not exist in namespace %s", name, nsname) } builder.Definition = builder.Object @@ -67,9 +85,37 @@ func PullPackageManifestByCatalog(apiClient *clients.Settings, name, nsname, glog.V(100).Infof("Pulling existing PackageManifest name %s in namespace %s and from catalog %s", name, nsname, catalog) - packageManifests, err := ListPackageManifest(apiClient, nsname, metav1.ListOptions{ - LabelSelector: fmt.Sprintf("catalog=%s", catalog), - FieldSelector: fmt.Sprintf("metadata.name=%s", name), + if name == "" { + glog.V(100).Infof("The Name of the PackageManifest is empty") + + return nil, fmt.Errorf("packageManifest 'name' cannot be empty") + } + + fieldSelector, err := fields.ParseSelector(fmt.Sprintf("metadata.name=%s", name)) + + if err != nil { + glog.V(100).Infof("Failed to parse invalid packageManifest name %s", name) + + return nil, err + } + + if catalog == "" { + glog.V(100).Infof("The Catalog of the PackageManifest is empty") + + return nil, fmt.Errorf("packageManifest 'catalog' cannot be empty") + } + + labelSelector, err := labels.Parse(fmt.Sprintf("catalog=%s", catalog)) + + if err != nil { + glog.V(100).Infof("Failed to parse invalid catalog name %s", catalog) + + return nil, err + } + + packageManifests, err := ListPackageManifest(apiClient, nsname, runtimeClient.ListOptions{ + LabelSelector: labelSelector, + FieldSelector: fieldSelector, }) if err != nil { @@ -94,6 +140,32 @@ func PullPackageManifestByCatalog(apiClient *clients.Settings, name, nsname, return packageManifests[0], nil } +// Get returns PackageManifest object if found. +func (builder *PackageManifestBuilder) Get() (*operatorv1.PackageManifest, error) { + if valid, err := builder.validate(); !valid { + return nil, err + } + + glog.V(100).Infof( + "Collecting packageManifest object %s in namespace %s", + builder.Definition.Name, builder.Definition.Namespace) + + packageManifest := &operatorv1.PackageManifest{} + err := builder.apiClient.Get(context.TODO(), + runtimeClient.ObjectKey{Name: builder.Definition.Name, Namespace: builder.Definition.Namespace}, + packageManifest) + + if err != nil { + glog.V(100).Infof( + "PackageManifest object %s does not exist in namespace %s", + builder.Definition.Name, builder.Definition.Namespace) + + return nil, err + } + + return packageManifest, nil +} + // Exists checks whether the given PackageManifest exists. func (builder *PackageManifestBuilder) Exists() bool { if valid, _ := builder.validate(); !valid { @@ -104,8 +176,7 @@ func (builder *PackageManifestBuilder) Exists() bool { "Checking if PackageManifest %s exists", builder.Definition.Name) var err error - builder.Object, err = builder.apiClient.PackageManifestInterface.PackageManifests( - builder.Definition.Namespace).Get(context.TODO(), builder.Definition.Name, metav1.GetOptions{}) + builder.Object, err = builder.Get() return err == nil || !k8serrors.IsNotFound(err) } @@ -123,8 +194,7 @@ func (builder *PackageManifestBuilder) Delete() error { return nil } - err := builder.apiClient.PackageManifestInterface.PackageManifests(builder.Definition.Namespace).Delete( - context.TODO(), builder.Object.Name, metav1.DeleteOptions{}) + err := builder.apiClient.Delete(context.TODO(), builder.Definition) if err != nil { return err diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/packagemanifestlist.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/packagemanifestlist.go index 928d605e7..2384b9c12 100644 --- a/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/packagemanifestlist.go +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/packagemanifestlist.go @@ -4,23 +4,39 @@ import ( "context" "fmt" + operatorv1 "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1" + "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/golang/glog" "github.com/openshift-kni/eco-goinfra/pkg/clients" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // ListPackageManifest returns PackageManifest inventory in the given namespace. func ListPackageManifest( apiClient *clients.Settings, nsname string, - options ...metav1.ListOptions) ([]*PackageManifestBuilder, error) { + options ...client.ListOptions) ([]*PackageManifestBuilder, error) { if nsname == "" { glog.V(100).Infof("packagemanifest 'nsname' parameter can not be empty") return nil, fmt.Errorf("failed to list packagemanifests, 'nsname' parameter is empty") } - passedOptions := metav1.ListOptions{} + if apiClient == nil { + glog.V(100).Infof("The apiClient cannot be nil") + + return nil, fmt.Errorf("failed to list packageManifest, 'apiClient' parameter is empty") + } + + err := apiClient.AttachScheme(operatorv1.AddToScheme) + + if err != nil { + glog.V(100).Infof("Failed to add packageManifest scheme to client schemes") + + return nil, err + } + + passedOptions := client.ListOptions{} logMessage := fmt.Sprintf("Listing PackageManifests in the namespace %s", nsname) if len(options) > 1 { @@ -36,8 +52,8 @@ func ListPackageManifest( glog.V(100).Infof(logMessage) - pkgManifestList, err := apiClient.PackageManifestInterface.PackageManifests(nsname).List(context.TODO(), - passedOptions) + pkgManifestList := new(operatorv1.PackageManifestList) + err = apiClient.List(context.TODO(), pkgManifestList, &passedOptions) if err != nil { glog.V(100).Infof("Failed to list PackageManifests in the namespace %s due to %s", @@ -51,7 +67,7 @@ func ListPackageManifest( for _, runningPkgManifest := range pkgManifestList.Items { copiedPkgManifest := runningPkgManifest pkgManifestBuilder := &PackageManifestBuilder{ - apiClient: apiClient, + apiClient: apiClient.Client, Object: &copiedPkgManifest, Definition: &copiedPkgManifest, } diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/metallb/mlboperator/metallb_types.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/metallb/mlboperator/metallb_types.go index fd1fd696c..267797e51 100644 --- a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/metallb/mlboperator/metallb_types.go +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/metallb/mlboperator/metallb_types.go @@ -37,9 +37,10 @@ const ( ) const ( - FRRMode BGPType = "frr" - NativeMode BGPType = "native" - FRRK8sMode BGPType = "frr-k8s" + FRRMode BGPType = "frr" + NativeMode BGPType = "native" + FRRK8sMode BGPType = "frr-k8s" + FRRK8sExternalMode BGPType = "frr-k8s-external" ) type BGPType string @@ -103,6 +104,8 @@ type MetalLBSpec struct { type FRRK8SConfig struct { // A list of cidrs we want always to block for incoming routes AlwaysBlock []string `json:"alwaysBlock,omitempty"` + // The namespace frr-k8s is running on in case of frr-k8s external mode + Namespace string `json:"namespace,omitempty"` } type Config struct { diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/metallb/mlboperator/metallb_webhook.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/metallb/mlboperator/metallb_webhook.go index ce0a4b897..93d94db51 100644 --- a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/metallb/mlboperator/metallb_webhook.go +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/metallb/mlboperator/metallb_webhook.go @@ -29,7 +29,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) -func (metallb *MetalLB) SetupWebhookWithManager(mgr ctrl.Manager) error { +var ExternalFRRK8sNamespace string + +func (metallb *MetalLB) SetupWebhookWithManager(mgr ctrl.Manager, externalFRRK8sNamespace string) error { + ExternalFRRK8sNamespace = externalFRRK8sNamespace return ctrl.NewWebhookManagedBy(mgr). For(metallb). Complete() @@ -109,22 +112,24 @@ func (metallb *MetalLB) Validate() error { if metallb.Spec.BGPBackend != "" && metallb.Spec.BGPBackend != NativeMode && metallb.Spec.BGPBackend != FRRK8sMode && + metallb.Spec.BGPBackend != FRRK8sExternalMode && metallb.Spec.BGPBackend != FRRMode { return errors.New("Invalid BGP Backend, must be one of native, frr, frr-k8s") } - if metallb.Spec.BGPBackend != FRRK8sMode && - metallb.Spec.FRRK8SConfig != nil { - return fmt.Errorf("can't apply frrk8s config while running in %s mode", metallb.Spec.BGPBackend) - } - - if err := validateFRRK8sConfig(metallb.Spec.FRRK8SConfig); err != nil { + if err := validateFRRK8sConfig(metallb.Spec); err != nil { return err } return nil } -func validateFRRK8sConfig(config *FRRK8SConfig) error { +func validateFRRK8sConfig(spec MetalLBSpec) error { + config := spec.FRRK8SConfig + if spec.BGPBackend == FRRK8sExternalMode && + ExternalFRRK8sNamespace == "" && (config == nil || config.Namespace == "") { + return errors.New("bgp backend: frrk8s external and no default or user provided namespace") + } + if config == nil { return nil } diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/doc.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/doc.go similarity index 100% rename from vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/doc.go rename to vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/doc.go diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/packagemanifest_types.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/packagemanifest_types.go similarity index 86% rename from vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/packagemanifest_types.go rename to vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/packagemanifest_types.go index 657a887ad..f35e41967 100644 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/packagemanifest_types.go +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/packagemanifest_types.go @@ -1,8 +1,8 @@ package operators import ( - "github.com/operator-framework/api/pkg/lib/version" - operatorv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1" + "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/version" + operatorv1alpha1 "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -46,9 +46,6 @@ type PackageManifestStatus struct { // PackageName is the name of the overall package, ala . PackageName string - // Deprecation is an optional field which contains information if the package is deprecated. - Deprecation *Deprecation - // Channels are the declared channels for the package, ala . // +listType=set Channels []PackageChannel @@ -84,9 +81,6 @@ type PackageChannel struct { // CurrentCSVSpec holds the spec of the current CSV CurrentCSVDesc CSVDescription - // Deprecation is an optional field which contains information if the channel is deprecated. - Deprecation *Deprecation - // Entries lists all CSVs in the channel. Entries []ChannelEntry } @@ -98,15 +92,6 @@ type ChannelEntry struct { // Version is the version of the bundle for this entry. Version string - - // Deprecation is an optional field which contains information if the channel entry is deprecated. - Deprecation *Deprecation -} - -// Deprecation conveys information regarding a deprecated resource. -type Deprecation struct { - // Message is a human readable message describing the deprecation. - Message string } // CSVDescription defines a description of a CSV diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/register.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/register.go similarity index 100% rename from vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/register.go rename to vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/register.go diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1/doc.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/doc.go similarity index 100% rename from vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1/doc.go rename to vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/doc.go diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1/packagemanifest_types.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/packagemanifest_types.go similarity index 87% rename from vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1/packagemanifest_types.go rename to vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/packagemanifest_types.go index e9cf6a1c1..ab5ce10c6 100644 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1/packagemanifest_types.go +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/packagemanifest_types.go @@ -1,8 +1,8 @@ package v1 import ( - "github.com/operator-framework/api/pkg/lib/version" - operatorv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1" + "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/version" + operatorv1alpha1 "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -46,9 +46,6 @@ type PackageManifestStatus struct { // PackageName is the name of the overall package, ala `etcd`. PackageName string `json:"packageName"` - // Deprecation is an optional field which contains information if the package is deprecated. - Deprecation *Deprecation `json:"deprecation,omitempty"` - // Channels are the declared channels for the package, ala `stable` or `alpha`. // +listType=set Channels []PackageChannel `json:"channels"` @@ -59,12 +56,6 @@ type PackageManifestStatus struct { DefaultChannel string `json:"defaultChannel"` } -// Deprecation conveys information regarding a deprecated resource. -type Deprecation struct { - // Message is a human readable message describing the deprecation. - Message string `json:"message"` -} - // GetDefaultChannel gets the default channel or returns the only one if there's only one. returns empty string if it // can't determine the default func (m PackageManifest) GetDefaultChannel() string { @@ -90,9 +81,6 @@ type PackageChannel struct { // CurrentCSVSpec holds the spec of the current CSV CurrentCSVDesc CSVDescription `json:"currentCSVDesc,omitempty"` - // Deprecation is an optional field which contains information if the channel is deprecated. - Deprecation *Deprecation `json:"deprecation,omitempty"` - // Entries lists all CSVs in the channel, with their upgrade edges. Entries []ChannelEntry `json:"entries"` } @@ -104,9 +92,6 @@ type ChannelEntry struct { // Version is the version of the bundle for this entry. Version string `json:"version,omitempty"` - - // Deprecation is an optional field which contains information if the channel entry is deprecated. - Deprecation *Deprecation `json:"deprecation,omitempty"` } // CSVDescription defines a description of a CSV diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1/register.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/register.go similarity index 95% rename from vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1/register.go rename to vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/register.go index dfd5332ee..9b9a26dee 100644 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1/register.go +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/register.go @@ -5,7 +5,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - "github.com/operator-framework/api/pkg/operators" + "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators" ) const ( diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1/zz_generated.conversion.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/zz_generated.conversion.go similarity index 90% rename from vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1/zz_generated.conversion.go rename to vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/zz_generated.conversion.go index 5ae5b1c98..a3a631b16 100644 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1/zz_generated.conversion.go +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/zz_generated.conversion.go @@ -24,8 +24,8 @@ package v1 import ( unsafe "unsafe" - v1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1" - operators "github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators" + v1alpha1 "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1" + operators "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" @@ -68,16 +68,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*Deprecation)(nil), (*operators.Deprecation)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1_Deprecation_To_operators_Deprecation(a.(*Deprecation), b.(*operators.Deprecation), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*operators.Deprecation)(nil), (*Deprecation)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_operators_Deprecation_To_v1_Deprecation(a.(*operators.Deprecation), b.(*Deprecation), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*Icon)(nil), (*operators.Icon)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1_Icon_To_operators_Icon(a.(*Icon), b.(*operators.Icon), scope) }); err != nil { @@ -230,7 +220,6 @@ func Convert_operators_CSVDescription_To_v1_CSVDescription(in *operators.CSVDesc func autoConvert_v1_ChannelEntry_To_operators_ChannelEntry(in *ChannelEntry, out *operators.ChannelEntry, s conversion.Scope) error { out.Name = in.Name out.Version = in.Version - out.Deprecation = (*operators.Deprecation)(unsafe.Pointer(in.Deprecation)) return nil } @@ -242,7 +231,6 @@ func Convert_v1_ChannelEntry_To_operators_ChannelEntry(in *ChannelEntry, out *op func autoConvert_operators_ChannelEntry_To_v1_ChannelEntry(in *operators.ChannelEntry, out *ChannelEntry, s conversion.Scope) error { out.Name = in.Name out.Version = in.Version - out.Deprecation = (*Deprecation)(unsafe.Pointer(in.Deprecation)) return nil } @@ -251,26 +239,6 @@ func Convert_operators_ChannelEntry_To_v1_ChannelEntry(in *operators.ChannelEntr return autoConvert_operators_ChannelEntry_To_v1_ChannelEntry(in, out, s) } -func autoConvert_v1_Deprecation_To_operators_Deprecation(in *Deprecation, out *operators.Deprecation, s conversion.Scope) error { - out.Message = in.Message - return nil -} - -// Convert_v1_Deprecation_To_operators_Deprecation is an autogenerated conversion function. -func Convert_v1_Deprecation_To_operators_Deprecation(in *Deprecation, out *operators.Deprecation, s conversion.Scope) error { - return autoConvert_v1_Deprecation_To_operators_Deprecation(in, out, s) -} - -func autoConvert_operators_Deprecation_To_v1_Deprecation(in *operators.Deprecation, out *Deprecation, s conversion.Scope) error { - out.Message = in.Message - return nil -} - -// Convert_operators_Deprecation_To_v1_Deprecation is an autogenerated conversion function. -func Convert_operators_Deprecation_To_v1_Deprecation(in *operators.Deprecation, out *Deprecation, s conversion.Scope) error { - return autoConvert_operators_Deprecation_To_v1_Deprecation(in, out, s) -} - func autoConvert_v1_Icon_To_operators_Icon(in *Icon, out *operators.Icon, s conversion.Scope) error { out.Base64Data = in.Base64Data out.Mediatype = in.Mediatype @@ -321,7 +289,6 @@ func autoConvert_v1_PackageChannel_To_operators_PackageChannel(in *PackageChanne if err := Convert_v1_CSVDescription_To_operators_CSVDescription(&in.CurrentCSVDesc, &out.CurrentCSVDesc, s); err != nil { return err } - out.Deprecation = (*operators.Deprecation)(unsafe.Pointer(in.Deprecation)) out.Entries = *(*[]operators.ChannelEntry)(unsafe.Pointer(&in.Entries)) return nil } @@ -337,7 +304,6 @@ func autoConvert_operators_PackageChannel_To_v1_PackageChannel(in *operators.Pac if err := Convert_operators_CSVDescription_To_v1_CSVDescription(&in.CurrentCSVDesc, &out.CurrentCSVDesc, s); err != nil { return err } - out.Deprecation = (*Deprecation)(unsafe.Pointer(in.Deprecation)) out.Entries = *(*[]ChannelEntry)(unsafe.Pointer(&in.Entries)) return nil } @@ -428,7 +394,6 @@ func autoConvert_v1_PackageManifestStatus_To_operators_PackageManifestStatus(in return err } out.PackageName = in.PackageName - out.Deprecation = (*operators.Deprecation)(unsafe.Pointer(in.Deprecation)) out.Channels = *(*[]operators.PackageChannel)(unsafe.Pointer(&in.Channels)) out.DefaultChannel = in.DefaultChannel return nil @@ -448,7 +413,6 @@ func autoConvert_operators_PackageManifestStatus_To_v1_PackageManifestStatus(in return err } out.PackageName = in.PackageName - out.Deprecation = (*Deprecation)(unsafe.Pointer(in.Deprecation)) out.Channels = *(*[]PackageChannel)(unsafe.Pointer(&in.Channels)) out.DefaultChannel = in.DefaultChannel return nil diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1/zz_generated.deepcopy.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/zz_generated.deepcopy.go similarity index 89% rename from vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1/zz_generated.deepcopy.go rename to vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/zz_generated.deepcopy.go index 45a63e69a..c867b5cbd 100644 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1/zz_generated.deepcopy.go +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/zz_generated.deepcopy.go @@ -22,7 +22,7 @@ limitations under the License. package v1 import ( - v1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1" + v1alpha1 "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -108,11 +108,6 @@ func (in *CSVDescription) DeepCopy() *CSVDescription { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ChannelEntry) DeepCopyInto(out *ChannelEntry) { *out = *in - if in.Deprecation != nil { - in, out := &in.Deprecation, &out.Deprecation - *out = new(Deprecation) - **out = **in - } return } @@ -126,22 +121,6 @@ func (in *ChannelEntry) DeepCopy() *ChannelEntry { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Deprecation) DeepCopyInto(out *Deprecation) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Deprecation. -func (in *Deprecation) DeepCopy() *Deprecation { - if in == nil { - return nil - } - out := new(Deprecation) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Icon) DeepCopyInto(out *Icon) { *out = *in @@ -178,17 +157,10 @@ func (in *Maintainer) DeepCopy() *Maintainer { func (in *PackageChannel) DeepCopyInto(out *PackageChannel) { *out = *in in.CurrentCSVDesc.DeepCopyInto(&out.CurrentCSVDesc) - if in.Deprecation != nil { - in, out := &in.Deprecation, &out.Deprecation - *out = new(Deprecation) - **out = **in - } if in.Entries != nil { in, out := &in.Entries, &out.Entries *out = make([]ChannelEntry, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } + copy(*out, *in) } return } @@ -284,11 +256,6 @@ func (in *PackageManifestSpec) DeepCopy() *PackageManifestSpec { func (in *PackageManifestStatus) DeepCopyInto(out *PackageManifestStatus) { *out = *in out.Provider = in.Provider - if in.Deprecation != nil { - in, out := &in.Deprecation, &out.Deprecation - *out = new(Deprecation) - **out = **in - } if in.Channels != nil { in, out := &in.Channels, &out.Channels *out = make([]PackageChannel, len(*in)) diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1/zz_generated.defaults.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/zz_generated.defaults.go similarity index 100% rename from vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1/zz_generated.defaults.go rename to vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/zz_generated.defaults.go diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/zz_generated.deepcopy.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/zz_generated.deepcopy.go similarity index 89% rename from vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/zz_generated.deepcopy.go rename to vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/zz_generated.deepcopy.go index 33a333b2d..500406b99 100644 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/zz_generated.deepcopy.go +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/zz_generated.deepcopy.go @@ -22,7 +22,7 @@ limitations under the License. package operators import ( - v1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1" + v1alpha1 "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -108,11 +108,6 @@ func (in *CSVDescription) DeepCopy() *CSVDescription { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ChannelEntry) DeepCopyInto(out *ChannelEntry) { *out = *in - if in.Deprecation != nil { - in, out := &in.Deprecation, &out.Deprecation - *out = new(Deprecation) - **out = **in - } return } @@ -126,22 +121,6 @@ func (in *ChannelEntry) DeepCopy() *ChannelEntry { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Deprecation) DeepCopyInto(out *Deprecation) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Deprecation. -func (in *Deprecation) DeepCopy() *Deprecation { - if in == nil { - return nil - } - out := new(Deprecation) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Icon) DeepCopyInto(out *Icon) { *out = *in @@ -178,17 +157,10 @@ func (in *Maintainer) DeepCopy() *Maintainer { func (in *PackageChannel) DeepCopyInto(out *PackageChannel) { *out = *in in.CurrentCSVDesc.DeepCopyInto(&out.CurrentCSVDesc) - if in.Deprecation != nil { - in, out := &in.Deprecation, &out.Deprecation - *out = new(Deprecation) - **out = **in - } if in.Entries != nil { in, out := &in.Entries, &out.Entries *out = make([]ChannelEntry, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } + copy(*out, *in) } return } @@ -284,11 +256,6 @@ func (in *PackageManifestSpec) DeepCopy() *PackageManifestSpec { func (in *PackageManifestStatus) DeepCopyInto(out *PackageManifestStatus) { *out = *in out.Provider = in.Provider - if in.Deprecation != nil { - in, out := &in.Deprecation, &out.Deprecation - *out = new(Deprecation) - **out = **in - } if in.Channels != nil { in, out := &in.Channels, &out.Channels *out = make([]PackageChannel, len(*in)) diff --git a/vendor/github.com/operator-framework/api/pkg/constraints/cel.go b/vendor/github.com/operator-framework/api/pkg/constraints/cel.go deleted file mode 100644 index 1fb10b5dd..000000000 --- a/vendor/github.com/operator-framework/api/pkg/constraints/cel.go +++ /dev/null @@ -1,135 +0,0 @@ -package constraints - -import ( - "fmt" - - "github.com/google/cel-go/cel" - "github.com/google/cel-go/checker/decls" - "github.com/google/cel-go/common/types" - "github.com/google/cel-go/common/types/ref" - "github.com/google/cel-go/interpreter/functions" - exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1" - - "github.com/blang/semver/v4" -) - -// PropertiesKey is the key for bundle properties map (input data for CEL evaluation) -const PropertiesKey = "properties" - -// Cel is a struct representing CEL expression information -type Cel struct { - // The CEL expression - Rule string `json:"rule" yaml:"rule"` -} - -// NewCelEnvironment returns a CEL environment which can be used to -// evaluate CEL expression and an error if occurs -func NewCelEnvironment() *CelEnvironment { - env, err := cel.NewEnv(cel.Declarations( - decls.NewVar(PropertiesKey, decls.NewListType(decls.NewMapType(decls.String, decls.Any)))), - cel.Lib(semverLib{}), - ) - // If an error occurs here, it means the CEL enviroment is unable to load - // configuration for custom libraries propertly. Hence, the CEL enviroment is - // unusable. Panic here will cause the program to fail immediately to prevent - // cascading failures later on when this CEL env is in use. - if err != nil { - panic(err) - } - return &CelEnvironment{ - env: env, - } -} - -// CelEnvironment is a struct that encapsulates CEL custom program enviroment -type CelEnvironment struct { - env *cel.Env -} - -// CelProgram is a struct that encapsulates compiled CEL program -type CelProgram struct { - program cel.Program -} - -/* -This section of code is for custom library for semver comparison in CEL -The code is inspired by https://github.com/google/cel-go/blob/master/cel/cel_test.go#L46 - -The semver_compare is written based on `Compare` function in https://github.com/blang/semver -particularly in https://github.com/blang/semver/blob/master/semver.go#L125 - -Example: -`semver_compare(v1, v2)` is equivalent of `v1.Compare(v2)` in blang/semver library - -The result is `semver_compare` is an integer just like `Compare`. So, the CEL -expression `semver_compare(v1, v2) == 0` is equivalent v1.Compare(v2) == 0. In -the other words, it checks if v1 is equal to v2 in term of semver comparision. -*/ -type semverLib struct{} - -func (semverLib) CompileOptions() []cel.EnvOption { - return []cel.EnvOption{ - cel.Declarations( - decls.NewFunction("semver_compare", - decls.NewOverload("semver_compare", - []*exprpb.Type{decls.Any, decls.Any}, - decls.Int))), - } -} - -func (semverLib) ProgramOptions() []cel.ProgramOption { - return []cel.ProgramOption{ - cel.Functions( - &functions.Overload{ - Operator: "semver_compare", - Binary: semverCompare, - }, - ), - } -} - -func semverCompare(val1, val2 ref.Val) ref.Val { - v1, err := semver.ParseTolerant(fmt.Sprint(val1.Value())) - if err != nil { - return types.ValOrErr(val1, "unable to parse '%v' to semver format", val1.Value()) - } - - v2, err := semver.ParseTolerant(fmt.Sprint(val2.Value())) - if err != nil { - return types.ValOrErr(val2, "unable to parse '%v' to semver format", val2.Value()) - } - return types.Int(v1.Compare(v2)) -} - -// Evaluate to evaluate the compiled CEL program against input data (map) -func (e CelProgram) Evaluate(data map[string]interface{}) (bool, error) { - result, _, err := e.program.Eval(data) - if err != nil { - return false, err - } - - // we should have already ensured that this will be types.Bool during compilation - if b, ok := result.Value().(bool); ok { - return b, nil - } - return false, fmt.Errorf("cel expression evalutated to %T, not bool", result.Value()) -} - -// Validate to validate the CEL expression string by compiling it into CEL program -func (e *CelEnvironment) Validate(rule string) (CelProgram, error) { - var celProg CelProgram - ast, issues := e.env.Compile(rule) - if err := issues.Err(); err != nil { - return celProg, err - } - - if ast.ResultType() != decls.Bool { - return celProg, fmt.Errorf("cel expressions must have type Bool") - } - - prog, err := e.env.Program(ast) - if err != nil { - return celProg, err - } - return CelProgram{program: prog}, nil -} diff --git a/vendor/github.com/operator-framework/api/pkg/constraints/constraint.go b/vendor/github.com/operator-framework/api/pkg/constraints/constraint.go deleted file mode 100644 index f65e8725d..000000000 --- a/vendor/github.com/operator-framework/api/pkg/constraints/constraint.go +++ /dev/null @@ -1,87 +0,0 @@ -package constraints - -import ( - "bytes" - "encoding/json" - "fmt" -) - -// OLMConstraintType is the schema "type" key for all constraints known to OLM -// (except for legacy types). -const OLMConstraintType = "olm.constraint" - -// Constraint holds parsed, potentially nested dependency constraints. -type Constraint struct { - // Constraint failure message that surfaces in resolution - // This field is optional - FailureMessage string `json:"failureMessage,omitempty" yaml:"failureMessage,omitempty"` - - // The cel struct that contraints CEL expression - Cel *Cel `json:"cel,omitempty" yaml:"cel,omitempty"` - - // Package defines a constraint for a package within a version range. - Package *PackageConstraint `json:"package,omitempty" yaml:"package,omitempty"` - - // GVK defines a constraint for a GVK. - GVK *GVKConstraint `json:"gvk,omitempty" yaml:"gvk,omitempty"` - - // All, Any, and Not are compound constraints. See this enhancement for details: - // https://github.com/operator-framework/enhancements/blob/master/enhancements/compound-bundle-constraints.md - All *CompoundConstraint `json:"all,omitempty" yaml:"all,omitempty"` - Any *CompoundConstraint `json:"any,omitempty" yaml:"any,omitempty"` - // A note on Not: this constraint isn't particularly useful by itself. - // It should be used within an All constraint alongside some other constraint type - // since saying "do not use any of these GVKs/packages/etc." without an alternative - // doesn't make sense. - Not *CompoundConstraint `json:"not,omitempty" yaml:"not,omitempty"` -} - -// CompoundConstraint holds a list of potentially nested constraints -// over which a boolean operation is applied. -type CompoundConstraint struct { - Constraints []Constraint `json:"constraints" yaml:"constraints"` -} - -// GVKConstraint defines a GVK constraint. -type GVKConstraint struct { - Group string `json:"group" yaml:"group"` - Kind string `json:"kind" yaml:"kind"` - Version string `json:"version" yaml:"version"` -} - -// PackageConstraint defines a package constraint. -type PackageConstraint struct { - // PackageName is the name of the package. - PackageName string `json:"packageName" yaml:"packageName"` - // VersionRange required for the package. - VersionRange string `json:"versionRange" yaml:"versionRange"` -} - -// maxConstraintSize defines the maximum raw size in bytes of an olm.constraint. -// 64Kb seems reasonable, since this number allows for long description strings -// and either few deep nestings or shallow nestings and long constraints lists, -// but not both. -// QUESTION: make this configurable? -const maxConstraintSize = 2 << 16 - -// ErrMaxConstraintSizeExceeded is returned when a constraint's size > maxConstraintSize. -var ErrMaxConstraintSizeExceeded = fmt.Errorf("olm.constraint value is greater than max constraint size %d bytes", maxConstraintSize) - -// Parse parses an olm.constraint property's value recursively into a Constraint. -// Unknown value schemas result in an error. Constraints that exceed the number of bytes -// defined by maxConstraintSize result results in an error. -func Parse(v json.RawMessage) (c Constraint, err error) { - // There is no way to explicitly limit nesting depth. - // From https://github.com/golang/go/issues/31789#issuecomment-538134396, - // the recommended approach is to error out if raw input size - // is greater than some threshold. - if len(v) > maxConstraintSize { - return c, ErrMaxConstraintSizeExceeded - } - - d := json.NewDecoder(bytes.NewBuffer(v)) - d.DisallowUnknownFields() - err = d.Decode(&c) - - return -} diff --git a/vendor/github.com/operator-framework/api/pkg/operators/v1/doc.go b/vendor/github.com/operator-framework/api/pkg/operators/v1/doc.go deleted file mode 100644 index dec83277b..000000000 --- a/vendor/github.com/operator-framework/api/pkg/operators/v1/doc.go +++ /dev/null @@ -1,4 +0,0 @@ -// +groupName=operators.coreos.com - -// Package v1 contains resources types for version v1 of the operators.coreos.com API group. -package v1 diff --git a/vendor/github.com/operator-framework/api/pkg/operators/v1/groupversion_info.go b/vendor/github.com/operator-framework/api/pkg/operators/v1/groupversion_info.go deleted file mode 100644 index 089ec8783..000000000 --- a/vendor/github.com/operator-framework/api/pkg/operators/v1/groupversion_info.go +++ /dev/null @@ -1,28 +0,0 @@ -// +kubebuilder:object:generate=true - -// Package v1 contains API Schema definitions for the operator v1 API group. -package v1 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/scheme" -) - -var ( - // GroupVersion is group version used to register these objects. - GroupVersion = schema.GroupVersion{Group: "operators.coreos.com", Version: "v1"} - - // SchemeGroupVersion is required for compatibility with client generation. - SchemeGroupVersion = GroupVersion - - // SchemeBuilder is used to add go types to the GroupVersionKind scheme. - SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} - - // AddToScheme adds the types in this group-version to the given scheme. - AddToScheme = SchemeBuilder.AddToScheme -) - -// Resource takes an unqualified resource and returns a Group qualified GroupResource -func Resource(resource string) schema.GroupResource { - return GroupVersion.WithResource(resource).GroupResource() -} diff --git a/vendor/github.com/operator-framework/api/pkg/operators/v1/olmconfig_types.go b/vendor/github.com/operator-framework/api/pkg/operators/v1/olmconfig_types.go deleted file mode 100644 index c15b5114f..000000000 --- a/vendor/github.com/operator-framework/api/pkg/operators/v1/olmconfig_types.go +++ /dev/null @@ -1,90 +0,0 @@ -package v1 - -import ( - "time" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -const ( - DisabledCopiedCSVsConditionType = "DisabledCopiedCSVs" -) - -// OLMConfigSpec is the spec for an OLMConfig resource. -type OLMConfigSpec struct { - Features *Features `json:"features,omitempty"` -} - -// Features contains the list of configurable OLM features. -type Features struct { - - // DisableCopiedCSVs is used to disable OLM's "Copied CSV" feature - // for operators installed at the cluster scope, where a cluster - // scoped operator is one that has been installed in an - // OperatorGroup that targets all namespaces. - // When reenabled, OLM will recreate the "Copied CSVs" for each - // cluster scoped operator. - DisableCopiedCSVs *bool `json:"disableCopiedCSVs,omitempty"` - // PackageServerSyncInterval is used to define the sync interval for - // packagerserver pods. Packageserver pods periodically check the - // status of CatalogSources; this specifies the period using duration - // format (e.g. "60m"). For this parameter, only hours ("h"), minutes - // ("m"), and seconds ("s") may be specified. When not specified, the - // period defaults to the value specified within the packageserver. - // +optional - // +kubebuilder:validation:Type=string - // +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(s|m|h))+$" - PackageServerSyncInterval *metav1.Duration `json:"packageServerSyncInterval,omitempty"` -} - -// OLMConfigStatus is the status for an OLMConfig resource. -type OLMConfigStatus struct { - Conditions []metav1.Condition `json:"conditions,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +genclient -// +genclient:nonNamespaced -// +kubebuilder:storageversion -// +kubebuilder:resource:categories=olm,scope=Cluster -// +kubebuilder:subresource:status - -// OLMConfig is a resource responsible for configuring OLM. -type OLMConfig struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata"` - - Spec OLMConfigSpec `json:"spec,omitempty"` - Status OLMConfigStatus `json:"status,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// OLMConfigList is a list of OLMConfig resources. -type OLMConfigList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata"` - // +listType=set - Items []OLMConfig `json:"items"` -} - -func init() { - SchemeBuilder.Register(&OLMConfig{}, &OLMConfigList{}) -} - -// CopiedCSVsAreEnabled returns true if and only if the olmConfigs DisableCopiedCSVs is set and true, -// otherwise false is returned -func (config *OLMConfig) CopiedCSVsAreEnabled() bool { - if config == nil || config.Spec.Features == nil || config.Spec.Features.DisableCopiedCSVs == nil { - return true - } - - return !*config.Spec.Features.DisableCopiedCSVs -} - -func (config *OLMConfig) PackageServerSyncInterval() *time.Duration { - if config == nil || config.Spec.Features == nil || config.Spec.Features.PackageServerSyncInterval == nil { - return nil - } - return &config.Spec.Features.PackageServerSyncInterval.Duration -} diff --git a/vendor/github.com/operator-framework/api/pkg/operators/v1/operator_types.go b/vendor/github.com/operator-framework/api/pkg/operators/v1/operator_types.go deleted file mode 100644 index af735950f..000000000 --- a/vendor/github.com/operator-framework/api/pkg/operators/v1/operator_types.go +++ /dev/null @@ -1,88 +0,0 @@ -package v1 - -import ( - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// OperatorSpec defines the desired state of Operator -type OperatorSpec struct{} - -// OperatorStatus defines the observed state of an Operator and its components -type OperatorStatus struct { - // Components describes resources that compose the operator. - // +optional - Components *Components `json:"components,omitempty"` -} - -// ConditionType codifies a condition's type. -type ConditionType string - -// Condition represent the latest available observations of an component's state. -type Condition struct { - // Type of condition. - Type ConditionType `json:"type"` - // Status of the condition, one of True, False, Unknown. - Status corev1.ConditionStatus `json:"status"` - // The reason for the condition's last transition. - // +optional - Reason string `json:"reason,omitempty"` - // A human readable message indicating details about the transition. - // +optional - Message string `json:"message,omitempty"` - // Last time the condition was probed - // +optional - LastUpdateTime *metav1.Time `json:"lastUpdateTime,omitempty"` - // Last time the condition transitioned from one status to another. - // +optional - LastTransitionTime *metav1.Time `json:"lastTransitionTime,omitempty"` -} - -// Components tracks the resources that compose an operator. -type Components struct { - // LabelSelector is a label query over a set of resources used to select the operator's components - LabelSelector *metav1.LabelSelector `json:"labelSelector"` - // Refs are a set of references to the operator's component resources, selected with LabelSelector. - // +optional - Refs []RichReference `json:"refs,omitempty"` -} - -// RichReference is a reference to a resource, enriched with its status conditions. -type RichReference struct { - *corev1.ObjectReference `json:",inline"` - // Conditions represents the latest state of the component. - // +optional - // +patchMergeKey=type - // +patchStrategy=merge - Conditions []Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` -} - -// +genclient -// +genclient:nonNamespaced -// +kubebuilder:object:root=true -// +kubebuilder:storageversion -// +kubebuilder:resource:categories=olm,scope=Cluster -// +kubebuilder:subresource:status - -// Operator represents a cluster operator. -type Operator struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec OperatorSpec `json:"spec,omitempty"` - Status OperatorStatus `json:"status,omitempty"` -} - -// +genclient:nonNamespaced -// +kubebuilder:object:root=true - -// OperatorList contains a list of Operators. -type OperatorList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Operator `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Operator{}, &OperatorList{}) -} diff --git a/vendor/github.com/operator-framework/api/pkg/operators/v1/operatorcondition_types.go b/vendor/github.com/operator-framework/api/pkg/operators/v1/operatorcondition_types.go deleted file mode 100644 index 8647b227e..000000000 --- a/vendor/github.com/operator-framework/api/pkg/operators/v1/operatorcondition_types.go +++ /dev/null @@ -1,49 +0,0 @@ -package v1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -const ( - // Upgradeable indicates that the operator is upgradeable - Upgradeable string = "Upgradeable" -) - -// OperatorConditionSpec allows a cluster admin to convey information about the state of an operator to OLM, potentially overriding state reported by the operator. -type OperatorConditionSpec struct { - ServiceAccounts []string `json:"serviceAccounts,omitempty"` - Deployments []string `json:"deployments,omitempty"` - Overrides []metav1.Condition `json:"overrides,omitempty"` -} - -// OperatorConditionStatus allows an operator to convey information its state to OLM. The status may trail the actual -// state of a system. -type OperatorConditionStatus struct { - Conditions []metav1.Condition `json:"conditions,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +genclient -// +kubebuilder:resource:shortName=condition,categories=olm -// +kubebuilder:subresource:status -// OperatorCondition is a Custom Resource of type `OperatorCondition` which is used to convey information to OLM about the state of an operator. -type OperatorCondition struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata"` - - Spec OperatorConditionSpec `json:"spec,omitempty"` - Status OperatorConditionStatus `json:"status,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// OperatorConditionList represents a list of Conditions. -type OperatorConditionList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata"` - - Items []OperatorCondition `json:"items"` -} - -func init() { - SchemeBuilder.Register(&OperatorCondition{}, &OperatorConditionList{}) -} diff --git a/vendor/github.com/operator-framework/api/pkg/operators/v1/operatorgroup_types.go b/vendor/github.com/operator-framework/api/pkg/operators/v1/operatorgroup_types.go deleted file mode 100644 index 81ad352d4..000000000 --- a/vendor/github.com/operator-framework/api/pkg/operators/v1/operatorgroup_types.go +++ /dev/null @@ -1,214 +0,0 @@ -package v1 - -import ( - "fmt" - "sort" - "strings" - - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -const ( - OperatorGroupAnnotationKey = "olm.operatorGroup" - OperatorGroupNamespaceAnnotationKey = "olm.operatorNamespace" - OperatorGroupTargetsAnnotationKey = "olm.targetNamespaces" - OperatorGroupProvidedAPIsAnnotationKey = "olm.providedAPIs" - - OperatorGroupKind = "OperatorGroup" - - OperatorGroupLabelPrefix = "olm.operatorgroup.uid/" - OperatorGroupLabelTemplate = OperatorGroupLabelPrefix + "%s" - - OperatorGroupServiceAccountCondition = "OperatorGroupServiceAccount" - MutlipleOperatorGroupCondition = "MultipleOperatorGroup" - MultipleOperatorGroupsReason = "MultipleOperatorGroupsFound" - OperatorGroupServiceAccountReason = "ServiceAccountNotFound" - - // UpgradeStrategyDefault configures OLM such that it will only allow - // clusterServiceVersions to move to the replacing phase to the succeeded - // phase. This effectively means that OLM will not allow operators to move - // to the next version if an installation or upgrade has failed. - UpgradeStrategyDefault UpgradeStrategy = "Default" - - // UpgradeStrategyUnsafeFailForward configures OLM such that it will allow - // clusterServiceVersions to move to the replacing phase from the succeeded - // phase or from the failed phase. Additionally, OLM will generate new - // installPlans when a subscription references a failed installPlan and the - // catalog has been updated with a new upgrade for the existing set of - // operators. - // - // WARNING: The UpgradeStrategyUnsafeFailForward upgrade strategy is unsafe - // and may result in unexpected behavior or unrecoverable data loss unless - // you have deep understanding of the set of operators being managed in the - // namespace. - UpgradeStrategyUnsafeFailForward UpgradeStrategy = "TechPreviewUnsafeFailForward" -) - -type UpgradeStrategy string - -// OperatorGroupSpec is the spec for an OperatorGroup resource. -type OperatorGroupSpec struct { - // Selector selects the OperatorGroup's target namespaces. - // +optional - Selector *metav1.LabelSelector `json:"selector,omitempty"` - - // TargetNamespaces is an explicit set of namespaces to target. - // If it is set, Selector is ignored. - // +optional - // +listType=set - TargetNamespaces []string `json:"targetNamespaces,omitempty"` - - // ServiceAccountName is the admin specified service account which will be - // used to deploy operator(s) in this operator group. - ServiceAccountName string `json:"serviceAccountName,omitempty"` - - // Static tells OLM not to update the OperatorGroup's providedAPIs annotation - // +optional - StaticProvidedAPIs bool `json:"staticProvidedAPIs,omitempty"` - - // UpgradeStrategy defines the upgrade strategy for operators in the namespace. - // There are currently two supported upgrade strategies: - // - // Default: OLM will only allow clusterServiceVersions to move to the replacing - // phase from the succeeded phase. This effectively means that OLM will not - // allow operators to move to the next version if an installation or upgrade - // has failed. - // - // TechPreviewUnsafeFailForward: OLM will allow clusterServiceVersions to move to the - // replacing phase from the succeeded phase or from the failed phase. - // Additionally, OLM will generate new installPlans when a subscription references - // a failed installPlan and the catalog has been updated with a new upgrade for - // the existing set of operators. - // - // WARNING: The TechPreviewUnsafeFailForward upgrade strategy is unsafe and may result - // in unexpected behavior or unrecoverable data loss unless you have deep - // understanding of the set of operators being managed in the namespace. - // - // +kubebuilder:validation:Enum=Default;TechPreviewUnsafeFailForward - // +kubebuilder:default=Default - // +optional - UpgradeStrategy UpgradeStrategy `json:"upgradeStrategy,omitempty"` -} - -// OperatorGroupStatus is the status for an OperatorGroupResource. -type OperatorGroupStatus struct { - // Namespaces is the set of target namespaces for the OperatorGroup. - // +listType=set - Namespaces []string `json:"namespaces,omitempty"` - - // ServiceAccountRef references the service account object specified. - ServiceAccountRef *corev1.ObjectReference `json:"serviceAccountRef,omitempty"` - - // LastUpdated is a timestamp of the last time the OperatorGroup's status was Updated. - LastUpdated *metav1.Time `json:"lastUpdated"` - - // Conditions is an array of the OperatorGroup's conditions. - Conditions []metav1.Condition `json:"conditions,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +genclient -// +kubebuilder:storageversion -// +kubebuilder:resource:shortName=og,categories=olm -// +kubebuilder:subresource:status - -// OperatorGroup is the unit of multitenancy for OLM managed operators. -// It constrains the installation of operators in its namespace to a specified set of target namespaces. -type OperatorGroup struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata"` - - // +optional - // +kubebuilder:default={upgradeStrategy:Default} - Spec OperatorGroupSpec `json:"spec"` - Status OperatorGroupStatus `json:"status,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// OperatorGroupList is a list of OperatorGroup resources. -type OperatorGroupList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata"` - // +listType=set - Items []OperatorGroup `json:"items"` -} - -// BuildTargetNamespaces returns the set of target namespaces as a sorted, comma-delimited string -func (o *OperatorGroup) BuildTargetNamespaces() string { - ns := make([]string, len(o.Status.Namespaces)) - copy(ns, o.Status.Namespaces) - sort.Strings(ns) - return strings.Join(ns, ",") -} - -// UpgradeStrategy returns the UpgradeStrategy specified or the default value otherwise. -func (o *OperatorGroup) UpgradeStrategy() UpgradeStrategy { - strategyName := o.Spec.UpgradeStrategy - switch { - case strategyName == UpgradeStrategyUnsafeFailForward: - return strategyName - default: - return UpgradeStrategyDefault - } -} - -// IsServiceAccountSpecified returns true if the spec has a service account name specified. -func (o *OperatorGroup) IsServiceAccountSpecified() bool { - if o.Spec.ServiceAccountName == "" { - return false - } - - return true -} - -// HasServiceAccountSynced returns true if the service account specified has been synced. -func (o *OperatorGroup) HasServiceAccountSynced() bool { - if o.IsServiceAccountSpecified() && o.Status.ServiceAccountRef != nil { - return true - } - - return false -} - -// OGLabelKeyAndValue returns a key and value that should be applied to namespaces listed in the OperatorGroup. -// If the UID is not set an error is returned. -func (o *OperatorGroup) OGLabelKeyAndValue() (string, string, error) { - if string(o.GetUID()) == "" { - return "", "", fmt.Errorf("Missing UID") - } - return fmt.Sprintf(OperatorGroupLabelTemplate, o.GetUID()), "", nil -} - -// NamespaceLabelSelector provides a selector that can be used to filter namespaces that belong to the OperatorGroup. -func (o *OperatorGroup) NamespaceLabelSelector() (*metav1.LabelSelector, error) { - if len(o.Spec.TargetNamespaces) == 0 { - // If no target namespaces are set, check if a selector exists. - if o.Spec.Selector != nil { - return o.Spec.Selector, nil - } - // No selector exists, return nil which should be used to select EVERYTHING. - return nil, nil - } - // Return a label that should be present on all namespaces defined in the OperatorGroup.Spec.TargetNamespaces field. - ogKey, ogValue, err := o.OGLabelKeyAndValue() - if err != nil { - return nil, err - } - - return &metav1.LabelSelector{ - MatchLabels: map[string]string{ - ogKey: ogValue, - }, - }, nil -} - -// IsOperatorGroupLabel returns true if the label is an OperatorGroup label. -func IsOperatorGroupLabel(label string) bool { - return strings.HasPrefix(label, OperatorGroupLabelPrefix) -} - -func init() { - SchemeBuilder.Register(&OperatorGroup{}, &OperatorGroupList{}) -} diff --git a/vendor/github.com/operator-framework/api/pkg/operators/v1/zz_generated.deepcopy.go b/vendor/github.com/operator-framework/api/pkg/operators/v1/zz_generated.deepcopy.go deleted file mode 100644 index d6f89ba40..000000000 --- a/vendor/github.com/operator-framework/api/pkg/operators/v1/zz_generated.deepcopy.go +++ /dev/null @@ -1,556 +0,0 @@ -//go:build !ignore_autogenerated - -/* - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by controller-gen. DO NOT EDIT. - -package v1 - -import ( - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Components) DeepCopyInto(out *Components) { - *out = *in - if in.LabelSelector != nil { - in, out := &in.LabelSelector, &out.LabelSelector - *out = new(metav1.LabelSelector) - (*in).DeepCopyInto(*out) - } - if in.Refs != nil { - in, out := &in.Refs, &out.Refs - *out = make([]RichReference, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Components. -func (in *Components) DeepCopy() *Components { - if in == nil { - return nil - } - out := new(Components) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Condition) DeepCopyInto(out *Condition) { - *out = *in - if in.LastUpdateTime != nil { - in, out := &in.LastUpdateTime, &out.LastUpdateTime - *out = (*in).DeepCopy() - } - if in.LastTransitionTime != nil { - in, out := &in.LastTransitionTime, &out.LastTransitionTime - *out = (*in).DeepCopy() - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Condition. -func (in *Condition) DeepCopy() *Condition { - if in == nil { - return nil - } - out := new(Condition) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Features) DeepCopyInto(out *Features) { - *out = *in - if in.DisableCopiedCSVs != nil { - in, out := &in.DisableCopiedCSVs, &out.DisableCopiedCSVs - *out = new(bool) - **out = **in - } - if in.PackageServerSyncInterval != nil { - in, out := &in.PackageServerSyncInterval, &out.PackageServerSyncInterval - *out = new(metav1.Duration) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Features. -func (in *Features) DeepCopy() *Features { - if in == nil { - return nil - } - out := new(Features) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OLMConfig) DeepCopyInto(out *OLMConfig) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OLMConfig. -func (in *OLMConfig) DeepCopy() *OLMConfig { - if in == nil { - return nil - } - out := new(OLMConfig) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OLMConfig) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OLMConfigList) DeepCopyInto(out *OLMConfigList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]OLMConfig, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OLMConfigList. -func (in *OLMConfigList) DeepCopy() *OLMConfigList { - if in == nil { - return nil - } - out := new(OLMConfigList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OLMConfigList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OLMConfigSpec) DeepCopyInto(out *OLMConfigSpec) { - *out = *in - if in.Features != nil { - in, out := &in.Features, &out.Features - *out = new(Features) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OLMConfigSpec. -func (in *OLMConfigSpec) DeepCopy() *OLMConfigSpec { - if in == nil { - return nil - } - out := new(OLMConfigSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OLMConfigStatus) DeepCopyInto(out *OLMConfigStatus) { - *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]metav1.Condition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OLMConfigStatus. -func (in *OLMConfigStatus) DeepCopy() *OLMConfigStatus { - if in == nil { - return nil - } - out := new(OLMConfigStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Operator) DeepCopyInto(out *Operator) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Operator. -func (in *Operator) DeepCopy() *Operator { - if in == nil { - return nil - } - out := new(Operator) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Operator) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OperatorCondition) DeepCopyInto(out *OperatorCondition) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorCondition. -func (in *OperatorCondition) DeepCopy() *OperatorCondition { - if in == nil { - return nil - } - out := new(OperatorCondition) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OperatorCondition) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OperatorConditionList) DeepCopyInto(out *OperatorConditionList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]OperatorCondition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorConditionList. -func (in *OperatorConditionList) DeepCopy() *OperatorConditionList { - if in == nil { - return nil - } - out := new(OperatorConditionList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OperatorConditionList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OperatorConditionSpec) DeepCopyInto(out *OperatorConditionSpec) { - *out = *in - if in.ServiceAccounts != nil { - in, out := &in.ServiceAccounts, &out.ServiceAccounts - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.Deployments != nil { - in, out := &in.Deployments, &out.Deployments - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.Overrides != nil { - in, out := &in.Overrides, &out.Overrides - *out = make([]metav1.Condition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorConditionSpec. -func (in *OperatorConditionSpec) DeepCopy() *OperatorConditionSpec { - if in == nil { - return nil - } - out := new(OperatorConditionSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OperatorConditionStatus) DeepCopyInto(out *OperatorConditionStatus) { - *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]metav1.Condition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorConditionStatus. -func (in *OperatorConditionStatus) DeepCopy() *OperatorConditionStatus { - if in == nil { - return nil - } - out := new(OperatorConditionStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OperatorGroup) DeepCopyInto(out *OperatorGroup) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorGroup. -func (in *OperatorGroup) DeepCopy() *OperatorGroup { - if in == nil { - return nil - } - out := new(OperatorGroup) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OperatorGroup) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OperatorGroupList) DeepCopyInto(out *OperatorGroupList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]OperatorGroup, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorGroupList. -func (in *OperatorGroupList) DeepCopy() *OperatorGroupList { - if in == nil { - return nil - } - out := new(OperatorGroupList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OperatorGroupList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OperatorGroupSpec) DeepCopyInto(out *OperatorGroupSpec) { - *out = *in - if in.Selector != nil { - in, out := &in.Selector, &out.Selector - *out = new(metav1.LabelSelector) - (*in).DeepCopyInto(*out) - } - if in.TargetNamespaces != nil { - in, out := &in.TargetNamespaces, &out.TargetNamespaces - *out = make([]string, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorGroupSpec. -func (in *OperatorGroupSpec) DeepCopy() *OperatorGroupSpec { - if in == nil { - return nil - } - out := new(OperatorGroupSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OperatorGroupStatus) DeepCopyInto(out *OperatorGroupStatus) { - *out = *in - if in.Namespaces != nil { - in, out := &in.Namespaces, &out.Namespaces - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.ServiceAccountRef != nil { - in, out := &in.ServiceAccountRef, &out.ServiceAccountRef - *out = new(corev1.ObjectReference) - **out = **in - } - if in.LastUpdated != nil { - in, out := &in.LastUpdated, &out.LastUpdated - *out = (*in).DeepCopy() - } - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]metav1.Condition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorGroupStatus. -func (in *OperatorGroupStatus) DeepCopy() *OperatorGroupStatus { - if in == nil { - return nil - } - out := new(OperatorGroupStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OperatorList) DeepCopyInto(out *OperatorList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Operator, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorList. -func (in *OperatorList) DeepCopy() *OperatorList { - if in == nil { - return nil - } - out := new(OperatorList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OperatorList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OperatorSpec) DeepCopyInto(out *OperatorSpec) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorSpec. -func (in *OperatorSpec) DeepCopy() *OperatorSpec { - if in == nil { - return nil - } - out := new(OperatorSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OperatorStatus) DeepCopyInto(out *OperatorStatus) { - *out = *in - if in.Components != nil { - in, out := &in.Components, &out.Components - *out = new(Components) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorStatus. -func (in *OperatorStatus) DeepCopy() *OperatorStatus { - if in == nil { - return nil - } - out := new(OperatorStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RichReference) DeepCopyInto(out *RichReference) { - *out = *in - if in.ObjectReference != nil { - in, out := &in.ObjectReference, &out.ObjectReference - *out = new(corev1.ObjectReference) - **out = **in - } - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]Condition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RichReference. -func (in *RichReference) DeepCopy() *RichReference { - if in == nil { - return nil - } - out := new(RichReference) - in.DeepCopyInto(out) - return out -} diff --git a/vendor/github.com/operator-framework/api/pkg/operators/v1alpha2/doc.go b/vendor/github.com/operator-framework/api/pkg/operators/v1alpha2/doc.go deleted file mode 100644 index b881240ad..000000000 --- a/vendor/github.com/operator-framework/api/pkg/operators/v1alpha2/doc.go +++ /dev/null @@ -1,6 +0,0 @@ -// +groupName=operators.coreos.com -// +k8s:deepcopy-gen=package -// +k8s:conversion-gen=github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators - -// Package v1alpha2 contains resources types for version v1alpha2 of the operators.coreos.com API group. -package v1alpha2 diff --git a/vendor/github.com/operator-framework/api/pkg/operators/v1alpha2/groupversion_info.go b/vendor/github.com/operator-framework/api/pkg/operators/v1alpha2/groupversion_info.go deleted file mode 100644 index 637dc4dfc..000000000 --- a/vendor/github.com/operator-framework/api/pkg/operators/v1alpha2/groupversion_info.go +++ /dev/null @@ -1,42 +0,0 @@ -/* -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// +kubebuilder:object:generate=true - -// Package v1alpha2 contains API Schema definitions for the discovery v1alpha2 API group. -package v1alpha2 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/scheme" -) - -var ( - // GroupVersion is group version used to register these objects. - GroupVersion = schema.GroupVersion{Group: "operators.coreos.com", Version: "v1alpha2"} - - // SchemeGroupVersion is required for compatibility with client generation. - SchemeGroupVersion = GroupVersion - - // SchemeBuilder is used to add go types to the GroupVersionKind scheme. - SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} - - // AddToScheme adds the types in this group-version to the given scheme. - AddToScheme = SchemeBuilder.AddToScheme -) - -// Resource takes an unqualified resource and returns a Group qualified GroupResource -func Resource(resource string) schema.GroupResource { - return GroupVersion.WithResource(resource).GroupResource() -} diff --git a/vendor/github.com/operator-framework/api/pkg/operators/v1alpha2/operatorgroup_types.go b/vendor/github.com/operator-framework/api/pkg/operators/v1alpha2/operatorgroup_types.go deleted file mode 100644 index 2e67773f5..000000000 --- a/vendor/github.com/operator-framework/api/pkg/operators/v1alpha2/operatorgroup_types.go +++ /dev/null @@ -1,99 +0,0 @@ -package v1alpha2 - -import ( - "sort" - "strings" - - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -const ( - OperatorGroupAnnotationKey = "olm.operatorGroup" - OperatorGroupNamespaceAnnotationKey = "olm.operatorNamespace" - OperatorGroupTargetsAnnotationKey = "olm.targetNamespaces" - OperatorGroupProvidedAPIsAnnotationKey = "olm.providedAPIs" - - OperatorGroupKind = "OperatorGroup" -) - -// OperatorGroupSpec is the spec for an OperatorGroup resource. -type OperatorGroupSpec struct { - // Selector selects the OperatorGroup's target namespaces. - // +optional - Selector *metav1.LabelSelector `json:"selector,omitempty"` - - // TargetNamespaces is an explicit set of namespaces to target. - // If it is set, Selector is ignored. - // +optional - TargetNamespaces []string `json:"targetNamespaces,omitempty"` - - // ServiceAccountName is the admin specified service account which will be - // used to deploy operator(s) in this operator group. - ServiceAccountName string `json:"serviceAccountName,omitempty"` - - // Static tells OLM not to update the OperatorGroup's providedAPIs annotation - // +optional - StaticProvidedAPIs bool `json:"staticProvidedAPIs,omitempty"` -} - -// OperatorGroupStatus is the status for an OperatorGroupResource. -type OperatorGroupStatus struct { - // Namespaces is the set of target namespaces for the OperatorGroup. - Namespaces []string `json:"namespaces,omitempty"` - - // ServiceAccountRef references the service account object specified. - ServiceAccountRef *corev1.ObjectReference `json:"serviceAccountRef,omitempty"` - - // LastUpdated is a timestamp of the last time the OperatorGroup's status was Updated. - LastUpdated *metav1.Time `json:"lastUpdated"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +genclient -// +kubebuilder:resource:shortName=og,categories=olm -// +kubebuilder:subresource:status - -// OperatorGroup is the unit of multitenancy for OLM managed operators. -// It constrains the installation of operators in its namespace to a specified set of target namespaces. -type OperatorGroup struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata"` - - // +optional - Spec OperatorGroupSpec `json:"spec"` - Status OperatorGroupStatus `json:"status,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// OperatorGroupList is a list of OperatorGroup resources. -type OperatorGroupList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata"` - - Items []OperatorGroup `json:"items"` -} - -func (o *OperatorGroup) BuildTargetNamespaces() string { - sort.Strings(o.Status.Namespaces) - return strings.Join(o.Status.Namespaces, ",") -} - -// IsServiceAccountSpecified returns true if the spec has a service account name specified. -func (o *OperatorGroup) IsServiceAccountSpecified() bool { - if o.Spec.ServiceAccountName == "" { - return false - } - - return true -} - -// HasServiceAccountSynced returns true if the service account specified has been synced. -func (o *OperatorGroup) HasServiceAccountSynced() bool { - if o.IsServiceAccountSpecified() && o.Status.ServiceAccountRef != nil { - return true - } - - return false -} diff --git a/vendor/github.com/operator-framework/api/pkg/operators/v1alpha2/zz_generated.deepcopy.go b/vendor/github.com/operator-framework/api/pkg/operators/v1alpha2/zz_generated.deepcopy.go deleted file mode 100644 index 885643cb7..000000000 --- a/vendor/github.com/operator-framework/api/pkg/operators/v1alpha2/zz_generated.deepcopy.go +++ /dev/null @@ -1,139 +0,0 @@ -//go:build !ignore_autogenerated - -/* - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by controller-gen. DO NOT EDIT. - -package v1alpha2 - -import ( - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OperatorGroup) DeepCopyInto(out *OperatorGroup) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorGroup. -func (in *OperatorGroup) DeepCopy() *OperatorGroup { - if in == nil { - return nil - } - out := new(OperatorGroup) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OperatorGroup) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OperatorGroupList) DeepCopyInto(out *OperatorGroupList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]OperatorGroup, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorGroupList. -func (in *OperatorGroupList) DeepCopy() *OperatorGroupList { - if in == nil { - return nil - } - out := new(OperatorGroupList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OperatorGroupList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OperatorGroupSpec) DeepCopyInto(out *OperatorGroupSpec) { - *out = *in - if in.Selector != nil { - in, out := &in.Selector, &out.Selector - *out = new(v1.LabelSelector) - (*in).DeepCopyInto(*out) - } - if in.TargetNamespaces != nil { - in, out := &in.TargetNamespaces, &out.TargetNamespaces - *out = make([]string, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorGroupSpec. -func (in *OperatorGroupSpec) DeepCopy() *OperatorGroupSpec { - if in == nil { - return nil - } - out := new(OperatorGroupSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OperatorGroupStatus) DeepCopyInto(out *OperatorGroupStatus) { - *out = *in - if in.Namespaces != nil { - in, out := &in.Namespaces, &out.Namespaces - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.ServiceAccountRef != nil { - in, out := &in.ServiceAccountRef, &out.ServiceAccountRef - *out = new(corev1.ObjectReference) - **out = **in - } - if in.LastUpdated != nil { - in, out := &in.LastUpdated, &out.LastUpdated - *out = (*in).DeepCopy() - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorGroupStatus. -func (in *OperatorGroupStatus) DeepCopy() *OperatorGroupStatus { - if in == nil { - return nil - } - out := new(OperatorGroupStatus) - in.DeepCopyInto(out) - return out -} diff --git a/vendor/github.com/operator-framework/api/pkg/operators/v2/doc.go b/vendor/github.com/operator-framework/api/pkg/operators/v2/doc.go deleted file mode 100644 index f85f79242..000000000 --- a/vendor/github.com/operator-framework/api/pkg/operators/v2/doc.go +++ /dev/null @@ -1,4 +0,0 @@ -// +groupName=operators.coreos.com - -// Package v2 contains resources types for version v2 of the operators.coreos.com API group. -package v2 diff --git a/vendor/github.com/operator-framework/api/pkg/operators/v2/groupversion_info.go b/vendor/github.com/operator-framework/api/pkg/operators/v2/groupversion_info.go deleted file mode 100644 index 2d2d923d1..000000000 --- a/vendor/github.com/operator-framework/api/pkg/operators/v2/groupversion_info.go +++ /dev/null @@ -1,28 +0,0 @@ -// +kubebuilder:object:generate=true - -// Package v2 contains API Schema definitions for the operator v2 API group. -package v2 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/scheme" -) - -var ( - // GroupVersion is group version used to register these objects. - GroupVersion = schema.GroupVersion{Group: "operators.coreos.com", Version: "v2"} - - // SchemeGroupVersion is required for compatibility with client generation. - SchemeGroupVersion = GroupVersion - - // SchemeBuilder is used to add go types to the GroupVersionKind scheme. - SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} - - // AddToScheme adds the types in this group-version to the given scheme. - AddToScheme = SchemeBuilder.AddToScheme -) - -// Resource takes an unqualified resource and returns a Group qualified GroupResource -func Resource(resource string) schema.GroupResource { - return GroupVersion.WithResource(resource).GroupResource() -} diff --git a/vendor/github.com/operator-framework/api/pkg/operators/v2/operatorcondition_types.go b/vendor/github.com/operator-framework/api/pkg/operators/v2/operatorcondition_types.go deleted file mode 100644 index ef1c56de6..000000000 --- a/vendor/github.com/operator-framework/api/pkg/operators/v2/operatorcondition_types.go +++ /dev/null @@ -1,54 +0,0 @@ -package v2 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -const ( - // Upgradeable indicates that the operator is upgradeable - Upgradeable string = "Upgradeable" -) - -// ConditionType codifies a condition's type. -type ConditionType string - -// OperatorConditionSpec allows an operator to report state to OLM and provides -// cluster admin with the ability to manually override state reported by the operator. -type OperatorConditionSpec struct { - ServiceAccounts []string `json:"serviceAccounts,omitempty"` - Deployments []string `json:"deployments,omitempty"` - Overrides []metav1.Condition `json:"overrides,omitempty"` - Conditions []metav1.Condition `json:"conditions,omitempty"` -} - -// OperatorConditionStatus allows OLM to convey which conditions have been observed. -type OperatorConditionStatus struct { - Conditions []metav1.Condition `json:"conditions,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +genclient -// +kubebuilder:storageversion -// +kubebuilder:resource:shortName=condition,categories=olm -// +kubebuilder:subresource:status -// OperatorCondition is a Custom Resource of type `OperatorCondition` which is used to convey information to OLM about the state of an operator. -type OperatorCondition struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata"` - - Spec OperatorConditionSpec `json:"spec,omitempty"` - Status OperatorConditionStatus `json:"status,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// OperatorConditionList represents a list of Conditions. -type OperatorConditionList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata"` - - Items []OperatorCondition `json:"items"` -} - -func init() { - SchemeBuilder.Register(&OperatorCondition{}, &OperatorConditionList{}) -} diff --git a/vendor/github.com/operator-framework/api/pkg/operators/v2/zz_generated.deepcopy.go b/vendor/github.com/operator-framework/api/pkg/operators/v2/zz_generated.deepcopy.go deleted file mode 100644 index 92ecc812a..000000000 --- a/vendor/github.com/operator-framework/api/pkg/operators/v2/zz_generated.deepcopy.go +++ /dev/null @@ -1,145 +0,0 @@ -//go:build !ignore_autogenerated - -/* - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by controller-gen. DO NOT EDIT. - -package v2 - -import ( - "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OperatorCondition) DeepCopyInto(out *OperatorCondition) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorCondition. -func (in *OperatorCondition) DeepCopy() *OperatorCondition { - if in == nil { - return nil - } - out := new(OperatorCondition) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OperatorCondition) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OperatorConditionList) DeepCopyInto(out *OperatorConditionList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]OperatorCondition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorConditionList. -func (in *OperatorConditionList) DeepCopy() *OperatorConditionList { - if in == nil { - return nil - } - out := new(OperatorConditionList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OperatorConditionList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OperatorConditionSpec) DeepCopyInto(out *OperatorConditionSpec) { - *out = *in - if in.ServiceAccounts != nil { - in, out := &in.ServiceAccounts, &out.ServiceAccounts - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.Deployments != nil { - in, out := &in.Deployments, &out.Deployments - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.Overrides != nil { - in, out := &in.Overrides, &out.Overrides - *out = make([]v1.Condition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]v1.Condition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorConditionSpec. -func (in *OperatorConditionSpec) DeepCopy() *OperatorConditionSpec { - if in == nil { - return nil - } - out := new(OperatorConditionSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OperatorConditionStatus) DeepCopyInto(out *OperatorConditionStatus) { - *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]v1.Condition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorConditionStatus. -func (in *OperatorConditionStatus) DeepCopy() *OperatorConditionStatus { - if in == nil { - return nil - } - out := new(OperatorConditionStatus) - in.DeepCopyInto(out) - return out -} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/LICENSE b/vendor/github.com/operator-framework/operator-lifecycle-manager/LICENSE deleted file mode 100644 index 261eeb9e9..000000000 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/scheme/doc.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/scheme/doc.go deleted file mode 100644 index 251358bb4..000000000 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/scheme/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright Red Hat, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -// This package contains the scheme of the automatically generated clientset. -package scheme diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/scheme/register.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/scheme/register.go deleted file mode 100644 index 7eac09fdd..000000000 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/scheme/register.go +++ /dev/null @@ -1,62 +0,0 @@ -/* -Copyright Red Hat, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package scheme - -import ( - operatorsv1 "github.com/operator-framework/api/pkg/operators/v1" - operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1" - operatorsv1alpha2 "github.com/operator-framework/api/pkg/operators/v1alpha2" - operatorsv2 "github.com/operator-framework/api/pkg/operators/v2" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - schema "k8s.io/apimachinery/pkg/runtime/schema" - serializer "k8s.io/apimachinery/pkg/runtime/serializer" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" -) - -var Scheme = runtime.NewScheme() -var Codecs = serializer.NewCodecFactory(Scheme) -var ParameterCodec = runtime.NewParameterCodec(Scheme) -var localSchemeBuilder = runtime.SchemeBuilder{ - operatorsv1alpha1.AddToScheme, - operatorsv1alpha2.AddToScheme, - operatorsv1.AddToScheme, - operatorsv2.AddToScheme, -} - -// AddToScheme adds all types of this clientset into the given scheme. This allows composition -// of clientsets, like in: -// -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) -// -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) -// -// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types -// correctly. -var AddToScheme = localSchemeBuilder.AddToScheme - -func init() { - v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) - utilruntime.Must(AddToScheme(Scheme)) -} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/doc.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/doc.go deleted file mode 100644 index d84e927bc..000000000 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright Red Hat, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -// This package has the automatically generated typed clients. -package v1 diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/generated_expansion.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/generated_expansion.go deleted file mode 100644 index 357fc8aae..000000000 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/generated_expansion.go +++ /dev/null @@ -1,27 +0,0 @@ -/* -Copyright Red Hat, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1 - -type OLMConfigExpansion interface{} - -type OperatorExpansion interface{} - -type OperatorConditionExpansion interface{} - -type OperatorGroupExpansion interface{} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/olmconfig.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/olmconfig.go deleted file mode 100644 index 4821e5297..000000000 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/olmconfig.go +++ /dev/null @@ -1,184 +0,0 @@ -/* -Copyright Red Hat, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1 - -import ( - "context" - "time" - - v1 "github.com/operator-framework/api/pkg/operators/v1" - scheme "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/scheme" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// OLMConfigsGetter has a method to return a OLMConfigInterface. -// A group's client should implement this interface. -type OLMConfigsGetter interface { - OLMConfigs() OLMConfigInterface -} - -// OLMConfigInterface has methods to work with OLMConfig resources. -type OLMConfigInterface interface { - Create(ctx context.Context, oLMConfig *v1.OLMConfig, opts metav1.CreateOptions) (*v1.OLMConfig, error) - Update(ctx context.Context, oLMConfig *v1.OLMConfig, opts metav1.UpdateOptions) (*v1.OLMConfig, error) - UpdateStatus(ctx context.Context, oLMConfig *v1.OLMConfig, opts metav1.UpdateOptions) (*v1.OLMConfig, error) - Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error - Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.OLMConfig, error) - List(ctx context.Context, opts metav1.ListOptions) (*v1.OLMConfigList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.OLMConfig, err error) - OLMConfigExpansion -} - -// oLMConfigs implements OLMConfigInterface -type oLMConfigs struct { - client rest.Interface -} - -// newOLMConfigs returns a OLMConfigs -func newOLMConfigs(c *OperatorsV1Client) *oLMConfigs { - return &oLMConfigs{ - client: c.RESTClient(), - } -} - -// Get takes name of the oLMConfig, and returns the corresponding oLMConfig object, and an error if there is any. -func (c *oLMConfigs) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.OLMConfig, err error) { - result = &v1.OLMConfig{} - err = c.client.Get(). - Resource("olmconfigs"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of OLMConfigs that match those selectors. -func (c *oLMConfigs) List(ctx context.Context, opts metav1.ListOptions) (result *v1.OLMConfigList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1.OLMConfigList{} - err = c.client.Get(). - Resource("olmconfigs"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested oLMConfigs. -func (c *oLMConfigs) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Resource("olmconfigs"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a oLMConfig and creates it. Returns the server's representation of the oLMConfig, and an error, if there is any. -func (c *oLMConfigs) Create(ctx context.Context, oLMConfig *v1.OLMConfig, opts metav1.CreateOptions) (result *v1.OLMConfig, err error) { - result = &v1.OLMConfig{} - err = c.client.Post(). - Resource("olmconfigs"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(oLMConfig). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a oLMConfig and updates it. Returns the server's representation of the oLMConfig, and an error, if there is any. -func (c *oLMConfigs) Update(ctx context.Context, oLMConfig *v1.OLMConfig, opts metav1.UpdateOptions) (result *v1.OLMConfig, err error) { - result = &v1.OLMConfig{} - err = c.client.Put(). - Resource("olmconfigs"). - Name(oLMConfig.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(oLMConfig). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *oLMConfigs) UpdateStatus(ctx context.Context, oLMConfig *v1.OLMConfig, opts metav1.UpdateOptions) (result *v1.OLMConfig, err error) { - result = &v1.OLMConfig{} - err = c.client.Put(). - Resource("olmconfigs"). - Name(oLMConfig.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(oLMConfig). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the oLMConfig and deletes it. Returns an error if one occurs. -func (c *oLMConfigs) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - return c.client.Delete(). - Resource("olmconfigs"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *oLMConfigs) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Resource("olmconfigs"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched oLMConfig. -func (c *oLMConfigs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.OLMConfig, err error) { - result = &v1.OLMConfig{} - err = c.client.Patch(pt). - Resource("olmconfigs"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/operator.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/operator.go deleted file mode 100644 index 01df76be5..000000000 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/operator.go +++ /dev/null @@ -1,184 +0,0 @@ -/* -Copyright Red Hat, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1 - -import ( - "context" - "time" - - v1 "github.com/operator-framework/api/pkg/operators/v1" - scheme "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/scheme" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// OperatorsGetter has a method to return a OperatorInterface. -// A group's client should implement this interface. -type OperatorsGetter interface { - Operators() OperatorInterface -} - -// OperatorInterface has methods to work with Operator resources. -type OperatorInterface interface { - Create(ctx context.Context, operator *v1.Operator, opts metav1.CreateOptions) (*v1.Operator, error) - Update(ctx context.Context, operator *v1.Operator, opts metav1.UpdateOptions) (*v1.Operator, error) - UpdateStatus(ctx context.Context, operator *v1.Operator, opts metav1.UpdateOptions) (*v1.Operator, error) - Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error - Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.Operator, error) - List(ctx context.Context, opts metav1.ListOptions) (*v1.OperatorList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.Operator, err error) - OperatorExpansion -} - -// operators implements OperatorInterface -type operators struct { - client rest.Interface -} - -// newOperators returns a Operators -func newOperators(c *OperatorsV1Client) *operators { - return &operators{ - client: c.RESTClient(), - } -} - -// Get takes name of the operator, and returns the corresponding operator object, and an error if there is any. -func (c *operators) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.Operator, err error) { - result = &v1.Operator{} - err = c.client.Get(). - Resource("operators"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of Operators that match those selectors. -func (c *operators) List(ctx context.Context, opts metav1.ListOptions) (result *v1.OperatorList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1.OperatorList{} - err = c.client.Get(). - Resource("operators"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested operators. -func (c *operators) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Resource("operators"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a operator and creates it. Returns the server's representation of the operator, and an error, if there is any. -func (c *operators) Create(ctx context.Context, operator *v1.Operator, opts metav1.CreateOptions) (result *v1.Operator, err error) { - result = &v1.Operator{} - err = c.client.Post(). - Resource("operators"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(operator). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a operator and updates it. Returns the server's representation of the operator, and an error, if there is any. -func (c *operators) Update(ctx context.Context, operator *v1.Operator, opts metav1.UpdateOptions) (result *v1.Operator, err error) { - result = &v1.Operator{} - err = c.client.Put(). - Resource("operators"). - Name(operator.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(operator). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *operators) UpdateStatus(ctx context.Context, operator *v1.Operator, opts metav1.UpdateOptions) (result *v1.Operator, err error) { - result = &v1.Operator{} - err = c.client.Put(). - Resource("operators"). - Name(operator.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(operator). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the operator and deletes it. Returns an error if one occurs. -func (c *operators) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - return c.client.Delete(). - Resource("operators"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *operators) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Resource("operators"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched operator. -func (c *operators) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.Operator, err error) { - result = &v1.Operator{} - err = c.client.Patch(pt). - Resource("operators"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/operatorcondition.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/operatorcondition.go deleted file mode 100644 index 5edd0d0ba..000000000 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/operatorcondition.go +++ /dev/null @@ -1,195 +0,0 @@ -/* -Copyright Red Hat, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1 - -import ( - "context" - "time" - - v1 "github.com/operator-framework/api/pkg/operators/v1" - scheme "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/scheme" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// OperatorConditionsGetter has a method to return a OperatorConditionInterface. -// A group's client should implement this interface. -type OperatorConditionsGetter interface { - OperatorConditions(namespace string) OperatorConditionInterface -} - -// OperatorConditionInterface has methods to work with OperatorCondition resources. -type OperatorConditionInterface interface { - Create(ctx context.Context, operatorCondition *v1.OperatorCondition, opts metav1.CreateOptions) (*v1.OperatorCondition, error) - Update(ctx context.Context, operatorCondition *v1.OperatorCondition, opts metav1.UpdateOptions) (*v1.OperatorCondition, error) - UpdateStatus(ctx context.Context, operatorCondition *v1.OperatorCondition, opts metav1.UpdateOptions) (*v1.OperatorCondition, error) - Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error - Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.OperatorCondition, error) - List(ctx context.Context, opts metav1.ListOptions) (*v1.OperatorConditionList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.OperatorCondition, err error) - OperatorConditionExpansion -} - -// operatorConditions implements OperatorConditionInterface -type operatorConditions struct { - client rest.Interface - ns string -} - -// newOperatorConditions returns a OperatorConditions -func newOperatorConditions(c *OperatorsV1Client, namespace string) *operatorConditions { - return &operatorConditions{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the operatorCondition, and returns the corresponding operatorCondition object, and an error if there is any. -func (c *operatorConditions) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.OperatorCondition, err error) { - result = &v1.OperatorCondition{} - err = c.client.Get(). - Namespace(c.ns). - Resource("operatorconditions"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of OperatorConditions that match those selectors. -func (c *operatorConditions) List(ctx context.Context, opts metav1.ListOptions) (result *v1.OperatorConditionList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1.OperatorConditionList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("operatorconditions"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested operatorConditions. -func (c *operatorConditions) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("operatorconditions"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a operatorCondition and creates it. Returns the server's representation of the operatorCondition, and an error, if there is any. -func (c *operatorConditions) Create(ctx context.Context, operatorCondition *v1.OperatorCondition, opts metav1.CreateOptions) (result *v1.OperatorCondition, err error) { - result = &v1.OperatorCondition{} - err = c.client.Post(). - Namespace(c.ns). - Resource("operatorconditions"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(operatorCondition). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a operatorCondition and updates it. Returns the server's representation of the operatorCondition, and an error, if there is any. -func (c *operatorConditions) Update(ctx context.Context, operatorCondition *v1.OperatorCondition, opts metav1.UpdateOptions) (result *v1.OperatorCondition, err error) { - result = &v1.OperatorCondition{} - err = c.client.Put(). - Namespace(c.ns). - Resource("operatorconditions"). - Name(operatorCondition.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(operatorCondition). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *operatorConditions) UpdateStatus(ctx context.Context, operatorCondition *v1.OperatorCondition, opts metav1.UpdateOptions) (result *v1.OperatorCondition, err error) { - result = &v1.OperatorCondition{} - err = c.client.Put(). - Namespace(c.ns). - Resource("operatorconditions"). - Name(operatorCondition.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(operatorCondition). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the operatorCondition and deletes it. Returns an error if one occurs. -func (c *operatorConditions) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("operatorconditions"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *operatorConditions) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("operatorconditions"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched operatorCondition. -func (c *operatorConditions) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.OperatorCondition, err error) { - result = &v1.OperatorCondition{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("operatorconditions"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/operatorgroup.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/operatorgroup.go deleted file mode 100644 index e8ab1944a..000000000 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/operatorgroup.go +++ /dev/null @@ -1,195 +0,0 @@ -/* -Copyright Red Hat, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1 - -import ( - "context" - "time" - - v1 "github.com/operator-framework/api/pkg/operators/v1" - scheme "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/scheme" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// OperatorGroupsGetter has a method to return a OperatorGroupInterface. -// A group's client should implement this interface. -type OperatorGroupsGetter interface { - OperatorGroups(namespace string) OperatorGroupInterface -} - -// OperatorGroupInterface has methods to work with OperatorGroup resources. -type OperatorGroupInterface interface { - Create(ctx context.Context, operatorGroup *v1.OperatorGroup, opts metav1.CreateOptions) (*v1.OperatorGroup, error) - Update(ctx context.Context, operatorGroup *v1.OperatorGroup, opts metav1.UpdateOptions) (*v1.OperatorGroup, error) - UpdateStatus(ctx context.Context, operatorGroup *v1.OperatorGroup, opts metav1.UpdateOptions) (*v1.OperatorGroup, error) - Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error - Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.OperatorGroup, error) - List(ctx context.Context, opts metav1.ListOptions) (*v1.OperatorGroupList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.OperatorGroup, err error) - OperatorGroupExpansion -} - -// operatorGroups implements OperatorGroupInterface -type operatorGroups struct { - client rest.Interface - ns string -} - -// newOperatorGroups returns a OperatorGroups -func newOperatorGroups(c *OperatorsV1Client, namespace string) *operatorGroups { - return &operatorGroups{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the operatorGroup, and returns the corresponding operatorGroup object, and an error if there is any. -func (c *operatorGroups) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.OperatorGroup, err error) { - result = &v1.OperatorGroup{} - err = c.client.Get(). - Namespace(c.ns). - Resource("operatorgroups"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of OperatorGroups that match those selectors. -func (c *operatorGroups) List(ctx context.Context, opts metav1.ListOptions) (result *v1.OperatorGroupList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1.OperatorGroupList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("operatorgroups"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested operatorGroups. -func (c *operatorGroups) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("operatorgroups"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a operatorGroup and creates it. Returns the server's representation of the operatorGroup, and an error, if there is any. -func (c *operatorGroups) Create(ctx context.Context, operatorGroup *v1.OperatorGroup, opts metav1.CreateOptions) (result *v1.OperatorGroup, err error) { - result = &v1.OperatorGroup{} - err = c.client.Post(). - Namespace(c.ns). - Resource("operatorgroups"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(operatorGroup). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a operatorGroup and updates it. Returns the server's representation of the operatorGroup, and an error, if there is any. -func (c *operatorGroups) Update(ctx context.Context, operatorGroup *v1.OperatorGroup, opts metav1.UpdateOptions) (result *v1.OperatorGroup, err error) { - result = &v1.OperatorGroup{} - err = c.client.Put(). - Namespace(c.ns). - Resource("operatorgroups"). - Name(operatorGroup.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(operatorGroup). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *operatorGroups) UpdateStatus(ctx context.Context, operatorGroup *v1.OperatorGroup, opts metav1.UpdateOptions) (result *v1.OperatorGroup, err error) { - result = &v1.OperatorGroup{} - err = c.client.Put(). - Namespace(c.ns). - Resource("operatorgroups"). - Name(operatorGroup.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(operatorGroup). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the operatorGroup and deletes it. Returns an error if one occurs. -func (c *operatorGroups) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("operatorgroups"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *operatorGroups) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("operatorgroups"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched operatorGroup. -func (c *operatorGroups) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.OperatorGroup, err error) { - result = &v1.OperatorGroup{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("operatorgroups"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/operators_client.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/operators_client.go deleted file mode 100644 index 436cd1ac5..000000000 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1/operators_client.go +++ /dev/null @@ -1,122 +0,0 @@ -/* -Copyright Red Hat, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1 - -import ( - "net/http" - - v1 "github.com/operator-framework/api/pkg/operators/v1" - "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/scheme" - rest "k8s.io/client-go/rest" -) - -type OperatorsV1Interface interface { - RESTClient() rest.Interface - OLMConfigsGetter - OperatorsGetter - OperatorConditionsGetter - OperatorGroupsGetter -} - -// OperatorsV1Client is used to interact with features provided by the operators.coreos.com group. -type OperatorsV1Client struct { - restClient rest.Interface -} - -func (c *OperatorsV1Client) OLMConfigs() OLMConfigInterface { - return newOLMConfigs(c) -} - -func (c *OperatorsV1Client) Operators() OperatorInterface { - return newOperators(c) -} - -func (c *OperatorsV1Client) OperatorConditions(namespace string) OperatorConditionInterface { - return newOperatorConditions(c, namespace) -} - -func (c *OperatorsV1Client) OperatorGroups(namespace string) OperatorGroupInterface { - return newOperatorGroups(c, namespace) -} - -// NewForConfig creates a new OperatorsV1Client for the given config. -// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), -// where httpClient was generated with rest.HTTPClientFor(c). -func NewForConfig(c *rest.Config) (*OperatorsV1Client, error) { - config := *c - if err := setConfigDefaults(&config); err != nil { - return nil, err - } - httpClient, err := rest.HTTPClientFor(&config) - if err != nil { - return nil, err - } - return NewForConfigAndClient(&config, httpClient) -} - -// NewForConfigAndClient creates a new OperatorsV1Client for the given config and http client. -// Note the http client provided takes precedence over the configured transport values. -func NewForConfigAndClient(c *rest.Config, h *http.Client) (*OperatorsV1Client, error) { - config := *c - if err := setConfigDefaults(&config); err != nil { - return nil, err - } - client, err := rest.RESTClientForConfigAndClient(&config, h) - if err != nil { - return nil, err - } - return &OperatorsV1Client{client}, nil -} - -// NewForConfigOrDie creates a new OperatorsV1Client for the given config and -// panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *OperatorsV1Client { - client, err := NewForConfig(c) - if err != nil { - panic(err) - } - return client -} - -// New creates a new OperatorsV1Client for the given RESTClient. -func New(c rest.Interface) *OperatorsV1Client { - return &OperatorsV1Client{c} -} - -func setConfigDefaults(config *rest.Config) error { - gv := v1.SchemeGroupVersion - config.GroupVersion = &gv - config.APIPath = "/apis" - config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() - - if config.UserAgent == "" { - config.UserAgent = rest.DefaultKubernetesUserAgent() - } - - return nil -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *OperatorsV1Client) RESTClient() rest.Interface { - if c == nil { - return nil - } - return c.restClient -} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/catalogsource.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/catalogsource.go deleted file mode 100644 index 62bd05191..000000000 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/catalogsource.go +++ /dev/null @@ -1,195 +0,0 @@ -/* -Copyright Red Hat, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - "context" - "time" - - v1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1" - scheme "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/scheme" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// CatalogSourcesGetter has a method to return a CatalogSourceInterface. -// A group's client should implement this interface. -type CatalogSourcesGetter interface { - CatalogSources(namespace string) CatalogSourceInterface -} - -// CatalogSourceInterface has methods to work with CatalogSource resources. -type CatalogSourceInterface interface { - Create(ctx context.Context, catalogSource *v1alpha1.CatalogSource, opts v1.CreateOptions) (*v1alpha1.CatalogSource, error) - Update(ctx context.Context, catalogSource *v1alpha1.CatalogSource, opts v1.UpdateOptions) (*v1alpha1.CatalogSource, error) - UpdateStatus(ctx context.Context, catalogSource *v1alpha1.CatalogSource, opts v1.UpdateOptions) (*v1alpha1.CatalogSource, error) - Delete(ctx context.Context, name string, opts v1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error - Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.CatalogSource, error) - List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.CatalogSourceList, error) - Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.CatalogSource, err error) - CatalogSourceExpansion -} - -// catalogSources implements CatalogSourceInterface -type catalogSources struct { - client rest.Interface - ns string -} - -// newCatalogSources returns a CatalogSources -func newCatalogSources(c *OperatorsV1alpha1Client, namespace string) *catalogSources { - return &catalogSources{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the catalogSource, and returns the corresponding catalogSource object, and an error if there is any. -func (c *catalogSources) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.CatalogSource, err error) { - result = &v1alpha1.CatalogSource{} - err = c.client.Get(). - Namespace(c.ns). - Resource("catalogsources"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of CatalogSources that match those selectors. -func (c *catalogSources) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.CatalogSourceList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.CatalogSourceList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("catalogsources"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested catalogSources. -func (c *catalogSources) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("catalogsources"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a catalogSource and creates it. Returns the server's representation of the catalogSource, and an error, if there is any. -func (c *catalogSources) Create(ctx context.Context, catalogSource *v1alpha1.CatalogSource, opts v1.CreateOptions) (result *v1alpha1.CatalogSource, err error) { - result = &v1alpha1.CatalogSource{} - err = c.client.Post(). - Namespace(c.ns). - Resource("catalogsources"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(catalogSource). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a catalogSource and updates it. Returns the server's representation of the catalogSource, and an error, if there is any. -func (c *catalogSources) Update(ctx context.Context, catalogSource *v1alpha1.CatalogSource, opts v1.UpdateOptions) (result *v1alpha1.CatalogSource, err error) { - result = &v1alpha1.CatalogSource{} - err = c.client.Put(). - Namespace(c.ns). - Resource("catalogsources"). - Name(catalogSource.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(catalogSource). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *catalogSources) UpdateStatus(ctx context.Context, catalogSource *v1alpha1.CatalogSource, opts v1.UpdateOptions) (result *v1alpha1.CatalogSource, err error) { - result = &v1alpha1.CatalogSource{} - err = c.client.Put(). - Namespace(c.ns). - Resource("catalogsources"). - Name(catalogSource.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(catalogSource). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the catalogSource and deletes it. Returns an error if one occurs. -func (c *catalogSources) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("catalogsources"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *catalogSources) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("catalogsources"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched catalogSource. -func (c *catalogSources) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.CatalogSource, err error) { - result = &v1alpha1.CatalogSource{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("catalogsources"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/clusterserviceversion.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/clusterserviceversion.go deleted file mode 100644 index 9c0c87b3f..000000000 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/clusterserviceversion.go +++ /dev/null @@ -1,195 +0,0 @@ -/* -Copyright Red Hat, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - "context" - "time" - - v1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1" - scheme "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/scheme" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// ClusterServiceVersionsGetter has a method to return a ClusterServiceVersionInterface. -// A group's client should implement this interface. -type ClusterServiceVersionsGetter interface { - ClusterServiceVersions(namespace string) ClusterServiceVersionInterface -} - -// ClusterServiceVersionInterface has methods to work with ClusterServiceVersion resources. -type ClusterServiceVersionInterface interface { - Create(ctx context.Context, clusterServiceVersion *v1alpha1.ClusterServiceVersion, opts v1.CreateOptions) (*v1alpha1.ClusterServiceVersion, error) - Update(ctx context.Context, clusterServiceVersion *v1alpha1.ClusterServiceVersion, opts v1.UpdateOptions) (*v1alpha1.ClusterServiceVersion, error) - UpdateStatus(ctx context.Context, clusterServiceVersion *v1alpha1.ClusterServiceVersion, opts v1.UpdateOptions) (*v1alpha1.ClusterServiceVersion, error) - Delete(ctx context.Context, name string, opts v1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error - Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.ClusterServiceVersion, error) - List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ClusterServiceVersionList, error) - Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ClusterServiceVersion, err error) - ClusterServiceVersionExpansion -} - -// clusterServiceVersions implements ClusterServiceVersionInterface -type clusterServiceVersions struct { - client rest.Interface - ns string -} - -// newClusterServiceVersions returns a ClusterServiceVersions -func newClusterServiceVersions(c *OperatorsV1alpha1Client, namespace string) *clusterServiceVersions { - return &clusterServiceVersions{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the clusterServiceVersion, and returns the corresponding clusterServiceVersion object, and an error if there is any. -func (c *clusterServiceVersions) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ClusterServiceVersion, err error) { - result = &v1alpha1.ClusterServiceVersion{} - err = c.client.Get(). - Namespace(c.ns). - Resource("clusterserviceversions"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of ClusterServiceVersions that match those selectors. -func (c *clusterServiceVersions) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ClusterServiceVersionList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.ClusterServiceVersionList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("clusterserviceversions"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested clusterServiceVersions. -func (c *clusterServiceVersions) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("clusterserviceversions"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a clusterServiceVersion and creates it. Returns the server's representation of the clusterServiceVersion, and an error, if there is any. -func (c *clusterServiceVersions) Create(ctx context.Context, clusterServiceVersion *v1alpha1.ClusterServiceVersion, opts v1.CreateOptions) (result *v1alpha1.ClusterServiceVersion, err error) { - result = &v1alpha1.ClusterServiceVersion{} - err = c.client.Post(). - Namespace(c.ns). - Resource("clusterserviceversions"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(clusterServiceVersion). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a clusterServiceVersion and updates it. Returns the server's representation of the clusterServiceVersion, and an error, if there is any. -func (c *clusterServiceVersions) Update(ctx context.Context, clusterServiceVersion *v1alpha1.ClusterServiceVersion, opts v1.UpdateOptions) (result *v1alpha1.ClusterServiceVersion, err error) { - result = &v1alpha1.ClusterServiceVersion{} - err = c.client.Put(). - Namespace(c.ns). - Resource("clusterserviceversions"). - Name(clusterServiceVersion.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(clusterServiceVersion). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *clusterServiceVersions) UpdateStatus(ctx context.Context, clusterServiceVersion *v1alpha1.ClusterServiceVersion, opts v1.UpdateOptions) (result *v1alpha1.ClusterServiceVersion, err error) { - result = &v1alpha1.ClusterServiceVersion{} - err = c.client.Put(). - Namespace(c.ns). - Resource("clusterserviceversions"). - Name(clusterServiceVersion.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(clusterServiceVersion). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the clusterServiceVersion and deletes it. Returns an error if one occurs. -func (c *clusterServiceVersions) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("clusterserviceversions"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *clusterServiceVersions) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("clusterserviceversions"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched clusterServiceVersion. -func (c *clusterServiceVersions) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ClusterServiceVersion, err error) { - result = &v1alpha1.ClusterServiceVersion{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("clusterserviceversions"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/doc.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/doc.go deleted file mode 100644 index 565b4e857..000000000 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright Red Hat, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -// This package has the automatically generated typed clients. -package v1alpha1 diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/generated_expansion.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/generated_expansion.go deleted file mode 100644 index 6e353f57b..000000000 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/generated_expansion.go +++ /dev/null @@ -1,27 +0,0 @@ -/* -Copyright Red Hat, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 - -type CatalogSourceExpansion interface{} - -type ClusterServiceVersionExpansion interface{} - -type InstallPlanExpansion interface{} - -type SubscriptionExpansion interface{} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/installplan.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/installplan.go deleted file mode 100644 index 24462cc38..000000000 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/installplan.go +++ /dev/null @@ -1,195 +0,0 @@ -/* -Copyright Red Hat, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - "context" - "time" - - v1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1" - scheme "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/scheme" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// InstallPlansGetter has a method to return a InstallPlanInterface. -// A group's client should implement this interface. -type InstallPlansGetter interface { - InstallPlans(namespace string) InstallPlanInterface -} - -// InstallPlanInterface has methods to work with InstallPlan resources. -type InstallPlanInterface interface { - Create(ctx context.Context, installPlan *v1alpha1.InstallPlan, opts v1.CreateOptions) (*v1alpha1.InstallPlan, error) - Update(ctx context.Context, installPlan *v1alpha1.InstallPlan, opts v1.UpdateOptions) (*v1alpha1.InstallPlan, error) - UpdateStatus(ctx context.Context, installPlan *v1alpha1.InstallPlan, opts v1.UpdateOptions) (*v1alpha1.InstallPlan, error) - Delete(ctx context.Context, name string, opts v1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error - Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.InstallPlan, error) - List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.InstallPlanList, error) - Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.InstallPlan, err error) - InstallPlanExpansion -} - -// installPlans implements InstallPlanInterface -type installPlans struct { - client rest.Interface - ns string -} - -// newInstallPlans returns a InstallPlans -func newInstallPlans(c *OperatorsV1alpha1Client, namespace string) *installPlans { - return &installPlans{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the installPlan, and returns the corresponding installPlan object, and an error if there is any. -func (c *installPlans) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.InstallPlan, err error) { - result = &v1alpha1.InstallPlan{} - err = c.client.Get(). - Namespace(c.ns). - Resource("installplans"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of InstallPlans that match those selectors. -func (c *installPlans) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.InstallPlanList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.InstallPlanList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("installplans"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested installPlans. -func (c *installPlans) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("installplans"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a installPlan and creates it. Returns the server's representation of the installPlan, and an error, if there is any. -func (c *installPlans) Create(ctx context.Context, installPlan *v1alpha1.InstallPlan, opts v1.CreateOptions) (result *v1alpha1.InstallPlan, err error) { - result = &v1alpha1.InstallPlan{} - err = c.client.Post(). - Namespace(c.ns). - Resource("installplans"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(installPlan). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a installPlan and updates it. Returns the server's representation of the installPlan, and an error, if there is any. -func (c *installPlans) Update(ctx context.Context, installPlan *v1alpha1.InstallPlan, opts v1.UpdateOptions) (result *v1alpha1.InstallPlan, err error) { - result = &v1alpha1.InstallPlan{} - err = c.client.Put(). - Namespace(c.ns). - Resource("installplans"). - Name(installPlan.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(installPlan). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *installPlans) UpdateStatus(ctx context.Context, installPlan *v1alpha1.InstallPlan, opts v1.UpdateOptions) (result *v1alpha1.InstallPlan, err error) { - result = &v1alpha1.InstallPlan{} - err = c.client.Put(). - Namespace(c.ns). - Resource("installplans"). - Name(installPlan.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(installPlan). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the installPlan and deletes it. Returns an error if one occurs. -func (c *installPlans) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("installplans"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *installPlans) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("installplans"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched installPlan. -func (c *installPlans) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.InstallPlan, err error) { - result = &v1alpha1.InstallPlan{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("installplans"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/operators_client.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/operators_client.go deleted file mode 100644 index 0e2826640..000000000 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/operators_client.go +++ /dev/null @@ -1,122 +0,0 @@ -/* -Copyright Red Hat, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - "net/http" - - v1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1" - "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/scheme" - rest "k8s.io/client-go/rest" -) - -type OperatorsV1alpha1Interface interface { - RESTClient() rest.Interface - CatalogSourcesGetter - ClusterServiceVersionsGetter - InstallPlansGetter - SubscriptionsGetter -} - -// OperatorsV1alpha1Client is used to interact with features provided by the operators.coreos.com group. -type OperatorsV1alpha1Client struct { - restClient rest.Interface -} - -func (c *OperatorsV1alpha1Client) CatalogSources(namespace string) CatalogSourceInterface { - return newCatalogSources(c, namespace) -} - -func (c *OperatorsV1alpha1Client) ClusterServiceVersions(namespace string) ClusterServiceVersionInterface { - return newClusterServiceVersions(c, namespace) -} - -func (c *OperatorsV1alpha1Client) InstallPlans(namespace string) InstallPlanInterface { - return newInstallPlans(c, namespace) -} - -func (c *OperatorsV1alpha1Client) Subscriptions(namespace string) SubscriptionInterface { - return newSubscriptions(c, namespace) -} - -// NewForConfig creates a new OperatorsV1alpha1Client for the given config. -// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), -// where httpClient was generated with rest.HTTPClientFor(c). -func NewForConfig(c *rest.Config) (*OperatorsV1alpha1Client, error) { - config := *c - if err := setConfigDefaults(&config); err != nil { - return nil, err - } - httpClient, err := rest.HTTPClientFor(&config) - if err != nil { - return nil, err - } - return NewForConfigAndClient(&config, httpClient) -} - -// NewForConfigAndClient creates a new OperatorsV1alpha1Client for the given config and http client. -// Note the http client provided takes precedence over the configured transport values. -func NewForConfigAndClient(c *rest.Config, h *http.Client) (*OperatorsV1alpha1Client, error) { - config := *c - if err := setConfigDefaults(&config); err != nil { - return nil, err - } - client, err := rest.RESTClientForConfigAndClient(&config, h) - if err != nil { - return nil, err - } - return &OperatorsV1alpha1Client{client}, nil -} - -// NewForConfigOrDie creates a new OperatorsV1alpha1Client for the given config and -// panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *OperatorsV1alpha1Client { - client, err := NewForConfig(c) - if err != nil { - panic(err) - } - return client -} - -// New creates a new OperatorsV1alpha1Client for the given RESTClient. -func New(c rest.Interface) *OperatorsV1alpha1Client { - return &OperatorsV1alpha1Client{c} -} - -func setConfigDefaults(config *rest.Config) error { - gv := v1alpha1.SchemeGroupVersion - config.GroupVersion = &gv - config.APIPath = "/apis" - config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() - - if config.UserAgent == "" { - config.UserAgent = rest.DefaultKubernetesUserAgent() - } - - return nil -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *OperatorsV1alpha1Client) RESTClient() rest.Interface { - if c == nil { - return nil - } - return c.restClient -} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/subscription.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/subscription.go deleted file mode 100644 index 5ae9a8b1e..000000000 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1/subscription.go +++ /dev/null @@ -1,195 +0,0 @@ -/* -Copyright Red Hat, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - "context" - "time" - - v1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1" - scheme "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/scheme" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// SubscriptionsGetter has a method to return a SubscriptionInterface. -// A group's client should implement this interface. -type SubscriptionsGetter interface { - Subscriptions(namespace string) SubscriptionInterface -} - -// SubscriptionInterface has methods to work with Subscription resources. -type SubscriptionInterface interface { - Create(ctx context.Context, subscription *v1alpha1.Subscription, opts v1.CreateOptions) (*v1alpha1.Subscription, error) - Update(ctx context.Context, subscription *v1alpha1.Subscription, opts v1.UpdateOptions) (*v1alpha1.Subscription, error) - UpdateStatus(ctx context.Context, subscription *v1alpha1.Subscription, opts v1.UpdateOptions) (*v1alpha1.Subscription, error) - Delete(ctx context.Context, name string, opts v1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error - Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.Subscription, error) - List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.SubscriptionList, error) - Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Subscription, err error) - SubscriptionExpansion -} - -// subscriptions implements SubscriptionInterface -type subscriptions struct { - client rest.Interface - ns string -} - -// newSubscriptions returns a Subscriptions -func newSubscriptions(c *OperatorsV1alpha1Client, namespace string) *subscriptions { - return &subscriptions{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the subscription, and returns the corresponding subscription object, and an error if there is any. -func (c *subscriptions) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Subscription, err error) { - result = &v1alpha1.Subscription{} - err = c.client.Get(). - Namespace(c.ns). - Resource("subscriptions"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of Subscriptions that match those selectors. -func (c *subscriptions) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.SubscriptionList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.SubscriptionList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("subscriptions"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested subscriptions. -func (c *subscriptions) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("subscriptions"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a subscription and creates it. Returns the server's representation of the subscription, and an error, if there is any. -func (c *subscriptions) Create(ctx context.Context, subscription *v1alpha1.Subscription, opts v1.CreateOptions) (result *v1alpha1.Subscription, err error) { - result = &v1alpha1.Subscription{} - err = c.client.Post(). - Namespace(c.ns). - Resource("subscriptions"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(subscription). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a subscription and updates it. Returns the server's representation of the subscription, and an error, if there is any. -func (c *subscriptions) Update(ctx context.Context, subscription *v1alpha1.Subscription, opts v1.UpdateOptions) (result *v1alpha1.Subscription, err error) { - result = &v1alpha1.Subscription{} - err = c.client.Put(). - Namespace(c.ns). - Resource("subscriptions"). - Name(subscription.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(subscription). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *subscriptions) UpdateStatus(ctx context.Context, subscription *v1alpha1.Subscription, opts v1.UpdateOptions) (result *v1alpha1.Subscription, err error) { - result = &v1alpha1.Subscription{} - err = c.client.Put(). - Namespace(c.ns). - Resource("subscriptions"). - Name(subscription.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(subscription). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the subscription and deletes it. Returns an error if one occurs. -func (c *subscriptions) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("subscriptions"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *subscriptions) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("subscriptions"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched subscription. -func (c *subscriptions) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Subscription, err error) { - result = &v1alpha1.Subscription{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("subscriptions"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/packagemanifest.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/packagemanifest.go deleted file mode 100644 index d1a89cc1f..000000000 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/packagemanifest.go +++ /dev/null @@ -1,134 +0,0 @@ -package operators - -import ( - "encoding/json" - - opregistry "github.com/operator-framework/operator-registry/pkg/registry" - - operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1" -) - -const ( - // The yaml attribute that specifies the related images of the ClusterServiceVersion - relatedImages = "relatedImages" -) - -// CreateCSVDescription creates a CSVDescription from a given CSV -func CreateCSVDescription(csv *operatorsv1alpha1.ClusterServiceVersion, csvJSON string) CSVDescription { - desc := CSVDescription{ - DisplayName: csv.Spec.DisplayName, - Version: csv.Spec.Version, - Provider: AppLink{ - Name: csv.Spec.Provider.Name, - URL: csv.Spec.Provider.URL, - }, - Annotations: csv.GetAnnotations(), - LongDescription: csv.Spec.Description, - InstallModes: csv.Spec.InstallModes, - CustomResourceDefinitions: operatorsv1alpha1.CustomResourceDefinitions{ - Owned: descriptionsForCRDs(csv.Spec.CustomResourceDefinitions.Owned), - Required: descriptionsForCRDs(csv.Spec.CustomResourceDefinitions.Required), - }, - APIServiceDefinitions: operatorsv1alpha1.APIServiceDefinitions{ - Owned: descriptionsForAPIServices(csv.Spec.APIServiceDefinitions.Owned), - Required: descriptionsForAPIServices(csv.Spec.APIServiceDefinitions.Required), - }, - NativeAPIs: csv.Spec.NativeAPIs, - MinKubeVersion: csv.Spec.MinKubeVersion, - RelatedImages: GetImages(csvJSON), - Keywords: csv.Spec.Keywords, - Maturity: csv.Spec.Maturity, - } - - icons := make([]Icon, len(csv.Spec.Icon)) - for i, icon := range csv.Spec.Icon { - icons[i] = Icon{ - Base64Data: icon.Data, - Mediatype: icon.MediaType, - } - } - - if len(icons) > 0 { - desc.Icon = icons - } - - desc.Links = make([]AppLink, len(csv.Spec.Links)) - for i, link := range csv.Spec.Links { - desc.Links[i] = AppLink{ - Name: link.Name, - URL: link.URL, - } - } - - desc.Maintainers = make([]Maintainer, len(csv.Spec.Maintainers)) - for i, maintainer := range csv.Spec.Maintainers { - desc.Maintainers[i] = Maintainer{ - Name: maintainer.Name, - Email: maintainer.Email, - } - } - - return desc -} - -// descriptionsForCRDs filters certain fields from provided API descriptions to reduce response size. -func descriptionsForCRDs(crds []operatorsv1alpha1.CRDDescription) []operatorsv1alpha1.CRDDescription { - descriptions := []operatorsv1alpha1.CRDDescription{} - for _, crd := range crds { - descriptions = append(descriptions, operatorsv1alpha1.CRDDescription{ - Name: crd.Name, - Version: crd.Version, - Kind: crd.Kind, - DisplayName: crd.DisplayName, - Description: crd.Description, - }) - } - return descriptions -} - -// descriptionsForAPIServices filters certain fields from provided API descriptions to reduce response size. -func descriptionsForAPIServices(apis []operatorsv1alpha1.APIServiceDescription) []operatorsv1alpha1.APIServiceDescription { - descriptions := []operatorsv1alpha1.APIServiceDescription{} - for _, api := range apis { - descriptions = append(descriptions, operatorsv1alpha1.APIServiceDescription{ - Name: api.Name, - Group: api.Group, - Version: api.Version, - Kind: api.Kind, - DisplayName: api.DisplayName, - Description: api.Description, - }) - } - return descriptions -} - -// GetImages returns a list of images listed in CSV (spec and deployments) -func GetImages(csvJSON string) []string { - var images []string - - csv := &opregistry.ClusterServiceVersion{} - err := json.Unmarshal([]byte(csvJSON), &csv) - if err != nil { - return images - } - - imageSet, err := csv.GetOperatorImages() - if err != nil { - return images - } - - relatedImgSet, err := csv.GetRelatedImages() - if err != nil { - return images - } - - for k := range relatedImgSet { - imageSet[k] = struct{}{} - } - - for k := range imageSet { - images = append(images, k) - } - - return images -} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1/packagemanifest.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1/packagemanifest.go deleted file mode 100644 index b61eeb5f4..000000000 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1/packagemanifest.go +++ /dev/null @@ -1,97 +0,0 @@ -package v1 - -import ( - "encoding/json" - - opregistry "github.com/operator-framework/operator-registry/pkg/registry" - - operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1" -) - -const ( - // The yaml attribute that specifies the related images of the ClusterServiceVersion - relatedImages = "relatedImages" -) - -// CreateCSVDescription creates a CSVDescription from a given CSV -func CreateCSVDescription(csv *operatorsv1alpha1.ClusterServiceVersion, csvJSON string) CSVDescription { - desc := CSVDescription{ - DisplayName: csv.Spec.DisplayName, - Version: csv.Spec.Version, - Provider: AppLink{ - Name: csv.Spec.Provider.Name, - URL: csv.Spec.Provider.URL, - }, - Annotations: csv.GetAnnotations(), - LongDescription: csv.Spec.Description, - InstallModes: csv.Spec.InstallModes, - CustomResourceDefinitions: csv.Spec.CustomResourceDefinitions, - APIServiceDefinitions: csv.Spec.APIServiceDefinitions, - NativeAPIs: csv.Spec.NativeAPIs, - MinKubeVersion: csv.Spec.MinKubeVersion, - RelatedImages: GetImages(csvJSON), - Keywords: csv.Spec.Keywords, - Maturity: csv.Spec.Maturity, - } - - icons := make([]Icon, len(csv.Spec.Icon)) - for i, icon := range csv.Spec.Icon { - icons[i] = Icon{ - Base64Data: icon.Data, - Mediatype: icon.MediaType, - } - } - - if len(icons) > 0 { - desc.Icon = icons - } - - desc.Links = make([]AppLink, len(csv.Spec.Links)) - for i, link := range csv.Spec.Links { - desc.Links[i] = AppLink{ - Name: link.Name, - URL: link.URL, - } - } - - desc.Maintainers = make([]Maintainer, len(csv.Spec.Maintainers)) - for i, maintainer := range csv.Spec.Maintainers { - desc.Maintainers[i] = Maintainer{ - Name: maintainer.Name, - Email: maintainer.Email, - } - } - - return desc -} - -// GetImages returns a list of images listed in CSV (spec and deployments) -func GetImages(csvJSON string) []string { - var images []string - - csv := &opregistry.ClusterServiceVersion{} - err := json.Unmarshal([]byte(csvJSON), &csv) - if err != nil { - return images - } - - imageSet, err := csv.GetOperatorImages() - if err != nil { - return images - } - - relatedImgSet, err := csv.GetRelatedImages() - if err != nil { - return images - } - - for k := range relatedImgSet { - imageSet[k] = struct{}{} - } - - for k := range imageSet { - images = append(images, k) - } - - return images -} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/scheme/doc.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/scheme/doc.go deleted file mode 100644 index 251358bb4..000000000 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/scheme/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright Red Hat, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -// This package contains the scheme of the automatically generated clientset. -package scheme diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/scheme/register.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/scheme/register.go deleted file mode 100644 index 63ead29be..000000000 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/scheme/register.go +++ /dev/null @@ -1,56 +0,0 @@ -/* -Copyright Red Hat, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package scheme - -import ( - operatorsv1 "github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - schema "k8s.io/apimachinery/pkg/runtime/schema" - serializer "k8s.io/apimachinery/pkg/runtime/serializer" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" -) - -var Scheme = runtime.NewScheme() -var Codecs = serializer.NewCodecFactory(Scheme) -var ParameterCodec = runtime.NewParameterCodec(Scheme) -var localSchemeBuilder = runtime.SchemeBuilder{ - operatorsv1.AddToScheme, -} - -// AddToScheme adds all types of this clientset into the given scheme. This allows composition -// of clientsets, like in: -// -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) -// -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) -// -// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types -// correctly. -var AddToScheme = localSchemeBuilder.AddToScheme - -func init() { - v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) - utilruntime.Must(AddToScheme(Scheme)) -} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/typed/operators/v1/doc.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/typed/operators/v1/doc.go deleted file mode 100644 index d84e927bc..000000000 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/typed/operators/v1/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright Red Hat, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -// This package has the automatically generated typed clients. -package v1 diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/typed/operators/v1/generated_expansion.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/typed/operators/v1/generated_expansion.go deleted file mode 100644 index f9bc8183f..000000000 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/typed/operators/v1/generated_expansion.go +++ /dev/null @@ -1,21 +0,0 @@ -/* -Copyright Red Hat, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1 - -type PackageManifestExpansion interface{} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/typed/operators/v1/operators_client.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/typed/operators/v1/operators_client.go deleted file mode 100644 index cd7b4ae60..000000000 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/typed/operators/v1/operators_client.go +++ /dev/null @@ -1,107 +0,0 @@ -/* -Copyright Red Hat, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1 - -import ( - "net/http" - - v1 "github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1" - "github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/scheme" - rest "k8s.io/client-go/rest" -) - -type OperatorsV1Interface interface { - RESTClient() rest.Interface - PackageManifestsGetter -} - -// OperatorsV1Client is used to interact with features provided by the operators.coreos.com group. -type OperatorsV1Client struct { - restClient rest.Interface -} - -func (c *OperatorsV1Client) PackageManifests(namespace string) PackageManifestInterface { - return newPackageManifests(c, namespace) -} - -// NewForConfig creates a new OperatorsV1Client for the given config. -// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), -// where httpClient was generated with rest.HTTPClientFor(c). -func NewForConfig(c *rest.Config) (*OperatorsV1Client, error) { - config := *c - if err := setConfigDefaults(&config); err != nil { - return nil, err - } - httpClient, err := rest.HTTPClientFor(&config) - if err != nil { - return nil, err - } - return NewForConfigAndClient(&config, httpClient) -} - -// NewForConfigAndClient creates a new OperatorsV1Client for the given config and http client. -// Note the http client provided takes precedence over the configured transport values. -func NewForConfigAndClient(c *rest.Config, h *http.Client) (*OperatorsV1Client, error) { - config := *c - if err := setConfigDefaults(&config); err != nil { - return nil, err - } - client, err := rest.RESTClientForConfigAndClient(&config, h) - if err != nil { - return nil, err - } - return &OperatorsV1Client{client}, nil -} - -// NewForConfigOrDie creates a new OperatorsV1Client for the given config and -// panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *OperatorsV1Client { - client, err := NewForConfig(c) - if err != nil { - panic(err) - } - return client -} - -// New creates a new OperatorsV1Client for the given RESTClient. -func New(c rest.Interface) *OperatorsV1Client { - return &OperatorsV1Client{c} -} - -func setConfigDefaults(config *rest.Config) error { - gv := v1.SchemeGroupVersion - config.GroupVersion = &gv - config.APIPath = "/apis" - config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() - - if config.UserAgent == "" { - config.UserAgent = rest.DefaultKubernetesUserAgent() - } - - return nil -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *OperatorsV1Client) RESTClient() rest.Interface { - if c == nil { - return nil - } - return c.restClient -} diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/typed/operators/v1/packagemanifest.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/typed/operators/v1/packagemanifest.go deleted file mode 100644 index fe87f30cb..000000000 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/typed/operators/v1/packagemanifest.go +++ /dev/null @@ -1,195 +0,0 @@ -/* -Copyright Red Hat, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1 - -import ( - "context" - "time" - - v1 "github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1" - scheme "github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/scheme" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// PackageManifestsGetter has a method to return a PackageManifestInterface. -// A group's client should implement this interface. -type PackageManifestsGetter interface { - PackageManifests(namespace string) PackageManifestInterface -} - -// PackageManifestInterface has methods to work with PackageManifest resources. -type PackageManifestInterface interface { - Create(ctx context.Context, packageManifest *v1.PackageManifest, opts metav1.CreateOptions) (*v1.PackageManifest, error) - Update(ctx context.Context, packageManifest *v1.PackageManifest, opts metav1.UpdateOptions) (*v1.PackageManifest, error) - UpdateStatus(ctx context.Context, packageManifest *v1.PackageManifest, opts metav1.UpdateOptions) (*v1.PackageManifest, error) - Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error - Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.PackageManifest, error) - List(ctx context.Context, opts metav1.ListOptions) (*v1.PackageManifestList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.PackageManifest, err error) - PackageManifestExpansion -} - -// packageManifests implements PackageManifestInterface -type packageManifests struct { - client rest.Interface - ns string -} - -// newPackageManifests returns a PackageManifests -func newPackageManifests(c *OperatorsV1Client, namespace string) *packageManifests { - return &packageManifests{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the packageManifest, and returns the corresponding packageManifest object, and an error if there is any. -func (c *packageManifests) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.PackageManifest, err error) { - result = &v1.PackageManifest{} - err = c.client.Get(). - Namespace(c.ns). - Resource("packagemanifests"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of PackageManifests that match those selectors. -func (c *packageManifests) List(ctx context.Context, opts metav1.ListOptions) (result *v1.PackageManifestList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1.PackageManifestList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("packagemanifests"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested packageManifests. -func (c *packageManifests) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("packagemanifests"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a packageManifest and creates it. Returns the server's representation of the packageManifest, and an error, if there is any. -func (c *packageManifests) Create(ctx context.Context, packageManifest *v1.PackageManifest, opts metav1.CreateOptions) (result *v1.PackageManifest, err error) { - result = &v1.PackageManifest{} - err = c.client.Post(). - Namespace(c.ns). - Resource("packagemanifests"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(packageManifest). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a packageManifest and updates it. Returns the server's representation of the packageManifest, and an error, if there is any. -func (c *packageManifests) Update(ctx context.Context, packageManifest *v1.PackageManifest, opts metav1.UpdateOptions) (result *v1.PackageManifest, err error) { - result = &v1.PackageManifest{} - err = c.client.Put(). - Namespace(c.ns). - Resource("packagemanifests"). - Name(packageManifest.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(packageManifest). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *packageManifests) UpdateStatus(ctx context.Context, packageManifest *v1.PackageManifest, opts metav1.UpdateOptions) (result *v1.PackageManifest, err error) { - result = &v1.PackageManifest{} - err = c.client.Put(). - Namespace(c.ns). - Resource("packagemanifests"). - Name(packageManifest.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(packageManifest). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the packageManifest and deletes it. Returns an error if one occurs. -func (c *packageManifests) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("packagemanifests"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *packageManifests) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("packagemanifests"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched packageManifest. -func (c *packageManifests) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.PackageManifest, err error) { - result = &v1.PackageManifest{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("packagemanifests"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/vendor/github.com/operator-framework/operator-registry/LICENSE b/vendor/github.com/operator-framework/operator-registry/LICENSE deleted file mode 100644 index 261eeb9e9..000000000 --- a/vendor/github.com/operator-framework/operator-registry/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/github.com/operator-framework/operator-registry/alpha/model/error.go b/vendor/github.com/operator-framework/operator-registry/alpha/model/error.go deleted file mode 100644 index 0ad0f7adb..000000000 --- a/vendor/github.com/operator-framework/operator-registry/alpha/model/error.go +++ /dev/null @@ -1,66 +0,0 @@ -package model - -import ( - "bytes" - "fmt" - "strings" -) - -type validationError struct { - message string - subErrors []error -} - -func newValidationError(message string) *validationError { - return &validationError{message: message} -} - -func (v *validationError) orNil() error { - if len(v.subErrors) == 0 { - return nil - } - return v -} - -func (v *validationError) Error() string { - if v == nil { - return "" - } - return strings.TrimSpace(v.errorPrefix(nil, true, nil)) -} - -func (v *validationError) errorPrefix(prefix []rune, last bool, seen []error) string { - for _, s := range seen { - if v == s { - return "" - } - } - seen = append(seen, v) - sep := ":\n" - if len(v.subErrors) == 0 { - sep = "\n" - } - errMsg := bytes.NewBufferString(fmt.Sprintf("%s%s%s", string(prefix), v.message, sep)) - for i, serr := range v.subErrors { - subPrefix := prefix - if len(subPrefix) >= 4 { - if last { - subPrefix = append(subPrefix[0:len(subPrefix)-4], []rune(" ")...) - } else { - subPrefix = append(subPrefix[0:len(subPrefix)-4], []rune("│ ")...) - } - } - subLast := i == len(v.subErrors)-1 - if subLast { - subPrefix = append(subPrefix, []rune("└── ")...) - } else { - subPrefix = append(subPrefix, []rune("├── ")...) - } - if verr, ok := serr.(*validationError); ok { - errMsg.WriteString(verr.errorPrefix(subPrefix, subLast, seen)) - } else { - errMsg.WriteString(fmt.Sprintf("%s%s\n", string(subPrefix), serr)) - } - } - return errMsg.String() -} diff --git a/vendor/github.com/operator-framework/operator-registry/alpha/model/model.go b/vendor/github.com/operator-framework/operator-registry/alpha/model/model.go deleted file mode 100644 index fe73a3c4c..000000000 --- a/vendor/github.com/operator-framework/operator-registry/alpha/model/model.go +++ /dev/null @@ -1,407 +0,0 @@ -package model - -import ( - "errors" - "fmt" - "sort" - "strings" - - "github.com/blang/semver/v4" - "github.com/h2non/filetype" - "github.com/h2non/filetype/matchers" - "github.com/h2non/filetype/types" - svg "github.com/h2non/go-is-svg" - "k8s.io/apimachinery/pkg/util/sets" - - "github.com/operator-framework/operator-registry/alpha/property" -) - -type Deprecation struct { - Message string `json:"message"` -} - -func init() { - t := types.NewType("svg", "image/svg+xml") - filetype.AddMatcher(t, svg.Is) - matchers.Image[types.NewType("svg", "image/svg+xml")] = svg.Is -} - -type Model map[string]*Package - -func (m Model) Validate() error { - result := newValidationError("invalid index") - - for name, pkg := range m { - if name != pkg.Name { - result.subErrors = append(result.subErrors, fmt.Errorf("package key %q does not match package name %q", name, pkg.Name)) - } - if err := pkg.Validate(); err != nil { - result.subErrors = append(result.subErrors, err) - } - } - return result.orNil() -} - -type Package struct { - Name string - Description string - Icon *Icon - DefaultChannel *Channel - Channels map[string]*Channel - Deprecation *Deprecation -} - -func (m *Package) Validate() error { - result := newValidationError(fmt.Sprintf("invalid package %q", m.Name)) - - if m.Name == "" { - result.subErrors = append(result.subErrors, errors.New("package name must not be empty")) - } - - if err := m.Icon.Validate(); err != nil { - result.subErrors = append(result.subErrors, err) - } - - if m.DefaultChannel == nil { - result.subErrors = append(result.subErrors, fmt.Errorf("default channel must be set")) - } - - if len(m.Channels) == 0 { - result.subErrors = append(result.subErrors, fmt.Errorf("package must contain at least one channel")) - } - - foundDefault := false - for name, ch := range m.Channels { - if name != ch.Name { - result.subErrors = append(result.subErrors, fmt.Errorf("channel key %q does not match channel name %q", name, ch.Name)) - } - if err := ch.Validate(); err != nil { - result.subErrors = append(result.subErrors, err) - } - if ch == m.DefaultChannel { - foundDefault = true - } - if ch.Package != m { - result.subErrors = append(result.subErrors, fmt.Errorf("channel %q not correctly linked to parent package", ch.Name)) - } - } - - if m.DefaultChannel != nil && !foundDefault { - result.subErrors = append(result.subErrors, fmt.Errorf("default channel %q not found in channels list", m.DefaultChannel.Name)) - } - - if err := m.Deprecation.Validate(); err != nil { - result.subErrors = append(result.subErrors, fmt.Errorf("invalid deprecation: %v", err)) - } - - return result.orNil() -} - -type Icon struct { - Data []byte `json:"base64data"` - MediaType string `json:"mediatype"` -} - -func (i *Icon) Validate() error { - if i == nil { - return nil - } - // TODO(joelanford): Should we check that data and mediatype are set, - // and detect the media type of the data and compare it to the - // mediatype listed in the icon field? Currently, some production - // index databases are failing these tests, so leaving this - // commented out for now. - result := newValidationError("invalid icon") - //if len(i.Data) == 0 { - // result.subErrors = append(result.subErrors, errors.New("icon data must be set if icon is defined")) - //} - //if len(i.MediaType) == 0 { - // result.subErrors = append(result.subErrors, errors.New("icon mediatype must be set if icon is defined")) - //} - //if len(i.Data) > 0 { - // if err := i.validateData(); err != nil { - // result.subErrors = append(result.subErrors, err) - // } - //} - return result.orNil() -} - -func (i *Icon) validateData() error { - if !filetype.IsImage(i.Data) { - return errors.New("icon data is not an image") - } - t, err := filetype.Match(i.Data) - if err != nil { - return err - } - if t.MIME.Value != i.MediaType { - return fmt.Errorf("icon media type %q does not match detected media type %q", i.MediaType, t.MIME.Value) - } - return nil -} - -type Channel struct { - Package *Package - Name string - Bundles map[string]*Bundle - Deprecation *Deprecation - // NOTICE: The field Properties of the type Channel is for internal use only. - // DO NOT use it for any public-facing functionalities. - // This API is in alpha stage and it is subject to change. - Properties []property.Property -} - -// TODO(joelanford): This function determines the channel head by finding the bundle that has 0 -// -// incoming edges, based on replaces and skips. It also expects to find exactly one such bundle. -// Is this the correct algorithm? -func (c Channel) Head() (*Bundle, error) { - incoming := map[string]int{} - for _, b := range c.Bundles { - if b.Replaces != "" { - incoming[b.Replaces]++ - } - for _, skip := range b.Skips { - incoming[skip]++ - } - } - var heads []*Bundle - for _, b := range c.Bundles { - if _, ok := incoming[b.Name]; !ok { - heads = append(heads, b) - } - } - if len(heads) == 0 { - return nil, fmt.Errorf("no channel head found in graph") - } - if len(heads) > 1 { - var headNames []string - for _, head := range heads { - headNames = append(headNames, head.Name) - } - sort.Strings(headNames) - return nil, fmt.Errorf("multiple channel heads found in graph: %s", strings.Join(headNames, ", ")) - } - return heads[0], nil -} - -func (c *Channel) Validate() error { - result := newValidationError(fmt.Sprintf("invalid channel %q", c.Name)) - - if c.Name == "" { - result.subErrors = append(result.subErrors, errors.New("channel name must not be empty")) - } - - if c.Package == nil { - result.subErrors = append(result.subErrors, errors.New("package must be set")) - } - - if len(c.Bundles) == 0 { - result.subErrors = append(result.subErrors, fmt.Errorf("channel must contain at least one bundle")) - } - - if len(c.Bundles) > 0 { - if err := c.validateReplacesChain(); err != nil { - result.subErrors = append(result.subErrors, err) - } - } - - for name, b := range c.Bundles { - if name != b.Name { - result.subErrors = append(result.subErrors, fmt.Errorf("bundle key %q does not match bundle name %q", name, b.Name)) - } - if err := b.Validate(); err != nil { - result.subErrors = append(result.subErrors, err) - } - if b.Channel != c { - result.subErrors = append(result.subErrors, fmt.Errorf("bundle %q not correctly linked to parent channel", b.Name)) - } - } - - if err := c.Deprecation.Validate(); err != nil { - result.subErrors = append(result.subErrors, fmt.Errorf("invalid deprecation: %v", err)) - } - - return result.orNil() -} - -// validateReplacesChain checks the replaces chain of a channel. -// Specifically the following rules must be followed: -// 1. There must be exactly 1 channel head. -// 2. Beginning at the head, the replaces chain must reach all non-skipped entries. -// Non-skipped entries are defined as entries that are not skipped by any other entry in the channel. -// 3. There must be no cycles in the replaces chain. -// 4. The tail entry in the replaces chain is permitted to replace a non-existent entry. -func (c *Channel) validateReplacesChain() error { - head, err := c.Head() - if err != nil { - return err - } - - allBundles := sets.NewString() - skippedBundles := sets.NewString() - for _, b := range c.Bundles { - allBundles = allBundles.Insert(b.Name) - skippedBundles = skippedBundles.Insert(b.Skips...) - } - - chainFrom := map[string][]string{} - replacesChainFromHead := sets.NewString(head.Name) - cur := head - for cur != nil { - if _, ok := chainFrom[cur.Name]; !ok { - chainFrom[cur.Name] = []string{cur.Name} - } - for k := range chainFrom { - chainFrom[k] = append(chainFrom[k], cur.Replaces) - } - if replacesChainFromHead.Has(cur.Replaces) { - return fmt.Errorf("detected cycle in replaces chain of upgrade graph: %s", strings.Join(chainFrom[cur.Replaces], " -> ")) - } - replacesChainFromHead = replacesChainFromHead.Insert(cur.Replaces) - cur = c.Bundles[cur.Replaces] - } - - strandedBundles := allBundles.Difference(replacesChainFromHead).Difference(skippedBundles).List() - if len(strandedBundles) > 0 { - return fmt.Errorf("channel contains one or more stranded bundles: %s", strings.Join(strandedBundles, ", ")) - } - - return nil -} - -type Bundle struct { - Package *Package - Channel *Channel - Name string - Image string - Replaces string - Skips []string - SkipRange string - Properties []property.Property - RelatedImages []RelatedImage - Deprecation *Deprecation - - // These fields are present so that we can continue serving - // the GRPC API the way packageserver expects us to in a - // backwards-compatible way. - Objects []string - CsvJSON string - - // These fields are used to compare bundles in a diff. - PropertiesP *property.Properties - Version semver.Version -} - -func (b *Bundle) Validate() error { - result := newValidationError(fmt.Sprintf("invalid bundle %q", b.Name)) - - if b.Name == "" { - result.subErrors = append(result.subErrors, errors.New("name must be set")) - } - if b.Channel == nil { - result.subErrors = append(result.subErrors, errors.New("channel must be set")) - } - if b.Package == nil { - result.subErrors = append(result.subErrors, errors.New("package must be set")) - } - if b.Channel != nil && b.Package != nil && b.Package != b.Channel.Package { - result.subErrors = append(result.subErrors, errors.New("package does not match channel's package")) - } - props, err := property.Parse(b.Properties) - if err != nil { - result.subErrors = append(result.subErrors, err) - } - for i, skip := range b.Skips { - if skip == "" { - result.subErrors = append(result.subErrors, fmt.Errorf("skip[%d] is empty", i)) - } - } - // TODO(joelanford): Validate related images? It looks like some - // CSVs in production databases use incorrect fields ([name,value] - // instead of [name,image]), which results in empty image values. - // Example is in redhat-operators: 3scale-operator.v0.5.5 - //for i, relatedImage := range b.RelatedImages { - // if err := relatedImage.Validate(); err != nil { - // result.subErrors = append(result.subErrors, WithIndex(i, err)) - // } - //} - - if props != nil && len(props.Packages) != 1 { - result.subErrors = append(result.subErrors, fmt.Errorf("must be exactly one property with type %q", property.TypePackage)) - } - - if b.Image == "" && len(b.Objects) == 0 { - result.subErrors = append(result.subErrors, errors.New("bundle image must be set")) - } - - if err := b.Deprecation.Validate(); err != nil { - result.subErrors = append(result.subErrors, fmt.Errorf("invalid deprecation: %v", err)) - } - - return result.orNil() -} - -type RelatedImage struct { - Name string - Image string -} - -func (i RelatedImage) Validate() error { - result := newValidationError("invalid related image") - if i.Image == "" { - result.subErrors = append(result.subErrors, fmt.Errorf("image must be set")) - } - return result.orNil() -} - -func (m Model) Normalize() { - for _, pkg := range m { - for _, ch := range pkg.Channels { - for _, b := range ch.Bundles { - for i := range b.Properties { - // Ensure property value is encoded in a standard way. - if normalized, err := property.Build(&b.Properties[i]); err == nil { - b.Properties[i] = *normalized - } - } - } - } - } -} - -func (m Model) AddBundle(b Bundle) { - if _, present := m[b.Package.Name]; !present { - m[b.Package.Name] = b.Package - } - p := m[b.Package.Name] - b.Package = p - - if ch, ok := p.Channels[b.Channel.Name]; ok { - b.Channel = ch - ch.Bundles[b.Name] = &b - } else { - newCh := &Channel{ - Name: b.Channel.Name, - Package: p, - Bundles: make(map[string]*Bundle), - } - b.Channel = newCh - newCh.Bundles[b.Name] = &b - p.Channels[newCh.Name] = newCh - } - - if p.DefaultChannel == nil { - p.DefaultChannel = b.Channel - } -} - -func (d *Deprecation) Validate() error { - if d == nil { - return nil - } - if d.Message == "" { - return errors.New("message must be set") - } - return nil -} diff --git a/vendor/github.com/operator-framework/operator-registry/alpha/property/errors.go b/vendor/github.com/operator-framework/operator-registry/alpha/property/errors.go deleted file mode 100644 index 6c3689c5b..000000000 --- a/vendor/github.com/operator-framework/operator-registry/alpha/property/errors.go +++ /dev/null @@ -1,25 +0,0 @@ -package property - -import ( - "fmt" -) - -type ParseError struct { - Idx int - Typ string - Err error -} - -func (e ParseError) Error() string { - return fmt.Sprintf("parse property[%d] of type %q: %v", e.Idx, e.Typ, e.Err) -} - -type MatchMissingError struct { - foundType string - foundValue interface{} - expectedType string -} - -func (e MatchMissingError) Error() string { - return fmt.Sprintf("property %q for %+v requires matching %q property", e.foundType, e.foundValue, e.expectedType) -} diff --git a/vendor/github.com/operator-framework/operator-registry/alpha/property/property.go b/vendor/github.com/operator-framework/operator-registry/alpha/property/property.go deleted file mode 100644 index 6869b2e67..000000000 --- a/vendor/github.com/operator-framework/operator-registry/alpha/property/property.go +++ /dev/null @@ -1,286 +0,0 @@ -package property - -import ( - "bytes" - "encoding/json" - "errors" - "fmt" - "reflect" - - "github.com/operator-framework/api/pkg/operators/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -type Property struct { - Type string `json:"type"` - Value json.RawMessage `json:"value"` -} - -func (p Property) Validate() error { - if len(p.Type) == 0 { - return errors.New("type must be set") - } - if len(p.Value) == 0 { - return errors.New("value must be set") - } - var raw json.RawMessage - if err := json.Unmarshal(p.Value, &raw); err != nil { - return fmt.Errorf("value is not valid json: %v", err) - } - return nil -} - -func (p Property) String() string { - return fmt.Sprintf("type: %q, value: %q", p.Type, p.Value) -} - -type Package struct { - PackageName string `json:"packageName"` - Version string `json:"version"` -} - -// NOTICE: The Channel properties are for internal use only. -// -// DO NOT use it for any public-facing functionalities. -// This API is in alpha stage and it is subject to change. -type Channel struct { - ChannelName string `json:"channelName"` - //Priority string `json:"priority"` - Priority int `json:"priority"` -} - -type PackageRequired struct { - PackageName string `json:"packageName"` - VersionRange string `json:"versionRange"` -} - -type GVK struct { - Group string `json:"group"` - Kind string `json:"kind"` - Version string `json:"version"` -} - -type GVKRequired struct { - Group string `json:"group"` - Kind string `json:"kind"` - Version string `json:"version"` -} - -type BundleObject struct { - Data []byte `json:"data"` -} - -type CSVMetadata struct { - Annotations map[string]string `json:"annotations,omitempty"` - APIServiceDefinitions v1alpha1.APIServiceDefinitions `json:"apiServiceDefinitions,omitempty"` - CustomResourceDefinitions v1alpha1.CustomResourceDefinitions `json:"crdDescriptions,omitempty"` - Description string `json:"description,omitempty"` - DisplayName string `json:"displayName,omitempty"` - InstallModes []v1alpha1.InstallMode `json:"installModes,omitempty"` - Keywords []string `json:"keywords,omitempty"` - Labels map[string]string `json:"labels,omitempty"` - Links []v1alpha1.AppLink `json:"links,omitempty"` - Maintainers []v1alpha1.Maintainer `json:"maintainers,omitempty"` - Maturity string `json:"maturity,omitempty"` - MinKubeVersion string `json:"minKubeVersion,omitempty"` - NativeAPIs []metav1.GroupVersionKind `json:"nativeAPIs,omitempty"` - Provider v1alpha1.AppLink `json:"provider,omitempty"` -} - -type Properties struct { - Packages []Package `hash:"set"` - PackagesRequired []PackageRequired `hash:"set"` - GVKs []GVK `hash:"set"` - GVKsRequired []GVKRequired `hash:"set"` - BundleObjects []BundleObject `hash:"set"` - Channels []Channel `hash:"set"` - CSVMetadatas []CSVMetadata `hash:"set"` - - Others []Property `hash:"set"` -} - -const ( - TypePackage = "olm.package" - TypePackageRequired = "olm.package.required" - TypeGVK = "olm.gvk" - TypeGVKRequired = "olm.gvk.required" - TypeBundleObject = "olm.bundle.object" - TypeCSVMetadata = "olm.csv.metadata" - TypeConstraint = "olm.constraint" - TypeChannel = "olm.channel" -) - -func Parse(in []Property) (*Properties, error) { - var out Properties - for i, prop := range in { - switch prop.Type { - case TypePackage: - var p Package - if err := json.Unmarshal(prop.Value, &p); err != nil { - return nil, ParseError{Idx: i, Typ: prop.Type, Err: err} - } - out.Packages = append(out.Packages, p) - case TypePackageRequired: - var p PackageRequired - if err := json.Unmarshal(prop.Value, &p); err != nil { - return nil, ParseError{Idx: i, Typ: prop.Type, Err: err} - } - out.PackagesRequired = append(out.PackagesRequired, p) - case TypeGVK: - var p GVK - if err := json.Unmarshal(prop.Value, &p); err != nil { - return nil, ParseError{Idx: i, Typ: prop.Type, Err: err} - } - out.GVKs = append(out.GVKs, p) - case TypeGVKRequired: - var p GVKRequired - if err := json.Unmarshal(prop.Value, &p); err != nil { - return nil, ParseError{Idx: i, Typ: prop.Type, Err: err} - } - out.GVKsRequired = append(out.GVKsRequired, p) - case TypeBundleObject: - var p BundleObject - if err := json.Unmarshal(prop.Value, &p); err != nil { - return nil, ParseError{Idx: i, Typ: prop.Type, Err: err} - } - out.BundleObjects = append(out.BundleObjects, p) - case TypeCSVMetadata: - var p CSVMetadata - if err := json.Unmarshal(prop.Value, &p); err != nil { - return nil, ParseError{Idx: i, Typ: prop.Type, Err: err} - } - out.CSVMetadatas = append(out.CSVMetadatas, p) - // NOTICE: The Channel properties are for internal use only. - // DO NOT use it for any public-facing functionalities. - // This API is in alpha stage and it is subject to change. - case TypeChannel: - var p Channel - if err := json.Unmarshal(prop.Value, &p); err != nil { - return nil, ParseError{Idx: i, Typ: prop.Type, Err: err} - } - out.Channels = append(out.Channels, p) - default: - var p json.RawMessage - if err := json.Unmarshal(prop.Value, &p); err != nil { - return nil, ParseError{Idx: i, Typ: prop.Type, Err: err} - } - out.Others = append(out.Others, prop) - } - } - return &out, nil -} - -func Deduplicate(in []Property) []Property { - type key struct { - typ string - value string - } - - props := map[key]Property{} - var out []Property - for _, p := range in { - k := key{p.Type, string(p.Value)} - if _, ok := props[k]; ok { - continue - } - props[k] = p - out = append(out, p) - } - return out -} - -func Build(p interface{}) (*Property, error) { - var ( - typ string - val interface{} - ) - if prop, ok := p.(*Property); ok { - typ = prop.Type - val = prop.Value - } else { - t := reflect.TypeOf(p) - if t.Kind() != reflect.Ptr { - return nil, errors.New("input must be a pointer to a type") - } - typ, ok = scheme[t] - if !ok { - return nil, fmt.Errorf("%s not a known property type registered with the scheme", t) - } - val = p - } - d, err := jsonMarshal(val) - if err != nil { - return nil, err - } - - return &Property{ - Type: typ, - Value: d, - }, nil -} - -func MustBuild(p interface{}) Property { - prop, err := Build(p) - if err != nil { - panic(err) - } - return *prop -} - -func jsonMarshal(p interface{}) ([]byte, error) { - buf := &bytes.Buffer{} - dec := json.NewEncoder(buf) - dec.SetEscapeHTML(false) - err := dec.Encode(p) - if err != nil { - return nil, err - } - out := &bytes.Buffer{} - if err := json.Compact(out, buf.Bytes()); err != nil { - return nil, err - } - return out.Bytes(), nil -} - -func MustBuildPackage(name, version string) Property { - return MustBuild(&Package{PackageName: name, Version: version}) -} -func MustBuildPackageRequired(name, versionRange string) Property { - return MustBuild(&PackageRequired{name, versionRange}) -} -func MustBuildGVK(group, version, kind string) Property { - return MustBuild(&GVK{group, kind, version}) -} -func MustBuildGVKRequired(group, version, kind string) Property { - return MustBuild(&GVKRequired{group, kind, version}) -} -func MustBuildBundleObject(data []byte) Property { - return MustBuild(&BundleObject{Data: data}) -} - -func MustBuildCSVMetadata(csv v1alpha1.ClusterServiceVersion) Property { - return MustBuild(&CSVMetadata{ - Annotations: csv.GetAnnotations(), - APIServiceDefinitions: csv.Spec.APIServiceDefinitions, - CustomResourceDefinitions: csv.Spec.CustomResourceDefinitions, - Description: csv.Spec.Description, - DisplayName: csv.Spec.DisplayName, - InstallModes: csv.Spec.InstallModes, - Keywords: csv.Spec.Keywords, - Labels: csv.GetLabels(), - Links: csv.Spec.Links, - Maintainers: csv.Spec.Maintainers, - Maturity: csv.Spec.Maturity, - MinKubeVersion: csv.Spec.MinKubeVersion, - NativeAPIs: csv.Spec.NativeAPIs, - Provider: csv.Spec.Provider, - }) -} - -// NOTICE: The Channel properties are for internal use only. -// -// DO NOT use it for any public-facing functionalities. -// This API is in alpha stage and it is subject to change. -func MustBuildChannelPriority(name string, priority int) Property { - return MustBuild(&Channel{ChannelName: name, Priority: priority}) -} diff --git a/vendor/github.com/operator-framework/operator-registry/alpha/property/scheme.go b/vendor/github.com/operator-framework/operator-registry/alpha/property/scheme.go deleted file mode 100644 index ab176856f..000000000 --- a/vendor/github.com/operator-framework/operator-registry/alpha/property/scheme.go +++ /dev/null @@ -1,34 +0,0 @@ -package property - -import ( - "fmt" - "reflect" -) - -func init() { - scheme = map[reflect.Type]string{ - reflect.TypeOf(&Package{}): TypePackage, - reflect.TypeOf(&PackageRequired{}): TypePackageRequired, - reflect.TypeOf(&GVK{}): TypeGVK, - reflect.TypeOf(&GVKRequired{}): TypeGVKRequired, - reflect.TypeOf(&BundleObject{}): TypeBundleObject, - reflect.TypeOf(&CSVMetadata{}): TypeCSVMetadata, - // NOTICE: The Channel properties are for internal use only. - // DO NOT use it for any public-facing functionalities. - // This API is in alpha stage and it is subject to change. - reflect.TypeOf(&Channel{}): TypeChannel, - } -} - -var scheme map[reflect.Type]string - -func AddToScheme(typ string, p interface{}) { - t := reflect.TypeOf(p) - if t.Kind() != reflect.Ptr { - panic("input must be a pointer to a type") - } - if _, ok := scheme[t]; ok { - panic(fmt.Sprintf("scheme already contains registration for type %q", t)) - } - scheme[t] = typ -} diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/api/api_to_model.go b/vendor/github.com/operator-framework/operator-registry/pkg/api/api_to_model.go deleted file mode 100644 index e9408c455..000000000 --- a/vendor/github.com/operator-framework/operator-registry/pkg/api/api_to_model.go +++ /dev/null @@ -1,155 +0,0 @@ -package api - -import ( - "encoding/json" - "fmt" - "sort" - - "github.com/operator-framework/api/pkg/operators/v1alpha1" - - "github.com/operator-framework/operator-registry/alpha/model" - "github.com/operator-framework/operator-registry/alpha/property" -) - -func ConvertAPIBundleToModelBundle(b *Bundle) (*model.Bundle, error) { - bundleProps, err := convertAPIBundleToModelProperties(b) - if err != nil { - return nil, fmt.Errorf("convert properties: %v", err) - } - - relatedImages, err := getRelatedImages(b.CsvJson) - if err != nil { - return nil, fmt.Errorf("get related iamges: %v", err) - } - - return &model.Bundle{ - Name: b.CsvName, - Image: b.BundlePath, - Replaces: b.Replaces, - Skips: b.Skips, - SkipRange: b.SkipRange, - CsvJSON: b.CsvJson, - Objects: b.Object, - Properties: bundleProps, - RelatedImages: relatedImages, - }, nil -} - -func convertAPIBundleToModelProperties(b *Bundle) ([]property.Property, error) { - var out []property.Property - - providedGVKs := map[property.GVK]struct{}{} - requiredGVKs := map[property.GVKRequired]struct{}{} - - foundPackageProperty := false - for i, p := range b.Properties { - switch p.Type { - case property.TypeGVK: - var v GroupVersionKind - if err := json.Unmarshal(json.RawMessage(p.Value), &v); err != nil { - return nil, property.ParseError{Idx: i, Typ: p.Type, Err: err} - } - k := property.GVK{Group: v.Group, Kind: v.Kind, Version: v.Version} - providedGVKs[k] = struct{}{} - case property.TypePackage: - foundPackageProperty = true - out = append(out, property.Property{ - Type: property.TypePackage, - Value: json.RawMessage(p.Value), - }) - default: - out = append(out, property.Property{ - Type: p.Type, - Value: json.RawMessage(p.Value), - }) - } - } - - for i, p := range b.Dependencies { - switch p.Type { - case property.TypeGVK: - var v GroupVersionKind - if err := json.Unmarshal(json.RawMessage(p.Value), &v); err != nil { - return nil, property.ParseError{Idx: i, Typ: p.Type, Err: err} - } - k := property.GVKRequired{Group: v.Group, Kind: v.Kind, Version: v.Version} - requiredGVKs[k] = struct{}{} - case property.TypePackage: - var v property.Package - if err := json.Unmarshal(json.RawMessage(p.Value), &v); err != nil { - return nil, property.ParseError{Idx: i, Typ: p.Type, Err: err} - } - out = append(out, property.MustBuildPackageRequired(v.PackageName, v.Version)) - } - } - - if !foundPackageProperty { - out = append(out, property.MustBuildPackage(b.PackageName, b.Version)) - } - - for _, p := range b.ProvidedApis { - k := property.GVK{Group: p.Group, Kind: p.Kind, Version: p.Version} - if _, ok := providedGVKs[k]; !ok { - providedGVKs[k] = struct{}{} - } - } - for _, p := range b.RequiredApis { - k := property.GVKRequired{Group: p.Group, Kind: p.Kind, Version: p.Version} - if _, ok := requiredGVKs[k]; !ok { - requiredGVKs[k] = struct{}{} - } - } - - for p := range providedGVKs { - out = append(out, property.MustBuildGVK(p.Group, p.Version, p.Kind)) - } - - for p := range requiredGVKs { - out = append(out, property.MustBuildGVKRequired(p.Group, p.Version, p.Kind)) - } - - // If there is a bundle image reference and a valid CSV, create an - // olm.csv.metadata property. Otherwise, create a bundle object property for - // each object in the bundle. - var csv v1alpha1.ClusterServiceVersion - csvErr := json.Unmarshal([]byte(b.CsvJson), &csv) - if csvErr == nil && b.BundlePath != "" { - out = append(out, property.MustBuildCSVMetadata(csv)) - } else { - for _, obj := range b.Object { - out = append(out, property.MustBuildBundleObject([]byte(obj))) - } - } - - sort.Slice(out, func(i, j int) bool { - if out[i].Type != out[j].Type { - return out[i].Type < out[j].Type - } - return string(out[i].Value) < string(out[j].Value) - }) - - return out, nil -} - -func getRelatedImages(csvJSON string) ([]model.RelatedImage, error) { - if len(csvJSON) == 0 { - return nil, nil - } - type csv struct { - Spec struct { - RelatedImages []struct { - Name string `json:"name"` - Image string `json:"image"` - } `json:"relatedImages"` - } `json:"spec"` - } - c := csv{} - if err := json.Unmarshal([]byte(csvJSON), &c); err != nil { - return nil, fmt.Errorf("unmarshal csv: %v", err) - } - relatedImages := []model.RelatedImage{} - for _, ri := range c.Spec.RelatedImages { - relatedImages = append(relatedImages, model.RelatedImage(ri)) - } - return relatedImages, nil -} diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/api/model_to_api.go b/vendor/github.com/operator-framework/operator-registry/pkg/api/model_to_api.go deleted file mode 100644 index e7714713d..000000000 --- a/vendor/github.com/operator-framework/operator-registry/pkg/api/model_to_api.go +++ /dev/null @@ -1,207 +0,0 @@ -package api - -import ( - "encoding/base64" - "encoding/json" - "fmt" - - "github.com/operator-framework/api/pkg/lib/version" - "github.com/operator-framework/api/pkg/operators" - "github.com/operator-framework/api/pkg/operators/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - "github.com/operator-framework/operator-registry/alpha/model" - "github.com/operator-framework/operator-registry/alpha/property" -) - -func ConvertModelBundleToAPIBundle(b model.Bundle) (*Bundle, error) { - props, err := parseProperties(b.Properties) - if err != nil { - return nil, fmt.Errorf("parse properties: %v", err) - } - - csvJson := b.CsvJSON - if csvJson == "" && len(props.CSVMetadatas) == 1 { - var icons []v1alpha1.Icon - if b.Package.Icon != nil { - icons = []v1alpha1.Icon{{ - Data: base64.StdEncoding.EncodeToString(b.Package.Icon.Data), - MediaType: b.Package.Icon.MediaType, - }} - } - csv := csvMetadataToCsv(props.CSVMetadatas[0]) - csv.Name = b.Name - csv.Spec.Icon = icons - csv.Spec.InstallStrategy = v1alpha1.NamedInstallStrategy{ - // This stub is required to avoid a panic in OLM's package server that results in - // attemptint to write to a nil map. - StrategyName: "deployment", - } - csv.Spec.Version = version.OperatorVersion{b.Version} - csv.Spec.RelatedImages = convertModelRelatedImagesToCSVRelatedImages(b.RelatedImages) - if csv.Spec.Description == "" { - csv.Spec.Description = b.Package.Description - } - csvData, err := json.Marshal(csv) - if err != nil { - return nil, err - } - csvJson = string(csvData) - if len(b.Objects) == 0 { - b.Objects = []string{csvJson} - } - } - - var deprecation *Deprecation - if b.Deprecation != nil { - deprecation = &Deprecation{ - Message: b.Deprecation.Message, - } - } - - apiDeps, err := convertModelPropertiesToAPIDependencies(b.Properties) - if err != nil { - return nil, fmt.Errorf("convert model properties to api dependencies: %v", err) - } - return &Bundle{ - CsvName: b.Name, - PackageName: b.Package.Name, - ChannelName: b.Channel.Name, - BundlePath: b.Image, - ProvidedApis: gvksProvidedtoAPIGVKs(props.GVKs), - RequiredApis: gvksRequirestoAPIGVKs(props.GVKsRequired), - Version: props.Packages[0].Version, - SkipRange: b.SkipRange, - Dependencies: apiDeps, - Properties: convertModelPropertiesToAPIProperties(b.Properties), - Replaces: b.Replaces, - Skips: b.Skips, - CsvJson: csvJson, - Object: b.Objects, - Deprecation: deprecation, - }, nil -} - -func parseProperties(in []property.Property) (*property.Properties, error) { - props, err := property.Parse(in) - if err != nil { - return nil, err - } - - if len(props.Packages) != 1 { - return nil, fmt.Errorf("expected exactly 1 property of type %q, found %d", property.TypePackage, len(props.Packages)) - } - - if len(props.CSVMetadatas) > 1 { - return nil, fmt.Errorf("expected at most 1 property of type %q, found %d", property.TypeCSVMetadata, len(props.CSVMetadatas)) - } - - return props, nil -} - -func csvMetadataToCsv(m property.CSVMetadata) v1alpha1.ClusterServiceVersion { - return v1alpha1.ClusterServiceVersion{ - TypeMeta: metav1.TypeMeta{ - Kind: operators.ClusterServiceVersionKind, - APIVersion: v1alpha1.ClusterServiceVersionAPIVersion, - }, - ObjectMeta: metav1.ObjectMeta{ - Annotations: m.Annotations, - Labels: m.Labels, - }, - Spec: v1alpha1.ClusterServiceVersionSpec{ - APIServiceDefinitions: m.APIServiceDefinitions, - CustomResourceDefinitions: m.CustomResourceDefinitions, - Description: m.Description, - DisplayName: m.DisplayName, - InstallModes: m.InstallModes, - Keywords: m.Keywords, - Links: m.Links, - Maintainers: m.Maintainers, - Maturity: m.Maturity, - MinKubeVersion: m.MinKubeVersion, - NativeAPIs: m.NativeAPIs, - Provider: m.Provider, - }, - } -} - -func gvksProvidedtoAPIGVKs(in []property.GVK) []*GroupVersionKind { - var out []*GroupVersionKind - for _, gvk := range in { - out = append(out, &GroupVersionKind{ - Group: gvk.Group, - Version: gvk.Version, - Kind: gvk.Kind, - }) - } - return out -} -func gvksRequirestoAPIGVKs(in []property.GVKRequired) []*GroupVersionKind { - var out []*GroupVersionKind - for _, gvk := range in { - out = append(out, &GroupVersionKind{ - Group: gvk.Group, - Version: gvk.Version, - Kind: gvk.Kind, - }) - } - return out -} - -func convertModelPropertiesToAPIProperties(props []property.Property) []*Property { - var out []*Property - for _, prop := range props { - - // NOTE: This is a special case filter to prevent problems with existing client implementations that - // project bundle properties into CSV annotations and store those CSVs in a size-constrained - // storage backend (e.g. etcd via kube-apiserver). If the bundle object property has data inlined - // in its `Data` field, this CSV annotation projection would cause the size of the on-cluster - // CSV to at least double, which is untenable since CSVs already have known issues running up - // against etcd size constraints. - if prop.Type == property.TypeBundleObject || prop.Type == property.TypeCSVMetadata { - continue - } - - out = append(out, &Property{ - Type: prop.Type, - Value: string(prop.Value), - }) - } - return out -} - -func convertModelPropertiesToAPIDependencies(props []property.Property) ([]*Dependency, error) { - var out []*Dependency - for _, prop := range props { - switch prop.Type { - case property.TypeGVKRequired: - out = append(out, &Dependency{ - Type: property.TypeGVK, - Value: string(prop.Value), - }) - case property.TypePackageRequired: - var v property.PackageRequired - if err := json.Unmarshal(prop.Value, &v); err != nil { - return nil, err - } - pkg := property.MustBuildPackage(v.PackageName, v.VersionRange) - out = append(out, &Dependency{ - Type: pkg.Type, - Value: string(pkg.Value), - }) - } - } - return out, nil -} - -func convertModelRelatedImagesToCSVRelatedImages(in []model.RelatedImage) []v1alpha1.RelatedImage { - var out []v1alpha1.RelatedImage - for _, ri := range in { - out = append(out, v1alpha1.RelatedImage{ - Name: ri.Name, - Image: ri.Image, - }) - } - return out -} diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/api/registry.pb.go b/vendor/github.com/operator-framework/operator-registry/pkg/api/registry.pb.go deleted file mode 100644 index 826e4674f..000000000 --- a/vendor/github.com/operator-framework/operator-registry/pkg/api/registry.pb.go +++ /dev/null @@ -1,1734 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.31.0 -// protoc v4.24.4 -// source: registry.proto - -package api - -import ( - reflect "reflect" - sync "sync" - - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" -) - -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) -) - -type Channel struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - CsvName string `protobuf:"bytes,2,opt,name=csvName,proto3" json:"csvName,omitempty"` - Deprecation *Deprecation `protobuf:"bytes,3,opt,name=deprecation,proto3" json:"deprecation,omitempty"` -} - -func (x *Channel) Reset() { - *x = Channel{} - if protoimpl.UnsafeEnabled { - mi := &file_registry_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Channel) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Channel) ProtoMessage() {} - -func (x *Channel) ProtoReflect() protoreflect.Message { - mi := &file_registry_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 Channel.ProtoReflect.Descriptor instead. -func (*Channel) Descriptor() ([]byte, []int) { - return file_registry_proto_rawDescGZIP(), []int{0} -} - -func (x *Channel) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Channel) GetCsvName() string { - if x != nil { - return x.CsvName - } - return "" -} - -func (x *Channel) GetDeprecation() *Deprecation { - if x != nil { - return x.Deprecation - } - return nil -} - -type PackageName struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` -} - -func (x *PackageName) Reset() { - *x = PackageName{} - if protoimpl.UnsafeEnabled { - mi := &file_registry_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *PackageName) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PackageName) ProtoMessage() {} - -func (x *PackageName) ProtoReflect() protoreflect.Message { - mi := &file_registry_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 PackageName.ProtoReflect.Descriptor instead. -func (*PackageName) Descriptor() ([]byte, []int) { - return file_registry_proto_rawDescGZIP(), []int{1} -} - -func (x *PackageName) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -type Package struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Channels []*Channel `protobuf:"bytes,2,rep,name=channels,proto3" json:"channels,omitempty"` - DefaultChannelName string `protobuf:"bytes,3,opt,name=defaultChannelName,proto3" json:"defaultChannelName,omitempty"` - Deprecation *Deprecation `protobuf:"bytes,4,opt,name=deprecation,proto3" json:"deprecation,omitempty"` -} - -func (x *Package) Reset() { - *x = Package{} - if protoimpl.UnsafeEnabled { - mi := &file_registry_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Package) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Package) ProtoMessage() {} - -func (x *Package) ProtoReflect() protoreflect.Message { - mi := &file_registry_proto_msgTypes[2] - 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 Package.ProtoReflect.Descriptor instead. -func (*Package) Descriptor() ([]byte, []int) { - return file_registry_proto_rawDescGZIP(), []int{2} -} - -func (x *Package) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Package) GetChannels() []*Channel { - if x != nil { - return x.Channels - } - return nil -} - -func (x *Package) GetDefaultChannelName() string { - if x != nil { - return x.DefaultChannelName - } - return "" -} - -func (x *Package) GetDeprecation() *Deprecation { - if x != nil { - return x.Deprecation - } - return nil -} - -type GroupVersionKind struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Group string `protobuf:"bytes,1,opt,name=group,proto3" json:"group,omitempty"` - Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` - Kind string `protobuf:"bytes,3,opt,name=kind,proto3" json:"kind,omitempty"` - Plural string `protobuf:"bytes,4,opt,name=plural,proto3" json:"plural,omitempty"` -} - -func (x *GroupVersionKind) Reset() { - *x = GroupVersionKind{} - if protoimpl.UnsafeEnabled { - mi := &file_registry_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GroupVersionKind) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupVersionKind) ProtoMessage() {} - -func (x *GroupVersionKind) ProtoReflect() protoreflect.Message { - mi := &file_registry_proto_msgTypes[3] - 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 GroupVersionKind.ProtoReflect.Descriptor instead. -func (*GroupVersionKind) Descriptor() ([]byte, []int) { - return file_registry_proto_rawDescGZIP(), []int{3} -} - -func (x *GroupVersionKind) GetGroup() string { - if x != nil { - return x.Group - } - return "" -} - -func (x *GroupVersionKind) GetVersion() string { - if x != nil { - return x.Version - } - return "" -} - -func (x *GroupVersionKind) GetKind() string { - if x != nil { - return x.Kind - } - return "" -} - -func (x *GroupVersionKind) GetPlural() string { - if x != nil { - return x.Plural - } - return "" -} - -type Dependency struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` - Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` -} - -func (x *Dependency) Reset() { - *x = Dependency{} - if protoimpl.UnsafeEnabled { - mi := &file_registry_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Dependency) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Dependency) ProtoMessage() {} - -func (x *Dependency) ProtoReflect() protoreflect.Message { - mi := &file_registry_proto_msgTypes[4] - 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 Dependency.ProtoReflect.Descriptor instead. -func (*Dependency) Descriptor() ([]byte, []int) { - return file_registry_proto_rawDescGZIP(), []int{4} -} - -func (x *Dependency) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *Dependency) GetValue() string { - if x != nil { - return x.Value - } - return "" -} - -type Property struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` - Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` -} - -func (x *Property) Reset() { - *x = Property{} - if protoimpl.UnsafeEnabled { - mi := &file_registry_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Property) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Property) ProtoMessage() {} - -func (x *Property) ProtoReflect() protoreflect.Message { - mi := &file_registry_proto_msgTypes[5] - 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 Property.ProtoReflect.Descriptor instead. -func (*Property) Descriptor() ([]byte, []int) { - return file_registry_proto_rawDescGZIP(), []int{5} -} - -func (x *Property) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *Property) GetValue() string { - if x != nil { - return x.Value - } - return "" -} - -type Bundle struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - CsvName string `protobuf:"bytes,1,opt,name=csvName,proto3" json:"csvName,omitempty"` - PackageName string `protobuf:"bytes,2,opt,name=packageName,proto3" json:"packageName,omitempty"` - ChannelName string `protobuf:"bytes,3,opt,name=channelName,proto3" json:"channelName,omitempty"` - CsvJson string `protobuf:"bytes,4,opt,name=csvJson,proto3" json:"csvJson,omitempty"` - Object []string `protobuf:"bytes,5,rep,name=object,proto3" json:"object,omitempty"` - BundlePath string `protobuf:"bytes,6,opt,name=bundlePath,proto3" json:"bundlePath,omitempty"` - ProvidedApis []*GroupVersionKind `protobuf:"bytes,7,rep,name=providedApis,proto3" json:"providedApis,omitempty"` - RequiredApis []*GroupVersionKind `protobuf:"bytes,8,rep,name=requiredApis,proto3" json:"requiredApis,omitempty"` - Version string `protobuf:"bytes,9,opt,name=version,proto3" json:"version,omitempty"` - SkipRange string `protobuf:"bytes,10,opt,name=skipRange,proto3" json:"skipRange,omitempty"` - Dependencies []*Dependency `protobuf:"bytes,11,rep,name=dependencies,proto3" json:"dependencies,omitempty"` - Properties []*Property `protobuf:"bytes,12,rep,name=properties,proto3" json:"properties,omitempty"` - Replaces string `protobuf:"bytes,13,opt,name=replaces,proto3" json:"replaces,omitempty"` - Skips []string `protobuf:"bytes,14,rep,name=skips,proto3" json:"skips,omitempty"` - Deprecation *Deprecation `protobuf:"bytes,15,opt,name=deprecation,proto3" json:"deprecation,omitempty"` -} - -func (x *Bundle) Reset() { - *x = Bundle{} - if protoimpl.UnsafeEnabled { - mi := &file_registry_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Bundle) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Bundle) ProtoMessage() {} - -func (x *Bundle) ProtoReflect() protoreflect.Message { - mi := &file_registry_proto_msgTypes[6] - 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 Bundle.ProtoReflect.Descriptor instead. -func (*Bundle) Descriptor() ([]byte, []int) { - return file_registry_proto_rawDescGZIP(), []int{6} -} - -func (x *Bundle) GetCsvName() string { - if x != nil { - return x.CsvName - } - return "" -} - -func (x *Bundle) GetPackageName() string { - if x != nil { - return x.PackageName - } - return "" -} - -func (x *Bundle) GetChannelName() string { - if x != nil { - return x.ChannelName - } - return "" -} - -func (x *Bundle) GetCsvJson() string { - if x != nil { - return x.CsvJson - } - return "" -} - -func (x *Bundle) GetObject() []string { - if x != nil { - return x.Object - } - return nil -} - -func (x *Bundle) GetBundlePath() string { - if x != nil { - return x.BundlePath - } - return "" -} - -func (x *Bundle) GetProvidedApis() []*GroupVersionKind { - if x != nil { - return x.ProvidedApis - } - return nil -} - -func (x *Bundle) GetRequiredApis() []*GroupVersionKind { - if x != nil { - return x.RequiredApis - } - return nil -} - -func (x *Bundle) GetVersion() string { - if x != nil { - return x.Version - } - return "" -} - -func (x *Bundle) GetSkipRange() string { - if x != nil { - return x.SkipRange - } - return "" -} - -func (x *Bundle) GetDependencies() []*Dependency { - if x != nil { - return x.Dependencies - } - return nil -} - -func (x *Bundle) GetProperties() []*Property { - if x != nil { - return x.Properties - } - return nil -} - -func (x *Bundle) GetReplaces() string { - if x != nil { - return x.Replaces - } - return "" -} - -func (x *Bundle) GetSkips() []string { - if x != nil { - return x.Skips - } - return nil -} - -func (x *Bundle) GetDeprecation() *Deprecation { - if x != nil { - return x.Deprecation - } - return nil -} - -type ChannelEntry struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - PackageName string `protobuf:"bytes,1,opt,name=packageName,proto3" json:"packageName,omitempty"` - ChannelName string `protobuf:"bytes,2,opt,name=channelName,proto3" json:"channelName,omitempty"` - BundleName string `protobuf:"bytes,3,opt,name=bundleName,proto3" json:"bundleName,omitempty"` - Replaces string `protobuf:"bytes,4,opt,name=replaces,proto3" json:"replaces,omitempty"` -} - -func (x *ChannelEntry) Reset() { - *x = ChannelEntry{} - if protoimpl.UnsafeEnabled { - mi := &file_registry_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ChannelEntry) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ChannelEntry) ProtoMessage() {} - -func (x *ChannelEntry) ProtoReflect() protoreflect.Message { - mi := &file_registry_proto_msgTypes[7] - 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 ChannelEntry.ProtoReflect.Descriptor instead. -func (*ChannelEntry) Descriptor() ([]byte, []int) { - return file_registry_proto_rawDescGZIP(), []int{7} -} - -func (x *ChannelEntry) GetPackageName() string { - if x != nil { - return x.PackageName - } - return "" -} - -func (x *ChannelEntry) GetChannelName() string { - if x != nil { - return x.ChannelName - } - return "" -} - -func (x *ChannelEntry) GetBundleName() string { - if x != nil { - return x.BundleName - } - return "" -} - -func (x *ChannelEntry) GetReplaces() string { - if x != nil { - return x.Replaces - } - return "" -} - -type ListPackageRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *ListPackageRequest) Reset() { - *x = ListPackageRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_registry_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListPackageRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListPackageRequest) ProtoMessage() {} - -func (x *ListPackageRequest) ProtoReflect() protoreflect.Message { - mi := &file_registry_proto_msgTypes[8] - 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 ListPackageRequest.ProtoReflect.Descriptor instead. -func (*ListPackageRequest) Descriptor() ([]byte, []int) { - return file_registry_proto_rawDescGZIP(), []int{8} -} - -type ListBundlesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *ListBundlesRequest) Reset() { - *x = ListBundlesRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_registry_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListBundlesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListBundlesRequest) ProtoMessage() {} - -func (x *ListBundlesRequest) ProtoReflect() protoreflect.Message { - mi := &file_registry_proto_msgTypes[9] - 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 ListBundlesRequest.ProtoReflect.Descriptor instead. -func (*ListBundlesRequest) Descriptor() ([]byte, []int) { - return file_registry_proto_rawDescGZIP(), []int{9} -} - -type GetPackageRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` -} - -func (x *GetPackageRequest) Reset() { - *x = GetPackageRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_registry_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetPackageRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetPackageRequest) ProtoMessage() {} - -func (x *GetPackageRequest) ProtoReflect() protoreflect.Message { - mi := &file_registry_proto_msgTypes[10] - 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 GetPackageRequest.ProtoReflect.Descriptor instead. -func (*GetPackageRequest) Descriptor() ([]byte, []int) { - return file_registry_proto_rawDescGZIP(), []int{10} -} - -func (x *GetPackageRequest) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -type GetBundleRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - PkgName string `protobuf:"bytes,1,opt,name=pkgName,proto3" json:"pkgName,omitempty"` - ChannelName string `protobuf:"bytes,2,opt,name=channelName,proto3" json:"channelName,omitempty"` - CsvName string `protobuf:"bytes,3,opt,name=csvName,proto3" json:"csvName,omitempty"` -} - -func (x *GetBundleRequest) Reset() { - *x = GetBundleRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_registry_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetBundleRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetBundleRequest) ProtoMessage() {} - -func (x *GetBundleRequest) ProtoReflect() protoreflect.Message { - mi := &file_registry_proto_msgTypes[11] - 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 GetBundleRequest.ProtoReflect.Descriptor instead. -func (*GetBundleRequest) Descriptor() ([]byte, []int) { - return file_registry_proto_rawDescGZIP(), []int{11} -} - -func (x *GetBundleRequest) GetPkgName() string { - if x != nil { - return x.PkgName - } - return "" -} - -func (x *GetBundleRequest) GetChannelName() string { - if x != nil { - return x.ChannelName - } - return "" -} - -func (x *GetBundleRequest) GetCsvName() string { - if x != nil { - return x.CsvName - } - return "" -} - -type GetBundleInChannelRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - PkgName string `protobuf:"bytes,1,opt,name=pkgName,proto3" json:"pkgName,omitempty"` - ChannelName string `protobuf:"bytes,2,opt,name=channelName,proto3" json:"channelName,omitempty"` -} - -func (x *GetBundleInChannelRequest) Reset() { - *x = GetBundleInChannelRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_registry_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetBundleInChannelRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetBundleInChannelRequest) ProtoMessage() {} - -func (x *GetBundleInChannelRequest) ProtoReflect() protoreflect.Message { - mi := &file_registry_proto_msgTypes[12] - 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 GetBundleInChannelRequest.ProtoReflect.Descriptor instead. -func (*GetBundleInChannelRequest) Descriptor() ([]byte, []int) { - return file_registry_proto_rawDescGZIP(), []int{12} -} - -func (x *GetBundleInChannelRequest) GetPkgName() string { - if x != nil { - return x.PkgName - } - return "" -} - -func (x *GetBundleInChannelRequest) GetChannelName() string { - if x != nil { - return x.ChannelName - } - return "" -} - -type GetAllReplacementsRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - CsvName string `protobuf:"bytes,1,opt,name=csvName,proto3" json:"csvName,omitempty"` -} - -func (x *GetAllReplacementsRequest) Reset() { - *x = GetAllReplacementsRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_registry_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetAllReplacementsRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetAllReplacementsRequest) ProtoMessage() {} - -func (x *GetAllReplacementsRequest) ProtoReflect() protoreflect.Message { - mi := &file_registry_proto_msgTypes[13] - 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 GetAllReplacementsRequest.ProtoReflect.Descriptor instead. -func (*GetAllReplacementsRequest) Descriptor() ([]byte, []int) { - return file_registry_proto_rawDescGZIP(), []int{13} -} - -func (x *GetAllReplacementsRequest) GetCsvName() string { - if x != nil { - return x.CsvName - } - return "" -} - -type GetReplacementRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - CsvName string `protobuf:"bytes,1,opt,name=csvName,proto3" json:"csvName,omitempty"` - PkgName string `protobuf:"bytes,2,opt,name=pkgName,proto3" json:"pkgName,omitempty"` - ChannelName string `protobuf:"bytes,3,opt,name=channelName,proto3" json:"channelName,omitempty"` -} - -func (x *GetReplacementRequest) Reset() { - *x = GetReplacementRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_registry_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetReplacementRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetReplacementRequest) ProtoMessage() {} - -func (x *GetReplacementRequest) ProtoReflect() protoreflect.Message { - mi := &file_registry_proto_msgTypes[14] - 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 GetReplacementRequest.ProtoReflect.Descriptor instead. -func (*GetReplacementRequest) Descriptor() ([]byte, []int) { - return file_registry_proto_rawDescGZIP(), []int{14} -} - -func (x *GetReplacementRequest) GetCsvName() string { - if x != nil { - return x.CsvName - } - return "" -} - -func (x *GetReplacementRequest) GetPkgName() string { - if x != nil { - return x.PkgName - } - return "" -} - -func (x *GetReplacementRequest) GetChannelName() string { - if x != nil { - return x.ChannelName - } - return "" -} - -type GetAllProvidersRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Group string `protobuf:"bytes,1,opt,name=group,proto3" json:"group,omitempty"` - Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` - Kind string `protobuf:"bytes,3,opt,name=kind,proto3" json:"kind,omitempty"` - Plural string `protobuf:"bytes,4,opt,name=plural,proto3" json:"plural,omitempty"` -} - -func (x *GetAllProvidersRequest) Reset() { - *x = GetAllProvidersRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_registry_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetAllProvidersRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetAllProvidersRequest) ProtoMessage() {} - -func (x *GetAllProvidersRequest) ProtoReflect() protoreflect.Message { - mi := &file_registry_proto_msgTypes[15] - 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 GetAllProvidersRequest.ProtoReflect.Descriptor instead. -func (*GetAllProvidersRequest) Descriptor() ([]byte, []int) { - return file_registry_proto_rawDescGZIP(), []int{15} -} - -func (x *GetAllProvidersRequest) GetGroup() string { - if x != nil { - return x.Group - } - return "" -} - -func (x *GetAllProvidersRequest) GetVersion() string { - if x != nil { - return x.Version - } - return "" -} - -func (x *GetAllProvidersRequest) GetKind() string { - if x != nil { - return x.Kind - } - return "" -} - -func (x *GetAllProvidersRequest) GetPlural() string { - if x != nil { - return x.Plural - } - return "" -} - -type GetLatestProvidersRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Group string `protobuf:"bytes,1,opt,name=group,proto3" json:"group,omitempty"` - Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` - Kind string `protobuf:"bytes,3,opt,name=kind,proto3" json:"kind,omitempty"` - Plural string `protobuf:"bytes,4,opt,name=plural,proto3" json:"plural,omitempty"` -} - -func (x *GetLatestProvidersRequest) Reset() { - *x = GetLatestProvidersRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_registry_proto_msgTypes[16] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetLatestProvidersRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetLatestProvidersRequest) ProtoMessage() {} - -func (x *GetLatestProvidersRequest) ProtoReflect() protoreflect.Message { - mi := &file_registry_proto_msgTypes[16] - 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 GetLatestProvidersRequest.ProtoReflect.Descriptor instead. -func (*GetLatestProvidersRequest) Descriptor() ([]byte, []int) { - return file_registry_proto_rawDescGZIP(), []int{16} -} - -func (x *GetLatestProvidersRequest) GetGroup() string { - if x != nil { - return x.Group - } - return "" -} - -func (x *GetLatestProvidersRequest) GetVersion() string { - if x != nil { - return x.Version - } - return "" -} - -func (x *GetLatestProvidersRequest) GetKind() string { - if x != nil { - return x.Kind - } - return "" -} - -func (x *GetLatestProvidersRequest) GetPlural() string { - if x != nil { - return x.Plural - } - return "" -} - -type GetDefaultProviderRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Group string `protobuf:"bytes,1,opt,name=group,proto3" json:"group,omitempty"` - Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` - Kind string `protobuf:"bytes,3,opt,name=kind,proto3" json:"kind,omitempty"` - Plural string `protobuf:"bytes,4,opt,name=plural,proto3" json:"plural,omitempty"` -} - -func (x *GetDefaultProviderRequest) Reset() { - *x = GetDefaultProviderRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_registry_proto_msgTypes[17] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetDefaultProviderRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetDefaultProviderRequest) ProtoMessage() {} - -func (x *GetDefaultProviderRequest) ProtoReflect() protoreflect.Message { - mi := &file_registry_proto_msgTypes[17] - 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 GetDefaultProviderRequest.ProtoReflect.Descriptor instead. -func (*GetDefaultProviderRequest) Descriptor() ([]byte, []int) { - return file_registry_proto_rawDescGZIP(), []int{17} -} - -func (x *GetDefaultProviderRequest) GetGroup() string { - if x != nil { - return x.Group - } - return "" -} - -func (x *GetDefaultProviderRequest) GetVersion() string { - if x != nil { - return x.Version - } - return "" -} - -func (x *GetDefaultProviderRequest) GetKind() string { - if x != nil { - return x.Kind - } - return "" -} - -func (x *GetDefaultProviderRequest) GetPlural() string { - if x != nil { - return x.Plural - } - return "" -} - -type Deprecation struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` -} - -func (x *Deprecation) Reset() { - *x = Deprecation{} - if protoimpl.UnsafeEnabled { - mi := &file_registry_proto_msgTypes[18] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Deprecation) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Deprecation) ProtoMessage() {} - -func (x *Deprecation) ProtoReflect() protoreflect.Message { - mi := &file_registry_proto_msgTypes[18] - 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 Deprecation.ProtoReflect.Descriptor instead. -func (*Deprecation) Descriptor() ([]byte, []int) { - return file_registry_proto_rawDescGZIP(), []int{18} -} - -func (x *Deprecation) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -var File_registry_proto protoreflect.FileDescriptor - -var file_registry_proto_rawDesc = []byte{ - 0x0a, 0x0e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x12, 0x03, 0x61, 0x70, 0x69, 0x22, 0x6b, 0x0a, 0x07, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, - 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x73, 0x76, 0x4e, 0x61, 0x6d, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x73, 0x76, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x32, - 0x0a, 0x0b, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x65, 0x70, 0x72, 0x65, 0x63, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x22, 0x21, 0x0a, 0x0b, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x4e, 0x61, 0x6d, - 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xab, 0x01, 0x0a, 0x07, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, - 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x08, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, - 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x68, - 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x08, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x73, 0x12, - 0x2e, 0x0a, 0x12, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, - 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x64, 0x65, 0x66, - 0x61, 0x75, 0x6c, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x12, - 0x32, 0x0a, 0x0b, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x65, 0x70, 0x72, 0x65, - 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x22, 0x6e, 0x0a, 0x10, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x56, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x18, 0x0a, - 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x70, - 0x6c, 0x75, 0x72, 0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x6c, 0x75, - 0x72, 0x61, 0x6c, 0x22, 0x36, 0x0a, 0x0a, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, - 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x34, 0x0a, 0x08, 0x50, - 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x22, 0xb0, 0x04, 0x0a, 0x06, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, - 0x63, 0x73, 0x76, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, - 0x73, 0x76, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, - 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x61, 0x63, - 0x6b, 0x61, 0x67, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x68, 0x61, 0x6e, - 0x6e, 0x65, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, - 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x73, - 0x76, 0x4a, 0x73, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x73, 0x76, - 0x4a, 0x73, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x05, - 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x1e, 0x0a, 0x0a, - 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x50, 0x61, 0x74, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0a, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x50, 0x61, 0x74, 0x68, 0x12, 0x39, 0x0a, 0x0c, - 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x64, 0x41, 0x70, 0x69, 0x73, 0x18, 0x07, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x56, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x4b, 0x69, 0x6e, 0x64, 0x52, 0x0c, 0x70, 0x72, 0x6f, 0x76, 0x69, - 0x64, 0x65, 0x64, 0x41, 0x70, 0x69, 0x73, 0x12, 0x39, 0x0a, 0x0c, 0x72, 0x65, 0x71, 0x75, 0x69, - 0x72, 0x65, 0x64, 0x41, 0x70, 0x69, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x4b, 0x69, 0x6e, 0x64, 0x52, 0x0c, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x41, 0x70, - 0x69, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x09, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, - 0x73, 0x6b, 0x69, 0x70, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x09, 0x73, 0x6b, 0x69, 0x70, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x33, 0x0a, 0x0c, 0x64, 0x65, - 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x69, 0x65, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x0f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, - 0x79, 0x52, 0x0c, 0x64, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x69, 0x65, 0x73, 0x12, - 0x2d, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x0c, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, - 0x74, 0x79, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x12, 0x1a, - 0x0a, 0x08, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x73, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x6b, - 0x69, 0x70, 0x73, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x73, 0x6b, 0x69, 0x70, 0x73, - 0x12, 0x32, 0x0a, 0x0b, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, - 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x65, 0x70, 0x72, - 0x65, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x8e, 0x01, 0x0a, 0x0c, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, - 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, - 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x61, 0x63, 0x6b, - 0x61, 0x67, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x68, 0x61, 0x6e, 0x6e, - 0x65, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x68, - 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x62, 0x75, 0x6e, - 0x64, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x62, - 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x70, - 0x6c, 0x61, 0x63, 0x65, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x70, - 0x6c, 0x61, 0x63, 0x65, 0x73, 0x22, 0x14, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, 0x63, - 0x6b, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x14, 0x0a, 0x12, 0x4c, - 0x69, 0x73, 0x74, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x22, 0x27, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x68, 0x0a, 0x10, 0x47, 0x65, - 0x74, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, - 0x0a, 0x07, 0x70, 0x6b, 0x67, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x70, 0x6b, 0x67, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x68, 0x61, 0x6e, - 0x6e, 0x65, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, - 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x73, - 0x76, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x73, 0x76, - 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x57, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x42, 0x75, 0x6e, 0x64, 0x6c, - 0x65, 0x49, 0x6e, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x6b, 0x67, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x70, 0x6b, 0x67, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, - 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0b, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x35, 0x0a, - 0x19, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x52, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x6d, 0x65, - 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x73, - 0x76, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x73, 0x76, - 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x6d, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x52, 0x65, 0x70, 0x6c, 0x61, - 0x63, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, - 0x07, 0x63, 0x73, 0x76, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x63, 0x73, 0x76, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x6b, 0x67, 0x4e, 0x61, - 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x6b, 0x67, 0x4e, 0x61, 0x6d, - 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x4e, 0x61, 0x6d, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x4e, - 0x61, 0x6d, 0x65, 0x22, 0x74, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x50, 0x72, 0x6f, - 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, - 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x67, 0x72, - 0x6f, 0x75, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, - 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, - 0x64, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x6c, 0x75, 0x72, 0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x06, 0x70, 0x6c, 0x75, 0x72, 0x61, 0x6c, 0x22, 0x77, 0x0a, 0x19, 0x47, 0x65, 0x74, - 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x18, 0x0a, 0x07, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x6c, - 0x75, 0x72, 0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x6c, 0x75, 0x72, - 0x61, 0x6c, 0x22, 0x77, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, - 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x14, 0x0a, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, - 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, - 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, - 0x69, 0x6e, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x6c, 0x75, 0x72, 0x61, 0x6c, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x6c, 0x75, 0x72, 0x61, 0x6c, 0x22, 0x27, 0x0a, 0x0b, 0x44, - 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 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, 0x32, 0xcf, 0x05, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, - 0x79, 0x12, 0x3d, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, - 0x73, 0x12, 0x17, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, 0x63, 0x6b, - 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x00, 0x30, 0x01, - 0x12, 0x34, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x16, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x61, 0x63, - 0x6b, 0x61, 0x67, 0x65, 0x22, 0x00, 0x12, 0x31, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x42, 0x75, 0x6e, - 0x64, 0x6c, 0x65, 0x12, 0x15, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x75, 0x6e, - 0x64, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0b, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x22, 0x00, 0x12, 0x47, 0x0a, 0x13, 0x47, 0x65, 0x74, - 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x46, 0x6f, 0x72, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, - 0x12, 0x1e, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, - 0x49, 0x6e, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x0b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x22, 0x03, 0x88, - 0x02, 0x01, 0x12, 0x55, 0x0a, 0x1c, 0x47, 0x65, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, - 0x45, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x54, 0x68, 0x61, 0x74, 0x52, 0x65, 0x70, 0x6c, 0x61, - 0x63, 0x65, 0x12, 0x1e, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x52, - 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, - 0x45, 0x6e, 0x74, 0x72, 0x79, 0x22, 0x00, 0x30, 0x01, 0x12, 0x42, 0x0a, 0x15, 0x47, 0x65, 0x74, - 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x54, 0x68, 0x61, 0x74, 0x52, 0x65, 0x70, 0x6c, 0x61, 0x63, - 0x65, 0x73, 0x12, 0x1a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x70, 0x6c, - 0x61, 0x63, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0b, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x22, 0x00, 0x12, 0x52, 0x0a, - 0x1c, 0x47, 0x65, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x45, 0x6e, 0x74, 0x72, 0x69, - 0x65, 0x73, 0x54, 0x68, 0x61, 0x74, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x12, 0x1b, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, - 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x22, 0x00, 0x30, - 0x01, 0x12, 0x5b, 0x0a, 0x22, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x43, 0x68, - 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x45, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x54, 0x68, 0x61, 0x74, - 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x12, 0x1e, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, - 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x68, - 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x22, 0x00, 0x30, 0x01, 0x12, 0x4d, - 0x0a, 0x1c, 0x47, 0x65, 0x74, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x42, 0x75, 0x6e, 0x64, - 0x6c, 0x65, 0x54, 0x68, 0x61, 0x74, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x73, 0x12, 0x1e, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x50, - 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0b, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x22, 0x00, 0x12, 0x37, 0x0a, - 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x73, 0x12, 0x17, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x75, 0x6e, 0x64, - 0x6c, 0x65, 0x22, 0x00, 0x30, 0x01, 0x42, 0x07, 0x5a, 0x05, 0x2e, 0x3b, 0x61, 0x70, 0x69, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_registry_proto_rawDescOnce sync.Once - file_registry_proto_rawDescData = file_registry_proto_rawDesc -) - -func file_registry_proto_rawDescGZIP() []byte { - file_registry_proto_rawDescOnce.Do(func() { - file_registry_proto_rawDescData = protoimpl.X.CompressGZIP(file_registry_proto_rawDescData) - }) - return file_registry_proto_rawDescData -} - -var file_registry_proto_msgTypes = make([]protoimpl.MessageInfo, 19) -var file_registry_proto_goTypes = []interface{}{ - (*Channel)(nil), // 0: api.Channel - (*PackageName)(nil), // 1: api.PackageName - (*Package)(nil), // 2: api.Package - (*GroupVersionKind)(nil), // 3: api.GroupVersionKind - (*Dependency)(nil), // 4: api.Dependency - (*Property)(nil), // 5: api.Property - (*Bundle)(nil), // 6: api.Bundle - (*ChannelEntry)(nil), // 7: api.ChannelEntry - (*ListPackageRequest)(nil), // 8: api.ListPackageRequest - (*ListBundlesRequest)(nil), // 9: api.ListBundlesRequest - (*GetPackageRequest)(nil), // 10: api.GetPackageRequest - (*GetBundleRequest)(nil), // 11: api.GetBundleRequest - (*GetBundleInChannelRequest)(nil), // 12: api.GetBundleInChannelRequest - (*GetAllReplacementsRequest)(nil), // 13: api.GetAllReplacementsRequest - (*GetReplacementRequest)(nil), // 14: api.GetReplacementRequest - (*GetAllProvidersRequest)(nil), // 15: api.GetAllProvidersRequest - (*GetLatestProvidersRequest)(nil), // 16: api.GetLatestProvidersRequest - (*GetDefaultProviderRequest)(nil), // 17: api.GetDefaultProviderRequest - (*Deprecation)(nil), // 18: api.Deprecation -} -var file_registry_proto_depIdxs = []int32{ - 18, // 0: api.Channel.deprecation:type_name -> api.Deprecation - 0, // 1: api.Package.channels:type_name -> api.Channel - 18, // 2: api.Package.deprecation:type_name -> api.Deprecation - 3, // 3: api.Bundle.providedApis:type_name -> api.GroupVersionKind - 3, // 4: api.Bundle.requiredApis:type_name -> api.GroupVersionKind - 4, // 5: api.Bundle.dependencies:type_name -> api.Dependency - 5, // 6: api.Bundle.properties:type_name -> api.Property - 18, // 7: api.Bundle.deprecation:type_name -> api.Deprecation - 8, // 8: api.Registry.ListPackages:input_type -> api.ListPackageRequest - 10, // 9: api.Registry.GetPackage:input_type -> api.GetPackageRequest - 11, // 10: api.Registry.GetBundle:input_type -> api.GetBundleRequest - 12, // 11: api.Registry.GetBundleForChannel:input_type -> api.GetBundleInChannelRequest - 13, // 12: api.Registry.GetChannelEntriesThatReplace:input_type -> api.GetAllReplacementsRequest - 14, // 13: api.Registry.GetBundleThatReplaces:input_type -> api.GetReplacementRequest - 15, // 14: api.Registry.GetChannelEntriesThatProvide:input_type -> api.GetAllProvidersRequest - 16, // 15: api.Registry.GetLatestChannelEntriesThatProvide:input_type -> api.GetLatestProvidersRequest - 17, // 16: api.Registry.GetDefaultBundleThatProvides:input_type -> api.GetDefaultProviderRequest - 9, // 17: api.Registry.ListBundles:input_type -> api.ListBundlesRequest - 1, // 18: api.Registry.ListPackages:output_type -> api.PackageName - 2, // 19: api.Registry.GetPackage:output_type -> api.Package - 6, // 20: api.Registry.GetBundle:output_type -> api.Bundle - 6, // 21: api.Registry.GetBundleForChannel:output_type -> api.Bundle - 7, // 22: api.Registry.GetChannelEntriesThatReplace:output_type -> api.ChannelEntry - 6, // 23: api.Registry.GetBundleThatReplaces:output_type -> api.Bundle - 7, // 24: api.Registry.GetChannelEntriesThatProvide:output_type -> api.ChannelEntry - 7, // 25: api.Registry.GetLatestChannelEntriesThatProvide:output_type -> api.ChannelEntry - 6, // 26: api.Registry.GetDefaultBundleThatProvides:output_type -> api.Bundle - 6, // 27: api.Registry.ListBundles:output_type -> api.Bundle - 18, // [18:28] is the sub-list for method output_type - 8, // [8:18] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name -} - -func init() { file_registry_proto_init() } -func file_registry_proto_init() { - if File_registry_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_registry_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Channel); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_registry_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PackageName); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_registry_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Package); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_registry_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GroupVersionKind); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_registry_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Dependency); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_registry_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Property); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_registry_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Bundle); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_registry_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ChannelEntry); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_registry_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListPackageRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_registry_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListBundlesRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_registry_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetPackageRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_registry_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetBundleRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_registry_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetBundleInChannelRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_registry_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetAllReplacementsRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_registry_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetReplacementRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_registry_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetAllProvidersRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_registry_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetLatestProvidersRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_registry_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetDefaultProviderRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_registry_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Deprecation); 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_registry_proto_rawDesc, - NumEnums: 0, - NumMessages: 19, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_registry_proto_goTypes, - DependencyIndexes: file_registry_proto_depIdxs, - MessageInfos: file_registry_proto_msgTypes, - }.Build() - File_registry_proto = out.File - file_registry_proto_rawDesc = nil - file_registry_proto_goTypes = nil - file_registry_proto_depIdxs = nil -} diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/api/registry.proto b/vendor/github.com/operator-framework/operator-registry/pkg/api/registry.proto deleted file mode 100644 index 5aa54a253..000000000 --- a/vendor/github.com/operator-framework/operator-registry/pkg/api/registry.proto +++ /dev/null @@ -1,133 +0,0 @@ -syntax = "proto3"; - -option go_package = ".;api"; - -package api; - -service Registry { - rpc ListPackages(ListPackageRequest) returns (stream PackageName) {} - rpc GetPackage(GetPackageRequest) returns (Package) {} - rpc GetBundle(GetBundleRequest) returns (Bundle) {} - rpc GetBundleForChannel(GetBundleInChannelRequest) returns (Bundle) { - option deprecated = true; - } - rpc GetChannelEntriesThatReplace(GetAllReplacementsRequest) returns (stream ChannelEntry) {} - rpc GetBundleThatReplaces(GetReplacementRequest) returns (Bundle) {} - rpc GetChannelEntriesThatProvide(GetAllProvidersRequest) returns (stream ChannelEntry) {} - rpc GetLatestChannelEntriesThatProvide(GetLatestProvidersRequest) returns (stream ChannelEntry) {} - rpc GetDefaultBundleThatProvides(GetDefaultProviderRequest) returns (Bundle) {} - rpc ListBundles(ListBundlesRequest) returns (stream Bundle) {} -} - -message Channel{ - string name = 1; - string csvName = 2; - Deprecation deprecation = 3; -} - -message PackageName{ - string name = 1; -} - -message Package{ - string name = 1; - repeated Channel channels = 2; - string defaultChannelName = 3; - Deprecation deprecation = 4; -} - -message GroupVersionKind{ - string group = 1; - string version = 2; - string kind = 3; - string plural = 4; -} - -message Dependency{ - string type = 1; - string value = 2; -} - -message Property{ - string type = 1; - string value = 2; -} - -message Bundle{ - string csvName = 1; - string packageName = 2; - string channelName = 3; - string csvJson = 4; - repeated string object = 5; - string bundlePath = 6; - repeated GroupVersionKind providedApis = 7; - repeated GroupVersionKind requiredApis = 8; - string version = 9; - string skipRange = 10; - repeated Dependency dependencies = 11; - repeated Property properties = 12; - string replaces = 13; - repeated string skips = 14; - Deprecation deprecation = 15; -} - -message ChannelEntry{ - string packageName = 1; - string channelName = 2; - string bundleName = 3; - string replaces = 4; -} - -message ListPackageRequest{} - -message ListBundlesRequest{} - -message GetPackageRequest{ - string name = 1; -} - -message GetBundleRequest{ - string pkgName = 1; - string channelName = 2; - string csvName = 3; -} - -message GetBundleInChannelRequest{ - string pkgName = 1; - string channelName = 2; -} - -message GetAllReplacementsRequest{ - string csvName = 1; -} - -message GetReplacementRequest{ - string csvName = 1; - string pkgName = 2; - string channelName = 3; -} - -message GetAllProvidersRequest{ - string group = 1; - string version = 2; - string kind = 3; - string plural = 4; -} - -message GetLatestProvidersRequest{ - string group = 1; - string version = 2; - string kind = 3; - string plural = 4; -} - -message GetDefaultProviderRequest{ - string group = 1; - string version = 2; - string kind = 3; - string plural = 4; -} - -message Deprecation{ - string message = 1; -} \ No newline at end of file diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/api/registry_grpc.pb.go b/vendor/github.com/operator-framework/operator-registry/pkg/api/registry_grpc.pb.go deleted file mode 100644 index bd9f08154..000000000 --- a/vendor/github.com/operator-framework/operator-registry/pkg/api/registry_grpc.pb.go +++ /dev/null @@ -1,582 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.3.0 -// - protoc v4.24.4 -// source: registry.proto - -package api - -import ( - context "context" - - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -const ( - Registry_ListPackages_FullMethodName = "/api.Registry/ListPackages" - Registry_GetPackage_FullMethodName = "/api.Registry/GetPackage" - Registry_GetBundle_FullMethodName = "/api.Registry/GetBundle" - Registry_GetBundleForChannel_FullMethodName = "/api.Registry/GetBundleForChannel" - Registry_GetChannelEntriesThatReplace_FullMethodName = "/api.Registry/GetChannelEntriesThatReplace" - Registry_GetBundleThatReplaces_FullMethodName = "/api.Registry/GetBundleThatReplaces" - Registry_GetChannelEntriesThatProvide_FullMethodName = "/api.Registry/GetChannelEntriesThatProvide" - Registry_GetLatestChannelEntriesThatProvide_FullMethodName = "/api.Registry/GetLatestChannelEntriesThatProvide" - Registry_GetDefaultBundleThatProvides_FullMethodName = "/api.Registry/GetDefaultBundleThatProvides" - Registry_ListBundles_FullMethodName = "/api.Registry/ListBundles" -) - -// RegistryClient is the client API for Registry service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type RegistryClient interface { - ListPackages(ctx context.Context, in *ListPackageRequest, opts ...grpc.CallOption) (Registry_ListPackagesClient, error) - GetPackage(ctx context.Context, in *GetPackageRequest, opts ...grpc.CallOption) (*Package, error) - GetBundle(ctx context.Context, in *GetBundleRequest, opts ...grpc.CallOption) (*Bundle, error) - // Deprecated: Do not use. - GetBundleForChannel(ctx context.Context, in *GetBundleInChannelRequest, opts ...grpc.CallOption) (*Bundle, error) - GetChannelEntriesThatReplace(ctx context.Context, in *GetAllReplacementsRequest, opts ...grpc.CallOption) (Registry_GetChannelEntriesThatReplaceClient, error) - GetBundleThatReplaces(ctx context.Context, in *GetReplacementRequest, opts ...grpc.CallOption) (*Bundle, error) - GetChannelEntriesThatProvide(ctx context.Context, in *GetAllProvidersRequest, opts ...grpc.CallOption) (Registry_GetChannelEntriesThatProvideClient, error) - GetLatestChannelEntriesThatProvide(ctx context.Context, in *GetLatestProvidersRequest, opts ...grpc.CallOption) (Registry_GetLatestChannelEntriesThatProvideClient, error) - GetDefaultBundleThatProvides(ctx context.Context, in *GetDefaultProviderRequest, opts ...grpc.CallOption) (*Bundle, error) - ListBundles(ctx context.Context, in *ListBundlesRequest, opts ...grpc.CallOption) (Registry_ListBundlesClient, error) -} - -type registryClient struct { - cc grpc.ClientConnInterface -} - -func NewRegistryClient(cc grpc.ClientConnInterface) RegistryClient { - return ®istryClient{cc} -} - -func (c *registryClient) ListPackages(ctx context.Context, in *ListPackageRequest, opts ...grpc.CallOption) (Registry_ListPackagesClient, error) { - stream, err := c.cc.NewStream(ctx, &Registry_ServiceDesc.Streams[0], Registry_ListPackages_FullMethodName, opts...) - if err != nil { - return nil, err - } - x := ®istryListPackagesClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -type Registry_ListPackagesClient interface { - Recv() (*PackageName, error) - grpc.ClientStream -} - -type registryListPackagesClient struct { - grpc.ClientStream -} - -func (x *registryListPackagesClient) Recv() (*PackageName, error) { - m := new(PackageName) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func (c *registryClient) GetPackage(ctx context.Context, in *GetPackageRequest, opts ...grpc.CallOption) (*Package, error) { - out := new(Package) - err := c.cc.Invoke(ctx, Registry_GetPackage_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *registryClient) GetBundle(ctx context.Context, in *GetBundleRequest, opts ...grpc.CallOption) (*Bundle, error) { - out := new(Bundle) - err := c.cc.Invoke(ctx, Registry_GetBundle_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// Deprecated: Do not use. -func (c *registryClient) GetBundleForChannel(ctx context.Context, in *GetBundleInChannelRequest, opts ...grpc.CallOption) (*Bundle, error) { - out := new(Bundle) - err := c.cc.Invoke(ctx, Registry_GetBundleForChannel_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *registryClient) GetChannelEntriesThatReplace(ctx context.Context, in *GetAllReplacementsRequest, opts ...grpc.CallOption) (Registry_GetChannelEntriesThatReplaceClient, error) { - stream, err := c.cc.NewStream(ctx, &Registry_ServiceDesc.Streams[1], Registry_GetChannelEntriesThatReplace_FullMethodName, opts...) - if err != nil { - return nil, err - } - x := ®istryGetChannelEntriesThatReplaceClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -type Registry_GetChannelEntriesThatReplaceClient interface { - Recv() (*ChannelEntry, error) - grpc.ClientStream -} - -type registryGetChannelEntriesThatReplaceClient struct { - grpc.ClientStream -} - -func (x *registryGetChannelEntriesThatReplaceClient) Recv() (*ChannelEntry, error) { - m := new(ChannelEntry) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func (c *registryClient) GetBundleThatReplaces(ctx context.Context, in *GetReplacementRequest, opts ...grpc.CallOption) (*Bundle, error) { - out := new(Bundle) - err := c.cc.Invoke(ctx, Registry_GetBundleThatReplaces_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *registryClient) GetChannelEntriesThatProvide(ctx context.Context, in *GetAllProvidersRequest, opts ...grpc.CallOption) (Registry_GetChannelEntriesThatProvideClient, error) { - stream, err := c.cc.NewStream(ctx, &Registry_ServiceDesc.Streams[2], Registry_GetChannelEntriesThatProvide_FullMethodName, opts...) - if err != nil { - return nil, err - } - x := ®istryGetChannelEntriesThatProvideClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -type Registry_GetChannelEntriesThatProvideClient interface { - Recv() (*ChannelEntry, error) - grpc.ClientStream -} - -type registryGetChannelEntriesThatProvideClient struct { - grpc.ClientStream -} - -func (x *registryGetChannelEntriesThatProvideClient) Recv() (*ChannelEntry, error) { - m := new(ChannelEntry) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func (c *registryClient) GetLatestChannelEntriesThatProvide(ctx context.Context, in *GetLatestProvidersRequest, opts ...grpc.CallOption) (Registry_GetLatestChannelEntriesThatProvideClient, error) { - stream, err := c.cc.NewStream(ctx, &Registry_ServiceDesc.Streams[3], Registry_GetLatestChannelEntriesThatProvide_FullMethodName, opts...) - if err != nil { - return nil, err - } - x := ®istryGetLatestChannelEntriesThatProvideClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -type Registry_GetLatestChannelEntriesThatProvideClient interface { - Recv() (*ChannelEntry, error) - grpc.ClientStream -} - -type registryGetLatestChannelEntriesThatProvideClient struct { - grpc.ClientStream -} - -func (x *registryGetLatestChannelEntriesThatProvideClient) Recv() (*ChannelEntry, error) { - m := new(ChannelEntry) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func (c *registryClient) GetDefaultBundleThatProvides(ctx context.Context, in *GetDefaultProviderRequest, opts ...grpc.CallOption) (*Bundle, error) { - out := new(Bundle) - err := c.cc.Invoke(ctx, Registry_GetDefaultBundleThatProvides_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *registryClient) ListBundles(ctx context.Context, in *ListBundlesRequest, opts ...grpc.CallOption) (Registry_ListBundlesClient, error) { - stream, err := c.cc.NewStream(ctx, &Registry_ServiceDesc.Streams[4], Registry_ListBundles_FullMethodName, opts...) - if err != nil { - return nil, err - } - x := ®istryListBundlesClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -type Registry_ListBundlesClient interface { - Recv() (*Bundle, error) - grpc.ClientStream -} - -type registryListBundlesClient struct { - grpc.ClientStream -} - -func (x *registryListBundlesClient) Recv() (*Bundle, error) { - m := new(Bundle) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// RegistryServer is the server API for Registry service. -// All implementations must embed UnimplementedRegistryServer -// for forward compatibility -type RegistryServer interface { - ListPackages(*ListPackageRequest, Registry_ListPackagesServer) error - GetPackage(context.Context, *GetPackageRequest) (*Package, error) - GetBundle(context.Context, *GetBundleRequest) (*Bundle, error) - // Deprecated: Do not use. - GetBundleForChannel(context.Context, *GetBundleInChannelRequest) (*Bundle, error) - GetChannelEntriesThatReplace(*GetAllReplacementsRequest, Registry_GetChannelEntriesThatReplaceServer) error - GetBundleThatReplaces(context.Context, *GetReplacementRequest) (*Bundle, error) - GetChannelEntriesThatProvide(*GetAllProvidersRequest, Registry_GetChannelEntriesThatProvideServer) error - GetLatestChannelEntriesThatProvide(*GetLatestProvidersRequest, Registry_GetLatestChannelEntriesThatProvideServer) error - GetDefaultBundleThatProvides(context.Context, *GetDefaultProviderRequest) (*Bundle, error) - ListBundles(*ListBundlesRequest, Registry_ListBundlesServer) error - mustEmbedUnimplementedRegistryServer() -} - -// UnimplementedRegistryServer must be embedded to have forward compatible implementations. -type UnimplementedRegistryServer struct { -} - -func (UnimplementedRegistryServer) ListPackages(*ListPackageRequest, Registry_ListPackagesServer) error { - return status.Errorf(codes.Unimplemented, "method ListPackages not implemented") -} -func (UnimplementedRegistryServer) GetPackage(context.Context, *GetPackageRequest) (*Package, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetPackage not implemented") -} -func (UnimplementedRegistryServer) GetBundle(context.Context, *GetBundleRequest) (*Bundle, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetBundle not implemented") -} -func (UnimplementedRegistryServer) GetBundleForChannel(context.Context, *GetBundleInChannelRequest) (*Bundle, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetBundleForChannel not implemented") -} -func (UnimplementedRegistryServer) GetChannelEntriesThatReplace(*GetAllReplacementsRequest, Registry_GetChannelEntriesThatReplaceServer) error { - return status.Errorf(codes.Unimplemented, "method GetChannelEntriesThatReplace not implemented") -} -func (UnimplementedRegistryServer) GetBundleThatReplaces(context.Context, *GetReplacementRequest) (*Bundle, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetBundleThatReplaces not implemented") -} -func (UnimplementedRegistryServer) GetChannelEntriesThatProvide(*GetAllProvidersRequest, Registry_GetChannelEntriesThatProvideServer) error { - return status.Errorf(codes.Unimplemented, "method GetChannelEntriesThatProvide not implemented") -} -func (UnimplementedRegistryServer) GetLatestChannelEntriesThatProvide(*GetLatestProvidersRequest, Registry_GetLatestChannelEntriesThatProvideServer) error { - return status.Errorf(codes.Unimplemented, "method GetLatestChannelEntriesThatProvide not implemented") -} -func (UnimplementedRegistryServer) GetDefaultBundleThatProvides(context.Context, *GetDefaultProviderRequest) (*Bundle, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetDefaultBundleThatProvides not implemented") -} -func (UnimplementedRegistryServer) ListBundles(*ListBundlesRequest, Registry_ListBundlesServer) error { - return status.Errorf(codes.Unimplemented, "method ListBundles not implemented") -} -func (UnimplementedRegistryServer) mustEmbedUnimplementedRegistryServer() {} - -// UnsafeRegistryServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to RegistryServer will -// result in compilation errors. -type UnsafeRegistryServer interface { - mustEmbedUnimplementedRegistryServer() -} - -func RegisterRegistryServer(s grpc.ServiceRegistrar, srv RegistryServer) { - s.RegisterService(&Registry_ServiceDesc, srv) -} - -func _Registry_ListPackages_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(ListPackageRequest) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(RegistryServer).ListPackages(m, ®istryListPackagesServer{stream}) -} - -type Registry_ListPackagesServer interface { - Send(*PackageName) error - grpc.ServerStream -} - -type registryListPackagesServer struct { - grpc.ServerStream -} - -func (x *registryListPackagesServer) Send(m *PackageName) error { - return x.ServerStream.SendMsg(m) -} - -func _Registry_GetPackage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetPackageRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RegistryServer).GetPackage(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Registry_GetPackage_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RegistryServer).GetPackage(ctx, req.(*GetPackageRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Registry_GetBundle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetBundleRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RegistryServer).GetBundle(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Registry_GetBundle_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RegistryServer).GetBundle(ctx, req.(*GetBundleRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Registry_GetBundleForChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetBundleInChannelRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RegistryServer).GetBundleForChannel(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Registry_GetBundleForChannel_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RegistryServer).GetBundleForChannel(ctx, req.(*GetBundleInChannelRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Registry_GetChannelEntriesThatReplace_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(GetAllReplacementsRequest) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(RegistryServer).GetChannelEntriesThatReplace(m, ®istryGetChannelEntriesThatReplaceServer{stream}) -} - -type Registry_GetChannelEntriesThatReplaceServer interface { - Send(*ChannelEntry) error - grpc.ServerStream -} - -type registryGetChannelEntriesThatReplaceServer struct { - grpc.ServerStream -} - -func (x *registryGetChannelEntriesThatReplaceServer) Send(m *ChannelEntry) error { - return x.ServerStream.SendMsg(m) -} - -func _Registry_GetBundleThatReplaces_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetReplacementRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RegistryServer).GetBundleThatReplaces(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Registry_GetBundleThatReplaces_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RegistryServer).GetBundleThatReplaces(ctx, req.(*GetReplacementRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Registry_GetChannelEntriesThatProvide_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(GetAllProvidersRequest) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(RegistryServer).GetChannelEntriesThatProvide(m, ®istryGetChannelEntriesThatProvideServer{stream}) -} - -type Registry_GetChannelEntriesThatProvideServer interface { - Send(*ChannelEntry) error - grpc.ServerStream -} - -type registryGetChannelEntriesThatProvideServer struct { - grpc.ServerStream -} - -func (x *registryGetChannelEntriesThatProvideServer) Send(m *ChannelEntry) error { - return x.ServerStream.SendMsg(m) -} - -func _Registry_GetLatestChannelEntriesThatProvide_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(GetLatestProvidersRequest) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(RegistryServer).GetLatestChannelEntriesThatProvide(m, ®istryGetLatestChannelEntriesThatProvideServer{stream}) -} - -type Registry_GetLatestChannelEntriesThatProvideServer interface { - Send(*ChannelEntry) error - grpc.ServerStream -} - -type registryGetLatestChannelEntriesThatProvideServer struct { - grpc.ServerStream -} - -func (x *registryGetLatestChannelEntriesThatProvideServer) Send(m *ChannelEntry) error { - return x.ServerStream.SendMsg(m) -} - -func _Registry_GetDefaultBundleThatProvides_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetDefaultProviderRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RegistryServer).GetDefaultBundleThatProvides(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Registry_GetDefaultBundleThatProvides_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RegistryServer).GetDefaultBundleThatProvides(ctx, req.(*GetDefaultProviderRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Registry_ListBundles_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(ListBundlesRequest) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(RegistryServer).ListBundles(m, ®istryListBundlesServer{stream}) -} - -type Registry_ListBundlesServer interface { - Send(*Bundle) error - grpc.ServerStream -} - -type registryListBundlesServer struct { - grpc.ServerStream -} - -func (x *registryListBundlesServer) Send(m *Bundle) error { - return x.ServerStream.SendMsg(m) -} - -// Registry_ServiceDesc is the grpc.ServiceDesc for Registry service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Registry_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.Registry", - HandlerType: (*RegistryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "GetPackage", - Handler: _Registry_GetPackage_Handler, - }, - { - MethodName: "GetBundle", - Handler: _Registry_GetBundle_Handler, - }, - { - MethodName: "GetBundleForChannel", - Handler: _Registry_GetBundleForChannel_Handler, - }, - { - MethodName: "GetBundleThatReplaces", - Handler: _Registry_GetBundleThatReplaces_Handler, - }, - { - MethodName: "GetDefaultBundleThatProvides", - Handler: _Registry_GetDefaultBundleThatProvides_Handler, - }, - }, - Streams: []grpc.StreamDesc{ - { - StreamName: "ListPackages", - Handler: _Registry_ListPackages_Handler, - ServerStreams: true, - }, - { - StreamName: "GetChannelEntriesThatReplace", - Handler: _Registry_GetChannelEntriesThatReplace_Handler, - ServerStreams: true, - }, - { - StreamName: "GetChannelEntriesThatProvide", - Handler: _Registry_GetChannelEntriesThatProvide_Handler, - ServerStreams: true, - }, - { - StreamName: "GetLatestChannelEntriesThatProvide", - Handler: _Registry_GetLatestChannelEntriesThatProvide_Handler, - ServerStreams: true, - }, - { - StreamName: "ListBundles", - Handler: _Registry_ListBundles_Handler, - ServerStreams: true, - }, - }, - Metadata: "registry.proto", -} diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/image/mock.go b/vendor/github.com/operator-framework/operator-registry/pkg/image/mock.go deleted file mode 100644 index f46d58516..000000000 --- a/vendor/github.com/operator-framework/operator-registry/pkg/image/mock.go +++ /dev/null @@ -1,85 +0,0 @@ -package image - -import ( - "context" - "errors" - "io/fs" - "os" - "path/filepath" - "sync" -) - -var _ Registry = &MockRegistry{} - -type MockRegistry struct { - RemoteImages map[Reference]*MockImage - localImages map[Reference]*MockImage - m sync.RWMutex -} - -type MockImage struct { - Labels map[string]string - FS fs.FS -} - -func (i *MockImage) unpack(dir string) error { - return fs.WalkDir(i.FS, ".", func(path string, entry fs.DirEntry, err error) error { - if err != nil { - return err - } - if entry.IsDir() { - return nil - } - data, err := fs.ReadFile(i.FS, path) - if err != nil { - return err - } - path = filepath.Join(dir, path) - pathDir := filepath.Dir(path) - if err := os.MkdirAll(pathDir, 0777); err != nil { - return err - } - return os.WriteFile(path, data, 0666) - }) -} - -func (m *MockRegistry) Pull(_ context.Context, ref Reference) error { - image, ok := m.RemoteImages[ref] - if !ok { - return errors.New("not found") - } - m.m.Lock() - defer m.m.Unlock() - if m.localImages == nil { - m.localImages = map[Reference]*MockImage{} - } - m.localImages[ref] = image - return nil -} - -func (m *MockRegistry) Unpack(_ context.Context, ref Reference, dir string) error { - m.m.RLock() - defer m.m.RUnlock() - image, ok := m.localImages[ref] - if !ok { - return errors.New("not found") - } - return image.unpack(dir) -} - -func (m *MockRegistry) Labels(_ context.Context, ref Reference) (map[string]string, error) { - m.m.RLock() - defer m.m.RUnlock() - image, ok := m.localImages[ref] - if !ok { - return nil, errors.New("not found") - } - return image.Labels, nil -} - -func (m *MockRegistry) Destroy() error { - m.m.Lock() - defer m.m.Unlock() - m.localImages = nil - return nil -} diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/image/reference.go b/vendor/github.com/operator-framework/operator-registry/pkg/image/reference.go deleted file mode 100644 index 660df5089..000000000 --- a/vendor/github.com/operator-framework/operator-registry/pkg/image/reference.go +++ /dev/null @@ -1,16 +0,0 @@ -package image - -import "fmt" - -// Reference describes a reference to a container image. -type Reference interface { - fmt.Stringer -} - -// SimpleReference is a reference backed by a string with no additional validation. -type SimpleReference string - -func (s SimpleReference) String() string { - ref := string(s) - return ref -} diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/image/registry.go b/vendor/github.com/operator-framework/operator-registry/pkg/image/registry.go deleted file mode 100644 index e7c365720..000000000 --- a/vendor/github.com/operator-framework/operator-registry/pkg/image/registry.go +++ /dev/null @@ -1,31 +0,0 @@ -package image - -import ( - "context" -) - -// Registry knows how to Pull and Unpack Operator Bundle images to the filesystem. -// Note: In the future, Registry will know how to Build and Push Operator Bundle images as well. -type Registry interface { - // Pull fetches and stores an image by reference. - Pull(ctx context.Context, ref Reference) error - - // Push uploads an image to the remote registry of its reference. - // If the referenced image does not exist in the registry, an error is returned. - // Push(ctx context.Context, ref string) error - - // Unpack writes the unpackaged content of an image to a directory. - // If the referenced image does not exist in the registry, an error is returned. - Unpack(ctx context.Context, ref Reference, dir string) error - - // Labels gets the labels for an image that is already stored. - Labels(ctx context.Context, ref Reference) (map[string]string, error) - - // Destroy cleans up any on-disk resources used to track images - Destroy() error - - // Pack creates and stores an image based on the given reference and returns a reference to the new image. - // If the referenced image does not exist in the registry, a new image is created from scratch. - // If it exists, it's used as the base image. - // Pack(ctx context.Context, ref Reference, from io.Reader) (next string, err error) -} diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/lib/semver/semver.go b/vendor/github.com/operator-framework/operator-registry/pkg/lib/semver/semver.go deleted file mode 100644 index 6875566d0..000000000 --- a/vendor/github.com/operator-framework/operator-registry/pkg/lib/semver/semver.go +++ /dev/null @@ -1,54 +0,0 @@ -package semver - -import ( - "fmt" - - "github.com/blang/semver/v4" -) - -// BuildIdCompare compares two versions and returns negative one if the first arg is less than the second arg, positive one if it is larger, and zero if they are equal. -// This comparison follows typical semver precedence rules, with one addition: whenever two versions are equal with the exception of their build-ids, the build-ids are compared using prerelease precedence rules. Further, versions with no build-id are always less than versions with build-ids; e.g. 1.0.0 < 1.0.0+1. -func BuildIdCompare(b semver.Version, v semver.Version) (int, error) { - if c := b.Compare(v); c != 0 { - return c, nil - } - - bPre, err := buildAsPrerelease(b) - if err != nil { - return 0, fmt.Errorf("failed to convert build-id of %s to prerelease version for comparison: %s", b, err) - } - - vPre, err := buildAsPrerelease(v) - if err != nil { - return 0, fmt.Errorf("failed to convert build-id of %s to prerelease version for comparison: %s", v, err) - } - - return bPre.Compare(*vPre), nil -} - -func buildAsPrerelease(v semver.Version) (*semver.Version, error) { - var pre []semver.PRVersion - for _, b := range v.Build { - p, err := semver.NewPRVersion(b) - if err != nil { - return nil, err - } - pre = append(pre, p) - } - - var major uint64 - if len(pre) > 0 { - // Adjust for the case where we compare a build-id prerelease analog to a version without a build-id. - // Without this `0.0.0+1` and `0.0.0` would become `0.0.0-1` and `0.0.0`, where the rules of prerelease comparison would - // end up giving us the wrong result; i.e. `0.0.0+1` < `0.0.0`. With this, `0.0.0+1` and `0.0.0` become `1.0.0-1` and `0.0.0` - // respectively, which does yield the intended result. - major = 1 - } - - return &semver.Version{ - Major: major, - Minor: 0, - Patch: 0, - Pre: pre, - }, nil -} diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/prettyunmarshaler/prettyunmarshaler.go b/vendor/github.com/operator-framework/operator-registry/pkg/prettyunmarshaler/prettyunmarshaler.go deleted file mode 100644 index 2f740151a..000000000 --- a/vendor/github.com/operator-framework/operator-registry/pkg/prettyunmarshaler/prettyunmarshaler.go +++ /dev/null @@ -1,93 +0,0 @@ -package prettyunmarshaler - -import ( - "bytes" - "encoding/json" - "errors" - "fmt" - "strings" -) - -type JsonUnmarshalError struct { - data []byte - offset int64 - err error -} - -func NewJSONUnmarshalError(data []byte, err error) *JsonUnmarshalError { - var te *json.UnmarshalTypeError - if errors.As(err, &te) { - return &JsonUnmarshalError{data: data, offset: te.Offset, err: te} - } - var se *json.SyntaxError - if errors.As(err, &se) { - return &JsonUnmarshalError{data: data, offset: se.Offset, err: se} - } - return &JsonUnmarshalError{data: data, offset: -1, err: err} -} - -func (e *JsonUnmarshalError) Error() string { - return e.err.Error() -} - -func (e *JsonUnmarshalError) Pretty() string { - if len(e.data) == 0 || e.offset < 0 || e.offset > int64(len(e.data)) { - return e.err.Error() - } - - const marker = " <==" - - var sb strings.Builder - _, _ = sb.WriteString(fmt.Sprintf("%s at offset %d (indicated by%s)\n", e.err.Error(), e.offset, marker)) - - prettyBuf := bytes.NewBuffer(make([]byte, 0, len(e.data))) - err := json.Indent(prettyBuf, e.data, "", " ") - - // If there was an error indenting the JSON, just treat the original data as the pretty data. - if err != nil { - prettyBuf = bytes.NewBuffer(e.data) - } - - // If the offset is at the end of the data, just print the pretty data and the marker at the end. - if int(e.offset) == len(e.data) { - _, _ = sb.WriteString(prettyBuf.String()) - _, _ = sb.WriteString(marker) - return sb.String() - } - - // If the offset is within the data, find the corresponding offset in the pretty data. - var ( - pIndex int - pOffset int - ) - pretty := prettyBuf.Bytes() - for dIndex, b := range e.data { - // If we've reached the offset, record it and break out of the loop - if dIndex == int(e.offset) { - pOffset = pIndex - break - } - - // Fast-forward the pretty index until we find the byte in the pretty data - // that matches the byte in the original data. - for pretty[pIndex] != b { - pIndex++ - if pIndex >= len(pretty) { - // Something went wrong. For example, if the pretty data somehow reordered - // the bytes or is missing a byte - return e.err.Error() - } - } - - // We found the byte in the pretty data that matches the byte in the original data, - // so increment the pretty index. - pIndex++ - - } - - _, _ = sb.Write(pretty[:pOffset]) - _, _ = sb.WriteString(fmt.Sprintf("%s ", marker)) - _, _ = sb.Write(pretty[pOffset:]) - - return sb.String() -} diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/registry/bundle.go b/vendor/github.com/operator-framework/operator-registry/pkg/registry/bundle.go deleted file mode 100644 index b5fb28b94..000000000 --- a/vendor/github.com/operator-framework/operator-registry/pkg/registry/bundle.go +++ /dev/null @@ -1,395 +0,0 @@ -package registry - -import ( - "encoding/json" - "fmt" - "strings" - - apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/serializer" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" - "k8s.io/apimachinery/pkg/util/yaml" -) - -const ( - v1beta1CRDVersion = "v1beta1" - v1CRDVersion = "v1" - CRDKind = "CustomResourceDefinition" -) - -// Scheme is the default instance of runtime.Scheme to which types in the Kubernetes API are already registered. -var Scheme = runtime.NewScheme() - -// Codecs provides access to encoding and decoding for the scheme -var Codecs = serializer.NewCodecFactory(Scheme) - -func DefaultYAMLDecoder() runtime.Decoder { - return Codecs.UniversalDeserializer() -} - -func init() { - utilruntime.Must(apiextensionsv1beta1.AddToScheme(Scheme)) - utilruntime.Must(apiextensionsv1.AddToScheme(Scheme)) -} - -type Bundle struct { - Name string - Objects []*unstructured.Unstructured - Package string - Channels []string - BundleImage string - version string - csv *ClusterServiceVersion - v1beta1crds []*apiextensionsv1beta1.CustomResourceDefinition - v1crds []*apiextensionsv1.CustomResourceDefinition - Dependencies []*Dependency - Properties []Property - Annotations *Annotations - cacheStale bool -} - -func NewBundle(name string, annotations *Annotations, objs ...*unstructured.Unstructured) *Bundle { - bundle := &Bundle{ - Name: name, - Package: annotations.PackageName, - Annotations: annotations, - } - for _, o := range objs { - bundle.Add(o) - } - - if annotations == nil { - return bundle - } - bundle.Channels = strings.Split(annotations.Channels, ",") - - return bundle -} - -func NewBundleFromStrings(name, version, pkg, defaultChannel, channels, objs string) (*Bundle, error) { - objStrs, err := BundleStringToObjectStrings(objs) - if err != nil { - return nil, err - } - - unstObjs := []*unstructured.Unstructured{} - for _, o := range objStrs { - dec := yaml.NewYAMLOrJSONDecoder(strings.NewReader(o), 10) - unst := &unstructured.Unstructured{} - if err := dec.Decode(unst); err != nil { - return nil, err - } - unstObjs = append(unstObjs, unst) - } - - annotations := &Annotations{ - PackageName: pkg, - Channels: channels, - DefaultChannelName: defaultChannel, - } - bundle := NewBundle(name, annotations, unstObjs...) - bundle.version = version - - return bundle, nil -} - -func (b *Bundle) Size() int { - return len(b.Objects) -} -func (b *Bundle) Add(obj *unstructured.Unstructured) { - b.Objects = append(b.Objects, obj) - b.cacheStale = true -} - -func (b *Bundle) ClusterServiceVersion() (*ClusterServiceVersion, error) { - if err := b.cache(); err != nil { - return nil, err - } - return b.csv, nil -} - -func (b *Bundle) Version() (string, error) { - if b.version != "" { - return b.version, nil - } - - var err error - if err = b.cache(); err != nil { - return "", err - } - - if b.csv != nil { - b.version, err = b.csv.GetVersion() - } - - return b.version, err -} - -func (b *Bundle) SkipRange() (string, error) { - if err := b.cache(); err != nil { - return "", err - } - return b.csv.GetSkipRange(), nil -} - -func (b *Bundle) Replaces() (string, error) { - if err := b.cache(); err != nil { - return "", err - } - return b.csv.GetReplaces() -} - -func (b *Bundle) Skips() ([]string, error) { - if err := b.cache(); err != nil { - return nil, err - } - return b.csv.GetSkips() -} - -func (b *Bundle) Icons() ([]Icon, error) { - if err := b.cache(); err != nil { - return nil, err - } - return b.csv.GetIcons() -} - -func (b *Bundle) Description() (string, error) { - if err := b.cache(); err != nil { - return "", err - } - return b.csv.GetDescription() -} - -func (b *Bundle) CustomResourceDefinitions() ([]runtime.Object, error) { - if err := b.cache(); err != nil { - return nil, err - } - var crds []runtime.Object - for _, crd := range b.v1crds { - crds = append(crds, crd) - } - for _, crd := range b.v1beta1crds { - crds = append(crds, crd) - } - return crds, nil -} - -func (b *Bundle) ProvidedAPIs() (map[APIKey]struct{}, error) { - provided := map[APIKey]struct{}{} - crds, err := b.CustomResourceDefinitions() - if err != nil { - return nil, fmt.Errorf("error getting crds: %s", err) - } - - for _, c := range crds { - switch crd := c.(type) { - case *apiextensionsv1.CustomResourceDefinition: - for _, v := range crd.Spec.Versions { - provided[APIKey{Group: crd.Spec.Group, Version: v.Name, Kind: crd.Spec.Names.Kind, Plural: crd.Spec.Names.Plural}] = struct{}{} - } - case *apiextensionsv1beta1.CustomResourceDefinition: - for _, v := range crd.Spec.Versions { - provided[APIKey{Group: crd.Spec.Group, Version: v.Name, Kind: crd.Spec.Names.Kind, Plural: crd.Spec.Names.Plural}] = struct{}{} - } - if crd.Spec.Version != "" { - provided[APIKey{Group: crd.Spec.Group, Version: crd.Spec.Version, Kind: crd.Spec.Names.Kind, Plural: crd.Spec.Names.Plural}] = struct{}{} - } - default: - return nil, fmt.Errorf("unknown api version in crd: %#v", crd) - } - } - - csv, err := b.ClusterServiceVersion() - if err != nil { - return nil, err - } - - ownedAPIs, _, err := csv.GetApiServiceDefinitions() - if err != nil { - return nil, fmt.Errorf("error getting apiservice definitions: %s", err) - } - for _, api := range ownedAPIs { - provided[APIKey{Group: api.Group, Version: api.Version, Kind: api.Kind, Plural: api.Name}] = struct{}{} - } - return provided, nil -} - -func (b *Bundle) RequiredAPIs() (map[APIKey]struct{}, error) { - required := map[APIKey]struct{}{} - csv, err := b.ClusterServiceVersion() - if err != nil { - return nil, err - } - - _, requiredCRDs, err := csv.GetCustomResourceDefintions() - if err != nil { - return nil, err - } - for _, api := range requiredCRDs { - parts := strings.SplitN(api.Name, ".", 2) - if len(parts) < 2 { - return nil, fmt.Errorf("couldn't parse plural.group from crd name: %s", api.Name) - } - required[APIKey{parts[1], api.Version, api.Kind, parts[0]}] = struct{}{} - - } - _, requiredAPIs, err := csv.GetApiServiceDefinitions() - if err != nil { - return nil, err - } - for _, api := range requiredAPIs { - required[APIKey{Group: api.Group, Version: api.Version, Kind: api.Kind, Plural: api.Name}] = struct{}{} - } - return required, nil -} - -func (b *Bundle) AllProvidedAPIsInBundle() error { - csv, err := b.ClusterServiceVersion() - if err != nil { - return err - } - bundleAPIs, err := b.ProvidedAPIs() - if err != nil { - return err - } - - ownedCRDs, _, err := csv.GetCustomResourceDefintions() - if err != nil { - return err - } - shouldExist := make(map[APIKey]struct{}, len(ownedCRDs)) - for _, crdDef := range ownedCRDs { - parts := strings.SplitN(crdDef.Name, ".", 2) - if len(parts) < 2 { - return fmt.Errorf("couldn't parse plural.group from crd name: %s", crdDef.Name) - } - shouldExist[APIKey{parts[1], crdDef.Version, crdDef.Kind, parts[0]}] = struct{}{} - } - for key := range shouldExist { - if _, ok := bundleAPIs[key]; !ok { - return fmt.Errorf("couldn't find %v in bundle. found: %v", key, bundleAPIs) - } - } - // note: don't need to check bundle for extension apiserver types, which don't require extra bundle entries - return nil -} - -func (b *Bundle) Serialize() (csvName, bundleImage string, csvBytes []byte, bundleBytes []byte, annotationBytes []byte, err error) { - csvCount := 0 - for _, obj := range b.Objects { - objBytes, err := runtime.Encode(unstructured.UnstructuredJSONScheme, obj) - if err != nil { - return "", "", nil, nil, nil, err - } - bundleBytes = append(bundleBytes, objBytes...) - - if obj.GroupVersionKind().Kind == "ClusterServiceVersion" { - csvName = obj.GetName() - csvBytes, err = runtime.Encode(unstructured.UnstructuredJSONScheme, obj) - if err != nil { - return "", "", nil, nil, nil, err - } - csvCount += 1 - if csvCount > 1 { - return "", "", nil, nil, nil, fmt.Errorf("two csvs found in one bundle") - } - } - } - - if b.Annotations != nil { - annotationBytes, err = json.Marshal(b.Annotations) - } - - return csvName, b.BundleImage, csvBytes, bundleBytes, annotationBytes, nil -} - -func (b *Bundle) Images() (map[string]struct{}, error) { - result := make(map[string]struct{}) - - if b.BundleImage != "" { - result[b.BundleImage] = struct{}{} - } - - csv, err := b.ClusterServiceVersion() - if err != nil { - return nil, err - } - - if csv == nil { - return result, nil - } - - images, err := csv.GetOperatorImages() - if err != nil { - return nil, err - } - for img := range images { - result[img] = struct{}{} - } - - relatedImages, err := csv.GetRelatedImages() - if err != nil { - return nil, err - } - for img := range relatedImages { - result[img] = struct{}{} - } - - return result, nil -} - -func (b *Bundle) cache() error { - if !b.cacheStale { - return nil - } - for _, o := range b.Objects { - if o.GroupVersionKind().Kind == "ClusterServiceVersion" { - csv := &ClusterServiceVersion{} - if err := runtime.DefaultUnstructuredConverter.FromUnstructured(o.UnstructuredContent(), csv); err != nil { - return err - } - b.csv = csv - break - } - } - - for _, o := range b.Objects { - if o.GroupVersionKind().Kind == CRDKind { - // Marshal Unstructured and Decode as CustomResourceDefinition. FromUnstructured has issues - // converting JSON numbers to float64 for CRD minimum/maximum validation. - cb, err := o.MarshalJSON() - if err != nil { - return err - } - dec := serializer.NewCodecFactory(Scheme).UniversalDeserializer() - switch o.GroupVersionKind().Version { - case v1CRDVersion: - crd := &apiextensionsv1.CustomResourceDefinition{} - if _, _, err = dec.Decode(cb, nil, crd); err != nil { - return fmt.Errorf("error decoding v1 CRD: %v", err) - } - b.v1crds = append(b.v1crds, crd) - case v1beta1CRDVersion: - crd := &apiextensionsv1beta1.CustomResourceDefinition{} - if _, _, err = dec.Decode(cb, nil, crd); err != nil { - return fmt.Errorf("error decoding v1beta1 CRD: %v", err) - } - b.v1beta1crds = append(b.v1beta1crds, crd) - } - } - } - - b.cacheStale = false - return nil -} - -func (b *Bundle) SubstitutesFor() (string, error) { - if err := b.cache(); err != nil { - return "", err - } - return b.csv.GetSubstitutesFor(), nil -} diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/registry/bundlegraphloader.go b/vendor/github.com/operator-framework/operator-registry/pkg/registry/bundlegraphloader.go deleted file mode 100644 index e8664c4e8..000000000 --- a/vendor/github.com/operator-framework/operator-registry/pkg/registry/bundlegraphloader.go +++ /dev/null @@ -1,160 +0,0 @@ -package registry - -import ( - "fmt" - - "github.com/blang/semver/v4" -) - -// BundleGraphLoader generates updated graphs by adding bundles to them, updating -// the graph implicitly via semantic version of each bundle -type BundleGraphLoader struct { -} - -// AddBundleToGraph takes a bundle and an existing graph and updates the graph to insert the new bundle -// into each channel it is included in -func (g *BundleGraphLoader) AddBundleToGraph(bundle *Bundle, graph *Package, annotations *AnnotationsFile, skippatch bool) (*Package, error) { - bundleVersion, err := bundle.Version() - if err != nil { - return nil, fmt.Errorf("Unable to extract bundle version from bundle %s, can't insert in semver mode", bundle.BundleImage) - } - - versionToAdd, err := semver.Make(bundleVersion) - if err != nil { - return nil, fmt.Errorf("Bundle version %s is not valid", bundleVersion) - } - - newBundleKey := BundleKey{ - CsvName: bundle.Name, - Version: versionToAdd.String(), - BundlePath: bundle.BundleImage, - } - - // initialize the graph if it started empty - if graph.Name == "" { - graph.Name = bundle.Package - } - - newDefaultChannel := annotations.Annotations.DefaultChannelName - if newDefaultChannel != "" { - graph.DefaultChannel = newDefaultChannel - } - - if graph.DefaultChannel == "" { - // Infer default channel from channel list - if annotations.SelectDefaultChannel() == "" { - return nil, fmt.Errorf("Default channel is missing and can't be inferred") - } - graph.DefaultChannel = annotations.SelectDefaultChannel() - } - - // generate the DAG for each channel the new bundle is being insert into - for _, channel := range bundle.Channels { - replaces := make(map[BundleKey]struct{}, 0) - - // If the channel doesn't exist yet, initialize it - if !graph.HasChannel(channel) { - // create the channel and add a single node - newChannelGraph := Channel{ - Head: newBundleKey, - Nodes: map[BundleKey]map[BundleKey]struct{}{ - newBundleKey: nil, - }, - } - if graph.Channels == nil { - graph.Channels = make(map[string]Channel, 1) - } - graph.Channels[channel] = newChannelGraph - continue - } - - // find the version(s) it should sit between - channelGraph := graph.Channels[channel] - if channelGraph.Nodes == nil { - channelGraph.Nodes = make(map[BundleKey]map[BundleKey]struct{}, 1) - } - - lowestAhead := BundleKey{} - greatestBehind := BundleKey{} - skipPatchCandidates := []BundleKey{} - - // Iterate over existing nodes and compare the new node's version to find the - // lowest version above it and highest version below it (to insert between these nodes) - for node := range channelGraph.Nodes { - nodeVersion, err := semver.Make(node.Version) - if err != nil { - return nil, fmt.Errorf("Unable to parse existing bundle version stored in index %s %s %s", - node.CsvName, node.Version, node.BundlePath) - } - - switch comparison := nodeVersion.Compare(versionToAdd); comparison { - case 0: - return nil, fmt.Errorf("Bundle version %s already added to index", bundleVersion) - case 1: - if lowestAhead.IsEmpty() { - lowestAhead = node - } else { - lowestAheadSemver, _ := semver.Make(lowestAhead.Version) - if nodeVersion.LT(lowestAheadSemver) { - lowestAhead = node - } - } - case -1: - if greatestBehind.IsEmpty() { - greatestBehind = node - } else { - greatestBehindSemver, _ := semver.Make(greatestBehind.Version) - if nodeVersion.GT(greatestBehindSemver) { - greatestBehind = node - } - } - } - - // if skippatch mode is enabled, check each node to determine if z-updates should - // be replaced as well. Keep track of them to delete those nodes from the graph itself, - // just be aware of them for replacements - if skippatch { - if isSkipPatchCandidate(versionToAdd, nodeVersion) { - skipPatchCandidates = append(skipPatchCandidates, node) - replaces[node] = struct{}{} - } - } - } - - // If we found a node behind the one we're adding, make the new node replace it - if !greatestBehind.IsEmpty() { - replaces[greatestBehind] = struct{}{} - } - - // If we found a node ahead of the one we're adding, make the lowest to replace - // the new node. If we didn't find a node semantically ahead, the new node is - // the new channel head - if !lowestAhead.IsEmpty() { - channelGraph.Nodes[lowestAhead] = map[BundleKey]struct{}{ - newBundleKey: struct{}{}, - } - } else { - channelGraph.Head = newBundleKey - } - - if skippatch { - // Remove the nodes that are now being skipped by a new patch version update - for _, candidate := range skipPatchCandidates { - delete(channelGraph.Nodes, candidate) - } - } - - // add the node and update the graph - channelGraph.Nodes[newBundleKey] = replaces - graph.Channels[channel] = channelGraph - } - - return graph, nil -} - -// isSkipPatchCandidate returns true if version is equal to toCompare -// in major and minor positions and strictly greater in all others, -// indicating that toCompare can be skipped over to version. -func isSkipPatchCandidate(version, toCompare semver.Version) bool { - return (version.Major == toCompare.Major) && (version.Minor == toCompare.Minor) && version.GT(toCompare) -} diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/registry/channelupdateoptions.go b/vendor/github.com/operator-framework/operator-registry/pkg/registry/channelupdateoptions.go deleted file mode 100644 index 85f5acb40..000000000 --- a/vendor/github.com/operator-framework/operator-registry/pkg/registry/channelupdateoptions.go +++ /dev/null @@ -1,27 +0,0 @@ -package registry - -import ( - "fmt" - "strings" -) - -type Mode int - -const ( - ReplacesMode = iota - SemVerMode - SkipPatchMode -) - -func GetModeFromString(mode string) (Mode, error) { - switch strings.ToLower(mode) { - case "replaces": - return ReplacesMode, nil - case "semver": - return SemVerMode, nil - case "semver-skippatch": - return SkipPatchMode, nil - default: - return -1, fmt.Errorf("Invalid channel update mode %s specified", mode) - } -} diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/registry/conversion.go b/vendor/github.com/operator-framework/operator-registry/pkg/registry/conversion.go deleted file mode 100644 index 62bb619f4..000000000 --- a/vendor/github.com/operator-framework/operator-registry/pkg/registry/conversion.go +++ /dev/null @@ -1,97 +0,0 @@ -package registry - -import ( - "encoding/json" - "fmt" - "strings" - - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/util/yaml" - - "github.com/operator-framework/operator-registry/pkg/api" -) - -func PackageManifestToAPIPackage(manifest *PackageManifest) *api.Package { - channels := []*api.Channel{} - for _, c := range manifest.Channels { - channels = append(channels, PackageChannelToAPIChannel(&c)) - } - var deprecation *api.Deprecation - if manifest.Deprecation != nil { - deprecation = &api.Deprecation{ - Message: manifest.Deprecation.Message, - } - } - return &api.Package{ - Name: manifest.PackageName, - DefaultChannelName: manifest.DefaultChannelName, - Channels: channels, - Deprecation: deprecation, - } -} - -func PackageChannelToAPIChannel(channel *PackageChannel) *api.Channel { - var deprecation *api.Deprecation - if channel.Deprecation != nil { - deprecation = &api.Deprecation{ - Message: channel.Deprecation.Message, - } - } - return &api.Channel{ - Name: channel.Name, - CsvName: channel.CurrentCSVName, - Deprecation: deprecation, - } -} - -func ChannelEntryToAPIChannelEntry(entry *ChannelEntry) *api.ChannelEntry { - return &api.ChannelEntry{ - PackageName: entry.PackageName, - ChannelName: entry.ChannelName, - BundleName: entry.BundleName, - Replaces: entry.Replaces, - } -} - -// Bundle strings are appended json objects, we need to split them apart -// e.g. {"my":"obj"}{"csv":"data"}{"crd":"too"} -func BundleStringToObjectStrings(bundleString string) ([]string, error) { - objs := []string{} - dec := json.NewDecoder(strings.NewReader(bundleString)) - - for dec.More() { - var m json.RawMessage - err := dec.Decode(&m) - if err != nil { - return nil, err - } - objs = append(objs, string(m)) - } - return objs, nil -} - -func BundleStringToAPIBundle(bundleString string) (*api.Bundle, error) { - objs, err := BundleStringToObjectStrings(bundleString) - if err != nil { - return nil, err - } - out := &api.Bundle{ - Object: objs, - } - for _, o := range objs { - dec := yaml.NewYAMLOrJSONDecoder(strings.NewReader(o), 10) - unst := &unstructured.Unstructured{} - if err := dec.Decode(unst); err != nil { - return nil, err - } - if unst.GetKind() == "ClusterServiceVersion" { - out.CsvName = unst.GetName() - out.CsvJson = o - break - } - } - if out.CsvName == "" { - return nil, fmt.Errorf("no csv in bundle") - } - return out, nil -} diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/registry/csv.go b/vendor/github.com/operator-framework/operator-registry/pkg/registry/csv.go deleted file mode 100644 index 8dcdf65ad..000000000 --- a/vendor/github.com/operator-framework/operator-registry/pkg/registry/csv.go +++ /dev/null @@ -1,469 +0,0 @@ -package registry - -import ( - "encoding/json" - "errors" - "fmt" - "os" - "path" - - prettyunmarshaler "github.com/operator-framework/operator-registry/pkg/prettyunmarshaler" - - v1 "k8s.io/api/apps/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/util/yaml" - - "github.com/operator-framework/api/pkg/operators" -) - -const ( - // Name of the CSV's kind - clusterServiceVersionKind = "ClusterServiceVersion" - - // Name of the section under which the list of owned and required list of - // CRD(s) is specified inside an operator manifest. - customResourceDefinitions = "customresourcedefinitions" - - // Name of the section under which the list of owned and required list of - // apiservices is specified inside an operator manifest. - apiServiceDefinitions = "apiservicedefinitions" - - // The yaml attribute that points to the name of an older - // ClusterServiceVersion object that the current ClusterServiceVersion - // replaces. - replaces = "replaces" - - // The yaml attribute that points to the names of older - // ClusterServiceVersion objects that the current ClusterServiceVersion - // skips - skips = "skips" - - // The yaml attribute that points to the icon for the ClusterServiceVersion - icon = "icon" - - // The yaml attribute that points to the icon.base64data for the ClusterServiceVersion - base64data = "base64data" - - // The yaml attribute that points to the icon.mediatype for the ClusterServiceVersion - mediatype = "mediatype" - // The yaml attribute that points to the description for the ClusterServiceVersion - description = "description" - - // The yaml attribute that specifies the version of the ClusterServiceVersion - // expected to be semver and parseable by blang/semver/v4 - version = "version" - - // The yaml attribute that specifies the related images of the ClusterServiceVersion - relatedImages = "relatedImages" - - // The yaml attribute that specifies the skipRange of the ClusterServiceVersion - skipRangeAnnotationKey = "olm.skipRange" - - // The yaml attribute that specifies the optional substitutesfor of the ClusterServiceVersion - substitutesForAnnotationKey = "olm.substitutesFor" -) - -// ClusterServiceVersion is a structured representation of cluster service -// version object(s) specified inside the 'clusterServiceVersions' section of -// an operator manifest. -type ClusterServiceVersion struct { - // Type metadata. - metav1.TypeMeta `json:",inline"` - - // Object metadata. - metav1.ObjectMeta `json:"metadata"` - - // Spec is the raw representation of the 'spec' element of - // ClusterServiceVersion object. Since we are - // not interested in the content of spec we are not parsing it. - Spec json.RawMessage `json:"spec"` -} - -// ReadCSVFromBundleDirectory tries to parse every YAML file in the directory without inspecting sub-directories and -// returns a CSV. According to the strict one CSV per bundle rule, func returns an error if more than one CSV is found. -func ReadCSVFromBundleDirectory(bundleDir string) (*ClusterServiceVersion, error) { - dirContent, err := os.ReadDir(bundleDir) - if err != nil { - return nil, fmt.Errorf("error reading bundle directory %s, %v", bundleDir, err) - } - - files := []string{} - for _, f := range dirContent { - if !f.IsDir() { - files = append(files, f.Name()) - } - } - - csv := ClusterServiceVersion{} - foundCSV := false - for _, file := range files { - yamlReader, err := os.Open(path.Join(bundleDir, file)) - if err != nil { - continue - } - defer yamlReader.Close() - - unstructuredCSV := unstructured.Unstructured{} - - decoder := yaml.NewYAMLOrJSONDecoder(yamlReader, 30) - if err = decoder.Decode(&unstructuredCSV); err != nil { - continue - } - - if unstructuredCSV.GetKind() != operators.ClusterServiceVersionKind { - continue - } - - if foundCSV { - return nil, fmt.Errorf("more than one ClusterServiceVersion is found in bundle") - } - - if err := runtime.DefaultUnstructuredConverter.FromUnstructured(unstructuredCSV.UnstructuredContent(), - &csv); err != nil { - return nil, err - } - foundCSV = true - } - - if foundCSV { - return &csv, nil - } - return nil, fmt.Errorf("no ClusterServiceVersion object found in %s", bundleDir) - -} - -// GetReplaces returns the name of the older ClusterServiceVersion object that -// is replaced by this ClusterServiceVersion object. -// -// If not defined, the function returns an empty string. -func (csv *ClusterServiceVersion) GetReplaces() (string, error) { - var objmap map[string]*json.RawMessage - if err := json.Unmarshal(csv.Spec, &objmap); err != nil { - return "", err - } - - rawValue, ok := objmap[replaces] - if !ok || rawValue == nil { - return "", nil - } - - var replaces string - if err := json.Unmarshal(*rawValue, &replaces); err != nil { - return "", err - } - - return replaces, nil -} - -// GetVersion returns the version of the CSV -// -// If not defined, the function returns an empty string. -func (csv *ClusterServiceVersion) GetVersion() (string, error) { - var objmap map[string]*json.RawMessage - if err := json.Unmarshal(csv.Spec, &objmap); err != nil { - return "", err - } - - rawValue, ok := objmap[version] - if !ok || rawValue == nil { - return "", nil - } - - var v string - if err := json.Unmarshal(*rawValue, &v); err != nil { - return "", err - } - - return v, nil -} - -// GetSkipRange returns the skiprange of the CSV -// -// If not defined, the function returns an empty string. -func (csv *ClusterServiceVersion) GetSkipRange() string { - skipRange, ok := csv.Annotations[skipRangeAnnotationKey] - if !ok { - return "" - } - return skipRange -} - -// GetSkips returns the name of the older ClusterServiceVersion objects that -// are skipped by this ClusterServiceVersion object. -// -// If not defined, the function returns an empty string. -func (csv *ClusterServiceVersion) GetSkips() ([]string, error) { - var objmap map[string]*json.RawMessage - if err := json.Unmarshal(csv.Spec, &objmap); err != nil { - return nil, err - } - - rawValue, ok := objmap[skips] - if !ok || rawValue == nil { - return nil, nil - } - - var skips []string - if err := json.Unmarshal(*rawValue, &skips); err != nil { - return nil, err - } - - return skips, nil -} - -// GetCustomResourceDefintions returns a list of owned and required -// CustomResourceDefinition object(s) specified inside the -// 'customresourcedefinitions' section of a ClusterServiceVersion 'spec'. -// -// owned represents the list of CRD(s) managed by this ClusterServiceVersion -// object. -// required represents the list of CRD(s) that this ClusterServiceVersion -// object depends on. -// -// If owned or required is not defined in the spec then an empty list is -// returned respectively. -func (csv *ClusterServiceVersion) GetCustomResourceDefintions() (owned []*DefinitionKey, required []*DefinitionKey, err error) { - var objmap map[string]*json.RawMessage - - if err = json.Unmarshal(csv.Spec, &objmap); err != nil { - return - } - - rawValue, ok := objmap[customResourceDefinitions] - if !ok || rawValue == nil { - return - } - - var definitions struct { - Owned []*DefinitionKey `json:"owned"` - Required []*DefinitionKey `json:"required"` - } - - if err = json.Unmarshal(*rawValue, &definitions); err != nil { - return - } - - owned = definitions.Owned - required = definitions.Required - return -} - -// GetApiServiceDefinitions returns a list of owned and required -// APISerivces specified inside the -// 'apiservicedefinitions' section of a ClusterServiceVersion 'spec'. -// -// owned represents the list of apiservices managed by this ClusterServiceVersion -// object. -// required represents the list of apiservices that this ClusterServiceVersion -// object depends on. -// -// If owned or required is not defined in the spec then an empty list is -// returned respectively. -func (csv *ClusterServiceVersion) GetApiServiceDefinitions() (owned []*DefinitionKey, required []*DefinitionKey, err error) { - var objmap map[string]*json.RawMessage - - if err = json.Unmarshal(csv.Spec, &objmap); err != nil { - return nil, nil, fmt.Errorf("error unmarshaling into object map: %s", err) - } - - rawValue, ok := objmap[apiServiceDefinitions] - if !ok || rawValue == nil { - return - } - - var definitions struct { - Owned []*DefinitionKey `json:"owned"` - Required []*DefinitionKey `json:"required"` - } - - if err = json.Unmarshal(*rawValue, &definitions); err != nil { - return - } - - owned = definitions.Owned - required = definitions.Required - return -} - -// GetRelatedImage returns the list of associated images for the operator -func (csv *ClusterServiceVersion) GetRelatedImages() (imageSet map[string]struct{}, err error) { - var objmap map[string]*json.RawMessage - imageSet = make(map[string]struct{}) - - if err = json.Unmarshal(csv.Spec, &objmap); err != nil { - return - } - - rawValue, ok := objmap[relatedImages] - if !ok || rawValue == nil { - return - } - - type relatedImage struct { - Name string `json:"name"` - Ref string `json:"image"` - } - var relatedImages []relatedImage - if err = json.Unmarshal(*rawValue, &relatedImages); err != nil { - return - } - - for _, img := range relatedImages { - imageSet[img.Ref] = struct{}{} - } - - return -} - -// GetOperatorImages returns a list of any images used to run the operator. -// Currently this pulls any images in the pod specs of operator deployments. -func (csv *ClusterServiceVersion) GetOperatorImages() (map[string]struct{}, error) { - type dep struct { - Name string - Spec v1.DeploymentSpec - } - type strategySpec struct { - Deployments []dep - } - type strategy struct { - Name string `json:"strategy"` - Spec strategySpec `json:"spec"` - } - type csvSpec struct { - Install strategy - } - - var spec csvSpec - if err := json.Unmarshal(csv.Spec, &spec); err != nil { - return nil, err - } - - // this is the only install strategy we know about - if spec.Install.Name != "deployment" { - return nil, nil - } - - images := map[string]struct{}{} - for _, d := range spec.Install.Spec.Deployments { - for _, c := range d.Spec.Template.Spec.Containers { - images[c.Image] = struct{}{} - } - for _, c := range d.Spec.Template.Spec.InitContainers { - images[c.Image] = struct{}{} - } - } - - return images, nil -} - -type Icon struct { - MediaType string `json:"mediatype"` - Base64data []byte `json:"base64data"` -} - -// GetIcons returns the icons from the ClusterServiceVersion -func (csv *ClusterServiceVersion) GetIcons() ([]Icon, error) { - var objmap map[string]*json.RawMessage - if err := json.Unmarshal(csv.Spec, &objmap); err != nil { - return nil, err - } - - rawValue, ok := objmap[icon] - if !ok || rawValue == nil { - return nil, nil - } - var icons []Icon - if err := json.Unmarshal(*rawValue, &icons); err != nil { - return nil, err - } - return icons, nil -} - -// GetDescription returns the description from the ClusterServiceVersion -// If not defined, the function returns an empty string. -func (csv *ClusterServiceVersion) GetDescription() (string, error) { - var objmap map[string]*json.RawMessage - - if err := json.Unmarshal(csv.Spec, &objmap); err != nil { - return "", err - } - - rawValue, ok := objmap[description] - if !ok || rawValue == nil { - return "", nil - } - - var desc string - if err := json.Unmarshal(*rawValue, &desc); err != nil { - return "", err - } - - return desc, nil -} - -// GetSubstitutesFor returns the name of the ClusterServiceVersion object that -// is substituted by this ClusterServiceVersion object. -// -// If not defined, the function returns an empty string. -func (csv *ClusterServiceVersion) GetSubstitutesFor() string { - substitutesFor, ok := csv.Annotations[substitutesForAnnotationKey] - if !ok { - return "" - } - return substitutesFor -} - -func (csv *ClusterServiceVersion) UnmarshalJSON(data []byte) error { - - if err := csv.UnmarshalSpec(data); err != nil { - return err - } - if err := csv.UnmarshalTypeMeta(data); err != nil { - return err - } - if err := csv.UnmarshalObjectMeta(data); err != nil { - return err - } - - return nil -} - -func (csv *ClusterServiceVersion) UnmarshalSpec(data []byte) error { - var m map[string]json.RawMessage - if err := json.Unmarshal(data, &m); err != nil { - return errors.New(prettyunmarshaler.NewJSONUnmarshalError(data, err).Pretty()) - } - - spec, ok := m["spec"] - if !ok { - return nil - } - csv.Spec = spec - - return nil -} - -func (csv *ClusterServiceVersion) UnmarshalTypeMeta(data []byte) error { - var t metav1.TypeMeta - if err := json.Unmarshal(data, &t); err != nil { - return errors.New(prettyunmarshaler.NewJSONUnmarshalError(data, err).Pretty()) - } - csv.TypeMeta = t - - return nil -} - -func (csv *ClusterServiceVersion) UnmarshalObjectMeta(data []byte) error { - var o struct { - Metadata metav1.ObjectMeta `json:"metadata"` - } - if err := json.Unmarshal(data, &o); err != nil { - return errors.New(prettyunmarshaler.NewJSONUnmarshalError(data, err).Pretty()) - } - - csv.ObjectMeta = o.Metadata - - return nil -} diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/registry/decode.go b/vendor/github.com/operator-framework/operator-registry/pkg/registry/decode.go deleted file mode 100644 index 0a9587d09..000000000 --- a/vendor/github.com/operator-framework/operator-registry/pkg/registry/decode.go +++ /dev/null @@ -1,69 +0,0 @@ -package registry - -import ( - "errors" - "fmt" - "io" - "io/fs" - - "github.com/sirupsen/logrus" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/util/yaml" -) - -// DecodeUnstructured decodes a raw stream into a an -// unstructured.Unstructured instance. -func DecodeUnstructured(reader io.Reader) (obj *unstructured.Unstructured, err error) { - decoder := yaml.NewYAMLOrJSONDecoder(reader, 30) - - t := &unstructured.Unstructured{} - if err = decoder.Decode(t); err != nil { - return - } - - obj = t - return -} - -// DecodePackageManifest decodes a raw stream into a a PackageManifest instance. -// If a package name is empty we consider the object invalid! -func DecodePackageManifest(reader io.Reader) (manifest *PackageManifest, err error) { - decoder := yaml.NewYAMLOrJSONDecoder(reader, 30) - - obj := &PackageManifest{} - if decodeErr := decoder.Decode(obj); decodeErr != nil { - err = fmt.Errorf("could not decode contents into package manifest - %v", decodeErr) - return - } - - if obj.PackageName == "" { - err = errors.New("name of package (packageName) is missing") - return - } - - manifest = obj - return -} - -func decodeFileFS(root fs.FS, path string, into interface{}, log *logrus.Entry) error { - fileReader, err := root.Open(path) - if err != nil { - return fmt.Errorf("unable to read file %s: %s", path, err) - } - defer fileReader.Close() - - decoder := yaml.NewYAMLOrJSONDecoder(fileReader, 30) - - errRet := decoder.Decode(into) - - if errRet == nil { - // Look for and warn about extra documents - extraDocument := &map[string]interface{}{} - err = decoder.Decode(extraDocument) - if err == nil && log != nil { - log.Warnf("found more than one document inside %s, using only the first one", path) - } - } - - return errRet -} diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/registry/directoryGraphLoader.go b/vendor/github.com/operator-framework/operator-registry/pkg/registry/directoryGraphLoader.go deleted file mode 100644 index a899f01e0..000000000 --- a/vendor/github.com/operator-framework/operator-registry/pkg/registry/directoryGraphLoader.go +++ /dev/null @@ -1,207 +0,0 @@ -package registry - -import ( - "fmt" - "os" - "path" - "path/filepath" - "sort" - - "github.com/blang/semver/v4" - "github.com/onsi/gomega/gstruct/errors" -) - -type DirGraphLoader struct { - PackageDir string - CsvNameAndReplaceMap map[string]csvReplaces - SortedCSVs csvs // only contains bundles with version field which will be considered for skip range. -} - -type csvReplaces struct { - replaces []string - skipRange semver.Range -} - -type csv struct { - name string - version semver.Version -} - -type csvs []csv - -func (c csvs) Len() int { return len(c) } -func (c csvs) Less(i, j int) bool { return c[i].version.LT(c[j].version) } -func (c csvs) Swap(i, j int) { c[i], c[j] = c[j], c[i] } - -// NewPackageGraphLoaderFromDir takes the root directory of the package in the file system. -func NewPackageGraphLoaderFromDir(packageDir string) (*DirGraphLoader, error) { - _, err := os.ReadDir(packageDir) - if err != nil { - return nil, fmt.Errorf("error reading from %s directory, %v", packageDir, err) - } - - loader := DirGraphLoader{ - PackageDir: packageDir, - } - - return &loader, nil -} - -// Generate returns Package graph by parsing through package directory assuming all bundles in the package exist. -func (g *DirGraphLoader) Generate() (*Package, error) { - err := g.loadBundleCsvPathMap() - if err != nil { - return nil, fmt.Errorf("error geting CSVs from bundles in the package directory, %v", err) - } - - pkg, err := g.parsePackageYAMLFile() - if err != nil { - return nil, fmt.Errorf("error parsing package.yaml file in the package root directory, %v", err) - } - - for chName, ch := range pkg.Channels { - pkg.Channels[chName] = Channel{ - Head: ch.Head, - Nodes: *g.getChannelNodes(ch.Head.CsvName), - } - } - return pkg, nil -} - -// loadBundleCsvPathMap loads the CsvNameAndReplaceMap and SortedCSVs in the Package Struct. -func (g *DirGraphLoader) loadBundleCsvPathMap() error { - bundleDirs, err := os.ReadDir(g.PackageDir) - if err != nil { - return fmt.Errorf("error reading from %s directory, %v", g.PackageDir, err) - } - CsvNameAndReplaceMap := make(map[string]csvReplaces) - for _, bundlePath := range bundleDirs { - if bundlePath.IsDir() { - csvStruct, err := ReadCSVFromBundleDirectory(filepath.Join(g.PackageDir, bundlePath.Name())) - if err != nil { - return err - } - - // Best effort to get Skips, Replace, and SkipRange - srString := csvStruct.GetSkipRange() - sr, _ := semver.ParseRange(srString) - - var replaceStrings []string - rs, err := csvStruct.GetSkips() - if err == nil && rs != nil { - replaceStrings = rs - } - - r, err := csvStruct.GetReplaces() - if err == nil && r != "" { - replaceStrings = append(replaceStrings, r) - } - - CsvNameAndReplaceMap[csvStruct.GetName()] = csvReplaces{ - replaces: replaceStrings, - skipRange: sr, - } - - version, err := csvStruct.GetVersion() - if err == nil && version != "" { - v, err := semver.Parse(version) - if err == nil { - g.SortedCSVs = append(g.SortedCSVs, csv{name: csvStruct.GetName(), version: v}) - } - } - } - } - - g.CsvNameAndReplaceMap = CsvNameAndReplaceMap - sort.Sort(g.SortedCSVs) - return nil -} - -// getChannelNodes follows the head of the channel csv through all replaces to fill the nodes until the tail of the -// channel which will not replace anything. -func (g *DirGraphLoader) getChannelNodes(channelHeadCsv string) *map[BundleKey]map[BundleKey]struct{} { - nodes := make(map[BundleKey]map[BundleKey]struct{}) - remainingCSVsInChannel := make(map[BundleKey]struct{}) - - remainingCSVsInChannel[BundleKey{CsvName: channelHeadCsv}] = struct{}{} - for _, csv := range g.CsvNameAndReplaceMap[channelHeadCsv].replaces { - remainingCSVsInChannel[BundleKey{CsvName: csv}] = struct{}{} - } - - // Iterate through remainingCSVsInChannel and add replaces of each encountered CSVs if not already in nodes. - // Loop only exit after all remaining csvs are visited/deleted. - for len(remainingCSVsInChannel) > 0 { - for bk, _ := range remainingCSVsInChannel { - if _, ok := nodes[BundleKey{CsvName: bk.CsvName}]; !ok { - nodes[BundleKey{CsvName: bk.CsvName}] = func() map[BundleKey]struct{} { - subNode := make(map[BundleKey]struct{}) - for _, csv := range g.CsvNameAndReplaceMap[bk.CsvName].replaces { - subNode[BundleKey{CsvName: csv}] = struct{}{} - } - return subNode - }() - for _, csv := range g.CsvNameAndReplaceMap[bk.CsvName].replaces { - if _, ok := nodes[BundleKey{CsvName: csv}]; !ok { - remainingCSVsInChannel[BundleKey{CsvName: csv}] = struct{}{} - } - } - } - delete(remainingCSVsInChannel, bk) - } - } - return &nodes -} - -// parsePackageYAMLFile parses the *.package.yaml file and fills the information in Package including name, -// defaultchannel, and head of all Channels. It returns parsing error if any. -func (g *DirGraphLoader) parsePackageYAMLFile() (*Package, error) { - files, err := os.ReadDir(g.PackageDir) - if err != nil { - return nil, fmt.Errorf("error reading bundle parent directory, %v", err) - } - - var ymlFiles []string - for _, f := range files { - if !f.IsDir() { - ymlFiles = append(ymlFiles, f.Name()) - } - } - - errs := errors.AggregateError{} - - for _, ymlFile := range ymlFiles { - ymlFile = path.Join(g.PackageDir, ymlFile) - ymlReader, err := os.Open(ymlFile) - if err != nil { - errs = append(errs, fmt.Errorf("error opening %s file, %v", ymlFile, err)) - continue - } - - pkgManifest, err := DecodePackageManifest(ymlReader) - if err != nil { - errs = append(errs, fmt.Errorf("error parsing %s as package.yaml file, %v", ymlFile, err)) - continue - } - return convertFromPackageManifest(*pkgManifest), nil - } - - return nil, fmt.Errorf("valid PackageManifest YAML file not found in %s, %s", g.PackageDir, errs.Error()) -} - -func convertFromPackageManifest(pkgManifest PackageManifest) *Package { - pkgChannels := make(map[string]Channel) - for _, channel := range pkgManifest.Channels { - pkgChannels[channel.Name] = Channel{ - Head: BundleKey{ - CsvName: channel.CurrentCSVName, - }, - } - } - - return &Package{ - Name: pkgManifest.PackageName, - DefaultChannel: pkgManifest.GetDefaultChannel(), - Channels: pkgChannels, - } - -} diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/registry/empty.go b/vendor/github.com/operator-framework/operator-registry/pkg/registry/empty.go deleted file mode 100644 index 936f39cca..000000000 --- a/vendor/github.com/operator-framework/operator-registry/pkg/registry/empty.go +++ /dev/null @@ -1,123 +0,0 @@ -package registry - -import ( - "context" - "errors" - - "github.com/operator-framework/operator-registry/pkg/api" -) - -// EmptyQuery acts as a "zero value" implementation of the Query interface. -// -// EmptyQuery can be used as a substitute for any operation dependent on Query. -type EmptyQuery struct{} - -func (EmptyQuery) ListTables(ctx context.Context) ([]string, error) { - return nil, errors.New("empty querier: cannot list tables") -} - -func (EmptyQuery) ListPackages(ctx context.Context) ([]string, error) { - return nil, errors.New("empty querier: cannot list packages") -} - -func (EmptyQuery) GetPackage(ctx context.Context, name string) (*PackageManifest, error) { - return nil, errors.New("empty querier: cannot get package") -} - -func (EmptyQuery) GetDefaultPackage(ctx context.Context, name string) (string, error) { - return "", errors.New("empty querier: cannot get default package") -} - -func (EmptyQuery) GetChannelEntriesFromPackage(ctx context.Context, packageName string) ([]ChannelEntryAnnotated, error) { - return nil, errors.New("empty querier: cannot get all channel entries for package") -} - -func (EmptyQuery) GetBundle(ctx context.Context, pkgName, channelName, csvName string) (*api.Bundle, error) { - return nil, errors.New("empty querier: cannot get bundle") -} - -func (EmptyQuery) GetBundleForChannel(ctx context.Context, pkgName string, channelName string) (*api.Bundle, error) { - return nil, errors.New("empty querier: cannot get bundle for channel") -} - -func (EmptyQuery) GetChannelEntriesThatReplace(ctx context.Context, name string) (entries []*ChannelEntry, err error) { - return nil, errors.New("empty querier: cannot get channel entries that replace") -} - -func (EmptyQuery) GetBundleThatReplaces(ctx context.Context, name, pkgName, channelName string) (*api.Bundle, error) { - return nil, errors.New("empty querier: cannot get bundle that replaces") -} - -func (EmptyQuery) GetChannelEntriesThatProvide(ctx context.Context, group, version, kind string) (entries []*ChannelEntry, err error) { - return nil, errors.New("empty querier: cannot get channel entries that provide") -} - -func (EmptyQuery) GetLatestChannelEntriesThatProvide(ctx context.Context, group, version, kind string) (entries []*ChannelEntry, err error) { - return nil, errors.New("empty querier: cannot get latest channel entries that provide") -} - -func (EmptyQuery) GetBundleThatProvides(ctx context.Context, group, version, kind string) (*api.Bundle, error) { - return nil, errors.New("empty querier: cannot get bundle that provides") -} - -func (EmptyQuery) ListImages(ctx context.Context) ([]string, error) { - return nil, errors.New("empty querier: cannot get image list") -} - -func (EmptyQuery) GetImagesForBundle(ctx context.Context, bundleName string) ([]string, error) { - return nil, errors.New("empty querier: cannot get image list") -} - -func (EmptyQuery) GetApisForEntry(ctx context.Context, entryId int64) (provided []*api.GroupVersionKind, required []*api.GroupVersionKind, err error) { - return nil, nil, errors.New("empty querier: cannot apis") -} - -func (EmptyQuery) GetBundleVersion(ctx context.Context, image string) (string, error) { - return "", errors.New("empty querier: cannot get version") -} - -func (EmptyQuery) GetBundlePathsForPackage(ctx context.Context, pkgName string) ([]string, error) { - return nil, errors.New("empty querier: cannot get images") -} - -func (EmptyQuery) GetBundlesForPackage(ctx context.Context, pkgName string) (map[BundleKey]struct{}, error) { - return nil, errors.New("empty querier: cannot get bundles") -} - -func (EmptyQuery) GetDefaultChannelForPackage(ctx context.Context, pkgName string) (string, error) { - return "", errors.New("empty querier: cannot get default channel") -} - -func (EmptyQuery) ListChannels(ctx context.Context, pkgName string) ([]string, error) { - return nil, errors.New("empty querier: cannot list channels") -} - -func (EmptyQuery) GetCurrentCSVNameForChannel(ctx context.Context, pkgName, channel string) (string, error) { - return "", errors.New("empty querier: cannot get csv name for package and channel") -} - -func (EmptyQuery) ListBundles(ctx context.Context) ([]*api.Bundle, error) { - return nil, errors.New("empty querier: cannot list bundles") -} - -func (EmptyQuery) SendBundles(ctx context.Context, stream BundleSender) error { - return errors.New("empty querier: cannot stream bundles") -} - -func (EmptyQuery) GetDependenciesForBundle(ctx context.Context, name, version, path string) (dependencies []*api.Dependency, err error) { - return nil, errors.New("empty querier: cannot get dependencies for bundle") -} - -func (EmptyQuery) GetBundlePathIfExists(ctx context.Context, csvName string) (bundlePath string, err error) { - return "", errors.New("empty querier: cannot get bundle path for bundle") -} - -func (EmptyQuery) ListRegistryBundles(ctx context.Context) ([]*Bundle, error) { - return nil, errors.New("empty querier: cannot list registry bundles") -} - -var _ Query = &EmptyQuery{} - -func NewEmptyQuerier() *EmptyQuery { - return &EmptyQuery{} -} diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/registry/graph.go b/vendor/github.com/operator-framework/operator-registry/pkg/registry/graph.go deleted file mode 100644 index 32185f189..000000000 --- a/vendor/github.com/operator-framework/operator-registry/pkg/registry/graph.go +++ /dev/null @@ -1,79 +0,0 @@ -package registry - -import ( - "fmt" - "strings" -) - -type Package struct { - Name string - DefaultChannel string - Channels map[string]Channel -} - -func (p *Package) String() string { - var b strings.Builder - b.WriteString("name: ") - b.WriteString(p.Name) - b.WriteString("\ndefault channel: ") - b.WriteString(p.DefaultChannel) - b.WriteString("\nchannels:\n") - - for n, c := range p.Channels { - b.WriteString(n) - b.WriteString("\n") - b.WriteString(c.String()) - } - - return b.String() -} - -type Channel struct { - Head BundleKey - Nodes map[BundleKey]map[BundleKey]struct{} -} - -func (c *Channel) String() string { - var b strings.Builder - for node, _ := range c.Nodes { - b.WriteString(node.String()) - b.WriteString("\n") - } - - return b.String() -} - -type BundleKey struct { - BundlePath string - Version string //semver string - CsvName string -} - -func (b *BundleKey) IsEmpty() bool { - return b.BundlePath == "" && b.Version == "" && b.CsvName == "" -} - -func (b *BundleKey) String() string { - return fmt.Sprintf("%s %s %s", b.CsvName, b.Version, b.BundlePath) -} - -func (p *Package) HasChannel(channel string) bool { - if p.Channels == nil { - return false - } - - _, found := p.Channels[channel] - return found -} - -func (p *Package) HasCsv(csv string) bool { - for _, channelGraph := range p.Channels { - for node := range channelGraph.Nodes { - if node.CsvName == csv { - return true - } - } - } - - return false -} diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/registry/imageinput.go b/vendor/github.com/operator-framework/operator-registry/pkg/registry/imageinput.go deleted file mode 100644 index 69fe210ef..000000000 --- a/vendor/github.com/operator-framework/operator-registry/pkg/registry/imageinput.go +++ /dev/null @@ -1,30 +0,0 @@ -package registry - -import ( - "os" - "path/filepath" - - "github.com/operator-framework/operator-registry/pkg/image" - "github.com/sirupsen/logrus" -) - -type ImageInput struct { - to image.Reference - from string - Bundle *Bundle -} - -func NewImageInput(to image.Reference, from string) (*ImageInput, error) { - parser := newBundleParser(logrus.WithFields(logrus.Fields{"with": from, "file": filepath.Join(from, "metadata"), "load": "annotations"})) - bundle, err := parser.Parse(os.DirFS(from)) - if err != nil { - return nil, err - } - bundle.BundleImage = to.String() - - return &ImageInput{ - to: to, - from: from, - Bundle: bundle, - }, nil -} diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/registry/interface.go b/vendor/github.com/operator-framework/operator-registry/pkg/registry/interface.go deleted file mode 100644 index 93df40c61..000000000 --- a/vendor/github.com/operator-framework/operator-registry/pkg/registry/interface.go +++ /dev/null @@ -1,110 +0,0 @@ -package registry - -import ( - "context" - - "github.com/operator-framework/operator-registry/pkg/api" -) - -type Load interface { - AddOperatorBundle(bundle *Bundle) error - AddBundleSemver(graph *Package, bundle *Bundle) error - AddPackageChannels(manifest PackageManifest) error - AddBundlePackageChannels(manifest PackageManifest, bundle *Bundle) error - RemovePackage(packageName string) error - RemoveStrandedBundles() error - DeprecateBundle(path string) error - ClearNonHeadBundles() error -} - -type BundleSender interface { - Send(*api.Bundle) error -} - -type GRPCQuery interface { - // List all available package names in the index - ListPackages(ctx context.Context) ([]string, error) - - // Sends all available bundles in the index - SendBundles(ctx context.Context, stream BundleSender) error - - // List all available bundles in the index - ListBundles(ctx context.Context) (bundles []*api.Bundle, err error) - - // Get a package by name from the index - GetPackage(ctx context.Context, name string) (*PackageManifest, error) - - // Get a bundle by its package name, channel name and csv name from the index - GetBundle(ctx context.Context, pkgName, channelName, csvName string) (*api.Bundle, error) - - // Get the bundle in the specified package at the head of the - // specified channel. DEPRECATED. Returned bundles may have - // only the "name" and "csvJson" fields populated in order to - // support legacy usage. - GetBundleForChannel(ctx context.Context, pkgName string, channelName string) (*api.Bundle, error) - - // Get all channel entries that say they replace this one - GetChannelEntriesThatReplace(ctx context.Context, name string) (entries []*ChannelEntry, err error) - - // Get the bundle in a package/channel that replace this one - GetBundleThatReplaces(ctx context.Context, name, pkgName, channelName string) (*api.Bundle, error) - - // Get all channel entries that provide an api - GetChannelEntriesThatProvide(ctx context.Context, group, version, kind string) (entries []*ChannelEntry, err error) - - // Get latest channel entries that provide an api - GetLatestChannelEntriesThatProvide(ctx context.Context, group, version, kind string) (entries []*ChannelEntry, err error) - - // Get the the latest bundle that provides the API in a default channel - GetBundleThatProvides(ctx context.Context, group, version, kind string) (*api.Bundle, error) -} - -type Query interface { - GRPCQuery - - ListTables(ctx context.Context) ([]string, error) - GetDefaultPackage(ctx context.Context, name string) (string, error) - GetChannelEntriesFromPackage(ctx context.Context, packageName string) ([]ChannelEntryAnnotated, error) - // List all images in the database - ListImages(ctx context.Context) ([]string, error) - // List all images for a particular bundle - GetImagesForBundle(ctx context.Context, bundleName string) ([]string, error) - // Get Provided and Required APIs for a particular bundle - GetApisForEntry(ctx context.Context, entryID int64) (provided []*api.GroupVersionKind, required []*api.GroupVersionKind, err error) - // Get Version of a Bundle Image - GetBundleVersion(ctx context.Context, image string) (string, error) - // List Images for Package - GetBundlePathsForPackage(ctx context.Context, pkgName string) ([]string, error) - // List Bundles for Package - GetBundlesForPackage(ctx context.Context, pkgName string) (map[BundleKey]struct{}, error) - // Get DefaultChannel for Package - GetDefaultChannelForPackage(ctx context.Context, pkgName string) (string, error) - // List channels for package - ListChannels(ctx context.Context, pkgName string) ([]string, error) - // Get CurrentCSV name for channel and package - GetCurrentCSVNameForChannel(ctx context.Context, pkgName, channel string) (string, error) - // Get the list of dependencies for a bundle - GetDependenciesForBundle(ctx context.Context, name, version, path string) (dependencies []*api.Dependency, err error) - // Get the bundle path if it exists - GetBundlePathIfExists(ctx context.Context, csvName string) (string, error) - // ListRegistryBundles returns a set of registry bundles. - ListRegistryBundles(ctx context.Context) ([]*Bundle, error) -} - -//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . GraphLoader - -// GraphLoader generates a graph -// GraphLoader supports multiple different loading schemes -// GraphLoader from SQL, GraphLoader from old format (filesystem), GraphLoader from SQL + input bundles -type GraphLoader interface { - Generate(packageName string) (*Package, error) -} - -// RegistryPopulator populates a registry. -type RegistryPopulator interface { - Populate() error -} - -type HeadOverwriter interface { - RemoveOverwrittenChannelHead(pkg, bundle string) error -} diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/registry/parse.go b/vendor/github.com/operator-framework/operator-registry/pkg/registry/parse.go deleted file mode 100644 index 4b13ef767..000000000 --- a/vendor/github.com/operator-framework/operator-registry/pkg/registry/parse.go +++ /dev/null @@ -1,251 +0,0 @@ -package registry - -import ( - "encoding/json" - "fmt" - "io/fs" - "strings" - - operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1" - "github.com/sirupsen/logrus" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" -) - -type bundleParser struct { - log *logrus.Entry -} - -func newBundleParser(log *logrus.Entry) *bundleParser { - return &bundleParser{ - log: log, - } -} - -// Parse parses the given FS into a Bundle. -func (b *bundleParser) Parse(root fs.FS) (*Bundle, error) { - if root == nil { - return nil, fmt.Errorf("filesystem is nil") - } - - bundle := &Bundle{} - manifests, err := fs.Sub(root, "manifests") - if err != nil { - return nil, fmt.Errorf("error opening manifests directory: %s", err) - } - if err := b.addManifests(manifests, bundle); err != nil { - return nil, err - } - - metadata, err := fs.Sub(root, "metadata") - if err != nil { - return nil, fmt.Errorf("error opening metadata directory: %s", err) - } - if err := b.addMetadata(metadata, bundle); err != nil { - return nil, err - } - - derived, err := b.derivedProperties(bundle) - if err != nil { - return nil, fmt.Errorf("failed to derive properties: %s", err) - } - - bundle.Properties = propertySet(append(bundle.Properties, derived...)) - - return bundle, nil -} - -// addManifests adds the result of parsing the manifests directory to a bundle. -func (b *bundleParser) addManifests(manifests fs.FS, bundle *Bundle) error { - files, err := fs.ReadDir(manifests, ".") - if err != nil { - return err - } - - var csvFound bool - for _, f := range files { - if f.IsDir() { - continue - } - - name := f.Name() - if strings.HasPrefix(name, ".") { - continue - } - - obj := &unstructured.Unstructured{} - if err = decodeFileFS(manifests, name, obj, b.log); err != nil { - b.log.Warnf("failed to decode: %s", err) - continue - } - - // Only include the first CSV we find in the - if obj.GetKind() == operatorsv1alpha1.ClusterServiceVersionKind { - if csvFound { - continue - } - csvFound = true - } - - if obj.Object != nil { - bundle.Add(obj) - } - } - - if bundle.Size() == 0 { - return fmt.Errorf("no bundle objects found") - } - - csv, err := bundle.ClusterServiceVersion() - if err != nil { - return err - } - if csv == nil { - return fmt.Errorf("no csv in bundle") - } - - bundle.Name = csv.GetName() - if err := bundle.AllProvidedAPIsInBundle(); err != nil { - return fmt.Errorf("error checking provided apis in bundle %s: %s", bundle.Name, err) - } - - return nil -} - -// addManifests adds the result of parsing the metadata directory to a bundle. -func (b *bundleParser) addMetadata(metadata fs.FS, bundle *Bundle) error { - files, err := fs.ReadDir(metadata, ".") - if err != nil { - return err - } - - var ( - af *AnnotationsFile - df *DependenciesFile - pf *PropertiesFile - ) - for _, f := range files { - name := f.Name() - if af == nil { - decoded := AnnotationsFile{} - if err = decodeFileFS(metadata, name, &decoded, b.log); err == nil { - if decoded != (AnnotationsFile{}) { - af = &decoded - } - } - } - if df == nil { - decoded := DependenciesFile{} - if err = decodeFileFS(metadata, name, &decoded, b.log); err == nil { - if len(decoded.Dependencies) > 0 { - df = &decoded - } - } - } - if pf == nil { - decoded := PropertiesFile{} - if err = decodeFileFS(metadata, name, &decoded, b.log); err == nil { - if len(decoded.Properties) > 0 { - pf = &decoded - } - } - } - } - - if af != nil { - bundle.Annotations = &af.Annotations - bundle.Package = af.Annotations.PackageName - bundle.Channels = af.GetChannels() - } else { - return fmt.Errorf("Could not find annotations file") - } - - if df != nil { - bundle.Dependencies = append(bundle.Dependencies, df.GetDependencies()...) - } else { - b.log.Info("Could not find optional dependencies file") - } - - if pf != nil { - bundle.Properties = append(bundle.Properties, pf.Properties...) - } else { - b.log.Info("Could not find optional properties file") - } - - return nil -} - -func (b *bundleParser) derivedProperties(bundle *Bundle) ([]Property, error) { - // Add properties from CSV annotations - csv, err := bundle.ClusterServiceVersion() - if err != nil { - return nil, fmt.Errorf("error getting csv: %s", err) - } - if csv == nil { - return nil, fmt.Errorf("bundle missing csv") - } - - var derived []Property - if len(csv.GetAnnotations()) > 0 { - properties, ok := csv.GetAnnotations()[PropertyKey] - if ok { - if err := json.Unmarshal([]byte(properties), &derived); err != nil { - b.log.Warnf("failed to unmarshal csv annotation properties: %s", err) - } - } - } - - if bundle.Annotations != nil && bundle.Annotations.PackageName != "" { - pkg := bundle.Annotations.PackageName - version, err := bundle.Version() - if err != nil { - return nil, err - } - - value, err := json.Marshal(PackageProperty{ - PackageName: pkg, - Version: version, - }) - if err != nil { - return nil, fmt.Errorf("failed to marshal package property: %s", err) - } - - // Annotations file takes precedent over CSV annotations - derived = append([]Property{{Type: PackageType, Value: value}}, derived...) - } - - providedAPIs, err := bundle.ProvidedAPIs() - if err != nil { - return nil, fmt.Errorf("error getting provided apis: %s", err) - } - - for api := range providedAPIs { - value, err := json.Marshal(GVKProperty{ - Group: api.Group, - Kind: api.Kind, - Version: api.Version, - }) - if err != nil { - return nil, fmt.Errorf("failed to marshal gvk property: %s", err) - } - derived = append(derived, Property{Type: GVKType, Value: value}) - } - - return propertySet(derived), nil -} - -// propertySet returns the deduplicated set of a property list. -func propertySet(properties []Property) []Property { - var ( - set []Property - visited = map[string]struct{}{} - ) - for _, p := range properties { - if _, ok := visited[p.String()]; ok { - continue - } - visited[p.String()] = struct{}{} - set = append(set, p) - } - - return set -} diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/registry/populator.go b/vendor/github.com/operator-framework/operator-registry/pkg/registry/populator.go deleted file mode 100644 index 730d27fb9..000000000 --- a/vendor/github.com/operator-framework/operator-registry/pkg/registry/populator.go +++ /dev/null @@ -1,464 +0,0 @@ -package registry - -import ( - "context" - "errors" - "fmt" - "os" - "sort" - - "github.com/blang/semver/v4" - utilerrors "k8s.io/apimachinery/pkg/util/errors" - "k8s.io/apimachinery/pkg/util/yaml" - - "github.com/operator-framework/operator-registry/pkg/image" - libsemver "github.com/operator-framework/operator-registry/pkg/lib/semver" -) - -type Dependencies struct { - RawMessage []map[string]interface{} `json:"dependencies" yaml:"dependencies"` -} - -// DirectoryPopulator loads an unpacked operator bundle from a directory into the database. -type DirectoryPopulator struct { - loader Load - graphLoader GraphLoader - querier Query - imageDirMap map[image.Reference]string - overwrittenImages map[string][]string -} - -func NewDirectoryPopulator(loader Load, graphLoader GraphLoader, querier Query, imageDirMap map[image.Reference]string, overwrittenImages map[string][]string) *DirectoryPopulator { - return &DirectoryPopulator{ - loader: loader, - graphLoader: graphLoader, - querier: querier, - imageDirMap: imageDirMap, - overwrittenImages: overwrittenImages, - } -} - -func (i *DirectoryPopulator) Populate(mode Mode) error { - var errs []error - imagesToAdd := make([]*ImageInput, 0) - for to, from := range i.imageDirMap { - imageInput, err := NewImageInput(to, from) - if err != nil { - errs = append(errs, err) - continue - } - - imagesToAdd = append(imagesToAdd, imageInput) - } - - if len(errs) > 0 { - return utilerrors.NewAggregate(errs) - } - - err := i.loadManifests(imagesToAdd, mode) - if err != nil { - return err - } - - return nil -} - -func (i *DirectoryPopulator) globalSanityCheck(imagesToAdd []*ImageInput) error { - overwrite := len(i.overwrittenImages) > 0 - var errs []error - images := make(map[string]struct{}) - for _, image := range imagesToAdd { - images[image.Bundle.BundleImage] = struct{}{} - } - - attemptedOverwritesPerPackage := map[string]struct{}{} - for _, image := range imagesToAdd { - validOverwrite := false - bundlePaths, err := i.querier.GetBundlePathsForPackage(context.TODO(), image.Bundle.Package) - if err != nil { - // Assume that this means that the bundle is empty - // Or that this is the first time the package is loaded. - return nil - } - for _, bundlePath := range bundlePaths { - if _, ok := images[bundlePath]; ok { - errs = append(errs, BundleImageAlreadyAddedErr{ErrorString: fmt.Sprintf("Bundle %s already exists", image.Bundle.BundleImage)}) - continue - } - } - channels, err := i.querier.ListChannels(context.TODO(), image.Bundle.Package) - if err != nil { - return err - } - - for _, channel := range channels { - bundle, err := i.querier.GetBundle(context.TODO(), image.Bundle.Package, channel, image.Bundle.Name) - if err != nil { - // Assume that if we can not find a bundle for the package, channel and or CSV Name that this is safe to add - continue - } - if bundle != nil { - if !overwrite { - // raise error that this package + channel + csv combo is already in the db - errs = append(errs, PackageVersionAlreadyAddedErr{ErrorString: "Bundle already added that provides package and csv"}) - break - } - // ensure overwrite is not in the middle of a channel (i.e. nothing replaces it) - _, err = i.querier.GetBundleThatReplaces(context.TODO(), image.Bundle.Name, image.Bundle.Package, channel) - if err != nil { - if err.Error() == fmt.Errorf("no entry found for %s %s", image.Bundle.Package, channel).Error() { - // overwrite is not replaced by any other bundle - validOverwrite = true - continue - } - errs = append(errs, err) - break - } - // This bundle is in this channel but is not the head of this channel - errs = append(errs, OverwriteErr{ErrorString: "Cannot overwrite a bundle that is not at the head of a channel using --overwrite-latest"}) - validOverwrite = false - break - } - } - if validOverwrite { - if _, ok := attemptedOverwritesPerPackage[image.Bundle.Package]; ok { - errs = append(errs, OverwriteErr{ErrorString: "Cannot overwrite more than one bundle at a time for a given package using --overwrite-latest"}) - break - } - attemptedOverwritesPerPackage[image.Bundle.Package] = struct{}{} - } - } - - if err := i.ValidateEdgeBundlePackage(imagesToAdd); err != nil { - errs = append(errs, err) - } - return utilerrors.NewAggregate(errs) -} - -func (i *DirectoryPopulator) loadManifests(imagesToAdd []*ImageInput, mode Mode) error { - // global sanity checks before insertion - if err := i.globalSanityCheck(imagesToAdd); err != nil { - return err - } - - switch mode { - case ReplacesMode: - // TODO: If this succeeds but the add fails there will be a disconnect between - // the registry and the index. Loading the bundles in a single transactions as - // described above would allow us to do the removable in that same transaction - // and ensure that rollback is possible. - - // globalSanityCheck should have verified this to be a head without anything replacing it - // and that we have a single overwrite per package - - if len(i.overwrittenImages) > 0 { - if overwriter, ok := i.loader.(HeadOverwriter); ok { - // Assume loader has some way to handle overwritten heads if HeadOverwriter isn't implemented explicitly - for pkg, imgToDelete := range i.overwrittenImages { - if len(imgToDelete) == 0 { - continue - } - // delete old head bundle and swap it with the previous real bundle in its replaces chain - if err := overwriter.RemoveOverwrittenChannelHead(pkg, imgToDelete[0]); err != nil { - return err - } - } - } - } - - return i.loadManifestsReplaces(imagesToAdd) - case SemVerMode: - for _, image := range imagesToAdd { - if err := i.loadManifestsSemver(image.Bundle, false); err != nil { - return err - } - } - case SkipPatchMode: - for _, image := range imagesToAdd { - if err := i.loadManifestsSemver(image.Bundle, true); err != nil { - return err - } - } - default: - return fmt.Errorf("Unsupported update mode") - } - - // Finally let's delete all the old bundles - if err := i.loader.ClearNonHeadBundles(); err != nil { - return fmt.Errorf("Error deleting previous bundles: %s", err) - } - - return nil -} - -var packageContextKey = "package" - -// ContextWithPackage adds a package value to a context. -func ContextWithPackage(ctx context.Context, pkg string) context.Context { - return context.WithValue(ctx, packageContextKey, pkg) -} - -// PackageFromContext returns the package value of the context if set, returns false if unset. -func PackageFromContext(ctx context.Context) (string, bool) { - pkg, ok := ctx.Value(packageContextKey).(string) - return pkg, ok -} - -func (i *DirectoryPopulator) loadManifestsReplaces(images []*ImageInput) error { - packages := map[string][]*Bundle{} - var errs []error - for _, img := range images { - // Add the bundle directly to the store - if err := i.loader.AddOperatorBundle(img.Bundle); err != nil { - errs = append(errs, err) - continue - } - - packages[img.Bundle.Package] = append(packages[img.Bundle.Package], img.Bundle) - } - - // Regenerate the upgrade graphs for each package - for pkg, bundles := range packages { - // Add any existing bundles into the mix - ctx := ContextWithPackage(context.TODO(), pkg) - existing, err := i.querier.ListRegistryBundles(ctx) - if err != nil { - errs = append(errs, err) - continue - } - - packageManifest, err := SemverPackageManifest(append(existing, bundles...)) - if err != nil { - errs = append(errs, err) - continue - } - - if err = i.loader.AddPackageChannels(*packageManifest); err != nil { - errs = append(errs, err) - } - } - - return utilerrors.NewAggregate(errs) -} - -func (i *DirectoryPopulator) loadManifestsSemver(bundle *Bundle, skippatch bool) error { - graph, err := i.graphLoader.Generate(bundle.Package) - if err != nil && !errors.Is(err, ErrPackageNotInDatabase) { - return err - } - - // add to the graph - bundleLoader := BundleGraphLoader{} - updatedGraph, err := bundleLoader.AddBundleToGraph(bundle, graph, &AnnotationsFile{Annotations: *bundle.Annotations}, skippatch) - if err != nil { - return err - } - - if err := i.loader.AddBundleSemver(updatedGraph, bundle); err != nil { - return fmt.Errorf("error loading bundle %s into db: %s", bundle.Name, err) - } - - return nil -} - -// loadOperatorBundle adds the package information to the loader's store -func (i *DirectoryPopulator) loadOperatorBundle(manifest PackageManifest, bundle *Bundle) error { - if manifest.PackageName == "" { - return nil - } - - if err := i.loader.AddBundlePackageChannels(manifest, bundle); err != nil { - return fmt.Errorf("error loading bundle %s into db: %s", bundle.Name, err) - } - - return nil -} - -type bundleVersion struct { - name string - version semver.Version - - // Keep track of the number of times we visit each version so we can tell if a head is contested - count int -} - -// compare returns a value less than one if the receiver arg is less smaller the given version, greater than one if it is larger, and zero if they are equal. -// This comparison follows typical semver precedence rules, with one addition: whenever two versions are equal with the exception of their build-ids, the build-ids are compared using prerelease precedence rules. Further, versions with no build-id are always less than versions with build-ids; e.g. 1.0.0 < 1.0.0+1. -func (b bundleVersion) compare(v bundleVersion) (int, error) { - return libsemver.BuildIdCompare(b.version, v.version) -} - -// SemverPackageManifest generates a PackageManifest from a set of bundles, determining channel heads and the default channel using semver. -// Bundles with the highest version field (according to semver) are chosen as channel heads, and the default channel is taken from the last, -// highest versioned bundle in the entire set to define it. -// The given bundles must all belong to the same package or an error is thrown. -func SemverPackageManifest(bundles []*Bundle) (*PackageManifest, error) { - heads := map[string]bundleVersion{} - - var ( - pkgName string - defaultChannel string - maxVersion bundleVersion - ) - - for _, bundle := range bundles { - if pkgName != "" && pkgName != bundle.Package { - return nil, fmt.Errorf("more than one package in input") - } - pkgName = bundle.Package - - rawVersion, err := bundle.Version() - if err != nil { - return nil, fmt.Errorf("error getting bundle %s version: %s", bundle.Name, err) - } - if rawVersion == "" { - // If a version isn't provided by the bundle, give it a dummy zero version - // The thought is that properly versioned bundles will always be non-zero - rawVersion = "0.0.0-z" - } - - version, err := semver.Parse(rawVersion) - if err != nil { - return nil, fmt.Errorf("error parsing bundle %s version %s: %s", bundle.Name, rawVersion, err) - } - current := bundleVersion{ - name: bundle.Name, - version: version, - count: 1, - } - - for _, channel := range bundle.Channels { - head, ok := heads[channel] - if !ok { - heads[channel] = current - continue - } - - if c, err := current.compare(head); err != nil { - return nil, err - } else if c < 0 { - continue - } else if c == 0 { - // We have a duplicate version, add the count - current.count += head.count - } - - // Current >= head - heads[channel] = current - } - - // Set max if bundle is greater - if c, err := current.compare(maxVersion); err != nil { - return nil, err - } else if c < 0 { - continue - } else if c == 0 { - current.count += maxVersion.count - } - - // Current >= maxVersion - maxVersion = current - if annotations := bundle.Annotations; annotations != nil && annotations.DefaultChannelName != "" { - // Take it when you can get it - defaultChannel = annotations.DefaultChannelName - } - } - - if maxVersion.count > 1 { - return nil, fmt.Errorf("more than one bundle with maximum version %s", maxVersion.version) - } - - pkg := &PackageManifest{ - PackageName: pkgName, - DefaultChannelName: defaultChannel, - } - defaultFound := len(heads) == 1 && defaultChannel == "" - for channel, head := range heads { - if head.count > 1 { - return nil, fmt.Errorf("more than one potential channel head for %s", channel) - } - if len(heads) == 1 { - // Only one possible default channel - pkg.DefaultChannelName = channel - } - defaultFound = defaultFound || channel == defaultChannel - pkg.Channels = append(pkg.Channels, PackageChannel{ - Name: channel, - CurrentCSVName: head.name, - }) - } - - if !defaultFound { - return nil, fmt.Errorf("unable to determine default channel among channel heads: %+v", heads) - } - - return pkg, nil -} - -// DecodeFile decodes the file at a path into the given interface. -func DecodeFile(path string, into interface{}) error { - if into == nil { - panic("programmer error: decode destination must be instantiated before decode") - } - - fileReader, err := os.Open(path) - if err != nil { - return fmt.Errorf("unable to read file %s: %s", path, err) - } - defer fileReader.Close() - - decoder := yaml.NewYAMLOrJSONDecoder(fileReader, 30) - - return decoder.Decode(into) -} - -// ValidateEdgeBundlePackage ensures that all bundles in the input will only skip or replace bundles in the same package. -func (i *DirectoryPopulator) ValidateEdgeBundlePackage(images []*ImageInput) error { - // track packages for encountered bundles - expectedBundlePackages := map[string]string{} - for _, b := range images { - r, err := b.Bundle.Replaces() - if err != nil { - return fmt.Errorf("failed to validate replaces for bundle %s(%s): %v", b.Bundle.Name, b.Bundle.BundleImage, err) - } - - skipped, err := b.Bundle.Skips() - if err != nil { - return fmt.Errorf("failed to validate skipped entries for bundle %s(%s): %v", b.Bundle.Name, b.Bundle.BundleImage, err) - } - - for _, bndl := range append(skipped, r, b.Bundle.Name) { - if len(bndl) == 0 { - continue - } - - if pkg, ok := expectedBundlePackages[bndl]; ok && pkg != b.Bundle.Package { - pkgs := []string{pkg, b.Bundle.Package} - sort.Strings(pkgs) - return fmt.Errorf("bundle %s must belong to exactly one package, found on: %v", bndl, pkgs) - } - expectedBundlePackages[bndl] = b.Bundle.Package - } - } - if len(expectedBundlePackages) == 0 { - return nil - } - - pkgs, err := i.querier.ListPackages(context.TODO()) - if err != nil { - return fmt.Errorf("unable to verify bundle packages: %v", err) - } - for _, pkg := range pkgs { - entries, err := i.querier.GetChannelEntriesFromPackage(context.TODO(), pkg) - if err != nil { - return fmt.Errorf("unable to verify bundles for package %v", err) - } - for _, b := range entries { - if bundlePkg, ok := expectedBundlePackages[b.BundleName]; ok && bundlePkg != b.PackageName { - return fmt.Errorf("bundle %s belongs to package %s on index, cannot be added as an edge for package %s", b.BundleName, b.PackageName, bundlePkg) - } - } - } - - return nil -} diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/registry/registry_to_model.go b/vendor/github.com/operator-framework/operator-registry/pkg/registry/registry_to_model.go deleted file mode 100644 index 431c4d1e0..000000000 --- a/vendor/github.com/operator-framework/operator-registry/pkg/registry/registry_to_model.go +++ /dev/null @@ -1,147 +0,0 @@ -package registry - -import ( - "encoding/json" - "fmt" - "sort" - - "github.com/operator-framework/api/pkg/operators" - "github.com/operator-framework/api/pkg/operators/v1alpha1" - - "github.com/operator-framework/operator-registry/alpha/property" -) - -func ObjectsAndPropertiesFromBundle(b *Bundle) ([]string, []property.Property, error) { - providedGVKs := map[property.GVK]struct{}{} - requiredGVKs := map[property.GVKRequired]struct{}{} - - var packageProvidedProperty *property.Property - var otherProps []property.Property - - for i, p := range b.Properties { - switch p.Type { - case property.TypeGVK: - var v property.GVK - if err := json.Unmarshal(p.Value, &v); err != nil { - return nil, nil, property.ParseError{Idx: i, Typ: p.Type, Err: err} - } - k := property.GVK{Group: v.Group, Kind: v.Kind, Version: v.Version} - providedGVKs[k] = struct{}{} - case property.TypePackage: - var v property.Package - if err := json.Unmarshal(p.Value, &v); err != nil { - return nil, nil, property.ParseError{Idx: i, Typ: p.Type, Err: err} - } - p := property.MustBuildPackage(v.PackageName, v.Version) - packageProvidedProperty = &p - default: - otherProps = append(otherProps, property.Property{ - Type: p.Type, - Value: p.Value, - }) - } - } - - var packageRequiredProps []property.Property - for i, p := range b.Dependencies { - switch p.Type { - case property.TypeGVK: - var v property.GVK - if err := json.Unmarshal(p.Value, &v); err != nil { - return nil, nil, property.ParseError{Idx: i, Typ: p.Type, Err: err} - } - k := property.GVKRequired{Group: v.Group, Kind: v.Kind, Version: v.Version} - requiredGVKs[k] = struct{}{} - case property.TypePackage: - var v property.Package - if err := json.Unmarshal(p.Value, &v); err != nil { - return nil, nil, property.ParseError{Idx: i, Typ: p.Type, Err: err} - } - packageRequiredProps = append(packageRequiredProps, property.MustBuildPackageRequired(v.PackageName, v.Version)) - default: - otherProps = append(otherProps, property.Property{ - Type: p.Type, - Value: p.Value, - }) - } - } - - version, err := b.Version() - if err != nil { - return nil, nil, fmt.Errorf("get version: %v", err) - } - - providedApis, err := b.ProvidedAPIs() - if err != nil { - return nil, nil, fmt.Errorf("get provided apis: %v", err) - } - - for p := range providedApis { - k := property.GVK{Group: p.Group, Kind: p.Kind, Version: p.Version} - if _, ok := providedGVKs[k]; !ok { - providedGVKs[k] = struct{}{} - } - } - requiredApis, err := b.RequiredAPIs() - if err != nil { - return nil, nil, fmt.Errorf("get required apis: %v", err) - } - for p := range requiredApis { - k := property.GVKRequired{Group: p.Group, Kind: p.Kind, Version: p.Version} - if _, ok := requiredGVKs[k]; !ok { - requiredGVKs[k] = struct{}{} - } - } - - var ( - props []property.Property - objects []string - ) - for _, obj := range b.Objects { - objData, err := json.Marshal(obj) - if err != nil { - return nil, nil, fmt.Errorf("marshal object %s/%s (%s) to json: %v", obj.GetName(), obj.GetNamespace(), obj.GroupVersionKind(), err) - } - objects = append(objects, string(objData)) - - // Make an olm.bundle.object property if there is no bundle image set. - // Otherwise, make a olm.csv.metadata property if the object is a CSV - // (and fallback to olm.bundle.object if parsing the CSV fails). - if b.BundleImage == "" { - props = append(props, property.MustBuildBundleObject(objData)) - } else if obj.GetKind() == operators.ClusterServiceVersionKind { - var csv v1alpha1.ClusterServiceVersion - if err := json.Unmarshal(objData, &csv); err != nil { - props = append(props, property.MustBuildBundleObject(objData)) - } else { - props = append(props, property.MustBuildCSVMetadata(csv)) - } - } - } - - if packageProvidedProperty == nil { - p := property.MustBuildPackage(b.Package, version) - packageProvidedProperty = &p - } - props = append(props, *packageProvidedProperty) - - for p := range providedGVKs { - props = append(props, property.MustBuildGVK(p.Group, p.Version, p.Kind)) - } - - for p := range requiredGVKs { - props = append(props, property.MustBuildGVKRequired(p.Group, p.Version, p.Kind)) - } - - props = append(props, packageRequiredProps...) - props = append(props, otherProps...) - - sort.Slice(props, func(i, j int) bool { - if props[i].Type != props[j].Type { - return props[i].Type < props[j].Type - } - return string(props[i].Value) < string(props[j].Value) - }) - - return objects, props, nil -} diff --git a/vendor/github.com/operator-framework/operator-registry/pkg/registry/types.go b/vendor/github.com/operator-framework/operator-registry/pkg/registry/types.go deleted file mode 100644 index 3a5ab6293..000000000 --- a/vendor/github.com/operator-framework/operator-registry/pkg/registry/types.go +++ /dev/null @@ -1,418 +0,0 @@ -package registry - -import ( - "encoding/json" - "errors" - "fmt" - "sort" - "strings" - - "github.com/blang/semver/v4" - "github.com/operator-framework/api/pkg/constraints" -) - -var ( - // ErrPackageNotInDatabase is an error that describes a package not found error when querying the registry - ErrPackageNotInDatabase = errors.New("Package not in database") - - // ErrBundleImageNotInDatabase is an error that describes a bundle image not found when querying the registry - ErrBundleImageNotInDatabase = errors.New("Bundle Image not in database") - - // ErrRemovingDefaultChannelDuringDeprecation is an error that describes a bundle deprecation causing the deletion - // of the default channel - ErrRemovingDefaultChannelDuringDeprecation = errors.New("Bundle deprecation causing default channel removal") -) - -// BundleImageAlreadyAddedErr is an error that describes a bundle is already added -type BundleImageAlreadyAddedErr struct { - ErrorString string -} - -func (e BundleImageAlreadyAddedErr) Error() string { - return e.ErrorString -} - -// PackageVersionAlreadyAddedErr is an error that describes that a bundle that is already in the databse that provides this package and version -type PackageVersionAlreadyAddedErr struct { - ErrorString string -} - -func (e PackageVersionAlreadyAddedErr) Error() string { - return e.ErrorString -} - -// OverwritesErr is an error that describes that an error with the add request with --force enabled. -type OverwriteErr struct { - ErrorString string -} - -func (e OverwriteErr) Error() string { - return e.ErrorString -} - -const ( - GVKType = "olm.gvk" - PackageType = "olm.package" - DeprecatedType = "olm.deprecated" - LabelType = "olm.label" - PropertyKey = "olm.properties" - ConstraintType = "olm.constraint" -) - -// APIKey stores GroupVersionKind for use as map keys -type APIKey struct { - Group string - Version string - Kind string - Plural string -} - -func (k APIKey) String() string { - return fmt.Sprintf("%s/%s/%s (%s)", k.Group, k.Version, k.Kind, k.Plural) -} - -// DefinitionKey represents the metadata for either an APIservice or a CRD from a CSV spec -type DefinitionKey struct { - Group string `json:"group"` - Kind string `json:"kind"` - Name string `json:"name"` - Version string `json:"version"` -} - -type Deprecation struct { - Message string `json:"message,omitempty" yaml:"message,omitempty"` -} - -// PackageManifest holds information about a package, which is a reference to one (or more) -// channels under a single package. -type PackageManifest struct { - // PackageName is the name of the overall package, ala `etcd`. - PackageName string `json:"packageName" yaml:"packageName"` - - // Channels are the declared channels for the package, ala `stable` or `alpha`. - Channels []PackageChannel `json:"channels" yaml:"channels"` - - // DefaultChannelName is, if specified, the name of the default channel for the package. The - // default channel will be installed if no other channel is explicitly given. If the package - // has a single channel, then that channel is implicitly the default. - DefaultChannelName string `json:"defaultChannel" yaml:"defaultChannel"` - Deprecation *Deprecation `json:"deprecation,omitempty" yaml:"deprecation,omitempty"` -} - -// GetDefaultChannel gets the default channel or returns the only one if there's only one. returns empty string if it -// can't determine the default -func (m PackageManifest) GetDefaultChannel() string { - if m.DefaultChannelName != "" { - return m.DefaultChannelName - } - if len(m.Channels) == 1 { - return m.Channels[0].Name - } - return "" -} - -// PackageChannel defines a single channel under a package, pointing to a version of that -// package. -type PackageChannel struct { - // Name is the name of the channel, e.g. `alpha` or `stable` - Name string `json:"name" yaml:"name"` - - // CurrentCSVName defines a reference to the CSV holding the version of this package currently - // for the channel. - CurrentCSVName string `json:"currentCSV" yaml:"currentCSV"` - Deprecation *Deprecation `json:"deprecation,omitempty" yaml:"deprecation,omitempty"` -} - -// IsDefaultChannel returns true if the PackageChennel is the default for the PackageManifest -func (pc PackageChannel) IsDefaultChannel(pm PackageManifest) bool { - return pc.Name == pm.DefaultChannelName || len(pm.Channels) == 1 -} - -// ChannelEntry is a denormalized node in a channel graph -type ChannelEntry struct { - PackageName string - ChannelName string - BundleName string - Replaces string -} - -// ChannelEntryAnnotated is a denormalized node in a channel graph annotated with additional entry level info -type ChannelEntryAnnotated struct { - PackageName string - ChannelName string - BundleName string - BundlePath string - Version string - Replaces string - ReplacesVersion string - ReplacesBundlePath string -} - -// AnnotationsFile holds annotation information about a bundle -type AnnotationsFile struct { - // annotations is a list of annotations for a given bundle - Annotations Annotations `json:"annotations" yaml:"annotations"` -} - -// Annotations is a list of annotations for a given bundle -type Annotations struct { - // PackageName is the name of the overall package, ala `etcd`. - PackageName string `json:"operators.operatorframework.io.bundle.package.v1" yaml:"operators.operatorframework.io.bundle.package.v1"` - - // Channels are a comma separated list of the declared channels for the bundle, ala `stable` or `alpha`. - Channels string `json:"operators.operatorframework.io.bundle.channels.v1" yaml:"operators.operatorframework.io.bundle.channels.v1"` - - // DefaultChannelName is, if specified, the name of the default channel for the package. The - // default channel will be installed if no other channel is explicitly given. If the package - // has a single channel, then that channel is implicitly the default. - DefaultChannelName string `json:"operators.operatorframework.io.bundle.channel.default.v1" yaml:"operators.operatorframework.io.bundle.channel.default.v1"` -} - -// DependenciesFile holds dependency information about a bundle. -type DependenciesFile struct { - // Dependencies is a list of dependencies for a given bundle - Dependencies []Dependency `json:"dependencies" yaml:"dependencies"` -} - -// Dependency specifies a single constraint that can be satisfied by a property on another bundle. -type Dependency struct { - // The type of dependency. This field is required. - Type string `json:"type" yaml:"type"` - - // The serialized value of the dependency - Value json.RawMessage `json:"value" yaml:"value"` -} - -// PropertiesFile holds the properties associated with a bundle. -type PropertiesFile struct { - // Properties is a list of properties. - Properties []Property `json:"properties" yaml:"properties"` -} - -// Property defines a single piece of the public interface for a bundle. Dependencies are specified over properties. -// The Type of the property determines how to interpret the Value, but the value is treated opaquely for -// for non-first-party types. -type Property struct { - // The type of property. This field is required. - Type string `json:"type" yaml:"type"` - - // The serialized value of the propertuy - Value json.RawMessage `json:"value" yaml:"value"` -} - -func (p Property) String() string { - return fmt.Sprintf("type: %s, value: %s", p.Type, p.Value) -} - -type GVKDependency struct { - // The group of GVK based dependency - Group string `json:"group" yaml:"group"` - - // The kind of GVK based dependency - Kind string `json:"kind" yaml:"kind"` - - // The version of GVK based dependency - Version string `json:"version" yaml:"version"` -} - -type PackageDependency struct { - // The name of dependency such as 'etcd' - PackageName string `json:"packageName" yaml:"packageName"` - - // The version range of dependency in semver range format - Version string `json:"version" yaml:"version"` -} - -type LabelDependency struct { - // The Label name of dependency - Label string `json:"label" yaml:"label"` -} - -type CelConstraint struct { - // Constraint failure message that surfaces in resolution - // This field is optional - FailureMessage string `json:"failureMessage" yaml:"failureMessage"` - - // The cel struct that contraints CEL expression - // This field is required - Cel *constraints.Cel `json:"cel" yaml:"cel"` -} - -type GVKProperty struct { - // The group of GVK based property - Group string `json:"group" yaml:"group"` - - // The kind of GVK based property - Kind string `json:"kind" yaml:"kind"` - - // The version of the API - Version string `json:"version" yaml:"version"` -} - -type PackageProperty struct { - // The name of package such as 'etcd' - PackageName string `json:"packageName" yaml:"packageName"` - - // The version of package in semver format - Version string `json:"version" yaml:"version"` -} - -type DeprecatedProperty struct { - // Whether the bundle is deprecated -} - -type LabelProperty struct { - // The name of Label - Label string `json:"label" yaml:"label"` -} - -// Validate will validate GVK dependency type and return error(s) -func (gd *GVKDependency) Validate() []error { - errs := []error{} - if gd.Group == "" { - errs = append(errs, fmt.Errorf("API Group is empty")) - } - if gd.Version == "" { - errs = append(errs, fmt.Errorf("API Version is empty")) - } - if gd.Kind == "" { - errs = append(errs, fmt.Errorf("API Kind is empty")) - } - return errs -} - -// Validate will validate Label dependency type and return error(s) -func (ld *LabelDependency) Validate() []error { - errs := []error{} - if *ld == (LabelDependency{}) { - errs = append(errs, fmt.Errorf("Label information is missing")) - } - return errs -} - -// Validate will validate package dependency type and return error(s) -func (pd *PackageDependency) Validate() []error { - errs := []error{} - if pd.PackageName == "" { - errs = append(errs, fmt.Errorf("Package name is empty")) - } - if pd.Version == "" { - errs = append(errs, fmt.Errorf("Package version is empty")) - } else { - _, err := semver.ParseRange(pd.Version) - if err != nil { - errs = append(errs, fmt.Errorf("Invalid semver format version")) - } - } - return errs -} - -// Validate will validate constraint type and return error(s) -func (cc *CelConstraint) Validate() []error { - errs := []error{} - if cc.Cel == nil { - errs = append(errs, fmt.Errorf("The CEL field is missing")) - } else { - if cc.Cel.Rule == "" { - errs = append(errs, fmt.Errorf("The CEL expression is missing")) - return errs - } - validator := constraints.NewCelEnvironment() - _, err := validator.Validate(cc.Cel.Rule) - if err != nil { - errs = append(errs, fmt.Errorf("Invalid CEL expression: %s", err.Error())) - } - } - return errs -} - -// GetDependencies returns the list of dependency -func (d *DependenciesFile) GetDependencies() []*Dependency { - var dependencies []*Dependency - for _, item := range d.Dependencies { - dep := item - dependencies = append(dependencies, &dep) - } - return dependencies -} - -// GetType returns the type of dependency -func (e *Dependency) GetType() string { - return e.Type -} - -// GetTypeValue returns the dependency object that is converted -// from value string -func (e *Dependency) GetTypeValue() interface{} { - switch e.GetType() { - case GVKType: - dep := GVKDependency{} - err := json.Unmarshal([]byte(e.GetValue()), &dep) - if err != nil { - return nil - } - return dep - case PackageType: - dep := PackageDependency{} - err := json.Unmarshal([]byte(e.GetValue()), &dep) - if err != nil { - return nil - } - return dep - case LabelType: - dep := LabelDependency{} - err := json.Unmarshal([]byte(e.GetValue()), &dep) - if err != nil { - return nil - } - return dep - case ConstraintType: - dep := CelConstraint{} - err := json.Unmarshal([]byte(e.GetValue()), &dep) - if err != nil { - return nil - } - return dep - } - return nil -} - -// GetValue returns the value content of dependency -func (e *Dependency) GetValue() string { - return string(e.Value) -} - -// GetName returns the package name of the bundle -func (a *AnnotationsFile) GetName() string { - return a.Annotations.PackageName -} - -// GetChannels returns the channels that this bundle should be added to -func (a *AnnotationsFile) GetChannels() []string { - if a.Annotations.Channels != "" { - return strings.Split(a.Annotations.Channels, ",") - } - return []string{} -} - -// GetDefaultChannelName returns the name of the default channel -func (a *AnnotationsFile) GetDefaultChannelName() string { - return a.Annotations.DefaultChannelName -} - -// SelectDefaultChannel returns the first item in channel list that is sorted -// in lexicographic order. -func (a *AnnotationsFile) SelectDefaultChannel() string { - return a.Annotations.SelectDefaultChannel() -} - -func (a Annotations) SelectDefaultChannel() string { - if len(a.Channels) < 1 { - return "" - } - - channels := strings.Split(a.Channels, ",") - sort.Strings(channels) - - return channels[0] -} diff --git a/vendor/github.com/stoewer/go-strcase/.gitignore b/vendor/github.com/stoewer/go-strcase/.gitignore deleted file mode 100644 index db5247b94..000000000 --- a/vendor/github.com/stoewer/go-strcase/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -vendor -doc - -# Temporary files -*~ -*.swp - -# Editor and IDE config -.idea -*.iml -.vscode diff --git a/vendor/github.com/stoewer/go-strcase/.golangci.yml b/vendor/github.com/stoewer/go-strcase/.golangci.yml deleted file mode 100644 index 7f98d55c4..000000000 --- a/vendor/github.com/stoewer/go-strcase/.golangci.yml +++ /dev/null @@ -1,26 +0,0 @@ -run: - deadline: 10m - -linters: - enable: - - dupl - - goconst - - gocyclo - - godox - - gosec - - interfacer - - lll - - maligned - - misspell - - prealloc - - stylecheck - - unconvert - - unparam - - errcheck - - golint - - gofmt - disable: [] - fast: false - -issues: - exclude-use-default: false diff --git a/vendor/github.com/stoewer/go-strcase/LICENSE b/vendor/github.com/stoewer/go-strcase/LICENSE deleted file mode 100644 index a105a3819..000000000 --- a/vendor/github.com/stoewer/go-strcase/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2017, Adrian Stoewer - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/github.com/stoewer/go-strcase/README.md b/vendor/github.com/stoewer/go-strcase/README.md deleted file mode 100644 index 84a640e71..000000000 --- a/vendor/github.com/stoewer/go-strcase/README.md +++ /dev/null @@ -1,50 +0,0 @@ -[![GH Actions](https://github.com/stoewer/go-strcase/actions/workflows/lint-test.yml/badge.svg?branch=master)](https://github.com/stoewer/go-strcase/actions) -[![codecov](https://codecov.io/github/stoewer/go-strcase/branch/master/graph/badge.svg?token=c0UokYnop5)](https://codecov.io/github/stoewer/go-strcase) -[![GoDoc](https://godoc.org/github.com/stoewer/go-strcase?status.svg)](https://pkg.go.dev/github.com/stoewer/go-strcase) ---- - -Go strcase -========== - -The package `strcase` converts between different kinds of naming formats such as camel case -(`CamelCase`), snake case (`snake_case`) or kebab case (`kebab-case`). -The package is designed to work only with strings consisting of standard ASCII letters. -Unicode is currently not supported. - -Versioning and stability ------------------------- - -Although the master branch is supposed to remain always backward compatible, the repository -contains version tags in order to support vendoring tools. -The tag names follow semantic versioning conventions and have the following format `v1.0.0`. -This package supports Go modules introduced with version 1.11. - -Example -------- - -```go -import "github.com/stoewer/go-strcase" - -var snake = strcase.SnakeCase("CamelCase") -``` - -Dependencies ------------- - -### Build dependencies - -* none - -### Test dependencies - -* `github.com/stretchr/testify` - -Run linters and unit tests --------------------------- - -To run the static code analysis, linters and tests use the following commands: - -``` -golangci-lint run --config .golangci.yml ./... -go test ./... -``` diff --git a/vendor/github.com/stoewer/go-strcase/camel.go b/vendor/github.com/stoewer/go-strcase/camel.go deleted file mode 100644 index ff9e66e0c..000000000 --- a/vendor/github.com/stoewer/go-strcase/camel.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2017, A. Stoewer -// All rights reserved. - -package strcase - -import ( - "strings" -) - -// UpperCamelCase converts a string into camel case starting with a upper case letter. -func UpperCamelCase(s string) string { - return camelCase(s, true) -} - -// LowerCamelCase converts a string into camel case starting with a lower case letter. -func LowerCamelCase(s string) string { - return camelCase(s, false) -} - -func camelCase(s string, upper bool) string { - s = strings.TrimSpace(s) - buffer := make([]rune, 0, len(s)) - - stringIter(s, func(prev, curr, next rune) { - if !isDelimiter(curr) { - if isDelimiter(prev) || (upper && prev == 0) { - buffer = append(buffer, toUpper(curr)) - } else if isLower(prev) { - buffer = append(buffer, curr) - } else if isUpper(prev) && isUpper(curr) && isLower(next) { - // Assume a case like "R" for "XRequestId" - buffer = append(buffer, curr) - } else { - buffer = append(buffer, toLower(curr)) - } - } - }) - - return string(buffer) -} diff --git a/vendor/github.com/stoewer/go-strcase/doc.go b/vendor/github.com/stoewer/go-strcase/doc.go deleted file mode 100644 index 3e441ca3e..000000000 --- a/vendor/github.com/stoewer/go-strcase/doc.go +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2017, A. Stoewer -// All rights reserved. - -// Package strcase converts between different kinds of naming formats such as camel case -// (CamelCase), snake case (snake_case) or kebab case (kebab-case). The package is designed -// to work only with strings consisting of standard ASCII letters. Unicode is currently not -// supported. -package strcase diff --git a/vendor/github.com/stoewer/go-strcase/helper.go b/vendor/github.com/stoewer/go-strcase/helper.go deleted file mode 100644 index ecad58914..000000000 --- a/vendor/github.com/stoewer/go-strcase/helper.go +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) 2017, A. Stoewer -// All rights reserved. - -package strcase - -// isLower checks if a character is lower case. More precisely it evaluates if it is -// in the range of ASCII character 'a' to 'z'. -func isLower(ch rune) bool { - return ch >= 'a' && ch <= 'z' -} - -// toLower converts a character in the range of ASCII characters 'A' to 'Z' to its lower -// case counterpart. Other characters remain the same. -func toLower(ch rune) rune { - if ch >= 'A' && ch <= 'Z' { - return ch + 32 - } - return ch -} - -// isLower checks if a character is upper case. More precisely it evaluates if it is -// in the range of ASCII characters 'A' to 'Z'. -func isUpper(ch rune) bool { - return ch >= 'A' && ch <= 'Z' -} - -// toLower converts a character in the range of ASCII characters 'a' to 'z' to its lower -// case counterpart. Other characters remain the same. -func toUpper(ch rune) rune { - if ch >= 'a' && ch <= 'z' { - return ch - 32 - } - return ch -} - -// isSpace checks if a character is some kind of whitespace. -func isSpace(ch rune) bool { - return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r' -} - -// isDelimiter checks if a character is some kind of whitespace or '_' or '-'. -func isDelimiter(ch rune) bool { - return ch == '-' || ch == '_' || isSpace(ch) -} - -// iterFunc is a callback that is called fro a specific position in a string. Its arguments are the -// rune at the respective string position as well as the previous and the next rune. If curr is at the -// first position of the string prev is zero. If curr is at the end of the string next is zero. -type iterFunc func(prev, curr, next rune) - -// stringIter iterates over a string, invoking the callback for every single rune in the string. -func stringIter(s string, callback iterFunc) { - var prev rune - var curr rune - for _, next := range s { - if curr == 0 { - prev = curr - curr = next - continue - } - - callback(prev, curr, next) - - prev = curr - curr = next - } - - if len(s) > 0 { - callback(prev, curr, 0) - } -} diff --git a/vendor/github.com/stoewer/go-strcase/kebab.go b/vendor/github.com/stoewer/go-strcase/kebab.go deleted file mode 100644 index e9a648757..000000000 --- a/vendor/github.com/stoewer/go-strcase/kebab.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2017, A. Stoewer -// All rights reserved. - -package strcase - -// KebabCase converts a string into kebab case. -func KebabCase(s string) string { - return delimiterCase(s, '-', false) -} - -// UpperKebabCase converts a string into kebab case with capital letters. -func UpperKebabCase(s string) string { - return delimiterCase(s, '-', true) -} diff --git a/vendor/github.com/stoewer/go-strcase/snake.go b/vendor/github.com/stoewer/go-strcase/snake.go deleted file mode 100644 index 1b216e20c..000000000 --- a/vendor/github.com/stoewer/go-strcase/snake.go +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2017, A. Stoewer -// All rights reserved. - -package strcase - -import ( - "strings" -) - -// SnakeCase converts a string into snake case. -func SnakeCase(s string) string { - return delimiterCase(s, '_', false) -} - -// UpperSnakeCase converts a string into snake case with capital letters. -func UpperSnakeCase(s string) string { - return delimiterCase(s, '_', true) -} - -// delimiterCase converts a string into snake_case or kebab-case depending on the delimiter passed -// as second argument. When upperCase is true the result will be UPPER_SNAKE_CASE or UPPER-KEBAB-CASE. -func delimiterCase(s string, delimiter rune, upperCase bool) string { - s = strings.TrimSpace(s) - buffer := make([]rune, 0, len(s)+3) - - adjustCase := toLower - if upperCase { - adjustCase = toUpper - } - - var prev rune - var curr rune - for _, next := range s { - if isDelimiter(curr) { - if !isDelimiter(prev) { - buffer = append(buffer, delimiter) - } - } else if isUpper(curr) { - if isLower(prev) || (isUpper(prev) && isLower(next)) { - buffer = append(buffer, delimiter) - } - buffer = append(buffer, adjustCase(curr)) - } else if curr != 0 { - buffer = append(buffer, adjustCase(curr)) - } - prev = curr - curr = next - } - - if len(s) > 0 { - if isUpper(curr) && isLower(prev) && prev != 0 { - buffer = append(buffer, delimiter) - } - buffer = append(buffer, adjustCase(curr)) - } - - return string(buffer) -} diff --git a/vendor/golang.org/x/net/internal/timeseries/timeseries.go b/vendor/golang.org/x/net/internal/timeseries/timeseries.go deleted file mode 100644 index dc5225b6d..000000000 --- a/vendor/golang.org/x/net/internal/timeseries/timeseries.go +++ /dev/null @@ -1,525 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package timeseries implements a time series structure for stats collection. -package timeseries // import "golang.org/x/net/internal/timeseries" - -import ( - "fmt" - "log" - "time" -) - -const ( - timeSeriesNumBuckets = 64 - minuteHourSeriesNumBuckets = 60 -) - -var timeSeriesResolutions = []time.Duration{ - 1 * time.Second, - 10 * time.Second, - 1 * time.Minute, - 10 * time.Minute, - 1 * time.Hour, - 6 * time.Hour, - 24 * time.Hour, // 1 day - 7 * 24 * time.Hour, // 1 week - 4 * 7 * 24 * time.Hour, // 4 weeks - 16 * 7 * 24 * time.Hour, // 16 weeks -} - -var minuteHourSeriesResolutions = []time.Duration{ - 1 * time.Second, - 1 * time.Minute, -} - -// An Observable is a kind of data that can be aggregated in a time series. -type Observable interface { - Multiply(ratio float64) // Multiplies the data in self by a given ratio - Add(other Observable) // Adds the data from a different observation to self - Clear() // Clears the observation so it can be reused. - CopyFrom(other Observable) // Copies the contents of a given observation to self -} - -// Float attaches the methods of Observable to a float64. -type Float float64 - -// NewFloat returns a Float. -func NewFloat() Observable { - f := Float(0) - return &f -} - -// String returns the float as a string. -func (f *Float) String() string { return fmt.Sprintf("%g", f.Value()) } - -// Value returns the float's value. -func (f *Float) Value() float64 { return float64(*f) } - -func (f *Float) Multiply(ratio float64) { *f *= Float(ratio) } - -func (f *Float) Add(other Observable) { - o := other.(*Float) - *f += *o -} - -func (f *Float) Clear() { *f = 0 } - -func (f *Float) CopyFrom(other Observable) { - o := other.(*Float) - *f = *o -} - -// A Clock tells the current time. -type Clock interface { - Time() time.Time -} - -type defaultClock int - -var defaultClockInstance defaultClock - -func (defaultClock) Time() time.Time { return time.Now() } - -// Information kept per level. Each level consists of a circular list of -// observations. The start of the level may be derived from end and the -// len(buckets) * sizeInMillis. -type tsLevel struct { - oldest int // index to oldest bucketed Observable - newest int // index to newest bucketed Observable - end time.Time // end timestamp for this level - size time.Duration // duration of the bucketed Observable - buckets []Observable // collections of observations - provider func() Observable // used for creating new Observable -} - -func (l *tsLevel) Clear() { - l.oldest = 0 - l.newest = len(l.buckets) - 1 - l.end = time.Time{} - for i := range l.buckets { - if l.buckets[i] != nil { - l.buckets[i].Clear() - l.buckets[i] = nil - } - } -} - -func (l *tsLevel) InitLevel(size time.Duration, numBuckets int, f func() Observable) { - l.size = size - l.provider = f - l.buckets = make([]Observable, numBuckets) -} - -// Keeps a sequence of levels. Each level is responsible for storing data at -// a given resolution. For example, the first level stores data at a one -// minute resolution while the second level stores data at a one hour -// resolution. - -// Each level is represented by a sequence of buckets. Each bucket spans an -// interval equal to the resolution of the level. New observations are added -// to the last bucket. -type timeSeries struct { - provider func() Observable // make more Observable - numBuckets int // number of buckets in each level - levels []*tsLevel // levels of bucketed Observable - lastAdd time.Time // time of last Observable tracked - total Observable // convenient aggregation of all Observable - clock Clock // Clock for getting current time - pending Observable // observations not yet bucketed - pendingTime time.Time // what time are we keeping in pending - dirty bool // if there are pending observations -} - -// init initializes a level according to the supplied criteria. -func (ts *timeSeries) init(resolutions []time.Duration, f func() Observable, numBuckets int, clock Clock) { - ts.provider = f - ts.numBuckets = numBuckets - ts.clock = clock - ts.levels = make([]*tsLevel, len(resolutions)) - - for i := range resolutions { - if i > 0 && resolutions[i-1] >= resolutions[i] { - log.Print("timeseries: resolutions must be monotonically increasing") - break - } - newLevel := new(tsLevel) - newLevel.InitLevel(resolutions[i], ts.numBuckets, ts.provider) - ts.levels[i] = newLevel - } - - ts.Clear() -} - -// Clear removes all observations from the time series. -func (ts *timeSeries) Clear() { - ts.lastAdd = time.Time{} - ts.total = ts.resetObservation(ts.total) - ts.pending = ts.resetObservation(ts.pending) - ts.pendingTime = time.Time{} - ts.dirty = false - - for i := range ts.levels { - ts.levels[i].Clear() - } -} - -// Add records an observation at the current time. -func (ts *timeSeries) Add(observation Observable) { - ts.AddWithTime(observation, ts.clock.Time()) -} - -// AddWithTime records an observation at the specified time. -func (ts *timeSeries) AddWithTime(observation Observable, t time.Time) { - - smallBucketDuration := ts.levels[0].size - - if t.After(ts.lastAdd) { - ts.lastAdd = t - } - - if t.After(ts.pendingTime) { - ts.advance(t) - ts.mergePendingUpdates() - ts.pendingTime = ts.levels[0].end - ts.pending.CopyFrom(observation) - ts.dirty = true - } else if t.After(ts.pendingTime.Add(-1 * smallBucketDuration)) { - // The observation is close enough to go into the pending bucket. - // This compensates for clock skewing and small scheduling delays - // by letting the update stay in the fast path. - ts.pending.Add(observation) - ts.dirty = true - } else { - ts.mergeValue(observation, t) - } -} - -// mergeValue inserts the observation at the specified time in the past into all levels. -func (ts *timeSeries) mergeValue(observation Observable, t time.Time) { - for _, level := range ts.levels { - index := (ts.numBuckets - 1) - int(level.end.Sub(t)/level.size) - if 0 <= index && index < ts.numBuckets { - bucketNumber := (level.oldest + index) % ts.numBuckets - if level.buckets[bucketNumber] == nil { - level.buckets[bucketNumber] = level.provider() - } - level.buckets[bucketNumber].Add(observation) - } - } - ts.total.Add(observation) -} - -// mergePendingUpdates applies the pending updates into all levels. -func (ts *timeSeries) mergePendingUpdates() { - if ts.dirty { - ts.mergeValue(ts.pending, ts.pendingTime) - ts.pending = ts.resetObservation(ts.pending) - ts.dirty = false - } -} - -// advance cycles the buckets at each level until the latest bucket in -// each level can hold the time specified. -func (ts *timeSeries) advance(t time.Time) { - if !t.After(ts.levels[0].end) { - return - } - for i := 0; i < len(ts.levels); i++ { - level := ts.levels[i] - if !level.end.Before(t) { - break - } - - // If the time is sufficiently far, just clear the level and advance - // directly. - if !t.Before(level.end.Add(level.size * time.Duration(ts.numBuckets))) { - for _, b := range level.buckets { - ts.resetObservation(b) - } - level.end = time.Unix(0, (t.UnixNano()/level.size.Nanoseconds())*level.size.Nanoseconds()) - } - - for t.After(level.end) { - level.end = level.end.Add(level.size) - level.newest = level.oldest - level.oldest = (level.oldest + 1) % ts.numBuckets - ts.resetObservation(level.buckets[level.newest]) - } - - t = level.end - } -} - -// Latest returns the sum of the num latest buckets from the level. -func (ts *timeSeries) Latest(level, num int) Observable { - now := ts.clock.Time() - if ts.levels[0].end.Before(now) { - ts.advance(now) - } - - ts.mergePendingUpdates() - - result := ts.provider() - l := ts.levels[level] - index := l.newest - - for i := 0; i < num; i++ { - if l.buckets[index] != nil { - result.Add(l.buckets[index]) - } - if index == 0 { - index = ts.numBuckets - } - index-- - } - - return result -} - -// LatestBuckets returns a copy of the num latest buckets from level. -func (ts *timeSeries) LatestBuckets(level, num int) []Observable { - if level < 0 || level > len(ts.levels) { - log.Print("timeseries: bad level argument: ", level) - return nil - } - if num < 0 || num >= ts.numBuckets { - log.Print("timeseries: bad num argument: ", num) - return nil - } - - results := make([]Observable, num) - now := ts.clock.Time() - if ts.levels[0].end.Before(now) { - ts.advance(now) - } - - ts.mergePendingUpdates() - - l := ts.levels[level] - index := l.newest - - for i := 0; i < num; i++ { - result := ts.provider() - results[i] = result - if l.buckets[index] != nil { - result.CopyFrom(l.buckets[index]) - } - - if index == 0 { - index = ts.numBuckets - } - index -= 1 - } - return results -} - -// ScaleBy updates observations by scaling by factor. -func (ts *timeSeries) ScaleBy(factor float64) { - for _, l := range ts.levels { - for i := 0; i < ts.numBuckets; i++ { - l.buckets[i].Multiply(factor) - } - } - - ts.total.Multiply(factor) - ts.pending.Multiply(factor) -} - -// Range returns the sum of observations added over the specified time range. -// If start or finish times don't fall on bucket boundaries of the same -// level, then return values are approximate answers. -func (ts *timeSeries) Range(start, finish time.Time) Observable { - return ts.ComputeRange(start, finish, 1)[0] -} - -// Recent returns the sum of observations from the last delta. -func (ts *timeSeries) Recent(delta time.Duration) Observable { - now := ts.clock.Time() - return ts.Range(now.Add(-delta), now) -} - -// Total returns the total of all observations. -func (ts *timeSeries) Total() Observable { - ts.mergePendingUpdates() - return ts.total -} - -// ComputeRange computes a specified number of values into a slice using -// the observations recorded over the specified time period. The return -// values are approximate if the start or finish times don't fall on the -// bucket boundaries at the same level or if the number of buckets spanning -// the range is not an integral multiple of num. -func (ts *timeSeries) ComputeRange(start, finish time.Time, num int) []Observable { - if start.After(finish) { - log.Printf("timeseries: start > finish, %v>%v", start, finish) - return nil - } - - if num < 0 { - log.Printf("timeseries: num < 0, %v", num) - return nil - } - - results := make([]Observable, num) - - for _, l := range ts.levels { - if !start.Before(l.end.Add(-l.size * time.Duration(ts.numBuckets))) { - ts.extract(l, start, finish, num, results) - return results - } - } - - // Failed to find a level that covers the desired range. So just - // extract from the last level, even if it doesn't cover the entire - // desired range. - ts.extract(ts.levels[len(ts.levels)-1], start, finish, num, results) - - return results -} - -// RecentList returns the specified number of values in slice over the most -// recent time period of the specified range. -func (ts *timeSeries) RecentList(delta time.Duration, num int) []Observable { - if delta < 0 { - return nil - } - now := ts.clock.Time() - return ts.ComputeRange(now.Add(-delta), now, num) -} - -// extract returns a slice of specified number of observations from a given -// level over a given range. -func (ts *timeSeries) extract(l *tsLevel, start, finish time.Time, num int, results []Observable) { - ts.mergePendingUpdates() - - srcInterval := l.size - dstInterval := finish.Sub(start) / time.Duration(num) - dstStart := start - srcStart := l.end.Add(-srcInterval * time.Duration(ts.numBuckets)) - - srcIndex := 0 - - // Where should scanning start? - if dstStart.After(srcStart) { - advance := int(dstStart.Sub(srcStart) / srcInterval) - srcIndex += advance - srcStart = srcStart.Add(time.Duration(advance) * srcInterval) - } - - // The i'th value is computed as show below. - // interval = (finish/start)/num - // i'th value = sum of observation in range - // [ start + i * interval, - // start + (i + 1) * interval ) - for i := 0; i < num; i++ { - results[i] = ts.resetObservation(results[i]) - dstEnd := dstStart.Add(dstInterval) - for srcIndex < ts.numBuckets && srcStart.Before(dstEnd) { - srcEnd := srcStart.Add(srcInterval) - if srcEnd.After(ts.lastAdd) { - srcEnd = ts.lastAdd - } - - if !srcEnd.Before(dstStart) { - srcValue := l.buckets[(srcIndex+l.oldest)%ts.numBuckets] - if !srcStart.Before(dstStart) && !srcEnd.After(dstEnd) { - // dst completely contains src. - if srcValue != nil { - results[i].Add(srcValue) - } - } else { - // dst partially overlaps src. - overlapStart := maxTime(srcStart, dstStart) - overlapEnd := minTime(srcEnd, dstEnd) - base := srcEnd.Sub(srcStart) - fraction := overlapEnd.Sub(overlapStart).Seconds() / base.Seconds() - - used := ts.provider() - if srcValue != nil { - used.CopyFrom(srcValue) - } - used.Multiply(fraction) - results[i].Add(used) - } - - if srcEnd.After(dstEnd) { - break - } - } - srcIndex++ - srcStart = srcStart.Add(srcInterval) - } - dstStart = dstStart.Add(dstInterval) - } -} - -// resetObservation clears the content so the struct may be reused. -func (ts *timeSeries) resetObservation(observation Observable) Observable { - if observation == nil { - observation = ts.provider() - } else { - observation.Clear() - } - return observation -} - -// TimeSeries tracks data at granularities from 1 second to 16 weeks. -type TimeSeries struct { - timeSeries -} - -// NewTimeSeries creates a new TimeSeries using the function provided for creating new Observable. -func NewTimeSeries(f func() Observable) *TimeSeries { - return NewTimeSeriesWithClock(f, defaultClockInstance) -} - -// NewTimeSeriesWithClock creates a new TimeSeries using the function provided for creating new Observable and the clock for -// assigning timestamps. -func NewTimeSeriesWithClock(f func() Observable, clock Clock) *TimeSeries { - ts := new(TimeSeries) - ts.timeSeries.init(timeSeriesResolutions, f, timeSeriesNumBuckets, clock) - return ts -} - -// MinuteHourSeries tracks data at granularities of 1 minute and 1 hour. -type MinuteHourSeries struct { - timeSeries -} - -// NewMinuteHourSeries creates a new MinuteHourSeries using the function provided for creating new Observable. -func NewMinuteHourSeries(f func() Observable) *MinuteHourSeries { - return NewMinuteHourSeriesWithClock(f, defaultClockInstance) -} - -// NewMinuteHourSeriesWithClock creates a new MinuteHourSeries using the function provided for creating new Observable and the clock for -// assigning timestamps. -func NewMinuteHourSeriesWithClock(f func() Observable, clock Clock) *MinuteHourSeries { - ts := new(MinuteHourSeries) - ts.timeSeries.init(minuteHourSeriesResolutions, f, - minuteHourSeriesNumBuckets, clock) - return ts -} - -func (ts *MinuteHourSeries) Minute() Observable { - return ts.timeSeries.Latest(0, 60) -} - -func (ts *MinuteHourSeries) Hour() Observable { - return ts.timeSeries.Latest(1, 60) -} - -func minTime(a, b time.Time) time.Time { - if a.Before(b) { - return a - } - return b -} - -func maxTime(a, b time.Time) time.Time { - if a.After(b) { - return a - } - return b -} diff --git a/vendor/golang.org/x/net/trace/events.go b/vendor/golang.org/x/net/trace/events.go deleted file mode 100644 index c646a6952..000000000 --- a/vendor/golang.org/x/net/trace/events.go +++ /dev/null @@ -1,532 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package trace - -import ( - "bytes" - "fmt" - "html/template" - "io" - "log" - "net/http" - "runtime" - "sort" - "strconv" - "strings" - "sync" - "sync/atomic" - "text/tabwriter" - "time" -) - -const maxEventsPerLog = 100 - -type bucket struct { - MaxErrAge time.Duration - String string -} - -var buckets = []bucket{ - {0, "total"}, - {10 * time.Second, "errs<10s"}, - {1 * time.Minute, "errs<1m"}, - {10 * time.Minute, "errs<10m"}, - {1 * time.Hour, "errs<1h"}, - {10 * time.Hour, "errs<10h"}, - {24000 * time.Hour, "errors"}, -} - -// RenderEvents renders the HTML page typically served at /debug/events. -// It does not do any auth checking. The request may be nil. -// -// Most users will use the Events handler. -func RenderEvents(w http.ResponseWriter, req *http.Request, sensitive bool) { - now := time.Now() - data := &struct { - Families []string // family names - Buckets []bucket - Counts [][]int // eventLog count per family/bucket - - // Set when a bucket has been selected. - Family string - Bucket int - EventLogs eventLogs - Expanded bool - }{ - Buckets: buckets, - } - - data.Families = make([]string, 0, len(families)) - famMu.RLock() - for name := range families { - data.Families = append(data.Families, name) - } - famMu.RUnlock() - sort.Strings(data.Families) - - // Count the number of eventLogs in each family for each error age. - data.Counts = make([][]int, len(data.Families)) - for i, name := range data.Families { - // TODO(sameer): move this loop under the family lock. - f := getEventFamily(name) - data.Counts[i] = make([]int, len(data.Buckets)) - for j, b := range data.Buckets { - data.Counts[i][j] = f.Count(now, b.MaxErrAge) - } - } - - if req != nil { - var ok bool - data.Family, data.Bucket, ok = parseEventsArgs(req) - if !ok { - // No-op - } else { - data.EventLogs = getEventFamily(data.Family).Copy(now, buckets[data.Bucket].MaxErrAge) - } - if data.EventLogs != nil { - defer data.EventLogs.Free() - sort.Sort(data.EventLogs) - } - if exp, err := strconv.ParseBool(req.FormValue("exp")); err == nil { - data.Expanded = exp - } - } - - famMu.RLock() - defer famMu.RUnlock() - if err := eventsTmpl().Execute(w, data); err != nil { - log.Printf("net/trace: Failed executing template: %v", err) - } -} - -func parseEventsArgs(req *http.Request) (fam string, b int, ok bool) { - fam, bStr := req.FormValue("fam"), req.FormValue("b") - if fam == "" || bStr == "" { - return "", 0, false - } - b, err := strconv.Atoi(bStr) - if err != nil || b < 0 || b >= len(buckets) { - return "", 0, false - } - return fam, b, true -} - -// An EventLog provides a log of events associated with a specific object. -type EventLog interface { - // Printf formats its arguments with fmt.Sprintf and adds the - // result to the event log. - Printf(format string, a ...interface{}) - - // Errorf is like Printf, but it marks this event as an error. - Errorf(format string, a ...interface{}) - - // Finish declares that this event log is complete. - // The event log should not be used after calling this method. - Finish() -} - -// NewEventLog returns a new EventLog with the specified family name -// and title. -func NewEventLog(family, title string) EventLog { - el := newEventLog() - el.ref() - el.Family, el.Title = family, title - el.Start = time.Now() - el.events = make([]logEntry, 0, maxEventsPerLog) - el.stack = make([]uintptr, 32) - n := runtime.Callers(2, el.stack) - el.stack = el.stack[:n] - - getEventFamily(family).add(el) - return el -} - -func (el *eventLog) Finish() { - getEventFamily(el.Family).remove(el) - el.unref() // matches ref in New -} - -var ( - famMu sync.RWMutex - families = make(map[string]*eventFamily) // family name => family -) - -func getEventFamily(fam string) *eventFamily { - famMu.Lock() - defer famMu.Unlock() - f := families[fam] - if f == nil { - f = &eventFamily{} - families[fam] = f - } - return f -} - -type eventFamily struct { - mu sync.RWMutex - eventLogs eventLogs -} - -func (f *eventFamily) add(el *eventLog) { - f.mu.Lock() - f.eventLogs = append(f.eventLogs, el) - f.mu.Unlock() -} - -func (f *eventFamily) remove(el *eventLog) { - f.mu.Lock() - defer f.mu.Unlock() - for i, el0 := range f.eventLogs { - if el == el0 { - copy(f.eventLogs[i:], f.eventLogs[i+1:]) - f.eventLogs = f.eventLogs[:len(f.eventLogs)-1] - return - } - } -} - -func (f *eventFamily) Count(now time.Time, maxErrAge time.Duration) (n int) { - f.mu.RLock() - defer f.mu.RUnlock() - for _, el := range f.eventLogs { - if el.hasRecentError(now, maxErrAge) { - n++ - } - } - return -} - -func (f *eventFamily) Copy(now time.Time, maxErrAge time.Duration) (els eventLogs) { - f.mu.RLock() - defer f.mu.RUnlock() - els = make(eventLogs, 0, len(f.eventLogs)) - for _, el := range f.eventLogs { - if el.hasRecentError(now, maxErrAge) { - el.ref() - els = append(els, el) - } - } - return -} - -type eventLogs []*eventLog - -// Free calls unref on each element of the list. -func (els eventLogs) Free() { - for _, el := range els { - el.unref() - } -} - -// eventLogs may be sorted in reverse chronological order. -func (els eventLogs) Len() int { return len(els) } -func (els eventLogs) Less(i, j int) bool { return els[i].Start.After(els[j].Start) } -func (els eventLogs) Swap(i, j int) { els[i], els[j] = els[j], els[i] } - -// A logEntry is a timestamped log entry in an event log. -type logEntry struct { - When time.Time - Elapsed time.Duration // since previous event in log - NewDay bool // whether this event is on a different day to the previous event - What string - IsErr bool -} - -// WhenString returns a string representation of the elapsed time of the event. -// It will include the date if midnight was crossed. -func (e logEntry) WhenString() string { - if e.NewDay { - return e.When.Format("2006/01/02 15:04:05.000000") - } - return e.When.Format("15:04:05.000000") -} - -// An eventLog represents an active event log. -type eventLog struct { - // Family is the top-level grouping of event logs to which this belongs. - Family string - - // Title is the title of this event log. - Title string - - // Timing information. - Start time.Time - - // Call stack where this event log was created. - stack []uintptr - - // Append-only sequence of events. - // - // TODO(sameer): change this to a ring buffer to avoid the array copy - // when we hit maxEventsPerLog. - mu sync.RWMutex - events []logEntry - LastErrorTime time.Time - discarded int - - refs int32 // how many buckets this is in -} - -func (el *eventLog) reset() { - // Clear all but the mutex. Mutexes may not be copied, even when unlocked. - el.Family = "" - el.Title = "" - el.Start = time.Time{} - el.stack = nil - el.events = nil - el.LastErrorTime = time.Time{} - el.discarded = 0 - el.refs = 0 -} - -func (el *eventLog) hasRecentError(now time.Time, maxErrAge time.Duration) bool { - if maxErrAge == 0 { - return true - } - el.mu.RLock() - defer el.mu.RUnlock() - return now.Sub(el.LastErrorTime) < maxErrAge -} - -// delta returns the elapsed time since the last event or the log start, -// and whether it spans midnight. -// L >= el.mu -func (el *eventLog) delta(t time.Time) (time.Duration, bool) { - if len(el.events) == 0 { - return t.Sub(el.Start), false - } - prev := el.events[len(el.events)-1].When - return t.Sub(prev), prev.Day() != t.Day() - -} - -func (el *eventLog) Printf(format string, a ...interface{}) { - el.printf(false, format, a...) -} - -func (el *eventLog) Errorf(format string, a ...interface{}) { - el.printf(true, format, a...) -} - -func (el *eventLog) printf(isErr bool, format string, a ...interface{}) { - e := logEntry{When: time.Now(), IsErr: isErr, What: fmt.Sprintf(format, a...)} - el.mu.Lock() - e.Elapsed, e.NewDay = el.delta(e.When) - if len(el.events) < maxEventsPerLog { - el.events = append(el.events, e) - } else { - // Discard the oldest event. - if el.discarded == 0 { - // el.discarded starts at two to count for the event it - // is replacing, plus the next one that we are about to - // drop. - el.discarded = 2 - } else { - el.discarded++ - } - // TODO(sameer): if this causes allocations on a critical path, - // change eventLog.What to be a fmt.Stringer, as in trace.go. - el.events[0].What = fmt.Sprintf("(%d events discarded)", el.discarded) - // The timestamp of the discarded meta-event should be - // the time of the last event it is representing. - el.events[0].When = el.events[1].When - copy(el.events[1:], el.events[2:]) - el.events[maxEventsPerLog-1] = e - } - if e.IsErr { - el.LastErrorTime = e.When - } - el.mu.Unlock() -} - -func (el *eventLog) ref() { - atomic.AddInt32(&el.refs, 1) -} - -func (el *eventLog) unref() { - if atomic.AddInt32(&el.refs, -1) == 0 { - freeEventLog(el) - } -} - -func (el *eventLog) When() string { - return el.Start.Format("2006/01/02 15:04:05.000000") -} - -func (el *eventLog) ElapsedTime() string { - elapsed := time.Since(el.Start) - return fmt.Sprintf("%.6f", elapsed.Seconds()) -} - -func (el *eventLog) Stack() string { - buf := new(bytes.Buffer) - tw := tabwriter.NewWriter(buf, 1, 8, 1, '\t', 0) - printStackRecord(tw, el.stack) - tw.Flush() - return buf.String() -} - -// printStackRecord prints the function + source line information -// for a single stack trace. -// Adapted from runtime/pprof/pprof.go. -func printStackRecord(w io.Writer, stk []uintptr) { - for _, pc := range stk { - f := runtime.FuncForPC(pc) - if f == nil { - continue - } - file, line := f.FileLine(pc) - name := f.Name() - // Hide runtime.goexit and any runtime functions at the beginning. - if strings.HasPrefix(name, "runtime.") { - continue - } - fmt.Fprintf(w, "# %s\t%s:%d\n", name, file, line) - } -} - -func (el *eventLog) Events() []logEntry { - el.mu.RLock() - defer el.mu.RUnlock() - return el.events -} - -// freeEventLogs is a freelist of *eventLog -var freeEventLogs = make(chan *eventLog, 1000) - -// newEventLog returns a event log ready to use. -func newEventLog() *eventLog { - select { - case el := <-freeEventLogs: - return el - default: - return new(eventLog) - } -} - -// freeEventLog adds el to freeEventLogs if there's room. -// This is non-blocking. -func freeEventLog(el *eventLog) { - el.reset() - select { - case freeEventLogs <- el: - default: - } -} - -var eventsTmplCache *template.Template -var eventsTmplOnce sync.Once - -func eventsTmpl() *template.Template { - eventsTmplOnce.Do(func() { - eventsTmplCache = template.Must(template.New("events").Funcs(template.FuncMap{ - "elapsed": elapsed, - "trimSpace": strings.TrimSpace, - }).Parse(eventsHTML)) - }) - return eventsTmplCache -} - -const eventsHTML = ` - - - events - - - - -

/debug/events

- - - {{range $i, $fam := .Families}} - - - - {{range $j, $bucket := $.Buckets}} - {{$n := index $.Counts $i $j}} - - {{end}} - - {{end}} -
{{$fam}} - {{if $n}}{{end}} - [{{$n}} {{$bucket.String}}] - {{if $n}}{{end}} -
- -{{if $.EventLogs}} -
-

Family: {{$.Family}}

- -{{if $.Expanded}}{{end}} -[Summary]{{if $.Expanded}}{{end}} - -{{if not $.Expanded}}{{end}} -[Expanded]{{if not $.Expanded}}{{end}} - - - - {{range $el := $.EventLogs}} - - - - - {{if $.Expanded}} - - - - - - {{range $el.Events}} - - - - - - {{end}} - {{end}} - {{end}} -
WhenElapsed
{{$el.When}}{{$el.ElapsedTime}}{{$el.Title}} -
{{$el.Stack|trimSpace}}
{{.WhenString}}{{elapsed .Elapsed}}.{{if .IsErr}}E{{else}}.{{end}}. {{.What}}
-{{end}} - - -` diff --git a/vendor/golang.org/x/net/trace/histogram.go b/vendor/golang.org/x/net/trace/histogram.go deleted file mode 100644 index d6c71101e..000000000 --- a/vendor/golang.org/x/net/trace/histogram.go +++ /dev/null @@ -1,365 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package trace - -// This file implements histogramming for RPC statistics collection. - -import ( - "bytes" - "fmt" - "html/template" - "log" - "math" - "sync" - - "golang.org/x/net/internal/timeseries" -) - -const ( - bucketCount = 38 -) - -// histogram keeps counts of values in buckets that are spaced -// out in powers of 2: 0-1, 2-3, 4-7... -// histogram implements timeseries.Observable -type histogram struct { - sum int64 // running total of measurements - sumOfSquares float64 // square of running total - buckets []int64 // bucketed values for histogram - value int // holds a single value as an optimization - valueCount int64 // number of values recorded for single value -} - -// addMeasurement records a value measurement observation to the histogram. -func (h *histogram) addMeasurement(value int64) { - // TODO: assert invariant - h.sum += value - h.sumOfSquares += float64(value) * float64(value) - - bucketIndex := getBucket(value) - - if h.valueCount == 0 || (h.valueCount > 0 && h.value == bucketIndex) { - h.value = bucketIndex - h.valueCount++ - } else { - h.allocateBuckets() - h.buckets[bucketIndex]++ - } -} - -func (h *histogram) allocateBuckets() { - if h.buckets == nil { - h.buckets = make([]int64, bucketCount) - h.buckets[h.value] = h.valueCount - h.value = 0 - h.valueCount = -1 - } -} - -func log2(i int64) int { - n := 0 - for ; i >= 0x100; i >>= 8 { - n += 8 - } - for ; i > 0; i >>= 1 { - n += 1 - } - return n -} - -func getBucket(i int64) (index int) { - index = log2(i) - 1 - if index < 0 { - index = 0 - } - if index >= bucketCount { - index = bucketCount - 1 - } - return -} - -// Total returns the number of recorded observations. -func (h *histogram) total() (total int64) { - if h.valueCount >= 0 { - total = h.valueCount - } - for _, val := range h.buckets { - total += int64(val) - } - return -} - -// Average returns the average value of recorded observations. -func (h *histogram) average() float64 { - t := h.total() - if t == 0 { - return 0 - } - return float64(h.sum) / float64(t) -} - -// Variance returns the variance of recorded observations. -func (h *histogram) variance() float64 { - t := float64(h.total()) - if t == 0 { - return 0 - } - s := float64(h.sum) / t - return h.sumOfSquares/t - s*s -} - -// StandardDeviation returns the standard deviation of recorded observations. -func (h *histogram) standardDeviation() float64 { - return math.Sqrt(h.variance()) -} - -// PercentileBoundary estimates the value that the given fraction of recorded -// observations are less than. -func (h *histogram) percentileBoundary(percentile float64) int64 { - total := h.total() - - // Corner cases (make sure result is strictly less than Total()) - if total == 0 { - return 0 - } else if total == 1 { - return int64(h.average()) - } - - percentOfTotal := round(float64(total) * percentile) - var runningTotal int64 - - for i := range h.buckets { - value := h.buckets[i] - runningTotal += value - if runningTotal == percentOfTotal { - // We hit an exact bucket boundary. If the next bucket has data, it is a - // good estimate of the value. If the bucket is empty, we interpolate the - // midpoint between the next bucket's boundary and the next non-zero - // bucket. If the remaining buckets are all empty, then we use the - // boundary for the next bucket as the estimate. - j := uint8(i + 1) - min := bucketBoundary(j) - if runningTotal < total { - for h.buckets[j] == 0 { - j++ - } - } - max := bucketBoundary(j) - return min + round(float64(max-min)/2) - } else if runningTotal > percentOfTotal { - // The value is in this bucket. Interpolate the value. - delta := runningTotal - percentOfTotal - percentBucket := float64(value-delta) / float64(value) - bucketMin := bucketBoundary(uint8(i)) - nextBucketMin := bucketBoundary(uint8(i + 1)) - bucketSize := nextBucketMin - bucketMin - return bucketMin + round(percentBucket*float64(bucketSize)) - } - } - return bucketBoundary(bucketCount - 1) -} - -// Median returns the estimated median of the observed values. -func (h *histogram) median() int64 { - return h.percentileBoundary(0.5) -} - -// Add adds other to h. -func (h *histogram) Add(other timeseries.Observable) { - o := other.(*histogram) - if o.valueCount == 0 { - // Other histogram is empty - } else if h.valueCount >= 0 && o.valueCount > 0 && h.value == o.value { - // Both have a single bucketed value, aggregate them - h.valueCount += o.valueCount - } else { - // Two different values necessitate buckets in this histogram - h.allocateBuckets() - if o.valueCount >= 0 { - h.buckets[o.value] += o.valueCount - } else { - for i := range h.buckets { - h.buckets[i] += o.buckets[i] - } - } - } - h.sumOfSquares += o.sumOfSquares - h.sum += o.sum -} - -// Clear resets the histogram to an empty state, removing all observed values. -func (h *histogram) Clear() { - h.buckets = nil - h.value = 0 - h.valueCount = 0 - h.sum = 0 - h.sumOfSquares = 0 -} - -// CopyFrom copies from other, which must be a *histogram, into h. -func (h *histogram) CopyFrom(other timeseries.Observable) { - o := other.(*histogram) - if o.valueCount == -1 { - h.allocateBuckets() - copy(h.buckets, o.buckets) - } - h.sum = o.sum - h.sumOfSquares = o.sumOfSquares - h.value = o.value - h.valueCount = o.valueCount -} - -// Multiply scales the histogram by the specified ratio. -func (h *histogram) Multiply(ratio float64) { - if h.valueCount == -1 { - for i := range h.buckets { - h.buckets[i] = int64(float64(h.buckets[i]) * ratio) - } - } else { - h.valueCount = int64(float64(h.valueCount) * ratio) - } - h.sum = int64(float64(h.sum) * ratio) - h.sumOfSquares = h.sumOfSquares * ratio -} - -// New creates a new histogram. -func (h *histogram) New() timeseries.Observable { - r := new(histogram) - r.Clear() - return r -} - -func (h *histogram) String() string { - return fmt.Sprintf("%d, %f, %d, %d, %v", - h.sum, h.sumOfSquares, h.value, h.valueCount, h.buckets) -} - -// round returns the closest int64 to the argument -func round(in float64) int64 { - return int64(math.Floor(in + 0.5)) -} - -// bucketBoundary returns the first value in the bucket. -func bucketBoundary(bucket uint8) int64 { - if bucket == 0 { - return 0 - } - return 1 << bucket -} - -// bucketData holds data about a specific bucket for use in distTmpl. -type bucketData struct { - Lower, Upper int64 - N int64 - Pct, CumulativePct float64 - GraphWidth int -} - -// data holds data about a Distribution for use in distTmpl. -type data struct { - Buckets []*bucketData - Count, Median int64 - Mean, StandardDeviation float64 -} - -// maxHTMLBarWidth is the maximum width of the HTML bar for visualizing buckets. -const maxHTMLBarWidth = 350.0 - -// newData returns data representing h for use in distTmpl. -func (h *histogram) newData() *data { - // Force the allocation of buckets to simplify the rendering implementation - h.allocateBuckets() - // We scale the bars on the right so that the largest bar is - // maxHTMLBarWidth pixels in width. - maxBucket := int64(0) - for _, n := range h.buckets { - if n > maxBucket { - maxBucket = n - } - } - total := h.total() - barsizeMult := maxHTMLBarWidth / float64(maxBucket) - var pctMult float64 - if total == 0 { - pctMult = 1.0 - } else { - pctMult = 100.0 / float64(total) - } - - buckets := make([]*bucketData, len(h.buckets)) - runningTotal := int64(0) - for i, n := range h.buckets { - if n == 0 { - continue - } - runningTotal += n - var upperBound int64 - if i < bucketCount-1 { - upperBound = bucketBoundary(uint8(i + 1)) - } else { - upperBound = math.MaxInt64 - } - buckets[i] = &bucketData{ - Lower: bucketBoundary(uint8(i)), - Upper: upperBound, - N: n, - Pct: float64(n) * pctMult, - CumulativePct: float64(runningTotal) * pctMult, - GraphWidth: int(float64(n) * barsizeMult), - } - } - return &data{ - Buckets: buckets, - Count: total, - Median: h.median(), - Mean: h.average(), - StandardDeviation: h.standardDeviation(), - } -} - -func (h *histogram) html() template.HTML { - buf := new(bytes.Buffer) - if err := distTmpl().Execute(buf, h.newData()); err != nil { - buf.Reset() - log.Printf("net/trace: couldn't execute template: %v", err) - } - return template.HTML(buf.String()) -} - -var distTmplCache *template.Template -var distTmplOnce sync.Once - -func distTmpl() *template.Template { - distTmplOnce.Do(func() { - // Input: data - distTmplCache = template.Must(template.New("distTmpl").Parse(` - - - - - - - -
Count: {{.Count}}Mean: {{printf "%.0f" .Mean}}StdDev: {{printf "%.0f" .StandardDeviation}}Median: {{.Median}}
-
- -{{range $b := .Buckets}} -{{if $b}} - - - - - - - - - -{{end}} -{{end}} -
[{{.Lower}},{{.Upper}}){{.N}}{{printf "%#.3f" .Pct}}%{{printf "%#.3f" .CumulativePct}}%
-`)) - }) - return distTmplCache -} diff --git a/vendor/golang.org/x/net/trace/trace.go b/vendor/golang.org/x/net/trace/trace.go deleted file mode 100644 index eae2a99f5..000000000 --- a/vendor/golang.org/x/net/trace/trace.go +++ /dev/null @@ -1,1130 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -/* -Package trace implements tracing of requests and long-lived objects. -It exports HTTP interfaces on /debug/requests and /debug/events. - -A trace.Trace provides tracing for short-lived objects, usually requests. -A request handler might be implemented like this: - - func fooHandler(w http.ResponseWriter, req *http.Request) { - tr := trace.New("mypkg.Foo", req.URL.Path) - defer tr.Finish() - ... - tr.LazyPrintf("some event %q happened", str) - ... - if err := somethingImportant(); err != nil { - tr.LazyPrintf("somethingImportant failed: %v", err) - tr.SetError() - } - } - -The /debug/requests HTTP endpoint organizes the traces by family, -errors, and duration. It also provides histogram of request duration -for each family. - -A trace.EventLog provides tracing for long-lived objects, such as RPC -connections. - - // A Fetcher fetches URL paths for a single domain. - type Fetcher struct { - domain string - events trace.EventLog - } - - func NewFetcher(domain string) *Fetcher { - return &Fetcher{ - domain, - trace.NewEventLog("mypkg.Fetcher", domain), - } - } - - func (f *Fetcher) Fetch(path string) (string, error) { - resp, err := http.Get("http://" + f.domain + "/" + path) - if err != nil { - f.events.Errorf("Get(%q) = %v", path, err) - return "", err - } - f.events.Printf("Get(%q) = %s", path, resp.Status) - ... - } - - func (f *Fetcher) Close() error { - f.events.Finish() - return nil - } - -The /debug/events HTTP endpoint organizes the event logs by family and -by time since the last error. The expanded view displays recent log -entries and the log's call stack. -*/ -package trace // import "golang.org/x/net/trace" - -import ( - "bytes" - "context" - "fmt" - "html/template" - "io" - "log" - "net" - "net/http" - "net/url" - "runtime" - "sort" - "strconv" - "sync" - "sync/atomic" - "time" - - "golang.org/x/net/internal/timeseries" -) - -// DebugUseAfterFinish controls whether to debug uses of Trace values after finishing. -// FOR DEBUGGING ONLY. This will slow down the program. -var DebugUseAfterFinish = false - -// HTTP ServeMux paths. -const ( - debugRequestsPath = "/debug/requests" - debugEventsPath = "/debug/events" -) - -// AuthRequest determines whether a specific request is permitted to load the -// /debug/requests or /debug/events pages. -// -// It returns two bools; the first indicates whether the page may be viewed at all, -// and the second indicates whether sensitive events will be shown. -// -// AuthRequest may be replaced by a program to customize its authorization requirements. -// -// The default AuthRequest function returns (true, true) if and only if the request -// comes from localhost/127.0.0.1/[::1]. -var AuthRequest = func(req *http.Request) (any, sensitive bool) { - // RemoteAddr is commonly in the form "IP" or "IP:port". - // If it is in the form "IP:port", split off the port. - host, _, err := net.SplitHostPort(req.RemoteAddr) - if err != nil { - host = req.RemoteAddr - } - switch host { - case "localhost", "127.0.0.1", "::1": - return true, true - default: - return false, false - } -} - -func init() { - _, pat := http.DefaultServeMux.Handler(&http.Request{URL: &url.URL{Path: debugRequestsPath}}) - if pat == debugRequestsPath { - panic("/debug/requests is already registered. You may have two independent copies of " + - "golang.org/x/net/trace in your binary, trying to maintain separate state. This may " + - "involve a vendored copy of golang.org/x/net/trace.") - } - - // TODO(jbd): Serve Traces from /debug/traces in the future? - // There is no requirement for a request to be present to have traces. - http.HandleFunc(debugRequestsPath, Traces) - http.HandleFunc(debugEventsPath, Events) -} - -// NewContext returns a copy of the parent context -// and associates it with a Trace. -func NewContext(ctx context.Context, tr Trace) context.Context { - return context.WithValue(ctx, contextKey, tr) -} - -// FromContext returns the Trace bound to the context, if any. -func FromContext(ctx context.Context) (tr Trace, ok bool) { - tr, ok = ctx.Value(contextKey).(Trace) - return -} - -// Traces responds with traces from the program. -// The package initialization registers it in http.DefaultServeMux -// at /debug/requests. -// -// It performs authorization by running AuthRequest. -func Traces(w http.ResponseWriter, req *http.Request) { - any, sensitive := AuthRequest(req) - if !any { - http.Error(w, "not allowed", http.StatusUnauthorized) - return - } - w.Header().Set("Content-Type", "text/html; charset=utf-8") - Render(w, req, sensitive) -} - -// Events responds with a page of events collected by EventLogs. -// The package initialization registers it in http.DefaultServeMux -// at /debug/events. -// -// It performs authorization by running AuthRequest. -func Events(w http.ResponseWriter, req *http.Request) { - any, sensitive := AuthRequest(req) - if !any { - http.Error(w, "not allowed", http.StatusUnauthorized) - return - } - w.Header().Set("Content-Type", "text/html; charset=utf-8") - RenderEvents(w, req, sensitive) -} - -// Render renders the HTML page typically served at /debug/requests. -// It does not do any auth checking. The request may be nil. -// -// Most users will use the Traces handler. -func Render(w io.Writer, req *http.Request, sensitive bool) { - data := &struct { - Families []string - ActiveTraceCount map[string]int - CompletedTraces map[string]*family - - // Set when a bucket has been selected. - Traces traceList - Family string - Bucket int - Expanded bool - Traced bool - Active bool - ShowSensitive bool // whether to show sensitive events - - Histogram template.HTML - HistogramWindow string // e.g. "last minute", "last hour", "all time" - - // If non-zero, the set of traces is a partial set, - // and this is the total number. - Total int - }{ - CompletedTraces: completedTraces, - } - - data.ShowSensitive = sensitive - if req != nil { - // Allow show_sensitive=0 to force hiding of sensitive data for testing. - // This only goes one way; you can't use show_sensitive=1 to see things. - if req.FormValue("show_sensitive") == "0" { - data.ShowSensitive = false - } - - if exp, err := strconv.ParseBool(req.FormValue("exp")); err == nil { - data.Expanded = exp - } - if exp, err := strconv.ParseBool(req.FormValue("rtraced")); err == nil { - data.Traced = exp - } - } - - completedMu.RLock() - data.Families = make([]string, 0, len(completedTraces)) - for fam := range completedTraces { - data.Families = append(data.Families, fam) - } - completedMu.RUnlock() - sort.Strings(data.Families) - - // We are careful here to minimize the time spent locking activeMu, - // since that lock is required every time an RPC starts and finishes. - data.ActiveTraceCount = make(map[string]int, len(data.Families)) - activeMu.RLock() - for fam, s := range activeTraces { - data.ActiveTraceCount[fam] = s.Len() - } - activeMu.RUnlock() - - var ok bool - data.Family, data.Bucket, ok = parseArgs(req) - switch { - case !ok: - // No-op - case data.Bucket == -1: - data.Active = true - n := data.ActiveTraceCount[data.Family] - data.Traces = getActiveTraces(data.Family) - if len(data.Traces) < n { - data.Total = n - } - case data.Bucket < bucketsPerFamily: - if b := lookupBucket(data.Family, data.Bucket); b != nil { - data.Traces = b.Copy(data.Traced) - } - default: - if f := getFamily(data.Family, false); f != nil { - var obs timeseries.Observable - f.LatencyMu.RLock() - switch o := data.Bucket - bucketsPerFamily; o { - case 0: - obs = f.Latency.Minute() - data.HistogramWindow = "last minute" - case 1: - obs = f.Latency.Hour() - data.HistogramWindow = "last hour" - case 2: - obs = f.Latency.Total() - data.HistogramWindow = "all time" - } - f.LatencyMu.RUnlock() - if obs != nil { - data.Histogram = obs.(*histogram).html() - } - } - } - - if data.Traces != nil { - defer data.Traces.Free() - sort.Sort(data.Traces) - } - - completedMu.RLock() - defer completedMu.RUnlock() - if err := pageTmpl().ExecuteTemplate(w, "Page", data); err != nil { - log.Printf("net/trace: Failed executing template: %v", err) - } -} - -func parseArgs(req *http.Request) (fam string, b int, ok bool) { - if req == nil { - return "", 0, false - } - fam, bStr := req.FormValue("fam"), req.FormValue("b") - if fam == "" || bStr == "" { - return "", 0, false - } - b, err := strconv.Atoi(bStr) - if err != nil || b < -1 { - return "", 0, false - } - - return fam, b, true -} - -func lookupBucket(fam string, b int) *traceBucket { - f := getFamily(fam, false) - if f == nil || b < 0 || b >= len(f.Buckets) { - return nil - } - return f.Buckets[b] -} - -type contextKeyT string - -var contextKey = contextKeyT("golang.org/x/net/trace.Trace") - -// Trace represents an active request. -type Trace interface { - // LazyLog adds x to the event log. It will be evaluated each time the - // /debug/requests page is rendered. Any memory referenced by x will be - // pinned until the trace is finished and later discarded. - LazyLog(x fmt.Stringer, sensitive bool) - - // LazyPrintf evaluates its arguments with fmt.Sprintf each time the - // /debug/requests page is rendered. Any memory referenced by a will be - // pinned until the trace is finished and later discarded. - LazyPrintf(format string, a ...interface{}) - - // SetError declares that this trace resulted in an error. - SetError() - - // SetRecycler sets a recycler for the trace. - // f will be called for each event passed to LazyLog at a time when - // it is no longer required, whether while the trace is still active - // and the event is discarded, or when a completed trace is discarded. - SetRecycler(f func(interface{})) - - // SetTraceInfo sets the trace info for the trace. - // This is currently unused. - SetTraceInfo(traceID, spanID uint64) - - // SetMaxEvents sets the maximum number of events that will be stored - // in the trace. This has no effect if any events have already been - // added to the trace. - SetMaxEvents(m int) - - // Finish declares that this trace is complete. - // The trace should not be used after calling this method. - Finish() -} - -type lazySprintf struct { - format string - a []interface{} -} - -func (l *lazySprintf) String() string { - return fmt.Sprintf(l.format, l.a...) -} - -// New returns a new Trace with the specified family and title. -func New(family, title string) Trace { - tr := newTrace() - tr.ref() - tr.Family, tr.Title = family, title - tr.Start = time.Now() - tr.maxEvents = maxEventsPerTrace - tr.events = tr.eventsBuf[:0] - - activeMu.RLock() - s := activeTraces[tr.Family] - activeMu.RUnlock() - if s == nil { - activeMu.Lock() - s = activeTraces[tr.Family] // check again - if s == nil { - s = new(traceSet) - activeTraces[tr.Family] = s - } - activeMu.Unlock() - } - s.Add(tr) - - // Trigger allocation of the completed trace structure for this family. - // This will cause the family to be present in the request page during - // the first trace of this family. We don't care about the return value, - // nor is there any need for this to run inline, so we execute it in its - // own goroutine, but only if the family isn't allocated yet. - completedMu.RLock() - if _, ok := completedTraces[tr.Family]; !ok { - go allocFamily(tr.Family) - } - completedMu.RUnlock() - - return tr -} - -func (tr *trace) Finish() { - elapsed := time.Since(tr.Start) - tr.mu.Lock() - tr.Elapsed = elapsed - tr.mu.Unlock() - - if DebugUseAfterFinish { - buf := make([]byte, 4<<10) // 4 KB should be enough - n := runtime.Stack(buf, false) - tr.finishStack = buf[:n] - } - - activeMu.RLock() - m := activeTraces[tr.Family] - activeMu.RUnlock() - m.Remove(tr) - - f := getFamily(tr.Family, true) - tr.mu.RLock() // protects tr fields in Cond.match calls - for _, b := range f.Buckets { - if b.Cond.match(tr) { - b.Add(tr) - } - } - tr.mu.RUnlock() - - // Add a sample of elapsed time as microseconds to the family's timeseries - h := new(histogram) - h.addMeasurement(elapsed.Nanoseconds() / 1e3) - f.LatencyMu.Lock() - f.Latency.Add(h) - f.LatencyMu.Unlock() - - tr.unref() // matches ref in New -} - -const ( - bucketsPerFamily = 9 - tracesPerBucket = 10 - maxActiveTraces = 20 // Maximum number of active traces to show. - maxEventsPerTrace = 10 - numHistogramBuckets = 38 -) - -var ( - // The active traces. - activeMu sync.RWMutex - activeTraces = make(map[string]*traceSet) // family -> traces - - // Families of completed traces. - completedMu sync.RWMutex - completedTraces = make(map[string]*family) // family -> traces -) - -type traceSet struct { - mu sync.RWMutex - m map[*trace]bool - - // We could avoid the entire map scan in FirstN by having a slice of all the traces - // ordered by start time, and an index into that from the trace struct, with a periodic - // repack of the slice after enough traces finish; we could also use a skip list or similar. - // However, that would shift some of the expense from /debug/requests time to RPC time, - // which is probably the wrong trade-off. -} - -func (ts *traceSet) Len() int { - ts.mu.RLock() - defer ts.mu.RUnlock() - return len(ts.m) -} - -func (ts *traceSet) Add(tr *trace) { - ts.mu.Lock() - if ts.m == nil { - ts.m = make(map[*trace]bool) - } - ts.m[tr] = true - ts.mu.Unlock() -} - -func (ts *traceSet) Remove(tr *trace) { - ts.mu.Lock() - delete(ts.m, tr) - ts.mu.Unlock() -} - -// FirstN returns the first n traces ordered by time. -func (ts *traceSet) FirstN(n int) traceList { - ts.mu.RLock() - defer ts.mu.RUnlock() - - if n > len(ts.m) { - n = len(ts.m) - } - trl := make(traceList, 0, n) - - // Fast path for when no selectivity is needed. - if n == len(ts.m) { - for tr := range ts.m { - tr.ref() - trl = append(trl, tr) - } - sort.Sort(trl) - return trl - } - - // Pick the oldest n traces. - // This is inefficient. See the comment in the traceSet struct. - for tr := range ts.m { - // Put the first n traces into trl in the order they occur. - // When we have n, sort trl, and thereafter maintain its order. - if len(trl) < n { - tr.ref() - trl = append(trl, tr) - if len(trl) == n { - // This is guaranteed to happen exactly once during this loop. - sort.Sort(trl) - } - continue - } - if tr.Start.After(trl[n-1].Start) { - continue - } - - // Find where to insert this one. - tr.ref() - i := sort.Search(n, func(i int) bool { return trl[i].Start.After(tr.Start) }) - trl[n-1].unref() - copy(trl[i+1:], trl[i:]) - trl[i] = tr - } - - return trl -} - -func getActiveTraces(fam string) traceList { - activeMu.RLock() - s := activeTraces[fam] - activeMu.RUnlock() - if s == nil { - return nil - } - return s.FirstN(maxActiveTraces) -} - -func getFamily(fam string, allocNew bool) *family { - completedMu.RLock() - f := completedTraces[fam] - completedMu.RUnlock() - if f == nil && allocNew { - f = allocFamily(fam) - } - return f -} - -func allocFamily(fam string) *family { - completedMu.Lock() - defer completedMu.Unlock() - f := completedTraces[fam] - if f == nil { - f = newFamily() - completedTraces[fam] = f - } - return f -} - -// family represents a set of trace buckets and associated latency information. -type family struct { - // traces may occur in multiple buckets. - Buckets [bucketsPerFamily]*traceBucket - - // latency time series - LatencyMu sync.RWMutex - Latency *timeseries.MinuteHourSeries -} - -func newFamily() *family { - return &family{ - Buckets: [bucketsPerFamily]*traceBucket{ - {Cond: minCond(0)}, - {Cond: minCond(50 * time.Millisecond)}, - {Cond: minCond(100 * time.Millisecond)}, - {Cond: minCond(200 * time.Millisecond)}, - {Cond: minCond(500 * time.Millisecond)}, - {Cond: minCond(1 * time.Second)}, - {Cond: minCond(10 * time.Second)}, - {Cond: minCond(100 * time.Second)}, - {Cond: errorCond{}}, - }, - Latency: timeseries.NewMinuteHourSeries(func() timeseries.Observable { return new(histogram) }), - } -} - -// traceBucket represents a size-capped bucket of historic traces, -// along with a condition for a trace to belong to the bucket. -type traceBucket struct { - Cond cond - - // Ring buffer implementation of a fixed-size FIFO queue. - mu sync.RWMutex - buf [tracesPerBucket]*trace - start int // < tracesPerBucket - length int // <= tracesPerBucket -} - -func (b *traceBucket) Add(tr *trace) { - b.mu.Lock() - defer b.mu.Unlock() - - i := b.start + b.length - if i >= tracesPerBucket { - i -= tracesPerBucket - } - if b.length == tracesPerBucket { - // "Remove" an element from the bucket. - b.buf[i].unref() - b.start++ - if b.start == tracesPerBucket { - b.start = 0 - } - } - b.buf[i] = tr - if b.length < tracesPerBucket { - b.length++ - } - tr.ref() -} - -// Copy returns a copy of the traces in the bucket. -// If tracedOnly is true, only the traces with trace information will be returned. -// The logs will be ref'd before returning; the caller should call -// the Free method when it is done with them. -// TODO(dsymonds): keep track of traced requests in separate buckets. -func (b *traceBucket) Copy(tracedOnly bool) traceList { - b.mu.RLock() - defer b.mu.RUnlock() - - trl := make(traceList, 0, b.length) - for i, x := 0, b.start; i < b.length; i++ { - tr := b.buf[x] - if !tracedOnly || tr.spanID != 0 { - tr.ref() - trl = append(trl, tr) - } - x++ - if x == b.length { - x = 0 - } - } - return trl -} - -func (b *traceBucket) Empty() bool { - b.mu.RLock() - defer b.mu.RUnlock() - return b.length == 0 -} - -// cond represents a condition on a trace. -type cond interface { - match(t *trace) bool - String() string -} - -type minCond time.Duration - -func (m minCond) match(t *trace) bool { return t.Elapsed >= time.Duration(m) } -func (m minCond) String() string { return fmt.Sprintf("≥%gs", time.Duration(m).Seconds()) } - -type errorCond struct{} - -func (e errorCond) match(t *trace) bool { return t.IsError } -func (e errorCond) String() string { return "errors" } - -type traceList []*trace - -// Free calls unref on each element of the list. -func (trl traceList) Free() { - for _, t := range trl { - t.unref() - } -} - -// traceList may be sorted in reverse chronological order. -func (trl traceList) Len() int { return len(trl) } -func (trl traceList) Less(i, j int) bool { return trl[i].Start.After(trl[j].Start) } -func (trl traceList) Swap(i, j int) { trl[i], trl[j] = trl[j], trl[i] } - -// An event is a timestamped log entry in a trace. -type event struct { - When time.Time - Elapsed time.Duration // since previous event in trace - NewDay bool // whether this event is on a different day to the previous event - Recyclable bool // whether this event was passed via LazyLog - Sensitive bool // whether this event contains sensitive information - What interface{} // string or fmt.Stringer -} - -// WhenString returns a string representation of the elapsed time of the event. -// It will include the date if midnight was crossed. -func (e event) WhenString() string { - if e.NewDay { - return e.When.Format("2006/01/02 15:04:05.000000") - } - return e.When.Format("15:04:05.000000") -} - -// discarded represents a number of discarded events. -// It is stored as *discarded to make it easier to update in-place. -type discarded int - -func (d *discarded) String() string { - return fmt.Sprintf("(%d events discarded)", int(*d)) -} - -// trace represents an active or complete request, -// either sent or received by this program. -type trace struct { - // Family is the top-level grouping of traces to which this belongs. - Family string - - // Title is the title of this trace. - Title string - - // Start time of the this trace. - Start time.Time - - mu sync.RWMutex - events []event // Append-only sequence of events (modulo discards). - maxEvents int - recycler func(interface{}) - IsError bool // Whether this trace resulted in an error. - Elapsed time.Duration // Elapsed time for this trace, zero while active. - traceID uint64 // Trace information if non-zero. - spanID uint64 - - refs int32 // how many buckets this is in - disc discarded // scratch space to avoid allocation - - finishStack []byte // where finish was called, if DebugUseAfterFinish is set - - eventsBuf [4]event // preallocated buffer in case we only log a few events -} - -func (tr *trace) reset() { - // Clear all but the mutex. Mutexes may not be copied, even when unlocked. - tr.Family = "" - tr.Title = "" - tr.Start = time.Time{} - - tr.mu.Lock() - tr.Elapsed = 0 - tr.traceID = 0 - tr.spanID = 0 - tr.IsError = false - tr.maxEvents = 0 - tr.events = nil - tr.recycler = nil - tr.mu.Unlock() - - tr.refs = 0 - tr.disc = 0 - tr.finishStack = nil - for i := range tr.eventsBuf { - tr.eventsBuf[i] = event{} - } -} - -// delta returns the elapsed time since the last event or the trace start, -// and whether it spans midnight. -// L >= tr.mu -func (tr *trace) delta(t time.Time) (time.Duration, bool) { - if len(tr.events) == 0 { - return t.Sub(tr.Start), false - } - prev := tr.events[len(tr.events)-1].When - return t.Sub(prev), prev.Day() != t.Day() -} - -func (tr *trace) addEvent(x interface{}, recyclable, sensitive bool) { - if DebugUseAfterFinish && tr.finishStack != nil { - buf := make([]byte, 4<<10) // 4 KB should be enough - n := runtime.Stack(buf, false) - log.Printf("net/trace: trace used after finish:\nFinished at:\n%s\nUsed at:\n%s", tr.finishStack, buf[:n]) - } - - /* - NOTE TO DEBUGGERS - - If you are here because your program panicked in this code, - it is almost definitely the fault of code using this package, - and very unlikely to be the fault of this code. - - The most likely scenario is that some code elsewhere is using - a trace.Trace after its Finish method is called. - You can temporarily set the DebugUseAfterFinish var - to help discover where that is; do not leave that var set, - since it makes this package much less efficient. - */ - - e := event{When: time.Now(), What: x, Recyclable: recyclable, Sensitive: sensitive} - tr.mu.Lock() - e.Elapsed, e.NewDay = tr.delta(e.When) - if len(tr.events) < tr.maxEvents { - tr.events = append(tr.events, e) - } else { - // Discard the middle events. - di := int((tr.maxEvents - 1) / 2) - if d, ok := tr.events[di].What.(*discarded); ok { - (*d)++ - } else { - // disc starts at two to count for the event it is replacing, - // plus the next one that we are about to drop. - tr.disc = 2 - if tr.recycler != nil && tr.events[di].Recyclable { - go tr.recycler(tr.events[di].What) - } - tr.events[di].What = &tr.disc - } - // The timestamp of the discarded meta-event should be - // the time of the last event it is representing. - tr.events[di].When = tr.events[di+1].When - - if tr.recycler != nil && tr.events[di+1].Recyclable { - go tr.recycler(tr.events[di+1].What) - } - copy(tr.events[di+1:], tr.events[di+2:]) - tr.events[tr.maxEvents-1] = e - } - tr.mu.Unlock() -} - -func (tr *trace) LazyLog(x fmt.Stringer, sensitive bool) { - tr.addEvent(x, true, sensitive) -} - -func (tr *trace) LazyPrintf(format string, a ...interface{}) { - tr.addEvent(&lazySprintf{format, a}, false, false) -} - -func (tr *trace) SetError() { - tr.mu.Lock() - tr.IsError = true - tr.mu.Unlock() -} - -func (tr *trace) SetRecycler(f func(interface{})) { - tr.mu.Lock() - tr.recycler = f - tr.mu.Unlock() -} - -func (tr *trace) SetTraceInfo(traceID, spanID uint64) { - tr.mu.Lock() - tr.traceID, tr.spanID = traceID, spanID - tr.mu.Unlock() -} - -func (tr *trace) SetMaxEvents(m int) { - tr.mu.Lock() - // Always keep at least three events: first, discarded count, last. - if len(tr.events) == 0 && m > 3 { - tr.maxEvents = m - } - tr.mu.Unlock() -} - -func (tr *trace) ref() { - atomic.AddInt32(&tr.refs, 1) -} - -func (tr *trace) unref() { - if atomic.AddInt32(&tr.refs, -1) == 0 { - tr.mu.RLock() - if tr.recycler != nil { - // freeTrace clears tr, so we hold tr.recycler and tr.events here. - go func(f func(interface{}), es []event) { - for _, e := range es { - if e.Recyclable { - f(e.What) - } - } - }(tr.recycler, tr.events) - } - tr.mu.RUnlock() - - freeTrace(tr) - } -} - -func (tr *trace) When() string { - return tr.Start.Format("2006/01/02 15:04:05.000000") -} - -func (tr *trace) ElapsedTime() string { - tr.mu.RLock() - t := tr.Elapsed - tr.mu.RUnlock() - - if t == 0 { - // Active trace. - t = time.Since(tr.Start) - } - return fmt.Sprintf("%.6f", t.Seconds()) -} - -func (tr *trace) Events() []event { - tr.mu.RLock() - defer tr.mu.RUnlock() - return tr.events -} - -var traceFreeList = make(chan *trace, 1000) // TODO(dsymonds): Use sync.Pool? - -// newTrace returns a trace ready to use. -func newTrace() *trace { - select { - case tr := <-traceFreeList: - return tr - default: - return new(trace) - } -} - -// freeTrace adds tr to traceFreeList if there's room. -// This is non-blocking. -func freeTrace(tr *trace) { - if DebugUseAfterFinish { - return // never reuse - } - tr.reset() - select { - case traceFreeList <- tr: - default: - } -} - -func elapsed(d time.Duration) string { - b := []byte(fmt.Sprintf("%.6f", d.Seconds())) - - // For subsecond durations, blank all zeros before decimal point, - // and all zeros between the decimal point and the first non-zero digit. - if d < time.Second { - dot := bytes.IndexByte(b, '.') - for i := 0; i < dot; i++ { - b[i] = ' ' - } - for i := dot + 1; i < len(b); i++ { - if b[i] == '0' { - b[i] = ' ' - } else { - break - } - } - } - - return string(b) -} - -var pageTmplCache *template.Template -var pageTmplOnce sync.Once - -func pageTmpl() *template.Template { - pageTmplOnce.Do(func() { - pageTmplCache = template.Must(template.New("Page").Funcs(template.FuncMap{ - "elapsed": elapsed, - "add": func(a, b int) int { return a + b }, - }).Parse(pageHTML)) - }) - return pageTmplCache -} - -const pageHTML = ` -{{template "Prolog" .}} -{{template "StatusTable" .}} -{{template "Epilog" .}} - -{{define "Prolog"}} - - - /debug/requests - - - - -

/debug/requests

-{{end}} {{/* end of Prolog */}} - -{{define "StatusTable"}} - - {{range $fam := .Families}} - - - - {{$n := index $.ActiveTraceCount $fam}} - - - {{$f := index $.CompletedTraces $fam}} - {{range $i, $b := $f.Buckets}} - {{$empty := $b.Empty}} - - {{end}} - - {{$nb := len $f.Buckets}} - - - - - - {{end}} -
{{$fam}} - {{if $n}}{{end}} - [{{$n}} active] - {{if $n}}{{end}} - - {{if not $empty}}{{end}} - [{{.Cond}}] - {{if not $empty}}{{end}} - - [minute] - - [hour] - - [total] -
-{{end}} {{/* end of StatusTable */}} - -{{define "Epilog"}} -{{if $.Traces}} -
-

Family: {{$.Family}}

- -{{if or $.Expanded $.Traced}} - [Normal/Summary] -{{else}} - [Normal/Summary] -{{end}} - -{{if or (not $.Expanded) $.Traced}} - [Normal/Expanded] -{{else}} - [Normal/Expanded] -{{end}} - -{{if not $.Active}} - {{if or $.Expanded (not $.Traced)}} - [Traced/Summary] - {{else}} - [Traced/Summary] - {{end}} - {{if or (not $.Expanded) (not $.Traced)}} - [Traced/Expanded] - {{else}} - [Traced/Expanded] - {{end}} -{{end}} - -{{if $.Total}} -

Showing {{len $.Traces}} of {{$.Total}} traces.

-{{end}} - - - - - {{range $tr := $.Traces}} - - - - - {{/* TODO: include traceID/spanID */}} - - {{if $.Expanded}} - {{range $tr.Events}} - - - - - - {{end}} - {{end}} - {{end}} -
- {{if $.Active}}Active{{else}}Completed{{end}} Requests -
WhenElapsed (s)
{{$tr.When}}{{$tr.ElapsedTime}}{{$tr.Title}}
{{.WhenString}}{{elapsed .Elapsed}}{{if or $.ShowSensitive (not .Sensitive)}}... {{.What}}{{else}}[redacted]{{end}}
-{{end}} {{/* if $.Traces */}} - -{{if $.Histogram}} -

Latency (µs) of {{$.Family}} over {{$.HistogramWindow}}

-{{$.Histogram}} -{{end}} {{/* if $.Histogram */}} - - - -{{end}} {{/* end of Epilog */}} -` diff --git a/vendor/golang.org/x/text/width/kind_string.go b/vendor/golang.org/x/text/width/kind_string.go deleted file mode 100644 index dd3febd43..000000000 --- a/vendor/golang.org/x/text/width/kind_string.go +++ /dev/null @@ -1,28 +0,0 @@ -// Code generated by "stringer -type=Kind"; DO NOT EDIT. - -package width - -import "strconv" - -func _() { - // An "invalid array index" compiler error signifies that the constant values have changed. - // Re-run the stringer command to generate them again. - var x [1]struct{} - _ = x[Neutral-0] - _ = x[EastAsianAmbiguous-1] - _ = x[EastAsianWide-2] - _ = x[EastAsianNarrow-3] - _ = x[EastAsianFullwidth-4] - _ = x[EastAsianHalfwidth-5] -} - -const _Kind_name = "NeutralEastAsianAmbiguousEastAsianWideEastAsianNarrowEastAsianFullwidthEastAsianHalfwidth" - -var _Kind_index = [...]uint8{0, 7, 25, 38, 53, 71, 89} - -func (i Kind) String() string { - if i < 0 || i >= Kind(len(_Kind_index)-1) { - return "Kind(" + strconv.FormatInt(int64(i), 10) + ")" - } - return _Kind_name[_Kind_index[i]:_Kind_index[i+1]] -} diff --git a/vendor/golang.org/x/text/width/tables10.0.0.go b/vendor/golang.org/x/text/width/tables10.0.0.go deleted file mode 100644 index 07c1cb17a..000000000 --- a/vendor/golang.org/x/text/width/tables10.0.0.go +++ /dev/null @@ -1,1328 +0,0 @@ -// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. - -//go:build go1.10 && !go1.13 - -package width - -// UnicodeVersion is the Unicode version from which the tables in this package are derived. -const UnicodeVersion = "10.0.0" - -// lookup returns the trie value for the first UTF-8 encoding in s and -// the width in bytes of this encoding. The size will be 0 if s does not -// hold enough bytes to complete the encoding. len(s) must be greater than 0. -func (t *widthTrie) lookup(s []byte) (v uint16, sz int) { - c0 := s[0] - switch { - case c0 < 0x80: // is ASCII - return widthValues[c0], 1 - case c0 < 0xC2: - return 0, 1 // Illegal UTF-8: not a starter, not ASCII. - case c0 < 0xE0: // 2-byte UTF-8 - if len(s) < 2 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c1), 2 - case c0 < 0xF0: // 3-byte UTF-8 - if len(s) < 3 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c2), 3 - case c0 < 0xF8: // 4-byte UTF-8 - if len(s) < 4 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - o = uint32(i)<<6 + uint32(c2) - i = widthIndex[o] - c3 := s[3] - if c3 < 0x80 || 0xC0 <= c3 { - return 0, 3 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c3), 4 - } - // Illegal rune - return 0, 1 -} - -// lookupUnsafe returns the trie value for the first UTF-8 encoding in s. -// s must start with a full and valid UTF-8 encoded rune. -func (t *widthTrie) lookupUnsafe(s []byte) uint16 { - c0 := s[0] - if c0 < 0x80 { // is ASCII - return widthValues[c0] - } - i := widthIndex[c0] - if c0 < 0xE0 { // 2-byte UTF-8 - return t.lookupValue(uint32(i), s[1]) - } - i = widthIndex[uint32(i)<<6+uint32(s[1])] - if c0 < 0xF0 { // 3-byte UTF-8 - return t.lookupValue(uint32(i), s[2]) - } - i = widthIndex[uint32(i)<<6+uint32(s[2])] - if c0 < 0xF8 { // 4-byte UTF-8 - return t.lookupValue(uint32(i), s[3]) - } - return 0 -} - -// lookupString returns the trie value for the first UTF-8 encoding in s and -// the width in bytes of this encoding. The size will be 0 if s does not -// hold enough bytes to complete the encoding. len(s) must be greater than 0. -func (t *widthTrie) lookupString(s string) (v uint16, sz int) { - c0 := s[0] - switch { - case c0 < 0x80: // is ASCII - return widthValues[c0], 1 - case c0 < 0xC2: - return 0, 1 // Illegal UTF-8: not a starter, not ASCII. - case c0 < 0xE0: // 2-byte UTF-8 - if len(s) < 2 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c1), 2 - case c0 < 0xF0: // 3-byte UTF-8 - if len(s) < 3 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c2), 3 - case c0 < 0xF8: // 4-byte UTF-8 - if len(s) < 4 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - o = uint32(i)<<6 + uint32(c2) - i = widthIndex[o] - c3 := s[3] - if c3 < 0x80 || 0xC0 <= c3 { - return 0, 3 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c3), 4 - } - // Illegal rune - return 0, 1 -} - -// lookupStringUnsafe returns the trie value for the first UTF-8 encoding in s. -// s must start with a full and valid UTF-8 encoded rune. -func (t *widthTrie) lookupStringUnsafe(s string) uint16 { - c0 := s[0] - if c0 < 0x80 { // is ASCII - return widthValues[c0] - } - i := widthIndex[c0] - if c0 < 0xE0 { // 2-byte UTF-8 - return t.lookupValue(uint32(i), s[1]) - } - i = widthIndex[uint32(i)<<6+uint32(s[1])] - if c0 < 0xF0 { // 3-byte UTF-8 - return t.lookupValue(uint32(i), s[2]) - } - i = widthIndex[uint32(i)<<6+uint32(s[2])] - if c0 < 0xF8 { // 4-byte UTF-8 - return t.lookupValue(uint32(i), s[3]) - } - return 0 -} - -// widthTrie. Total size: 14336 bytes (14.00 KiB). Checksum: c59df54630d3dc4a. -type widthTrie struct{} - -func newWidthTrie(i int) *widthTrie { - return &widthTrie{} -} - -// lookupValue determines the type of block n and looks up the value for b. -func (t *widthTrie) lookupValue(n uint32, b byte) uint16 { - switch { - default: - return uint16(widthValues[n<<6+uint32(b)]) - } -} - -// widthValues: 101 blocks, 6464 entries, 12928 bytes -// The third block is the zero block. -var widthValues = [6464]uint16{ - // Block 0x0, offset 0x0 - 0x20: 0x6001, 0x21: 0x6002, 0x22: 0x6002, 0x23: 0x6002, - 0x24: 0x6002, 0x25: 0x6002, 0x26: 0x6002, 0x27: 0x6002, 0x28: 0x6002, 0x29: 0x6002, - 0x2a: 0x6002, 0x2b: 0x6002, 0x2c: 0x6002, 0x2d: 0x6002, 0x2e: 0x6002, 0x2f: 0x6002, - 0x30: 0x6002, 0x31: 0x6002, 0x32: 0x6002, 0x33: 0x6002, 0x34: 0x6002, 0x35: 0x6002, - 0x36: 0x6002, 0x37: 0x6002, 0x38: 0x6002, 0x39: 0x6002, 0x3a: 0x6002, 0x3b: 0x6002, - 0x3c: 0x6002, 0x3d: 0x6002, 0x3e: 0x6002, 0x3f: 0x6002, - // Block 0x1, offset 0x40 - 0x40: 0x6003, 0x41: 0x6003, 0x42: 0x6003, 0x43: 0x6003, 0x44: 0x6003, 0x45: 0x6003, - 0x46: 0x6003, 0x47: 0x6003, 0x48: 0x6003, 0x49: 0x6003, 0x4a: 0x6003, 0x4b: 0x6003, - 0x4c: 0x6003, 0x4d: 0x6003, 0x4e: 0x6003, 0x4f: 0x6003, 0x50: 0x6003, 0x51: 0x6003, - 0x52: 0x6003, 0x53: 0x6003, 0x54: 0x6003, 0x55: 0x6003, 0x56: 0x6003, 0x57: 0x6003, - 0x58: 0x6003, 0x59: 0x6003, 0x5a: 0x6003, 0x5b: 0x6003, 0x5c: 0x6003, 0x5d: 0x6003, - 0x5e: 0x6003, 0x5f: 0x6003, 0x60: 0x6004, 0x61: 0x6004, 0x62: 0x6004, 0x63: 0x6004, - 0x64: 0x6004, 0x65: 0x6004, 0x66: 0x6004, 0x67: 0x6004, 0x68: 0x6004, 0x69: 0x6004, - 0x6a: 0x6004, 0x6b: 0x6004, 0x6c: 0x6004, 0x6d: 0x6004, 0x6e: 0x6004, 0x6f: 0x6004, - 0x70: 0x6004, 0x71: 0x6004, 0x72: 0x6004, 0x73: 0x6004, 0x74: 0x6004, 0x75: 0x6004, - 0x76: 0x6004, 0x77: 0x6004, 0x78: 0x6004, 0x79: 0x6004, 0x7a: 0x6004, 0x7b: 0x6004, - 0x7c: 0x6004, 0x7d: 0x6004, 0x7e: 0x6004, - // Block 0x2, offset 0x80 - // Block 0x3, offset 0xc0 - 0xe1: 0x2000, 0xe2: 0x6005, 0xe3: 0x6005, - 0xe4: 0x2000, 0xe5: 0x6006, 0xe6: 0x6005, 0xe7: 0x2000, 0xe8: 0x2000, - 0xea: 0x2000, 0xec: 0x6007, 0xed: 0x2000, 0xee: 0x2000, 0xef: 0x6008, - 0xf0: 0x2000, 0xf1: 0x2000, 0xf2: 0x2000, 0xf3: 0x2000, 0xf4: 0x2000, - 0xf6: 0x2000, 0xf7: 0x2000, 0xf8: 0x2000, 0xf9: 0x2000, 0xfa: 0x2000, - 0xfc: 0x2000, 0xfd: 0x2000, 0xfe: 0x2000, 0xff: 0x2000, - // Block 0x4, offset 0x100 - 0x106: 0x2000, - 0x110: 0x2000, - 0x117: 0x2000, - 0x118: 0x2000, - 0x11e: 0x2000, 0x11f: 0x2000, 0x120: 0x2000, 0x121: 0x2000, - 0x126: 0x2000, 0x128: 0x2000, 0x129: 0x2000, - 0x12a: 0x2000, 0x12c: 0x2000, 0x12d: 0x2000, - 0x130: 0x2000, 0x132: 0x2000, 0x133: 0x2000, - 0x137: 0x2000, 0x138: 0x2000, 0x139: 0x2000, 0x13a: 0x2000, - 0x13c: 0x2000, 0x13e: 0x2000, - // Block 0x5, offset 0x140 - 0x141: 0x2000, - 0x151: 0x2000, - 0x153: 0x2000, - 0x15b: 0x2000, - 0x166: 0x2000, 0x167: 0x2000, - 0x16b: 0x2000, - 0x171: 0x2000, 0x172: 0x2000, 0x173: 0x2000, - 0x178: 0x2000, - 0x17f: 0x2000, - // Block 0x6, offset 0x180 - 0x180: 0x2000, 0x181: 0x2000, 0x182: 0x2000, 0x184: 0x2000, - 0x188: 0x2000, 0x189: 0x2000, 0x18a: 0x2000, 0x18b: 0x2000, - 0x18d: 0x2000, - 0x192: 0x2000, 0x193: 0x2000, - 0x1a6: 0x2000, 0x1a7: 0x2000, - 0x1ab: 0x2000, - // Block 0x7, offset 0x1c0 - 0x1ce: 0x2000, 0x1d0: 0x2000, - 0x1d2: 0x2000, 0x1d4: 0x2000, 0x1d6: 0x2000, - 0x1d8: 0x2000, 0x1da: 0x2000, 0x1dc: 0x2000, - // Block 0x8, offset 0x200 - 0x211: 0x2000, - 0x221: 0x2000, - // Block 0x9, offset 0x240 - 0x244: 0x2000, - 0x247: 0x2000, 0x249: 0x2000, 0x24a: 0x2000, 0x24b: 0x2000, - 0x24d: 0x2000, 0x250: 0x2000, - 0x258: 0x2000, 0x259: 0x2000, 0x25a: 0x2000, 0x25b: 0x2000, 0x25d: 0x2000, - 0x25f: 0x2000, - // Block 0xa, offset 0x280 - 0x280: 0x2000, 0x281: 0x2000, 0x282: 0x2000, 0x283: 0x2000, 0x284: 0x2000, 0x285: 0x2000, - 0x286: 0x2000, 0x287: 0x2000, 0x288: 0x2000, 0x289: 0x2000, 0x28a: 0x2000, 0x28b: 0x2000, - 0x28c: 0x2000, 0x28d: 0x2000, 0x28e: 0x2000, 0x28f: 0x2000, 0x290: 0x2000, 0x291: 0x2000, - 0x292: 0x2000, 0x293: 0x2000, 0x294: 0x2000, 0x295: 0x2000, 0x296: 0x2000, 0x297: 0x2000, - 0x298: 0x2000, 0x299: 0x2000, 0x29a: 0x2000, 0x29b: 0x2000, 0x29c: 0x2000, 0x29d: 0x2000, - 0x29e: 0x2000, 0x29f: 0x2000, 0x2a0: 0x2000, 0x2a1: 0x2000, 0x2a2: 0x2000, 0x2a3: 0x2000, - 0x2a4: 0x2000, 0x2a5: 0x2000, 0x2a6: 0x2000, 0x2a7: 0x2000, 0x2a8: 0x2000, 0x2a9: 0x2000, - 0x2aa: 0x2000, 0x2ab: 0x2000, 0x2ac: 0x2000, 0x2ad: 0x2000, 0x2ae: 0x2000, 0x2af: 0x2000, - 0x2b0: 0x2000, 0x2b1: 0x2000, 0x2b2: 0x2000, 0x2b3: 0x2000, 0x2b4: 0x2000, 0x2b5: 0x2000, - 0x2b6: 0x2000, 0x2b7: 0x2000, 0x2b8: 0x2000, 0x2b9: 0x2000, 0x2ba: 0x2000, 0x2bb: 0x2000, - 0x2bc: 0x2000, 0x2bd: 0x2000, 0x2be: 0x2000, 0x2bf: 0x2000, - // Block 0xb, offset 0x2c0 - 0x2c0: 0x2000, 0x2c1: 0x2000, 0x2c2: 0x2000, 0x2c3: 0x2000, 0x2c4: 0x2000, 0x2c5: 0x2000, - 0x2c6: 0x2000, 0x2c7: 0x2000, 0x2c8: 0x2000, 0x2c9: 0x2000, 0x2ca: 0x2000, 0x2cb: 0x2000, - 0x2cc: 0x2000, 0x2cd: 0x2000, 0x2ce: 0x2000, 0x2cf: 0x2000, 0x2d0: 0x2000, 0x2d1: 0x2000, - 0x2d2: 0x2000, 0x2d3: 0x2000, 0x2d4: 0x2000, 0x2d5: 0x2000, 0x2d6: 0x2000, 0x2d7: 0x2000, - 0x2d8: 0x2000, 0x2d9: 0x2000, 0x2da: 0x2000, 0x2db: 0x2000, 0x2dc: 0x2000, 0x2dd: 0x2000, - 0x2de: 0x2000, 0x2df: 0x2000, 0x2e0: 0x2000, 0x2e1: 0x2000, 0x2e2: 0x2000, 0x2e3: 0x2000, - 0x2e4: 0x2000, 0x2e5: 0x2000, 0x2e6: 0x2000, 0x2e7: 0x2000, 0x2e8: 0x2000, 0x2e9: 0x2000, - 0x2ea: 0x2000, 0x2eb: 0x2000, 0x2ec: 0x2000, 0x2ed: 0x2000, 0x2ee: 0x2000, 0x2ef: 0x2000, - // Block 0xc, offset 0x300 - 0x311: 0x2000, - 0x312: 0x2000, 0x313: 0x2000, 0x314: 0x2000, 0x315: 0x2000, 0x316: 0x2000, 0x317: 0x2000, - 0x318: 0x2000, 0x319: 0x2000, 0x31a: 0x2000, 0x31b: 0x2000, 0x31c: 0x2000, 0x31d: 0x2000, - 0x31e: 0x2000, 0x31f: 0x2000, 0x320: 0x2000, 0x321: 0x2000, 0x323: 0x2000, - 0x324: 0x2000, 0x325: 0x2000, 0x326: 0x2000, 0x327: 0x2000, 0x328: 0x2000, 0x329: 0x2000, - 0x331: 0x2000, 0x332: 0x2000, 0x333: 0x2000, 0x334: 0x2000, 0x335: 0x2000, - 0x336: 0x2000, 0x337: 0x2000, 0x338: 0x2000, 0x339: 0x2000, 0x33a: 0x2000, 0x33b: 0x2000, - 0x33c: 0x2000, 0x33d: 0x2000, 0x33e: 0x2000, 0x33f: 0x2000, - // Block 0xd, offset 0x340 - 0x340: 0x2000, 0x341: 0x2000, 0x343: 0x2000, 0x344: 0x2000, 0x345: 0x2000, - 0x346: 0x2000, 0x347: 0x2000, 0x348: 0x2000, 0x349: 0x2000, - // Block 0xe, offset 0x380 - 0x381: 0x2000, - 0x390: 0x2000, 0x391: 0x2000, - 0x392: 0x2000, 0x393: 0x2000, 0x394: 0x2000, 0x395: 0x2000, 0x396: 0x2000, 0x397: 0x2000, - 0x398: 0x2000, 0x399: 0x2000, 0x39a: 0x2000, 0x39b: 0x2000, 0x39c: 0x2000, 0x39d: 0x2000, - 0x39e: 0x2000, 0x39f: 0x2000, 0x3a0: 0x2000, 0x3a1: 0x2000, 0x3a2: 0x2000, 0x3a3: 0x2000, - 0x3a4: 0x2000, 0x3a5: 0x2000, 0x3a6: 0x2000, 0x3a7: 0x2000, 0x3a8: 0x2000, 0x3a9: 0x2000, - 0x3aa: 0x2000, 0x3ab: 0x2000, 0x3ac: 0x2000, 0x3ad: 0x2000, 0x3ae: 0x2000, 0x3af: 0x2000, - 0x3b0: 0x2000, 0x3b1: 0x2000, 0x3b2: 0x2000, 0x3b3: 0x2000, 0x3b4: 0x2000, 0x3b5: 0x2000, - 0x3b6: 0x2000, 0x3b7: 0x2000, 0x3b8: 0x2000, 0x3b9: 0x2000, 0x3ba: 0x2000, 0x3bb: 0x2000, - 0x3bc: 0x2000, 0x3bd: 0x2000, 0x3be: 0x2000, 0x3bf: 0x2000, - // Block 0xf, offset 0x3c0 - 0x3c0: 0x2000, 0x3c1: 0x2000, 0x3c2: 0x2000, 0x3c3: 0x2000, 0x3c4: 0x2000, 0x3c5: 0x2000, - 0x3c6: 0x2000, 0x3c7: 0x2000, 0x3c8: 0x2000, 0x3c9: 0x2000, 0x3ca: 0x2000, 0x3cb: 0x2000, - 0x3cc: 0x2000, 0x3cd: 0x2000, 0x3ce: 0x2000, 0x3cf: 0x2000, 0x3d1: 0x2000, - // Block 0x10, offset 0x400 - 0x400: 0x4000, 0x401: 0x4000, 0x402: 0x4000, 0x403: 0x4000, 0x404: 0x4000, 0x405: 0x4000, - 0x406: 0x4000, 0x407: 0x4000, 0x408: 0x4000, 0x409: 0x4000, 0x40a: 0x4000, 0x40b: 0x4000, - 0x40c: 0x4000, 0x40d: 0x4000, 0x40e: 0x4000, 0x40f: 0x4000, 0x410: 0x4000, 0x411: 0x4000, - 0x412: 0x4000, 0x413: 0x4000, 0x414: 0x4000, 0x415: 0x4000, 0x416: 0x4000, 0x417: 0x4000, - 0x418: 0x4000, 0x419: 0x4000, 0x41a: 0x4000, 0x41b: 0x4000, 0x41c: 0x4000, 0x41d: 0x4000, - 0x41e: 0x4000, 0x41f: 0x4000, 0x420: 0x4000, 0x421: 0x4000, 0x422: 0x4000, 0x423: 0x4000, - 0x424: 0x4000, 0x425: 0x4000, 0x426: 0x4000, 0x427: 0x4000, 0x428: 0x4000, 0x429: 0x4000, - 0x42a: 0x4000, 0x42b: 0x4000, 0x42c: 0x4000, 0x42d: 0x4000, 0x42e: 0x4000, 0x42f: 0x4000, - 0x430: 0x4000, 0x431: 0x4000, 0x432: 0x4000, 0x433: 0x4000, 0x434: 0x4000, 0x435: 0x4000, - 0x436: 0x4000, 0x437: 0x4000, 0x438: 0x4000, 0x439: 0x4000, 0x43a: 0x4000, 0x43b: 0x4000, - 0x43c: 0x4000, 0x43d: 0x4000, 0x43e: 0x4000, 0x43f: 0x4000, - // Block 0x11, offset 0x440 - 0x440: 0x4000, 0x441: 0x4000, 0x442: 0x4000, 0x443: 0x4000, 0x444: 0x4000, 0x445: 0x4000, - 0x446: 0x4000, 0x447: 0x4000, 0x448: 0x4000, 0x449: 0x4000, 0x44a: 0x4000, 0x44b: 0x4000, - 0x44c: 0x4000, 0x44d: 0x4000, 0x44e: 0x4000, 0x44f: 0x4000, 0x450: 0x4000, 0x451: 0x4000, - 0x452: 0x4000, 0x453: 0x4000, 0x454: 0x4000, 0x455: 0x4000, 0x456: 0x4000, 0x457: 0x4000, - 0x458: 0x4000, 0x459: 0x4000, 0x45a: 0x4000, 0x45b: 0x4000, 0x45c: 0x4000, 0x45d: 0x4000, - 0x45e: 0x4000, 0x45f: 0x4000, - // Block 0x12, offset 0x480 - 0x490: 0x2000, - 0x493: 0x2000, 0x494: 0x2000, 0x495: 0x2000, 0x496: 0x2000, - 0x498: 0x2000, 0x499: 0x2000, 0x49c: 0x2000, 0x49d: 0x2000, - 0x4a0: 0x2000, 0x4a1: 0x2000, 0x4a2: 0x2000, - 0x4a4: 0x2000, 0x4a5: 0x2000, 0x4a6: 0x2000, 0x4a7: 0x2000, - 0x4b0: 0x2000, 0x4b2: 0x2000, 0x4b3: 0x2000, 0x4b5: 0x2000, - 0x4bb: 0x2000, - 0x4be: 0x2000, - // Block 0x13, offset 0x4c0 - 0x4f4: 0x2000, - 0x4ff: 0x2000, - // Block 0x14, offset 0x500 - 0x501: 0x2000, 0x502: 0x2000, 0x503: 0x2000, 0x504: 0x2000, - 0x529: 0xa009, - 0x52c: 0x2000, - // Block 0x15, offset 0x540 - 0x543: 0x2000, 0x545: 0x2000, - 0x549: 0x2000, - 0x553: 0x2000, 0x556: 0x2000, - 0x561: 0x2000, 0x562: 0x2000, - 0x566: 0x2000, - 0x56b: 0x2000, - // Block 0x16, offset 0x580 - 0x593: 0x2000, 0x594: 0x2000, - 0x59b: 0x2000, 0x59c: 0x2000, 0x59d: 0x2000, - 0x59e: 0x2000, 0x5a0: 0x2000, 0x5a1: 0x2000, 0x5a2: 0x2000, 0x5a3: 0x2000, - 0x5a4: 0x2000, 0x5a5: 0x2000, 0x5a6: 0x2000, 0x5a7: 0x2000, 0x5a8: 0x2000, 0x5a9: 0x2000, - 0x5aa: 0x2000, 0x5ab: 0x2000, - 0x5b0: 0x2000, 0x5b1: 0x2000, 0x5b2: 0x2000, 0x5b3: 0x2000, 0x5b4: 0x2000, 0x5b5: 0x2000, - 0x5b6: 0x2000, 0x5b7: 0x2000, 0x5b8: 0x2000, 0x5b9: 0x2000, - // Block 0x17, offset 0x5c0 - 0x5c9: 0x2000, - 0x5d0: 0x200a, 0x5d1: 0x200b, - 0x5d2: 0x200a, 0x5d3: 0x200c, 0x5d4: 0x2000, 0x5d5: 0x2000, 0x5d6: 0x2000, 0x5d7: 0x2000, - 0x5d8: 0x2000, 0x5d9: 0x2000, - 0x5f8: 0x2000, 0x5f9: 0x2000, - // Block 0x18, offset 0x600 - 0x612: 0x2000, 0x614: 0x2000, - 0x627: 0x2000, - // Block 0x19, offset 0x640 - 0x640: 0x2000, 0x642: 0x2000, 0x643: 0x2000, - 0x647: 0x2000, 0x648: 0x2000, 0x64b: 0x2000, - 0x64f: 0x2000, 0x651: 0x2000, - 0x655: 0x2000, - 0x65a: 0x2000, 0x65d: 0x2000, - 0x65e: 0x2000, 0x65f: 0x2000, 0x660: 0x2000, 0x663: 0x2000, - 0x665: 0x2000, 0x667: 0x2000, 0x668: 0x2000, 0x669: 0x2000, - 0x66a: 0x2000, 0x66b: 0x2000, 0x66c: 0x2000, 0x66e: 0x2000, - 0x674: 0x2000, 0x675: 0x2000, - 0x676: 0x2000, 0x677: 0x2000, - 0x67c: 0x2000, 0x67d: 0x2000, - // Block 0x1a, offset 0x680 - 0x688: 0x2000, - 0x68c: 0x2000, - 0x692: 0x2000, - 0x6a0: 0x2000, 0x6a1: 0x2000, - 0x6a4: 0x2000, 0x6a5: 0x2000, 0x6a6: 0x2000, 0x6a7: 0x2000, - 0x6aa: 0x2000, 0x6ab: 0x2000, 0x6ae: 0x2000, 0x6af: 0x2000, - // Block 0x1b, offset 0x6c0 - 0x6c2: 0x2000, 0x6c3: 0x2000, - 0x6c6: 0x2000, 0x6c7: 0x2000, - 0x6d5: 0x2000, - 0x6d9: 0x2000, - 0x6e5: 0x2000, - 0x6ff: 0x2000, - // Block 0x1c, offset 0x700 - 0x712: 0x2000, - 0x71a: 0x4000, 0x71b: 0x4000, - 0x729: 0x4000, - 0x72a: 0x4000, - // Block 0x1d, offset 0x740 - 0x769: 0x4000, - 0x76a: 0x4000, 0x76b: 0x4000, 0x76c: 0x4000, - 0x770: 0x4000, 0x773: 0x4000, - // Block 0x1e, offset 0x780 - 0x7a0: 0x2000, 0x7a1: 0x2000, 0x7a2: 0x2000, 0x7a3: 0x2000, - 0x7a4: 0x2000, 0x7a5: 0x2000, 0x7a6: 0x2000, 0x7a7: 0x2000, 0x7a8: 0x2000, 0x7a9: 0x2000, - 0x7aa: 0x2000, 0x7ab: 0x2000, 0x7ac: 0x2000, 0x7ad: 0x2000, 0x7ae: 0x2000, 0x7af: 0x2000, - 0x7b0: 0x2000, 0x7b1: 0x2000, 0x7b2: 0x2000, 0x7b3: 0x2000, 0x7b4: 0x2000, 0x7b5: 0x2000, - 0x7b6: 0x2000, 0x7b7: 0x2000, 0x7b8: 0x2000, 0x7b9: 0x2000, 0x7ba: 0x2000, 0x7bb: 0x2000, - 0x7bc: 0x2000, 0x7bd: 0x2000, 0x7be: 0x2000, 0x7bf: 0x2000, - // Block 0x1f, offset 0x7c0 - 0x7c0: 0x2000, 0x7c1: 0x2000, 0x7c2: 0x2000, 0x7c3: 0x2000, 0x7c4: 0x2000, 0x7c5: 0x2000, - 0x7c6: 0x2000, 0x7c7: 0x2000, 0x7c8: 0x2000, 0x7c9: 0x2000, 0x7ca: 0x2000, 0x7cb: 0x2000, - 0x7cc: 0x2000, 0x7cd: 0x2000, 0x7ce: 0x2000, 0x7cf: 0x2000, 0x7d0: 0x2000, 0x7d1: 0x2000, - 0x7d2: 0x2000, 0x7d3: 0x2000, 0x7d4: 0x2000, 0x7d5: 0x2000, 0x7d6: 0x2000, 0x7d7: 0x2000, - 0x7d8: 0x2000, 0x7d9: 0x2000, 0x7da: 0x2000, 0x7db: 0x2000, 0x7dc: 0x2000, 0x7dd: 0x2000, - 0x7de: 0x2000, 0x7df: 0x2000, 0x7e0: 0x2000, 0x7e1: 0x2000, 0x7e2: 0x2000, 0x7e3: 0x2000, - 0x7e4: 0x2000, 0x7e5: 0x2000, 0x7e6: 0x2000, 0x7e7: 0x2000, 0x7e8: 0x2000, 0x7e9: 0x2000, - 0x7eb: 0x2000, 0x7ec: 0x2000, 0x7ed: 0x2000, 0x7ee: 0x2000, 0x7ef: 0x2000, - 0x7f0: 0x2000, 0x7f1: 0x2000, 0x7f2: 0x2000, 0x7f3: 0x2000, 0x7f4: 0x2000, 0x7f5: 0x2000, - 0x7f6: 0x2000, 0x7f7: 0x2000, 0x7f8: 0x2000, 0x7f9: 0x2000, 0x7fa: 0x2000, 0x7fb: 0x2000, - 0x7fc: 0x2000, 0x7fd: 0x2000, 0x7fe: 0x2000, 0x7ff: 0x2000, - // Block 0x20, offset 0x800 - 0x800: 0x2000, 0x801: 0x2000, 0x802: 0x200d, 0x803: 0x2000, 0x804: 0x2000, 0x805: 0x2000, - 0x806: 0x2000, 0x807: 0x2000, 0x808: 0x2000, 0x809: 0x2000, 0x80a: 0x2000, 0x80b: 0x2000, - 0x80c: 0x2000, 0x80d: 0x2000, 0x80e: 0x2000, 0x80f: 0x2000, 0x810: 0x2000, 0x811: 0x2000, - 0x812: 0x2000, 0x813: 0x2000, 0x814: 0x2000, 0x815: 0x2000, 0x816: 0x2000, 0x817: 0x2000, - 0x818: 0x2000, 0x819: 0x2000, 0x81a: 0x2000, 0x81b: 0x2000, 0x81c: 0x2000, 0x81d: 0x2000, - 0x81e: 0x2000, 0x81f: 0x2000, 0x820: 0x2000, 0x821: 0x2000, 0x822: 0x2000, 0x823: 0x2000, - 0x824: 0x2000, 0x825: 0x2000, 0x826: 0x2000, 0x827: 0x2000, 0x828: 0x2000, 0x829: 0x2000, - 0x82a: 0x2000, 0x82b: 0x2000, 0x82c: 0x2000, 0x82d: 0x2000, 0x82e: 0x2000, 0x82f: 0x2000, - 0x830: 0x2000, 0x831: 0x2000, 0x832: 0x2000, 0x833: 0x2000, 0x834: 0x2000, 0x835: 0x2000, - 0x836: 0x2000, 0x837: 0x2000, 0x838: 0x2000, 0x839: 0x2000, 0x83a: 0x2000, 0x83b: 0x2000, - 0x83c: 0x2000, 0x83d: 0x2000, 0x83e: 0x2000, 0x83f: 0x2000, - // Block 0x21, offset 0x840 - 0x840: 0x2000, 0x841: 0x2000, 0x842: 0x2000, 0x843: 0x2000, 0x844: 0x2000, 0x845: 0x2000, - 0x846: 0x2000, 0x847: 0x2000, 0x848: 0x2000, 0x849: 0x2000, 0x84a: 0x2000, 0x84b: 0x2000, - 0x850: 0x2000, 0x851: 0x2000, - 0x852: 0x2000, 0x853: 0x2000, 0x854: 0x2000, 0x855: 0x2000, 0x856: 0x2000, 0x857: 0x2000, - 0x858: 0x2000, 0x859: 0x2000, 0x85a: 0x2000, 0x85b: 0x2000, 0x85c: 0x2000, 0x85d: 0x2000, - 0x85e: 0x2000, 0x85f: 0x2000, 0x860: 0x2000, 0x861: 0x2000, 0x862: 0x2000, 0x863: 0x2000, - 0x864: 0x2000, 0x865: 0x2000, 0x866: 0x2000, 0x867: 0x2000, 0x868: 0x2000, 0x869: 0x2000, - 0x86a: 0x2000, 0x86b: 0x2000, 0x86c: 0x2000, 0x86d: 0x2000, 0x86e: 0x2000, 0x86f: 0x2000, - 0x870: 0x2000, 0x871: 0x2000, 0x872: 0x2000, 0x873: 0x2000, - // Block 0x22, offset 0x880 - 0x880: 0x2000, 0x881: 0x2000, 0x882: 0x2000, 0x883: 0x2000, 0x884: 0x2000, 0x885: 0x2000, - 0x886: 0x2000, 0x887: 0x2000, 0x888: 0x2000, 0x889: 0x2000, 0x88a: 0x2000, 0x88b: 0x2000, - 0x88c: 0x2000, 0x88d: 0x2000, 0x88e: 0x2000, 0x88f: 0x2000, - 0x892: 0x2000, 0x893: 0x2000, 0x894: 0x2000, 0x895: 0x2000, - 0x8a0: 0x200e, 0x8a1: 0x2000, 0x8a3: 0x2000, - 0x8a4: 0x2000, 0x8a5: 0x2000, 0x8a6: 0x2000, 0x8a7: 0x2000, 0x8a8: 0x2000, 0x8a9: 0x2000, - 0x8b2: 0x2000, 0x8b3: 0x2000, - 0x8b6: 0x2000, 0x8b7: 0x2000, - 0x8bc: 0x2000, 0x8bd: 0x2000, - // Block 0x23, offset 0x8c0 - 0x8c0: 0x2000, 0x8c1: 0x2000, - 0x8c6: 0x2000, 0x8c7: 0x2000, 0x8c8: 0x2000, 0x8cb: 0x200f, - 0x8ce: 0x2000, 0x8cf: 0x2000, 0x8d0: 0x2000, 0x8d1: 0x2000, - 0x8e2: 0x2000, 0x8e3: 0x2000, - 0x8e4: 0x2000, 0x8e5: 0x2000, - 0x8ef: 0x2000, - 0x8fd: 0x4000, 0x8fe: 0x4000, - // Block 0x24, offset 0x900 - 0x905: 0x2000, - 0x906: 0x2000, 0x909: 0x2000, - 0x90e: 0x2000, 0x90f: 0x2000, - 0x914: 0x4000, 0x915: 0x4000, - 0x91c: 0x2000, - 0x91e: 0x2000, - // Block 0x25, offset 0x940 - 0x940: 0x2000, 0x942: 0x2000, - 0x948: 0x4000, 0x949: 0x4000, 0x94a: 0x4000, 0x94b: 0x4000, - 0x94c: 0x4000, 0x94d: 0x4000, 0x94e: 0x4000, 0x94f: 0x4000, 0x950: 0x4000, 0x951: 0x4000, - 0x952: 0x4000, 0x953: 0x4000, - 0x960: 0x2000, 0x961: 0x2000, 0x963: 0x2000, - 0x964: 0x2000, 0x965: 0x2000, 0x967: 0x2000, 0x968: 0x2000, 0x969: 0x2000, - 0x96a: 0x2000, 0x96c: 0x2000, 0x96d: 0x2000, 0x96f: 0x2000, - 0x97f: 0x4000, - // Block 0x26, offset 0x980 - 0x993: 0x4000, - 0x99e: 0x2000, 0x99f: 0x2000, 0x9a1: 0x4000, - 0x9aa: 0x4000, 0x9ab: 0x4000, - 0x9bd: 0x4000, 0x9be: 0x4000, 0x9bf: 0x2000, - // Block 0x27, offset 0x9c0 - 0x9c4: 0x4000, 0x9c5: 0x4000, - 0x9c6: 0x2000, 0x9c7: 0x2000, 0x9c8: 0x2000, 0x9c9: 0x2000, 0x9ca: 0x2000, 0x9cb: 0x2000, - 0x9cc: 0x2000, 0x9cd: 0x2000, 0x9ce: 0x4000, 0x9cf: 0x2000, 0x9d0: 0x2000, 0x9d1: 0x2000, - 0x9d2: 0x2000, 0x9d3: 0x2000, 0x9d4: 0x4000, 0x9d5: 0x2000, 0x9d6: 0x2000, 0x9d7: 0x2000, - 0x9d8: 0x2000, 0x9d9: 0x2000, 0x9da: 0x2000, 0x9db: 0x2000, 0x9dc: 0x2000, 0x9dd: 0x2000, - 0x9de: 0x2000, 0x9df: 0x2000, 0x9e0: 0x2000, 0x9e1: 0x2000, 0x9e3: 0x2000, - 0x9e8: 0x2000, 0x9e9: 0x2000, - 0x9ea: 0x4000, 0x9eb: 0x2000, 0x9ec: 0x2000, 0x9ed: 0x2000, 0x9ee: 0x2000, 0x9ef: 0x2000, - 0x9f0: 0x2000, 0x9f1: 0x2000, 0x9f2: 0x4000, 0x9f3: 0x4000, 0x9f4: 0x2000, 0x9f5: 0x4000, - 0x9f6: 0x2000, 0x9f7: 0x2000, 0x9f8: 0x2000, 0x9f9: 0x2000, 0x9fa: 0x4000, 0x9fb: 0x2000, - 0x9fc: 0x2000, 0x9fd: 0x4000, 0x9fe: 0x2000, 0x9ff: 0x2000, - // Block 0x28, offset 0xa00 - 0xa05: 0x4000, - 0xa0a: 0x4000, 0xa0b: 0x4000, - 0xa28: 0x4000, - 0xa3d: 0x2000, - // Block 0x29, offset 0xa40 - 0xa4c: 0x4000, 0xa4e: 0x4000, - 0xa53: 0x4000, 0xa54: 0x4000, 0xa55: 0x4000, 0xa57: 0x4000, - 0xa76: 0x2000, 0xa77: 0x2000, 0xa78: 0x2000, 0xa79: 0x2000, 0xa7a: 0x2000, 0xa7b: 0x2000, - 0xa7c: 0x2000, 0xa7d: 0x2000, 0xa7e: 0x2000, 0xa7f: 0x2000, - // Block 0x2a, offset 0xa80 - 0xa95: 0x4000, 0xa96: 0x4000, 0xa97: 0x4000, - 0xab0: 0x4000, - 0xabf: 0x4000, - // Block 0x2b, offset 0xac0 - 0xae6: 0x6000, 0xae7: 0x6000, 0xae8: 0x6000, 0xae9: 0x6000, - 0xaea: 0x6000, 0xaeb: 0x6000, 0xaec: 0x6000, 0xaed: 0x6000, - // Block 0x2c, offset 0xb00 - 0xb05: 0x6010, - 0xb06: 0x6011, - // Block 0x2d, offset 0xb40 - 0xb5b: 0x4000, 0xb5c: 0x4000, - // Block 0x2e, offset 0xb80 - 0xb90: 0x4000, - 0xb95: 0x4000, 0xb96: 0x2000, 0xb97: 0x2000, - 0xb98: 0x2000, 0xb99: 0x2000, - // Block 0x2f, offset 0xbc0 - 0xbc0: 0x4000, 0xbc1: 0x4000, 0xbc2: 0x4000, 0xbc3: 0x4000, 0xbc4: 0x4000, 0xbc5: 0x4000, - 0xbc6: 0x4000, 0xbc7: 0x4000, 0xbc8: 0x4000, 0xbc9: 0x4000, 0xbca: 0x4000, 0xbcb: 0x4000, - 0xbcc: 0x4000, 0xbcd: 0x4000, 0xbce: 0x4000, 0xbcf: 0x4000, 0xbd0: 0x4000, 0xbd1: 0x4000, - 0xbd2: 0x4000, 0xbd3: 0x4000, 0xbd4: 0x4000, 0xbd5: 0x4000, 0xbd6: 0x4000, 0xbd7: 0x4000, - 0xbd8: 0x4000, 0xbd9: 0x4000, 0xbdb: 0x4000, 0xbdc: 0x4000, 0xbdd: 0x4000, - 0xbde: 0x4000, 0xbdf: 0x4000, 0xbe0: 0x4000, 0xbe1: 0x4000, 0xbe2: 0x4000, 0xbe3: 0x4000, - 0xbe4: 0x4000, 0xbe5: 0x4000, 0xbe6: 0x4000, 0xbe7: 0x4000, 0xbe8: 0x4000, 0xbe9: 0x4000, - 0xbea: 0x4000, 0xbeb: 0x4000, 0xbec: 0x4000, 0xbed: 0x4000, 0xbee: 0x4000, 0xbef: 0x4000, - 0xbf0: 0x4000, 0xbf1: 0x4000, 0xbf2: 0x4000, 0xbf3: 0x4000, 0xbf4: 0x4000, 0xbf5: 0x4000, - 0xbf6: 0x4000, 0xbf7: 0x4000, 0xbf8: 0x4000, 0xbf9: 0x4000, 0xbfa: 0x4000, 0xbfb: 0x4000, - 0xbfc: 0x4000, 0xbfd: 0x4000, 0xbfe: 0x4000, 0xbff: 0x4000, - // Block 0x30, offset 0xc00 - 0xc00: 0x4000, 0xc01: 0x4000, 0xc02: 0x4000, 0xc03: 0x4000, 0xc04: 0x4000, 0xc05: 0x4000, - 0xc06: 0x4000, 0xc07: 0x4000, 0xc08: 0x4000, 0xc09: 0x4000, 0xc0a: 0x4000, 0xc0b: 0x4000, - 0xc0c: 0x4000, 0xc0d: 0x4000, 0xc0e: 0x4000, 0xc0f: 0x4000, 0xc10: 0x4000, 0xc11: 0x4000, - 0xc12: 0x4000, 0xc13: 0x4000, 0xc14: 0x4000, 0xc15: 0x4000, 0xc16: 0x4000, 0xc17: 0x4000, - 0xc18: 0x4000, 0xc19: 0x4000, 0xc1a: 0x4000, 0xc1b: 0x4000, 0xc1c: 0x4000, 0xc1d: 0x4000, - 0xc1e: 0x4000, 0xc1f: 0x4000, 0xc20: 0x4000, 0xc21: 0x4000, 0xc22: 0x4000, 0xc23: 0x4000, - 0xc24: 0x4000, 0xc25: 0x4000, 0xc26: 0x4000, 0xc27: 0x4000, 0xc28: 0x4000, 0xc29: 0x4000, - 0xc2a: 0x4000, 0xc2b: 0x4000, 0xc2c: 0x4000, 0xc2d: 0x4000, 0xc2e: 0x4000, 0xc2f: 0x4000, - 0xc30: 0x4000, 0xc31: 0x4000, 0xc32: 0x4000, 0xc33: 0x4000, - // Block 0x31, offset 0xc40 - 0xc40: 0x4000, 0xc41: 0x4000, 0xc42: 0x4000, 0xc43: 0x4000, 0xc44: 0x4000, 0xc45: 0x4000, - 0xc46: 0x4000, 0xc47: 0x4000, 0xc48: 0x4000, 0xc49: 0x4000, 0xc4a: 0x4000, 0xc4b: 0x4000, - 0xc4c: 0x4000, 0xc4d: 0x4000, 0xc4e: 0x4000, 0xc4f: 0x4000, 0xc50: 0x4000, 0xc51: 0x4000, - 0xc52: 0x4000, 0xc53: 0x4000, 0xc54: 0x4000, 0xc55: 0x4000, - 0xc70: 0x4000, 0xc71: 0x4000, 0xc72: 0x4000, 0xc73: 0x4000, 0xc74: 0x4000, 0xc75: 0x4000, - 0xc76: 0x4000, 0xc77: 0x4000, 0xc78: 0x4000, 0xc79: 0x4000, 0xc7a: 0x4000, 0xc7b: 0x4000, - // Block 0x32, offset 0xc80 - 0xc80: 0x9012, 0xc81: 0x4013, 0xc82: 0x4014, 0xc83: 0x4000, 0xc84: 0x4000, 0xc85: 0x4000, - 0xc86: 0x4000, 0xc87: 0x4000, 0xc88: 0x4000, 0xc89: 0x4000, 0xc8a: 0x4000, 0xc8b: 0x4000, - 0xc8c: 0x4015, 0xc8d: 0x4015, 0xc8e: 0x4000, 0xc8f: 0x4000, 0xc90: 0x4000, 0xc91: 0x4000, - 0xc92: 0x4000, 0xc93: 0x4000, 0xc94: 0x4000, 0xc95: 0x4000, 0xc96: 0x4000, 0xc97: 0x4000, - 0xc98: 0x4000, 0xc99: 0x4000, 0xc9a: 0x4000, 0xc9b: 0x4000, 0xc9c: 0x4000, 0xc9d: 0x4000, - 0xc9e: 0x4000, 0xc9f: 0x4000, 0xca0: 0x4000, 0xca1: 0x4000, 0xca2: 0x4000, 0xca3: 0x4000, - 0xca4: 0x4000, 0xca5: 0x4000, 0xca6: 0x4000, 0xca7: 0x4000, 0xca8: 0x4000, 0xca9: 0x4000, - 0xcaa: 0x4000, 0xcab: 0x4000, 0xcac: 0x4000, 0xcad: 0x4000, 0xcae: 0x4000, 0xcaf: 0x4000, - 0xcb0: 0x4000, 0xcb1: 0x4000, 0xcb2: 0x4000, 0xcb3: 0x4000, 0xcb4: 0x4000, 0xcb5: 0x4000, - 0xcb6: 0x4000, 0xcb7: 0x4000, 0xcb8: 0x4000, 0xcb9: 0x4000, 0xcba: 0x4000, 0xcbb: 0x4000, - 0xcbc: 0x4000, 0xcbd: 0x4000, 0xcbe: 0x4000, - // Block 0x33, offset 0xcc0 - 0xcc1: 0x4000, 0xcc2: 0x4000, 0xcc3: 0x4000, 0xcc4: 0x4000, 0xcc5: 0x4000, - 0xcc6: 0x4000, 0xcc7: 0x4000, 0xcc8: 0x4000, 0xcc9: 0x4000, 0xcca: 0x4000, 0xccb: 0x4000, - 0xccc: 0x4000, 0xccd: 0x4000, 0xcce: 0x4000, 0xccf: 0x4000, 0xcd0: 0x4000, 0xcd1: 0x4000, - 0xcd2: 0x4000, 0xcd3: 0x4000, 0xcd4: 0x4000, 0xcd5: 0x4000, 0xcd6: 0x4000, 0xcd7: 0x4000, - 0xcd8: 0x4000, 0xcd9: 0x4000, 0xcda: 0x4000, 0xcdb: 0x4000, 0xcdc: 0x4000, 0xcdd: 0x4000, - 0xcde: 0x4000, 0xcdf: 0x4000, 0xce0: 0x4000, 0xce1: 0x4000, 0xce2: 0x4000, 0xce3: 0x4000, - 0xce4: 0x4000, 0xce5: 0x4000, 0xce6: 0x4000, 0xce7: 0x4000, 0xce8: 0x4000, 0xce9: 0x4000, - 0xcea: 0x4000, 0xceb: 0x4000, 0xcec: 0x4000, 0xced: 0x4000, 0xcee: 0x4000, 0xcef: 0x4000, - 0xcf0: 0x4000, 0xcf1: 0x4000, 0xcf2: 0x4000, 0xcf3: 0x4000, 0xcf4: 0x4000, 0xcf5: 0x4000, - 0xcf6: 0x4000, 0xcf7: 0x4000, 0xcf8: 0x4000, 0xcf9: 0x4000, 0xcfa: 0x4000, 0xcfb: 0x4000, - 0xcfc: 0x4000, 0xcfd: 0x4000, 0xcfe: 0x4000, 0xcff: 0x4000, - // Block 0x34, offset 0xd00 - 0xd00: 0x4000, 0xd01: 0x4000, 0xd02: 0x4000, 0xd03: 0x4000, 0xd04: 0x4000, 0xd05: 0x4000, - 0xd06: 0x4000, 0xd07: 0x4000, 0xd08: 0x4000, 0xd09: 0x4000, 0xd0a: 0x4000, 0xd0b: 0x4000, - 0xd0c: 0x4000, 0xd0d: 0x4000, 0xd0e: 0x4000, 0xd0f: 0x4000, 0xd10: 0x4000, 0xd11: 0x4000, - 0xd12: 0x4000, 0xd13: 0x4000, 0xd14: 0x4000, 0xd15: 0x4000, 0xd16: 0x4000, - 0xd19: 0x4016, 0xd1a: 0x4017, 0xd1b: 0x4000, 0xd1c: 0x4000, 0xd1d: 0x4000, - 0xd1e: 0x4000, 0xd1f: 0x4000, 0xd20: 0x4000, 0xd21: 0x4018, 0xd22: 0x4019, 0xd23: 0x401a, - 0xd24: 0x401b, 0xd25: 0x401c, 0xd26: 0x401d, 0xd27: 0x401e, 0xd28: 0x401f, 0xd29: 0x4020, - 0xd2a: 0x4021, 0xd2b: 0x4022, 0xd2c: 0x4000, 0xd2d: 0x4010, 0xd2e: 0x4000, 0xd2f: 0x4023, - 0xd30: 0x4000, 0xd31: 0x4024, 0xd32: 0x4000, 0xd33: 0x4025, 0xd34: 0x4000, 0xd35: 0x4026, - 0xd36: 0x4000, 0xd37: 0x401a, 0xd38: 0x4000, 0xd39: 0x4027, 0xd3a: 0x4000, 0xd3b: 0x4028, - 0xd3c: 0x4000, 0xd3d: 0x4020, 0xd3e: 0x4000, 0xd3f: 0x4029, - // Block 0x35, offset 0xd40 - 0xd40: 0x4000, 0xd41: 0x402a, 0xd42: 0x4000, 0xd43: 0x402b, 0xd44: 0x402c, 0xd45: 0x4000, - 0xd46: 0x4017, 0xd47: 0x4000, 0xd48: 0x402d, 0xd49: 0x4000, 0xd4a: 0x402e, 0xd4b: 0x402f, - 0xd4c: 0x4030, 0xd4d: 0x4017, 0xd4e: 0x4016, 0xd4f: 0x4017, 0xd50: 0x4000, 0xd51: 0x4000, - 0xd52: 0x4031, 0xd53: 0x4000, 0xd54: 0x4000, 0xd55: 0x4031, 0xd56: 0x4000, 0xd57: 0x4000, - 0xd58: 0x4032, 0xd59: 0x4000, 0xd5a: 0x4000, 0xd5b: 0x4032, 0xd5c: 0x4000, 0xd5d: 0x4000, - 0xd5e: 0x4033, 0xd5f: 0x402e, 0xd60: 0x4034, 0xd61: 0x4035, 0xd62: 0x4034, 0xd63: 0x4036, - 0xd64: 0x4037, 0xd65: 0x4024, 0xd66: 0x4035, 0xd67: 0x4025, 0xd68: 0x4038, 0xd69: 0x4038, - 0xd6a: 0x4039, 0xd6b: 0x4039, 0xd6c: 0x403a, 0xd6d: 0x403a, 0xd6e: 0x4000, 0xd6f: 0x4035, - 0xd70: 0x4000, 0xd71: 0x4000, 0xd72: 0x403b, 0xd73: 0x403c, 0xd74: 0x4000, 0xd75: 0x4000, - 0xd76: 0x4000, 0xd77: 0x4000, 0xd78: 0x4000, 0xd79: 0x4000, 0xd7a: 0x4000, 0xd7b: 0x403d, - 0xd7c: 0x401c, 0xd7d: 0x4000, 0xd7e: 0x4000, 0xd7f: 0x4000, - // Block 0x36, offset 0xd80 - 0xd85: 0x4000, - 0xd86: 0x4000, 0xd87: 0x4000, 0xd88: 0x4000, 0xd89: 0x4000, 0xd8a: 0x4000, 0xd8b: 0x4000, - 0xd8c: 0x4000, 0xd8d: 0x4000, 0xd8e: 0x4000, 0xd8f: 0x4000, 0xd90: 0x4000, 0xd91: 0x4000, - 0xd92: 0x4000, 0xd93: 0x4000, 0xd94: 0x4000, 0xd95: 0x4000, 0xd96: 0x4000, 0xd97: 0x4000, - 0xd98: 0x4000, 0xd99: 0x4000, 0xd9a: 0x4000, 0xd9b: 0x4000, 0xd9c: 0x4000, 0xd9d: 0x4000, - 0xd9e: 0x4000, 0xd9f: 0x4000, 0xda0: 0x4000, 0xda1: 0x4000, 0xda2: 0x4000, 0xda3: 0x4000, - 0xda4: 0x4000, 0xda5: 0x4000, 0xda6: 0x4000, 0xda7: 0x4000, 0xda8: 0x4000, 0xda9: 0x4000, - 0xdaa: 0x4000, 0xdab: 0x4000, 0xdac: 0x4000, 0xdad: 0x4000, 0xdae: 0x4000, - 0xdb1: 0x403e, 0xdb2: 0x403e, 0xdb3: 0x403e, 0xdb4: 0x403e, 0xdb5: 0x403e, - 0xdb6: 0x403e, 0xdb7: 0x403e, 0xdb8: 0x403e, 0xdb9: 0x403e, 0xdba: 0x403e, 0xdbb: 0x403e, - 0xdbc: 0x403e, 0xdbd: 0x403e, 0xdbe: 0x403e, 0xdbf: 0x403e, - // Block 0x37, offset 0xdc0 - 0xdc0: 0x4037, 0xdc1: 0x4037, 0xdc2: 0x4037, 0xdc3: 0x4037, 0xdc4: 0x4037, 0xdc5: 0x4037, - 0xdc6: 0x4037, 0xdc7: 0x4037, 0xdc8: 0x4037, 0xdc9: 0x4037, 0xdca: 0x4037, 0xdcb: 0x4037, - 0xdcc: 0x4037, 0xdcd: 0x4037, 0xdce: 0x4037, 0xdcf: 0x400e, 0xdd0: 0x403f, 0xdd1: 0x4040, - 0xdd2: 0x4041, 0xdd3: 0x4040, 0xdd4: 0x403f, 0xdd5: 0x4042, 0xdd6: 0x4043, 0xdd7: 0x4044, - 0xdd8: 0x4040, 0xdd9: 0x4041, 0xdda: 0x4040, 0xddb: 0x4045, 0xddc: 0x4009, 0xddd: 0x4045, - 0xdde: 0x4046, 0xddf: 0x4045, 0xde0: 0x4047, 0xde1: 0x400b, 0xde2: 0x400a, 0xde3: 0x400c, - 0xde4: 0x4048, 0xde5: 0x4000, 0xde6: 0x4000, 0xde7: 0x4000, 0xde8: 0x4000, 0xde9: 0x4000, - 0xdea: 0x4000, 0xdeb: 0x4000, 0xdec: 0x4000, 0xded: 0x4000, 0xdee: 0x4000, 0xdef: 0x4000, - 0xdf0: 0x4000, 0xdf1: 0x4000, 0xdf2: 0x4000, 0xdf3: 0x4000, 0xdf4: 0x4000, 0xdf5: 0x4000, - 0xdf6: 0x4000, 0xdf7: 0x4000, 0xdf8: 0x4000, 0xdf9: 0x4000, 0xdfa: 0x4000, 0xdfb: 0x4000, - 0xdfc: 0x4000, 0xdfd: 0x4000, 0xdfe: 0x4000, 0xdff: 0x4000, - // Block 0x38, offset 0xe00 - 0xe00: 0x4000, 0xe01: 0x4000, 0xe02: 0x4000, 0xe03: 0x4000, 0xe04: 0x4000, 0xe05: 0x4000, - 0xe06: 0x4000, 0xe07: 0x4000, 0xe08: 0x4000, 0xe09: 0x4000, 0xe0a: 0x4000, 0xe0b: 0x4000, - 0xe0c: 0x4000, 0xe0d: 0x4000, 0xe0e: 0x4000, 0xe10: 0x4000, 0xe11: 0x4000, - 0xe12: 0x4000, 0xe13: 0x4000, 0xe14: 0x4000, 0xe15: 0x4000, 0xe16: 0x4000, 0xe17: 0x4000, - 0xe18: 0x4000, 0xe19: 0x4000, 0xe1a: 0x4000, 0xe1b: 0x4000, 0xe1c: 0x4000, 0xe1d: 0x4000, - 0xe1e: 0x4000, 0xe1f: 0x4000, 0xe20: 0x4000, 0xe21: 0x4000, 0xe22: 0x4000, 0xe23: 0x4000, - 0xe24: 0x4000, 0xe25: 0x4000, 0xe26: 0x4000, 0xe27: 0x4000, 0xe28: 0x4000, 0xe29: 0x4000, - 0xe2a: 0x4000, 0xe2b: 0x4000, 0xe2c: 0x4000, 0xe2d: 0x4000, 0xe2e: 0x4000, 0xe2f: 0x4000, - 0xe30: 0x4000, 0xe31: 0x4000, 0xe32: 0x4000, 0xe33: 0x4000, 0xe34: 0x4000, 0xe35: 0x4000, - 0xe36: 0x4000, 0xe37: 0x4000, 0xe38: 0x4000, 0xe39: 0x4000, 0xe3a: 0x4000, - // Block 0x39, offset 0xe40 - 0xe40: 0x4000, 0xe41: 0x4000, 0xe42: 0x4000, 0xe43: 0x4000, 0xe44: 0x4000, 0xe45: 0x4000, - 0xe46: 0x4000, 0xe47: 0x4000, 0xe48: 0x4000, 0xe49: 0x4000, 0xe4a: 0x4000, 0xe4b: 0x4000, - 0xe4c: 0x4000, 0xe4d: 0x4000, 0xe4e: 0x4000, 0xe4f: 0x4000, 0xe50: 0x4000, 0xe51: 0x4000, - 0xe52: 0x4000, 0xe53: 0x4000, 0xe54: 0x4000, 0xe55: 0x4000, 0xe56: 0x4000, 0xe57: 0x4000, - 0xe58: 0x4000, 0xe59: 0x4000, 0xe5a: 0x4000, 0xe5b: 0x4000, 0xe5c: 0x4000, 0xe5d: 0x4000, - 0xe5e: 0x4000, 0xe5f: 0x4000, 0xe60: 0x4000, 0xe61: 0x4000, 0xe62: 0x4000, 0xe63: 0x4000, - 0xe70: 0x4000, 0xe71: 0x4000, 0xe72: 0x4000, 0xe73: 0x4000, 0xe74: 0x4000, 0xe75: 0x4000, - 0xe76: 0x4000, 0xe77: 0x4000, 0xe78: 0x4000, 0xe79: 0x4000, 0xe7a: 0x4000, 0xe7b: 0x4000, - 0xe7c: 0x4000, 0xe7d: 0x4000, 0xe7e: 0x4000, 0xe7f: 0x4000, - // Block 0x3a, offset 0xe80 - 0xe80: 0x4000, 0xe81: 0x4000, 0xe82: 0x4000, 0xe83: 0x4000, 0xe84: 0x4000, 0xe85: 0x4000, - 0xe86: 0x4000, 0xe87: 0x4000, 0xe88: 0x4000, 0xe89: 0x4000, 0xe8a: 0x4000, 0xe8b: 0x4000, - 0xe8c: 0x4000, 0xe8d: 0x4000, 0xe8e: 0x4000, 0xe8f: 0x4000, 0xe90: 0x4000, 0xe91: 0x4000, - 0xe92: 0x4000, 0xe93: 0x4000, 0xe94: 0x4000, 0xe95: 0x4000, 0xe96: 0x4000, 0xe97: 0x4000, - 0xe98: 0x4000, 0xe99: 0x4000, 0xe9a: 0x4000, 0xe9b: 0x4000, 0xe9c: 0x4000, 0xe9d: 0x4000, - 0xe9e: 0x4000, 0xea0: 0x4000, 0xea1: 0x4000, 0xea2: 0x4000, 0xea3: 0x4000, - 0xea4: 0x4000, 0xea5: 0x4000, 0xea6: 0x4000, 0xea7: 0x4000, 0xea8: 0x4000, 0xea9: 0x4000, - 0xeaa: 0x4000, 0xeab: 0x4000, 0xeac: 0x4000, 0xead: 0x4000, 0xeae: 0x4000, 0xeaf: 0x4000, - 0xeb0: 0x4000, 0xeb1: 0x4000, 0xeb2: 0x4000, 0xeb3: 0x4000, 0xeb4: 0x4000, 0xeb5: 0x4000, - 0xeb6: 0x4000, 0xeb7: 0x4000, 0xeb8: 0x4000, 0xeb9: 0x4000, 0xeba: 0x4000, 0xebb: 0x4000, - 0xebc: 0x4000, 0xebd: 0x4000, 0xebe: 0x4000, 0xebf: 0x4000, - // Block 0x3b, offset 0xec0 - 0xec0: 0x4000, 0xec1: 0x4000, 0xec2: 0x4000, 0xec3: 0x4000, 0xec4: 0x4000, 0xec5: 0x4000, - 0xec6: 0x4000, 0xec7: 0x4000, 0xec8: 0x2000, 0xec9: 0x2000, 0xeca: 0x2000, 0xecb: 0x2000, - 0xecc: 0x2000, 0xecd: 0x2000, 0xece: 0x2000, 0xecf: 0x2000, 0xed0: 0x4000, 0xed1: 0x4000, - 0xed2: 0x4000, 0xed3: 0x4000, 0xed4: 0x4000, 0xed5: 0x4000, 0xed6: 0x4000, 0xed7: 0x4000, - 0xed8: 0x4000, 0xed9: 0x4000, 0xeda: 0x4000, 0xedb: 0x4000, 0xedc: 0x4000, 0xedd: 0x4000, - 0xede: 0x4000, 0xedf: 0x4000, 0xee0: 0x4000, 0xee1: 0x4000, 0xee2: 0x4000, 0xee3: 0x4000, - 0xee4: 0x4000, 0xee5: 0x4000, 0xee6: 0x4000, 0xee7: 0x4000, 0xee8: 0x4000, 0xee9: 0x4000, - 0xeea: 0x4000, 0xeeb: 0x4000, 0xeec: 0x4000, 0xeed: 0x4000, 0xeee: 0x4000, 0xeef: 0x4000, - 0xef0: 0x4000, 0xef1: 0x4000, 0xef2: 0x4000, 0xef3: 0x4000, 0xef4: 0x4000, 0xef5: 0x4000, - 0xef6: 0x4000, 0xef7: 0x4000, 0xef8: 0x4000, 0xef9: 0x4000, 0xefa: 0x4000, 0xefb: 0x4000, - 0xefc: 0x4000, 0xefd: 0x4000, 0xefe: 0x4000, 0xeff: 0x4000, - // Block 0x3c, offset 0xf00 - 0xf00: 0x4000, 0xf01: 0x4000, 0xf02: 0x4000, 0xf03: 0x4000, 0xf04: 0x4000, 0xf05: 0x4000, - 0xf06: 0x4000, 0xf07: 0x4000, 0xf08: 0x4000, 0xf09: 0x4000, 0xf0a: 0x4000, 0xf0b: 0x4000, - 0xf0c: 0x4000, 0xf0d: 0x4000, 0xf0e: 0x4000, 0xf0f: 0x4000, 0xf10: 0x4000, 0xf11: 0x4000, - 0xf12: 0x4000, 0xf13: 0x4000, 0xf14: 0x4000, 0xf15: 0x4000, 0xf16: 0x4000, 0xf17: 0x4000, - 0xf18: 0x4000, 0xf19: 0x4000, 0xf1a: 0x4000, 0xf1b: 0x4000, 0xf1c: 0x4000, 0xf1d: 0x4000, - 0xf1e: 0x4000, 0xf1f: 0x4000, 0xf20: 0x4000, 0xf21: 0x4000, 0xf22: 0x4000, 0xf23: 0x4000, - 0xf24: 0x4000, 0xf25: 0x4000, 0xf26: 0x4000, 0xf27: 0x4000, 0xf28: 0x4000, 0xf29: 0x4000, - 0xf2a: 0x4000, 0xf2b: 0x4000, 0xf2c: 0x4000, 0xf2d: 0x4000, 0xf2e: 0x4000, 0xf2f: 0x4000, - 0xf30: 0x4000, 0xf31: 0x4000, 0xf32: 0x4000, 0xf33: 0x4000, 0xf34: 0x4000, 0xf35: 0x4000, - 0xf36: 0x4000, 0xf37: 0x4000, 0xf38: 0x4000, 0xf39: 0x4000, 0xf3a: 0x4000, 0xf3b: 0x4000, - 0xf3c: 0x4000, 0xf3d: 0x4000, 0xf3e: 0x4000, - // Block 0x3d, offset 0xf40 - 0xf40: 0x4000, 0xf41: 0x4000, 0xf42: 0x4000, 0xf43: 0x4000, 0xf44: 0x4000, 0xf45: 0x4000, - 0xf46: 0x4000, 0xf47: 0x4000, 0xf48: 0x4000, 0xf49: 0x4000, 0xf4a: 0x4000, 0xf4b: 0x4000, - 0xf4c: 0x4000, 0xf50: 0x4000, 0xf51: 0x4000, - 0xf52: 0x4000, 0xf53: 0x4000, 0xf54: 0x4000, 0xf55: 0x4000, 0xf56: 0x4000, 0xf57: 0x4000, - 0xf58: 0x4000, 0xf59: 0x4000, 0xf5a: 0x4000, 0xf5b: 0x4000, 0xf5c: 0x4000, 0xf5d: 0x4000, - 0xf5e: 0x4000, 0xf5f: 0x4000, 0xf60: 0x4000, 0xf61: 0x4000, 0xf62: 0x4000, 0xf63: 0x4000, - 0xf64: 0x4000, 0xf65: 0x4000, 0xf66: 0x4000, 0xf67: 0x4000, 0xf68: 0x4000, 0xf69: 0x4000, - 0xf6a: 0x4000, 0xf6b: 0x4000, 0xf6c: 0x4000, 0xf6d: 0x4000, 0xf6e: 0x4000, 0xf6f: 0x4000, - 0xf70: 0x4000, 0xf71: 0x4000, 0xf72: 0x4000, 0xf73: 0x4000, 0xf74: 0x4000, 0xf75: 0x4000, - 0xf76: 0x4000, 0xf77: 0x4000, 0xf78: 0x4000, 0xf79: 0x4000, 0xf7a: 0x4000, 0xf7b: 0x4000, - 0xf7c: 0x4000, 0xf7d: 0x4000, 0xf7e: 0x4000, 0xf7f: 0x4000, - // Block 0x3e, offset 0xf80 - 0xf80: 0x4000, 0xf81: 0x4000, 0xf82: 0x4000, 0xf83: 0x4000, 0xf84: 0x4000, 0xf85: 0x4000, - 0xf86: 0x4000, - // Block 0x3f, offset 0xfc0 - 0xfe0: 0x4000, 0xfe1: 0x4000, 0xfe2: 0x4000, 0xfe3: 0x4000, - 0xfe4: 0x4000, 0xfe5: 0x4000, 0xfe6: 0x4000, 0xfe7: 0x4000, 0xfe8: 0x4000, 0xfe9: 0x4000, - 0xfea: 0x4000, 0xfeb: 0x4000, 0xfec: 0x4000, 0xfed: 0x4000, 0xfee: 0x4000, 0xfef: 0x4000, - 0xff0: 0x4000, 0xff1: 0x4000, 0xff2: 0x4000, 0xff3: 0x4000, 0xff4: 0x4000, 0xff5: 0x4000, - 0xff6: 0x4000, 0xff7: 0x4000, 0xff8: 0x4000, 0xff9: 0x4000, 0xffa: 0x4000, 0xffb: 0x4000, - 0xffc: 0x4000, - // Block 0x40, offset 0x1000 - 0x1000: 0x4000, 0x1001: 0x4000, 0x1002: 0x4000, 0x1003: 0x4000, 0x1004: 0x4000, 0x1005: 0x4000, - 0x1006: 0x4000, 0x1007: 0x4000, 0x1008: 0x4000, 0x1009: 0x4000, 0x100a: 0x4000, 0x100b: 0x4000, - 0x100c: 0x4000, 0x100d: 0x4000, 0x100e: 0x4000, 0x100f: 0x4000, 0x1010: 0x4000, 0x1011: 0x4000, - 0x1012: 0x4000, 0x1013: 0x4000, 0x1014: 0x4000, 0x1015: 0x4000, 0x1016: 0x4000, 0x1017: 0x4000, - 0x1018: 0x4000, 0x1019: 0x4000, 0x101a: 0x4000, 0x101b: 0x4000, 0x101c: 0x4000, 0x101d: 0x4000, - 0x101e: 0x4000, 0x101f: 0x4000, 0x1020: 0x4000, 0x1021: 0x4000, 0x1022: 0x4000, 0x1023: 0x4000, - // Block 0x41, offset 0x1040 - 0x1040: 0x2000, 0x1041: 0x2000, 0x1042: 0x2000, 0x1043: 0x2000, 0x1044: 0x2000, 0x1045: 0x2000, - 0x1046: 0x2000, 0x1047: 0x2000, 0x1048: 0x2000, 0x1049: 0x2000, 0x104a: 0x2000, 0x104b: 0x2000, - 0x104c: 0x2000, 0x104d: 0x2000, 0x104e: 0x2000, 0x104f: 0x2000, 0x1050: 0x4000, 0x1051: 0x4000, - 0x1052: 0x4000, 0x1053: 0x4000, 0x1054: 0x4000, 0x1055: 0x4000, 0x1056: 0x4000, 0x1057: 0x4000, - 0x1058: 0x4000, 0x1059: 0x4000, - 0x1070: 0x4000, 0x1071: 0x4000, 0x1072: 0x4000, 0x1073: 0x4000, 0x1074: 0x4000, 0x1075: 0x4000, - 0x1076: 0x4000, 0x1077: 0x4000, 0x1078: 0x4000, 0x1079: 0x4000, 0x107a: 0x4000, 0x107b: 0x4000, - 0x107c: 0x4000, 0x107d: 0x4000, 0x107e: 0x4000, 0x107f: 0x4000, - // Block 0x42, offset 0x1080 - 0x1080: 0x4000, 0x1081: 0x4000, 0x1082: 0x4000, 0x1083: 0x4000, 0x1084: 0x4000, 0x1085: 0x4000, - 0x1086: 0x4000, 0x1087: 0x4000, 0x1088: 0x4000, 0x1089: 0x4000, 0x108a: 0x4000, 0x108b: 0x4000, - 0x108c: 0x4000, 0x108d: 0x4000, 0x108e: 0x4000, 0x108f: 0x4000, 0x1090: 0x4000, 0x1091: 0x4000, - 0x1092: 0x4000, 0x1094: 0x4000, 0x1095: 0x4000, 0x1096: 0x4000, 0x1097: 0x4000, - 0x1098: 0x4000, 0x1099: 0x4000, 0x109a: 0x4000, 0x109b: 0x4000, 0x109c: 0x4000, 0x109d: 0x4000, - 0x109e: 0x4000, 0x109f: 0x4000, 0x10a0: 0x4000, 0x10a1: 0x4000, 0x10a2: 0x4000, 0x10a3: 0x4000, - 0x10a4: 0x4000, 0x10a5: 0x4000, 0x10a6: 0x4000, 0x10a8: 0x4000, 0x10a9: 0x4000, - 0x10aa: 0x4000, 0x10ab: 0x4000, - // Block 0x43, offset 0x10c0 - 0x10c1: 0x9012, 0x10c2: 0x9012, 0x10c3: 0x9012, 0x10c4: 0x9012, 0x10c5: 0x9012, - 0x10c6: 0x9012, 0x10c7: 0x9012, 0x10c8: 0x9012, 0x10c9: 0x9012, 0x10ca: 0x9012, 0x10cb: 0x9012, - 0x10cc: 0x9012, 0x10cd: 0x9012, 0x10ce: 0x9012, 0x10cf: 0x9012, 0x10d0: 0x9012, 0x10d1: 0x9012, - 0x10d2: 0x9012, 0x10d3: 0x9012, 0x10d4: 0x9012, 0x10d5: 0x9012, 0x10d6: 0x9012, 0x10d7: 0x9012, - 0x10d8: 0x9012, 0x10d9: 0x9012, 0x10da: 0x9012, 0x10db: 0x9012, 0x10dc: 0x9012, 0x10dd: 0x9012, - 0x10de: 0x9012, 0x10df: 0x9012, 0x10e0: 0x9049, 0x10e1: 0x9049, 0x10e2: 0x9049, 0x10e3: 0x9049, - 0x10e4: 0x9049, 0x10e5: 0x9049, 0x10e6: 0x9049, 0x10e7: 0x9049, 0x10e8: 0x9049, 0x10e9: 0x9049, - 0x10ea: 0x9049, 0x10eb: 0x9049, 0x10ec: 0x9049, 0x10ed: 0x9049, 0x10ee: 0x9049, 0x10ef: 0x9049, - 0x10f0: 0x9049, 0x10f1: 0x9049, 0x10f2: 0x9049, 0x10f3: 0x9049, 0x10f4: 0x9049, 0x10f5: 0x9049, - 0x10f6: 0x9049, 0x10f7: 0x9049, 0x10f8: 0x9049, 0x10f9: 0x9049, 0x10fa: 0x9049, 0x10fb: 0x9049, - 0x10fc: 0x9049, 0x10fd: 0x9049, 0x10fe: 0x9049, 0x10ff: 0x9049, - // Block 0x44, offset 0x1100 - 0x1100: 0x9049, 0x1101: 0x9049, 0x1102: 0x9049, 0x1103: 0x9049, 0x1104: 0x9049, 0x1105: 0x9049, - 0x1106: 0x9049, 0x1107: 0x9049, 0x1108: 0x9049, 0x1109: 0x9049, 0x110a: 0x9049, 0x110b: 0x9049, - 0x110c: 0x9049, 0x110d: 0x9049, 0x110e: 0x9049, 0x110f: 0x9049, 0x1110: 0x9049, 0x1111: 0x9049, - 0x1112: 0x9049, 0x1113: 0x9049, 0x1114: 0x9049, 0x1115: 0x9049, 0x1116: 0x9049, 0x1117: 0x9049, - 0x1118: 0x9049, 0x1119: 0x9049, 0x111a: 0x9049, 0x111b: 0x9049, 0x111c: 0x9049, 0x111d: 0x9049, - 0x111e: 0x9049, 0x111f: 0x904a, 0x1120: 0x904b, 0x1121: 0xb04c, 0x1122: 0xb04d, 0x1123: 0xb04d, - 0x1124: 0xb04e, 0x1125: 0xb04f, 0x1126: 0xb050, 0x1127: 0xb051, 0x1128: 0xb052, 0x1129: 0xb053, - 0x112a: 0xb054, 0x112b: 0xb055, 0x112c: 0xb056, 0x112d: 0xb057, 0x112e: 0xb058, 0x112f: 0xb059, - 0x1130: 0xb05a, 0x1131: 0xb05b, 0x1132: 0xb05c, 0x1133: 0xb05d, 0x1134: 0xb05e, 0x1135: 0xb05f, - 0x1136: 0xb060, 0x1137: 0xb061, 0x1138: 0xb062, 0x1139: 0xb063, 0x113a: 0xb064, 0x113b: 0xb065, - 0x113c: 0xb052, 0x113d: 0xb066, 0x113e: 0xb067, 0x113f: 0xb055, - // Block 0x45, offset 0x1140 - 0x1140: 0xb068, 0x1141: 0xb069, 0x1142: 0xb06a, 0x1143: 0xb06b, 0x1144: 0xb05a, 0x1145: 0xb056, - 0x1146: 0xb06c, 0x1147: 0xb06d, 0x1148: 0xb06b, 0x1149: 0xb06e, 0x114a: 0xb06b, 0x114b: 0xb06f, - 0x114c: 0xb06f, 0x114d: 0xb070, 0x114e: 0xb070, 0x114f: 0xb071, 0x1150: 0xb056, 0x1151: 0xb072, - 0x1152: 0xb073, 0x1153: 0xb072, 0x1154: 0xb074, 0x1155: 0xb073, 0x1156: 0xb075, 0x1157: 0xb075, - 0x1158: 0xb076, 0x1159: 0xb076, 0x115a: 0xb077, 0x115b: 0xb077, 0x115c: 0xb073, 0x115d: 0xb078, - 0x115e: 0xb079, 0x115f: 0xb067, 0x1160: 0xb07a, 0x1161: 0xb07b, 0x1162: 0xb07b, 0x1163: 0xb07b, - 0x1164: 0xb07b, 0x1165: 0xb07b, 0x1166: 0xb07b, 0x1167: 0xb07b, 0x1168: 0xb07b, 0x1169: 0xb07b, - 0x116a: 0xb07b, 0x116b: 0xb07b, 0x116c: 0xb07b, 0x116d: 0xb07b, 0x116e: 0xb07b, 0x116f: 0xb07b, - 0x1170: 0xb07c, 0x1171: 0xb07c, 0x1172: 0xb07c, 0x1173: 0xb07c, 0x1174: 0xb07c, 0x1175: 0xb07c, - 0x1176: 0xb07c, 0x1177: 0xb07c, 0x1178: 0xb07c, 0x1179: 0xb07c, 0x117a: 0xb07c, 0x117b: 0xb07c, - 0x117c: 0xb07c, 0x117d: 0xb07c, 0x117e: 0xb07c, - // Block 0x46, offset 0x1180 - 0x1182: 0xb07d, 0x1183: 0xb07e, 0x1184: 0xb07f, 0x1185: 0xb080, - 0x1186: 0xb07f, 0x1187: 0xb07e, 0x118a: 0xb081, 0x118b: 0xb082, - 0x118c: 0xb083, 0x118d: 0xb07f, 0x118e: 0xb080, 0x118f: 0xb07f, - 0x1192: 0xb084, 0x1193: 0xb085, 0x1194: 0xb084, 0x1195: 0xb086, 0x1196: 0xb084, 0x1197: 0xb087, - 0x119a: 0xb088, 0x119b: 0xb089, 0x119c: 0xb08a, - 0x11a0: 0x908b, 0x11a1: 0x908b, 0x11a2: 0x908c, 0x11a3: 0x908d, - 0x11a4: 0x908b, 0x11a5: 0x908e, 0x11a6: 0x908f, 0x11a8: 0xb090, 0x11a9: 0xb091, - 0x11aa: 0xb092, 0x11ab: 0xb091, 0x11ac: 0xb093, 0x11ad: 0xb094, 0x11ae: 0xb095, - 0x11bd: 0x2000, - // Block 0x47, offset 0x11c0 - 0x11e0: 0x4000, 0x11e1: 0x4000, - // Block 0x48, offset 0x1200 - 0x1200: 0x4000, 0x1201: 0x4000, 0x1202: 0x4000, 0x1203: 0x4000, 0x1204: 0x4000, 0x1205: 0x4000, - 0x1206: 0x4000, 0x1207: 0x4000, 0x1208: 0x4000, 0x1209: 0x4000, 0x120a: 0x4000, 0x120b: 0x4000, - 0x120c: 0x4000, 0x120d: 0x4000, 0x120e: 0x4000, 0x120f: 0x4000, 0x1210: 0x4000, 0x1211: 0x4000, - 0x1212: 0x4000, 0x1213: 0x4000, 0x1214: 0x4000, 0x1215: 0x4000, 0x1216: 0x4000, 0x1217: 0x4000, - 0x1218: 0x4000, 0x1219: 0x4000, 0x121a: 0x4000, 0x121b: 0x4000, 0x121c: 0x4000, 0x121d: 0x4000, - 0x121e: 0x4000, 0x121f: 0x4000, 0x1220: 0x4000, 0x1221: 0x4000, 0x1222: 0x4000, 0x1223: 0x4000, - 0x1224: 0x4000, 0x1225: 0x4000, 0x1226: 0x4000, 0x1227: 0x4000, 0x1228: 0x4000, 0x1229: 0x4000, - 0x122a: 0x4000, 0x122b: 0x4000, 0x122c: 0x4000, - // Block 0x49, offset 0x1240 - 0x1240: 0x4000, 0x1241: 0x4000, 0x1242: 0x4000, 0x1243: 0x4000, 0x1244: 0x4000, 0x1245: 0x4000, - 0x1246: 0x4000, 0x1247: 0x4000, 0x1248: 0x4000, 0x1249: 0x4000, 0x124a: 0x4000, 0x124b: 0x4000, - 0x124c: 0x4000, 0x124d: 0x4000, 0x124e: 0x4000, 0x124f: 0x4000, 0x1250: 0x4000, 0x1251: 0x4000, - 0x1252: 0x4000, 0x1253: 0x4000, 0x1254: 0x4000, 0x1255: 0x4000, 0x1256: 0x4000, 0x1257: 0x4000, - 0x1258: 0x4000, 0x1259: 0x4000, 0x125a: 0x4000, 0x125b: 0x4000, 0x125c: 0x4000, 0x125d: 0x4000, - 0x125e: 0x4000, 0x125f: 0x4000, 0x1260: 0x4000, 0x1261: 0x4000, 0x1262: 0x4000, 0x1263: 0x4000, - 0x1264: 0x4000, 0x1265: 0x4000, 0x1266: 0x4000, 0x1267: 0x4000, 0x1268: 0x4000, 0x1269: 0x4000, - 0x126a: 0x4000, 0x126b: 0x4000, 0x126c: 0x4000, 0x126d: 0x4000, 0x126e: 0x4000, 0x126f: 0x4000, - 0x1270: 0x4000, 0x1271: 0x4000, 0x1272: 0x4000, - // Block 0x4a, offset 0x1280 - 0x1280: 0x4000, 0x1281: 0x4000, 0x1282: 0x4000, 0x1283: 0x4000, 0x1284: 0x4000, 0x1285: 0x4000, - 0x1286: 0x4000, 0x1287: 0x4000, 0x1288: 0x4000, 0x1289: 0x4000, 0x128a: 0x4000, 0x128b: 0x4000, - 0x128c: 0x4000, 0x128d: 0x4000, 0x128e: 0x4000, 0x128f: 0x4000, 0x1290: 0x4000, 0x1291: 0x4000, - 0x1292: 0x4000, 0x1293: 0x4000, 0x1294: 0x4000, 0x1295: 0x4000, 0x1296: 0x4000, 0x1297: 0x4000, - 0x1298: 0x4000, 0x1299: 0x4000, 0x129a: 0x4000, 0x129b: 0x4000, 0x129c: 0x4000, 0x129d: 0x4000, - 0x129e: 0x4000, - // Block 0x4b, offset 0x12c0 - 0x12f0: 0x4000, 0x12f1: 0x4000, 0x12f2: 0x4000, 0x12f3: 0x4000, 0x12f4: 0x4000, 0x12f5: 0x4000, - 0x12f6: 0x4000, 0x12f7: 0x4000, 0x12f8: 0x4000, 0x12f9: 0x4000, 0x12fa: 0x4000, 0x12fb: 0x4000, - 0x12fc: 0x4000, 0x12fd: 0x4000, 0x12fe: 0x4000, 0x12ff: 0x4000, - // Block 0x4c, offset 0x1300 - 0x1300: 0x4000, 0x1301: 0x4000, 0x1302: 0x4000, 0x1303: 0x4000, 0x1304: 0x4000, 0x1305: 0x4000, - 0x1306: 0x4000, 0x1307: 0x4000, 0x1308: 0x4000, 0x1309: 0x4000, 0x130a: 0x4000, 0x130b: 0x4000, - 0x130c: 0x4000, 0x130d: 0x4000, 0x130e: 0x4000, 0x130f: 0x4000, 0x1310: 0x4000, 0x1311: 0x4000, - 0x1312: 0x4000, 0x1313: 0x4000, 0x1314: 0x4000, 0x1315: 0x4000, 0x1316: 0x4000, 0x1317: 0x4000, - 0x1318: 0x4000, 0x1319: 0x4000, 0x131a: 0x4000, 0x131b: 0x4000, 0x131c: 0x4000, 0x131d: 0x4000, - 0x131e: 0x4000, 0x131f: 0x4000, 0x1320: 0x4000, 0x1321: 0x4000, 0x1322: 0x4000, 0x1323: 0x4000, - 0x1324: 0x4000, 0x1325: 0x4000, 0x1326: 0x4000, 0x1327: 0x4000, 0x1328: 0x4000, 0x1329: 0x4000, - 0x132a: 0x4000, 0x132b: 0x4000, 0x132c: 0x4000, 0x132d: 0x4000, 0x132e: 0x4000, 0x132f: 0x4000, - 0x1330: 0x4000, 0x1331: 0x4000, 0x1332: 0x4000, 0x1333: 0x4000, 0x1334: 0x4000, 0x1335: 0x4000, - 0x1336: 0x4000, 0x1337: 0x4000, 0x1338: 0x4000, 0x1339: 0x4000, 0x133a: 0x4000, 0x133b: 0x4000, - // Block 0x4d, offset 0x1340 - 0x1344: 0x4000, - // Block 0x4e, offset 0x1380 - 0x138f: 0x4000, - // Block 0x4f, offset 0x13c0 - 0x13c0: 0x2000, 0x13c1: 0x2000, 0x13c2: 0x2000, 0x13c3: 0x2000, 0x13c4: 0x2000, 0x13c5: 0x2000, - 0x13c6: 0x2000, 0x13c7: 0x2000, 0x13c8: 0x2000, 0x13c9: 0x2000, 0x13ca: 0x2000, - 0x13d0: 0x2000, 0x13d1: 0x2000, - 0x13d2: 0x2000, 0x13d3: 0x2000, 0x13d4: 0x2000, 0x13d5: 0x2000, 0x13d6: 0x2000, 0x13d7: 0x2000, - 0x13d8: 0x2000, 0x13d9: 0x2000, 0x13da: 0x2000, 0x13db: 0x2000, 0x13dc: 0x2000, 0x13dd: 0x2000, - 0x13de: 0x2000, 0x13df: 0x2000, 0x13e0: 0x2000, 0x13e1: 0x2000, 0x13e2: 0x2000, 0x13e3: 0x2000, - 0x13e4: 0x2000, 0x13e5: 0x2000, 0x13e6: 0x2000, 0x13e7: 0x2000, 0x13e8: 0x2000, 0x13e9: 0x2000, - 0x13ea: 0x2000, 0x13eb: 0x2000, 0x13ec: 0x2000, 0x13ed: 0x2000, - 0x13f0: 0x2000, 0x13f1: 0x2000, 0x13f2: 0x2000, 0x13f3: 0x2000, 0x13f4: 0x2000, 0x13f5: 0x2000, - 0x13f6: 0x2000, 0x13f7: 0x2000, 0x13f8: 0x2000, 0x13f9: 0x2000, 0x13fa: 0x2000, 0x13fb: 0x2000, - 0x13fc: 0x2000, 0x13fd: 0x2000, 0x13fe: 0x2000, 0x13ff: 0x2000, - // Block 0x50, offset 0x1400 - 0x1400: 0x2000, 0x1401: 0x2000, 0x1402: 0x2000, 0x1403: 0x2000, 0x1404: 0x2000, 0x1405: 0x2000, - 0x1406: 0x2000, 0x1407: 0x2000, 0x1408: 0x2000, 0x1409: 0x2000, 0x140a: 0x2000, 0x140b: 0x2000, - 0x140c: 0x2000, 0x140d: 0x2000, 0x140e: 0x2000, 0x140f: 0x2000, 0x1410: 0x2000, 0x1411: 0x2000, - 0x1412: 0x2000, 0x1413: 0x2000, 0x1414: 0x2000, 0x1415: 0x2000, 0x1416: 0x2000, 0x1417: 0x2000, - 0x1418: 0x2000, 0x1419: 0x2000, 0x141a: 0x2000, 0x141b: 0x2000, 0x141c: 0x2000, 0x141d: 0x2000, - 0x141e: 0x2000, 0x141f: 0x2000, 0x1420: 0x2000, 0x1421: 0x2000, 0x1422: 0x2000, 0x1423: 0x2000, - 0x1424: 0x2000, 0x1425: 0x2000, 0x1426: 0x2000, 0x1427: 0x2000, 0x1428: 0x2000, 0x1429: 0x2000, - 0x1430: 0x2000, 0x1431: 0x2000, 0x1432: 0x2000, 0x1433: 0x2000, 0x1434: 0x2000, 0x1435: 0x2000, - 0x1436: 0x2000, 0x1437: 0x2000, 0x1438: 0x2000, 0x1439: 0x2000, 0x143a: 0x2000, 0x143b: 0x2000, - 0x143c: 0x2000, 0x143d: 0x2000, 0x143e: 0x2000, 0x143f: 0x2000, - // Block 0x51, offset 0x1440 - 0x1440: 0x2000, 0x1441: 0x2000, 0x1442: 0x2000, 0x1443: 0x2000, 0x1444: 0x2000, 0x1445: 0x2000, - 0x1446: 0x2000, 0x1447: 0x2000, 0x1448: 0x2000, 0x1449: 0x2000, 0x144a: 0x2000, 0x144b: 0x2000, - 0x144c: 0x2000, 0x144d: 0x2000, 0x144e: 0x4000, 0x144f: 0x2000, 0x1450: 0x2000, 0x1451: 0x4000, - 0x1452: 0x4000, 0x1453: 0x4000, 0x1454: 0x4000, 0x1455: 0x4000, 0x1456: 0x4000, 0x1457: 0x4000, - 0x1458: 0x4000, 0x1459: 0x4000, 0x145a: 0x4000, 0x145b: 0x2000, 0x145c: 0x2000, 0x145d: 0x2000, - 0x145e: 0x2000, 0x145f: 0x2000, 0x1460: 0x2000, 0x1461: 0x2000, 0x1462: 0x2000, 0x1463: 0x2000, - 0x1464: 0x2000, 0x1465: 0x2000, 0x1466: 0x2000, 0x1467: 0x2000, 0x1468: 0x2000, 0x1469: 0x2000, - 0x146a: 0x2000, 0x146b: 0x2000, 0x146c: 0x2000, - // Block 0x52, offset 0x1480 - 0x1480: 0x4000, 0x1481: 0x4000, 0x1482: 0x4000, - 0x1490: 0x4000, 0x1491: 0x4000, - 0x1492: 0x4000, 0x1493: 0x4000, 0x1494: 0x4000, 0x1495: 0x4000, 0x1496: 0x4000, 0x1497: 0x4000, - 0x1498: 0x4000, 0x1499: 0x4000, 0x149a: 0x4000, 0x149b: 0x4000, 0x149c: 0x4000, 0x149d: 0x4000, - 0x149e: 0x4000, 0x149f: 0x4000, 0x14a0: 0x4000, 0x14a1: 0x4000, 0x14a2: 0x4000, 0x14a3: 0x4000, - 0x14a4: 0x4000, 0x14a5: 0x4000, 0x14a6: 0x4000, 0x14a7: 0x4000, 0x14a8: 0x4000, 0x14a9: 0x4000, - 0x14aa: 0x4000, 0x14ab: 0x4000, 0x14ac: 0x4000, 0x14ad: 0x4000, 0x14ae: 0x4000, 0x14af: 0x4000, - 0x14b0: 0x4000, 0x14b1: 0x4000, 0x14b2: 0x4000, 0x14b3: 0x4000, 0x14b4: 0x4000, 0x14b5: 0x4000, - 0x14b6: 0x4000, 0x14b7: 0x4000, 0x14b8: 0x4000, 0x14b9: 0x4000, 0x14ba: 0x4000, 0x14bb: 0x4000, - // Block 0x53, offset 0x14c0 - 0x14c0: 0x4000, 0x14c1: 0x4000, 0x14c2: 0x4000, 0x14c3: 0x4000, 0x14c4: 0x4000, 0x14c5: 0x4000, - 0x14c6: 0x4000, 0x14c7: 0x4000, 0x14c8: 0x4000, - 0x14d0: 0x4000, 0x14d1: 0x4000, - 0x14e0: 0x4000, 0x14e1: 0x4000, 0x14e2: 0x4000, 0x14e3: 0x4000, - 0x14e4: 0x4000, 0x14e5: 0x4000, - // Block 0x54, offset 0x1500 - 0x1500: 0x4000, 0x1501: 0x4000, 0x1502: 0x4000, 0x1503: 0x4000, 0x1504: 0x4000, 0x1505: 0x4000, - 0x1506: 0x4000, 0x1507: 0x4000, 0x1508: 0x4000, 0x1509: 0x4000, 0x150a: 0x4000, 0x150b: 0x4000, - 0x150c: 0x4000, 0x150d: 0x4000, 0x150e: 0x4000, 0x150f: 0x4000, 0x1510: 0x4000, 0x1511: 0x4000, - 0x1512: 0x4000, 0x1513: 0x4000, 0x1514: 0x4000, 0x1515: 0x4000, 0x1516: 0x4000, 0x1517: 0x4000, - 0x1518: 0x4000, 0x1519: 0x4000, 0x151a: 0x4000, 0x151b: 0x4000, 0x151c: 0x4000, 0x151d: 0x4000, - 0x151e: 0x4000, 0x151f: 0x4000, 0x1520: 0x4000, - 0x152d: 0x4000, 0x152e: 0x4000, 0x152f: 0x4000, - 0x1530: 0x4000, 0x1531: 0x4000, 0x1532: 0x4000, 0x1533: 0x4000, 0x1534: 0x4000, 0x1535: 0x4000, - 0x1537: 0x4000, 0x1538: 0x4000, 0x1539: 0x4000, 0x153a: 0x4000, 0x153b: 0x4000, - 0x153c: 0x4000, 0x153d: 0x4000, 0x153e: 0x4000, 0x153f: 0x4000, - // Block 0x55, offset 0x1540 - 0x1540: 0x4000, 0x1541: 0x4000, 0x1542: 0x4000, 0x1543: 0x4000, 0x1544: 0x4000, 0x1545: 0x4000, - 0x1546: 0x4000, 0x1547: 0x4000, 0x1548: 0x4000, 0x1549: 0x4000, 0x154a: 0x4000, 0x154b: 0x4000, - 0x154c: 0x4000, 0x154d: 0x4000, 0x154e: 0x4000, 0x154f: 0x4000, 0x1550: 0x4000, 0x1551: 0x4000, - 0x1552: 0x4000, 0x1553: 0x4000, 0x1554: 0x4000, 0x1555: 0x4000, 0x1556: 0x4000, 0x1557: 0x4000, - 0x1558: 0x4000, 0x1559: 0x4000, 0x155a: 0x4000, 0x155b: 0x4000, 0x155c: 0x4000, 0x155d: 0x4000, - 0x155e: 0x4000, 0x155f: 0x4000, 0x1560: 0x4000, 0x1561: 0x4000, 0x1562: 0x4000, 0x1563: 0x4000, - 0x1564: 0x4000, 0x1565: 0x4000, 0x1566: 0x4000, 0x1567: 0x4000, 0x1568: 0x4000, 0x1569: 0x4000, - 0x156a: 0x4000, 0x156b: 0x4000, 0x156c: 0x4000, 0x156d: 0x4000, 0x156e: 0x4000, 0x156f: 0x4000, - 0x1570: 0x4000, 0x1571: 0x4000, 0x1572: 0x4000, 0x1573: 0x4000, 0x1574: 0x4000, 0x1575: 0x4000, - 0x1576: 0x4000, 0x1577: 0x4000, 0x1578: 0x4000, 0x1579: 0x4000, 0x157a: 0x4000, 0x157b: 0x4000, - 0x157c: 0x4000, 0x157e: 0x4000, 0x157f: 0x4000, - // Block 0x56, offset 0x1580 - 0x1580: 0x4000, 0x1581: 0x4000, 0x1582: 0x4000, 0x1583: 0x4000, 0x1584: 0x4000, 0x1585: 0x4000, - 0x1586: 0x4000, 0x1587: 0x4000, 0x1588: 0x4000, 0x1589: 0x4000, 0x158a: 0x4000, 0x158b: 0x4000, - 0x158c: 0x4000, 0x158d: 0x4000, 0x158e: 0x4000, 0x158f: 0x4000, 0x1590: 0x4000, 0x1591: 0x4000, - 0x1592: 0x4000, 0x1593: 0x4000, - 0x15a0: 0x4000, 0x15a1: 0x4000, 0x15a2: 0x4000, 0x15a3: 0x4000, - 0x15a4: 0x4000, 0x15a5: 0x4000, 0x15a6: 0x4000, 0x15a7: 0x4000, 0x15a8: 0x4000, 0x15a9: 0x4000, - 0x15aa: 0x4000, 0x15ab: 0x4000, 0x15ac: 0x4000, 0x15ad: 0x4000, 0x15ae: 0x4000, 0x15af: 0x4000, - 0x15b0: 0x4000, 0x15b1: 0x4000, 0x15b2: 0x4000, 0x15b3: 0x4000, 0x15b4: 0x4000, 0x15b5: 0x4000, - 0x15b6: 0x4000, 0x15b7: 0x4000, 0x15b8: 0x4000, 0x15b9: 0x4000, 0x15ba: 0x4000, 0x15bb: 0x4000, - 0x15bc: 0x4000, 0x15bd: 0x4000, 0x15be: 0x4000, 0x15bf: 0x4000, - // Block 0x57, offset 0x15c0 - 0x15c0: 0x4000, 0x15c1: 0x4000, 0x15c2: 0x4000, 0x15c3: 0x4000, 0x15c4: 0x4000, 0x15c5: 0x4000, - 0x15c6: 0x4000, 0x15c7: 0x4000, 0x15c8: 0x4000, 0x15c9: 0x4000, 0x15ca: 0x4000, - 0x15cf: 0x4000, 0x15d0: 0x4000, 0x15d1: 0x4000, - 0x15d2: 0x4000, 0x15d3: 0x4000, - 0x15e0: 0x4000, 0x15e1: 0x4000, 0x15e2: 0x4000, 0x15e3: 0x4000, - 0x15e4: 0x4000, 0x15e5: 0x4000, 0x15e6: 0x4000, 0x15e7: 0x4000, 0x15e8: 0x4000, 0x15e9: 0x4000, - 0x15ea: 0x4000, 0x15eb: 0x4000, 0x15ec: 0x4000, 0x15ed: 0x4000, 0x15ee: 0x4000, 0x15ef: 0x4000, - 0x15f0: 0x4000, 0x15f4: 0x4000, - 0x15f8: 0x4000, 0x15f9: 0x4000, 0x15fa: 0x4000, 0x15fb: 0x4000, - 0x15fc: 0x4000, 0x15fd: 0x4000, 0x15fe: 0x4000, 0x15ff: 0x4000, - // Block 0x58, offset 0x1600 - 0x1600: 0x4000, 0x1602: 0x4000, 0x1603: 0x4000, 0x1604: 0x4000, 0x1605: 0x4000, - 0x1606: 0x4000, 0x1607: 0x4000, 0x1608: 0x4000, 0x1609: 0x4000, 0x160a: 0x4000, 0x160b: 0x4000, - 0x160c: 0x4000, 0x160d: 0x4000, 0x160e: 0x4000, 0x160f: 0x4000, 0x1610: 0x4000, 0x1611: 0x4000, - 0x1612: 0x4000, 0x1613: 0x4000, 0x1614: 0x4000, 0x1615: 0x4000, 0x1616: 0x4000, 0x1617: 0x4000, - 0x1618: 0x4000, 0x1619: 0x4000, 0x161a: 0x4000, 0x161b: 0x4000, 0x161c: 0x4000, 0x161d: 0x4000, - 0x161e: 0x4000, 0x161f: 0x4000, 0x1620: 0x4000, 0x1621: 0x4000, 0x1622: 0x4000, 0x1623: 0x4000, - 0x1624: 0x4000, 0x1625: 0x4000, 0x1626: 0x4000, 0x1627: 0x4000, 0x1628: 0x4000, 0x1629: 0x4000, - 0x162a: 0x4000, 0x162b: 0x4000, 0x162c: 0x4000, 0x162d: 0x4000, 0x162e: 0x4000, 0x162f: 0x4000, - 0x1630: 0x4000, 0x1631: 0x4000, 0x1632: 0x4000, 0x1633: 0x4000, 0x1634: 0x4000, 0x1635: 0x4000, - 0x1636: 0x4000, 0x1637: 0x4000, 0x1638: 0x4000, 0x1639: 0x4000, 0x163a: 0x4000, 0x163b: 0x4000, - 0x163c: 0x4000, 0x163d: 0x4000, 0x163e: 0x4000, 0x163f: 0x4000, - // Block 0x59, offset 0x1640 - 0x1640: 0x4000, 0x1641: 0x4000, 0x1642: 0x4000, 0x1643: 0x4000, 0x1644: 0x4000, 0x1645: 0x4000, - 0x1646: 0x4000, 0x1647: 0x4000, 0x1648: 0x4000, 0x1649: 0x4000, 0x164a: 0x4000, 0x164b: 0x4000, - 0x164c: 0x4000, 0x164d: 0x4000, 0x164e: 0x4000, 0x164f: 0x4000, 0x1650: 0x4000, 0x1651: 0x4000, - 0x1652: 0x4000, 0x1653: 0x4000, 0x1654: 0x4000, 0x1655: 0x4000, 0x1656: 0x4000, 0x1657: 0x4000, - 0x1658: 0x4000, 0x1659: 0x4000, 0x165a: 0x4000, 0x165b: 0x4000, 0x165c: 0x4000, 0x165d: 0x4000, - 0x165e: 0x4000, 0x165f: 0x4000, 0x1660: 0x4000, 0x1661: 0x4000, 0x1662: 0x4000, 0x1663: 0x4000, - 0x1664: 0x4000, 0x1665: 0x4000, 0x1666: 0x4000, 0x1667: 0x4000, 0x1668: 0x4000, 0x1669: 0x4000, - 0x166a: 0x4000, 0x166b: 0x4000, 0x166c: 0x4000, 0x166d: 0x4000, 0x166e: 0x4000, 0x166f: 0x4000, - 0x1670: 0x4000, 0x1671: 0x4000, 0x1672: 0x4000, 0x1673: 0x4000, 0x1674: 0x4000, 0x1675: 0x4000, - 0x1676: 0x4000, 0x1677: 0x4000, 0x1678: 0x4000, 0x1679: 0x4000, 0x167a: 0x4000, 0x167b: 0x4000, - 0x167c: 0x4000, 0x167f: 0x4000, - // Block 0x5a, offset 0x1680 - 0x1680: 0x4000, 0x1681: 0x4000, 0x1682: 0x4000, 0x1683: 0x4000, 0x1684: 0x4000, 0x1685: 0x4000, - 0x1686: 0x4000, 0x1687: 0x4000, 0x1688: 0x4000, 0x1689: 0x4000, 0x168a: 0x4000, 0x168b: 0x4000, - 0x168c: 0x4000, 0x168d: 0x4000, 0x168e: 0x4000, 0x168f: 0x4000, 0x1690: 0x4000, 0x1691: 0x4000, - 0x1692: 0x4000, 0x1693: 0x4000, 0x1694: 0x4000, 0x1695: 0x4000, 0x1696: 0x4000, 0x1697: 0x4000, - 0x1698: 0x4000, 0x1699: 0x4000, 0x169a: 0x4000, 0x169b: 0x4000, 0x169c: 0x4000, 0x169d: 0x4000, - 0x169e: 0x4000, 0x169f: 0x4000, 0x16a0: 0x4000, 0x16a1: 0x4000, 0x16a2: 0x4000, 0x16a3: 0x4000, - 0x16a4: 0x4000, 0x16a5: 0x4000, 0x16a6: 0x4000, 0x16a7: 0x4000, 0x16a8: 0x4000, 0x16a9: 0x4000, - 0x16aa: 0x4000, 0x16ab: 0x4000, 0x16ac: 0x4000, 0x16ad: 0x4000, 0x16ae: 0x4000, 0x16af: 0x4000, - 0x16b0: 0x4000, 0x16b1: 0x4000, 0x16b2: 0x4000, 0x16b3: 0x4000, 0x16b4: 0x4000, 0x16b5: 0x4000, - 0x16b6: 0x4000, 0x16b7: 0x4000, 0x16b8: 0x4000, 0x16b9: 0x4000, 0x16ba: 0x4000, 0x16bb: 0x4000, - 0x16bc: 0x4000, 0x16bd: 0x4000, - // Block 0x5b, offset 0x16c0 - 0x16cb: 0x4000, - 0x16cc: 0x4000, 0x16cd: 0x4000, 0x16ce: 0x4000, 0x16d0: 0x4000, 0x16d1: 0x4000, - 0x16d2: 0x4000, 0x16d3: 0x4000, 0x16d4: 0x4000, 0x16d5: 0x4000, 0x16d6: 0x4000, 0x16d7: 0x4000, - 0x16d8: 0x4000, 0x16d9: 0x4000, 0x16da: 0x4000, 0x16db: 0x4000, 0x16dc: 0x4000, 0x16dd: 0x4000, - 0x16de: 0x4000, 0x16df: 0x4000, 0x16e0: 0x4000, 0x16e1: 0x4000, 0x16e2: 0x4000, 0x16e3: 0x4000, - 0x16e4: 0x4000, 0x16e5: 0x4000, 0x16e6: 0x4000, 0x16e7: 0x4000, - 0x16fa: 0x4000, - // Block 0x5c, offset 0x1700 - 0x1715: 0x4000, 0x1716: 0x4000, - 0x1724: 0x4000, - // Block 0x5d, offset 0x1740 - 0x177b: 0x4000, - 0x177c: 0x4000, 0x177d: 0x4000, 0x177e: 0x4000, 0x177f: 0x4000, - // Block 0x5e, offset 0x1780 - 0x1780: 0x4000, 0x1781: 0x4000, 0x1782: 0x4000, 0x1783: 0x4000, 0x1784: 0x4000, 0x1785: 0x4000, - 0x1786: 0x4000, 0x1787: 0x4000, 0x1788: 0x4000, 0x1789: 0x4000, 0x178a: 0x4000, 0x178b: 0x4000, - 0x178c: 0x4000, 0x178d: 0x4000, 0x178e: 0x4000, 0x178f: 0x4000, - // Block 0x5f, offset 0x17c0 - 0x17c0: 0x4000, 0x17c1: 0x4000, 0x17c2: 0x4000, 0x17c3: 0x4000, 0x17c4: 0x4000, 0x17c5: 0x4000, - 0x17cc: 0x4000, 0x17d0: 0x4000, 0x17d1: 0x4000, - 0x17d2: 0x4000, - 0x17eb: 0x4000, 0x17ec: 0x4000, - 0x17f4: 0x4000, 0x17f5: 0x4000, - 0x17f6: 0x4000, 0x17f7: 0x4000, 0x17f8: 0x4000, - // Block 0x60, offset 0x1800 - 0x1810: 0x4000, 0x1811: 0x4000, - 0x1812: 0x4000, 0x1813: 0x4000, 0x1814: 0x4000, 0x1815: 0x4000, 0x1816: 0x4000, 0x1817: 0x4000, - 0x1818: 0x4000, 0x1819: 0x4000, 0x181a: 0x4000, 0x181b: 0x4000, 0x181c: 0x4000, 0x181d: 0x4000, - 0x181e: 0x4000, 0x181f: 0x4000, 0x1820: 0x4000, 0x1821: 0x4000, 0x1822: 0x4000, 0x1823: 0x4000, - 0x1824: 0x4000, 0x1825: 0x4000, 0x1826: 0x4000, 0x1827: 0x4000, 0x1828: 0x4000, 0x1829: 0x4000, - 0x182a: 0x4000, 0x182b: 0x4000, 0x182c: 0x4000, 0x182d: 0x4000, 0x182e: 0x4000, 0x182f: 0x4000, - 0x1830: 0x4000, 0x1831: 0x4000, 0x1832: 0x4000, 0x1833: 0x4000, 0x1834: 0x4000, 0x1835: 0x4000, - 0x1836: 0x4000, 0x1837: 0x4000, 0x1838: 0x4000, 0x1839: 0x4000, 0x183a: 0x4000, 0x183b: 0x4000, - 0x183c: 0x4000, 0x183d: 0x4000, 0x183e: 0x4000, - // Block 0x61, offset 0x1840 - 0x1840: 0x4000, 0x1841: 0x4000, 0x1842: 0x4000, 0x1843: 0x4000, 0x1844: 0x4000, 0x1845: 0x4000, - 0x1846: 0x4000, 0x1847: 0x4000, 0x1848: 0x4000, 0x1849: 0x4000, 0x184a: 0x4000, 0x184b: 0x4000, - 0x184c: 0x4000, 0x1850: 0x4000, 0x1851: 0x4000, - 0x1852: 0x4000, 0x1853: 0x4000, 0x1854: 0x4000, 0x1855: 0x4000, 0x1856: 0x4000, 0x1857: 0x4000, - 0x1858: 0x4000, 0x1859: 0x4000, 0x185a: 0x4000, 0x185b: 0x4000, 0x185c: 0x4000, 0x185d: 0x4000, - 0x185e: 0x4000, 0x185f: 0x4000, 0x1860: 0x4000, 0x1861: 0x4000, 0x1862: 0x4000, 0x1863: 0x4000, - 0x1864: 0x4000, 0x1865: 0x4000, 0x1866: 0x4000, 0x1867: 0x4000, 0x1868: 0x4000, 0x1869: 0x4000, - 0x186a: 0x4000, 0x186b: 0x4000, - // Block 0x62, offset 0x1880 - 0x1880: 0x4000, 0x1881: 0x4000, 0x1882: 0x4000, 0x1883: 0x4000, 0x1884: 0x4000, 0x1885: 0x4000, - 0x1886: 0x4000, 0x1887: 0x4000, 0x1888: 0x4000, 0x1889: 0x4000, 0x188a: 0x4000, 0x188b: 0x4000, - 0x188c: 0x4000, 0x188d: 0x4000, 0x188e: 0x4000, 0x188f: 0x4000, 0x1890: 0x4000, 0x1891: 0x4000, - 0x1892: 0x4000, 0x1893: 0x4000, 0x1894: 0x4000, 0x1895: 0x4000, 0x1896: 0x4000, 0x1897: 0x4000, - // Block 0x63, offset 0x18c0 - 0x18c0: 0x4000, - 0x18d0: 0x4000, 0x18d1: 0x4000, - 0x18d2: 0x4000, 0x18d3: 0x4000, 0x18d4: 0x4000, 0x18d5: 0x4000, 0x18d6: 0x4000, 0x18d7: 0x4000, - 0x18d8: 0x4000, 0x18d9: 0x4000, 0x18da: 0x4000, 0x18db: 0x4000, 0x18dc: 0x4000, 0x18dd: 0x4000, - 0x18de: 0x4000, 0x18df: 0x4000, 0x18e0: 0x4000, 0x18e1: 0x4000, 0x18e2: 0x4000, 0x18e3: 0x4000, - 0x18e4: 0x4000, 0x18e5: 0x4000, 0x18e6: 0x4000, - // Block 0x64, offset 0x1900 - 0x1900: 0x2000, 0x1901: 0x2000, 0x1902: 0x2000, 0x1903: 0x2000, 0x1904: 0x2000, 0x1905: 0x2000, - 0x1906: 0x2000, 0x1907: 0x2000, 0x1908: 0x2000, 0x1909: 0x2000, 0x190a: 0x2000, 0x190b: 0x2000, - 0x190c: 0x2000, 0x190d: 0x2000, 0x190e: 0x2000, 0x190f: 0x2000, 0x1910: 0x2000, 0x1911: 0x2000, - 0x1912: 0x2000, 0x1913: 0x2000, 0x1914: 0x2000, 0x1915: 0x2000, 0x1916: 0x2000, 0x1917: 0x2000, - 0x1918: 0x2000, 0x1919: 0x2000, 0x191a: 0x2000, 0x191b: 0x2000, 0x191c: 0x2000, 0x191d: 0x2000, - 0x191e: 0x2000, 0x191f: 0x2000, 0x1920: 0x2000, 0x1921: 0x2000, 0x1922: 0x2000, 0x1923: 0x2000, - 0x1924: 0x2000, 0x1925: 0x2000, 0x1926: 0x2000, 0x1927: 0x2000, 0x1928: 0x2000, 0x1929: 0x2000, - 0x192a: 0x2000, 0x192b: 0x2000, 0x192c: 0x2000, 0x192d: 0x2000, 0x192e: 0x2000, 0x192f: 0x2000, - 0x1930: 0x2000, 0x1931: 0x2000, 0x1932: 0x2000, 0x1933: 0x2000, 0x1934: 0x2000, 0x1935: 0x2000, - 0x1936: 0x2000, 0x1937: 0x2000, 0x1938: 0x2000, 0x1939: 0x2000, 0x193a: 0x2000, 0x193b: 0x2000, - 0x193c: 0x2000, 0x193d: 0x2000, -} - -// widthIndex: 22 blocks, 1408 entries, 1408 bytes -// Block 0 is the zero block. -var widthIndex = [1408]uint8{ - // Block 0x0, offset 0x0 - // Block 0x1, offset 0x40 - // Block 0x2, offset 0x80 - // Block 0x3, offset 0xc0 - 0xc2: 0x01, 0xc3: 0x02, 0xc4: 0x03, 0xc5: 0x04, 0xc7: 0x05, - 0xc9: 0x06, 0xcb: 0x07, 0xcc: 0x08, 0xcd: 0x09, 0xce: 0x0a, 0xcf: 0x0b, - 0xd0: 0x0c, 0xd1: 0x0d, - 0xe1: 0x02, 0xe2: 0x03, 0xe3: 0x04, 0xe4: 0x05, 0xe5: 0x06, 0xe6: 0x06, 0xe7: 0x06, - 0xe8: 0x06, 0xe9: 0x06, 0xea: 0x07, 0xeb: 0x06, 0xec: 0x06, 0xed: 0x08, 0xee: 0x09, 0xef: 0x0a, - 0xf0: 0x0f, 0xf3: 0x12, 0xf4: 0x13, - // Block 0x4, offset 0x100 - 0x104: 0x0e, 0x105: 0x0f, - // Block 0x5, offset 0x140 - 0x140: 0x10, 0x141: 0x11, 0x142: 0x12, 0x144: 0x13, 0x145: 0x14, 0x146: 0x15, 0x147: 0x16, - 0x148: 0x17, 0x149: 0x18, 0x14a: 0x19, 0x14c: 0x1a, 0x14f: 0x1b, - 0x151: 0x1c, 0x152: 0x08, 0x153: 0x1d, 0x154: 0x1e, 0x155: 0x1f, 0x156: 0x20, 0x157: 0x21, - 0x158: 0x22, 0x159: 0x23, 0x15a: 0x24, 0x15b: 0x25, 0x15c: 0x26, 0x15d: 0x27, 0x15e: 0x28, 0x15f: 0x29, - 0x166: 0x2a, - 0x16c: 0x2b, 0x16d: 0x2c, - 0x17a: 0x2d, 0x17b: 0x2e, 0x17c: 0x0e, 0x17d: 0x0e, 0x17e: 0x0e, 0x17f: 0x2f, - // Block 0x6, offset 0x180 - 0x180: 0x30, 0x181: 0x31, 0x182: 0x32, 0x183: 0x33, 0x184: 0x34, 0x185: 0x35, 0x186: 0x36, 0x187: 0x37, - 0x188: 0x38, 0x189: 0x39, 0x18a: 0x0e, 0x18b: 0x3a, 0x18c: 0x0e, 0x18d: 0x0e, 0x18e: 0x0e, 0x18f: 0x0e, - 0x190: 0x0e, 0x191: 0x0e, 0x192: 0x0e, 0x193: 0x0e, 0x194: 0x0e, 0x195: 0x0e, 0x196: 0x0e, 0x197: 0x0e, - 0x198: 0x0e, 0x199: 0x0e, 0x19a: 0x0e, 0x19b: 0x0e, 0x19c: 0x0e, 0x19d: 0x0e, 0x19e: 0x0e, 0x19f: 0x0e, - 0x1a0: 0x0e, 0x1a1: 0x0e, 0x1a2: 0x0e, 0x1a3: 0x0e, 0x1a4: 0x0e, 0x1a5: 0x0e, 0x1a6: 0x0e, 0x1a7: 0x0e, - 0x1a8: 0x0e, 0x1a9: 0x0e, 0x1aa: 0x0e, 0x1ab: 0x0e, 0x1ac: 0x0e, 0x1ad: 0x0e, 0x1ae: 0x0e, 0x1af: 0x0e, - 0x1b0: 0x0e, 0x1b1: 0x0e, 0x1b2: 0x0e, 0x1b3: 0x0e, 0x1b4: 0x0e, 0x1b5: 0x0e, 0x1b6: 0x0e, 0x1b7: 0x0e, - 0x1b8: 0x0e, 0x1b9: 0x0e, 0x1ba: 0x0e, 0x1bb: 0x0e, 0x1bc: 0x0e, 0x1bd: 0x0e, 0x1be: 0x0e, 0x1bf: 0x0e, - // Block 0x7, offset 0x1c0 - 0x1c0: 0x0e, 0x1c1: 0x0e, 0x1c2: 0x0e, 0x1c3: 0x0e, 0x1c4: 0x0e, 0x1c5: 0x0e, 0x1c6: 0x0e, 0x1c7: 0x0e, - 0x1c8: 0x0e, 0x1c9: 0x0e, 0x1ca: 0x0e, 0x1cb: 0x0e, 0x1cc: 0x0e, 0x1cd: 0x0e, 0x1ce: 0x0e, 0x1cf: 0x0e, - 0x1d0: 0x0e, 0x1d1: 0x0e, 0x1d2: 0x0e, 0x1d3: 0x0e, 0x1d4: 0x0e, 0x1d5: 0x0e, 0x1d6: 0x0e, 0x1d7: 0x0e, - 0x1d8: 0x0e, 0x1d9: 0x0e, 0x1da: 0x0e, 0x1db: 0x0e, 0x1dc: 0x0e, 0x1dd: 0x0e, 0x1de: 0x0e, 0x1df: 0x0e, - 0x1e0: 0x0e, 0x1e1: 0x0e, 0x1e2: 0x0e, 0x1e3: 0x0e, 0x1e4: 0x0e, 0x1e5: 0x0e, 0x1e6: 0x0e, 0x1e7: 0x0e, - 0x1e8: 0x0e, 0x1e9: 0x0e, 0x1ea: 0x0e, 0x1eb: 0x0e, 0x1ec: 0x0e, 0x1ed: 0x0e, 0x1ee: 0x0e, 0x1ef: 0x0e, - 0x1f0: 0x0e, 0x1f1: 0x0e, 0x1f2: 0x0e, 0x1f3: 0x0e, 0x1f4: 0x0e, 0x1f5: 0x0e, 0x1f6: 0x0e, - 0x1f8: 0x0e, 0x1f9: 0x0e, 0x1fa: 0x0e, 0x1fb: 0x0e, 0x1fc: 0x0e, 0x1fd: 0x0e, 0x1fe: 0x0e, 0x1ff: 0x0e, - // Block 0x8, offset 0x200 - 0x200: 0x0e, 0x201: 0x0e, 0x202: 0x0e, 0x203: 0x0e, 0x204: 0x0e, 0x205: 0x0e, 0x206: 0x0e, 0x207: 0x0e, - 0x208: 0x0e, 0x209: 0x0e, 0x20a: 0x0e, 0x20b: 0x0e, 0x20c: 0x0e, 0x20d: 0x0e, 0x20e: 0x0e, 0x20f: 0x0e, - 0x210: 0x0e, 0x211: 0x0e, 0x212: 0x0e, 0x213: 0x0e, 0x214: 0x0e, 0x215: 0x0e, 0x216: 0x0e, 0x217: 0x0e, - 0x218: 0x0e, 0x219: 0x0e, 0x21a: 0x0e, 0x21b: 0x0e, 0x21c: 0x0e, 0x21d: 0x0e, 0x21e: 0x0e, 0x21f: 0x0e, - 0x220: 0x0e, 0x221: 0x0e, 0x222: 0x0e, 0x223: 0x0e, 0x224: 0x0e, 0x225: 0x0e, 0x226: 0x0e, 0x227: 0x0e, - 0x228: 0x0e, 0x229: 0x0e, 0x22a: 0x0e, 0x22b: 0x0e, 0x22c: 0x0e, 0x22d: 0x0e, 0x22e: 0x0e, 0x22f: 0x0e, - 0x230: 0x0e, 0x231: 0x0e, 0x232: 0x0e, 0x233: 0x0e, 0x234: 0x0e, 0x235: 0x0e, 0x236: 0x0e, 0x237: 0x0e, - 0x238: 0x0e, 0x239: 0x0e, 0x23a: 0x0e, 0x23b: 0x0e, 0x23c: 0x0e, 0x23d: 0x0e, 0x23e: 0x0e, 0x23f: 0x0e, - // Block 0x9, offset 0x240 - 0x240: 0x0e, 0x241: 0x0e, 0x242: 0x0e, 0x243: 0x0e, 0x244: 0x0e, 0x245: 0x0e, 0x246: 0x0e, 0x247: 0x0e, - 0x248: 0x0e, 0x249: 0x0e, 0x24a: 0x0e, 0x24b: 0x0e, 0x24c: 0x0e, 0x24d: 0x0e, 0x24e: 0x0e, 0x24f: 0x0e, - 0x250: 0x0e, 0x251: 0x0e, 0x252: 0x3b, 0x253: 0x3c, - 0x265: 0x3d, - 0x270: 0x0e, 0x271: 0x0e, 0x272: 0x0e, 0x273: 0x0e, 0x274: 0x0e, 0x275: 0x0e, 0x276: 0x0e, 0x277: 0x0e, - 0x278: 0x0e, 0x279: 0x0e, 0x27a: 0x0e, 0x27b: 0x0e, 0x27c: 0x0e, 0x27d: 0x0e, 0x27e: 0x0e, 0x27f: 0x0e, - // Block 0xa, offset 0x280 - 0x280: 0x0e, 0x281: 0x0e, 0x282: 0x0e, 0x283: 0x0e, 0x284: 0x0e, 0x285: 0x0e, 0x286: 0x0e, 0x287: 0x0e, - 0x288: 0x0e, 0x289: 0x0e, 0x28a: 0x0e, 0x28b: 0x0e, 0x28c: 0x0e, 0x28d: 0x0e, 0x28e: 0x0e, 0x28f: 0x0e, - 0x290: 0x0e, 0x291: 0x0e, 0x292: 0x0e, 0x293: 0x0e, 0x294: 0x0e, 0x295: 0x0e, 0x296: 0x0e, 0x297: 0x0e, - 0x298: 0x0e, 0x299: 0x0e, 0x29a: 0x0e, 0x29b: 0x0e, 0x29c: 0x0e, 0x29d: 0x0e, 0x29e: 0x3e, - // Block 0xb, offset 0x2c0 - 0x2c0: 0x08, 0x2c1: 0x08, 0x2c2: 0x08, 0x2c3: 0x08, 0x2c4: 0x08, 0x2c5: 0x08, 0x2c6: 0x08, 0x2c7: 0x08, - 0x2c8: 0x08, 0x2c9: 0x08, 0x2ca: 0x08, 0x2cb: 0x08, 0x2cc: 0x08, 0x2cd: 0x08, 0x2ce: 0x08, 0x2cf: 0x08, - 0x2d0: 0x08, 0x2d1: 0x08, 0x2d2: 0x08, 0x2d3: 0x08, 0x2d4: 0x08, 0x2d5: 0x08, 0x2d6: 0x08, 0x2d7: 0x08, - 0x2d8: 0x08, 0x2d9: 0x08, 0x2da: 0x08, 0x2db: 0x08, 0x2dc: 0x08, 0x2dd: 0x08, 0x2de: 0x08, 0x2df: 0x08, - 0x2e0: 0x08, 0x2e1: 0x08, 0x2e2: 0x08, 0x2e3: 0x08, 0x2e4: 0x08, 0x2e5: 0x08, 0x2e6: 0x08, 0x2e7: 0x08, - 0x2e8: 0x08, 0x2e9: 0x08, 0x2ea: 0x08, 0x2eb: 0x08, 0x2ec: 0x08, 0x2ed: 0x08, 0x2ee: 0x08, 0x2ef: 0x08, - 0x2f0: 0x08, 0x2f1: 0x08, 0x2f2: 0x08, 0x2f3: 0x08, 0x2f4: 0x08, 0x2f5: 0x08, 0x2f6: 0x08, 0x2f7: 0x08, - 0x2f8: 0x08, 0x2f9: 0x08, 0x2fa: 0x08, 0x2fb: 0x08, 0x2fc: 0x08, 0x2fd: 0x08, 0x2fe: 0x08, 0x2ff: 0x08, - // Block 0xc, offset 0x300 - 0x300: 0x08, 0x301: 0x08, 0x302: 0x08, 0x303: 0x08, 0x304: 0x08, 0x305: 0x08, 0x306: 0x08, 0x307: 0x08, - 0x308: 0x08, 0x309: 0x08, 0x30a: 0x08, 0x30b: 0x08, 0x30c: 0x08, 0x30d: 0x08, 0x30e: 0x08, 0x30f: 0x08, - 0x310: 0x08, 0x311: 0x08, 0x312: 0x08, 0x313: 0x08, 0x314: 0x08, 0x315: 0x08, 0x316: 0x08, 0x317: 0x08, - 0x318: 0x08, 0x319: 0x08, 0x31a: 0x08, 0x31b: 0x08, 0x31c: 0x08, 0x31d: 0x08, 0x31e: 0x08, 0x31f: 0x08, - 0x320: 0x08, 0x321: 0x08, 0x322: 0x08, 0x323: 0x08, 0x324: 0x0e, 0x325: 0x0e, 0x326: 0x0e, 0x327: 0x0e, - 0x328: 0x0e, 0x329: 0x0e, 0x32a: 0x0e, 0x32b: 0x0e, - 0x338: 0x3f, 0x339: 0x40, 0x33c: 0x41, 0x33d: 0x42, 0x33e: 0x43, 0x33f: 0x44, - // Block 0xd, offset 0x340 - 0x37f: 0x45, - // Block 0xe, offset 0x380 - 0x380: 0x0e, 0x381: 0x0e, 0x382: 0x0e, 0x383: 0x0e, 0x384: 0x0e, 0x385: 0x0e, 0x386: 0x0e, 0x387: 0x0e, - 0x388: 0x0e, 0x389: 0x0e, 0x38a: 0x0e, 0x38b: 0x0e, 0x38c: 0x0e, 0x38d: 0x0e, 0x38e: 0x0e, 0x38f: 0x0e, - 0x390: 0x0e, 0x391: 0x0e, 0x392: 0x0e, 0x393: 0x0e, 0x394: 0x0e, 0x395: 0x0e, 0x396: 0x0e, 0x397: 0x0e, - 0x398: 0x0e, 0x399: 0x0e, 0x39a: 0x0e, 0x39b: 0x0e, 0x39c: 0x0e, 0x39d: 0x0e, 0x39e: 0x0e, 0x39f: 0x46, - 0x3a0: 0x0e, 0x3a1: 0x0e, 0x3a2: 0x0e, 0x3a3: 0x0e, 0x3a4: 0x0e, 0x3a5: 0x0e, 0x3a6: 0x0e, 0x3a7: 0x0e, - 0x3a8: 0x0e, 0x3a9: 0x0e, 0x3aa: 0x0e, 0x3ab: 0x47, - // Block 0xf, offset 0x3c0 - 0x3c0: 0x0e, 0x3c1: 0x0e, 0x3c2: 0x0e, 0x3c3: 0x0e, 0x3c4: 0x48, 0x3c5: 0x49, 0x3c6: 0x0e, 0x3c7: 0x0e, - 0x3c8: 0x0e, 0x3c9: 0x0e, 0x3ca: 0x0e, 0x3cb: 0x4a, - // Block 0x10, offset 0x400 - 0x400: 0x4b, 0x403: 0x4c, 0x404: 0x4d, 0x405: 0x4e, 0x406: 0x4f, - 0x408: 0x50, 0x409: 0x51, 0x40c: 0x52, 0x40d: 0x53, 0x40e: 0x54, 0x40f: 0x55, - 0x410: 0x3a, 0x411: 0x56, 0x412: 0x0e, 0x413: 0x57, 0x414: 0x58, 0x415: 0x59, 0x416: 0x5a, 0x417: 0x5b, - 0x418: 0x0e, 0x419: 0x5c, 0x41a: 0x0e, 0x41b: 0x5d, - 0x424: 0x5e, 0x425: 0x5f, 0x426: 0x60, 0x427: 0x61, - // Block 0x11, offset 0x440 - 0x456: 0x0b, 0x457: 0x06, - 0x458: 0x0c, 0x45b: 0x0d, 0x45f: 0x0e, - 0x460: 0x06, 0x461: 0x06, 0x462: 0x06, 0x463: 0x06, 0x464: 0x06, 0x465: 0x06, 0x466: 0x06, 0x467: 0x06, - 0x468: 0x06, 0x469: 0x06, 0x46a: 0x06, 0x46b: 0x06, 0x46c: 0x06, 0x46d: 0x06, 0x46e: 0x06, 0x46f: 0x06, - 0x470: 0x06, 0x471: 0x06, 0x472: 0x06, 0x473: 0x06, 0x474: 0x06, 0x475: 0x06, 0x476: 0x06, 0x477: 0x06, - 0x478: 0x06, 0x479: 0x06, 0x47a: 0x06, 0x47b: 0x06, 0x47c: 0x06, 0x47d: 0x06, 0x47e: 0x06, 0x47f: 0x06, - // Block 0x12, offset 0x480 - 0x484: 0x08, 0x485: 0x08, 0x486: 0x08, 0x487: 0x09, - // Block 0x13, offset 0x4c0 - 0x4c0: 0x08, 0x4c1: 0x08, 0x4c2: 0x08, 0x4c3: 0x08, 0x4c4: 0x08, 0x4c5: 0x08, 0x4c6: 0x08, 0x4c7: 0x08, - 0x4c8: 0x08, 0x4c9: 0x08, 0x4ca: 0x08, 0x4cb: 0x08, 0x4cc: 0x08, 0x4cd: 0x08, 0x4ce: 0x08, 0x4cf: 0x08, - 0x4d0: 0x08, 0x4d1: 0x08, 0x4d2: 0x08, 0x4d3: 0x08, 0x4d4: 0x08, 0x4d5: 0x08, 0x4d6: 0x08, 0x4d7: 0x08, - 0x4d8: 0x08, 0x4d9: 0x08, 0x4da: 0x08, 0x4db: 0x08, 0x4dc: 0x08, 0x4dd: 0x08, 0x4de: 0x08, 0x4df: 0x08, - 0x4e0: 0x08, 0x4e1: 0x08, 0x4e2: 0x08, 0x4e3: 0x08, 0x4e4: 0x08, 0x4e5: 0x08, 0x4e6: 0x08, 0x4e7: 0x08, - 0x4e8: 0x08, 0x4e9: 0x08, 0x4ea: 0x08, 0x4eb: 0x08, 0x4ec: 0x08, 0x4ed: 0x08, 0x4ee: 0x08, 0x4ef: 0x08, - 0x4f0: 0x08, 0x4f1: 0x08, 0x4f2: 0x08, 0x4f3: 0x08, 0x4f4: 0x08, 0x4f5: 0x08, 0x4f6: 0x08, 0x4f7: 0x08, - 0x4f8: 0x08, 0x4f9: 0x08, 0x4fa: 0x08, 0x4fb: 0x08, 0x4fc: 0x08, 0x4fd: 0x08, 0x4fe: 0x08, 0x4ff: 0x62, - // Block 0x14, offset 0x500 - 0x520: 0x10, - 0x530: 0x09, 0x531: 0x09, 0x532: 0x09, 0x533: 0x09, 0x534: 0x09, 0x535: 0x09, 0x536: 0x09, 0x537: 0x09, - 0x538: 0x09, 0x539: 0x09, 0x53a: 0x09, 0x53b: 0x09, 0x53c: 0x09, 0x53d: 0x09, 0x53e: 0x09, 0x53f: 0x11, - // Block 0x15, offset 0x540 - 0x540: 0x09, 0x541: 0x09, 0x542: 0x09, 0x543: 0x09, 0x544: 0x09, 0x545: 0x09, 0x546: 0x09, 0x547: 0x09, - 0x548: 0x09, 0x549: 0x09, 0x54a: 0x09, 0x54b: 0x09, 0x54c: 0x09, 0x54d: 0x09, 0x54e: 0x09, 0x54f: 0x11, -} - -// inverseData contains 4-byte entries of the following format: -// -// <0 padding> -// -// The last byte of the UTF-8-encoded rune is xor-ed with the last byte of the -// UTF-8 encoding of the original rune. Mappings often have the following -// pattern: -// -// A -> A (U+FF21 -> U+0041) -// B -> B (U+FF22 -> U+0042) -// ... -// -// By xor-ing the last byte the same entry can be shared by many mappings. This -// reduces the total number of distinct entries by about two thirds. -// The resulting entry for the aforementioned mappings is -// -// { 0x01, 0xE0, 0x00, 0x00 } -// -// Using this entry to map U+FF21 (UTF-8 [EF BC A1]), we get -// -// E0 ^ A1 = 41. -// -// Similarly, for U+FF22 (UTF-8 [EF BC A2]), we get -// -// E0 ^ A2 = 42. -// -// Note that because of the xor-ing, the byte sequence stored in the entry is -// not valid UTF-8. -var inverseData = [150][4]byte{ - {0x00, 0x00, 0x00, 0x00}, - {0x03, 0xe3, 0x80, 0xa0}, - {0x03, 0xef, 0xbc, 0xa0}, - {0x03, 0xef, 0xbc, 0xe0}, - {0x03, 0xef, 0xbd, 0xe0}, - {0x03, 0xef, 0xbf, 0x02}, - {0x03, 0xef, 0xbf, 0x00}, - {0x03, 0xef, 0xbf, 0x0e}, - {0x03, 0xef, 0xbf, 0x0c}, - {0x03, 0xef, 0xbf, 0x0f}, - {0x03, 0xef, 0xbf, 0x39}, - {0x03, 0xef, 0xbf, 0x3b}, - {0x03, 0xef, 0xbf, 0x3f}, - {0x03, 0xef, 0xbf, 0x2a}, - {0x03, 0xef, 0xbf, 0x0d}, - {0x03, 0xef, 0xbf, 0x25}, - {0x03, 0xef, 0xbd, 0x1a}, - {0x03, 0xef, 0xbd, 0x26}, - {0x01, 0xa0, 0x00, 0x00}, - {0x03, 0xef, 0xbd, 0x25}, - {0x03, 0xef, 0xbd, 0x23}, - {0x03, 0xef, 0xbd, 0x2e}, - {0x03, 0xef, 0xbe, 0x07}, - {0x03, 0xef, 0xbe, 0x05}, - {0x03, 0xef, 0xbd, 0x06}, - {0x03, 0xef, 0xbd, 0x13}, - {0x03, 0xef, 0xbd, 0x0b}, - {0x03, 0xef, 0xbd, 0x16}, - {0x03, 0xef, 0xbd, 0x0c}, - {0x03, 0xef, 0xbd, 0x15}, - {0x03, 0xef, 0xbd, 0x0d}, - {0x03, 0xef, 0xbd, 0x1c}, - {0x03, 0xef, 0xbd, 0x02}, - {0x03, 0xef, 0xbd, 0x1f}, - {0x03, 0xef, 0xbd, 0x1d}, - {0x03, 0xef, 0xbd, 0x17}, - {0x03, 0xef, 0xbd, 0x08}, - {0x03, 0xef, 0xbd, 0x09}, - {0x03, 0xef, 0xbd, 0x0e}, - {0x03, 0xef, 0xbd, 0x04}, - {0x03, 0xef, 0xbd, 0x05}, - {0x03, 0xef, 0xbe, 0x3f}, - {0x03, 0xef, 0xbe, 0x00}, - {0x03, 0xef, 0xbd, 0x2c}, - {0x03, 0xef, 0xbe, 0x06}, - {0x03, 0xef, 0xbe, 0x0c}, - {0x03, 0xef, 0xbe, 0x0f}, - {0x03, 0xef, 0xbe, 0x0d}, - {0x03, 0xef, 0xbe, 0x0b}, - {0x03, 0xef, 0xbe, 0x19}, - {0x03, 0xef, 0xbe, 0x15}, - {0x03, 0xef, 0xbe, 0x11}, - {0x03, 0xef, 0xbe, 0x31}, - {0x03, 0xef, 0xbe, 0x33}, - {0x03, 0xef, 0xbd, 0x0f}, - {0x03, 0xef, 0xbe, 0x30}, - {0x03, 0xef, 0xbe, 0x3e}, - {0x03, 0xef, 0xbe, 0x32}, - {0x03, 0xef, 0xbe, 0x36}, - {0x03, 0xef, 0xbd, 0x14}, - {0x03, 0xef, 0xbe, 0x2e}, - {0x03, 0xef, 0xbd, 0x1e}, - {0x03, 0xef, 0xbe, 0x10}, - {0x03, 0xef, 0xbf, 0x13}, - {0x03, 0xef, 0xbf, 0x15}, - {0x03, 0xef, 0xbf, 0x17}, - {0x03, 0xef, 0xbf, 0x1f}, - {0x03, 0xef, 0xbf, 0x1d}, - {0x03, 0xef, 0xbf, 0x1b}, - {0x03, 0xef, 0xbf, 0x09}, - {0x03, 0xef, 0xbf, 0x0b}, - {0x03, 0xef, 0xbf, 0x37}, - {0x03, 0xef, 0xbe, 0x04}, - {0x01, 0xe0, 0x00, 0x00}, - {0x03, 0xe2, 0xa6, 0x1a}, - {0x03, 0xe2, 0xa6, 0x26}, - {0x03, 0xe3, 0x80, 0x23}, - {0x03, 0xe3, 0x80, 0x2e}, - {0x03, 0xe3, 0x80, 0x25}, - {0x03, 0xe3, 0x83, 0x1e}, - {0x03, 0xe3, 0x83, 0x14}, - {0x03, 0xe3, 0x82, 0x06}, - {0x03, 0xe3, 0x82, 0x0b}, - {0x03, 0xe3, 0x82, 0x0c}, - {0x03, 0xe3, 0x82, 0x0d}, - {0x03, 0xe3, 0x82, 0x02}, - {0x03, 0xe3, 0x83, 0x0f}, - {0x03, 0xe3, 0x83, 0x08}, - {0x03, 0xe3, 0x83, 0x09}, - {0x03, 0xe3, 0x83, 0x2c}, - {0x03, 0xe3, 0x83, 0x0c}, - {0x03, 0xe3, 0x82, 0x13}, - {0x03, 0xe3, 0x82, 0x16}, - {0x03, 0xe3, 0x82, 0x15}, - {0x03, 0xe3, 0x82, 0x1c}, - {0x03, 0xe3, 0x82, 0x1f}, - {0x03, 0xe3, 0x82, 0x1d}, - {0x03, 0xe3, 0x82, 0x1a}, - {0x03, 0xe3, 0x82, 0x17}, - {0x03, 0xe3, 0x82, 0x08}, - {0x03, 0xe3, 0x82, 0x09}, - {0x03, 0xe3, 0x82, 0x0e}, - {0x03, 0xe3, 0x82, 0x04}, - {0x03, 0xe3, 0x82, 0x05}, - {0x03, 0xe3, 0x82, 0x3f}, - {0x03, 0xe3, 0x83, 0x00}, - {0x03, 0xe3, 0x83, 0x06}, - {0x03, 0xe3, 0x83, 0x05}, - {0x03, 0xe3, 0x83, 0x0d}, - {0x03, 0xe3, 0x83, 0x0b}, - {0x03, 0xe3, 0x83, 0x07}, - {0x03, 0xe3, 0x83, 0x19}, - {0x03, 0xe3, 0x83, 0x15}, - {0x03, 0xe3, 0x83, 0x11}, - {0x03, 0xe3, 0x83, 0x31}, - {0x03, 0xe3, 0x83, 0x33}, - {0x03, 0xe3, 0x83, 0x30}, - {0x03, 0xe3, 0x83, 0x3e}, - {0x03, 0xe3, 0x83, 0x32}, - {0x03, 0xe3, 0x83, 0x36}, - {0x03, 0xe3, 0x83, 0x2e}, - {0x03, 0xe3, 0x82, 0x07}, - {0x03, 0xe3, 0x85, 0x04}, - {0x03, 0xe3, 0x84, 0x10}, - {0x03, 0xe3, 0x85, 0x30}, - {0x03, 0xe3, 0x85, 0x0d}, - {0x03, 0xe3, 0x85, 0x13}, - {0x03, 0xe3, 0x85, 0x15}, - {0x03, 0xe3, 0x85, 0x17}, - {0x03, 0xe3, 0x85, 0x1f}, - {0x03, 0xe3, 0x85, 0x1d}, - {0x03, 0xe3, 0x85, 0x1b}, - {0x03, 0xe3, 0x85, 0x09}, - {0x03, 0xe3, 0x85, 0x0f}, - {0x03, 0xe3, 0x85, 0x0b}, - {0x03, 0xe3, 0x85, 0x37}, - {0x03, 0xe3, 0x85, 0x3b}, - {0x03, 0xe3, 0x85, 0x39}, - {0x03, 0xe3, 0x85, 0x3f}, - {0x02, 0xc2, 0x02, 0x00}, - {0x02, 0xc2, 0x0e, 0x00}, - {0x02, 0xc2, 0x0c, 0x00}, - {0x02, 0xc2, 0x00, 0x00}, - {0x03, 0xe2, 0x82, 0x0f}, - {0x03, 0xe2, 0x94, 0x2a}, - {0x03, 0xe2, 0x86, 0x39}, - {0x03, 0xe2, 0x86, 0x3b}, - {0x03, 0xe2, 0x86, 0x3f}, - {0x03, 0xe2, 0x96, 0x0d}, - {0x03, 0xe2, 0x97, 0x25}, -} - -// Total table size 14936 bytes (14KiB) diff --git a/vendor/golang.org/x/text/width/tables11.0.0.go b/vendor/golang.org/x/text/width/tables11.0.0.go deleted file mode 100644 index 89288b3da..000000000 --- a/vendor/golang.org/x/text/width/tables11.0.0.go +++ /dev/null @@ -1,1340 +0,0 @@ -// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. - -//go:build go1.13 && !go1.14 - -package width - -// UnicodeVersion is the Unicode version from which the tables in this package are derived. -const UnicodeVersion = "11.0.0" - -// lookup returns the trie value for the first UTF-8 encoding in s and -// the width in bytes of this encoding. The size will be 0 if s does not -// hold enough bytes to complete the encoding. len(s) must be greater than 0. -func (t *widthTrie) lookup(s []byte) (v uint16, sz int) { - c0 := s[0] - switch { - case c0 < 0x80: // is ASCII - return widthValues[c0], 1 - case c0 < 0xC2: - return 0, 1 // Illegal UTF-8: not a starter, not ASCII. - case c0 < 0xE0: // 2-byte UTF-8 - if len(s) < 2 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c1), 2 - case c0 < 0xF0: // 3-byte UTF-8 - if len(s) < 3 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c2), 3 - case c0 < 0xF8: // 4-byte UTF-8 - if len(s) < 4 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - o = uint32(i)<<6 + uint32(c2) - i = widthIndex[o] - c3 := s[3] - if c3 < 0x80 || 0xC0 <= c3 { - return 0, 3 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c3), 4 - } - // Illegal rune - return 0, 1 -} - -// lookupUnsafe returns the trie value for the first UTF-8 encoding in s. -// s must start with a full and valid UTF-8 encoded rune. -func (t *widthTrie) lookupUnsafe(s []byte) uint16 { - c0 := s[0] - if c0 < 0x80 { // is ASCII - return widthValues[c0] - } - i := widthIndex[c0] - if c0 < 0xE0 { // 2-byte UTF-8 - return t.lookupValue(uint32(i), s[1]) - } - i = widthIndex[uint32(i)<<6+uint32(s[1])] - if c0 < 0xF0 { // 3-byte UTF-8 - return t.lookupValue(uint32(i), s[2]) - } - i = widthIndex[uint32(i)<<6+uint32(s[2])] - if c0 < 0xF8 { // 4-byte UTF-8 - return t.lookupValue(uint32(i), s[3]) - } - return 0 -} - -// lookupString returns the trie value for the first UTF-8 encoding in s and -// the width in bytes of this encoding. The size will be 0 if s does not -// hold enough bytes to complete the encoding. len(s) must be greater than 0. -func (t *widthTrie) lookupString(s string) (v uint16, sz int) { - c0 := s[0] - switch { - case c0 < 0x80: // is ASCII - return widthValues[c0], 1 - case c0 < 0xC2: - return 0, 1 // Illegal UTF-8: not a starter, not ASCII. - case c0 < 0xE0: // 2-byte UTF-8 - if len(s) < 2 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c1), 2 - case c0 < 0xF0: // 3-byte UTF-8 - if len(s) < 3 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c2), 3 - case c0 < 0xF8: // 4-byte UTF-8 - if len(s) < 4 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - o = uint32(i)<<6 + uint32(c2) - i = widthIndex[o] - c3 := s[3] - if c3 < 0x80 || 0xC0 <= c3 { - return 0, 3 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c3), 4 - } - // Illegal rune - return 0, 1 -} - -// lookupStringUnsafe returns the trie value for the first UTF-8 encoding in s. -// s must start with a full and valid UTF-8 encoded rune. -func (t *widthTrie) lookupStringUnsafe(s string) uint16 { - c0 := s[0] - if c0 < 0x80 { // is ASCII - return widthValues[c0] - } - i := widthIndex[c0] - if c0 < 0xE0 { // 2-byte UTF-8 - return t.lookupValue(uint32(i), s[1]) - } - i = widthIndex[uint32(i)<<6+uint32(s[1])] - if c0 < 0xF0 { // 3-byte UTF-8 - return t.lookupValue(uint32(i), s[2]) - } - i = widthIndex[uint32(i)<<6+uint32(s[2])] - if c0 < 0xF8 { // 4-byte UTF-8 - return t.lookupValue(uint32(i), s[3]) - } - return 0 -} - -// widthTrie. Total size: 14336 bytes (14.00 KiB). Checksum: c0f7712776e71cd4. -type widthTrie struct{} - -func newWidthTrie(i int) *widthTrie { - return &widthTrie{} -} - -// lookupValue determines the type of block n and looks up the value for b. -func (t *widthTrie) lookupValue(n uint32, b byte) uint16 { - switch { - default: - return uint16(widthValues[n<<6+uint32(b)]) - } -} - -// widthValues: 101 blocks, 6464 entries, 12928 bytes -// The third block is the zero block. -var widthValues = [6464]uint16{ - // Block 0x0, offset 0x0 - 0x20: 0x6001, 0x21: 0x6002, 0x22: 0x6002, 0x23: 0x6002, - 0x24: 0x6002, 0x25: 0x6002, 0x26: 0x6002, 0x27: 0x6002, 0x28: 0x6002, 0x29: 0x6002, - 0x2a: 0x6002, 0x2b: 0x6002, 0x2c: 0x6002, 0x2d: 0x6002, 0x2e: 0x6002, 0x2f: 0x6002, - 0x30: 0x6002, 0x31: 0x6002, 0x32: 0x6002, 0x33: 0x6002, 0x34: 0x6002, 0x35: 0x6002, - 0x36: 0x6002, 0x37: 0x6002, 0x38: 0x6002, 0x39: 0x6002, 0x3a: 0x6002, 0x3b: 0x6002, - 0x3c: 0x6002, 0x3d: 0x6002, 0x3e: 0x6002, 0x3f: 0x6002, - // Block 0x1, offset 0x40 - 0x40: 0x6003, 0x41: 0x6003, 0x42: 0x6003, 0x43: 0x6003, 0x44: 0x6003, 0x45: 0x6003, - 0x46: 0x6003, 0x47: 0x6003, 0x48: 0x6003, 0x49: 0x6003, 0x4a: 0x6003, 0x4b: 0x6003, - 0x4c: 0x6003, 0x4d: 0x6003, 0x4e: 0x6003, 0x4f: 0x6003, 0x50: 0x6003, 0x51: 0x6003, - 0x52: 0x6003, 0x53: 0x6003, 0x54: 0x6003, 0x55: 0x6003, 0x56: 0x6003, 0x57: 0x6003, - 0x58: 0x6003, 0x59: 0x6003, 0x5a: 0x6003, 0x5b: 0x6003, 0x5c: 0x6003, 0x5d: 0x6003, - 0x5e: 0x6003, 0x5f: 0x6003, 0x60: 0x6004, 0x61: 0x6004, 0x62: 0x6004, 0x63: 0x6004, - 0x64: 0x6004, 0x65: 0x6004, 0x66: 0x6004, 0x67: 0x6004, 0x68: 0x6004, 0x69: 0x6004, - 0x6a: 0x6004, 0x6b: 0x6004, 0x6c: 0x6004, 0x6d: 0x6004, 0x6e: 0x6004, 0x6f: 0x6004, - 0x70: 0x6004, 0x71: 0x6004, 0x72: 0x6004, 0x73: 0x6004, 0x74: 0x6004, 0x75: 0x6004, - 0x76: 0x6004, 0x77: 0x6004, 0x78: 0x6004, 0x79: 0x6004, 0x7a: 0x6004, 0x7b: 0x6004, - 0x7c: 0x6004, 0x7d: 0x6004, 0x7e: 0x6004, - // Block 0x2, offset 0x80 - // Block 0x3, offset 0xc0 - 0xe1: 0x2000, 0xe2: 0x6005, 0xe3: 0x6005, - 0xe4: 0x2000, 0xe5: 0x6006, 0xe6: 0x6005, 0xe7: 0x2000, 0xe8: 0x2000, - 0xea: 0x2000, 0xec: 0x6007, 0xed: 0x2000, 0xee: 0x2000, 0xef: 0x6008, - 0xf0: 0x2000, 0xf1: 0x2000, 0xf2: 0x2000, 0xf3: 0x2000, 0xf4: 0x2000, - 0xf6: 0x2000, 0xf7: 0x2000, 0xf8: 0x2000, 0xf9: 0x2000, 0xfa: 0x2000, - 0xfc: 0x2000, 0xfd: 0x2000, 0xfe: 0x2000, 0xff: 0x2000, - // Block 0x4, offset 0x100 - 0x106: 0x2000, - 0x110: 0x2000, - 0x117: 0x2000, - 0x118: 0x2000, - 0x11e: 0x2000, 0x11f: 0x2000, 0x120: 0x2000, 0x121: 0x2000, - 0x126: 0x2000, 0x128: 0x2000, 0x129: 0x2000, - 0x12a: 0x2000, 0x12c: 0x2000, 0x12d: 0x2000, - 0x130: 0x2000, 0x132: 0x2000, 0x133: 0x2000, - 0x137: 0x2000, 0x138: 0x2000, 0x139: 0x2000, 0x13a: 0x2000, - 0x13c: 0x2000, 0x13e: 0x2000, - // Block 0x5, offset 0x140 - 0x141: 0x2000, - 0x151: 0x2000, - 0x153: 0x2000, - 0x15b: 0x2000, - 0x166: 0x2000, 0x167: 0x2000, - 0x16b: 0x2000, - 0x171: 0x2000, 0x172: 0x2000, 0x173: 0x2000, - 0x178: 0x2000, - 0x17f: 0x2000, - // Block 0x6, offset 0x180 - 0x180: 0x2000, 0x181: 0x2000, 0x182: 0x2000, 0x184: 0x2000, - 0x188: 0x2000, 0x189: 0x2000, 0x18a: 0x2000, 0x18b: 0x2000, - 0x18d: 0x2000, - 0x192: 0x2000, 0x193: 0x2000, - 0x1a6: 0x2000, 0x1a7: 0x2000, - 0x1ab: 0x2000, - // Block 0x7, offset 0x1c0 - 0x1ce: 0x2000, 0x1d0: 0x2000, - 0x1d2: 0x2000, 0x1d4: 0x2000, 0x1d6: 0x2000, - 0x1d8: 0x2000, 0x1da: 0x2000, 0x1dc: 0x2000, - // Block 0x8, offset 0x200 - 0x211: 0x2000, - 0x221: 0x2000, - // Block 0x9, offset 0x240 - 0x244: 0x2000, - 0x247: 0x2000, 0x249: 0x2000, 0x24a: 0x2000, 0x24b: 0x2000, - 0x24d: 0x2000, 0x250: 0x2000, - 0x258: 0x2000, 0x259: 0x2000, 0x25a: 0x2000, 0x25b: 0x2000, 0x25d: 0x2000, - 0x25f: 0x2000, - // Block 0xa, offset 0x280 - 0x280: 0x2000, 0x281: 0x2000, 0x282: 0x2000, 0x283: 0x2000, 0x284: 0x2000, 0x285: 0x2000, - 0x286: 0x2000, 0x287: 0x2000, 0x288: 0x2000, 0x289: 0x2000, 0x28a: 0x2000, 0x28b: 0x2000, - 0x28c: 0x2000, 0x28d: 0x2000, 0x28e: 0x2000, 0x28f: 0x2000, 0x290: 0x2000, 0x291: 0x2000, - 0x292: 0x2000, 0x293: 0x2000, 0x294: 0x2000, 0x295: 0x2000, 0x296: 0x2000, 0x297: 0x2000, - 0x298: 0x2000, 0x299: 0x2000, 0x29a: 0x2000, 0x29b: 0x2000, 0x29c: 0x2000, 0x29d: 0x2000, - 0x29e: 0x2000, 0x29f: 0x2000, 0x2a0: 0x2000, 0x2a1: 0x2000, 0x2a2: 0x2000, 0x2a3: 0x2000, - 0x2a4: 0x2000, 0x2a5: 0x2000, 0x2a6: 0x2000, 0x2a7: 0x2000, 0x2a8: 0x2000, 0x2a9: 0x2000, - 0x2aa: 0x2000, 0x2ab: 0x2000, 0x2ac: 0x2000, 0x2ad: 0x2000, 0x2ae: 0x2000, 0x2af: 0x2000, - 0x2b0: 0x2000, 0x2b1: 0x2000, 0x2b2: 0x2000, 0x2b3: 0x2000, 0x2b4: 0x2000, 0x2b5: 0x2000, - 0x2b6: 0x2000, 0x2b7: 0x2000, 0x2b8: 0x2000, 0x2b9: 0x2000, 0x2ba: 0x2000, 0x2bb: 0x2000, - 0x2bc: 0x2000, 0x2bd: 0x2000, 0x2be: 0x2000, 0x2bf: 0x2000, - // Block 0xb, offset 0x2c0 - 0x2c0: 0x2000, 0x2c1: 0x2000, 0x2c2: 0x2000, 0x2c3: 0x2000, 0x2c4: 0x2000, 0x2c5: 0x2000, - 0x2c6: 0x2000, 0x2c7: 0x2000, 0x2c8: 0x2000, 0x2c9: 0x2000, 0x2ca: 0x2000, 0x2cb: 0x2000, - 0x2cc: 0x2000, 0x2cd: 0x2000, 0x2ce: 0x2000, 0x2cf: 0x2000, 0x2d0: 0x2000, 0x2d1: 0x2000, - 0x2d2: 0x2000, 0x2d3: 0x2000, 0x2d4: 0x2000, 0x2d5: 0x2000, 0x2d6: 0x2000, 0x2d7: 0x2000, - 0x2d8: 0x2000, 0x2d9: 0x2000, 0x2da: 0x2000, 0x2db: 0x2000, 0x2dc: 0x2000, 0x2dd: 0x2000, - 0x2de: 0x2000, 0x2df: 0x2000, 0x2e0: 0x2000, 0x2e1: 0x2000, 0x2e2: 0x2000, 0x2e3: 0x2000, - 0x2e4: 0x2000, 0x2e5: 0x2000, 0x2e6: 0x2000, 0x2e7: 0x2000, 0x2e8: 0x2000, 0x2e9: 0x2000, - 0x2ea: 0x2000, 0x2eb: 0x2000, 0x2ec: 0x2000, 0x2ed: 0x2000, 0x2ee: 0x2000, 0x2ef: 0x2000, - // Block 0xc, offset 0x300 - 0x311: 0x2000, - 0x312: 0x2000, 0x313: 0x2000, 0x314: 0x2000, 0x315: 0x2000, 0x316: 0x2000, 0x317: 0x2000, - 0x318: 0x2000, 0x319: 0x2000, 0x31a: 0x2000, 0x31b: 0x2000, 0x31c: 0x2000, 0x31d: 0x2000, - 0x31e: 0x2000, 0x31f: 0x2000, 0x320: 0x2000, 0x321: 0x2000, 0x323: 0x2000, - 0x324: 0x2000, 0x325: 0x2000, 0x326: 0x2000, 0x327: 0x2000, 0x328: 0x2000, 0x329: 0x2000, - 0x331: 0x2000, 0x332: 0x2000, 0x333: 0x2000, 0x334: 0x2000, 0x335: 0x2000, - 0x336: 0x2000, 0x337: 0x2000, 0x338: 0x2000, 0x339: 0x2000, 0x33a: 0x2000, 0x33b: 0x2000, - 0x33c: 0x2000, 0x33d: 0x2000, 0x33e: 0x2000, 0x33f: 0x2000, - // Block 0xd, offset 0x340 - 0x340: 0x2000, 0x341: 0x2000, 0x343: 0x2000, 0x344: 0x2000, 0x345: 0x2000, - 0x346: 0x2000, 0x347: 0x2000, 0x348: 0x2000, 0x349: 0x2000, - // Block 0xe, offset 0x380 - 0x381: 0x2000, - 0x390: 0x2000, 0x391: 0x2000, - 0x392: 0x2000, 0x393: 0x2000, 0x394: 0x2000, 0x395: 0x2000, 0x396: 0x2000, 0x397: 0x2000, - 0x398: 0x2000, 0x399: 0x2000, 0x39a: 0x2000, 0x39b: 0x2000, 0x39c: 0x2000, 0x39d: 0x2000, - 0x39e: 0x2000, 0x39f: 0x2000, 0x3a0: 0x2000, 0x3a1: 0x2000, 0x3a2: 0x2000, 0x3a3: 0x2000, - 0x3a4: 0x2000, 0x3a5: 0x2000, 0x3a6: 0x2000, 0x3a7: 0x2000, 0x3a8: 0x2000, 0x3a9: 0x2000, - 0x3aa: 0x2000, 0x3ab: 0x2000, 0x3ac: 0x2000, 0x3ad: 0x2000, 0x3ae: 0x2000, 0x3af: 0x2000, - 0x3b0: 0x2000, 0x3b1: 0x2000, 0x3b2: 0x2000, 0x3b3: 0x2000, 0x3b4: 0x2000, 0x3b5: 0x2000, - 0x3b6: 0x2000, 0x3b7: 0x2000, 0x3b8: 0x2000, 0x3b9: 0x2000, 0x3ba: 0x2000, 0x3bb: 0x2000, - 0x3bc: 0x2000, 0x3bd: 0x2000, 0x3be: 0x2000, 0x3bf: 0x2000, - // Block 0xf, offset 0x3c0 - 0x3c0: 0x2000, 0x3c1: 0x2000, 0x3c2: 0x2000, 0x3c3: 0x2000, 0x3c4: 0x2000, 0x3c5: 0x2000, - 0x3c6: 0x2000, 0x3c7: 0x2000, 0x3c8: 0x2000, 0x3c9: 0x2000, 0x3ca: 0x2000, 0x3cb: 0x2000, - 0x3cc: 0x2000, 0x3cd: 0x2000, 0x3ce: 0x2000, 0x3cf: 0x2000, 0x3d1: 0x2000, - // Block 0x10, offset 0x400 - 0x400: 0x4000, 0x401: 0x4000, 0x402: 0x4000, 0x403: 0x4000, 0x404: 0x4000, 0x405: 0x4000, - 0x406: 0x4000, 0x407: 0x4000, 0x408: 0x4000, 0x409: 0x4000, 0x40a: 0x4000, 0x40b: 0x4000, - 0x40c: 0x4000, 0x40d: 0x4000, 0x40e: 0x4000, 0x40f: 0x4000, 0x410: 0x4000, 0x411: 0x4000, - 0x412: 0x4000, 0x413: 0x4000, 0x414: 0x4000, 0x415: 0x4000, 0x416: 0x4000, 0x417: 0x4000, - 0x418: 0x4000, 0x419: 0x4000, 0x41a: 0x4000, 0x41b: 0x4000, 0x41c: 0x4000, 0x41d: 0x4000, - 0x41e: 0x4000, 0x41f: 0x4000, 0x420: 0x4000, 0x421: 0x4000, 0x422: 0x4000, 0x423: 0x4000, - 0x424: 0x4000, 0x425: 0x4000, 0x426: 0x4000, 0x427: 0x4000, 0x428: 0x4000, 0x429: 0x4000, - 0x42a: 0x4000, 0x42b: 0x4000, 0x42c: 0x4000, 0x42d: 0x4000, 0x42e: 0x4000, 0x42f: 0x4000, - 0x430: 0x4000, 0x431: 0x4000, 0x432: 0x4000, 0x433: 0x4000, 0x434: 0x4000, 0x435: 0x4000, - 0x436: 0x4000, 0x437: 0x4000, 0x438: 0x4000, 0x439: 0x4000, 0x43a: 0x4000, 0x43b: 0x4000, - 0x43c: 0x4000, 0x43d: 0x4000, 0x43e: 0x4000, 0x43f: 0x4000, - // Block 0x11, offset 0x440 - 0x440: 0x4000, 0x441: 0x4000, 0x442: 0x4000, 0x443: 0x4000, 0x444: 0x4000, 0x445: 0x4000, - 0x446: 0x4000, 0x447: 0x4000, 0x448: 0x4000, 0x449: 0x4000, 0x44a: 0x4000, 0x44b: 0x4000, - 0x44c: 0x4000, 0x44d: 0x4000, 0x44e: 0x4000, 0x44f: 0x4000, 0x450: 0x4000, 0x451: 0x4000, - 0x452: 0x4000, 0x453: 0x4000, 0x454: 0x4000, 0x455: 0x4000, 0x456: 0x4000, 0x457: 0x4000, - 0x458: 0x4000, 0x459: 0x4000, 0x45a: 0x4000, 0x45b: 0x4000, 0x45c: 0x4000, 0x45d: 0x4000, - 0x45e: 0x4000, 0x45f: 0x4000, - // Block 0x12, offset 0x480 - 0x490: 0x2000, - 0x493: 0x2000, 0x494: 0x2000, 0x495: 0x2000, 0x496: 0x2000, - 0x498: 0x2000, 0x499: 0x2000, 0x49c: 0x2000, 0x49d: 0x2000, - 0x4a0: 0x2000, 0x4a1: 0x2000, 0x4a2: 0x2000, - 0x4a4: 0x2000, 0x4a5: 0x2000, 0x4a6: 0x2000, 0x4a7: 0x2000, - 0x4b0: 0x2000, 0x4b2: 0x2000, 0x4b3: 0x2000, 0x4b5: 0x2000, - 0x4bb: 0x2000, - 0x4be: 0x2000, - // Block 0x13, offset 0x4c0 - 0x4f4: 0x2000, - 0x4ff: 0x2000, - // Block 0x14, offset 0x500 - 0x501: 0x2000, 0x502: 0x2000, 0x503: 0x2000, 0x504: 0x2000, - 0x529: 0xa009, - 0x52c: 0x2000, - // Block 0x15, offset 0x540 - 0x543: 0x2000, 0x545: 0x2000, - 0x549: 0x2000, - 0x553: 0x2000, 0x556: 0x2000, - 0x561: 0x2000, 0x562: 0x2000, - 0x566: 0x2000, - 0x56b: 0x2000, - // Block 0x16, offset 0x580 - 0x593: 0x2000, 0x594: 0x2000, - 0x59b: 0x2000, 0x59c: 0x2000, 0x59d: 0x2000, - 0x59e: 0x2000, 0x5a0: 0x2000, 0x5a1: 0x2000, 0x5a2: 0x2000, 0x5a3: 0x2000, - 0x5a4: 0x2000, 0x5a5: 0x2000, 0x5a6: 0x2000, 0x5a7: 0x2000, 0x5a8: 0x2000, 0x5a9: 0x2000, - 0x5aa: 0x2000, 0x5ab: 0x2000, - 0x5b0: 0x2000, 0x5b1: 0x2000, 0x5b2: 0x2000, 0x5b3: 0x2000, 0x5b4: 0x2000, 0x5b5: 0x2000, - 0x5b6: 0x2000, 0x5b7: 0x2000, 0x5b8: 0x2000, 0x5b9: 0x2000, - // Block 0x17, offset 0x5c0 - 0x5c9: 0x2000, - 0x5d0: 0x200a, 0x5d1: 0x200b, - 0x5d2: 0x200a, 0x5d3: 0x200c, 0x5d4: 0x2000, 0x5d5: 0x2000, 0x5d6: 0x2000, 0x5d7: 0x2000, - 0x5d8: 0x2000, 0x5d9: 0x2000, - 0x5f8: 0x2000, 0x5f9: 0x2000, - // Block 0x18, offset 0x600 - 0x612: 0x2000, 0x614: 0x2000, - 0x627: 0x2000, - // Block 0x19, offset 0x640 - 0x640: 0x2000, 0x642: 0x2000, 0x643: 0x2000, - 0x647: 0x2000, 0x648: 0x2000, 0x64b: 0x2000, - 0x64f: 0x2000, 0x651: 0x2000, - 0x655: 0x2000, - 0x65a: 0x2000, 0x65d: 0x2000, - 0x65e: 0x2000, 0x65f: 0x2000, 0x660: 0x2000, 0x663: 0x2000, - 0x665: 0x2000, 0x667: 0x2000, 0x668: 0x2000, 0x669: 0x2000, - 0x66a: 0x2000, 0x66b: 0x2000, 0x66c: 0x2000, 0x66e: 0x2000, - 0x674: 0x2000, 0x675: 0x2000, - 0x676: 0x2000, 0x677: 0x2000, - 0x67c: 0x2000, 0x67d: 0x2000, - // Block 0x1a, offset 0x680 - 0x688: 0x2000, - 0x68c: 0x2000, - 0x692: 0x2000, - 0x6a0: 0x2000, 0x6a1: 0x2000, - 0x6a4: 0x2000, 0x6a5: 0x2000, 0x6a6: 0x2000, 0x6a7: 0x2000, - 0x6aa: 0x2000, 0x6ab: 0x2000, 0x6ae: 0x2000, 0x6af: 0x2000, - // Block 0x1b, offset 0x6c0 - 0x6c2: 0x2000, 0x6c3: 0x2000, - 0x6c6: 0x2000, 0x6c7: 0x2000, - 0x6d5: 0x2000, - 0x6d9: 0x2000, - 0x6e5: 0x2000, - 0x6ff: 0x2000, - // Block 0x1c, offset 0x700 - 0x712: 0x2000, - 0x71a: 0x4000, 0x71b: 0x4000, - 0x729: 0x4000, - 0x72a: 0x4000, - // Block 0x1d, offset 0x740 - 0x769: 0x4000, - 0x76a: 0x4000, 0x76b: 0x4000, 0x76c: 0x4000, - 0x770: 0x4000, 0x773: 0x4000, - // Block 0x1e, offset 0x780 - 0x7a0: 0x2000, 0x7a1: 0x2000, 0x7a2: 0x2000, 0x7a3: 0x2000, - 0x7a4: 0x2000, 0x7a5: 0x2000, 0x7a6: 0x2000, 0x7a7: 0x2000, 0x7a8: 0x2000, 0x7a9: 0x2000, - 0x7aa: 0x2000, 0x7ab: 0x2000, 0x7ac: 0x2000, 0x7ad: 0x2000, 0x7ae: 0x2000, 0x7af: 0x2000, - 0x7b0: 0x2000, 0x7b1: 0x2000, 0x7b2: 0x2000, 0x7b3: 0x2000, 0x7b4: 0x2000, 0x7b5: 0x2000, - 0x7b6: 0x2000, 0x7b7: 0x2000, 0x7b8: 0x2000, 0x7b9: 0x2000, 0x7ba: 0x2000, 0x7bb: 0x2000, - 0x7bc: 0x2000, 0x7bd: 0x2000, 0x7be: 0x2000, 0x7bf: 0x2000, - // Block 0x1f, offset 0x7c0 - 0x7c0: 0x2000, 0x7c1: 0x2000, 0x7c2: 0x2000, 0x7c3: 0x2000, 0x7c4: 0x2000, 0x7c5: 0x2000, - 0x7c6: 0x2000, 0x7c7: 0x2000, 0x7c8: 0x2000, 0x7c9: 0x2000, 0x7ca: 0x2000, 0x7cb: 0x2000, - 0x7cc: 0x2000, 0x7cd: 0x2000, 0x7ce: 0x2000, 0x7cf: 0x2000, 0x7d0: 0x2000, 0x7d1: 0x2000, - 0x7d2: 0x2000, 0x7d3: 0x2000, 0x7d4: 0x2000, 0x7d5: 0x2000, 0x7d6: 0x2000, 0x7d7: 0x2000, - 0x7d8: 0x2000, 0x7d9: 0x2000, 0x7da: 0x2000, 0x7db: 0x2000, 0x7dc: 0x2000, 0x7dd: 0x2000, - 0x7de: 0x2000, 0x7df: 0x2000, 0x7e0: 0x2000, 0x7e1: 0x2000, 0x7e2: 0x2000, 0x7e3: 0x2000, - 0x7e4: 0x2000, 0x7e5: 0x2000, 0x7e6: 0x2000, 0x7e7: 0x2000, 0x7e8: 0x2000, 0x7e9: 0x2000, - 0x7eb: 0x2000, 0x7ec: 0x2000, 0x7ed: 0x2000, 0x7ee: 0x2000, 0x7ef: 0x2000, - 0x7f0: 0x2000, 0x7f1: 0x2000, 0x7f2: 0x2000, 0x7f3: 0x2000, 0x7f4: 0x2000, 0x7f5: 0x2000, - 0x7f6: 0x2000, 0x7f7: 0x2000, 0x7f8: 0x2000, 0x7f9: 0x2000, 0x7fa: 0x2000, 0x7fb: 0x2000, - 0x7fc: 0x2000, 0x7fd: 0x2000, 0x7fe: 0x2000, 0x7ff: 0x2000, - // Block 0x20, offset 0x800 - 0x800: 0x2000, 0x801: 0x2000, 0x802: 0x200d, 0x803: 0x2000, 0x804: 0x2000, 0x805: 0x2000, - 0x806: 0x2000, 0x807: 0x2000, 0x808: 0x2000, 0x809: 0x2000, 0x80a: 0x2000, 0x80b: 0x2000, - 0x80c: 0x2000, 0x80d: 0x2000, 0x80e: 0x2000, 0x80f: 0x2000, 0x810: 0x2000, 0x811: 0x2000, - 0x812: 0x2000, 0x813: 0x2000, 0x814: 0x2000, 0x815: 0x2000, 0x816: 0x2000, 0x817: 0x2000, - 0x818: 0x2000, 0x819: 0x2000, 0x81a: 0x2000, 0x81b: 0x2000, 0x81c: 0x2000, 0x81d: 0x2000, - 0x81e: 0x2000, 0x81f: 0x2000, 0x820: 0x2000, 0x821: 0x2000, 0x822: 0x2000, 0x823: 0x2000, - 0x824: 0x2000, 0x825: 0x2000, 0x826: 0x2000, 0x827: 0x2000, 0x828: 0x2000, 0x829: 0x2000, - 0x82a: 0x2000, 0x82b: 0x2000, 0x82c: 0x2000, 0x82d: 0x2000, 0x82e: 0x2000, 0x82f: 0x2000, - 0x830: 0x2000, 0x831: 0x2000, 0x832: 0x2000, 0x833: 0x2000, 0x834: 0x2000, 0x835: 0x2000, - 0x836: 0x2000, 0x837: 0x2000, 0x838: 0x2000, 0x839: 0x2000, 0x83a: 0x2000, 0x83b: 0x2000, - 0x83c: 0x2000, 0x83d: 0x2000, 0x83e: 0x2000, 0x83f: 0x2000, - // Block 0x21, offset 0x840 - 0x840: 0x2000, 0x841: 0x2000, 0x842: 0x2000, 0x843: 0x2000, 0x844: 0x2000, 0x845: 0x2000, - 0x846: 0x2000, 0x847: 0x2000, 0x848: 0x2000, 0x849: 0x2000, 0x84a: 0x2000, 0x84b: 0x2000, - 0x850: 0x2000, 0x851: 0x2000, - 0x852: 0x2000, 0x853: 0x2000, 0x854: 0x2000, 0x855: 0x2000, 0x856: 0x2000, 0x857: 0x2000, - 0x858: 0x2000, 0x859: 0x2000, 0x85a: 0x2000, 0x85b: 0x2000, 0x85c: 0x2000, 0x85d: 0x2000, - 0x85e: 0x2000, 0x85f: 0x2000, 0x860: 0x2000, 0x861: 0x2000, 0x862: 0x2000, 0x863: 0x2000, - 0x864: 0x2000, 0x865: 0x2000, 0x866: 0x2000, 0x867: 0x2000, 0x868: 0x2000, 0x869: 0x2000, - 0x86a: 0x2000, 0x86b: 0x2000, 0x86c: 0x2000, 0x86d: 0x2000, 0x86e: 0x2000, 0x86f: 0x2000, - 0x870: 0x2000, 0x871: 0x2000, 0x872: 0x2000, 0x873: 0x2000, - // Block 0x22, offset 0x880 - 0x880: 0x2000, 0x881: 0x2000, 0x882: 0x2000, 0x883: 0x2000, 0x884: 0x2000, 0x885: 0x2000, - 0x886: 0x2000, 0x887: 0x2000, 0x888: 0x2000, 0x889: 0x2000, 0x88a: 0x2000, 0x88b: 0x2000, - 0x88c: 0x2000, 0x88d: 0x2000, 0x88e: 0x2000, 0x88f: 0x2000, - 0x892: 0x2000, 0x893: 0x2000, 0x894: 0x2000, 0x895: 0x2000, - 0x8a0: 0x200e, 0x8a1: 0x2000, 0x8a3: 0x2000, - 0x8a4: 0x2000, 0x8a5: 0x2000, 0x8a6: 0x2000, 0x8a7: 0x2000, 0x8a8: 0x2000, 0x8a9: 0x2000, - 0x8b2: 0x2000, 0x8b3: 0x2000, - 0x8b6: 0x2000, 0x8b7: 0x2000, - 0x8bc: 0x2000, 0x8bd: 0x2000, - // Block 0x23, offset 0x8c0 - 0x8c0: 0x2000, 0x8c1: 0x2000, - 0x8c6: 0x2000, 0x8c7: 0x2000, 0x8c8: 0x2000, 0x8cb: 0x200f, - 0x8ce: 0x2000, 0x8cf: 0x2000, 0x8d0: 0x2000, 0x8d1: 0x2000, - 0x8e2: 0x2000, 0x8e3: 0x2000, - 0x8e4: 0x2000, 0x8e5: 0x2000, - 0x8ef: 0x2000, - 0x8fd: 0x4000, 0x8fe: 0x4000, - // Block 0x24, offset 0x900 - 0x905: 0x2000, - 0x906: 0x2000, 0x909: 0x2000, - 0x90e: 0x2000, 0x90f: 0x2000, - 0x914: 0x4000, 0x915: 0x4000, - 0x91c: 0x2000, - 0x91e: 0x2000, - // Block 0x25, offset 0x940 - 0x940: 0x2000, 0x942: 0x2000, - 0x948: 0x4000, 0x949: 0x4000, 0x94a: 0x4000, 0x94b: 0x4000, - 0x94c: 0x4000, 0x94d: 0x4000, 0x94e: 0x4000, 0x94f: 0x4000, 0x950: 0x4000, 0x951: 0x4000, - 0x952: 0x4000, 0x953: 0x4000, - 0x960: 0x2000, 0x961: 0x2000, 0x963: 0x2000, - 0x964: 0x2000, 0x965: 0x2000, 0x967: 0x2000, 0x968: 0x2000, 0x969: 0x2000, - 0x96a: 0x2000, 0x96c: 0x2000, 0x96d: 0x2000, 0x96f: 0x2000, - 0x97f: 0x4000, - // Block 0x26, offset 0x980 - 0x993: 0x4000, - 0x99e: 0x2000, 0x99f: 0x2000, 0x9a1: 0x4000, - 0x9aa: 0x4000, 0x9ab: 0x4000, - 0x9bd: 0x4000, 0x9be: 0x4000, 0x9bf: 0x2000, - // Block 0x27, offset 0x9c0 - 0x9c4: 0x4000, 0x9c5: 0x4000, - 0x9c6: 0x2000, 0x9c7: 0x2000, 0x9c8: 0x2000, 0x9c9: 0x2000, 0x9ca: 0x2000, 0x9cb: 0x2000, - 0x9cc: 0x2000, 0x9cd: 0x2000, 0x9ce: 0x4000, 0x9cf: 0x2000, 0x9d0: 0x2000, 0x9d1: 0x2000, - 0x9d2: 0x2000, 0x9d3: 0x2000, 0x9d4: 0x4000, 0x9d5: 0x2000, 0x9d6: 0x2000, 0x9d7: 0x2000, - 0x9d8: 0x2000, 0x9d9: 0x2000, 0x9da: 0x2000, 0x9db: 0x2000, 0x9dc: 0x2000, 0x9dd: 0x2000, - 0x9de: 0x2000, 0x9df: 0x2000, 0x9e0: 0x2000, 0x9e1: 0x2000, 0x9e3: 0x2000, - 0x9e8: 0x2000, 0x9e9: 0x2000, - 0x9ea: 0x4000, 0x9eb: 0x2000, 0x9ec: 0x2000, 0x9ed: 0x2000, 0x9ee: 0x2000, 0x9ef: 0x2000, - 0x9f0: 0x2000, 0x9f1: 0x2000, 0x9f2: 0x4000, 0x9f3: 0x4000, 0x9f4: 0x2000, 0x9f5: 0x4000, - 0x9f6: 0x2000, 0x9f7: 0x2000, 0x9f8: 0x2000, 0x9f9: 0x2000, 0x9fa: 0x4000, 0x9fb: 0x2000, - 0x9fc: 0x2000, 0x9fd: 0x4000, 0x9fe: 0x2000, 0x9ff: 0x2000, - // Block 0x28, offset 0xa00 - 0xa05: 0x4000, - 0xa0a: 0x4000, 0xa0b: 0x4000, - 0xa28: 0x4000, - 0xa3d: 0x2000, - // Block 0x29, offset 0xa40 - 0xa4c: 0x4000, 0xa4e: 0x4000, - 0xa53: 0x4000, 0xa54: 0x4000, 0xa55: 0x4000, 0xa57: 0x4000, - 0xa76: 0x2000, 0xa77: 0x2000, 0xa78: 0x2000, 0xa79: 0x2000, 0xa7a: 0x2000, 0xa7b: 0x2000, - 0xa7c: 0x2000, 0xa7d: 0x2000, 0xa7e: 0x2000, 0xa7f: 0x2000, - // Block 0x2a, offset 0xa80 - 0xa95: 0x4000, 0xa96: 0x4000, 0xa97: 0x4000, - 0xab0: 0x4000, - 0xabf: 0x4000, - // Block 0x2b, offset 0xac0 - 0xae6: 0x6000, 0xae7: 0x6000, 0xae8: 0x6000, 0xae9: 0x6000, - 0xaea: 0x6000, 0xaeb: 0x6000, 0xaec: 0x6000, 0xaed: 0x6000, - // Block 0x2c, offset 0xb00 - 0xb05: 0x6010, - 0xb06: 0x6011, - // Block 0x2d, offset 0xb40 - 0xb5b: 0x4000, 0xb5c: 0x4000, - // Block 0x2e, offset 0xb80 - 0xb90: 0x4000, - 0xb95: 0x4000, 0xb96: 0x2000, 0xb97: 0x2000, - 0xb98: 0x2000, 0xb99: 0x2000, - // Block 0x2f, offset 0xbc0 - 0xbc0: 0x4000, 0xbc1: 0x4000, 0xbc2: 0x4000, 0xbc3: 0x4000, 0xbc4: 0x4000, 0xbc5: 0x4000, - 0xbc6: 0x4000, 0xbc7: 0x4000, 0xbc8: 0x4000, 0xbc9: 0x4000, 0xbca: 0x4000, 0xbcb: 0x4000, - 0xbcc: 0x4000, 0xbcd: 0x4000, 0xbce: 0x4000, 0xbcf: 0x4000, 0xbd0: 0x4000, 0xbd1: 0x4000, - 0xbd2: 0x4000, 0xbd3: 0x4000, 0xbd4: 0x4000, 0xbd5: 0x4000, 0xbd6: 0x4000, 0xbd7: 0x4000, - 0xbd8: 0x4000, 0xbd9: 0x4000, 0xbdb: 0x4000, 0xbdc: 0x4000, 0xbdd: 0x4000, - 0xbde: 0x4000, 0xbdf: 0x4000, 0xbe0: 0x4000, 0xbe1: 0x4000, 0xbe2: 0x4000, 0xbe3: 0x4000, - 0xbe4: 0x4000, 0xbe5: 0x4000, 0xbe6: 0x4000, 0xbe7: 0x4000, 0xbe8: 0x4000, 0xbe9: 0x4000, - 0xbea: 0x4000, 0xbeb: 0x4000, 0xbec: 0x4000, 0xbed: 0x4000, 0xbee: 0x4000, 0xbef: 0x4000, - 0xbf0: 0x4000, 0xbf1: 0x4000, 0xbf2: 0x4000, 0xbf3: 0x4000, 0xbf4: 0x4000, 0xbf5: 0x4000, - 0xbf6: 0x4000, 0xbf7: 0x4000, 0xbf8: 0x4000, 0xbf9: 0x4000, 0xbfa: 0x4000, 0xbfb: 0x4000, - 0xbfc: 0x4000, 0xbfd: 0x4000, 0xbfe: 0x4000, 0xbff: 0x4000, - // Block 0x30, offset 0xc00 - 0xc00: 0x4000, 0xc01: 0x4000, 0xc02: 0x4000, 0xc03: 0x4000, 0xc04: 0x4000, 0xc05: 0x4000, - 0xc06: 0x4000, 0xc07: 0x4000, 0xc08: 0x4000, 0xc09: 0x4000, 0xc0a: 0x4000, 0xc0b: 0x4000, - 0xc0c: 0x4000, 0xc0d: 0x4000, 0xc0e: 0x4000, 0xc0f: 0x4000, 0xc10: 0x4000, 0xc11: 0x4000, - 0xc12: 0x4000, 0xc13: 0x4000, 0xc14: 0x4000, 0xc15: 0x4000, 0xc16: 0x4000, 0xc17: 0x4000, - 0xc18: 0x4000, 0xc19: 0x4000, 0xc1a: 0x4000, 0xc1b: 0x4000, 0xc1c: 0x4000, 0xc1d: 0x4000, - 0xc1e: 0x4000, 0xc1f: 0x4000, 0xc20: 0x4000, 0xc21: 0x4000, 0xc22: 0x4000, 0xc23: 0x4000, - 0xc24: 0x4000, 0xc25: 0x4000, 0xc26: 0x4000, 0xc27: 0x4000, 0xc28: 0x4000, 0xc29: 0x4000, - 0xc2a: 0x4000, 0xc2b: 0x4000, 0xc2c: 0x4000, 0xc2d: 0x4000, 0xc2e: 0x4000, 0xc2f: 0x4000, - 0xc30: 0x4000, 0xc31: 0x4000, 0xc32: 0x4000, 0xc33: 0x4000, - // Block 0x31, offset 0xc40 - 0xc40: 0x4000, 0xc41: 0x4000, 0xc42: 0x4000, 0xc43: 0x4000, 0xc44: 0x4000, 0xc45: 0x4000, - 0xc46: 0x4000, 0xc47: 0x4000, 0xc48: 0x4000, 0xc49: 0x4000, 0xc4a: 0x4000, 0xc4b: 0x4000, - 0xc4c: 0x4000, 0xc4d: 0x4000, 0xc4e: 0x4000, 0xc4f: 0x4000, 0xc50: 0x4000, 0xc51: 0x4000, - 0xc52: 0x4000, 0xc53: 0x4000, 0xc54: 0x4000, 0xc55: 0x4000, - 0xc70: 0x4000, 0xc71: 0x4000, 0xc72: 0x4000, 0xc73: 0x4000, 0xc74: 0x4000, 0xc75: 0x4000, - 0xc76: 0x4000, 0xc77: 0x4000, 0xc78: 0x4000, 0xc79: 0x4000, 0xc7a: 0x4000, 0xc7b: 0x4000, - // Block 0x32, offset 0xc80 - 0xc80: 0x9012, 0xc81: 0x4013, 0xc82: 0x4014, 0xc83: 0x4000, 0xc84: 0x4000, 0xc85: 0x4000, - 0xc86: 0x4000, 0xc87: 0x4000, 0xc88: 0x4000, 0xc89: 0x4000, 0xc8a: 0x4000, 0xc8b: 0x4000, - 0xc8c: 0x4015, 0xc8d: 0x4015, 0xc8e: 0x4000, 0xc8f: 0x4000, 0xc90: 0x4000, 0xc91: 0x4000, - 0xc92: 0x4000, 0xc93: 0x4000, 0xc94: 0x4000, 0xc95: 0x4000, 0xc96: 0x4000, 0xc97: 0x4000, - 0xc98: 0x4000, 0xc99: 0x4000, 0xc9a: 0x4000, 0xc9b: 0x4000, 0xc9c: 0x4000, 0xc9d: 0x4000, - 0xc9e: 0x4000, 0xc9f: 0x4000, 0xca0: 0x4000, 0xca1: 0x4000, 0xca2: 0x4000, 0xca3: 0x4000, - 0xca4: 0x4000, 0xca5: 0x4000, 0xca6: 0x4000, 0xca7: 0x4000, 0xca8: 0x4000, 0xca9: 0x4000, - 0xcaa: 0x4000, 0xcab: 0x4000, 0xcac: 0x4000, 0xcad: 0x4000, 0xcae: 0x4000, 0xcaf: 0x4000, - 0xcb0: 0x4000, 0xcb1: 0x4000, 0xcb2: 0x4000, 0xcb3: 0x4000, 0xcb4: 0x4000, 0xcb5: 0x4000, - 0xcb6: 0x4000, 0xcb7: 0x4000, 0xcb8: 0x4000, 0xcb9: 0x4000, 0xcba: 0x4000, 0xcbb: 0x4000, - 0xcbc: 0x4000, 0xcbd: 0x4000, 0xcbe: 0x4000, - // Block 0x33, offset 0xcc0 - 0xcc1: 0x4000, 0xcc2: 0x4000, 0xcc3: 0x4000, 0xcc4: 0x4000, 0xcc5: 0x4000, - 0xcc6: 0x4000, 0xcc7: 0x4000, 0xcc8: 0x4000, 0xcc9: 0x4000, 0xcca: 0x4000, 0xccb: 0x4000, - 0xccc: 0x4000, 0xccd: 0x4000, 0xcce: 0x4000, 0xccf: 0x4000, 0xcd0: 0x4000, 0xcd1: 0x4000, - 0xcd2: 0x4000, 0xcd3: 0x4000, 0xcd4: 0x4000, 0xcd5: 0x4000, 0xcd6: 0x4000, 0xcd7: 0x4000, - 0xcd8: 0x4000, 0xcd9: 0x4000, 0xcda: 0x4000, 0xcdb: 0x4000, 0xcdc: 0x4000, 0xcdd: 0x4000, - 0xcde: 0x4000, 0xcdf: 0x4000, 0xce0: 0x4000, 0xce1: 0x4000, 0xce2: 0x4000, 0xce3: 0x4000, - 0xce4: 0x4000, 0xce5: 0x4000, 0xce6: 0x4000, 0xce7: 0x4000, 0xce8: 0x4000, 0xce9: 0x4000, - 0xcea: 0x4000, 0xceb: 0x4000, 0xcec: 0x4000, 0xced: 0x4000, 0xcee: 0x4000, 0xcef: 0x4000, - 0xcf0: 0x4000, 0xcf1: 0x4000, 0xcf2: 0x4000, 0xcf3: 0x4000, 0xcf4: 0x4000, 0xcf5: 0x4000, - 0xcf6: 0x4000, 0xcf7: 0x4000, 0xcf8: 0x4000, 0xcf9: 0x4000, 0xcfa: 0x4000, 0xcfb: 0x4000, - 0xcfc: 0x4000, 0xcfd: 0x4000, 0xcfe: 0x4000, 0xcff: 0x4000, - // Block 0x34, offset 0xd00 - 0xd00: 0x4000, 0xd01: 0x4000, 0xd02: 0x4000, 0xd03: 0x4000, 0xd04: 0x4000, 0xd05: 0x4000, - 0xd06: 0x4000, 0xd07: 0x4000, 0xd08: 0x4000, 0xd09: 0x4000, 0xd0a: 0x4000, 0xd0b: 0x4000, - 0xd0c: 0x4000, 0xd0d: 0x4000, 0xd0e: 0x4000, 0xd0f: 0x4000, 0xd10: 0x4000, 0xd11: 0x4000, - 0xd12: 0x4000, 0xd13: 0x4000, 0xd14: 0x4000, 0xd15: 0x4000, 0xd16: 0x4000, - 0xd19: 0x4016, 0xd1a: 0x4017, 0xd1b: 0x4000, 0xd1c: 0x4000, 0xd1d: 0x4000, - 0xd1e: 0x4000, 0xd1f: 0x4000, 0xd20: 0x4000, 0xd21: 0x4018, 0xd22: 0x4019, 0xd23: 0x401a, - 0xd24: 0x401b, 0xd25: 0x401c, 0xd26: 0x401d, 0xd27: 0x401e, 0xd28: 0x401f, 0xd29: 0x4020, - 0xd2a: 0x4021, 0xd2b: 0x4022, 0xd2c: 0x4000, 0xd2d: 0x4010, 0xd2e: 0x4000, 0xd2f: 0x4023, - 0xd30: 0x4000, 0xd31: 0x4024, 0xd32: 0x4000, 0xd33: 0x4025, 0xd34: 0x4000, 0xd35: 0x4026, - 0xd36: 0x4000, 0xd37: 0x401a, 0xd38: 0x4000, 0xd39: 0x4027, 0xd3a: 0x4000, 0xd3b: 0x4028, - 0xd3c: 0x4000, 0xd3d: 0x4020, 0xd3e: 0x4000, 0xd3f: 0x4029, - // Block 0x35, offset 0xd40 - 0xd40: 0x4000, 0xd41: 0x402a, 0xd42: 0x4000, 0xd43: 0x402b, 0xd44: 0x402c, 0xd45: 0x4000, - 0xd46: 0x4017, 0xd47: 0x4000, 0xd48: 0x402d, 0xd49: 0x4000, 0xd4a: 0x402e, 0xd4b: 0x402f, - 0xd4c: 0x4030, 0xd4d: 0x4017, 0xd4e: 0x4016, 0xd4f: 0x4017, 0xd50: 0x4000, 0xd51: 0x4000, - 0xd52: 0x4031, 0xd53: 0x4000, 0xd54: 0x4000, 0xd55: 0x4031, 0xd56: 0x4000, 0xd57: 0x4000, - 0xd58: 0x4032, 0xd59: 0x4000, 0xd5a: 0x4000, 0xd5b: 0x4032, 0xd5c: 0x4000, 0xd5d: 0x4000, - 0xd5e: 0x4033, 0xd5f: 0x402e, 0xd60: 0x4034, 0xd61: 0x4035, 0xd62: 0x4034, 0xd63: 0x4036, - 0xd64: 0x4037, 0xd65: 0x4024, 0xd66: 0x4035, 0xd67: 0x4025, 0xd68: 0x4038, 0xd69: 0x4038, - 0xd6a: 0x4039, 0xd6b: 0x4039, 0xd6c: 0x403a, 0xd6d: 0x403a, 0xd6e: 0x4000, 0xd6f: 0x4035, - 0xd70: 0x4000, 0xd71: 0x4000, 0xd72: 0x403b, 0xd73: 0x403c, 0xd74: 0x4000, 0xd75: 0x4000, - 0xd76: 0x4000, 0xd77: 0x4000, 0xd78: 0x4000, 0xd79: 0x4000, 0xd7a: 0x4000, 0xd7b: 0x403d, - 0xd7c: 0x401c, 0xd7d: 0x4000, 0xd7e: 0x4000, 0xd7f: 0x4000, - // Block 0x36, offset 0xd80 - 0xd85: 0x4000, - 0xd86: 0x4000, 0xd87: 0x4000, 0xd88: 0x4000, 0xd89: 0x4000, 0xd8a: 0x4000, 0xd8b: 0x4000, - 0xd8c: 0x4000, 0xd8d: 0x4000, 0xd8e: 0x4000, 0xd8f: 0x4000, 0xd90: 0x4000, 0xd91: 0x4000, - 0xd92: 0x4000, 0xd93: 0x4000, 0xd94: 0x4000, 0xd95: 0x4000, 0xd96: 0x4000, 0xd97: 0x4000, - 0xd98: 0x4000, 0xd99: 0x4000, 0xd9a: 0x4000, 0xd9b: 0x4000, 0xd9c: 0x4000, 0xd9d: 0x4000, - 0xd9e: 0x4000, 0xd9f: 0x4000, 0xda0: 0x4000, 0xda1: 0x4000, 0xda2: 0x4000, 0xda3: 0x4000, - 0xda4: 0x4000, 0xda5: 0x4000, 0xda6: 0x4000, 0xda7: 0x4000, 0xda8: 0x4000, 0xda9: 0x4000, - 0xdaa: 0x4000, 0xdab: 0x4000, 0xdac: 0x4000, 0xdad: 0x4000, 0xdae: 0x4000, 0xdaf: 0x4000, - 0xdb1: 0x403e, 0xdb2: 0x403e, 0xdb3: 0x403e, 0xdb4: 0x403e, 0xdb5: 0x403e, - 0xdb6: 0x403e, 0xdb7: 0x403e, 0xdb8: 0x403e, 0xdb9: 0x403e, 0xdba: 0x403e, 0xdbb: 0x403e, - 0xdbc: 0x403e, 0xdbd: 0x403e, 0xdbe: 0x403e, 0xdbf: 0x403e, - // Block 0x37, offset 0xdc0 - 0xdc0: 0x4037, 0xdc1: 0x4037, 0xdc2: 0x4037, 0xdc3: 0x4037, 0xdc4: 0x4037, 0xdc5: 0x4037, - 0xdc6: 0x4037, 0xdc7: 0x4037, 0xdc8: 0x4037, 0xdc9: 0x4037, 0xdca: 0x4037, 0xdcb: 0x4037, - 0xdcc: 0x4037, 0xdcd: 0x4037, 0xdce: 0x4037, 0xdcf: 0x400e, 0xdd0: 0x403f, 0xdd1: 0x4040, - 0xdd2: 0x4041, 0xdd3: 0x4040, 0xdd4: 0x403f, 0xdd5: 0x4042, 0xdd6: 0x4043, 0xdd7: 0x4044, - 0xdd8: 0x4040, 0xdd9: 0x4041, 0xdda: 0x4040, 0xddb: 0x4045, 0xddc: 0x4009, 0xddd: 0x4045, - 0xdde: 0x4046, 0xddf: 0x4045, 0xde0: 0x4047, 0xde1: 0x400b, 0xde2: 0x400a, 0xde3: 0x400c, - 0xde4: 0x4048, 0xde5: 0x4000, 0xde6: 0x4000, 0xde7: 0x4000, 0xde8: 0x4000, 0xde9: 0x4000, - 0xdea: 0x4000, 0xdeb: 0x4000, 0xdec: 0x4000, 0xded: 0x4000, 0xdee: 0x4000, 0xdef: 0x4000, - 0xdf0: 0x4000, 0xdf1: 0x4000, 0xdf2: 0x4000, 0xdf3: 0x4000, 0xdf4: 0x4000, 0xdf5: 0x4000, - 0xdf6: 0x4000, 0xdf7: 0x4000, 0xdf8: 0x4000, 0xdf9: 0x4000, 0xdfa: 0x4000, 0xdfb: 0x4000, - 0xdfc: 0x4000, 0xdfd: 0x4000, 0xdfe: 0x4000, 0xdff: 0x4000, - // Block 0x38, offset 0xe00 - 0xe00: 0x4000, 0xe01: 0x4000, 0xe02: 0x4000, 0xe03: 0x4000, 0xe04: 0x4000, 0xe05: 0x4000, - 0xe06: 0x4000, 0xe07: 0x4000, 0xe08: 0x4000, 0xe09: 0x4000, 0xe0a: 0x4000, 0xe0b: 0x4000, - 0xe0c: 0x4000, 0xe0d: 0x4000, 0xe0e: 0x4000, 0xe10: 0x4000, 0xe11: 0x4000, - 0xe12: 0x4000, 0xe13: 0x4000, 0xe14: 0x4000, 0xe15: 0x4000, 0xe16: 0x4000, 0xe17: 0x4000, - 0xe18: 0x4000, 0xe19: 0x4000, 0xe1a: 0x4000, 0xe1b: 0x4000, 0xe1c: 0x4000, 0xe1d: 0x4000, - 0xe1e: 0x4000, 0xe1f: 0x4000, 0xe20: 0x4000, 0xe21: 0x4000, 0xe22: 0x4000, 0xe23: 0x4000, - 0xe24: 0x4000, 0xe25: 0x4000, 0xe26: 0x4000, 0xe27: 0x4000, 0xe28: 0x4000, 0xe29: 0x4000, - 0xe2a: 0x4000, 0xe2b: 0x4000, 0xe2c: 0x4000, 0xe2d: 0x4000, 0xe2e: 0x4000, 0xe2f: 0x4000, - 0xe30: 0x4000, 0xe31: 0x4000, 0xe32: 0x4000, 0xe33: 0x4000, 0xe34: 0x4000, 0xe35: 0x4000, - 0xe36: 0x4000, 0xe37: 0x4000, 0xe38: 0x4000, 0xe39: 0x4000, 0xe3a: 0x4000, - // Block 0x39, offset 0xe40 - 0xe40: 0x4000, 0xe41: 0x4000, 0xe42: 0x4000, 0xe43: 0x4000, 0xe44: 0x4000, 0xe45: 0x4000, - 0xe46: 0x4000, 0xe47: 0x4000, 0xe48: 0x4000, 0xe49: 0x4000, 0xe4a: 0x4000, 0xe4b: 0x4000, - 0xe4c: 0x4000, 0xe4d: 0x4000, 0xe4e: 0x4000, 0xe4f: 0x4000, 0xe50: 0x4000, 0xe51: 0x4000, - 0xe52: 0x4000, 0xe53: 0x4000, 0xe54: 0x4000, 0xe55: 0x4000, 0xe56: 0x4000, 0xe57: 0x4000, - 0xe58: 0x4000, 0xe59: 0x4000, 0xe5a: 0x4000, 0xe5b: 0x4000, 0xe5c: 0x4000, 0xe5d: 0x4000, - 0xe5e: 0x4000, 0xe5f: 0x4000, 0xe60: 0x4000, 0xe61: 0x4000, 0xe62: 0x4000, 0xe63: 0x4000, - 0xe70: 0x4000, 0xe71: 0x4000, 0xe72: 0x4000, 0xe73: 0x4000, 0xe74: 0x4000, 0xe75: 0x4000, - 0xe76: 0x4000, 0xe77: 0x4000, 0xe78: 0x4000, 0xe79: 0x4000, 0xe7a: 0x4000, 0xe7b: 0x4000, - 0xe7c: 0x4000, 0xe7d: 0x4000, 0xe7e: 0x4000, 0xe7f: 0x4000, - // Block 0x3a, offset 0xe80 - 0xe80: 0x4000, 0xe81: 0x4000, 0xe82: 0x4000, 0xe83: 0x4000, 0xe84: 0x4000, 0xe85: 0x4000, - 0xe86: 0x4000, 0xe87: 0x4000, 0xe88: 0x4000, 0xe89: 0x4000, 0xe8a: 0x4000, 0xe8b: 0x4000, - 0xe8c: 0x4000, 0xe8d: 0x4000, 0xe8e: 0x4000, 0xe8f: 0x4000, 0xe90: 0x4000, 0xe91: 0x4000, - 0xe92: 0x4000, 0xe93: 0x4000, 0xe94: 0x4000, 0xe95: 0x4000, 0xe96: 0x4000, 0xe97: 0x4000, - 0xe98: 0x4000, 0xe99: 0x4000, 0xe9a: 0x4000, 0xe9b: 0x4000, 0xe9c: 0x4000, 0xe9d: 0x4000, - 0xe9e: 0x4000, 0xea0: 0x4000, 0xea1: 0x4000, 0xea2: 0x4000, 0xea3: 0x4000, - 0xea4: 0x4000, 0xea5: 0x4000, 0xea6: 0x4000, 0xea7: 0x4000, 0xea8: 0x4000, 0xea9: 0x4000, - 0xeaa: 0x4000, 0xeab: 0x4000, 0xeac: 0x4000, 0xead: 0x4000, 0xeae: 0x4000, 0xeaf: 0x4000, - 0xeb0: 0x4000, 0xeb1: 0x4000, 0xeb2: 0x4000, 0xeb3: 0x4000, 0xeb4: 0x4000, 0xeb5: 0x4000, - 0xeb6: 0x4000, 0xeb7: 0x4000, 0xeb8: 0x4000, 0xeb9: 0x4000, 0xeba: 0x4000, 0xebb: 0x4000, - 0xebc: 0x4000, 0xebd: 0x4000, 0xebe: 0x4000, 0xebf: 0x4000, - // Block 0x3b, offset 0xec0 - 0xec0: 0x4000, 0xec1: 0x4000, 0xec2: 0x4000, 0xec3: 0x4000, 0xec4: 0x4000, 0xec5: 0x4000, - 0xec6: 0x4000, 0xec7: 0x4000, 0xec8: 0x2000, 0xec9: 0x2000, 0xeca: 0x2000, 0xecb: 0x2000, - 0xecc: 0x2000, 0xecd: 0x2000, 0xece: 0x2000, 0xecf: 0x2000, 0xed0: 0x4000, 0xed1: 0x4000, - 0xed2: 0x4000, 0xed3: 0x4000, 0xed4: 0x4000, 0xed5: 0x4000, 0xed6: 0x4000, 0xed7: 0x4000, - 0xed8: 0x4000, 0xed9: 0x4000, 0xeda: 0x4000, 0xedb: 0x4000, 0xedc: 0x4000, 0xedd: 0x4000, - 0xede: 0x4000, 0xedf: 0x4000, 0xee0: 0x4000, 0xee1: 0x4000, 0xee2: 0x4000, 0xee3: 0x4000, - 0xee4: 0x4000, 0xee5: 0x4000, 0xee6: 0x4000, 0xee7: 0x4000, 0xee8: 0x4000, 0xee9: 0x4000, - 0xeea: 0x4000, 0xeeb: 0x4000, 0xeec: 0x4000, 0xeed: 0x4000, 0xeee: 0x4000, 0xeef: 0x4000, - 0xef0: 0x4000, 0xef1: 0x4000, 0xef2: 0x4000, 0xef3: 0x4000, 0xef4: 0x4000, 0xef5: 0x4000, - 0xef6: 0x4000, 0xef7: 0x4000, 0xef8: 0x4000, 0xef9: 0x4000, 0xefa: 0x4000, 0xefb: 0x4000, - 0xefc: 0x4000, 0xefd: 0x4000, 0xefe: 0x4000, 0xeff: 0x4000, - // Block 0x3c, offset 0xf00 - 0xf00: 0x4000, 0xf01: 0x4000, 0xf02: 0x4000, 0xf03: 0x4000, 0xf04: 0x4000, 0xf05: 0x4000, - 0xf06: 0x4000, 0xf07: 0x4000, 0xf08: 0x4000, 0xf09: 0x4000, 0xf0a: 0x4000, 0xf0b: 0x4000, - 0xf0c: 0x4000, 0xf0d: 0x4000, 0xf0e: 0x4000, 0xf0f: 0x4000, 0xf10: 0x4000, 0xf11: 0x4000, - 0xf12: 0x4000, 0xf13: 0x4000, 0xf14: 0x4000, 0xf15: 0x4000, 0xf16: 0x4000, 0xf17: 0x4000, - 0xf18: 0x4000, 0xf19: 0x4000, 0xf1a: 0x4000, 0xf1b: 0x4000, 0xf1c: 0x4000, 0xf1d: 0x4000, - 0xf1e: 0x4000, 0xf1f: 0x4000, 0xf20: 0x4000, 0xf21: 0x4000, 0xf22: 0x4000, 0xf23: 0x4000, - 0xf24: 0x4000, 0xf25: 0x4000, 0xf26: 0x4000, 0xf27: 0x4000, 0xf28: 0x4000, 0xf29: 0x4000, - 0xf2a: 0x4000, 0xf2b: 0x4000, 0xf2c: 0x4000, 0xf2d: 0x4000, 0xf2e: 0x4000, 0xf2f: 0x4000, - 0xf30: 0x4000, 0xf31: 0x4000, 0xf32: 0x4000, 0xf33: 0x4000, 0xf34: 0x4000, 0xf35: 0x4000, - 0xf36: 0x4000, 0xf37: 0x4000, 0xf38: 0x4000, 0xf39: 0x4000, 0xf3a: 0x4000, 0xf3b: 0x4000, - 0xf3c: 0x4000, 0xf3d: 0x4000, 0xf3e: 0x4000, - // Block 0x3d, offset 0xf40 - 0xf40: 0x4000, 0xf41: 0x4000, 0xf42: 0x4000, 0xf43: 0x4000, 0xf44: 0x4000, 0xf45: 0x4000, - 0xf46: 0x4000, 0xf47: 0x4000, 0xf48: 0x4000, 0xf49: 0x4000, 0xf4a: 0x4000, 0xf4b: 0x4000, - 0xf4c: 0x4000, 0xf50: 0x4000, 0xf51: 0x4000, - 0xf52: 0x4000, 0xf53: 0x4000, 0xf54: 0x4000, 0xf55: 0x4000, 0xf56: 0x4000, 0xf57: 0x4000, - 0xf58: 0x4000, 0xf59: 0x4000, 0xf5a: 0x4000, 0xf5b: 0x4000, 0xf5c: 0x4000, 0xf5d: 0x4000, - 0xf5e: 0x4000, 0xf5f: 0x4000, 0xf60: 0x4000, 0xf61: 0x4000, 0xf62: 0x4000, 0xf63: 0x4000, - 0xf64: 0x4000, 0xf65: 0x4000, 0xf66: 0x4000, 0xf67: 0x4000, 0xf68: 0x4000, 0xf69: 0x4000, - 0xf6a: 0x4000, 0xf6b: 0x4000, 0xf6c: 0x4000, 0xf6d: 0x4000, 0xf6e: 0x4000, 0xf6f: 0x4000, - 0xf70: 0x4000, 0xf71: 0x4000, 0xf72: 0x4000, 0xf73: 0x4000, 0xf74: 0x4000, 0xf75: 0x4000, - 0xf76: 0x4000, 0xf77: 0x4000, 0xf78: 0x4000, 0xf79: 0x4000, 0xf7a: 0x4000, 0xf7b: 0x4000, - 0xf7c: 0x4000, 0xf7d: 0x4000, 0xf7e: 0x4000, 0xf7f: 0x4000, - // Block 0x3e, offset 0xf80 - 0xf80: 0x4000, 0xf81: 0x4000, 0xf82: 0x4000, 0xf83: 0x4000, 0xf84: 0x4000, 0xf85: 0x4000, - 0xf86: 0x4000, - // Block 0x3f, offset 0xfc0 - 0xfe0: 0x4000, 0xfe1: 0x4000, 0xfe2: 0x4000, 0xfe3: 0x4000, - 0xfe4: 0x4000, 0xfe5: 0x4000, 0xfe6: 0x4000, 0xfe7: 0x4000, 0xfe8: 0x4000, 0xfe9: 0x4000, - 0xfea: 0x4000, 0xfeb: 0x4000, 0xfec: 0x4000, 0xfed: 0x4000, 0xfee: 0x4000, 0xfef: 0x4000, - 0xff0: 0x4000, 0xff1: 0x4000, 0xff2: 0x4000, 0xff3: 0x4000, 0xff4: 0x4000, 0xff5: 0x4000, - 0xff6: 0x4000, 0xff7: 0x4000, 0xff8: 0x4000, 0xff9: 0x4000, 0xffa: 0x4000, 0xffb: 0x4000, - 0xffc: 0x4000, - // Block 0x40, offset 0x1000 - 0x1000: 0x4000, 0x1001: 0x4000, 0x1002: 0x4000, 0x1003: 0x4000, 0x1004: 0x4000, 0x1005: 0x4000, - 0x1006: 0x4000, 0x1007: 0x4000, 0x1008: 0x4000, 0x1009: 0x4000, 0x100a: 0x4000, 0x100b: 0x4000, - 0x100c: 0x4000, 0x100d: 0x4000, 0x100e: 0x4000, 0x100f: 0x4000, 0x1010: 0x4000, 0x1011: 0x4000, - 0x1012: 0x4000, 0x1013: 0x4000, 0x1014: 0x4000, 0x1015: 0x4000, 0x1016: 0x4000, 0x1017: 0x4000, - 0x1018: 0x4000, 0x1019: 0x4000, 0x101a: 0x4000, 0x101b: 0x4000, 0x101c: 0x4000, 0x101d: 0x4000, - 0x101e: 0x4000, 0x101f: 0x4000, 0x1020: 0x4000, 0x1021: 0x4000, 0x1022: 0x4000, 0x1023: 0x4000, - // Block 0x41, offset 0x1040 - 0x1040: 0x2000, 0x1041: 0x2000, 0x1042: 0x2000, 0x1043: 0x2000, 0x1044: 0x2000, 0x1045: 0x2000, - 0x1046: 0x2000, 0x1047: 0x2000, 0x1048: 0x2000, 0x1049: 0x2000, 0x104a: 0x2000, 0x104b: 0x2000, - 0x104c: 0x2000, 0x104d: 0x2000, 0x104e: 0x2000, 0x104f: 0x2000, 0x1050: 0x4000, 0x1051: 0x4000, - 0x1052: 0x4000, 0x1053: 0x4000, 0x1054: 0x4000, 0x1055: 0x4000, 0x1056: 0x4000, 0x1057: 0x4000, - 0x1058: 0x4000, 0x1059: 0x4000, - 0x1070: 0x4000, 0x1071: 0x4000, 0x1072: 0x4000, 0x1073: 0x4000, 0x1074: 0x4000, 0x1075: 0x4000, - 0x1076: 0x4000, 0x1077: 0x4000, 0x1078: 0x4000, 0x1079: 0x4000, 0x107a: 0x4000, 0x107b: 0x4000, - 0x107c: 0x4000, 0x107d: 0x4000, 0x107e: 0x4000, 0x107f: 0x4000, - // Block 0x42, offset 0x1080 - 0x1080: 0x4000, 0x1081: 0x4000, 0x1082: 0x4000, 0x1083: 0x4000, 0x1084: 0x4000, 0x1085: 0x4000, - 0x1086: 0x4000, 0x1087: 0x4000, 0x1088: 0x4000, 0x1089: 0x4000, 0x108a: 0x4000, 0x108b: 0x4000, - 0x108c: 0x4000, 0x108d: 0x4000, 0x108e: 0x4000, 0x108f: 0x4000, 0x1090: 0x4000, 0x1091: 0x4000, - 0x1092: 0x4000, 0x1094: 0x4000, 0x1095: 0x4000, 0x1096: 0x4000, 0x1097: 0x4000, - 0x1098: 0x4000, 0x1099: 0x4000, 0x109a: 0x4000, 0x109b: 0x4000, 0x109c: 0x4000, 0x109d: 0x4000, - 0x109e: 0x4000, 0x109f: 0x4000, 0x10a0: 0x4000, 0x10a1: 0x4000, 0x10a2: 0x4000, 0x10a3: 0x4000, - 0x10a4: 0x4000, 0x10a5: 0x4000, 0x10a6: 0x4000, 0x10a8: 0x4000, 0x10a9: 0x4000, - 0x10aa: 0x4000, 0x10ab: 0x4000, - // Block 0x43, offset 0x10c0 - 0x10c1: 0x9012, 0x10c2: 0x9012, 0x10c3: 0x9012, 0x10c4: 0x9012, 0x10c5: 0x9012, - 0x10c6: 0x9012, 0x10c7: 0x9012, 0x10c8: 0x9012, 0x10c9: 0x9012, 0x10ca: 0x9012, 0x10cb: 0x9012, - 0x10cc: 0x9012, 0x10cd: 0x9012, 0x10ce: 0x9012, 0x10cf: 0x9012, 0x10d0: 0x9012, 0x10d1: 0x9012, - 0x10d2: 0x9012, 0x10d3: 0x9012, 0x10d4: 0x9012, 0x10d5: 0x9012, 0x10d6: 0x9012, 0x10d7: 0x9012, - 0x10d8: 0x9012, 0x10d9: 0x9012, 0x10da: 0x9012, 0x10db: 0x9012, 0x10dc: 0x9012, 0x10dd: 0x9012, - 0x10de: 0x9012, 0x10df: 0x9012, 0x10e0: 0x9049, 0x10e1: 0x9049, 0x10e2: 0x9049, 0x10e3: 0x9049, - 0x10e4: 0x9049, 0x10e5: 0x9049, 0x10e6: 0x9049, 0x10e7: 0x9049, 0x10e8: 0x9049, 0x10e9: 0x9049, - 0x10ea: 0x9049, 0x10eb: 0x9049, 0x10ec: 0x9049, 0x10ed: 0x9049, 0x10ee: 0x9049, 0x10ef: 0x9049, - 0x10f0: 0x9049, 0x10f1: 0x9049, 0x10f2: 0x9049, 0x10f3: 0x9049, 0x10f4: 0x9049, 0x10f5: 0x9049, - 0x10f6: 0x9049, 0x10f7: 0x9049, 0x10f8: 0x9049, 0x10f9: 0x9049, 0x10fa: 0x9049, 0x10fb: 0x9049, - 0x10fc: 0x9049, 0x10fd: 0x9049, 0x10fe: 0x9049, 0x10ff: 0x9049, - // Block 0x44, offset 0x1100 - 0x1100: 0x9049, 0x1101: 0x9049, 0x1102: 0x9049, 0x1103: 0x9049, 0x1104: 0x9049, 0x1105: 0x9049, - 0x1106: 0x9049, 0x1107: 0x9049, 0x1108: 0x9049, 0x1109: 0x9049, 0x110a: 0x9049, 0x110b: 0x9049, - 0x110c: 0x9049, 0x110d: 0x9049, 0x110e: 0x9049, 0x110f: 0x9049, 0x1110: 0x9049, 0x1111: 0x9049, - 0x1112: 0x9049, 0x1113: 0x9049, 0x1114: 0x9049, 0x1115: 0x9049, 0x1116: 0x9049, 0x1117: 0x9049, - 0x1118: 0x9049, 0x1119: 0x9049, 0x111a: 0x9049, 0x111b: 0x9049, 0x111c: 0x9049, 0x111d: 0x9049, - 0x111e: 0x9049, 0x111f: 0x904a, 0x1120: 0x904b, 0x1121: 0xb04c, 0x1122: 0xb04d, 0x1123: 0xb04d, - 0x1124: 0xb04e, 0x1125: 0xb04f, 0x1126: 0xb050, 0x1127: 0xb051, 0x1128: 0xb052, 0x1129: 0xb053, - 0x112a: 0xb054, 0x112b: 0xb055, 0x112c: 0xb056, 0x112d: 0xb057, 0x112e: 0xb058, 0x112f: 0xb059, - 0x1130: 0xb05a, 0x1131: 0xb05b, 0x1132: 0xb05c, 0x1133: 0xb05d, 0x1134: 0xb05e, 0x1135: 0xb05f, - 0x1136: 0xb060, 0x1137: 0xb061, 0x1138: 0xb062, 0x1139: 0xb063, 0x113a: 0xb064, 0x113b: 0xb065, - 0x113c: 0xb052, 0x113d: 0xb066, 0x113e: 0xb067, 0x113f: 0xb055, - // Block 0x45, offset 0x1140 - 0x1140: 0xb068, 0x1141: 0xb069, 0x1142: 0xb06a, 0x1143: 0xb06b, 0x1144: 0xb05a, 0x1145: 0xb056, - 0x1146: 0xb06c, 0x1147: 0xb06d, 0x1148: 0xb06b, 0x1149: 0xb06e, 0x114a: 0xb06b, 0x114b: 0xb06f, - 0x114c: 0xb06f, 0x114d: 0xb070, 0x114e: 0xb070, 0x114f: 0xb071, 0x1150: 0xb056, 0x1151: 0xb072, - 0x1152: 0xb073, 0x1153: 0xb072, 0x1154: 0xb074, 0x1155: 0xb073, 0x1156: 0xb075, 0x1157: 0xb075, - 0x1158: 0xb076, 0x1159: 0xb076, 0x115a: 0xb077, 0x115b: 0xb077, 0x115c: 0xb073, 0x115d: 0xb078, - 0x115e: 0xb079, 0x115f: 0xb067, 0x1160: 0xb07a, 0x1161: 0xb07b, 0x1162: 0xb07b, 0x1163: 0xb07b, - 0x1164: 0xb07b, 0x1165: 0xb07b, 0x1166: 0xb07b, 0x1167: 0xb07b, 0x1168: 0xb07b, 0x1169: 0xb07b, - 0x116a: 0xb07b, 0x116b: 0xb07b, 0x116c: 0xb07b, 0x116d: 0xb07b, 0x116e: 0xb07b, 0x116f: 0xb07b, - 0x1170: 0xb07c, 0x1171: 0xb07c, 0x1172: 0xb07c, 0x1173: 0xb07c, 0x1174: 0xb07c, 0x1175: 0xb07c, - 0x1176: 0xb07c, 0x1177: 0xb07c, 0x1178: 0xb07c, 0x1179: 0xb07c, 0x117a: 0xb07c, 0x117b: 0xb07c, - 0x117c: 0xb07c, 0x117d: 0xb07c, 0x117e: 0xb07c, - // Block 0x46, offset 0x1180 - 0x1182: 0xb07d, 0x1183: 0xb07e, 0x1184: 0xb07f, 0x1185: 0xb080, - 0x1186: 0xb07f, 0x1187: 0xb07e, 0x118a: 0xb081, 0x118b: 0xb082, - 0x118c: 0xb083, 0x118d: 0xb07f, 0x118e: 0xb080, 0x118f: 0xb07f, - 0x1192: 0xb084, 0x1193: 0xb085, 0x1194: 0xb084, 0x1195: 0xb086, 0x1196: 0xb084, 0x1197: 0xb087, - 0x119a: 0xb088, 0x119b: 0xb089, 0x119c: 0xb08a, - 0x11a0: 0x908b, 0x11a1: 0x908b, 0x11a2: 0x908c, 0x11a3: 0x908d, - 0x11a4: 0x908b, 0x11a5: 0x908e, 0x11a6: 0x908f, 0x11a8: 0xb090, 0x11a9: 0xb091, - 0x11aa: 0xb092, 0x11ab: 0xb091, 0x11ac: 0xb093, 0x11ad: 0xb094, 0x11ae: 0xb095, - 0x11bd: 0x2000, - // Block 0x47, offset 0x11c0 - 0x11e0: 0x4000, 0x11e1: 0x4000, - // Block 0x48, offset 0x1200 - 0x1200: 0x4000, 0x1201: 0x4000, 0x1202: 0x4000, 0x1203: 0x4000, 0x1204: 0x4000, 0x1205: 0x4000, - 0x1206: 0x4000, 0x1207: 0x4000, 0x1208: 0x4000, 0x1209: 0x4000, 0x120a: 0x4000, 0x120b: 0x4000, - 0x120c: 0x4000, 0x120d: 0x4000, 0x120e: 0x4000, 0x120f: 0x4000, 0x1210: 0x4000, 0x1211: 0x4000, - 0x1212: 0x4000, 0x1213: 0x4000, 0x1214: 0x4000, 0x1215: 0x4000, 0x1216: 0x4000, 0x1217: 0x4000, - 0x1218: 0x4000, 0x1219: 0x4000, 0x121a: 0x4000, 0x121b: 0x4000, 0x121c: 0x4000, 0x121d: 0x4000, - 0x121e: 0x4000, 0x121f: 0x4000, 0x1220: 0x4000, 0x1221: 0x4000, 0x1222: 0x4000, 0x1223: 0x4000, - 0x1224: 0x4000, 0x1225: 0x4000, 0x1226: 0x4000, 0x1227: 0x4000, 0x1228: 0x4000, 0x1229: 0x4000, - 0x122a: 0x4000, 0x122b: 0x4000, 0x122c: 0x4000, 0x122d: 0x4000, 0x122e: 0x4000, 0x122f: 0x4000, - 0x1230: 0x4000, 0x1231: 0x4000, - // Block 0x49, offset 0x1240 - 0x1240: 0x4000, 0x1241: 0x4000, 0x1242: 0x4000, 0x1243: 0x4000, 0x1244: 0x4000, 0x1245: 0x4000, - 0x1246: 0x4000, 0x1247: 0x4000, 0x1248: 0x4000, 0x1249: 0x4000, 0x124a: 0x4000, 0x124b: 0x4000, - 0x124c: 0x4000, 0x124d: 0x4000, 0x124e: 0x4000, 0x124f: 0x4000, 0x1250: 0x4000, 0x1251: 0x4000, - 0x1252: 0x4000, 0x1253: 0x4000, 0x1254: 0x4000, 0x1255: 0x4000, 0x1256: 0x4000, 0x1257: 0x4000, - 0x1258: 0x4000, 0x1259: 0x4000, 0x125a: 0x4000, 0x125b: 0x4000, 0x125c: 0x4000, 0x125d: 0x4000, - 0x125e: 0x4000, 0x125f: 0x4000, 0x1260: 0x4000, 0x1261: 0x4000, 0x1262: 0x4000, 0x1263: 0x4000, - 0x1264: 0x4000, 0x1265: 0x4000, 0x1266: 0x4000, 0x1267: 0x4000, 0x1268: 0x4000, 0x1269: 0x4000, - 0x126a: 0x4000, 0x126b: 0x4000, 0x126c: 0x4000, 0x126d: 0x4000, 0x126e: 0x4000, 0x126f: 0x4000, - 0x1270: 0x4000, 0x1271: 0x4000, 0x1272: 0x4000, - // Block 0x4a, offset 0x1280 - 0x1280: 0x4000, 0x1281: 0x4000, 0x1282: 0x4000, 0x1283: 0x4000, 0x1284: 0x4000, 0x1285: 0x4000, - 0x1286: 0x4000, 0x1287: 0x4000, 0x1288: 0x4000, 0x1289: 0x4000, 0x128a: 0x4000, 0x128b: 0x4000, - 0x128c: 0x4000, 0x128d: 0x4000, 0x128e: 0x4000, 0x128f: 0x4000, 0x1290: 0x4000, 0x1291: 0x4000, - 0x1292: 0x4000, 0x1293: 0x4000, 0x1294: 0x4000, 0x1295: 0x4000, 0x1296: 0x4000, 0x1297: 0x4000, - 0x1298: 0x4000, 0x1299: 0x4000, 0x129a: 0x4000, 0x129b: 0x4000, 0x129c: 0x4000, 0x129d: 0x4000, - 0x129e: 0x4000, - // Block 0x4b, offset 0x12c0 - 0x12f0: 0x4000, 0x12f1: 0x4000, 0x12f2: 0x4000, 0x12f3: 0x4000, 0x12f4: 0x4000, 0x12f5: 0x4000, - 0x12f6: 0x4000, 0x12f7: 0x4000, 0x12f8: 0x4000, 0x12f9: 0x4000, 0x12fa: 0x4000, 0x12fb: 0x4000, - 0x12fc: 0x4000, 0x12fd: 0x4000, 0x12fe: 0x4000, 0x12ff: 0x4000, - // Block 0x4c, offset 0x1300 - 0x1300: 0x4000, 0x1301: 0x4000, 0x1302: 0x4000, 0x1303: 0x4000, 0x1304: 0x4000, 0x1305: 0x4000, - 0x1306: 0x4000, 0x1307: 0x4000, 0x1308: 0x4000, 0x1309: 0x4000, 0x130a: 0x4000, 0x130b: 0x4000, - 0x130c: 0x4000, 0x130d: 0x4000, 0x130e: 0x4000, 0x130f: 0x4000, 0x1310: 0x4000, 0x1311: 0x4000, - 0x1312: 0x4000, 0x1313: 0x4000, 0x1314: 0x4000, 0x1315: 0x4000, 0x1316: 0x4000, 0x1317: 0x4000, - 0x1318: 0x4000, 0x1319: 0x4000, 0x131a: 0x4000, 0x131b: 0x4000, 0x131c: 0x4000, 0x131d: 0x4000, - 0x131e: 0x4000, 0x131f: 0x4000, 0x1320: 0x4000, 0x1321: 0x4000, 0x1322: 0x4000, 0x1323: 0x4000, - 0x1324: 0x4000, 0x1325: 0x4000, 0x1326: 0x4000, 0x1327: 0x4000, 0x1328: 0x4000, 0x1329: 0x4000, - 0x132a: 0x4000, 0x132b: 0x4000, 0x132c: 0x4000, 0x132d: 0x4000, 0x132e: 0x4000, 0x132f: 0x4000, - 0x1330: 0x4000, 0x1331: 0x4000, 0x1332: 0x4000, 0x1333: 0x4000, 0x1334: 0x4000, 0x1335: 0x4000, - 0x1336: 0x4000, 0x1337: 0x4000, 0x1338: 0x4000, 0x1339: 0x4000, 0x133a: 0x4000, 0x133b: 0x4000, - // Block 0x4d, offset 0x1340 - 0x1344: 0x4000, - // Block 0x4e, offset 0x1380 - 0x138f: 0x4000, - // Block 0x4f, offset 0x13c0 - 0x13c0: 0x2000, 0x13c1: 0x2000, 0x13c2: 0x2000, 0x13c3: 0x2000, 0x13c4: 0x2000, 0x13c5: 0x2000, - 0x13c6: 0x2000, 0x13c7: 0x2000, 0x13c8: 0x2000, 0x13c9: 0x2000, 0x13ca: 0x2000, - 0x13d0: 0x2000, 0x13d1: 0x2000, - 0x13d2: 0x2000, 0x13d3: 0x2000, 0x13d4: 0x2000, 0x13d5: 0x2000, 0x13d6: 0x2000, 0x13d7: 0x2000, - 0x13d8: 0x2000, 0x13d9: 0x2000, 0x13da: 0x2000, 0x13db: 0x2000, 0x13dc: 0x2000, 0x13dd: 0x2000, - 0x13de: 0x2000, 0x13df: 0x2000, 0x13e0: 0x2000, 0x13e1: 0x2000, 0x13e2: 0x2000, 0x13e3: 0x2000, - 0x13e4: 0x2000, 0x13e5: 0x2000, 0x13e6: 0x2000, 0x13e7: 0x2000, 0x13e8: 0x2000, 0x13e9: 0x2000, - 0x13ea: 0x2000, 0x13eb: 0x2000, 0x13ec: 0x2000, 0x13ed: 0x2000, - 0x13f0: 0x2000, 0x13f1: 0x2000, 0x13f2: 0x2000, 0x13f3: 0x2000, 0x13f4: 0x2000, 0x13f5: 0x2000, - 0x13f6: 0x2000, 0x13f7: 0x2000, 0x13f8: 0x2000, 0x13f9: 0x2000, 0x13fa: 0x2000, 0x13fb: 0x2000, - 0x13fc: 0x2000, 0x13fd: 0x2000, 0x13fe: 0x2000, 0x13ff: 0x2000, - // Block 0x50, offset 0x1400 - 0x1400: 0x2000, 0x1401: 0x2000, 0x1402: 0x2000, 0x1403: 0x2000, 0x1404: 0x2000, 0x1405: 0x2000, - 0x1406: 0x2000, 0x1407: 0x2000, 0x1408: 0x2000, 0x1409: 0x2000, 0x140a: 0x2000, 0x140b: 0x2000, - 0x140c: 0x2000, 0x140d: 0x2000, 0x140e: 0x2000, 0x140f: 0x2000, 0x1410: 0x2000, 0x1411: 0x2000, - 0x1412: 0x2000, 0x1413: 0x2000, 0x1414: 0x2000, 0x1415: 0x2000, 0x1416: 0x2000, 0x1417: 0x2000, - 0x1418: 0x2000, 0x1419: 0x2000, 0x141a: 0x2000, 0x141b: 0x2000, 0x141c: 0x2000, 0x141d: 0x2000, - 0x141e: 0x2000, 0x141f: 0x2000, 0x1420: 0x2000, 0x1421: 0x2000, 0x1422: 0x2000, 0x1423: 0x2000, - 0x1424: 0x2000, 0x1425: 0x2000, 0x1426: 0x2000, 0x1427: 0x2000, 0x1428: 0x2000, 0x1429: 0x2000, - 0x1430: 0x2000, 0x1431: 0x2000, 0x1432: 0x2000, 0x1433: 0x2000, 0x1434: 0x2000, 0x1435: 0x2000, - 0x1436: 0x2000, 0x1437: 0x2000, 0x1438: 0x2000, 0x1439: 0x2000, 0x143a: 0x2000, 0x143b: 0x2000, - 0x143c: 0x2000, 0x143d: 0x2000, 0x143e: 0x2000, 0x143f: 0x2000, - // Block 0x51, offset 0x1440 - 0x1440: 0x2000, 0x1441: 0x2000, 0x1442: 0x2000, 0x1443: 0x2000, 0x1444: 0x2000, 0x1445: 0x2000, - 0x1446: 0x2000, 0x1447: 0x2000, 0x1448: 0x2000, 0x1449: 0x2000, 0x144a: 0x2000, 0x144b: 0x2000, - 0x144c: 0x2000, 0x144d: 0x2000, 0x144e: 0x4000, 0x144f: 0x2000, 0x1450: 0x2000, 0x1451: 0x4000, - 0x1452: 0x4000, 0x1453: 0x4000, 0x1454: 0x4000, 0x1455: 0x4000, 0x1456: 0x4000, 0x1457: 0x4000, - 0x1458: 0x4000, 0x1459: 0x4000, 0x145a: 0x4000, 0x145b: 0x2000, 0x145c: 0x2000, 0x145d: 0x2000, - 0x145e: 0x2000, 0x145f: 0x2000, 0x1460: 0x2000, 0x1461: 0x2000, 0x1462: 0x2000, 0x1463: 0x2000, - 0x1464: 0x2000, 0x1465: 0x2000, 0x1466: 0x2000, 0x1467: 0x2000, 0x1468: 0x2000, 0x1469: 0x2000, - 0x146a: 0x2000, 0x146b: 0x2000, 0x146c: 0x2000, - // Block 0x52, offset 0x1480 - 0x1480: 0x4000, 0x1481: 0x4000, 0x1482: 0x4000, - 0x1490: 0x4000, 0x1491: 0x4000, - 0x1492: 0x4000, 0x1493: 0x4000, 0x1494: 0x4000, 0x1495: 0x4000, 0x1496: 0x4000, 0x1497: 0x4000, - 0x1498: 0x4000, 0x1499: 0x4000, 0x149a: 0x4000, 0x149b: 0x4000, 0x149c: 0x4000, 0x149d: 0x4000, - 0x149e: 0x4000, 0x149f: 0x4000, 0x14a0: 0x4000, 0x14a1: 0x4000, 0x14a2: 0x4000, 0x14a3: 0x4000, - 0x14a4: 0x4000, 0x14a5: 0x4000, 0x14a6: 0x4000, 0x14a7: 0x4000, 0x14a8: 0x4000, 0x14a9: 0x4000, - 0x14aa: 0x4000, 0x14ab: 0x4000, 0x14ac: 0x4000, 0x14ad: 0x4000, 0x14ae: 0x4000, 0x14af: 0x4000, - 0x14b0: 0x4000, 0x14b1: 0x4000, 0x14b2: 0x4000, 0x14b3: 0x4000, 0x14b4: 0x4000, 0x14b5: 0x4000, - 0x14b6: 0x4000, 0x14b7: 0x4000, 0x14b8: 0x4000, 0x14b9: 0x4000, 0x14ba: 0x4000, 0x14bb: 0x4000, - // Block 0x53, offset 0x14c0 - 0x14c0: 0x4000, 0x14c1: 0x4000, 0x14c2: 0x4000, 0x14c3: 0x4000, 0x14c4: 0x4000, 0x14c5: 0x4000, - 0x14c6: 0x4000, 0x14c7: 0x4000, 0x14c8: 0x4000, - 0x14d0: 0x4000, 0x14d1: 0x4000, - 0x14e0: 0x4000, 0x14e1: 0x4000, 0x14e2: 0x4000, 0x14e3: 0x4000, - 0x14e4: 0x4000, 0x14e5: 0x4000, - // Block 0x54, offset 0x1500 - 0x1500: 0x4000, 0x1501: 0x4000, 0x1502: 0x4000, 0x1503: 0x4000, 0x1504: 0x4000, 0x1505: 0x4000, - 0x1506: 0x4000, 0x1507: 0x4000, 0x1508: 0x4000, 0x1509: 0x4000, 0x150a: 0x4000, 0x150b: 0x4000, - 0x150c: 0x4000, 0x150d: 0x4000, 0x150e: 0x4000, 0x150f: 0x4000, 0x1510: 0x4000, 0x1511: 0x4000, - 0x1512: 0x4000, 0x1513: 0x4000, 0x1514: 0x4000, 0x1515: 0x4000, 0x1516: 0x4000, 0x1517: 0x4000, - 0x1518: 0x4000, 0x1519: 0x4000, 0x151a: 0x4000, 0x151b: 0x4000, 0x151c: 0x4000, 0x151d: 0x4000, - 0x151e: 0x4000, 0x151f: 0x4000, 0x1520: 0x4000, - 0x152d: 0x4000, 0x152e: 0x4000, 0x152f: 0x4000, - 0x1530: 0x4000, 0x1531: 0x4000, 0x1532: 0x4000, 0x1533: 0x4000, 0x1534: 0x4000, 0x1535: 0x4000, - 0x1537: 0x4000, 0x1538: 0x4000, 0x1539: 0x4000, 0x153a: 0x4000, 0x153b: 0x4000, - 0x153c: 0x4000, 0x153d: 0x4000, 0x153e: 0x4000, 0x153f: 0x4000, - // Block 0x55, offset 0x1540 - 0x1540: 0x4000, 0x1541: 0x4000, 0x1542: 0x4000, 0x1543: 0x4000, 0x1544: 0x4000, 0x1545: 0x4000, - 0x1546: 0x4000, 0x1547: 0x4000, 0x1548: 0x4000, 0x1549: 0x4000, 0x154a: 0x4000, 0x154b: 0x4000, - 0x154c: 0x4000, 0x154d: 0x4000, 0x154e: 0x4000, 0x154f: 0x4000, 0x1550: 0x4000, 0x1551: 0x4000, - 0x1552: 0x4000, 0x1553: 0x4000, 0x1554: 0x4000, 0x1555: 0x4000, 0x1556: 0x4000, 0x1557: 0x4000, - 0x1558: 0x4000, 0x1559: 0x4000, 0x155a: 0x4000, 0x155b: 0x4000, 0x155c: 0x4000, 0x155d: 0x4000, - 0x155e: 0x4000, 0x155f: 0x4000, 0x1560: 0x4000, 0x1561: 0x4000, 0x1562: 0x4000, 0x1563: 0x4000, - 0x1564: 0x4000, 0x1565: 0x4000, 0x1566: 0x4000, 0x1567: 0x4000, 0x1568: 0x4000, 0x1569: 0x4000, - 0x156a: 0x4000, 0x156b: 0x4000, 0x156c: 0x4000, 0x156d: 0x4000, 0x156e: 0x4000, 0x156f: 0x4000, - 0x1570: 0x4000, 0x1571: 0x4000, 0x1572: 0x4000, 0x1573: 0x4000, 0x1574: 0x4000, 0x1575: 0x4000, - 0x1576: 0x4000, 0x1577: 0x4000, 0x1578: 0x4000, 0x1579: 0x4000, 0x157a: 0x4000, 0x157b: 0x4000, - 0x157c: 0x4000, 0x157e: 0x4000, 0x157f: 0x4000, - // Block 0x56, offset 0x1580 - 0x1580: 0x4000, 0x1581: 0x4000, 0x1582: 0x4000, 0x1583: 0x4000, 0x1584: 0x4000, 0x1585: 0x4000, - 0x1586: 0x4000, 0x1587: 0x4000, 0x1588: 0x4000, 0x1589: 0x4000, 0x158a: 0x4000, 0x158b: 0x4000, - 0x158c: 0x4000, 0x158d: 0x4000, 0x158e: 0x4000, 0x158f: 0x4000, 0x1590: 0x4000, 0x1591: 0x4000, - 0x1592: 0x4000, 0x1593: 0x4000, - 0x15a0: 0x4000, 0x15a1: 0x4000, 0x15a2: 0x4000, 0x15a3: 0x4000, - 0x15a4: 0x4000, 0x15a5: 0x4000, 0x15a6: 0x4000, 0x15a7: 0x4000, 0x15a8: 0x4000, 0x15a9: 0x4000, - 0x15aa: 0x4000, 0x15ab: 0x4000, 0x15ac: 0x4000, 0x15ad: 0x4000, 0x15ae: 0x4000, 0x15af: 0x4000, - 0x15b0: 0x4000, 0x15b1: 0x4000, 0x15b2: 0x4000, 0x15b3: 0x4000, 0x15b4: 0x4000, 0x15b5: 0x4000, - 0x15b6: 0x4000, 0x15b7: 0x4000, 0x15b8: 0x4000, 0x15b9: 0x4000, 0x15ba: 0x4000, 0x15bb: 0x4000, - 0x15bc: 0x4000, 0x15bd: 0x4000, 0x15be: 0x4000, 0x15bf: 0x4000, - // Block 0x57, offset 0x15c0 - 0x15c0: 0x4000, 0x15c1: 0x4000, 0x15c2: 0x4000, 0x15c3: 0x4000, 0x15c4: 0x4000, 0x15c5: 0x4000, - 0x15c6: 0x4000, 0x15c7: 0x4000, 0x15c8: 0x4000, 0x15c9: 0x4000, 0x15ca: 0x4000, - 0x15cf: 0x4000, 0x15d0: 0x4000, 0x15d1: 0x4000, - 0x15d2: 0x4000, 0x15d3: 0x4000, - 0x15e0: 0x4000, 0x15e1: 0x4000, 0x15e2: 0x4000, 0x15e3: 0x4000, - 0x15e4: 0x4000, 0x15e5: 0x4000, 0x15e6: 0x4000, 0x15e7: 0x4000, 0x15e8: 0x4000, 0x15e9: 0x4000, - 0x15ea: 0x4000, 0x15eb: 0x4000, 0x15ec: 0x4000, 0x15ed: 0x4000, 0x15ee: 0x4000, 0x15ef: 0x4000, - 0x15f0: 0x4000, 0x15f4: 0x4000, - 0x15f8: 0x4000, 0x15f9: 0x4000, 0x15fa: 0x4000, 0x15fb: 0x4000, - 0x15fc: 0x4000, 0x15fd: 0x4000, 0x15fe: 0x4000, 0x15ff: 0x4000, - // Block 0x58, offset 0x1600 - 0x1600: 0x4000, 0x1602: 0x4000, 0x1603: 0x4000, 0x1604: 0x4000, 0x1605: 0x4000, - 0x1606: 0x4000, 0x1607: 0x4000, 0x1608: 0x4000, 0x1609: 0x4000, 0x160a: 0x4000, 0x160b: 0x4000, - 0x160c: 0x4000, 0x160d: 0x4000, 0x160e: 0x4000, 0x160f: 0x4000, 0x1610: 0x4000, 0x1611: 0x4000, - 0x1612: 0x4000, 0x1613: 0x4000, 0x1614: 0x4000, 0x1615: 0x4000, 0x1616: 0x4000, 0x1617: 0x4000, - 0x1618: 0x4000, 0x1619: 0x4000, 0x161a: 0x4000, 0x161b: 0x4000, 0x161c: 0x4000, 0x161d: 0x4000, - 0x161e: 0x4000, 0x161f: 0x4000, 0x1620: 0x4000, 0x1621: 0x4000, 0x1622: 0x4000, 0x1623: 0x4000, - 0x1624: 0x4000, 0x1625: 0x4000, 0x1626: 0x4000, 0x1627: 0x4000, 0x1628: 0x4000, 0x1629: 0x4000, - 0x162a: 0x4000, 0x162b: 0x4000, 0x162c: 0x4000, 0x162d: 0x4000, 0x162e: 0x4000, 0x162f: 0x4000, - 0x1630: 0x4000, 0x1631: 0x4000, 0x1632: 0x4000, 0x1633: 0x4000, 0x1634: 0x4000, 0x1635: 0x4000, - 0x1636: 0x4000, 0x1637: 0x4000, 0x1638: 0x4000, 0x1639: 0x4000, 0x163a: 0x4000, 0x163b: 0x4000, - 0x163c: 0x4000, 0x163d: 0x4000, 0x163e: 0x4000, 0x163f: 0x4000, - // Block 0x59, offset 0x1640 - 0x1640: 0x4000, 0x1641: 0x4000, 0x1642: 0x4000, 0x1643: 0x4000, 0x1644: 0x4000, 0x1645: 0x4000, - 0x1646: 0x4000, 0x1647: 0x4000, 0x1648: 0x4000, 0x1649: 0x4000, 0x164a: 0x4000, 0x164b: 0x4000, - 0x164c: 0x4000, 0x164d: 0x4000, 0x164e: 0x4000, 0x164f: 0x4000, 0x1650: 0x4000, 0x1651: 0x4000, - 0x1652: 0x4000, 0x1653: 0x4000, 0x1654: 0x4000, 0x1655: 0x4000, 0x1656: 0x4000, 0x1657: 0x4000, - 0x1658: 0x4000, 0x1659: 0x4000, 0x165a: 0x4000, 0x165b: 0x4000, 0x165c: 0x4000, 0x165d: 0x4000, - 0x165e: 0x4000, 0x165f: 0x4000, 0x1660: 0x4000, 0x1661: 0x4000, 0x1662: 0x4000, 0x1663: 0x4000, - 0x1664: 0x4000, 0x1665: 0x4000, 0x1666: 0x4000, 0x1667: 0x4000, 0x1668: 0x4000, 0x1669: 0x4000, - 0x166a: 0x4000, 0x166b: 0x4000, 0x166c: 0x4000, 0x166d: 0x4000, 0x166e: 0x4000, 0x166f: 0x4000, - 0x1670: 0x4000, 0x1671: 0x4000, 0x1672: 0x4000, 0x1673: 0x4000, 0x1674: 0x4000, 0x1675: 0x4000, - 0x1676: 0x4000, 0x1677: 0x4000, 0x1678: 0x4000, 0x1679: 0x4000, 0x167a: 0x4000, 0x167b: 0x4000, - 0x167c: 0x4000, 0x167f: 0x4000, - // Block 0x5a, offset 0x1680 - 0x1680: 0x4000, 0x1681: 0x4000, 0x1682: 0x4000, 0x1683: 0x4000, 0x1684: 0x4000, 0x1685: 0x4000, - 0x1686: 0x4000, 0x1687: 0x4000, 0x1688: 0x4000, 0x1689: 0x4000, 0x168a: 0x4000, 0x168b: 0x4000, - 0x168c: 0x4000, 0x168d: 0x4000, 0x168e: 0x4000, 0x168f: 0x4000, 0x1690: 0x4000, 0x1691: 0x4000, - 0x1692: 0x4000, 0x1693: 0x4000, 0x1694: 0x4000, 0x1695: 0x4000, 0x1696: 0x4000, 0x1697: 0x4000, - 0x1698: 0x4000, 0x1699: 0x4000, 0x169a: 0x4000, 0x169b: 0x4000, 0x169c: 0x4000, 0x169d: 0x4000, - 0x169e: 0x4000, 0x169f: 0x4000, 0x16a0: 0x4000, 0x16a1: 0x4000, 0x16a2: 0x4000, 0x16a3: 0x4000, - 0x16a4: 0x4000, 0x16a5: 0x4000, 0x16a6: 0x4000, 0x16a7: 0x4000, 0x16a8: 0x4000, 0x16a9: 0x4000, - 0x16aa: 0x4000, 0x16ab: 0x4000, 0x16ac: 0x4000, 0x16ad: 0x4000, 0x16ae: 0x4000, 0x16af: 0x4000, - 0x16b0: 0x4000, 0x16b1: 0x4000, 0x16b2: 0x4000, 0x16b3: 0x4000, 0x16b4: 0x4000, 0x16b5: 0x4000, - 0x16b6: 0x4000, 0x16b7: 0x4000, 0x16b8: 0x4000, 0x16b9: 0x4000, 0x16ba: 0x4000, 0x16bb: 0x4000, - 0x16bc: 0x4000, 0x16bd: 0x4000, - // Block 0x5b, offset 0x16c0 - 0x16cb: 0x4000, - 0x16cc: 0x4000, 0x16cd: 0x4000, 0x16ce: 0x4000, 0x16d0: 0x4000, 0x16d1: 0x4000, - 0x16d2: 0x4000, 0x16d3: 0x4000, 0x16d4: 0x4000, 0x16d5: 0x4000, 0x16d6: 0x4000, 0x16d7: 0x4000, - 0x16d8: 0x4000, 0x16d9: 0x4000, 0x16da: 0x4000, 0x16db: 0x4000, 0x16dc: 0x4000, 0x16dd: 0x4000, - 0x16de: 0x4000, 0x16df: 0x4000, 0x16e0: 0x4000, 0x16e1: 0x4000, 0x16e2: 0x4000, 0x16e3: 0x4000, - 0x16e4: 0x4000, 0x16e5: 0x4000, 0x16e6: 0x4000, 0x16e7: 0x4000, - 0x16fa: 0x4000, - // Block 0x5c, offset 0x1700 - 0x1715: 0x4000, 0x1716: 0x4000, - 0x1724: 0x4000, - // Block 0x5d, offset 0x1740 - 0x177b: 0x4000, - 0x177c: 0x4000, 0x177d: 0x4000, 0x177e: 0x4000, 0x177f: 0x4000, - // Block 0x5e, offset 0x1780 - 0x1780: 0x4000, 0x1781: 0x4000, 0x1782: 0x4000, 0x1783: 0x4000, 0x1784: 0x4000, 0x1785: 0x4000, - 0x1786: 0x4000, 0x1787: 0x4000, 0x1788: 0x4000, 0x1789: 0x4000, 0x178a: 0x4000, 0x178b: 0x4000, - 0x178c: 0x4000, 0x178d: 0x4000, 0x178e: 0x4000, 0x178f: 0x4000, - // Block 0x5f, offset 0x17c0 - 0x17c0: 0x4000, 0x17c1: 0x4000, 0x17c2: 0x4000, 0x17c3: 0x4000, 0x17c4: 0x4000, 0x17c5: 0x4000, - 0x17cc: 0x4000, 0x17d0: 0x4000, 0x17d1: 0x4000, - 0x17d2: 0x4000, - 0x17eb: 0x4000, 0x17ec: 0x4000, - 0x17f4: 0x4000, 0x17f5: 0x4000, - 0x17f6: 0x4000, 0x17f7: 0x4000, 0x17f8: 0x4000, 0x17f9: 0x4000, - // Block 0x60, offset 0x1800 - 0x1810: 0x4000, 0x1811: 0x4000, - 0x1812: 0x4000, 0x1813: 0x4000, 0x1814: 0x4000, 0x1815: 0x4000, 0x1816: 0x4000, 0x1817: 0x4000, - 0x1818: 0x4000, 0x1819: 0x4000, 0x181a: 0x4000, 0x181b: 0x4000, 0x181c: 0x4000, 0x181d: 0x4000, - 0x181e: 0x4000, 0x181f: 0x4000, 0x1820: 0x4000, 0x1821: 0x4000, 0x1822: 0x4000, 0x1823: 0x4000, - 0x1824: 0x4000, 0x1825: 0x4000, 0x1826: 0x4000, 0x1827: 0x4000, 0x1828: 0x4000, 0x1829: 0x4000, - 0x182a: 0x4000, 0x182b: 0x4000, 0x182c: 0x4000, 0x182d: 0x4000, 0x182e: 0x4000, 0x182f: 0x4000, - 0x1830: 0x4000, 0x1831: 0x4000, 0x1832: 0x4000, 0x1833: 0x4000, 0x1834: 0x4000, 0x1835: 0x4000, - 0x1836: 0x4000, 0x1837: 0x4000, 0x1838: 0x4000, 0x1839: 0x4000, 0x183a: 0x4000, 0x183b: 0x4000, - 0x183c: 0x4000, 0x183d: 0x4000, 0x183e: 0x4000, - // Block 0x61, offset 0x1840 - 0x1840: 0x4000, 0x1841: 0x4000, 0x1842: 0x4000, 0x1843: 0x4000, 0x1844: 0x4000, 0x1845: 0x4000, - 0x1846: 0x4000, 0x1847: 0x4000, 0x1848: 0x4000, 0x1849: 0x4000, 0x184a: 0x4000, 0x184b: 0x4000, - 0x184c: 0x4000, 0x184d: 0x4000, 0x184e: 0x4000, 0x184f: 0x4000, 0x1850: 0x4000, 0x1851: 0x4000, - 0x1852: 0x4000, 0x1853: 0x4000, 0x1854: 0x4000, 0x1855: 0x4000, 0x1856: 0x4000, 0x1857: 0x4000, - 0x1858: 0x4000, 0x1859: 0x4000, 0x185a: 0x4000, 0x185b: 0x4000, 0x185c: 0x4000, 0x185d: 0x4000, - 0x185e: 0x4000, 0x185f: 0x4000, 0x1860: 0x4000, 0x1861: 0x4000, 0x1862: 0x4000, 0x1863: 0x4000, - 0x1864: 0x4000, 0x1865: 0x4000, 0x1866: 0x4000, 0x1867: 0x4000, 0x1868: 0x4000, 0x1869: 0x4000, - 0x186a: 0x4000, 0x186b: 0x4000, 0x186c: 0x4000, 0x186d: 0x4000, 0x186e: 0x4000, 0x186f: 0x4000, - 0x1870: 0x4000, 0x1873: 0x4000, 0x1874: 0x4000, 0x1875: 0x4000, - 0x1876: 0x4000, 0x187a: 0x4000, - 0x187c: 0x4000, 0x187d: 0x4000, 0x187e: 0x4000, 0x187f: 0x4000, - // Block 0x62, offset 0x1880 - 0x1880: 0x4000, 0x1881: 0x4000, 0x1882: 0x4000, 0x1883: 0x4000, 0x1884: 0x4000, 0x1885: 0x4000, - 0x1886: 0x4000, 0x1887: 0x4000, 0x1888: 0x4000, 0x1889: 0x4000, 0x188a: 0x4000, 0x188b: 0x4000, - 0x188c: 0x4000, 0x188d: 0x4000, 0x188e: 0x4000, 0x188f: 0x4000, 0x1890: 0x4000, 0x1891: 0x4000, - 0x1892: 0x4000, 0x1893: 0x4000, 0x1894: 0x4000, 0x1895: 0x4000, 0x1896: 0x4000, 0x1897: 0x4000, - 0x1898: 0x4000, 0x1899: 0x4000, 0x189a: 0x4000, 0x189b: 0x4000, 0x189c: 0x4000, 0x189d: 0x4000, - 0x189e: 0x4000, 0x189f: 0x4000, 0x18a0: 0x4000, 0x18a1: 0x4000, 0x18a2: 0x4000, - 0x18b0: 0x4000, 0x18b1: 0x4000, 0x18b2: 0x4000, 0x18b3: 0x4000, 0x18b4: 0x4000, 0x18b5: 0x4000, - 0x18b6: 0x4000, 0x18b7: 0x4000, 0x18b8: 0x4000, 0x18b9: 0x4000, - // Block 0x63, offset 0x18c0 - 0x18c0: 0x4000, 0x18c1: 0x4000, 0x18c2: 0x4000, - 0x18d0: 0x4000, 0x18d1: 0x4000, - 0x18d2: 0x4000, 0x18d3: 0x4000, 0x18d4: 0x4000, 0x18d5: 0x4000, 0x18d6: 0x4000, 0x18d7: 0x4000, - 0x18d8: 0x4000, 0x18d9: 0x4000, 0x18da: 0x4000, 0x18db: 0x4000, 0x18dc: 0x4000, 0x18dd: 0x4000, - 0x18de: 0x4000, 0x18df: 0x4000, 0x18e0: 0x4000, 0x18e1: 0x4000, 0x18e2: 0x4000, 0x18e3: 0x4000, - 0x18e4: 0x4000, 0x18e5: 0x4000, 0x18e6: 0x4000, 0x18e7: 0x4000, 0x18e8: 0x4000, 0x18e9: 0x4000, - 0x18ea: 0x4000, 0x18eb: 0x4000, 0x18ec: 0x4000, 0x18ed: 0x4000, 0x18ee: 0x4000, 0x18ef: 0x4000, - 0x18f0: 0x4000, 0x18f1: 0x4000, 0x18f2: 0x4000, 0x18f3: 0x4000, 0x18f4: 0x4000, 0x18f5: 0x4000, - 0x18f6: 0x4000, 0x18f7: 0x4000, 0x18f8: 0x4000, 0x18f9: 0x4000, 0x18fa: 0x4000, 0x18fb: 0x4000, - 0x18fc: 0x4000, 0x18fd: 0x4000, 0x18fe: 0x4000, 0x18ff: 0x4000, - // Block 0x64, offset 0x1900 - 0x1900: 0x2000, 0x1901: 0x2000, 0x1902: 0x2000, 0x1903: 0x2000, 0x1904: 0x2000, 0x1905: 0x2000, - 0x1906: 0x2000, 0x1907: 0x2000, 0x1908: 0x2000, 0x1909: 0x2000, 0x190a: 0x2000, 0x190b: 0x2000, - 0x190c: 0x2000, 0x190d: 0x2000, 0x190e: 0x2000, 0x190f: 0x2000, 0x1910: 0x2000, 0x1911: 0x2000, - 0x1912: 0x2000, 0x1913: 0x2000, 0x1914: 0x2000, 0x1915: 0x2000, 0x1916: 0x2000, 0x1917: 0x2000, - 0x1918: 0x2000, 0x1919: 0x2000, 0x191a: 0x2000, 0x191b: 0x2000, 0x191c: 0x2000, 0x191d: 0x2000, - 0x191e: 0x2000, 0x191f: 0x2000, 0x1920: 0x2000, 0x1921: 0x2000, 0x1922: 0x2000, 0x1923: 0x2000, - 0x1924: 0x2000, 0x1925: 0x2000, 0x1926: 0x2000, 0x1927: 0x2000, 0x1928: 0x2000, 0x1929: 0x2000, - 0x192a: 0x2000, 0x192b: 0x2000, 0x192c: 0x2000, 0x192d: 0x2000, 0x192e: 0x2000, 0x192f: 0x2000, - 0x1930: 0x2000, 0x1931: 0x2000, 0x1932: 0x2000, 0x1933: 0x2000, 0x1934: 0x2000, 0x1935: 0x2000, - 0x1936: 0x2000, 0x1937: 0x2000, 0x1938: 0x2000, 0x1939: 0x2000, 0x193a: 0x2000, 0x193b: 0x2000, - 0x193c: 0x2000, 0x193d: 0x2000, -} - -// widthIndex: 22 blocks, 1408 entries, 1408 bytes -// Block 0 is the zero block. -var widthIndex = [1408]uint8{ - // Block 0x0, offset 0x0 - // Block 0x1, offset 0x40 - // Block 0x2, offset 0x80 - // Block 0x3, offset 0xc0 - 0xc2: 0x01, 0xc3: 0x02, 0xc4: 0x03, 0xc5: 0x04, 0xc7: 0x05, - 0xc9: 0x06, 0xcb: 0x07, 0xcc: 0x08, 0xcd: 0x09, 0xce: 0x0a, 0xcf: 0x0b, - 0xd0: 0x0c, 0xd1: 0x0d, - 0xe1: 0x02, 0xe2: 0x03, 0xe3: 0x04, 0xe4: 0x05, 0xe5: 0x06, 0xe6: 0x06, 0xe7: 0x06, - 0xe8: 0x06, 0xe9: 0x06, 0xea: 0x07, 0xeb: 0x06, 0xec: 0x06, 0xed: 0x08, 0xee: 0x09, 0xef: 0x0a, - 0xf0: 0x0f, 0xf3: 0x12, 0xf4: 0x13, - // Block 0x4, offset 0x100 - 0x104: 0x0e, 0x105: 0x0f, - // Block 0x5, offset 0x140 - 0x140: 0x10, 0x141: 0x11, 0x142: 0x12, 0x144: 0x13, 0x145: 0x14, 0x146: 0x15, 0x147: 0x16, - 0x148: 0x17, 0x149: 0x18, 0x14a: 0x19, 0x14c: 0x1a, 0x14f: 0x1b, - 0x151: 0x1c, 0x152: 0x08, 0x153: 0x1d, 0x154: 0x1e, 0x155: 0x1f, 0x156: 0x20, 0x157: 0x21, - 0x158: 0x22, 0x159: 0x23, 0x15a: 0x24, 0x15b: 0x25, 0x15c: 0x26, 0x15d: 0x27, 0x15e: 0x28, 0x15f: 0x29, - 0x166: 0x2a, - 0x16c: 0x2b, 0x16d: 0x2c, - 0x17a: 0x2d, 0x17b: 0x2e, 0x17c: 0x0e, 0x17d: 0x0e, 0x17e: 0x0e, 0x17f: 0x2f, - // Block 0x6, offset 0x180 - 0x180: 0x30, 0x181: 0x31, 0x182: 0x32, 0x183: 0x33, 0x184: 0x34, 0x185: 0x35, 0x186: 0x36, 0x187: 0x37, - 0x188: 0x38, 0x189: 0x39, 0x18a: 0x0e, 0x18b: 0x3a, 0x18c: 0x0e, 0x18d: 0x0e, 0x18e: 0x0e, 0x18f: 0x0e, - 0x190: 0x0e, 0x191: 0x0e, 0x192: 0x0e, 0x193: 0x0e, 0x194: 0x0e, 0x195: 0x0e, 0x196: 0x0e, 0x197: 0x0e, - 0x198: 0x0e, 0x199: 0x0e, 0x19a: 0x0e, 0x19b: 0x0e, 0x19c: 0x0e, 0x19d: 0x0e, 0x19e: 0x0e, 0x19f: 0x0e, - 0x1a0: 0x0e, 0x1a1: 0x0e, 0x1a2: 0x0e, 0x1a3: 0x0e, 0x1a4: 0x0e, 0x1a5: 0x0e, 0x1a6: 0x0e, 0x1a7: 0x0e, - 0x1a8: 0x0e, 0x1a9: 0x0e, 0x1aa: 0x0e, 0x1ab: 0x0e, 0x1ac: 0x0e, 0x1ad: 0x0e, 0x1ae: 0x0e, 0x1af: 0x0e, - 0x1b0: 0x0e, 0x1b1: 0x0e, 0x1b2: 0x0e, 0x1b3: 0x0e, 0x1b4: 0x0e, 0x1b5: 0x0e, 0x1b6: 0x0e, 0x1b7: 0x0e, - 0x1b8: 0x0e, 0x1b9: 0x0e, 0x1ba: 0x0e, 0x1bb: 0x0e, 0x1bc: 0x0e, 0x1bd: 0x0e, 0x1be: 0x0e, 0x1bf: 0x0e, - // Block 0x7, offset 0x1c0 - 0x1c0: 0x0e, 0x1c1: 0x0e, 0x1c2: 0x0e, 0x1c3: 0x0e, 0x1c4: 0x0e, 0x1c5: 0x0e, 0x1c6: 0x0e, 0x1c7: 0x0e, - 0x1c8: 0x0e, 0x1c9: 0x0e, 0x1ca: 0x0e, 0x1cb: 0x0e, 0x1cc: 0x0e, 0x1cd: 0x0e, 0x1ce: 0x0e, 0x1cf: 0x0e, - 0x1d0: 0x0e, 0x1d1: 0x0e, 0x1d2: 0x0e, 0x1d3: 0x0e, 0x1d4: 0x0e, 0x1d5: 0x0e, 0x1d6: 0x0e, 0x1d7: 0x0e, - 0x1d8: 0x0e, 0x1d9: 0x0e, 0x1da: 0x0e, 0x1db: 0x0e, 0x1dc: 0x0e, 0x1dd: 0x0e, 0x1de: 0x0e, 0x1df: 0x0e, - 0x1e0: 0x0e, 0x1e1: 0x0e, 0x1e2: 0x0e, 0x1e3: 0x0e, 0x1e4: 0x0e, 0x1e5: 0x0e, 0x1e6: 0x0e, 0x1e7: 0x0e, - 0x1e8: 0x0e, 0x1e9: 0x0e, 0x1ea: 0x0e, 0x1eb: 0x0e, 0x1ec: 0x0e, 0x1ed: 0x0e, 0x1ee: 0x0e, 0x1ef: 0x0e, - 0x1f0: 0x0e, 0x1f1: 0x0e, 0x1f2: 0x0e, 0x1f3: 0x0e, 0x1f4: 0x0e, 0x1f5: 0x0e, 0x1f6: 0x0e, - 0x1f8: 0x0e, 0x1f9: 0x0e, 0x1fa: 0x0e, 0x1fb: 0x0e, 0x1fc: 0x0e, 0x1fd: 0x0e, 0x1fe: 0x0e, 0x1ff: 0x0e, - // Block 0x8, offset 0x200 - 0x200: 0x0e, 0x201: 0x0e, 0x202: 0x0e, 0x203: 0x0e, 0x204: 0x0e, 0x205: 0x0e, 0x206: 0x0e, 0x207: 0x0e, - 0x208: 0x0e, 0x209: 0x0e, 0x20a: 0x0e, 0x20b: 0x0e, 0x20c: 0x0e, 0x20d: 0x0e, 0x20e: 0x0e, 0x20f: 0x0e, - 0x210: 0x0e, 0x211: 0x0e, 0x212: 0x0e, 0x213: 0x0e, 0x214: 0x0e, 0x215: 0x0e, 0x216: 0x0e, 0x217: 0x0e, - 0x218: 0x0e, 0x219: 0x0e, 0x21a: 0x0e, 0x21b: 0x0e, 0x21c: 0x0e, 0x21d: 0x0e, 0x21e: 0x0e, 0x21f: 0x0e, - 0x220: 0x0e, 0x221: 0x0e, 0x222: 0x0e, 0x223: 0x0e, 0x224: 0x0e, 0x225: 0x0e, 0x226: 0x0e, 0x227: 0x0e, - 0x228: 0x0e, 0x229: 0x0e, 0x22a: 0x0e, 0x22b: 0x0e, 0x22c: 0x0e, 0x22d: 0x0e, 0x22e: 0x0e, 0x22f: 0x0e, - 0x230: 0x0e, 0x231: 0x0e, 0x232: 0x0e, 0x233: 0x0e, 0x234: 0x0e, 0x235: 0x0e, 0x236: 0x0e, 0x237: 0x0e, - 0x238: 0x0e, 0x239: 0x0e, 0x23a: 0x0e, 0x23b: 0x0e, 0x23c: 0x0e, 0x23d: 0x0e, 0x23e: 0x0e, 0x23f: 0x0e, - // Block 0x9, offset 0x240 - 0x240: 0x0e, 0x241: 0x0e, 0x242: 0x0e, 0x243: 0x0e, 0x244: 0x0e, 0x245: 0x0e, 0x246: 0x0e, 0x247: 0x0e, - 0x248: 0x0e, 0x249: 0x0e, 0x24a: 0x0e, 0x24b: 0x0e, 0x24c: 0x0e, 0x24d: 0x0e, 0x24e: 0x0e, 0x24f: 0x0e, - 0x250: 0x0e, 0x251: 0x0e, 0x252: 0x3b, 0x253: 0x3c, - 0x265: 0x3d, - 0x270: 0x0e, 0x271: 0x0e, 0x272: 0x0e, 0x273: 0x0e, 0x274: 0x0e, 0x275: 0x0e, 0x276: 0x0e, 0x277: 0x0e, - 0x278: 0x0e, 0x279: 0x0e, 0x27a: 0x0e, 0x27b: 0x0e, 0x27c: 0x0e, 0x27d: 0x0e, 0x27e: 0x0e, 0x27f: 0x0e, - // Block 0xa, offset 0x280 - 0x280: 0x0e, 0x281: 0x0e, 0x282: 0x0e, 0x283: 0x0e, 0x284: 0x0e, 0x285: 0x0e, 0x286: 0x0e, 0x287: 0x0e, - 0x288: 0x0e, 0x289: 0x0e, 0x28a: 0x0e, 0x28b: 0x0e, 0x28c: 0x0e, 0x28d: 0x0e, 0x28e: 0x0e, 0x28f: 0x0e, - 0x290: 0x0e, 0x291: 0x0e, 0x292: 0x0e, 0x293: 0x0e, 0x294: 0x0e, 0x295: 0x0e, 0x296: 0x0e, 0x297: 0x0e, - 0x298: 0x0e, 0x299: 0x0e, 0x29a: 0x0e, 0x29b: 0x0e, 0x29c: 0x0e, 0x29d: 0x0e, 0x29e: 0x3e, - // Block 0xb, offset 0x2c0 - 0x2c0: 0x08, 0x2c1: 0x08, 0x2c2: 0x08, 0x2c3: 0x08, 0x2c4: 0x08, 0x2c5: 0x08, 0x2c6: 0x08, 0x2c7: 0x08, - 0x2c8: 0x08, 0x2c9: 0x08, 0x2ca: 0x08, 0x2cb: 0x08, 0x2cc: 0x08, 0x2cd: 0x08, 0x2ce: 0x08, 0x2cf: 0x08, - 0x2d0: 0x08, 0x2d1: 0x08, 0x2d2: 0x08, 0x2d3: 0x08, 0x2d4: 0x08, 0x2d5: 0x08, 0x2d6: 0x08, 0x2d7: 0x08, - 0x2d8: 0x08, 0x2d9: 0x08, 0x2da: 0x08, 0x2db: 0x08, 0x2dc: 0x08, 0x2dd: 0x08, 0x2de: 0x08, 0x2df: 0x08, - 0x2e0: 0x08, 0x2e1: 0x08, 0x2e2: 0x08, 0x2e3: 0x08, 0x2e4: 0x08, 0x2e5: 0x08, 0x2e6: 0x08, 0x2e7: 0x08, - 0x2e8: 0x08, 0x2e9: 0x08, 0x2ea: 0x08, 0x2eb: 0x08, 0x2ec: 0x08, 0x2ed: 0x08, 0x2ee: 0x08, 0x2ef: 0x08, - 0x2f0: 0x08, 0x2f1: 0x08, 0x2f2: 0x08, 0x2f3: 0x08, 0x2f4: 0x08, 0x2f5: 0x08, 0x2f6: 0x08, 0x2f7: 0x08, - 0x2f8: 0x08, 0x2f9: 0x08, 0x2fa: 0x08, 0x2fb: 0x08, 0x2fc: 0x08, 0x2fd: 0x08, 0x2fe: 0x08, 0x2ff: 0x08, - // Block 0xc, offset 0x300 - 0x300: 0x08, 0x301: 0x08, 0x302: 0x08, 0x303: 0x08, 0x304: 0x08, 0x305: 0x08, 0x306: 0x08, 0x307: 0x08, - 0x308: 0x08, 0x309: 0x08, 0x30a: 0x08, 0x30b: 0x08, 0x30c: 0x08, 0x30d: 0x08, 0x30e: 0x08, 0x30f: 0x08, - 0x310: 0x08, 0x311: 0x08, 0x312: 0x08, 0x313: 0x08, 0x314: 0x08, 0x315: 0x08, 0x316: 0x08, 0x317: 0x08, - 0x318: 0x08, 0x319: 0x08, 0x31a: 0x08, 0x31b: 0x08, 0x31c: 0x08, 0x31d: 0x08, 0x31e: 0x08, 0x31f: 0x08, - 0x320: 0x08, 0x321: 0x08, 0x322: 0x08, 0x323: 0x08, 0x324: 0x0e, 0x325: 0x0e, 0x326: 0x0e, 0x327: 0x0e, - 0x328: 0x0e, 0x329: 0x0e, 0x32a: 0x0e, 0x32b: 0x0e, - 0x338: 0x3f, 0x339: 0x40, 0x33c: 0x41, 0x33d: 0x42, 0x33e: 0x43, 0x33f: 0x44, - // Block 0xd, offset 0x340 - 0x37f: 0x45, - // Block 0xe, offset 0x380 - 0x380: 0x0e, 0x381: 0x0e, 0x382: 0x0e, 0x383: 0x0e, 0x384: 0x0e, 0x385: 0x0e, 0x386: 0x0e, 0x387: 0x0e, - 0x388: 0x0e, 0x389: 0x0e, 0x38a: 0x0e, 0x38b: 0x0e, 0x38c: 0x0e, 0x38d: 0x0e, 0x38e: 0x0e, 0x38f: 0x0e, - 0x390: 0x0e, 0x391: 0x0e, 0x392: 0x0e, 0x393: 0x0e, 0x394: 0x0e, 0x395: 0x0e, 0x396: 0x0e, 0x397: 0x0e, - 0x398: 0x0e, 0x399: 0x0e, 0x39a: 0x0e, 0x39b: 0x0e, 0x39c: 0x0e, 0x39d: 0x0e, 0x39e: 0x0e, 0x39f: 0x46, - 0x3a0: 0x0e, 0x3a1: 0x0e, 0x3a2: 0x0e, 0x3a3: 0x0e, 0x3a4: 0x0e, 0x3a5: 0x0e, 0x3a6: 0x0e, 0x3a7: 0x0e, - 0x3a8: 0x0e, 0x3a9: 0x0e, 0x3aa: 0x0e, 0x3ab: 0x47, - // Block 0xf, offset 0x3c0 - 0x3c0: 0x0e, 0x3c1: 0x0e, 0x3c2: 0x0e, 0x3c3: 0x0e, 0x3c4: 0x48, 0x3c5: 0x49, 0x3c6: 0x0e, 0x3c7: 0x0e, - 0x3c8: 0x0e, 0x3c9: 0x0e, 0x3ca: 0x0e, 0x3cb: 0x4a, - // Block 0x10, offset 0x400 - 0x400: 0x4b, 0x403: 0x4c, 0x404: 0x4d, 0x405: 0x4e, 0x406: 0x4f, - 0x408: 0x50, 0x409: 0x51, 0x40c: 0x52, 0x40d: 0x53, 0x40e: 0x54, 0x40f: 0x55, - 0x410: 0x3a, 0x411: 0x56, 0x412: 0x0e, 0x413: 0x57, 0x414: 0x58, 0x415: 0x59, 0x416: 0x5a, 0x417: 0x5b, - 0x418: 0x0e, 0x419: 0x5c, 0x41a: 0x0e, 0x41b: 0x5d, - 0x424: 0x5e, 0x425: 0x5f, 0x426: 0x60, 0x427: 0x61, - // Block 0x11, offset 0x440 - 0x456: 0x0b, 0x457: 0x06, - 0x458: 0x0c, 0x45b: 0x0d, 0x45f: 0x0e, - 0x460: 0x06, 0x461: 0x06, 0x462: 0x06, 0x463: 0x06, 0x464: 0x06, 0x465: 0x06, 0x466: 0x06, 0x467: 0x06, - 0x468: 0x06, 0x469: 0x06, 0x46a: 0x06, 0x46b: 0x06, 0x46c: 0x06, 0x46d: 0x06, 0x46e: 0x06, 0x46f: 0x06, - 0x470: 0x06, 0x471: 0x06, 0x472: 0x06, 0x473: 0x06, 0x474: 0x06, 0x475: 0x06, 0x476: 0x06, 0x477: 0x06, - 0x478: 0x06, 0x479: 0x06, 0x47a: 0x06, 0x47b: 0x06, 0x47c: 0x06, 0x47d: 0x06, 0x47e: 0x06, 0x47f: 0x06, - // Block 0x12, offset 0x480 - 0x484: 0x08, 0x485: 0x08, 0x486: 0x08, 0x487: 0x09, - // Block 0x13, offset 0x4c0 - 0x4c0: 0x08, 0x4c1: 0x08, 0x4c2: 0x08, 0x4c3: 0x08, 0x4c4: 0x08, 0x4c5: 0x08, 0x4c6: 0x08, 0x4c7: 0x08, - 0x4c8: 0x08, 0x4c9: 0x08, 0x4ca: 0x08, 0x4cb: 0x08, 0x4cc: 0x08, 0x4cd: 0x08, 0x4ce: 0x08, 0x4cf: 0x08, - 0x4d0: 0x08, 0x4d1: 0x08, 0x4d2: 0x08, 0x4d3: 0x08, 0x4d4: 0x08, 0x4d5: 0x08, 0x4d6: 0x08, 0x4d7: 0x08, - 0x4d8: 0x08, 0x4d9: 0x08, 0x4da: 0x08, 0x4db: 0x08, 0x4dc: 0x08, 0x4dd: 0x08, 0x4de: 0x08, 0x4df: 0x08, - 0x4e0: 0x08, 0x4e1: 0x08, 0x4e2: 0x08, 0x4e3: 0x08, 0x4e4: 0x08, 0x4e5: 0x08, 0x4e6: 0x08, 0x4e7: 0x08, - 0x4e8: 0x08, 0x4e9: 0x08, 0x4ea: 0x08, 0x4eb: 0x08, 0x4ec: 0x08, 0x4ed: 0x08, 0x4ee: 0x08, 0x4ef: 0x08, - 0x4f0: 0x08, 0x4f1: 0x08, 0x4f2: 0x08, 0x4f3: 0x08, 0x4f4: 0x08, 0x4f5: 0x08, 0x4f6: 0x08, 0x4f7: 0x08, - 0x4f8: 0x08, 0x4f9: 0x08, 0x4fa: 0x08, 0x4fb: 0x08, 0x4fc: 0x08, 0x4fd: 0x08, 0x4fe: 0x08, 0x4ff: 0x62, - // Block 0x14, offset 0x500 - 0x520: 0x10, - 0x530: 0x09, 0x531: 0x09, 0x532: 0x09, 0x533: 0x09, 0x534: 0x09, 0x535: 0x09, 0x536: 0x09, 0x537: 0x09, - 0x538: 0x09, 0x539: 0x09, 0x53a: 0x09, 0x53b: 0x09, 0x53c: 0x09, 0x53d: 0x09, 0x53e: 0x09, 0x53f: 0x11, - // Block 0x15, offset 0x540 - 0x540: 0x09, 0x541: 0x09, 0x542: 0x09, 0x543: 0x09, 0x544: 0x09, 0x545: 0x09, 0x546: 0x09, 0x547: 0x09, - 0x548: 0x09, 0x549: 0x09, 0x54a: 0x09, 0x54b: 0x09, 0x54c: 0x09, 0x54d: 0x09, 0x54e: 0x09, 0x54f: 0x11, -} - -// inverseData contains 4-byte entries of the following format: -// -// <0 padding> -// -// The last byte of the UTF-8-encoded rune is xor-ed with the last byte of the -// UTF-8 encoding of the original rune. Mappings often have the following -// pattern: -// -// A -> A (U+FF21 -> U+0041) -// B -> B (U+FF22 -> U+0042) -// ... -// -// By xor-ing the last byte the same entry can be shared by many mappings. This -// reduces the total number of distinct entries by about two thirds. -// The resulting entry for the aforementioned mappings is -// -// { 0x01, 0xE0, 0x00, 0x00 } -// -// Using this entry to map U+FF21 (UTF-8 [EF BC A1]), we get -// -// E0 ^ A1 = 41. -// -// Similarly, for U+FF22 (UTF-8 [EF BC A2]), we get -// -// E0 ^ A2 = 42. -// -// Note that because of the xor-ing, the byte sequence stored in the entry is -// not valid UTF-8. -var inverseData = [150][4]byte{ - {0x00, 0x00, 0x00, 0x00}, - {0x03, 0xe3, 0x80, 0xa0}, - {0x03, 0xef, 0xbc, 0xa0}, - {0x03, 0xef, 0xbc, 0xe0}, - {0x03, 0xef, 0xbd, 0xe0}, - {0x03, 0xef, 0xbf, 0x02}, - {0x03, 0xef, 0xbf, 0x00}, - {0x03, 0xef, 0xbf, 0x0e}, - {0x03, 0xef, 0xbf, 0x0c}, - {0x03, 0xef, 0xbf, 0x0f}, - {0x03, 0xef, 0xbf, 0x39}, - {0x03, 0xef, 0xbf, 0x3b}, - {0x03, 0xef, 0xbf, 0x3f}, - {0x03, 0xef, 0xbf, 0x2a}, - {0x03, 0xef, 0xbf, 0x0d}, - {0x03, 0xef, 0xbf, 0x25}, - {0x03, 0xef, 0xbd, 0x1a}, - {0x03, 0xef, 0xbd, 0x26}, - {0x01, 0xa0, 0x00, 0x00}, - {0x03, 0xef, 0xbd, 0x25}, - {0x03, 0xef, 0xbd, 0x23}, - {0x03, 0xef, 0xbd, 0x2e}, - {0x03, 0xef, 0xbe, 0x07}, - {0x03, 0xef, 0xbe, 0x05}, - {0x03, 0xef, 0xbd, 0x06}, - {0x03, 0xef, 0xbd, 0x13}, - {0x03, 0xef, 0xbd, 0x0b}, - {0x03, 0xef, 0xbd, 0x16}, - {0x03, 0xef, 0xbd, 0x0c}, - {0x03, 0xef, 0xbd, 0x15}, - {0x03, 0xef, 0xbd, 0x0d}, - {0x03, 0xef, 0xbd, 0x1c}, - {0x03, 0xef, 0xbd, 0x02}, - {0x03, 0xef, 0xbd, 0x1f}, - {0x03, 0xef, 0xbd, 0x1d}, - {0x03, 0xef, 0xbd, 0x17}, - {0x03, 0xef, 0xbd, 0x08}, - {0x03, 0xef, 0xbd, 0x09}, - {0x03, 0xef, 0xbd, 0x0e}, - {0x03, 0xef, 0xbd, 0x04}, - {0x03, 0xef, 0xbd, 0x05}, - {0x03, 0xef, 0xbe, 0x3f}, - {0x03, 0xef, 0xbe, 0x00}, - {0x03, 0xef, 0xbd, 0x2c}, - {0x03, 0xef, 0xbe, 0x06}, - {0x03, 0xef, 0xbe, 0x0c}, - {0x03, 0xef, 0xbe, 0x0f}, - {0x03, 0xef, 0xbe, 0x0d}, - {0x03, 0xef, 0xbe, 0x0b}, - {0x03, 0xef, 0xbe, 0x19}, - {0x03, 0xef, 0xbe, 0x15}, - {0x03, 0xef, 0xbe, 0x11}, - {0x03, 0xef, 0xbe, 0x31}, - {0x03, 0xef, 0xbe, 0x33}, - {0x03, 0xef, 0xbd, 0x0f}, - {0x03, 0xef, 0xbe, 0x30}, - {0x03, 0xef, 0xbe, 0x3e}, - {0x03, 0xef, 0xbe, 0x32}, - {0x03, 0xef, 0xbe, 0x36}, - {0x03, 0xef, 0xbd, 0x14}, - {0x03, 0xef, 0xbe, 0x2e}, - {0x03, 0xef, 0xbd, 0x1e}, - {0x03, 0xef, 0xbe, 0x10}, - {0x03, 0xef, 0xbf, 0x13}, - {0x03, 0xef, 0xbf, 0x15}, - {0x03, 0xef, 0xbf, 0x17}, - {0x03, 0xef, 0xbf, 0x1f}, - {0x03, 0xef, 0xbf, 0x1d}, - {0x03, 0xef, 0xbf, 0x1b}, - {0x03, 0xef, 0xbf, 0x09}, - {0x03, 0xef, 0xbf, 0x0b}, - {0x03, 0xef, 0xbf, 0x37}, - {0x03, 0xef, 0xbe, 0x04}, - {0x01, 0xe0, 0x00, 0x00}, - {0x03, 0xe2, 0xa6, 0x1a}, - {0x03, 0xe2, 0xa6, 0x26}, - {0x03, 0xe3, 0x80, 0x23}, - {0x03, 0xe3, 0x80, 0x2e}, - {0x03, 0xe3, 0x80, 0x25}, - {0x03, 0xe3, 0x83, 0x1e}, - {0x03, 0xe3, 0x83, 0x14}, - {0x03, 0xe3, 0x82, 0x06}, - {0x03, 0xe3, 0x82, 0x0b}, - {0x03, 0xe3, 0x82, 0x0c}, - {0x03, 0xe3, 0x82, 0x0d}, - {0x03, 0xe3, 0x82, 0x02}, - {0x03, 0xe3, 0x83, 0x0f}, - {0x03, 0xe3, 0x83, 0x08}, - {0x03, 0xe3, 0x83, 0x09}, - {0x03, 0xe3, 0x83, 0x2c}, - {0x03, 0xe3, 0x83, 0x0c}, - {0x03, 0xe3, 0x82, 0x13}, - {0x03, 0xe3, 0x82, 0x16}, - {0x03, 0xe3, 0x82, 0x15}, - {0x03, 0xe3, 0x82, 0x1c}, - {0x03, 0xe3, 0x82, 0x1f}, - {0x03, 0xe3, 0x82, 0x1d}, - {0x03, 0xe3, 0x82, 0x1a}, - {0x03, 0xe3, 0x82, 0x17}, - {0x03, 0xe3, 0x82, 0x08}, - {0x03, 0xe3, 0x82, 0x09}, - {0x03, 0xe3, 0x82, 0x0e}, - {0x03, 0xe3, 0x82, 0x04}, - {0x03, 0xe3, 0x82, 0x05}, - {0x03, 0xe3, 0x82, 0x3f}, - {0x03, 0xe3, 0x83, 0x00}, - {0x03, 0xe3, 0x83, 0x06}, - {0x03, 0xe3, 0x83, 0x05}, - {0x03, 0xe3, 0x83, 0x0d}, - {0x03, 0xe3, 0x83, 0x0b}, - {0x03, 0xe3, 0x83, 0x07}, - {0x03, 0xe3, 0x83, 0x19}, - {0x03, 0xe3, 0x83, 0x15}, - {0x03, 0xe3, 0x83, 0x11}, - {0x03, 0xe3, 0x83, 0x31}, - {0x03, 0xe3, 0x83, 0x33}, - {0x03, 0xe3, 0x83, 0x30}, - {0x03, 0xe3, 0x83, 0x3e}, - {0x03, 0xe3, 0x83, 0x32}, - {0x03, 0xe3, 0x83, 0x36}, - {0x03, 0xe3, 0x83, 0x2e}, - {0x03, 0xe3, 0x82, 0x07}, - {0x03, 0xe3, 0x85, 0x04}, - {0x03, 0xe3, 0x84, 0x10}, - {0x03, 0xe3, 0x85, 0x30}, - {0x03, 0xe3, 0x85, 0x0d}, - {0x03, 0xe3, 0x85, 0x13}, - {0x03, 0xe3, 0x85, 0x15}, - {0x03, 0xe3, 0x85, 0x17}, - {0x03, 0xe3, 0x85, 0x1f}, - {0x03, 0xe3, 0x85, 0x1d}, - {0x03, 0xe3, 0x85, 0x1b}, - {0x03, 0xe3, 0x85, 0x09}, - {0x03, 0xe3, 0x85, 0x0f}, - {0x03, 0xe3, 0x85, 0x0b}, - {0x03, 0xe3, 0x85, 0x37}, - {0x03, 0xe3, 0x85, 0x3b}, - {0x03, 0xe3, 0x85, 0x39}, - {0x03, 0xe3, 0x85, 0x3f}, - {0x02, 0xc2, 0x02, 0x00}, - {0x02, 0xc2, 0x0e, 0x00}, - {0x02, 0xc2, 0x0c, 0x00}, - {0x02, 0xc2, 0x00, 0x00}, - {0x03, 0xe2, 0x82, 0x0f}, - {0x03, 0xe2, 0x94, 0x2a}, - {0x03, 0xe2, 0x86, 0x39}, - {0x03, 0xe2, 0x86, 0x3b}, - {0x03, 0xe2, 0x86, 0x3f}, - {0x03, 0xe2, 0x96, 0x0d}, - {0x03, 0xe2, 0x97, 0x25}, -} - -// Total table size 14936 bytes (14KiB) diff --git a/vendor/golang.org/x/text/width/tables12.0.0.go b/vendor/golang.org/x/text/width/tables12.0.0.go deleted file mode 100644 index 755ee9122..000000000 --- a/vendor/golang.org/x/text/width/tables12.0.0.go +++ /dev/null @@ -1,1360 +0,0 @@ -// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. - -//go:build go1.14 && !go1.16 - -package width - -// UnicodeVersion is the Unicode version from which the tables in this package are derived. -const UnicodeVersion = "12.0.0" - -// lookup returns the trie value for the first UTF-8 encoding in s and -// the width in bytes of this encoding. The size will be 0 if s does not -// hold enough bytes to complete the encoding. len(s) must be greater than 0. -func (t *widthTrie) lookup(s []byte) (v uint16, sz int) { - c0 := s[0] - switch { - case c0 < 0x80: // is ASCII - return widthValues[c0], 1 - case c0 < 0xC2: - return 0, 1 // Illegal UTF-8: not a starter, not ASCII. - case c0 < 0xE0: // 2-byte UTF-8 - if len(s) < 2 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c1), 2 - case c0 < 0xF0: // 3-byte UTF-8 - if len(s) < 3 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c2), 3 - case c0 < 0xF8: // 4-byte UTF-8 - if len(s) < 4 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - o = uint32(i)<<6 + uint32(c2) - i = widthIndex[o] - c3 := s[3] - if c3 < 0x80 || 0xC0 <= c3 { - return 0, 3 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c3), 4 - } - // Illegal rune - return 0, 1 -} - -// lookupUnsafe returns the trie value for the first UTF-8 encoding in s. -// s must start with a full and valid UTF-8 encoded rune. -func (t *widthTrie) lookupUnsafe(s []byte) uint16 { - c0 := s[0] - if c0 < 0x80 { // is ASCII - return widthValues[c0] - } - i := widthIndex[c0] - if c0 < 0xE0 { // 2-byte UTF-8 - return t.lookupValue(uint32(i), s[1]) - } - i = widthIndex[uint32(i)<<6+uint32(s[1])] - if c0 < 0xF0 { // 3-byte UTF-8 - return t.lookupValue(uint32(i), s[2]) - } - i = widthIndex[uint32(i)<<6+uint32(s[2])] - if c0 < 0xF8 { // 4-byte UTF-8 - return t.lookupValue(uint32(i), s[3]) - } - return 0 -} - -// lookupString returns the trie value for the first UTF-8 encoding in s and -// the width in bytes of this encoding. The size will be 0 if s does not -// hold enough bytes to complete the encoding. len(s) must be greater than 0. -func (t *widthTrie) lookupString(s string) (v uint16, sz int) { - c0 := s[0] - switch { - case c0 < 0x80: // is ASCII - return widthValues[c0], 1 - case c0 < 0xC2: - return 0, 1 // Illegal UTF-8: not a starter, not ASCII. - case c0 < 0xE0: // 2-byte UTF-8 - if len(s) < 2 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c1), 2 - case c0 < 0xF0: // 3-byte UTF-8 - if len(s) < 3 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c2), 3 - case c0 < 0xF8: // 4-byte UTF-8 - if len(s) < 4 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - o = uint32(i)<<6 + uint32(c2) - i = widthIndex[o] - c3 := s[3] - if c3 < 0x80 || 0xC0 <= c3 { - return 0, 3 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c3), 4 - } - // Illegal rune - return 0, 1 -} - -// lookupStringUnsafe returns the trie value for the first UTF-8 encoding in s. -// s must start with a full and valid UTF-8 encoded rune. -func (t *widthTrie) lookupStringUnsafe(s string) uint16 { - c0 := s[0] - if c0 < 0x80 { // is ASCII - return widthValues[c0] - } - i := widthIndex[c0] - if c0 < 0xE0 { // 2-byte UTF-8 - return t.lookupValue(uint32(i), s[1]) - } - i = widthIndex[uint32(i)<<6+uint32(s[1])] - if c0 < 0xF0 { // 3-byte UTF-8 - return t.lookupValue(uint32(i), s[2]) - } - i = widthIndex[uint32(i)<<6+uint32(s[2])] - if c0 < 0xF8 { // 4-byte UTF-8 - return t.lookupValue(uint32(i), s[3]) - } - return 0 -} - -// widthTrie. Total size: 14720 bytes (14.38 KiB). Checksum: 3f4f2516ded5489b. -type widthTrie struct{} - -func newWidthTrie(i int) *widthTrie { - return &widthTrie{} -} - -// lookupValue determines the type of block n and looks up the value for b. -func (t *widthTrie) lookupValue(n uint32, b byte) uint16 { - switch { - default: - return uint16(widthValues[n<<6+uint32(b)]) - } -} - -// widthValues: 104 blocks, 6656 entries, 13312 bytes -// The third block is the zero block. -var widthValues = [6656]uint16{ - // Block 0x0, offset 0x0 - 0x20: 0x6001, 0x21: 0x6002, 0x22: 0x6002, 0x23: 0x6002, - 0x24: 0x6002, 0x25: 0x6002, 0x26: 0x6002, 0x27: 0x6002, 0x28: 0x6002, 0x29: 0x6002, - 0x2a: 0x6002, 0x2b: 0x6002, 0x2c: 0x6002, 0x2d: 0x6002, 0x2e: 0x6002, 0x2f: 0x6002, - 0x30: 0x6002, 0x31: 0x6002, 0x32: 0x6002, 0x33: 0x6002, 0x34: 0x6002, 0x35: 0x6002, - 0x36: 0x6002, 0x37: 0x6002, 0x38: 0x6002, 0x39: 0x6002, 0x3a: 0x6002, 0x3b: 0x6002, - 0x3c: 0x6002, 0x3d: 0x6002, 0x3e: 0x6002, 0x3f: 0x6002, - // Block 0x1, offset 0x40 - 0x40: 0x6003, 0x41: 0x6003, 0x42: 0x6003, 0x43: 0x6003, 0x44: 0x6003, 0x45: 0x6003, - 0x46: 0x6003, 0x47: 0x6003, 0x48: 0x6003, 0x49: 0x6003, 0x4a: 0x6003, 0x4b: 0x6003, - 0x4c: 0x6003, 0x4d: 0x6003, 0x4e: 0x6003, 0x4f: 0x6003, 0x50: 0x6003, 0x51: 0x6003, - 0x52: 0x6003, 0x53: 0x6003, 0x54: 0x6003, 0x55: 0x6003, 0x56: 0x6003, 0x57: 0x6003, - 0x58: 0x6003, 0x59: 0x6003, 0x5a: 0x6003, 0x5b: 0x6003, 0x5c: 0x6003, 0x5d: 0x6003, - 0x5e: 0x6003, 0x5f: 0x6003, 0x60: 0x6004, 0x61: 0x6004, 0x62: 0x6004, 0x63: 0x6004, - 0x64: 0x6004, 0x65: 0x6004, 0x66: 0x6004, 0x67: 0x6004, 0x68: 0x6004, 0x69: 0x6004, - 0x6a: 0x6004, 0x6b: 0x6004, 0x6c: 0x6004, 0x6d: 0x6004, 0x6e: 0x6004, 0x6f: 0x6004, - 0x70: 0x6004, 0x71: 0x6004, 0x72: 0x6004, 0x73: 0x6004, 0x74: 0x6004, 0x75: 0x6004, - 0x76: 0x6004, 0x77: 0x6004, 0x78: 0x6004, 0x79: 0x6004, 0x7a: 0x6004, 0x7b: 0x6004, - 0x7c: 0x6004, 0x7d: 0x6004, 0x7e: 0x6004, - // Block 0x2, offset 0x80 - // Block 0x3, offset 0xc0 - 0xe1: 0x2000, 0xe2: 0x6005, 0xe3: 0x6005, - 0xe4: 0x2000, 0xe5: 0x6006, 0xe6: 0x6005, 0xe7: 0x2000, 0xe8: 0x2000, - 0xea: 0x2000, 0xec: 0x6007, 0xed: 0x2000, 0xee: 0x2000, 0xef: 0x6008, - 0xf0: 0x2000, 0xf1: 0x2000, 0xf2: 0x2000, 0xf3: 0x2000, 0xf4: 0x2000, - 0xf6: 0x2000, 0xf7: 0x2000, 0xf8: 0x2000, 0xf9: 0x2000, 0xfa: 0x2000, - 0xfc: 0x2000, 0xfd: 0x2000, 0xfe: 0x2000, 0xff: 0x2000, - // Block 0x4, offset 0x100 - 0x106: 0x2000, - 0x110: 0x2000, - 0x117: 0x2000, - 0x118: 0x2000, - 0x11e: 0x2000, 0x11f: 0x2000, 0x120: 0x2000, 0x121: 0x2000, - 0x126: 0x2000, 0x128: 0x2000, 0x129: 0x2000, - 0x12a: 0x2000, 0x12c: 0x2000, 0x12d: 0x2000, - 0x130: 0x2000, 0x132: 0x2000, 0x133: 0x2000, - 0x137: 0x2000, 0x138: 0x2000, 0x139: 0x2000, 0x13a: 0x2000, - 0x13c: 0x2000, 0x13e: 0x2000, - // Block 0x5, offset 0x140 - 0x141: 0x2000, - 0x151: 0x2000, - 0x153: 0x2000, - 0x15b: 0x2000, - 0x166: 0x2000, 0x167: 0x2000, - 0x16b: 0x2000, - 0x171: 0x2000, 0x172: 0x2000, 0x173: 0x2000, - 0x178: 0x2000, - 0x17f: 0x2000, - // Block 0x6, offset 0x180 - 0x180: 0x2000, 0x181: 0x2000, 0x182: 0x2000, 0x184: 0x2000, - 0x188: 0x2000, 0x189: 0x2000, 0x18a: 0x2000, 0x18b: 0x2000, - 0x18d: 0x2000, - 0x192: 0x2000, 0x193: 0x2000, - 0x1a6: 0x2000, 0x1a7: 0x2000, - 0x1ab: 0x2000, - // Block 0x7, offset 0x1c0 - 0x1ce: 0x2000, 0x1d0: 0x2000, - 0x1d2: 0x2000, 0x1d4: 0x2000, 0x1d6: 0x2000, - 0x1d8: 0x2000, 0x1da: 0x2000, 0x1dc: 0x2000, - // Block 0x8, offset 0x200 - 0x211: 0x2000, - 0x221: 0x2000, - // Block 0x9, offset 0x240 - 0x244: 0x2000, - 0x247: 0x2000, 0x249: 0x2000, 0x24a: 0x2000, 0x24b: 0x2000, - 0x24d: 0x2000, 0x250: 0x2000, - 0x258: 0x2000, 0x259: 0x2000, 0x25a: 0x2000, 0x25b: 0x2000, 0x25d: 0x2000, - 0x25f: 0x2000, - // Block 0xa, offset 0x280 - 0x280: 0x2000, 0x281: 0x2000, 0x282: 0x2000, 0x283: 0x2000, 0x284: 0x2000, 0x285: 0x2000, - 0x286: 0x2000, 0x287: 0x2000, 0x288: 0x2000, 0x289: 0x2000, 0x28a: 0x2000, 0x28b: 0x2000, - 0x28c: 0x2000, 0x28d: 0x2000, 0x28e: 0x2000, 0x28f: 0x2000, 0x290: 0x2000, 0x291: 0x2000, - 0x292: 0x2000, 0x293: 0x2000, 0x294: 0x2000, 0x295: 0x2000, 0x296: 0x2000, 0x297: 0x2000, - 0x298: 0x2000, 0x299: 0x2000, 0x29a: 0x2000, 0x29b: 0x2000, 0x29c: 0x2000, 0x29d: 0x2000, - 0x29e: 0x2000, 0x29f: 0x2000, 0x2a0: 0x2000, 0x2a1: 0x2000, 0x2a2: 0x2000, 0x2a3: 0x2000, - 0x2a4: 0x2000, 0x2a5: 0x2000, 0x2a6: 0x2000, 0x2a7: 0x2000, 0x2a8: 0x2000, 0x2a9: 0x2000, - 0x2aa: 0x2000, 0x2ab: 0x2000, 0x2ac: 0x2000, 0x2ad: 0x2000, 0x2ae: 0x2000, 0x2af: 0x2000, - 0x2b0: 0x2000, 0x2b1: 0x2000, 0x2b2: 0x2000, 0x2b3: 0x2000, 0x2b4: 0x2000, 0x2b5: 0x2000, - 0x2b6: 0x2000, 0x2b7: 0x2000, 0x2b8: 0x2000, 0x2b9: 0x2000, 0x2ba: 0x2000, 0x2bb: 0x2000, - 0x2bc: 0x2000, 0x2bd: 0x2000, 0x2be: 0x2000, 0x2bf: 0x2000, - // Block 0xb, offset 0x2c0 - 0x2c0: 0x2000, 0x2c1: 0x2000, 0x2c2: 0x2000, 0x2c3: 0x2000, 0x2c4: 0x2000, 0x2c5: 0x2000, - 0x2c6: 0x2000, 0x2c7: 0x2000, 0x2c8: 0x2000, 0x2c9: 0x2000, 0x2ca: 0x2000, 0x2cb: 0x2000, - 0x2cc: 0x2000, 0x2cd: 0x2000, 0x2ce: 0x2000, 0x2cf: 0x2000, 0x2d0: 0x2000, 0x2d1: 0x2000, - 0x2d2: 0x2000, 0x2d3: 0x2000, 0x2d4: 0x2000, 0x2d5: 0x2000, 0x2d6: 0x2000, 0x2d7: 0x2000, - 0x2d8: 0x2000, 0x2d9: 0x2000, 0x2da: 0x2000, 0x2db: 0x2000, 0x2dc: 0x2000, 0x2dd: 0x2000, - 0x2de: 0x2000, 0x2df: 0x2000, 0x2e0: 0x2000, 0x2e1: 0x2000, 0x2e2: 0x2000, 0x2e3: 0x2000, - 0x2e4: 0x2000, 0x2e5: 0x2000, 0x2e6: 0x2000, 0x2e7: 0x2000, 0x2e8: 0x2000, 0x2e9: 0x2000, - 0x2ea: 0x2000, 0x2eb: 0x2000, 0x2ec: 0x2000, 0x2ed: 0x2000, 0x2ee: 0x2000, 0x2ef: 0x2000, - // Block 0xc, offset 0x300 - 0x311: 0x2000, - 0x312: 0x2000, 0x313: 0x2000, 0x314: 0x2000, 0x315: 0x2000, 0x316: 0x2000, 0x317: 0x2000, - 0x318: 0x2000, 0x319: 0x2000, 0x31a: 0x2000, 0x31b: 0x2000, 0x31c: 0x2000, 0x31d: 0x2000, - 0x31e: 0x2000, 0x31f: 0x2000, 0x320: 0x2000, 0x321: 0x2000, 0x323: 0x2000, - 0x324: 0x2000, 0x325: 0x2000, 0x326: 0x2000, 0x327: 0x2000, 0x328: 0x2000, 0x329: 0x2000, - 0x331: 0x2000, 0x332: 0x2000, 0x333: 0x2000, 0x334: 0x2000, 0x335: 0x2000, - 0x336: 0x2000, 0x337: 0x2000, 0x338: 0x2000, 0x339: 0x2000, 0x33a: 0x2000, 0x33b: 0x2000, - 0x33c: 0x2000, 0x33d: 0x2000, 0x33e: 0x2000, 0x33f: 0x2000, - // Block 0xd, offset 0x340 - 0x340: 0x2000, 0x341: 0x2000, 0x343: 0x2000, 0x344: 0x2000, 0x345: 0x2000, - 0x346: 0x2000, 0x347: 0x2000, 0x348: 0x2000, 0x349: 0x2000, - // Block 0xe, offset 0x380 - 0x381: 0x2000, - 0x390: 0x2000, 0x391: 0x2000, - 0x392: 0x2000, 0x393: 0x2000, 0x394: 0x2000, 0x395: 0x2000, 0x396: 0x2000, 0x397: 0x2000, - 0x398: 0x2000, 0x399: 0x2000, 0x39a: 0x2000, 0x39b: 0x2000, 0x39c: 0x2000, 0x39d: 0x2000, - 0x39e: 0x2000, 0x39f: 0x2000, 0x3a0: 0x2000, 0x3a1: 0x2000, 0x3a2: 0x2000, 0x3a3: 0x2000, - 0x3a4: 0x2000, 0x3a5: 0x2000, 0x3a6: 0x2000, 0x3a7: 0x2000, 0x3a8: 0x2000, 0x3a9: 0x2000, - 0x3aa: 0x2000, 0x3ab: 0x2000, 0x3ac: 0x2000, 0x3ad: 0x2000, 0x3ae: 0x2000, 0x3af: 0x2000, - 0x3b0: 0x2000, 0x3b1: 0x2000, 0x3b2: 0x2000, 0x3b3: 0x2000, 0x3b4: 0x2000, 0x3b5: 0x2000, - 0x3b6: 0x2000, 0x3b7: 0x2000, 0x3b8: 0x2000, 0x3b9: 0x2000, 0x3ba: 0x2000, 0x3bb: 0x2000, - 0x3bc: 0x2000, 0x3bd: 0x2000, 0x3be: 0x2000, 0x3bf: 0x2000, - // Block 0xf, offset 0x3c0 - 0x3c0: 0x2000, 0x3c1: 0x2000, 0x3c2: 0x2000, 0x3c3: 0x2000, 0x3c4: 0x2000, 0x3c5: 0x2000, - 0x3c6: 0x2000, 0x3c7: 0x2000, 0x3c8: 0x2000, 0x3c9: 0x2000, 0x3ca: 0x2000, 0x3cb: 0x2000, - 0x3cc: 0x2000, 0x3cd: 0x2000, 0x3ce: 0x2000, 0x3cf: 0x2000, 0x3d1: 0x2000, - // Block 0x10, offset 0x400 - 0x400: 0x4000, 0x401: 0x4000, 0x402: 0x4000, 0x403: 0x4000, 0x404: 0x4000, 0x405: 0x4000, - 0x406: 0x4000, 0x407: 0x4000, 0x408: 0x4000, 0x409: 0x4000, 0x40a: 0x4000, 0x40b: 0x4000, - 0x40c: 0x4000, 0x40d: 0x4000, 0x40e: 0x4000, 0x40f: 0x4000, 0x410: 0x4000, 0x411: 0x4000, - 0x412: 0x4000, 0x413: 0x4000, 0x414: 0x4000, 0x415: 0x4000, 0x416: 0x4000, 0x417: 0x4000, - 0x418: 0x4000, 0x419: 0x4000, 0x41a: 0x4000, 0x41b: 0x4000, 0x41c: 0x4000, 0x41d: 0x4000, - 0x41e: 0x4000, 0x41f: 0x4000, 0x420: 0x4000, 0x421: 0x4000, 0x422: 0x4000, 0x423: 0x4000, - 0x424: 0x4000, 0x425: 0x4000, 0x426: 0x4000, 0x427: 0x4000, 0x428: 0x4000, 0x429: 0x4000, - 0x42a: 0x4000, 0x42b: 0x4000, 0x42c: 0x4000, 0x42d: 0x4000, 0x42e: 0x4000, 0x42f: 0x4000, - 0x430: 0x4000, 0x431: 0x4000, 0x432: 0x4000, 0x433: 0x4000, 0x434: 0x4000, 0x435: 0x4000, - 0x436: 0x4000, 0x437: 0x4000, 0x438: 0x4000, 0x439: 0x4000, 0x43a: 0x4000, 0x43b: 0x4000, - 0x43c: 0x4000, 0x43d: 0x4000, 0x43e: 0x4000, 0x43f: 0x4000, - // Block 0x11, offset 0x440 - 0x440: 0x4000, 0x441: 0x4000, 0x442: 0x4000, 0x443: 0x4000, 0x444: 0x4000, 0x445: 0x4000, - 0x446: 0x4000, 0x447: 0x4000, 0x448: 0x4000, 0x449: 0x4000, 0x44a: 0x4000, 0x44b: 0x4000, - 0x44c: 0x4000, 0x44d: 0x4000, 0x44e: 0x4000, 0x44f: 0x4000, 0x450: 0x4000, 0x451: 0x4000, - 0x452: 0x4000, 0x453: 0x4000, 0x454: 0x4000, 0x455: 0x4000, 0x456: 0x4000, 0x457: 0x4000, - 0x458: 0x4000, 0x459: 0x4000, 0x45a: 0x4000, 0x45b: 0x4000, 0x45c: 0x4000, 0x45d: 0x4000, - 0x45e: 0x4000, 0x45f: 0x4000, - // Block 0x12, offset 0x480 - 0x490: 0x2000, - 0x493: 0x2000, 0x494: 0x2000, 0x495: 0x2000, 0x496: 0x2000, - 0x498: 0x2000, 0x499: 0x2000, 0x49c: 0x2000, 0x49d: 0x2000, - 0x4a0: 0x2000, 0x4a1: 0x2000, 0x4a2: 0x2000, - 0x4a4: 0x2000, 0x4a5: 0x2000, 0x4a6: 0x2000, 0x4a7: 0x2000, - 0x4b0: 0x2000, 0x4b2: 0x2000, 0x4b3: 0x2000, 0x4b5: 0x2000, - 0x4bb: 0x2000, - 0x4be: 0x2000, - // Block 0x13, offset 0x4c0 - 0x4f4: 0x2000, - 0x4ff: 0x2000, - // Block 0x14, offset 0x500 - 0x501: 0x2000, 0x502: 0x2000, 0x503: 0x2000, 0x504: 0x2000, - 0x529: 0xa009, - 0x52c: 0x2000, - // Block 0x15, offset 0x540 - 0x543: 0x2000, 0x545: 0x2000, - 0x549: 0x2000, - 0x553: 0x2000, 0x556: 0x2000, - 0x561: 0x2000, 0x562: 0x2000, - 0x566: 0x2000, - 0x56b: 0x2000, - // Block 0x16, offset 0x580 - 0x593: 0x2000, 0x594: 0x2000, - 0x59b: 0x2000, 0x59c: 0x2000, 0x59d: 0x2000, - 0x59e: 0x2000, 0x5a0: 0x2000, 0x5a1: 0x2000, 0x5a2: 0x2000, 0x5a3: 0x2000, - 0x5a4: 0x2000, 0x5a5: 0x2000, 0x5a6: 0x2000, 0x5a7: 0x2000, 0x5a8: 0x2000, 0x5a9: 0x2000, - 0x5aa: 0x2000, 0x5ab: 0x2000, - 0x5b0: 0x2000, 0x5b1: 0x2000, 0x5b2: 0x2000, 0x5b3: 0x2000, 0x5b4: 0x2000, 0x5b5: 0x2000, - 0x5b6: 0x2000, 0x5b7: 0x2000, 0x5b8: 0x2000, 0x5b9: 0x2000, - // Block 0x17, offset 0x5c0 - 0x5c9: 0x2000, - 0x5d0: 0x200a, 0x5d1: 0x200b, - 0x5d2: 0x200a, 0x5d3: 0x200c, 0x5d4: 0x2000, 0x5d5: 0x2000, 0x5d6: 0x2000, 0x5d7: 0x2000, - 0x5d8: 0x2000, 0x5d9: 0x2000, - 0x5f8: 0x2000, 0x5f9: 0x2000, - // Block 0x18, offset 0x600 - 0x612: 0x2000, 0x614: 0x2000, - 0x627: 0x2000, - // Block 0x19, offset 0x640 - 0x640: 0x2000, 0x642: 0x2000, 0x643: 0x2000, - 0x647: 0x2000, 0x648: 0x2000, 0x64b: 0x2000, - 0x64f: 0x2000, 0x651: 0x2000, - 0x655: 0x2000, - 0x65a: 0x2000, 0x65d: 0x2000, - 0x65e: 0x2000, 0x65f: 0x2000, 0x660: 0x2000, 0x663: 0x2000, - 0x665: 0x2000, 0x667: 0x2000, 0x668: 0x2000, 0x669: 0x2000, - 0x66a: 0x2000, 0x66b: 0x2000, 0x66c: 0x2000, 0x66e: 0x2000, - 0x674: 0x2000, 0x675: 0x2000, - 0x676: 0x2000, 0x677: 0x2000, - 0x67c: 0x2000, 0x67d: 0x2000, - // Block 0x1a, offset 0x680 - 0x688: 0x2000, - 0x68c: 0x2000, - 0x692: 0x2000, - 0x6a0: 0x2000, 0x6a1: 0x2000, - 0x6a4: 0x2000, 0x6a5: 0x2000, 0x6a6: 0x2000, 0x6a7: 0x2000, - 0x6aa: 0x2000, 0x6ab: 0x2000, 0x6ae: 0x2000, 0x6af: 0x2000, - // Block 0x1b, offset 0x6c0 - 0x6c2: 0x2000, 0x6c3: 0x2000, - 0x6c6: 0x2000, 0x6c7: 0x2000, - 0x6d5: 0x2000, - 0x6d9: 0x2000, - 0x6e5: 0x2000, - 0x6ff: 0x2000, - // Block 0x1c, offset 0x700 - 0x712: 0x2000, - 0x71a: 0x4000, 0x71b: 0x4000, - 0x729: 0x4000, - 0x72a: 0x4000, - // Block 0x1d, offset 0x740 - 0x769: 0x4000, - 0x76a: 0x4000, 0x76b: 0x4000, 0x76c: 0x4000, - 0x770: 0x4000, 0x773: 0x4000, - // Block 0x1e, offset 0x780 - 0x7a0: 0x2000, 0x7a1: 0x2000, 0x7a2: 0x2000, 0x7a3: 0x2000, - 0x7a4: 0x2000, 0x7a5: 0x2000, 0x7a6: 0x2000, 0x7a7: 0x2000, 0x7a8: 0x2000, 0x7a9: 0x2000, - 0x7aa: 0x2000, 0x7ab: 0x2000, 0x7ac: 0x2000, 0x7ad: 0x2000, 0x7ae: 0x2000, 0x7af: 0x2000, - 0x7b0: 0x2000, 0x7b1: 0x2000, 0x7b2: 0x2000, 0x7b3: 0x2000, 0x7b4: 0x2000, 0x7b5: 0x2000, - 0x7b6: 0x2000, 0x7b7: 0x2000, 0x7b8: 0x2000, 0x7b9: 0x2000, 0x7ba: 0x2000, 0x7bb: 0x2000, - 0x7bc: 0x2000, 0x7bd: 0x2000, 0x7be: 0x2000, 0x7bf: 0x2000, - // Block 0x1f, offset 0x7c0 - 0x7c0: 0x2000, 0x7c1: 0x2000, 0x7c2: 0x2000, 0x7c3: 0x2000, 0x7c4: 0x2000, 0x7c5: 0x2000, - 0x7c6: 0x2000, 0x7c7: 0x2000, 0x7c8: 0x2000, 0x7c9: 0x2000, 0x7ca: 0x2000, 0x7cb: 0x2000, - 0x7cc: 0x2000, 0x7cd: 0x2000, 0x7ce: 0x2000, 0x7cf: 0x2000, 0x7d0: 0x2000, 0x7d1: 0x2000, - 0x7d2: 0x2000, 0x7d3: 0x2000, 0x7d4: 0x2000, 0x7d5: 0x2000, 0x7d6: 0x2000, 0x7d7: 0x2000, - 0x7d8: 0x2000, 0x7d9: 0x2000, 0x7da: 0x2000, 0x7db: 0x2000, 0x7dc: 0x2000, 0x7dd: 0x2000, - 0x7de: 0x2000, 0x7df: 0x2000, 0x7e0: 0x2000, 0x7e1: 0x2000, 0x7e2: 0x2000, 0x7e3: 0x2000, - 0x7e4: 0x2000, 0x7e5: 0x2000, 0x7e6: 0x2000, 0x7e7: 0x2000, 0x7e8: 0x2000, 0x7e9: 0x2000, - 0x7eb: 0x2000, 0x7ec: 0x2000, 0x7ed: 0x2000, 0x7ee: 0x2000, 0x7ef: 0x2000, - 0x7f0: 0x2000, 0x7f1: 0x2000, 0x7f2: 0x2000, 0x7f3: 0x2000, 0x7f4: 0x2000, 0x7f5: 0x2000, - 0x7f6: 0x2000, 0x7f7: 0x2000, 0x7f8: 0x2000, 0x7f9: 0x2000, 0x7fa: 0x2000, 0x7fb: 0x2000, - 0x7fc: 0x2000, 0x7fd: 0x2000, 0x7fe: 0x2000, 0x7ff: 0x2000, - // Block 0x20, offset 0x800 - 0x800: 0x2000, 0x801: 0x2000, 0x802: 0x200d, 0x803: 0x2000, 0x804: 0x2000, 0x805: 0x2000, - 0x806: 0x2000, 0x807: 0x2000, 0x808: 0x2000, 0x809: 0x2000, 0x80a: 0x2000, 0x80b: 0x2000, - 0x80c: 0x2000, 0x80d: 0x2000, 0x80e: 0x2000, 0x80f: 0x2000, 0x810: 0x2000, 0x811: 0x2000, - 0x812: 0x2000, 0x813: 0x2000, 0x814: 0x2000, 0x815: 0x2000, 0x816: 0x2000, 0x817: 0x2000, - 0x818: 0x2000, 0x819: 0x2000, 0x81a: 0x2000, 0x81b: 0x2000, 0x81c: 0x2000, 0x81d: 0x2000, - 0x81e: 0x2000, 0x81f: 0x2000, 0x820: 0x2000, 0x821: 0x2000, 0x822: 0x2000, 0x823: 0x2000, - 0x824: 0x2000, 0x825: 0x2000, 0x826: 0x2000, 0x827: 0x2000, 0x828: 0x2000, 0x829: 0x2000, - 0x82a: 0x2000, 0x82b: 0x2000, 0x82c: 0x2000, 0x82d: 0x2000, 0x82e: 0x2000, 0x82f: 0x2000, - 0x830: 0x2000, 0x831: 0x2000, 0x832: 0x2000, 0x833: 0x2000, 0x834: 0x2000, 0x835: 0x2000, - 0x836: 0x2000, 0x837: 0x2000, 0x838: 0x2000, 0x839: 0x2000, 0x83a: 0x2000, 0x83b: 0x2000, - 0x83c: 0x2000, 0x83d: 0x2000, 0x83e: 0x2000, 0x83f: 0x2000, - // Block 0x21, offset 0x840 - 0x840: 0x2000, 0x841: 0x2000, 0x842: 0x2000, 0x843: 0x2000, 0x844: 0x2000, 0x845: 0x2000, - 0x846: 0x2000, 0x847: 0x2000, 0x848: 0x2000, 0x849: 0x2000, 0x84a: 0x2000, 0x84b: 0x2000, - 0x850: 0x2000, 0x851: 0x2000, - 0x852: 0x2000, 0x853: 0x2000, 0x854: 0x2000, 0x855: 0x2000, 0x856: 0x2000, 0x857: 0x2000, - 0x858: 0x2000, 0x859: 0x2000, 0x85a: 0x2000, 0x85b: 0x2000, 0x85c: 0x2000, 0x85d: 0x2000, - 0x85e: 0x2000, 0x85f: 0x2000, 0x860: 0x2000, 0x861: 0x2000, 0x862: 0x2000, 0x863: 0x2000, - 0x864: 0x2000, 0x865: 0x2000, 0x866: 0x2000, 0x867: 0x2000, 0x868: 0x2000, 0x869: 0x2000, - 0x86a: 0x2000, 0x86b: 0x2000, 0x86c: 0x2000, 0x86d: 0x2000, 0x86e: 0x2000, 0x86f: 0x2000, - 0x870: 0x2000, 0x871: 0x2000, 0x872: 0x2000, 0x873: 0x2000, - // Block 0x22, offset 0x880 - 0x880: 0x2000, 0x881: 0x2000, 0x882: 0x2000, 0x883: 0x2000, 0x884: 0x2000, 0x885: 0x2000, - 0x886: 0x2000, 0x887: 0x2000, 0x888: 0x2000, 0x889: 0x2000, 0x88a: 0x2000, 0x88b: 0x2000, - 0x88c: 0x2000, 0x88d: 0x2000, 0x88e: 0x2000, 0x88f: 0x2000, - 0x892: 0x2000, 0x893: 0x2000, 0x894: 0x2000, 0x895: 0x2000, - 0x8a0: 0x200e, 0x8a1: 0x2000, 0x8a3: 0x2000, - 0x8a4: 0x2000, 0x8a5: 0x2000, 0x8a6: 0x2000, 0x8a7: 0x2000, 0x8a8: 0x2000, 0x8a9: 0x2000, - 0x8b2: 0x2000, 0x8b3: 0x2000, - 0x8b6: 0x2000, 0x8b7: 0x2000, - 0x8bc: 0x2000, 0x8bd: 0x2000, - // Block 0x23, offset 0x8c0 - 0x8c0: 0x2000, 0x8c1: 0x2000, - 0x8c6: 0x2000, 0x8c7: 0x2000, 0x8c8: 0x2000, 0x8cb: 0x200f, - 0x8ce: 0x2000, 0x8cf: 0x2000, 0x8d0: 0x2000, 0x8d1: 0x2000, - 0x8e2: 0x2000, 0x8e3: 0x2000, - 0x8e4: 0x2000, 0x8e5: 0x2000, - 0x8ef: 0x2000, - 0x8fd: 0x4000, 0x8fe: 0x4000, - // Block 0x24, offset 0x900 - 0x905: 0x2000, - 0x906: 0x2000, 0x909: 0x2000, - 0x90e: 0x2000, 0x90f: 0x2000, - 0x914: 0x4000, 0x915: 0x4000, - 0x91c: 0x2000, - 0x91e: 0x2000, - // Block 0x25, offset 0x940 - 0x940: 0x2000, 0x942: 0x2000, - 0x948: 0x4000, 0x949: 0x4000, 0x94a: 0x4000, 0x94b: 0x4000, - 0x94c: 0x4000, 0x94d: 0x4000, 0x94e: 0x4000, 0x94f: 0x4000, 0x950: 0x4000, 0x951: 0x4000, - 0x952: 0x4000, 0x953: 0x4000, - 0x960: 0x2000, 0x961: 0x2000, 0x963: 0x2000, - 0x964: 0x2000, 0x965: 0x2000, 0x967: 0x2000, 0x968: 0x2000, 0x969: 0x2000, - 0x96a: 0x2000, 0x96c: 0x2000, 0x96d: 0x2000, 0x96f: 0x2000, - 0x97f: 0x4000, - // Block 0x26, offset 0x980 - 0x993: 0x4000, - 0x99e: 0x2000, 0x99f: 0x2000, 0x9a1: 0x4000, - 0x9aa: 0x4000, 0x9ab: 0x4000, - 0x9bd: 0x4000, 0x9be: 0x4000, 0x9bf: 0x2000, - // Block 0x27, offset 0x9c0 - 0x9c4: 0x4000, 0x9c5: 0x4000, - 0x9c6: 0x2000, 0x9c7: 0x2000, 0x9c8: 0x2000, 0x9c9: 0x2000, 0x9ca: 0x2000, 0x9cb: 0x2000, - 0x9cc: 0x2000, 0x9cd: 0x2000, 0x9ce: 0x4000, 0x9cf: 0x2000, 0x9d0: 0x2000, 0x9d1: 0x2000, - 0x9d2: 0x2000, 0x9d3: 0x2000, 0x9d4: 0x4000, 0x9d5: 0x2000, 0x9d6: 0x2000, 0x9d7: 0x2000, - 0x9d8: 0x2000, 0x9d9: 0x2000, 0x9da: 0x2000, 0x9db: 0x2000, 0x9dc: 0x2000, 0x9dd: 0x2000, - 0x9de: 0x2000, 0x9df: 0x2000, 0x9e0: 0x2000, 0x9e1: 0x2000, 0x9e3: 0x2000, - 0x9e8: 0x2000, 0x9e9: 0x2000, - 0x9ea: 0x4000, 0x9eb: 0x2000, 0x9ec: 0x2000, 0x9ed: 0x2000, 0x9ee: 0x2000, 0x9ef: 0x2000, - 0x9f0: 0x2000, 0x9f1: 0x2000, 0x9f2: 0x4000, 0x9f3: 0x4000, 0x9f4: 0x2000, 0x9f5: 0x4000, - 0x9f6: 0x2000, 0x9f7: 0x2000, 0x9f8: 0x2000, 0x9f9: 0x2000, 0x9fa: 0x4000, 0x9fb: 0x2000, - 0x9fc: 0x2000, 0x9fd: 0x4000, 0x9fe: 0x2000, 0x9ff: 0x2000, - // Block 0x28, offset 0xa00 - 0xa05: 0x4000, - 0xa0a: 0x4000, 0xa0b: 0x4000, - 0xa28: 0x4000, - 0xa3d: 0x2000, - // Block 0x29, offset 0xa40 - 0xa4c: 0x4000, 0xa4e: 0x4000, - 0xa53: 0x4000, 0xa54: 0x4000, 0xa55: 0x4000, 0xa57: 0x4000, - 0xa76: 0x2000, 0xa77: 0x2000, 0xa78: 0x2000, 0xa79: 0x2000, 0xa7a: 0x2000, 0xa7b: 0x2000, - 0xa7c: 0x2000, 0xa7d: 0x2000, 0xa7e: 0x2000, 0xa7f: 0x2000, - // Block 0x2a, offset 0xa80 - 0xa95: 0x4000, 0xa96: 0x4000, 0xa97: 0x4000, - 0xab0: 0x4000, - 0xabf: 0x4000, - // Block 0x2b, offset 0xac0 - 0xae6: 0x6000, 0xae7: 0x6000, 0xae8: 0x6000, 0xae9: 0x6000, - 0xaea: 0x6000, 0xaeb: 0x6000, 0xaec: 0x6000, 0xaed: 0x6000, - // Block 0x2c, offset 0xb00 - 0xb05: 0x6010, - 0xb06: 0x6011, - // Block 0x2d, offset 0xb40 - 0xb5b: 0x4000, 0xb5c: 0x4000, - // Block 0x2e, offset 0xb80 - 0xb90: 0x4000, - 0xb95: 0x4000, 0xb96: 0x2000, 0xb97: 0x2000, - 0xb98: 0x2000, 0xb99: 0x2000, - // Block 0x2f, offset 0xbc0 - 0xbc0: 0x4000, 0xbc1: 0x4000, 0xbc2: 0x4000, 0xbc3: 0x4000, 0xbc4: 0x4000, 0xbc5: 0x4000, - 0xbc6: 0x4000, 0xbc7: 0x4000, 0xbc8: 0x4000, 0xbc9: 0x4000, 0xbca: 0x4000, 0xbcb: 0x4000, - 0xbcc: 0x4000, 0xbcd: 0x4000, 0xbce: 0x4000, 0xbcf: 0x4000, 0xbd0: 0x4000, 0xbd1: 0x4000, - 0xbd2: 0x4000, 0xbd3: 0x4000, 0xbd4: 0x4000, 0xbd5: 0x4000, 0xbd6: 0x4000, 0xbd7: 0x4000, - 0xbd8: 0x4000, 0xbd9: 0x4000, 0xbdb: 0x4000, 0xbdc: 0x4000, 0xbdd: 0x4000, - 0xbde: 0x4000, 0xbdf: 0x4000, 0xbe0: 0x4000, 0xbe1: 0x4000, 0xbe2: 0x4000, 0xbe3: 0x4000, - 0xbe4: 0x4000, 0xbe5: 0x4000, 0xbe6: 0x4000, 0xbe7: 0x4000, 0xbe8: 0x4000, 0xbe9: 0x4000, - 0xbea: 0x4000, 0xbeb: 0x4000, 0xbec: 0x4000, 0xbed: 0x4000, 0xbee: 0x4000, 0xbef: 0x4000, - 0xbf0: 0x4000, 0xbf1: 0x4000, 0xbf2: 0x4000, 0xbf3: 0x4000, 0xbf4: 0x4000, 0xbf5: 0x4000, - 0xbf6: 0x4000, 0xbf7: 0x4000, 0xbf8: 0x4000, 0xbf9: 0x4000, 0xbfa: 0x4000, 0xbfb: 0x4000, - 0xbfc: 0x4000, 0xbfd: 0x4000, 0xbfe: 0x4000, 0xbff: 0x4000, - // Block 0x30, offset 0xc00 - 0xc00: 0x4000, 0xc01: 0x4000, 0xc02: 0x4000, 0xc03: 0x4000, 0xc04: 0x4000, 0xc05: 0x4000, - 0xc06: 0x4000, 0xc07: 0x4000, 0xc08: 0x4000, 0xc09: 0x4000, 0xc0a: 0x4000, 0xc0b: 0x4000, - 0xc0c: 0x4000, 0xc0d: 0x4000, 0xc0e: 0x4000, 0xc0f: 0x4000, 0xc10: 0x4000, 0xc11: 0x4000, - 0xc12: 0x4000, 0xc13: 0x4000, 0xc14: 0x4000, 0xc15: 0x4000, 0xc16: 0x4000, 0xc17: 0x4000, - 0xc18: 0x4000, 0xc19: 0x4000, 0xc1a: 0x4000, 0xc1b: 0x4000, 0xc1c: 0x4000, 0xc1d: 0x4000, - 0xc1e: 0x4000, 0xc1f: 0x4000, 0xc20: 0x4000, 0xc21: 0x4000, 0xc22: 0x4000, 0xc23: 0x4000, - 0xc24: 0x4000, 0xc25: 0x4000, 0xc26: 0x4000, 0xc27: 0x4000, 0xc28: 0x4000, 0xc29: 0x4000, - 0xc2a: 0x4000, 0xc2b: 0x4000, 0xc2c: 0x4000, 0xc2d: 0x4000, 0xc2e: 0x4000, 0xc2f: 0x4000, - 0xc30: 0x4000, 0xc31: 0x4000, 0xc32: 0x4000, 0xc33: 0x4000, - // Block 0x31, offset 0xc40 - 0xc40: 0x4000, 0xc41: 0x4000, 0xc42: 0x4000, 0xc43: 0x4000, 0xc44: 0x4000, 0xc45: 0x4000, - 0xc46: 0x4000, 0xc47: 0x4000, 0xc48: 0x4000, 0xc49: 0x4000, 0xc4a: 0x4000, 0xc4b: 0x4000, - 0xc4c: 0x4000, 0xc4d: 0x4000, 0xc4e: 0x4000, 0xc4f: 0x4000, 0xc50: 0x4000, 0xc51: 0x4000, - 0xc52: 0x4000, 0xc53: 0x4000, 0xc54: 0x4000, 0xc55: 0x4000, - 0xc70: 0x4000, 0xc71: 0x4000, 0xc72: 0x4000, 0xc73: 0x4000, 0xc74: 0x4000, 0xc75: 0x4000, - 0xc76: 0x4000, 0xc77: 0x4000, 0xc78: 0x4000, 0xc79: 0x4000, 0xc7a: 0x4000, 0xc7b: 0x4000, - // Block 0x32, offset 0xc80 - 0xc80: 0x9012, 0xc81: 0x4013, 0xc82: 0x4014, 0xc83: 0x4000, 0xc84: 0x4000, 0xc85: 0x4000, - 0xc86: 0x4000, 0xc87: 0x4000, 0xc88: 0x4000, 0xc89: 0x4000, 0xc8a: 0x4000, 0xc8b: 0x4000, - 0xc8c: 0x4015, 0xc8d: 0x4015, 0xc8e: 0x4000, 0xc8f: 0x4000, 0xc90: 0x4000, 0xc91: 0x4000, - 0xc92: 0x4000, 0xc93: 0x4000, 0xc94: 0x4000, 0xc95: 0x4000, 0xc96: 0x4000, 0xc97: 0x4000, - 0xc98: 0x4000, 0xc99: 0x4000, 0xc9a: 0x4000, 0xc9b: 0x4000, 0xc9c: 0x4000, 0xc9d: 0x4000, - 0xc9e: 0x4000, 0xc9f: 0x4000, 0xca0: 0x4000, 0xca1: 0x4000, 0xca2: 0x4000, 0xca3: 0x4000, - 0xca4: 0x4000, 0xca5: 0x4000, 0xca6: 0x4000, 0xca7: 0x4000, 0xca8: 0x4000, 0xca9: 0x4000, - 0xcaa: 0x4000, 0xcab: 0x4000, 0xcac: 0x4000, 0xcad: 0x4000, 0xcae: 0x4000, 0xcaf: 0x4000, - 0xcb0: 0x4000, 0xcb1: 0x4000, 0xcb2: 0x4000, 0xcb3: 0x4000, 0xcb4: 0x4000, 0xcb5: 0x4000, - 0xcb6: 0x4000, 0xcb7: 0x4000, 0xcb8: 0x4000, 0xcb9: 0x4000, 0xcba: 0x4000, 0xcbb: 0x4000, - 0xcbc: 0x4000, 0xcbd: 0x4000, 0xcbe: 0x4000, - // Block 0x33, offset 0xcc0 - 0xcc1: 0x4000, 0xcc2: 0x4000, 0xcc3: 0x4000, 0xcc4: 0x4000, 0xcc5: 0x4000, - 0xcc6: 0x4000, 0xcc7: 0x4000, 0xcc8: 0x4000, 0xcc9: 0x4000, 0xcca: 0x4000, 0xccb: 0x4000, - 0xccc: 0x4000, 0xccd: 0x4000, 0xcce: 0x4000, 0xccf: 0x4000, 0xcd0: 0x4000, 0xcd1: 0x4000, - 0xcd2: 0x4000, 0xcd3: 0x4000, 0xcd4: 0x4000, 0xcd5: 0x4000, 0xcd6: 0x4000, 0xcd7: 0x4000, - 0xcd8: 0x4000, 0xcd9: 0x4000, 0xcda: 0x4000, 0xcdb: 0x4000, 0xcdc: 0x4000, 0xcdd: 0x4000, - 0xcde: 0x4000, 0xcdf: 0x4000, 0xce0: 0x4000, 0xce1: 0x4000, 0xce2: 0x4000, 0xce3: 0x4000, - 0xce4: 0x4000, 0xce5: 0x4000, 0xce6: 0x4000, 0xce7: 0x4000, 0xce8: 0x4000, 0xce9: 0x4000, - 0xcea: 0x4000, 0xceb: 0x4000, 0xcec: 0x4000, 0xced: 0x4000, 0xcee: 0x4000, 0xcef: 0x4000, - 0xcf0: 0x4000, 0xcf1: 0x4000, 0xcf2: 0x4000, 0xcf3: 0x4000, 0xcf4: 0x4000, 0xcf5: 0x4000, - 0xcf6: 0x4000, 0xcf7: 0x4000, 0xcf8: 0x4000, 0xcf9: 0x4000, 0xcfa: 0x4000, 0xcfb: 0x4000, - 0xcfc: 0x4000, 0xcfd: 0x4000, 0xcfe: 0x4000, 0xcff: 0x4000, - // Block 0x34, offset 0xd00 - 0xd00: 0x4000, 0xd01: 0x4000, 0xd02: 0x4000, 0xd03: 0x4000, 0xd04: 0x4000, 0xd05: 0x4000, - 0xd06: 0x4000, 0xd07: 0x4000, 0xd08: 0x4000, 0xd09: 0x4000, 0xd0a: 0x4000, 0xd0b: 0x4000, - 0xd0c: 0x4000, 0xd0d: 0x4000, 0xd0e: 0x4000, 0xd0f: 0x4000, 0xd10: 0x4000, 0xd11: 0x4000, - 0xd12: 0x4000, 0xd13: 0x4000, 0xd14: 0x4000, 0xd15: 0x4000, 0xd16: 0x4000, - 0xd19: 0x4016, 0xd1a: 0x4017, 0xd1b: 0x4000, 0xd1c: 0x4000, 0xd1d: 0x4000, - 0xd1e: 0x4000, 0xd1f: 0x4000, 0xd20: 0x4000, 0xd21: 0x4018, 0xd22: 0x4019, 0xd23: 0x401a, - 0xd24: 0x401b, 0xd25: 0x401c, 0xd26: 0x401d, 0xd27: 0x401e, 0xd28: 0x401f, 0xd29: 0x4020, - 0xd2a: 0x4021, 0xd2b: 0x4022, 0xd2c: 0x4000, 0xd2d: 0x4010, 0xd2e: 0x4000, 0xd2f: 0x4023, - 0xd30: 0x4000, 0xd31: 0x4024, 0xd32: 0x4000, 0xd33: 0x4025, 0xd34: 0x4000, 0xd35: 0x4026, - 0xd36: 0x4000, 0xd37: 0x401a, 0xd38: 0x4000, 0xd39: 0x4027, 0xd3a: 0x4000, 0xd3b: 0x4028, - 0xd3c: 0x4000, 0xd3d: 0x4020, 0xd3e: 0x4000, 0xd3f: 0x4029, - // Block 0x35, offset 0xd40 - 0xd40: 0x4000, 0xd41: 0x402a, 0xd42: 0x4000, 0xd43: 0x402b, 0xd44: 0x402c, 0xd45: 0x4000, - 0xd46: 0x4017, 0xd47: 0x4000, 0xd48: 0x402d, 0xd49: 0x4000, 0xd4a: 0x402e, 0xd4b: 0x402f, - 0xd4c: 0x4030, 0xd4d: 0x4017, 0xd4e: 0x4016, 0xd4f: 0x4017, 0xd50: 0x4000, 0xd51: 0x4000, - 0xd52: 0x4031, 0xd53: 0x4000, 0xd54: 0x4000, 0xd55: 0x4031, 0xd56: 0x4000, 0xd57: 0x4000, - 0xd58: 0x4032, 0xd59: 0x4000, 0xd5a: 0x4000, 0xd5b: 0x4032, 0xd5c: 0x4000, 0xd5d: 0x4000, - 0xd5e: 0x4033, 0xd5f: 0x402e, 0xd60: 0x4034, 0xd61: 0x4035, 0xd62: 0x4034, 0xd63: 0x4036, - 0xd64: 0x4037, 0xd65: 0x4024, 0xd66: 0x4035, 0xd67: 0x4025, 0xd68: 0x4038, 0xd69: 0x4038, - 0xd6a: 0x4039, 0xd6b: 0x4039, 0xd6c: 0x403a, 0xd6d: 0x403a, 0xd6e: 0x4000, 0xd6f: 0x4035, - 0xd70: 0x4000, 0xd71: 0x4000, 0xd72: 0x403b, 0xd73: 0x403c, 0xd74: 0x4000, 0xd75: 0x4000, - 0xd76: 0x4000, 0xd77: 0x4000, 0xd78: 0x4000, 0xd79: 0x4000, 0xd7a: 0x4000, 0xd7b: 0x403d, - 0xd7c: 0x401c, 0xd7d: 0x4000, 0xd7e: 0x4000, 0xd7f: 0x4000, - // Block 0x36, offset 0xd80 - 0xd85: 0x4000, - 0xd86: 0x4000, 0xd87: 0x4000, 0xd88: 0x4000, 0xd89: 0x4000, 0xd8a: 0x4000, 0xd8b: 0x4000, - 0xd8c: 0x4000, 0xd8d: 0x4000, 0xd8e: 0x4000, 0xd8f: 0x4000, 0xd90: 0x4000, 0xd91: 0x4000, - 0xd92: 0x4000, 0xd93: 0x4000, 0xd94: 0x4000, 0xd95: 0x4000, 0xd96: 0x4000, 0xd97: 0x4000, - 0xd98: 0x4000, 0xd99: 0x4000, 0xd9a: 0x4000, 0xd9b: 0x4000, 0xd9c: 0x4000, 0xd9d: 0x4000, - 0xd9e: 0x4000, 0xd9f: 0x4000, 0xda0: 0x4000, 0xda1: 0x4000, 0xda2: 0x4000, 0xda3: 0x4000, - 0xda4: 0x4000, 0xda5: 0x4000, 0xda6: 0x4000, 0xda7: 0x4000, 0xda8: 0x4000, 0xda9: 0x4000, - 0xdaa: 0x4000, 0xdab: 0x4000, 0xdac: 0x4000, 0xdad: 0x4000, 0xdae: 0x4000, 0xdaf: 0x4000, - 0xdb1: 0x403e, 0xdb2: 0x403e, 0xdb3: 0x403e, 0xdb4: 0x403e, 0xdb5: 0x403e, - 0xdb6: 0x403e, 0xdb7: 0x403e, 0xdb8: 0x403e, 0xdb9: 0x403e, 0xdba: 0x403e, 0xdbb: 0x403e, - 0xdbc: 0x403e, 0xdbd: 0x403e, 0xdbe: 0x403e, 0xdbf: 0x403e, - // Block 0x37, offset 0xdc0 - 0xdc0: 0x4037, 0xdc1: 0x4037, 0xdc2: 0x4037, 0xdc3: 0x4037, 0xdc4: 0x4037, 0xdc5: 0x4037, - 0xdc6: 0x4037, 0xdc7: 0x4037, 0xdc8: 0x4037, 0xdc9: 0x4037, 0xdca: 0x4037, 0xdcb: 0x4037, - 0xdcc: 0x4037, 0xdcd: 0x4037, 0xdce: 0x4037, 0xdcf: 0x400e, 0xdd0: 0x403f, 0xdd1: 0x4040, - 0xdd2: 0x4041, 0xdd3: 0x4040, 0xdd4: 0x403f, 0xdd5: 0x4042, 0xdd6: 0x4043, 0xdd7: 0x4044, - 0xdd8: 0x4040, 0xdd9: 0x4041, 0xdda: 0x4040, 0xddb: 0x4045, 0xddc: 0x4009, 0xddd: 0x4045, - 0xdde: 0x4046, 0xddf: 0x4045, 0xde0: 0x4047, 0xde1: 0x400b, 0xde2: 0x400a, 0xde3: 0x400c, - 0xde4: 0x4048, 0xde5: 0x4000, 0xde6: 0x4000, 0xde7: 0x4000, 0xde8: 0x4000, 0xde9: 0x4000, - 0xdea: 0x4000, 0xdeb: 0x4000, 0xdec: 0x4000, 0xded: 0x4000, 0xdee: 0x4000, 0xdef: 0x4000, - 0xdf0: 0x4000, 0xdf1: 0x4000, 0xdf2: 0x4000, 0xdf3: 0x4000, 0xdf4: 0x4000, 0xdf5: 0x4000, - 0xdf6: 0x4000, 0xdf7: 0x4000, 0xdf8: 0x4000, 0xdf9: 0x4000, 0xdfa: 0x4000, 0xdfb: 0x4000, - 0xdfc: 0x4000, 0xdfd: 0x4000, 0xdfe: 0x4000, 0xdff: 0x4000, - // Block 0x38, offset 0xe00 - 0xe00: 0x4000, 0xe01: 0x4000, 0xe02: 0x4000, 0xe03: 0x4000, 0xe04: 0x4000, 0xe05: 0x4000, - 0xe06: 0x4000, 0xe07: 0x4000, 0xe08: 0x4000, 0xe09: 0x4000, 0xe0a: 0x4000, 0xe0b: 0x4000, - 0xe0c: 0x4000, 0xe0d: 0x4000, 0xe0e: 0x4000, 0xe10: 0x4000, 0xe11: 0x4000, - 0xe12: 0x4000, 0xe13: 0x4000, 0xe14: 0x4000, 0xe15: 0x4000, 0xe16: 0x4000, 0xe17: 0x4000, - 0xe18: 0x4000, 0xe19: 0x4000, 0xe1a: 0x4000, 0xe1b: 0x4000, 0xe1c: 0x4000, 0xe1d: 0x4000, - 0xe1e: 0x4000, 0xe1f: 0x4000, 0xe20: 0x4000, 0xe21: 0x4000, 0xe22: 0x4000, 0xe23: 0x4000, - 0xe24: 0x4000, 0xe25: 0x4000, 0xe26: 0x4000, 0xe27: 0x4000, 0xe28: 0x4000, 0xe29: 0x4000, - 0xe2a: 0x4000, 0xe2b: 0x4000, 0xe2c: 0x4000, 0xe2d: 0x4000, 0xe2e: 0x4000, 0xe2f: 0x4000, - 0xe30: 0x4000, 0xe31: 0x4000, 0xe32: 0x4000, 0xe33: 0x4000, 0xe34: 0x4000, 0xe35: 0x4000, - 0xe36: 0x4000, 0xe37: 0x4000, 0xe38: 0x4000, 0xe39: 0x4000, 0xe3a: 0x4000, - // Block 0x39, offset 0xe40 - 0xe40: 0x4000, 0xe41: 0x4000, 0xe42: 0x4000, 0xe43: 0x4000, 0xe44: 0x4000, 0xe45: 0x4000, - 0xe46: 0x4000, 0xe47: 0x4000, 0xe48: 0x4000, 0xe49: 0x4000, 0xe4a: 0x4000, 0xe4b: 0x4000, - 0xe4c: 0x4000, 0xe4d: 0x4000, 0xe4e: 0x4000, 0xe4f: 0x4000, 0xe50: 0x4000, 0xe51: 0x4000, - 0xe52: 0x4000, 0xe53: 0x4000, 0xe54: 0x4000, 0xe55: 0x4000, 0xe56: 0x4000, 0xe57: 0x4000, - 0xe58: 0x4000, 0xe59: 0x4000, 0xe5a: 0x4000, 0xe5b: 0x4000, 0xe5c: 0x4000, 0xe5d: 0x4000, - 0xe5e: 0x4000, 0xe5f: 0x4000, 0xe60: 0x4000, 0xe61: 0x4000, 0xe62: 0x4000, 0xe63: 0x4000, - 0xe70: 0x4000, 0xe71: 0x4000, 0xe72: 0x4000, 0xe73: 0x4000, 0xe74: 0x4000, 0xe75: 0x4000, - 0xe76: 0x4000, 0xe77: 0x4000, 0xe78: 0x4000, 0xe79: 0x4000, 0xe7a: 0x4000, 0xe7b: 0x4000, - 0xe7c: 0x4000, 0xe7d: 0x4000, 0xe7e: 0x4000, 0xe7f: 0x4000, - // Block 0x3a, offset 0xe80 - 0xe80: 0x4000, 0xe81: 0x4000, 0xe82: 0x4000, 0xe83: 0x4000, 0xe84: 0x4000, 0xe85: 0x4000, - 0xe86: 0x4000, 0xe87: 0x4000, 0xe88: 0x4000, 0xe89: 0x4000, 0xe8a: 0x4000, 0xe8b: 0x4000, - 0xe8c: 0x4000, 0xe8d: 0x4000, 0xe8e: 0x4000, 0xe8f: 0x4000, 0xe90: 0x4000, 0xe91: 0x4000, - 0xe92: 0x4000, 0xe93: 0x4000, 0xe94: 0x4000, 0xe95: 0x4000, 0xe96: 0x4000, 0xe97: 0x4000, - 0xe98: 0x4000, 0xe99: 0x4000, 0xe9a: 0x4000, 0xe9b: 0x4000, 0xe9c: 0x4000, 0xe9d: 0x4000, - 0xe9e: 0x4000, 0xea0: 0x4000, 0xea1: 0x4000, 0xea2: 0x4000, 0xea3: 0x4000, - 0xea4: 0x4000, 0xea5: 0x4000, 0xea6: 0x4000, 0xea7: 0x4000, 0xea8: 0x4000, 0xea9: 0x4000, - 0xeaa: 0x4000, 0xeab: 0x4000, 0xeac: 0x4000, 0xead: 0x4000, 0xeae: 0x4000, 0xeaf: 0x4000, - 0xeb0: 0x4000, 0xeb1: 0x4000, 0xeb2: 0x4000, 0xeb3: 0x4000, 0xeb4: 0x4000, 0xeb5: 0x4000, - 0xeb6: 0x4000, 0xeb7: 0x4000, 0xeb8: 0x4000, 0xeb9: 0x4000, 0xeba: 0x4000, 0xebb: 0x4000, - 0xebc: 0x4000, 0xebd: 0x4000, 0xebe: 0x4000, 0xebf: 0x4000, - // Block 0x3b, offset 0xec0 - 0xec0: 0x4000, 0xec1: 0x4000, 0xec2: 0x4000, 0xec3: 0x4000, 0xec4: 0x4000, 0xec5: 0x4000, - 0xec6: 0x4000, 0xec7: 0x4000, 0xec8: 0x2000, 0xec9: 0x2000, 0xeca: 0x2000, 0xecb: 0x2000, - 0xecc: 0x2000, 0xecd: 0x2000, 0xece: 0x2000, 0xecf: 0x2000, 0xed0: 0x4000, 0xed1: 0x4000, - 0xed2: 0x4000, 0xed3: 0x4000, 0xed4: 0x4000, 0xed5: 0x4000, 0xed6: 0x4000, 0xed7: 0x4000, - 0xed8: 0x4000, 0xed9: 0x4000, 0xeda: 0x4000, 0xedb: 0x4000, 0xedc: 0x4000, 0xedd: 0x4000, - 0xede: 0x4000, 0xedf: 0x4000, 0xee0: 0x4000, 0xee1: 0x4000, 0xee2: 0x4000, 0xee3: 0x4000, - 0xee4: 0x4000, 0xee5: 0x4000, 0xee6: 0x4000, 0xee7: 0x4000, 0xee8: 0x4000, 0xee9: 0x4000, - 0xeea: 0x4000, 0xeeb: 0x4000, 0xeec: 0x4000, 0xeed: 0x4000, 0xeee: 0x4000, 0xeef: 0x4000, - 0xef0: 0x4000, 0xef1: 0x4000, 0xef2: 0x4000, 0xef3: 0x4000, 0xef4: 0x4000, 0xef5: 0x4000, - 0xef6: 0x4000, 0xef7: 0x4000, 0xef8: 0x4000, 0xef9: 0x4000, 0xefa: 0x4000, 0xefb: 0x4000, - 0xefc: 0x4000, 0xefd: 0x4000, 0xefe: 0x4000, 0xeff: 0x4000, - // Block 0x3c, offset 0xf00 - 0xf00: 0x4000, 0xf01: 0x4000, 0xf02: 0x4000, 0xf03: 0x4000, 0xf04: 0x4000, 0xf05: 0x4000, - 0xf06: 0x4000, 0xf07: 0x4000, 0xf08: 0x4000, 0xf09: 0x4000, 0xf0a: 0x4000, 0xf0b: 0x4000, - 0xf0c: 0x4000, 0xf0d: 0x4000, 0xf0e: 0x4000, 0xf0f: 0x4000, 0xf10: 0x4000, 0xf11: 0x4000, - 0xf12: 0x4000, 0xf13: 0x4000, 0xf14: 0x4000, 0xf15: 0x4000, 0xf16: 0x4000, 0xf17: 0x4000, - 0xf18: 0x4000, 0xf19: 0x4000, 0xf1a: 0x4000, 0xf1b: 0x4000, 0xf1c: 0x4000, 0xf1d: 0x4000, - 0xf1e: 0x4000, 0xf1f: 0x4000, 0xf20: 0x4000, 0xf21: 0x4000, 0xf22: 0x4000, 0xf23: 0x4000, - 0xf24: 0x4000, 0xf25: 0x4000, 0xf26: 0x4000, 0xf27: 0x4000, 0xf28: 0x4000, 0xf29: 0x4000, - 0xf2a: 0x4000, 0xf2b: 0x4000, 0xf2c: 0x4000, 0xf2d: 0x4000, 0xf2e: 0x4000, 0xf2f: 0x4000, - 0xf30: 0x4000, 0xf31: 0x4000, 0xf32: 0x4000, 0xf33: 0x4000, 0xf34: 0x4000, 0xf35: 0x4000, - 0xf36: 0x4000, 0xf37: 0x4000, 0xf38: 0x4000, 0xf39: 0x4000, 0xf3a: 0x4000, 0xf3b: 0x4000, - 0xf3c: 0x4000, 0xf3d: 0x4000, 0xf3e: 0x4000, - // Block 0x3d, offset 0xf40 - 0xf40: 0x4000, 0xf41: 0x4000, 0xf42: 0x4000, 0xf43: 0x4000, 0xf44: 0x4000, 0xf45: 0x4000, - 0xf46: 0x4000, 0xf47: 0x4000, 0xf48: 0x4000, 0xf49: 0x4000, 0xf4a: 0x4000, 0xf4b: 0x4000, - 0xf4c: 0x4000, 0xf50: 0x4000, 0xf51: 0x4000, - 0xf52: 0x4000, 0xf53: 0x4000, 0xf54: 0x4000, 0xf55: 0x4000, 0xf56: 0x4000, 0xf57: 0x4000, - 0xf58: 0x4000, 0xf59: 0x4000, 0xf5a: 0x4000, 0xf5b: 0x4000, 0xf5c: 0x4000, 0xf5d: 0x4000, - 0xf5e: 0x4000, 0xf5f: 0x4000, 0xf60: 0x4000, 0xf61: 0x4000, 0xf62: 0x4000, 0xf63: 0x4000, - 0xf64: 0x4000, 0xf65: 0x4000, 0xf66: 0x4000, 0xf67: 0x4000, 0xf68: 0x4000, 0xf69: 0x4000, - 0xf6a: 0x4000, 0xf6b: 0x4000, 0xf6c: 0x4000, 0xf6d: 0x4000, 0xf6e: 0x4000, 0xf6f: 0x4000, - 0xf70: 0x4000, 0xf71: 0x4000, 0xf72: 0x4000, 0xf73: 0x4000, 0xf74: 0x4000, 0xf75: 0x4000, - 0xf76: 0x4000, 0xf77: 0x4000, 0xf78: 0x4000, 0xf79: 0x4000, 0xf7a: 0x4000, 0xf7b: 0x4000, - 0xf7c: 0x4000, 0xf7d: 0x4000, 0xf7e: 0x4000, 0xf7f: 0x4000, - // Block 0x3e, offset 0xf80 - 0xf80: 0x4000, 0xf81: 0x4000, 0xf82: 0x4000, 0xf83: 0x4000, 0xf84: 0x4000, 0xf85: 0x4000, - 0xf86: 0x4000, - // Block 0x3f, offset 0xfc0 - 0xfe0: 0x4000, 0xfe1: 0x4000, 0xfe2: 0x4000, 0xfe3: 0x4000, - 0xfe4: 0x4000, 0xfe5: 0x4000, 0xfe6: 0x4000, 0xfe7: 0x4000, 0xfe8: 0x4000, 0xfe9: 0x4000, - 0xfea: 0x4000, 0xfeb: 0x4000, 0xfec: 0x4000, 0xfed: 0x4000, 0xfee: 0x4000, 0xfef: 0x4000, - 0xff0: 0x4000, 0xff1: 0x4000, 0xff2: 0x4000, 0xff3: 0x4000, 0xff4: 0x4000, 0xff5: 0x4000, - 0xff6: 0x4000, 0xff7: 0x4000, 0xff8: 0x4000, 0xff9: 0x4000, 0xffa: 0x4000, 0xffb: 0x4000, - 0xffc: 0x4000, - // Block 0x40, offset 0x1000 - 0x1000: 0x4000, 0x1001: 0x4000, 0x1002: 0x4000, 0x1003: 0x4000, 0x1004: 0x4000, 0x1005: 0x4000, - 0x1006: 0x4000, 0x1007: 0x4000, 0x1008: 0x4000, 0x1009: 0x4000, 0x100a: 0x4000, 0x100b: 0x4000, - 0x100c: 0x4000, 0x100d: 0x4000, 0x100e: 0x4000, 0x100f: 0x4000, 0x1010: 0x4000, 0x1011: 0x4000, - 0x1012: 0x4000, 0x1013: 0x4000, 0x1014: 0x4000, 0x1015: 0x4000, 0x1016: 0x4000, 0x1017: 0x4000, - 0x1018: 0x4000, 0x1019: 0x4000, 0x101a: 0x4000, 0x101b: 0x4000, 0x101c: 0x4000, 0x101d: 0x4000, - 0x101e: 0x4000, 0x101f: 0x4000, 0x1020: 0x4000, 0x1021: 0x4000, 0x1022: 0x4000, 0x1023: 0x4000, - // Block 0x41, offset 0x1040 - 0x1040: 0x2000, 0x1041: 0x2000, 0x1042: 0x2000, 0x1043: 0x2000, 0x1044: 0x2000, 0x1045: 0x2000, - 0x1046: 0x2000, 0x1047: 0x2000, 0x1048: 0x2000, 0x1049: 0x2000, 0x104a: 0x2000, 0x104b: 0x2000, - 0x104c: 0x2000, 0x104d: 0x2000, 0x104e: 0x2000, 0x104f: 0x2000, 0x1050: 0x4000, 0x1051: 0x4000, - 0x1052: 0x4000, 0x1053: 0x4000, 0x1054: 0x4000, 0x1055: 0x4000, 0x1056: 0x4000, 0x1057: 0x4000, - 0x1058: 0x4000, 0x1059: 0x4000, - 0x1070: 0x4000, 0x1071: 0x4000, 0x1072: 0x4000, 0x1073: 0x4000, 0x1074: 0x4000, 0x1075: 0x4000, - 0x1076: 0x4000, 0x1077: 0x4000, 0x1078: 0x4000, 0x1079: 0x4000, 0x107a: 0x4000, 0x107b: 0x4000, - 0x107c: 0x4000, 0x107d: 0x4000, 0x107e: 0x4000, 0x107f: 0x4000, - // Block 0x42, offset 0x1080 - 0x1080: 0x4000, 0x1081: 0x4000, 0x1082: 0x4000, 0x1083: 0x4000, 0x1084: 0x4000, 0x1085: 0x4000, - 0x1086: 0x4000, 0x1087: 0x4000, 0x1088: 0x4000, 0x1089: 0x4000, 0x108a: 0x4000, 0x108b: 0x4000, - 0x108c: 0x4000, 0x108d: 0x4000, 0x108e: 0x4000, 0x108f: 0x4000, 0x1090: 0x4000, 0x1091: 0x4000, - 0x1092: 0x4000, 0x1094: 0x4000, 0x1095: 0x4000, 0x1096: 0x4000, 0x1097: 0x4000, - 0x1098: 0x4000, 0x1099: 0x4000, 0x109a: 0x4000, 0x109b: 0x4000, 0x109c: 0x4000, 0x109d: 0x4000, - 0x109e: 0x4000, 0x109f: 0x4000, 0x10a0: 0x4000, 0x10a1: 0x4000, 0x10a2: 0x4000, 0x10a3: 0x4000, - 0x10a4: 0x4000, 0x10a5: 0x4000, 0x10a6: 0x4000, 0x10a8: 0x4000, 0x10a9: 0x4000, - 0x10aa: 0x4000, 0x10ab: 0x4000, - // Block 0x43, offset 0x10c0 - 0x10c1: 0x9012, 0x10c2: 0x9012, 0x10c3: 0x9012, 0x10c4: 0x9012, 0x10c5: 0x9012, - 0x10c6: 0x9012, 0x10c7: 0x9012, 0x10c8: 0x9012, 0x10c9: 0x9012, 0x10ca: 0x9012, 0x10cb: 0x9012, - 0x10cc: 0x9012, 0x10cd: 0x9012, 0x10ce: 0x9012, 0x10cf: 0x9012, 0x10d0: 0x9012, 0x10d1: 0x9012, - 0x10d2: 0x9012, 0x10d3: 0x9012, 0x10d4: 0x9012, 0x10d5: 0x9012, 0x10d6: 0x9012, 0x10d7: 0x9012, - 0x10d8: 0x9012, 0x10d9: 0x9012, 0x10da: 0x9012, 0x10db: 0x9012, 0x10dc: 0x9012, 0x10dd: 0x9012, - 0x10de: 0x9012, 0x10df: 0x9012, 0x10e0: 0x9049, 0x10e1: 0x9049, 0x10e2: 0x9049, 0x10e3: 0x9049, - 0x10e4: 0x9049, 0x10e5: 0x9049, 0x10e6: 0x9049, 0x10e7: 0x9049, 0x10e8: 0x9049, 0x10e9: 0x9049, - 0x10ea: 0x9049, 0x10eb: 0x9049, 0x10ec: 0x9049, 0x10ed: 0x9049, 0x10ee: 0x9049, 0x10ef: 0x9049, - 0x10f0: 0x9049, 0x10f1: 0x9049, 0x10f2: 0x9049, 0x10f3: 0x9049, 0x10f4: 0x9049, 0x10f5: 0x9049, - 0x10f6: 0x9049, 0x10f7: 0x9049, 0x10f8: 0x9049, 0x10f9: 0x9049, 0x10fa: 0x9049, 0x10fb: 0x9049, - 0x10fc: 0x9049, 0x10fd: 0x9049, 0x10fe: 0x9049, 0x10ff: 0x9049, - // Block 0x44, offset 0x1100 - 0x1100: 0x9049, 0x1101: 0x9049, 0x1102: 0x9049, 0x1103: 0x9049, 0x1104: 0x9049, 0x1105: 0x9049, - 0x1106: 0x9049, 0x1107: 0x9049, 0x1108: 0x9049, 0x1109: 0x9049, 0x110a: 0x9049, 0x110b: 0x9049, - 0x110c: 0x9049, 0x110d: 0x9049, 0x110e: 0x9049, 0x110f: 0x9049, 0x1110: 0x9049, 0x1111: 0x9049, - 0x1112: 0x9049, 0x1113: 0x9049, 0x1114: 0x9049, 0x1115: 0x9049, 0x1116: 0x9049, 0x1117: 0x9049, - 0x1118: 0x9049, 0x1119: 0x9049, 0x111a: 0x9049, 0x111b: 0x9049, 0x111c: 0x9049, 0x111d: 0x9049, - 0x111e: 0x9049, 0x111f: 0x904a, 0x1120: 0x904b, 0x1121: 0xb04c, 0x1122: 0xb04d, 0x1123: 0xb04d, - 0x1124: 0xb04e, 0x1125: 0xb04f, 0x1126: 0xb050, 0x1127: 0xb051, 0x1128: 0xb052, 0x1129: 0xb053, - 0x112a: 0xb054, 0x112b: 0xb055, 0x112c: 0xb056, 0x112d: 0xb057, 0x112e: 0xb058, 0x112f: 0xb059, - 0x1130: 0xb05a, 0x1131: 0xb05b, 0x1132: 0xb05c, 0x1133: 0xb05d, 0x1134: 0xb05e, 0x1135: 0xb05f, - 0x1136: 0xb060, 0x1137: 0xb061, 0x1138: 0xb062, 0x1139: 0xb063, 0x113a: 0xb064, 0x113b: 0xb065, - 0x113c: 0xb052, 0x113d: 0xb066, 0x113e: 0xb067, 0x113f: 0xb055, - // Block 0x45, offset 0x1140 - 0x1140: 0xb068, 0x1141: 0xb069, 0x1142: 0xb06a, 0x1143: 0xb06b, 0x1144: 0xb05a, 0x1145: 0xb056, - 0x1146: 0xb06c, 0x1147: 0xb06d, 0x1148: 0xb06b, 0x1149: 0xb06e, 0x114a: 0xb06b, 0x114b: 0xb06f, - 0x114c: 0xb06f, 0x114d: 0xb070, 0x114e: 0xb070, 0x114f: 0xb071, 0x1150: 0xb056, 0x1151: 0xb072, - 0x1152: 0xb073, 0x1153: 0xb072, 0x1154: 0xb074, 0x1155: 0xb073, 0x1156: 0xb075, 0x1157: 0xb075, - 0x1158: 0xb076, 0x1159: 0xb076, 0x115a: 0xb077, 0x115b: 0xb077, 0x115c: 0xb073, 0x115d: 0xb078, - 0x115e: 0xb079, 0x115f: 0xb067, 0x1160: 0xb07a, 0x1161: 0xb07b, 0x1162: 0xb07b, 0x1163: 0xb07b, - 0x1164: 0xb07b, 0x1165: 0xb07b, 0x1166: 0xb07b, 0x1167: 0xb07b, 0x1168: 0xb07b, 0x1169: 0xb07b, - 0x116a: 0xb07b, 0x116b: 0xb07b, 0x116c: 0xb07b, 0x116d: 0xb07b, 0x116e: 0xb07b, 0x116f: 0xb07b, - 0x1170: 0xb07c, 0x1171: 0xb07c, 0x1172: 0xb07c, 0x1173: 0xb07c, 0x1174: 0xb07c, 0x1175: 0xb07c, - 0x1176: 0xb07c, 0x1177: 0xb07c, 0x1178: 0xb07c, 0x1179: 0xb07c, 0x117a: 0xb07c, 0x117b: 0xb07c, - 0x117c: 0xb07c, 0x117d: 0xb07c, 0x117e: 0xb07c, - // Block 0x46, offset 0x1180 - 0x1182: 0xb07d, 0x1183: 0xb07e, 0x1184: 0xb07f, 0x1185: 0xb080, - 0x1186: 0xb07f, 0x1187: 0xb07e, 0x118a: 0xb081, 0x118b: 0xb082, - 0x118c: 0xb083, 0x118d: 0xb07f, 0x118e: 0xb080, 0x118f: 0xb07f, - 0x1192: 0xb084, 0x1193: 0xb085, 0x1194: 0xb084, 0x1195: 0xb086, 0x1196: 0xb084, 0x1197: 0xb087, - 0x119a: 0xb088, 0x119b: 0xb089, 0x119c: 0xb08a, - 0x11a0: 0x908b, 0x11a1: 0x908b, 0x11a2: 0x908c, 0x11a3: 0x908d, - 0x11a4: 0x908b, 0x11a5: 0x908e, 0x11a6: 0x908f, 0x11a8: 0xb090, 0x11a9: 0xb091, - 0x11aa: 0xb092, 0x11ab: 0xb091, 0x11ac: 0xb093, 0x11ad: 0xb094, 0x11ae: 0xb095, - 0x11bd: 0x2000, - // Block 0x47, offset 0x11c0 - 0x11e0: 0x4000, 0x11e1: 0x4000, 0x11e2: 0x4000, 0x11e3: 0x4000, - // Block 0x48, offset 0x1200 - 0x1200: 0x4000, 0x1201: 0x4000, 0x1202: 0x4000, 0x1203: 0x4000, 0x1204: 0x4000, 0x1205: 0x4000, - 0x1206: 0x4000, 0x1207: 0x4000, 0x1208: 0x4000, 0x1209: 0x4000, 0x120a: 0x4000, 0x120b: 0x4000, - 0x120c: 0x4000, 0x120d: 0x4000, 0x120e: 0x4000, 0x120f: 0x4000, 0x1210: 0x4000, 0x1211: 0x4000, - 0x1212: 0x4000, 0x1213: 0x4000, 0x1214: 0x4000, 0x1215: 0x4000, 0x1216: 0x4000, 0x1217: 0x4000, - 0x1218: 0x4000, 0x1219: 0x4000, 0x121a: 0x4000, 0x121b: 0x4000, 0x121c: 0x4000, 0x121d: 0x4000, - 0x121e: 0x4000, 0x121f: 0x4000, 0x1220: 0x4000, 0x1221: 0x4000, 0x1222: 0x4000, 0x1223: 0x4000, - 0x1224: 0x4000, 0x1225: 0x4000, 0x1226: 0x4000, 0x1227: 0x4000, 0x1228: 0x4000, 0x1229: 0x4000, - 0x122a: 0x4000, 0x122b: 0x4000, 0x122c: 0x4000, 0x122d: 0x4000, 0x122e: 0x4000, 0x122f: 0x4000, - 0x1230: 0x4000, 0x1231: 0x4000, 0x1232: 0x4000, 0x1233: 0x4000, 0x1234: 0x4000, 0x1235: 0x4000, - 0x1236: 0x4000, 0x1237: 0x4000, - // Block 0x49, offset 0x1240 - 0x1240: 0x4000, 0x1241: 0x4000, 0x1242: 0x4000, 0x1243: 0x4000, 0x1244: 0x4000, 0x1245: 0x4000, - 0x1246: 0x4000, 0x1247: 0x4000, 0x1248: 0x4000, 0x1249: 0x4000, 0x124a: 0x4000, 0x124b: 0x4000, - 0x124c: 0x4000, 0x124d: 0x4000, 0x124e: 0x4000, 0x124f: 0x4000, 0x1250: 0x4000, 0x1251: 0x4000, - 0x1252: 0x4000, 0x1253: 0x4000, 0x1254: 0x4000, 0x1255: 0x4000, 0x1256: 0x4000, 0x1257: 0x4000, - 0x1258: 0x4000, 0x1259: 0x4000, 0x125a: 0x4000, 0x125b: 0x4000, 0x125c: 0x4000, 0x125d: 0x4000, - 0x125e: 0x4000, 0x125f: 0x4000, 0x1260: 0x4000, 0x1261: 0x4000, 0x1262: 0x4000, 0x1263: 0x4000, - 0x1264: 0x4000, 0x1265: 0x4000, 0x1266: 0x4000, 0x1267: 0x4000, 0x1268: 0x4000, 0x1269: 0x4000, - 0x126a: 0x4000, 0x126b: 0x4000, 0x126c: 0x4000, 0x126d: 0x4000, 0x126e: 0x4000, 0x126f: 0x4000, - 0x1270: 0x4000, 0x1271: 0x4000, 0x1272: 0x4000, - // Block 0x4a, offset 0x1280 - 0x1280: 0x4000, 0x1281: 0x4000, 0x1282: 0x4000, 0x1283: 0x4000, 0x1284: 0x4000, 0x1285: 0x4000, - 0x1286: 0x4000, 0x1287: 0x4000, 0x1288: 0x4000, 0x1289: 0x4000, 0x128a: 0x4000, 0x128b: 0x4000, - 0x128c: 0x4000, 0x128d: 0x4000, 0x128e: 0x4000, 0x128f: 0x4000, 0x1290: 0x4000, 0x1291: 0x4000, - 0x1292: 0x4000, 0x1293: 0x4000, 0x1294: 0x4000, 0x1295: 0x4000, 0x1296: 0x4000, 0x1297: 0x4000, - 0x1298: 0x4000, 0x1299: 0x4000, 0x129a: 0x4000, 0x129b: 0x4000, 0x129c: 0x4000, 0x129d: 0x4000, - 0x129e: 0x4000, - // Block 0x4b, offset 0x12c0 - 0x12d0: 0x4000, 0x12d1: 0x4000, - 0x12d2: 0x4000, - 0x12e4: 0x4000, 0x12e5: 0x4000, 0x12e6: 0x4000, 0x12e7: 0x4000, - 0x12f0: 0x4000, 0x12f1: 0x4000, 0x12f2: 0x4000, 0x12f3: 0x4000, 0x12f4: 0x4000, 0x12f5: 0x4000, - 0x12f6: 0x4000, 0x12f7: 0x4000, 0x12f8: 0x4000, 0x12f9: 0x4000, 0x12fa: 0x4000, 0x12fb: 0x4000, - 0x12fc: 0x4000, 0x12fd: 0x4000, 0x12fe: 0x4000, 0x12ff: 0x4000, - // Block 0x4c, offset 0x1300 - 0x1300: 0x4000, 0x1301: 0x4000, 0x1302: 0x4000, 0x1303: 0x4000, 0x1304: 0x4000, 0x1305: 0x4000, - 0x1306: 0x4000, 0x1307: 0x4000, 0x1308: 0x4000, 0x1309: 0x4000, 0x130a: 0x4000, 0x130b: 0x4000, - 0x130c: 0x4000, 0x130d: 0x4000, 0x130e: 0x4000, 0x130f: 0x4000, 0x1310: 0x4000, 0x1311: 0x4000, - 0x1312: 0x4000, 0x1313: 0x4000, 0x1314: 0x4000, 0x1315: 0x4000, 0x1316: 0x4000, 0x1317: 0x4000, - 0x1318: 0x4000, 0x1319: 0x4000, 0x131a: 0x4000, 0x131b: 0x4000, 0x131c: 0x4000, 0x131d: 0x4000, - 0x131e: 0x4000, 0x131f: 0x4000, 0x1320: 0x4000, 0x1321: 0x4000, 0x1322: 0x4000, 0x1323: 0x4000, - 0x1324: 0x4000, 0x1325: 0x4000, 0x1326: 0x4000, 0x1327: 0x4000, 0x1328: 0x4000, 0x1329: 0x4000, - 0x132a: 0x4000, 0x132b: 0x4000, 0x132c: 0x4000, 0x132d: 0x4000, 0x132e: 0x4000, 0x132f: 0x4000, - 0x1330: 0x4000, 0x1331: 0x4000, 0x1332: 0x4000, 0x1333: 0x4000, 0x1334: 0x4000, 0x1335: 0x4000, - 0x1336: 0x4000, 0x1337: 0x4000, 0x1338: 0x4000, 0x1339: 0x4000, 0x133a: 0x4000, 0x133b: 0x4000, - // Block 0x4d, offset 0x1340 - 0x1344: 0x4000, - // Block 0x4e, offset 0x1380 - 0x138f: 0x4000, - // Block 0x4f, offset 0x13c0 - 0x13c0: 0x2000, 0x13c1: 0x2000, 0x13c2: 0x2000, 0x13c3: 0x2000, 0x13c4: 0x2000, 0x13c5: 0x2000, - 0x13c6: 0x2000, 0x13c7: 0x2000, 0x13c8: 0x2000, 0x13c9: 0x2000, 0x13ca: 0x2000, - 0x13d0: 0x2000, 0x13d1: 0x2000, - 0x13d2: 0x2000, 0x13d3: 0x2000, 0x13d4: 0x2000, 0x13d5: 0x2000, 0x13d6: 0x2000, 0x13d7: 0x2000, - 0x13d8: 0x2000, 0x13d9: 0x2000, 0x13da: 0x2000, 0x13db: 0x2000, 0x13dc: 0x2000, 0x13dd: 0x2000, - 0x13de: 0x2000, 0x13df: 0x2000, 0x13e0: 0x2000, 0x13e1: 0x2000, 0x13e2: 0x2000, 0x13e3: 0x2000, - 0x13e4: 0x2000, 0x13e5: 0x2000, 0x13e6: 0x2000, 0x13e7: 0x2000, 0x13e8: 0x2000, 0x13e9: 0x2000, - 0x13ea: 0x2000, 0x13eb: 0x2000, 0x13ec: 0x2000, 0x13ed: 0x2000, - 0x13f0: 0x2000, 0x13f1: 0x2000, 0x13f2: 0x2000, 0x13f3: 0x2000, 0x13f4: 0x2000, 0x13f5: 0x2000, - 0x13f6: 0x2000, 0x13f7: 0x2000, 0x13f8: 0x2000, 0x13f9: 0x2000, 0x13fa: 0x2000, 0x13fb: 0x2000, - 0x13fc: 0x2000, 0x13fd: 0x2000, 0x13fe: 0x2000, 0x13ff: 0x2000, - // Block 0x50, offset 0x1400 - 0x1400: 0x2000, 0x1401: 0x2000, 0x1402: 0x2000, 0x1403: 0x2000, 0x1404: 0x2000, 0x1405: 0x2000, - 0x1406: 0x2000, 0x1407: 0x2000, 0x1408: 0x2000, 0x1409: 0x2000, 0x140a: 0x2000, 0x140b: 0x2000, - 0x140c: 0x2000, 0x140d: 0x2000, 0x140e: 0x2000, 0x140f: 0x2000, 0x1410: 0x2000, 0x1411: 0x2000, - 0x1412: 0x2000, 0x1413: 0x2000, 0x1414: 0x2000, 0x1415: 0x2000, 0x1416: 0x2000, 0x1417: 0x2000, - 0x1418: 0x2000, 0x1419: 0x2000, 0x141a: 0x2000, 0x141b: 0x2000, 0x141c: 0x2000, 0x141d: 0x2000, - 0x141e: 0x2000, 0x141f: 0x2000, 0x1420: 0x2000, 0x1421: 0x2000, 0x1422: 0x2000, 0x1423: 0x2000, - 0x1424: 0x2000, 0x1425: 0x2000, 0x1426: 0x2000, 0x1427: 0x2000, 0x1428: 0x2000, 0x1429: 0x2000, - 0x1430: 0x2000, 0x1431: 0x2000, 0x1432: 0x2000, 0x1433: 0x2000, 0x1434: 0x2000, 0x1435: 0x2000, - 0x1436: 0x2000, 0x1437: 0x2000, 0x1438: 0x2000, 0x1439: 0x2000, 0x143a: 0x2000, 0x143b: 0x2000, - 0x143c: 0x2000, 0x143d: 0x2000, 0x143e: 0x2000, 0x143f: 0x2000, - // Block 0x51, offset 0x1440 - 0x1440: 0x2000, 0x1441: 0x2000, 0x1442: 0x2000, 0x1443: 0x2000, 0x1444: 0x2000, 0x1445: 0x2000, - 0x1446: 0x2000, 0x1447: 0x2000, 0x1448: 0x2000, 0x1449: 0x2000, 0x144a: 0x2000, 0x144b: 0x2000, - 0x144c: 0x2000, 0x144d: 0x2000, 0x144e: 0x4000, 0x144f: 0x2000, 0x1450: 0x2000, 0x1451: 0x4000, - 0x1452: 0x4000, 0x1453: 0x4000, 0x1454: 0x4000, 0x1455: 0x4000, 0x1456: 0x4000, 0x1457: 0x4000, - 0x1458: 0x4000, 0x1459: 0x4000, 0x145a: 0x4000, 0x145b: 0x2000, 0x145c: 0x2000, 0x145d: 0x2000, - 0x145e: 0x2000, 0x145f: 0x2000, 0x1460: 0x2000, 0x1461: 0x2000, 0x1462: 0x2000, 0x1463: 0x2000, - 0x1464: 0x2000, 0x1465: 0x2000, 0x1466: 0x2000, 0x1467: 0x2000, 0x1468: 0x2000, 0x1469: 0x2000, - 0x146a: 0x2000, 0x146b: 0x2000, 0x146c: 0x2000, - // Block 0x52, offset 0x1480 - 0x1480: 0x4000, 0x1481: 0x4000, 0x1482: 0x4000, - 0x1490: 0x4000, 0x1491: 0x4000, - 0x1492: 0x4000, 0x1493: 0x4000, 0x1494: 0x4000, 0x1495: 0x4000, 0x1496: 0x4000, 0x1497: 0x4000, - 0x1498: 0x4000, 0x1499: 0x4000, 0x149a: 0x4000, 0x149b: 0x4000, 0x149c: 0x4000, 0x149d: 0x4000, - 0x149e: 0x4000, 0x149f: 0x4000, 0x14a0: 0x4000, 0x14a1: 0x4000, 0x14a2: 0x4000, 0x14a3: 0x4000, - 0x14a4: 0x4000, 0x14a5: 0x4000, 0x14a6: 0x4000, 0x14a7: 0x4000, 0x14a8: 0x4000, 0x14a9: 0x4000, - 0x14aa: 0x4000, 0x14ab: 0x4000, 0x14ac: 0x4000, 0x14ad: 0x4000, 0x14ae: 0x4000, 0x14af: 0x4000, - 0x14b0: 0x4000, 0x14b1: 0x4000, 0x14b2: 0x4000, 0x14b3: 0x4000, 0x14b4: 0x4000, 0x14b5: 0x4000, - 0x14b6: 0x4000, 0x14b7: 0x4000, 0x14b8: 0x4000, 0x14b9: 0x4000, 0x14ba: 0x4000, 0x14bb: 0x4000, - // Block 0x53, offset 0x14c0 - 0x14c0: 0x4000, 0x14c1: 0x4000, 0x14c2: 0x4000, 0x14c3: 0x4000, 0x14c4: 0x4000, 0x14c5: 0x4000, - 0x14c6: 0x4000, 0x14c7: 0x4000, 0x14c8: 0x4000, - 0x14d0: 0x4000, 0x14d1: 0x4000, - 0x14e0: 0x4000, 0x14e1: 0x4000, 0x14e2: 0x4000, 0x14e3: 0x4000, - 0x14e4: 0x4000, 0x14e5: 0x4000, - // Block 0x54, offset 0x1500 - 0x1500: 0x4000, 0x1501: 0x4000, 0x1502: 0x4000, 0x1503: 0x4000, 0x1504: 0x4000, 0x1505: 0x4000, - 0x1506: 0x4000, 0x1507: 0x4000, 0x1508: 0x4000, 0x1509: 0x4000, 0x150a: 0x4000, 0x150b: 0x4000, - 0x150c: 0x4000, 0x150d: 0x4000, 0x150e: 0x4000, 0x150f: 0x4000, 0x1510: 0x4000, 0x1511: 0x4000, - 0x1512: 0x4000, 0x1513: 0x4000, 0x1514: 0x4000, 0x1515: 0x4000, 0x1516: 0x4000, 0x1517: 0x4000, - 0x1518: 0x4000, 0x1519: 0x4000, 0x151a: 0x4000, 0x151b: 0x4000, 0x151c: 0x4000, 0x151d: 0x4000, - 0x151e: 0x4000, 0x151f: 0x4000, 0x1520: 0x4000, - 0x152d: 0x4000, 0x152e: 0x4000, 0x152f: 0x4000, - 0x1530: 0x4000, 0x1531: 0x4000, 0x1532: 0x4000, 0x1533: 0x4000, 0x1534: 0x4000, 0x1535: 0x4000, - 0x1537: 0x4000, 0x1538: 0x4000, 0x1539: 0x4000, 0x153a: 0x4000, 0x153b: 0x4000, - 0x153c: 0x4000, 0x153d: 0x4000, 0x153e: 0x4000, 0x153f: 0x4000, - // Block 0x55, offset 0x1540 - 0x1540: 0x4000, 0x1541: 0x4000, 0x1542: 0x4000, 0x1543: 0x4000, 0x1544: 0x4000, 0x1545: 0x4000, - 0x1546: 0x4000, 0x1547: 0x4000, 0x1548: 0x4000, 0x1549: 0x4000, 0x154a: 0x4000, 0x154b: 0x4000, - 0x154c: 0x4000, 0x154d: 0x4000, 0x154e: 0x4000, 0x154f: 0x4000, 0x1550: 0x4000, 0x1551: 0x4000, - 0x1552: 0x4000, 0x1553: 0x4000, 0x1554: 0x4000, 0x1555: 0x4000, 0x1556: 0x4000, 0x1557: 0x4000, - 0x1558: 0x4000, 0x1559: 0x4000, 0x155a: 0x4000, 0x155b: 0x4000, 0x155c: 0x4000, 0x155d: 0x4000, - 0x155e: 0x4000, 0x155f: 0x4000, 0x1560: 0x4000, 0x1561: 0x4000, 0x1562: 0x4000, 0x1563: 0x4000, - 0x1564: 0x4000, 0x1565: 0x4000, 0x1566: 0x4000, 0x1567: 0x4000, 0x1568: 0x4000, 0x1569: 0x4000, - 0x156a: 0x4000, 0x156b: 0x4000, 0x156c: 0x4000, 0x156d: 0x4000, 0x156e: 0x4000, 0x156f: 0x4000, - 0x1570: 0x4000, 0x1571: 0x4000, 0x1572: 0x4000, 0x1573: 0x4000, 0x1574: 0x4000, 0x1575: 0x4000, - 0x1576: 0x4000, 0x1577: 0x4000, 0x1578: 0x4000, 0x1579: 0x4000, 0x157a: 0x4000, 0x157b: 0x4000, - 0x157c: 0x4000, 0x157e: 0x4000, 0x157f: 0x4000, - // Block 0x56, offset 0x1580 - 0x1580: 0x4000, 0x1581: 0x4000, 0x1582: 0x4000, 0x1583: 0x4000, 0x1584: 0x4000, 0x1585: 0x4000, - 0x1586: 0x4000, 0x1587: 0x4000, 0x1588: 0x4000, 0x1589: 0x4000, 0x158a: 0x4000, 0x158b: 0x4000, - 0x158c: 0x4000, 0x158d: 0x4000, 0x158e: 0x4000, 0x158f: 0x4000, 0x1590: 0x4000, 0x1591: 0x4000, - 0x1592: 0x4000, 0x1593: 0x4000, - 0x15a0: 0x4000, 0x15a1: 0x4000, 0x15a2: 0x4000, 0x15a3: 0x4000, - 0x15a4: 0x4000, 0x15a5: 0x4000, 0x15a6: 0x4000, 0x15a7: 0x4000, 0x15a8: 0x4000, 0x15a9: 0x4000, - 0x15aa: 0x4000, 0x15ab: 0x4000, 0x15ac: 0x4000, 0x15ad: 0x4000, 0x15ae: 0x4000, 0x15af: 0x4000, - 0x15b0: 0x4000, 0x15b1: 0x4000, 0x15b2: 0x4000, 0x15b3: 0x4000, 0x15b4: 0x4000, 0x15b5: 0x4000, - 0x15b6: 0x4000, 0x15b7: 0x4000, 0x15b8: 0x4000, 0x15b9: 0x4000, 0x15ba: 0x4000, 0x15bb: 0x4000, - 0x15bc: 0x4000, 0x15bd: 0x4000, 0x15be: 0x4000, 0x15bf: 0x4000, - // Block 0x57, offset 0x15c0 - 0x15c0: 0x4000, 0x15c1: 0x4000, 0x15c2: 0x4000, 0x15c3: 0x4000, 0x15c4: 0x4000, 0x15c5: 0x4000, - 0x15c6: 0x4000, 0x15c7: 0x4000, 0x15c8: 0x4000, 0x15c9: 0x4000, 0x15ca: 0x4000, - 0x15cf: 0x4000, 0x15d0: 0x4000, 0x15d1: 0x4000, - 0x15d2: 0x4000, 0x15d3: 0x4000, - 0x15e0: 0x4000, 0x15e1: 0x4000, 0x15e2: 0x4000, 0x15e3: 0x4000, - 0x15e4: 0x4000, 0x15e5: 0x4000, 0x15e6: 0x4000, 0x15e7: 0x4000, 0x15e8: 0x4000, 0x15e9: 0x4000, - 0x15ea: 0x4000, 0x15eb: 0x4000, 0x15ec: 0x4000, 0x15ed: 0x4000, 0x15ee: 0x4000, 0x15ef: 0x4000, - 0x15f0: 0x4000, 0x15f4: 0x4000, - 0x15f8: 0x4000, 0x15f9: 0x4000, 0x15fa: 0x4000, 0x15fb: 0x4000, - 0x15fc: 0x4000, 0x15fd: 0x4000, 0x15fe: 0x4000, 0x15ff: 0x4000, - // Block 0x58, offset 0x1600 - 0x1600: 0x4000, 0x1602: 0x4000, 0x1603: 0x4000, 0x1604: 0x4000, 0x1605: 0x4000, - 0x1606: 0x4000, 0x1607: 0x4000, 0x1608: 0x4000, 0x1609: 0x4000, 0x160a: 0x4000, 0x160b: 0x4000, - 0x160c: 0x4000, 0x160d: 0x4000, 0x160e: 0x4000, 0x160f: 0x4000, 0x1610: 0x4000, 0x1611: 0x4000, - 0x1612: 0x4000, 0x1613: 0x4000, 0x1614: 0x4000, 0x1615: 0x4000, 0x1616: 0x4000, 0x1617: 0x4000, - 0x1618: 0x4000, 0x1619: 0x4000, 0x161a: 0x4000, 0x161b: 0x4000, 0x161c: 0x4000, 0x161d: 0x4000, - 0x161e: 0x4000, 0x161f: 0x4000, 0x1620: 0x4000, 0x1621: 0x4000, 0x1622: 0x4000, 0x1623: 0x4000, - 0x1624: 0x4000, 0x1625: 0x4000, 0x1626: 0x4000, 0x1627: 0x4000, 0x1628: 0x4000, 0x1629: 0x4000, - 0x162a: 0x4000, 0x162b: 0x4000, 0x162c: 0x4000, 0x162d: 0x4000, 0x162e: 0x4000, 0x162f: 0x4000, - 0x1630: 0x4000, 0x1631: 0x4000, 0x1632: 0x4000, 0x1633: 0x4000, 0x1634: 0x4000, 0x1635: 0x4000, - 0x1636: 0x4000, 0x1637: 0x4000, 0x1638: 0x4000, 0x1639: 0x4000, 0x163a: 0x4000, 0x163b: 0x4000, - 0x163c: 0x4000, 0x163d: 0x4000, 0x163e: 0x4000, 0x163f: 0x4000, - // Block 0x59, offset 0x1640 - 0x1640: 0x4000, 0x1641: 0x4000, 0x1642: 0x4000, 0x1643: 0x4000, 0x1644: 0x4000, 0x1645: 0x4000, - 0x1646: 0x4000, 0x1647: 0x4000, 0x1648: 0x4000, 0x1649: 0x4000, 0x164a: 0x4000, 0x164b: 0x4000, - 0x164c: 0x4000, 0x164d: 0x4000, 0x164e: 0x4000, 0x164f: 0x4000, 0x1650: 0x4000, 0x1651: 0x4000, - 0x1652: 0x4000, 0x1653: 0x4000, 0x1654: 0x4000, 0x1655: 0x4000, 0x1656: 0x4000, 0x1657: 0x4000, - 0x1658: 0x4000, 0x1659: 0x4000, 0x165a: 0x4000, 0x165b: 0x4000, 0x165c: 0x4000, 0x165d: 0x4000, - 0x165e: 0x4000, 0x165f: 0x4000, 0x1660: 0x4000, 0x1661: 0x4000, 0x1662: 0x4000, 0x1663: 0x4000, - 0x1664: 0x4000, 0x1665: 0x4000, 0x1666: 0x4000, 0x1667: 0x4000, 0x1668: 0x4000, 0x1669: 0x4000, - 0x166a: 0x4000, 0x166b: 0x4000, 0x166c: 0x4000, 0x166d: 0x4000, 0x166e: 0x4000, 0x166f: 0x4000, - 0x1670: 0x4000, 0x1671: 0x4000, 0x1672: 0x4000, 0x1673: 0x4000, 0x1674: 0x4000, 0x1675: 0x4000, - 0x1676: 0x4000, 0x1677: 0x4000, 0x1678: 0x4000, 0x1679: 0x4000, 0x167a: 0x4000, 0x167b: 0x4000, - 0x167c: 0x4000, 0x167f: 0x4000, - // Block 0x5a, offset 0x1680 - 0x1680: 0x4000, 0x1681: 0x4000, 0x1682: 0x4000, 0x1683: 0x4000, 0x1684: 0x4000, 0x1685: 0x4000, - 0x1686: 0x4000, 0x1687: 0x4000, 0x1688: 0x4000, 0x1689: 0x4000, 0x168a: 0x4000, 0x168b: 0x4000, - 0x168c: 0x4000, 0x168d: 0x4000, 0x168e: 0x4000, 0x168f: 0x4000, 0x1690: 0x4000, 0x1691: 0x4000, - 0x1692: 0x4000, 0x1693: 0x4000, 0x1694: 0x4000, 0x1695: 0x4000, 0x1696: 0x4000, 0x1697: 0x4000, - 0x1698: 0x4000, 0x1699: 0x4000, 0x169a: 0x4000, 0x169b: 0x4000, 0x169c: 0x4000, 0x169d: 0x4000, - 0x169e: 0x4000, 0x169f: 0x4000, 0x16a0: 0x4000, 0x16a1: 0x4000, 0x16a2: 0x4000, 0x16a3: 0x4000, - 0x16a4: 0x4000, 0x16a5: 0x4000, 0x16a6: 0x4000, 0x16a7: 0x4000, 0x16a8: 0x4000, 0x16a9: 0x4000, - 0x16aa: 0x4000, 0x16ab: 0x4000, 0x16ac: 0x4000, 0x16ad: 0x4000, 0x16ae: 0x4000, 0x16af: 0x4000, - 0x16b0: 0x4000, 0x16b1: 0x4000, 0x16b2: 0x4000, 0x16b3: 0x4000, 0x16b4: 0x4000, 0x16b5: 0x4000, - 0x16b6: 0x4000, 0x16b7: 0x4000, 0x16b8: 0x4000, 0x16b9: 0x4000, 0x16ba: 0x4000, 0x16bb: 0x4000, - 0x16bc: 0x4000, 0x16bd: 0x4000, - // Block 0x5b, offset 0x16c0 - 0x16cb: 0x4000, - 0x16cc: 0x4000, 0x16cd: 0x4000, 0x16ce: 0x4000, 0x16d0: 0x4000, 0x16d1: 0x4000, - 0x16d2: 0x4000, 0x16d3: 0x4000, 0x16d4: 0x4000, 0x16d5: 0x4000, 0x16d6: 0x4000, 0x16d7: 0x4000, - 0x16d8: 0x4000, 0x16d9: 0x4000, 0x16da: 0x4000, 0x16db: 0x4000, 0x16dc: 0x4000, 0x16dd: 0x4000, - 0x16de: 0x4000, 0x16df: 0x4000, 0x16e0: 0x4000, 0x16e1: 0x4000, 0x16e2: 0x4000, 0x16e3: 0x4000, - 0x16e4: 0x4000, 0x16e5: 0x4000, 0x16e6: 0x4000, 0x16e7: 0x4000, - 0x16fa: 0x4000, - // Block 0x5c, offset 0x1700 - 0x1715: 0x4000, 0x1716: 0x4000, - 0x1724: 0x4000, - // Block 0x5d, offset 0x1740 - 0x177b: 0x4000, - 0x177c: 0x4000, 0x177d: 0x4000, 0x177e: 0x4000, 0x177f: 0x4000, - // Block 0x5e, offset 0x1780 - 0x1780: 0x4000, 0x1781: 0x4000, 0x1782: 0x4000, 0x1783: 0x4000, 0x1784: 0x4000, 0x1785: 0x4000, - 0x1786: 0x4000, 0x1787: 0x4000, 0x1788: 0x4000, 0x1789: 0x4000, 0x178a: 0x4000, 0x178b: 0x4000, - 0x178c: 0x4000, 0x178d: 0x4000, 0x178e: 0x4000, 0x178f: 0x4000, - // Block 0x5f, offset 0x17c0 - 0x17c0: 0x4000, 0x17c1: 0x4000, 0x17c2: 0x4000, 0x17c3: 0x4000, 0x17c4: 0x4000, 0x17c5: 0x4000, - 0x17cc: 0x4000, 0x17d0: 0x4000, 0x17d1: 0x4000, - 0x17d2: 0x4000, 0x17d5: 0x4000, - 0x17eb: 0x4000, 0x17ec: 0x4000, - 0x17f4: 0x4000, 0x17f5: 0x4000, - 0x17f6: 0x4000, 0x17f7: 0x4000, 0x17f8: 0x4000, 0x17f9: 0x4000, 0x17fa: 0x4000, - // Block 0x60, offset 0x1800 - 0x1820: 0x4000, 0x1821: 0x4000, 0x1822: 0x4000, 0x1823: 0x4000, - 0x1824: 0x4000, 0x1825: 0x4000, 0x1826: 0x4000, 0x1827: 0x4000, 0x1828: 0x4000, 0x1829: 0x4000, - 0x182a: 0x4000, 0x182b: 0x4000, - // Block 0x61, offset 0x1840 - 0x184d: 0x4000, 0x184e: 0x4000, 0x184f: 0x4000, 0x1850: 0x4000, 0x1851: 0x4000, - 0x1852: 0x4000, 0x1853: 0x4000, 0x1854: 0x4000, 0x1855: 0x4000, 0x1856: 0x4000, 0x1857: 0x4000, - 0x1858: 0x4000, 0x1859: 0x4000, 0x185a: 0x4000, 0x185b: 0x4000, 0x185c: 0x4000, 0x185d: 0x4000, - 0x185e: 0x4000, 0x185f: 0x4000, 0x1860: 0x4000, 0x1861: 0x4000, 0x1862: 0x4000, 0x1863: 0x4000, - 0x1864: 0x4000, 0x1865: 0x4000, 0x1866: 0x4000, 0x1867: 0x4000, 0x1868: 0x4000, 0x1869: 0x4000, - 0x186a: 0x4000, 0x186b: 0x4000, 0x186c: 0x4000, 0x186d: 0x4000, 0x186e: 0x4000, 0x186f: 0x4000, - 0x1870: 0x4000, 0x1871: 0x4000, 0x1872: 0x4000, 0x1873: 0x4000, 0x1874: 0x4000, 0x1875: 0x4000, - 0x1876: 0x4000, 0x1877: 0x4000, 0x1878: 0x4000, 0x1879: 0x4000, 0x187a: 0x4000, 0x187b: 0x4000, - 0x187c: 0x4000, 0x187d: 0x4000, 0x187e: 0x4000, 0x187f: 0x4000, - // Block 0x62, offset 0x1880 - 0x1880: 0x4000, 0x1881: 0x4000, 0x1882: 0x4000, 0x1883: 0x4000, 0x1884: 0x4000, 0x1885: 0x4000, - 0x1886: 0x4000, 0x1887: 0x4000, 0x1888: 0x4000, 0x1889: 0x4000, 0x188a: 0x4000, 0x188b: 0x4000, - 0x188c: 0x4000, 0x188d: 0x4000, 0x188e: 0x4000, 0x188f: 0x4000, 0x1890: 0x4000, 0x1891: 0x4000, - 0x1892: 0x4000, 0x1893: 0x4000, 0x1894: 0x4000, 0x1895: 0x4000, 0x1896: 0x4000, 0x1897: 0x4000, - 0x1898: 0x4000, 0x1899: 0x4000, 0x189a: 0x4000, 0x189b: 0x4000, 0x189c: 0x4000, 0x189d: 0x4000, - 0x189e: 0x4000, 0x189f: 0x4000, 0x18a0: 0x4000, 0x18a1: 0x4000, 0x18a2: 0x4000, 0x18a3: 0x4000, - 0x18a4: 0x4000, 0x18a5: 0x4000, 0x18a6: 0x4000, 0x18a7: 0x4000, 0x18a8: 0x4000, 0x18a9: 0x4000, - 0x18aa: 0x4000, 0x18ab: 0x4000, 0x18ac: 0x4000, 0x18ad: 0x4000, 0x18ae: 0x4000, 0x18af: 0x4000, - 0x18b0: 0x4000, 0x18b1: 0x4000, 0x18b3: 0x4000, 0x18b4: 0x4000, 0x18b5: 0x4000, - 0x18b6: 0x4000, 0x18ba: 0x4000, 0x18bb: 0x4000, - 0x18bc: 0x4000, 0x18bd: 0x4000, 0x18be: 0x4000, 0x18bf: 0x4000, - // Block 0x63, offset 0x18c0 - 0x18c0: 0x4000, 0x18c1: 0x4000, 0x18c2: 0x4000, 0x18c3: 0x4000, 0x18c4: 0x4000, 0x18c5: 0x4000, - 0x18c6: 0x4000, 0x18c7: 0x4000, 0x18c8: 0x4000, 0x18c9: 0x4000, 0x18ca: 0x4000, 0x18cb: 0x4000, - 0x18cc: 0x4000, 0x18cd: 0x4000, 0x18ce: 0x4000, 0x18cf: 0x4000, 0x18d0: 0x4000, 0x18d1: 0x4000, - 0x18d2: 0x4000, 0x18d3: 0x4000, 0x18d4: 0x4000, 0x18d5: 0x4000, 0x18d6: 0x4000, 0x18d7: 0x4000, - 0x18d8: 0x4000, 0x18d9: 0x4000, 0x18da: 0x4000, 0x18db: 0x4000, 0x18dc: 0x4000, 0x18dd: 0x4000, - 0x18de: 0x4000, 0x18df: 0x4000, 0x18e0: 0x4000, 0x18e1: 0x4000, 0x18e2: 0x4000, - 0x18e5: 0x4000, 0x18e6: 0x4000, 0x18e7: 0x4000, 0x18e8: 0x4000, 0x18e9: 0x4000, - 0x18ea: 0x4000, 0x18ee: 0x4000, 0x18ef: 0x4000, - 0x18f0: 0x4000, 0x18f1: 0x4000, 0x18f2: 0x4000, 0x18f3: 0x4000, 0x18f4: 0x4000, 0x18f5: 0x4000, - 0x18f6: 0x4000, 0x18f7: 0x4000, 0x18f8: 0x4000, 0x18f9: 0x4000, 0x18fa: 0x4000, 0x18fb: 0x4000, - 0x18fc: 0x4000, 0x18fd: 0x4000, 0x18fe: 0x4000, 0x18ff: 0x4000, - // Block 0x64, offset 0x1900 - 0x1900: 0x4000, 0x1901: 0x4000, 0x1902: 0x4000, 0x1903: 0x4000, 0x1904: 0x4000, 0x1905: 0x4000, - 0x1906: 0x4000, 0x1907: 0x4000, 0x1908: 0x4000, 0x1909: 0x4000, 0x190a: 0x4000, - 0x190d: 0x4000, 0x190e: 0x4000, 0x190f: 0x4000, 0x1910: 0x4000, 0x1911: 0x4000, - 0x1912: 0x4000, 0x1913: 0x4000, 0x1914: 0x4000, 0x1915: 0x4000, 0x1916: 0x4000, 0x1917: 0x4000, - 0x1918: 0x4000, 0x1919: 0x4000, 0x191a: 0x4000, 0x191b: 0x4000, 0x191c: 0x4000, 0x191d: 0x4000, - 0x191e: 0x4000, 0x191f: 0x4000, 0x1920: 0x4000, 0x1921: 0x4000, 0x1922: 0x4000, 0x1923: 0x4000, - 0x1924: 0x4000, 0x1925: 0x4000, 0x1926: 0x4000, 0x1927: 0x4000, 0x1928: 0x4000, 0x1929: 0x4000, - 0x192a: 0x4000, 0x192b: 0x4000, 0x192c: 0x4000, 0x192d: 0x4000, 0x192e: 0x4000, 0x192f: 0x4000, - 0x1930: 0x4000, 0x1931: 0x4000, 0x1932: 0x4000, 0x1933: 0x4000, 0x1934: 0x4000, 0x1935: 0x4000, - 0x1936: 0x4000, 0x1937: 0x4000, 0x1938: 0x4000, 0x1939: 0x4000, 0x193a: 0x4000, 0x193b: 0x4000, - 0x193c: 0x4000, 0x193d: 0x4000, 0x193e: 0x4000, 0x193f: 0x4000, - // Block 0x65, offset 0x1940 - 0x1970: 0x4000, 0x1971: 0x4000, 0x1972: 0x4000, 0x1973: 0x4000, - 0x1978: 0x4000, 0x1979: 0x4000, 0x197a: 0x4000, - // Block 0x66, offset 0x1980 - 0x1980: 0x4000, 0x1981: 0x4000, 0x1982: 0x4000, - 0x1990: 0x4000, 0x1991: 0x4000, - 0x1992: 0x4000, 0x1993: 0x4000, 0x1994: 0x4000, 0x1995: 0x4000, - // Block 0x67, offset 0x19c0 - 0x19c0: 0x2000, 0x19c1: 0x2000, 0x19c2: 0x2000, 0x19c3: 0x2000, 0x19c4: 0x2000, 0x19c5: 0x2000, - 0x19c6: 0x2000, 0x19c7: 0x2000, 0x19c8: 0x2000, 0x19c9: 0x2000, 0x19ca: 0x2000, 0x19cb: 0x2000, - 0x19cc: 0x2000, 0x19cd: 0x2000, 0x19ce: 0x2000, 0x19cf: 0x2000, 0x19d0: 0x2000, 0x19d1: 0x2000, - 0x19d2: 0x2000, 0x19d3: 0x2000, 0x19d4: 0x2000, 0x19d5: 0x2000, 0x19d6: 0x2000, 0x19d7: 0x2000, - 0x19d8: 0x2000, 0x19d9: 0x2000, 0x19da: 0x2000, 0x19db: 0x2000, 0x19dc: 0x2000, 0x19dd: 0x2000, - 0x19de: 0x2000, 0x19df: 0x2000, 0x19e0: 0x2000, 0x19e1: 0x2000, 0x19e2: 0x2000, 0x19e3: 0x2000, - 0x19e4: 0x2000, 0x19e5: 0x2000, 0x19e6: 0x2000, 0x19e7: 0x2000, 0x19e8: 0x2000, 0x19e9: 0x2000, - 0x19ea: 0x2000, 0x19eb: 0x2000, 0x19ec: 0x2000, 0x19ed: 0x2000, 0x19ee: 0x2000, 0x19ef: 0x2000, - 0x19f0: 0x2000, 0x19f1: 0x2000, 0x19f2: 0x2000, 0x19f3: 0x2000, 0x19f4: 0x2000, 0x19f5: 0x2000, - 0x19f6: 0x2000, 0x19f7: 0x2000, 0x19f8: 0x2000, 0x19f9: 0x2000, 0x19fa: 0x2000, 0x19fb: 0x2000, - 0x19fc: 0x2000, 0x19fd: 0x2000, -} - -// widthIndex: 22 blocks, 1408 entries, 1408 bytes -// Block 0 is the zero block. -var widthIndex = [1408]uint8{ - // Block 0x0, offset 0x0 - // Block 0x1, offset 0x40 - // Block 0x2, offset 0x80 - // Block 0x3, offset 0xc0 - 0xc2: 0x01, 0xc3: 0x02, 0xc4: 0x03, 0xc5: 0x04, 0xc7: 0x05, - 0xc9: 0x06, 0xcb: 0x07, 0xcc: 0x08, 0xcd: 0x09, 0xce: 0x0a, 0xcf: 0x0b, - 0xd0: 0x0c, 0xd1: 0x0d, - 0xe1: 0x02, 0xe2: 0x03, 0xe3: 0x04, 0xe4: 0x05, 0xe5: 0x06, 0xe6: 0x06, 0xe7: 0x06, - 0xe8: 0x06, 0xe9: 0x06, 0xea: 0x07, 0xeb: 0x06, 0xec: 0x06, 0xed: 0x08, 0xee: 0x09, 0xef: 0x0a, - 0xf0: 0x0f, 0xf3: 0x12, 0xf4: 0x13, - // Block 0x4, offset 0x100 - 0x104: 0x0e, 0x105: 0x0f, - // Block 0x5, offset 0x140 - 0x140: 0x10, 0x141: 0x11, 0x142: 0x12, 0x144: 0x13, 0x145: 0x14, 0x146: 0x15, 0x147: 0x16, - 0x148: 0x17, 0x149: 0x18, 0x14a: 0x19, 0x14c: 0x1a, 0x14f: 0x1b, - 0x151: 0x1c, 0x152: 0x08, 0x153: 0x1d, 0x154: 0x1e, 0x155: 0x1f, 0x156: 0x20, 0x157: 0x21, - 0x158: 0x22, 0x159: 0x23, 0x15a: 0x24, 0x15b: 0x25, 0x15c: 0x26, 0x15d: 0x27, 0x15e: 0x28, 0x15f: 0x29, - 0x166: 0x2a, - 0x16c: 0x2b, 0x16d: 0x2c, - 0x17a: 0x2d, 0x17b: 0x2e, 0x17c: 0x0e, 0x17d: 0x0e, 0x17e: 0x0e, 0x17f: 0x2f, - // Block 0x6, offset 0x180 - 0x180: 0x30, 0x181: 0x31, 0x182: 0x32, 0x183: 0x33, 0x184: 0x34, 0x185: 0x35, 0x186: 0x36, 0x187: 0x37, - 0x188: 0x38, 0x189: 0x39, 0x18a: 0x0e, 0x18b: 0x3a, 0x18c: 0x0e, 0x18d: 0x0e, 0x18e: 0x0e, 0x18f: 0x0e, - 0x190: 0x0e, 0x191: 0x0e, 0x192: 0x0e, 0x193: 0x0e, 0x194: 0x0e, 0x195: 0x0e, 0x196: 0x0e, 0x197: 0x0e, - 0x198: 0x0e, 0x199: 0x0e, 0x19a: 0x0e, 0x19b: 0x0e, 0x19c: 0x0e, 0x19d: 0x0e, 0x19e: 0x0e, 0x19f: 0x0e, - 0x1a0: 0x0e, 0x1a1: 0x0e, 0x1a2: 0x0e, 0x1a3: 0x0e, 0x1a4: 0x0e, 0x1a5: 0x0e, 0x1a6: 0x0e, 0x1a7: 0x0e, - 0x1a8: 0x0e, 0x1a9: 0x0e, 0x1aa: 0x0e, 0x1ab: 0x0e, 0x1ac: 0x0e, 0x1ad: 0x0e, 0x1ae: 0x0e, 0x1af: 0x0e, - 0x1b0: 0x0e, 0x1b1: 0x0e, 0x1b2: 0x0e, 0x1b3: 0x0e, 0x1b4: 0x0e, 0x1b5: 0x0e, 0x1b6: 0x0e, 0x1b7: 0x0e, - 0x1b8: 0x0e, 0x1b9: 0x0e, 0x1ba: 0x0e, 0x1bb: 0x0e, 0x1bc: 0x0e, 0x1bd: 0x0e, 0x1be: 0x0e, 0x1bf: 0x0e, - // Block 0x7, offset 0x1c0 - 0x1c0: 0x0e, 0x1c1: 0x0e, 0x1c2: 0x0e, 0x1c3: 0x0e, 0x1c4: 0x0e, 0x1c5: 0x0e, 0x1c6: 0x0e, 0x1c7: 0x0e, - 0x1c8: 0x0e, 0x1c9: 0x0e, 0x1ca: 0x0e, 0x1cb: 0x0e, 0x1cc: 0x0e, 0x1cd: 0x0e, 0x1ce: 0x0e, 0x1cf: 0x0e, - 0x1d0: 0x0e, 0x1d1: 0x0e, 0x1d2: 0x0e, 0x1d3: 0x0e, 0x1d4: 0x0e, 0x1d5: 0x0e, 0x1d6: 0x0e, 0x1d7: 0x0e, - 0x1d8: 0x0e, 0x1d9: 0x0e, 0x1da: 0x0e, 0x1db: 0x0e, 0x1dc: 0x0e, 0x1dd: 0x0e, 0x1de: 0x0e, 0x1df: 0x0e, - 0x1e0: 0x0e, 0x1e1: 0x0e, 0x1e2: 0x0e, 0x1e3: 0x0e, 0x1e4: 0x0e, 0x1e5: 0x0e, 0x1e6: 0x0e, 0x1e7: 0x0e, - 0x1e8: 0x0e, 0x1e9: 0x0e, 0x1ea: 0x0e, 0x1eb: 0x0e, 0x1ec: 0x0e, 0x1ed: 0x0e, 0x1ee: 0x0e, 0x1ef: 0x0e, - 0x1f0: 0x0e, 0x1f1: 0x0e, 0x1f2: 0x0e, 0x1f3: 0x0e, 0x1f4: 0x0e, 0x1f5: 0x0e, 0x1f6: 0x0e, - 0x1f8: 0x0e, 0x1f9: 0x0e, 0x1fa: 0x0e, 0x1fb: 0x0e, 0x1fc: 0x0e, 0x1fd: 0x0e, 0x1fe: 0x0e, 0x1ff: 0x0e, - // Block 0x8, offset 0x200 - 0x200: 0x0e, 0x201: 0x0e, 0x202: 0x0e, 0x203: 0x0e, 0x204: 0x0e, 0x205: 0x0e, 0x206: 0x0e, 0x207: 0x0e, - 0x208: 0x0e, 0x209: 0x0e, 0x20a: 0x0e, 0x20b: 0x0e, 0x20c: 0x0e, 0x20d: 0x0e, 0x20e: 0x0e, 0x20f: 0x0e, - 0x210: 0x0e, 0x211: 0x0e, 0x212: 0x0e, 0x213: 0x0e, 0x214: 0x0e, 0x215: 0x0e, 0x216: 0x0e, 0x217: 0x0e, - 0x218: 0x0e, 0x219: 0x0e, 0x21a: 0x0e, 0x21b: 0x0e, 0x21c: 0x0e, 0x21d: 0x0e, 0x21e: 0x0e, 0x21f: 0x0e, - 0x220: 0x0e, 0x221: 0x0e, 0x222: 0x0e, 0x223: 0x0e, 0x224: 0x0e, 0x225: 0x0e, 0x226: 0x0e, 0x227: 0x0e, - 0x228: 0x0e, 0x229: 0x0e, 0x22a: 0x0e, 0x22b: 0x0e, 0x22c: 0x0e, 0x22d: 0x0e, 0x22e: 0x0e, 0x22f: 0x0e, - 0x230: 0x0e, 0x231: 0x0e, 0x232: 0x0e, 0x233: 0x0e, 0x234: 0x0e, 0x235: 0x0e, 0x236: 0x0e, 0x237: 0x0e, - 0x238: 0x0e, 0x239: 0x0e, 0x23a: 0x0e, 0x23b: 0x0e, 0x23c: 0x0e, 0x23d: 0x0e, 0x23e: 0x0e, 0x23f: 0x0e, - // Block 0x9, offset 0x240 - 0x240: 0x0e, 0x241: 0x0e, 0x242: 0x0e, 0x243: 0x0e, 0x244: 0x0e, 0x245: 0x0e, 0x246: 0x0e, 0x247: 0x0e, - 0x248: 0x0e, 0x249: 0x0e, 0x24a: 0x0e, 0x24b: 0x0e, 0x24c: 0x0e, 0x24d: 0x0e, 0x24e: 0x0e, 0x24f: 0x0e, - 0x250: 0x0e, 0x251: 0x0e, 0x252: 0x3b, 0x253: 0x3c, - 0x265: 0x3d, - 0x270: 0x0e, 0x271: 0x0e, 0x272: 0x0e, 0x273: 0x0e, 0x274: 0x0e, 0x275: 0x0e, 0x276: 0x0e, 0x277: 0x0e, - 0x278: 0x0e, 0x279: 0x0e, 0x27a: 0x0e, 0x27b: 0x0e, 0x27c: 0x0e, 0x27d: 0x0e, 0x27e: 0x0e, 0x27f: 0x0e, - // Block 0xa, offset 0x280 - 0x280: 0x0e, 0x281: 0x0e, 0x282: 0x0e, 0x283: 0x0e, 0x284: 0x0e, 0x285: 0x0e, 0x286: 0x0e, 0x287: 0x0e, - 0x288: 0x0e, 0x289: 0x0e, 0x28a: 0x0e, 0x28b: 0x0e, 0x28c: 0x0e, 0x28d: 0x0e, 0x28e: 0x0e, 0x28f: 0x0e, - 0x290: 0x0e, 0x291: 0x0e, 0x292: 0x0e, 0x293: 0x0e, 0x294: 0x0e, 0x295: 0x0e, 0x296: 0x0e, 0x297: 0x0e, - 0x298: 0x0e, 0x299: 0x0e, 0x29a: 0x0e, 0x29b: 0x0e, 0x29c: 0x0e, 0x29d: 0x0e, 0x29e: 0x3e, - // Block 0xb, offset 0x2c0 - 0x2c0: 0x08, 0x2c1: 0x08, 0x2c2: 0x08, 0x2c3: 0x08, 0x2c4: 0x08, 0x2c5: 0x08, 0x2c6: 0x08, 0x2c7: 0x08, - 0x2c8: 0x08, 0x2c9: 0x08, 0x2ca: 0x08, 0x2cb: 0x08, 0x2cc: 0x08, 0x2cd: 0x08, 0x2ce: 0x08, 0x2cf: 0x08, - 0x2d0: 0x08, 0x2d1: 0x08, 0x2d2: 0x08, 0x2d3: 0x08, 0x2d4: 0x08, 0x2d5: 0x08, 0x2d6: 0x08, 0x2d7: 0x08, - 0x2d8: 0x08, 0x2d9: 0x08, 0x2da: 0x08, 0x2db: 0x08, 0x2dc: 0x08, 0x2dd: 0x08, 0x2de: 0x08, 0x2df: 0x08, - 0x2e0: 0x08, 0x2e1: 0x08, 0x2e2: 0x08, 0x2e3: 0x08, 0x2e4: 0x08, 0x2e5: 0x08, 0x2e6: 0x08, 0x2e7: 0x08, - 0x2e8: 0x08, 0x2e9: 0x08, 0x2ea: 0x08, 0x2eb: 0x08, 0x2ec: 0x08, 0x2ed: 0x08, 0x2ee: 0x08, 0x2ef: 0x08, - 0x2f0: 0x08, 0x2f1: 0x08, 0x2f2: 0x08, 0x2f3: 0x08, 0x2f4: 0x08, 0x2f5: 0x08, 0x2f6: 0x08, 0x2f7: 0x08, - 0x2f8: 0x08, 0x2f9: 0x08, 0x2fa: 0x08, 0x2fb: 0x08, 0x2fc: 0x08, 0x2fd: 0x08, 0x2fe: 0x08, 0x2ff: 0x08, - // Block 0xc, offset 0x300 - 0x300: 0x08, 0x301: 0x08, 0x302: 0x08, 0x303: 0x08, 0x304: 0x08, 0x305: 0x08, 0x306: 0x08, 0x307: 0x08, - 0x308: 0x08, 0x309: 0x08, 0x30a: 0x08, 0x30b: 0x08, 0x30c: 0x08, 0x30d: 0x08, 0x30e: 0x08, 0x30f: 0x08, - 0x310: 0x08, 0x311: 0x08, 0x312: 0x08, 0x313: 0x08, 0x314: 0x08, 0x315: 0x08, 0x316: 0x08, 0x317: 0x08, - 0x318: 0x08, 0x319: 0x08, 0x31a: 0x08, 0x31b: 0x08, 0x31c: 0x08, 0x31d: 0x08, 0x31e: 0x08, 0x31f: 0x08, - 0x320: 0x08, 0x321: 0x08, 0x322: 0x08, 0x323: 0x08, 0x324: 0x0e, 0x325: 0x0e, 0x326: 0x0e, 0x327: 0x0e, - 0x328: 0x0e, 0x329: 0x0e, 0x32a: 0x0e, 0x32b: 0x0e, - 0x338: 0x3f, 0x339: 0x40, 0x33c: 0x41, 0x33d: 0x42, 0x33e: 0x43, 0x33f: 0x44, - // Block 0xd, offset 0x340 - 0x37f: 0x45, - // Block 0xe, offset 0x380 - 0x380: 0x0e, 0x381: 0x0e, 0x382: 0x0e, 0x383: 0x0e, 0x384: 0x0e, 0x385: 0x0e, 0x386: 0x0e, 0x387: 0x0e, - 0x388: 0x0e, 0x389: 0x0e, 0x38a: 0x0e, 0x38b: 0x0e, 0x38c: 0x0e, 0x38d: 0x0e, 0x38e: 0x0e, 0x38f: 0x0e, - 0x390: 0x0e, 0x391: 0x0e, 0x392: 0x0e, 0x393: 0x0e, 0x394: 0x0e, 0x395: 0x0e, 0x396: 0x0e, 0x397: 0x0e, - 0x398: 0x0e, 0x399: 0x0e, 0x39a: 0x0e, 0x39b: 0x0e, 0x39c: 0x0e, 0x39d: 0x0e, 0x39e: 0x0e, 0x39f: 0x46, - 0x3a0: 0x0e, 0x3a1: 0x0e, 0x3a2: 0x0e, 0x3a3: 0x0e, 0x3a4: 0x0e, 0x3a5: 0x0e, 0x3a6: 0x0e, 0x3a7: 0x0e, - 0x3a8: 0x0e, 0x3a9: 0x0e, 0x3aa: 0x0e, 0x3ab: 0x47, - // Block 0xf, offset 0x3c0 - 0x3c0: 0x0e, 0x3c1: 0x0e, 0x3c2: 0x0e, 0x3c3: 0x0e, 0x3c4: 0x48, 0x3c5: 0x49, 0x3c6: 0x0e, 0x3c7: 0x0e, - 0x3c8: 0x0e, 0x3c9: 0x0e, 0x3ca: 0x0e, 0x3cb: 0x4a, - // Block 0x10, offset 0x400 - 0x400: 0x4b, 0x403: 0x4c, 0x404: 0x4d, 0x405: 0x4e, 0x406: 0x4f, - 0x408: 0x50, 0x409: 0x51, 0x40c: 0x52, 0x40d: 0x53, 0x40e: 0x54, 0x40f: 0x55, - 0x410: 0x3a, 0x411: 0x56, 0x412: 0x0e, 0x413: 0x57, 0x414: 0x58, 0x415: 0x59, 0x416: 0x5a, 0x417: 0x5b, - 0x418: 0x0e, 0x419: 0x5c, 0x41a: 0x0e, 0x41b: 0x5d, 0x41f: 0x5e, - 0x424: 0x5f, 0x425: 0x60, 0x426: 0x61, 0x427: 0x62, - 0x429: 0x63, 0x42a: 0x64, - // Block 0x11, offset 0x440 - 0x456: 0x0b, 0x457: 0x06, - 0x458: 0x0c, 0x45b: 0x0d, 0x45f: 0x0e, - 0x460: 0x06, 0x461: 0x06, 0x462: 0x06, 0x463: 0x06, 0x464: 0x06, 0x465: 0x06, 0x466: 0x06, 0x467: 0x06, - 0x468: 0x06, 0x469: 0x06, 0x46a: 0x06, 0x46b: 0x06, 0x46c: 0x06, 0x46d: 0x06, 0x46e: 0x06, 0x46f: 0x06, - 0x470: 0x06, 0x471: 0x06, 0x472: 0x06, 0x473: 0x06, 0x474: 0x06, 0x475: 0x06, 0x476: 0x06, 0x477: 0x06, - 0x478: 0x06, 0x479: 0x06, 0x47a: 0x06, 0x47b: 0x06, 0x47c: 0x06, 0x47d: 0x06, 0x47e: 0x06, 0x47f: 0x06, - // Block 0x12, offset 0x480 - 0x484: 0x08, 0x485: 0x08, 0x486: 0x08, 0x487: 0x09, - // Block 0x13, offset 0x4c0 - 0x4c0: 0x08, 0x4c1: 0x08, 0x4c2: 0x08, 0x4c3: 0x08, 0x4c4: 0x08, 0x4c5: 0x08, 0x4c6: 0x08, 0x4c7: 0x08, - 0x4c8: 0x08, 0x4c9: 0x08, 0x4ca: 0x08, 0x4cb: 0x08, 0x4cc: 0x08, 0x4cd: 0x08, 0x4ce: 0x08, 0x4cf: 0x08, - 0x4d0: 0x08, 0x4d1: 0x08, 0x4d2: 0x08, 0x4d3: 0x08, 0x4d4: 0x08, 0x4d5: 0x08, 0x4d6: 0x08, 0x4d7: 0x08, - 0x4d8: 0x08, 0x4d9: 0x08, 0x4da: 0x08, 0x4db: 0x08, 0x4dc: 0x08, 0x4dd: 0x08, 0x4de: 0x08, 0x4df: 0x08, - 0x4e0: 0x08, 0x4e1: 0x08, 0x4e2: 0x08, 0x4e3: 0x08, 0x4e4: 0x08, 0x4e5: 0x08, 0x4e6: 0x08, 0x4e7: 0x08, - 0x4e8: 0x08, 0x4e9: 0x08, 0x4ea: 0x08, 0x4eb: 0x08, 0x4ec: 0x08, 0x4ed: 0x08, 0x4ee: 0x08, 0x4ef: 0x08, - 0x4f0: 0x08, 0x4f1: 0x08, 0x4f2: 0x08, 0x4f3: 0x08, 0x4f4: 0x08, 0x4f5: 0x08, 0x4f6: 0x08, 0x4f7: 0x08, - 0x4f8: 0x08, 0x4f9: 0x08, 0x4fa: 0x08, 0x4fb: 0x08, 0x4fc: 0x08, 0x4fd: 0x08, 0x4fe: 0x08, 0x4ff: 0x65, - // Block 0x14, offset 0x500 - 0x520: 0x10, - 0x530: 0x09, 0x531: 0x09, 0x532: 0x09, 0x533: 0x09, 0x534: 0x09, 0x535: 0x09, 0x536: 0x09, 0x537: 0x09, - 0x538: 0x09, 0x539: 0x09, 0x53a: 0x09, 0x53b: 0x09, 0x53c: 0x09, 0x53d: 0x09, 0x53e: 0x09, 0x53f: 0x11, - // Block 0x15, offset 0x540 - 0x540: 0x09, 0x541: 0x09, 0x542: 0x09, 0x543: 0x09, 0x544: 0x09, 0x545: 0x09, 0x546: 0x09, 0x547: 0x09, - 0x548: 0x09, 0x549: 0x09, 0x54a: 0x09, 0x54b: 0x09, 0x54c: 0x09, 0x54d: 0x09, 0x54e: 0x09, 0x54f: 0x11, -} - -// inverseData contains 4-byte entries of the following format: -// -// <0 padding> -// -// The last byte of the UTF-8-encoded rune is xor-ed with the last byte of the -// UTF-8 encoding of the original rune. Mappings often have the following -// pattern: -// -// A -> A (U+FF21 -> U+0041) -// B -> B (U+FF22 -> U+0042) -// ... -// -// By xor-ing the last byte the same entry can be shared by many mappings. This -// reduces the total number of distinct entries by about two thirds. -// The resulting entry for the aforementioned mappings is -// -// { 0x01, 0xE0, 0x00, 0x00 } -// -// Using this entry to map U+FF21 (UTF-8 [EF BC A1]), we get -// -// E0 ^ A1 = 41. -// -// Similarly, for U+FF22 (UTF-8 [EF BC A2]), we get -// -// E0 ^ A2 = 42. -// -// Note that because of the xor-ing, the byte sequence stored in the entry is -// not valid UTF-8. -var inverseData = [150][4]byte{ - {0x00, 0x00, 0x00, 0x00}, - {0x03, 0xe3, 0x80, 0xa0}, - {0x03, 0xef, 0xbc, 0xa0}, - {0x03, 0xef, 0xbc, 0xe0}, - {0x03, 0xef, 0xbd, 0xe0}, - {0x03, 0xef, 0xbf, 0x02}, - {0x03, 0xef, 0xbf, 0x00}, - {0x03, 0xef, 0xbf, 0x0e}, - {0x03, 0xef, 0xbf, 0x0c}, - {0x03, 0xef, 0xbf, 0x0f}, - {0x03, 0xef, 0xbf, 0x39}, - {0x03, 0xef, 0xbf, 0x3b}, - {0x03, 0xef, 0xbf, 0x3f}, - {0x03, 0xef, 0xbf, 0x2a}, - {0x03, 0xef, 0xbf, 0x0d}, - {0x03, 0xef, 0xbf, 0x25}, - {0x03, 0xef, 0xbd, 0x1a}, - {0x03, 0xef, 0xbd, 0x26}, - {0x01, 0xa0, 0x00, 0x00}, - {0x03, 0xef, 0xbd, 0x25}, - {0x03, 0xef, 0xbd, 0x23}, - {0x03, 0xef, 0xbd, 0x2e}, - {0x03, 0xef, 0xbe, 0x07}, - {0x03, 0xef, 0xbe, 0x05}, - {0x03, 0xef, 0xbd, 0x06}, - {0x03, 0xef, 0xbd, 0x13}, - {0x03, 0xef, 0xbd, 0x0b}, - {0x03, 0xef, 0xbd, 0x16}, - {0x03, 0xef, 0xbd, 0x0c}, - {0x03, 0xef, 0xbd, 0x15}, - {0x03, 0xef, 0xbd, 0x0d}, - {0x03, 0xef, 0xbd, 0x1c}, - {0x03, 0xef, 0xbd, 0x02}, - {0x03, 0xef, 0xbd, 0x1f}, - {0x03, 0xef, 0xbd, 0x1d}, - {0x03, 0xef, 0xbd, 0x17}, - {0x03, 0xef, 0xbd, 0x08}, - {0x03, 0xef, 0xbd, 0x09}, - {0x03, 0xef, 0xbd, 0x0e}, - {0x03, 0xef, 0xbd, 0x04}, - {0x03, 0xef, 0xbd, 0x05}, - {0x03, 0xef, 0xbe, 0x3f}, - {0x03, 0xef, 0xbe, 0x00}, - {0x03, 0xef, 0xbd, 0x2c}, - {0x03, 0xef, 0xbe, 0x06}, - {0x03, 0xef, 0xbe, 0x0c}, - {0x03, 0xef, 0xbe, 0x0f}, - {0x03, 0xef, 0xbe, 0x0d}, - {0x03, 0xef, 0xbe, 0x0b}, - {0x03, 0xef, 0xbe, 0x19}, - {0x03, 0xef, 0xbe, 0x15}, - {0x03, 0xef, 0xbe, 0x11}, - {0x03, 0xef, 0xbe, 0x31}, - {0x03, 0xef, 0xbe, 0x33}, - {0x03, 0xef, 0xbd, 0x0f}, - {0x03, 0xef, 0xbe, 0x30}, - {0x03, 0xef, 0xbe, 0x3e}, - {0x03, 0xef, 0xbe, 0x32}, - {0x03, 0xef, 0xbe, 0x36}, - {0x03, 0xef, 0xbd, 0x14}, - {0x03, 0xef, 0xbe, 0x2e}, - {0x03, 0xef, 0xbd, 0x1e}, - {0x03, 0xef, 0xbe, 0x10}, - {0x03, 0xef, 0xbf, 0x13}, - {0x03, 0xef, 0xbf, 0x15}, - {0x03, 0xef, 0xbf, 0x17}, - {0x03, 0xef, 0xbf, 0x1f}, - {0x03, 0xef, 0xbf, 0x1d}, - {0x03, 0xef, 0xbf, 0x1b}, - {0x03, 0xef, 0xbf, 0x09}, - {0x03, 0xef, 0xbf, 0x0b}, - {0x03, 0xef, 0xbf, 0x37}, - {0x03, 0xef, 0xbe, 0x04}, - {0x01, 0xe0, 0x00, 0x00}, - {0x03, 0xe2, 0xa6, 0x1a}, - {0x03, 0xe2, 0xa6, 0x26}, - {0x03, 0xe3, 0x80, 0x23}, - {0x03, 0xe3, 0x80, 0x2e}, - {0x03, 0xe3, 0x80, 0x25}, - {0x03, 0xe3, 0x83, 0x1e}, - {0x03, 0xe3, 0x83, 0x14}, - {0x03, 0xe3, 0x82, 0x06}, - {0x03, 0xe3, 0x82, 0x0b}, - {0x03, 0xe3, 0x82, 0x0c}, - {0x03, 0xe3, 0x82, 0x0d}, - {0x03, 0xe3, 0x82, 0x02}, - {0x03, 0xe3, 0x83, 0x0f}, - {0x03, 0xe3, 0x83, 0x08}, - {0x03, 0xe3, 0x83, 0x09}, - {0x03, 0xe3, 0x83, 0x2c}, - {0x03, 0xe3, 0x83, 0x0c}, - {0x03, 0xe3, 0x82, 0x13}, - {0x03, 0xe3, 0x82, 0x16}, - {0x03, 0xe3, 0x82, 0x15}, - {0x03, 0xe3, 0x82, 0x1c}, - {0x03, 0xe3, 0x82, 0x1f}, - {0x03, 0xe3, 0x82, 0x1d}, - {0x03, 0xe3, 0x82, 0x1a}, - {0x03, 0xe3, 0x82, 0x17}, - {0x03, 0xe3, 0x82, 0x08}, - {0x03, 0xe3, 0x82, 0x09}, - {0x03, 0xe3, 0x82, 0x0e}, - {0x03, 0xe3, 0x82, 0x04}, - {0x03, 0xe3, 0x82, 0x05}, - {0x03, 0xe3, 0x82, 0x3f}, - {0x03, 0xe3, 0x83, 0x00}, - {0x03, 0xe3, 0x83, 0x06}, - {0x03, 0xe3, 0x83, 0x05}, - {0x03, 0xe3, 0x83, 0x0d}, - {0x03, 0xe3, 0x83, 0x0b}, - {0x03, 0xe3, 0x83, 0x07}, - {0x03, 0xe3, 0x83, 0x19}, - {0x03, 0xe3, 0x83, 0x15}, - {0x03, 0xe3, 0x83, 0x11}, - {0x03, 0xe3, 0x83, 0x31}, - {0x03, 0xe3, 0x83, 0x33}, - {0x03, 0xe3, 0x83, 0x30}, - {0x03, 0xe3, 0x83, 0x3e}, - {0x03, 0xe3, 0x83, 0x32}, - {0x03, 0xe3, 0x83, 0x36}, - {0x03, 0xe3, 0x83, 0x2e}, - {0x03, 0xe3, 0x82, 0x07}, - {0x03, 0xe3, 0x85, 0x04}, - {0x03, 0xe3, 0x84, 0x10}, - {0x03, 0xe3, 0x85, 0x30}, - {0x03, 0xe3, 0x85, 0x0d}, - {0x03, 0xe3, 0x85, 0x13}, - {0x03, 0xe3, 0x85, 0x15}, - {0x03, 0xe3, 0x85, 0x17}, - {0x03, 0xe3, 0x85, 0x1f}, - {0x03, 0xe3, 0x85, 0x1d}, - {0x03, 0xe3, 0x85, 0x1b}, - {0x03, 0xe3, 0x85, 0x09}, - {0x03, 0xe3, 0x85, 0x0f}, - {0x03, 0xe3, 0x85, 0x0b}, - {0x03, 0xe3, 0x85, 0x37}, - {0x03, 0xe3, 0x85, 0x3b}, - {0x03, 0xe3, 0x85, 0x39}, - {0x03, 0xe3, 0x85, 0x3f}, - {0x02, 0xc2, 0x02, 0x00}, - {0x02, 0xc2, 0x0e, 0x00}, - {0x02, 0xc2, 0x0c, 0x00}, - {0x02, 0xc2, 0x00, 0x00}, - {0x03, 0xe2, 0x82, 0x0f}, - {0x03, 0xe2, 0x94, 0x2a}, - {0x03, 0xe2, 0x86, 0x39}, - {0x03, 0xe2, 0x86, 0x3b}, - {0x03, 0xe2, 0x86, 0x3f}, - {0x03, 0xe2, 0x96, 0x0d}, - {0x03, 0xe2, 0x97, 0x25}, -} - -// Total table size 15320 bytes (14KiB) diff --git a/vendor/golang.org/x/text/width/tables13.0.0.go b/vendor/golang.org/x/text/width/tables13.0.0.go deleted file mode 100644 index 40c169edf..000000000 --- a/vendor/golang.org/x/text/width/tables13.0.0.go +++ /dev/null @@ -1,1361 +0,0 @@ -// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. - -//go:build go1.16 && !go1.21 - -package width - -// UnicodeVersion is the Unicode version from which the tables in this package are derived. -const UnicodeVersion = "13.0.0" - -// lookup returns the trie value for the first UTF-8 encoding in s and -// the width in bytes of this encoding. The size will be 0 if s does not -// hold enough bytes to complete the encoding. len(s) must be greater than 0. -func (t *widthTrie) lookup(s []byte) (v uint16, sz int) { - c0 := s[0] - switch { - case c0 < 0x80: // is ASCII - return widthValues[c0], 1 - case c0 < 0xC2: - return 0, 1 // Illegal UTF-8: not a starter, not ASCII. - case c0 < 0xE0: // 2-byte UTF-8 - if len(s) < 2 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c1), 2 - case c0 < 0xF0: // 3-byte UTF-8 - if len(s) < 3 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c2), 3 - case c0 < 0xF8: // 4-byte UTF-8 - if len(s) < 4 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - o = uint32(i)<<6 + uint32(c2) - i = widthIndex[o] - c3 := s[3] - if c3 < 0x80 || 0xC0 <= c3 { - return 0, 3 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c3), 4 - } - // Illegal rune - return 0, 1 -} - -// lookupUnsafe returns the trie value for the first UTF-8 encoding in s. -// s must start with a full and valid UTF-8 encoded rune. -func (t *widthTrie) lookupUnsafe(s []byte) uint16 { - c0 := s[0] - if c0 < 0x80 { // is ASCII - return widthValues[c0] - } - i := widthIndex[c0] - if c0 < 0xE0 { // 2-byte UTF-8 - return t.lookupValue(uint32(i), s[1]) - } - i = widthIndex[uint32(i)<<6+uint32(s[1])] - if c0 < 0xF0 { // 3-byte UTF-8 - return t.lookupValue(uint32(i), s[2]) - } - i = widthIndex[uint32(i)<<6+uint32(s[2])] - if c0 < 0xF8 { // 4-byte UTF-8 - return t.lookupValue(uint32(i), s[3]) - } - return 0 -} - -// lookupString returns the trie value for the first UTF-8 encoding in s and -// the width in bytes of this encoding. The size will be 0 if s does not -// hold enough bytes to complete the encoding. len(s) must be greater than 0. -func (t *widthTrie) lookupString(s string) (v uint16, sz int) { - c0 := s[0] - switch { - case c0 < 0x80: // is ASCII - return widthValues[c0], 1 - case c0 < 0xC2: - return 0, 1 // Illegal UTF-8: not a starter, not ASCII. - case c0 < 0xE0: // 2-byte UTF-8 - if len(s) < 2 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c1), 2 - case c0 < 0xF0: // 3-byte UTF-8 - if len(s) < 3 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c2), 3 - case c0 < 0xF8: // 4-byte UTF-8 - if len(s) < 4 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - o = uint32(i)<<6 + uint32(c2) - i = widthIndex[o] - c3 := s[3] - if c3 < 0x80 || 0xC0 <= c3 { - return 0, 3 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c3), 4 - } - // Illegal rune - return 0, 1 -} - -// lookupStringUnsafe returns the trie value for the first UTF-8 encoding in s. -// s must start with a full and valid UTF-8 encoded rune. -func (t *widthTrie) lookupStringUnsafe(s string) uint16 { - c0 := s[0] - if c0 < 0x80 { // is ASCII - return widthValues[c0] - } - i := widthIndex[c0] - if c0 < 0xE0 { // 2-byte UTF-8 - return t.lookupValue(uint32(i), s[1]) - } - i = widthIndex[uint32(i)<<6+uint32(s[1])] - if c0 < 0xF0 { // 3-byte UTF-8 - return t.lookupValue(uint32(i), s[2]) - } - i = widthIndex[uint32(i)<<6+uint32(s[2])] - if c0 < 0xF8 { // 4-byte UTF-8 - return t.lookupValue(uint32(i), s[3]) - } - return 0 -} - -// widthTrie. Total size: 14848 bytes (14.50 KiB). Checksum: 17e24343536472f6. -type widthTrie struct{} - -func newWidthTrie(i int) *widthTrie { - return &widthTrie{} -} - -// lookupValue determines the type of block n and looks up the value for b. -func (t *widthTrie) lookupValue(n uint32, b byte) uint16 { - switch { - default: - return uint16(widthValues[n<<6+uint32(b)]) - } -} - -// widthValues: 105 blocks, 6720 entries, 13440 bytes -// The third block is the zero block. -var widthValues = [6720]uint16{ - // Block 0x0, offset 0x0 - 0x20: 0x6001, 0x21: 0x6002, 0x22: 0x6002, 0x23: 0x6002, - 0x24: 0x6002, 0x25: 0x6002, 0x26: 0x6002, 0x27: 0x6002, 0x28: 0x6002, 0x29: 0x6002, - 0x2a: 0x6002, 0x2b: 0x6002, 0x2c: 0x6002, 0x2d: 0x6002, 0x2e: 0x6002, 0x2f: 0x6002, - 0x30: 0x6002, 0x31: 0x6002, 0x32: 0x6002, 0x33: 0x6002, 0x34: 0x6002, 0x35: 0x6002, - 0x36: 0x6002, 0x37: 0x6002, 0x38: 0x6002, 0x39: 0x6002, 0x3a: 0x6002, 0x3b: 0x6002, - 0x3c: 0x6002, 0x3d: 0x6002, 0x3e: 0x6002, 0x3f: 0x6002, - // Block 0x1, offset 0x40 - 0x40: 0x6003, 0x41: 0x6003, 0x42: 0x6003, 0x43: 0x6003, 0x44: 0x6003, 0x45: 0x6003, - 0x46: 0x6003, 0x47: 0x6003, 0x48: 0x6003, 0x49: 0x6003, 0x4a: 0x6003, 0x4b: 0x6003, - 0x4c: 0x6003, 0x4d: 0x6003, 0x4e: 0x6003, 0x4f: 0x6003, 0x50: 0x6003, 0x51: 0x6003, - 0x52: 0x6003, 0x53: 0x6003, 0x54: 0x6003, 0x55: 0x6003, 0x56: 0x6003, 0x57: 0x6003, - 0x58: 0x6003, 0x59: 0x6003, 0x5a: 0x6003, 0x5b: 0x6003, 0x5c: 0x6003, 0x5d: 0x6003, - 0x5e: 0x6003, 0x5f: 0x6003, 0x60: 0x6004, 0x61: 0x6004, 0x62: 0x6004, 0x63: 0x6004, - 0x64: 0x6004, 0x65: 0x6004, 0x66: 0x6004, 0x67: 0x6004, 0x68: 0x6004, 0x69: 0x6004, - 0x6a: 0x6004, 0x6b: 0x6004, 0x6c: 0x6004, 0x6d: 0x6004, 0x6e: 0x6004, 0x6f: 0x6004, - 0x70: 0x6004, 0x71: 0x6004, 0x72: 0x6004, 0x73: 0x6004, 0x74: 0x6004, 0x75: 0x6004, - 0x76: 0x6004, 0x77: 0x6004, 0x78: 0x6004, 0x79: 0x6004, 0x7a: 0x6004, 0x7b: 0x6004, - 0x7c: 0x6004, 0x7d: 0x6004, 0x7e: 0x6004, - // Block 0x2, offset 0x80 - // Block 0x3, offset 0xc0 - 0xe1: 0x2000, 0xe2: 0x6005, 0xe3: 0x6005, - 0xe4: 0x2000, 0xe5: 0x6006, 0xe6: 0x6005, 0xe7: 0x2000, 0xe8: 0x2000, - 0xea: 0x2000, 0xec: 0x6007, 0xed: 0x2000, 0xee: 0x2000, 0xef: 0x6008, - 0xf0: 0x2000, 0xf1: 0x2000, 0xf2: 0x2000, 0xf3: 0x2000, 0xf4: 0x2000, - 0xf6: 0x2000, 0xf7: 0x2000, 0xf8: 0x2000, 0xf9: 0x2000, 0xfa: 0x2000, - 0xfc: 0x2000, 0xfd: 0x2000, 0xfe: 0x2000, 0xff: 0x2000, - // Block 0x4, offset 0x100 - 0x106: 0x2000, - 0x110: 0x2000, - 0x117: 0x2000, - 0x118: 0x2000, - 0x11e: 0x2000, 0x11f: 0x2000, 0x120: 0x2000, 0x121: 0x2000, - 0x126: 0x2000, 0x128: 0x2000, 0x129: 0x2000, - 0x12a: 0x2000, 0x12c: 0x2000, 0x12d: 0x2000, - 0x130: 0x2000, 0x132: 0x2000, 0x133: 0x2000, - 0x137: 0x2000, 0x138: 0x2000, 0x139: 0x2000, 0x13a: 0x2000, - 0x13c: 0x2000, 0x13e: 0x2000, - // Block 0x5, offset 0x140 - 0x141: 0x2000, - 0x151: 0x2000, - 0x153: 0x2000, - 0x15b: 0x2000, - 0x166: 0x2000, 0x167: 0x2000, - 0x16b: 0x2000, - 0x171: 0x2000, 0x172: 0x2000, 0x173: 0x2000, - 0x178: 0x2000, - 0x17f: 0x2000, - // Block 0x6, offset 0x180 - 0x180: 0x2000, 0x181: 0x2000, 0x182: 0x2000, 0x184: 0x2000, - 0x188: 0x2000, 0x189: 0x2000, 0x18a: 0x2000, 0x18b: 0x2000, - 0x18d: 0x2000, - 0x192: 0x2000, 0x193: 0x2000, - 0x1a6: 0x2000, 0x1a7: 0x2000, - 0x1ab: 0x2000, - // Block 0x7, offset 0x1c0 - 0x1ce: 0x2000, 0x1d0: 0x2000, - 0x1d2: 0x2000, 0x1d4: 0x2000, 0x1d6: 0x2000, - 0x1d8: 0x2000, 0x1da: 0x2000, 0x1dc: 0x2000, - // Block 0x8, offset 0x200 - 0x211: 0x2000, - 0x221: 0x2000, - // Block 0x9, offset 0x240 - 0x244: 0x2000, - 0x247: 0x2000, 0x249: 0x2000, 0x24a: 0x2000, 0x24b: 0x2000, - 0x24d: 0x2000, 0x250: 0x2000, - 0x258: 0x2000, 0x259: 0x2000, 0x25a: 0x2000, 0x25b: 0x2000, 0x25d: 0x2000, - 0x25f: 0x2000, - // Block 0xa, offset 0x280 - 0x280: 0x2000, 0x281: 0x2000, 0x282: 0x2000, 0x283: 0x2000, 0x284: 0x2000, 0x285: 0x2000, - 0x286: 0x2000, 0x287: 0x2000, 0x288: 0x2000, 0x289: 0x2000, 0x28a: 0x2000, 0x28b: 0x2000, - 0x28c: 0x2000, 0x28d: 0x2000, 0x28e: 0x2000, 0x28f: 0x2000, 0x290: 0x2000, 0x291: 0x2000, - 0x292: 0x2000, 0x293: 0x2000, 0x294: 0x2000, 0x295: 0x2000, 0x296: 0x2000, 0x297: 0x2000, - 0x298: 0x2000, 0x299: 0x2000, 0x29a: 0x2000, 0x29b: 0x2000, 0x29c: 0x2000, 0x29d: 0x2000, - 0x29e: 0x2000, 0x29f: 0x2000, 0x2a0: 0x2000, 0x2a1: 0x2000, 0x2a2: 0x2000, 0x2a3: 0x2000, - 0x2a4: 0x2000, 0x2a5: 0x2000, 0x2a6: 0x2000, 0x2a7: 0x2000, 0x2a8: 0x2000, 0x2a9: 0x2000, - 0x2aa: 0x2000, 0x2ab: 0x2000, 0x2ac: 0x2000, 0x2ad: 0x2000, 0x2ae: 0x2000, 0x2af: 0x2000, - 0x2b0: 0x2000, 0x2b1: 0x2000, 0x2b2: 0x2000, 0x2b3: 0x2000, 0x2b4: 0x2000, 0x2b5: 0x2000, - 0x2b6: 0x2000, 0x2b7: 0x2000, 0x2b8: 0x2000, 0x2b9: 0x2000, 0x2ba: 0x2000, 0x2bb: 0x2000, - 0x2bc: 0x2000, 0x2bd: 0x2000, 0x2be: 0x2000, 0x2bf: 0x2000, - // Block 0xb, offset 0x2c0 - 0x2c0: 0x2000, 0x2c1: 0x2000, 0x2c2: 0x2000, 0x2c3: 0x2000, 0x2c4: 0x2000, 0x2c5: 0x2000, - 0x2c6: 0x2000, 0x2c7: 0x2000, 0x2c8: 0x2000, 0x2c9: 0x2000, 0x2ca: 0x2000, 0x2cb: 0x2000, - 0x2cc: 0x2000, 0x2cd: 0x2000, 0x2ce: 0x2000, 0x2cf: 0x2000, 0x2d0: 0x2000, 0x2d1: 0x2000, - 0x2d2: 0x2000, 0x2d3: 0x2000, 0x2d4: 0x2000, 0x2d5: 0x2000, 0x2d6: 0x2000, 0x2d7: 0x2000, - 0x2d8: 0x2000, 0x2d9: 0x2000, 0x2da: 0x2000, 0x2db: 0x2000, 0x2dc: 0x2000, 0x2dd: 0x2000, - 0x2de: 0x2000, 0x2df: 0x2000, 0x2e0: 0x2000, 0x2e1: 0x2000, 0x2e2: 0x2000, 0x2e3: 0x2000, - 0x2e4: 0x2000, 0x2e5: 0x2000, 0x2e6: 0x2000, 0x2e7: 0x2000, 0x2e8: 0x2000, 0x2e9: 0x2000, - 0x2ea: 0x2000, 0x2eb: 0x2000, 0x2ec: 0x2000, 0x2ed: 0x2000, 0x2ee: 0x2000, 0x2ef: 0x2000, - // Block 0xc, offset 0x300 - 0x311: 0x2000, - 0x312: 0x2000, 0x313: 0x2000, 0x314: 0x2000, 0x315: 0x2000, 0x316: 0x2000, 0x317: 0x2000, - 0x318: 0x2000, 0x319: 0x2000, 0x31a: 0x2000, 0x31b: 0x2000, 0x31c: 0x2000, 0x31d: 0x2000, - 0x31e: 0x2000, 0x31f: 0x2000, 0x320: 0x2000, 0x321: 0x2000, 0x323: 0x2000, - 0x324: 0x2000, 0x325: 0x2000, 0x326: 0x2000, 0x327: 0x2000, 0x328: 0x2000, 0x329: 0x2000, - 0x331: 0x2000, 0x332: 0x2000, 0x333: 0x2000, 0x334: 0x2000, 0x335: 0x2000, - 0x336: 0x2000, 0x337: 0x2000, 0x338: 0x2000, 0x339: 0x2000, 0x33a: 0x2000, 0x33b: 0x2000, - 0x33c: 0x2000, 0x33d: 0x2000, 0x33e: 0x2000, 0x33f: 0x2000, - // Block 0xd, offset 0x340 - 0x340: 0x2000, 0x341: 0x2000, 0x343: 0x2000, 0x344: 0x2000, 0x345: 0x2000, - 0x346: 0x2000, 0x347: 0x2000, 0x348: 0x2000, 0x349: 0x2000, - // Block 0xe, offset 0x380 - 0x381: 0x2000, - 0x390: 0x2000, 0x391: 0x2000, - 0x392: 0x2000, 0x393: 0x2000, 0x394: 0x2000, 0x395: 0x2000, 0x396: 0x2000, 0x397: 0x2000, - 0x398: 0x2000, 0x399: 0x2000, 0x39a: 0x2000, 0x39b: 0x2000, 0x39c: 0x2000, 0x39d: 0x2000, - 0x39e: 0x2000, 0x39f: 0x2000, 0x3a0: 0x2000, 0x3a1: 0x2000, 0x3a2: 0x2000, 0x3a3: 0x2000, - 0x3a4: 0x2000, 0x3a5: 0x2000, 0x3a6: 0x2000, 0x3a7: 0x2000, 0x3a8: 0x2000, 0x3a9: 0x2000, - 0x3aa: 0x2000, 0x3ab: 0x2000, 0x3ac: 0x2000, 0x3ad: 0x2000, 0x3ae: 0x2000, 0x3af: 0x2000, - 0x3b0: 0x2000, 0x3b1: 0x2000, 0x3b2: 0x2000, 0x3b3: 0x2000, 0x3b4: 0x2000, 0x3b5: 0x2000, - 0x3b6: 0x2000, 0x3b7: 0x2000, 0x3b8: 0x2000, 0x3b9: 0x2000, 0x3ba: 0x2000, 0x3bb: 0x2000, - 0x3bc: 0x2000, 0x3bd: 0x2000, 0x3be: 0x2000, 0x3bf: 0x2000, - // Block 0xf, offset 0x3c0 - 0x3c0: 0x2000, 0x3c1: 0x2000, 0x3c2: 0x2000, 0x3c3: 0x2000, 0x3c4: 0x2000, 0x3c5: 0x2000, - 0x3c6: 0x2000, 0x3c7: 0x2000, 0x3c8: 0x2000, 0x3c9: 0x2000, 0x3ca: 0x2000, 0x3cb: 0x2000, - 0x3cc: 0x2000, 0x3cd: 0x2000, 0x3ce: 0x2000, 0x3cf: 0x2000, 0x3d1: 0x2000, - // Block 0x10, offset 0x400 - 0x400: 0x4000, 0x401: 0x4000, 0x402: 0x4000, 0x403: 0x4000, 0x404: 0x4000, 0x405: 0x4000, - 0x406: 0x4000, 0x407: 0x4000, 0x408: 0x4000, 0x409: 0x4000, 0x40a: 0x4000, 0x40b: 0x4000, - 0x40c: 0x4000, 0x40d: 0x4000, 0x40e: 0x4000, 0x40f: 0x4000, 0x410: 0x4000, 0x411: 0x4000, - 0x412: 0x4000, 0x413: 0x4000, 0x414: 0x4000, 0x415: 0x4000, 0x416: 0x4000, 0x417: 0x4000, - 0x418: 0x4000, 0x419: 0x4000, 0x41a: 0x4000, 0x41b: 0x4000, 0x41c: 0x4000, 0x41d: 0x4000, - 0x41e: 0x4000, 0x41f: 0x4000, 0x420: 0x4000, 0x421: 0x4000, 0x422: 0x4000, 0x423: 0x4000, - 0x424: 0x4000, 0x425: 0x4000, 0x426: 0x4000, 0x427: 0x4000, 0x428: 0x4000, 0x429: 0x4000, - 0x42a: 0x4000, 0x42b: 0x4000, 0x42c: 0x4000, 0x42d: 0x4000, 0x42e: 0x4000, 0x42f: 0x4000, - 0x430: 0x4000, 0x431: 0x4000, 0x432: 0x4000, 0x433: 0x4000, 0x434: 0x4000, 0x435: 0x4000, - 0x436: 0x4000, 0x437: 0x4000, 0x438: 0x4000, 0x439: 0x4000, 0x43a: 0x4000, 0x43b: 0x4000, - 0x43c: 0x4000, 0x43d: 0x4000, 0x43e: 0x4000, 0x43f: 0x4000, - // Block 0x11, offset 0x440 - 0x440: 0x4000, 0x441: 0x4000, 0x442: 0x4000, 0x443: 0x4000, 0x444: 0x4000, 0x445: 0x4000, - 0x446: 0x4000, 0x447: 0x4000, 0x448: 0x4000, 0x449: 0x4000, 0x44a: 0x4000, 0x44b: 0x4000, - 0x44c: 0x4000, 0x44d: 0x4000, 0x44e: 0x4000, 0x44f: 0x4000, 0x450: 0x4000, 0x451: 0x4000, - 0x452: 0x4000, 0x453: 0x4000, 0x454: 0x4000, 0x455: 0x4000, 0x456: 0x4000, 0x457: 0x4000, - 0x458: 0x4000, 0x459: 0x4000, 0x45a: 0x4000, 0x45b: 0x4000, 0x45c: 0x4000, 0x45d: 0x4000, - 0x45e: 0x4000, 0x45f: 0x4000, - // Block 0x12, offset 0x480 - 0x490: 0x2000, - 0x493: 0x2000, 0x494: 0x2000, 0x495: 0x2000, 0x496: 0x2000, - 0x498: 0x2000, 0x499: 0x2000, 0x49c: 0x2000, 0x49d: 0x2000, - 0x4a0: 0x2000, 0x4a1: 0x2000, 0x4a2: 0x2000, - 0x4a4: 0x2000, 0x4a5: 0x2000, 0x4a6: 0x2000, 0x4a7: 0x2000, - 0x4b0: 0x2000, 0x4b2: 0x2000, 0x4b3: 0x2000, 0x4b5: 0x2000, - 0x4bb: 0x2000, - 0x4be: 0x2000, - // Block 0x13, offset 0x4c0 - 0x4f4: 0x2000, - 0x4ff: 0x2000, - // Block 0x14, offset 0x500 - 0x501: 0x2000, 0x502: 0x2000, 0x503: 0x2000, 0x504: 0x2000, - 0x529: 0xa009, - 0x52c: 0x2000, - // Block 0x15, offset 0x540 - 0x543: 0x2000, 0x545: 0x2000, - 0x549: 0x2000, - 0x553: 0x2000, 0x556: 0x2000, - 0x561: 0x2000, 0x562: 0x2000, - 0x566: 0x2000, - 0x56b: 0x2000, - // Block 0x16, offset 0x580 - 0x593: 0x2000, 0x594: 0x2000, - 0x59b: 0x2000, 0x59c: 0x2000, 0x59d: 0x2000, - 0x59e: 0x2000, 0x5a0: 0x2000, 0x5a1: 0x2000, 0x5a2: 0x2000, 0x5a3: 0x2000, - 0x5a4: 0x2000, 0x5a5: 0x2000, 0x5a6: 0x2000, 0x5a7: 0x2000, 0x5a8: 0x2000, 0x5a9: 0x2000, - 0x5aa: 0x2000, 0x5ab: 0x2000, - 0x5b0: 0x2000, 0x5b1: 0x2000, 0x5b2: 0x2000, 0x5b3: 0x2000, 0x5b4: 0x2000, 0x5b5: 0x2000, - 0x5b6: 0x2000, 0x5b7: 0x2000, 0x5b8: 0x2000, 0x5b9: 0x2000, - // Block 0x17, offset 0x5c0 - 0x5c9: 0x2000, - 0x5d0: 0x200a, 0x5d1: 0x200b, - 0x5d2: 0x200a, 0x5d3: 0x200c, 0x5d4: 0x2000, 0x5d5: 0x2000, 0x5d6: 0x2000, 0x5d7: 0x2000, - 0x5d8: 0x2000, 0x5d9: 0x2000, - 0x5f8: 0x2000, 0x5f9: 0x2000, - // Block 0x18, offset 0x600 - 0x612: 0x2000, 0x614: 0x2000, - 0x627: 0x2000, - // Block 0x19, offset 0x640 - 0x640: 0x2000, 0x642: 0x2000, 0x643: 0x2000, - 0x647: 0x2000, 0x648: 0x2000, 0x64b: 0x2000, - 0x64f: 0x2000, 0x651: 0x2000, - 0x655: 0x2000, - 0x65a: 0x2000, 0x65d: 0x2000, - 0x65e: 0x2000, 0x65f: 0x2000, 0x660: 0x2000, 0x663: 0x2000, - 0x665: 0x2000, 0x667: 0x2000, 0x668: 0x2000, 0x669: 0x2000, - 0x66a: 0x2000, 0x66b: 0x2000, 0x66c: 0x2000, 0x66e: 0x2000, - 0x674: 0x2000, 0x675: 0x2000, - 0x676: 0x2000, 0x677: 0x2000, - 0x67c: 0x2000, 0x67d: 0x2000, - // Block 0x1a, offset 0x680 - 0x688: 0x2000, - 0x68c: 0x2000, - 0x692: 0x2000, - 0x6a0: 0x2000, 0x6a1: 0x2000, - 0x6a4: 0x2000, 0x6a5: 0x2000, 0x6a6: 0x2000, 0x6a7: 0x2000, - 0x6aa: 0x2000, 0x6ab: 0x2000, 0x6ae: 0x2000, 0x6af: 0x2000, - // Block 0x1b, offset 0x6c0 - 0x6c2: 0x2000, 0x6c3: 0x2000, - 0x6c6: 0x2000, 0x6c7: 0x2000, - 0x6d5: 0x2000, - 0x6d9: 0x2000, - 0x6e5: 0x2000, - 0x6ff: 0x2000, - // Block 0x1c, offset 0x700 - 0x712: 0x2000, - 0x71a: 0x4000, 0x71b: 0x4000, - 0x729: 0x4000, - 0x72a: 0x4000, - // Block 0x1d, offset 0x740 - 0x769: 0x4000, - 0x76a: 0x4000, 0x76b: 0x4000, 0x76c: 0x4000, - 0x770: 0x4000, 0x773: 0x4000, - // Block 0x1e, offset 0x780 - 0x7a0: 0x2000, 0x7a1: 0x2000, 0x7a2: 0x2000, 0x7a3: 0x2000, - 0x7a4: 0x2000, 0x7a5: 0x2000, 0x7a6: 0x2000, 0x7a7: 0x2000, 0x7a8: 0x2000, 0x7a9: 0x2000, - 0x7aa: 0x2000, 0x7ab: 0x2000, 0x7ac: 0x2000, 0x7ad: 0x2000, 0x7ae: 0x2000, 0x7af: 0x2000, - 0x7b0: 0x2000, 0x7b1: 0x2000, 0x7b2: 0x2000, 0x7b3: 0x2000, 0x7b4: 0x2000, 0x7b5: 0x2000, - 0x7b6: 0x2000, 0x7b7: 0x2000, 0x7b8: 0x2000, 0x7b9: 0x2000, 0x7ba: 0x2000, 0x7bb: 0x2000, - 0x7bc: 0x2000, 0x7bd: 0x2000, 0x7be: 0x2000, 0x7bf: 0x2000, - // Block 0x1f, offset 0x7c0 - 0x7c0: 0x2000, 0x7c1: 0x2000, 0x7c2: 0x2000, 0x7c3: 0x2000, 0x7c4: 0x2000, 0x7c5: 0x2000, - 0x7c6: 0x2000, 0x7c7: 0x2000, 0x7c8: 0x2000, 0x7c9: 0x2000, 0x7ca: 0x2000, 0x7cb: 0x2000, - 0x7cc: 0x2000, 0x7cd: 0x2000, 0x7ce: 0x2000, 0x7cf: 0x2000, 0x7d0: 0x2000, 0x7d1: 0x2000, - 0x7d2: 0x2000, 0x7d3: 0x2000, 0x7d4: 0x2000, 0x7d5: 0x2000, 0x7d6: 0x2000, 0x7d7: 0x2000, - 0x7d8: 0x2000, 0x7d9: 0x2000, 0x7da: 0x2000, 0x7db: 0x2000, 0x7dc: 0x2000, 0x7dd: 0x2000, - 0x7de: 0x2000, 0x7df: 0x2000, 0x7e0: 0x2000, 0x7e1: 0x2000, 0x7e2: 0x2000, 0x7e3: 0x2000, - 0x7e4: 0x2000, 0x7e5: 0x2000, 0x7e6: 0x2000, 0x7e7: 0x2000, 0x7e8: 0x2000, 0x7e9: 0x2000, - 0x7eb: 0x2000, 0x7ec: 0x2000, 0x7ed: 0x2000, 0x7ee: 0x2000, 0x7ef: 0x2000, - 0x7f0: 0x2000, 0x7f1: 0x2000, 0x7f2: 0x2000, 0x7f3: 0x2000, 0x7f4: 0x2000, 0x7f5: 0x2000, - 0x7f6: 0x2000, 0x7f7: 0x2000, 0x7f8: 0x2000, 0x7f9: 0x2000, 0x7fa: 0x2000, 0x7fb: 0x2000, - 0x7fc: 0x2000, 0x7fd: 0x2000, 0x7fe: 0x2000, 0x7ff: 0x2000, - // Block 0x20, offset 0x800 - 0x800: 0x2000, 0x801: 0x2000, 0x802: 0x200d, 0x803: 0x2000, 0x804: 0x2000, 0x805: 0x2000, - 0x806: 0x2000, 0x807: 0x2000, 0x808: 0x2000, 0x809: 0x2000, 0x80a: 0x2000, 0x80b: 0x2000, - 0x80c: 0x2000, 0x80d: 0x2000, 0x80e: 0x2000, 0x80f: 0x2000, 0x810: 0x2000, 0x811: 0x2000, - 0x812: 0x2000, 0x813: 0x2000, 0x814: 0x2000, 0x815: 0x2000, 0x816: 0x2000, 0x817: 0x2000, - 0x818: 0x2000, 0x819: 0x2000, 0x81a: 0x2000, 0x81b: 0x2000, 0x81c: 0x2000, 0x81d: 0x2000, - 0x81e: 0x2000, 0x81f: 0x2000, 0x820: 0x2000, 0x821: 0x2000, 0x822: 0x2000, 0x823: 0x2000, - 0x824: 0x2000, 0x825: 0x2000, 0x826: 0x2000, 0x827: 0x2000, 0x828: 0x2000, 0x829: 0x2000, - 0x82a: 0x2000, 0x82b: 0x2000, 0x82c: 0x2000, 0x82d: 0x2000, 0x82e: 0x2000, 0x82f: 0x2000, - 0x830: 0x2000, 0x831: 0x2000, 0x832: 0x2000, 0x833: 0x2000, 0x834: 0x2000, 0x835: 0x2000, - 0x836: 0x2000, 0x837: 0x2000, 0x838: 0x2000, 0x839: 0x2000, 0x83a: 0x2000, 0x83b: 0x2000, - 0x83c: 0x2000, 0x83d: 0x2000, 0x83e: 0x2000, 0x83f: 0x2000, - // Block 0x21, offset 0x840 - 0x840: 0x2000, 0x841: 0x2000, 0x842: 0x2000, 0x843: 0x2000, 0x844: 0x2000, 0x845: 0x2000, - 0x846: 0x2000, 0x847: 0x2000, 0x848: 0x2000, 0x849: 0x2000, 0x84a: 0x2000, 0x84b: 0x2000, - 0x850: 0x2000, 0x851: 0x2000, - 0x852: 0x2000, 0x853: 0x2000, 0x854: 0x2000, 0x855: 0x2000, 0x856: 0x2000, 0x857: 0x2000, - 0x858: 0x2000, 0x859: 0x2000, 0x85a: 0x2000, 0x85b: 0x2000, 0x85c: 0x2000, 0x85d: 0x2000, - 0x85e: 0x2000, 0x85f: 0x2000, 0x860: 0x2000, 0x861: 0x2000, 0x862: 0x2000, 0x863: 0x2000, - 0x864: 0x2000, 0x865: 0x2000, 0x866: 0x2000, 0x867: 0x2000, 0x868: 0x2000, 0x869: 0x2000, - 0x86a: 0x2000, 0x86b: 0x2000, 0x86c: 0x2000, 0x86d: 0x2000, 0x86e: 0x2000, 0x86f: 0x2000, - 0x870: 0x2000, 0x871: 0x2000, 0x872: 0x2000, 0x873: 0x2000, - // Block 0x22, offset 0x880 - 0x880: 0x2000, 0x881: 0x2000, 0x882: 0x2000, 0x883: 0x2000, 0x884: 0x2000, 0x885: 0x2000, - 0x886: 0x2000, 0x887: 0x2000, 0x888: 0x2000, 0x889: 0x2000, 0x88a: 0x2000, 0x88b: 0x2000, - 0x88c: 0x2000, 0x88d: 0x2000, 0x88e: 0x2000, 0x88f: 0x2000, - 0x892: 0x2000, 0x893: 0x2000, 0x894: 0x2000, 0x895: 0x2000, - 0x8a0: 0x200e, 0x8a1: 0x2000, 0x8a3: 0x2000, - 0x8a4: 0x2000, 0x8a5: 0x2000, 0x8a6: 0x2000, 0x8a7: 0x2000, 0x8a8: 0x2000, 0x8a9: 0x2000, - 0x8b2: 0x2000, 0x8b3: 0x2000, - 0x8b6: 0x2000, 0x8b7: 0x2000, - 0x8bc: 0x2000, 0x8bd: 0x2000, - // Block 0x23, offset 0x8c0 - 0x8c0: 0x2000, 0x8c1: 0x2000, - 0x8c6: 0x2000, 0x8c7: 0x2000, 0x8c8: 0x2000, 0x8cb: 0x200f, - 0x8ce: 0x2000, 0x8cf: 0x2000, 0x8d0: 0x2000, 0x8d1: 0x2000, - 0x8e2: 0x2000, 0x8e3: 0x2000, - 0x8e4: 0x2000, 0x8e5: 0x2000, - 0x8ef: 0x2000, - 0x8fd: 0x4000, 0x8fe: 0x4000, - // Block 0x24, offset 0x900 - 0x905: 0x2000, - 0x906: 0x2000, 0x909: 0x2000, - 0x90e: 0x2000, 0x90f: 0x2000, - 0x914: 0x4000, 0x915: 0x4000, - 0x91c: 0x2000, - 0x91e: 0x2000, - // Block 0x25, offset 0x940 - 0x940: 0x2000, 0x942: 0x2000, - 0x948: 0x4000, 0x949: 0x4000, 0x94a: 0x4000, 0x94b: 0x4000, - 0x94c: 0x4000, 0x94d: 0x4000, 0x94e: 0x4000, 0x94f: 0x4000, 0x950: 0x4000, 0x951: 0x4000, - 0x952: 0x4000, 0x953: 0x4000, - 0x960: 0x2000, 0x961: 0x2000, 0x963: 0x2000, - 0x964: 0x2000, 0x965: 0x2000, 0x967: 0x2000, 0x968: 0x2000, 0x969: 0x2000, - 0x96a: 0x2000, 0x96c: 0x2000, 0x96d: 0x2000, 0x96f: 0x2000, - 0x97f: 0x4000, - // Block 0x26, offset 0x980 - 0x993: 0x4000, - 0x99e: 0x2000, 0x99f: 0x2000, 0x9a1: 0x4000, - 0x9aa: 0x4000, 0x9ab: 0x4000, - 0x9bd: 0x4000, 0x9be: 0x4000, 0x9bf: 0x2000, - // Block 0x27, offset 0x9c0 - 0x9c4: 0x4000, 0x9c5: 0x4000, - 0x9c6: 0x2000, 0x9c7: 0x2000, 0x9c8: 0x2000, 0x9c9: 0x2000, 0x9ca: 0x2000, 0x9cb: 0x2000, - 0x9cc: 0x2000, 0x9cd: 0x2000, 0x9ce: 0x4000, 0x9cf: 0x2000, 0x9d0: 0x2000, 0x9d1: 0x2000, - 0x9d2: 0x2000, 0x9d3: 0x2000, 0x9d4: 0x4000, 0x9d5: 0x2000, 0x9d6: 0x2000, 0x9d7: 0x2000, - 0x9d8: 0x2000, 0x9d9: 0x2000, 0x9da: 0x2000, 0x9db: 0x2000, 0x9dc: 0x2000, 0x9dd: 0x2000, - 0x9de: 0x2000, 0x9df: 0x2000, 0x9e0: 0x2000, 0x9e1: 0x2000, 0x9e3: 0x2000, - 0x9e8: 0x2000, 0x9e9: 0x2000, - 0x9ea: 0x4000, 0x9eb: 0x2000, 0x9ec: 0x2000, 0x9ed: 0x2000, 0x9ee: 0x2000, 0x9ef: 0x2000, - 0x9f0: 0x2000, 0x9f1: 0x2000, 0x9f2: 0x4000, 0x9f3: 0x4000, 0x9f4: 0x2000, 0x9f5: 0x4000, - 0x9f6: 0x2000, 0x9f7: 0x2000, 0x9f8: 0x2000, 0x9f9: 0x2000, 0x9fa: 0x4000, 0x9fb: 0x2000, - 0x9fc: 0x2000, 0x9fd: 0x4000, 0x9fe: 0x2000, 0x9ff: 0x2000, - // Block 0x28, offset 0xa00 - 0xa05: 0x4000, - 0xa0a: 0x4000, 0xa0b: 0x4000, - 0xa28: 0x4000, - 0xa3d: 0x2000, - // Block 0x29, offset 0xa40 - 0xa4c: 0x4000, 0xa4e: 0x4000, - 0xa53: 0x4000, 0xa54: 0x4000, 0xa55: 0x4000, 0xa57: 0x4000, - 0xa76: 0x2000, 0xa77: 0x2000, 0xa78: 0x2000, 0xa79: 0x2000, 0xa7a: 0x2000, 0xa7b: 0x2000, - 0xa7c: 0x2000, 0xa7d: 0x2000, 0xa7e: 0x2000, 0xa7f: 0x2000, - // Block 0x2a, offset 0xa80 - 0xa95: 0x4000, 0xa96: 0x4000, 0xa97: 0x4000, - 0xab0: 0x4000, - 0xabf: 0x4000, - // Block 0x2b, offset 0xac0 - 0xae6: 0x6000, 0xae7: 0x6000, 0xae8: 0x6000, 0xae9: 0x6000, - 0xaea: 0x6000, 0xaeb: 0x6000, 0xaec: 0x6000, 0xaed: 0x6000, - // Block 0x2c, offset 0xb00 - 0xb05: 0x6010, - 0xb06: 0x6011, - // Block 0x2d, offset 0xb40 - 0xb5b: 0x4000, 0xb5c: 0x4000, - // Block 0x2e, offset 0xb80 - 0xb90: 0x4000, - 0xb95: 0x4000, 0xb96: 0x2000, 0xb97: 0x2000, - 0xb98: 0x2000, 0xb99: 0x2000, - // Block 0x2f, offset 0xbc0 - 0xbc0: 0x4000, 0xbc1: 0x4000, 0xbc2: 0x4000, 0xbc3: 0x4000, 0xbc4: 0x4000, 0xbc5: 0x4000, - 0xbc6: 0x4000, 0xbc7: 0x4000, 0xbc8: 0x4000, 0xbc9: 0x4000, 0xbca: 0x4000, 0xbcb: 0x4000, - 0xbcc: 0x4000, 0xbcd: 0x4000, 0xbce: 0x4000, 0xbcf: 0x4000, 0xbd0: 0x4000, 0xbd1: 0x4000, - 0xbd2: 0x4000, 0xbd3: 0x4000, 0xbd4: 0x4000, 0xbd5: 0x4000, 0xbd6: 0x4000, 0xbd7: 0x4000, - 0xbd8: 0x4000, 0xbd9: 0x4000, 0xbdb: 0x4000, 0xbdc: 0x4000, 0xbdd: 0x4000, - 0xbde: 0x4000, 0xbdf: 0x4000, 0xbe0: 0x4000, 0xbe1: 0x4000, 0xbe2: 0x4000, 0xbe3: 0x4000, - 0xbe4: 0x4000, 0xbe5: 0x4000, 0xbe6: 0x4000, 0xbe7: 0x4000, 0xbe8: 0x4000, 0xbe9: 0x4000, - 0xbea: 0x4000, 0xbeb: 0x4000, 0xbec: 0x4000, 0xbed: 0x4000, 0xbee: 0x4000, 0xbef: 0x4000, - 0xbf0: 0x4000, 0xbf1: 0x4000, 0xbf2: 0x4000, 0xbf3: 0x4000, 0xbf4: 0x4000, 0xbf5: 0x4000, - 0xbf6: 0x4000, 0xbf7: 0x4000, 0xbf8: 0x4000, 0xbf9: 0x4000, 0xbfa: 0x4000, 0xbfb: 0x4000, - 0xbfc: 0x4000, 0xbfd: 0x4000, 0xbfe: 0x4000, 0xbff: 0x4000, - // Block 0x30, offset 0xc00 - 0xc00: 0x4000, 0xc01: 0x4000, 0xc02: 0x4000, 0xc03: 0x4000, 0xc04: 0x4000, 0xc05: 0x4000, - 0xc06: 0x4000, 0xc07: 0x4000, 0xc08: 0x4000, 0xc09: 0x4000, 0xc0a: 0x4000, 0xc0b: 0x4000, - 0xc0c: 0x4000, 0xc0d: 0x4000, 0xc0e: 0x4000, 0xc0f: 0x4000, 0xc10: 0x4000, 0xc11: 0x4000, - 0xc12: 0x4000, 0xc13: 0x4000, 0xc14: 0x4000, 0xc15: 0x4000, 0xc16: 0x4000, 0xc17: 0x4000, - 0xc18: 0x4000, 0xc19: 0x4000, 0xc1a: 0x4000, 0xc1b: 0x4000, 0xc1c: 0x4000, 0xc1d: 0x4000, - 0xc1e: 0x4000, 0xc1f: 0x4000, 0xc20: 0x4000, 0xc21: 0x4000, 0xc22: 0x4000, 0xc23: 0x4000, - 0xc24: 0x4000, 0xc25: 0x4000, 0xc26: 0x4000, 0xc27: 0x4000, 0xc28: 0x4000, 0xc29: 0x4000, - 0xc2a: 0x4000, 0xc2b: 0x4000, 0xc2c: 0x4000, 0xc2d: 0x4000, 0xc2e: 0x4000, 0xc2f: 0x4000, - 0xc30: 0x4000, 0xc31: 0x4000, 0xc32: 0x4000, 0xc33: 0x4000, - // Block 0x31, offset 0xc40 - 0xc40: 0x4000, 0xc41: 0x4000, 0xc42: 0x4000, 0xc43: 0x4000, 0xc44: 0x4000, 0xc45: 0x4000, - 0xc46: 0x4000, 0xc47: 0x4000, 0xc48: 0x4000, 0xc49: 0x4000, 0xc4a: 0x4000, 0xc4b: 0x4000, - 0xc4c: 0x4000, 0xc4d: 0x4000, 0xc4e: 0x4000, 0xc4f: 0x4000, 0xc50: 0x4000, 0xc51: 0x4000, - 0xc52: 0x4000, 0xc53: 0x4000, 0xc54: 0x4000, 0xc55: 0x4000, - 0xc70: 0x4000, 0xc71: 0x4000, 0xc72: 0x4000, 0xc73: 0x4000, 0xc74: 0x4000, 0xc75: 0x4000, - 0xc76: 0x4000, 0xc77: 0x4000, 0xc78: 0x4000, 0xc79: 0x4000, 0xc7a: 0x4000, 0xc7b: 0x4000, - // Block 0x32, offset 0xc80 - 0xc80: 0x9012, 0xc81: 0x4013, 0xc82: 0x4014, 0xc83: 0x4000, 0xc84: 0x4000, 0xc85: 0x4000, - 0xc86: 0x4000, 0xc87: 0x4000, 0xc88: 0x4000, 0xc89: 0x4000, 0xc8a: 0x4000, 0xc8b: 0x4000, - 0xc8c: 0x4015, 0xc8d: 0x4015, 0xc8e: 0x4000, 0xc8f: 0x4000, 0xc90: 0x4000, 0xc91: 0x4000, - 0xc92: 0x4000, 0xc93: 0x4000, 0xc94: 0x4000, 0xc95: 0x4000, 0xc96: 0x4000, 0xc97: 0x4000, - 0xc98: 0x4000, 0xc99: 0x4000, 0xc9a: 0x4000, 0xc9b: 0x4000, 0xc9c: 0x4000, 0xc9d: 0x4000, - 0xc9e: 0x4000, 0xc9f: 0x4000, 0xca0: 0x4000, 0xca1: 0x4000, 0xca2: 0x4000, 0xca3: 0x4000, - 0xca4: 0x4000, 0xca5: 0x4000, 0xca6: 0x4000, 0xca7: 0x4000, 0xca8: 0x4000, 0xca9: 0x4000, - 0xcaa: 0x4000, 0xcab: 0x4000, 0xcac: 0x4000, 0xcad: 0x4000, 0xcae: 0x4000, 0xcaf: 0x4000, - 0xcb0: 0x4000, 0xcb1: 0x4000, 0xcb2: 0x4000, 0xcb3: 0x4000, 0xcb4: 0x4000, 0xcb5: 0x4000, - 0xcb6: 0x4000, 0xcb7: 0x4000, 0xcb8: 0x4000, 0xcb9: 0x4000, 0xcba: 0x4000, 0xcbb: 0x4000, - 0xcbc: 0x4000, 0xcbd: 0x4000, 0xcbe: 0x4000, - // Block 0x33, offset 0xcc0 - 0xcc1: 0x4000, 0xcc2: 0x4000, 0xcc3: 0x4000, 0xcc4: 0x4000, 0xcc5: 0x4000, - 0xcc6: 0x4000, 0xcc7: 0x4000, 0xcc8: 0x4000, 0xcc9: 0x4000, 0xcca: 0x4000, 0xccb: 0x4000, - 0xccc: 0x4000, 0xccd: 0x4000, 0xcce: 0x4000, 0xccf: 0x4000, 0xcd0: 0x4000, 0xcd1: 0x4000, - 0xcd2: 0x4000, 0xcd3: 0x4000, 0xcd4: 0x4000, 0xcd5: 0x4000, 0xcd6: 0x4000, 0xcd7: 0x4000, - 0xcd8: 0x4000, 0xcd9: 0x4000, 0xcda: 0x4000, 0xcdb: 0x4000, 0xcdc: 0x4000, 0xcdd: 0x4000, - 0xcde: 0x4000, 0xcdf: 0x4000, 0xce0: 0x4000, 0xce1: 0x4000, 0xce2: 0x4000, 0xce3: 0x4000, - 0xce4: 0x4000, 0xce5: 0x4000, 0xce6: 0x4000, 0xce7: 0x4000, 0xce8: 0x4000, 0xce9: 0x4000, - 0xcea: 0x4000, 0xceb: 0x4000, 0xcec: 0x4000, 0xced: 0x4000, 0xcee: 0x4000, 0xcef: 0x4000, - 0xcf0: 0x4000, 0xcf1: 0x4000, 0xcf2: 0x4000, 0xcf3: 0x4000, 0xcf4: 0x4000, 0xcf5: 0x4000, - 0xcf6: 0x4000, 0xcf7: 0x4000, 0xcf8: 0x4000, 0xcf9: 0x4000, 0xcfa: 0x4000, 0xcfb: 0x4000, - 0xcfc: 0x4000, 0xcfd: 0x4000, 0xcfe: 0x4000, 0xcff: 0x4000, - // Block 0x34, offset 0xd00 - 0xd00: 0x4000, 0xd01: 0x4000, 0xd02: 0x4000, 0xd03: 0x4000, 0xd04: 0x4000, 0xd05: 0x4000, - 0xd06: 0x4000, 0xd07: 0x4000, 0xd08: 0x4000, 0xd09: 0x4000, 0xd0a: 0x4000, 0xd0b: 0x4000, - 0xd0c: 0x4000, 0xd0d: 0x4000, 0xd0e: 0x4000, 0xd0f: 0x4000, 0xd10: 0x4000, 0xd11: 0x4000, - 0xd12: 0x4000, 0xd13: 0x4000, 0xd14: 0x4000, 0xd15: 0x4000, 0xd16: 0x4000, - 0xd19: 0x4016, 0xd1a: 0x4017, 0xd1b: 0x4000, 0xd1c: 0x4000, 0xd1d: 0x4000, - 0xd1e: 0x4000, 0xd1f: 0x4000, 0xd20: 0x4000, 0xd21: 0x4018, 0xd22: 0x4019, 0xd23: 0x401a, - 0xd24: 0x401b, 0xd25: 0x401c, 0xd26: 0x401d, 0xd27: 0x401e, 0xd28: 0x401f, 0xd29: 0x4020, - 0xd2a: 0x4021, 0xd2b: 0x4022, 0xd2c: 0x4000, 0xd2d: 0x4010, 0xd2e: 0x4000, 0xd2f: 0x4023, - 0xd30: 0x4000, 0xd31: 0x4024, 0xd32: 0x4000, 0xd33: 0x4025, 0xd34: 0x4000, 0xd35: 0x4026, - 0xd36: 0x4000, 0xd37: 0x401a, 0xd38: 0x4000, 0xd39: 0x4027, 0xd3a: 0x4000, 0xd3b: 0x4028, - 0xd3c: 0x4000, 0xd3d: 0x4020, 0xd3e: 0x4000, 0xd3f: 0x4029, - // Block 0x35, offset 0xd40 - 0xd40: 0x4000, 0xd41: 0x402a, 0xd42: 0x4000, 0xd43: 0x402b, 0xd44: 0x402c, 0xd45: 0x4000, - 0xd46: 0x4017, 0xd47: 0x4000, 0xd48: 0x402d, 0xd49: 0x4000, 0xd4a: 0x402e, 0xd4b: 0x402f, - 0xd4c: 0x4030, 0xd4d: 0x4017, 0xd4e: 0x4016, 0xd4f: 0x4017, 0xd50: 0x4000, 0xd51: 0x4000, - 0xd52: 0x4031, 0xd53: 0x4000, 0xd54: 0x4000, 0xd55: 0x4031, 0xd56: 0x4000, 0xd57: 0x4000, - 0xd58: 0x4032, 0xd59: 0x4000, 0xd5a: 0x4000, 0xd5b: 0x4032, 0xd5c: 0x4000, 0xd5d: 0x4000, - 0xd5e: 0x4033, 0xd5f: 0x402e, 0xd60: 0x4034, 0xd61: 0x4035, 0xd62: 0x4034, 0xd63: 0x4036, - 0xd64: 0x4037, 0xd65: 0x4024, 0xd66: 0x4035, 0xd67: 0x4025, 0xd68: 0x4038, 0xd69: 0x4038, - 0xd6a: 0x4039, 0xd6b: 0x4039, 0xd6c: 0x403a, 0xd6d: 0x403a, 0xd6e: 0x4000, 0xd6f: 0x4035, - 0xd70: 0x4000, 0xd71: 0x4000, 0xd72: 0x403b, 0xd73: 0x403c, 0xd74: 0x4000, 0xd75: 0x4000, - 0xd76: 0x4000, 0xd77: 0x4000, 0xd78: 0x4000, 0xd79: 0x4000, 0xd7a: 0x4000, 0xd7b: 0x403d, - 0xd7c: 0x401c, 0xd7d: 0x4000, 0xd7e: 0x4000, 0xd7f: 0x4000, - // Block 0x36, offset 0xd80 - 0xd85: 0x4000, - 0xd86: 0x4000, 0xd87: 0x4000, 0xd88: 0x4000, 0xd89: 0x4000, 0xd8a: 0x4000, 0xd8b: 0x4000, - 0xd8c: 0x4000, 0xd8d: 0x4000, 0xd8e: 0x4000, 0xd8f: 0x4000, 0xd90: 0x4000, 0xd91: 0x4000, - 0xd92: 0x4000, 0xd93: 0x4000, 0xd94: 0x4000, 0xd95: 0x4000, 0xd96: 0x4000, 0xd97: 0x4000, - 0xd98: 0x4000, 0xd99: 0x4000, 0xd9a: 0x4000, 0xd9b: 0x4000, 0xd9c: 0x4000, 0xd9d: 0x4000, - 0xd9e: 0x4000, 0xd9f: 0x4000, 0xda0: 0x4000, 0xda1: 0x4000, 0xda2: 0x4000, 0xda3: 0x4000, - 0xda4: 0x4000, 0xda5: 0x4000, 0xda6: 0x4000, 0xda7: 0x4000, 0xda8: 0x4000, 0xda9: 0x4000, - 0xdaa: 0x4000, 0xdab: 0x4000, 0xdac: 0x4000, 0xdad: 0x4000, 0xdae: 0x4000, 0xdaf: 0x4000, - 0xdb1: 0x403e, 0xdb2: 0x403e, 0xdb3: 0x403e, 0xdb4: 0x403e, 0xdb5: 0x403e, - 0xdb6: 0x403e, 0xdb7: 0x403e, 0xdb8: 0x403e, 0xdb9: 0x403e, 0xdba: 0x403e, 0xdbb: 0x403e, - 0xdbc: 0x403e, 0xdbd: 0x403e, 0xdbe: 0x403e, 0xdbf: 0x403e, - // Block 0x37, offset 0xdc0 - 0xdc0: 0x4037, 0xdc1: 0x4037, 0xdc2: 0x4037, 0xdc3: 0x4037, 0xdc4: 0x4037, 0xdc5: 0x4037, - 0xdc6: 0x4037, 0xdc7: 0x4037, 0xdc8: 0x4037, 0xdc9: 0x4037, 0xdca: 0x4037, 0xdcb: 0x4037, - 0xdcc: 0x4037, 0xdcd: 0x4037, 0xdce: 0x4037, 0xdcf: 0x400e, 0xdd0: 0x403f, 0xdd1: 0x4040, - 0xdd2: 0x4041, 0xdd3: 0x4040, 0xdd4: 0x403f, 0xdd5: 0x4042, 0xdd6: 0x4043, 0xdd7: 0x4044, - 0xdd8: 0x4040, 0xdd9: 0x4041, 0xdda: 0x4040, 0xddb: 0x4045, 0xddc: 0x4009, 0xddd: 0x4045, - 0xdde: 0x4046, 0xddf: 0x4045, 0xde0: 0x4047, 0xde1: 0x400b, 0xde2: 0x400a, 0xde3: 0x400c, - 0xde4: 0x4048, 0xde5: 0x4000, 0xde6: 0x4000, 0xde7: 0x4000, 0xde8: 0x4000, 0xde9: 0x4000, - 0xdea: 0x4000, 0xdeb: 0x4000, 0xdec: 0x4000, 0xded: 0x4000, 0xdee: 0x4000, 0xdef: 0x4000, - 0xdf0: 0x4000, 0xdf1: 0x4000, 0xdf2: 0x4000, 0xdf3: 0x4000, 0xdf4: 0x4000, 0xdf5: 0x4000, - 0xdf6: 0x4000, 0xdf7: 0x4000, 0xdf8: 0x4000, 0xdf9: 0x4000, 0xdfa: 0x4000, 0xdfb: 0x4000, - 0xdfc: 0x4000, 0xdfd: 0x4000, 0xdfe: 0x4000, 0xdff: 0x4000, - // Block 0x38, offset 0xe00 - 0xe00: 0x4000, 0xe01: 0x4000, 0xe02: 0x4000, 0xe03: 0x4000, 0xe04: 0x4000, 0xe05: 0x4000, - 0xe06: 0x4000, 0xe07: 0x4000, 0xe08: 0x4000, 0xe09: 0x4000, 0xe0a: 0x4000, 0xe0b: 0x4000, - 0xe0c: 0x4000, 0xe0d: 0x4000, 0xe0e: 0x4000, 0xe10: 0x4000, 0xe11: 0x4000, - 0xe12: 0x4000, 0xe13: 0x4000, 0xe14: 0x4000, 0xe15: 0x4000, 0xe16: 0x4000, 0xe17: 0x4000, - 0xe18: 0x4000, 0xe19: 0x4000, 0xe1a: 0x4000, 0xe1b: 0x4000, 0xe1c: 0x4000, 0xe1d: 0x4000, - 0xe1e: 0x4000, 0xe1f: 0x4000, 0xe20: 0x4000, 0xe21: 0x4000, 0xe22: 0x4000, 0xe23: 0x4000, - 0xe24: 0x4000, 0xe25: 0x4000, 0xe26: 0x4000, 0xe27: 0x4000, 0xe28: 0x4000, 0xe29: 0x4000, - 0xe2a: 0x4000, 0xe2b: 0x4000, 0xe2c: 0x4000, 0xe2d: 0x4000, 0xe2e: 0x4000, 0xe2f: 0x4000, - 0xe30: 0x4000, 0xe31: 0x4000, 0xe32: 0x4000, 0xe33: 0x4000, 0xe34: 0x4000, 0xe35: 0x4000, - 0xe36: 0x4000, 0xe37: 0x4000, 0xe38: 0x4000, 0xe39: 0x4000, 0xe3a: 0x4000, 0xe3b: 0x4000, - 0xe3c: 0x4000, 0xe3d: 0x4000, 0xe3e: 0x4000, 0xe3f: 0x4000, - // Block 0x39, offset 0xe40 - 0xe40: 0x4000, 0xe41: 0x4000, 0xe42: 0x4000, 0xe43: 0x4000, 0xe44: 0x4000, 0xe45: 0x4000, - 0xe46: 0x4000, 0xe47: 0x4000, 0xe48: 0x4000, 0xe49: 0x4000, 0xe4a: 0x4000, 0xe4b: 0x4000, - 0xe4c: 0x4000, 0xe4d: 0x4000, 0xe4e: 0x4000, 0xe4f: 0x4000, 0xe50: 0x4000, 0xe51: 0x4000, - 0xe52: 0x4000, 0xe53: 0x4000, 0xe54: 0x4000, 0xe55: 0x4000, 0xe56: 0x4000, 0xe57: 0x4000, - 0xe58: 0x4000, 0xe59: 0x4000, 0xe5a: 0x4000, 0xe5b: 0x4000, 0xe5c: 0x4000, 0xe5d: 0x4000, - 0xe5e: 0x4000, 0xe5f: 0x4000, 0xe60: 0x4000, 0xe61: 0x4000, 0xe62: 0x4000, 0xe63: 0x4000, - 0xe70: 0x4000, 0xe71: 0x4000, 0xe72: 0x4000, 0xe73: 0x4000, 0xe74: 0x4000, 0xe75: 0x4000, - 0xe76: 0x4000, 0xe77: 0x4000, 0xe78: 0x4000, 0xe79: 0x4000, 0xe7a: 0x4000, 0xe7b: 0x4000, - 0xe7c: 0x4000, 0xe7d: 0x4000, 0xe7e: 0x4000, 0xe7f: 0x4000, - // Block 0x3a, offset 0xe80 - 0xe80: 0x4000, 0xe81: 0x4000, 0xe82: 0x4000, 0xe83: 0x4000, 0xe84: 0x4000, 0xe85: 0x4000, - 0xe86: 0x4000, 0xe87: 0x4000, 0xe88: 0x4000, 0xe89: 0x4000, 0xe8a: 0x4000, 0xe8b: 0x4000, - 0xe8c: 0x4000, 0xe8d: 0x4000, 0xe8e: 0x4000, 0xe8f: 0x4000, 0xe90: 0x4000, 0xe91: 0x4000, - 0xe92: 0x4000, 0xe93: 0x4000, 0xe94: 0x4000, 0xe95: 0x4000, 0xe96: 0x4000, 0xe97: 0x4000, - 0xe98: 0x4000, 0xe99: 0x4000, 0xe9a: 0x4000, 0xe9b: 0x4000, 0xe9c: 0x4000, 0xe9d: 0x4000, - 0xe9e: 0x4000, 0xea0: 0x4000, 0xea1: 0x4000, 0xea2: 0x4000, 0xea3: 0x4000, - 0xea4: 0x4000, 0xea5: 0x4000, 0xea6: 0x4000, 0xea7: 0x4000, 0xea8: 0x4000, 0xea9: 0x4000, - 0xeaa: 0x4000, 0xeab: 0x4000, 0xeac: 0x4000, 0xead: 0x4000, 0xeae: 0x4000, 0xeaf: 0x4000, - 0xeb0: 0x4000, 0xeb1: 0x4000, 0xeb2: 0x4000, 0xeb3: 0x4000, 0xeb4: 0x4000, 0xeb5: 0x4000, - 0xeb6: 0x4000, 0xeb7: 0x4000, 0xeb8: 0x4000, 0xeb9: 0x4000, 0xeba: 0x4000, 0xebb: 0x4000, - 0xebc: 0x4000, 0xebd: 0x4000, 0xebe: 0x4000, 0xebf: 0x4000, - // Block 0x3b, offset 0xec0 - 0xec0: 0x4000, 0xec1: 0x4000, 0xec2: 0x4000, 0xec3: 0x4000, 0xec4: 0x4000, 0xec5: 0x4000, - 0xec6: 0x4000, 0xec7: 0x4000, 0xec8: 0x2000, 0xec9: 0x2000, 0xeca: 0x2000, 0xecb: 0x2000, - 0xecc: 0x2000, 0xecd: 0x2000, 0xece: 0x2000, 0xecf: 0x2000, 0xed0: 0x4000, 0xed1: 0x4000, - 0xed2: 0x4000, 0xed3: 0x4000, 0xed4: 0x4000, 0xed5: 0x4000, 0xed6: 0x4000, 0xed7: 0x4000, - 0xed8: 0x4000, 0xed9: 0x4000, 0xeda: 0x4000, 0xedb: 0x4000, 0xedc: 0x4000, 0xedd: 0x4000, - 0xede: 0x4000, 0xedf: 0x4000, 0xee0: 0x4000, 0xee1: 0x4000, 0xee2: 0x4000, 0xee3: 0x4000, - 0xee4: 0x4000, 0xee5: 0x4000, 0xee6: 0x4000, 0xee7: 0x4000, 0xee8: 0x4000, 0xee9: 0x4000, - 0xeea: 0x4000, 0xeeb: 0x4000, 0xeec: 0x4000, 0xeed: 0x4000, 0xeee: 0x4000, 0xeef: 0x4000, - 0xef0: 0x4000, 0xef1: 0x4000, 0xef2: 0x4000, 0xef3: 0x4000, 0xef4: 0x4000, 0xef5: 0x4000, - 0xef6: 0x4000, 0xef7: 0x4000, 0xef8: 0x4000, 0xef9: 0x4000, 0xefa: 0x4000, 0xefb: 0x4000, - 0xefc: 0x4000, 0xefd: 0x4000, 0xefe: 0x4000, 0xeff: 0x4000, - // Block 0x3c, offset 0xf00 - 0xf00: 0x4000, 0xf01: 0x4000, 0xf02: 0x4000, 0xf03: 0x4000, 0xf04: 0x4000, 0xf05: 0x4000, - 0xf06: 0x4000, 0xf07: 0x4000, 0xf08: 0x4000, 0xf09: 0x4000, 0xf0a: 0x4000, 0xf0b: 0x4000, - 0xf0c: 0x4000, 0xf10: 0x4000, 0xf11: 0x4000, - 0xf12: 0x4000, 0xf13: 0x4000, 0xf14: 0x4000, 0xf15: 0x4000, 0xf16: 0x4000, 0xf17: 0x4000, - 0xf18: 0x4000, 0xf19: 0x4000, 0xf1a: 0x4000, 0xf1b: 0x4000, 0xf1c: 0x4000, 0xf1d: 0x4000, - 0xf1e: 0x4000, 0xf1f: 0x4000, 0xf20: 0x4000, 0xf21: 0x4000, 0xf22: 0x4000, 0xf23: 0x4000, - 0xf24: 0x4000, 0xf25: 0x4000, 0xf26: 0x4000, 0xf27: 0x4000, 0xf28: 0x4000, 0xf29: 0x4000, - 0xf2a: 0x4000, 0xf2b: 0x4000, 0xf2c: 0x4000, 0xf2d: 0x4000, 0xf2e: 0x4000, 0xf2f: 0x4000, - 0xf30: 0x4000, 0xf31: 0x4000, 0xf32: 0x4000, 0xf33: 0x4000, 0xf34: 0x4000, 0xf35: 0x4000, - 0xf36: 0x4000, 0xf37: 0x4000, 0xf38: 0x4000, 0xf39: 0x4000, 0xf3a: 0x4000, 0xf3b: 0x4000, - 0xf3c: 0x4000, 0xf3d: 0x4000, 0xf3e: 0x4000, 0xf3f: 0x4000, - // Block 0x3d, offset 0xf40 - 0xf40: 0x4000, 0xf41: 0x4000, 0xf42: 0x4000, 0xf43: 0x4000, 0xf44: 0x4000, 0xf45: 0x4000, - 0xf46: 0x4000, - // Block 0x3e, offset 0xf80 - 0xfa0: 0x4000, 0xfa1: 0x4000, 0xfa2: 0x4000, 0xfa3: 0x4000, - 0xfa4: 0x4000, 0xfa5: 0x4000, 0xfa6: 0x4000, 0xfa7: 0x4000, 0xfa8: 0x4000, 0xfa9: 0x4000, - 0xfaa: 0x4000, 0xfab: 0x4000, 0xfac: 0x4000, 0xfad: 0x4000, 0xfae: 0x4000, 0xfaf: 0x4000, - 0xfb0: 0x4000, 0xfb1: 0x4000, 0xfb2: 0x4000, 0xfb3: 0x4000, 0xfb4: 0x4000, 0xfb5: 0x4000, - 0xfb6: 0x4000, 0xfb7: 0x4000, 0xfb8: 0x4000, 0xfb9: 0x4000, 0xfba: 0x4000, 0xfbb: 0x4000, - 0xfbc: 0x4000, - // Block 0x3f, offset 0xfc0 - 0xfc0: 0x4000, 0xfc1: 0x4000, 0xfc2: 0x4000, 0xfc3: 0x4000, 0xfc4: 0x4000, 0xfc5: 0x4000, - 0xfc6: 0x4000, 0xfc7: 0x4000, 0xfc8: 0x4000, 0xfc9: 0x4000, 0xfca: 0x4000, 0xfcb: 0x4000, - 0xfcc: 0x4000, 0xfcd: 0x4000, 0xfce: 0x4000, 0xfcf: 0x4000, 0xfd0: 0x4000, 0xfd1: 0x4000, - 0xfd2: 0x4000, 0xfd3: 0x4000, 0xfd4: 0x4000, 0xfd5: 0x4000, 0xfd6: 0x4000, 0xfd7: 0x4000, - 0xfd8: 0x4000, 0xfd9: 0x4000, 0xfda: 0x4000, 0xfdb: 0x4000, 0xfdc: 0x4000, 0xfdd: 0x4000, - 0xfde: 0x4000, 0xfdf: 0x4000, 0xfe0: 0x4000, 0xfe1: 0x4000, 0xfe2: 0x4000, 0xfe3: 0x4000, - // Block 0x40, offset 0x1000 - 0x1000: 0x2000, 0x1001: 0x2000, 0x1002: 0x2000, 0x1003: 0x2000, 0x1004: 0x2000, 0x1005: 0x2000, - 0x1006: 0x2000, 0x1007: 0x2000, 0x1008: 0x2000, 0x1009: 0x2000, 0x100a: 0x2000, 0x100b: 0x2000, - 0x100c: 0x2000, 0x100d: 0x2000, 0x100e: 0x2000, 0x100f: 0x2000, 0x1010: 0x4000, 0x1011: 0x4000, - 0x1012: 0x4000, 0x1013: 0x4000, 0x1014: 0x4000, 0x1015: 0x4000, 0x1016: 0x4000, 0x1017: 0x4000, - 0x1018: 0x4000, 0x1019: 0x4000, - 0x1030: 0x4000, 0x1031: 0x4000, 0x1032: 0x4000, 0x1033: 0x4000, 0x1034: 0x4000, 0x1035: 0x4000, - 0x1036: 0x4000, 0x1037: 0x4000, 0x1038: 0x4000, 0x1039: 0x4000, 0x103a: 0x4000, 0x103b: 0x4000, - 0x103c: 0x4000, 0x103d: 0x4000, 0x103e: 0x4000, 0x103f: 0x4000, - // Block 0x41, offset 0x1040 - 0x1040: 0x4000, 0x1041: 0x4000, 0x1042: 0x4000, 0x1043: 0x4000, 0x1044: 0x4000, 0x1045: 0x4000, - 0x1046: 0x4000, 0x1047: 0x4000, 0x1048: 0x4000, 0x1049: 0x4000, 0x104a: 0x4000, 0x104b: 0x4000, - 0x104c: 0x4000, 0x104d: 0x4000, 0x104e: 0x4000, 0x104f: 0x4000, 0x1050: 0x4000, 0x1051: 0x4000, - 0x1052: 0x4000, 0x1054: 0x4000, 0x1055: 0x4000, 0x1056: 0x4000, 0x1057: 0x4000, - 0x1058: 0x4000, 0x1059: 0x4000, 0x105a: 0x4000, 0x105b: 0x4000, 0x105c: 0x4000, 0x105d: 0x4000, - 0x105e: 0x4000, 0x105f: 0x4000, 0x1060: 0x4000, 0x1061: 0x4000, 0x1062: 0x4000, 0x1063: 0x4000, - 0x1064: 0x4000, 0x1065: 0x4000, 0x1066: 0x4000, 0x1068: 0x4000, 0x1069: 0x4000, - 0x106a: 0x4000, 0x106b: 0x4000, - // Block 0x42, offset 0x1080 - 0x1081: 0x9012, 0x1082: 0x9012, 0x1083: 0x9012, 0x1084: 0x9012, 0x1085: 0x9012, - 0x1086: 0x9012, 0x1087: 0x9012, 0x1088: 0x9012, 0x1089: 0x9012, 0x108a: 0x9012, 0x108b: 0x9012, - 0x108c: 0x9012, 0x108d: 0x9012, 0x108e: 0x9012, 0x108f: 0x9012, 0x1090: 0x9012, 0x1091: 0x9012, - 0x1092: 0x9012, 0x1093: 0x9012, 0x1094: 0x9012, 0x1095: 0x9012, 0x1096: 0x9012, 0x1097: 0x9012, - 0x1098: 0x9012, 0x1099: 0x9012, 0x109a: 0x9012, 0x109b: 0x9012, 0x109c: 0x9012, 0x109d: 0x9012, - 0x109e: 0x9012, 0x109f: 0x9012, 0x10a0: 0x9049, 0x10a1: 0x9049, 0x10a2: 0x9049, 0x10a3: 0x9049, - 0x10a4: 0x9049, 0x10a5: 0x9049, 0x10a6: 0x9049, 0x10a7: 0x9049, 0x10a8: 0x9049, 0x10a9: 0x9049, - 0x10aa: 0x9049, 0x10ab: 0x9049, 0x10ac: 0x9049, 0x10ad: 0x9049, 0x10ae: 0x9049, 0x10af: 0x9049, - 0x10b0: 0x9049, 0x10b1: 0x9049, 0x10b2: 0x9049, 0x10b3: 0x9049, 0x10b4: 0x9049, 0x10b5: 0x9049, - 0x10b6: 0x9049, 0x10b7: 0x9049, 0x10b8: 0x9049, 0x10b9: 0x9049, 0x10ba: 0x9049, 0x10bb: 0x9049, - 0x10bc: 0x9049, 0x10bd: 0x9049, 0x10be: 0x9049, 0x10bf: 0x9049, - // Block 0x43, offset 0x10c0 - 0x10c0: 0x9049, 0x10c1: 0x9049, 0x10c2: 0x9049, 0x10c3: 0x9049, 0x10c4: 0x9049, 0x10c5: 0x9049, - 0x10c6: 0x9049, 0x10c7: 0x9049, 0x10c8: 0x9049, 0x10c9: 0x9049, 0x10ca: 0x9049, 0x10cb: 0x9049, - 0x10cc: 0x9049, 0x10cd: 0x9049, 0x10ce: 0x9049, 0x10cf: 0x9049, 0x10d0: 0x9049, 0x10d1: 0x9049, - 0x10d2: 0x9049, 0x10d3: 0x9049, 0x10d4: 0x9049, 0x10d5: 0x9049, 0x10d6: 0x9049, 0x10d7: 0x9049, - 0x10d8: 0x9049, 0x10d9: 0x9049, 0x10da: 0x9049, 0x10db: 0x9049, 0x10dc: 0x9049, 0x10dd: 0x9049, - 0x10de: 0x9049, 0x10df: 0x904a, 0x10e0: 0x904b, 0x10e1: 0xb04c, 0x10e2: 0xb04d, 0x10e3: 0xb04d, - 0x10e4: 0xb04e, 0x10e5: 0xb04f, 0x10e6: 0xb050, 0x10e7: 0xb051, 0x10e8: 0xb052, 0x10e9: 0xb053, - 0x10ea: 0xb054, 0x10eb: 0xb055, 0x10ec: 0xb056, 0x10ed: 0xb057, 0x10ee: 0xb058, 0x10ef: 0xb059, - 0x10f0: 0xb05a, 0x10f1: 0xb05b, 0x10f2: 0xb05c, 0x10f3: 0xb05d, 0x10f4: 0xb05e, 0x10f5: 0xb05f, - 0x10f6: 0xb060, 0x10f7: 0xb061, 0x10f8: 0xb062, 0x10f9: 0xb063, 0x10fa: 0xb064, 0x10fb: 0xb065, - 0x10fc: 0xb052, 0x10fd: 0xb066, 0x10fe: 0xb067, 0x10ff: 0xb055, - // Block 0x44, offset 0x1100 - 0x1100: 0xb068, 0x1101: 0xb069, 0x1102: 0xb06a, 0x1103: 0xb06b, 0x1104: 0xb05a, 0x1105: 0xb056, - 0x1106: 0xb06c, 0x1107: 0xb06d, 0x1108: 0xb06b, 0x1109: 0xb06e, 0x110a: 0xb06b, 0x110b: 0xb06f, - 0x110c: 0xb06f, 0x110d: 0xb070, 0x110e: 0xb070, 0x110f: 0xb071, 0x1110: 0xb056, 0x1111: 0xb072, - 0x1112: 0xb073, 0x1113: 0xb072, 0x1114: 0xb074, 0x1115: 0xb073, 0x1116: 0xb075, 0x1117: 0xb075, - 0x1118: 0xb076, 0x1119: 0xb076, 0x111a: 0xb077, 0x111b: 0xb077, 0x111c: 0xb073, 0x111d: 0xb078, - 0x111e: 0xb079, 0x111f: 0xb067, 0x1120: 0xb07a, 0x1121: 0xb07b, 0x1122: 0xb07b, 0x1123: 0xb07b, - 0x1124: 0xb07b, 0x1125: 0xb07b, 0x1126: 0xb07b, 0x1127: 0xb07b, 0x1128: 0xb07b, 0x1129: 0xb07b, - 0x112a: 0xb07b, 0x112b: 0xb07b, 0x112c: 0xb07b, 0x112d: 0xb07b, 0x112e: 0xb07b, 0x112f: 0xb07b, - 0x1130: 0xb07c, 0x1131: 0xb07c, 0x1132: 0xb07c, 0x1133: 0xb07c, 0x1134: 0xb07c, 0x1135: 0xb07c, - 0x1136: 0xb07c, 0x1137: 0xb07c, 0x1138: 0xb07c, 0x1139: 0xb07c, 0x113a: 0xb07c, 0x113b: 0xb07c, - 0x113c: 0xb07c, 0x113d: 0xb07c, 0x113e: 0xb07c, - // Block 0x45, offset 0x1140 - 0x1142: 0xb07d, 0x1143: 0xb07e, 0x1144: 0xb07f, 0x1145: 0xb080, - 0x1146: 0xb07f, 0x1147: 0xb07e, 0x114a: 0xb081, 0x114b: 0xb082, - 0x114c: 0xb083, 0x114d: 0xb07f, 0x114e: 0xb080, 0x114f: 0xb07f, - 0x1152: 0xb084, 0x1153: 0xb085, 0x1154: 0xb084, 0x1155: 0xb086, 0x1156: 0xb084, 0x1157: 0xb087, - 0x115a: 0xb088, 0x115b: 0xb089, 0x115c: 0xb08a, - 0x1160: 0x908b, 0x1161: 0x908b, 0x1162: 0x908c, 0x1163: 0x908d, - 0x1164: 0x908b, 0x1165: 0x908e, 0x1166: 0x908f, 0x1168: 0xb090, 0x1169: 0xb091, - 0x116a: 0xb092, 0x116b: 0xb091, 0x116c: 0xb093, 0x116d: 0xb094, 0x116e: 0xb095, - 0x117d: 0x2000, - // Block 0x46, offset 0x1180 - 0x11a0: 0x4000, 0x11a1: 0x4000, 0x11a2: 0x4000, 0x11a3: 0x4000, - 0x11a4: 0x4000, - 0x11b0: 0x4000, 0x11b1: 0x4000, - // Block 0x47, offset 0x11c0 - 0x11c0: 0x4000, 0x11c1: 0x4000, 0x11c2: 0x4000, 0x11c3: 0x4000, 0x11c4: 0x4000, 0x11c5: 0x4000, - 0x11c6: 0x4000, 0x11c7: 0x4000, 0x11c8: 0x4000, 0x11c9: 0x4000, 0x11ca: 0x4000, 0x11cb: 0x4000, - 0x11cc: 0x4000, 0x11cd: 0x4000, 0x11ce: 0x4000, 0x11cf: 0x4000, 0x11d0: 0x4000, 0x11d1: 0x4000, - 0x11d2: 0x4000, 0x11d3: 0x4000, 0x11d4: 0x4000, 0x11d5: 0x4000, 0x11d6: 0x4000, 0x11d7: 0x4000, - 0x11d8: 0x4000, 0x11d9: 0x4000, 0x11da: 0x4000, 0x11db: 0x4000, 0x11dc: 0x4000, 0x11dd: 0x4000, - 0x11de: 0x4000, 0x11df: 0x4000, 0x11e0: 0x4000, 0x11e1: 0x4000, 0x11e2: 0x4000, 0x11e3: 0x4000, - 0x11e4: 0x4000, 0x11e5: 0x4000, 0x11e6: 0x4000, 0x11e7: 0x4000, 0x11e8: 0x4000, 0x11e9: 0x4000, - 0x11ea: 0x4000, 0x11eb: 0x4000, 0x11ec: 0x4000, 0x11ed: 0x4000, 0x11ee: 0x4000, 0x11ef: 0x4000, - 0x11f0: 0x4000, 0x11f1: 0x4000, 0x11f2: 0x4000, 0x11f3: 0x4000, 0x11f4: 0x4000, 0x11f5: 0x4000, - 0x11f6: 0x4000, 0x11f7: 0x4000, - // Block 0x48, offset 0x1200 - 0x1200: 0x4000, 0x1201: 0x4000, 0x1202: 0x4000, 0x1203: 0x4000, 0x1204: 0x4000, 0x1205: 0x4000, - 0x1206: 0x4000, 0x1207: 0x4000, 0x1208: 0x4000, 0x1209: 0x4000, 0x120a: 0x4000, 0x120b: 0x4000, - 0x120c: 0x4000, 0x120d: 0x4000, 0x120e: 0x4000, 0x120f: 0x4000, 0x1210: 0x4000, 0x1211: 0x4000, - 0x1212: 0x4000, 0x1213: 0x4000, 0x1214: 0x4000, 0x1215: 0x4000, - // Block 0x49, offset 0x1240 - 0x1240: 0x4000, 0x1241: 0x4000, 0x1242: 0x4000, 0x1243: 0x4000, 0x1244: 0x4000, 0x1245: 0x4000, - 0x1246: 0x4000, 0x1247: 0x4000, 0x1248: 0x4000, - // Block 0x4a, offset 0x1280 - 0x1280: 0x4000, 0x1281: 0x4000, 0x1282: 0x4000, 0x1283: 0x4000, 0x1284: 0x4000, 0x1285: 0x4000, - 0x1286: 0x4000, 0x1287: 0x4000, 0x1288: 0x4000, 0x1289: 0x4000, 0x128a: 0x4000, 0x128b: 0x4000, - 0x128c: 0x4000, 0x128d: 0x4000, 0x128e: 0x4000, 0x128f: 0x4000, 0x1290: 0x4000, 0x1291: 0x4000, - 0x1292: 0x4000, 0x1293: 0x4000, 0x1294: 0x4000, 0x1295: 0x4000, 0x1296: 0x4000, 0x1297: 0x4000, - 0x1298: 0x4000, 0x1299: 0x4000, 0x129a: 0x4000, 0x129b: 0x4000, 0x129c: 0x4000, 0x129d: 0x4000, - 0x129e: 0x4000, - // Block 0x4b, offset 0x12c0 - 0x12d0: 0x4000, 0x12d1: 0x4000, - 0x12d2: 0x4000, - 0x12e4: 0x4000, 0x12e5: 0x4000, 0x12e6: 0x4000, 0x12e7: 0x4000, - 0x12f0: 0x4000, 0x12f1: 0x4000, 0x12f2: 0x4000, 0x12f3: 0x4000, 0x12f4: 0x4000, 0x12f5: 0x4000, - 0x12f6: 0x4000, 0x12f7: 0x4000, 0x12f8: 0x4000, 0x12f9: 0x4000, 0x12fa: 0x4000, 0x12fb: 0x4000, - 0x12fc: 0x4000, 0x12fd: 0x4000, 0x12fe: 0x4000, 0x12ff: 0x4000, - // Block 0x4c, offset 0x1300 - 0x1300: 0x4000, 0x1301: 0x4000, 0x1302: 0x4000, 0x1303: 0x4000, 0x1304: 0x4000, 0x1305: 0x4000, - 0x1306: 0x4000, 0x1307: 0x4000, 0x1308: 0x4000, 0x1309: 0x4000, 0x130a: 0x4000, 0x130b: 0x4000, - 0x130c: 0x4000, 0x130d: 0x4000, 0x130e: 0x4000, 0x130f: 0x4000, 0x1310: 0x4000, 0x1311: 0x4000, - 0x1312: 0x4000, 0x1313: 0x4000, 0x1314: 0x4000, 0x1315: 0x4000, 0x1316: 0x4000, 0x1317: 0x4000, - 0x1318: 0x4000, 0x1319: 0x4000, 0x131a: 0x4000, 0x131b: 0x4000, 0x131c: 0x4000, 0x131d: 0x4000, - 0x131e: 0x4000, 0x131f: 0x4000, 0x1320: 0x4000, 0x1321: 0x4000, 0x1322: 0x4000, 0x1323: 0x4000, - 0x1324: 0x4000, 0x1325: 0x4000, 0x1326: 0x4000, 0x1327: 0x4000, 0x1328: 0x4000, 0x1329: 0x4000, - 0x132a: 0x4000, 0x132b: 0x4000, 0x132c: 0x4000, 0x132d: 0x4000, 0x132e: 0x4000, 0x132f: 0x4000, - 0x1330: 0x4000, 0x1331: 0x4000, 0x1332: 0x4000, 0x1333: 0x4000, 0x1334: 0x4000, 0x1335: 0x4000, - 0x1336: 0x4000, 0x1337: 0x4000, 0x1338: 0x4000, 0x1339: 0x4000, 0x133a: 0x4000, 0x133b: 0x4000, - // Block 0x4d, offset 0x1340 - 0x1344: 0x4000, - // Block 0x4e, offset 0x1380 - 0x138f: 0x4000, - // Block 0x4f, offset 0x13c0 - 0x13c0: 0x2000, 0x13c1: 0x2000, 0x13c2: 0x2000, 0x13c3: 0x2000, 0x13c4: 0x2000, 0x13c5: 0x2000, - 0x13c6: 0x2000, 0x13c7: 0x2000, 0x13c8: 0x2000, 0x13c9: 0x2000, 0x13ca: 0x2000, - 0x13d0: 0x2000, 0x13d1: 0x2000, - 0x13d2: 0x2000, 0x13d3: 0x2000, 0x13d4: 0x2000, 0x13d5: 0x2000, 0x13d6: 0x2000, 0x13d7: 0x2000, - 0x13d8: 0x2000, 0x13d9: 0x2000, 0x13da: 0x2000, 0x13db: 0x2000, 0x13dc: 0x2000, 0x13dd: 0x2000, - 0x13de: 0x2000, 0x13df: 0x2000, 0x13e0: 0x2000, 0x13e1: 0x2000, 0x13e2: 0x2000, 0x13e3: 0x2000, - 0x13e4: 0x2000, 0x13e5: 0x2000, 0x13e6: 0x2000, 0x13e7: 0x2000, 0x13e8: 0x2000, 0x13e9: 0x2000, - 0x13ea: 0x2000, 0x13eb: 0x2000, 0x13ec: 0x2000, 0x13ed: 0x2000, - 0x13f0: 0x2000, 0x13f1: 0x2000, 0x13f2: 0x2000, 0x13f3: 0x2000, 0x13f4: 0x2000, 0x13f5: 0x2000, - 0x13f6: 0x2000, 0x13f7: 0x2000, 0x13f8: 0x2000, 0x13f9: 0x2000, 0x13fa: 0x2000, 0x13fb: 0x2000, - 0x13fc: 0x2000, 0x13fd: 0x2000, 0x13fe: 0x2000, 0x13ff: 0x2000, - // Block 0x50, offset 0x1400 - 0x1400: 0x2000, 0x1401: 0x2000, 0x1402: 0x2000, 0x1403: 0x2000, 0x1404: 0x2000, 0x1405: 0x2000, - 0x1406: 0x2000, 0x1407: 0x2000, 0x1408: 0x2000, 0x1409: 0x2000, 0x140a: 0x2000, 0x140b: 0x2000, - 0x140c: 0x2000, 0x140d: 0x2000, 0x140e: 0x2000, 0x140f: 0x2000, 0x1410: 0x2000, 0x1411: 0x2000, - 0x1412: 0x2000, 0x1413: 0x2000, 0x1414: 0x2000, 0x1415: 0x2000, 0x1416: 0x2000, 0x1417: 0x2000, - 0x1418: 0x2000, 0x1419: 0x2000, 0x141a: 0x2000, 0x141b: 0x2000, 0x141c: 0x2000, 0x141d: 0x2000, - 0x141e: 0x2000, 0x141f: 0x2000, 0x1420: 0x2000, 0x1421: 0x2000, 0x1422: 0x2000, 0x1423: 0x2000, - 0x1424: 0x2000, 0x1425: 0x2000, 0x1426: 0x2000, 0x1427: 0x2000, 0x1428: 0x2000, 0x1429: 0x2000, - 0x1430: 0x2000, 0x1431: 0x2000, 0x1432: 0x2000, 0x1433: 0x2000, 0x1434: 0x2000, 0x1435: 0x2000, - 0x1436: 0x2000, 0x1437: 0x2000, 0x1438: 0x2000, 0x1439: 0x2000, 0x143a: 0x2000, 0x143b: 0x2000, - 0x143c: 0x2000, 0x143d: 0x2000, 0x143e: 0x2000, 0x143f: 0x2000, - // Block 0x51, offset 0x1440 - 0x1440: 0x2000, 0x1441: 0x2000, 0x1442: 0x2000, 0x1443: 0x2000, 0x1444: 0x2000, 0x1445: 0x2000, - 0x1446: 0x2000, 0x1447: 0x2000, 0x1448: 0x2000, 0x1449: 0x2000, 0x144a: 0x2000, 0x144b: 0x2000, - 0x144c: 0x2000, 0x144d: 0x2000, 0x144e: 0x4000, 0x144f: 0x2000, 0x1450: 0x2000, 0x1451: 0x4000, - 0x1452: 0x4000, 0x1453: 0x4000, 0x1454: 0x4000, 0x1455: 0x4000, 0x1456: 0x4000, 0x1457: 0x4000, - 0x1458: 0x4000, 0x1459: 0x4000, 0x145a: 0x4000, 0x145b: 0x2000, 0x145c: 0x2000, 0x145d: 0x2000, - 0x145e: 0x2000, 0x145f: 0x2000, 0x1460: 0x2000, 0x1461: 0x2000, 0x1462: 0x2000, 0x1463: 0x2000, - 0x1464: 0x2000, 0x1465: 0x2000, 0x1466: 0x2000, 0x1467: 0x2000, 0x1468: 0x2000, 0x1469: 0x2000, - 0x146a: 0x2000, 0x146b: 0x2000, 0x146c: 0x2000, - // Block 0x52, offset 0x1480 - 0x1480: 0x4000, 0x1481: 0x4000, 0x1482: 0x4000, - 0x1490: 0x4000, 0x1491: 0x4000, - 0x1492: 0x4000, 0x1493: 0x4000, 0x1494: 0x4000, 0x1495: 0x4000, 0x1496: 0x4000, 0x1497: 0x4000, - 0x1498: 0x4000, 0x1499: 0x4000, 0x149a: 0x4000, 0x149b: 0x4000, 0x149c: 0x4000, 0x149d: 0x4000, - 0x149e: 0x4000, 0x149f: 0x4000, 0x14a0: 0x4000, 0x14a1: 0x4000, 0x14a2: 0x4000, 0x14a3: 0x4000, - 0x14a4: 0x4000, 0x14a5: 0x4000, 0x14a6: 0x4000, 0x14a7: 0x4000, 0x14a8: 0x4000, 0x14a9: 0x4000, - 0x14aa: 0x4000, 0x14ab: 0x4000, 0x14ac: 0x4000, 0x14ad: 0x4000, 0x14ae: 0x4000, 0x14af: 0x4000, - 0x14b0: 0x4000, 0x14b1: 0x4000, 0x14b2: 0x4000, 0x14b3: 0x4000, 0x14b4: 0x4000, 0x14b5: 0x4000, - 0x14b6: 0x4000, 0x14b7: 0x4000, 0x14b8: 0x4000, 0x14b9: 0x4000, 0x14ba: 0x4000, 0x14bb: 0x4000, - // Block 0x53, offset 0x14c0 - 0x14c0: 0x4000, 0x14c1: 0x4000, 0x14c2: 0x4000, 0x14c3: 0x4000, 0x14c4: 0x4000, 0x14c5: 0x4000, - 0x14c6: 0x4000, 0x14c7: 0x4000, 0x14c8: 0x4000, - 0x14d0: 0x4000, 0x14d1: 0x4000, - 0x14e0: 0x4000, 0x14e1: 0x4000, 0x14e2: 0x4000, 0x14e3: 0x4000, - 0x14e4: 0x4000, 0x14e5: 0x4000, - // Block 0x54, offset 0x1500 - 0x1500: 0x4000, 0x1501: 0x4000, 0x1502: 0x4000, 0x1503: 0x4000, 0x1504: 0x4000, 0x1505: 0x4000, - 0x1506: 0x4000, 0x1507: 0x4000, 0x1508: 0x4000, 0x1509: 0x4000, 0x150a: 0x4000, 0x150b: 0x4000, - 0x150c: 0x4000, 0x150d: 0x4000, 0x150e: 0x4000, 0x150f: 0x4000, 0x1510: 0x4000, 0x1511: 0x4000, - 0x1512: 0x4000, 0x1513: 0x4000, 0x1514: 0x4000, 0x1515: 0x4000, 0x1516: 0x4000, 0x1517: 0x4000, - 0x1518: 0x4000, 0x1519: 0x4000, 0x151a: 0x4000, 0x151b: 0x4000, 0x151c: 0x4000, 0x151d: 0x4000, - 0x151e: 0x4000, 0x151f: 0x4000, 0x1520: 0x4000, - 0x152d: 0x4000, 0x152e: 0x4000, 0x152f: 0x4000, - 0x1530: 0x4000, 0x1531: 0x4000, 0x1532: 0x4000, 0x1533: 0x4000, 0x1534: 0x4000, 0x1535: 0x4000, - 0x1537: 0x4000, 0x1538: 0x4000, 0x1539: 0x4000, 0x153a: 0x4000, 0x153b: 0x4000, - 0x153c: 0x4000, 0x153d: 0x4000, 0x153e: 0x4000, 0x153f: 0x4000, - // Block 0x55, offset 0x1540 - 0x1540: 0x4000, 0x1541: 0x4000, 0x1542: 0x4000, 0x1543: 0x4000, 0x1544: 0x4000, 0x1545: 0x4000, - 0x1546: 0x4000, 0x1547: 0x4000, 0x1548: 0x4000, 0x1549: 0x4000, 0x154a: 0x4000, 0x154b: 0x4000, - 0x154c: 0x4000, 0x154d: 0x4000, 0x154e: 0x4000, 0x154f: 0x4000, 0x1550: 0x4000, 0x1551: 0x4000, - 0x1552: 0x4000, 0x1553: 0x4000, 0x1554: 0x4000, 0x1555: 0x4000, 0x1556: 0x4000, 0x1557: 0x4000, - 0x1558: 0x4000, 0x1559: 0x4000, 0x155a: 0x4000, 0x155b: 0x4000, 0x155c: 0x4000, 0x155d: 0x4000, - 0x155e: 0x4000, 0x155f: 0x4000, 0x1560: 0x4000, 0x1561: 0x4000, 0x1562: 0x4000, 0x1563: 0x4000, - 0x1564: 0x4000, 0x1565: 0x4000, 0x1566: 0x4000, 0x1567: 0x4000, 0x1568: 0x4000, 0x1569: 0x4000, - 0x156a: 0x4000, 0x156b: 0x4000, 0x156c: 0x4000, 0x156d: 0x4000, 0x156e: 0x4000, 0x156f: 0x4000, - 0x1570: 0x4000, 0x1571: 0x4000, 0x1572: 0x4000, 0x1573: 0x4000, 0x1574: 0x4000, 0x1575: 0x4000, - 0x1576: 0x4000, 0x1577: 0x4000, 0x1578: 0x4000, 0x1579: 0x4000, 0x157a: 0x4000, 0x157b: 0x4000, - 0x157c: 0x4000, 0x157e: 0x4000, 0x157f: 0x4000, - // Block 0x56, offset 0x1580 - 0x1580: 0x4000, 0x1581: 0x4000, 0x1582: 0x4000, 0x1583: 0x4000, 0x1584: 0x4000, 0x1585: 0x4000, - 0x1586: 0x4000, 0x1587: 0x4000, 0x1588: 0x4000, 0x1589: 0x4000, 0x158a: 0x4000, 0x158b: 0x4000, - 0x158c: 0x4000, 0x158d: 0x4000, 0x158e: 0x4000, 0x158f: 0x4000, 0x1590: 0x4000, 0x1591: 0x4000, - 0x1592: 0x4000, 0x1593: 0x4000, - 0x15a0: 0x4000, 0x15a1: 0x4000, 0x15a2: 0x4000, 0x15a3: 0x4000, - 0x15a4: 0x4000, 0x15a5: 0x4000, 0x15a6: 0x4000, 0x15a7: 0x4000, 0x15a8: 0x4000, 0x15a9: 0x4000, - 0x15aa: 0x4000, 0x15ab: 0x4000, 0x15ac: 0x4000, 0x15ad: 0x4000, 0x15ae: 0x4000, 0x15af: 0x4000, - 0x15b0: 0x4000, 0x15b1: 0x4000, 0x15b2: 0x4000, 0x15b3: 0x4000, 0x15b4: 0x4000, 0x15b5: 0x4000, - 0x15b6: 0x4000, 0x15b7: 0x4000, 0x15b8: 0x4000, 0x15b9: 0x4000, 0x15ba: 0x4000, 0x15bb: 0x4000, - 0x15bc: 0x4000, 0x15bd: 0x4000, 0x15be: 0x4000, 0x15bf: 0x4000, - // Block 0x57, offset 0x15c0 - 0x15c0: 0x4000, 0x15c1: 0x4000, 0x15c2: 0x4000, 0x15c3: 0x4000, 0x15c4: 0x4000, 0x15c5: 0x4000, - 0x15c6: 0x4000, 0x15c7: 0x4000, 0x15c8: 0x4000, 0x15c9: 0x4000, 0x15ca: 0x4000, - 0x15cf: 0x4000, 0x15d0: 0x4000, 0x15d1: 0x4000, - 0x15d2: 0x4000, 0x15d3: 0x4000, - 0x15e0: 0x4000, 0x15e1: 0x4000, 0x15e2: 0x4000, 0x15e3: 0x4000, - 0x15e4: 0x4000, 0x15e5: 0x4000, 0x15e6: 0x4000, 0x15e7: 0x4000, 0x15e8: 0x4000, 0x15e9: 0x4000, - 0x15ea: 0x4000, 0x15eb: 0x4000, 0x15ec: 0x4000, 0x15ed: 0x4000, 0x15ee: 0x4000, 0x15ef: 0x4000, - 0x15f0: 0x4000, 0x15f4: 0x4000, - 0x15f8: 0x4000, 0x15f9: 0x4000, 0x15fa: 0x4000, 0x15fb: 0x4000, - 0x15fc: 0x4000, 0x15fd: 0x4000, 0x15fe: 0x4000, 0x15ff: 0x4000, - // Block 0x58, offset 0x1600 - 0x1600: 0x4000, 0x1601: 0x4000, 0x1602: 0x4000, 0x1603: 0x4000, 0x1604: 0x4000, 0x1605: 0x4000, - 0x1606: 0x4000, 0x1607: 0x4000, 0x1608: 0x4000, 0x1609: 0x4000, 0x160a: 0x4000, 0x160b: 0x4000, - 0x160c: 0x4000, 0x160d: 0x4000, 0x160e: 0x4000, 0x160f: 0x4000, 0x1610: 0x4000, 0x1611: 0x4000, - 0x1612: 0x4000, 0x1613: 0x4000, 0x1614: 0x4000, 0x1615: 0x4000, 0x1616: 0x4000, 0x1617: 0x4000, - 0x1618: 0x4000, 0x1619: 0x4000, 0x161a: 0x4000, 0x161b: 0x4000, 0x161c: 0x4000, 0x161d: 0x4000, - 0x161e: 0x4000, 0x161f: 0x4000, 0x1620: 0x4000, 0x1621: 0x4000, 0x1622: 0x4000, 0x1623: 0x4000, - 0x1624: 0x4000, 0x1625: 0x4000, 0x1626: 0x4000, 0x1627: 0x4000, 0x1628: 0x4000, 0x1629: 0x4000, - 0x162a: 0x4000, 0x162b: 0x4000, 0x162c: 0x4000, 0x162d: 0x4000, 0x162e: 0x4000, 0x162f: 0x4000, - 0x1630: 0x4000, 0x1631: 0x4000, 0x1632: 0x4000, 0x1633: 0x4000, 0x1634: 0x4000, 0x1635: 0x4000, - 0x1636: 0x4000, 0x1637: 0x4000, 0x1638: 0x4000, 0x1639: 0x4000, 0x163a: 0x4000, 0x163b: 0x4000, - 0x163c: 0x4000, 0x163d: 0x4000, 0x163e: 0x4000, - // Block 0x59, offset 0x1640 - 0x1640: 0x4000, 0x1642: 0x4000, 0x1643: 0x4000, 0x1644: 0x4000, 0x1645: 0x4000, - 0x1646: 0x4000, 0x1647: 0x4000, 0x1648: 0x4000, 0x1649: 0x4000, 0x164a: 0x4000, 0x164b: 0x4000, - 0x164c: 0x4000, 0x164d: 0x4000, 0x164e: 0x4000, 0x164f: 0x4000, 0x1650: 0x4000, 0x1651: 0x4000, - 0x1652: 0x4000, 0x1653: 0x4000, 0x1654: 0x4000, 0x1655: 0x4000, 0x1656: 0x4000, 0x1657: 0x4000, - 0x1658: 0x4000, 0x1659: 0x4000, 0x165a: 0x4000, 0x165b: 0x4000, 0x165c: 0x4000, 0x165d: 0x4000, - 0x165e: 0x4000, 0x165f: 0x4000, 0x1660: 0x4000, 0x1661: 0x4000, 0x1662: 0x4000, 0x1663: 0x4000, - 0x1664: 0x4000, 0x1665: 0x4000, 0x1666: 0x4000, 0x1667: 0x4000, 0x1668: 0x4000, 0x1669: 0x4000, - 0x166a: 0x4000, 0x166b: 0x4000, 0x166c: 0x4000, 0x166d: 0x4000, 0x166e: 0x4000, 0x166f: 0x4000, - 0x1670: 0x4000, 0x1671: 0x4000, 0x1672: 0x4000, 0x1673: 0x4000, 0x1674: 0x4000, 0x1675: 0x4000, - 0x1676: 0x4000, 0x1677: 0x4000, 0x1678: 0x4000, 0x1679: 0x4000, 0x167a: 0x4000, 0x167b: 0x4000, - 0x167c: 0x4000, 0x167d: 0x4000, 0x167e: 0x4000, 0x167f: 0x4000, - // Block 0x5a, offset 0x1680 - 0x1680: 0x4000, 0x1681: 0x4000, 0x1682: 0x4000, 0x1683: 0x4000, 0x1684: 0x4000, 0x1685: 0x4000, - 0x1686: 0x4000, 0x1687: 0x4000, 0x1688: 0x4000, 0x1689: 0x4000, 0x168a: 0x4000, 0x168b: 0x4000, - 0x168c: 0x4000, 0x168d: 0x4000, 0x168e: 0x4000, 0x168f: 0x4000, 0x1690: 0x4000, 0x1691: 0x4000, - 0x1692: 0x4000, 0x1693: 0x4000, 0x1694: 0x4000, 0x1695: 0x4000, 0x1696: 0x4000, 0x1697: 0x4000, - 0x1698: 0x4000, 0x1699: 0x4000, 0x169a: 0x4000, 0x169b: 0x4000, 0x169c: 0x4000, 0x169d: 0x4000, - 0x169e: 0x4000, 0x169f: 0x4000, 0x16a0: 0x4000, 0x16a1: 0x4000, 0x16a2: 0x4000, 0x16a3: 0x4000, - 0x16a4: 0x4000, 0x16a5: 0x4000, 0x16a6: 0x4000, 0x16a7: 0x4000, 0x16a8: 0x4000, 0x16a9: 0x4000, - 0x16aa: 0x4000, 0x16ab: 0x4000, 0x16ac: 0x4000, 0x16ad: 0x4000, 0x16ae: 0x4000, 0x16af: 0x4000, - 0x16b0: 0x4000, 0x16b1: 0x4000, 0x16b2: 0x4000, 0x16b3: 0x4000, 0x16b4: 0x4000, 0x16b5: 0x4000, - 0x16b6: 0x4000, 0x16b7: 0x4000, 0x16b8: 0x4000, 0x16b9: 0x4000, 0x16ba: 0x4000, 0x16bb: 0x4000, - 0x16bc: 0x4000, 0x16bf: 0x4000, - // Block 0x5b, offset 0x16c0 - 0x16c0: 0x4000, 0x16c1: 0x4000, 0x16c2: 0x4000, 0x16c3: 0x4000, 0x16c4: 0x4000, 0x16c5: 0x4000, - 0x16c6: 0x4000, 0x16c7: 0x4000, 0x16c8: 0x4000, 0x16c9: 0x4000, 0x16ca: 0x4000, 0x16cb: 0x4000, - 0x16cc: 0x4000, 0x16cd: 0x4000, 0x16ce: 0x4000, 0x16cf: 0x4000, 0x16d0: 0x4000, 0x16d1: 0x4000, - 0x16d2: 0x4000, 0x16d3: 0x4000, 0x16d4: 0x4000, 0x16d5: 0x4000, 0x16d6: 0x4000, 0x16d7: 0x4000, - 0x16d8: 0x4000, 0x16d9: 0x4000, 0x16da: 0x4000, 0x16db: 0x4000, 0x16dc: 0x4000, 0x16dd: 0x4000, - 0x16de: 0x4000, 0x16df: 0x4000, 0x16e0: 0x4000, 0x16e1: 0x4000, 0x16e2: 0x4000, 0x16e3: 0x4000, - 0x16e4: 0x4000, 0x16e5: 0x4000, 0x16e6: 0x4000, 0x16e7: 0x4000, 0x16e8: 0x4000, 0x16e9: 0x4000, - 0x16ea: 0x4000, 0x16eb: 0x4000, 0x16ec: 0x4000, 0x16ed: 0x4000, 0x16ee: 0x4000, 0x16ef: 0x4000, - 0x16f0: 0x4000, 0x16f1: 0x4000, 0x16f2: 0x4000, 0x16f3: 0x4000, 0x16f4: 0x4000, 0x16f5: 0x4000, - 0x16f6: 0x4000, 0x16f7: 0x4000, 0x16f8: 0x4000, 0x16f9: 0x4000, 0x16fa: 0x4000, 0x16fb: 0x4000, - 0x16fc: 0x4000, 0x16fd: 0x4000, - // Block 0x5c, offset 0x1700 - 0x170b: 0x4000, - 0x170c: 0x4000, 0x170d: 0x4000, 0x170e: 0x4000, 0x1710: 0x4000, 0x1711: 0x4000, - 0x1712: 0x4000, 0x1713: 0x4000, 0x1714: 0x4000, 0x1715: 0x4000, 0x1716: 0x4000, 0x1717: 0x4000, - 0x1718: 0x4000, 0x1719: 0x4000, 0x171a: 0x4000, 0x171b: 0x4000, 0x171c: 0x4000, 0x171d: 0x4000, - 0x171e: 0x4000, 0x171f: 0x4000, 0x1720: 0x4000, 0x1721: 0x4000, 0x1722: 0x4000, 0x1723: 0x4000, - 0x1724: 0x4000, 0x1725: 0x4000, 0x1726: 0x4000, 0x1727: 0x4000, - 0x173a: 0x4000, - // Block 0x5d, offset 0x1740 - 0x1755: 0x4000, 0x1756: 0x4000, - 0x1764: 0x4000, - // Block 0x5e, offset 0x1780 - 0x17bb: 0x4000, - 0x17bc: 0x4000, 0x17bd: 0x4000, 0x17be: 0x4000, 0x17bf: 0x4000, - // Block 0x5f, offset 0x17c0 - 0x17c0: 0x4000, 0x17c1: 0x4000, 0x17c2: 0x4000, 0x17c3: 0x4000, 0x17c4: 0x4000, 0x17c5: 0x4000, - 0x17c6: 0x4000, 0x17c7: 0x4000, 0x17c8: 0x4000, 0x17c9: 0x4000, 0x17ca: 0x4000, 0x17cb: 0x4000, - 0x17cc: 0x4000, 0x17cd: 0x4000, 0x17ce: 0x4000, 0x17cf: 0x4000, - // Block 0x60, offset 0x1800 - 0x1800: 0x4000, 0x1801: 0x4000, 0x1802: 0x4000, 0x1803: 0x4000, 0x1804: 0x4000, 0x1805: 0x4000, - 0x180c: 0x4000, 0x1810: 0x4000, 0x1811: 0x4000, - 0x1812: 0x4000, 0x1815: 0x4000, 0x1816: 0x4000, 0x1817: 0x4000, - 0x182b: 0x4000, 0x182c: 0x4000, - 0x1834: 0x4000, 0x1835: 0x4000, - 0x1836: 0x4000, 0x1837: 0x4000, 0x1838: 0x4000, 0x1839: 0x4000, 0x183a: 0x4000, 0x183b: 0x4000, - 0x183c: 0x4000, - // Block 0x61, offset 0x1840 - 0x1860: 0x4000, 0x1861: 0x4000, 0x1862: 0x4000, 0x1863: 0x4000, - 0x1864: 0x4000, 0x1865: 0x4000, 0x1866: 0x4000, 0x1867: 0x4000, 0x1868: 0x4000, 0x1869: 0x4000, - 0x186a: 0x4000, 0x186b: 0x4000, - // Block 0x62, offset 0x1880 - 0x188c: 0x4000, 0x188d: 0x4000, 0x188e: 0x4000, 0x188f: 0x4000, 0x1890: 0x4000, 0x1891: 0x4000, - 0x1892: 0x4000, 0x1893: 0x4000, 0x1894: 0x4000, 0x1895: 0x4000, 0x1896: 0x4000, 0x1897: 0x4000, - 0x1898: 0x4000, 0x1899: 0x4000, 0x189a: 0x4000, 0x189b: 0x4000, 0x189c: 0x4000, 0x189d: 0x4000, - 0x189e: 0x4000, 0x189f: 0x4000, 0x18a0: 0x4000, 0x18a1: 0x4000, 0x18a2: 0x4000, 0x18a3: 0x4000, - 0x18a4: 0x4000, 0x18a5: 0x4000, 0x18a6: 0x4000, 0x18a7: 0x4000, 0x18a8: 0x4000, 0x18a9: 0x4000, - 0x18aa: 0x4000, 0x18ab: 0x4000, 0x18ac: 0x4000, 0x18ad: 0x4000, 0x18ae: 0x4000, 0x18af: 0x4000, - 0x18b0: 0x4000, 0x18b1: 0x4000, 0x18b2: 0x4000, 0x18b3: 0x4000, 0x18b4: 0x4000, 0x18b5: 0x4000, - 0x18b6: 0x4000, 0x18b7: 0x4000, 0x18b8: 0x4000, 0x18b9: 0x4000, 0x18ba: 0x4000, - 0x18bc: 0x4000, 0x18bd: 0x4000, 0x18be: 0x4000, 0x18bf: 0x4000, - // Block 0x63, offset 0x18c0 - 0x18c0: 0x4000, 0x18c1: 0x4000, 0x18c2: 0x4000, 0x18c3: 0x4000, 0x18c4: 0x4000, 0x18c5: 0x4000, - 0x18c7: 0x4000, 0x18c8: 0x4000, 0x18c9: 0x4000, 0x18ca: 0x4000, 0x18cb: 0x4000, - 0x18cc: 0x4000, 0x18cd: 0x4000, 0x18ce: 0x4000, 0x18cf: 0x4000, 0x18d0: 0x4000, 0x18d1: 0x4000, - 0x18d2: 0x4000, 0x18d3: 0x4000, 0x18d4: 0x4000, 0x18d5: 0x4000, 0x18d6: 0x4000, 0x18d7: 0x4000, - 0x18d8: 0x4000, 0x18d9: 0x4000, 0x18da: 0x4000, 0x18db: 0x4000, 0x18dc: 0x4000, 0x18dd: 0x4000, - 0x18de: 0x4000, 0x18df: 0x4000, 0x18e0: 0x4000, 0x18e1: 0x4000, 0x18e2: 0x4000, 0x18e3: 0x4000, - 0x18e4: 0x4000, 0x18e5: 0x4000, 0x18e6: 0x4000, 0x18e7: 0x4000, 0x18e8: 0x4000, 0x18e9: 0x4000, - 0x18ea: 0x4000, 0x18eb: 0x4000, 0x18ec: 0x4000, 0x18ed: 0x4000, 0x18ee: 0x4000, 0x18ef: 0x4000, - 0x18f0: 0x4000, 0x18f1: 0x4000, 0x18f2: 0x4000, 0x18f3: 0x4000, 0x18f4: 0x4000, 0x18f5: 0x4000, - 0x18f6: 0x4000, 0x18f7: 0x4000, 0x18f8: 0x4000, 0x18fa: 0x4000, 0x18fb: 0x4000, - 0x18fc: 0x4000, 0x18fd: 0x4000, 0x18fe: 0x4000, 0x18ff: 0x4000, - // Block 0x64, offset 0x1900 - 0x1900: 0x4000, 0x1901: 0x4000, 0x1902: 0x4000, 0x1903: 0x4000, 0x1904: 0x4000, 0x1905: 0x4000, - 0x1906: 0x4000, 0x1907: 0x4000, 0x1908: 0x4000, 0x1909: 0x4000, 0x190a: 0x4000, 0x190b: 0x4000, - 0x190d: 0x4000, 0x190e: 0x4000, 0x190f: 0x4000, 0x1910: 0x4000, 0x1911: 0x4000, - 0x1912: 0x4000, 0x1913: 0x4000, 0x1914: 0x4000, 0x1915: 0x4000, 0x1916: 0x4000, 0x1917: 0x4000, - 0x1918: 0x4000, 0x1919: 0x4000, 0x191a: 0x4000, 0x191b: 0x4000, 0x191c: 0x4000, 0x191d: 0x4000, - 0x191e: 0x4000, 0x191f: 0x4000, 0x1920: 0x4000, 0x1921: 0x4000, 0x1922: 0x4000, 0x1923: 0x4000, - 0x1924: 0x4000, 0x1925: 0x4000, 0x1926: 0x4000, 0x1927: 0x4000, 0x1928: 0x4000, 0x1929: 0x4000, - 0x192a: 0x4000, 0x192b: 0x4000, 0x192c: 0x4000, 0x192d: 0x4000, 0x192e: 0x4000, 0x192f: 0x4000, - 0x1930: 0x4000, 0x1931: 0x4000, 0x1932: 0x4000, 0x1933: 0x4000, 0x1934: 0x4000, 0x1935: 0x4000, - 0x1936: 0x4000, 0x1937: 0x4000, 0x1938: 0x4000, 0x1939: 0x4000, 0x193a: 0x4000, 0x193b: 0x4000, - 0x193c: 0x4000, 0x193d: 0x4000, 0x193e: 0x4000, 0x193f: 0x4000, - // Block 0x65, offset 0x1940 - 0x1970: 0x4000, 0x1971: 0x4000, 0x1972: 0x4000, 0x1973: 0x4000, 0x1974: 0x4000, - 0x1978: 0x4000, 0x1979: 0x4000, 0x197a: 0x4000, - // Block 0x66, offset 0x1980 - 0x1980: 0x4000, 0x1981: 0x4000, 0x1982: 0x4000, 0x1983: 0x4000, 0x1984: 0x4000, 0x1985: 0x4000, - 0x1986: 0x4000, - 0x1990: 0x4000, 0x1991: 0x4000, - 0x1992: 0x4000, 0x1993: 0x4000, 0x1994: 0x4000, 0x1995: 0x4000, 0x1996: 0x4000, 0x1997: 0x4000, - 0x1998: 0x4000, 0x1999: 0x4000, 0x199a: 0x4000, 0x199b: 0x4000, 0x199c: 0x4000, 0x199d: 0x4000, - 0x199e: 0x4000, 0x199f: 0x4000, 0x19a0: 0x4000, 0x19a1: 0x4000, 0x19a2: 0x4000, 0x19a3: 0x4000, - 0x19a4: 0x4000, 0x19a5: 0x4000, 0x19a6: 0x4000, 0x19a7: 0x4000, 0x19a8: 0x4000, - 0x19b0: 0x4000, 0x19b1: 0x4000, 0x19b2: 0x4000, 0x19b3: 0x4000, 0x19b4: 0x4000, 0x19b5: 0x4000, - 0x19b6: 0x4000, - // Block 0x67, offset 0x19c0 - 0x19c0: 0x4000, 0x19c1: 0x4000, 0x19c2: 0x4000, - 0x19d0: 0x4000, 0x19d1: 0x4000, - 0x19d2: 0x4000, 0x19d3: 0x4000, 0x19d4: 0x4000, 0x19d5: 0x4000, 0x19d6: 0x4000, - // Block 0x68, offset 0x1a00 - 0x1a00: 0x2000, 0x1a01: 0x2000, 0x1a02: 0x2000, 0x1a03: 0x2000, 0x1a04: 0x2000, 0x1a05: 0x2000, - 0x1a06: 0x2000, 0x1a07: 0x2000, 0x1a08: 0x2000, 0x1a09: 0x2000, 0x1a0a: 0x2000, 0x1a0b: 0x2000, - 0x1a0c: 0x2000, 0x1a0d: 0x2000, 0x1a0e: 0x2000, 0x1a0f: 0x2000, 0x1a10: 0x2000, 0x1a11: 0x2000, - 0x1a12: 0x2000, 0x1a13: 0x2000, 0x1a14: 0x2000, 0x1a15: 0x2000, 0x1a16: 0x2000, 0x1a17: 0x2000, - 0x1a18: 0x2000, 0x1a19: 0x2000, 0x1a1a: 0x2000, 0x1a1b: 0x2000, 0x1a1c: 0x2000, 0x1a1d: 0x2000, - 0x1a1e: 0x2000, 0x1a1f: 0x2000, 0x1a20: 0x2000, 0x1a21: 0x2000, 0x1a22: 0x2000, 0x1a23: 0x2000, - 0x1a24: 0x2000, 0x1a25: 0x2000, 0x1a26: 0x2000, 0x1a27: 0x2000, 0x1a28: 0x2000, 0x1a29: 0x2000, - 0x1a2a: 0x2000, 0x1a2b: 0x2000, 0x1a2c: 0x2000, 0x1a2d: 0x2000, 0x1a2e: 0x2000, 0x1a2f: 0x2000, - 0x1a30: 0x2000, 0x1a31: 0x2000, 0x1a32: 0x2000, 0x1a33: 0x2000, 0x1a34: 0x2000, 0x1a35: 0x2000, - 0x1a36: 0x2000, 0x1a37: 0x2000, 0x1a38: 0x2000, 0x1a39: 0x2000, 0x1a3a: 0x2000, 0x1a3b: 0x2000, - 0x1a3c: 0x2000, 0x1a3d: 0x2000, -} - -// widthIndex: 22 blocks, 1408 entries, 1408 bytes -// Block 0 is the zero block. -var widthIndex = [1408]uint8{ - // Block 0x0, offset 0x0 - // Block 0x1, offset 0x40 - // Block 0x2, offset 0x80 - // Block 0x3, offset 0xc0 - 0xc2: 0x01, 0xc3: 0x02, 0xc4: 0x03, 0xc5: 0x04, 0xc7: 0x05, - 0xc9: 0x06, 0xcb: 0x07, 0xcc: 0x08, 0xcd: 0x09, 0xce: 0x0a, 0xcf: 0x0b, - 0xd0: 0x0c, 0xd1: 0x0d, - 0xe1: 0x02, 0xe2: 0x03, 0xe3: 0x04, 0xe4: 0x05, 0xe5: 0x06, 0xe6: 0x06, 0xe7: 0x06, - 0xe8: 0x06, 0xe9: 0x06, 0xea: 0x07, 0xeb: 0x06, 0xec: 0x06, 0xed: 0x08, 0xee: 0x09, 0xef: 0x0a, - 0xf0: 0x0f, 0xf3: 0x12, 0xf4: 0x13, - // Block 0x4, offset 0x100 - 0x104: 0x0e, 0x105: 0x0f, - // Block 0x5, offset 0x140 - 0x140: 0x10, 0x141: 0x11, 0x142: 0x12, 0x144: 0x13, 0x145: 0x14, 0x146: 0x15, 0x147: 0x16, - 0x148: 0x17, 0x149: 0x18, 0x14a: 0x19, 0x14c: 0x1a, 0x14f: 0x1b, - 0x151: 0x1c, 0x152: 0x08, 0x153: 0x1d, 0x154: 0x1e, 0x155: 0x1f, 0x156: 0x20, 0x157: 0x21, - 0x158: 0x22, 0x159: 0x23, 0x15a: 0x24, 0x15b: 0x25, 0x15c: 0x26, 0x15d: 0x27, 0x15e: 0x28, 0x15f: 0x29, - 0x166: 0x2a, - 0x16c: 0x2b, 0x16d: 0x2c, - 0x17a: 0x2d, 0x17b: 0x2e, 0x17c: 0x0e, 0x17d: 0x0e, 0x17e: 0x0e, 0x17f: 0x2f, - // Block 0x6, offset 0x180 - 0x180: 0x30, 0x181: 0x31, 0x182: 0x32, 0x183: 0x33, 0x184: 0x34, 0x185: 0x35, 0x186: 0x36, 0x187: 0x37, - 0x188: 0x38, 0x189: 0x39, 0x18a: 0x0e, 0x18b: 0x0e, 0x18c: 0x0e, 0x18d: 0x0e, 0x18e: 0x0e, 0x18f: 0x0e, - 0x190: 0x0e, 0x191: 0x0e, 0x192: 0x0e, 0x193: 0x0e, 0x194: 0x0e, 0x195: 0x0e, 0x196: 0x0e, 0x197: 0x0e, - 0x198: 0x0e, 0x199: 0x0e, 0x19a: 0x0e, 0x19b: 0x0e, 0x19c: 0x0e, 0x19d: 0x0e, 0x19e: 0x0e, 0x19f: 0x0e, - 0x1a0: 0x0e, 0x1a1: 0x0e, 0x1a2: 0x0e, 0x1a3: 0x0e, 0x1a4: 0x0e, 0x1a5: 0x0e, 0x1a6: 0x0e, 0x1a7: 0x0e, - 0x1a8: 0x0e, 0x1a9: 0x0e, 0x1aa: 0x0e, 0x1ab: 0x0e, 0x1ac: 0x0e, 0x1ad: 0x0e, 0x1ae: 0x0e, 0x1af: 0x0e, - 0x1b0: 0x0e, 0x1b1: 0x0e, 0x1b2: 0x0e, 0x1b3: 0x0e, 0x1b4: 0x0e, 0x1b5: 0x0e, 0x1b6: 0x0e, 0x1b7: 0x0e, - 0x1b8: 0x0e, 0x1b9: 0x0e, 0x1ba: 0x0e, 0x1bb: 0x0e, 0x1bc: 0x0e, 0x1bd: 0x0e, 0x1be: 0x0e, 0x1bf: 0x0e, - // Block 0x7, offset 0x1c0 - 0x1c0: 0x0e, 0x1c1: 0x0e, 0x1c2: 0x0e, 0x1c3: 0x0e, 0x1c4: 0x0e, 0x1c5: 0x0e, 0x1c6: 0x0e, 0x1c7: 0x0e, - 0x1c8: 0x0e, 0x1c9: 0x0e, 0x1ca: 0x0e, 0x1cb: 0x0e, 0x1cc: 0x0e, 0x1cd: 0x0e, 0x1ce: 0x0e, 0x1cf: 0x0e, - 0x1d0: 0x0e, 0x1d1: 0x0e, 0x1d2: 0x0e, 0x1d3: 0x0e, 0x1d4: 0x0e, 0x1d5: 0x0e, 0x1d6: 0x0e, 0x1d7: 0x0e, - 0x1d8: 0x0e, 0x1d9: 0x0e, 0x1da: 0x0e, 0x1db: 0x0e, 0x1dc: 0x0e, 0x1dd: 0x0e, 0x1de: 0x0e, 0x1df: 0x0e, - 0x1e0: 0x0e, 0x1e1: 0x0e, 0x1e2: 0x0e, 0x1e3: 0x0e, 0x1e4: 0x0e, 0x1e5: 0x0e, 0x1e6: 0x0e, 0x1e7: 0x0e, - 0x1e8: 0x0e, 0x1e9: 0x0e, 0x1ea: 0x0e, 0x1eb: 0x0e, 0x1ec: 0x0e, 0x1ed: 0x0e, 0x1ee: 0x0e, 0x1ef: 0x0e, - 0x1f0: 0x0e, 0x1f1: 0x0e, 0x1f2: 0x0e, 0x1f3: 0x0e, 0x1f4: 0x0e, 0x1f5: 0x0e, 0x1f6: 0x0e, - 0x1f8: 0x0e, 0x1f9: 0x0e, 0x1fa: 0x0e, 0x1fb: 0x0e, 0x1fc: 0x0e, 0x1fd: 0x0e, 0x1fe: 0x0e, 0x1ff: 0x0e, - // Block 0x8, offset 0x200 - 0x200: 0x0e, 0x201: 0x0e, 0x202: 0x0e, 0x203: 0x0e, 0x204: 0x0e, 0x205: 0x0e, 0x206: 0x0e, 0x207: 0x0e, - 0x208: 0x0e, 0x209: 0x0e, 0x20a: 0x0e, 0x20b: 0x0e, 0x20c: 0x0e, 0x20d: 0x0e, 0x20e: 0x0e, 0x20f: 0x0e, - 0x210: 0x0e, 0x211: 0x0e, 0x212: 0x0e, 0x213: 0x0e, 0x214: 0x0e, 0x215: 0x0e, 0x216: 0x0e, 0x217: 0x0e, - 0x218: 0x0e, 0x219: 0x0e, 0x21a: 0x0e, 0x21b: 0x0e, 0x21c: 0x0e, 0x21d: 0x0e, 0x21e: 0x0e, 0x21f: 0x0e, - 0x220: 0x0e, 0x221: 0x0e, 0x222: 0x0e, 0x223: 0x0e, 0x224: 0x0e, 0x225: 0x0e, 0x226: 0x0e, 0x227: 0x0e, - 0x228: 0x0e, 0x229: 0x0e, 0x22a: 0x0e, 0x22b: 0x0e, 0x22c: 0x0e, 0x22d: 0x0e, 0x22e: 0x0e, 0x22f: 0x0e, - 0x230: 0x0e, 0x231: 0x0e, 0x232: 0x0e, 0x233: 0x0e, 0x234: 0x0e, 0x235: 0x0e, 0x236: 0x0e, 0x237: 0x0e, - 0x238: 0x0e, 0x239: 0x0e, 0x23a: 0x0e, 0x23b: 0x0e, 0x23c: 0x0e, 0x23d: 0x0e, 0x23e: 0x0e, 0x23f: 0x0e, - // Block 0x9, offset 0x240 - 0x240: 0x0e, 0x241: 0x0e, 0x242: 0x0e, 0x243: 0x0e, 0x244: 0x0e, 0x245: 0x0e, 0x246: 0x0e, 0x247: 0x0e, - 0x248: 0x0e, 0x249: 0x0e, 0x24a: 0x0e, 0x24b: 0x0e, 0x24c: 0x0e, 0x24d: 0x0e, 0x24e: 0x0e, 0x24f: 0x0e, - 0x250: 0x0e, 0x251: 0x0e, 0x252: 0x3a, 0x253: 0x3b, - 0x265: 0x3c, - 0x270: 0x0e, 0x271: 0x0e, 0x272: 0x0e, 0x273: 0x0e, 0x274: 0x0e, 0x275: 0x0e, 0x276: 0x0e, 0x277: 0x0e, - 0x278: 0x0e, 0x279: 0x0e, 0x27a: 0x0e, 0x27b: 0x0e, 0x27c: 0x0e, 0x27d: 0x0e, 0x27e: 0x0e, 0x27f: 0x0e, - // Block 0xa, offset 0x280 - 0x280: 0x0e, 0x281: 0x0e, 0x282: 0x0e, 0x283: 0x0e, 0x284: 0x0e, 0x285: 0x0e, 0x286: 0x0e, 0x287: 0x0e, - 0x288: 0x0e, 0x289: 0x0e, 0x28a: 0x0e, 0x28b: 0x0e, 0x28c: 0x0e, 0x28d: 0x0e, 0x28e: 0x0e, 0x28f: 0x0e, - 0x290: 0x0e, 0x291: 0x0e, 0x292: 0x0e, 0x293: 0x0e, 0x294: 0x0e, 0x295: 0x0e, 0x296: 0x0e, 0x297: 0x0e, - 0x298: 0x0e, 0x299: 0x0e, 0x29a: 0x0e, 0x29b: 0x0e, 0x29c: 0x0e, 0x29d: 0x0e, 0x29e: 0x3d, - // Block 0xb, offset 0x2c0 - 0x2c0: 0x08, 0x2c1: 0x08, 0x2c2: 0x08, 0x2c3: 0x08, 0x2c4: 0x08, 0x2c5: 0x08, 0x2c6: 0x08, 0x2c7: 0x08, - 0x2c8: 0x08, 0x2c9: 0x08, 0x2ca: 0x08, 0x2cb: 0x08, 0x2cc: 0x08, 0x2cd: 0x08, 0x2ce: 0x08, 0x2cf: 0x08, - 0x2d0: 0x08, 0x2d1: 0x08, 0x2d2: 0x08, 0x2d3: 0x08, 0x2d4: 0x08, 0x2d5: 0x08, 0x2d6: 0x08, 0x2d7: 0x08, - 0x2d8: 0x08, 0x2d9: 0x08, 0x2da: 0x08, 0x2db: 0x08, 0x2dc: 0x08, 0x2dd: 0x08, 0x2de: 0x08, 0x2df: 0x08, - 0x2e0: 0x08, 0x2e1: 0x08, 0x2e2: 0x08, 0x2e3: 0x08, 0x2e4: 0x08, 0x2e5: 0x08, 0x2e6: 0x08, 0x2e7: 0x08, - 0x2e8: 0x08, 0x2e9: 0x08, 0x2ea: 0x08, 0x2eb: 0x08, 0x2ec: 0x08, 0x2ed: 0x08, 0x2ee: 0x08, 0x2ef: 0x08, - 0x2f0: 0x08, 0x2f1: 0x08, 0x2f2: 0x08, 0x2f3: 0x08, 0x2f4: 0x08, 0x2f5: 0x08, 0x2f6: 0x08, 0x2f7: 0x08, - 0x2f8: 0x08, 0x2f9: 0x08, 0x2fa: 0x08, 0x2fb: 0x08, 0x2fc: 0x08, 0x2fd: 0x08, 0x2fe: 0x08, 0x2ff: 0x08, - // Block 0xc, offset 0x300 - 0x300: 0x08, 0x301: 0x08, 0x302: 0x08, 0x303: 0x08, 0x304: 0x08, 0x305: 0x08, 0x306: 0x08, 0x307: 0x08, - 0x308: 0x08, 0x309: 0x08, 0x30a: 0x08, 0x30b: 0x08, 0x30c: 0x08, 0x30d: 0x08, 0x30e: 0x08, 0x30f: 0x08, - 0x310: 0x08, 0x311: 0x08, 0x312: 0x08, 0x313: 0x08, 0x314: 0x08, 0x315: 0x08, 0x316: 0x08, 0x317: 0x08, - 0x318: 0x08, 0x319: 0x08, 0x31a: 0x08, 0x31b: 0x08, 0x31c: 0x08, 0x31d: 0x08, 0x31e: 0x08, 0x31f: 0x08, - 0x320: 0x08, 0x321: 0x08, 0x322: 0x08, 0x323: 0x08, 0x324: 0x0e, 0x325: 0x0e, 0x326: 0x0e, 0x327: 0x0e, - 0x328: 0x0e, 0x329: 0x0e, 0x32a: 0x0e, 0x32b: 0x0e, - 0x338: 0x3e, 0x339: 0x3f, 0x33c: 0x40, 0x33d: 0x41, 0x33e: 0x42, 0x33f: 0x43, - // Block 0xd, offset 0x340 - 0x37f: 0x44, - // Block 0xe, offset 0x380 - 0x380: 0x0e, 0x381: 0x0e, 0x382: 0x0e, 0x383: 0x0e, 0x384: 0x0e, 0x385: 0x0e, 0x386: 0x0e, 0x387: 0x0e, - 0x388: 0x0e, 0x389: 0x0e, 0x38a: 0x0e, 0x38b: 0x0e, 0x38c: 0x0e, 0x38d: 0x0e, 0x38e: 0x0e, 0x38f: 0x0e, - 0x390: 0x0e, 0x391: 0x0e, 0x392: 0x0e, 0x393: 0x0e, 0x394: 0x0e, 0x395: 0x0e, 0x396: 0x0e, 0x397: 0x0e, - 0x398: 0x0e, 0x399: 0x0e, 0x39a: 0x0e, 0x39b: 0x0e, 0x39c: 0x0e, 0x39d: 0x0e, 0x39e: 0x0e, 0x39f: 0x45, - 0x3a0: 0x0e, 0x3a1: 0x0e, 0x3a2: 0x0e, 0x3a3: 0x0e, 0x3a4: 0x0e, 0x3a5: 0x0e, 0x3a6: 0x0e, 0x3a7: 0x0e, - 0x3a8: 0x0e, 0x3a9: 0x0e, 0x3aa: 0x0e, 0x3ab: 0x0e, 0x3ac: 0x0e, 0x3ad: 0x0e, 0x3ae: 0x0e, 0x3af: 0x0e, - 0x3b0: 0x0e, 0x3b1: 0x0e, 0x3b2: 0x0e, 0x3b3: 0x46, 0x3b4: 0x47, - // Block 0xf, offset 0x3c0 - 0x3c0: 0x0e, 0x3c1: 0x0e, 0x3c2: 0x0e, 0x3c3: 0x0e, 0x3c4: 0x48, 0x3c5: 0x49, 0x3c6: 0x0e, 0x3c7: 0x0e, - 0x3c8: 0x0e, 0x3c9: 0x0e, 0x3ca: 0x0e, 0x3cb: 0x4a, - // Block 0x10, offset 0x400 - 0x400: 0x4b, 0x403: 0x4c, 0x404: 0x4d, 0x405: 0x4e, 0x406: 0x4f, - 0x408: 0x50, 0x409: 0x51, 0x40c: 0x52, 0x40d: 0x53, 0x40e: 0x54, 0x40f: 0x55, - 0x410: 0x56, 0x411: 0x57, 0x412: 0x0e, 0x413: 0x58, 0x414: 0x59, 0x415: 0x5a, 0x416: 0x5b, 0x417: 0x5c, - 0x418: 0x0e, 0x419: 0x5d, 0x41a: 0x0e, 0x41b: 0x5e, 0x41f: 0x5f, - 0x424: 0x60, 0x425: 0x61, 0x426: 0x0e, 0x427: 0x62, - 0x429: 0x63, 0x42a: 0x64, 0x42b: 0x65, - // Block 0x11, offset 0x440 - 0x456: 0x0b, 0x457: 0x06, - 0x458: 0x0c, 0x45b: 0x0d, 0x45f: 0x0e, - 0x460: 0x06, 0x461: 0x06, 0x462: 0x06, 0x463: 0x06, 0x464: 0x06, 0x465: 0x06, 0x466: 0x06, 0x467: 0x06, - 0x468: 0x06, 0x469: 0x06, 0x46a: 0x06, 0x46b: 0x06, 0x46c: 0x06, 0x46d: 0x06, 0x46e: 0x06, 0x46f: 0x06, - 0x470: 0x06, 0x471: 0x06, 0x472: 0x06, 0x473: 0x06, 0x474: 0x06, 0x475: 0x06, 0x476: 0x06, 0x477: 0x06, - 0x478: 0x06, 0x479: 0x06, 0x47a: 0x06, 0x47b: 0x06, 0x47c: 0x06, 0x47d: 0x06, 0x47e: 0x06, 0x47f: 0x06, - // Block 0x12, offset 0x480 - 0x484: 0x08, 0x485: 0x08, 0x486: 0x08, 0x487: 0x09, - // Block 0x13, offset 0x4c0 - 0x4c0: 0x08, 0x4c1: 0x08, 0x4c2: 0x08, 0x4c3: 0x08, 0x4c4: 0x08, 0x4c5: 0x08, 0x4c6: 0x08, 0x4c7: 0x08, - 0x4c8: 0x08, 0x4c9: 0x08, 0x4ca: 0x08, 0x4cb: 0x08, 0x4cc: 0x08, 0x4cd: 0x08, 0x4ce: 0x08, 0x4cf: 0x08, - 0x4d0: 0x08, 0x4d1: 0x08, 0x4d2: 0x08, 0x4d3: 0x08, 0x4d4: 0x08, 0x4d5: 0x08, 0x4d6: 0x08, 0x4d7: 0x08, - 0x4d8: 0x08, 0x4d9: 0x08, 0x4da: 0x08, 0x4db: 0x08, 0x4dc: 0x08, 0x4dd: 0x08, 0x4de: 0x08, 0x4df: 0x08, - 0x4e0: 0x08, 0x4e1: 0x08, 0x4e2: 0x08, 0x4e3: 0x08, 0x4e4: 0x08, 0x4e5: 0x08, 0x4e6: 0x08, 0x4e7: 0x08, - 0x4e8: 0x08, 0x4e9: 0x08, 0x4ea: 0x08, 0x4eb: 0x08, 0x4ec: 0x08, 0x4ed: 0x08, 0x4ee: 0x08, 0x4ef: 0x08, - 0x4f0: 0x08, 0x4f1: 0x08, 0x4f2: 0x08, 0x4f3: 0x08, 0x4f4: 0x08, 0x4f5: 0x08, 0x4f6: 0x08, 0x4f7: 0x08, - 0x4f8: 0x08, 0x4f9: 0x08, 0x4fa: 0x08, 0x4fb: 0x08, 0x4fc: 0x08, 0x4fd: 0x08, 0x4fe: 0x08, 0x4ff: 0x66, - // Block 0x14, offset 0x500 - 0x520: 0x10, - 0x530: 0x09, 0x531: 0x09, 0x532: 0x09, 0x533: 0x09, 0x534: 0x09, 0x535: 0x09, 0x536: 0x09, 0x537: 0x09, - 0x538: 0x09, 0x539: 0x09, 0x53a: 0x09, 0x53b: 0x09, 0x53c: 0x09, 0x53d: 0x09, 0x53e: 0x09, 0x53f: 0x11, - // Block 0x15, offset 0x540 - 0x540: 0x09, 0x541: 0x09, 0x542: 0x09, 0x543: 0x09, 0x544: 0x09, 0x545: 0x09, 0x546: 0x09, 0x547: 0x09, - 0x548: 0x09, 0x549: 0x09, 0x54a: 0x09, 0x54b: 0x09, 0x54c: 0x09, 0x54d: 0x09, 0x54e: 0x09, 0x54f: 0x11, -} - -// inverseData contains 4-byte entries of the following format: -// -// <0 padding> -// -// The last byte of the UTF-8-encoded rune is xor-ed with the last byte of the -// UTF-8 encoding of the original rune. Mappings often have the following -// pattern: -// -// A -> A (U+FF21 -> U+0041) -// B -> B (U+FF22 -> U+0042) -// ... -// -// By xor-ing the last byte the same entry can be shared by many mappings. This -// reduces the total number of distinct entries by about two thirds. -// The resulting entry for the aforementioned mappings is -// -// { 0x01, 0xE0, 0x00, 0x00 } -// -// Using this entry to map U+FF21 (UTF-8 [EF BC A1]), we get -// -// E0 ^ A1 = 41. -// -// Similarly, for U+FF22 (UTF-8 [EF BC A2]), we get -// -// E0 ^ A2 = 42. -// -// Note that because of the xor-ing, the byte sequence stored in the entry is -// not valid UTF-8. -var inverseData = [150][4]byte{ - {0x00, 0x00, 0x00, 0x00}, - {0x03, 0xe3, 0x80, 0xa0}, - {0x03, 0xef, 0xbc, 0xa0}, - {0x03, 0xef, 0xbc, 0xe0}, - {0x03, 0xef, 0xbd, 0xe0}, - {0x03, 0xef, 0xbf, 0x02}, - {0x03, 0xef, 0xbf, 0x00}, - {0x03, 0xef, 0xbf, 0x0e}, - {0x03, 0xef, 0xbf, 0x0c}, - {0x03, 0xef, 0xbf, 0x0f}, - {0x03, 0xef, 0xbf, 0x39}, - {0x03, 0xef, 0xbf, 0x3b}, - {0x03, 0xef, 0xbf, 0x3f}, - {0x03, 0xef, 0xbf, 0x2a}, - {0x03, 0xef, 0xbf, 0x0d}, - {0x03, 0xef, 0xbf, 0x25}, - {0x03, 0xef, 0xbd, 0x1a}, - {0x03, 0xef, 0xbd, 0x26}, - {0x01, 0xa0, 0x00, 0x00}, - {0x03, 0xef, 0xbd, 0x25}, - {0x03, 0xef, 0xbd, 0x23}, - {0x03, 0xef, 0xbd, 0x2e}, - {0x03, 0xef, 0xbe, 0x07}, - {0x03, 0xef, 0xbe, 0x05}, - {0x03, 0xef, 0xbd, 0x06}, - {0x03, 0xef, 0xbd, 0x13}, - {0x03, 0xef, 0xbd, 0x0b}, - {0x03, 0xef, 0xbd, 0x16}, - {0x03, 0xef, 0xbd, 0x0c}, - {0x03, 0xef, 0xbd, 0x15}, - {0x03, 0xef, 0xbd, 0x0d}, - {0x03, 0xef, 0xbd, 0x1c}, - {0x03, 0xef, 0xbd, 0x02}, - {0x03, 0xef, 0xbd, 0x1f}, - {0x03, 0xef, 0xbd, 0x1d}, - {0x03, 0xef, 0xbd, 0x17}, - {0x03, 0xef, 0xbd, 0x08}, - {0x03, 0xef, 0xbd, 0x09}, - {0x03, 0xef, 0xbd, 0x0e}, - {0x03, 0xef, 0xbd, 0x04}, - {0x03, 0xef, 0xbd, 0x05}, - {0x03, 0xef, 0xbe, 0x3f}, - {0x03, 0xef, 0xbe, 0x00}, - {0x03, 0xef, 0xbd, 0x2c}, - {0x03, 0xef, 0xbe, 0x06}, - {0x03, 0xef, 0xbe, 0x0c}, - {0x03, 0xef, 0xbe, 0x0f}, - {0x03, 0xef, 0xbe, 0x0d}, - {0x03, 0xef, 0xbe, 0x0b}, - {0x03, 0xef, 0xbe, 0x19}, - {0x03, 0xef, 0xbe, 0x15}, - {0x03, 0xef, 0xbe, 0x11}, - {0x03, 0xef, 0xbe, 0x31}, - {0x03, 0xef, 0xbe, 0x33}, - {0x03, 0xef, 0xbd, 0x0f}, - {0x03, 0xef, 0xbe, 0x30}, - {0x03, 0xef, 0xbe, 0x3e}, - {0x03, 0xef, 0xbe, 0x32}, - {0x03, 0xef, 0xbe, 0x36}, - {0x03, 0xef, 0xbd, 0x14}, - {0x03, 0xef, 0xbe, 0x2e}, - {0x03, 0xef, 0xbd, 0x1e}, - {0x03, 0xef, 0xbe, 0x10}, - {0x03, 0xef, 0xbf, 0x13}, - {0x03, 0xef, 0xbf, 0x15}, - {0x03, 0xef, 0xbf, 0x17}, - {0x03, 0xef, 0xbf, 0x1f}, - {0x03, 0xef, 0xbf, 0x1d}, - {0x03, 0xef, 0xbf, 0x1b}, - {0x03, 0xef, 0xbf, 0x09}, - {0x03, 0xef, 0xbf, 0x0b}, - {0x03, 0xef, 0xbf, 0x37}, - {0x03, 0xef, 0xbe, 0x04}, - {0x01, 0xe0, 0x00, 0x00}, - {0x03, 0xe2, 0xa6, 0x1a}, - {0x03, 0xe2, 0xa6, 0x26}, - {0x03, 0xe3, 0x80, 0x23}, - {0x03, 0xe3, 0x80, 0x2e}, - {0x03, 0xe3, 0x80, 0x25}, - {0x03, 0xe3, 0x83, 0x1e}, - {0x03, 0xe3, 0x83, 0x14}, - {0x03, 0xe3, 0x82, 0x06}, - {0x03, 0xe3, 0x82, 0x0b}, - {0x03, 0xe3, 0x82, 0x0c}, - {0x03, 0xe3, 0x82, 0x0d}, - {0x03, 0xe3, 0x82, 0x02}, - {0x03, 0xe3, 0x83, 0x0f}, - {0x03, 0xe3, 0x83, 0x08}, - {0x03, 0xe3, 0x83, 0x09}, - {0x03, 0xe3, 0x83, 0x2c}, - {0x03, 0xe3, 0x83, 0x0c}, - {0x03, 0xe3, 0x82, 0x13}, - {0x03, 0xe3, 0x82, 0x16}, - {0x03, 0xe3, 0x82, 0x15}, - {0x03, 0xe3, 0x82, 0x1c}, - {0x03, 0xe3, 0x82, 0x1f}, - {0x03, 0xe3, 0x82, 0x1d}, - {0x03, 0xe3, 0x82, 0x1a}, - {0x03, 0xe3, 0x82, 0x17}, - {0x03, 0xe3, 0x82, 0x08}, - {0x03, 0xe3, 0x82, 0x09}, - {0x03, 0xe3, 0x82, 0x0e}, - {0x03, 0xe3, 0x82, 0x04}, - {0x03, 0xe3, 0x82, 0x05}, - {0x03, 0xe3, 0x82, 0x3f}, - {0x03, 0xe3, 0x83, 0x00}, - {0x03, 0xe3, 0x83, 0x06}, - {0x03, 0xe3, 0x83, 0x05}, - {0x03, 0xe3, 0x83, 0x0d}, - {0x03, 0xe3, 0x83, 0x0b}, - {0x03, 0xe3, 0x83, 0x07}, - {0x03, 0xe3, 0x83, 0x19}, - {0x03, 0xe3, 0x83, 0x15}, - {0x03, 0xe3, 0x83, 0x11}, - {0x03, 0xe3, 0x83, 0x31}, - {0x03, 0xe3, 0x83, 0x33}, - {0x03, 0xe3, 0x83, 0x30}, - {0x03, 0xe3, 0x83, 0x3e}, - {0x03, 0xe3, 0x83, 0x32}, - {0x03, 0xe3, 0x83, 0x36}, - {0x03, 0xe3, 0x83, 0x2e}, - {0x03, 0xe3, 0x82, 0x07}, - {0x03, 0xe3, 0x85, 0x04}, - {0x03, 0xe3, 0x84, 0x10}, - {0x03, 0xe3, 0x85, 0x30}, - {0x03, 0xe3, 0x85, 0x0d}, - {0x03, 0xe3, 0x85, 0x13}, - {0x03, 0xe3, 0x85, 0x15}, - {0x03, 0xe3, 0x85, 0x17}, - {0x03, 0xe3, 0x85, 0x1f}, - {0x03, 0xe3, 0x85, 0x1d}, - {0x03, 0xe3, 0x85, 0x1b}, - {0x03, 0xe3, 0x85, 0x09}, - {0x03, 0xe3, 0x85, 0x0f}, - {0x03, 0xe3, 0x85, 0x0b}, - {0x03, 0xe3, 0x85, 0x37}, - {0x03, 0xe3, 0x85, 0x3b}, - {0x03, 0xe3, 0x85, 0x39}, - {0x03, 0xe3, 0x85, 0x3f}, - {0x02, 0xc2, 0x02, 0x00}, - {0x02, 0xc2, 0x0e, 0x00}, - {0x02, 0xc2, 0x0c, 0x00}, - {0x02, 0xc2, 0x00, 0x00}, - {0x03, 0xe2, 0x82, 0x0f}, - {0x03, 0xe2, 0x94, 0x2a}, - {0x03, 0xe2, 0x86, 0x39}, - {0x03, 0xe2, 0x86, 0x3b}, - {0x03, 0xe2, 0x86, 0x3f}, - {0x03, 0xe2, 0x96, 0x0d}, - {0x03, 0xe2, 0x97, 0x25}, -} - -// Total table size 15448 bytes (15KiB) diff --git a/vendor/golang.org/x/text/width/tables15.0.0.go b/vendor/golang.org/x/text/width/tables15.0.0.go deleted file mode 100644 index 2b8528967..000000000 --- a/vendor/golang.org/x/text/width/tables15.0.0.go +++ /dev/null @@ -1,1367 +0,0 @@ -// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. - -//go:build go1.21 - -package width - -// UnicodeVersion is the Unicode version from which the tables in this package are derived. -const UnicodeVersion = "15.0.0" - -// lookup returns the trie value for the first UTF-8 encoding in s and -// the width in bytes of this encoding. The size will be 0 if s does not -// hold enough bytes to complete the encoding. len(s) must be greater than 0. -func (t *widthTrie) lookup(s []byte) (v uint16, sz int) { - c0 := s[0] - switch { - case c0 < 0x80: // is ASCII - return widthValues[c0], 1 - case c0 < 0xC2: - return 0, 1 // Illegal UTF-8: not a starter, not ASCII. - case c0 < 0xE0: // 2-byte UTF-8 - if len(s) < 2 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c1), 2 - case c0 < 0xF0: // 3-byte UTF-8 - if len(s) < 3 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c2), 3 - case c0 < 0xF8: // 4-byte UTF-8 - if len(s) < 4 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - o = uint32(i)<<6 + uint32(c2) - i = widthIndex[o] - c3 := s[3] - if c3 < 0x80 || 0xC0 <= c3 { - return 0, 3 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c3), 4 - } - // Illegal rune - return 0, 1 -} - -// lookupUnsafe returns the trie value for the first UTF-8 encoding in s. -// s must start with a full and valid UTF-8 encoded rune. -func (t *widthTrie) lookupUnsafe(s []byte) uint16 { - c0 := s[0] - if c0 < 0x80 { // is ASCII - return widthValues[c0] - } - i := widthIndex[c0] - if c0 < 0xE0 { // 2-byte UTF-8 - return t.lookupValue(uint32(i), s[1]) - } - i = widthIndex[uint32(i)<<6+uint32(s[1])] - if c0 < 0xF0 { // 3-byte UTF-8 - return t.lookupValue(uint32(i), s[2]) - } - i = widthIndex[uint32(i)<<6+uint32(s[2])] - if c0 < 0xF8 { // 4-byte UTF-8 - return t.lookupValue(uint32(i), s[3]) - } - return 0 -} - -// lookupString returns the trie value for the first UTF-8 encoding in s and -// the width in bytes of this encoding. The size will be 0 if s does not -// hold enough bytes to complete the encoding. len(s) must be greater than 0. -func (t *widthTrie) lookupString(s string) (v uint16, sz int) { - c0 := s[0] - switch { - case c0 < 0x80: // is ASCII - return widthValues[c0], 1 - case c0 < 0xC2: - return 0, 1 // Illegal UTF-8: not a starter, not ASCII. - case c0 < 0xE0: // 2-byte UTF-8 - if len(s) < 2 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c1), 2 - case c0 < 0xF0: // 3-byte UTF-8 - if len(s) < 3 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c2), 3 - case c0 < 0xF8: // 4-byte UTF-8 - if len(s) < 4 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - o = uint32(i)<<6 + uint32(c2) - i = widthIndex[o] - c3 := s[3] - if c3 < 0x80 || 0xC0 <= c3 { - return 0, 3 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c3), 4 - } - // Illegal rune - return 0, 1 -} - -// lookupStringUnsafe returns the trie value for the first UTF-8 encoding in s. -// s must start with a full and valid UTF-8 encoded rune. -func (t *widthTrie) lookupStringUnsafe(s string) uint16 { - c0 := s[0] - if c0 < 0x80 { // is ASCII - return widthValues[c0] - } - i := widthIndex[c0] - if c0 < 0xE0 { // 2-byte UTF-8 - return t.lookupValue(uint32(i), s[1]) - } - i = widthIndex[uint32(i)<<6+uint32(s[1])] - if c0 < 0xF0 { // 3-byte UTF-8 - return t.lookupValue(uint32(i), s[2]) - } - i = widthIndex[uint32(i)<<6+uint32(s[2])] - if c0 < 0xF8 { // 4-byte UTF-8 - return t.lookupValue(uint32(i), s[3]) - } - return 0 -} - -// widthTrie. Total size: 14912 bytes (14.56 KiB). Checksum: 4468b6cd178303d2. -type widthTrie struct{} - -func newWidthTrie(i int) *widthTrie { - return &widthTrie{} -} - -// lookupValue determines the type of block n and looks up the value for b. -func (t *widthTrie) lookupValue(n uint32, b byte) uint16 { - switch { - default: - return uint16(widthValues[n<<6+uint32(b)]) - } -} - -// widthValues: 105 blocks, 6720 entries, 13440 bytes -// The third block is the zero block. -var widthValues = [6720]uint16{ - // Block 0x0, offset 0x0 - 0x20: 0x6001, 0x21: 0x6002, 0x22: 0x6002, 0x23: 0x6002, - 0x24: 0x6002, 0x25: 0x6002, 0x26: 0x6002, 0x27: 0x6002, 0x28: 0x6002, 0x29: 0x6002, - 0x2a: 0x6002, 0x2b: 0x6002, 0x2c: 0x6002, 0x2d: 0x6002, 0x2e: 0x6002, 0x2f: 0x6002, - 0x30: 0x6002, 0x31: 0x6002, 0x32: 0x6002, 0x33: 0x6002, 0x34: 0x6002, 0x35: 0x6002, - 0x36: 0x6002, 0x37: 0x6002, 0x38: 0x6002, 0x39: 0x6002, 0x3a: 0x6002, 0x3b: 0x6002, - 0x3c: 0x6002, 0x3d: 0x6002, 0x3e: 0x6002, 0x3f: 0x6002, - // Block 0x1, offset 0x40 - 0x40: 0x6003, 0x41: 0x6003, 0x42: 0x6003, 0x43: 0x6003, 0x44: 0x6003, 0x45: 0x6003, - 0x46: 0x6003, 0x47: 0x6003, 0x48: 0x6003, 0x49: 0x6003, 0x4a: 0x6003, 0x4b: 0x6003, - 0x4c: 0x6003, 0x4d: 0x6003, 0x4e: 0x6003, 0x4f: 0x6003, 0x50: 0x6003, 0x51: 0x6003, - 0x52: 0x6003, 0x53: 0x6003, 0x54: 0x6003, 0x55: 0x6003, 0x56: 0x6003, 0x57: 0x6003, - 0x58: 0x6003, 0x59: 0x6003, 0x5a: 0x6003, 0x5b: 0x6003, 0x5c: 0x6003, 0x5d: 0x6003, - 0x5e: 0x6003, 0x5f: 0x6003, 0x60: 0x6004, 0x61: 0x6004, 0x62: 0x6004, 0x63: 0x6004, - 0x64: 0x6004, 0x65: 0x6004, 0x66: 0x6004, 0x67: 0x6004, 0x68: 0x6004, 0x69: 0x6004, - 0x6a: 0x6004, 0x6b: 0x6004, 0x6c: 0x6004, 0x6d: 0x6004, 0x6e: 0x6004, 0x6f: 0x6004, - 0x70: 0x6004, 0x71: 0x6004, 0x72: 0x6004, 0x73: 0x6004, 0x74: 0x6004, 0x75: 0x6004, - 0x76: 0x6004, 0x77: 0x6004, 0x78: 0x6004, 0x79: 0x6004, 0x7a: 0x6004, 0x7b: 0x6004, - 0x7c: 0x6004, 0x7d: 0x6004, 0x7e: 0x6004, - // Block 0x2, offset 0x80 - // Block 0x3, offset 0xc0 - 0xe1: 0x2000, 0xe2: 0x6005, 0xe3: 0x6005, - 0xe4: 0x2000, 0xe5: 0x6006, 0xe6: 0x6005, 0xe7: 0x2000, 0xe8: 0x2000, - 0xea: 0x2000, 0xec: 0x6007, 0xed: 0x2000, 0xee: 0x2000, 0xef: 0x6008, - 0xf0: 0x2000, 0xf1: 0x2000, 0xf2: 0x2000, 0xf3: 0x2000, 0xf4: 0x2000, - 0xf6: 0x2000, 0xf7: 0x2000, 0xf8: 0x2000, 0xf9: 0x2000, 0xfa: 0x2000, - 0xfc: 0x2000, 0xfd: 0x2000, 0xfe: 0x2000, 0xff: 0x2000, - // Block 0x4, offset 0x100 - 0x106: 0x2000, - 0x110: 0x2000, - 0x117: 0x2000, - 0x118: 0x2000, - 0x11e: 0x2000, 0x11f: 0x2000, 0x120: 0x2000, 0x121: 0x2000, - 0x126: 0x2000, 0x128: 0x2000, 0x129: 0x2000, - 0x12a: 0x2000, 0x12c: 0x2000, 0x12d: 0x2000, - 0x130: 0x2000, 0x132: 0x2000, 0x133: 0x2000, - 0x137: 0x2000, 0x138: 0x2000, 0x139: 0x2000, 0x13a: 0x2000, - 0x13c: 0x2000, 0x13e: 0x2000, - // Block 0x5, offset 0x140 - 0x141: 0x2000, - 0x151: 0x2000, - 0x153: 0x2000, - 0x15b: 0x2000, - 0x166: 0x2000, 0x167: 0x2000, - 0x16b: 0x2000, - 0x171: 0x2000, 0x172: 0x2000, 0x173: 0x2000, - 0x178: 0x2000, - 0x17f: 0x2000, - // Block 0x6, offset 0x180 - 0x180: 0x2000, 0x181: 0x2000, 0x182: 0x2000, 0x184: 0x2000, - 0x188: 0x2000, 0x189: 0x2000, 0x18a: 0x2000, 0x18b: 0x2000, - 0x18d: 0x2000, - 0x192: 0x2000, 0x193: 0x2000, - 0x1a6: 0x2000, 0x1a7: 0x2000, - 0x1ab: 0x2000, - // Block 0x7, offset 0x1c0 - 0x1ce: 0x2000, 0x1d0: 0x2000, - 0x1d2: 0x2000, 0x1d4: 0x2000, 0x1d6: 0x2000, - 0x1d8: 0x2000, 0x1da: 0x2000, 0x1dc: 0x2000, - // Block 0x8, offset 0x200 - 0x211: 0x2000, - 0x221: 0x2000, - // Block 0x9, offset 0x240 - 0x244: 0x2000, - 0x247: 0x2000, 0x249: 0x2000, 0x24a: 0x2000, 0x24b: 0x2000, - 0x24d: 0x2000, 0x250: 0x2000, - 0x258: 0x2000, 0x259: 0x2000, 0x25a: 0x2000, 0x25b: 0x2000, 0x25d: 0x2000, - 0x25f: 0x2000, - // Block 0xa, offset 0x280 - 0x280: 0x2000, 0x281: 0x2000, 0x282: 0x2000, 0x283: 0x2000, 0x284: 0x2000, 0x285: 0x2000, - 0x286: 0x2000, 0x287: 0x2000, 0x288: 0x2000, 0x289: 0x2000, 0x28a: 0x2000, 0x28b: 0x2000, - 0x28c: 0x2000, 0x28d: 0x2000, 0x28e: 0x2000, 0x28f: 0x2000, 0x290: 0x2000, 0x291: 0x2000, - 0x292: 0x2000, 0x293: 0x2000, 0x294: 0x2000, 0x295: 0x2000, 0x296: 0x2000, 0x297: 0x2000, - 0x298: 0x2000, 0x299: 0x2000, 0x29a: 0x2000, 0x29b: 0x2000, 0x29c: 0x2000, 0x29d: 0x2000, - 0x29e: 0x2000, 0x29f: 0x2000, 0x2a0: 0x2000, 0x2a1: 0x2000, 0x2a2: 0x2000, 0x2a3: 0x2000, - 0x2a4: 0x2000, 0x2a5: 0x2000, 0x2a6: 0x2000, 0x2a7: 0x2000, 0x2a8: 0x2000, 0x2a9: 0x2000, - 0x2aa: 0x2000, 0x2ab: 0x2000, 0x2ac: 0x2000, 0x2ad: 0x2000, 0x2ae: 0x2000, 0x2af: 0x2000, - 0x2b0: 0x2000, 0x2b1: 0x2000, 0x2b2: 0x2000, 0x2b3: 0x2000, 0x2b4: 0x2000, 0x2b5: 0x2000, - 0x2b6: 0x2000, 0x2b7: 0x2000, 0x2b8: 0x2000, 0x2b9: 0x2000, 0x2ba: 0x2000, 0x2bb: 0x2000, - 0x2bc: 0x2000, 0x2bd: 0x2000, 0x2be: 0x2000, 0x2bf: 0x2000, - // Block 0xb, offset 0x2c0 - 0x2c0: 0x2000, 0x2c1: 0x2000, 0x2c2: 0x2000, 0x2c3: 0x2000, 0x2c4: 0x2000, 0x2c5: 0x2000, - 0x2c6: 0x2000, 0x2c7: 0x2000, 0x2c8: 0x2000, 0x2c9: 0x2000, 0x2ca: 0x2000, 0x2cb: 0x2000, - 0x2cc: 0x2000, 0x2cd: 0x2000, 0x2ce: 0x2000, 0x2cf: 0x2000, 0x2d0: 0x2000, 0x2d1: 0x2000, - 0x2d2: 0x2000, 0x2d3: 0x2000, 0x2d4: 0x2000, 0x2d5: 0x2000, 0x2d6: 0x2000, 0x2d7: 0x2000, - 0x2d8: 0x2000, 0x2d9: 0x2000, 0x2da: 0x2000, 0x2db: 0x2000, 0x2dc: 0x2000, 0x2dd: 0x2000, - 0x2de: 0x2000, 0x2df: 0x2000, 0x2e0: 0x2000, 0x2e1: 0x2000, 0x2e2: 0x2000, 0x2e3: 0x2000, - 0x2e4: 0x2000, 0x2e5: 0x2000, 0x2e6: 0x2000, 0x2e7: 0x2000, 0x2e8: 0x2000, 0x2e9: 0x2000, - 0x2ea: 0x2000, 0x2eb: 0x2000, 0x2ec: 0x2000, 0x2ed: 0x2000, 0x2ee: 0x2000, 0x2ef: 0x2000, - // Block 0xc, offset 0x300 - 0x311: 0x2000, - 0x312: 0x2000, 0x313: 0x2000, 0x314: 0x2000, 0x315: 0x2000, 0x316: 0x2000, 0x317: 0x2000, - 0x318: 0x2000, 0x319: 0x2000, 0x31a: 0x2000, 0x31b: 0x2000, 0x31c: 0x2000, 0x31d: 0x2000, - 0x31e: 0x2000, 0x31f: 0x2000, 0x320: 0x2000, 0x321: 0x2000, 0x323: 0x2000, - 0x324: 0x2000, 0x325: 0x2000, 0x326: 0x2000, 0x327: 0x2000, 0x328: 0x2000, 0x329: 0x2000, - 0x331: 0x2000, 0x332: 0x2000, 0x333: 0x2000, 0x334: 0x2000, 0x335: 0x2000, - 0x336: 0x2000, 0x337: 0x2000, 0x338: 0x2000, 0x339: 0x2000, 0x33a: 0x2000, 0x33b: 0x2000, - 0x33c: 0x2000, 0x33d: 0x2000, 0x33e: 0x2000, 0x33f: 0x2000, - // Block 0xd, offset 0x340 - 0x340: 0x2000, 0x341: 0x2000, 0x343: 0x2000, 0x344: 0x2000, 0x345: 0x2000, - 0x346: 0x2000, 0x347: 0x2000, 0x348: 0x2000, 0x349: 0x2000, - // Block 0xe, offset 0x380 - 0x381: 0x2000, - 0x390: 0x2000, 0x391: 0x2000, - 0x392: 0x2000, 0x393: 0x2000, 0x394: 0x2000, 0x395: 0x2000, 0x396: 0x2000, 0x397: 0x2000, - 0x398: 0x2000, 0x399: 0x2000, 0x39a: 0x2000, 0x39b: 0x2000, 0x39c: 0x2000, 0x39d: 0x2000, - 0x39e: 0x2000, 0x39f: 0x2000, 0x3a0: 0x2000, 0x3a1: 0x2000, 0x3a2: 0x2000, 0x3a3: 0x2000, - 0x3a4: 0x2000, 0x3a5: 0x2000, 0x3a6: 0x2000, 0x3a7: 0x2000, 0x3a8: 0x2000, 0x3a9: 0x2000, - 0x3aa: 0x2000, 0x3ab: 0x2000, 0x3ac: 0x2000, 0x3ad: 0x2000, 0x3ae: 0x2000, 0x3af: 0x2000, - 0x3b0: 0x2000, 0x3b1: 0x2000, 0x3b2: 0x2000, 0x3b3: 0x2000, 0x3b4: 0x2000, 0x3b5: 0x2000, - 0x3b6: 0x2000, 0x3b7: 0x2000, 0x3b8: 0x2000, 0x3b9: 0x2000, 0x3ba: 0x2000, 0x3bb: 0x2000, - 0x3bc: 0x2000, 0x3bd: 0x2000, 0x3be: 0x2000, 0x3bf: 0x2000, - // Block 0xf, offset 0x3c0 - 0x3c0: 0x2000, 0x3c1: 0x2000, 0x3c2: 0x2000, 0x3c3: 0x2000, 0x3c4: 0x2000, 0x3c5: 0x2000, - 0x3c6: 0x2000, 0x3c7: 0x2000, 0x3c8: 0x2000, 0x3c9: 0x2000, 0x3ca: 0x2000, 0x3cb: 0x2000, - 0x3cc: 0x2000, 0x3cd: 0x2000, 0x3ce: 0x2000, 0x3cf: 0x2000, 0x3d1: 0x2000, - // Block 0x10, offset 0x400 - 0x400: 0x4000, 0x401: 0x4000, 0x402: 0x4000, 0x403: 0x4000, 0x404: 0x4000, 0x405: 0x4000, - 0x406: 0x4000, 0x407: 0x4000, 0x408: 0x4000, 0x409: 0x4000, 0x40a: 0x4000, 0x40b: 0x4000, - 0x40c: 0x4000, 0x40d: 0x4000, 0x40e: 0x4000, 0x40f: 0x4000, 0x410: 0x4000, 0x411: 0x4000, - 0x412: 0x4000, 0x413: 0x4000, 0x414: 0x4000, 0x415: 0x4000, 0x416: 0x4000, 0x417: 0x4000, - 0x418: 0x4000, 0x419: 0x4000, 0x41a: 0x4000, 0x41b: 0x4000, 0x41c: 0x4000, 0x41d: 0x4000, - 0x41e: 0x4000, 0x41f: 0x4000, 0x420: 0x4000, 0x421: 0x4000, 0x422: 0x4000, 0x423: 0x4000, - 0x424: 0x4000, 0x425: 0x4000, 0x426: 0x4000, 0x427: 0x4000, 0x428: 0x4000, 0x429: 0x4000, - 0x42a: 0x4000, 0x42b: 0x4000, 0x42c: 0x4000, 0x42d: 0x4000, 0x42e: 0x4000, 0x42f: 0x4000, - 0x430: 0x4000, 0x431: 0x4000, 0x432: 0x4000, 0x433: 0x4000, 0x434: 0x4000, 0x435: 0x4000, - 0x436: 0x4000, 0x437: 0x4000, 0x438: 0x4000, 0x439: 0x4000, 0x43a: 0x4000, 0x43b: 0x4000, - 0x43c: 0x4000, 0x43d: 0x4000, 0x43e: 0x4000, 0x43f: 0x4000, - // Block 0x11, offset 0x440 - 0x440: 0x4000, 0x441: 0x4000, 0x442: 0x4000, 0x443: 0x4000, 0x444: 0x4000, 0x445: 0x4000, - 0x446: 0x4000, 0x447: 0x4000, 0x448: 0x4000, 0x449: 0x4000, 0x44a: 0x4000, 0x44b: 0x4000, - 0x44c: 0x4000, 0x44d: 0x4000, 0x44e: 0x4000, 0x44f: 0x4000, 0x450: 0x4000, 0x451: 0x4000, - 0x452: 0x4000, 0x453: 0x4000, 0x454: 0x4000, 0x455: 0x4000, 0x456: 0x4000, 0x457: 0x4000, - 0x458: 0x4000, 0x459: 0x4000, 0x45a: 0x4000, 0x45b: 0x4000, 0x45c: 0x4000, 0x45d: 0x4000, - 0x45e: 0x4000, 0x45f: 0x4000, - // Block 0x12, offset 0x480 - 0x490: 0x2000, - 0x493: 0x2000, 0x494: 0x2000, 0x495: 0x2000, 0x496: 0x2000, - 0x498: 0x2000, 0x499: 0x2000, 0x49c: 0x2000, 0x49d: 0x2000, - 0x4a0: 0x2000, 0x4a1: 0x2000, 0x4a2: 0x2000, - 0x4a4: 0x2000, 0x4a5: 0x2000, 0x4a6: 0x2000, 0x4a7: 0x2000, - 0x4b0: 0x2000, 0x4b2: 0x2000, 0x4b3: 0x2000, 0x4b5: 0x2000, - 0x4bb: 0x2000, - 0x4be: 0x2000, - // Block 0x13, offset 0x4c0 - 0x4f4: 0x2000, - 0x4ff: 0x2000, - // Block 0x14, offset 0x500 - 0x501: 0x2000, 0x502: 0x2000, 0x503: 0x2000, 0x504: 0x2000, - 0x529: 0xa009, - 0x52c: 0x2000, - // Block 0x15, offset 0x540 - 0x543: 0x2000, 0x545: 0x2000, - 0x549: 0x2000, - 0x553: 0x2000, 0x556: 0x2000, - 0x561: 0x2000, 0x562: 0x2000, - 0x566: 0x2000, - 0x56b: 0x2000, - // Block 0x16, offset 0x580 - 0x593: 0x2000, 0x594: 0x2000, - 0x59b: 0x2000, 0x59c: 0x2000, 0x59d: 0x2000, - 0x59e: 0x2000, 0x5a0: 0x2000, 0x5a1: 0x2000, 0x5a2: 0x2000, 0x5a3: 0x2000, - 0x5a4: 0x2000, 0x5a5: 0x2000, 0x5a6: 0x2000, 0x5a7: 0x2000, 0x5a8: 0x2000, 0x5a9: 0x2000, - 0x5aa: 0x2000, 0x5ab: 0x2000, - 0x5b0: 0x2000, 0x5b1: 0x2000, 0x5b2: 0x2000, 0x5b3: 0x2000, 0x5b4: 0x2000, 0x5b5: 0x2000, - 0x5b6: 0x2000, 0x5b7: 0x2000, 0x5b8: 0x2000, 0x5b9: 0x2000, - // Block 0x17, offset 0x5c0 - 0x5c9: 0x2000, - 0x5d0: 0x200a, 0x5d1: 0x200b, - 0x5d2: 0x200a, 0x5d3: 0x200c, 0x5d4: 0x2000, 0x5d5: 0x2000, 0x5d6: 0x2000, 0x5d7: 0x2000, - 0x5d8: 0x2000, 0x5d9: 0x2000, - 0x5f8: 0x2000, 0x5f9: 0x2000, - // Block 0x18, offset 0x600 - 0x612: 0x2000, 0x614: 0x2000, - 0x627: 0x2000, - // Block 0x19, offset 0x640 - 0x640: 0x2000, 0x642: 0x2000, 0x643: 0x2000, - 0x647: 0x2000, 0x648: 0x2000, 0x64b: 0x2000, - 0x64f: 0x2000, 0x651: 0x2000, - 0x655: 0x2000, - 0x65a: 0x2000, 0x65d: 0x2000, - 0x65e: 0x2000, 0x65f: 0x2000, 0x660: 0x2000, 0x663: 0x2000, - 0x665: 0x2000, 0x667: 0x2000, 0x668: 0x2000, 0x669: 0x2000, - 0x66a: 0x2000, 0x66b: 0x2000, 0x66c: 0x2000, 0x66e: 0x2000, - 0x674: 0x2000, 0x675: 0x2000, - 0x676: 0x2000, 0x677: 0x2000, - 0x67c: 0x2000, 0x67d: 0x2000, - // Block 0x1a, offset 0x680 - 0x688: 0x2000, - 0x68c: 0x2000, - 0x692: 0x2000, - 0x6a0: 0x2000, 0x6a1: 0x2000, - 0x6a4: 0x2000, 0x6a5: 0x2000, 0x6a6: 0x2000, 0x6a7: 0x2000, - 0x6aa: 0x2000, 0x6ab: 0x2000, 0x6ae: 0x2000, 0x6af: 0x2000, - // Block 0x1b, offset 0x6c0 - 0x6c2: 0x2000, 0x6c3: 0x2000, - 0x6c6: 0x2000, 0x6c7: 0x2000, - 0x6d5: 0x2000, - 0x6d9: 0x2000, - 0x6e5: 0x2000, - 0x6ff: 0x2000, - // Block 0x1c, offset 0x700 - 0x712: 0x2000, - 0x71a: 0x4000, 0x71b: 0x4000, - 0x729: 0x4000, - 0x72a: 0x4000, - // Block 0x1d, offset 0x740 - 0x769: 0x4000, - 0x76a: 0x4000, 0x76b: 0x4000, 0x76c: 0x4000, - 0x770: 0x4000, 0x773: 0x4000, - // Block 0x1e, offset 0x780 - 0x7a0: 0x2000, 0x7a1: 0x2000, 0x7a2: 0x2000, 0x7a3: 0x2000, - 0x7a4: 0x2000, 0x7a5: 0x2000, 0x7a6: 0x2000, 0x7a7: 0x2000, 0x7a8: 0x2000, 0x7a9: 0x2000, - 0x7aa: 0x2000, 0x7ab: 0x2000, 0x7ac: 0x2000, 0x7ad: 0x2000, 0x7ae: 0x2000, 0x7af: 0x2000, - 0x7b0: 0x2000, 0x7b1: 0x2000, 0x7b2: 0x2000, 0x7b3: 0x2000, 0x7b4: 0x2000, 0x7b5: 0x2000, - 0x7b6: 0x2000, 0x7b7: 0x2000, 0x7b8: 0x2000, 0x7b9: 0x2000, 0x7ba: 0x2000, 0x7bb: 0x2000, - 0x7bc: 0x2000, 0x7bd: 0x2000, 0x7be: 0x2000, 0x7bf: 0x2000, - // Block 0x1f, offset 0x7c0 - 0x7c0: 0x2000, 0x7c1: 0x2000, 0x7c2: 0x2000, 0x7c3: 0x2000, 0x7c4: 0x2000, 0x7c5: 0x2000, - 0x7c6: 0x2000, 0x7c7: 0x2000, 0x7c8: 0x2000, 0x7c9: 0x2000, 0x7ca: 0x2000, 0x7cb: 0x2000, - 0x7cc: 0x2000, 0x7cd: 0x2000, 0x7ce: 0x2000, 0x7cf: 0x2000, 0x7d0: 0x2000, 0x7d1: 0x2000, - 0x7d2: 0x2000, 0x7d3: 0x2000, 0x7d4: 0x2000, 0x7d5: 0x2000, 0x7d6: 0x2000, 0x7d7: 0x2000, - 0x7d8: 0x2000, 0x7d9: 0x2000, 0x7da: 0x2000, 0x7db: 0x2000, 0x7dc: 0x2000, 0x7dd: 0x2000, - 0x7de: 0x2000, 0x7df: 0x2000, 0x7e0: 0x2000, 0x7e1: 0x2000, 0x7e2: 0x2000, 0x7e3: 0x2000, - 0x7e4: 0x2000, 0x7e5: 0x2000, 0x7e6: 0x2000, 0x7e7: 0x2000, 0x7e8: 0x2000, 0x7e9: 0x2000, - 0x7eb: 0x2000, 0x7ec: 0x2000, 0x7ed: 0x2000, 0x7ee: 0x2000, 0x7ef: 0x2000, - 0x7f0: 0x2000, 0x7f1: 0x2000, 0x7f2: 0x2000, 0x7f3: 0x2000, 0x7f4: 0x2000, 0x7f5: 0x2000, - 0x7f6: 0x2000, 0x7f7: 0x2000, 0x7f8: 0x2000, 0x7f9: 0x2000, 0x7fa: 0x2000, 0x7fb: 0x2000, - 0x7fc: 0x2000, 0x7fd: 0x2000, 0x7fe: 0x2000, 0x7ff: 0x2000, - // Block 0x20, offset 0x800 - 0x800: 0x2000, 0x801: 0x2000, 0x802: 0x200d, 0x803: 0x2000, 0x804: 0x2000, 0x805: 0x2000, - 0x806: 0x2000, 0x807: 0x2000, 0x808: 0x2000, 0x809: 0x2000, 0x80a: 0x2000, 0x80b: 0x2000, - 0x80c: 0x2000, 0x80d: 0x2000, 0x80e: 0x2000, 0x80f: 0x2000, 0x810: 0x2000, 0x811: 0x2000, - 0x812: 0x2000, 0x813: 0x2000, 0x814: 0x2000, 0x815: 0x2000, 0x816: 0x2000, 0x817: 0x2000, - 0x818: 0x2000, 0x819: 0x2000, 0x81a: 0x2000, 0x81b: 0x2000, 0x81c: 0x2000, 0x81d: 0x2000, - 0x81e: 0x2000, 0x81f: 0x2000, 0x820: 0x2000, 0x821: 0x2000, 0x822: 0x2000, 0x823: 0x2000, - 0x824: 0x2000, 0x825: 0x2000, 0x826: 0x2000, 0x827: 0x2000, 0x828: 0x2000, 0x829: 0x2000, - 0x82a: 0x2000, 0x82b: 0x2000, 0x82c: 0x2000, 0x82d: 0x2000, 0x82e: 0x2000, 0x82f: 0x2000, - 0x830: 0x2000, 0x831: 0x2000, 0x832: 0x2000, 0x833: 0x2000, 0x834: 0x2000, 0x835: 0x2000, - 0x836: 0x2000, 0x837: 0x2000, 0x838: 0x2000, 0x839: 0x2000, 0x83a: 0x2000, 0x83b: 0x2000, - 0x83c: 0x2000, 0x83d: 0x2000, 0x83e: 0x2000, 0x83f: 0x2000, - // Block 0x21, offset 0x840 - 0x840: 0x2000, 0x841: 0x2000, 0x842: 0x2000, 0x843: 0x2000, 0x844: 0x2000, 0x845: 0x2000, - 0x846: 0x2000, 0x847: 0x2000, 0x848: 0x2000, 0x849: 0x2000, 0x84a: 0x2000, 0x84b: 0x2000, - 0x850: 0x2000, 0x851: 0x2000, - 0x852: 0x2000, 0x853: 0x2000, 0x854: 0x2000, 0x855: 0x2000, 0x856: 0x2000, 0x857: 0x2000, - 0x858: 0x2000, 0x859: 0x2000, 0x85a: 0x2000, 0x85b: 0x2000, 0x85c: 0x2000, 0x85d: 0x2000, - 0x85e: 0x2000, 0x85f: 0x2000, 0x860: 0x2000, 0x861: 0x2000, 0x862: 0x2000, 0x863: 0x2000, - 0x864: 0x2000, 0x865: 0x2000, 0x866: 0x2000, 0x867: 0x2000, 0x868: 0x2000, 0x869: 0x2000, - 0x86a: 0x2000, 0x86b: 0x2000, 0x86c: 0x2000, 0x86d: 0x2000, 0x86e: 0x2000, 0x86f: 0x2000, - 0x870: 0x2000, 0x871: 0x2000, 0x872: 0x2000, 0x873: 0x2000, - // Block 0x22, offset 0x880 - 0x880: 0x2000, 0x881: 0x2000, 0x882: 0x2000, 0x883: 0x2000, 0x884: 0x2000, 0x885: 0x2000, - 0x886: 0x2000, 0x887: 0x2000, 0x888: 0x2000, 0x889: 0x2000, 0x88a: 0x2000, 0x88b: 0x2000, - 0x88c: 0x2000, 0x88d: 0x2000, 0x88e: 0x2000, 0x88f: 0x2000, - 0x892: 0x2000, 0x893: 0x2000, 0x894: 0x2000, 0x895: 0x2000, - 0x8a0: 0x200e, 0x8a1: 0x2000, 0x8a3: 0x2000, - 0x8a4: 0x2000, 0x8a5: 0x2000, 0x8a6: 0x2000, 0x8a7: 0x2000, 0x8a8: 0x2000, 0x8a9: 0x2000, - 0x8b2: 0x2000, 0x8b3: 0x2000, - 0x8b6: 0x2000, 0x8b7: 0x2000, - 0x8bc: 0x2000, 0x8bd: 0x2000, - // Block 0x23, offset 0x8c0 - 0x8c0: 0x2000, 0x8c1: 0x2000, - 0x8c6: 0x2000, 0x8c7: 0x2000, 0x8c8: 0x2000, 0x8cb: 0x200f, - 0x8ce: 0x2000, 0x8cf: 0x2000, 0x8d0: 0x2000, 0x8d1: 0x2000, - 0x8e2: 0x2000, 0x8e3: 0x2000, - 0x8e4: 0x2000, 0x8e5: 0x2000, - 0x8ef: 0x2000, - 0x8fd: 0x4000, 0x8fe: 0x4000, - // Block 0x24, offset 0x900 - 0x905: 0x2000, - 0x906: 0x2000, 0x909: 0x2000, - 0x90e: 0x2000, 0x90f: 0x2000, - 0x914: 0x4000, 0x915: 0x4000, - 0x91c: 0x2000, - 0x91e: 0x2000, - // Block 0x25, offset 0x940 - 0x940: 0x2000, 0x942: 0x2000, - 0x948: 0x4000, 0x949: 0x4000, 0x94a: 0x4000, 0x94b: 0x4000, - 0x94c: 0x4000, 0x94d: 0x4000, 0x94e: 0x4000, 0x94f: 0x4000, 0x950: 0x4000, 0x951: 0x4000, - 0x952: 0x4000, 0x953: 0x4000, - 0x960: 0x2000, 0x961: 0x2000, 0x963: 0x2000, - 0x964: 0x2000, 0x965: 0x2000, 0x967: 0x2000, 0x968: 0x2000, 0x969: 0x2000, - 0x96a: 0x2000, 0x96c: 0x2000, 0x96d: 0x2000, 0x96f: 0x2000, - 0x97f: 0x4000, - // Block 0x26, offset 0x980 - 0x993: 0x4000, - 0x99e: 0x2000, 0x99f: 0x2000, 0x9a1: 0x4000, - 0x9aa: 0x4000, 0x9ab: 0x4000, - 0x9bd: 0x4000, 0x9be: 0x4000, 0x9bf: 0x2000, - // Block 0x27, offset 0x9c0 - 0x9c4: 0x4000, 0x9c5: 0x4000, - 0x9c6: 0x2000, 0x9c7: 0x2000, 0x9c8: 0x2000, 0x9c9: 0x2000, 0x9ca: 0x2000, 0x9cb: 0x2000, - 0x9cc: 0x2000, 0x9cd: 0x2000, 0x9ce: 0x4000, 0x9cf: 0x2000, 0x9d0: 0x2000, 0x9d1: 0x2000, - 0x9d2: 0x2000, 0x9d3: 0x2000, 0x9d4: 0x4000, 0x9d5: 0x2000, 0x9d6: 0x2000, 0x9d7: 0x2000, - 0x9d8: 0x2000, 0x9d9: 0x2000, 0x9da: 0x2000, 0x9db: 0x2000, 0x9dc: 0x2000, 0x9dd: 0x2000, - 0x9de: 0x2000, 0x9df: 0x2000, 0x9e0: 0x2000, 0x9e1: 0x2000, 0x9e3: 0x2000, - 0x9e8: 0x2000, 0x9e9: 0x2000, - 0x9ea: 0x4000, 0x9eb: 0x2000, 0x9ec: 0x2000, 0x9ed: 0x2000, 0x9ee: 0x2000, 0x9ef: 0x2000, - 0x9f0: 0x2000, 0x9f1: 0x2000, 0x9f2: 0x4000, 0x9f3: 0x4000, 0x9f4: 0x2000, 0x9f5: 0x4000, - 0x9f6: 0x2000, 0x9f7: 0x2000, 0x9f8: 0x2000, 0x9f9: 0x2000, 0x9fa: 0x4000, 0x9fb: 0x2000, - 0x9fc: 0x2000, 0x9fd: 0x4000, 0x9fe: 0x2000, 0x9ff: 0x2000, - // Block 0x28, offset 0xa00 - 0xa05: 0x4000, - 0xa0a: 0x4000, 0xa0b: 0x4000, - 0xa28: 0x4000, - 0xa3d: 0x2000, - // Block 0x29, offset 0xa40 - 0xa4c: 0x4000, 0xa4e: 0x4000, - 0xa53: 0x4000, 0xa54: 0x4000, 0xa55: 0x4000, 0xa57: 0x4000, - 0xa76: 0x2000, 0xa77: 0x2000, 0xa78: 0x2000, 0xa79: 0x2000, 0xa7a: 0x2000, 0xa7b: 0x2000, - 0xa7c: 0x2000, 0xa7d: 0x2000, 0xa7e: 0x2000, 0xa7f: 0x2000, - // Block 0x2a, offset 0xa80 - 0xa95: 0x4000, 0xa96: 0x4000, 0xa97: 0x4000, - 0xab0: 0x4000, - 0xabf: 0x4000, - // Block 0x2b, offset 0xac0 - 0xae6: 0x6000, 0xae7: 0x6000, 0xae8: 0x6000, 0xae9: 0x6000, - 0xaea: 0x6000, 0xaeb: 0x6000, 0xaec: 0x6000, 0xaed: 0x6000, - // Block 0x2c, offset 0xb00 - 0xb05: 0x6010, - 0xb06: 0x6011, - // Block 0x2d, offset 0xb40 - 0xb5b: 0x4000, 0xb5c: 0x4000, - // Block 0x2e, offset 0xb80 - 0xb90: 0x4000, - 0xb95: 0x4000, 0xb96: 0x2000, 0xb97: 0x2000, - 0xb98: 0x2000, 0xb99: 0x2000, - // Block 0x2f, offset 0xbc0 - 0xbc0: 0x4000, 0xbc1: 0x4000, 0xbc2: 0x4000, 0xbc3: 0x4000, 0xbc4: 0x4000, 0xbc5: 0x4000, - 0xbc6: 0x4000, 0xbc7: 0x4000, 0xbc8: 0x4000, 0xbc9: 0x4000, 0xbca: 0x4000, 0xbcb: 0x4000, - 0xbcc: 0x4000, 0xbcd: 0x4000, 0xbce: 0x4000, 0xbcf: 0x4000, 0xbd0: 0x4000, 0xbd1: 0x4000, - 0xbd2: 0x4000, 0xbd3: 0x4000, 0xbd4: 0x4000, 0xbd5: 0x4000, 0xbd6: 0x4000, 0xbd7: 0x4000, - 0xbd8: 0x4000, 0xbd9: 0x4000, 0xbdb: 0x4000, 0xbdc: 0x4000, 0xbdd: 0x4000, - 0xbde: 0x4000, 0xbdf: 0x4000, 0xbe0: 0x4000, 0xbe1: 0x4000, 0xbe2: 0x4000, 0xbe3: 0x4000, - 0xbe4: 0x4000, 0xbe5: 0x4000, 0xbe6: 0x4000, 0xbe7: 0x4000, 0xbe8: 0x4000, 0xbe9: 0x4000, - 0xbea: 0x4000, 0xbeb: 0x4000, 0xbec: 0x4000, 0xbed: 0x4000, 0xbee: 0x4000, 0xbef: 0x4000, - 0xbf0: 0x4000, 0xbf1: 0x4000, 0xbf2: 0x4000, 0xbf3: 0x4000, 0xbf4: 0x4000, 0xbf5: 0x4000, - 0xbf6: 0x4000, 0xbf7: 0x4000, 0xbf8: 0x4000, 0xbf9: 0x4000, 0xbfa: 0x4000, 0xbfb: 0x4000, - 0xbfc: 0x4000, 0xbfd: 0x4000, 0xbfe: 0x4000, 0xbff: 0x4000, - // Block 0x30, offset 0xc00 - 0xc00: 0x4000, 0xc01: 0x4000, 0xc02: 0x4000, 0xc03: 0x4000, 0xc04: 0x4000, 0xc05: 0x4000, - 0xc06: 0x4000, 0xc07: 0x4000, 0xc08: 0x4000, 0xc09: 0x4000, 0xc0a: 0x4000, 0xc0b: 0x4000, - 0xc0c: 0x4000, 0xc0d: 0x4000, 0xc0e: 0x4000, 0xc0f: 0x4000, 0xc10: 0x4000, 0xc11: 0x4000, - 0xc12: 0x4000, 0xc13: 0x4000, 0xc14: 0x4000, 0xc15: 0x4000, 0xc16: 0x4000, 0xc17: 0x4000, - 0xc18: 0x4000, 0xc19: 0x4000, 0xc1a: 0x4000, 0xc1b: 0x4000, 0xc1c: 0x4000, 0xc1d: 0x4000, - 0xc1e: 0x4000, 0xc1f: 0x4000, 0xc20: 0x4000, 0xc21: 0x4000, 0xc22: 0x4000, 0xc23: 0x4000, - 0xc24: 0x4000, 0xc25: 0x4000, 0xc26: 0x4000, 0xc27: 0x4000, 0xc28: 0x4000, 0xc29: 0x4000, - 0xc2a: 0x4000, 0xc2b: 0x4000, 0xc2c: 0x4000, 0xc2d: 0x4000, 0xc2e: 0x4000, 0xc2f: 0x4000, - 0xc30: 0x4000, 0xc31: 0x4000, 0xc32: 0x4000, 0xc33: 0x4000, - // Block 0x31, offset 0xc40 - 0xc40: 0x4000, 0xc41: 0x4000, 0xc42: 0x4000, 0xc43: 0x4000, 0xc44: 0x4000, 0xc45: 0x4000, - 0xc46: 0x4000, 0xc47: 0x4000, 0xc48: 0x4000, 0xc49: 0x4000, 0xc4a: 0x4000, 0xc4b: 0x4000, - 0xc4c: 0x4000, 0xc4d: 0x4000, 0xc4e: 0x4000, 0xc4f: 0x4000, 0xc50: 0x4000, 0xc51: 0x4000, - 0xc52: 0x4000, 0xc53: 0x4000, 0xc54: 0x4000, 0xc55: 0x4000, - 0xc70: 0x4000, 0xc71: 0x4000, 0xc72: 0x4000, 0xc73: 0x4000, 0xc74: 0x4000, 0xc75: 0x4000, - 0xc76: 0x4000, 0xc77: 0x4000, 0xc78: 0x4000, 0xc79: 0x4000, 0xc7a: 0x4000, 0xc7b: 0x4000, - // Block 0x32, offset 0xc80 - 0xc80: 0x9012, 0xc81: 0x4013, 0xc82: 0x4014, 0xc83: 0x4000, 0xc84: 0x4000, 0xc85: 0x4000, - 0xc86: 0x4000, 0xc87: 0x4000, 0xc88: 0x4000, 0xc89: 0x4000, 0xc8a: 0x4000, 0xc8b: 0x4000, - 0xc8c: 0x4015, 0xc8d: 0x4015, 0xc8e: 0x4000, 0xc8f: 0x4000, 0xc90: 0x4000, 0xc91: 0x4000, - 0xc92: 0x4000, 0xc93: 0x4000, 0xc94: 0x4000, 0xc95: 0x4000, 0xc96: 0x4000, 0xc97: 0x4000, - 0xc98: 0x4000, 0xc99: 0x4000, 0xc9a: 0x4000, 0xc9b: 0x4000, 0xc9c: 0x4000, 0xc9d: 0x4000, - 0xc9e: 0x4000, 0xc9f: 0x4000, 0xca0: 0x4000, 0xca1: 0x4000, 0xca2: 0x4000, 0xca3: 0x4000, - 0xca4: 0x4000, 0xca5: 0x4000, 0xca6: 0x4000, 0xca7: 0x4000, 0xca8: 0x4000, 0xca9: 0x4000, - 0xcaa: 0x4000, 0xcab: 0x4000, 0xcac: 0x4000, 0xcad: 0x4000, 0xcae: 0x4000, 0xcaf: 0x4000, - 0xcb0: 0x4000, 0xcb1: 0x4000, 0xcb2: 0x4000, 0xcb3: 0x4000, 0xcb4: 0x4000, 0xcb5: 0x4000, - 0xcb6: 0x4000, 0xcb7: 0x4000, 0xcb8: 0x4000, 0xcb9: 0x4000, 0xcba: 0x4000, 0xcbb: 0x4000, - 0xcbc: 0x4000, 0xcbd: 0x4000, 0xcbe: 0x4000, - // Block 0x33, offset 0xcc0 - 0xcc1: 0x4000, 0xcc2: 0x4000, 0xcc3: 0x4000, 0xcc4: 0x4000, 0xcc5: 0x4000, - 0xcc6: 0x4000, 0xcc7: 0x4000, 0xcc8: 0x4000, 0xcc9: 0x4000, 0xcca: 0x4000, 0xccb: 0x4000, - 0xccc: 0x4000, 0xccd: 0x4000, 0xcce: 0x4000, 0xccf: 0x4000, 0xcd0: 0x4000, 0xcd1: 0x4000, - 0xcd2: 0x4000, 0xcd3: 0x4000, 0xcd4: 0x4000, 0xcd5: 0x4000, 0xcd6: 0x4000, 0xcd7: 0x4000, - 0xcd8: 0x4000, 0xcd9: 0x4000, 0xcda: 0x4000, 0xcdb: 0x4000, 0xcdc: 0x4000, 0xcdd: 0x4000, - 0xcde: 0x4000, 0xcdf: 0x4000, 0xce0: 0x4000, 0xce1: 0x4000, 0xce2: 0x4000, 0xce3: 0x4000, - 0xce4: 0x4000, 0xce5: 0x4000, 0xce6: 0x4000, 0xce7: 0x4000, 0xce8: 0x4000, 0xce9: 0x4000, - 0xcea: 0x4000, 0xceb: 0x4000, 0xcec: 0x4000, 0xced: 0x4000, 0xcee: 0x4000, 0xcef: 0x4000, - 0xcf0: 0x4000, 0xcf1: 0x4000, 0xcf2: 0x4000, 0xcf3: 0x4000, 0xcf4: 0x4000, 0xcf5: 0x4000, - 0xcf6: 0x4000, 0xcf7: 0x4000, 0xcf8: 0x4000, 0xcf9: 0x4000, 0xcfa: 0x4000, 0xcfb: 0x4000, - 0xcfc: 0x4000, 0xcfd: 0x4000, 0xcfe: 0x4000, 0xcff: 0x4000, - // Block 0x34, offset 0xd00 - 0xd00: 0x4000, 0xd01: 0x4000, 0xd02: 0x4000, 0xd03: 0x4000, 0xd04: 0x4000, 0xd05: 0x4000, - 0xd06: 0x4000, 0xd07: 0x4000, 0xd08: 0x4000, 0xd09: 0x4000, 0xd0a: 0x4000, 0xd0b: 0x4000, - 0xd0c: 0x4000, 0xd0d: 0x4000, 0xd0e: 0x4000, 0xd0f: 0x4000, 0xd10: 0x4000, 0xd11: 0x4000, - 0xd12: 0x4000, 0xd13: 0x4000, 0xd14: 0x4000, 0xd15: 0x4000, 0xd16: 0x4000, - 0xd19: 0x4016, 0xd1a: 0x4017, 0xd1b: 0x4000, 0xd1c: 0x4000, 0xd1d: 0x4000, - 0xd1e: 0x4000, 0xd1f: 0x4000, 0xd20: 0x4000, 0xd21: 0x4018, 0xd22: 0x4019, 0xd23: 0x401a, - 0xd24: 0x401b, 0xd25: 0x401c, 0xd26: 0x401d, 0xd27: 0x401e, 0xd28: 0x401f, 0xd29: 0x4020, - 0xd2a: 0x4021, 0xd2b: 0x4022, 0xd2c: 0x4000, 0xd2d: 0x4010, 0xd2e: 0x4000, 0xd2f: 0x4023, - 0xd30: 0x4000, 0xd31: 0x4024, 0xd32: 0x4000, 0xd33: 0x4025, 0xd34: 0x4000, 0xd35: 0x4026, - 0xd36: 0x4000, 0xd37: 0x401a, 0xd38: 0x4000, 0xd39: 0x4027, 0xd3a: 0x4000, 0xd3b: 0x4028, - 0xd3c: 0x4000, 0xd3d: 0x4020, 0xd3e: 0x4000, 0xd3f: 0x4029, - // Block 0x35, offset 0xd40 - 0xd40: 0x4000, 0xd41: 0x402a, 0xd42: 0x4000, 0xd43: 0x402b, 0xd44: 0x402c, 0xd45: 0x4000, - 0xd46: 0x4017, 0xd47: 0x4000, 0xd48: 0x402d, 0xd49: 0x4000, 0xd4a: 0x402e, 0xd4b: 0x402f, - 0xd4c: 0x4030, 0xd4d: 0x4017, 0xd4e: 0x4016, 0xd4f: 0x4017, 0xd50: 0x4000, 0xd51: 0x4000, - 0xd52: 0x4031, 0xd53: 0x4000, 0xd54: 0x4000, 0xd55: 0x4031, 0xd56: 0x4000, 0xd57: 0x4000, - 0xd58: 0x4032, 0xd59: 0x4000, 0xd5a: 0x4000, 0xd5b: 0x4032, 0xd5c: 0x4000, 0xd5d: 0x4000, - 0xd5e: 0x4033, 0xd5f: 0x402e, 0xd60: 0x4034, 0xd61: 0x4035, 0xd62: 0x4034, 0xd63: 0x4036, - 0xd64: 0x4037, 0xd65: 0x4024, 0xd66: 0x4035, 0xd67: 0x4025, 0xd68: 0x4038, 0xd69: 0x4038, - 0xd6a: 0x4039, 0xd6b: 0x4039, 0xd6c: 0x403a, 0xd6d: 0x403a, 0xd6e: 0x4000, 0xd6f: 0x4035, - 0xd70: 0x4000, 0xd71: 0x4000, 0xd72: 0x403b, 0xd73: 0x403c, 0xd74: 0x4000, 0xd75: 0x4000, - 0xd76: 0x4000, 0xd77: 0x4000, 0xd78: 0x4000, 0xd79: 0x4000, 0xd7a: 0x4000, 0xd7b: 0x403d, - 0xd7c: 0x401c, 0xd7d: 0x4000, 0xd7e: 0x4000, 0xd7f: 0x4000, - // Block 0x36, offset 0xd80 - 0xd85: 0x4000, - 0xd86: 0x4000, 0xd87: 0x4000, 0xd88: 0x4000, 0xd89: 0x4000, 0xd8a: 0x4000, 0xd8b: 0x4000, - 0xd8c: 0x4000, 0xd8d: 0x4000, 0xd8e: 0x4000, 0xd8f: 0x4000, 0xd90: 0x4000, 0xd91: 0x4000, - 0xd92: 0x4000, 0xd93: 0x4000, 0xd94: 0x4000, 0xd95: 0x4000, 0xd96: 0x4000, 0xd97: 0x4000, - 0xd98: 0x4000, 0xd99: 0x4000, 0xd9a: 0x4000, 0xd9b: 0x4000, 0xd9c: 0x4000, 0xd9d: 0x4000, - 0xd9e: 0x4000, 0xd9f: 0x4000, 0xda0: 0x4000, 0xda1: 0x4000, 0xda2: 0x4000, 0xda3: 0x4000, - 0xda4: 0x4000, 0xda5: 0x4000, 0xda6: 0x4000, 0xda7: 0x4000, 0xda8: 0x4000, 0xda9: 0x4000, - 0xdaa: 0x4000, 0xdab: 0x4000, 0xdac: 0x4000, 0xdad: 0x4000, 0xdae: 0x4000, 0xdaf: 0x4000, - 0xdb1: 0x403e, 0xdb2: 0x403e, 0xdb3: 0x403e, 0xdb4: 0x403e, 0xdb5: 0x403e, - 0xdb6: 0x403e, 0xdb7: 0x403e, 0xdb8: 0x403e, 0xdb9: 0x403e, 0xdba: 0x403e, 0xdbb: 0x403e, - 0xdbc: 0x403e, 0xdbd: 0x403e, 0xdbe: 0x403e, 0xdbf: 0x403e, - // Block 0x37, offset 0xdc0 - 0xdc0: 0x4037, 0xdc1: 0x4037, 0xdc2: 0x4037, 0xdc3: 0x4037, 0xdc4: 0x4037, 0xdc5: 0x4037, - 0xdc6: 0x4037, 0xdc7: 0x4037, 0xdc8: 0x4037, 0xdc9: 0x4037, 0xdca: 0x4037, 0xdcb: 0x4037, - 0xdcc: 0x4037, 0xdcd: 0x4037, 0xdce: 0x4037, 0xdcf: 0x400e, 0xdd0: 0x403f, 0xdd1: 0x4040, - 0xdd2: 0x4041, 0xdd3: 0x4040, 0xdd4: 0x403f, 0xdd5: 0x4042, 0xdd6: 0x4043, 0xdd7: 0x4044, - 0xdd8: 0x4040, 0xdd9: 0x4041, 0xdda: 0x4040, 0xddb: 0x4045, 0xddc: 0x4009, 0xddd: 0x4045, - 0xdde: 0x4046, 0xddf: 0x4045, 0xde0: 0x4047, 0xde1: 0x400b, 0xde2: 0x400a, 0xde3: 0x400c, - 0xde4: 0x4048, 0xde5: 0x4000, 0xde6: 0x4000, 0xde7: 0x4000, 0xde8: 0x4000, 0xde9: 0x4000, - 0xdea: 0x4000, 0xdeb: 0x4000, 0xdec: 0x4000, 0xded: 0x4000, 0xdee: 0x4000, 0xdef: 0x4000, - 0xdf0: 0x4000, 0xdf1: 0x4000, 0xdf2: 0x4000, 0xdf3: 0x4000, 0xdf4: 0x4000, 0xdf5: 0x4000, - 0xdf6: 0x4000, 0xdf7: 0x4000, 0xdf8: 0x4000, 0xdf9: 0x4000, 0xdfa: 0x4000, 0xdfb: 0x4000, - 0xdfc: 0x4000, 0xdfd: 0x4000, 0xdfe: 0x4000, 0xdff: 0x4000, - // Block 0x38, offset 0xe00 - 0xe00: 0x4000, 0xe01: 0x4000, 0xe02: 0x4000, 0xe03: 0x4000, 0xe04: 0x4000, 0xe05: 0x4000, - 0xe06: 0x4000, 0xe07: 0x4000, 0xe08: 0x4000, 0xe09: 0x4000, 0xe0a: 0x4000, 0xe0b: 0x4000, - 0xe0c: 0x4000, 0xe0d: 0x4000, 0xe0e: 0x4000, 0xe10: 0x4000, 0xe11: 0x4000, - 0xe12: 0x4000, 0xe13: 0x4000, 0xe14: 0x4000, 0xe15: 0x4000, 0xe16: 0x4000, 0xe17: 0x4000, - 0xe18: 0x4000, 0xe19: 0x4000, 0xe1a: 0x4000, 0xe1b: 0x4000, 0xe1c: 0x4000, 0xe1d: 0x4000, - 0xe1e: 0x4000, 0xe1f: 0x4000, 0xe20: 0x4000, 0xe21: 0x4000, 0xe22: 0x4000, 0xe23: 0x4000, - 0xe24: 0x4000, 0xe25: 0x4000, 0xe26: 0x4000, 0xe27: 0x4000, 0xe28: 0x4000, 0xe29: 0x4000, - 0xe2a: 0x4000, 0xe2b: 0x4000, 0xe2c: 0x4000, 0xe2d: 0x4000, 0xe2e: 0x4000, 0xe2f: 0x4000, - 0xe30: 0x4000, 0xe31: 0x4000, 0xe32: 0x4000, 0xe33: 0x4000, 0xe34: 0x4000, 0xe35: 0x4000, - 0xe36: 0x4000, 0xe37: 0x4000, 0xe38: 0x4000, 0xe39: 0x4000, 0xe3a: 0x4000, 0xe3b: 0x4000, - 0xe3c: 0x4000, 0xe3d: 0x4000, 0xe3e: 0x4000, 0xe3f: 0x4000, - // Block 0x39, offset 0xe40 - 0xe40: 0x4000, 0xe41: 0x4000, 0xe42: 0x4000, 0xe43: 0x4000, 0xe44: 0x4000, 0xe45: 0x4000, - 0xe46: 0x4000, 0xe47: 0x4000, 0xe48: 0x4000, 0xe49: 0x4000, 0xe4a: 0x4000, 0xe4b: 0x4000, - 0xe4c: 0x4000, 0xe4d: 0x4000, 0xe4e: 0x4000, 0xe4f: 0x4000, 0xe50: 0x4000, 0xe51: 0x4000, - 0xe52: 0x4000, 0xe53: 0x4000, 0xe54: 0x4000, 0xe55: 0x4000, 0xe56: 0x4000, 0xe57: 0x4000, - 0xe58: 0x4000, 0xe59: 0x4000, 0xe5a: 0x4000, 0xe5b: 0x4000, 0xe5c: 0x4000, 0xe5d: 0x4000, - 0xe5e: 0x4000, 0xe5f: 0x4000, 0xe60: 0x4000, 0xe61: 0x4000, 0xe62: 0x4000, 0xe63: 0x4000, - 0xe70: 0x4000, 0xe71: 0x4000, 0xe72: 0x4000, 0xe73: 0x4000, 0xe74: 0x4000, 0xe75: 0x4000, - 0xe76: 0x4000, 0xe77: 0x4000, 0xe78: 0x4000, 0xe79: 0x4000, 0xe7a: 0x4000, 0xe7b: 0x4000, - 0xe7c: 0x4000, 0xe7d: 0x4000, 0xe7e: 0x4000, 0xe7f: 0x4000, - // Block 0x3a, offset 0xe80 - 0xe80: 0x4000, 0xe81: 0x4000, 0xe82: 0x4000, 0xe83: 0x4000, 0xe84: 0x4000, 0xe85: 0x4000, - 0xe86: 0x4000, 0xe87: 0x4000, 0xe88: 0x4000, 0xe89: 0x4000, 0xe8a: 0x4000, 0xe8b: 0x4000, - 0xe8c: 0x4000, 0xe8d: 0x4000, 0xe8e: 0x4000, 0xe8f: 0x4000, 0xe90: 0x4000, 0xe91: 0x4000, - 0xe92: 0x4000, 0xe93: 0x4000, 0xe94: 0x4000, 0xe95: 0x4000, 0xe96: 0x4000, 0xe97: 0x4000, - 0xe98: 0x4000, 0xe99: 0x4000, 0xe9a: 0x4000, 0xe9b: 0x4000, 0xe9c: 0x4000, 0xe9d: 0x4000, - 0xe9e: 0x4000, 0xea0: 0x4000, 0xea1: 0x4000, 0xea2: 0x4000, 0xea3: 0x4000, - 0xea4: 0x4000, 0xea5: 0x4000, 0xea6: 0x4000, 0xea7: 0x4000, 0xea8: 0x4000, 0xea9: 0x4000, - 0xeaa: 0x4000, 0xeab: 0x4000, 0xeac: 0x4000, 0xead: 0x4000, 0xeae: 0x4000, 0xeaf: 0x4000, - 0xeb0: 0x4000, 0xeb1: 0x4000, 0xeb2: 0x4000, 0xeb3: 0x4000, 0xeb4: 0x4000, 0xeb5: 0x4000, - 0xeb6: 0x4000, 0xeb7: 0x4000, 0xeb8: 0x4000, 0xeb9: 0x4000, 0xeba: 0x4000, 0xebb: 0x4000, - 0xebc: 0x4000, 0xebd: 0x4000, 0xebe: 0x4000, 0xebf: 0x4000, - // Block 0x3b, offset 0xec0 - 0xec0: 0x4000, 0xec1: 0x4000, 0xec2: 0x4000, 0xec3: 0x4000, 0xec4: 0x4000, 0xec5: 0x4000, - 0xec6: 0x4000, 0xec7: 0x4000, 0xec8: 0x2000, 0xec9: 0x2000, 0xeca: 0x2000, 0xecb: 0x2000, - 0xecc: 0x2000, 0xecd: 0x2000, 0xece: 0x2000, 0xecf: 0x2000, 0xed0: 0x4000, 0xed1: 0x4000, - 0xed2: 0x4000, 0xed3: 0x4000, 0xed4: 0x4000, 0xed5: 0x4000, 0xed6: 0x4000, 0xed7: 0x4000, - 0xed8: 0x4000, 0xed9: 0x4000, 0xeda: 0x4000, 0xedb: 0x4000, 0xedc: 0x4000, 0xedd: 0x4000, - 0xede: 0x4000, 0xedf: 0x4000, 0xee0: 0x4000, 0xee1: 0x4000, 0xee2: 0x4000, 0xee3: 0x4000, - 0xee4: 0x4000, 0xee5: 0x4000, 0xee6: 0x4000, 0xee7: 0x4000, 0xee8: 0x4000, 0xee9: 0x4000, - 0xeea: 0x4000, 0xeeb: 0x4000, 0xeec: 0x4000, 0xeed: 0x4000, 0xeee: 0x4000, 0xeef: 0x4000, - 0xef0: 0x4000, 0xef1: 0x4000, 0xef2: 0x4000, 0xef3: 0x4000, 0xef4: 0x4000, 0xef5: 0x4000, - 0xef6: 0x4000, 0xef7: 0x4000, 0xef8: 0x4000, 0xef9: 0x4000, 0xefa: 0x4000, 0xefb: 0x4000, - 0xefc: 0x4000, 0xefd: 0x4000, 0xefe: 0x4000, 0xeff: 0x4000, - // Block 0x3c, offset 0xf00 - 0xf00: 0x4000, 0xf01: 0x4000, 0xf02: 0x4000, 0xf03: 0x4000, 0xf04: 0x4000, 0xf05: 0x4000, - 0xf06: 0x4000, 0xf07: 0x4000, 0xf08: 0x4000, 0xf09: 0x4000, 0xf0a: 0x4000, 0xf0b: 0x4000, - 0xf0c: 0x4000, 0xf10: 0x4000, 0xf11: 0x4000, - 0xf12: 0x4000, 0xf13: 0x4000, 0xf14: 0x4000, 0xf15: 0x4000, 0xf16: 0x4000, 0xf17: 0x4000, - 0xf18: 0x4000, 0xf19: 0x4000, 0xf1a: 0x4000, 0xf1b: 0x4000, 0xf1c: 0x4000, 0xf1d: 0x4000, - 0xf1e: 0x4000, 0xf1f: 0x4000, 0xf20: 0x4000, 0xf21: 0x4000, 0xf22: 0x4000, 0xf23: 0x4000, - 0xf24: 0x4000, 0xf25: 0x4000, 0xf26: 0x4000, 0xf27: 0x4000, 0xf28: 0x4000, 0xf29: 0x4000, - 0xf2a: 0x4000, 0xf2b: 0x4000, 0xf2c: 0x4000, 0xf2d: 0x4000, 0xf2e: 0x4000, 0xf2f: 0x4000, - 0xf30: 0x4000, 0xf31: 0x4000, 0xf32: 0x4000, 0xf33: 0x4000, 0xf34: 0x4000, 0xf35: 0x4000, - 0xf36: 0x4000, 0xf37: 0x4000, 0xf38: 0x4000, 0xf39: 0x4000, 0xf3a: 0x4000, 0xf3b: 0x4000, - 0xf3c: 0x4000, 0xf3d: 0x4000, 0xf3e: 0x4000, 0xf3f: 0x4000, - // Block 0x3d, offset 0xf40 - 0xf40: 0x4000, 0xf41: 0x4000, 0xf42: 0x4000, 0xf43: 0x4000, 0xf44: 0x4000, 0xf45: 0x4000, - 0xf46: 0x4000, - // Block 0x3e, offset 0xf80 - 0xfa0: 0x4000, 0xfa1: 0x4000, 0xfa2: 0x4000, 0xfa3: 0x4000, - 0xfa4: 0x4000, 0xfa5: 0x4000, 0xfa6: 0x4000, 0xfa7: 0x4000, 0xfa8: 0x4000, 0xfa9: 0x4000, - 0xfaa: 0x4000, 0xfab: 0x4000, 0xfac: 0x4000, 0xfad: 0x4000, 0xfae: 0x4000, 0xfaf: 0x4000, - 0xfb0: 0x4000, 0xfb1: 0x4000, 0xfb2: 0x4000, 0xfb3: 0x4000, 0xfb4: 0x4000, 0xfb5: 0x4000, - 0xfb6: 0x4000, 0xfb7: 0x4000, 0xfb8: 0x4000, 0xfb9: 0x4000, 0xfba: 0x4000, 0xfbb: 0x4000, - 0xfbc: 0x4000, - // Block 0x3f, offset 0xfc0 - 0xfc0: 0x4000, 0xfc1: 0x4000, 0xfc2: 0x4000, 0xfc3: 0x4000, 0xfc4: 0x4000, 0xfc5: 0x4000, - 0xfc6: 0x4000, 0xfc7: 0x4000, 0xfc8: 0x4000, 0xfc9: 0x4000, 0xfca: 0x4000, 0xfcb: 0x4000, - 0xfcc: 0x4000, 0xfcd: 0x4000, 0xfce: 0x4000, 0xfcf: 0x4000, 0xfd0: 0x4000, 0xfd1: 0x4000, - 0xfd2: 0x4000, 0xfd3: 0x4000, 0xfd4: 0x4000, 0xfd5: 0x4000, 0xfd6: 0x4000, 0xfd7: 0x4000, - 0xfd8: 0x4000, 0xfd9: 0x4000, 0xfda: 0x4000, 0xfdb: 0x4000, 0xfdc: 0x4000, 0xfdd: 0x4000, - 0xfde: 0x4000, 0xfdf: 0x4000, 0xfe0: 0x4000, 0xfe1: 0x4000, 0xfe2: 0x4000, 0xfe3: 0x4000, - // Block 0x40, offset 0x1000 - 0x1000: 0x2000, 0x1001: 0x2000, 0x1002: 0x2000, 0x1003: 0x2000, 0x1004: 0x2000, 0x1005: 0x2000, - 0x1006: 0x2000, 0x1007: 0x2000, 0x1008: 0x2000, 0x1009: 0x2000, 0x100a: 0x2000, 0x100b: 0x2000, - 0x100c: 0x2000, 0x100d: 0x2000, 0x100e: 0x2000, 0x100f: 0x2000, 0x1010: 0x4000, 0x1011: 0x4000, - 0x1012: 0x4000, 0x1013: 0x4000, 0x1014: 0x4000, 0x1015: 0x4000, 0x1016: 0x4000, 0x1017: 0x4000, - 0x1018: 0x4000, 0x1019: 0x4000, - 0x1030: 0x4000, 0x1031: 0x4000, 0x1032: 0x4000, 0x1033: 0x4000, 0x1034: 0x4000, 0x1035: 0x4000, - 0x1036: 0x4000, 0x1037: 0x4000, 0x1038: 0x4000, 0x1039: 0x4000, 0x103a: 0x4000, 0x103b: 0x4000, - 0x103c: 0x4000, 0x103d: 0x4000, 0x103e: 0x4000, 0x103f: 0x4000, - // Block 0x41, offset 0x1040 - 0x1040: 0x4000, 0x1041: 0x4000, 0x1042: 0x4000, 0x1043: 0x4000, 0x1044: 0x4000, 0x1045: 0x4000, - 0x1046: 0x4000, 0x1047: 0x4000, 0x1048: 0x4000, 0x1049: 0x4000, 0x104a: 0x4000, 0x104b: 0x4000, - 0x104c: 0x4000, 0x104d: 0x4000, 0x104e: 0x4000, 0x104f: 0x4000, 0x1050: 0x4000, 0x1051: 0x4000, - 0x1052: 0x4000, 0x1054: 0x4000, 0x1055: 0x4000, 0x1056: 0x4000, 0x1057: 0x4000, - 0x1058: 0x4000, 0x1059: 0x4000, 0x105a: 0x4000, 0x105b: 0x4000, 0x105c: 0x4000, 0x105d: 0x4000, - 0x105e: 0x4000, 0x105f: 0x4000, 0x1060: 0x4000, 0x1061: 0x4000, 0x1062: 0x4000, 0x1063: 0x4000, - 0x1064: 0x4000, 0x1065: 0x4000, 0x1066: 0x4000, 0x1068: 0x4000, 0x1069: 0x4000, - 0x106a: 0x4000, 0x106b: 0x4000, - // Block 0x42, offset 0x1080 - 0x1081: 0x9012, 0x1082: 0x9012, 0x1083: 0x9012, 0x1084: 0x9012, 0x1085: 0x9012, - 0x1086: 0x9012, 0x1087: 0x9012, 0x1088: 0x9012, 0x1089: 0x9012, 0x108a: 0x9012, 0x108b: 0x9012, - 0x108c: 0x9012, 0x108d: 0x9012, 0x108e: 0x9012, 0x108f: 0x9012, 0x1090: 0x9012, 0x1091: 0x9012, - 0x1092: 0x9012, 0x1093: 0x9012, 0x1094: 0x9012, 0x1095: 0x9012, 0x1096: 0x9012, 0x1097: 0x9012, - 0x1098: 0x9012, 0x1099: 0x9012, 0x109a: 0x9012, 0x109b: 0x9012, 0x109c: 0x9012, 0x109d: 0x9012, - 0x109e: 0x9012, 0x109f: 0x9012, 0x10a0: 0x9049, 0x10a1: 0x9049, 0x10a2: 0x9049, 0x10a3: 0x9049, - 0x10a4: 0x9049, 0x10a5: 0x9049, 0x10a6: 0x9049, 0x10a7: 0x9049, 0x10a8: 0x9049, 0x10a9: 0x9049, - 0x10aa: 0x9049, 0x10ab: 0x9049, 0x10ac: 0x9049, 0x10ad: 0x9049, 0x10ae: 0x9049, 0x10af: 0x9049, - 0x10b0: 0x9049, 0x10b1: 0x9049, 0x10b2: 0x9049, 0x10b3: 0x9049, 0x10b4: 0x9049, 0x10b5: 0x9049, - 0x10b6: 0x9049, 0x10b7: 0x9049, 0x10b8: 0x9049, 0x10b9: 0x9049, 0x10ba: 0x9049, 0x10bb: 0x9049, - 0x10bc: 0x9049, 0x10bd: 0x9049, 0x10be: 0x9049, 0x10bf: 0x9049, - // Block 0x43, offset 0x10c0 - 0x10c0: 0x9049, 0x10c1: 0x9049, 0x10c2: 0x9049, 0x10c3: 0x9049, 0x10c4: 0x9049, 0x10c5: 0x9049, - 0x10c6: 0x9049, 0x10c7: 0x9049, 0x10c8: 0x9049, 0x10c9: 0x9049, 0x10ca: 0x9049, 0x10cb: 0x9049, - 0x10cc: 0x9049, 0x10cd: 0x9049, 0x10ce: 0x9049, 0x10cf: 0x9049, 0x10d0: 0x9049, 0x10d1: 0x9049, - 0x10d2: 0x9049, 0x10d3: 0x9049, 0x10d4: 0x9049, 0x10d5: 0x9049, 0x10d6: 0x9049, 0x10d7: 0x9049, - 0x10d8: 0x9049, 0x10d9: 0x9049, 0x10da: 0x9049, 0x10db: 0x9049, 0x10dc: 0x9049, 0x10dd: 0x9049, - 0x10de: 0x9049, 0x10df: 0x904a, 0x10e0: 0x904b, 0x10e1: 0xb04c, 0x10e2: 0xb04d, 0x10e3: 0xb04d, - 0x10e4: 0xb04e, 0x10e5: 0xb04f, 0x10e6: 0xb050, 0x10e7: 0xb051, 0x10e8: 0xb052, 0x10e9: 0xb053, - 0x10ea: 0xb054, 0x10eb: 0xb055, 0x10ec: 0xb056, 0x10ed: 0xb057, 0x10ee: 0xb058, 0x10ef: 0xb059, - 0x10f0: 0xb05a, 0x10f1: 0xb05b, 0x10f2: 0xb05c, 0x10f3: 0xb05d, 0x10f4: 0xb05e, 0x10f5: 0xb05f, - 0x10f6: 0xb060, 0x10f7: 0xb061, 0x10f8: 0xb062, 0x10f9: 0xb063, 0x10fa: 0xb064, 0x10fb: 0xb065, - 0x10fc: 0xb052, 0x10fd: 0xb066, 0x10fe: 0xb067, 0x10ff: 0xb055, - // Block 0x44, offset 0x1100 - 0x1100: 0xb068, 0x1101: 0xb069, 0x1102: 0xb06a, 0x1103: 0xb06b, 0x1104: 0xb05a, 0x1105: 0xb056, - 0x1106: 0xb06c, 0x1107: 0xb06d, 0x1108: 0xb06b, 0x1109: 0xb06e, 0x110a: 0xb06b, 0x110b: 0xb06f, - 0x110c: 0xb06f, 0x110d: 0xb070, 0x110e: 0xb070, 0x110f: 0xb071, 0x1110: 0xb056, 0x1111: 0xb072, - 0x1112: 0xb073, 0x1113: 0xb072, 0x1114: 0xb074, 0x1115: 0xb073, 0x1116: 0xb075, 0x1117: 0xb075, - 0x1118: 0xb076, 0x1119: 0xb076, 0x111a: 0xb077, 0x111b: 0xb077, 0x111c: 0xb073, 0x111d: 0xb078, - 0x111e: 0xb079, 0x111f: 0xb067, 0x1120: 0xb07a, 0x1121: 0xb07b, 0x1122: 0xb07b, 0x1123: 0xb07b, - 0x1124: 0xb07b, 0x1125: 0xb07b, 0x1126: 0xb07b, 0x1127: 0xb07b, 0x1128: 0xb07b, 0x1129: 0xb07b, - 0x112a: 0xb07b, 0x112b: 0xb07b, 0x112c: 0xb07b, 0x112d: 0xb07b, 0x112e: 0xb07b, 0x112f: 0xb07b, - 0x1130: 0xb07c, 0x1131: 0xb07c, 0x1132: 0xb07c, 0x1133: 0xb07c, 0x1134: 0xb07c, 0x1135: 0xb07c, - 0x1136: 0xb07c, 0x1137: 0xb07c, 0x1138: 0xb07c, 0x1139: 0xb07c, 0x113a: 0xb07c, 0x113b: 0xb07c, - 0x113c: 0xb07c, 0x113d: 0xb07c, 0x113e: 0xb07c, - // Block 0x45, offset 0x1140 - 0x1142: 0xb07d, 0x1143: 0xb07e, 0x1144: 0xb07f, 0x1145: 0xb080, - 0x1146: 0xb07f, 0x1147: 0xb07e, 0x114a: 0xb081, 0x114b: 0xb082, - 0x114c: 0xb083, 0x114d: 0xb07f, 0x114e: 0xb080, 0x114f: 0xb07f, - 0x1152: 0xb084, 0x1153: 0xb085, 0x1154: 0xb084, 0x1155: 0xb086, 0x1156: 0xb084, 0x1157: 0xb087, - 0x115a: 0xb088, 0x115b: 0xb089, 0x115c: 0xb08a, - 0x1160: 0x908b, 0x1161: 0x908b, 0x1162: 0x908c, 0x1163: 0x908d, - 0x1164: 0x908b, 0x1165: 0x908e, 0x1166: 0x908f, 0x1168: 0xb090, 0x1169: 0xb091, - 0x116a: 0xb092, 0x116b: 0xb091, 0x116c: 0xb093, 0x116d: 0xb094, 0x116e: 0xb095, - 0x117d: 0x2000, - // Block 0x46, offset 0x1180 - 0x11a0: 0x4000, 0x11a1: 0x4000, 0x11a2: 0x4000, 0x11a3: 0x4000, - 0x11a4: 0x4000, - 0x11b0: 0x4000, 0x11b1: 0x4000, - // Block 0x47, offset 0x11c0 - 0x11c0: 0x4000, 0x11c1: 0x4000, 0x11c2: 0x4000, 0x11c3: 0x4000, 0x11c4: 0x4000, 0x11c5: 0x4000, - 0x11c6: 0x4000, 0x11c7: 0x4000, 0x11c8: 0x4000, 0x11c9: 0x4000, 0x11ca: 0x4000, 0x11cb: 0x4000, - 0x11cc: 0x4000, 0x11cd: 0x4000, 0x11ce: 0x4000, 0x11cf: 0x4000, 0x11d0: 0x4000, 0x11d1: 0x4000, - 0x11d2: 0x4000, 0x11d3: 0x4000, 0x11d4: 0x4000, 0x11d5: 0x4000, 0x11d6: 0x4000, 0x11d7: 0x4000, - 0x11d8: 0x4000, 0x11d9: 0x4000, 0x11da: 0x4000, 0x11db: 0x4000, 0x11dc: 0x4000, 0x11dd: 0x4000, - 0x11de: 0x4000, 0x11df: 0x4000, 0x11e0: 0x4000, 0x11e1: 0x4000, 0x11e2: 0x4000, 0x11e3: 0x4000, - 0x11e4: 0x4000, 0x11e5: 0x4000, 0x11e6: 0x4000, 0x11e7: 0x4000, 0x11e8: 0x4000, 0x11e9: 0x4000, - 0x11ea: 0x4000, 0x11eb: 0x4000, 0x11ec: 0x4000, 0x11ed: 0x4000, 0x11ee: 0x4000, 0x11ef: 0x4000, - 0x11f0: 0x4000, 0x11f1: 0x4000, 0x11f2: 0x4000, 0x11f3: 0x4000, 0x11f4: 0x4000, 0x11f5: 0x4000, - 0x11f6: 0x4000, 0x11f7: 0x4000, - // Block 0x48, offset 0x1200 - 0x1200: 0x4000, 0x1201: 0x4000, 0x1202: 0x4000, 0x1203: 0x4000, 0x1204: 0x4000, 0x1205: 0x4000, - 0x1206: 0x4000, 0x1207: 0x4000, 0x1208: 0x4000, 0x1209: 0x4000, 0x120a: 0x4000, 0x120b: 0x4000, - 0x120c: 0x4000, 0x120d: 0x4000, 0x120e: 0x4000, 0x120f: 0x4000, 0x1210: 0x4000, 0x1211: 0x4000, - 0x1212: 0x4000, 0x1213: 0x4000, 0x1214: 0x4000, 0x1215: 0x4000, - // Block 0x49, offset 0x1240 - 0x1240: 0x4000, 0x1241: 0x4000, 0x1242: 0x4000, 0x1243: 0x4000, 0x1244: 0x4000, 0x1245: 0x4000, - 0x1246: 0x4000, 0x1247: 0x4000, 0x1248: 0x4000, - // Block 0x4a, offset 0x1280 - 0x12b0: 0x4000, 0x12b1: 0x4000, 0x12b2: 0x4000, 0x12b3: 0x4000, 0x12b5: 0x4000, - 0x12b6: 0x4000, 0x12b7: 0x4000, 0x12b8: 0x4000, 0x12b9: 0x4000, 0x12ba: 0x4000, 0x12bb: 0x4000, - 0x12bd: 0x4000, 0x12be: 0x4000, - // Block 0x4b, offset 0x12c0 - 0x12c0: 0x4000, 0x12c1: 0x4000, 0x12c2: 0x4000, 0x12c3: 0x4000, 0x12c4: 0x4000, 0x12c5: 0x4000, - 0x12c6: 0x4000, 0x12c7: 0x4000, 0x12c8: 0x4000, 0x12c9: 0x4000, 0x12ca: 0x4000, 0x12cb: 0x4000, - 0x12cc: 0x4000, 0x12cd: 0x4000, 0x12ce: 0x4000, 0x12cf: 0x4000, 0x12d0: 0x4000, 0x12d1: 0x4000, - 0x12d2: 0x4000, 0x12d3: 0x4000, 0x12d4: 0x4000, 0x12d5: 0x4000, 0x12d6: 0x4000, 0x12d7: 0x4000, - 0x12d8: 0x4000, 0x12d9: 0x4000, 0x12da: 0x4000, 0x12db: 0x4000, 0x12dc: 0x4000, 0x12dd: 0x4000, - 0x12de: 0x4000, 0x12df: 0x4000, 0x12e0: 0x4000, 0x12e1: 0x4000, 0x12e2: 0x4000, - 0x12f2: 0x4000, - // Block 0x4c, offset 0x1300 - 0x1310: 0x4000, 0x1311: 0x4000, - 0x1312: 0x4000, 0x1315: 0x4000, - 0x1324: 0x4000, 0x1325: 0x4000, 0x1326: 0x4000, 0x1327: 0x4000, - 0x1330: 0x4000, 0x1331: 0x4000, 0x1332: 0x4000, 0x1333: 0x4000, 0x1334: 0x4000, 0x1335: 0x4000, - 0x1336: 0x4000, 0x1337: 0x4000, 0x1338: 0x4000, 0x1339: 0x4000, 0x133a: 0x4000, 0x133b: 0x4000, - 0x133c: 0x4000, 0x133d: 0x4000, 0x133e: 0x4000, 0x133f: 0x4000, - // Block 0x4d, offset 0x1340 - 0x1340: 0x4000, 0x1341: 0x4000, 0x1342: 0x4000, 0x1343: 0x4000, 0x1344: 0x4000, 0x1345: 0x4000, - 0x1346: 0x4000, 0x1347: 0x4000, 0x1348: 0x4000, 0x1349: 0x4000, 0x134a: 0x4000, 0x134b: 0x4000, - 0x134c: 0x4000, 0x134d: 0x4000, 0x134e: 0x4000, 0x134f: 0x4000, 0x1350: 0x4000, 0x1351: 0x4000, - 0x1352: 0x4000, 0x1353: 0x4000, 0x1354: 0x4000, 0x1355: 0x4000, 0x1356: 0x4000, 0x1357: 0x4000, - 0x1358: 0x4000, 0x1359: 0x4000, 0x135a: 0x4000, 0x135b: 0x4000, 0x135c: 0x4000, 0x135d: 0x4000, - 0x135e: 0x4000, 0x135f: 0x4000, 0x1360: 0x4000, 0x1361: 0x4000, 0x1362: 0x4000, 0x1363: 0x4000, - 0x1364: 0x4000, 0x1365: 0x4000, 0x1366: 0x4000, 0x1367: 0x4000, 0x1368: 0x4000, 0x1369: 0x4000, - 0x136a: 0x4000, 0x136b: 0x4000, 0x136c: 0x4000, 0x136d: 0x4000, 0x136e: 0x4000, 0x136f: 0x4000, - 0x1370: 0x4000, 0x1371: 0x4000, 0x1372: 0x4000, 0x1373: 0x4000, 0x1374: 0x4000, 0x1375: 0x4000, - 0x1376: 0x4000, 0x1377: 0x4000, 0x1378: 0x4000, 0x1379: 0x4000, 0x137a: 0x4000, 0x137b: 0x4000, - // Block 0x4e, offset 0x1380 - 0x1384: 0x4000, - // Block 0x4f, offset 0x13c0 - 0x13cf: 0x4000, - // Block 0x50, offset 0x1400 - 0x1400: 0x2000, 0x1401: 0x2000, 0x1402: 0x2000, 0x1403: 0x2000, 0x1404: 0x2000, 0x1405: 0x2000, - 0x1406: 0x2000, 0x1407: 0x2000, 0x1408: 0x2000, 0x1409: 0x2000, 0x140a: 0x2000, - 0x1410: 0x2000, 0x1411: 0x2000, - 0x1412: 0x2000, 0x1413: 0x2000, 0x1414: 0x2000, 0x1415: 0x2000, 0x1416: 0x2000, 0x1417: 0x2000, - 0x1418: 0x2000, 0x1419: 0x2000, 0x141a: 0x2000, 0x141b: 0x2000, 0x141c: 0x2000, 0x141d: 0x2000, - 0x141e: 0x2000, 0x141f: 0x2000, 0x1420: 0x2000, 0x1421: 0x2000, 0x1422: 0x2000, 0x1423: 0x2000, - 0x1424: 0x2000, 0x1425: 0x2000, 0x1426: 0x2000, 0x1427: 0x2000, 0x1428: 0x2000, 0x1429: 0x2000, - 0x142a: 0x2000, 0x142b: 0x2000, 0x142c: 0x2000, 0x142d: 0x2000, - 0x1430: 0x2000, 0x1431: 0x2000, 0x1432: 0x2000, 0x1433: 0x2000, 0x1434: 0x2000, 0x1435: 0x2000, - 0x1436: 0x2000, 0x1437: 0x2000, 0x1438: 0x2000, 0x1439: 0x2000, 0x143a: 0x2000, 0x143b: 0x2000, - 0x143c: 0x2000, 0x143d: 0x2000, 0x143e: 0x2000, 0x143f: 0x2000, - // Block 0x51, offset 0x1440 - 0x1440: 0x2000, 0x1441: 0x2000, 0x1442: 0x2000, 0x1443: 0x2000, 0x1444: 0x2000, 0x1445: 0x2000, - 0x1446: 0x2000, 0x1447: 0x2000, 0x1448: 0x2000, 0x1449: 0x2000, 0x144a: 0x2000, 0x144b: 0x2000, - 0x144c: 0x2000, 0x144d: 0x2000, 0x144e: 0x2000, 0x144f: 0x2000, 0x1450: 0x2000, 0x1451: 0x2000, - 0x1452: 0x2000, 0x1453: 0x2000, 0x1454: 0x2000, 0x1455: 0x2000, 0x1456: 0x2000, 0x1457: 0x2000, - 0x1458: 0x2000, 0x1459: 0x2000, 0x145a: 0x2000, 0x145b: 0x2000, 0x145c: 0x2000, 0x145d: 0x2000, - 0x145e: 0x2000, 0x145f: 0x2000, 0x1460: 0x2000, 0x1461: 0x2000, 0x1462: 0x2000, 0x1463: 0x2000, - 0x1464: 0x2000, 0x1465: 0x2000, 0x1466: 0x2000, 0x1467: 0x2000, 0x1468: 0x2000, 0x1469: 0x2000, - 0x1470: 0x2000, 0x1471: 0x2000, 0x1472: 0x2000, 0x1473: 0x2000, 0x1474: 0x2000, 0x1475: 0x2000, - 0x1476: 0x2000, 0x1477: 0x2000, 0x1478: 0x2000, 0x1479: 0x2000, 0x147a: 0x2000, 0x147b: 0x2000, - 0x147c: 0x2000, 0x147d: 0x2000, 0x147e: 0x2000, 0x147f: 0x2000, - // Block 0x52, offset 0x1480 - 0x1480: 0x2000, 0x1481: 0x2000, 0x1482: 0x2000, 0x1483: 0x2000, 0x1484: 0x2000, 0x1485: 0x2000, - 0x1486: 0x2000, 0x1487: 0x2000, 0x1488: 0x2000, 0x1489: 0x2000, 0x148a: 0x2000, 0x148b: 0x2000, - 0x148c: 0x2000, 0x148d: 0x2000, 0x148e: 0x4000, 0x148f: 0x2000, 0x1490: 0x2000, 0x1491: 0x4000, - 0x1492: 0x4000, 0x1493: 0x4000, 0x1494: 0x4000, 0x1495: 0x4000, 0x1496: 0x4000, 0x1497: 0x4000, - 0x1498: 0x4000, 0x1499: 0x4000, 0x149a: 0x4000, 0x149b: 0x2000, 0x149c: 0x2000, 0x149d: 0x2000, - 0x149e: 0x2000, 0x149f: 0x2000, 0x14a0: 0x2000, 0x14a1: 0x2000, 0x14a2: 0x2000, 0x14a3: 0x2000, - 0x14a4: 0x2000, 0x14a5: 0x2000, 0x14a6: 0x2000, 0x14a7: 0x2000, 0x14a8: 0x2000, 0x14a9: 0x2000, - 0x14aa: 0x2000, 0x14ab: 0x2000, 0x14ac: 0x2000, - // Block 0x53, offset 0x14c0 - 0x14c0: 0x4000, 0x14c1: 0x4000, 0x14c2: 0x4000, - 0x14d0: 0x4000, 0x14d1: 0x4000, - 0x14d2: 0x4000, 0x14d3: 0x4000, 0x14d4: 0x4000, 0x14d5: 0x4000, 0x14d6: 0x4000, 0x14d7: 0x4000, - 0x14d8: 0x4000, 0x14d9: 0x4000, 0x14da: 0x4000, 0x14db: 0x4000, 0x14dc: 0x4000, 0x14dd: 0x4000, - 0x14de: 0x4000, 0x14df: 0x4000, 0x14e0: 0x4000, 0x14e1: 0x4000, 0x14e2: 0x4000, 0x14e3: 0x4000, - 0x14e4: 0x4000, 0x14e5: 0x4000, 0x14e6: 0x4000, 0x14e7: 0x4000, 0x14e8: 0x4000, 0x14e9: 0x4000, - 0x14ea: 0x4000, 0x14eb: 0x4000, 0x14ec: 0x4000, 0x14ed: 0x4000, 0x14ee: 0x4000, 0x14ef: 0x4000, - 0x14f0: 0x4000, 0x14f1: 0x4000, 0x14f2: 0x4000, 0x14f3: 0x4000, 0x14f4: 0x4000, 0x14f5: 0x4000, - 0x14f6: 0x4000, 0x14f7: 0x4000, 0x14f8: 0x4000, 0x14f9: 0x4000, 0x14fa: 0x4000, 0x14fb: 0x4000, - // Block 0x54, offset 0x1500 - 0x1500: 0x4000, 0x1501: 0x4000, 0x1502: 0x4000, 0x1503: 0x4000, 0x1504: 0x4000, 0x1505: 0x4000, - 0x1506: 0x4000, 0x1507: 0x4000, 0x1508: 0x4000, - 0x1510: 0x4000, 0x1511: 0x4000, - 0x1520: 0x4000, 0x1521: 0x4000, 0x1522: 0x4000, 0x1523: 0x4000, - 0x1524: 0x4000, 0x1525: 0x4000, - // Block 0x55, offset 0x1540 - 0x1540: 0x4000, 0x1541: 0x4000, 0x1542: 0x4000, 0x1543: 0x4000, 0x1544: 0x4000, 0x1545: 0x4000, - 0x1546: 0x4000, 0x1547: 0x4000, 0x1548: 0x4000, 0x1549: 0x4000, 0x154a: 0x4000, 0x154b: 0x4000, - 0x154c: 0x4000, 0x154d: 0x4000, 0x154e: 0x4000, 0x154f: 0x4000, 0x1550: 0x4000, 0x1551: 0x4000, - 0x1552: 0x4000, 0x1553: 0x4000, 0x1554: 0x4000, 0x1555: 0x4000, 0x1556: 0x4000, 0x1557: 0x4000, - 0x1558: 0x4000, 0x1559: 0x4000, 0x155a: 0x4000, 0x155b: 0x4000, 0x155c: 0x4000, 0x155d: 0x4000, - 0x155e: 0x4000, 0x155f: 0x4000, 0x1560: 0x4000, - 0x156d: 0x4000, 0x156e: 0x4000, 0x156f: 0x4000, - 0x1570: 0x4000, 0x1571: 0x4000, 0x1572: 0x4000, 0x1573: 0x4000, 0x1574: 0x4000, 0x1575: 0x4000, - 0x1577: 0x4000, 0x1578: 0x4000, 0x1579: 0x4000, 0x157a: 0x4000, 0x157b: 0x4000, - 0x157c: 0x4000, 0x157d: 0x4000, 0x157e: 0x4000, 0x157f: 0x4000, - // Block 0x56, offset 0x1580 - 0x1580: 0x4000, 0x1581: 0x4000, 0x1582: 0x4000, 0x1583: 0x4000, 0x1584: 0x4000, 0x1585: 0x4000, - 0x1586: 0x4000, 0x1587: 0x4000, 0x1588: 0x4000, 0x1589: 0x4000, 0x158a: 0x4000, 0x158b: 0x4000, - 0x158c: 0x4000, 0x158d: 0x4000, 0x158e: 0x4000, 0x158f: 0x4000, 0x1590: 0x4000, 0x1591: 0x4000, - 0x1592: 0x4000, 0x1593: 0x4000, 0x1594: 0x4000, 0x1595: 0x4000, 0x1596: 0x4000, 0x1597: 0x4000, - 0x1598: 0x4000, 0x1599: 0x4000, 0x159a: 0x4000, 0x159b: 0x4000, 0x159c: 0x4000, 0x159d: 0x4000, - 0x159e: 0x4000, 0x159f: 0x4000, 0x15a0: 0x4000, 0x15a1: 0x4000, 0x15a2: 0x4000, 0x15a3: 0x4000, - 0x15a4: 0x4000, 0x15a5: 0x4000, 0x15a6: 0x4000, 0x15a7: 0x4000, 0x15a8: 0x4000, 0x15a9: 0x4000, - 0x15aa: 0x4000, 0x15ab: 0x4000, 0x15ac: 0x4000, 0x15ad: 0x4000, 0x15ae: 0x4000, 0x15af: 0x4000, - 0x15b0: 0x4000, 0x15b1: 0x4000, 0x15b2: 0x4000, 0x15b3: 0x4000, 0x15b4: 0x4000, 0x15b5: 0x4000, - 0x15b6: 0x4000, 0x15b7: 0x4000, 0x15b8: 0x4000, 0x15b9: 0x4000, 0x15ba: 0x4000, 0x15bb: 0x4000, - 0x15bc: 0x4000, 0x15be: 0x4000, 0x15bf: 0x4000, - // Block 0x57, offset 0x15c0 - 0x15c0: 0x4000, 0x15c1: 0x4000, 0x15c2: 0x4000, 0x15c3: 0x4000, 0x15c4: 0x4000, 0x15c5: 0x4000, - 0x15c6: 0x4000, 0x15c7: 0x4000, 0x15c8: 0x4000, 0x15c9: 0x4000, 0x15ca: 0x4000, 0x15cb: 0x4000, - 0x15cc: 0x4000, 0x15cd: 0x4000, 0x15ce: 0x4000, 0x15cf: 0x4000, 0x15d0: 0x4000, 0x15d1: 0x4000, - 0x15d2: 0x4000, 0x15d3: 0x4000, - 0x15e0: 0x4000, 0x15e1: 0x4000, 0x15e2: 0x4000, 0x15e3: 0x4000, - 0x15e4: 0x4000, 0x15e5: 0x4000, 0x15e6: 0x4000, 0x15e7: 0x4000, 0x15e8: 0x4000, 0x15e9: 0x4000, - 0x15ea: 0x4000, 0x15eb: 0x4000, 0x15ec: 0x4000, 0x15ed: 0x4000, 0x15ee: 0x4000, 0x15ef: 0x4000, - 0x15f0: 0x4000, 0x15f1: 0x4000, 0x15f2: 0x4000, 0x15f3: 0x4000, 0x15f4: 0x4000, 0x15f5: 0x4000, - 0x15f6: 0x4000, 0x15f7: 0x4000, 0x15f8: 0x4000, 0x15f9: 0x4000, 0x15fa: 0x4000, 0x15fb: 0x4000, - 0x15fc: 0x4000, 0x15fd: 0x4000, 0x15fe: 0x4000, 0x15ff: 0x4000, - // Block 0x58, offset 0x1600 - 0x1600: 0x4000, 0x1601: 0x4000, 0x1602: 0x4000, 0x1603: 0x4000, 0x1604: 0x4000, 0x1605: 0x4000, - 0x1606: 0x4000, 0x1607: 0x4000, 0x1608: 0x4000, 0x1609: 0x4000, 0x160a: 0x4000, - 0x160f: 0x4000, 0x1610: 0x4000, 0x1611: 0x4000, - 0x1612: 0x4000, 0x1613: 0x4000, - 0x1620: 0x4000, 0x1621: 0x4000, 0x1622: 0x4000, 0x1623: 0x4000, - 0x1624: 0x4000, 0x1625: 0x4000, 0x1626: 0x4000, 0x1627: 0x4000, 0x1628: 0x4000, 0x1629: 0x4000, - 0x162a: 0x4000, 0x162b: 0x4000, 0x162c: 0x4000, 0x162d: 0x4000, 0x162e: 0x4000, 0x162f: 0x4000, - 0x1630: 0x4000, 0x1634: 0x4000, - 0x1638: 0x4000, 0x1639: 0x4000, 0x163a: 0x4000, 0x163b: 0x4000, - 0x163c: 0x4000, 0x163d: 0x4000, 0x163e: 0x4000, 0x163f: 0x4000, - // Block 0x59, offset 0x1640 - 0x1640: 0x4000, 0x1641: 0x4000, 0x1642: 0x4000, 0x1643: 0x4000, 0x1644: 0x4000, 0x1645: 0x4000, - 0x1646: 0x4000, 0x1647: 0x4000, 0x1648: 0x4000, 0x1649: 0x4000, 0x164a: 0x4000, 0x164b: 0x4000, - 0x164c: 0x4000, 0x164d: 0x4000, 0x164e: 0x4000, 0x164f: 0x4000, 0x1650: 0x4000, 0x1651: 0x4000, - 0x1652: 0x4000, 0x1653: 0x4000, 0x1654: 0x4000, 0x1655: 0x4000, 0x1656: 0x4000, 0x1657: 0x4000, - 0x1658: 0x4000, 0x1659: 0x4000, 0x165a: 0x4000, 0x165b: 0x4000, 0x165c: 0x4000, 0x165d: 0x4000, - 0x165e: 0x4000, 0x165f: 0x4000, 0x1660: 0x4000, 0x1661: 0x4000, 0x1662: 0x4000, 0x1663: 0x4000, - 0x1664: 0x4000, 0x1665: 0x4000, 0x1666: 0x4000, 0x1667: 0x4000, 0x1668: 0x4000, 0x1669: 0x4000, - 0x166a: 0x4000, 0x166b: 0x4000, 0x166c: 0x4000, 0x166d: 0x4000, 0x166e: 0x4000, 0x166f: 0x4000, - 0x1670: 0x4000, 0x1671: 0x4000, 0x1672: 0x4000, 0x1673: 0x4000, 0x1674: 0x4000, 0x1675: 0x4000, - 0x1676: 0x4000, 0x1677: 0x4000, 0x1678: 0x4000, 0x1679: 0x4000, 0x167a: 0x4000, 0x167b: 0x4000, - 0x167c: 0x4000, 0x167d: 0x4000, 0x167e: 0x4000, - // Block 0x5a, offset 0x1680 - 0x1680: 0x4000, 0x1682: 0x4000, 0x1683: 0x4000, 0x1684: 0x4000, 0x1685: 0x4000, - 0x1686: 0x4000, 0x1687: 0x4000, 0x1688: 0x4000, 0x1689: 0x4000, 0x168a: 0x4000, 0x168b: 0x4000, - 0x168c: 0x4000, 0x168d: 0x4000, 0x168e: 0x4000, 0x168f: 0x4000, 0x1690: 0x4000, 0x1691: 0x4000, - 0x1692: 0x4000, 0x1693: 0x4000, 0x1694: 0x4000, 0x1695: 0x4000, 0x1696: 0x4000, 0x1697: 0x4000, - 0x1698: 0x4000, 0x1699: 0x4000, 0x169a: 0x4000, 0x169b: 0x4000, 0x169c: 0x4000, 0x169d: 0x4000, - 0x169e: 0x4000, 0x169f: 0x4000, 0x16a0: 0x4000, 0x16a1: 0x4000, 0x16a2: 0x4000, 0x16a3: 0x4000, - 0x16a4: 0x4000, 0x16a5: 0x4000, 0x16a6: 0x4000, 0x16a7: 0x4000, 0x16a8: 0x4000, 0x16a9: 0x4000, - 0x16aa: 0x4000, 0x16ab: 0x4000, 0x16ac: 0x4000, 0x16ad: 0x4000, 0x16ae: 0x4000, 0x16af: 0x4000, - 0x16b0: 0x4000, 0x16b1: 0x4000, 0x16b2: 0x4000, 0x16b3: 0x4000, 0x16b4: 0x4000, 0x16b5: 0x4000, - 0x16b6: 0x4000, 0x16b7: 0x4000, 0x16b8: 0x4000, 0x16b9: 0x4000, 0x16ba: 0x4000, 0x16bb: 0x4000, - 0x16bc: 0x4000, 0x16bd: 0x4000, 0x16be: 0x4000, 0x16bf: 0x4000, - // Block 0x5b, offset 0x16c0 - 0x16c0: 0x4000, 0x16c1: 0x4000, 0x16c2: 0x4000, 0x16c3: 0x4000, 0x16c4: 0x4000, 0x16c5: 0x4000, - 0x16c6: 0x4000, 0x16c7: 0x4000, 0x16c8: 0x4000, 0x16c9: 0x4000, 0x16ca: 0x4000, 0x16cb: 0x4000, - 0x16cc: 0x4000, 0x16cd: 0x4000, 0x16ce: 0x4000, 0x16cf: 0x4000, 0x16d0: 0x4000, 0x16d1: 0x4000, - 0x16d2: 0x4000, 0x16d3: 0x4000, 0x16d4: 0x4000, 0x16d5: 0x4000, 0x16d6: 0x4000, 0x16d7: 0x4000, - 0x16d8: 0x4000, 0x16d9: 0x4000, 0x16da: 0x4000, 0x16db: 0x4000, 0x16dc: 0x4000, 0x16dd: 0x4000, - 0x16de: 0x4000, 0x16df: 0x4000, 0x16e0: 0x4000, 0x16e1: 0x4000, 0x16e2: 0x4000, 0x16e3: 0x4000, - 0x16e4: 0x4000, 0x16e5: 0x4000, 0x16e6: 0x4000, 0x16e7: 0x4000, 0x16e8: 0x4000, 0x16e9: 0x4000, - 0x16ea: 0x4000, 0x16eb: 0x4000, 0x16ec: 0x4000, 0x16ed: 0x4000, 0x16ee: 0x4000, 0x16ef: 0x4000, - 0x16f0: 0x4000, 0x16f1: 0x4000, 0x16f2: 0x4000, 0x16f3: 0x4000, 0x16f4: 0x4000, 0x16f5: 0x4000, - 0x16f6: 0x4000, 0x16f7: 0x4000, 0x16f8: 0x4000, 0x16f9: 0x4000, 0x16fa: 0x4000, 0x16fb: 0x4000, - 0x16fc: 0x4000, 0x16ff: 0x4000, - // Block 0x5c, offset 0x1700 - 0x1700: 0x4000, 0x1701: 0x4000, 0x1702: 0x4000, 0x1703: 0x4000, 0x1704: 0x4000, 0x1705: 0x4000, - 0x1706: 0x4000, 0x1707: 0x4000, 0x1708: 0x4000, 0x1709: 0x4000, 0x170a: 0x4000, 0x170b: 0x4000, - 0x170c: 0x4000, 0x170d: 0x4000, 0x170e: 0x4000, 0x170f: 0x4000, 0x1710: 0x4000, 0x1711: 0x4000, - 0x1712: 0x4000, 0x1713: 0x4000, 0x1714: 0x4000, 0x1715: 0x4000, 0x1716: 0x4000, 0x1717: 0x4000, - 0x1718: 0x4000, 0x1719: 0x4000, 0x171a: 0x4000, 0x171b: 0x4000, 0x171c: 0x4000, 0x171d: 0x4000, - 0x171e: 0x4000, 0x171f: 0x4000, 0x1720: 0x4000, 0x1721: 0x4000, 0x1722: 0x4000, 0x1723: 0x4000, - 0x1724: 0x4000, 0x1725: 0x4000, 0x1726: 0x4000, 0x1727: 0x4000, 0x1728: 0x4000, 0x1729: 0x4000, - 0x172a: 0x4000, 0x172b: 0x4000, 0x172c: 0x4000, 0x172d: 0x4000, 0x172e: 0x4000, 0x172f: 0x4000, - 0x1730: 0x4000, 0x1731: 0x4000, 0x1732: 0x4000, 0x1733: 0x4000, 0x1734: 0x4000, 0x1735: 0x4000, - 0x1736: 0x4000, 0x1737: 0x4000, 0x1738: 0x4000, 0x1739: 0x4000, 0x173a: 0x4000, 0x173b: 0x4000, - 0x173c: 0x4000, 0x173d: 0x4000, - // Block 0x5d, offset 0x1740 - 0x174b: 0x4000, - 0x174c: 0x4000, 0x174d: 0x4000, 0x174e: 0x4000, 0x1750: 0x4000, 0x1751: 0x4000, - 0x1752: 0x4000, 0x1753: 0x4000, 0x1754: 0x4000, 0x1755: 0x4000, 0x1756: 0x4000, 0x1757: 0x4000, - 0x1758: 0x4000, 0x1759: 0x4000, 0x175a: 0x4000, 0x175b: 0x4000, 0x175c: 0x4000, 0x175d: 0x4000, - 0x175e: 0x4000, 0x175f: 0x4000, 0x1760: 0x4000, 0x1761: 0x4000, 0x1762: 0x4000, 0x1763: 0x4000, - 0x1764: 0x4000, 0x1765: 0x4000, 0x1766: 0x4000, 0x1767: 0x4000, - 0x177a: 0x4000, - // Block 0x5e, offset 0x1780 - 0x1795: 0x4000, 0x1796: 0x4000, - 0x17a4: 0x4000, - // Block 0x5f, offset 0x17c0 - 0x17fb: 0x4000, - 0x17fc: 0x4000, 0x17fd: 0x4000, 0x17fe: 0x4000, 0x17ff: 0x4000, - // Block 0x60, offset 0x1800 - 0x1800: 0x4000, 0x1801: 0x4000, 0x1802: 0x4000, 0x1803: 0x4000, 0x1804: 0x4000, 0x1805: 0x4000, - 0x1806: 0x4000, 0x1807: 0x4000, 0x1808: 0x4000, 0x1809: 0x4000, 0x180a: 0x4000, 0x180b: 0x4000, - 0x180c: 0x4000, 0x180d: 0x4000, 0x180e: 0x4000, 0x180f: 0x4000, - // Block 0x61, offset 0x1840 - 0x1840: 0x4000, 0x1841: 0x4000, 0x1842: 0x4000, 0x1843: 0x4000, 0x1844: 0x4000, 0x1845: 0x4000, - 0x184c: 0x4000, 0x1850: 0x4000, 0x1851: 0x4000, - 0x1852: 0x4000, 0x1855: 0x4000, 0x1856: 0x4000, 0x1857: 0x4000, - 0x185c: 0x4000, 0x185d: 0x4000, - 0x185e: 0x4000, 0x185f: 0x4000, - 0x186b: 0x4000, 0x186c: 0x4000, - 0x1874: 0x4000, 0x1875: 0x4000, - 0x1876: 0x4000, 0x1877: 0x4000, 0x1878: 0x4000, 0x1879: 0x4000, 0x187a: 0x4000, 0x187b: 0x4000, - 0x187c: 0x4000, - // Block 0x62, offset 0x1880 - 0x18a0: 0x4000, 0x18a1: 0x4000, 0x18a2: 0x4000, 0x18a3: 0x4000, - 0x18a4: 0x4000, 0x18a5: 0x4000, 0x18a6: 0x4000, 0x18a7: 0x4000, 0x18a8: 0x4000, 0x18a9: 0x4000, - 0x18aa: 0x4000, 0x18ab: 0x4000, - 0x18b0: 0x4000, - // Block 0x63, offset 0x18c0 - 0x18cc: 0x4000, 0x18cd: 0x4000, 0x18ce: 0x4000, 0x18cf: 0x4000, 0x18d0: 0x4000, 0x18d1: 0x4000, - 0x18d2: 0x4000, 0x18d3: 0x4000, 0x18d4: 0x4000, 0x18d5: 0x4000, 0x18d6: 0x4000, 0x18d7: 0x4000, - 0x18d8: 0x4000, 0x18d9: 0x4000, 0x18da: 0x4000, 0x18db: 0x4000, 0x18dc: 0x4000, 0x18dd: 0x4000, - 0x18de: 0x4000, 0x18df: 0x4000, 0x18e0: 0x4000, 0x18e1: 0x4000, 0x18e2: 0x4000, 0x18e3: 0x4000, - 0x18e4: 0x4000, 0x18e5: 0x4000, 0x18e6: 0x4000, 0x18e7: 0x4000, 0x18e8: 0x4000, 0x18e9: 0x4000, - 0x18ea: 0x4000, 0x18eb: 0x4000, 0x18ec: 0x4000, 0x18ed: 0x4000, 0x18ee: 0x4000, 0x18ef: 0x4000, - 0x18f0: 0x4000, 0x18f1: 0x4000, 0x18f2: 0x4000, 0x18f3: 0x4000, 0x18f4: 0x4000, 0x18f5: 0x4000, - 0x18f6: 0x4000, 0x18f7: 0x4000, 0x18f8: 0x4000, 0x18f9: 0x4000, 0x18fa: 0x4000, - 0x18fc: 0x4000, 0x18fd: 0x4000, 0x18fe: 0x4000, 0x18ff: 0x4000, - // Block 0x64, offset 0x1900 - 0x1900: 0x4000, 0x1901: 0x4000, 0x1902: 0x4000, 0x1903: 0x4000, 0x1904: 0x4000, 0x1905: 0x4000, - 0x1907: 0x4000, 0x1908: 0x4000, 0x1909: 0x4000, 0x190a: 0x4000, 0x190b: 0x4000, - 0x190c: 0x4000, 0x190d: 0x4000, 0x190e: 0x4000, 0x190f: 0x4000, 0x1910: 0x4000, 0x1911: 0x4000, - 0x1912: 0x4000, 0x1913: 0x4000, 0x1914: 0x4000, 0x1915: 0x4000, 0x1916: 0x4000, 0x1917: 0x4000, - 0x1918: 0x4000, 0x1919: 0x4000, 0x191a: 0x4000, 0x191b: 0x4000, 0x191c: 0x4000, 0x191d: 0x4000, - 0x191e: 0x4000, 0x191f: 0x4000, 0x1920: 0x4000, 0x1921: 0x4000, 0x1922: 0x4000, 0x1923: 0x4000, - 0x1924: 0x4000, 0x1925: 0x4000, 0x1926: 0x4000, 0x1927: 0x4000, 0x1928: 0x4000, 0x1929: 0x4000, - 0x192a: 0x4000, 0x192b: 0x4000, 0x192c: 0x4000, 0x192d: 0x4000, 0x192e: 0x4000, 0x192f: 0x4000, - 0x1930: 0x4000, 0x1931: 0x4000, 0x1932: 0x4000, 0x1933: 0x4000, 0x1934: 0x4000, 0x1935: 0x4000, - 0x1936: 0x4000, 0x1937: 0x4000, 0x1938: 0x4000, 0x1939: 0x4000, 0x193a: 0x4000, 0x193b: 0x4000, - 0x193c: 0x4000, 0x193d: 0x4000, 0x193e: 0x4000, 0x193f: 0x4000, - // Block 0x65, offset 0x1940 - 0x1970: 0x4000, 0x1971: 0x4000, 0x1972: 0x4000, 0x1973: 0x4000, 0x1974: 0x4000, 0x1975: 0x4000, - 0x1976: 0x4000, 0x1977: 0x4000, 0x1978: 0x4000, 0x1979: 0x4000, 0x197a: 0x4000, 0x197b: 0x4000, - 0x197c: 0x4000, - // Block 0x66, offset 0x1980 - 0x1980: 0x4000, 0x1981: 0x4000, 0x1982: 0x4000, 0x1983: 0x4000, 0x1984: 0x4000, 0x1985: 0x4000, - 0x1986: 0x4000, 0x1987: 0x4000, 0x1988: 0x4000, - 0x1990: 0x4000, 0x1991: 0x4000, - 0x1992: 0x4000, 0x1993: 0x4000, 0x1994: 0x4000, 0x1995: 0x4000, 0x1996: 0x4000, 0x1997: 0x4000, - 0x1998: 0x4000, 0x1999: 0x4000, 0x199a: 0x4000, 0x199b: 0x4000, 0x199c: 0x4000, 0x199d: 0x4000, - 0x199e: 0x4000, 0x199f: 0x4000, 0x19a0: 0x4000, 0x19a1: 0x4000, 0x19a2: 0x4000, 0x19a3: 0x4000, - 0x19a4: 0x4000, 0x19a5: 0x4000, 0x19a6: 0x4000, 0x19a7: 0x4000, 0x19a8: 0x4000, 0x19a9: 0x4000, - 0x19aa: 0x4000, 0x19ab: 0x4000, 0x19ac: 0x4000, 0x19ad: 0x4000, 0x19ae: 0x4000, 0x19af: 0x4000, - 0x19b0: 0x4000, 0x19b1: 0x4000, 0x19b2: 0x4000, 0x19b3: 0x4000, 0x19b4: 0x4000, 0x19b5: 0x4000, - 0x19b6: 0x4000, 0x19b7: 0x4000, 0x19b8: 0x4000, 0x19b9: 0x4000, 0x19ba: 0x4000, 0x19bb: 0x4000, - 0x19bc: 0x4000, 0x19bd: 0x4000, 0x19bf: 0x4000, - // Block 0x67, offset 0x19c0 - 0x19c0: 0x4000, 0x19c1: 0x4000, 0x19c2: 0x4000, 0x19c3: 0x4000, 0x19c4: 0x4000, 0x19c5: 0x4000, - 0x19ce: 0x4000, 0x19cf: 0x4000, 0x19d0: 0x4000, 0x19d1: 0x4000, - 0x19d2: 0x4000, 0x19d3: 0x4000, 0x19d4: 0x4000, 0x19d5: 0x4000, 0x19d6: 0x4000, 0x19d7: 0x4000, - 0x19d8: 0x4000, 0x19d9: 0x4000, 0x19da: 0x4000, 0x19db: 0x4000, - 0x19e0: 0x4000, 0x19e1: 0x4000, 0x19e2: 0x4000, 0x19e3: 0x4000, - 0x19e4: 0x4000, 0x19e5: 0x4000, 0x19e6: 0x4000, 0x19e7: 0x4000, 0x19e8: 0x4000, - 0x19f0: 0x4000, 0x19f1: 0x4000, 0x19f2: 0x4000, 0x19f3: 0x4000, 0x19f4: 0x4000, 0x19f5: 0x4000, - 0x19f6: 0x4000, 0x19f7: 0x4000, 0x19f8: 0x4000, - // Block 0x68, offset 0x1a00 - 0x1a00: 0x2000, 0x1a01: 0x2000, 0x1a02: 0x2000, 0x1a03: 0x2000, 0x1a04: 0x2000, 0x1a05: 0x2000, - 0x1a06: 0x2000, 0x1a07: 0x2000, 0x1a08: 0x2000, 0x1a09: 0x2000, 0x1a0a: 0x2000, 0x1a0b: 0x2000, - 0x1a0c: 0x2000, 0x1a0d: 0x2000, 0x1a0e: 0x2000, 0x1a0f: 0x2000, 0x1a10: 0x2000, 0x1a11: 0x2000, - 0x1a12: 0x2000, 0x1a13: 0x2000, 0x1a14: 0x2000, 0x1a15: 0x2000, 0x1a16: 0x2000, 0x1a17: 0x2000, - 0x1a18: 0x2000, 0x1a19: 0x2000, 0x1a1a: 0x2000, 0x1a1b: 0x2000, 0x1a1c: 0x2000, 0x1a1d: 0x2000, - 0x1a1e: 0x2000, 0x1a1f: 0x2000, 0x1a20: 0x2000, 0x1a21: 0x2000, 0x1a22: 0x2000, 0x1a23: 0x2000, - 0x1a24: 0x2000, 0x1a25: 0x2000, 0x1a26: 0x2000, 0x1a27: 0x2000, 0x1a28: 0x2000, 0x1a29: 0x2000, - 0x1a2a: 0x2000, 0x1a2b: 0x2000, 0x1a2c: 0x2000, 0x1a2d: 0x2000, 0x1a2e: 0x2000, 0x1a2f: 0x2000, - 0x1a30: 0x2000, 0x1a31: 0x2000, 0x1a32: 0x2000, 0x1a33: 0x2000, 0x1a34: 0x2000, 0x1a35: 0x2000, - 0x1a36: 0x2000, 0x1a37: 0x2000, 0x1a38: 0x2000, 0x1a39: 0x2000, 0x1a3a: 0x2000, 0x1a3b: 0x2000, - 0x1a3c: 0x2000, 0x1a3d: 0x2000, -} - -// widthIndex: 23 blocks, 1472 entries, 1472 bytes -// Block 0 is the zero block. -var widthIndex = [1472]uint8{ - // Block 0x0, offset 0x0 - // Block 0x1, offset 0x40 - // Block 0x2, offset 0x80 - // Block 0x3, offset 0xc0 - 0xc2: 0x01, 0xc3: 0x02, 0xc4: 0x03, 0xc5: 0x04, 0xc7: 0x05, - 0xc9: 0x06, 0xcb: 0x07, 0xcc: 0x08, 0xcd: 0x09, 0xce: 0x0a, 0xcf: 0x0b, - 0xd0: 0x0c, 0xd1: 0x0d, - 0xe1: 0x02, 0xe2: 0x03, 0xe3: 0x04, 0xe4: 0x05, 0xe5: 0x06, 0xe6: 0x06, 0xe7: 0x06, - 0xe8: 0x06, 0xe9: 0x06, 0xea: 0x07, 0xeb: 0x06, 0xec: 0x06, 0xed: 0x08, 0xee: 0x09, 0xef: 0x0a, - 0xf0: 0x10, 0xf3: 0x13, 0xf4: 0x14, - // Block 0x4, offset 0x100 - 0x104: 0x0e, 0x105: 0x0f, - // Block 0x5, offset 0x140 - 0x140: 0x10, 0x141: 0x11, 0x142: 0x12, 0x144: 0x13, 0x145: 0x14, 0x146: 0x15, 0x147: 0x16, - 0x148: 0x17, 0x149: 0x18, 0x14a: 0x19, 0x14c: 0x1a, 0x14f: 0x1b, - 0x151: 0x1c, 0x152: 0x08, 0x153: 0x1d, 0x154: 0x1e, 0x155: 0x1f, 0x156: 0x20, 0x157: 0x21, - 0x158: 0x22, 0x159: 0x23, 0x15a: 0x24, 0x15b: 0x25, 0x15c: 0x26, 0x15d: 0x27, 0x15e: 0x28, 0x15f: 0x29, - 0x166: 0x2a, - 0x16c: 0x2b, 0x16d: 0x2c, - 0x17a: 0x2d, 0x17b: 0x2e, 0x17c: 0x0e, 0x17d: 0x0e, 0x17e: 0x0e, 0x17f: 0x2f, - // Block 0x6, offset 0x180 - 0x180: 0x30, 0x181: 0x31, 0x182: 0x32, 0x183: 0x33, 0x184: 0x34, 0x185: 0x35, 0x186: 0x36, 0x187: 0x37, - 0x188: 0x38, 0x189: 0x39, 0x18a: 0x0e, 0x18b: 0x0e, 0x18c: 0x0e, 0x18d: 0x0e, 0x18e: 0x0e, 0x18f: 0x0e, - 0x190: 0x0e, 0x191: 0x0e, 0x192: 0x0e, 0x193: 0x0e, 0x194: 0x0e, 0x195: 0x0e, 0x196: 0x0e, 0x197: 0x0e, - 0x198: 0x0e, 0x199: 0x0e, 0x19a: 0x0e, 0x19b: 0x0e, 0x19c: 0x0e, 0x19d: 0x0e, 0x19e: 0x0e, 0x19f: 0x0e, - 0x1a0: 0x0e, 0x1a1: 0x0e, 0x1a2: 0x0e, 0x1a3: 0x0e, 0x1a4: 0x0e, 0x1a5: 0x0e, 0x1a6: 0x0e, 0x1a7: 0x0e, - 0x1a8: 0x0e, 0x1a9: 0x0e, 0x1aa: 0x0e, 0x1ab: 0x0e, 0x1ac: 0x0e, 0x1ad: 0x0e, 0x1ae: 0x0e, 0x1af: 0x0e, - 0x1b0: 0x0e, 0x1b1: 0x0e, 0x1b2: 0x0e, 0x1b3: 0x0e, 0x1b4: 0x0e, 0x1b5: 0x0e, 0x1b6: 0x0e, 0x1b7: 0x0e, - 0x1b8: 0x0e, 0x1b9: 0x0e, 0x1ba: 0x0e, 0x1bb: 0x0e, 0x1bc: 0x0e, 0x1bd: 0x0e, 0x1be: 0x0e, 0x1bf: 0x0e, - // Block 0x7, offset 0x1c0 - 0x1c0: 0x0e, 0x1c1: 0x0e, 0x1c2: 0x0e, 0x1c3: 0x0e, 0x1c4: 0x0e, 0x1c5: 0x0e, 0x1c6: 0x0e, 0x1c7: 0x0e, - 0x1c8: 0x0e, 0x1c9: 0x0e, 0x1ca: 0x0e, 0x1cb: 0x0e, 0x1cc: 0x0e, 0x1cd: 0x0e, 0x1ce: 0x0e, 0x1cf: 0x0e, - 0x1d0: 0x0e, 0x1d1: 0x0e, 0x1d2: 0x0e, 0x1d3: 0x0e, 0x1d4: 0x0e, 0x1d5: 0x0e, 0x1d6: 0x0e, 0x1d7: 0x0e, - 0x1d8: 0x0e, 0x1d9: 0x0e, 0x1da: 0x0e, 0x1db: 0x0e, 0x1dc: 0x0e, 0x1dd: 0x0e, 0x1de: 0x0e, 0x1df: 0x0e, - 0x1e0: 0x0e, 0x1e1: 0x0e, 0x1e2: 0x0e, 0x1e3: 0x0e, 0x1e4: 0x0e, 0x1e5: 0x0e, 0x1e6: 0x0e, 0x1e7: 0x0e, - 0x1e8: 0x0e, 0x1e9: 0x0e, 0x1ea: 0x0e, 0x1eb: 0x0e, 0x1ec: 0x0e, 0x1ed: 0x0e, 0x1ee: 0x0e, 0x1ef: 0x0e, - 0x1f0: 0x0e, 0x1f1: 0x0e, 0x1f2: 0x0e, 0x1f3: 0x0e, 0x1f4: 0x0e, 0x1f5: 0x0e, 0x1f6: 0x0e, - 0x1f8: 0x0e, 0x1f9: 0x0e, 0x1fa: 0x0e, 0x1fb: 0x0e, 0x1fc: 0x0e, 0x1fd: 0x0e, 0x1fe: 0x0e, 0x1ff: 0x0e, - // Block 0x8, offset 0x200 - 0x200: 0x0e, 0x201: 0x0e, 0x202: 0x0e, 0x203: 0x0e, 0x204: 0x0e, 0x205: 0x0e, 0x206: 0x0e, 0x207: 0x0e, - 0x208: 0x0e, 0x209: 0x0e, 0x20a: 0x0e, 0x20b: 0x0e, 0x20c: 0x0e, 0x20d: 0x0e, 0x20e: 0x0e, 0x20f: 0x0e, - 0x210: 0x0e, 0x211: 0x0e, 0x212: 0x0e, 0x213: 0x0e, 0x214: 0x0e, 0x215: 0x0e, 0x216: 0x0e, 0x217: 0x0e, - 0x218: 0x0e, 0x219: 0x0e, 0x21a: 0x0e, 0x21b: 0x0e, 0x21c: 0x0e, 0x21d: 0x0e, 0x21e: 0x0e, 0x21f: 0x0e, - 0x220: 0x0e, 0x221: 0x0e, 0x222: 0x0e, 0x223: 0x0e, 0x224: 0x0e, 0x225: 0x0e, 0x226: 0x0e, 0x227: 0x0e, - 0x228: 0x0e, 0x229: 0x0e, 0x22a: 0x0e, 0x22b: 0x0e, 0x22c: 0x0e, 0x22d: 0x0e, 0x22e: 0x0e, 0x22f: 0x0e, - 0x230: 0x0e, 0x231: 0x0e, 0x232: 0x0e, 0x233: 0x0e, 0x234: 0x0e, 0x235: 0x0e, 0x236: 0x0e, 0x237: 0x0e, - 0x238: 0x0e, 0x239: 0x0e, 0x23a: 0x0e, 0x23b: 0x0e, 0x23c: 0x0e, 0x23d: 0x0e, 0x23e: 0x0e, 0x23f: 0x0e, - // Block 0x9, offset 0x240 - 0x240: 0x0e, 0x241: 0x0e, 0x242: 0x0e, 0x243: 0x0e, 0x244: 0x0e, 0x245: 0x0e, 0x246: 0x0e, 0x247: 0x0e, - 0x248: 0x0e, 0x249: 0x0e, 0x24a: 0x0e, 0x24b: 0x0e, 0x24c: 0x0e, 0x24d: 0x0e, 0x24e: 0x0e, 0x24f: 0x0e, - 0x250: 0x0e, 0x251: 0x0e, 0x252: 0x3a, 0x253: 0x3b, - 0x265: 0x3c, - 0x270: 0x0e, 0x271: 0x0e, 0x272: 0x0e, 0x273: 0x0e, 0x274: 0x0e, 0x275: 0x0e, 0x276: 0x0e, 0x277: 0x0e, - 0x278: 0x0e, 0x279: 0x0e, 0x27a: 0x0e, 0x27b: 0x0e, 0x27c: 0x0e, 0x27d: 0x0e, 0x27e: 0x0e, 0x27f: 0x0e, - // Block 0xa, offset 0x280 - 0x280: 0x0e, 0x281: 0x0e, 0x282: 0x0e, 0x283: 0x0e, 0x284: 0x0e, 0x285: 0x0e, 0x286: 0x0e, 0x287: 0x0e, - 0x288: 0x0e, 0x289: 0x0e, 0x28a: 0x0e, 0x28b: 0x0e, 0x28c: 0x0e, 0x28d: 0x0e, 0x28e: 0x0e, 0x28f: 0x0e, - 0x290: 0x0e, 0x291: 0x0e, 0x292: 0x0e, 0x293: 0x0e, 0x294: 0x0e, 0x295: 0x0e, 0x296: 0x0e, 0x297: 0x0e, - 0x298: 0x0e, 0x299: 0x0e, 0x29a: 0x0e, 0x29b: 0x0e, 0x29c: 0x0e, 0x29d: 0x0e, 0x29e: 0x3d, - // Block 0xb, offset 0x2c0 - 0x2c0: 0x08, 0x2c1: 0x08, 0x2c2: 0x08, 0x2c3: 0x08, 0x2c4: 0x08, 0x2c5: 0x08, 0x2c6: 0x08, 0x2c7: 0x08, - 0x2c8: 0x08, 0x2c9: 0x08, 0x2ca: 0x08, 0x2cb: 0x08, 0x2cc: 0x08, 0x2cd: 0x08, 0x2ce: 0x08, 0x2cf: 0x08, - 0x2d0: 0x08, 0x2d1: 0x08, 0x2d2: 0x08, 0x2d3: 0x08, 0x2d4: 0x08, 0x2d5: 0x08, 0x2d6: 0x08, 0x2d7: 0x08, - 0x2d8: 0x08, 0x2d9: 0x08, 0x2da: 0x08, 0x2db: 0x08, 0x2dc: 0x08, 0x2dd: 0x08, 0x2de: 0x08, 0x2df: 0x08, - 0x2e0: 0x08, 0x2e1: 0x08, 0x2e2: 0x08, 0x2e3: 0x08, 0x2e4: 0x08, 0x2e5: 0x08, 0x2e6: 0x08, 0x2e7: 0x08, - 0x2e8: 0x08, 0x2e9: 0x08, 0x2ea: 0x08, 0x2eb: 0x08, 0x2ec: 0x08, 0x2ed: 0x08, 0x2ee: 0x08, 0x2ef: 0x08, - 0x2f0: 0x08, 0x2f1: 0x08, 0x2f2: 0x08, 0x2f3: 0x08, 0x2f4: 0x08, 0x2f5: 0x08, 0x2f6: 0x08, 0x2f7: 0x08, - 0x2f8: 0x08, 0x2f9: 0x08, 0x2fa: 0x08, 0x2fb: 0x08, 0x2fc: 0x08, 0x2fd: 0x08, 0x2fe: 0x08, 0x2ff: 0x08, - // Block 0xc, offset 0x300 - 0x300: 0x08, 0x301: 0x08, 0x302: 0x08, 0x303: 0x08, 0x304: 0x08, 0x305: 0x08, 0x306: 0x08, 0x307: 0x08, - 0x308: 0x08, 0x309: 0x08, 0x30a: 0x08, 0x30b: 0x08, 0x30c: 0x08, 0x30d: 0x08, 0x30e: 0x08, 0x30f: 0x08, - 0x310: 0x08, 0x311: 0x08, 0x312: 0x08, 0x313: 0x08, 0x314: 0x08, 0x315: 0x08, 0x316: 0x08, 0x317: 0x08, - 0x318: 0x08, 0x319: 0x08, 0x31a: 0x08, 0x31b: 0x08, 0x31c: 0x08, 0x31d: 0x08, 0x31e: 0x08, 0x31f: 0x08, - 0x320: 0x08, 0x321: 0x08, 0x322: 0x08, 0x323: 0x08, 0x324: 0x0e, 0x325: 0x0e, 0x326: 0x0e, 0x327: 0x0e, - 0x328: 0x0e, 0x329: 0x0e, 0x32a: 0x0e, 0x32b: 0x0e, - 0x338: 0x3e, 0x339: 0x3f, 0x33c: 0x40, 0x33d: 0x41, 0x33e: 0x42, 0x33f: 0x43, - // Block 0xd, offset 0x340 - 0x37f: 0x44, - // Block 0xe, offset 0x380 - 0x380: 0x0e, 0x381: 0x0e, 0x382: 0x0e, 0x383: 0x0e, 0x384: 0x0e, 0x385: 0x0e, 0x386: 0x0e, 0x387: 0x0e, - 0x388: 0x0e, 0x389: 0x0e, 0x38a: 0x0e, 0x38b: 0x0e, 0x38c: 0x0e, 0x38d: 0x0e, 0x38e: 0x0e, 0x38f: 0x0e, - 0x390: 0x0e, 0x391: 0x0e, 0x392: 0x0e, 0x393: 0x0e, 0x394: 0x0e, 0x395: 0x0e, 0x396: 0x0e, 0x397: 0x0e, - 0x398: 0x0e, 0x399: 0x0e, 0x39a: 0x0e, 0x39b: 0x0e, 0x39c: 0x0e, 0x39d: 0x0e, 0x39e: 0x0e, 0x39f: 0x45, - 0x3a0: 0x0e, 0x3a1: 0x0e, 0x3a2: 0x0e, 0x3a3: 0x0e, 0x3a4: 0x0e, 0x3a5: 0x0e, 0x3a6: 0x0e, 0x3a7: 0x0e, - 0x3a8: 0x0e, 0x3a9: 0x0e, 0x3aa: 0x0e, 0x3ab: 0x0e, 0x3ac: 0x0e, 0x3ad: 0x0e, 0x3ae: 0x0e, 0x3af: 0x0e, - 0x3b0: 0x0e, 0x3b1: 0x0e, 0x3b2: 0x0e, 0x3b3: 0x46, 0x3b4: 0x47, - // Block 0xf, offset 0x3c0 - 0x3ff: 0x48, - // Block 0x10, offset 0x400 - 0x400: 0x0e, 0x401: 0x0e, 0x402: 0x0e, 0x403: 0x0e, 0x404: 0x49, 0x405: 0x4a, 0x406: 0x0e, 0x407: 0x0e, - 0x408: 0x0e, 0x409: 0x0e, 0x40a: 0x0e, 0x40b: 0x4b, - // Block 0x11, offset 0x440 - 0x440: 0x4c, 0x443: 0x4d, 0x444: 0x4e, 0x445: 0x4f, 0x446: 0x50, - 0x448: 0x51, 0x449: 0x52, 0x44c: 0x53, 0x44d: 0x54, 0x44e: 0x55, 0x44f: 0x56, - 0x450: 0x57, 0x451: 0x58, 0x452: 0x0e, 0x453: 0x59, 0x454: 0x5a, 0x455: 0x5b, 0x456: 0x5c, 0x457: 0x5d, - 0x458: 0x0e, 0x459: 0x5e, 0x45a: 0x0e, 0x45b: 0x5f, 0x45f: 0x60, - 0x464: 0x61, 0x465: 0x62, 0x466: 0x0e, 0x467: 0x0e, - 0x469: 0x63, 0x46a: 0x64, 0x46b: 0x65, - // Block 0x12, offset 0x480 - 0x496: 0x0b, 0x497: 0x06, - 0x498: 0x0c, 0x49a: 0x0d, 0x49b: 0x0e, 0x49f: 0x0f, - 0x4a0: 0x06, 0x4a1: 0x06, 0x4a2: 0x06, 0x4a3: 0x06, 0x4a4: 0x06, 0x4a5: 0x06, 0x4a6: 0x06, 0x4a7: 0x06, - 0x4a8: 0x06, 0x4a9: 0x06, 0x4aa: 0x06, 0x4ab: 0x06, 0x4ac: 0x06, 0x4ad: 0x06, 0x4ae: 0x06, 0x4af: 0x06, - 0x4b0: 0x06, 0x4b1: 0x06, 0x4b2: 0x06, 0x4b3: 0x06, 0x4b4: 0x06, 0x4b5: 0x06, 0x4b6: 0x06, 0x4b7: 0x06, - 0x4b8: 0x06, 0x4b9: 0x06, 0x4ba: 0x06, 0x4bb: 0x06, 0x4bc: 0x06, 0x4bd: 0x06, 0x4be: 0x06, 0x4bf: 0x06, - // Block 0x13, offset 0x4c0 - 0x4c4: 0x08, 0x4c5: 0x08, 0x4c6: 0x08, 0x4c7: 0x09, - // Block 0x14, offset 0x500 - 0x500: 0x08, 0x501: 0x08, 0x502: 0x08, 0x503: 0x08, 0x504: 0x08, 0x505: 0x08, 0x506: 0x08, 0x507: 0x08, - 0x508: 0x08, 0x509: 0x08, 0x50a: 0x08, 0x50b: 0x08, 0x50c: 0x08, 0x50d: 0x08, 0x50e: 0x08, 0x50f: 0x08, - 0x510: 0x08, 0x511: 0x08, 0x512: 0x08, 0x513: 0x08, 0x514: 0x08, 0x515: 0x08, 0x516: 0x08, 0x517: 0x08, - 0x518: 0x08, 0x519: 0x08, 0x51a: 0x08, 0x51b: 0x08, 0x51c: 0x08, 0x51d: 0x08, 0x51e: 0x08, 0x51f: 0x08, - 0x520: 0x08, 0x521: 0x08, 0x522: 0x08, 0x523: 0x08, 0x524: 0x08, 0x525: 0x08, 0x526: 0x08, 0x527: 0x08, - 0x528: 0x08, 0x529: 0x08, 0x52a: 0x08, 0x52b: 0x08, 0x52c: 0x08, 0x52d: 0x08, 0x52e: 0x08, 0x52f: 0x08, - 0x530: 0x08, 0x531: 0x08, 0x532: 0x08, 0x533: 0x08, 0x534: 0x08, 0x535: 0x08, 0x536: 0x08, 0x537: 0x08, - 0x538: 0x08, 0x539: 0x08, 0x53a: 0x08, 0x53b: 0x08, 0x53c: 0x08, 0x53d: 0x08, 0x53e: 0x08, 0x53f: 0x66, - // Block 0x15, offset 0x540 - 0x560: 0x11, - 0x570: 0x09, 0x571: 0x09, 0x572: 0x09, 0x573: 0x09, 0x574: 0x09, 0x575: 0x09, 0x576: 0x09, 0x577: 0x09, - 0x578: 0x09, 0x579: 0x09, 0x57a: 0x09, 0x57b: 0x09, 0x57c: 0x09, 0x57d: 0x09, 0x57e: 0x09, 0x57f: 0x12, - // Block 0x16, offset 0x580 - 0x580: 0x09, 0x581: 0x09, 0x582: 0x09, 0x583: 0x09, 0x584: 0x09, 0x585: 0x09, 0x586: 0x09, 0x587: 0x09, - 0x588: 0x09, 0x589: 0x09, 0x58a: 0x09, 0x58b: 0x09, 0x58c: 0x09, 0x58d: 0x09, 0x58e: 0x09, 0x58f: 0x12, -} - -// inverseData contains 4-byte entries of the following format: -// -// <0 padding> -// -// The last byte of the UTF-8-encoded rune is xor-ed with the last byte of the -// UTF-8 encoding of the original rune. Mappings often have the following -// pattern: -// -// A -> A (U+FF21 -> U+0041) -// B -> B (U+FF22 -> U+0042) -// ... -// -// By xor-ing the last byte the same entry can be shared by many mappings. This -// reduces the total number of distinct entries by about two thirds. -// The resulting entry for the aforementioned mappings is -// -// { 0x01, 0xE0, 0x00, 0x00 } -// -// Using this entry to map U+FF21 (UTF-8 [EF BC A1]), we get -// -// E0 ^ A1 = 41. -// -// Similarly, for U+FF22 (UTF-8 [EF BC A2]), we get -// -// E0 ^ A2 = 42. -// -// Note that because of the xor-ing, the byte sequence stored in the entry is -// not valid UTF-8. -var inverseData = [150][4]byte{ - {0x00, 0x00, 0x00, 0x00}, - {0x03, 0xe3, 0x80, 0xa0}, - {0x03, 0xef, 0xbc, 0xa0}, - {0x03, 0xef, 0xbc, 0xe0}, - {0x03, 0xef, 0xbd, 0xe0}, - {0x03, 0xef, 0xbf, 0x02}, - {0x03, 0xef, 0xbf, 0x00}, - {0x03, 0xef, 0xbf, 0x0e}, - {0x03, 0xef, 0xbf, 0x0c}, - {0x03, 0xef, 0xbf, 0x0f}, - {0x03, 0xef, 0xbf, 0x39}, - {0x03, 0xef, 0xbf, 0x3b}, - {0x03, 0xef, 0xbf, 0x3f}, - {0x03, 0xef, 0xbf, 0x2a}, - {0x03, 0xef, 0xbf, 0x0d}, - {0x03, 0xef, 0xbf, 0x25}, - {0x03, 0xef, 0xbd, 0x1a}, - {0x03, 0xef, 0xbd, 0x26}, - {0x01, 0xa0, 0x00, 0x00}, - {0x03, 0xef, 0xbd, 0x25}, - {0x03, 0xef, 0xbd, 0x23}, - {0x03, 0xef, 0xbd, 0x2e}, - {0x03, 0xef, 0xbe, 0x07}, - {0x03, 0xef, 0xbe, 0x05}, - {0x03, 0xef, 0xbd, 0x06}, - {0x03, 0xef, 0xbd, 0x13}, - {0x03, 0xef, 0xbd, 0x0b}, - {0x03, 0xef, 0xbd, 0x16}, - {0x03, 0xef, 0xbd, 0x0c}, - {0x03, 0xef, 0xbd, 0x15}, - {0x03, 0xef, 0xbd, 0x0d}, - {0x03, 0xef, 0xbd, 0x1c}, - {0x03, 0xef, 0xbd, 0x02}, - {0x03, 0xef, 0xbd, 0x1f}, - {0x03, 0xef, 0xbd, 0x1d}, - {0x03, 0xef, 0xbd, 0x17}, - {0x03, 0xef, 0xbd, 0x08}, - {0x03, 0xef, 0xbd, 0x09}, - {0x03, 0xef, 0xbd, 0x0e}, - {0x03, 0xef, 0xbd, 0x04}, - {0x03, 0xef, 0xbd, 0x05}, - {0x03, 0xef, 0xbe, 0x3f}, - {0x03, 0xef, 0xbe, 0x00}, - {0x03, 0xef, 0xbd, 0x2c}, - {0x03, 0xef, 0xbe, 0x06}, - {0x03, 0xef, 0xbe, 0x0c}, - {0x03, 0xef, 0xbe, 0x0f}, - {0x03, 0xef, 0xbe, 0x0d}, - {0x03, 0xef, 0xbe, 0x0b}, - {0x03, 0xef, 0xbe, 0x19}, - {0x03, 0xef, 0xbe, 0x15}, - {0x03, 0xef, 0xbe, 0x11}, - {0x03, 0xef, 0xbe, 0x31}, - {0x03, 0xef, 0xbe, 0x33}, - {0x03, 0xef, 0xbd, 0x0f}, - {0x03, 0xef, 0xbe, 0x30}, - {0x03, 0xef, 0xbe, 0x3e}, - {0x03, 0xef, 0xbe, 0x32}, - {0x03, 0xef, 0xbe, 0x36}, - {0x03, 0xef, 0xbd, 0x14}, - {0x03, 0xef, 0xbe, 0x2e}, - {0x03, 0xef, 0xbd, 0x1e}, - {0x03, 0xef, 0xbe, 0x10}, - {0x03, 0xef, 0xbf, 0x13}, - {0x03, 0xef, 0xbf, 0x15}, - {0x03, 0xef, 0xbf, 0x17}, - {0x03, 0xef, 0xbf, 0x1f}, - {0x03, 0xef, 0xbf, 0x1d}, - {0x03, 0xef, 0xbf, 0x1b}, - {0x03, 0xef, 0xbf, 0x09}, - {0x03, 0xef, 0xbf, 0x0b}, - {0x03, 0xef, 0xbf, 0x37}, - {0x03, 0xef, 0xbe, 0x04}, - {0x01, 0xe0, 0x00, 0x00}, - {0x03, 0xe2, 0xa6, 0x1a}, - {0x03, 0xe2, 0xa6, 0x26}, - {0x03, 0xe3, 0x80, 0x23}, - {0x03, 0xe3, 0x80, 0x2e}, - {0x03, 0xe3, 0x80, 0x25}, - {0x03, 0xe3, 0x83, 0x1e}, - {0x03, 0xe3, 0x83, 0x14}, - {0x03, 0xe3, 0x82, 0x06}, - {0x03, 0xe3, 0x82, 0x0b}, - {0x03, 0xe3, 0x82, 0x0c}, - {0x03, 0xe3, 0x82, 0x0d}, - {0x03, 0xe3, 0x82, 0x02}, - {0x03, 0xe3, 0x83, 0x0f}, - {0x03, 0xe3, 0x83, 0x08}, - {0x03, 0xe3, 0x83, 0x09}, - {0x03, 0xe3, 0x83, 0x2c}, - {0x03, 0xe3, 0x83, 0x0c}, - {0x03, 0xe3, 0x82, 0x13}, - {0x03, 0xe3, 0x82, 0x16}, - {0x03, 0xe3, 0x82, 0x15}, - {0x03, 0xe3, 0x82, 0x1c}, - {0x03, 0xe3, 0x82, 0x1f}, - {0x03, 0xe3, 0x82, 0x1d}, - {0x03, 0xe3, 0x82, 0x1a}, - {0x03, 0xe3, 0x82, 0x17}, - {0x03, 0xe3, 0x82, 0x08}, - {0x03, 0xe3, 0x82, 0x09}, - {0x03, 0xe3, 0x82, 0x0e}, - {0x03, 0xe3, 0x82, 0x04}, - {0x03, 0xe3, 0x82, 0x05}, - {0x03, 0xe3, 0x82, 0x3f}, - {0x03, 0xe3, 0x83, 0x00}, - {0x03, 0xe3, 0x83, 0x06}, - {0x03, 0xe3, 0x83, 0x05}, - {0x03, 0xe3, 0x83, 0x0d}, - {0x03, 0xe3, 0x83, 0x0b}, - {0x03, 0xe3, 0x83, 0x07}, - {0x03, 0xe3, 0x83, 0x19}, - {0x03, 0xe3, 0x83, 0x15}, - {0x03, 0xe3, 0x83, 0x11}, - {0x03, 0xe3, 0x83, 0x31}, - {0x03, 0xe3, 0x83, 0x33}, - {0x03, 0xe3, 0x83, 0x30}, - {0x03, 0xe3, 0x83, 0x3e}, - {0x03, 0xe3, 0x83, 0x32}, - {0x03, 0xe3, 0x83, 0x36}, - {0x03, 0xe3, 0x83, 0x2e}, - {0x03, 0xe3, 0x82, 0x07}, - {0x03, 0xe3, 0x85, 0x04}, - {0x03, 0xe3, 0x84, 0x10}, - {0x03, 0xe3, 0x85, 0x30}, - {0x03, 0xe3, 0x85, 0x0d}, - {0x03, 0xe3, 0x85, 0x13}, - {0x03, 0xe3, 0x85, 0x15}, - {0x03, 0xe3, 0x85, 0x17}, - {0x03, 0xe3, 0x85, 0x1f}, - {0x03, 0xe3, 0x85, 0x1d}, - {0x03, 0xe3, 0x85, 0x1b}, - {0x03, 0xe3, 0x85, 0x09}, - {0x03, 0xe3, 0x85, 0x0f}, - {0x03, 0xe3, 0x85, 0x0b}, - {0x03, 0xe3, 0x85, 0x37}, - {0x03, 0xe3, 0x85, 0x3b}, - {0x03, 0xe3, 0x85, 0x39}, - {0x03, 0xe3, 0x85, 0x3f}, - {0x02, 0xc2, 0x02, 0x00}, - {0x02, 0xc2, 0x0e, 0x00}, - {0x02, 0xc2, 0x0c, 0x00}, - {0x02, 0xc2, 0x00, 0x00}, - {0x03, 0xe2, 0x82, 0x0f}, - {0x03, 0xe2, 0x94, 0x2a}, - {0x03, 0xe2, 0x86, 0x39}, - {0x03, 0xe2, 0x86, 0x3b}, - {0x03, 0xe2, 0x86, 0x3f}, - {0x03, 0xe2, 0x96, 0x0d}, - {0x03, 0xe2, 0x97, 0x25}, -} - -// Total table size 15512 bytes (15KiB) diff --git a/vendor/golang.org/x/text/width/tables9.0.0.go b/vendor/golang.org/x/text/width/tables9.0.0.go deleted file mode 100644 index d981330a9..000000000 --- a/vendor/golang.org/x/text/width/tables9.0.0.go +++ /dev/null @@ -1,1296 +0,0 @@ -// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. - -//go:build !go1.10 - -package width - -// UnicodeVersion is the Unicode version from which the tables in this package are derived. -const UnicodeVersion = "9.0.0" - -// lookup returns the trie value for the first UTF-8 encoding in s and -// the width in bytes of this encoding. The size will be 0 if s does not -// hold enough bytes to complete the encoding. len(s) must be greater than 0. -func (t *widthTrie) lookup(s []byte) (v uint16, sz int) { - c0 := s[0] - switch { - case c0 < 0x80: // is ASCII - return widthValues[c0], 1 - case c0 < 0xC2: - return 0, 1 // Illegal UTF-8: not a starter, not ASCII. - case c0 < 0xE0: // 2-byte UTF-8 - if len(s) < 2 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c1), 2 - case c0 < 0xF0: // 3-byte UTF-8 - if len(s) < 3 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c2), 3 - case c0 < 0xF8: // 4-byte UTF-8 - if len(s) < 4 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - o = uint32(i)<<6 + uint32(c2) - i = widthIndex[o] - c3 := s[3] - if c3 < 0x80 || 0xC0 <= c3 { - return 0, 3 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c3), 4 - } - // Illegal rune - return 0, 1 -} - -// lookupUnsafe returns the trie value for the first UTF-8 encoding in s. -// s must start with a full and valid UTF-8 encoded rune. -func (t *widthTrie) lookupUnsafe(s []byte) uint16 { - c0 := s[0] - if c0 < 0x80 { // is ASCII - return widthValues[c0] - } - i := widthIndex[c0] - if c0 < 0xE0 { // 2-byte UTF-8 - return t.lookupValue(uint32(i), s[1]) - } - i = widthIndex[uint32(i)<<6+uint32(s[1])] - if c0 < 0xF0 { // 3-byte UTF-8 - return t.lookupValue(uint32(i), s[2]) - } - i = widthIndex[uint32(i)<<6+uint32(s[2])] - if c0 < 0xF8 { // 4-byte UTF-8 - return t.lookupValue(uint32(i), s[3]) - } - return 0 -} - -// lookupString returns the trie value for the first UTF-8 encoding in s and -// the width in bytes of this encoding. The size will be 0 if s does not -// hold enough bytes to complete the encoding. len(s) must be greater than 0. -func (t *widthTrie) lookupString(s string) (v uint16, sz int) { - c0 := s[0] - switch { - case c0 < 0x80: // is ASCII - return widthValues[c0], 1 - case c0 < 0xC2: - return 0, 1 // Illegal UTF-8: not a starter, not ASCII. - case c0 < 0xE0: // 2-byte UTF-8 - if len(s) < 2 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c1), 2 - case c0 < 0xF0: // 3-byte UTF-8 - if len(s) < 3 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c2), 3 - case c0 < 0xF8: // 4-byte UTF-8 - if len(s) < 4 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - o = uint32(i)<<6 + uint32(c2) - i = widthIndex[o] - c3 := s[3] - if c3 < 0x80 || 0xC0 <= c3 { - return 0, 3 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c3), 4 - } - // Illegal rune - return 0, 1 -} - -// lookupStringUnsafe returns the trie value for the first UTF-8 encoding in s. -// s must start with a full and valid UTF-8 encoded rune. -func (t *widthTrie) lookupStringUnsafe(s string) uint16 { - c0 := s[0] - if c0 < 0x80 { // is ASCII - return widthValues[c0] - } - i := widthIndex[c0] - if c0 < 0xE0 { // 2-byte UTF-8 - return t.lookupValue(uint32(i), s[1]) - } - i = widthIndex[uint32(i)<<6+uint32(s[1])] - if c0 < 0xF0 { // 3-byte UTF-8 - return t.lookupValue(uint32(i), s[2]) - } - i = widthIndex[uint32(i)<<6+uint32(s[2])] - if c0 < 0xF8 { // 4-byte UTF-8 - return t.lookupValue(uint32(i), s[3]) - } - return 0 -} - -// widthTrie. Total size: 14080 bytes (13.75 KiB). Checksum: 3b8aeb3dc03667a3. -type widthTrie struct{} - -func newWidthTrie(i int) *widthTrie { - return &widthTrie{} -} - -// lookupValue determines the type of block n and looks up the value for b. -func (t *widthTrie) lookupValue(n uint32, b byte) uint16 { - switch { - default: - return uint16(widthValues[n<<6+uint32(b)]) - } -} - -// widthValues: 99 blocks, 6336 entries, 12672 bytes -// The third block is the zero block. -var widthValues = [6336]uint16{ - // Block 0x0, offset 0x0 - 0x20: 0x6001, 0x21: 0x6002, 0x22: 0x6002, 0x23: 0x6002, - 0x24: 0x6002, 0x25: 0x6002, 0x26: 0x6002, 0x27: 0x6002, 0x28: 0x6002, 0x29: 0x6002, - 0x2a: 0x6002, 0x2b: 0x6002, 0x2c: 0x6002, 0x2d: 0x6002, 0x2e: 0x6002, 0x2f: 0x6002, - 0x30: 0x6002, 0x31: 0x6002, 0x32: 0x6002, 0x33: 0x6002, 0x34: 0x6002, 0x35: 0x6002, - 0x36: 0x6002, 0x37: 0x6002, 0x38: 0x6002, 0x39: 0x6002, 0x3a: 0x6002, 0x3b: 0x6002, - 0x3c: 0x6002, 0x3d: 0x6002, 0x3e: 0x6002, 0x3f: 0x6002, - // Block 0x1, offset 0x40 - 0x40: 0x6003, 0x41: 0x6003, 0x42: 0x6003, 0x43: 0x6003, 0x44: 0x6003, 0x45: 0x6003, - 0x46: 0x6003, 0x47: 0x6003, 0x48: 0x6003, 0x49: 0x6003, 0x4a: 0x6003, 0x4b: 0x6003, - 0x4c: 0x6003, 0x4d: 0x6003, 0x4e: 0x6003, 0x4f: 0x6003, 0x50: 0x6003, 0x51: 0x6003, - 0x52: 0x6003, 0x53: 0x6003, 0x54: 0x6003, 0x55: 0x6003, 0x56: 0x6003, 0x57: 0x6003, - 0x58: 0x6003, 0x59: 0x6003, 0x5a: 0x6003, 0x5b: 0x6003, 0x5c: 0x6003, 0x5d: 0x6003, - 0x5e: 0x6003, 0x5f: 0x6003, 0x60: 0x6004, 0x61: 0x6004, 0x62: 0x6004, 0x63: 0x6004, - 0x64: 0x6004, 0x65: 0x6004, 0x66: 0x6004, 0x67: 0x6004, 0x68: 0x6004, 0x69: 0x6004, - 0x6a: 0x6004, 0x6b: 0x6004, 0x6c: 0x6004, 0x6d: 0x6004, 0x6e: 0x6004, 0x6f: 0x6004, - 0x70: 0x6004, 0x71: 0x6004, 0x72: 0x6004, 0x73: 0x6004, 0x74: 0x6004, 0x75: 0x6004, - 0x76: 0x6004, 0x77: 0x6004, 0x78: 0x6004, 0x79: 0x6004, 0x7a: 0x6004, 0x7b: 0x6004, - 0x7c: 0x6004, 0x7d: 0x6004, 0x7e: 0x6004, - // Block 0x2, offset 0x80 - // Block 0x3, offset 0xc0 - 0xe1: 0x2000, 0xe2: 0x6005, 0xe3: 0x6005, - 0xe4: 0x2000, 0xe5: 0x6006, 0xe6: 0x6005, 0xe7: 0x2000, 0xe8: 0x2000, - 0xea: 0x2000, 0xec: 0x6007, 0xed: 0x2000, 0xee: 0x2000, 0xef: 0x6008, - 0xf0: 0x2000, 0xf1: 0x2000, 0xf2: 0x2000, 0xf3: 0x2000, 0xf4: 0x2000, - 0xf6: 0x2000, 0xf7: 0x2000, 0xf8: 0x2000, 0xf9: 0x2000, 0xfa: 0x2000, - 0xfc: 0x2000, 0xfd: 0x2000, 0xfe: 0x2000, 0xff: 0x2000, - // Block 0x4, offset 0x100 - 0x106: 0x2000, - 0x110: 0x2000, - 0x117: 0x2000, - 0x118: 0x2000, - 0x11e: 0x2000, 0x11f: 0x2000, 0x120: 0x2000, 0x121: 0x2000, - 0x126: 0x2000, 0x128: 0x2000, 0x129: 0x2000, - 0x12a: 0x2000, 0x12c: 0x2000, 0x12d: 0x2000, - 0x130: 0x2000, 0x132: 0x2000, 0x133: 0x2000, - 0x137: 0x2000, 0x138: 0x2000, 0x139: 0x2000, 0x13a: 0x2000, - 0x13c: 0x2000, 0x13e: 0x2000, - // Block 0x5, offset 0x140 - 0x141: 0x2000, - 0x151: 0x2000, - 0x153: 0x2000, - 0x15b: 0x2000, - 0x166: 0x2000, 0x167: 0x2000, - 0x16b: 0x2000, - 0x171: 0x2000, 0x172: 0x2000, 0x173: 0x2000, - 0x178: 0x2000, - 0x17f: 0x2000, - // Block 0x6, offset 0x180 - 0x180: 0x2000, 0x181: 0x2000, 0x182: 0x2000, 0x184: 0x2000, - 0x188: 0x2000, 0x189: 0x2000, 0x18a: 0x2000, 0x18b: 0x2000, - 0x18d: 0x2000, - 0x192: 0x2000, 0x193: 0x2000, - 0x1a6: 0x2000, 0x1a7: 0x2000, - 0x1ab: 0x2000, - // Block 0x7, offset 0x1c0 - 0x1ce: 0x2000, 0x1d0: 0x2000, - 0x1d2: 0x2000, 0x1d4: 0x2000, 0x1d6: 0x2000, - 0x1d8: 0x2000, 0x1da: 0x2000, 0x1dc: 0x2000, - // Block 0x8, offset 0x200 - 0x211: 0x2000, - 0x221: 0x2000, - // Block 0x9, offset 0x240 - 0x244: 0x2000, - 0x247: 0x2000, 0x249: 0x2000, 0x24a: 0x2000, 0x24b: 0x2000, - 0x24d: 0x2000, 0x250: 0x2000, - 0x258: 0x2000, 0x259: 0x2000, 0x25a: 0x2000, 0x25b: 0x2000, 0x25d: 0x2000, - 0x25f: 0x2000, - // Block 0xa, offset 0x280 - 0x280: 0x2000, 0x281: 0x2000, 0x282: 0x2000, 0x283: 0x2000, 0x284: 0x2000, 0x285: 0x2000, - 0x286: 0x2000, 0x287: 0x2000, 0x288: 0x2000, 0x289: 0x2000, 0x28a: 0x2000, 0x28b: 0x2000, - 0x28c: 0x2000, 0x28d: 0x2000, 0x28e: 0x2000, 0x28f: 0x2000, 0x290: 0x2000, 0x291: 0x2000, - 0x292: 0x2000, 0x293: 0x2000, 0x294: 0x2000, 0x295: 0x2000, 0x296: 0x2000, 0x297: 0x2000, - 0x298: 0x2000, 0x299: 0x2000, 0x29a: 0x2000, 0x29b: 0x2000, 0x29c: 0x2000, 0x29d: 0x2000, - 0x29e: 0x2000, 0x29f: 0x2000, 0x2a0: 0x2000, 0x2a1: 0x2000, 0x2a2: 0x2000, 0x2a3: 0x2000, - 0x2a4: 0x2000, 0x2a5: 0x2000, 0x2a6: 0x2000, 0x2a7: 0x2000, 0x2a8: 0x2000, 0x2a9: 0x2000, - 0x2aa: 0x2000, 0x2ab: 0x2000, 0x2ac: 0x2000, 0x2ad: 0x2000, 0x2ae: 0x2000, 0x2af: 0x2000, - 0x2b0: 0x2000, 0x2b1: 0x2000, 0x2b2: 0x2000, 0x2b3: 0x2000, 0x2b4: 0x2000, 0x2b5: 0x2000, - 0x2b6: 0x2000, 0x2b7: 0x2000, 0x2b8: 0x2000, 0x2b9: 0x2000, 0x2ba: 0x2000, 0x2bb: 0x2000, - 0x2bc: 0x2000, 0x2bd: 0x2000, 0x2be: 0x2000, 0x2bf: 0x2000, - // Block 0xb, offset 0x2c0 - 0x2c0: 0x2000, 0x2c1: 0x2000, 0x2c2: 0x2000, 0x2c3: 0x2000, 0x2c4: 0x2000, 0x2c5: 0x2000, - 0x2c6: 0x2000, 0x2c7: 0x2000, 0x2c8: 0x2000, 0x2c9: 0x2000, 0x2ca: 0x2000, 0x2cb: 0x2000, - 0x2cc: 0x2000, 0x2cd: 0x2000, 0x2ce: 0x2000, 0x2cf: 0x2000, 0x2d0: 0x2000, 0x2d1: 0x2000, - 0x2d2: 0x2000, 0x2d3: 0x2000, 0x2d4: 0x2000, 0x2d5: 0x2000, 0x2d6: 0x2000, 0x2d7: 0x2000, - 0x2d8: 0x2000, 0x2d9: 0x2000, 0x2da: 0x2000, 0x2db: 0x2000, 0x2dc: 0x2000, 0x2dd: 0x2000, - 0x2de: 0x2000, 0x2df: 0x2000, 0x2e0: 0x2000, 0x2e1: 0x2000, 0x2e2: 0x2000, 0x2e3: 0x2000, - 0x2e4: 0x2000, 0x2e5: 0x2000, 0x2e6: 0x2000, 0x2e7: 0x2000, 0x2e8: 0x2000, 0x2e9: 0x2000, - 0x2ea: 0x2000, 0x2eb: 0x2000, 0x2ec: 0x2000, 0x2ed: 0x2000, 0x2ee: 0x2000, 0x2ef: 0x2000, - // Block 0xc, offset 0x300 - 0x311: 0x2000, - 0x312: 0x2000, 0x313: 0x2000, 0x314: 0x2000, 0x315: 0x2000, 0x316: 0x2000, 0x317: 0x2000, - 0x318: 0x2000, 0x319: 0x2000, 0x31a: 0x2000, 0x31b: 0x2000, 0x31c: 0x2000, 0x31d: 0x2000, - 0x31e: 0x2000, 0x31f: 0x2000, 0x320: 0x2000, 0x321: 0x2000, 0x323: 0x2000, - 0x324: 0x2000, 0x325: 0x2000, 0x326: 0x2000, 0x327: 0x2000, 0x328: 0x2000, 0x329: 0x2000, - 0x331: 0x2000, 0x332: 0x2000, 0x333: 0x2000, 0x334: 0x2000, 0x335: 0x2000, - 0x336: 0x2000, 0x337: 0x2000, 0x338: 0x2000, 0x339: 0x2000, 0x33a: 0x2000, 0x33b: 0x2000, - 0x33c: 0x2000, 0x33d: 0x2000, 0x33e: 0x2000, 0x33f: 0x2000, - // Block 0xd, offset 0x340 - 0x340: 0x2000, 0x341: 0x2000, 0x343: 0x2000, 0x344: 0x2000, 0x345: 0x2000, - 0x346: 0x2000, 0x347: 0x2000, 0x348: 0x2000, 0x349: 0x2000, - // Block 0xe, offset 0x380 - 0x381: 0x2000, - 0x390: 0x2000, 0x391: 0x2000, - 0x392: 0x2000, 0x393: 0x2000, 0x394: 0x2000, 0x395: 0x2000, 0x396: 0x2000, 0x397: 0x2000, - 0x398: 0x2000, 0x399: 0x2000, 0x39a: 0x2000, 0x39b: 0x2000, 0x39c: 0x2000, 0x39d: 0x2000, - 0x39e: 0x2000, 0x39f: 0x2000, 0x3a0: 0x2000, 0x3a1: 0x2000, 0x3a2: 0x2000, 0x3a3: 0x2000, - 0x3a4: 0x2000, 0x3a5: 0x2000, 0x3a6: 0x2000, 0x3a7: 0x2000, 0x3a8: 0x2000, 0x3a9: 0x2000, - 0x3aa: 0x2000, 0x3ab: 0x2000, 0x3ac: 0x2000, 0x3ad: 0x2000, 0x3ae: 0x2000, 0x3af: 0x2000, - 0x3b0: 0x2000, 0x3b1: 0x2000, 0x3b2: 0x2000, 0x3b3: 0x2000, 0x3b4: 0x2000, 0x3b5: 0x2000, - 0x3b6: 0x2000, 0x3b7: 0x2000, 0x3b8: 0x2000, 0x3b9: 0x2000, 0x3ba: 0x2000, 0x3bb: 0x2000, - 0x3bc: 0x2000, 0x3bd: 0x2000, 0x3be: 0x2000, 0x3bf: 0x2000, - // Block 0xf, offset 0x3c0 - 0x3c0: 0x2000, 0x3c1: 0x2000, 0x3c2: 0x2000, 0x3c3: 0x2000, 0x3c4: 0x2000, 0x3c5: 0x2000, - 0x3c6: 0x2000, 0x3c7: 0x2000, 0x3c8: 0x2000, 0x3c9: 0x2000, 0x3ca: 0x2000, 0x3cb: 0x2000, - 0x3cc: 0x2000, 0x3cd: 0x2000, 0x3ce: 0x2000, 0x3cf: 0x2000, 0x3d1: 0x2000, - // Block 0x10, offset 0x400 - 0x400: 0x4000, 0x401: 0x4000, 0x402: 0x4000, 0x403: 0x4000, 0x404: 0x4000, 0x405: 0x4000, - 0x406: 0x4000, 0x407: 0x4000, 0x408: 0x4000, 0x409: 0x4000, 0x40a: 0x4000, 0x40b: 0x4000, - 0x40c: 0x4000, 0x40d: 0x4000, 0x40e: 0x4000, 0x40f: 0x4000, 0x410: 0x4000, 0x411: 0x4000, - 0x412: 0x4000, 0x413: 0x4000, 0x414: 0x4000, 0x415: 0x4000, 0x416: 0x4000, 0x417: 0x4000, - 0x418: 0x4000, 0x419: 0x4000, 0x41a: 0x4000, 0x41b: 0x4000, 0x41c: 0x4000, 0x41d: 0x4000, - 0x41e: 0x4000, 0x41f: 0x4000, 0x420: 0x4000, 0x421: 0x4000, 0x422: 0x4000, 0x423: 0x4000, - 0x424: 0x4000, 0x425: 0x4000, 0x426: 0x4000, 0x427: 0x4000, 0x428: 0x4000, 0x429: 0x4000, - 0x42a: 0x4000, 0x42b: 0x4000, 0x42c: 0x4000, 0x42d: 0x4000, 0x42e: 0x4000, 0x42f: 0x4000, - 0x430: 0x4000, 0x431: 0x4000, 0x432: 0x4000, 0x433: 0x4000, 0x434: 0x4000, 0x435: 0x4000, - 0x436: 0x4000, 0x437: 0x4000, 0x438: 0x4000, 0x439: 0x4000, 0x43a: 0x4000, 0x43b: 0x4000, - 0x43c: 0x4000, 0x43d: 0x4000, 0x43e: 0x4000, 0x43f: 0x4000, - // Block 0x11, offset 0x440 - 0x440: 0x4000, 0x441: 0x4000, 0x442: 0x4000, 0x443: 0x4000, 0x444: 0x4000, 0x445: 0x4000, - 0x446: 0x4000, 0x447: 0x4000, 0x448: 0x4000, 0x449: 0x4000, 0x44a: 0x4000, 0x44b: 0x4000, - 0x44c: 0x4000, 0x44d: 0x4000, 0x44e: 0x4000, 0x44f: 0x4000, 0x450: 0x4000, 0x451: 0x4000, - 0x452: 0x4000, 0x453: 0x4000, 0x454: 0x4000, 0x455: 0x4000, 0x456: 0x4000, 0x457: 0x4000, - 0x458: 0x4000, 0x459: 0x4000, 0x45a: 0x4000, 0x45b: 0x4000, 0x45c: 0x4000, 0x45d: 0x4000, - 0x45e: 0x4000, 0x45f: 0x4000, - // Block 0x12, offset 0x480 - 0x490: 0x2000, - 0x493: 0x2000, 0x494: 0x2000, 0x495: 0x2000, 0x496: 0x2000, - 0x498: 0x2000, 0x499: 0x2000, 0x49c: 0x2000, 0x49d: 0x2000, - 0x4a0: 0x2000, 0x4a1: 0x2000, 0x4a2: 0x2000, - 0x4a4: 0x2000, 0x4a5: 0x2000, 0x4a6: 0x2000, 0x4a7: 0x2000, - 0x4b0: 0x2000, 0x4b2: 0x2000, 0x4b3: 0x2000, 0x4b5: 0x2000, - 0x4bb: 0x2000, - 0x4be: 0x2000, - // Block 0x13, offset 0x4c0 - 0x4f4: 0x2000, - 0x4ff: 0x2000, - // Block 0x14, offset 0x500 - 0x501: 0x2000, 0x502: 0x2000, 0x503: 0x2000, 0x504: 0x2000, - 0x529: 0xa009, - 0x52c: 0x2000, - // Block 0x15, offset 0x540 - 0x543: 0x2000, 0x545: 0x2000, - 0x549: 0x2000, - 0x553: 0x2000, 0x556: 0x2000, - 0x561: 0x2000, 0x562: 0x2000, - 0x566: 0x2000, - 0x56b: 0x2000, - // Block 0x16, offset 0x580 - 0x593: 0x2000, 0x594: 0x2000, - 0x59b: 0x2000, 0x59c: 0x2000, 0x59d: 0x2000, - 0x59e: 0x2000, 0x5a0: 0x2000, 0x5a1: 0x2000, 0x5a2: 0x2000, 0x5a3: 0x2000, - 0x5a4: 0x2000, 0x5a5: 0x2000, 0x5a6: 0x2000, 0x5a7: 0x2000, 0x5a8: 0x2000, 0x5a9: 0x2000, - 0x5aa: 0x2000, 0x5ab: 0x2000, - 0x5b0: 0x2000, 0x5b1: 0x2000, 0x5b2: 0x2000, 0x5b3: 0x2000, 0x5b4: 0x2000, 0x5b5: 0x2000, - 0x5b6: 0x2000, 0x5b7: 0x2000, 0x5b8: 0x2000, 0x5b9: 0x2000, - // Block 0x17, offset 0x5c0 - 0x5c9: 0x2000, - 0x5d0: 0x200a, 0x5d1: 0x200b, - 0x5d2: 0x200a, 0x5d3: 0x200c, 0x5d4: 0x2000, 0x5d5: 0x2000, 0x5d6: 0x2000, 0x5d7: 0x2000, - 0x5d8: 0x2000, 0x5d9: 0x2000, - 0x5f8: 0x2000, 0x5f9: 0x2000, - // Block 0x18, offset 0x600 - 0x612: 0x2000, 0x614: 0x2000, - 0x627: 0x2000, - // Block 0x19, offset 0x640 - 0x640: 0x2000, 0x642: 0x2000, 0x643: 0x2000, - 0x647: 0x2000, 0x648: 0x2000, 0x64b: 0x2000, - 0x64f: 0x2000, 0x651: 0x2000, - 0x655: 0x2000, - 0x65a: 0x2000, 0x65d: 0x2000, - 0x65e: 0x2000, 0x65f: 0x2000, 0x660: 0x2000, 0x663: 0x2000, - 0x665: 0x2000, 0x667: 0x2000, 0x668: 0x2000, 0x669: 0x2000, - 0x66a: 0x2000, 0x66b: 0x2000, 0x66c: 0x2000, 0x66e: 0x2000, - 0x674: 0x2000, 0x675: 0x2000, - 0x676: 0x2000, 0x677: 0x2000, - 0x67c: 0x2000, 0x67d: 0x2000, - // Block 0x1a, offset 0x680 - 0x688: 0x2000, - 0x68c: 0x2000, - 0x692: 0x2000, - 0x6a0: 0x2000, 0x6a1: 0x2000, - 0x6a4: 0x2000, 0x6a5: 0x2000, 0x6a6: 0x2000, 0x6a7: 0x2000, - 0x6aa: 0x2000, 0x6ab: 0x2000, 0x6ae: 0x2000, 0x6af: 0x2000, - // Block 0x1b, offset 0x6c0 - 0x6c2: 0x2000, 0x6c3: 0x2000, - 0x6c6: 0x2000, 0x6c7: 0x2000, - 0x6d5: 0x2000, - 0x6d9: 0x2000, - 0x6e5: 0x2000, - 0x6ff: 0x2000, - // Block 0x1c, offset 0x700 - 0x712: 0x2000, - 0x71a: 0x4000, 0x71b: 0x4000, - 0x729: 0x4000, - 0x72a: 0x4000, - // Block 0x1d, offset 0x740 - 0x769: 0x4000, - 0x76a: 0x4000, 0x76b: 0x4000, 0x76c: 0x4000, - 0x770: 0x4000, 0x773: 0x4000, - // Block 0x1e, offset 0x780 - 0x7a0: 0x2000, 0x7a1: 0x2000, 0x7a2: 0x2000, 0x7a3: 0x2000, - 0x7a4: 0x2000, 0x7a5: 0x2000, 0x7a6: 0x2000, 0x7a7: 0x2000, 0x7a8: 0x2000, 0x7a9: 0x2000, - 0x7aa: 0x2000, 0x7ab: 0x2000, 0x7ac: 0x2000, 0x7ad: 0x2000, 0x7ae: 0x2000, 0x7af: 0x2000, - 0x7b0: 0x2000, 0x7b1: 0x2000, 0x7b2: 0x2000, 0x7b3: 0x2000, 0x7b4: 0x2000, 0x7b5: 0x2000, - 0x7b6: 0x2000, 0x7b7: 0x2000, 0x7b8: 0x2000, 0x7b9: 0x2000, 0x7ba: 0x2000, 0x7bb: 0x2000, - 0x7bc: 0x2000, 0x7bd: 0x2000, 0x7be: 0x2000, 0x7bf: 0x2000, - // Block 0x1f, offset 0x7c0 - 0x7c0: 0x2000, 0x7c1: 0x2000, 0x7c2: 0x2000, 0x7c3: 0x2000, 0x7c4: 0x2000, 0x7c5: 0x2000, - 0x7c6: 0x2000, 0x7c7: 0x2000, 0x7c8: 0x2000, 0x7c9: 0x2000, 0x7ca: 0x2000, 0x7cb: 0x2000, - 0x7cc: 0x2000, 0x7cd: 0x2000, 0x7ce: 0x2000, 0x7cf: 0x2000, 0x7d0: 0x2000, 0x7d1: 0x2000, - 0x7d2: 0x2000, 0x7d3: 0x2000, 0x7d4: 0x2000, 0x7d5: 0x2000, 0x7d6: 0x2000, 0x7d7: 0x2000, - 0x7d8: 0x2000, 0x7d9: 0x2000, 0x7da: 0x2000, 0x7db: 0x2000, 0x7dc: 0x2000, 0x7dd: 0x2000, - 0x7de: 0x2000, 0x7df: 0x2000, 0x7e0: 0x2000, 0x7e1: 0x2000, 0x7e2: 0x2000, 0x7e3: 0x2000, - 0x7e4: 0x2000, 0x7e5: 0x2000, 0x7e6: 0x2000, 0x7e7: 0x2000, 0x7e8: 0x2000, 0x7e9: 0x2000, - 0x7eb: 0x2000, 0x7ec: 0x2000, 0x7ed: 0x2000, 0x7ee: 0x2000, 0x7ef: 0x2000, - 0x7f0: 0x2000, 0x7f1: 0x2000, 0x7f2: 0x2000, 0x7f3: 0x2000, 0x7f4: 0x2000, 0x7f5: 0x2000, - 0x7f6: 0x2000, 0x7f7: 0x2000, 0x7f8: 0x2000, 0x7f9: 0x2000, 0x7fa: 0x2000, 0x7fb: 0x2000, - 0x7fc: 0x2000, 0x7fd: 0x2000, 0x7fe: 0x2000, 0x7ff: 0x2000, - // Block 0x20, offset 0x800 - 0x800: 0x2000, 0x801: 0x2000, 0x802: 0x200d, 0x803: 0x2000, 0x804: 0x2000, 0x805: 0x2000, - 0x806: 0x2000, 0x807: 0x2000, 0x808: 0x2000, 0x809: 0x2000, 0x80a: 0x2000, 0x80b: 0x2000, - 0x80c: 0x2000, 0x80d: 0x2000, 0x80e: 0x2000, 0x80f: 0x2000, 0x810: 0x2000, 0x811: 0x2000, - 0x812: 0x2000, 0x813: 0x2000, 0x814: 0x2000, 0x815: 0x2000, 0x816: 0x2000, 0x817: 0x2000, - 0x818: 0x2000, 0x819: 0x2000, 0x81a: 0x2000, 0x81b: 0x2000, 0x81c: 0x2000, 0x81d: 0x2000, - 0x81e: 0x2000, 0x81f: 0x2000, 0x820: 0x2000, 0x821: 0x2000, 0x822: 0x2000, 0x823: 0x2000, - 0x824: 0x2000, 0x825: 0x2000, 0x826: 0x2000, 0x827: 0x2000, 0x828: 0x2000, 0x829: 0x2000, - 0x82a: 0x2000, 0x82b: 0x2000, 0x82c: 0x2000, 0x82d: 0x2000, 0x82e: 0x2000, 0x82f: 0x2000, - 0x830: 0x2000, 0x831: 0x2000, 0x832: 0x2000, 0x833: 0x2000, 0x834: 0x2000, 0x835: 0x2000, - 0x836: 0x2000, 0x837: 0x2000, 0x838: 0x2000, 0x839: 0x2000, 0x83a: 0x2000, 0x83b: 0x2000, - 0x83c: 0x2000, 0x83d: 0x2000, 0x83e: 0x2000, 0x83f: 0x2000, - // Block 0x21, offset 0x840 - 0x840: 0x2000, 0x841: 0x2000, 0x842: 0x2000, 0x843: 0x2000, 0x844: 0x2000, 0x845: 0x2000, - 0x846: 0x2000, 0x847: 0x2000, 0x848: 0x2000, 0x849: 0x2000, 0x84a: 0x2000, 0x84b: 0x2000, - 0x850: 0x2000, 0x851: 0x2000, - 0x852: 0x2000, 0x853: 0x2000, 0x854: 0x2000, 0x855: 0x2000, 0x856: 0x2000, 0x857: 0x2000, - 0x858: 0x2000, 0x859: 0x2000, 0x85a: 0x2000, 0x85b: 0x2000, 0x85c: 0x2000, 0x85d: 0x2000, - 0x85e: 0x2000, 0x85f: 0x2000, 0x860: 0x2000, 0x861: 0x2000, 0x862: 0x2000, 0x863: 0x2000, - 0x864: 0x2000, 0x865: 0x2000, 0x866: 0x2000, 0x867: 0x2000, 0x868: 0x2000, 0x869: 0x2000, - 0x86a: 0x2000, 0x86b: 0x2000, 0x86c: 0x2000, 0x86d: 0x2000, 0x86e: 0x2000, 0x86f: 0x2000, - 0x870: 0x2000, 0x871: 0x2000, 0x872: 0x2000, 0x873: 0x2000, - // Block 0x22, offset 0x880 - 0x880: 0x2000, 0x881: 0x2000, 0x882: 0x2000, 0x883: 0x2000, 0x884: 0x2000, 0x885: 0x2000, - 0x886: 0x2000, 0x887: 0x2000, 0x888: 0x2000, 0x889: 0x2000, 0x88a: 0x2000, 0x88b: 0x2000, - 0x88c: 0x2000, 0x88d: 0x2000, 0x88e: 0x2000, 0x88f: 0x2000, - 0x892: 0x2000, 0x893: 0x2000, 0x894: 0x2000, 0x895: 0x2000, - 0x8a0: 0x200e, 0x8a1: 0x2000, 0x8a3: 0x2000, - 0x8a4: 0x2000, 0x8a5: 0x2000, 0x8a6: 0x2000, 0x8a7: 0x2000, 0x8a8: 0x2000, 0x8a9: 0x2000, - 0x8b2: 0x2000, 0x8b3: 0x2000, - 0x8b6: 0x2000, 0x8b7: 0x2000, - 0x8bc: 0x2000, 0x8bd: 0x2000, - // Block 0x23, offset 0x8c0 - 0x8c0: 0x2000, 0x8c1: 0x2000, - 0x8c6: 0x2000, 0x8c7: 0x2000, 0x8c8: 0x2000, 0x8cb: 0x200f, - 0x8ce: 0x2000, 0x8cf: 0x2000, 0x8d0: 0x2000, 0x8d1: 0x2000, - 0x8e2: 0x2000, 0x8e3: 0x2000, - 0x8e4: 0x2000, 0x8e5: 0x2000, - 0x8ef: 0x2000, - 0x8fd: 0x4000, 0x8fe: 0x4000, - // Block 0x24, offset 0x900 - 0x905: 0x2000, - 0x906: 0x2000, 0x909: 0x2000, - 0x90e: 0x2000, 0x90f: 0x2000, - 0x914: 0x4000, 0x915: 0x4000, - 0x91c: 0x2000, - 0x91e: 0x2000, - // Block 0x25, offset 0x940 - 0x940: 0x2000, 0x942: 0x2000, - 0x948: 0x4000, 0x949: 0x4000, 0x94a: 0x4000, 0x94b: 0x4000, - 0x94c: 0x4000, 0x94d: 0x4000, 0x94e: 0x4000, 0x94f: 0x4000, 0x950: 0x4000, 0x951: 0x4000, - 0x952: 0x4000, 0x953: 0x4000, - 0x960: 0x2000, 0x961: 0x2000, 0x963: 0x2000, - 0x964: 0x2000, 0x965: 0x2000, 0x967: 0x2000, 0x968: 0x2000, 0x969: 0x2000, - 0x96a: 0x2000, 0x96c: 0x2000, 0x96d: 0x2000, 0x96f: 0x2000, - 0x97f: 0x4000, - // Block 0x26, offset 0x980 - 0x993: 0x4000, - 0x99e: 0x2000, 0x99f: 0x2000, 0x9a1: 0x4000, - 0x9aa: 0x4000, 0x9ab: 0x4000, - 0x9bd: 0x4000, 0x9be: 0x4000, 0x9bf: 0x2000, - // Block 0x27, offset 0x9c0 - 0x9c4: 0x4000, 0x9c5: 0x4000, - 0x9c6: 0x2000, 0x9c7: 0x2000, 0x9c8: 0x2000, 0x9c9: 0x2000, 0x9ca: 0x2000, 0x9cb: 0x2000, - 0x9cc: 0x2000, 0x9cd: 0x2000, 0x9ce: 0x4000, 0x9cf: 0x2000, 0x9d0: 0x2000, 0x9d1: 0x2000, - 0x9d2: 0x2000, 0x9d3: 0x2000, 0x9d4: 0x4000, 0x9d5: 0x2000, 0x9d6: 0x2000, 0x9d7: 0x2000, - 0x9d8: 0x2000, 0x9d9: 0x2000, 0x9da: 0x2000, 0x9db: 0x2000, 0x9dc: 0x2000, 0x9dd: 0x2000, - 0x9de: 0x2000, 0x9df: 0x2000, 0x9e0: 0x2000, 0x9e1: 0x2000, 0x9e3: 0x2000, - 0x9e8: 0x2000, 0x9e9: 0x2000, - 0x9ea: 0x4000, 0x9eb: 0x2000, 0x9ec: 0x2000, 0x9ed: 0x2000, 0x9ee: 0x2000, 0x9ef: 0x2000, - 0x9f0: 0x2000, 0x9f1: 0x2000, 0x9f2: 0x4000, 0x9f3: 0x4000, 0x9f4: 0x2000, 0x9f5: 0x4000, - 0x9f6: 0x2000, 0x9f7: 0x2000, 0x9f8: 0x2000, 0x9f9: 0x2000, 0x9fa: 0x4000, 0x9fb: 0x2000, - 0x9fc: 0x2000, 0x9fd: 0x4000, 0x9fe: 0x2000, 0x9ff: 0x2000, - // Block 0x28, offset 0xa00 - 0xa05: 0x4000, - 0xa0a: 0x4000, 0xa0b: 0x4000, - 0xa28: 0x4000, - 0xa3d: 0x2000, - // Block 0x29, offset 0xa40 - 0xa4c: 0x4000, 0xa4e: 0x4000, - 0xa53: 0x4000, 0xa54: 0x4000, 0xa55: 0x4000, 0xa57: 0x4000, - 0xa76: 0x2000, 0xa77: 0x2000, 0xa78: 0x2000, 0xa79: 0x2000, 0xa7a: 0x2000, 0xa7b: 0x2000, - 0xa7c: 0x2000, 0xa7d: 0x2000, 0xa7e: 0x2000, 0xa7f: 0x2000, - // Block 0x2a, offset 0xa80 - 0xa95: 0x4000, 0xa96: 0x4000, 0xa97: 0x4000, - 0xab0: 0x4000, - 0xabf: 0x4000, - // Block 0x2b, offset 0xac0 - 0xae6: 0x6000, 0xae7: 0x6000, 0xae8: 0x6000, 0xae9: 0x6000, - 0xaea: 0x6000, 0xaeb: 0x6000, 0xaec: 0x6000, 0xaed: 0x6000, - // Block 0x2c, offset 0xb00 - 0xb05: 0x6010, - 0xb06: 0x6011, - // Block 0x2d, offset 0xb40 - 0xb5b: 0x4000, 0xb5c: 0x4000, - // Block 0x2e, offset 0xb80 - 0xb90: 0x4000, - 0xb95: 0x4000, 0xb96: 0x2000, 0xb97: 0x2000, - 0xb98: 0x2000, 0xb99: 0x2000, - // Block 0x2f, offset 0xbc0 - 0xbc0: 0x4000, 0xbc1: 0x4000, 0xbc2: 0x4000, 0xbc3: 0x4000, 0xbc4: 0x4000, 0xbc5: 0x4000, - 0xbc6: 0x4000, 0xbc7: 0x4000, 0xbc8: 0x4000, 0xbc9: 0x4000, 0xbca: 0x4000, 0xbcb: 0x4000, - 0xbcc: 0x4000, 0xbcd: 0x4000, 0xbce: 0x4000, 0xbcf: 0x4000, 0xbd0: 0x4000, 0xbd1: 0x4000, - 0xbd2: 0x4000, 0xbd3: 0x4000, 0xbd4: 0x4000, 0xbd5: 0x4000, 0xbd6: 0x4000, 0xbd7: 0x4000, - 0xbd8: 0x4000, 0xbd9: 0x4000, 0xbdb: 0x4000, 0xbdc: 0x4000, 0xbdd: 0x4000, - 0xbde: 0x4000, 0xbdf: 0x4000, 0xbe0: 0x4000, 0xbe1: 0x4000, 0xbe2: 0x4000, 0xbe3: 0x4000, - 0xbe4: 0x4000, 0xbe5: 0x4000, 0xbe6: 0x4000, 0xbe7: 0x4000, 0xbe8: 0x4000, 0xbe9: 0x4000, - 0xbea: 0x4000, 0xbeb: 0x4000, 0xbec: 0x4000, 0xbed: 0x4000, 0xbee: 0x4000, 0xbef: 0x4000, - 0xbf0: 0x4000, 0xbf1: 0x4000, 0xbf2: 0x4000, 0xbf3: 0x4000, 0xbf4: 0x4000, 0xbf5: 0x4000, - 0xbf6: 0x4000, 0xbf7: 0x4000, 0xbf8: 0x4000, 0xbf9: 0x4000, 0xbfa: 0x4000, 0xbfb: 0x4000, - 0xbfc: 0x4000, 0xbfd: 0x4000, 0xbfe: 0x4000, 0xbff: 0x4000, - // Block 0x30, offset 0xc00 - 0xc00: 0x4000, 0xc01: 0x4000, 0xc02: 0x4000, 0xc03: 0x4000, 0xc04: 0x4000, 0xc05: 0x4000, - 0xc06: 0x4000, 0xc07: 0x4000, 0xc08: 0x4000, 0xc09: 0x4000, 0xc0a: 0x4000, 0xc0b: 0x4000, - 0xc0c: 0x4000, 0xc0d: 0x4000, 0xc0e: 0x4000, 0xc0f: 0x4000, 0xc10: 0x4000, 0xc11: 0x4000, - 0xc12: 0x4000, 0xc13: 0x4000, 0xc14: 0x4000, 0xc15: 0x4000, 0xc16: 0x4000, 0xc17: 0x4000, - 0xc18: 0x4000, 0xc19: 0x4000, 0xc1a: 0x4000, 0xc1b: 0x4000, 0xc1c: 0x4000, 0xc1d: 0x4000, - 0xc1e: 0x4000, 0xc1f: 0x4000, 0xc20: 0x4000, 0xc21: 0x4000, 0xc22: 0x4000, 0xc23: 0x4000, - 0xc24: 0x4000, 0xc25: 0x4000, 0xc26: 0x4000, 0xc27: 0x4000, 0xc28: 0x4000, 0xc29: 0x4000, - 0xc2a: 0x4000, 0xc2b: 0x4000, 0xc2c: 0x4000, 0xc2d: 0x4000, 0xc2e: 0x4000, 0xc2f: 0x4000, - 0xc30: 0x4000, 0xc31: 0x4000, 0xc32: 0x4000, 0xc33: 0x4000, - // Block 0x31, offset 0xc40 - 0xc40: 0x4000, 0xc41: 0x4000, 0xc42: 0x4000, 0xc43: 0x4000, 0xc44: 0x4000, 0xc45: 0x4000, - 0xc46: 0x4000, 0xc47: 0x4000, 0xc48: 0x4000, 0xc49: 0x4000, 0xc4a: 0x4000, 0xc4b: 0x4000, - 0xc4c: 0x4000, 0xc4d: 0x4000, 0xc4e: 0x4000, 0xc4f: 0x4000, 0xc50: 0x4000, 0xc51: 0x4000, - 0xc52: 0x4000, 0xc53: 0x4000, 0xc54: 0x4000, 0xc55: 0x4000, - 0xc70: 0x4000, 0xc71: 0x4000, 0xc72: 0x4000, 0xc73: 0x4000, 0xc74: 0x4000, 0xc75: 0x4000, - 0xc76: 0x4000, 0xc77: 0x4000, 0xc78: 0x4000, 0xc79: 0x4000, 0xc7a: 0x4000, 0xc7b: 0x4000, - // Block 0x32, offset 0xc80 - 0xc80: 0x9012, 0xc81: 0x4013, 0xc82: 0x4014, 0xc83: 0x4000, 0xc84: 0x4000, 0xc85: 0x4000, - 0xc86: 0x4000, 0xc87: 0x4000, 0xc88: 0x4000, 0xc89: 0x4000, 0xc8a: 0x4000, 0xc8b: 0x4000, - 0xc8c: 0x4015, 0xc8d: 0x4015, 0xc8e: 0x4000, 0xc8f: 0x4000, 0xc90: 0x4000, 0xc91: 0x4000, - 0xc92: 0x4000, 0xc93: 0x4000, 0xc94: 0x4000, 0xc95: 0x4000, 0xc96: 0x4000, 0xc97: 0x4000, - 0xc98: 0x4000, 0xc99: 0x4000, 0xc9a: 0x4000, 0xc9b: 0x4000, 0xc9c: 0x4000, 0xc9d: 0x4000, - 0xc9e: 0x4000, 0xc9f: 0x4000, 0xca0: 0x4000, 0xca1: 0x4000, 0xca2: 0x4000, 0xca3: 0x4000, - 0xca4: 0x4000, 0xca5: 0x4000, 0xca6: 0x4000, 0xca7: 0x4000, 0xca8: 0x4000, 0xca9: 0x4000, - 0xcaa: 0x4000, 0xcab: 0x4000, 0xcac: 0x4000, 0xcad: 0x4000, 0xcae: 0x4000, 0xcaf: 0x4000, - 0xcb0: 0x4000, 0xcb1: 0x4000, 0xcb2: 0x4000, 0xcb3: 0x4000, 0xcb4: 0x4000, 0xcb5: 0x4000, - 0xcb6: 0x4000, 0xcb7: 0x4000, 0xcb8: 0x4000, 0xcb9: 0x4000, 0xcba: 0x4000, 0xcbb: 0x4000, - 0xcbc: 0x4000, 0xcbd: 0x4000, 0xcbe: 0x4000, - // Block 0x33, offset 0xcc0 - 0xcc1: 0x4000, 0xcc2: 0x4000, 0xcc3: 0x4000, 0xcc4: 0x4000, 0xcc5: 0x4000, - 0xcc6: 0x4000, 0xcc7: 0x4000, 0xcc8: 0x4000, 0xcc9: 0x4000, 0xcca: 0x4000, 0xccb: 0x4000, - 0xccc: 0x4000, 0xccd: 0x4000, 0xcce: 0x4000, 0xccf: 0x4000, 0xcd0: 0x4000, 0xcd1: 0x4000, - 0xcd2: 0x4000, 0xcd3: 0x4000, 0xcd4: 0x4000, 0xcd5: 0x4000, 0xcd6: 0x4000, 0xcd7: 0x4000, - 0xcd8: 0x4000, 0xcd9: 0x4000, 0xcda: 0x4000, 0xcdb: 0x4000, 0xcdc: 0x4000, 0xcdd: 0x4000, - 0xcde: 0x4000, 0xcdf: 0x4000, 0xce0: 0x4000, 0xce1: 0x4000, 0xce2: 0x4000, 0xce3: 0x4000, - 0xce4: 0x4000, 0xce5: 0x4000, 0xce6: 0x4000, 0xce7: 0x4000, 0xce8: 0x4000, 0xce9: 0x4000, - 0xcea: 0x4000, 0xceb: 0x4000, 0xcec: 0x4000, 0xced: 0x4000, 0xcee: 0x4000, 0xcef: 0x4000, - 0xcf0: 0x4000, 0xcf1: 0x4000, 0xcf2: 0x4000, 0xcf3: 0x4000, 0xcf4: 0x4000, 0xcf5: 0x4000, - 0xcf6: 0x4000, 0xcf7: 0x4000, 0xcf8: 0x4000, 0xcf9: 0x4000, 0xcfa: 0x4000, 0xcfb: 0x4000, - 0xcfc: 0x4000, 0xcfd: 0x4000, 0xcfe: 0x4000, 0xcff: 0x4000, - // Block 0x34, offset 0xd00 - 0xd00: 0x4000, 0xd01: 0x4000, 0xd02: 0x4000, 0xd03: 0x4000, 0xd04: 0x4000, 0xd05: 0x4000, - 0xd06: 0x4000, 0xd07: 0x4000, 0xd08: 0x4000, 0xd09: 0x4000, 0xd0a: 0x4000, 0xd0b: 0x4000, - 0xd0c: 0x4000, 0xd0d: 0x4000, 0xd0e: 0x4000, 0xd0f: 0x4000, 0xd10: 0x4000, 0xd11: 0x4000, - 0xd12: 0x4000, 0xd13: 0x4000, 0xd14: 0x4000, 0xd15: 0x4000, 0xd16: 0x4000, - 0xd19: 0x4016, 0xd1a: 0x4017, 0xd1b: 0x4000, 0xd1c: 0x4000, 0xd1d: 0x4000, - 0xd1e: 0x4000, 0xd1f: 0x4000, 0xd20: 0x4000, 0xd21: 0x4018, 0xd22: 0x4019, 0xd23: 0x401a, - 0xd24: 0x401b, 0xd25: 0x401c, 0xd26: 0x401d, 0xd27: 0x401e, 0xd28: 0x401f, 0xd29: 0x4020, - 0xd2a: 0x4021, 0xd2b: 0x4022, 0xd2c: 0x4000, 0xd2d: 0x4010, 0xd2e: 0x4000, 0xd2f: 0x4023, - 0xd30: 0x4000, 0xd31: 0x4024, 0xd32: 0x4000, 0xd33: 0x4025, 0xd34: 0x4000, 0xd35: 0x4026, - 0xd36: 0x4000, 0xd37: 0x401a, 0xd38: 0x4000, 0xd39: 0x4027, 0xd3a: 0x4000, 0xd3b: 0x4028, - 0xd3c: 0x4000, 0xd3d: 0x4020, 0xd3e: 0x4000, 0xd3f: 0x4029, - // Block 0x35, offset 0xd40 - 0xd40: 0x4000, 0xd41: 0x402a, 0xd42: 0x4000, 0xd43: 0x402b, 0xd44: 0x402c, 0xd45: 0x4000, - 0xd46: 0x4017, 0xd47: 0x4000, 0xd48: 0x402d, 0xd49: 0x4000, 0xd4a: 0x402e, 0xd4b: 0x402f, - 0xd4c: 0x4030, 0xd4d: 0x4017, 0xd4e: 0x4016, 0xd4f: 0x4017, 0xd50: 0x4000, 0xd51: 0x4000, - 0xd52: 0x4031, 0xd53: 0x4000, 0xd54: 0x4000, 0xd55: 0x4031, 0xd56: 0x4000, 0xd57: 0x4000, - 0xd58: 0x4032, 0xd59: 0x4000, 0xd5a: 0x4000, 0xd5b: 0x4032, 0xd5c: 0x4000, 0xd5d: 0x4000, - 0xd5e: 0x4033, 0xd5f: 0x402e, 0xd60: 0x4034, 0xd61: 0x4035, 0xd62: 0x4034, 0xd63: 0x4036, - 0xd64: 0x4037, 0xd65: 0x4024, 0xd66: 0x4035, 0xd67: 0x4025, 0xd68: 0x4038, 0xd69: 0x4038, - 0xd6a: 0x4039, 0xd6b: 0x4039, 0xd6c: 0x403a, 0xd6d: 0x403a, 0xd6e: 0x4000, 0xd6f: 0x4035, - 0xd70: 0x4000, 0xd71: 0x4000, 0xd72: 0x403b, 0xd73: 0x403c, 0xd74: 0x4000, 0xd75: 0x4000, - 0xd76: 0x4000, 0xd77: 0x4000, 0xd78: 0x4000, 0xd79: 0x4000, 0xd7a: 0x4000, 0xd7b: 0x403d, - 0xd7c: 0x401c, 0xd7d: 0x4000, 0xd7e: 0x4000, 0xd7f: 0x4000, - // Block 0x36, offset 0xd80 - 0xd85: 0x4000, - 0xd86: 0x4000, 0xd87: 0x4000, 0xd88: 0x4000, 0xd89: 0x4000, 0xd8a: 0x4000, 0xd8b: 0x4000, - 0xd8c: 0x4000, 0xd8d: 0x4000, 0xd8e: 0x4000, 0xd8f: 0x4000, 0xd90: 0x4000, 0xd91: 0x4000, - 0xd92: 0x4000, 0xd93: 0x4000, 0xd94: 0x4000, 0xd95: 0x4000, 0xd96: 0x4000, 0xd97: 0x4000, - 0xd98: 0x4000, 0xd99: 0x4000, 0xd9a: 0x4000, 0xd9b: 0x4000, 0xd9c: 0x4000, 0xd9d: 0x4000, - 0xd9e: 0x4000, 0xd9f: 0x4000, 0xda0: 0x4000, 0xda1: 0x4000, 0xda2: 0x4000, 0xda3: 0x4000, - 0xda4: 0x4000, 0xda5: 0x4000, 0xda6: 0x4000, 0xda7: 0x4000, 0xda8: 0x4000, 0xda9: 0x4000, - 0xdaa: 0x4000, 0xdab: 0x4000, 0xdac: 0x4000, 0xdad: 0x4000, - 0xdb1: 0x403e, 0xdb2: 0x403e, 0xdb3: 0x403e, 0xdb4: 0x403e, 0xdb5: 0x403e, - 0xdb6: 0x403e, 0xdb7: 0x403e, 0xdb8: 0x403e, 0xdb9: 0x403e, 0xdba: 0x403e, 0xdbb: 0x403e, - 0xdbc: 0x403e, 0xdbd: 0x403e, 0xdbe: 0x403e, 0xdbf: 0x403e, - // Block 0x37, offset 0xdc0 - 0xdc0: 0x4037, 0xdc1: 0x4037, 0xdc2: 0x4037, 0xdc3: 0x4037, 0xdc4: 0x4037, 0xdc5: 0x4037, - 0xdc6: 0x4037, 0xdc7: 0x4037, 0xdc8: 0x4037, 0xdc9: 0x4037, 0xdca: 0x4037, 0xdcb: 0x4037, - 0xdcc: 0x4037, 0xdcd: 0x4037, 0xdce: 0x4037, 0xdcf: 0x400e, 0xdd0: 0x403f, 0xdd1: 0x4040, - 0xdd2: 0x4041, 0xdd3: 0x4040, 0xdd4: 0x403f, 0xdd5: 0x4042, 0xdd6: 0x4043, 0xdd7: 0x4044, - 0xdd8: 0x4040, 0xdd9: 0x4041, 0xdda: 0x4040, 0xddb: 0x4045, 0xddc: 0x4009, 0xddd: 0x4045, - 0xdde: 0x4046, 0xddf: 0x4045, 0xde0: 0x4047, 0xde1: 0x400b, 0xde2: 0x400a, 0xde3: 0x400c, - 0xde4: 0x4048, 0xde5: 0x4000, 0xde6: 0x4000, 0xde7: 0x4000, 0xde8: 0x4000, 0xde9: 0x4000, - 0xdea: 0x4000, 0xdeb: 0x4000, 0xdec: 0x4000, 0xded: 0x4000, 0xdee: 0x4000, 0xdef: 0x4000, - 0xdf0: 0x4000, 0xdf1: 0x4000, 0xdf2: 0x4000, 0xdf3: 0x4000, 0xdf4: 0x4000, 0xdf5: 0x4000, - 0xdf6: 0x4000, 0xdf7: 0x4000, 0xdf8: 0x4000, 0xdf9: 0x4000, 0xdfa: 0x4000, 0xdfb: 0x4000, - 0xdfc: 0x4000, 0xdfd: 0x4000, 0xdfe: 0x4000, 0xdff: 0x4000, - // Block 0x38, offset 0xe00 - 0xe00: 0x4000, 0xe01: 0x4000, 0xe02: 0x4000, 0xe03: 0x4000, 0xe04: 0x4000, 0xe05: 0x4000, - 0xe06: 0x4000, 0xe07: 0x4000, 0xe08: 0x4000, 0xe09: 0x4000, 0xe0a: 0x4000, 0xe0b: 0x4000, - 0xe0c: 0x4000, 0xe0d: 0x4000, 0xe0e: 0x4000, 0xe10: 0x4000, 0xe11: 0x4000, - 0xe12: 0x4000, 0xe13: 0x4000, 0xe14: 0x4000, 0xe15: 0x4000, 0xe16: 0x4000, 0xe17: 0x4000, - 0xe18: 0x4000, 0xe19: 0x4000, 0xe1a: 0x4000, 0xe1b: 0x4000, 0xe1c: 0x4000, 0xe1d: 0x4000, - 0xe1e: 0x4000, 0xe1f: 0x4000, 0xe20: 0x4000, 0xe21: 0x4000, 0xe22: 0x4000, 0xe23: 0x4000, - 0xe24: 0x4000, 0xe25: 0x4000, 0xe26: 0x4000, 0xe27: 0x4000, 0xe28: 0x4000, 0xe29: 0x4000, - 0xe2a: 0x4000, 0xe2b: 0x4000, 0xe2c: 0x4000, 0xe2d: 0x4000, 0xe2e: 0x4000, 0xe2f: 0x4000, - 0xe30: 0x4000, 0xe31: 0x4000, 0xe32: 0x4000, 0xe33: 0x4000, 0xe34: 0x4000, 0xe35: 0x4000, - 0xe36: 0x4000, 0xe37: 0x4000, 0xe38: 0x4000, 0xe39: 0x4000, 0xe3a: 0x4000, - // Block 0x39, offset 0xe40 - 0xe40: 0x4000, 0xe41: 0x4000, 0xe42: 0x4000, 0xe43: 0x4000, 0xe44: 0x4000, 0xe45: 0x4000, - 0xe46: 0x4000, 0xe47: 0x4000, 0xe48: 0x4000, 0xe49: 0x4000, 0xe4a: 0x4000, 0xe4b: 0x4000, - 0xe4c: 0x4000, 0xe4d: 0x4000, 0xe4e: 0x4000, 0xe4f: 0x4000, 0xe50: 0x4000, 0xe51: 0x4000, - 0xe52: 0x4000, 0xe53: 0x4000, 0xe54: 0x4000, 0xe55: 0x4000, 0xe56: 0x4000, 0xe57: 0x4000, - 0xe58: 0x4000, 0xe59: 0x4000, 0xe5a: 0x4000, 0xe5b: 0x4000, 0xe5c: 0x4000, 0xe5d: 0x4000, - 0xe5e: 0x4000, 0xe5f: 0x4000, 0xe60: 0x4000, 0xe61: 0x4000, 0xe62: 0x4000, 0xe63: 0x4000, - 0xe70: 0x4000, 0xe71: 0x4000, 0xe72: 0x4000, 0xe73: 0x4000, 0xe74: 0x4000, 0xe75: 0x4000, - 0xe76: 0x4000, 0xe77: 0x4000, 0xe78: 0x4000, 0xe79: 0x4000, 0xe7a: 0x4000, 0xe7b: 0x4000, - 0xe7c: 0x4000, 0xe7d: 0x4000, 0xe7e: 0x4000, 0xe7f: 0x4000, - // Block 0x3a, offset 0xe80 - 0xe80: 0x4000, 0xe81: 0x4000, 0xe82: 0x4000, 0xe83: 0x4000, 0xe84: 0x4000, 0xe85: 0x4000, - 0xe86: 0x4000, 0xe87: 0x4000, 0xe88: 0x4000, 0xe89: 0x4000, 0xe8a: 0x4000, 0xe8b: 0x4000, - 0xe8c: 0x4000, 0xe8d: 0x4000, 0xe8e: 0x4000, 0xe8f: 0x4000, 0xe90: 0x4000, 0xe91: 0x4000, - 0xe92: 0x4000, 0xe93: 0x4000, 0xe94: 0x4000, 0xe95: 0x4000, 0xe96: 0x4000, 0xe97: 0x4000, - 0xe98: 0x4000, 0xe99: 0x4000, 0xe9a: 0x4000, 0xe9b: 0x4000, 0xe9c: 0x4000, 0xe9d: 0x4000, - 0xe9e: 0x4000, 0xea0: 0x4000, 0xea1: 0x4000, 0xea2: 0x4000, 0xea3: 0x4000, - 0xea4: 0x4000, 0xea5: 0x4000, 0xea6: 0x4000, 0xea7: 0x4000, 0xea8: 0x4000, 0xea9: 0x4000, - 0xeaa: 0x4000, 0xeab: 0x4000, 0xeac: 0x4000, 0xead: 0x4000, 0xeae: 0x4000, 0xeaf: 0x4000, - 0xeb0: 0x4000, 0xeb1: 0x4000, 0xeb2: 0x4000, 0xeb3: 0x4000, 0xeb4: 0x4000, 0xeb5: 0x4000, - 0xeb6: 0x4000, 0xeb7: 0x4000, 0xeb8: 0x4000, 0xeb9: 0x4000, 0xeba: 0x4000, 0xebb: 0x4000, - 0xebc: 0x4000, 0xebd: 0x4000, 0xebe: 0x4000, 0xebf: 0x4000, - // Block 0x3b, offset 0xec0 - 0xec0: 0x4000, 0xec1: 0x4000, 0xec2: 0x4000, 0xec3: 0x4000, 0xec4: 0x4000, 0xec5: 0x4000, - 0xec6: 0x4000, 0xec7: 0x4000, 0xec8: 0x2000, 0xec9: 0x2000, 0xeca: 0x2000, 0xecb: 0x2000, - 0xecc: 0x2000, 0xecd: 0x2000, 0xece: 0x2000, 0xecf: 0x2000, 0xed0: 0x4000, 0xed1: 0x4000, - 0xed2: 0x4000, 0xed3: 0x4000, 0xed4: 0x4000, 0xed5: 0x4000, 0xed6: 0x4000, 0xed7: 0x4000, - 0xed8: 0x4000, 0xed9: 0x4000, 0xeda: 0x4000, 0xedb: 0x4000, 0xedc: 0x4000, 0xedd: 0x4000, - 0xede: 0x4000, 0xedf: 0x4000, 0xee0: 0x4000, 0xee1: 0x4000, 0xee2: 0x4000, 0xee3: 0x4000, - 0xee4: 0x4000, 0xee5: 0x4000, 0xee6: 0x4000, 0xee7: 0x4000, 0xee8: 0x4000, 0xee9: 0x4000, - 0xeea: 0x4000, 0xeeb: 0x4000, 0xeec: 0x4000, 0xeed: 0x4000, 0xeee: 0x4000, 0xeef: 0x4000, - 0xef0: 0x4000, 0xef1: 0x4000, 0xef2: 0x4000, 0xef3: 0x4000, 0xef4: 0x4000, 0xef5: 0x4000, - 0xef6: 0x4000, 0xef7: 0x4000, 0xef8: 0x4000, 0xef9: 0x4000, 0xefa: 0x4000, 0xefb: 0x4000, - 0xefc: 0x4000, 0xefd: 0x4000, 0xefe: 0x4000, 0xeff: 0x4000, - // Block 0x3c, offset 0xf00 - 0xf00: 0x4000, 0xf01: 0x4000, 0xf02: 0x4000, 0xf03: 0x4000, 0xf04: 0x4000, 0xf05: 0x4000, - 0xf06: 0x4000, 0xf07: 0x4000, 0xf08: 0x4000, 0xf09: 0x4000, 0xf0a: 0x4000, 0xf0b: 0x4000, - 0xf0c: 0x4000, 0xf0d: 0x4000, 0xf0e: 0x4000, 0xf0f: 0x4000, 0xf10: 0x4000, 0xf11: 0x4000, - 0xf12: 0x4000, 0xf13: 0x4000, 0xf14: 0x4000, 0xf15: 0x4000, 0xf16: 0x4000, 0xf17: 0x4000, - 0xf18: 0x4000, 0xf19: 0x4000, 0xf1a: 0x4000, 0xf1b: 0x4000, 0xf1c: 0x4000, 0xf1d: 0x4000, - 0xf1e: 0x4000, 0xf1f: 0x4000, 0xf20: 0x4000, 0xf21: 0x4000, 0xf22: 0x4000, 0xf23: 0x4000, - 0xf24: 0x4000, 0xf25: 0x4000, 0xf26: 0x4000, 0xf27: 0x4000, 0xf28: 0x4000, 0xf29: 0x4000, - 0xf2a: 0x4000, 0xf2b: 0x4000, 0xf2c: 0x4000, 0xf2d: 0x4000, 0xf2e: 0x4000, 0xf2f: 0x4000, - 0xf30: 0x4000, 0xf31: 0x4000, 0xf32: 0x4000, 0xf33: 0x4000, 0xf34: 0x4000, 0xf35: 0x4000, - 0xf36: 0x4000, 0xf37: 0x4000, 0xf38: 0x4000, 0xf39: 0x4000, 0xf3a: 0x4000, 0xf3b: 0x4000, - 0xf3c: 0x4000, 0xf3d: 0x4000, 0xf3e: 0x4000, - // Block 0x3d, offset 0xf40 - 0xf40: 0x4000, 0xf41: 0x4000, 0xf42: 0x4000, 0xf43: 0x4000, 0xf44: 0x4000, 0xf45: 0x4000, - 0xf46: 0x4000, 0xf47: 0x4000, 0xf48: 0x4000, 0xf49: 0x4000, 0xf4a: 0x4000, 0xf4b: 0x4000, - 0xf4c: 0x4000, 0xf50: 0x4000, 0xf51: 0x4000, - 0xf52: 0x4000, 0xf53: 0x4000, 0xf54: 0x4000, 0xf55: 0x4000, 0xf56: 0x4000, 0xf57: 0x4000, - 0xf58: 0x4000, 0xf59: 0x4000, 0xf5a: 0x4000, 0xf5b: 0x4000, 0xf5c: 0x4000, 0xf5d: 0x4000, - 0xf5e: 0x4000, 0xf5f: 0x4000, 0xf60: 0x4000, 0xf61: 0x4000, 0xf62: 0x4000, 0xf63: 0x4000, - 0xf64: 0x4000, 0xf65: 0x4000, 0xf66: 0x4000, 0xf67: 0x4000, 0xf68: 0x4000, 0xf69: 0x4000, - 0xf6a: 0x4000, 0xf6b: 0x4000, 0xf6c: 0x4000, 0xf6d: 0x4000, 0xf6e: 0x4000, 0xf6f: 0x4000, - 0xf70: 0x4000, 0xf71: 0x4000, 0xf72: 0x4000, 0xf73: 0x4000, 0xf74: 0x4000, 0xf75: 0x4000, - 0xf76: 0x4000, 0xf77: 0x4000, 0xf78: 0x4000, 0xf79: 0x4000, 0xf7a: 0x4000, 0xf7b: 0x4000, - 0xf7c: 0x4000, 0xf7d: 0x4000, 0xf7e: 0x4000, 0xf7f: 0x4000, - // Block 0x3e, offset 0xf80 - 0xf80: 0x4000, 0xf81: 0x4000, 0xf82: 0x4000, 0xf83: 0x4000, 0xf84: 0x4000, 0xf85: 0x4000, - 0xf86: 0x4000, - // Block 0x3f, offset 0xfc0 - 0xfe0: 0x4000, 0xfe1: 0x4000, 0xfe2: 0x4000, 0xfe3: 0x4000, - 0xfe4: 0x4000, 0xfe5: 0x4000, 0xfe6: 0x4000, 0xfe7: 0x4000, 0xfe8: 0x4000, 0xfe9: 0x4000, - 0xfea: 0x4000, 0xfeb: 0x4000, 0xfec: 0x4000, 0xfed: 0x4000, 0xfee: 0x4000, 0xfef: 0x4000, - 0xff0: 0x4000, 0xff1: 0x4000, 0xff2: 0x4000, 0xff3: 0x4000, 0xff4: 0x4000, 0xff5: 0x4000, - 0xff6: 0x4000, 0xff7: 0x4000, 0xff8: 0x4000, 0xff9: 0x4000, 0xffa: 0x4000, 0xffb: 0x4000, - 0xffc: 0x4000, - // Block 0x40, offset 0x1000 - 0x1000: 0x4000, 0x1001: 0x4000, 0x1002: 0x4000, 0x1003: 0x4000, 0x1004: 0x4000, 0x1005: 0x4000, - 0x1006: 0x4000, 0x1007: 0x4000, 0x1008: 0x4000, 0x1009: 0x4000, 0x100a: 0x4000, 0x100b: 0x4000, - 0x100c: 0x4000, 0x100d: 0x4000, 0x100e: 0x4000, 0x100f: 0x4000, 0x1010: 0x4000, 0x1011: 0x4000, - 0x1012: 0x4000, 0x1013: 0x4000, 0x1014: 0x4000, 0x1015: 0x4000, 0x1016: 0x4000, 0x1017: 0x4000, - 0x1018: 0x4000, 0x1019: 0x4000, 0x101a: 0x4000, 0x101b: 0x4000, 0x101c: 0x4000, 0x101d: 0x4000, - 0x101e: 0x4000, 0x101f: 0x4000, 0x1020: 0x4000, 0x1021: 0x4000, 0x1022: 0x4000, 0x1023: 0x4000, - // Block 0x41, offset 0x1040 - 0x1040: 0x2000, 0x1041: 0x2000, 0x1042: 0x2000, 0x1043: 0x2000, 0x1044: 0x2000, 0x1045: 0x2000, - 0x1046: 0x2000, 0x1047: 0x2000, 0x1048: 0x2000, 0x1049: 0x2000, 0x104a: 0x2000, 0x104b: 0x2000, - 0x104c: 0x2000, 0x104d: 0x2000, 0x104e: 0x2000, 0x104f: 0x2000, 0x1050: 0x4000, 0x1051: 0x4000, - 0x1052: 0x4000, 0x1053: 0x4000, 0x1054: 0x4000, 0x1055: 0x4000, 0x1056: 0x4000, 0x1057: 0x4000, - 0x1058: 0x4000, 0x1059: 0x4000, - 0x1070: 0x4000, 0x1071: 0x4000, 0x1072: 0x4000, 0x1073: 0x4000, 0x1074: 0x4000, 0x1075: 0x4000, - 0x1076: 0x4000, 0x1077: 0x4000, 0x1078: 0x4000, 0x1079: 0x4000, 0x107a: 0x4000, 0x107b: 0x4000, - 0x107c: 0x4000, 0x107d: 0x4000, 0x107e: 0x4000, 0x107f: 0x4000, - // Block 0x42, offset 0x1080 - 0x1080: 0x4000, 0x1081: 0x4000, 0x1082: 0x4000, 0x1083: 0x4000, 0x1084: 0x4000, 0x1085: 0x4000, - 0x1086: 0x4000, 0x1087: 0x4000, 0x1088: 0x4000, 0x1089: 0x4000, 0x108a: 0x4000, 0x108b: 0x4000, - 0x108c: 0x4000, 0x108d: 0x4000, 0x108e: 0x4000, 0x108f: 0x4000, 0x1090: 0x4000, 0x1091: 0x4000, - 0x1092: 0x4000, 0x1094: 0x4000, 0x1095: 0x4000, 0x1096: 0x4000, 0x1097: 0x4000, - 0x1098: 0x4000, 0x1099: 0x4000, 0x109a: 0x4000, 0x109b: 0x4000, 0x109c: 0x4000, 0x109d: 0x4000, - 0x109e: 0x4000, 0x109f: 0x4000, 0x10a0: 0x4000, 0x10a1: 0x4000, 0x10a2: 0x4000, 0x10a3: 0x4000, - 0x10a4: 0x4000, 0x10a5: 0x4000, 0x10a6: 0x4000, 0x10a8: 0x4000, 0x10a9: 0x4000, - 0x10aa: 0x4000, 0x10ab: 0x4000, - // Block 0x43, offset 0x10c0 - 0x10c1: 0x9012, 0x10c2: 0x9012, 0x10c3: 0x9012, 0x10c4: 0x9012, 0x10c5: 0x9012, - 0x10c6: 0x9012, 0x10c7: 0x9012, 0x10c8: 0x9012, 0x10c9: 0x9012, 0x10ca: 0x9012, 0x10cb: 0x9012, - 0x10cc: 0x9012, 0x10cd: 0x9012, 0x10ce: 0x9012, 0x10cf: 0x9012, 0x10d0: 0x9012, 0x10d1: 0x9012, - 0x10d2: 0x9012, 0x10d3: 0x9012, 0x10d4: 0x9012, 0x10d5: 0x9012, 0x10d6: 0x9012, 0x10d7: 0x9012, - 0x10d8: 0x9012, 0x10d9: 0x9012, 0x10da: 0x9012, 0x10db: 0x9012, 0x10dc: 0x9012, 0x10dd: 0x9012, - 0x10de: 0x9012, 0x10df: 0x9012, 0x10e0: 0x9049, 0x10e1: 0x9049, 0x10e2: 0x9049, 0x10e3: 0x9049, - 0x10e4: 0x9049, 0x10e5: 0x9049, 0x10e6: 0x9049, 0x10e7: 0x9049, 0x10e8: 0x9049, 0x10e9: 0x9049, - 0x10ea: 0x9049, 0x10eb: 0x9049, 0x10ec: 0x9049, 0x10ed: 0x9049, 0x10ee: 0x9049, 0x10ef: 0x9049, - 0x10f0: 0x9049, 0x10f1: 0x9049, 0x10f2: 0x9049, 0x10f3: 0x9049, 0x10f4: 0x9049, 0x10f5: 0x9049, - 0x10f6: 0x9049, 0x10f7: 0x9049, 0x10f8: 0x9049, 0x10f9: 0x9049, 0x10fa: 0x9049, 0x10fb: 0x9049, - 0x10fc: 0x9049, 0x10fd: 0x9049, 0x10fe: 0x9049, 0x10ff: 0x9049, - // Block 0x44, offset 0x1100 - 0x1100: 0x9049, 0x1101: 0x9049, 0x1102: 0x9049, 0x1103: 0x9049, 0x1104: 0x9049, 0x1105: 0x9049, - 0x1106: 0x9049, 0x1107: 0x9049, 0x1108: 0x9049, 0x1109: 0x9049, 0x110a: 0x9049, 0x110b: 0x9049, - 0x110c: 0x9049, 0x110d: 0x9049, 0x110e: 0x9049, 0x110f: 0x9049, 0x1110: 0x9049, 0x1111: 0x9049, - 0x1112: 0x9049, 0x1113: 0x9049, 0x1114: 0x9049, 0x1115: 0x9049, 0x1116: 0x9049, 0x1117: 0x9049, - 0x1118: 0x9049, 0x1119: 0x9049, 0x111a: 0x9049, 0x111b: 0x9049, 0x111c: 0x9049, 0x111d: 0x9049, - 0x111e: 0x9049, 0x111f: 0x904a, 0x1120: 0x904b, 0x1121: 0xb04c, 0x1122: 0xb04d, 0x1123: 0xb04d, - 0x1124: 0xb04e, 0x1125: 0xb04f, 0x1126: 0xb050, 0x1127: 0xb051, 0x1128: 0xb052, 0x1129: 0xb053, - 0x112a: 0xb054, 0x112b: 0xb055, 0x112c: 0xb056, 0x112d: 0xb057, 0x112e: 0xb058, 0x112f: 0xb059, - 0x1130: 0xb05a, 0x1131: 0xb05b, 0x1132: 0xb05c, 0x1133: 0xb05d, 0x1134: 0xb05e, 0x1135: 0xb05f, - 0x1136: 0xb060, 0x1137: 0xb061, 0x1138: 0xb062, 0x1139: 0xb063, 0x113a: 0xb064, 0x113b: 0xb065, - 0x113c: 0xb052, 0x113d: 0xb066, 0x113e: 0xb067, 0x113f: 0xb055, - // Block 0x45, offset 0x1140 - 0x1140: 0xb068, 0x1141: 0xb069, 0x1142: 0xb06a, 0x1143: 0xb06b, 0x1144: 0xb05a, 0x1145: 0xb056, - 0x1146: 0xb06c, 0x1147: 0xb06d, 0x1148: 0xb06b, 0x1149: 0xb06e, 0x114a: 0xb06b, 0x114b: 0xb06f, - 0x114c: 0xb06f, 0x114d: 0xb070, 0x114e: 0xb070, 0x114f: 0xb071, 0x1150: 0xb056, 0x1151: 0xb072, - 0x1152: 0xb073, 0x1153: 0xb072, 0x1154: 0xb074, 0x1155: 0xb073, 0x1156: 0xb075, 0x1157: 0xb075, - 0x1158: 0xb076, 0x1159: 0xb076, 0x115a: 0xb077, 0x115b: 0xb077, 0x115c: 0xb073, 0x115d: 0xb078, - 0x115e: 0xb079, 0x115f: 0xb067, 0x1160: 0xb07a, 0x1161: 0xb07b, 0x1162: 0xb07b, 0x1163: 0xb07b, - 0x1164: 0xb07b, 0x1165: 0xb07b, 0x1166: 0xb07b, 0x1167: 0xb07b, 0x1168: 0xb07b, 0x1169: 0xb07b, - 0x116a: 0xb07b, 0x116b: 0xb07b, 0x116c: 0xb07b, 0x116d: 0xb07b, 0x116e: 0xb07b, 0x116f: 0xb07b, - 0x1170: 0xb07c, 0x1171: 0xb07c, 0x1172: 0xb07c, 0x1173: 0xb07c, 0x1174: 0xb07c, 0x1175: 0xb07c, - 0x1176: 0xb07c, 0x1177: 0xb07c, 0x1178: 0xb07c, 0x1179: 0xb07c, 0x117a: 0xb07c, 0x117b: 0xb07c, - 0x117c: 0xb07c, 0x117d: 0xb07c, 0x117e: 0xb07c, - // Block 0x46, offset 0x1180 - 0x1182: 0xb07d, 0x1183: 0xb07e, 0x1184: 0xb07f, 0x1185: 0xb080, - 0x1186: 0xb07f, 0x1187: 0xb07e, 0x118a: 0xb081, 0x118b: 0xb082, - 0x118c: 0xb083, 0x118d: 0xb07f, 0x118e: 0xb080, 0x118f: 0xb07f, - 0x1192: 0xb084, 0x1193: 0xb085, 0x1194: 0xb084, 0x1195: 0xb086, 0x1196: 0xb084, 0x1197: 0xb087, - 0x119a: 0xb088, 0x119b: 0xb089, 0x119c: 0xb08a, - 0x11a0: 0x908b, 0x11a1: 0x908b, 0x11a2: 0x908c, 0x11a3: 0x908d, - 0x11a4: 0x908b, 0x11a5: 0x908e, 0x11a6: 0x908f, 0x11a8: 0xb090, 0x11a9: 0xb091, - 0x11aa: 0xb092, 0x11ab: 0xb091, 0x11ac: 0xb093, 0x11ad: 0xb094, 0x11ae: 0xb095, - 0x11bd: 0x2000, - // Block 0x47, offset 0x11c0 - 0x11e0: 0x4000, - // Block 0x48, offset 0x1200 - 0x1200: 0x4000, 0x1201: 0x4000, 0x1202: 0x4000, 0x1203: 0x4000, 0x1204: 0x4000, 0x1205: 0x4000, - 0x1206: 0x4000, 0x1207: 0x4000, 0x1208: 0x4000, 0x1209: 0x4000, 0x120a: 0x4000, 0x120b: 0x4000, - 0x120c: 0x4000, 0x120d: 0x4000, 0x120e: 0x4000, 0x120f: 0x4000, 0x1210: 0x4000, 0x1211: 0x4000, - 0x1212: 0x4000, 0x1213: 0x4000, 0x1214: 0x4000, 0x1215: 0x4000, 0x1216: 0x4000, 0x1217: 0x4000, - 0x1218: 0x4000, 0x1219: 0x4000, 0x121a: 0x4000, 0x121b: 0x4000, 0x121c: 0x4000, 0x121d: 0x4000, - 0x121e: 0x4000, 0x121f: 0x4000, 0x1220: 0x4000, 0x1221: 0x4000, 0x1222: 0x4000, 0x1223: 0x4000, - 0x1224: 0x4000, 0x1225: 0x4000, 0x1226: 0x4000, 0x1227: 0x4000, 0x1228: 0x4000, 0x1229: 0x4000, - 0x122a: 0x4000, 0x122b: 0x4000, 0x122c: 0x4000, - // Block 0x49, offset 0x1240 - 0x1240: 0x4000, 0x1241: 0x4000, 0x1242: 0x4000, 0x1243: 0x4000, 0x1244: 0x4000, 0x1245: 0x4000, - 0x1246: 0x4000, 0x1247: 0x4000, 0x1248: 0x4000, 0x1249: 0x4000, 0x124a: 0x4000, 0x124b: 0x4000, - 0x124c: 0x4000, 0x124d: 0x4000, 0x124e: 0x4000, 0x124f: 0x4000, 0x1250: 0x4000, 0x1251: 0x4000, - 0x1252: 0x4000, 0x1253: 0x4000, 0x1254: 0x4000, 0x1255: 0x4000, 0x1256: 0x4000, 0x1257: 0x4000, - 0x1258: 0x4000, 0x1259: 0x4000, 0x125a: 0x4000, 0x125b: 0x4000, 0x125c: 0x4000, 0x125d: 0x4000, - 0x125e: 0x4000, 0x125f: 0x4000, 0x1260: 0x4000, 0x1261: 0x4000, 0x1262: 0x4000, 0x1263: 0x4000, - 0x1264: 0x4000, 0x1265: 0x4000, 0x1266: 0x4000, 0x1267: 0x4000, 0x1268: 0x4000, 0x1269: 0x4000, - 0x126a: 0x4000, 0x126b: 0x4000, 0x126c: 0x4000, 0x126d: 0x4000, 0x126e: 0x4000, 0x126f: 0x4000, - 0x1270: 0x4000, 0x1271: 0x4000, 0x1272: 0x4000, - // Block 0x4a, offset 0x1280 - 0x1280: 0x4000, 0x1281: 0x4000, - // Block 0x4b, offset 0x12c0 - 0x12c4: 0x4000, - // Block 0x4c, offset 0x1300 - 0x130f: 0x4000, - // Block 0x4d, offset 0x1340 - 0x1340: 0x2000, 0x1341: 0x2000, 0x1342: 0x2000, 0x1343: 0x2000, 0x1344: 0x2000, 0x1345: 0x2000, - 0x1346: 0x2000, 0x1347: 0x2000, 0x1348: 0x2000, 0x1349: 0x2000, 0x134a: 0x2000, - 0x1350: 0x2000, 0x1351: 0x2000, - 0x1352: 0x2000, 0x1353: 0x2000, 0x1354: 0x2000, 0x1355: 0x2000, 0x1356: 0x2000, 0x1357: 0x2000, - 0x1358: 0x2000, 0x1359: 0x2000, 0x135a: 0x2000, 0x135b: 0x2000, 0x135c: 0x2000, 0x135d: 0x2000, - 0x135e: 0x2000, 0x135f: 0x2000, 0x1360: 0x2000, 0x1361: 0x2000, 0x1362: 0x2000, 0x1363: 0x2000, - 0x1364: 0x2000, 0x1365: 0x2000, 0x1366: 0x2000, 0x1367: 0x2000, 0x1368: 0x2000, 0x1369: 0x2000, - 0x136a: 0x2000, 0x136b: 0x2000, 0x136c: 0x2000, 0x136d: 0x2000, - 0x1370: 0x2000, 0x1371: 0x2000, 0x1372: 0x2000, 0x1373: 0x2000, 0x1374: 0x2000, 0x1375: 0x2000, - 0x1376: 0x2000, 0x1377: 0x2000, 0x1378: 0x2000, 0x1379: 0x2000, 0x137a: 0x2000, 0x137b: 0x2000, - 0x137c: 0x2000, 0x137d: 0x2000, 0x137e: 0x2000, 0x137f: 0x2000, - // Block 0x4e, offset 0x1380 - 0x1380: 0x2000, 0x1381: 0x2000, 0x1382: 0x2000, 0x1383: 0x2000, 0x1384: 0x2000, 0x1385: 0x2000, - 0x1386: 0x2000, 0x1387: 0x2000, 0x1388: 0x2000, 0x1389: 0x2000, 0x138a: 0x2000, 0x138b: 0x2000, - 0x138c: 0x2000, 0x138d: 0x2000, 0x138e: 0x2000, 0x138f: 0x2000, 0x1390: 0x2000, 0x1391: 0x2000, - 0x1392: 0x2000, 0x1393: 0x2000, 0x1394: 0x2000, 0x1395: 0x2000, 0x1396: 0x2000, 0x1397: 0x2000, - 0x1398: 0x2000, 0x1399: 0x2000, 0x139a: 0x2000, 0x139b: 0x2000, 0x139c: 0x2000, 0x139d: 0x2000, - 0x139e: 0x2000, 0x139f: 0x2000, 0x13a0: 0x2000, 0x13a1: 0x2000, 0x13a2: 0x2000, 0x13a3: 0x2000, - 0x13a4: 0x2000, 0x13a5: 0x2000, 0x13a6: 0x2000, 0x13a7: 0x2000, 0x13a8: 0x2000, 0x13a9: 0x2000, - 0x13b0: 0x2000, 0x13b1: 0x2000, 0x13b2: 0x2000, 0x13b3: 0x2000, 0x13b4: 0x2000, 0x13b5: 0x2000, - 0x13b6: 0x2000, 0x13b7: 0x2000, 0x13b8: 0x2000, 0x13b9: 0x2000, 0x13ba: 0x2000, 0x13bb: 0x2000, - 0x13bc: 0x2000, 0x13bd: 0x2000, 0x13be: 0x2000, 0x13bf: 0x2000, - // Block 0x4f, offset 0x13c0 - 0x13c0: 0x2000, 0x13c1: 0x2000, 0x13c2: 0x2000, 0x13c3: 0x2000, 0x13c4: 0x2000, 0x13c5: 0x2000, - 0x13c6: 0x2000, 0x13c7: 0x2000, 0x13c8: 0x2000, 0x13c9: 0x2000, 0x13ca: 0x2000, 0x13cb: 0x2000, - 0x13cc: 0x2000, 0x13cd: 0x2000, 0x13ce: 0x4000, 0x13cf: 0x2000, 0x13d0: 0x2000, 0x13d1: 0x4000, - 0x13d2: 0x4000, 0x13d3: 0x4000, 0x13d4: 0x4000, 0x13d5: 0x4000, 0x13d6: 0x4000, 0x13d7: 0x4000, - 0x13d8: 0x4000, 0x13d9: 0x4000, 0x13da: 0x4000, 0x13db: 0x2000, 0x13dc: 0x2000, 0x13dd: 0x2000, - 0x13de: 0x2000, 0x13df: 0x2000, 0x13e0: 0x2000, 0x13e1: 0x2000, 0x13e2: 0x2000, 0x13e3: 0x2000, - 0x13e4: 0x2000, 0x13e5: 0x2000, 0x13e6: 0x2000, 0x13e7: 0x2000, 0x13e8: 0x2000, 0x13e9: 0x2000, - 0x13ea: 0x2000, 0x13eb: 0x2000, 0x13ec: 0x2000, - // Block 0x50, offset 0x1400 - 0x1400: 0x4000, 0x1401: 0x4000, 0x1402: 0x4000, - 0x1410: 0x4000, 0x1411: 0x4000, - 0x1412: 0x4000, 0x1413: 0x4000, 0x1414: 0x4000, 0x1415: 0x4000, 0x1416: 0x4000, 0x1417: 0x4000, - 0x1418: 0x4000, 0x1419: 0x4000, 0x141a: 0x4000, 0x141b: 0x4000, 0x141c: 0x4000, 0x141d: 0x4000, - 0x141e: 0x4000, 0x141f: 0x4000, 0x1420: 0x4000, 0x1421: 0x4000, 0x1422: 0x4000, 0x1423: 0x4000, - 0x1424: 0x4000, 0x1425: 0x4000, 0x1426: 0x4000, 0x1427: 0x4000, 0x1428: 0x4000, 0x1429: 0x4000, - 0x142a: 0x4000, 0x142b: 0x4000, 0x142c: 0x4000, 0x142d: 0x4000, 0x142e: 0x4000, 0x142f: 0x4000, - 0x1430: 0x4000, 0x1431: 0x4000, 0x1432: 0x4000, 0x1433: 0x4000, 0x1434: 0x4000, 0x1435: 0x4000, - 0x1436: 0x4000, 0x1437: 0x4000, 0x1438: 0x4000, 0x1439: 0x4000, 0x143a: 0x4000, 0x143b: 0x4000, - // Block 0x51, offset 0x1440 - 0x1440: 0x4000, 0x1441: 0x4000, 0x1442: 0x4000, 0x1443: 0x4000, 0x1444: 0x4000, 0x1445: 0x4000, - 0x1446: 0x4000, 0x1447: 0x4000, 0x1448: 0x4000, - 0x1450: 0x4000, 0x1451: 0x4000, - // Block 0x52, offset 0x1480 - 0x1480: 0x4000, 0x1481: 0x4000, 0x1482: 0x4000, 0x1483: 0x4000, 0x1484: 0x4000, 0x1485: 0x4000, - 0x1486: 0x4000, 0x1487: 0x4000, 0x1488: 0x4000, 0x1489: 0x4000, 0x148a: 0x4000, 0x148b: 0x4000, - 0x148c: 0x4000, 0x148d: 0x4000, 0x148e: 0x4000, 0x148f: 0x4000, 0x1490: 0x4000, 0x1491: 0x4000, - 0x1492: 0x4000, 0x1493: 0x4000, 0x1494: 0x4000, 0x1495: 0x4000, 0x1496: 0x4000, 0x1497: 0x4000, - 0x1498: 0x4000, 0x1499: 0x4000, 0x149a: 0x4000, 0x149b: 0x4000, 0x149c: 0x4000, 0x149d: 0x4000, - 0x149e: 0x4000, 0x149f: 0x4000, 0x14a0: 0x4000, - 0x14ad: 0x4000, 0x14ae: 0x4000, 0x14af: 0x4000, - 0x14b0: 0x4000, 0x14b1: 0x4000, 0x14b2: 0x4000, 0x14b3: 0x4000, 0x14b4: 0x4000, 0x14b5: 0x4000, - 0x14b7: 0x4000, 0x14b8: 0x4000, 0x14b9: 0x4000, 0x14ba: 0x4000, 0x14bb: 0x4000, - 0x14bc: 0x4000, 0x14bd: 0x4000, 0x14be: 0x4000, 0x14bf: 0x4000, - // Block 0x53, offset 0x14c0 - 0x14c0: 0x4000, 0x14c1: 0x4000, 0x14c2: 0x4000, 0x14c3: 0x4000, 0x14c4: 0x4000, 0x14c5: 0x4000, - 0x14c6: 0x4000, 0x14c7: 0x4000, 0x14c8: 0x4000, 0x14c9: 0x4000, 0x14ca: 0x4000, 0x14cb: 0x4000, - 0x14cc: 0x4000, 0x14cd: 0x4000, 0x14ce: 0x4000, 0x14cf: 0x4000, 0x14d0: 0x4000, 0x14d1: 0x4000, - 0x14d2: 0x4000, 0x14d3: 0x4000, 0x14d4: 0x4000, 0x14d5: 0x4000, 0x14d6: 0x4000, 0x14d7: 0x4000, - 0x14d8: 0x4000, 0x14d9: 0x4000, 0x14da: 0x4000, 0x14db: 0x4000, 0x14dc: 0x4000, 0x14dd: 0x4000, - 0x14de: 0x4000, 0x14df: 0x4000, 0x14e0: 0x4000, 0x14e1: 0x4000, 0x14e2: 0x4000, 0x14e3: 0x4000, - 0x14e4: 0x4000, 0x14e5: 0x4000, 0x14e6: 0x4000, 0x14e7: 0x4000, 0x14e8: 0x4000, 0x14e9: 0x4000, - 0x14ea: 0x4000, 0x14eb: 0x4000, 0x14ec: 0x4000, 0x14ed: 0x4000, 0x14ee: 0x4000, 0x14ef: 0x4000, - 0x14f0: 0x4000, 0x14f1: 0x4000, 0x14f2: 0x4000, 0x14f3: 0x4000, 0x14f4: 0x4000, 0x14f5: 0x4000, - 0x14f6: 0x4000, 0x14f7: 0x4000, 0x14f8: 0x4000, 0x14f9: 0x4000, 0x14fa: 0x4000, 0x14fb: 0x4000, - 0x14fc: 0x4000, 0x14fe: 0x4000, 0x14ff: 0x4000, - // Block 0x54, offset 0x1500 - 0x1500: 0x4000, 0x1501: 0x4000, 0x1502: 0x4000, 0x1503: 0x4000, 0x1504: 0x4000, 0x1505: 0x4000, - 0x1506: 0x4000, 0x1507: 0x4000, 0x1508: 0x4000, 0x1509: 0x4000, 0x150a: 0x4000, 0x150b: 0x4000, - 0x150c: 0x4000, 0x150d: 0x4000, 0x150e: 0x4000, 0x150f: 0x4000, 0x1510: 0x4000, 0x1511: 0x4000, - 0x1512: 0x4000, 0x1513: 0x4000, - 0x1520: 0x4000, 0x1521: 0x4000, 0x1522: 0x4000, 0x1523: 0x4000, - 0x1524: 0x4000, 0x1525: 0x4000, 0x1526: 0x4000, 0x1527: 0x4000, 0x1528: 0x4000, 0x1529: 0x4000, - 0x152a: 0x4000, 0x152b: 0x4000, 0x152c: 0x4000, 0x152d: 0x4000, 0x152e: 0x4000, 0x152f: 0x4000, - 0x1530: 0x4000, 0x1531: 0x4000, 0x1532: 0x4000, 0x1533: 0x4000, 0x1534: 0x4000, 0x1535: 0x4000, - 0x1536: 0x4000, 0x1537: 0x4000, 0x1538: 0x4000, 0x1539: 0x4000, 0x153a: 0x4000, 0x153b: 0x4000, - 0x153c: 0x4000, 0x153d: 0x4000, 0x153e: 0x4000, 0x153f: 0x4000, - // Block 0x55, offset 0x1540 - 0x1540: 0x4000, 0x1541: 0x4000, 0x1542: 0x4000, 0x1543: 0x4000, 0x1544: 0x4000, 0x1545: 0x4000, - 0x1546: 0x4000, 0x1547: 0x4000, 0x1548: 0x4000, 0x1549: 0x4000, 0x154a: 0x4000, - 0x154f: 0x4000, 0x1550: 0x4000, 0x1551: 0x4000, - 0x1552: 0x4000, 0x1553: 0x4000, - 0x1560: 0x4000, 0x1561: 0x4000, 0x1562: 0x4000, 0x1563: 0x4000, - 0x1564: 0x4000, 0x1565: 0x4000, 0x1566: 0x4000, 0x1567: 0x4000, 0x1568: 0x4000, 0x1569: 0x4000, - 0x156a: 0x4000, 0x156b: 0x4000, 0x156c: 0x4000, 0x156d: 0x4000, 0x156e: 0x4000, 0x156f: 0x4000, - 0x1570: 0x4000, 0x1574: 0x4000, - 0x1578: 0x4000, 0x1579: 0x4000, 0x157a: 0x4000, 0x157b: 0x4000, - 0x157c: 0x4000, 0x157d: 0x4000, 0x157e: 0x4000, 0x157f: 0x4000, - // Block 0x56, offset 0x1580 - 0x1580: 0x4000, 0x1582: 0x4000, 0x1583: 0x4000, 0x1584: 0x4000, 0x1585: 0x4000, - 0x1586: 0x4000, 0x1587: 0x4000, 0x1588: 0x4000, 0x1589: 0x4000, 0x158a: 0x4000, 0x158b: 0x4000, - 0x158c: 0x4000, 0x158d: 0x4000, 0x158e: 0x4000, 0x158f: 0x4000, 0x1590: 0x4000, 0x1591: 0x4000, - 0x1592: 0x4000, 0x1593: 0x4000, 0x1594: 0x4000, 0x1595: 0x4000, 0x1596: 0x4000, 0x1597: 0x4000, - 0x1598: 0x4000, 0x1599: 0x4000, 0x159a: 0x4000, 0x159b: 0x4000, 0x159c: 0x4000, 0x159d: 0x4000, - 0x159e: 0x4000, 0x159f: 0x4000, 0x15a0: 0x4000, 0x15a1: 0x4000, 0x15a2: 0x4000, 0x15a3: 0x4000, - 0x15a4: 0x4000, 0x15a5: 0x4000, 0x15a6: 0x4000, 0x15a7: 0x4000, 0x15a8: 0x4000, 0x15a9: 0x4000, - 0x15aa: 0x4000, 0x15ab: 0x4000, 0x15ac: 0x4000, 0x15ad: 0x4000, 0x15ae: 0x4000, 0x15af: 0x4000, - 0x15b0: 0x4000, 0x15b1: 0x4000, 0x15b2: 0x4000, 0x15b3: 0x4000, 0x15b4: 0x4000, 0x15b5: 0x4000, - 0x15b6: 0x4000, 0x15b7: 0x4000, 0x15b8: 0x4000, 0x15b9: 0x4000, 0x15ba: 0x4000, 0x15bb: 0x4000, - 0x15bc: 0x4000, 0x15bd: 0x4000, 0x15be: 0x4000, 0x15bf: 0x4000, - // Block 0x57, offset 0x15c0 - 0x15c0: 0x4000, 0x15c1: 0x4000, 0x15c2: 0x4000, 0x15c3: 0x4000, 0x15c4: 0x4000, 0x15c5: 0x4000, - 0x15c6: 0x4000, 0x15c7: 0x4000, 0x15c8: 0x4000, 0x15c9: 0x4000, 0x15ca: 0x4000, 0x15cb: 0x4000, - 0x15cc: 0x4000, 0x15cd: 0x4000, 0x15ce: 0x4000, 0x15cf: 0x4000, 0x15d0: 0x4000, 0x15d1: 0x4000, - 0x15d2: 0x4000, 0x15d3: 0x4000, 0x15d4: 0x4000, 0x15d5: 0x4000, 0x15d6: 0x4000, 0x15d7: 0x4000, - 0x15d8: 0x4000, 0x15d9: 0x4000, 0x15da: 0x4000, 0x15db: 0x4000, 0x15dc: 0x4000, 0x15dd: 0x4000, - 0x15de: 0x4000, 0x15df: 0x4000, 0x15e0: 0x4000, 0x15e1: 0x4000, 0x15e2: 0x4000, 0x15e3: 0x4000, - 0x15e4: 0x4000, 0x15e5: 0x4000, 0x15e6: 0x4000, 0x15e7: 0x4000, 0x15e8: 0x4000, 0x15e9: 0x4000, - 0x15ea: 0x4000, 0x15eb: 0x4000, 0x15ec: 0x4000, 0x15ed: 0x4000, 0x15ee: 0x4000, 0x15ef: 0x4000, - 0x15f0: 0x4000, 0x15f1: 0x4000, 0x15f2: 0x4000, 0x15f3: 0x4000, 0x15f4: 0x4000, 0x15f5: 0x4000, - 0x15f6: 0x4000, 0x15f7: 0x4000, 0x15f8: 0x4000, 0x15f9: 0x4000, 0x15fa: 0x4000, 0x15fb: 0x4000, - 0x15fc: 0x4000, 0x15ff: 0x4000, - // Block 0x58, offset 0x1600 - 0x1600: 0x4000, 0x1601: 0x4000, 0x1602: 0x4000, 0x1603: 0x4000, 0x1604: 0x4000, 0x1605: 0x4000, - 0x1606: 0x4000, 0x1607: 0x4000, 0x1608: 0x4000, 0x1609: 0x4000, 0x160a: 0x4000, 0x160b: 0x4000, - 0x160c: 0x4000, 0x160d: 0x4000, 0x160e: 0x4000, 0x160f: 0x4000, 0x1610: 0x4000, 0x1611: 0x4000, - 0x1612: 0x4000, 0x1613: 0x4000, 0x1614: 0x4000, 0x1615: 0x4000, 0x1616: 0x4000, 0x1617: 0x4000, - 0x1618: 0x4000, 0x1619: 0x4000, 0x161a: 0x4000, 0x161b: 0x4000, 0x161c: 0x4000, 0x161d: 0x4000, - 0x161e: 0x4000, 0x161f: 0x4000, 0x1620: 0x4000, 0x1621: 0x4000, 0x1622: 0x4000, 0x1623: 0x4000, - 0x1624: 0x4000, 0x1625: 0x4000, 0x1626: 0x4000, 0x1627: 0x4000, 0x1628: 0x4000, 0x1629: 0x4000, - 0x162a: 0x4000, 0x162b: 0x4000, 0x162c: 0x4000, 0x162d: 0x4000, 0x162e: 0x4000, 0x162f: 0x4000, - 0x1630: 0x4000, 0x1631: 0x4000, 0x1632: 0x4000, 0x1633: 0x4000, 0x1634: 0x4000, 0x1635: 0x4000, - 0x1636: 0x4000, 0x1637: 0x4000, 0x1638: 0x4000, 0x1639: 0x4000, 0x163a: 0x4000, 0x163b: 0x4000, - 0x163c: 0x4000, 0x163d: 0x4000, - // Block 0x59, offset 0x1640 - 0x164b: 0x4000, - 0x164c: 0x4000, 0x164d: 0x4000, 0x164e: 0x4000, 0x1650: 0x4000, 0x1651: 0x4000, - 0x1652: 0x4000, 0x1653: 0x4000, 0x1654: 0x4000, 0x1655: 0x4000, 0x1656: 0x4000, 0x1657: 0x4000, - 0x1658: 0x4000, 0x1659: 0x4000, 0x165a: 0x4000, 0x165b: 0x4000, 0x165c: 0x4000, 0x165d: 0x4000, - 0x165e: 0x4000, 0x165f: 0x4000, 0x1660: 0x4000, 0x1661: 0x4000, 0x1662: 0x4000, 0x1663: 0x4000, - 0x1664: 0x4000, 0x1665: 0x4000, 0x1666: 0x4000, 0x1667: 0x4000, - 0x167a: 0x4000, - // Block 0x5a, offset 0x1680 - 0x1695: 0x4000, 0x1696: 0x4000, - 0x16a4: 0x4000, - // Block 0x5b, offset 0x16c0 - 0x16fb: 0x4000, - 0x16fc: 0x4000, 0x16fd: 0x4000, 0x16fe: 0x4000, 0x16ff: 0x4000, - // Block 0x5c, offset 0x1700 - 0x1700: 0x4000, 0x1701: 0x4000, 0x1702: 0x4000, 0x1703: 0x4000, 0x1704: 0x4000, 0x1705: 0x4000, - 0x1706: 0x4000, 0x1707: 0x4000, 0x1708: 0x4000, 0x1709: 0x4000, 0x170a: 0x4000, 0x170b: 0x4000, - 0x170c: 0x4000, 0x170d: 0x4000, 0x170e: 0x4000, 0x170f: 0x4000, - // Block 0x5d, offset 0x1740 - 0x1740: 0x4000, 0x1741: 0x4000, 0x1742: 0x4000, 0x1743: 0x4000, 0x1744: 0x4000, 0x1745: 0x4000, - 0x174c: 0x4000, 0x1750: 0x4000, 0x1751: 0x4000, - 0x1752: 0x4000, - 0x176b: 0x4000, 0x176c: 0x4000, - 0x1774: 0x4000, 0x1775: 0x4000, - 0x1776: 0x4000, - // Block 0x5e, offset 0x1780 - 0x1790: 0x4000, 0x1791: 0x4000, - 0x1792: 0x4000, 0x1793: 0x4000, 0x1794: 0x4000, 0x1795: 0x4000, 0x1796: 0x4000, 0x1797: 0x4000, - 0x1798: 0x4000, 0x1799: 0x4000, 0x179a: 0x4000, 0x179b: 0x4000, 0x179c: 0x4000, 0x179d: 0x4000, - 0x179e: 0x4000, 0x17a0: 0x4000, 0x17a1: 0x4000, 0x17a2: 0x4000, 0x17a3: 0x4000, - 0x17a4: 0x4000, 0x17a5: 0x4000, 0x17a6: 0x4000, 0x17a7: 0x4000, - 0x17b0: 0x4000, 0x17b3: 0x4000, 0x17b4: 0x4000, 0x17b5: 0x4000, - 0x17b6: 0x4000, 0x17b7: 0x4000, 0x17b8: 0x4000, 0x17b9: 0x4000, 0x17ba: 0x4000, 0x17bb: 0x4000, - 0x17bc: 0x4000, 0x17bd: 0x4000, 0x17be: 0x4000, - // Block 0x5f, offset 0x17c0 - 0x17c0: 0x4000, 0x17c1: 0x4000, 0x17c2: 0x4000, 0x17c3: 0x4000, 0x17c4: 0x4000, 0x17c5: 0x4000, - 0x17c6: 0x4000, 0x17c7: 0x4000, 0x17c8: 0x4000, 0x17c9: 0x4000, 0x17ca: 0x4000, 0x17cb: 0x4000, - 0x17d0: 0x4000, 0x17d1: 0x4000, - 0x17d2: 0x4000, 0x17d3: 0x4000, 0x17d4: 0x4000, 0x17d5: 0x4000, 0x17d6: 0x4000, 0x17d7: 0x4000, - 0x17d8: 0x4000, 0x17d9: 0x4000, 0x17da: 0x4000, 0x17db: 0x4000, 0x17dc: 0x4000, 0x17dd: 0x4000, - 0x17de: 0x4000, - // Block 0x60, offset 0x1800 - 0x1800: 0x4000, 0x1801: 0x4000, 0x1802: 0x4000, 0x1803: 0x4000, 0x1804: 0x4000, 0x1805: 0x4000, - 0x1806: 0x4000, 0x1807: 0x4000, 0x1808: 0x4000, 0x1809: 0x4000, 0x180a: 0x4000, 0x180b: 0x4000, - 0x180c: 0x4000, 0x180d: 0x4000, 0x180e: 0x4000, 0x180f: 0x4000, 0x1810: 0x4000, 0x1811: 0x4000, - // Block 0x61, offset 0x1840 - 0x1840: 0x4000, - // Block 0x62, offset 0x1880 - 0x1880: 0x2000, 0x1881: 0x2000, 0x1882: 0x2000, 0x1883: 0x2000, 0x1884: 0x2000, 0x1885: 0x2000, - 0x1886: 0x2000, 0x1887: 0x2000, 0x1888: 0x2000, 0x1889: 0x2000, 0x188a: 0x2000, 0x188b: 0x2000, - 0x188c: 0x2000, 0x188d: 0x2000, 0x188e: 0x2000, 0x188f: 0x2000, 0x1890: 0x2000, 0x1891: 0x2000, - 0x1892: 0x2000, 0x1893: 0x2000, 0x1894: 0x2000, 0x1895: 0x2000, 0x1896: 0x2000, 0x1897: 0x2000, - 0x1898: 0x2000, 0x1899: 0x2000, 0x189a: 0x2000, 0x189b: 0x2000, 0x189c: 0x2000, 0x189d: 0x2000, - 0x189e: 0x2000, 0x189f: 0x2000, 0x18a0: 0x2000, 0x18a1: 0x2000, 0x18a2: 0x2000, 0x18a3: 0x2000, - 0x18a4: 0x2000, 0x18a5: 0x2000, 0x18a6: 0x2000, 0x18a7: 0x2000, 0x18a8: 0x2000, 0x18a9: 0x2000, - 0x18aa: 0x2000, 0x18ab: 0x2000, 0x18ac: 0x2000, 0x18ad: 0x2000, 0x18ae: 0x2000, 0x18af: 0x2000, - 0x18b0: 0x2000, 0x18b1: 0x2000, 0x18b2: 0x2000, 0x18b3: 0x2000, 0x18b4: 0x2000, 0x18b5: 0x2000, - 0x18b6: 0x2000, 0x18b7: 0x2000, 0x18b8: 0x2000, 0x18b9: 0x2000, 0x18ba: 0x2000, 0x18bb: 0x2000, - 0x18bc: 0x2000, 0x18bd: 0x2000, -} - -// widthIndex: 22 blocks, 1408 entries, 1408 bytes -// Block 0 is the zero block. -var widthIndex = [1408]uint8{ - // Block 0x0, offset 0x0 - // Block 0x1, offset 0x40 - // Block 0x2, offset 0x80 - // Block 0x3, offset 0xc0 - 0xc2: 0x01, 0xc3: 0x02, 0xc4: 0x03, 0xc5: 0x04, 0xc7: 0x05, - 0xc9: 0x06, 0xcb: 0x07, 0xcc: 0x08, 0xcd: 0x09, 0xce: 0x0a, 0xcf: 0x0b, - 0xd0: 0x0c, 0xd1: 0x0d, - 0xe1: 0x02, 0xe2: 0x03, 0xe3: 0x04, 0xe4: 0x05, 0xe5: 0x06, 0xe6: 0x06, 0xe7: 0x06, - 0xe8: 0x06, 0xe9: 0x06, 0xea: 0x07, 0xeb: 0x06, 0xec: 0x06, 0xed: 0x08, 0xee: 0x09, 0xef: 0x0a, - 0xf0: 0x0f, 0xf3: 0x12, 0xf4: 0x13, - // Block 0x4, offset 0x100 - 0x104: 0x0e, 0x105: 0x0f, - // Block 0x5, offset 0x140 - 0x140: 0x10, 0x141: 0x11, 0x142: 0x12, 0x144: 0x13, 0x145: 0x14, 0x146: 0x15, 0x147: 0x16, - 0x148: 0x17, 0x149: 0x18, 0x14a: 0x19, 0x14c: 0x1a, 0x14f: 0x1b, - 0x151: 0x1c, 0x152: 0x08, 0x153: 0x1d, 0x154: 0x1e, 0x155: 0x1f, 0x156: 0x20, 0x157: 0x21, - 0x158: 0x22, 0x159: 0x23, 0x15a: 0x24, 0x15b: 0x25, 0x15c: 0x26, 0x15d: 0x27, 0x15e: 0x28, 0x15f: 0x29, - 0x166: 0x2a, - 0x16c: 0x2b, 0x16d: 0x2c, - 0x17a: 0x2d, 0x17b: 0x2e, 0x17c: 0x0e, 0x17d: 0x0e, 0x17e: 0x0e, 0x17f: 0x2f, - // Block 0x6, offset 0x180 - 0x180: 0x30, 0x181: 0x31, 0x182: 0x32, 0x183: 0x33, 0x184: 0x34, 0x185: 0x35, 0x186: 0x36, 0x187: 0x37, - 0x188: 0x38, 0x189: 0x39, 0x18a: 0x0e, 0x18b: 0x3a, 0x18c: 0x0e, 0x18d: 0x0e, 0x18e: 0x0e, 0x18f: 0x0e, - 0x190: 0x0e, 0x191: 0x0e, 0x192: 0x0e, 0x193: 0x0e, 0x194: 0x0e, 0x195: 0x0e, 0x196: 0x0e, 0x197: 0x0e, - 0x198: 0x0e, 0x199: 0x0e, 0x19a: 0x0e, 0x19b: 0x0e, 0x19c: 0x0e, 0x19d: 0x0e, 0x19e: 0x0e, 0x19f: 0x0e, - 0x1a0: 0x0e, 0x1a1: 0x0e, 0x1a2: 0x0e, 0x1a3: 0x0e, 0x1a4: 0x0e, 0x1a5: 0x0e, 0x1a6: 0x0e, 0x1a7: 0x0e, - 0x1a8: 0x0e, 0x1a9: 0x0e, 0x1aa: 0x0e, 0x1ab: 0x0e, 0x1ac: 0x0e, 0x1ad: 0x0e, 0x1ae: 0x0e, 0x1af: 0x0e, - 0x1b0: 0x0e, 0x1b1: 0x0e, 0x1b2: 0x0e, 0x1b3: 0x0e, 0x1b4: 0x0e, 0x1b5: 0x0e, 0x1b6: 0x0e, 0x1b7: 0x0e, - 0x1b8: 0x0e, 0x1b9: 0x0e, 0x1ba: 0x0e, 0x1bb: 0x0e, 0x1bc: 0x0e, 0x1bd: 0x0e, 0x1be: 0x0e, 0x1bf: 0x0e, - // Block 0x7, offset 0x1c0 - 0x1c0: 0x0e, 0x1c1: 0x0e, 0x1c2: 0x0e, 0x1c3: 0x0e, 0x1c4: 0x0e, 0x1c5: 0x0e, 0x1c6: 0x0e, 0x1c7: 0x0e, - 0x1c8: 0x0e, 0x1c9: 0x0e, 0x1ca: 0x0e, 0x1cb: 0x0e, 0x1cc: 0x0e, 0x1cd: 0x0e, 0x1ce: 0x0e, 0x1cf: 0x0e, - 0x1d0: 0x0e, 0x1d1: 0x0e, 0x1d2: 0x0e, 0x1d3: 0x0e, 0x1d4: 0x0e, 0x1d5: 0x0e, 0x1d6: 0x0e, 0x1d7: 0x0e, - 0x1d8: 0x0e, 0x1d9: 0x0e, 0x1da: 0x0e, 0x1db: 0x0e, 0x1dc: 0x0e, 0x1dd: 0x0e, 0x1de: 0x0e, 0x1df: 0x0e, - 0x1e0: 0x0e, 0x1e1: 0x0e, 0x1e2: 0x0e, 0x1e3: 0x0e, 0x1e4: 0x0e, 0x1e5: 0x0e, 0x1e6: 0x0e, 0x1e7: 0x0e, - 0x1e8: 0x0e, 0x1e9: 0x0e, 0x1ea: 0x0e, 0x1eb: 0x0e, 0x1ec: 0x0e, 0x1ed: 0x0e, 0x1ee: 0x0e, 0x1ef: 0x0e, - 0x1f0: 0x0e, 0x1f1: 0x0e, 0x1f2: 0x0e, 0x1f3: 0x0e, 0x1f4: 0x0e, 0x1f5: 0x0e, 0x1f6: 0x0e, - 0x1f8: 0x0e, 0x1f9: 0x0e, 0x1fa: 0x0e, 0x1fb: 0x0e, 0x1fc: 0x0e, 0x1fd: 0x0e, 0x1fe: 0x0e, 0x1ff: 0x0e, - // Block 0x8, offset 0x200 - 0x200: 0x0e, 0x201: 0x0e, 0x202: 0x0e, 0x203: 0x0e, 0x204: 0x0e, 0x205: 0x0e, 0x206: 0x0e, 0x207: 0x0e, - 0x208: 0x0e, 0x209: 0x0e, 0x20a: 0x0e, 0x20b: 0x0e, 0x20c: 0x0e, 0x20d: 0x0e, 0x20e: 0x0e, 0x20f: 0x0e, - 0x210: 0x0e, 0x211: 0x0e, 0x212: 0x0e, 0x213: 0x0e, 0x214: 0x0e, 0x215: 0x0e, 0x216: 0x0e, 0x217: 0x0e, - 0x218: 0x0e, 0x219: 0x0e, 0x21a: 0x0e, 0x21b: 0x0e, 0x21c: 0x0e, 0x21d: 0x0e, 0x21e: 0x0e, 0x21f: 0x0e, - 0x220: 0x0e, 0x221: 0x0e, 0x222: 0x0e, 0x223: 0x0e, 0x224: 0x0e, 0x225: 0x0e, 0x226: 0x0e, 0x227: 0x0e, - 0x228: 0x0e, 0x229: 0x0e, 0x22a: 0x0e, 0x22b: 0x0e, 0x22c: 0x0e, 0x22d: 0x0e, 0x22e: 0x0e, 0x22f: 0x0e, - 0x230: 0x0e, 0x231: 0x0e, 0x232: 0x0e, 0x233: 0x0e, 0x234: 0x0e, 0x235: 0x0e, 0x236: 0x0e, 0x237: 0x0e, - 0x238: 0x0e, 0x239: 0x0e, 0x23a: 0x0e, 0x23b: 0x0e, 0x23c: 0x0e, 0x23d: 0x0e, 0x23e: 0x0e, 0x23f: 0x0e, - // Block 0x9, offset 0x240 - 0x240: 0x0e, 0x241: 0x0e, 0x242: 0x0e, 0x243: 0x0e, 0x244: 0x0e, 0x245: 0x0e, 0x246: 0x0e, 0x247: 0x0e, - 0x248: 0x0e, 0x249: 0x0e, 0x24a: 0x0e, 0x24b: 0x0e, 0x24c: 0x0e, 0x24d: 0x0e, 0x24e: 0x0e, 0x24f: 0x0e, - 0x250: 0x0e, 0x251: 0x0e, 0x252: 0x3b, 0x253: 0x3c, - 0x265: 0x3d, - 0x270: 0x0e, 0x271: 0x0e, 0x272: 0x0e, 0x273: 0x0e, 0x274: 0x0e, 0x275: 0x0e, 0x276: 0x0e, 0x277: 0x0e, - 0x278: 0x0e, 0x279: 0x0e, 0x27a: 0x0e, 0x27b: 0x0e, 0x27c: 0x0e, 0x27d: 0x0e, 0x27e: 0x0e, 0x27f: 0x0e, - // Block 0xa, offset 0x280 - 0x280: 0x0e, 0x281: 0x0e, 0x282: 0x0e, 0x283: 0x0e, 0x284: 0x0e, 0x285: 0x0e, 0x286: 0x0e, 0x287: 0x0e, - 0x288: 0x0e, 0x289: 0x0e, 0x28a: 0x0e, 0x28b: 0x0e, 0x28c: 0x0e, 0x28d: 0x0e, 0x28e: 0x0e, 0x28f: 0x0e, - 0x290: 0x0e, 0x291: 0x0e, 0x292: 0x0e, 0x293: 0x0e, 0x294: 0x0e, 0x295: 0x0e, 0x296: 0x0e, 0x297: 0x0e, - 0x298: 0x0e, 0x299: 0x0e, 0x29a: 0x0e, 0x29b: 0x0e, 0x29c: 0x0e, 0x29d: 0x0e, 0x29e: 0x3e, - // Block 0xb, offset 0x2c0 - 0x2c0: 0x08, 0x2c1: 0x08, 0x2c2: 0x08, 0x2c3: 0x08, 0x2c4: 0x08, 0x2c5: 0x08, 0x2c6: 0x08, 0x2c7: 0x08, - 0x2c8: 0x08, 0x2c9: 0x08, 0x2ca: 0x08, 0x2cb: 0x08, 0x2cc: 0x08, 0x2cd: 0x08, 0x2ce: 0x08, 0x2cf: 0x08, - 0x2d0: 0x08, 0x2d1: 0x08, 0x2d2: 0x08, 0x2d3: 0x08, 0x2d4: 0x08, 0x2d5: 0x08, 0x2d6: 0x08, 0x2d7: 0x08, - 0x2d8: 0x08, 0x2d9: 0x08, 0x2da: 0x08, 0x2db: 0x08, 0x2dc: 0x08, 0x2dd: 0x08, 0x2de: 0x08, 0x2df: 0x08, - 0x2e0: 0x08, 0x2e1: 0x08, 0x2e2: 0x08, 0x2e3: 0x08, 0x2e4: 0x08, 0x2e5: 0x08, 0x2e6: 0x08, 0x2e7: 0x08, - 0x2e8: 0x08, 0x2e9: 0x08, 0x2ea: 0x08, 0x2eb: 0x08, 0x2ec: 0x08, 0x2ed: 0x08, 0x2ee: 0x08, 0x2ef: 0x08, - 0x2f0: 0x08, 0x2f1: 0x08, 0x2f2: 0x08, 0x2f3: 0x08, 0x2f4: 0x08, 0x2f5: 0x08, 0x2f6: 0x08, 0x2f7: 0x08, - 0x2f8: 0x08, 0x2f9: 0x08, 0x2fa: 0x08, 0x2fb: 0x08, 0x2fc: 0x08, 0x2fd: 0x08, 0x2fe: 0x08, 0x2ff: 0x08, - // Block 0xc, offset 0x300 - 0x300: 0x08, 0x301: 0x08, 0x302: 0x08, 0x303: 0x08, 0x304: 0x08, 0x305: 0x08, 0x306: 0x08, 0x307: 0x08, - 0x308: 0x08, 0x309: 0x08, 0x30a: 0x08, 0x30b: 0x08, 0x30c: 0x08, 0x30d: 0x08, 0x30e: 0x08, 0x30f: 0x08, - 0x310: 0x08, 0x311: 0x08, 0x312: 0x08, 0x313: 0x08, 0x314: 0x08, 0x315: 0x08, 0x316: 0x08, 0x317: 0x08, - 0x318: 0x08, 0x319: 0x08, 0x31a: 0x08, 0x31b: 0x08, 0x31c: 0x08, 0x31d: 0x08, 0x31e: 0x08, 0x31f: 0x08, - 0x320: 0x08, 0x321: 0x08, 0x322: 0x08, 0x323: 0x08, 0x324: 0x0e, 0x325: 0x0e, 0x326: 0x0e, 0x327: 0x0e, - 0x328: 0x0e, 0x329: 0x0e, 0x32a: 0x0e, 0x32b: 0x0e, - 0x338: 0x3f, 0x339: 0x40, 0x33c: 0x41, 0x33d: 0x42, 0x33e: 0x43, 0x33f: 0x44, - // Block 0xd, offset 0x340 - 0x37f: 0x45, - // Block 0xe, offset 0x380 - 0x380: 0x0e, 0x381: 0x0e, 0x382: 0x0e, 0x383: 0x0e, 0x384: 0x0e, 0x385: 0x0e, 0x386: 0x0e, 0x387: 0x0e, - 0x388: 0x0e, 0x389: 0x0e, 0x38a: 0x0e, 0x38b: 0x0e, 0x38c: 0x0e, 0x38d: 0x0e, 0x38e: 0x0e, 0x38f: 0x0e, - 0x390: 0x0e, 0x391: 0x0e, 0x392: 0x0e, 0x393: 0x0e, 0x394: 0x0e, 0x395: 0x0e, 0x396: 0x0e, 0x397: 0x0e, - 0x398: 0x0e, 0x399: 0x0e, 0x39a: 0x0e, 0x39b: 0x0e, 0x39c: 0x0e, 0x39d: 0x0e, 0x39e: 0x0e, 0x39f: 0x46, - 0x3a0: 0x0e, 0x3a1: 0x0e, 0x3a2: 0x0e, 0x3a3: 0x0e, 0x3a4: 0x0e, 0x3a5: 0x0e, 0x3a6: 0x0e, 0x3a7: 0x0e, - 0x3a8: 0x0e, 0x3a9: 0x0e, 0x3aa: 0x0e, 0x3ab: 0x47, - // Block 0xf, offset 0x3c0 - 0x3c0: 0x48, - // Block 0x10, offset 0x400 - 0x400: 0x49, 0x403: 0x4a, 0x404: 0x4b, 0x405: 0x4c, 0x406: 0x4d, - 0x408: 0x4e, 0x409: 0x4f, 0x40c: 0x50, 0x40d: 0x51, 0x40e: 0x52, 0x40f: 0x53, - 0x410: 0x3a, 0x411: 0x54, 0x412: 0x0e, 0x413: 0x55, 0x414: 0x56, 0x415: 0x57, 0x416: 0x58, 0x417: 0x59, - 0x418: 0x0e, 0x419: 0x5a, 0x41a: 0x0e, 0x41b: 0x5b, - 0x424: 0x5c, 0x425: 0x5d, 0x426: 0x5e, 0x427: 0x5f, - // Block 0x11, offset 0x440 - 0x456: 0x0b, 0x457: 0x06, - 0x458: 0x0c, 0x45b: 0x0d, 0x45f: 0x0e, - 0x460: 0x06, 0x461: 0x06, 0x462: 0x06, 0x463: 0x06, 0x464: 0x06, 0x465: 0x06, 0x466: 0x06, 0x467: 0x06, - 0x468: 0x06, 0x469: 0x06, 0x46a: 0x06, 0x46b: 0x06, 0x46c: 0x06, 0x46d: 0x06, 0x46e: 0x06, 0x46f: 0x06, - 0x470: 0x06, 0x471: 0x06, 0x472: 0x06, 0x473: 0x06, 0x474: 0x06, 0x475: 0x06, 0x476: 0x06, 0x477: 0x06, - 0x478: 0x06, 0x479: 0x06, 0x47a: 0x06, 0x47b: 0x06, 0x47c: 0x06, 0x47d: 0x06, 0x47e: 0x06, 0x47f: 0x06, - // Block 0x12, offset 0x480 - 0x484: 0x08, 0x485: 0x08, 0x486: 0x08, 0x487: 0x09, - // Block 0x13, offset 0x4c0 - 0x4c0: 0x08, 0x4c1: 0x08, 0x4c2: 0x08, 0x4c3: 0x08, 0x4c4: 0x08, 0x4c5: 0x08, 0x4c6: 0x08, 0x4c7: 0x08, - 0x4c8: 0x08, 0x4c9: 0x08, 0x4ca: 0x08, 0x4cb: 0x08, 0x4cc: 0x08, 0x4cd: 0x08, 0x4ce: 0x08, 0x4cf: 0x08, - 0x4d0: 0x08, 0x4d1: 0x08, 0x4d2: 0x08, 0x4d3: 0x08, 0x4d4: 0x08, 0x4d5: 0x08, 0x4d6: 0x08, 0x4d7: 0x08, - 0x4d8: 0x08, 0x4d9: 0x08, 0x4da: 0x08, 0x4db: 0x08, 0x4dc: 0x08, 0x4dd: 0x08, 0x4de: 0x08, 0x4df: 0x08, - 0x4e0: 0x08, 0x4e1: 0x08, 0x4e2: 0x08, 0x4e3: 0x08, 0x4e4: 0x08, 0x4e5: 0x08, 0x4e6: 0x08, 0x4e7: 0x08, - 0x4e8: 0x08, 0x4e9: 0x08, 0x4ea: 0x08, 0x4eb: 0x08, 0x4ec: 0x08, 0x4ed: 0x08, 0x4ee: 0x08, 0x4ef: 0x08, - 0x4f0: 0x08, 0x4f1: 0x08, 0x4f2: 0x08, 0x4f3: 0x08, 0x4f4: 0x08, 0x4f5: 0x08, 0x4f6: 0x08, 0x4f7: 0x08, - 0x4f8: 0x08, 0x4f9: 0x08, 0x4fa: 0x08, 0x4fb: 0x08, 0x4fc: 0x08, 0x4fd: 0x08, 0x4fe: 0x08, 0x4ff: 0x60, - // Block 0x14, offset 0x500 - 0x520: 0x10, - 0x530: 0x09, 0x531: 0x09, 0x532: 0x09, 0x533: 0x09, 0x534: 0x09, 0x535: 0x09, 0x536: 0x09, 0x537: 0x09, - 0x538: 0x09, 0x539: 0x09, 0x53a: 0x09, 0x53b: 0x09, 0x53c: 0x09, 0x53d: 0x09, 0x53e: 0x09, 0x53f: 0x11, - // Block 0x15, offset 0x540 - 0x540: 0x09, 0x541: 0x09, 0x542: 0x09, 0x543: 0x09, 0x544: 0x09, 0x545: 0x09, 0x546: 0x09, 0x547: 0x09, - 0x548: 0x09, 0x549: 0x09, 0x54a: 0x09, 0x54b: 0x09, 0x54c: 0x09, 0x54d: 0x09, 0x54e: 0x09, 0x54f: 0x11, -} - -// inverseData contains 4-byte entries of the following format: -// -// <0 padding> -// -// The last byte of the UTF-8-encoded rune is xor-ed with the last byte of the -// UTF-8 encoding of the original rune. Mappings often have the following -// pattern: -// -// A -> A (U+FF21 -> U+0041) -// B -> B (U+FF22 -> U+0042) -// ... -// -// By xor-ing the last byte the same entry can be shared by many mappings. This -// reduces the total number of distinct entries by about two thirds. -// The resulting entry for the aforementioned mappings is -// -// { 0x01, 0xE0, 0x00, 0x00 } -// -// Using this entry to map U+FF21 (UTF-8 [EF BC A1]), we get -// -// E0 ^ A1 = 41. -// -// Similarly, for U+FF22 (UTF-8 [EF BC A2]), we get -// -// E0 ^ A2 = 42. -// -// Note that because of the xor-ing, the byte sequence stored in the entry is -// not valid UTF-8. -var inverseData = [150][4]byte{ - {0x00, 0x00, 0x00, 0x00}, - {0x03, 0xe3, 0x80, 0xa0}, - {0x03, 0xef, 0xbc, 0xa0}, - {0x03, 0xef, 0xbc, 0xe0}, - {0x03, 0xef, 0xbd, 0xe0}, - {0x03, 0xef, 0xbf, 0x02}, - {0x03, 0xef, 0xbf, 0x00}, - {0x03, 0xef, 0xbf, 0x0e}, - {0x03, 0xef, 0xbf, 0x0c}, - {0x03, 0xef, 0xbf, 0x0f}, - {0x03, 0xef, 0xbf, 0x39}, - {0x03, 0xef, 0xbf, 0x3b}, - {0x03, 0xef, 0xbf, 0x3f}, - {0x03, 0xef, 0xbf, 0x2a}, - {0x03, 0xef, 0xbf, 0x0d}, - {0x03, 0xef, 0xbf, 0x25}, - {0x03, 0xef, 0xbd, 0x1a}, - {0x03, 0xef, 0xbd, 0x26}, - {0x01, 0xa0, 0x00, 0x00}, - {0x03, 0xef, 0xbd, 0x25}, - {0x03, 0xef, 0xbd, 0x23}, - {0x03, 0xef, 0xbd, 0x2e}, - {0x03, 0xef, 0xbe, 0x07}, - {0x03, 0xef, 0xbe, 0x05}, - {0x03, 0xef, 0xbd, 0x06}, - {0x03, 0xef, 0xbd, 0x13}, - {0x03, 0xef, 0xbd, 0x0b}, - {0x03, 0xef, 0xbd, 0x16}, - {0x03, 0xef, 0xbd, 0x0c}, - {0x03, 0xef, 0xbd, 0x15}, - {0x03, 0xef, 0xbd, 0x0d}, - {0x03, 0xef, 0xbd, 0x1c}, - {0x03, 0xef, 0xbd, 0x02}, - {0x03, 0xef, 0xbd, 0x1f}, - {0x03, 0xef, 0xbd, 0x1d}, - {0x03, 0xef, 0xbd, 0x17}, - {0x03, 0xef, 0xbd, 0x08}, - {0x03, 0xef, 0xbd, 0x09}, - {0x03, 0xef, 0xbd, 0x0e}, - {0x03, 0xef, 0xbd, 0x04}, - {0x03, 0xef, 0xbd, 0x05}, - {0x03, 0xef, 0xbe, 0x3f}, - {0x03, 0xef, 0xbe, 0x00}, - {0x03, 0xef, 0xbd, 0x2c}, - {0x03, 0xef, 0xbe, 0x06}, - {0x03, 0xef, 0xbe, 0x0c}, - {0x03, 0xef, 0xbe, 0x0f}, - {0x03, 0xef, 0xbe, 0x0d}, - {0x03, 0xef, 0xbe, 0x0b}, - {0x03, 0xef, 0xbe, 0x19}, - {0x03, 0xef, 0xbe, 0x15}, - {0x03, 0xef, 0xbe, 0x11}, - {0x03, 0xef, 0xbe, 0x31}, - {0x03, 0xef, 0xbe, 0x33}, - {0x03, 0xef, 0xbd, 0x0f}, - {0x03, 0xef, 0xbe, 0x30}, - {0x03, 0xef, 0xbe, 0x3e}, - {0x03, 0xef, 0xbe, 0x32}, - {0x03, 0xef, 0xbe, 0x36}, - {0x03, 0xef, 0xbd, 0x14}, - {0x03, 0xef, 0xbe, 0x2e}, - {0x03, 0xef, 0xbd, 0x1e}, - {0x03, 0xef, 0xbe, 0x10}, - {0x03, 0xef, 0xbf, 0x13}, - {0x03, 0xef, 0xbf, 0x15}, - {0x03, 0xef, 0xbf, 0x17}, - {0x03, 0xef, 0xbf, 0x1f}, - {0x03, 0xef, 0xbf, 0x1d}, - {0x03, 0xef, 0xbf, 0x1b}, - {0x03, 0xef, 0xbf, 0x09}, - {0x03, 0xef, 0xbf, 0x0b}, - {0x03, 0xef, 0xbf, 0x37}, - {0x03, 0xef, 0xbe, 0x04}, - {0x01, 0xe0, 0x00, 0x00}, - {0x03, 0xe2, 0xa6, 0x1a}, - {0x03, 0xe2, 0xa6, 0x26}, - {0x03, 0xe3, 0x80, 0x23}, - {0x03, 0xe3, 0x80, 0x2e}, - {0x03, 0xe3, 0x80, 0x25}, - {0x03, 0xe3, 0x83, 0x1e}, - {0x03, 0xe3, 0x83, 0x14}, - {0x03, 0xe3, 0x82, 0x06}, - {0x03, 0xe3, 0x82, 0x0b}, - {0x03, 0xe3, 0x82, 0x0c}, - {0x03, 0xe3, 0x82, 0x0d}, - {0x03, 0xe3, 0x82, 0x02}, - {0x03, 0xe3, 0x83, 0x0f}, - {0x03, 0xe3, 0x83, 0x08}, - {0x03, 0xe3, 0x83, 0x09}, - {0x03, 0xe3, 0x83, 0x2c}, - {0x03, 0xe3, 0x83, 0x0c}, - {0x03, 0xe3, 0x82, 0x13}, - {0x03, 0xe3, 0x82, 0x16}, - {0x03, 0xe3, 0x82, 0x15}, - {0x03, 0xe3, 0x82, 0x1c}, - {0x03, 0xe3, 0x82, 0x1f}, - {0x03, 0xe3, 0x82, 0x1d}, - {0x03, 0xe3, 0x82, 0x1a}, - {0x03, 0xe3, 0x82, 0x17}, - {0x03, 0xe3, 0x82, 0x08}, - {0x03, 0xe3, 0x82, 0x09}, - {0x03, 0xe3, 0x82, 0x0e}, - {0x03, 0xe3, 0x82, 0x04}, - {0x03, 0xe3, 0x82, 0x05}, - {0x03, 0xe3, 0x82, 0x3f}, - {0x03, 0xe3, 0x83, 0x00}, - {0x03, 0xe3, 0x83, 0x06}, - {0x03, 0xe3, 0x83, 0x05}, - {0x03, 0xe3, 0x83, 0x0d}, - {0x03, 0xe3, 0x83, 0x0b}, - {0x03, 0xe3, 0x83, 0x07}, - {0x03, 0xe3, 0x83, 0x19}, - {0x03, 0xe3, 0x83, 0x15}, - {0x03, 0xe3, 0x83, 0x11}, - {0x03, 0xe3, 0x83, 0x31}, - {0x03, 0xe3, 0x83, 0x33}, - {0x03, 0xe3, 0x83, 0x30}, - {0x03, 0xe3, 0x83, 0x3e}, - {0x03, 0xe3, 0x83, 0x32}, - {0x03, 0xe3, 0x83, 0x36}, - {0x03, 0xe3, 0x83, 0x2e}, - {0x03, 0xe3, 0x82, 0x07}, - {0x03, 0xe3, 0x85, 0x04}, - {0x03, 0xe3, 0x84, 0x10}, - {0x03, 0xe3, 0x85, 0x30}, - {0x03, 0xe3, 0x85, 0x0d}, - {0x03, 0xe3, 0x85, 0x13}, - {0x03, 0xe3, 0x85, 0x15}, - {0x03, 0xe3, 0x85, 0x17}, - {0x03, 0xe3, 0x85, 0x1f}, - {0x03, 0xe3, 0x85, 0x1d}, - {0x03, 0xe3, 0x85, 0x1b}, - {0x03, 0xe3, 0x85, 0x09}, - {0x03, 0xe3, 0x85, 0x0f}, - {0x03, 0xe3, 0x85, 0x0b}, - {0x03, 0xe3, 0x85, 0x37}, - {0x03, 0xe3, 0x85, 0x3b}, - {0x03, 0xe3, 0x85, 0x39}, - {0x03, 0xe3, 0x85, 0x3f}, - {0x02, 0xc2, 0x02, 0x00}, - {0x02, 0xc2, 0x0e, 0x00}, - {0x02, 0xc2, 0x0c, 0x00}, - {0x02, 0xc2, 0x00, 0x00}, - {0x03, 0xe2, 0x82, 0x0f}, - {0x03, 0xe2, 0x94, 0x2a}, - {0x03, 0xe2, 0x86, 0x39}, - {0x03, 0xe2, 0x86, 0x3b}, - {0x03, 0xe2, 0x86, 0x3f}, - {0x03, 0xe2, 0x96, 0x0d}, - {0x03, 0xe2, 0x97, 0x25}, -} - -// Total table size 14680 bytes (14KiB) diff --git a/vendor/golang.org/x/text/width/transform.go b/vendor/golang.org/x/text/width/transform.go deleted file mode 100644 index 0049f700a..000000000 --- a/vendor/golang.org/x/text/width/transform.go +++ /dev/null @@ -1,239 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package width - -import ( - "unicode/utf8" - - "golang.org/x/text/transform" -) - -type foldTransform struct { - transform.NopResetter -} - -func (foldTransform) Span(src []byte, atEOF bool) (n int, err error) { - for n < len(src) { - if src[n] < utf8.RuneSelf { - // ASCII fast path. - for n++; n < len(src) && src[n] < utf8.RuneSelf; n++ { - } - continue - } - v, size := trie.lookup(src[n:]) - if size == 0 { // incomplete UTF-8 encoding - if !atEOF { - err = transform.ErrShortSrc - } else { - n = len(src) - } - break - } - if elem(v)&tagNeedsFold != 0 { - err = transform.ErrEndOfSpan - break - } - n += size - } - return n, err -} - -func (foldTransform) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) { - for nSrc < len(src) { - if src[nSrc] < utf8.RuneSelf { - // ASCII fast path. - start, end := nSrc, len(src) - if d := len(dst) - nDst; d < end-start { - end = nSrc + d - } - for nSrc++; nSrc < end && src[nSrc] < utf8.RuneSelf; nSrc++ { - } - n := copy(dst[nDst:], src[start:nSrc]) - if nDst += n; nDst == len(dst) { - nSrc = start + n - if nSrc == len(src) { - return nDst, nSrc, nil - } - if src[nSrc] < utf8.RuneSelf { - return nDst, nSrc, transform.ErrShortDst - } - } - continue - } - v, size := trie.lookup(src[nSrc:]) - if size == 0 { // incomplete UTF-8 encoding - if !atEOF { - return nDst, nSrc, transform.ErrShortSrc - } - size = 1 // gobble 1 byte - } - if elem(v)&tagNeedsFold == 0 { - if size != copy(dst[nDst:], src[nSrc:nSrc+size]) { - return nDst, nSrc, transform.ErrShortDst - } - nDst += size - } else { - data := inverseData[byte(v)] - if len(dst)-nDst < int(data[0]) { - return nDst, nSrc, transform.ErrShortDst - } - i := 1 - for end := int(data[0]); i < end; i++ { - dst[nDst] = data[i] - nDst++ - } - dst[nDst] = data[i] ^ src[nSrc+size-1] - nDst++ - } - nSrc += size - } - return nDst, nSrc, nil -} - -type narrowTransform struct { - transform.NopResetter -} - -func (narrowTransform) Span(src []byte, atEOF bool) (n int, err error) { - for n < len(src) { - if src[n] < utf8.RuneSelf { - // ASCII fast path. - for n++; n < len(src) && src[n] < utf8.RuneSelf; n++ { - } - continue - } - v, size := trie.lookup(src[n:]) - if size == 0 { // incomplete UTF-8 encoding - if !atEOF { - err = transform.ErrShortSrc - } else { - n = len(src) - } - break - } - if k := elem(v).kind(); byte(v) == 0 || k != EastAsianFullwidth && k != EastAsianWide && k != EastAsianAmbiguous { - } else { - err = transform.ErrEndOfSpan - break - } - n += size - } - return n, err -} - -func (narrowTransform) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) { - for nSrc < len(src) { - if src[nSrc] < utf8.RuneSelf { - // ASCII fast path. - start, end := nSrc, len(src) - if d := len(dst) - nDst; d < end-start { - end = nSrc + d - } - for nSrc++; nSrc < end && src[nSrc] < utf8.RuneSelf; nSrc++ { - } - n := copy(dst[nDst:], src[start:nSrc]) - if nDst += n; nDst == len(dst) { - nSrc = start + n - if nSrc == len(src) { - return nDst, nSrc, nil - } - if src[nSrc] < utf8.RuneSelf { - return nDst, nSrc, transform.ErrShortDst - } - } - continue - } - v, size := trie.lookup(src[nSrc:]) - if size == 0 { // incomplete UTF-8 encoding - if !atEOF { - return nDst, nSrc, transform.ErrShortSrc - } - size = 1 // gobble 1 byte - } - if k := elem(v).kind(); byte(v) == 0 || k != EastAsianFullwidth && k != EastAsianWide && k != EastAsianAmbiguous { - if size != copy(dst[nDst:], src[nSrc:nSrc+size]) { - return nDst, nSrc, transform.ErrShortDst - } - nDst += size - } else { - data := inverseData[byte(v)] - if len(dst)-nDst < int(data[0]) { - return nDst, nSrc, transform.ErrShortDst - } - i := 1 - for end := int(data[0]); i < end; i++ { - dst[nDst] = data[i] - nDst++ - } - dst[nDst] = data[i] ^ src[nSrc+size-1] - nDst++ - } - nSrc += size - } - return nDst, nSrc, nil -} - -type wideTransform struct { - transform.NopResetter -} - -func (wideTransform) Span(src []byte, atEOF bool) (n int, err error) { - for n < len(src) { - // TODO: Consider ASCII fast path. Special-casing ASCII handling can - // reduce the ns/op of BenchmarkWideASCII by about 30%. This is probably - // not enough to warrant the extra code and complexity. - v, size := trie.lookup(src[n:]) - if size == 0 { // incomplete UTF-8 encoding - if !atEOF { - err = transform.ErrShortSrc - } else { - n = len(src) - } - break - } - if k := elem(v).kind(); byte(v) == 0 || k != EastAsianHalfwidth && k != EastAsianNarrow { - } else { - err = transform.ErrEndOfSpan - break - } - n += size - } - return n, err -} - -func (wideTransform) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) { - for nSrc < len(src) { - // TODO: Consider ASCII fast path. Special-casing ASCII handling can - // reduce the ns/op of BenchmarkWideASCII by about 30%. This is probably - // not enough to warrant the extra code and complexity. - v, size := trie.lookup(src[nSrc:]) - if size == 0 { // incomplete UTF-8 encoding - if !atEOF { - return nDst, nSrc, transform.ErrShortSrc - } - size = 1 // gobble 1 byte - } - if k := elem(v).kind(); byte(v) == 0 || k != EastAsianHalfwidth && k != EastAsianNarrow { - if size != copy(dst[nDst:], src[nSrc:nSrc+size]) { - return nDst, nSrc, transform.ErrShortDst - } - nDst += size - } else { - data := inverseData[byte(v)] - if len(dst)-nDst < int(data[0]) { - return nDst, nSrc, transform.ErrShortDst - } - i := 1 - for end := int(data[0]); i < end; i++ { - dst[nDst] = data[i] - nDst++ - } - dst[nDst] = data[i] ^ src[nSrc+size-1] - nDst++ - } - nSrc += size - } - return nDst, nSrc, nil -} diff --git a/vendor/golang.org/x/text/width/trieval.go b/vendor/golang.org/x/text/width/trieval.go deleted file mode 100644 index ca8e45fd1..000000000 --- a/vendor/golang.org/x/text/width/trieval.go +++ /dev/null @@ -1,30 +0,0 @@ -// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. - -package width - -// elem is an entry of the width trie. The high byte is used to encode the type -// of the rune. The low byte is used to store the index to a mapping entry in -// the inverseData array. -type elem uint16 - -const ( - tagNeutral elem = iota << typeShift - tagAmbiguous - tagWide - tagNarrow - tagFullwidth - tagHalfwidth -) - -const ( - numTypeBits = 3 - typeShift = 16 - numTypeBits - - // tagNeedsFold is true for all fullwidth and halfwidth runes except for - // the Won sign U+20A9. - tagNeedsFold = 0x1000 - - // The Korean Won sign is halfwidth, but SHOULD NOT be mapped to a wide - // variant. - wonSign rune = 0x20A9 -) diff --git a/vendor/golang.org/x/text/width/width.go b/vendor/golang.org/x/text/width/width.go deleted file mode 100644 index 29c7509be..000000000 --- a/vendor/golang.org/x/text/width/width.go +++ /dev/null @@ -1,206 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:generate stringer -type=Kind -//go:generate go run gen.go gen_common.go gen_trieval.go - -// Package width provides functionality for handling different widths in text. -// -// Wide characters behave like ideographs; they tend to allow line breaks after -// each character and remain upright in vertical text layout. Narrow characters -// are kept together in words or runs that are rotated sideways in vertical text -// layout. -// -// For more information, see https://unicode.org/reports/tr11/. -package width // import "golang.org/x/text/width" - -import ( - "unicode/utf8" - - "golang.org/x/text/transform" -) - -// TODO -// 1) Reduce table size by compressing blocks. -// 2) API proposition for computing display length -// (approximation, fixed pitch only). -// 3) Implement display length. - -// Kind indicates the type of width property as defined in https://unicode.org/reports/tr11/. -type Kind int - -const ( - // Neutral characters do not occur in legacy East Asian character sets. - Neutral Kind = iota - - // EastAsianAmbiguous characters that can be sometimes wide and sometimes - // narrow and require additional information not contained in the character - // code to further resolve their width. - EastAsianAmbiguous - - // EastAsianWide characters are wide in its usual form. They occur only in - // the context of East Asian typography. These runes may have explicit - // halfwidth counterparts. - EastAsianWide - - // EastAsianNarrow characters are narrow in its usual form. They often have - // fullwidth counterparts. - EastAsianNarrow - - // Note: there exist Narrow runes that do not have fullwidth or wide - // counterparts, despite what the definition says (e.g. U+27E6). - - // EastAsianFullwidth characters have a compatibility decompositions of type - // wide that map to a narrow counterpart. - EastAsianFullwidth - - // EastAsianHalfwidth characters have a compatibility decomposition of type - // narrow that map to a wide or ambiguous counterpart, plus U+20A9 ₩ WON - // SIGN. - EastAsianHalfwidth - - // Note: there exist runes that have a halfwidth counterparts but that are - // classified as Ambiguous, rather than wide (e.g. U+2190). -) - -// TODO: the generated tries need to return size 1 for invalid runes for the -// width to be computed correctly (each byte should render width 1) - -var trie = newWidthTrie(0) - -// Lookup reports the Properties of the first rune in b and the number of bytes -// of its UTF-8 encoding. -func Lookup(b []byte) (p Properties, size int) { - v, sz := trie.lookup(b) - return Properties{elem(v), b[sz-1]}, sz -} - -// LookupString reports the Properties of the first rune in s and the number of -// bytes of its UTF-8 encoding. -func LookupString(s string) (p Properties, size int) { - v, sz := trie.lookupString(s) - return Properties{elem(v), s[sz-1]}, sz -} - -// LookupRune reports the Properties of rune r. -func LookupRune(r rune) Properties { - var buf [4]byte - n := utf8.EncodeRune(buf[:], r) - v, _ := trie.lookup(buf[:n]) - last := byte(r) - if r >= utf8.RuneSelf { - last = 0x80 + byte(r&0x3f) - } - return Properties{elem(v), last} -} - -// Properties provides access to width properties of a rune. -type Properties struct { - elem elem - last byte -} - -func (e elem) kind() Kind { - return Kind(e >> typeShift) -} - -// Kind returns the Kind of a rune as defined in Unicode TR #11. -// See https://unicode.org/reports/tr11/ for more details. -func (p Properties) Kind() Kind { - return p.elem.kind() -} - -// Folded returns the folded variant of a rune or 0 if the rune is canonical. -func (p Properties) Folded() rune { - if p.elem&tagNeedsFold != 0 { - buf := inverseData[byte(p.elem)] - buf[buf[0]] ^= p.last - r, _ := utf8.DecodeRune(buf[1 : 1+buf[0]]) - return r - } - return 0 -} - -// Narrow returns the narrow variant of a rune or 0 if the rune is already -// narrow or doesn't have a narrow variant. -func (p Properties) Narrow() rune { - if k := p.elem.kind(); byte(p.elem) != 0 && (k == EastAsianFullwidth || k == EastAsianWide || k == EastAsianAmbiguous) { - buf := inverseData[byte(p.elem)] - buf[buf[0]] ^= p.last - r, _ := utf8.DecodeRune(buf[1 : 1+buf[0]]) - return r - } - return 0 -} - -// Wide returns the wide variant of a rune or 0 if the rune is already -// wide or doesn't have a wide variant. -func (p Properties) Wide() rune { - if k := p.elem.kind(); byte(p.elem) != 0 && (k == EastAsianHalfwidth || k == EastAsianNarrow) { - buf := inverseData[byte(p.elem)] - buf[buf[0]] ^= p.last - r, _ := utf8.DecodeRune(buf[1 : 1+buf[0]]) - return r - } - return 0 -} - -// TODO for Properties: -// - Add Fullwidth/Halfwidth or Inverted methods for computing variants -// mapping. -// - Add width information (including information on non-spacing runes). - -// Transformer implements the transform.Transformer interface. -type Transformer struct { - t transform.SpanningTransformer -} - -// Reset implements the transform.Transformer interface. -func (t Transformer) Reset() { t.t.Reset() } - -// Transform implements the transform.Transformer interface. -func (t Transformer) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) { - return t.t.Transform(dst, src, atEOF) -} - -// Span implements the transform.SpanningTransformer interface. -func (t Transformer) Span(src []byte, atEOF bool) (n int, err error) { - return t.t.Span(src, atEOF) -} - -// Bytes returns a new byte slice with the result of applying t to b. -func (t Transformer) Bytes(b []byte) []byte { - b, _, _ = transform.Bytes(t, b) - return b -} - -// String returns a string with the result of applying t to s. -func (t Transformer) String(s string) string { - s, _, _ = transform.String(t, s) - return s -} - -var ( - // Fold is a transform that maps all runes to their canonical width. - // - // Note that the NFKC and NFKD transforms in golang.org/x/text/unicode/norm - // provide a more generic folding mechanism. - Fold Transformer = Transformer{foldTransform{}} - - // Widen is a transform that maps runes to their wide variant, if - // available. - Widen Transformer = Transformer{wideTransform{}} - - // Narrow is a transform that maps runes to their narrow variant, if - // available. - Narrow Transformer = Transformer{narrowTransform{}} -) - -// TODO: Consider the following options: -// - Treat Ambiguous runes that have a halfwidth counterpart as wide, or some -// generalized variant of this. -// - Consider a wide Won character to be the default width (or some generalized -// variant of this). -// - Filter the set of characters that gets converted (the preferred approach is -// to allow applying filters to transforms). diff --git a/vendor/google.golang.org/genproto/googleapis/api/LICENSE b/vendor/google.golang.org/genproto/googleapis/api/LICENSE deleted file mode 100644 index d64569567..000000000 --- a/vendor/google.golang.org/genproto/googleapis/api/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/checked.pb.go b/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/checked.pb.go deleted file mode 100644 index 137ff5b1e..000000000 --- a/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/checked.pb.go +++ /dev/null @@ -1,1664 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.26.0 -// protoc v4.24.4 -// source: google/api/expr/v1alpha1/checked.proto - -package expr - -import ( - reflect "reflect" - sync "sync" - - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - emptypb "google.golang.org/protobuf/types/known/emptypb" - structpb "google.golang.org/protobuf/types/known/structpb" -) - -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) -) - -// CEL primitive types. -type Type_PrimitiveType int32 - -const ( - // Unspecified type. - Type_PRIMITIVE_TYPE_UNSPECIFIED Type_PrimitiveType = 0 - // Boolean type. - Type_BOOL Type_PrimitiveType = 1 - // Int64 type. - // - // Proto-based integer values are widened to int64. - Type_INT64 Type_PrimitiveType = 2 - // Uint64 type. - // - // Proto-based unsigned integer values are widened to uint64. - Type_UINT64 Type_PrimitiveType = 3 - // Double type. - // - // Proto-based float values are widened to double values. - Type_DOUBLE Type_PrimitiveType = 4 - // String type. - Type_STRING Type_PrimitiveType = 5 - // Bytes type. - Type_BYTES Type_PrimitiveType = 6 -) - -// Enum value maps for Type_PrimitiveType. -var ( - Type_PrimitiveType_name = map[int32]string{ - 0: "PRIMITIVE_TYPE_UNSPECIFIED", - 1: "BOOL", - 2: "INT64", - 3: "UINT64", - 4: "DOUBLE", - 5: "STRING", - 6: "BYTES", - } - Type_PrimitiveType_value = map[string]int32{ - "PRIMITIVE_TYPE_UNSPECIFIED": 0, - "BOOL": 1, - "INT64": 2, - "UINT64": 3, - "DOUBLE": 4, - "STRING": 5, - "BYTES": 6, - } -) - -func (x Type_PrimitiveType) Enum() *Type_PrimitiveType { - p := new(Type_PrimitiveType) - *p = x - return p -} - -func (x Type_PrimitiveType) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (Type_PrimitiveType) Descriptor() protoreflect.EnumDescriptor { - return file_google_api_expr_v1alpha1_checked_proto_enumTypes[0].Descriptor() -} - -func (Type_PrimitiveType) Type() protoreflect.EnumType { - return &file_google_api_expr_v1alpha1_checked_proto_enumTypes[0] -} - -func (x Type_PrimitiveType) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use Type_PrimitiveType.Descriptor instead. -func (Type_PrimitiveType) EnumDescriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_checked_proto_rawDescGZIP(), []int{1, 0} -} - -// Well-known protobuf types treated with first-class support in CEL. -type Type_WellKnownType int32 - -const ( - // Unspecified type. - Type_WELL_KNOWN_TYPE_UNSPECIFIED Type_WellKnownType = 0 - // Well-known protobuf.Any type. - // - // Any types are a polymorphic message type. During type-checking they are - // treated like `DYN` types, but at runtime they are resolved to a specific - // message type specified at evaluation time. - Type_ANY Type_WellKnownType = 1 - // Well-known protobuf.Timestamp type, internally referenced as `timestamp`. - Type_TIMESTAMP Type_WellKnownType = 2 - // Well-known protobuf.Duration type, internally referenced as `duration`. - Type_DURATION Type_WellKnownType = 3 -) - -// Enum value maps for Type_WellKnownType. -var ( - Type_WellKnownType_name = map[int32]string{ - 0: "WELL_KNOWN_TYPE_UNSPECIFIED", - 1: "ANY", - 2: "TIMESTAMP", - 3: "DURATION", - } - Type_WellKnownType_value = map[string]int32{ - "WELL_KNOWN_TYPE_UNSPECIFIED": 0, - "ANY": 1, - "TIMESTAMP": 2, - "DURATION": 3, - } -) - -func (x Type_WellKnownType) Enum() *Type_WellKnownType { - p := new(Type_WellKnownType) - *p = x - return p -} - -func (x Type_WellKnownType) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (Type_WellKnownType) Descriptor() protoreflect.EnumDescriptor { - return file_google_api_expr_v1alpha1_checked_proto_enumTypes[1].Descriptor() -} - -func (Type_WellKnownType) Type() protoreflect.EnumType { - return &file_google_api_expr_v1alpha1_checked_proto_enumTypes[1] -} - -func (x Type_WellKnownType) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use Type_WellKnownType.Descriptor instead. -func (Type_WellKnownType) EnumDescriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_checked_proto_rawDescGZIP(), []int{1, 1} -} - -// A CEL expression which has been successfully type checked. -type CheckedExpr struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // A map from expression ids to resolved references. - // - // The following entries are in this table: - // - // - An Ident or Select expression is represented here if it resolves to a - // declaration. For instance, if `a.b.c` is represented by - // `select(select(id(a), b), c)`, and `a.b` resolves to a declaration, - // while `c` is a field selection, then the reference is attached to the - // nested select expression (but not to the id or or the outer select). - // In turn, if `a` resolves to a declaration and `b.c` are field selections, - // the reference is attached to the ident expression. - // - Every Call expression has an entry here, identifying the function being - // called. - // - Every CreateStruct expression for a message has an entry, identifying - // the message. - ReferenceMap map[int64]*Reference `protobuf:"bytes,2,rep,name=reference_map,json=referenceMap,proto3" json:"reference_map,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - // A map from expression ids to types. - // - // Every expression node which has a type different than DYN has a mapping - // here. If an expression has type DYN, it is omitted from this map to save - // space. - TypeMap map[int64]*Type `protobuf:"bytes,3,rep,name=type_map,json=typeMap,proto3" json:"type_map,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - // The source info derived from input that generated the parsed `expr` and - // any optimizations made during the type-checking pass. - SourceInfo *SourceInfo `protobuf:"bytes,5,opt,name=source_info,json=sourceInfo,proto3" json:"source_info,omitempty"` - // The expr version indicates the major / minor version number of the `expr` - // representation. - // - // The most common reason for a version change will be to indicate to the CEL - // runtimes that transformations have been performed on the expr during static - // analysis. In some cases, this will save the runtime the work of applying - // the same or similar transformations prior to evaluation. - ExprVersion string `protobuf:"bytes,6,opt,name=expr_version,json=exprVersion,proto3" json:"expr_version,omitempty"` - // The checked expression. Semantically equivalent to the parsed `expr`, but - // may have structural differences. - Expr *Expr `protobuf:"bytes,4,opt,name=expr,proto3" json:"expr,omitempty"` -} - -func (x *CheckedExpr) Reset() { - *x = CheckedExpr{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_checked_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CheckedExpr) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CheckedExpr) ProtoMessage() {} - -func (x *CheckedExpr) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_checked_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 CheckedExpr.ProtoReflect.Descriptor instead. -func (*CheckedExpr) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_checked_proto_rawDescGZIP(), []int{0} -} - -func (x *CheckedExpr) GetReferenceMap() map[int64]*Reference { - if x != nil { - return x.ReferenceMap - } - return nil -} - -func (x *CheckedExpr) GetTypeMap() map[int64]*Type { - if x != nil { - return x.TypeMap - } - return nil -} - -func (x *CheckedExpr) GetSourceInfo() *SourceInfo { - if x != nil { - return x.SourceInfo - } - return nil -} - -func (x *CheckedExpr) GetExprVersion() string { - if x != nil { - return x.ExprVersion - } - return "" -} - -func (x *CheckedExpr) GetExpr() *Expr { - if x != nil { - return x.Expr - } - return nil -} - -// Represents a CEL type. -type Type struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The kind of type. - // - // Types that are assignable to TypeKind: - // - // *Type_Dyn - // *Type_Null - // *Type_Primitive - // *Type_Wrapper - // *Type_WellKnown - // *Type_ListType_ - // *Type_MapType_ - // *Type_Function - // *Type_MessageType - // *Type_TypeParam - // *Type_Type - // *Type_Error - // *Type_AbstractType_ - TypeKind isType_TypeKind `protobuf_oneof:"type_kind"` -} - -func (x *Type) Reset() { - *x = Type{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_checked_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Type) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Type) ProtoMessage() {} - -func (x *Type) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_checked_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 Type.ProtoReflect.Descriptor instead. -func (*Type) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_checked_proto_rawDescGZIP(), []int{1} -} - -func (m *Type) GetTypeKind() isType_TypeKind { - if m != nil { - return m.TypeKind - } - return nil -} - -func (x *Type) GetDyn() *emptypb.Empty { - if x, ok := x.GetTypeKind().(*Type_Dyn); ok { - return x.Dyn - } - return nil -} - -func (x *Type) GetNull() structpb.NullValue { - if x, ok := x.GetTypeKind().(*Type_Null); ok { - return x.Null - } - return structpb.NullValue_NULL_VALUE -} - -func (x *Type) GetPrimitive() Type_PrimitiveType { - if x, ok := x.GetTypeKind().(*Type_Primitive); ok { - return x.Primitive - } - return Type_PRIMITIVE_TYPE_UNSPECIFIED -} - -func (x *Type) GetWrapper() Type_PrimitiveType { - if x, ok := x.GetTypeKind().(*Type_Wrapper); ok { - return x.Wrapper - } - return Type_PRIMITIVE_TYPE_UNSPECIFIED -} - -func (x *Type) GetWellKnown() Type_WellKnownType { - if x, ok := x.GetTypeKind().(*Type_WellKnown); ok { - return x.WellKnown - } - return Type_WELL_KNOWN_TYPE_UNSPECIFIED -} - -func (x *Type) GetListType() *Type_ListType { - if x, ok := x.GetTypeKind().(*Type_ListType_); ok { - return x.ListType - } - return nil -} - -func (x *Type) GetMapType() *Type_MapType { - if x, ok := x.GetTypeKind().(*Type_MapType_); ok { - return x.MapType - } - return nil -} - -func (x *Type) GetFunction() *Type_FunctionType { - if x, ok := x.GetTypeKind().(*Type_Function); ok { - return x.Function - } - return nil -} - -func (x *Type) GetMessageType() string { - if x, ok := x.GetTypeKind().(*Type_MessageType); ok { - return x.MessageType - } - return "" -} - -func (x *Type) GetTypeParam() string { - if x, ok := x.GetTypeKind().(*Type_TypeParam); ok { - return x.TypeParam - } - return "" -} - -func (x *Type) GetType() *Type { - if x, ok := x.GetTypeKind().(*Type_Type); ok { - return x.Type - } - return nil -} - -func (x *Type) GetError() *emptypb.Empty { - if x, ok := x.GetTypeKind().(*Type_Error); ok { - return x.Error - } - return nil -} - -func (x *Type) GetAbstractType() *Type_AbstractType { - if x, ok := x.GetTypeKind().(*Type_AbstractType_); ok { - return x.AbstractType - } - return nil -} - -type isType_TypeKind interface { - isType_TypeKind() -} - -type Type_Dyn struct { - // Dynamic type. - Dyn *emptypb.Empty `protobuf:"bytes,1,opt,name=dyn,proto3,oneof"` -} - -type Type_Null struct { - // Null value. - Null structpb.NullValue `protobuf:"varint,2,opt,name=null,proto3,enum=google.protobuf.NullValue,oneof"` -} - -type Type_Primitive struct { - // Primitive types: `true`, `1u`, `-2.0`, `'string'`, `b'bytes'`. - Primitive Type_PrimitiveType `protobuf:"varint,3,opt,name=primitive,proto3,enum=google.api.expr.v1alpha1.Type_PrimitiveType,oneof"` -} - -type Type_Wrapper struct { - // Wrapper of a primitive type, e.g. `google.protobuf.Int64Value`. - Wrapper Type_PrimitiveType `protobuf:"varint,4,opt,name=wrapper,proto3,enum=google.api.expr.v1alpha1.Type_PrimitiveType,oneof"` -} - -type Type_WellKnown struct { - // Well-known protobuf type such as `google.protobuf.Timestamp`. - WellKnown Type_WellKnownType `protobuf:"varint,5,opt,name=well_known,json=wellKnown,proto3,enum=google.api.expr.v1alpha1.Type_WellKnownType,oneof"` -} - -type Type_ListType_ struct { - // Parameterized list with elements of `list_type`, e.g. `list`. - ListType *Type_ListType `protobuf:"bytes,6,opt,name=list_type,json=listType,proto3,oneof"` -} - -type Type_MapType_ struct { - // Parameterized map with typed keys and values. - MapType *Type_MapType `protobuf:"bytes,7,opt,name=map_type,json=mapType,proto3,oneof"` -} - -type Type_Function struct { - // Function type. - Function *Type_FunctionType `protobuf:"bytes,8,opt,name=function,proto3,oneof"` -} - -type Type_MessageType struct { - // Protocol buffer message type. - // - // The `message_type` string specifies the qualified message type name. For - // example, `google.plus.Profile`. - MessageType string `protobuf:"bytes,9,opt,name=message_type,json=messageType,proto3,oneof"` -} - -type Type_TypeParam struct { - // Type param type. - // - // The `type_param` string specifies the type parameter name, e.g. `list` - // would be a `list_type` whose element type was a `type_param` type - // named `E`. - TypeParam string `protobuf:"bytes,10,opt,name=type_param,json=typeParam,proto3,oneof"` -} - -type Type_Type struct { - // Type type. - // - // The `type` value specifies the target type. e.g. int is type with a - // target type of `Primitive.INT`. - Type *Type `protobuf:"bytes,11,opt,name=type,proto3,oneof"` -} - -type Type_Error struct { - // Error type. - // - // During type-checking if an expression is an error, its type is propagated - // as the `ERROR` type. This permits the type-checker to discover other - // errors present in the expression. - Error *emptypb.Empty `protobuf:"bytes,12,opt,name=error,proto3,oneof"` -} - -type Type_AbstractType_ struct { - // Abstract, application defined type. - AbstractType *Type_AbstractType `protobuf:"bytes,14,opt,name=abstract_type,json=abstractType,proto3,oneof"` -} - -func (*Type_Dyn) isType_TypeKind() {} - -func (*Type_Null) isType_TypeKind() {} - -func (*Type_Primitive) isType_TypeKind() {} - -func (*Type_Wrapper) isType_TypeKind() {} - -func (*Type_WellKnown) isType_TypeKind() {} - -func (*Type_ListType_) isType_TypeKind() {} - -func (*Type_MapType_) isType_TypeKind() {} - -func (*Type_Function) isType_TypeKind() {} - -func (*Type_MessageType) isType_TypeKind() {} - -func (*Type_TypeParam) isType_TypeKind() {} - -func (*Type_Type) isType_TypeKind() {} - -func (*Type_Error) isType_TypeKind() {} - -func (*Type_AbstractType_) isType_TypeKind() {} - -// Represents a declaration of a named value or function. -// -// A declaration is part of the contract between the expression, the agent -// evaluating that expression, and the caller requesting evaluation. -type Decl struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The fully qualified name of the declaration. - // - // Declarations are organized in containers and this represents the full path - // to the declaration in its container, as in `google.api.expr.Decl`. - // - // Declarations used as - // [FunctionDecl.Overload][google.api.expr.v1alpha1.Decl.FunctionDecl.Overload] - // parameters may or may not have a name depending on whether the overload is - // function declaration or a function definition containing a result - // [Expr][google.api.expr.v1alpha1.Expr]. - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - // Required. The declaration kind. - // - // Types that are assignable to DeclKind: - // - // *Decl_Ident - // *Decl_Function - DeclKind isDecl_DeclKind `protobuf_oneof:"decl_kind"` -} - -func (x *Decl) Reset() { - *x = Decl{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_checked_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Decl) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Decl) ProtoMessage() {} - -func (x *Decl) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_checked_proto_msgTypes[2] - 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 Decl.ProtoReflect.Descriptor instead. -func (*Decl) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_checked_proto_rawDescGZIP(), []int{2} -} - -func (x *Decl) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (m *Decl) GetDeclKind() isDecl_DeclKind { - if m != nil { - return m.DeclKind - } - return nil -} - -func (x *Decl) GetIdent() *Decl_IdentDecl { - if x, ok := x.GetDeclKind().(*Decl_Ident); ok { - return x.Ident - } - return nil -} - -func (x *Decl) GetFunction() *Decl_FunctionDecl { - if x, ok := x.GetDeclKind().(*Decl_Function); ok { - return x.Function - } - return nil -} - -type isDecl_DeclKind interface { - isDecl_DeclKind() -} - -type Decl_Ident struct { - // Identifier declaration. - Ident *Decl_IdentDecl `protobuf:"bytes,2,opt,name=ident,proto3,oneof"` -} - -type Decl_Function struct { - // Function declaration. - Function *Decl_FunctionDecl `protobuf:"bytes,3,opt,name=function,proto3,oneof"` -} - -func (*Decl_Ident) isDecl_DeclKind() {} - -func (*Decl_Function) isDecl_DeclKind() {} - -// Describes a resolved reference to a declaration. -type Reference struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The fully qualified name of the declaration. - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - // For references to functions, this is a list of `Overload.overload_id` - // values which match according to typing rules. - // - // If the list has more than one element, overload resolution among the - // presented candidates must happen at runtime because of dynamic types. The - // type checker attempts to narrow down this list as much as possible. - // - // Empty if this is not a reference to a - // [Decl.FunctionDecl][google.api.expr.v1alpha1.Decl.FunctionDecl]. - OverloadId []string `protobuf:"bytes,3,rep,name=overload_id,json=overloadId,proto3" json:"overload_id,omitempty"` - // For references to constants, this may contain the value of the - // constant if known at compile time. - Value *Constant `protobuf:"bytes,4,opt,name=value,proto3" json:"value,omitempty"` -} - -func (x *Reference) Reset() { - *x = Reference{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_checked_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Reference) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Reference) ProtoMessage() {} - -func (x *Reference) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_checked_proto_msgTypes[3] - 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 Reference.ProtoReflect.Descriptor instead. -func (*Reference) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_checked_proto_rawDescGZIP(), []int{3} -} - -func (x *Reference) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Reference) GetOverloadId() []string { - if x != nil { - return x.OverloadId - } - return nil -} - -func (x *Reference) GetValue() *Constant { - if x != nil { - return x.Value - } - return nil -} - -// List type with typed elements, e.g. `list`. -type Type_ListType struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The element type. - ElemType *Type `protobuf:"bytes,1,opt,name=elem_type,json=elemType,proto3" json:"elem_type,omitempty"` -} - -func (x *Type_ListType) Reset() { - *x = Type_ListType{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_checked_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Type_ListType) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Type_ListType) ProtoMessage() {} - -func (x *Type_ListType) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_checked_proto_msgTypes[6] - 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 Type_ListType.ProtoReflect.Descriptor instead. -func (*Type_ListType) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_checked_proto_rawDescGZIP(), []int{1, 0} -} - -func (x *Type_ListType) GetElemType() *Type { - if x != nil { - return x.ElemType - } - return nil -} - -// Map type with parameterized key and value types, e.g. `map`. -type Type_MapType struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The type of the key. - KeyType *Type `protobuf:"bytes,1,opt,name=key_type,json=keyType,proto3" json:"key_type,omitempty"` - // The type of the value. - ValueType *Type `protobuf:"bytes,2,opt,name=value_type,json=valueType,proto3" json:"value_type,omitempty"` -} - -func (x *Type_MapType) Reset() { - *x = Type_MapType{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_checked_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Type_MapType) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Type_MapType) ProtoMessage() {} - -func (x *Type_MapType) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_checked_proto_msgTypes[7] - 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 Type_MapType.ProtoReflect.Descriptor instead. -func (*Type_MapType) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_checked_proto_rawDescGZIP(), []int{1, 1} -} - -func (x *Type_MapType) GetKeyType() *Type { - if x != nil { - return x.KeyType - } - return nil -} - -func (x *Type_MapType) GetValueType() *Type { - if x != nil { - return x.ValueType - } - return nil -} - -// Function type with result and arg types. -type Type_FunctionType struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Result type of the function. - ResultType *Type `protobuf:"bytes,1,opt,name=result_type,json=resultType,proto3" json:"result_type,omitempty"` - // Argument types of the function. - ArgTypes []*Type `protobuf:"bytes,2,rep,name=arg_types,json=argTypes,proto3" json:"arg_types,omitempty"` -} - -func (x *Type_FunctionType) Reset() { - *x = Type_FunctionType{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_checked_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Type_FunctionType) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Type_FunctionType) ProtoMessage() {} - -func (x *Type_FunctionType) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_checked_proto_msgTypes[8] - 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 Type_FunctionType.ProtoReflect.Descriptor instead. -func (*Type_FunctionType) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_checked_proto_rawDescGZIP(), []int{1, 2} -} - -func (x *Type_FunctionType) GetResultType() *Type { - if x != nil { - return x.ResultType - } - return nil -} - -func (x *Type_FunctionType) GetArgTypes() []*Type { - if x != nil { - return x.ArgTypes - } - return nil -} - -// Application defined abstract type. -type Type_AbstractType struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The fully qualified name of this abstract type. - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - // Parameter types for this abstract type. - ParameterTypes []*Type `protobuf:"bytes,2,rep,name=parameter_types,json=parameterTypes,proto3" json:"parameter_types,omitempty"` -} - -func (x *Type_AbstractType) Reset() { - *x = Type_AbstractType{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_checked_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Type_AbstractType) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Type_AbstractType) ProtoMessage() {} - -func (x *Type_AbstractType) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_checked_proto_msgTypes[9] - 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 Type_AbstractType.ProtoReflect.Descriptor instead. -func (*Type_AbstractType) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_checked_proto_rawDescGZIP(), []int{1, 3} -} - -func (x *Type_AbstractType) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Type_AbstractType) GetParameterTypes() []*Type { - if x != nil { - return x.ParameterTypes - } - return nil -} - -// Identifier declaration which specifies its type and optional `Expr` value. -// -// An identifier without a value is a declaration that must be provided at -// evaluation time. An identifier with a value should resolve to a constant, -// but may be used in conjunction with other identifiers bound at evaluation -// time. -type Decl_IdentDecl struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Required. The type of the identifier. - Type *Type `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` - // The constant value of the identifier. If not specified, the identifier - // must be supplied at evaluation time. - Value *Constant `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` - // Documentation string for the identifier. - Doc string `protobuf:"bytes,3,opt,name=doc,proto3" json:"doc,omitempty"` -} - -func (x *Decl_IdentDecl) Reset() { - *x = Decl_IdentDecl{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_checked_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Decl_IdentDecl) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Decl_IdentDecl) ProtoMessage() {} - -func (x *Decl_IdentDecl) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_checked_proto_msgTypes[10] - 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 Decl_IdentDecl.ProtoReflect.Descriptor instead. -func (*Decl_IdentDecl) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_checked_proto_rawDescGZIP(), []int{2, 0} -} - -func (x *Decl_IdentDecl) GetType() *Type { - if x != nil { - return x.Type - } - return nil -} - -func (x *Decl_IdentDecl) GetValue() *Constant { - if x != nil { - return x.Value - } - return nil -} - -func (x *Decl_IdentDecl) GetDoc() string { - if x != nil { - return x.Doc - } - return "" -} - -// Function declaration specifies one or more overloads which indicate the -// function's parameter types and return type. -// -// Functions have no observable side-effects (there may be side-effects like -// logging which are not observable from CEL). -type Decl_FunctionDecl struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Required. List of function overloads, must contain at least one overload. - Overloads []*Decl_FunctionDecl_Overload `protobuf:"bytes,1,rep,name=overloads,proto3" json:"overloads,omitempty"` -} - -func (x *Decl_FunctionDecl) Reset() { - *x = Decl_FunctionDecl{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_checked_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Decl_FunctionDecl) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Decl_FunctionDecl) ProtoMessage() {} - -func (x *Decl_FunctionDecl) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_checked_proto_msgTypes[11] - 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 Decl_FunctionDecl.ProtoReflect.Descriptor instead. -func (*Decl_FunctionDecl) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_checked_proto_rawDescGZIP(), []int{2, 1} -} - -func (x *Decl_FunctionDecl) GetOverloads() []*Decl_FunctionDecl_Overload { - if x != nil { - return x.Overloads - } - return nil -} - -// An overload indicates a function's parameter types and return type, and -// may optionally include a function body described in terms of -// [Expr][google.api.expr.v1alpha1.Expr] values. -// -// Functions overloads are declared in either a function or method -// call-style. For methods, the `params[0]` is the expected type of the -// target receiver. -// -// Overloads must have non-overlapping argument types after erasure of all -// parameterized type variables (similar as type erasure in Java). -type Decl_FunctionDecl_Overload struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Required. Globally unique overload name of the function which reflects - // the function name and argument types. - // - // This will be used by a [Reference][google.api.expr.v1alpha1.Reference] - // to indicate the `overload_id` that was resolved for the function - // `name`. - OverloadId string `protobuf:"bytes,1,opt,name=overload_id,json=overloadId,proto3" json:"overload_id,omitempty"` - // List of function parameter [Type][google.api.expr.v1alpha1.Type] - // values. - // - // Param types are disjoint after generic type parameters have been - // replaced with the type `DYN`. Since the `DYN` type is compatible with - // any other type, this means that if `A` is a type parameter, the - // function types `int` and `int` are not disjoint. Likewise, - // `map` is not disjoint from `map`. - // - // When the `result_type` of a function is a generic type param, the - // type param name also appears as the `type` of on at least one params. - Params []*Type `protobuf:"bytes,2,rep,name=params,proto3" json:"params,omitempty"` - // The type param names associated with the function declaration. - // - // For example, `function ex(K key, map map) : V` would yield - // the type params of `K, V`. - TypeParams []string `protobuf:"bytes,3,rep,name=type_params,json=typeParams,proto3" json:"type_params,omitempty"` - // Required. The result type of the function. For example, the operator - // `string.isEmpty()` would have `result_type` of `kind: BOOL`. - ResultType *Type `protobuf:"bytes,4,opt,name=result_type,json=resultType,proto3" json:"result_type,omitempty"` - // Whether the function is to be used in a method call-style `x.f(...)` - // or a function call-style `f(x, ...)`. - // - // For methods, the first parameter declaration, `params[0]` is the - // expected type of the target receiver. - IsInstanceFunction bool `protobuf:"varint,5,opt,name=is_instance_function,json=isInstanceFunction,proto3" json:"is_instance_function,omitempty"` - // Documentation string for the overload. - Doc string `protobuf:"bytes,6,opt,name=doc,proto3" json:"doc,omitempty"` -} - -func (x *Decl_FunctionDecl_Overload) Reset() { - *x = Decl_FunctionDecl_Overload{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_checked_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Decl_FunctionDecl_Overload) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Decl_FunctionDecl_Overload) ProtoMessage() {} - -func (x *Decl_FunctionDecl_Overload) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_checked_proto_msgTypes[12] - 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 Decl_FunctionDecl_Overload.ProtoReflect.Descriptor instead. -func (*Decl_FunctionDecl_Overload) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_checked_proto_rawDescGZIP(), []int{2, 1, 0} -} - -func (x *Decl_FunctionDecl_Overload) GetOverloadId() string { - if x != nil { - return x.OverloadId - } - return "" -} - -func (x *Decl_FunctionDecl_Overload) GetParams() []*Type { - if x != nil { - return x.Params - } - return nil -} - -func (x *Decl_FunctionDecl_Overload) GetTypeParams() []string { - if x != nil { - return x.TypeParams - } - return nil -} - -func (x *Decl_FunctionDecl_Overload) GetResultType() *Type { - if x != nil { - return x.ResultType - } - return nil -} - -func (x *Decl_FunctionDecl_Overload) GetIsInstanceFunction() bool { - if x != nil { - return x.IsInstanceFunction - } - return false -} - -func (x *Decl_FunctionDecl_Overload) GetDoc() string { - if x != nil { - return x.Doc - } - return "" -} - -var File_google_api_expr_v1alpha1_checked_proto protoreflect.FileDescriptor - -var file_google_api_expr_v1alpha1_checked_proto_rawDesc = []byte{ - 0x0a, 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, 0x12, 0x18, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x65, 0x78, 0x70, 0x72, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 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, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x9a, 0x04, 0x0a, 0x0b, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x64, - 0x45, 0x78, 0x70, 0x72, 0x12, 0x5c, 0x0a, 0x0d, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, - 0x65, 0x5f, 0x6d, 0x61, 0x70, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x37, 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, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x4d, 0x61, 0x70, 0x45, - 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0c, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x4d, - 0x61, 0x70, 0x12, 0x4d, 0x0a, 0x08, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x6d, 0x61, 0x70, 0x18, 0x03, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x32, 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, 0x2e, 0x54, 0x79, 0x70, 0x65, - 0x4d, 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x74, 0x79, 0x70, 0x65, 0x4d, 0x61, - 0x70, 0x12, 0x45, 0x0a, 0x0b, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x6e, 0x66, 0x6f, - 0x18, 0x05, 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, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0a, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x21, 0x0a, 0x0c, 0x65, 0x78, 0x70, 0x72, - 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, - 0x65, 0x78, 0x70, 0x72, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x04, 0x65, - 0x78, 0x70, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 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, 0x45, 0x78, 0x70, 0x72, 0x52, 0x04, 0x65, 0x78, 0x70, 0x72, 0x1a, - 0x64, 0x0a, 0x11, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x4d, 0x61, 0x70, 0x45, - 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x39, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 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, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x5a, 0x0a, 0x0c, 0x54, 0x79, 0x70, 0x65, 0x4d, 0x61, 0x70, - 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x34, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 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, 0x54, 0x79, 0x70, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, - 0x01, 0x22, 0xc8, 0x0b, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x2a, 0x0a, 0x03, 0x64, 0x79, - 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x48, - 0x00, 0x52, 0x03, 0x64, 0x79, 0x6e, 0x12, 0x30, 0x0a, 0x04, 0x6e, 0x75, 0x6c, 0x6c, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4e, 0x75, 0x6c, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, - 0x48, 0x00, 0x52, 0x04, 0x6e, 0x75, 0x6c, 0x6c, 0x12, 0x4c, 0x0a, 0x09, 0x70, 0x72, 0x69, 0x6d, - 0x69, 0x74, 0x69, 0x76, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2c, 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, 0x54, 0x79, 0x70, 0x65, 0x2e, 0x50, 0x72, 0x69, 0x6d, - 0x69, 0x74, 0x69, 0x76, 0x65, 0x54, 0x79, 0x70, 0x65, 0x48, 0x00, 0x52, 0x09, 0x70, 0x72, 0x69, - 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x12, 0x48, 0x0a, 0x07, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, - 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2c, 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, 0x54, 0x79, 0x70, 0x65, 0x2e, 0x50, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, - 0x65, 0x54, 0x79, 0x70, 0x65, 0x48, 0x00, 0x52, 0x07, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, - 0x12, 0x4d, 0x0a, 0x0a, 0x77, 0x65, 0x6c, 0x6c, 0x5f, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2c, 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, - 0x54, 0x79, 0x70, 0x65, 0x2e, 0x57, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x79, - 0x70, 0x65, 0x48, 0x00, 0x52, 0x09, 0x77, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x12, - 0x46, 0x0a, 0x09, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x27, 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, 0x54, 0x79, - 0x70, 0x65, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x48, 0x00, 0x52, 0x08, 0x6c, - 0x69, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x43, 0x0a, 0x08, 0x6d, 0x61, 0x70, 0x5f, 0x74, - 0x79, 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 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, 0x54, 0x79, 0x70, 0x65, 0x2e, 0x4d, 0x61, 0x70, 0x54, 0x79, 0x70, - 0x65, 0x48, 0x00, 0x52, 0x07, 0x6d, 0x61, 0x70, 0x54, 0x79, 0x70, 0x65, 0x12, 0x49, 0x0a, 0x08, - 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, - 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, 0x54, 0x79, 0x70, 0x65, 0x2e, 0x46, - 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x48, 0x00, 0x52, 0x08, 0x66, - 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x23, 0x0a, 0x0c, 0x6d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, - 0x0b, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1f, 0x0a, 0x0a, - 0x74, 0x79, 0x70, 0x65, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, - 0x48, 0x00, 0x52, 0x09, 0x74, 0x79, 0x70, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x12, 0x34, 0x0a, - 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 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, 0x54, 0x79, 0x70, 0x65, 0x48, 0x00, 0x52, 0x04, 0x74, - 0x79, 0x70, 0x65, 0x12, 0x2e, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x0c, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x48, 0x00, 0x52, 0x05, 0x65, 0x72, - 0x72, 0x6f, 0x72, 0x12, 0x52, 0x0a, 0x0d, 0x61, 0x62, 0x73, 0x74, 0x72, 0x61, 0x63, 0x74, 0x5f, - 0x74, 0x79, 0x70, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 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, 0x54, 0x79, 0x70, 0x65, 0x2e, 0x41, 0x62, 0x73, 0x74, 0x72, - 0x61, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x48, 0x00, 0x52, 0x0c, 0x61, 0x62, 0x73, 0x74, 0x72, - 0x61, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x1a, 0x47, 0x0a, 0x08, 0x4c, 0x69, 0x73, 0x74, 0x54, - 0x79, 0x70, 0x65, 0x12, 0x3b, 0x0a, 0x09, 0x65, 0x6c, 0x65, 0x6d, 0x5f, 0x74, 0x79, 0x70, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 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, 0x54, 0x79, 0x70, 0x65, 0x52, 0x08, 0x65, 0x6c, 0x65, 0x6d, 0x54, 0x79, 0x70, 0x65, - 0x1a, 0x83, 0x01, 0x0a, 0x07, 0x4d, 0x61, 0x70, 0x54, 0x79, 0x70, 0x65, 0x12, 0x39, 0x0a, 0x08, - 0x6b, 0x65, 0x79, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, - 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, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, - 0x6b, 0x65, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x3d, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 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, 0x54, 0x79, 0x70, 0x65, 0x52, 0x09, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x54, 0x79, 0x70, 0x65, 0x1a, 0x8c, 0x01, 0x0a, 0x0c, 0x46, 0x75, 0x6e, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x3f, 0x0a, 0x0b, 0x72, 0x65, 0x73, 0x75, 0x6c, - 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 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, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0a, 0x72, 0x65, - 0x73, 0x75, 0x6c, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x3b, 0x0a, 0x09, 0x61, 0x72, 0x67, 0x5f, - 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 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, 0x54, 0x79, 0x70, 0x65, 0x52, 0x08, 0x61, 0x72, 0x67, - 0x54, 0x79, 0x70, 0x65, 0x73, 0x1a, 0x6b, 0x0a, 0x0c, 0x41, 0x62, 0x73, 0x74, 0x72, 0x61, 0x63, - 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x47, 0x0a, 0x0f, 0x70, 0x61, 0x72, - 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x1e, 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, 0x54, 0x79, - 0x70, 0x65, 0x52, 0x0e, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x54, 0x79, 0x70, - 0x65, 0x73, 0x22, 0x73, 0x0a, 0x0d, 0x50, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x54, - 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x1a, 0x50, 0x52, 0x49, 0x4d, 0x49, 0x54, 0x49, 0x56, 0x45, - 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, - 0x44, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x42, 0x4f, 0x4f, 0x4c, 0x10, 0x01, 0x12, 0x09, 0x0a, - 0x05, 0x49, 0x4e, 0x54, 0x36, 0x34, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x49, 0x4e, 0x54, - 0x36, 0x34, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x44, 0x4f, 0x55, 0x42, 0x4c, 0x45, 0x10, 0x04, - 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x10, 0x05, 0x12, 0x09, 0x0a, 0x05, - 0x42, 0x59, 0x54, 0x45, 0x53, 0x10, 0x06, 0x22, 0x56, 0x0a, 0x0d, 0x57, 0x65, 0x6c, 0x6c, 0x4b, - 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1f, 0x0a, 0x1b, 0x57, 0x45, 0x4c, 0x4c, - 0x5f, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, - 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x4e, 0x59, - 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x54, 0x49, 0x4d, 0x45, 0x53, 0x54, 0x41, 0x4d, 0x50, 0x10, - 0x02, 0x12, 0x0c, 0x0a, 0x08, 0x44, 0x55, 0x52, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x03, 0x42, - 0x0b, 0x0a, 0x09, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x6b, 0x69, 0x6e, 0x64, 0x22, 0xb3, 0x05, 0x0a, - 0x04, 0x44, 0x65, 0x63, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x40, 0x0a, 0x05, 0x69, 0x64, 0x65, - 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 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, 0x44, 0x65, 0x63, 0x6c, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x44, 0x65, - 0x63, 0x6c, 0x48, 0x00, 0x52, 0x05, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x12, 0x49, 0x0a, 0x08, 0x66, - 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 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, 0x44, 0x65, 0x63, 0x6c, 0x2e, 0x46, 0x75, - 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x63, 0x6c, 0x48, 0x00, 0x52, 0x08, 0x66, 0x75, - 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x8b, 0x01, 0x0a, 0x09, 0x49, 0x64, 0x65, 0x6e, 0x74, - 0x44, 0x65, 0x63, 0x6c, 0x12, 0x32, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1e, 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, 0x54, 0x79, - 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x38, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 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, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x52, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x64, 0x6f, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x64, 0x6f, 0x63, 0x1a, 0xee, 0x02, 0x0a, 0x0c, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x44, 0x65, 0x63, 0x6c, 0x12, 0x52, 0x0a, 0x09, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x6f, 0x61, - 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x34, 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, 0x44, 0x65, 0x63, 0x6c, 0x2e, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x44, 0x65, 0x63, 0x6c, 0x2e, 0x4f, 0x76, 0x65, 0x72, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x09, - 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x6f, 0x61, 0x64, 0x73, 0x1a, 0x89, 0x02, 0x0a, 0x08, 0x4f, 0x76, - 0x65, 0x72, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x6f, - 0x61, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6f, 0x76, 0x65, - 0x72, 0x6c, 0x6f, 0x61, 0x64, 0x49, 0x64, 0x12, 0x36, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, - 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 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, 0x54, 0x79, 0x70, 0x65, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, - 0x1f, 0x0a, 0x0b, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x03, - 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x79, 0x70, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, - 0x12, 0x3f, 0x0a, 0x0b, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 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, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0a, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x54, 0x79, 0x70, - 0x65, 0x12, 0x30, 0x0a, 0x14, 0x69, 0x73, 0x5f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, - 0x5f, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x12, 0x69, 0x73, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x46, 0x75, 0x6e, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x64, 0x6f, 0x63, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x03, 0x64, 0x6f, 0x63, 0x42, 0x0b, 0x0a, 0x09, 0x64, 0x65, 0x63, 0x6c, 0x5f, 0x6b, 0x69, - 0x6e, 0x64, 0x22, 0x7a, 0x0a, 0x09, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, - 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x6f, 0x61, 0x64, 0x5f, - 0x69, 0x64, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x6f, - 0x61, 0x64, 0x49, 0x64, 0x12, 0x38, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x22, 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, - 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x6c, - 0x0a, 0x1c, 0x63, 0x6f, 0x6d, 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, 0x42, 0x09, - 0x44, 0x65, 0x63, 0x6c, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3c, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x67, - 0x65, 0x6e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x61, 0x70, - 0x69, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x65, 0x78, 0x70, 0x72, 0x2f, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x3b, 0x65, 0x78, 0x70, 0x72, 0xf8, 0x01, 0x01, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_google_api_expr_v1alpha1_checked_proto_rawDescOnce sync.Once - file_google_api_expr_v1alpha1_checked_proto_rawDescData = file_google_api_expr_v1alpha1_checked_proto_rawDesc -) - -func file_google_api_expr_v1alpha1_checked_proto_rawDescGZIP() []byte { - file_google_api_expr_v1alpha1_checked_proto_rawDescOnce.Do(func() { - file_google_api_expr_v1alpha1_checked_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_api_expr_v1alpha1_checked_proto_rawDescData) - }) - return file_google_api_expr_v1alpha1_checked_proto_rawDescData -} - -var file_google_api_expr_v1alpha1_checked_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_google_api_expr_v1alpha1_checked_proto_msgTypes = make([]protoimpl.MessageInfo, 13) -var file_google_api_expr_v1alpha1_checked_proto_goTypes = []interface{}{ - (Type_PrimitiveType)(0), // 0: google.api.expr.v1alpha1.Type.PrimitiveType - (Type_WellKnownType)(0), // 1: google.api.expr.v1alpha1.Type.WellKnownType - (*CheckedExpr)(nil), // 2: google.api.expr.v1alpha1.CheckedExpr - (*Type)(nil), // 3: google.api.expr.v1alpha1.Type - (*Decl)(nil), // 4: google.api.expr.v1alpha1.Decl - (*Reference)(nil), // 5: google.api.expr.v1alpha1.Reference - nil, // 6: google.api.expr.v1alpha1.CheckedExpr.ReferenceMapEntry - nil, // 7: google.api.expr.v1alpha1.CheckedExpr.TypeMapEntry - (*Type_ListType)(nil), // 8: google.api.expr.v1alpha1.Type.ListType - (*Type_MapType)(nil), // 9: google.api.expr.v1alpha1.Type.MapType - (*Type_FunctionType)(nil), // 10: google.api.expr.v1alpha1.Type.FunctionType - (*Type_AbstractType)(nil), // 11: google.api.expr.v1alpha1.Type.AbstractType - (*Decl_IdentDecl)(nil), // 12: google.api.expr.v1alpha1.Decl.IdentDecl - (*Decl_FunctionDecl)(nil), // 13: google.api.expr.v1alpha1.Decl.FunctionDecl - (*Decl_FunctionDecl_Overload)(nil), // 14: google.api.expr.v1alpha1.Decl.FunctionDecl.Overload - (*SourceInfo)(nil), // 15: google.api.expr.v1alpha1.SourceInfo - (*Expr)(nil), // 16: google.api.expr.v1alpha1.Expr - (*emptypb.Empty)(nil), // 17: google.protobuf.Empty - (structpb.NullValue)(0), // 18: google.protobuf.NullValue - (*Constant)(nil), // 19: google.api.expr.v1alpha1.Constant -} -var file_google_api_expr_v1alpha1_checked_proto_depIdxs = []int32{ - 6, // 0: google.api.expr.v1alpha1.CheckedExpr.reference_map:type_name -> google.api.expr.v1alpha1.CheckedExpr.ReferenceMapEntry - 7, // 1: google.api.expr.v1alpha1.CheckedExpr.type_map:type_name -> google.api.expr.v1alpha1.CheckedExpr.TypeMapEntry - 15, // 2: google.api.expr.v1alpha1.CheckedExpr.source_info:type_name -> google.api.expr.v1alpha1.SourceInfo - 16, // 3: google.api.expr.v1alpha1.CheckedExpr.expr:type_name -> google.api.expr.v1alpha1.Expr - 17, // 4: google.api.expr.v1alpha1.Type.dyn:type_name -> google.protobuf.Empty - 18, // 5: google.api.expr.v1alpha1.Type.null:type_name -> google.protobuf.NullValue - 0, // 6: google.api.expr.v1alpha1.Type.primitive:type_name -> google.api.expr.v1alpha1.Type.PrimitiveType - 0, // 7: google.api.expr.v1alpha1.Type.wrapper:type_name -> google.api.expr.v1alpha1.Type.PrimitiveType - 1, // 8: google.api.expr.v1alpha1.Type.well_known:type_name -> google.api.expr.v1alpha1.Type.WellKnownType - 8, // 9: google.api.expr.v1alpha1.Type.list_type:type_name -> google.api.expr.v1alpha1.Type.ListType - 9, // 10: google.api.expr.v1alpha1.Type.map_type:type_name -> google.api.expr.v1alpha1.Type.MapType - 10, // 11: google.api.expr.v1alpha1.Type.function:type_name -> google.api.expr.v1alpha1.Type.FunctionType - 3, // 12: google.api.expr.v1alpha1.Type.type:type_name -> google.api.expr.v1alpha1.Type - 17, // 13: google.api.expr.v1alpha1.Type.error:type_name -> google.protobuf.Empty - 11, // 14: google.api.expr.v1alpha1.Type.abstract_type:type_name -> google.api.expr.v1alpha1.Type.AbstractType - 12, // 15: google.api.expr.v1alpha1.Decl.ident:type_name -> google.api.expr.v1alpha1.Decl.IdentDecl - 13, // 16: google.api.expr.v1alpha1.Decl.function:type_name -> google.api.expr.v1alpha1.Decl.FunctionDecl - 19, // 17: google.api.expr.v1alpha1.Reference.value:type_name -> google.api.expr.v1alpha1.Constant - 5, // 18: google.api.expr.v1alpha1.CheckedExpr.ReferenceMapEntry.value:type_name -> google.api.expr.v1alpha1.Reference - 3, // 19: google.api.expr.v1alpha1.CheckedExpr.TypeMapEntry.value:type_name -> google.api.expr.v1alpha1.Type - 3, // 20: google.api.expr.v1alpha1.Type.ListType.elem_type:type_name -> google.api.expr.v1alpha1.Type - 3, // 21: google.api.expr.v1alpha1.Type.MapType.key_type:type_name -> google.api.expr.v1alpha1.Type - 3, // 22: google.api.expr.v1alpha1.Type.MapType.value_type:type_name -> google.api.expr.v1alpha1.Type - 3, // 23: google.api.expr.v1alpha1.Type.FunctionType.result_type:type_name -> google.api.expr.v1alpha1.Type - 3, // 24: google.api.expr.v1alpha1.Type.FunctionType.arg_types:type_name -> google.api.expr.v1alpha1.Type - 3, // 25: google.api.expr.v1alpha1.Type.AbstractType.parameter_types:type_name -> google.api.expr.v1alpha1.Type - 3, // 26: google.api.expr.v1alpha1.Decl.IdentDecl.type:type_name -> google.api.expr.v1alpha1.Type - 19, // 27: google.api.expr.v1alpha1.Decl.IdentDecl.value:type_name -> google.api.expr.v1alpha1.Constant - 14, // 28: google.api.expr.v1alpha1.Decl.FunctionDecl.overloads:type_name -> google.api.expr.v1alpha1.Decl.FunctionDecl.Overload - 3, // 29: google.api.expr.v1alpha1.Decl.FunctionDecl.Overload.params:type_name -> google.api.expr.v1alpha1.Type - 3, // 30: google.api.expr.v1alpha1.Decl.FunctionDecl.Overload.result_type:type_name -> google.api.expr.v1alpha1.Type - 31, // [31:31] is the sub-list for method output_type - 31, // [31:31] is the sub-list for method input_type - 31, // [31:31] is the sub-list for extension type_name - 31, // [31:31] is the sub-list for extension extendee - 0, // [0:31] is the sub-list for field type_name -} - -func init() { file_google_api_expr_v1alpha1_checked_proto_init() } -func file_google_api_expr_v1alpha1_checked_proto_init() { - if File_google_api_expr_v1alpha1_checked_proto != nil { - return - } - file_google_api_expr_v1alpha1_syntax_proto_init() - if !protoimpl.UnsafeEnabled { - file_google_api_expr_v1alpha1_checked_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CheckedExpr); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_checked_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Type); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_checked_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Decl); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_checked_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Reference); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_checked_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Type_ListType); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_checked_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Type_MapType); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_checked_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Type_FunctionType); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_checked_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Type_AbstractType); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_checked_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Decl_IdentDecl); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_checked_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Decl_FunctionDecl); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_checked_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Decl_FunctionDecl_Overload); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_google_api_expr_v1alpha1_checked_proto_msgTypes[1].OneofWrappers = []interface{}{ - (*Type_Dyn)(nil), - (*Type_Null)(nil), - (*Type_Primitive)(nil), - (*Type_Wrapper)(nil), - (*Type_WellKnown)(nil), - (*Type_ListType_)(nil), - (*Type_MapType_)(nil), - (*Type_Function)(nil), - (*Type_MessageType)(nil), - (*Type_TypeParam)(nil), - (*Type_Type)(nil), - (*Type_Error)(nil), - (*Type_AbstractType_)(nil), - } - file_google_api_expr_v1alpha1_checked_proto_msgTypes[2].OneofWrappers = []interface{}{ - (*Decl_Ident)(nil), - (*Decl_Function)(nil), - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_google_api_expr_v1alpha1_checked_proto_rawDesc, - NumEnums: 2, - NumMessages: 13, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_google_api_expr_v1alpha1_checked_proto_goTypes, - DependencyIndexes: file_google_api_expr_v1alpha1_checked_proto_depIdxs, - EnumInfos: file_google_api_expr_v1alpha1_checked_proto_enumTypes, - MessageInfos: file_google_api_expr_v1alpha1_checked_proto_msgTypes, - }.Build() - File_google_api_expr_v1alpha1_checked_proto = out.File - file_google_api_expr_v1alpha1_checked_proto_rawDesc = nil - file_google_api_expr_v1alpha1_checked_proto_goTypes = nil - file_google_api_expr_v1alpha1_checked_proto_depIdxs = nil -} diff --git a/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/eval.pb.go b/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/eval.pb.go deleted file mode 100644 index ca4415956..000000000 --- a/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/eval.pb.go +++ /dev/null @@ -1,580 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.26.0 -// protoc v4.24.4 -// source: google/api/expr/v1alpha1/eval.proto - -package expr - -import ( - reflect "reflect" - sync "sync" - - status "google.golang.org/genproto/googleapis/rpc/status" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" -) - -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) -) - -// The state of an evaluation. -// -// Can represent an inital, partial, or completed state of evaluation. -type EvalState struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The unique values referenced in this message. - Values []*ExprValue `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"` - // An ordered list of results. - // - // Tracks the flow of evaluation through the expression. - // May be sparse. - Results []*EvalState_Result `protobuf:"bytes,3,rep,name=results,proto3" json:"results,omitempty"` -} - -func (x *EvalState) Reset() { - *x = EvalState{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_eval_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *EvalState) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*EvalState) ProtoMessage() {} - -func (x *EvalState) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_eval_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 EvalState.ProtoReflect.Descriptor instead. -func (*EvalState) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_eval_proto_rawDescGZIP(), []int{0} -} - -func (x *EvalState) GetValues() []*ExprValue { - if x != nil { - return x.Values - } - return nil -} - -func (x *EvalState) GetResults() []*EvalState_Result { - if x != nil { - return x.Results - } - return nil -} - -// The value of an evaluated expression. -type ExprValue struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // An expression can resolve to a value, error or unknown. - // - // Types that are assignable to Kind: - // - // *ExprValue_Value - // *ExprValue_Error - // *ExprValue_Unknown - Kind isExprValue_Kind `protobuf_oneof:"kind"` -} - -func (x *ExprValue) Reset() { - *x = ExprValue{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_eval_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ExprValue) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ExprValue) ProtoMessage() {} - -func (x *ExprValue) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_eval_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 ExprValue.ProtoReflect.Descriptor instead. -func (*ExprValue) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_eval_proto_rawDescGZIP(), []int{1} -} - -func (m *ExprValue) GetKind() isExprValue_Kind { - if m != nil { - return m.Kind - } - return nil -} - -func (x *ExprValue) GetValue() *Value { - if x, ok := x.GetKind().(*ExprValue_Value); ok { - return x.Value - } - return nil -} - -func (x *ExprValue) GetError() *ErrorSet { - if x, ok := x.GetKind().(*ExprValue_Error); ok { - return x.Error - } - return nil -} - -func (x *ExprValue) GetUnknown() *UnknownSet { - if x, ok := x.GetKind().(*ExprValue_Unknown); ok { - return x.Unknown - } - return nil -} - -type isExprValue_Kind interface { - isExprValue_Kind() -} - -type ExprValue_Value struct { - // A concrete value. - Value *Value `protobuf:"bytes,1,opt,name=value,proto3,oneof"` -} - -type ExprValue_Error struct { - // The set of errors in the critical path of evalution. - // - // Only errors in the critical path are included. For example, - // `( || true) && ` will only result in ``, - // while ` || ` will result in both `` and - // ``. - // - // Errors cause by the presence of other errors are not included in the - // set. For example `.foo`, `foo()`, and ` + 1` will - // only result in ``. - // - // Multiple errors *might* be included when evaluation could result - // in different errors. For example ` + ` and - // `foo(, )` may result in ``, `` or both. - // The exact subset of errors included for this case is unspecified and - // depends on the implementation details of the evaluator. - Error *ErrorSet `protobuf:"bytes,2,opt,name=error,proto3,oneof"` -} - -type ExprValue_Unknown struct { - // The set of unknowns in the critical path of evaluation. - // - // Unknown behaves identically to Error with regards to propagation. - // Specifically, only unknowns in the critical path are included, unknowns - // caused by the presence of other unknowns are not included, and multiple - // unknowns *might* be included included when evaluation could result in - // different unknowns. For example: - // - // ( || true) && -> - // || -> - // .foo -> - // foo() -> - // + -> or - // - // Unknown takes precidence over Error in cases where a `Value` can short - // circuit the result: - // - // || -> - // && -> - // - // Errors take precidence in all other cases: - // - // + -> - // foo(, ) -> - Unknown *UnknownSet `protobuf:"bytes,3,opt,name=unknown,proto3,oneof"` -} - -func (*ExprValue_Value) isExprValue_Kind() {} - -func (*ExprValue_Error) isExprValue_Kind() {} - -func (*ExprValue_Unknown) isExprValue_Kind() {} - -// A set of errors. -// -// The errors included depend on the context. See `ExprValue.error`. -type ErrorSet struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The errors in the set. - Errors []*status.Status `protobuf:"bytes,1,rep,name=errors,proto3" json:"errors,omitempty"` -} - -func (x *ErrorSet) Reset() { - *x = ErrorSet{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_eval_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ErrorSet) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ErrorSet) ProtoMessage() {} - -func (x *ErrorSet) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_eval_proto_msgTypes[2] - 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 ErrorSet.ProtoReflect.Descriptor instead. -func (*ErrorSet) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_eval_proto_rawDescGZIP(), []int{2} -} - -func (x *ErrorSet) GetErrors() []*status.Status { - if x != nil { - return x.Errors - } - return nil -} - -// A set of expressions for which the value is unknown. -// -// The unknowns included depend on the context. See `ExprValue.unknown`. -type UnknownSet struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The ids of the expressions with unknown values. - Exprs []int64 `protobuf:"varint,1,rep,packed,name=exprs,proto3" json:"exprs,omitempty"` -} - -func (x *UnknownSet) Reset() { - *x = UnknownSet{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_eval_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *UnknownSet) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UnknownSet) ProtoMessage() {} - -func (x *UnknownSet) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_eval_proto_msgTypes[3] - 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 UnknownSet.ProtoReflect.Descriptor instead. -func (*UnknownSet) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_eval_proto_rawDescGZIP(), []int{3} -} - -func (x *UnknownSet) GetExprs() []int64 { - if x != nil { - return x.Exprs - } - return nil -} - -// A single evalution result. -type EvalState_Result struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The id of the expression this result if for. - Expr int64 `protobuf:"varint,1,opt,name=expr,proto3" json:"expr,omitempty"` - // The index in `values` of the resulting value. - Value int64 `protobuf:"varint,2,opt,name=value,proto3" json:"value,omitempty"` -} - -func (x *EvalState_Result) Reset() { - *x = EvalState_Result{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_eval_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *EvalState_Result) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*EvalState_Result) ProtoMessage() {} - -func (x *EvalState_Result) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_eval_proto_msgTypes[4] - 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 EvalState_Result.ProtoReflect.Descriptor instead. -func (*EvalState_Result) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_eval_proto_rawDescGZIP(), []int{0, 0} -} - -func (x *EvalState_Result) GetExpr() int64 { - if x != nil { - return x.Expr - } - return 0 -} - -func (x *EvalState_Result) GetValue() int64 { - if x != nil { - return x.Value - } - return 0 -} - -var File_google_api_expr_v1alpha1_eval_proto protoreflect.FileDescriptor - -var file_google_api_expr_v1alpha1_eval_proto_rawDesc = []byte{ - 0x0a, 0x23, 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, 0x65, 0x76, 0x61, 0x6c, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x18, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x65, 0x78, 0x70, 0x72, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x1a, - 0x24, 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, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x72, 0x70, - 0x63, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc2, - 0x01, 0x0a, 0x09, 0x45, 0x76, 0x61, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x3b, 0x0a, 0x06, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 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, 0x45, 0x78, 0x70, 0x72, 0x56, 0x61, 0x6c, 0x75, - 0x65, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, 0x44, 0x0a, 0x07, 0x72, 0x65, 0x73, - 0x75, 0x6c, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 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, 0x45, 0x76, 0x61, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x65, 0x2e, - 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x1a, - 0x32, 0x0a, 0x06, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x65, 0x78, 0x70, - 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x65, 0x78, 0x70, 0x72, 0x12, 0x14, 0x0a, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x22, 0xca, 0x01, 0x0a, 0x09, 0x45, 0x78, 0x70, 0x72, 0x56, 0x61, 0x6c, 0x75, - 0x65, 0x12, 0x37, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x1f, 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, 0x56, 0x61, 0x6c, 0x75, - 0x65, 0x48, 0x00, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3a, 0x0a, 0x05, 0x65, 0x72, - 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 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, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x48, 0x00, 0x52, - 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x40, 0x0a, 0x07, 0x75, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, - 0x6e, 0x18, 0x03, 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, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x53, 0x65, 0x74, 0x48, 0x00, 0x52, - 0x07, 0x75, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x42, 0x06, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, - 0x22, 0x36, 0x0a, 0x08, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x12, 0x2a, 0x0a, 0x06, - 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x06, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x22, 0x22, 0x0a, 0x0a, 0x55, 0x6e, 0x6b, 0x6e, - 0x6f, 0x77, 0x6e, 0x53, 0x65, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x78, 0x70, 0x72, 0x73, 0x18, - 0x01, 0x20, 0x03, 0x28, 0x03, 0x52, 0x05, 0x65, 0x78, 0x70, 0x72, 0x73, 0x42, 0x6c, 0x0a, 0x1c, - 0x63, 0x6f, 0x6d, 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, 0x42, 0x09, 0x45, 0x76, - 0x61, 0x6c, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x67, 0x65, 0x6e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x61, 0x70, 0x69, 0x73, - 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x65, 0x78, 0x70, 0x72, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x3b, 0x65, 0x78, 0x70, 0x72, 0xf8, 0x01, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, -} - -var ( - file_google_api_expr_v1alpha1_eval_proto_rawDescOnce sync.Once - file_google_api_expr_v1alpha1_eval_proto_rawDescData = file_google_api_expr_v1alpha1_eval_proto_rawDesc -) - -func file_google_api_expr_v1alpha1_eval_proto_rawDescGZIP() []byte { - file_google_api_expr_v1alpha1_eval_proto_rawDescOnce.Do(func() { - file_google_api_expr_v1alpha1_eval_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_api_expr_v1alpha1_eval_proto_rawDescData) - }) - return file_google_api_expr_v1alpha1_eval_proto_rawDescData -} - -var file_google_api_expr_v1alpha1_eval_proto_msgTypes = make([]protoimpl.MessageInfo, 5) -var file_google_api_expr_v1alpha1_eval_proto_goTypes = []interface{}{ - (*EvalState)(nil), // 0: google.api.expr.v1alpha1.EvalState - (*ExprValue)(nil), // 1: google.api.expr.v1alpha1.ExprValue - (*ErrorSet)(nil), // 2: google.api.expr.v1alpha1.ErrorSet - (*UnknownSet)(nil), // 3: google.api.expr.v1alpha1.UnknownSet - (*EvalState_Result)(nil), // 4: google.api.expr.v1alpha1.EvalState.Result - (*Value)(nil), // 5: google.api.expr.v1alpha1.Value - (*status.Status)(nil), // 6: google.rpc.Status -} -var file_google_api_expr_v1alpha1_eval_proto_depIdxs = []int32{ - 1, // 0: google.api.expr.v1alpha1.EvalState.values:type_name -> google.api.expr.v1alpha1.ExprValue - 4, // 1: google.api.expr.v1alpha1.EvalState.results:type_name -> google.api.expr.v1alpha1.EvalState.Result - 5, // 2: google.api.expr.v1alpha1.ExprValue.value:type_name -> google.api.expr.v1alpha1.Value - 2, // 3: google.api.expr.v1alpha1.ExprValue.error:type_name -> google.api.expr.v1alpha1.ErrorSet - 3, // 4: google.api.expr.v1alpha1.ExprValue.unknown:type_name -> google.api.expr.v1alpha1.UnknownSet - 6, // 5: google.api.expr.v1alpha1.ErrorSet.errors:type_name -> google.rpc.Status - 6, // [6:6] is the sub-list for method output_type - 6, // [6:6] is the sub-list for method input_type - 6, // [6:6] is the sub-list for extension type_name - 6, // [6:6] is the sub-list for extension extendee - 0, // [0:6] is the sub-list for field type_name -} - -func init() { file_google_api_expr_v1alpha1_eval_proto_init() } -func file_google_api_expr_v1alpha1_eval_proto_init() { - if File_google_api_expr_v1alpha1_eval_proto != nil { - return - } - file_google_api_expr_v1alpha1_value_proto_init() - if !protoimpl.UnsafeEnabled { - file_google_api_expr_v1alpha1_eval_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*EvalState); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_eval_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ExprValue); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_eval_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ErrorSet); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_eval_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UnknownSet); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_eval_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*EvalState_Result); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_google_api_expr_v1alpha1_eval_proto_msgTypes[1].OneofWrappers = []interface{}{ - (*ExprValue_Value)(nil), - (*ExprValue_Error)(nil), - (*ExprValue_Unknown)(nil), - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_google_api_expr_v1alpha1_eval_proto_rawDesc, - NumEnums: 0, - NumMessages: 5, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_google_api_expr_v1alpha1_eval_proto_goTypes, - DependencyIndexes: file_google_api_expr_v1alpha1_eval_proto_depIdxs, - MessageInfos: file_google_api_expr_v1alpha1_eval_proto_msgTypes, - }.Build() - File_google_api_expr_v1alpha1_eval_proto = out.File - file_google_api_expr_v1alpha1_eval_proto_rawDesc = nil - file_google_api_expr_v1alpha1_eval_proto_goTypes = nil - file_google_api_expr_v1alpha1_eval_proto_depIdxs = nil -} diff --git a/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/explain.pb.go b/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/explain.pb.go deleted file mode 100644 index 3f994b4e3..000000000 --- a/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/explain.pb.go +++ /dev/null @@ -1,275 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.26.0 -// protoc v4.24.4 -// source: google/api/expr/v1alpha1/explain.proto - -package expr - -import ( - reflect "reflect" - sync "sync" - - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" -) - -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) -) - -// Values of intermediate expressions produced when evaluating expression. -// Deprecated, use `EvalState` instead. -// -// Deprecated: Do not use. -type Explain struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // All of the observed values. - // - // The field value_index is an index in the values list. - // Separating values from steps is needed to remove redundant values. - Values []*Value `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"` - // List of steps. - // - // Repeated evaluations of the same expression generate new ExprStep - // instances. The order of such ExprStep instances matches the order of - // elements returned by Comprehension.iter_range. - ExprSteps []*Explain_ExprStep `protobuf:"bytes,2,rep,name=expr_steps,json=exprSteps,proto3" json:"expr_steps,omitempty"` -} - -func (x *Explain) Reset() { - *x = Explain{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_explain_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Explain) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Explain) ProtoMessage() {} - -func (x *Explain) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_explain_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 Explain.ProtoReflect.Descriptor instead. -func (*Explain) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_explain_proto_rawDescGZIP(), []int{0} -} - -func (x *Explain) GetValues() []*Value { - if x != nil { - return x.Values - } - return nil -} - -func (x *Explain) GetExprSteps() []*Explain_ExprStep { - if x != nil { - return x.ExprSteps - } - return nil -} - -// ID and value index of one step. -type Explain_ExprStep struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // ID of corresponding Expr node. - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // Index of the value in the values list. - ValueIndex int32 `protobuf:"varint,2,opt,name=value_index,json=valueIndex,proto3" json:"value_index,omitempty"` -} - -func (x *Explain_ExprStep) Reset() { - *x = Explain_ExprStep{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_explain_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Explain_ExprStep) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Explain_ExprStep) ProtoMessage() {} - -func (x *Explain_ExprStep) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_explain_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 Explain_ExprStep.ProtoReflect.Descriptor instead. -func (*Explain_ExprStep) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_explain_proto_rawDescGZIP(), []int{0, 0} -} - -func (x *Explain_ExprStep) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *Explain_ExprStep) GetValueIndex() int32 { - if x != nil { - return x.ValueIndex - } - return 0 -} - -var File_google_api_expr_v1alpha1_explain_proto protoreflect.FileDescriptor - -var file_google_api_expr_v1alpha1_explain_proto_rawDesc = []byte{ - 0x0a, 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, 0x65, 0x78, 0x70, 0x6c, 0x61, - 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x18, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x65, 0x78, 0x70, 0x72, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x1a, 0x24, 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, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xce, 0x01, 0x0a, 0x07, 0x45, 0x78, 0x70, - 0x6c, 0x61, 0x69, 0x6e, 0x12, 0x37, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 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, - 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, 0x49, 0x0a, - 0x0a, 0x65, 0x78, 0x70, 0x72, 0x5f, 0x73, 0x74, 0x65, 0x70, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x2a, 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, 0x45, 0x78, 0x70, - 0x6c, 0x61, 0x69, 0x6e, 0x2e, 0x45, 0x78, 0x70, 0x72, 0x53, 0x74, 0x65, 0x70, 0x52, 0x09, 0x65, - 0x78, 0x70, 0x72, 0x53, 0x74, 0x65, 0x70, 0x73, 0x1a, 0x3b, 0x0a, 0x08, 0x45, 0x78, 0x70, 0x72, - 0x53, 0x74, 0x65, 0x70, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x02, 0x69, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x69, 0x6e, - 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x49, 0x6e, 0x64, 0x65, 0x78, 0x3a, 0x02, 0x18, 0x01, 0x42, 0x6f, 0x0a, 0x1c, 0x63, 0x6f, 0x6d, - 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, 0x42, 0x0c, 0x45, 0x78, 0x70, 0x6c, 0x61, - 0x69, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x67, 0x65, 0x6e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x61, 0x70, 0x69, 0x73, - 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x65, 0x78, 0x70, 0x72, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x3b, 0x65, 0x78, 0x70, 0x72, 0xf8, 0x01, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, -} - -var ( - file_google_api_expr_v1alpha1_explain_proto_rawDescOnce sync.Once - file_google_api_expr_v1alpha1_explain_proto_rawDescData = file_google_api_expr_v1alpha1_explain_proto_rawDesc -) - -func file_google_api_expr_v1alpha1_explain_proto_rawDescGZIP() []byte { - file_google_api_expr_v1alpha1_explain_proto_rawDescOnce.Do(func() { - file_google_api_expr_v1alpha1_explain_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_api_expr_v1alpha1_explain_proto_rawDescData) - }) - return file_google_api_expr_v1alpha1_explain_proto_rawDescData -} - -var file_google_api_expr_v1alpha1_explain_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_google_api_expr_v1alpha1_explain_proto_goTypes = []interface{}{ - (*Explain)(nil), // 0: google.api.expr.v1alpha1.Explain - (*Explain_ExprStep)(nil), // 1: google.api.expr.v1alpha1.Explain.ExprStep - (*Value)(nil), // 2: google.api.expr.v1alpha1.Value -} -var file_google_api_expr_v1alpha1_explain_proto_depIdxs = []int32{ - 2, // 0: google.api.expr.v1alpha1.Explain.values:type_name -> google.api.expr.v1alpha1.Value - 1, // 1: google.api.expr.v1alpha1.Explain.expr_steps:type_name -> google.api.expr.v1alpha1.Explain.ExprStep - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name -} - -func init() { file_google_api_expr_v1alpha1_explain_proto_init() } -func file_google_api_expr_v1alpha1_explain_proto_init() { - if File_google_api_expr_v1alpha1_explain_proto != nil { - return - } - file_google_api_expr_v1alpha1_value_proto_init() - if !protoimpl.UnsafeEnabled { - file_google_api_expr_v1alpha1_explain_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Explain); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_explain_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Explain_ExprStep); 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_google_api_expr_v1alpha1_explain_proto_rawDesc, - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_google_api_expr_v1alpha1_explain_proto_goTypes, - DependencyIndexes: file_google_api_expr_v1alpha1_explain_proto_depIdxs, - MessageInfos: file_google_api_expr_v1alpha1_explain_proto_msgTypes, - }.Build() - File_google_api_expr_v1alpha1_explain_proto = out.File - file_google_api_expr_v1alpha1_explain_proto_rawDesc = nil - file_google_api_expr_v1alpha1_explain_proto_goTypes = nil - file_google_api_expr_v1alpha1_explain_proto_depIdxs = nil -} diff --git a/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/syntax.pb.go b/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/syntax.pb.go deleted file mode 100644 index 0d718fc36..000000000 --- a/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/syntax.pb.go +++ /dev/null @@ -1,1990 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.26.0 -// protoc v4.24.4 -// source: google/api/expr/v1alpha1/syntax.proto - -package expr - -import ( - reflect "reflect" - sync "sync" - - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - durationpb "google.golang.org/protobuf/types/known/durationpb" - structpb "google.golang.org/protobuf/types/known/structpb" - timestamppb "google.golang.org/protobuf/types/known/timestamppb" -) - -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) -) - -// CEL component specifier. -type SourceInfo_Extension_Component int32 - -const ( - // Unspecified, default. - SourceInfo_Extension_COMPONENT_UNSPECIFIED SourceInfo_Extension_Component = 0 - // Parser. Converts a CEL string to an AST. - SourceInfo_Extension_COMPONENT_PARSER SourceInfo_Extension_Component = 1 - // Type checker. Checks that references in an AST are defined and types - // agree. - SourceInfo_Extension_COMPONENT_TYPE_CHECKER SourceInfo_Extension_Component = 2 - // Runtime. Evaluates a parsed and optionally checked CEL AST against a - // context. - SourceInfo_Extension_COMPONENT_RUNTIME SourceInfo_Extension_Component = 3 -) - -// Enum value maps for SourceInfo_Extension_Component. -var ( - SourceInfo_Extension_Component_name = map[int32]string{ - 0: "COMPONENT_UNSPECIFIED", - 1: "COMPONENT_PARSER", - 2: "COMPONENT_TYPE_CHECKER", - 3: "COMPONENT_RUNTIME", - } - SourceInfo_Extension_Component_value = map[string]int32{ - "COMPONENT_UNSPECIFIED": 0, - "COMPONENT_PARSER": 1, - "COMPONENT_TYPE_CHECKER": 2, - "COMPONENT_RUNTIME": 3, - } -) - -func (x SourceInfo_Extension_Component) Enum() *SourceInfo_Extension_Component { - p := new(SourceInfo_Extension_Component) - *p = x - return p -} - -func (x SourceInfo_Extension_Component) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (SourceInfo_Extension_Component) Descriptor() protoreflect.EnumDescriptor { - return file_google_api_expr_v1alpha1_syntax_proto_enumTypes[0].Descriptor() -} - -func (SourceInfo_Extension_Component) Type() protoreflect.EnumType { - return &file_google_api_expr_v1alpha1_syntax_proto_enumTypes[0] -} - -func (x SourceInfo_Extension_Component) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use SourceInfo_Extension_Component.Descriptor instead. -func (SourceInfo_Extension_Component) EnumDescriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_syntax_proto_rawDescGZIP(), []int{3, 0, 0} -} - -// An expression together with source information as returned by the parser. -type ParsedExpr struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The parsed expression. - Expr *Expr `protobuf:"bytes,2,opt,name=expr,proto3" json:"expr,omitempty"` - // The source info derived from input that generated the parsed `expr`. - SourceInfo *SourceInfo `protobuf:"bytes,3,opt,name=source_info,json=sourceInfo,proto3" json:"source_info,omitempty"` -} - -func (x *ParsedExpr) Reset() { - *x = ParsedExpr{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_syntax_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ParsedExpr) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ParsedExpr) ProtoMessage() {} - -func (x *ParsedExpr) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_syntax_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 ParsedExpr.ProtoReflect.Descriptor instead. -func (*ParsedExpr) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_syntax_proto_rawDescGZIP(), []int{0} -} - -func (x *ParsedExpr) GetExpr() *Expr { - if x != nil { - return x.Expr - } - return nil -} - -func (x *ParsedExpr) GetSourceInfo() *SourceInfo { - if x != nil { - return x.SourceInfo - } - return nil -} - -// An abstract representation of a common expression. -// -// Expressions are abstractly represented as a collection of identifiers, -// select statements, function calls, literals, and comprehensions. All -// operators with the exception of the '.' operator are modelled as function -// calls. This makes it easy to represent new operators into the existing AST. -// -// All references within expressions must resolve to a -// [Decl][google.api.expr.v1alpha1.Decl] provided at type-check for an -// expression to be valid. A reference may either be a bare identifier `name` or -// a qualified identifier `google.api.name`. References may either refer to a -// value or a function declaration. -// -// For example, the expression `google.api.name.startsWith('expr')` references -// the declaration `google.api.name` within a -// [Expr.Select][google.api.expr.v1alpha1.Expr.Select] expression, and the -// function declaration `startsWith`. -type Expr struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Required. An id assigned to this node by the parser which is unique in a - // given expression tree. This is used to associate type information and other - // attributes to a node in the parse tree. - Id int64 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` - // Required. Variants of expressions. - // - // Types that are assignable to ExprKind: - // - // *Expr_ConstExpr - // *Expr_IdentExpr - // *Expr_SelectExpr - // *Expr_CallExpr - // *Expr_ListExpr - // *Expr_StructExpr - // *Expr_ComprehensionExpr - ExprKind isExpr_ExprKind `protobuf_oneof:"expr_kind"` -} - -func (x *Expr) Reset() { - *x = Expr{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_syntax_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Expr) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Expr) ProtoMessage() {} - -func (x *Expr) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_syntax_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 Expr.ProtoReflect.Descriptor instead. -func (*Expr) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_syntax_proto_rawDescGZIP(), []int{1} -} - -func (x *Expr) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (m *Expr) GetExprKind() isExpr_ExprKind { - if m != nil { - return m.ExprKind - } - return nil -} - -func (x *Expr) GetConstExpr() *Constant { - if x, ok := x.GetExprKind().(*Expr_ConstExpr); ok { - return x.ConstExpr - } - return nil -} - -func (x *Expr) GetIdentExpr() *Expr_Ident { - if x, ok := x.GetExprKind().(*Expr_IdentExpr); ok { - return x.IdentExpr - } - return nil -} - -func (x *Expr) GetSelectExpr() *Expr_Select { - if x, ok := x.GetExprKind().(*Expr_SelectExpr); ok { - return x.SelectExpr - } - return nil -} - -func (x *Expr) GetCallExpr() *Expr_Call { - if x, ok := x.GetExprKind().(*Expr_CallExpr); ok { - return x.CallExpr - } - return nil -} - -func (x *Expr) GetListExpr() *Expr_CreateList { - if x, ok := x.GetExprKind().(*Expr_ListExpr); ok { - return x.ListExpr - } - return nil -} - -func (x *Expr) GetStructExpr() *Expr_CreateStruct { - if x, ok := x.GetExprKind().(*Expr_StructExpr); ok { - return x.StructExpr - } - return nil -} - -func (x *Expr) GetComprehensionExpr() *Expr_Comprehension { - if x, ok := x.GetExprKind().(*Expr_ComprehensionExpr); ok { - return x.ComprehensionExpr - } - return nil -} - -type isExpr_ExprKind interface { - isExpr_ExprKind() -} - -type Expr_ConstExpr struct { - // A literal expression. - ConstExpr *Constant `protobuf:"bytes,3,opt,name=const_expr,json=constExpr,proto3,oneof"` -} - -type Expr_IdentExpr struct { - // An identifier expression. - IdentExpr *Expr_Ident `protobuf:"bytes,4,opt,name=ident_expr,json=identExpr,proto3,oneof"` -} - -type Expr_SelectExpr struct { - // A field selection expression, e.g. `request.auth`. - SelectExpr *Expr_Select `protobuf:"bytes,5,opt,name=select_expr,json=selectExpr,proto3,oneof"` -} - -type Expr_CallExpr struct { - // A call expression, including calls to predefined functions and operators. - CallExpr *Expr_Call `protobuf:"bytes,6,opt,name=call_expr,json=callExpr,proto3,oneof"` -} - -type Expr_ListExpr struct { - // A list creation expression. - ListExpr *Expr_CreateList `protobuf:"bytes,7,opt,name=list_expr,json=listExpr,proto3,oneof"` -} - -type Expr_StructExpr struct { - // A map or message creation expression. - StructExpr *Expr_CreateStruct `protobuf:"bytes,8,opt,name=struct_expr,json=structExpr,proto3,oneof"` -} - -type Expr_ComprehensionExpr struct { - // A comprehension expression. - ComprehensionExpr *Expr_Comprehension `protobuf:"bytes,9,opt,name=comprehension_expr,json=comprehensionExpr,proto3,oneof"` -} - -func (*Expr_ConstExpr) isExpr_ExprKind() {} - -func (*Expr_IdentExpr) isExpr_ExprKind() {} - -func (*Expr_SelectExpr) isExpr_ExprKind() {} - -func (*Expr_CallExpr) isExpr_ExprKind() {} - -func (*Expr_ListExpr) isExpr_ExprKind() {} - -func (*Expr_StructExpr) isExpr_ExprKind() {} - -func (*Expr_ComprehensionExpr) isExpr_ExprKind() {} - -// Represents a primitive literal. -// -// Named 'Constant' here for backwards compatibility. -// -// This is similar as the primitives supported in the well-known type -// `google.protobuf.Value`, but richer so it can represent CEL's full range of -// primitives. -// -// Lists and structs are not included as constants as these aggregate types may -// contain [Expr][google.api.expr.v1alpha1.Expr] elements which require -// evaluation and are thus not constant. -// -// Examples of literals include: `"hello"`, `b'bytes'`, `1u`, `4.2`, `-2`, -// `true`, `null`. -type Constant struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Required. The valid constant kinds. - // - // Types that are assignable to ConstantKind: - // - // *Constant_NullValue - // *Constant_BoolValue - // *Constant_Int64Value - // *Constant_Uint64Value - // *Constant_DoubleValue - // *Constant_StringValue - // *Constant_BytesValue - // *Constant_DurationValue - // *Constant_TimestampValue - ConstantKind isConstant_ConstantKind `protobuf_oneof:"constant_kind"` -} - -func (x *Constant) Reset() { - *x = Constant{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_syntax_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Constant) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Constant) ProtoMessage() {} - -func (x *Constant) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_syntax_proto_msgTypes[2] - 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 Constant.ProtoReflect.Descriptor instead. -func (*Constant) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_syntax_proto_rawDescGZIP(), []int{2} -} - -func (m *Constant) GetConstantKind() isConstant_ConstantKind { - if m != nil { - return m.ConstantKind - } - return nil -} - -func (x *Constant) GetNullValue() structpb.NullValue { - if x, ok := x.GetConstantKind().(*Constant_NullValue); ok { - return x.NullValue - } - return structpb.NullValue_NULL_VALUE -} - -func (x *Constant) GetBoolValue() bool { - if x, ok := x.GetConstantKind().(*Constant_BoolValue); ok { - return x.BoolValue - } - return false -} - -func (x *Constant) GetInt64Value() int64 { - if x, ok := x.GetConstantKind().(*Constant_Int64Value); ok { - return x.Int64Value - } - return 0 -} - -func (x *Constant) GetUint64Value() uint64 { - if x, ok := x.GetConstantKind().(*Constant_Uint64Value); ok { - return x.Uint64Value - } - return 0 -} - -func (x *Constant) GetDoubleValue() float64 { - if x, ok := x.GetConstantKind().(*Constant_DoubleValue); ok { - return x.DoubleValue - } - return 0 -} - -func (x *Constant) GetStringValue() string { - if x, ok := x.GetConstantKind().(*Constant_StringValue); ok { - return x.StringValue - } - return "" -} - -func (x *Constant) GetBytesValue() []byte { - if x, ok := x.GetConstantKind().(*Constant_BytesValue); ok { - return x.BytesValue - } - return nil -} - -// Deprecated: Do not use. -func (x *Constant) GetDurationValue() *durationpb.Duration { - if x, ok := x.GetConstantKind().(*Constant_DurationValue); ok { - return x.DurationValue - } - return nil -} - -// Deprecated: Do not use. -func (x *Constant) GetTimestampValue() *timestamppb.Timestamp { - if x, ok := x.GetConstantKind().(*Constant_TimestampValue); ok { - return x.TimestampValue - } - return nil -} - -type isConstant_ConstantKind interface { - isConstant_ConstantKind() -} - -type Constant_NullValue struct { - // null value. - NullValue structpb.NullValue `protobuf:"varint,1,opt,name=null_value,json=nullValue,proto3,enum=google.protobuf.NullValue,oneof"` -} - -type Constant_BoolValue struct { - // boolean value. - BoolValue bool `protobuf:"varint,2,opt,name=bool_value,json=boolValue,proto3,oneof"` -} - -type Constant_Int64Value struct { - // int64 value. - Int64Value int64 `protobuf:"varint,3,opt,name=int64_value,json=int64Value,proto3,oneof"` -} - -type Constant_Uint64Value struct { - // uint64 value. - Uint64Value uint64 `protobuf:"varint,4,opt,name=uint64_value,json=uint64Value,proto3,oneof"` -} - -type Constant_DoubleValue struct { - // double value. - DoubleValue float64 `protobuf:"fixed64,5,opt,name=double_value,json=doubleValue,proto3,oneof"` -} - -type Constant_StringValue struct { - // string value. - StringValue string `protobuf:"bytes,6,opt,name=string_value,json=stringValue,proto3,oneof"` -} - -type Constant_BytesValue struct { - // bytes value. - BytesValue []byte `protobuf:"bytes,7,opt,name=bytes_value,json=bytesValue,proto3,oneof"` -} - -type Constant_DurationValue struct { - // protobuf.Duration value. - // - // Deprecated: duration is no longer considered a builtin cel type. - // - // Deprecated: Do not use. - DurationValue *durationpb.Duration `protobuf:"bytes,8,opt,name=duration_value,json=durationValue,proto3,oneof"` -} - -type Constant_TimestampValue struct { - // protobuf.Timestamp value. - // - // Deprecated: timestamp is no longer considered a builtin cel type. - // - // Deprecated: Do not use. - TimestampValue *timestamppb.Timestamp `protobuf:"bytes,9,opt,name=timestamp_value,json=timestampValue,proto3,oneof"` -} - -func (*Constant_NullValue) isConstant_ConstantKind() {} - -func (*Constant_BoolValue) isConstant_ConstantKind() {} - -func (*Constant_Int64Value) isConstant_ConstantKind() {} - -func (*Constant_Uint64Value) isConstant_ConstantKind() {} - -func (*Constant_DoubleValue) isConstant_ConstantKind() {} - -func (*Constant_StringValue) isConstant_ConstantKind() {} - -func (*Constant_BytesValue) isConstant_ConstantKind() {} - -func (*Constant_DurationValue) isConstant_ConstantKind() {} - -func (*Constant_TimestampValue) isConstant_ConstantKind() {} - -// Source information collected at parse time. -type SourceInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The syntax version of the source, e.g. `cel1`. - SyntaxVersion string `protobuf:"bytes,1,opt,name=syntax_version,json=syntaxVersion,proto3" json:"syntax_version,omitempty"` - // The location name. All position information attached to an expression is - // relative to this location. - // - // The location could be a file, UI element, or similar. For example, - // `acme/app/AnvilPolicy.cel`. - Location string `protobuf:"bytes,2,opt,name=location,proto3" json:"location,omitempty"` - // Monotonically increasing list of code point offsets where newlines - // `\n` appear. - // - // The line number of a given position is the index `i` where for a given - // `id` the `line_offsets[i] < id_positions[id] < line_offsets[i+1]`. The - // column may be derivd from `id_positions[id] - line_offsets[i]`. - LineOffsets []int32 `protobuf:"varint,3,rep,packed,name=line_offsets,json=lineOffsets,proto3" json:"line_offsets,omitempty"` - // A map from the parse node id (e.g. `Expr.id`) to the code point offset - // within the source. - Positions map[int64]int32 `protobuf:"bytes,4,rep,name=positions,proto3" json:"positions,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` - // A map from the parse node id where a macro replacement was made to the - // call `Expr` that resulted in a macro expansion. - // - // For example, `has(value.field)` is a function call that is replaced by a - // `test_only` field selection in the AST. Likewise, the call - // `list.exists(e, e > 10)` translates to a comprehension expression. The key - // in the map corresponds to the expression id of the expanded macro, and the - // value is the call `Expr` that was replaced. - MacroCalls map[int64]*Expr `protobuf:"bytes,5,rep,name=macro_calls,json=macroCalls,proto3" json:"macro_calls,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - // A list of tags for extensions that were used while parsing or type checking - // the source expression. For example, optimizations that require special - // runtime support may be specified. - // - // These are used to check feature support between components in separate - // implementations. This can be used to either skip redundant work or - // report an error if the extension is unsupported. - Extensions []*SourceInfo_Extension `protobuf:"bytes,6,rep,name=extensions,proto3" json:"extensions,omitempty"` -} - -func (x *SourceInfo) Reset() { - *x = SourceInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_syntax_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SourceInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SourceInfo) ProtoMessage() {} - -func (x *SourceInfo) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_syntax_proto_msgTypes[3] - 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 SourceInfo.ProtoReflect.Descriptor instead. -func (*SourceInfo) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_syntax_proto_rawDescGZIP(), []int{3} -} - -func (x *SourceInfo) GetSyntaxVersion() string { - if x != nil { - return x.SyntaxVersion - } - return "" -} - -func (x *SourceInfo) GetLocation() string { - if x != nil { - return x.Location - } - return "" -} - -func (x *SourceInfo) GetLineOffsets() []int32 { - if x != nil { - return x.LineOffsets - } - return nil -} - -func (x *SourceInfo) GetPositions() map[int64]int32 { - if x != nil { - return x.Positions - } - return nil -} - -func (x *SourceInfo) GetMacroCalls() map[int64]*Expr { - if x != nil { - return x.MacroCalls - } - return nil -} - -func (x *SourceInfo) GetExtensions() []*SourceInfo_Extension { - if x != nil { - return x.Extensions - } - return nil -} - -// A specific position in source. -type SourcePosition struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The soucre location name (e.g. file name). - Location string `protobuf:"bytes,1,opt,name=location,proto3" json:"location,omitempty"` - // The UTF-8 code unit offset. - Offset int32 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"` - // The 1-based index of the starting line in the source text - // where the issue occurs, or 0 if unknown. - Line int32 `protobuf:"varint,3,opt,name=line,proto3" json:"line,omitempty"` - // The 0-based index of the starting position within the line of source text - // where the issue occurs. Only meaningful if line is nonzero. - Column int32 `protobuf:"varint,4,opt,name=column,proto3" json:"column,omitempty"` -} - -func (x *SourcePosition) Reset() { - *x = SourcePosition{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_syntax_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SourcePosition) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SourcePosition) ProtoMessage() {} - -func (x *SourcePosition) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_syntax_proto_msgTypes[4] - 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 SourcePosition.ProtoReflect.Descriptor instead. -func (*SourcePosition) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_syntax_proto_rawDescGZIP(), []int{4} -} - -func (x *SourcePosition) GetLocation() string { - if x != nil { - return x.Location - } - return "" -} - -func (x *SourcePosition) GetOffset() int32 { - if x != nil { - return x.Offset - } - return 0 -} - -func (x *SourcePosition) GetLine() int32 { - if x != nil { - return x.Line - } - return 0 -} - -func (x *SourcePosition) GetColumn() int32 { - if x != nil { - return x.Column - } - return 0 -} - -// An identifier expression. e.g. `request`. -type Expr_Ident struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Required. Holds a single, unqualified identifier, possibly preceded by a - // '.'. - // - // Qualified names are represented by the - // [Expr.Select][google.api.expr.v1alpha1.Expr.Select] expression. - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` -} - -func (x *Expr_Ident) Reset() { - *x = Expr_Ident{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_syntax_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Expr_Ident) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Expr_Ident) ProtoMessage() {} - -func (x *Expr_Ident) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_syntax_proto_msgTypes[5] - 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 Expr_Ident.ProtoReflect.Descriptor instead. -func (*Expr_Ident) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_syntax_proto_rawDescGZIP(), []int{1, 0} -} - -func (x *Expr_Ident) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -// A field selection expression. e.g. `request.auth`. -type Expr_Select struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Required. The target of the selection expression. - // - // For example, in the select expression `request.auth`, the `request` - // portion of the expression is the `operand`. - Operand *Expr `protobuf:"bytes,1,opt,name=operand,proto3" json:"operand,omitempty"` - // Required. The name of the field to select. - // - // For example, in the select expression `request.auth`, the `auth` portion - // of the expression would be the `field`. - Field string `protobuf:"bytes,2,opt,name=field,proto3" json:"field,omitempty"` - // Whether the select is to be interpreted as a field presence test. - // - // This results from the macro `has(request.auth)`. - TestOnly bool `protobuf:"varint,3,opt,name=test_only,json=testOnly,proto3" json:"test_only,omitempty"` -} - -func (x *Expr_Select) Reset() { - *x = Expr_Select{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_syntax_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Expr_Select) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Expr_Select) ProtoMessage() {} - -func (x *Expr_Select) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_syntax_proto_msgTypes[6] - 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 Expr_Select.ProtoReflect.Descriptor instead. -func (*Expr_Select) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_syntax_proto_rawDescGZIP(), []int{1, 1} -} - -func (x *Expr_Select) GetOperand() *Expr { - if x != nil { - return x.Operand - } - return nil -} - -func (x *Expr_Select) GetField() string { - if x != nil { - return x.Field - } - return "" -} - -func (x *Expr_Select) GetTestOnly() bool { - if x != nil { - return x.TestOnly - } - return false -} - -// A call expression, including calls to predefined functions and operators. -// -// For example, `value == 10`, `size(map_value)`. -type Expr_Call struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The target of an method call-style expression. For example, `x` in - // `x.f()`. - Target *Expr `protobuf:"bytes,1,opt,name=target,proto3" json:"target,omitempty"` - // Required. The name of the function or method being called. - Function string `protobuf:"bytes,2,opt,name=function,proto3" json:"function,omitempty"` - // The arguments. - Args []*Expr `protobuf:"bytes,3,rep,name=args,proto3" json:"args,omitempty"` -} - -func (x *Expr_Call) Reset() { - *x = Expr_Call{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_syntax_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Expr_Call) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Expr_Call) ProtoMessage() {} - -func (x *Expr_Call) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_syntax_proto_msgTypes[7] - 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 Expr_Call.ProtoReflect.Descriptor instead. -func (*Expr_Call) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_syntax_proto_rawDescGZIP(), []int{1, 2} -} - -func (x *Expr_Call) GetTarget() *Expr { - if x != nil { - return x.Target - } - return nil -} - -func (x *Expr_Call) GetFunction() string { - if x != nil { - return x.Function - } - return "" -} - -func (x *Expr_Call) GetArgs() []*Expr { - if x != nil { - return x.Args - } - return nil -} - -// A list creation expression. -// -// Lists may either be homogenous, e.g. `[1, 2, 3]`, or heterogeneous, e.g. -// `dyn([1, 'hello', 2.0])` -type Expr_CreateList struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The elements part of the list. - Elements []*Expr `protobuf:"bytes,1,rep,name=elements,proto3" json:"elements,omitempty"` - // The indices within the elements list which are marked as optional - // elements. - // - // When an optional-typed value is present, the value it contains - // is included in the list. If the optional-typed value is absent, the list - // element is omitted from the CreateList result. - OptionalIndices []int32 `protobuf:"varint,2,rep,packed,name=optional_indices,json=optionalIndices,proto3" json:"optional_indices,omitempty"` -} - -func (x *Expr_CreateList) Reset() { - *x = Expr_CreateList{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_syntax_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Expr_CreateList) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Expr_CreateList) ProtoMessage() {} - -func (x *Expr_CreateList) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_syntax_proto_msgTypes[8] - 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 Expr_CreateList.ProtoReflect.Descriptor instead. -func (*Expr_CreateList) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_syntax_proto_rawDescGZIP(), []int{1, 3} -} - -func (x *Expr_CreateList) GetElements() []*Expr { - if x != nil { - return x.Elements - } - return nil -} - -func (x *Expr_CreateList) GetOptionalIndices() []int32 { - if x != nil { - return x.OptionalIndices - } - return nil -} - -// A map or message creation expression. -// -// Maps are constructed as `{'key_name': 'value'}`. Message construction is -// similar, but prefixed with a type name and composed of field ids: -// `types.MyType{field_id: 'value'}`. -type Expr_CreateStruct struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The type name of the message to be created, empty when creating map - // literals. - MessageName string `protobuf:"bytes,1,opt,name=message_name,json=messageName,proto3" json:"message_name,omitempty"` - // The entries in the creation expression. - Entries []*Expr_CreateStruct_Entry `protobuf:"bytes,2,rep,name=entries,proto3" json:"entries,omitempty"` -} - -func (x *Expr_CreateStruct) Reset() { - *x = Expr_CreateStruct{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_syntax_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Expr_CreateStruct) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Expr_CreateStruct) ProtoMessage() {} - -func (x *Expr_CreateStruct) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_syntax_proto_msgTypes[9] - 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 Expr_CreateStruct.ProtoReflect.Descriptor instead. -func (*Expr_CreateStruct) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_syntax_proto_rawDescGZIP(), []int{1, 4} -} - -func (x *Expr_CreateStruct) GetMessageName() string { - if x != nil { - return x.MessageName - } - return "" -} - -func (x *Expr_CreateStruct) GetEntries() []*Expr_CreateStruct_Entry { - if x != nil { - return x.Entries - } - return nil -} - -// A comprehension expression applied to a list or map. -// -// Comprehensions are not part of the core syntax, but enabled with macros. -// A macro matches a specific call signature within a parsed AST and replaces -// the call with an alternate AST block. Macro expansion happens at parse -// time. -// -// The following macros are supported within CEL: -// -// Aggregate type macros may be applied to all elements in a list or all keys -// in a map: -// -// - `all`, `exists`, `exists_one` - test a predicate expression against -// the inputs and return `true` if the predicate is satisfied for all, -// any, or only one value `list.all(x, x < 10)`. -// - `filter` - test a predicate expression against the inputs and return -// the subset of elements which satisfy the predicate: -// `payments.filter(p, p > 1000)`. -// - `map` - apply an expression to all elements in the input and return the -// output aggregate type: `[1, 2, 3].map(i, i * i)`. -// -// The `has(m.x)` macro tests whether the property `x` is present in struct -// `m`. The semantics of this macro depend on the type of `m`. For proto2 -// messages `has(m.x)` is defined as 'defined, but not set`. For proto3, the -// macro tests whether the property is set to its default. For map and struct -// types, the macro tests whether the property `x` is defined on `m`. -type Expr_Comprehension struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The name of the iteration variable. - IterVar string `protobuf:"bytes,1,opt,name=iter_var,json=iterVar,proto3" json:"iter_var,omitempty"` - // The range over which var iterates. - IterRange *Expr `protobuf:"bytes,2,opt,name=iter_range,json=iterRange,proto3" json:"iter_range,omitempty"` - // The name of the variable used for accumulation of the result. - AccuVar string `protobuf:"bytes,3,opt,name=accu_var,json=accuVar,proto3" json:"accu_var,omitempty"` - // The initial value of the accumulator. - AccuInit *Expr `protobuf:"bytes,4,opt,name=accu_init,json=accuInit,proto3" json:"accu_init,omitempty"` - // An expression which can contain iter_var and accu_var. - // - // Returns false when the result has been computed and may be used as - // a hint to short-circuit the remainder of the comprehension. - LoopCondition *Expr `protobuf:"bytes,5,opt,name=loop_condition,json=loopCondition,proto3" json:"loop_condition,omitempty"` - // An expression which can contain iter_var and accu_var. - // - // Computes the next value of accu_var. - LoopStep *Expr `protobuf:"bytes,6,opt,name=loop_step,json=loopStep,proto3" json:"loop_step,omitempty"` - // An expression which can contain accu_var. - // - // Computes the result. - Result *Expr `protobuf:"bytes,7,opt,name=result,proto3" json:"result,omitempty"` -} - -func (x *Expr_Comprehension) Reset() { - *x = Expr_Comprehension{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_syntax_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Expr_Comprehension) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Expr_Comprehension) ProtoMessage() {} - -func (x *Expr_Comprehension) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_syntax_proto_msgTypes[10] - 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 Expr_Comprehension.ProtoReflect.Descriptor instead. -func (*Expr_Comprehension) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_syntax_proto_rawDescGZIP(), []int{1, 5} -} - -func (x *Expr_Comprehension) GetIterVar() string { - if x != nil { - return x.IterVar - } - return "" -} - -func (x *Expr_Comprehension) GetIterRange() *Expr { - if x != nil { - return x.IterRange - } - return nil -} - -func (x *Expr_Comprehension) GetAccuVar() string { - if x != nil { - return x.AccuVar - } - return "" -} - -func (x *Expr_Comprehension) GetAccuInit() *Expr { - if x != nil { - return x.AccuInit - } - return nil -} - -func (x *Expr_Comprehension) GetLoopCondition() *Expr { - if x != nil { - return x.LoopCondition - } - return nil -} - -func (x *Expr_Comprehension) GetLoopStep() *Expr { - if x != nil { - return x.LoopStep - } - return nil -} - -func (x *Expr_Comprehension) GetResult() *Expr { - if x != nil { - return x.Result - } - return nil -} - -// Represents an entry. -type Expr_CreateStruct_Entry struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Required. An id assigned to this node by the parser which is unique - // in a given expression tree. This is used to associate type - // information and other attributes to the node. - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // The `Entry` key kinds. - // - // Types that are assignable to KeyKind: - // - // *Expr_CreateStruct_Entry_FieldKey - // *Expr_CreateStruct_Entry_MapKey - KeyKind isExpr_CreateStruct_Entry_KeyKind `protobuf_oneof:"key_kind"` - // Required. The value assigned to the key. - // - // If the optional_entry field is true, the expression must resolve to an - // optional-typed value. If the optional value is present, the key will be - // set; however, if the optional value is absent, the key will be unset. - Value *Expr `protobuf:"bytes,4,opt,name=value,proto3" json:"value,omitempty"` - // Whether the key-value pair is optional. - OptionalEntry bool `protobuf:"varint,5,opt,name=optional_entry,json=optionalEntry,proto3" json:"optional_entry,omitempty"` -} - -func (x *Expr_CreateStruct_Entry) Reset() { - *x = Expr_CreateStruct_Entry{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_syntax_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Expr_CreateStruct_Entry) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Expr_CreateStruct_Entry) ProtoMessage() {} - -func (x *Expr_CreateStruct_Entry) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_syntax_proto_msgTypes[11] - 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 Expr_CreateStruct_Entry.ProtoReflect.Descriptor instead. -func (*Expr_CreateStruct_Entry) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_syntax_proto_rawDescGZIP(), []int{1, 4, 0} -} - -func (x *Expr_CreateStruct_Entry) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (m *Expr_CreateStruct_Entry) GetKeyKind() isExpr_CreateStruct_Entry_KeyKind { - if m != nil { - return m.KeyKind - } - return nil -} - -func (x *Expr_CreateStruct_Entry) GetFieldKey() string { - if x, ok := x.GetKeyKind().(*Expr_CreateStruct_Entry_FieldKey); ok { - return x.FieldKey - } - return "" -} - -func (x *Expr_CreateStruct_Entry) GetMapKey() *Expr { - if x, ok := x.GetKeyKind().(*Expr_CreateStruct_Entry_MapKey); ok { - return x.MapKey - } - return nil -} - -func (x *Expr_CreateStruct_Entry) GetValue() *Expr { - if x != nil { - return x.Value - } - return nil -} - -func (x *Expr_CreateStruct_Entry) GetOptionalEntry() bool { - if x != nil { - return x.OptionalEntry - } - return false -} - -type isExpr_CreateStruct_Entry_KeyKind interface { - isExpr_CreateStruct_Entry_KeyKind() -} - -type Expr_CreateStruct_Entry_FieldKey struct { - // The field key for a message creator statement. - FieldKey string `protobuf:"bytes,2,opt,name=field_key,json=fieldKey,proto3,oneof"` -} - -type Expr_CreateStruct_Entry_MapKey struct { - // The key expression for a map creation statement. - MapKey *Expr `protobuf:"bytes,3,opt,name=map_key,json=mapKey,proto3,oneof"` -} - -func (*Expr_CreateStruct_Entry_FieldKey) isExpr_CreateStruct_Entry_KeyKind() {} - -func (*Expr_CreateStruct_Entry_MapKey) isExpr_CreateStruct_Entry_KeyKind() {} - -// An extension that was requested for the source expression. -type SourceInfo_Extension struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Identifier for the extension. Example: constant_folding - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - // If set, the listed components must understand the extension for the - // expression to evaluate correctly. - // - // This field has set semantics, repeated values should be deduplicated. - AffectedComponents []SourceInfo_Extension_Component `protobuf:"varint,2,rep,packed,name=affected_components,json=affectedComponents,proto3,enum=google.api.expr.v1alpha1.SourceInfo_Extension_Component" json:"affected_components,omitempty"` - // Version info. May be skipped if it isn't meaningful for the extension. - // (for example constant_folding might always be v0.0). - Version *SourceInfo_Extension_Version `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"` -} - -func (x *SourceInfo_Extension) Reset() { - *x = SourceInfo_Extension{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_syntax_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SourceInfo_Extension) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SourceInfo_Extension) ProtoMessage() {} - -func (x *SourceInfo_Extension) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_syntax_proto_msgTypes[12] - 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 SourceInfo_Extension.ProtoReflect.Descriptor instead. -func (*SourceInfo_Extension) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_syntax_proto_rawDescGZIP(), []int{3, 0} -} - -func (x *SourceInfo_Extension) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *SourceInfo_Extension) GetAffectedComponents() []SourceInfo_Extension_Component { - if x != nil { - return x.AffectedComponents - } - return nil -} - -func (x *SourceInfo_Extension) GetVersion() *SourceInfo_Extension_Version { - if x != nil { - return x.Version - } - return nil -} - -// Version -type SourceInfo_Extension_Version struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Major version changes indicate different required support level from - // the required components. - Major int64 `protobuf:"varint,1,opt,name=major,proto3" json:"major,omitempty"` - // Minor version changes must not change the observed behavior from - // existing implementations, but may be provided informationally. - Minor int64 `protobuf:"varint,2,opt,name=minor,proto3" json:"minor,omitempty"` -} - -func (x *SourceInfo_Extension_Version) Reset() { - *x = SourceInfo_Extension_Version{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_syntax_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SourceInfo_Extension_Version) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SourceInfo_Extension_Version) ProtoMessage() {} - -func (x *SourceInfo_Extension_Version) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_syntax_proto_msgTypes[15] - 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 SourceInfo_Extension_Version.ProtoReflect.Descriptor instead. -func (*SourceInfo_Extension_Version) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_syntax_proto_rawDescGZIP(), []int{3, 0, 0} -} - -func (x *SourceInfo_Extension_Version) GetMajor() int64 { - if x != nil { - return x.Major - } - return 0 -} - -func (x *SourceInfo_Extension_Version) GetMinor() int64 { - if x != nil { - return x.Minor - } - return 0 -} - -var File_google_api_expr_v1alpha1_syntax_proto protoreflect.FileDescriptor - -var file_google_api_expr_v1alpha1_syntax_proto_rawDesc = []byte{ - 0x0a, 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, 0x12, 0x18, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x65, 0x78, 0x70, 0x72, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, - 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x22, 0x87, 0x01, 0x0a, 0x0a, 0x50, 0x61, 0x72, 0x73, 0x65, 0x64, 0x45, 0x78, 0x70, 0x72, 0x12, - 0x32, 0x0a, 0x04, 0x65, 0x78, 0x70, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 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, 0x45, 0x78, 0x70, 0x72, 0x52, 0x04, 0x65, - 0x78, 0x70, 0x72, 0x12, 0x45, 0x0a, 0x0b, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x6e, - 0x66, 0x6f, 0x18, 0x03, 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, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0a, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0xae, 0x0d, 0x0a, 0x04, 0x45, - 0x78, 0x70, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x02, 0x69, 0x64, 0x12, 0x43, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x5f, 0x65, 0x78, 0x70, - 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 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, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x09, 0x63, - 0x6f, 0x6e, 0x73, 0x74, 0x45, 0x78, 0x70, 0x72, 0x12, 0x45, 0x0a, 0x0a, 0x69, 0x64, 0x65, 0x6e, - 0x74, 0x5f, 0x65, 0x78, 0x70, 0x72, 0x18, 0x04, 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, 0x45, 0x78, 0x70, 0x72, 0x2e, 0x49, 0x64, 0x65, - 0x6e, 0x74, 0x48, 0x00, 0x52, 0x09, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x45, 0x78, 0x70, 0x72, 0x12, - 0x48, 0x0a, 0x0b, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x5f, 0x65, 0x78, 0x70, 0x72, 0x18, 0x05, - 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, - 0x45, 0x78, 0x70, 0x72, 0x2e, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x48, 0x00, 0x52, 0x0a, 0x73, - 0x65, 0x6c, 0x65, 0x63, 0x74, 0x45, 0x78, 0x70, 0x72, 0x12, 0x42, 0x0a, 0x09, 0x63, 0x61, 0x6c, - 0x6c, 0x5f, 0x65, 0x78, 0x70, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 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, 0x45, 0x78, 0x70, 0x72, 0x2e, 0x43, 0x61, 0x6c, - 0x6c, 0x48, 0x00, 0x52, 0x08, 0x63, 0x61, 0x6c, 0x6c, 0x45, 0x78, 0x70, 0x72, 0x12, 0x48, 0x0a, - 0x09, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x65, 0x78, 0x70, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x29, 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, 0x45, 0x78, 0x70, 0x72, - 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x48, 0x00, 0x52, 0x08, 0x6c, - 0x69, 0x73, 0x74, 0x45, 0x78, 0x70, 0x72, 0x12, 0x4e, 0x0a, 0x0b, 0x73, 0x74, 0x72, 0x75, 0x63, - 0x74, 0x5f, 0x65, 0x78, 0x70, 0x72, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 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, 0x45, 0x78, 0x70, 0x72, 0x2e, 0x43, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x48, 0x00, 0x52, 0x0a, 0x73, 0x74, 0x72, - 0x75, 0x63, 0x74, 0x45, 0x78, 0x70, 0x72, 0x12, 0x5d, 0x0a, 0x12, 0x63, 0x6f, 0x6d, 0x70, 0x72, - 0x65, 0x68, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x78, 0x70, 0x72, 0x18, 0x09, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x2c, 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, 0x45, - 0x78, 0x70, 0x72, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x68, 0x65, 0x6e, 0x73, 0x69, 0x6f, - 0x6e, 0x48, 0x00, 0x52, 0x11, 0x63, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x68, 0x65, 0x6e, 0x73, 0x69, - 0x6f, 0x6e, 0x45, 0x78, 0x70, 0x72, 0x1a, 0x1b, 0x0a, 0x05, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x12, - 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x1a, 0x75, 0x0a, 0x06, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x12, 0x38, 0x0a, - 0x07, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, - 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, 0x45, 0x78, 0x70, 0x72, 0x52, 0x07, - 0x6f, 0x70, 0x65, 0x72, 0x61, 0x6e, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x1b, 0x0a, - 0x09, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x08, 0x74, 0x65, 0x73, 0x74, 0x4f, 0x6e, 0x6c, 0x79, 0x1a, 0x8e, 0x01, 0x0a, 0x04, 0x43, - 0x61, 0x6c, 0x6c, 0x12, 0x36, 0x0a, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1e, 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, 0x45, - 0x78, 0x70, 0x72, 0x52, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x66, - 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, - 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x04, 0x61, 0x72, 0x67, 0x73, 0x18, - 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 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, 0x45, 0x78, 0x70, 0x72, 0x52, 0x04, 0x61, 0x72, 0x67, 0x73, 0x1a, 0x73, 0x0a, 0x0a, 0x43, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x3a, 0x0a, 0x08, 0x65, 0x6c, 0x65, - 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 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, 0x45, 0x78, 0x70, 0x72, 0x52, 0x08, 0x65, 0x6c, 0x65, - 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x29, 0x0a, 0x10, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, - 0x6c, 0x5f, 0x69, 0x6e, 0x64, 0x69, 0x63, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x05, 0x52, - 0x0f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x49, 0x6e, 0x64, 0x69, 0x63, 0x65, 0x73, - 0x1a, 0xdb, 0x02, 0x0a, 0x0c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x74, 0x72, 0x75, 0x63, - 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x4b, 0x0a, 0x07, 0x65, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x18, - 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x31, 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, 0x45, 0x78, 0x70, 0x72, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x74, 0x72, 0x75, - 0x63, 0x74, 0x2e, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x65, 0x6e, 0x74, 0x72, 0x69, 0x65, - 0x73, 0x1a, 0xda, 0x01, 0x0a, 0x05, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x09, 0x66, - 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, - 0x52, 0x08, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x4b, 0x65, 0x79, 0x12, 0x39, 0x0a, 0x07, 0x6d, 0x61, - 0x70, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 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, 0x45, 0x78, 0x70, 0x72, 0x48, 0x00, 0x52, 0x06, 0x6d, - 0x61, 0x70, 0x4b, 0x65, 0x79, 0x12, 0x34, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 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, - 0x45, 0x78, 0x70, 0x72, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x6f, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x0d, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x42, 0x0a, 0x0a, 0x08, 0x6b, 0x65, 0x79, 0x5f, 0x6b, 0x69, 0x6e, 0x64, 0x1a, 0xfd, - 0x02, 0x0a, 0x0d, 0x43, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x68, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, - 0x12, 0x19, 0x0a, 0x08, 0x69, 0x74, 0x65, 0x72, 0x5f, 0x76, 0x61, 0x72, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x69, 0x74, 0x65, 0x72, 0x56, 0x61, 0x72, 0x12, 0x3d, 0x0a, 0x0a, 0x69, - 0x74, 0x65, 0x72, 0x5f, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1e, 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, 0x45, 0x78, 0x70, 0x72, 0x52, - 0x09, 0x69, 0x74, 0x65, 0x72, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x61, 0x63, - 0x63, 0x75, 0x5f, 0x76, 0x61, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, - 0x63, 0x75, 0x56, 0x61, 0x72, 0x12, 0x3b, 0x0a, 0x09, 0x61, 0x63, 0x63, 0x75, 0x5f, 0x69, 0x6e, - 0x69, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 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, 0x45, 0x78, 0x70, 0x72, 0x52, 0x08, 0x61, 0x63, 0x63, 0x75, 0x49, 0x6e, - 0x69, 0x74, 0x12, 0x45, 0x0a, 0x0e, 0x6c, 0x6f, 0x6f, 0x70, 0x5f, 0x63, 0x6f, 0x6e, 0x64, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 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, 0x45, 0x78, 0x70, 0x72, 0x52, 0x0d, 0x6c, 0x6f, 0x6f, 0x70, - 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x09, 0x6c, 0x6f, 0x6f, - 0x70, 0x5f, 0x73, 0x74, 0x65, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 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, 0x45, 0x78, 0x70, 0x72, 0x52, 0x08, 0x6c, 0x6f, - 0x6f, 0x70, 0x53, 0x74, 0x65, 0x70, 0x12, 0x36, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, - 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 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, 0x45, 0x78, 0x70, 0x72, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x42, 0x0b, - 0x0a, 0x09, 0x65, 0x78, 0x70, 0x72, 0x5f, 0x6b, 0x69, 0x6e, 0x64, 0x22, 0xc1, 0x03, 0x0a, 0x08, - 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x12, 0x3b, 0x0a, 0x0a, 0x6e, 0x75, 0x6c, 0x6c, - 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4e, - 0x75, 0x6c, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x48, 0x00, 0x52, 0x09, 0x6e, 0x75, 0x6c, 0x6c, - 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1f, 0x0a, 0x0a, 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x09, 0x62, 0x6f, 0x6f, - 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0b, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x48, 0x00, 0x52, 0x0a, 0x69, - 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x23, 0x0a, 0x0c, 0x75, 0x69, 0x6e, - 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x48, - 0x00, 0x52, 0x0b, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x23, - 0x0a, 0x0c, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x01, 0x48, 0x00, 0x52, 0x0b, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, - 0x6c, 0x75, 0x65, 0x12, 0x23, 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0b, 0x73, 0x74, 0x72, - 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0b, 0x62, 0x79, 0x74, 0x65, - 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, - 0x0a, 0x62, 0x79, 0x74, 0x65, 0x73, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x46, 0x0a, 0x0e, 0x64, - 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x08, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x02, - 0x18, 0x01, 0x48, 0x00, 0x52, 0x0d, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x61, - 0x6c, 0x75, 0x65, 0x12, 0x49, 0x0a, 0x0f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x02, 0x18, 0x01, 0x48, 0x00, 0x52, 0x0e, - 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x0f, - 0x0a, 0x0d, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x5f, 0x6b, 0x69, 0x6e, 0x64, 0x22, - 0x8c, 0x07, 0x0a, 0x0a, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x25, - 0x0a, 0x0e, 0x73, 0x79, 0x6e, 0x74, 0x61, 0x78, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x79, 0x6e, 0x74, 0x61, 0x78, 0x56, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, - 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x05, 0x52, 0x0b, 0x6c, 0x69, 0x6e, 0x65, 0x4f, 0x66, 0x66, - 0x73, 0x65, 0x74, 0x73, 0x12, 0x51, 0x0a, 0x09, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x33, 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, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x50, 0x6f, - 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x70, 0x6f, - 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x55, 0x0a, 0x0b, 0x6d, 0x61, 0x63, 0x72, 0x6f, - 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x34, 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, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x6e, - 0x66, 0x6f, 0x2e, 0x4d, 0x61, 0x63, 0x72, 0x6f, 0x43, 0x61, 0x6c, 0x6c, 0x73, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x52, 0x0a, 0x6d, 0x61, 0x63, 0x72, 0x6f, 0x43, 0x61, 0x6c, 0x6c, 0x73, 0x12, 0x4e, - 0x0a, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x06, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x2e, 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, 0x53, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, - 0x6f, 0x6e, 0x52, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x80, - 0x03, 0x0a, 0x09, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x69, 0x0a, 0x13, - 0x61, 0x66, 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, 0x5f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, - 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x38, 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, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, - 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, - 0x65, 0x6e, 0x74, 0x52, 0x12, 0x61, 0x66, 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x6d, - 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x50, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x36, 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, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x45, - 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x1a, 0x35, 0x0a, 0x07, 0x56, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x61, 0x6a, 0x6f, 0x72, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x05, 0x6d, 0x61, 0x6a, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x69, - 0x6e, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x6d, 0x69, 0x6e, 0x6f, 0x72, - 0x22, 0x6f, 0x0a, 0x09, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x12, 0x19, 0x0a, - 0x15, 0x43, 0x4f, 0x4d, 0x50, 0x4f, 0x4e, 0x45, 0x4e, 0x54, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, - 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x43, 0x4f, 0x4d, 0x50, - 0x4f, 0x4e, 0x45, 0x4e, 0x54, 0x5f, 0x50, 0x41, 0x52, 0x53, 0x45, 0x52, 0x10, 0x01, 0x12, 0x1a, - 0x0a, 0x16, 0x43, 0x4f, 0x4d, 0x50, 0x4f, 0x4e, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, - 0x5f, 0x43, 0x48, 0x45, 0x43, 0x4b, 0x45, 0x52, 0x10, 0x02, 0x12, 0x15, 0x0a, 0x11, 0x43, 0x4f, - 0x4d, 0x50, 0x4f, 0x4e, 0x45, 0x4e, 0x54, 0x5f, 0x52, 0x55, 0x4e, 0x54, 0x49, 0x4d, 0x45, 0x10, - 0x03, 0x1a, 0x3c, 0x0a, 0x0e, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, - 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, - 0x5d, 0x0a, 0x0f, 0x4d, 0x61, 0x63, 0x72, 0x6f, 0x43, 0x61, 0x6c, 0x6c, 0x73, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x03, 0x6b, 0x65, 0x79, 0x12, 0x34, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1e, 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, 0x45, - 0x78, 0x70, 0x72, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x70, - 0x0a, 0x0e, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x12, 0x1a, 0x0a, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, - 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6f, 0x66, - 0x66, 0x73, 0x65, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6c, 0x75, - 0x6d, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, - 0x42, 0x6e, 0x0a, 0x1c, 0x63, 0x6f, 0x6d, 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, - 0x42, 0x0b, 0x53, 0x79, 0x6e, 0x74, 0x61, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, - 0x3c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, - 0x72, 0x67, 0x2f, 0x67, 0x65, 0x6e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x65, 0x78, 0x70, 0x72, 0x2f, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x65, 0x78, 0x70, 0x72, 0xf8, 0x01, 0x01, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_google_api_expr_v1alpha1_syntax_proto_rawDescOnce sync.Once - file_google_api_expr_v1alpha1_syntax_proto_rawDescData = file_google_api_expr_v1alpha1_syntax_proto_rawDesc -) - -func file_google_api_expr_v1alpha1_syntax_proto_rawDescGZIP() []byte { - file_google_api_expr_v1alpha1_syntax_proto_rawDescOnce.Do(func() { - file_google_api_expr_v1alpha1_syntax_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_api_expr_v1alpha1_syntax_proto_rawDescData) - }) - return file_google_api_expr_v1alpha1_syntax_proto_rawDescData -} - -var file_google_api_expr_v1alpha1_syntax_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_google_api_expr_v1alpha1_syntax_proto_msgTypes = make([]protoimpl.MessageInfo, 16) -var file_google_api_expr_v1alpha1_syntax_proto_goTypes = []interface{}{ - (SourceInfo_Extension_Component)(0), // 0: google.api.expr.v1alpha1.SourceInfo.Extension.Component - (*ParsedExpr)(nil), // 1: google.api.expr.v1alpha1.ParsedExpr - (*Expr)(nil), // 2: google.api.expr.v1alpha1.Expr - (*Constant)(nil), // 3: google.api.expr.v1alpha1.Constant - (*SourceInfo)(nil), // 4: google.api.expr.v1alpha1.SourceInfo - (*SourcePosition)(nil), // 5: google.api.expr.v1alpha1.SourcePosition - (*Expr_Ident)(nil), // 6: google.api.expr.v1alpha1.Expr.Ident - (*Expr_Select)(nil), // 7: google.api.expr.v1alpha1.Expr.Select - (*Expr_Call)(nil), // 8: google.api.expr.v1alpha1.Expr.Call - (*Expr_CreateList)(nil), // 9: google.api.expr.v1alpha1.Expr.CreateList - (*Expr_CreateStruct)(nil), // 10: google.api.expr.v1alpha1.Expr.CreateStruct - (*Expr_Comprehension)(nil), // 11: google.api.expr.v1alpha1.Expr.Comprehension - (*Expr_CreateStruct_Entry)(nil), // 12: google.api.expr.v1alpha1.Expr.CreateStruct.Entry - (*SourceInfo_Extension)(nil), // 13: google.api.expr.v1alpha1.SourceInfo.Extension - nil, // 14: google.api.expr.v1alpha1.SourceInfo.PositionsEntry - nil, // 15: google.api.expr.v1alpha1.SourceInfo.MacroCallsEntry - (*SourceInfo_Extension_Version)(nil), // 16: google.api.expr.v1alpha1.SourceInfo.Extension.Version - (structpb.NullValue)(0), // 17: google.protobuf.NullValue - (*durationpb.Duration)(nil), // 18: google.protobuf.Duration - (*timestamppb.Timestamp)(nil), // 19: google.protobuf.Timestamp -} -var file_google_api_expr_v1alpha1_syntax_proto_depIdxs = []int32{ - 2, // 0: google.api.expr.v1alpha1.ParsedExpr.expr:type_name -> google.api.expr.v1alpha1.Expr - 4, // 1: google.api.expr.v1alpha1.ParsedExpr.source_info:type_name -> google.api.expr.v1alpha1.SourceInfo - 3, // 2: google.api.expr.v1alpha1.Expr.const_expr:type_name -> google.api.expr.v1alpha1.Constant - 6, // 3: google.api.expr.v1alpha1.Expr.ident_expr:type_name -> google.api.expr.v1alpha1.Expr.Ident - 7, // 4: google.api.expr.v1alpha1.Expr.select_expr:type_name -> google.api.expr.v1alpha1.Expr.Select - 8, // 5: google.api.expr.v1alpha1.Expr.call_expr:type_name -> google.api.expr.v1alpha1.Expr.Call - 9, // 6: google.api.expr.v1alpha1.Expr.list_expr:type_name -> google.api.expr.v1alpha1.Expr.CreateList - 10, // 7: google.api.expr.v1alpha1.Expr.struct_expr:type_name -> google.api.expr.v1alpha1.Expr.CreateStruct - 11, // 8: google.api.expr.v1alpha1.Expr.comprehension_expr:type_name -> google.api.expr.v1alpha1.Expr.Comprehension - 17, // 9: google.api.expr.v1alpha1.Constant.null_value:type_name -> google.protobuf.NullValue - 18, // 10: google.api.expr.v1alpha1.Constant.duration_value:type_name -> google.protobuf.Duration - 19, // 11: google.api.expr.v1alpha1.Constant.timestamp_value:type_name -> google.protobuf.Timestamp - 14, // 12: google.api.expr.v1alpha1.SourceInfo.positions:type_name -> google.api.expr.v1alpha1.SourceInfo.PositionsEntry - 15, // 13: google.api.expr.v1alpha1.SourceInfo.macro_calls:type_name -> google.api.expr.v1alpha1.SourceInfo.MacroCallsEntry - 13, // 14: google.api.expr.v1alpha1.SourceInfo.extensions:type_name -> google.api.expr.v1alpha1.SourceInfo.Extension - 2, // 15: google.api.expr.v1alpha1.Expr.Select.operand:type_name -> google.api.expr.v1alpha1.Expr - 2, // 16: google.api.expr.v1alpha1.Expr.Call.target:type_name -> google.api.expr.v1alpha1.Expr - 2, // 17: google.api.expr.v1alpha1.Expr.Call.args:type_name -> google.api.expr.v1alpha1.Expr - 2, // 18: google.api.expr.v1alpha1.Expr.CreateList.elements:type_name -> google.api.expr.v1alpha1.Expr - 12, // 19: google.api.expr.v1alpha1.Expr.CreateStruct.entries:type_name -> google.api.expr.v1alpha1.Expr.CreateStruct.Entry - 2, // 20: google.api.expr.v1alpha1.Expr.Comprehension.iter_range:type_name -> google.api.expr.v1alpha1.Expr - 2, // 21: google.api.expr.v1alpha1.Expr.Comprehension.accu_init:type_name -> google.api.expr.v1alpha1.Expr - 2, // 22: google.api.expr.v1alpha1.Expr.Comprehension.loop_condition:type_name -> google.api.expr.v1alpha1.Expr - 2, // 23: google.api.expr.v1alpha1.Expr.Comprehension.loop_step:type_name -> google.api.expr.v1alpha1.Expr - 2, // 24: google.api.expr.v1alpha1.Expr.Comprehension.result:type_name -> google.api.expr.v1alpha1.Expr - 2, // 25: google.api.expr.v1alpha1.Expr.CreateStruct.Entry.map_key:type_name -> google.api.expr.v1alpha1.Expr - 2, // 26: google.api.expr.v1alpha1.Expr.CreateStruct.Entry.value:type_name -> google.api.expr.v1alpha1.Expr - 0, // 27: google.api.expr.v1alpha1.SourceInfo.Extension.affected_components:type_name -> google.api.expr.v1alpha1.SourceInfo.Extension.Component - 16, // 28: google.api.expr.v1alpha1.SourceInfo.Extension.version:type_name -> google.api.expr.v1alpha1.SourceInfo.Extension.Version - 2, // 29: google.api.expr.v1alpha1.SourceInfo.MacroCallsEntry.value:type_name -> google.api.expr.v1alpha1.Expr - 30, // [30:30] is the sub-list for method output_type - 30, // [30:30] is the sub-list for method input_type - 30, // [30:30] is the sub-list for extension type_name - 30, // [30:30] is the sub-list for extension extendee - 0, // [0:30] is the sub-list for field type_name -} - -func init() { file_google_api_expr_v1alpha1_syntax_proto_init() } -func file_google_api_expr_v1alpha1_syntax_proto_init() { - if File_google_api_expr_v1alpha1_syntax_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_google_api_expr_v1alpha1_syntax_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ParsedExpr); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_syntax_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Expr); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_syntax_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Constant); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_syntax_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SourceInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_syntax_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SourcePosition); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_syntax_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Expr_Ident); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_syntax_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Expr_Select); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_syntax_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Expr_Call); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_syntax_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Expr_CreateList); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_syntax_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Expr_CreateStruct); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_syntax_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Expr_Comprehension); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_syntax_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Expr_CreateStruct_Entry); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_syntax_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SourceInfo_Extension); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_syntax_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SourceInfo_Extension_Version); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_google_api_expr_v1alpha1_syntax_proto_msgTypes[1].OneofWrappers = []interface{}{ - (*Expr_ConstExpr)(nil), - (*Expr_IdentExpr)(nil), - (*Expr_SelectExpr)(nil), - (*Expr_CallExpr)(nil), - (*Expr_ListExpr)(nil), - (*Expr_StructExpr)(nil), - (*Expr_ComprehensionExpr)(nil), - } - file_google_api_expr_v1alpha1_syntax_proto_msgTypes[2].OneofWrappers = []interface{}{ - (*Constant_NullValue)(nil), - (*Constant_BoolValue)(nil), - (*Constant_Int64Value)(nil), - (*Constant_Uint64Value)(nil), - (*Constant_DoubleValue)(nil), - (*Constant_StringValue)(nil), - (*Constant_BytesValue)(nil), - (*Constant_DurationValue)(nil), - (*Constant_TimestampValue)(nil), - } - file_google_api_expr_v1alpha1_syntax_proto_msgTypes[11].OneofWrappers = []interface{}{ - (*Expr_CreateStruct_Entry_FieldKey)(nil), - (*Expr_CreateStruct_Entry_MapKey)(nil), - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_google_api_expr_v1alpha1_syntax_proto_rawDesc, - NumEnums: 1, - NumMessages: 16, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_google_api_expr_v1alpha1_syntax_proto_goTypes, - DependencyIndexes: file_google_api_expr_v1alpha1_syntax_proto_depIdxs, - EnumInfos: file_google_api_expr_v1alpha1_syntax_proto_enumTypes, - MessageInfos: file_google_api_expr_v1alpha1_syntax_proto_msgTypes, - }.Build() - File_google_api_expr_v1alpha1_syntax_proto = out.File - file_google_api_expr_v1alpha1_syntax_proto_rawDesc = nil - file_google_api_expr_v1alpha1_syntax_proto_goTypes = nil - file_google_api_expr_v1alpha1_syntax_proto_depIdxs = nil -} diff --git a/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/value.pb.go b/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/value.pb.go deleted file mode 100644 index 033f23868..000000000 --- a/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/value.pb.go +++ /dev/null @@ -1,721 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.26.0 -// protoc v4.24.4 -// source: google/api/expr/v1alpha1/value.proto - -package expr - -import ( - reflect "reflect" - sync "sync" - - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - anypb "google.golang.org/protobuf/types/known/anypb" - structpb "google.golang.org/protobuf/types/known/structpb" -) - -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) -) - -// Represents a CEL value. -// -// This is similar to `google.protobuf.Value`, but can represent CEL's full -// range of values. -type Value struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Required. The valid kinds of values. - // - // Types that are assignable to Kind: - // - // *Value_NullValue - // *Value_BoolValue - // *Value_Int64Value - // *Value_Uint64Value - // *Value_DoubleValue - // *Value_StringValue - // *Value_BytesValue - // *Value_EnumValue - // *Value_ObjectValue - // *Value_MapValue - // *Value_ListValue - // *Value_TypeValue - Kind isValue_Kind `protobuf_oneof:"kind"` -} - -func (x *Value) Reset() { - *x = Value{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_value_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Value) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Value) ProtoMessage() {} - -func (x *Value) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_value_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 Value.ProtoReflect.Descriptor instead. -func (*Value) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_value_proto_rawDescGZIP(), []int{0} -} - -func (m *Value) GetKind() isValue_Kind { - if m != nil { - return m.Kind - } - return nil -} - -func (x *Value) GetNullValue() structpb.NullValue { - if x, ok := x.GetKind().(*Value_NullValue); ok { - return x.NullValue - } - return structpb.NullValue_NULL_VALUE -} - -func (x *Value) GetBoolValue() bool { - if x, ok := x.GetKind().(*Value_BoolValue); ok { - return x.BoolValue - } - return false -} - -func (x *Value) GetInt64Value() int64 { - if x, ok := x.GetKind().(*Value_Int64Value); ok { - return x.Int64Value - } - return 0 -} - -func (x *Value) GetUint64Value() uint64 { - if x, ok := x.GetKind().(*Value_Uint64Value); ok { - return x.Uint64Value - } - return 0 -} - -func (x *Value) GetDoubleValue() float64 { - if x, ok := x.GetKind().(*Value_DoubleValue); ok { - return x.DoubleValue - } - return 0 -} - -func (x *Value) GetStringValue() string { - if x, ok := x.GetKind().(*Value_StringValue); ok { - return x.StringValue - } - return "" -} - -func (x *Value) GetBytesValue() []byte { - if x, ok := x.GetKind().(*Value_BytesValue); ok { - return x.BytesValue - } - return nil -} - -func (x *Value) GetEnumValue() *EnumValue { - if x, ok := x.GetKind().(*Value_EnumValue); ok { - return x.EnumValue - } - return nil -} - -func (x *Value) GetObjectValue() *anypb.Any { - if x, ok := x.GetKind().(*Value_ObjectValue); ok { - return x.ObjectValue - } - return nil -} - -func (x *Value) GetMapValue() *MapValue { - if x, ok := x.GetKind().(*Value_MapValue); ok { - return x.MapValue - } - return nil -} - -func (x *Value) GetListValue() *ListValue { - if x, ok := x.GetKind().(*Value_ListValue); ok { - return x.ListValue - } - return nil -} - -func (x *Value) GetTypeValue() string { - if x, ok := x.GetKind().(*Value_TypeValue); ok { - return x.TypeValue - } - return "" -} - -type isValue_Kind interface { - isValue_Kind() -} - -type Value_NullValue struct { - // Null value. - NullValue structpb.NullValue `protobuf:"varint,1,opt,name=null_value,json=nullValue,proto3,enum=google.protobuf.NullValue,oneof"` -} - -type Value_BoolValue struct { - // Boolean value. - BoolValue bool `protobuf:"varint,2,opt,name=bool_value,json=boolValue,proto3,oneof"` -} - -type Value_Int64Value struct { - // Signed integer value. - Int64Value int64 `protobuf:"varint,3,opt,name=int64_value,json=int64Value,proto3,oneof"` -} - -type Value_Uint64Value struct { - // Unsigned integer value. - Uint64Value uint64 `protobuf:"varint,4,opt,name=uint64_value,json=uint64Value,proto3,oneof"` -} - -type Value_DoubleValue struct { - // Floating point value. - DoubleValue float64 `protobuf:"fixed64,5,opt,name=double_value,json=doubleValue,proto3,oneof"` -} - -type Value_StringValue struct { - // UTF-8 string value. - StringValue string `protobuf:"bytes,6,opt,name=string_value,json=stringValue,proto3,oneof"` -} - -type Value_BytesValue struct { - // Byte string value. - BytesValue []byte `protobuf:"bytes,7,opt,name=bytes_value,json=bytesValue,proto3,oneof"` -} - -type Value_EnumValue struct { - // An enum value. - EnumValue *EnumValue `protobuf:"bytes,9,opt,name=enum_value,json=enumValue,proto3,oneof"` -} - -type Value_ObjectValue struct { - // The proto message backing an object value. - ObjectValue *anypb.Any `protobuf:"bytes,10,opt,name=object_value,json=objectValue,proto3,oneof"` -} - -type Value_MapValue struct { - // Map value. - MapValue *MapValue `protobuf:"bytes,11,opt,name=map_value,json=mapValue,proto3,oneof"` -} - -type Value_ListValue struct { - // List value. - ListValue *ListValue `protobuf:"bytes,12,opt,name=list_value,json=listValue,proto3,oneof"` -} - -type Value_TypeValue struct { - // Type value. - TypeValue string `protobuf:"bytes,15,opt,name=type_value,json=typeValue,proto3,oneof"` -} - -func (*Value_NullValue) isValue_Kind() {} - -func (*Value_BoolValue) isValue_Kind() {} - -func (*Value_Int64Value) isValue_Kind() {} - -func (*Value_Uint64Value) isValue_Kind() {} - -func (*Value_DoubleValue) isValue_Kind() {} - -func (*Value_StringValue) isValue_Kind() {} - -func (*Value_BytesValue) isValue_Kind() {} - -func (*Value_EnumValue) isValue_Kind() {} - -func (*Value_ObjectValue) isValue_Kind() {} - -func (*Value_MapValue) isValue_Kind() {} - -func (*Value_ListValue) isValue_Kind() {} - -func (*Value_TypeValue) isValue_Kind() {} - -// An enum value. -type EnumValue struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The fully qualified name of the enum type. - Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` - // The value of the enum. - Value int32 `protobuf:"varint,2,opt,name=value,proto3" json:"value,omitempty"` -} - -func (x *EnumValue) Reset() { - *x = EnumValue{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_value_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *EnumValue) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*EnumValue) ProtoMessage() {} - -func (x *EnumValue) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_value_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 EnumValue.ProtoReflect.Descriptor instead. -func (*EnumValue) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_value_proto_rawDescGZIP(), []int{1} -} - -func (x *EnumValue) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *EnumValue) GetValue() int32 { - if x != nil { - return x.Value - } - return 0 -} - -// A list. -// -// Wrapped in a message so 'not set' and empty can be differentiated, which is -// required for use in a 'oneof'. -type ListValue struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The ordered values in the list. - Values []*Value `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"` -} - -func (x *ListValue) Reset() { - *x = ListValue{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_value_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListValue) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListValue) ProtoMessage() {} - -func (x *ListValue) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_value_proto_msgTypes[2] - 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 ListValue.ProtoReflect.Descriptor instead. -func (*ListValue) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_value_proto_rawDescGZIP(), []int{2} -} - -func (x *ListValue) GetValues() []*Value { - if x != nil { - return x.Values - } - return nil -} - -// A map. -// -// Wrapped in a message so 'not set' and empty can be differentiated, which is -// required for use in a 'oneof'. -type MapValue struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The set of map entries. - // - // CEL has fewer restrictions on keys, so a protobuf map represenation - // cannot be used. - Entries []*MapValue_Entry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"` -} - -func (x *MapValue) Reset() { - *x = MapValue{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_value_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *MapValue) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*MapValue) ProtoMessage() {} - -func (x *MapValue) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_value_proto_msgTypes[3] - 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 MapValue.ProtoReflect.Descriptor instead. -func (*MapValue) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_value_proto_rawDescGZIP(), []int{3} -} - -func (x *MapValue) GetEntries() []*MapValue_Entry { - if x != nil { - return x.Entries - } - return nil -} - -// An entry in the map. -type MapValue_Entry struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The key. - // - // Must be unique with in the map. - // Currently only boolean, int, uint, and string values can be keys. - Key *Value `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - // The value. - Value *Value `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` -} - -func (x *MapValue_Entry) Reset() { - *x = MapValue_Entry{} - if protoimpl.UnsafeEnabled { - mi := &file_google_api_expr_v1alpha1_value_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *MapValue_Entry) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*MapValue_Entry) ProtoMessage() {} - -func (x *MapValue_Entry) ProtoReflect() protoreflect.Message { - mi := &file_google_api_expr_v1alpha1_value_proto_msgTypes[4] - 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 MapValue_Entry.ProtoReflect.Descriptor instead. -func (*MapValue_Entry) Descriptor() ([]byte, []int) { - return file_google_api_expr_v1alpha1_value_proto_rawDescGZIP(), []int{3, 0} -} - -func (x *MapValue_Entry) GetKey() *Value { - if x != nil { - return x.Key - } - return nil -} - -func (x *MapValue_Entry) GetValue() *Value { - if x != nil { - return x.Value - } - return nil -} - -var File_google_api_expr_v1alpha1_value_proto protoreflect.FileDescriptor - -var file_google_api_expr_v1alpha1_value_proto_rawDesc = []byte{ - 0x0a, 0x24, 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, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x18, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x65, 0x78, 0x70, 0x72, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, - 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xcd, 0x04, 0x0a, 0x05, 0x56, 0x61, - 0x6c, 0x75, 0x65, 0x12, 0x3b, 0x0a, 0x0a, 0x6e, 0x75, 0x6c, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4e, 0x75, 0x6c, 0x6c, 0x56, 0x61, - 0x6c, 0x75, 0x65, 0x48, 0x00, 0x52, 0x09, 0x6e, 0x75, 0x6c, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, - 0x12, 0x1f, 0x0a, 0x0a, 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x09, 0x62, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, - 0x65, 0x12, 0x21, 0x0a, 0x0b, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x48, 0x00, 0x52, 0x0a, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x56, - 0x61, 0x6c, 0x75, 0x65, 0x12, 0x23, 0x0a, 0x0c, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x48, 0x00, 0x52, 0x0b, 0x75, 0x69, - 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x23, 0x0a, 0x0c, 0x64, 0x6f, 0x75, - 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x01, 0x48, - 0x00, 0x52, 0x0b, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x23, - 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x06, - 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, - 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0b, 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x0a, 0x62, 0x79, 0x74, 0x65, - 0x73, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x44, 0x0a, 0x0a, 0x65, 0x6e, 0x75, 0x6d, 0x5f, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 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, 0x45, 0x6e, 0x75, 0x6d, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x48, - 0x00, 0x52, 0x09, 0x65, 0x6e, 0x75, 0x6d, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x39, 0x0a, 0x0c, - 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0a, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x48, 0x00, 0x52, 0x0b, 0x6f, 0x62, 0x6a, 0x65, - 0x63, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x41, 0x0a, 0x09, 0x6d, 0x61, 0x70, 0x5f, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 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, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x48, 0x00, - 0x52, 0x08, 0x6d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x44, 0x0a, 0x0a, 0x6c, 0x69, - 0x73, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, - 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, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x61, - 0x6c, 0x75, 0x65, 0x48, 0x00, 0x52, 0x09, 0x6c, 0x69, 0x73, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, - 0x12, 0x1f, 0x0a, 0x0a, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0f, - 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x09, 0x74, 0x79, 0x70, 0x65, 0x56, 0x61, 0x6c, 0x75, - 0x65, 0x42, 0x06, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x22, 0x35, 0x0a, 0x09, 0x45, 0x6e, 0x75, - 0x6d, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x22, 0x44, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x37, 0x0a, - 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 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, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x06, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x22, 0xc1, 0x01, 0x0a, 0x08, 0x4d, 0x61, 0x70, 0x56, 0x61, - 0x6c, 0x75, 0x65, 0x12, 0x42, 0x0a, 0x07, 0x65, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 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, - 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x2e, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, - 0x65, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x1a, 0x71, 0x0a, 0x05, 0x45, 0x6e, 0x74, 0x72, 0x79, - 0x12, 0x31, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 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, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x03, - 0x6b, 0x65, 0x79, 0x12, 0x35, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1f, 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, 0x56, 0x61, - 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x6d, 0x0a, 0x1c, 0x63, 0x6f, - 0x6d, 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, 0x42, 0x0a, 0x56, 0x61, 0x6c, 0x75, - 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x67, 0x65, 0x6e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x61, 0x70, 0x69, 0x73, 0x2f, - 0x61, 0x70, 0x69, 0x2f, 0x65, 0x78, 0x70, 0x72, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x3b, 0x65, 0x78, 0x70, 0x72, 0xf8, 0x01, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, -} - -var ( - file_google_api_expr_v1alpha1_value_proto_rawDescOnce sync.Once - file_google_api_expr_v1alpha1_value_proto_rawDescData = file_google_api_expr_v1alpha1_value_proto_rawDesc -) - -func file_google_api_expr_v1alpha1_value_proto_rawDescGZIP() []byte { - file_google_api_expr_v1alpha1_value_proto_rawDescOnce.Do(func() { - file_google_api_expr_v1alpha1_value_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_api_expr_v1alpha1_value_proto_rawDescData) - }) - return file_google_api_expr_v1alpha1_value_proto_rawDescData -} - -var file_google_api_expr_v1alpha1_value_proto_msgTypes = make([]protoimpl.MessageInfo, 5) -var file_google_api_expr_v1alpha1_value_proto_goTypes = []interface{}{ - (*Value)(nil), // 0: google.api.expr.v1alpha1.Value - (*EnumValue)(nil), // 1: google.api.expr.v1alpha1.EnumValue - (*ListValue)(nil), // 2: google.api.expr.v1alpha1.ListValue - (*MapValue)(nil), // 3: google.api.expr.v1alpha1.MapValue - (*MapValue_Entry)(nil), // 4: google.api.expr.v1alpha1.MapValue.Entry - (structpb.NullValue)(0), // 5: google.protobuf.NullValue - (*anypb.Any)(nil), // 6: google.protobuf.Any -} -var file_google_api_expr_v1alpha1_value_proto_depIdxs = []int32{ - 5, // 0: google.api.expr.v1alpha1.Value.null_value:type_name -> google.protobuf.NullValue - 1, // 1: google.api.expr.v1alpha1.Value.enum_value:type_name -> google.api.expr.v1alpha1.EnumValue - 6, // 2: google.api.expr.v1alpha1.Value.object_value:type_name -> google.protobuf.Any - 3, // 3: google.api.expr.v1alpha1.Value.map_value:type_name -> google.api.expr.v1alpha1.MapValue - 2, // 4: google.api.expr.v1alpha1.Value.list_value:type_name -> google.api.expr.v1alpha1.ListValue - 0, // 5: google.api.expr.v1alpha1.ListValue.values:type_name -> google.api.expr.v1alpha1.Value - 4, // 6: google.api.expr.v1alpha1.MapValue.entries:type_name -> google.api.expr.v1alpha1.MapValue.Entry - 0, // 7: google.api.expr.v1alpha1.MapValue.Entry.key:type_name -> google.api.expr.v1alpha1.Value - 0, // 8: google.api.expr.v1alpha1.MapValue.Entry.value:type_name -> google.api.expr.v1alpha1.Value - 9, // [9:9] is the sub-list for method output_type - 9, // [9:9] is the sub-list for method input_type - 9, // [9:9] is the sub-list for extension type_name - 9, // [9:9] is the sub-list for extension extendee - 0, // [0:9] is the sub-list for field type_name -} - -func init() { file_google_api_expr_v1alpha1_value_proto_init() } -func file_google_api_expr_v1alpha1_value_proto_init() { - if File_google_api_expr_v1alpha1_value_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_google_api_expr_v1alpha1_value_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Value); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_value_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*EnumValue); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_value_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListValue); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_value_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MapValue); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_api_expr_v1alpha1_value_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MapValue_Entry); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_google_api_expr_v1alpha1_value_proto_msgTypes[0].OneofWrappers = []interface{}{ - (*Value_NullValue)(nil), - (*Value_BoolValue)(nil), - (*Value_Int64Value)(nil), - (*Value_Uint64Value)(nil), - (*Value_DoubleValue)(nil), - (*Value_StringValue)(nil), - (*Value_BytesValue)(nil), - (*Value_EnumValue)(nil), - (*Value_ObjectValue)(nil), - (*Value_MapValue)(nil), - (*Value_ListValue)(nil), - (*Value_TypeValue)(nil), - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_google_api_expr_v1alpha1_value_proto_rawDesc, - NumEnums: 0, - NumMessages: 5, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_google_api_expr_v1alpha1_value_proto_goTypes, - DependencyIndexes: file_google_api_expr_v1alpha1_value_proto_depIdxs, - MessageInfos: file_google_api_expr_v1alpha1_value_proto_msgTypes, - }.Build() - File_google_api_expr_v1alpha1_value_proto = out.File - file_google_api_expr_v1alpha1_value_proto_rawDesc = nil - file_google_api_expr_v1alpha1_value_proto_goTypes = nil - file_google_api_expr_v1alpha1_value_proto_depIdxs = nil -} diff --git a/vendor/google.golang.org/genproto/googleapis/rpc/LICENSE b/vendor/google.golang.org/genproto/googleapis/rpc/LICENSE deleted file mode 100644 index d64569567..000000000 --- a/vendor/google.golang.org/genproto/googleapis/rpc/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/google.golang.org/genproto/googleapis/rpc/status/status.pb.go b/vendor/google.golang.org/genproto/googleapis/rpc/status/status.pb.go deleted file mode 100644 index a6b508188..000000000 --- a/vendor/google.golang.org/genproto/googleapis/rpc/status/status.pb.go +++ /dev/null @@ -1,203 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.26.0 -// protoc v3.21.9 -// source: google/rpc/status.proto - -package status - -import ( - reflect "reflect" - sync "sync" - - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - anypb "google.golang.org/protobuf/types/known/anypb" -) - -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) -) - -// The `Status` type defines a logical error model that is suitable for -// different programming environments, including REST APIs and RPC APIs. It is -// used by [gRPC](https://github.com/grpc). Each `Status` message contains -// three pieces of data: error code, error message, and error details. -// -// You can find out more about this error model and how to work with it in the -// [API Design Guide](https://cloud.google.com/apis/design/errors). -type Status struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The status code, which should be an enum value of - // [google.rpc.Code][google.rpc.Code]. - Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` - // A developer-facing error message, which should be in English. Any - // user-facing error message should be localized and sent in the - // [google.rpc.Status.details][google.rpc.Status.details] field, or localized - // by the client. - Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` - // A list of messages that carry the error details. There is a common set of - // message types for APIs to use. - Details []*anypb.Any `protobuf:"bytes,3,rep,name=details,proto3" json:"details,omitempty"` -} - -func (x *Status) Reset() { - *x = Status{} - if protoimpl.UnsafeEnabled { - mi := &file_google_rpc_status_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Status) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Status) ProtoMessage() {} - -func (x *Status) ProtoReflect() protoreflect.Message { - mi := &file_google_rpc_status_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 Status.ProtoReflect.Descriptor instead. -func (*Status) Descriptor() ([]byte, []int) { - return file_google_rpc_status_proto_rawDescGZIP(), []int{0} -} - -func (x *Status) GetCode() int32 { - if x != nil { - return x.Code - } - return 0 -} - -func (x *Status) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -func (x *Status) GetDetails() []*anypb.Any { - if x != nil { - return x.Details - } - return nil -} - -var File_google_rpc_status_proto protoreflect.FileDescriptor - -var file_google_rpc_status_proto_rawDesc = []byte{ - 0x0a, 0x17, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x72, 0x70, 0x63, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x22, 0x66, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, - 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18, - 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x2e, 0x0a, 0x07, 0x64, 0x65, 0x74, 0x61, - 0x69, 0x6c, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, - 0x07, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x42, 0x61, 0x0a, 0x0e, 0x63, 0x6f, 0x6d, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x72, 0x70, 0x63, 0x42, 0x0b, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x37, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x67, 0x65, 0x6e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x61, 0x70, 0x69, 0x73, - 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x3b, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0xf8, 0x01, 0x01, 0xa2, 0x02, 0x03, 0x52, 0x50, 0x43, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, -} - -var ( - file_google_rpc_status_proto_rawDescOnce sync.Once - file_google_rpc_status_proto_rawDescData = file_google_rpc_status_proto_rawDesc -) - -func file_google_rpc_status_proto_rawDescGZIP() []byte { - file_google_rpc_status_proto_rawDescOnce.Do(func() { - file_google_rpc_status_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_rpc_status_proto_rawDescData) - }) - return file_google_rpc_status_proto_rawDescData -} - -var file_google_rpc_status_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_google_rpc_status_proto_goTypes = []interface{}{ - (*Status)(nil), // 0: google.rpc.Status - (*anypb.Any)(nil), // 1: google.protobuf.Any -} -var file_google_rpc_status_proto_depIdxs = []int32{ - 1, // 0: google.rpc.Status.details:type_name -> google.protobuf.Any - 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_google_rpc_status_proto_init() } -func file_google_rpc_status_proto_init() { - if File_google_rpc_status_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_google_rpc_status_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Status); 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_google_rpc_status_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_google_rpc_status_proto_goTypes, - DependencyIndexes: file_google_rpc_status_proto_depIdxs, - MessageInfos: file_google_rpc_status_proto_msgTypes, - }.Build() - File_google_rpc_status_proto = out.File - file_google_rpc_status_proto_rawDesc = nil - file_google_rpc_status_proto_goTypes = nil - file_google_rpc_status_proto_depIdxs = nil -} diff --git a/vendor/google.golang.org/grpc/AUTHORS b/vendor/google.golang.org/grpc/AUTHORS deleted file mode 100644 index e491a9e7f..000000000 --- a/vendor/google.golang.org/grpc/AUTHORS +++ /dev/null @@ -1 +0,0 @@ -Google Inc. diff --git a/vendor/google.golang.org/grpc/CODE-OF-CONDUCT.md b/vendor/google.golang.org/grpc/CODE-OF-CONDUCT.md deleted file mode 100644 index 9d4213ebc..000000000 --- a/vendor/google.golang.org/grpc/CODE-OF-CONDUCT.md +++ /dev/null @@ -1,3 +0,0 @@ -## Community Code of Conduct - -gRPC follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md). diff --git a/vendor/google.golang.org/grpc/CONTRIBUTING.md b/vendor/google.golang.org/grpc/CONTRIBUTING.md deleted file mode 100644 index 608aa6e1a..000000000 --- a/vendor/google.golang.org/grpc/CONTRIBUTING.md +++ /dev/null @@ -1,73 +0,0 @@ -# How to contribute - -We definitely welcome your patches and contributions to gRPC! Please read the gRPC -organization's [governance rules](https://github.com/grpc/grpc-community/blob/master/governance.md) -and [contribution guidelines](https://github.com/grpc/grpc-community/blob/master/CONTRIBUTING.md) before proceeding. - -If you are new to github, please start by reading [Pull Request howto](https://help.github.com/articles/about-pull-requests/) - -## Legal requirements - -In order to protect both you and ourselves, you will need to sign the -[Contributor License Agreement](https://identity.linuxfoundation.org/projects/cncf). - -## Guidelines for Pull Requests -How to get your contributions merged smoothly and quickly. - -- Create **small PRs** that are narrowly focused on **addressing a single - concern**. We often times receive PRs that are trying to fix several things at - a time, but only one fix is considered acceptable, nothing gets merged and - both author's & review's time is wasted. Create more PRs to address different - concerns and everyone will be happy. - -- If you are searching for features to work on, issues labeled [Status: Help - Wanted](https://github.com/grpc/grpc-go/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22Status%3A+Help+Wanted%22) - is a great place to start. These issues are well-documented and usually can be - resolved with a single pull request. - -- If you are adding a new file, make sure it has the copyright message template - at the top as a comment. You can copy over the message from an existing file - and update the year. - -- The grpc package should only depend on standard Go packages and a small number - of exceptions. If your contribution introduces new dependencies which are NOT - in the [list](https://godoc.org/google.golang.org/grpc?imports), you need a - discussion with gRPC-Go authors and consultants. - -- For speculative changes, consider opening an issue and discussing it first. If - you are suggesting a behavioral or API change, consider starting with a [gRFC - proposal](https://github.com/grpc/proposal). - -- Provide a good **PR description** as a record of **what** change is being made - and **why** it was made. Link to a github issue if it exists. - -- If you want to fix formatting or style, consider whether your changes are an - obvious improvement or might be considered a personal preference. If a style - change is based on preference, it likely will not be accepted. If it corrects - widely agreed-upon anti-patterns, then please do create a PR and explain the - benefits of the change. - -- Unless your PR is trivial, you should expect there will be reviewer comments - that you'll need to address before merging. We'll mark it as `Status: Requires - Reporter Clarification` if we expect you to respond to these comments in a - timely manner. If the PR remains inactive for 6 days, it will be marked as - `stale` and automatically close 7 days after that if we don't hear back from - you. - -- Maintain **clean commit history** and use **meaningful commit messages**. PRs - with messy commit history are difficult to review and won't be merged. Use - `rebase -i upstream/master` to curate your commit history and/or to bring in - latest changes from master (but avoid rebasing in the middle of a code - review). - -- Keep your PR up to date with upstream/master (if there are merge conflicts, we - can't really merge your change). - -- **All tests need to be passing** before your change can be merged. We - recommend you **run tests locally** before creating your PR to catch breakages - early on. - - `VET_SKIP_PROTO=1 ./vet.sh` to catch vet errors - - `go test -cpu 1,4 -timeout 7m ./...` to run the tests - - `go test -race -cpu 1,4 -timeout 7m ./...` to run tests in race mode - -- Exceptions to the rules can be made if there's a compelling reason for doing so. diff --git a/vendor/google.golang.org/grpc/GOVERNANCE.md b/vendor/google.golang.org/grpc/GOVERNANCE.md deleted file mode 100644 index d6ff26747..000000000 --- a/vendor/google.golang.org/grpc/GOVERNANCE.md +++ /dev/null @@ -1 +0,0 @@ -This repository is governed by the gRPC organization's [governance rules](https://github.com/grpc/grpc-community/blob/master/governance.md). diff --git a/vendor/google.golang.org/grpc/LICENSE b/vendor/google.golang.org/grpc/LICENSE deleted file mode 100644 index d64569567..000000000 --- a/vendor/google.golang.org/grpc/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/google.golang.org/grpc/MAINTAINERS.md b/vendor/google.golang.org/grpc/MAINTAINERS.md deleted file mode 100644 index c6672c0a3..000000000 --- a/vendor/google.golang.org/grpc/MAINTAINERS.md +++ /dev/null @@ -1,28 +0,0 @@ -This page lists all active maintainers of this repository. If you were a -maintainer and would like to add your name to the Emeritus list, please send us a -PR. - -See [GOVERNANCE.md](https://github.com/grpc/grpc-community/blob/master/governance.md) -for governance guidelines and how to become a maintainer. -See [CONTRIBUTING.md](https://github.com/grpc/grpc-community/blob/master/CONTRIBUTING.md) -for general contribution guidelines. - -## Maintainers (in alphabetical order) - -- [cesarghali](https://github.com/cesarghali), Google LLC -- [dfawley](https://github.com/dfawley), Google LLC -- [easwars](https://github.com/easwars), Google LLC -- [menghanl](https://github.com/menghanl), Google LLC -- [srini100](https://github.com/srini100), Google LLC - -## Emeritus Maintainers (in alphabetical order) -- [adelez](https://github.com/adelez), Google LLC -- [canguler](https://github.com/canguler), Google LLC -- [iamqizhao](https://github.com/iamqizhao), Google LLC -- [jadekler](https://github.com/jadekler), Google LLC -- [jtattermusch](https://github.com/jtattermusch), Google LLC -- [lyuxuan](https://github.com/lyuxuan), Google LLC -- [makmukhi](https://github.com/makmukhi), Google LLC -- [matt-kwong](https://github.com/matt-kwong), Google LLC -- [nicolasnoble](https://github.com/nicolasnoble), Google LLC -- [yongni](https://github.com/yongni), Google LLC diff --git a/vendor/google.golang.org/grpc/Makefile b/vendor/google.golang.org/grpc/Makefile deleted file mode 100644 index 1f8960922..000000000 --- a/vendor/google.golang.org/grpc/Makefile +++ /dev/null @@ -1,46 +0,0 @@ -all: vet test testrace - -build: - go build google.golang.org/grpc/... - -clean: - go clean -i google.golang.org/grpc/... - -deps: - GO111MODULE=on go get -d -v google.golang.org/grpc/... - -proto: - @ if ! which protoc > /dev/null; then \ - echo "error: protoc not installed" >&2; \ - exit 1; \ - fi - go generate google.golang.org/grpc/... - -test: - go test -cpu 1,4 -timeout 7m google.golang.org/grpc/... - -testsubmodule: - cd security/advancedtls && go test -cpu 1,4 -timeout 7m google.golang.org/grpc/security/advancedtls/... - cd security/authorization && go test -cpu 1,4 -timeout 7m google.golang.org/grpc/security/authorization/... - -testrace: - go test -race -cpu 1,4 -timeout 7m google.golang.org/grpc/... - -testdeps: - GO111MODULE=on go get -d -v -t google.golang.org/grpc/... - -vet: vetdeps - ./vet.sh - -vetdeps: - ./vet.sh -install - -.PHONY: \ - all \ - build \ - clean \ - proto \ - test \ - testrace \ - vet \ - vetdeps diff --git a/vendor/google.golang.org/grpc/NOTICE.txt b/vendor/google.golang.org/grpc/NOTICE.txt deleted file mode 100644 index 530197749..000000000 --- a/vendor/google.golang.org/grpc/NOTICE.txt +++ /dev/null @@ -1,13 +0,0 @@ -Copyright 2014 gRPC authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/vendor/google.golang.org/grpc/README.md b/vendor/google.golang.org/grpc/README.md deleted file mode 100644 index ab0fbb79b..000000000 --- a/vendor/google.golang.org/grpc/README.md +++ /dev/null @@ -1,107 +0,0 @@ -# gRPC-Go - -[![GoDoc](https://pkg.go.dev/badge/google.golang.org/grpc)][API] -[![GoReportCard](https://goreportcard.com/badge/grpc/grpc-go)](https://goreportcard.com/report/github.com/grpc/grpc-go) -[![codecov](https://codecov.io/gh/grpc/grpc-go/graph/badge.svg)](https://codecov.io/gh/grpc/grpc-go) - -The [Go][] implementation of [gRPC][]: A high performance, open source, general -RPC framework that puts mobile and HTTP/2 first. For more information see the -[Go gRPC docs][], or jump directly into the [quick start][]. - -## Prerequisites - -- **[Go][]**: any one of the **three latest major** [releases][go-releases]. - -## Installation - -Simply add the following import to your code, and then `go [build|run|test]` -will automatically fetch the necessary dependencies: - - -```go -import "google.golang.org/grpc" -``` - -> **Note:** If you are trying to access `grpc-go` from **China**, see the -> [FAQ](#FAQ) below. - -## Learn more - -- [Go gRPC docs][], which include a [quick start][] and [API - reference][API] among other resources -- [Low-level technical docs](Documentation) from this repository -- [Performance benchmark][] -- [Examples](examples) - -## FAQ - -### I/O Timeout Errors - -The `golang.org` domain may be blocked from some countries. `go get` usually -produces an error like the following when this happens: - -```console -$ go get -u google.golang.org/grpc -package google.golang.org/grpc: unrecognized import path "google.golang.org/grpc" (https fetch: Get https://google.golang.org/grpc?go-get=1: dial tcp 216.239.37.1:443: i/o timeout) -``` - -To build Go code, there are several options: - -- Set up a VPN and access google.golang.org through that. - -- With Go module support: it is possible to use the `replace` feature of `go - mod` to create aliases for golang.org packages. In your project's directory: - - ```sh - go mod edit -replace=google.golang.org/grpc=github.com/grpc/grpc-go@latest - go mod tidy - go mod vendor - go build -mod=vendor - ``` - - Again, this will need to be done for all transitive dependencies hosted on - golang.org as well. For details, refer to [golang/go issue - #28652](https://github.com/golang/go/issues/28652). - -### Compiling error, undefined: grpc.SupportPackageIsVersion - -Please update to the latest version of gRPC-Go using -`go get google.golang.org/grpc`. - -### How to turn on logging - -The default logger is controlled by environment variables. Turn everything on -like this: - -```console -$ export GRPC_GO_LOG_VERBOSITY_LEVEL=99 -$ export GRPC_GO_LOG_SEVERITY_LEVEL=info -``` - -### The RPC failed with error `"code = Unavailable desc = transport is closing"` - -This error means the connection the RPC is using was closed, and there are many -possible reasons, including: - 1. mis-configured transport credentials, connection failed on handshaking - 1. bytes disrupted, possibly by a proxy in between - 1. server shutdown - 1. Keepalive parameters caused connection shutdown, for example if you have - configured your server to terminate connections regularly to [trigger DNS - lookups](https://github.com/grpc/grpc-go/issues/3170#issuecomment-552517779). - If this is the case, you may want to increase your - [MaxConnectionAgeGrace](https://pkg.go.dev/google.golang.org/grpc/keepalive?tab=doc#ServerParameters), - to allow longer RPC calls to finish. - -It can be tricky to debug this because the error happens on the client side but -the root cause of the connection being closed is on the server side. Turn on -logging on __both client and server__, and see if there are any transport -errors. - -[API]: https://pkg.go.dev/google.golang.org/grpc -[Go]: https://golang.org -[Go module]: https://github.com/golang/go/wiki/Modules -[gRPC]: https://grpc.io -[Go gRPC docs]: https://grpc.io/docs/languages/go -[Performance benchmark]: https://performance-dot-grpc-testing.appspot.com/explore?dashboard=5180705743044608 -[quick start]: https://grpc.io/docs/languages/go/quickstart -[go-releases]: https://golang.org/doc/devel/release.html diff --git a/vendor/google.golang.org/grpc/SECURITY.md b/vendor/google.golang.org/grpc/SECURITY.md deleted file mode 100644 index be6e10870..000000000 --- a/vendor/google.golang.org/grpc/SECURITY.md +++ /dev/null @@ -1,3 +0,0 @@ -# Security Policy - -For information on gRPC Security Policy and reporting potentional security issues, please see [gRPC CVE Process](https://github.com/grpc/proposal/blob/master/P4-grpc-cve-process.md). diff --git a/vendor/google.golang.org/grpc/attributes/attributes.go b/vendor/google.golang.org/grpc/attributes/attributes.go deleted file mode 100644 index 52d530d7a..000000000 --- a/vendor/google.golang.org/grpc/attributes/attributes.go +++ /dev/null @@ -1,141 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package attributes defines a generic key/value store used in various gRPC -// components. -// -// # Experimental -// -// Notice: This package is EXPERIMENTAL and may be changed or removed in a -// later release. -package attributes - -import ( - "fmt" - "strings" -) - -// Attributes is an immutable struct for storing and retrieving generic -// key/value pairs. Keys must be hashable, and users should define their own -// types for keys. Values should not be modified after they are added to an -// Attributes or if they were received from one. If values implement 'Equal(o -// any) bool', it will be called by (*Attributes).Equal to determine whether -// two values with the same key should be considered equal. -type Attributes struct { - m map[any]any -} - -// New returns a new Attributes containing the key/value pair. -func New(key, value any) *Attributes { - return &Attributes{m: map[any]any{key: value}} -} - -// WithValue returns a new Attributes containing the previous keys and values -// and the new key/value pair. If the same key appears multiple times, the -// last value overwrites all previous values for that key. To remove an -// existing key, use a nil value. value should not be modified later. -func (a *Attributes) WithValue(key, value any) *Attributes { - if a == nil { - return New(key, value) - } - n := &Attributes{m: make(map[any]any, len(a.m)+1)} - for k, v := range a.m { - n.m[k] = v - } - n.m[key] = value - return n -} - -// Value returns the value associated with these attributes for key, or nil if -// no value is associated with key. The returned value should not be modified. -func (a *Attributes) Value(key any) any { - if a == nil { - return nil - } - return a.m[key] -} - -// Equal returns whether a and o are equivalent. If 'Equal(o any) bool' is -// implemented for a value in the attributes, it is called to determine if the -// value matches the one stored in the other attributes. If Equal is not -// implemented, standard equality is used to determine if the two values are -// equal. Note that some types (e.g. maps) aren't comparable by default, so -// they must be wrapped in a struct, or in an alias type, with Equal defined. -func (a *Attributes) Equal(o *Attributes) bool { - if a == nil && o == nil { - return true - } - if a == nil || o == nil { - return false - } - if len(a.m) != len(o.m) { - return false - } - for k, v := range a.m { - ov, ok := o.m[k] - if !ok { - // o missing element of a - return false - } - if eq, ok := v.(interface{ Equal(o any) bool }); ok { - if !eq.Equal(ov) { - return false - } - } else if v != ov { - // Fallback to a standard equality check if Value is unimplemented. - return false - } - } - return true -} - -// String prints the attribute map. If any key or values throughout the map -// implement fmt.Stringer, it calls that method and appends. -func (a *Attributes) String() string { - var sb strings.Builder - sb.WriteString("{") - first := true - for k, v := range a.m { - if !first { - sb.WriteString(", ") - } - sb.WriteString(fmt.Sprintf("%q: %q ", str(k), str(v))) - first = false - } - sb.WriteString("}") - return sb.String() -} - -func str(x any) (s string) { - if v, ok := x.(fmt.Stringer); ok { - return fmt.Sprint(v) - } else if v, ok := x.(string); ok { - return v - } - return fmt.Sprintf("<%p>", x) -} - -// MarshalJSON helps implement the json.Marshaler interface, thereby rendering -// the Attributes correctly when printing (via pretty.JSON) structs containing -// Attributes as fields. -// -// Is it impossible to unmarshal attributes from a JSON representation and this -// method is meant only for debugging purposes. -func (a *Attributes) MarshalJSON() ([]byte, error) { - return []byte(a.String()), nil -} diff --git a/vendor/google.golang.org/grpc/backoff.go b/vendor/google.golang.org/grpc/backoff.go deleted file mode 100644 index 29475e31c..000000000 --- a/vendor/google.golang.org/grpc/backoff.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// See internal/backoff package for the backoff implementation. This file is -// kept for the exported types and API backward compatibility. - -package grpc - -import ( - "time" - - "google.golang.org/grpc/backoff" -) - -// DefaultBackoffConfig uses values specified for backoff in -// https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md. -// -// Deprecated: use ConnectParams instead. Will be supported throughout 1.x. -var DefaultBackoffConfig = BackoffConfig{ - MaxDelay: 120 * time.Second, -} - -// BackoffConfig defines the parameters for the default gRPC backoff strategy. -// -// Deprecated: use ConnectParams instead. Will be supported throughout 1.x. -type BackoffConfig struct { - // MaxDelay is the upper bound of backoff delay. - MaxDelay time.Duration -} - -// ConnectParams defines the parameters for connecting and retrying. Users are -// encouraged to use this instead of the BackoffConfig type defined above. See -// here for more details: -// https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md. -// -// # Experimental -// -// Notice: This type is EXPERIMENTAL and may be changed or removed in a -// later release. -type ConnectParams struct { - // Backoff specifies the configuration options for connection backoff. - Backoff backoff.Config - // MinConnectTimeout is the minimum amount of time we are willing to give a - // connection to complete. - MinConnectTimeout time.Duration -} diff --git a/vendor/google.golang.org/grpc/backoff/backoff.go b/vendor/google.golang.org/grpc/backoff/backoff.go deleted file mode 100644 index 0787d0b50..000000000 --- a/vendor/google.golang.org/grpc/backoff/backoff.go +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package backoff provides configuration options for backoff. -// -// More details can be found at: -// https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md. -// -// All APIs in this package are experimental. -package backoff - -import "time" - -// Config defines the configuration options for backoff. -type Config struct { - // BaseDelay is the amount of time to backoff after the first failure. - BaseDelay time.Duration - // Multiplier is the factor with which to multiply backoffs after a - // failed retry. Should ideally be greater than 1. - Multiplier float64 - // Jitter is the factor with which backoffs are randomized. - Jitter float64 - // MaxDelay is the upper bound of backoff delay. - MaxDelay time.Duration -} - -// DefaultConfig is a backoff configuration with the default values specfied -// at https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md. -// -// This should be useful for callers who want to configure backoff with -// non-default values only for a subset of the options. -var DefaultConfig = Config{ - BaseDelay: 1.0 * time.Second, - Multiplier: 1.6, - Jitter: 0.2, - MaxDelay: 120 * time.Second, -} diff --git a/vendor/google.golang.org/grpc/balancer/balancer.go b/vendor/google.golang.org/grpc/balancer/balancer.go deleted file mode 100644 index f391744f7..000000000 --- a/vendor/google.golang.org/grpc/balancer/balancer.go +++ /dev/null @@ -1,443 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package balancer defines APIs for load balancing in gRPC. -// All APIs in this package are experimental. -package balancer - -import ( - "context" - "encoding/json" - "errors" - "net" - "strings" - - "google.golang.org/grpc/channelz" - "google.golang.org/grpc/connectivity" - "google.golang.org/grpc/credentials" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/internal" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/resolver" - "google.golang.org/grpc/serviceconfig" -) - -var ( - // m is a map from name to balancer builder. - m = make(map[string]Builder) - - logger = grpclog.Component("balancer") -) - -// Register registers the balancer builder to the balancer map. b.Name -// (lowercased) will be used as the name registered with this builder. If the -// Builder implements ConfigParser, ParseConfig will be called when new service -// configs are received by the resolver, and the result will be provided to the -// Balancer in UpdateClientConnState. -// -// NOTE: this function must only be called during initialization time (i.e. in -// an init() function), and is not thread-safe. If multiple Balancers are -// registered with the same name, the one registered last will take effect. -func Register(b Builder) { - name := strings.ToLower(b.Name()) - if name != b.Name() { - // TODO: Skip the use of strings.ToLower() to index the map after v1.59 - // is released to switch to case sensitive balancer registry. Also, - // remove this warning and update the docstrings for Register and Get. - logger.Warningf("Balancer registered with name %q. grpc-go will be switching to case sensitive balancer registries soon", b.Name()) - } - m[name] = b -} - -// unregisterForTesting deletes the balancer with the given name from the -// balancer map. -// -// This function is not thread-safe. -func unregisterForTesting(name string) { - delete(m, name) -} - -func init() { - internal.BalancerUnregister = unregisterForTesting -} - -// Get returns the resolver builder registered with the given name. -// Note that the compare is done in a case-insensitive fashion. -// If no builder is register with the name, nil will be returned. -func Get(name string) Builder { - if strings.ToLower(name) != name { - // TODO: Skip the use of strings.ToLower() to index the map after v1.59 - // is released to switch to case sensitive balancer registry. Also, - // remove this warning and update the docstrings for Register and Get. - logger.Warningf("Balancer retrieved for name %q. grpc-go will be switching to case sensitive balancer registries soon", name) - } - if b, ok := m[strings.ToLower(name)]; ok { - return b - } - return nil -} - -// A SubConn represents a single connection to a gRPC backend service. -// -// Each SubConn contains a list of addresses. -// -// All SubConns start in IDLE, and will not try to connect. To trigger the -// connecting, Balancers must call Connect. If a connection re-enters IDLE, -// Balancers must call Connect again to trigger a new connection attempt. -// -// gRPC will try to connect to the addresses in sequence, and stop trying the -// remainder once the first connection is successful. If an attempt to connect -// to all addresses encounters an error, the SubConn will enter -// TRANSIENT_FAILURE for a backoff period, and then transition to IDLE. -// -// Once established, if a connection is lost, the SubConn will transition -// directly to IDLE. -// -// This interface is to be implemented by gRPC. Users should not need their own -// implementation of this interface. For situations like testing, any -// implementations should embed this interface. This allows gRPC to add new -// methods to this interface. -type SubConn interface { - // UpdateAddresses updates the addresses used in this SubConn. - // gRPC checks if currently-connected address is still in the new list. - // If it's in the list, the connection will be kept. - // If it's not in the list, the connection will gracefully closed, and - // a new connection will be created. - // - // This will trigger a state transition for the SubConn. - // - // Deprecated: this method will be removed. Create new SubConns for new - // addresses instead. - UpdateAddresses([]resolver.Address) - // Connect starts the connecting for this SubConn. - Connect() - // GetOrBuildProducer returns a reference to the existing Producer for this - // ProducerBuilder in this SubConn, or, if one does not currently exist, - // creates a new one and returns it. Returns a close function which must - // be called when the Producer is no longer needed. - GetOrBuildProducer(ProducerBuilder) (p Producer, close func()) - // Shutdown shuts down the SubConn gracefully. Any started RPCs will be - // allowed to complete. No future calls should be made on the SubConn. - // One final state update will be delivered to the StateListener (or - // UpdateSubConnState; deprecated) with ConnectivityState of Shutdown to - // indicate the shutdown operation. This may be delivered before - // in-progress RPCs are complete and the actual connection is closed. - Shutdown() -} - -// NewSubConnOptions contains options to create new SubConn. -type NewSubConnOptions struct { - // CredsBundle is the credentials bundle that will be used in the created - // SubConn. If it's nil, the original creds from grpc DialOptions will be - // used. - // - // Deprecated: Use the Attributes field in resolver.Address to pass - // arbitrary data to the credential handshaker. - CredsBundle credentials.Bundle - // HealthCheckEnabled indicates whether health check service should be - // enabled on this SubConn - HealthCheckEnabled bool - // StateListener is called when the state of the subconn changes. If nil, - // Balancer.UpdateSubConnState will be called instead. Will never be - // invoked until after Connect() is called on the SubConn created with - // these options. - StateListener func(SubConnState) -} - -// State contains the balancer's state relevant to the gRPC ClientConn. -type State struct { - // State contains the connectivity state of the balancer, which is used to - // determine the state of the ClientConn. - ConnectivityState connectivity.State - // Picker is used to choose connections (SubConns) for RPCs. - Picker Picker -} - -// ClientConn represents a gRPC ClientConn. -// -// This interface is to be implemented by gRPC. Users should not need a -// brand new implementation of this interface. For the situations like -// testing, the new implementation should embed this interface. This allows -// gRPC to add new methods to this interface. -type ClientConn interface { - // NewSubConn is called by balancer to create a new SubConn. - // It doesn't block and wait for the connections to be established. - // Behaviors of the SubConn can be controlled by options. - // - // Deprecated: please be aware that in a future version, SubConns will only - // support one address per SubConn. - NewSubConn([]resolver.Address, NewSubConnOptions) (SubConn, error) - // RemoveSubConn removes the SubConn from ClientConn. - // The SubConn will be shutdown. - // - // Deprecated: use SubConn.Shutdown instead. - RemoveSubConn(SubConn) - // UpdateAddresses updates the addresses used in the passed in SubConn. - // gRPC checks if the currently connected address is still in the new list. - // If so, the connection will be kept. Else, the connection will be - // gracefully closed, and a new connection will be created. - // - // This may trigger a state transition for the SubConn. - // - // Deprecated: this method will be removed. Create new SubConns for new - // addresses instead. - UpdateAddresses(SubConn, []resolver.Address) - - // UpdateState notifies gRPC that the balancer's internal state has - // changed. - // - // gRPC will update the connectivity state of the ClientConn, and will call - // Pick on the new Picker to pick new SubConns. - UpdateState(State) - - // ResolveNow is called by balancer to notify gRPC to do a name resolving. - ResolveNow(resolver.ResolveNowOptions) - - // Target returns the dial target for this ClientConn. - // - // Deprecated: Use the Target field in the BuildOptions instead. - Target() string -} - -// BuildOptions contains additional information for Build. -type BuildOptions struct { - // DialCreds is the transport credentials to use when communicating with a - // remote load balancer server. Balancer implementations which do not - // communicate with a remote load balancer server can ignore this field. - DialCreds credentials.TransportCredentials - // CredsBundle is the credentials bundle to use when communicating with a - // remote load balancer server. Balancer implementations which do not - // communicate with a remote load balancer server can ignore this field. - CredsBundle credentials.Bundle - // Dialer is the custom dialer to use when communicating with a remote load - // balancer server. Balancer implementations which do not communicate with a - // remote load balancer server can ignore this field. - Dialer func(context.Context, string) (net.Conn, error) - // Authority is the server name to use as part of the authentication - // handshake when communicating with a remote load balancer server. Balancer - // implementations which do not communicate with a remote load balancer - // server can ignore this field. - Authority string - // ChannelzParent is the parent ClientConn's channelz channel. - ChannelzParent channelz.Identifier - // CustomUserAgent is the custom user agent set on the parent ClientConn. - // The balancer should set the same custom user agent if it creates a - // ClientConn. - CustomUserAgent string - // Target contains the parsed address info of the dial target. It is the - // same resolver.Target as passed to the resolver. See the documentation for - // the resolver.Target type for details about what it contains. - Target resolver.Target -} - -// Builder creates a balancer. -type Builder interface { - // Build creates a new balancer with the ClientConn. - Build(cc ClientConn, opts BuildOptions) Balancer - // Name returns the name of balancers built by this builder. - // It will be used to pick balancers (for example in service config). - Name() string -} - -// ConfigParser parses load balancer configs. -type ConfigParser interface { - // ParseConfig parses the JSON load balancer config provided into an - // internal form or returns an error if the config is invalid. For future - // compatibility reasons, unknown fields in the config should be ignored. - ParseConfig(LoadBalancingConfigJSON json.RawMessage) (serviceconfig.LoadBalancingConfig, error) -} - -// PickInfo contains additional information for the Pick operation. -type PickInfo struct { - // FullMethodName is the method name that NewClientStream() is called - // with. The canonical format is /service/Method. - FullMethodName string - // Ctx is the RPC's context, and may contain relevant RPC-level information - // like the outgoing header metadata. - Ctx context.Context -} - -// DoneInfo contains additional information for done. -type DoneInfo struct { - // Err is the rpc error the RPC finished with. It could be nil. - Err error - // Trailer contains the metadata from the RPC's trailer, if present. - Trailer metadata.MD - // BytesSent indicates if any bytes have been sent to the server. - BytesSent bool - // BytesReceived indicates if any byte has been received from the server. - BytesReceived bool - // ServerLoad is the load received from server. It's usually sent as part of - // trailing metadata. - // - // The only supported type now is *orca_v3.LoadReport. - ServerLoad any -} - -var ( - // ErrNoSubConnAvailable indicates no SubConn is available for pick(). - // gRPC will block the RPC until a new picker is available via UpdateState(). - ErrNoSubConnAvailable = errors.New("no SubConn is available") - // ErrTransientFailure indicates all SubConns are in TransientFailure. - // WaitForReady RPCs will block, non-WaitForReady RPCs will fail. - // - // Deprecated: return an appropriate error based on the last resolution or - // connection attempt instead. The behavior is the same for any non-gRPC - // status error. - ErrTransientFailure = errors.New("all SubConns are in TransientFailure") -) - -// PickResult contains information related to a connection chosen for an RPC. -type PickResult struct { - // SubConn is the connection to use for this pick, if its state is Ready. - // If the state is not Ready, gRPC will block the RPC until a new Picker is - // provided by the balancer (using ClientConn.UpdateState). The SubConn - // must be one returned by ClientConn.NewSubConn. - SubConn SubConn - - // Done is called when the RPC is completed. If the SubConn is not ready, - // this will be called with a nil parameter. If the SubConn is not a valid - // type, Done may not be called. May be nil if the balancer does not wish - // to be notified when the RPC completes. - Done func(DoneInfo) - - // Metadata provides a way for LB policies to inject arbitrary per-call - // metadata. Any metadata returned here will be merged with existing - // metadata added by the client application. - // - // LB policies with child policies are responsible for propagating metadata - // injected by their children to the ClientConn, as part of Pick(). - Metadata metadata.MD -} - -// TransientFailureError returns e. It exists for backward compatibility and -// will be deleted soon. -// -// Deprecated: no longer necessary, picker errors are treated this way by -// default. -func TransientFailureError(e error) error { return e } - -// Picker is used by gRPC to pick a SubConn to send an RPC. -// Balancer is expected to generate a new picker from its snapshot every time its -// internal state has changed. -// -// The pickers used by gRPC can be updated by ClientConn.UpdateState(). -type Picker interface { - // Pick returns the connection to use for this RPC and related information. - // - // Pick should not block. If the balancer needs to do I/O or any blocking - // or time-consuming work to service this call, it should return - // ErrNoSubConnAvailable, and the Pick call will be repeated by gRPC when - // the Picker is updated (using ClientConn.UpdateState). - // - // If an error is returned: - // - // - If the error is ErrNoSubConnAvailable, gRPC will block until a new - // Picker is provided by the balancer (using ClientConn.UpdateState). - // - // - If the error is a status error (implemented by the grpc/status - // package), gRPC will terminate the RPC with the code and message - // provided. - // - // - For all other errors, wait for ready RPCs will wait, but non-wait for - // ready RPCs will be terminated with this error's Error() string and - // status code Unavailable. - Pick(info PickInfo) (PickResult, error) -} - -// Balancer takes input from gRPC, manages SubConns, and collects and aggregates -// the connectivity states. -// -// It also generates and updates the Picker used by gRPC to pick SubConns for RPCs. -// -// UpdateClientConnState, ResolverError, UpdateSubConnState, and Close are -// guaranteed to be called synchronously from the same goroutine. There's no -// guarantee on picker.Pick, it may be called anytime. -type Balancer interface { - // UpdateClientConnState is called by gRPC when the state of the ClientConn - // changes. If the error returned is ErrBadResolverState, the ClientConn - // will begin calling ResolveNow on the active name resolver with - // exponential backoff until a subsequent call to UpdateClientConnState - // returns a nil error. Any other errors are currently ignored. - UpdateClientConnState(ClientConnState) error - // ResolverError is called by gRPC when the name resolver reports an error. - ResolverError(error) - // UpdateSubConnState is called by gRPC when the state of a SubConn - // changes. - // - // Deprecated: Use NewSubConnOptions.StateListener when creating the - // SubConn instead. - UpdateSubConnState(SubConn, SubConnState) - // Close closes the balancer. The balancer is not currently required to - // call SubConn.Shutdown for its existing SubConns; however, this will be - // required in a future release, so it is recommended. - Close() -} - -// ExitIdler is an optional interface for balancers to implement. If -// implemented, ExitIdle will be called when ClientConn.Connect is called, if -// the ClientConn is idle. If unimplemented, ClientConn.Connect will cause -// all SubConns to connect. -// -// Notice: it will be required for all balancers to implement this in a future -// release. -type ExitIdler interface { - // ExitIdle instructs the LB policy to reconnect to backends / exit the - // IDLE state, if appropriate and possible. Note that SubConns that enter - // the IDLE state will not reconnect until SubConn.Connect is called. - ExitIdle() -} - -// SubConnState describes the state of a SubConn. -type SubConnState struct { - // ConnectivityState is the connectivity state of the SubConn. - ConnectivityState connectivity.State - // ConnectionError is set if the ConnectivityState is TransientFailure, - // describing the reason the SubConn failed. Otherwise, it is nil. - ConnectionError error -} - -// ClientConnState describes the state of a ClientConn relevant to the -// balancer. -type ClientConnState struct { - ResolverState resolver.State - // The parsed load balancing configuration returned by the builder's - // ParseConfig method, if implemented. - BalancerConfig serviceconfig.LoadBalancingConfig -} - -// ErrBadResolverState may be returned by UpdateClientConnState to indicate a -// problem with the provided name resolver data. -var ErrBadResolverState = errors.New("bad resolver state") - -// A ProducerBuilder is a simple constructor for a Producer. It is used by the -// SubConn to create producers when needed. -type ProducerBuilder interface { - // Build creates a Producer. The first parameter is always a - // grpc.ClientConnInterface (a type to allow creating RPCs/streams on the - // associated SubConn), but is declared as `any` to avoid a dependency - // cycle. Should also return a close function that will be called when all - // references to the Producer have been given up. - Build(grpcClientConnInterface any) (p Producer, close func()) -} - -// A Producer is a type shared among potentially many consumers. It is -// associated with a SubConn, and an implementation will typically contain -// other methods to provide additional functionality, e.g. configuration or -// subscription registration. -type Producer any diff --git a/vendor/google.golang.org/grpc/balancer/base/balancer.go b/vendor/google.golang.org/grpc/balancer/base/balancer.go deleted file mode 100644 index a7f1eeec8..000000000 --- a/vendor/google.golang.org/grpc/balancer/base/balancer.go +++ /dev/null @@ -1,264 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package base - -import ( - "errors" - "fmt" - - "google.golang.org/grpc/balancer" - "google.golang.org/grpc/connectivity" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/resolver" -) - -var logger = grpclog.Component("balancer") - -type baseBuilder struct { - name string - pickerBuilder PickerBuilder - config Config -} - -func (bb *baseBuilder) Build(cc balancer.ClientConn, opt balancer.BuildOptions) balancer.Balancer { - bal := &baseBalancer{ - cc: cc, - pickerBuilder: bb.pickerBuilder, - - subConns: resolver.NewAddressMap(), - scStates: make(map[balancer.SubConn]connectivity.State), - csEvltr: &balancer.ConnectivityStateEvaluator{}, - config: bb.config, - state: connectivity.Connecting, - } - // Initialize picker to a picker that always returns - // ErrNoSubConnAvailable, because when state of a SubConn changes, we - // may call UpdateState with this picker. - bal.picker = NewErrPicker(balancer.ErrNoSubConnAvailable) - return bal -} - -func (bb *baseBuilder) Name() string { - return bb.name -} - -type baseBalancer struct { - cc balancer.ClientConn - pickerBuilder PickerBuilder - - csEvltr *balancer.ConnectivityStateEvaluator - state connectivity.State - - subConns *resolver.AddressMap - scStates map[balancer.SubConn]connectivity.State - picker balancer.Picker - config Config - - resolverErr error // the last error reported by the resolver; cleared on successful resolution - connErr error // the last connection error; cleared upon leaving TransientFailure -} - -func (b *baseBalancer) ResolverError(err error) { - b.resolverErr = err - if b.subConns.Len() == 0 { - b.state = connectivity.TransientFailure - } - - if b.state != connectivity.TransientFailure { - // The picker will not change since the balancer does not currently - // report an error. - return - } - b.regeneratePicker() - b.cc.UpdateState(balancer.State{ - ConnectivityState: b.state, - Picker: b.picker, - }) -} - -func (b *baseBalancer) UpdateClientConnState(s balancer.ClientConnState) error { - // TODO: handle s.ResolverState.ServiceConfig? - if logger.V(2) { - logger.Info("base.baseBalancer: got new ClientConn state: ", s) - } - // Successful resolution; clear resolver error and ensure we return nil. - b.resolverErr = nil - // addrsSet is the set converted from addrs, it's used for quick lookup of an address. - addrsSet := resolver.NewAddressMap() - for _, a := range s.ResolverState.Addresses { - addrsSet.Set(a, nil) - if _, ok := b.subConns.Get(a); !ok { - // a is a new address (not existing in b.subConns). - var sc balancer.SubConn - opts := balancer.NewSubConnOptions{ - HealthCheckEnabled: b.config.HealthCheck, - StateListener: func(scs balancer.SubConnState) { b.updateSubConnState(sc, scs) }, - } - sc, err := b.cc.NewSubConn([]resolver.Address{a}, opts) - if err != nil { - logger.Warningf("base.baseBalancer: failed to create new SubConn: %v", err) - continue - } - b.subConns.Set(a, sc) - b.scStates[sc] = connectivity.Idle - b.csEvltr.RecordTransition(connectivity.Shutdown, connectivity.Idle) - sc.Connect() - } - } - for _, a := range b.subConns.Keys() { - sci, _ := b.subConns.Get(a) - sc := sci.(balancer.SubConn) - // a was removed by resolver. - if _, ok := addrsSet.Get(a); !ok { - sc.Shutdown() - b.subConns.Delete(a) - // Keep the state of this sc in b.scStates until sc's state becomes Shutdown. - // The entry will be deleted in updateSubConnState. - } - } - // If resolver state contains no addresses, return an error so ClientConn - // will trigger re-resolve. Also records this as an resolver error, so when - // the overall state turns transient failure, the error message will have - // the zero address information. - if len(s.ResolverState.Addresses) == 0 { - b.ResolverError(errors.New("produced zero addresses")) - return balancer.ErrBadResolverState - } - - b.regeneratePicker() - b.cc.UpdateState(balancer.State{ConnectivityState: b.state, Picker: b.picker}) - return nil -} - -// mergeErrors builds an error from the last connection error and the last -// resolver error. Must only be called if b.state is TransientFailure. -func (b *baseBalancer) mergeErrors() error { - // connErr must always be non-nil unless there are no SubConns, in which - // case resolverErr must be non-nil. - if b.connErr == nil { - return fmt.Errorf("last resolver error: %v", b.resolverErr) - } - if b.resolverErr == nil { - return fmt.Errorf("last connection error: %v", b.connErr) - } - return fmt.Errorf("last connection error: %v; last resolver error: %v", b.connErr, b.resolverErr) -} - -// regeneratePicker takes a snapshot of the balancer, and generates a picker -// from it. The picker is -// - errPicker if the balancer is in TransientFailure, -// - built by the pickerBuilder with all READY SubConns otherwise. -func (b *baseBalancer) regeneratePicker() { - if b.state == connectivity.TransientFailure { - b.picker = NewErrPicker(b.mergeErrors()) - return - } - readySCs := make(map[balancer.SubConn]SubConnInfo) - - // Filter out all ready SCs from full subConn map. - for _, addr := range b.subConns.Keys() { - sci, _ := b.subConns.Get(addr) - sc := sci.(balancer.SubConn) - if st, ok := b.scStates[sc]; ok && st == connectivity.Ready { - readySCs[sc] = SubConnInfo{Address: addr} - } - } - b.picker = b.pickerBuilder.Build(PickerBuildInfo{ReadySCs: readySCs}) -} - -// UpdateSubConnState is a nop because a StateListener is always set in NewSubConn. -func (b *baseBalancer) UpdateSubConnState(sc balancer.SubConn, state balancer.SubConnState) { - logger.Errorf("base.baseBalancer: UpdateSubConnState(%v, %+v) called unexpectedly", sc, state) -} - -func (b *baseBalancer) updateSubConnState(sc balancer.SubConn, state balancer.SubConnState) { - s := state.ConnectivityState - if logger.V(2) { - logger.Infof("base.baseBalancer: handle SubConn state change: %p, %v", sc, s) - } - oldS, ok := b.scStates[sc] - if !ok { - if logger.V(2) { - logger.Infof("base.baseBalancer: got state changes for an unknown SubConn: %p, %v", sc, s) - } - return - } - if oldS == connectivity.TransientFailure && - (s == connectivity.Connecting || s == connectivity.Idle) { - // Once a subconn enters TRANSIENT_FAILURE, ignore subsequent IDLE or - // CONNECTING transitions to prevent the aggregated state from being - // always CONNECTING when many backends exist but are all down. - if s == connectivity.Idle { - sc.Connect() - } - return - } - b.scStates[sc] = s - switch s { - case connectivity.Idle: - sc.Connect() - case connectivity.Shutdown: - // When an address was removed by resolver, b called Shutdown but kept - // the sc's state in scStates. Remove state for this sc here. - delete(b.scStates, sc) - case connectivity.TransientFailure: - // Save error to be reported via picker. - b.connErr = state.ConnectionError - } - - b.state = b.csEvltr.RecordTransition(oldS, s) - - // Regenerate picker when one of the following happens: - // - this sc entered or left ready - // - the aggregated state of balancer is TransientFailure - // (may need to update error message) - if (s == connectivity.Ready) != (oldS == connectivity.Ready) || - b.state == connectivity.TransientFailure { - b.regeneratePicker() - } - b.cc.UpdateState(balancer.State{ConnectivityState: b.state, Picker: b.picker}) -} - -// Close is a nop because base balancer doesn't have internal state to clean up, -// and it doesn't need to call Shutdown for the SubConns. -func (b *baseBalancer) Close() { -} - -// ExitIdle is a nop because the base balancer attempts to stay connected to -// all SubConns at all times. -func (b *baseBalancer) ExitIdle() { -} - -// NewErrPicker returns a Picker that always returns err on Pick(). -func NewErrPicker(err error) balancer.Picker { - return &errPicker{err: err} -} - -// NewErrPickerV2 is temporarily defined for backward compatibility reasons. -// -// Deprecated: use NewErrPicker instead. -var NewErrPickerV2 = NewErrPicker - -type errPicker struct { - err error // Pick() always returns this err. -} - -func (p *errPicker) Pick(info balancer.PickInfo) (balancer.PickResult, error) { - return balancer.PickResult{}, p.err -} diff --git a/vendor/google.golang.org/grpc/balancer/base/base.go b/vendor/google.golang.org/grpc/balancer/base/base.go deleted file mode 100644 index e31d76e33..000000000 --- a/vendor/google.golang.org/grpc/balancer/base/base.go +++ /dev/null @@ -1,71 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package base defines a balancer base that can be used to build balancers with -// different picking algorithms. -// -// The base balancer creates a new SubConn for each resolved address. The -// provided picker will only be notified about READY SubConns. -// -// This package is the base of round_robin balancer, its purpose is to be used -// to build round_robin like balancers with complex picking algorithms. -// Balancers with more complicated logic should try to implement a balancer -// builder from scratch. -// -// All APIs in this package are experimental. -package base - -import ( - "google.golang.org/grpc/balancer" - "google.golang.org/grpc/resolver" -) - -// PickerBuilder creates balancer.Picker. -type PickerBuilder interface { - // Build returns a picker that will be used by gRPC to pick a SubConn. - Build(info PickerBuildInfo) balancer.Picker -} - -// PickerBuildInfo contains information needed by the picker builder to -// construct a picker. -type PickerBuildInfo struct { - // ReadySCs is a map from all ready SubConns to the Addresses used to - // create them. - ReadySCs map[balancer.SubConn]SubConnInfo -} - -// SubConnInfo contains information about a SubConn created by the base -// balancer. -type SubConnInfo struct { - Address resolver.Address // the address used to create this SubConn -} - -// Config contains the config info about the base balancer builder. -type Config struct { - // HealthCheck indicates whether health checking should be enabled for this specific balancer. - HealthCheck bool -} - -// NewBalancerBuilder returns a base balancer builder configured by the provided config. -func NewBalancerBuilder(name string, pb PickerBuilder, config Config) balancer.Builder { - return &baseBuilder{ - name: name, - pickerBuilder: pb, - config: config, - } -} diff --git a/vendor/google.golang.org/grpc/balancer/conn_state_evaluator.go b/vendor/google.golang.org/grpc/balancer/conn_state_evaluator.go deleted file mode 100644 index c33413581..000000000 --- a/vendor/google.golang.org/grpc/balancer/conn_state_evaluator.go +++ /dev/null @@ -1,74 +0,0 @@ -/* - * - * Copyright 2022 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package balancer - -import "google.golang.org/grpc/connectivity" - -// ConnectivityStateEvaluator takes the connectivity states of multiple SubConns -// and returns one aggregated connectivity state. -// -// It's not thread safe. -type ConnectivityStateEvaluator struct { - numReady uint64 // Number of addrConns in ready state. - numConnecting uint64 // Number of addrConns in connecting state. - numTransientFailure uint64 // Number of addrConns in transient failure state. - numIdle uint64 // Number of addrConns in idle state. -} - -// RecordTransition records state change happening in subConn and based on that -// it evaluates what aggregated state should be. -// -// - If at least one SubConn in Ready, the aggregated state is Ready; -// - Else if at least one SubConn in Connecting, the aggregated state is Connecting; -// - Else if at least one SubConn is Idle, the aggregated state is Idle; -// - Else if at least one SubConn is TransientFailure (or there are no SubConns), the aggregated state is Transient Failure. -// -// Shutdown is not considered. -func (cse *ConnectivityStateEvaluator) RecordTransition(oldState, newState connectivity.State) connectivity.State { - // Update counters. - for idx, state := range []connectivity.State{oldState, newState} { - updateVal := 2*uint64(idx) - 1 // -1 for oldState and +1 for new. - switch state { - case connectivity.Ready: - cse.numReady += updateVal - case connectivity.Connecting: - cse.numConnecting += updateVal - case connectivity.TransientFailure: - cse.numTransientFailure += updateVal - case connectivity.Idle: - cse.numIdle += updateVal - } - } - return cse.CurrentState() -} - -// CurrentState returns the current aggregate conn state by evaluating the counters -func (cse *ConnectivityStateEvaluator) CurrentState() connectivity.State { - // Evaluate. - if cse.numReady > 0 { - return connectivity.Ready - } - if cse.numConnecting > 0 { - return connectivity.Connecting - } - if cse.numIdle > 0 { - return connectivity.Idle - } - return connectivity.TransientFailure -} diff --git a/vendor/google.golang.org/grpc/balancer/grpclb/state/state.go b/vendor/google.golang.org/grpc/balancer/grpclb/state/state.go deleted file mode 100644 index 4ecfa1c21..000000000 --- a/vendor/google.golang.org/grpc/balancer/grpclb/state/state.go +++ /dev/null @@ -1,51 +0,0 @@ -/* - * - * Copyright 2020 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package state declares grpclb types to be set by resolvers wishing to pass -// information to grpclb via resolver.State Attributes. -package state - -import ( - "google.golang.org/grpc/resolver" -) - -// keyType is the key to use for storing State in Attributes. -type keyType string - -const key = keyType("grpc.grpclb.state") - -// State contains gRPCLB-relevant data passed from the name resolver. -type State struct { - // BalancerAddresses contains the remote load balancer address(es). If - // set, overrides any resolver-provided addresses with Type of GRPCLB. - BalancerAddresses []resolver.Address -} - -// Set returns a copy of the provided state with attributes containing s. s's -// data should not be mutated after calling Set. -func Set(state resolver.State, s *State) resolver.State { - state.Attributes = state.Attributes.WithValue(key, s) - return state -} - -// Get returns the grpclb State in the resolver.State, or nil if not present. -// The returned data should not be mutated. -func Get(state resolver.State) *State { - s, _ := state.Attributes.Value(key).(*State) - return s -} diff --git a/vendor/google.golang.org/grpc/balancer/roundrobin/roundrobin.go b/vendor/google.golang.org/grpc/balancer/roundrobin/roundrobin.go deleted file mode 100644 index f7031ad22..000000000 --- a/vendor/google.golang.org/grpc/balancer/roundrobin/roundrobin.go +++ /dev/null @@ -1,81 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package roundrobin defines a roundrobin balancer. Roundrobin balancer is -// installed as one of the default balancers in gRPC, users don't need to -// explicitly install this balancer. -package roundrobin - -import ( - "sync/atomic" - - "google.golang.org/grpc/balancer" - "google.golang.org/grpc/balancer/base" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/internal/grpcrand" -) - -// Name is the name of round_robin balancer. -const Name = "round_robin" - -var logger = grpclog.Component("roundrobin") - -// newBuilder creates a new roundrobin balancer builder. -func newBuilder() balancer.Builder { - return base.NewBalancerBuilder(Name, &rrPickerBuilder{}, base.Config{HealthCheck: true}) -} - -func init() { - balancer.Register(newBuilder()) -} - -type rrPickerBuilder struct{} - -func (*rrPickerBuilder) Build(info base.PickerBuildInfo) balancer.Picker { - logger.Infof("roundrobinPicker: Build called with info: %v", info) - if len(info.ReadySCs) == 0 { - return base.NewErrPicker(balancer.ErrNoSubConnAvailable) - } - scs := make([]balancer.SubConn, 0, len(info.ReadySCs)) - for sc := range info.ReadySCs { - scs = append(scs, sc) - } - return &rrPicker{ - subConns: scs, - // Start at a random index, as the same RR balancer rebuilds a new - // picker when SubConn states change, and we don't want to apply excess - // load to the first server in the list. - next: uint32(grpcrand.Intn(len(scs))), - } -} - -type rrPicker struct { - // subConns is the snapshot of the roundrobin balancer when this picker was - // created. The slice is immutable. Each Get() will do a round robin - // selection from it and return the selected SubConn. - subConns []balancer.SubConn - next uint32 -} - -func (p *rrPicker) Pick(balancer.PickInfo) (balancer.PickResult, error) { - subConnsLen := uint32(len(p.subConns)) - nextIndex := atomic.AddUint32(&p.next, 1) - - sc := p.subConns[nextIndex%subConnsLen] - return balancer.PickResult{SubConn: sc}, nil -} diff --git a/vendor/google.golang.org/grpc/balancer_wrapper.go b/vendor/google.golang.org/grpc/balancer_wrapper.go deleted file mode 100644 index af39b8a4c..000000000 --- a/vendor/google.golang.org/grpc/balancer_wrapper.go +++ /dev/null @@ -1,337 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpc - -import ( - "context" - "fmt" - "sync" - - "google.golang.org/grpc/balancer" - "google.golang.org/grpc/connectivity" - "google.golang.org/grpc/internal/balancer/gracefulswitch" - "google.golang.org/grpc/internal/channelz" - "google.golang.org/grpc/internal/grpcsync" - "google.golang.org/grpc/resolver" -) - -// ccBalancerWrapper sits between the ClientConn and the Balancer. -// -// ccBalancerWrapper implements methods corresponding to the ones on the -// balancer.Balancer interface. The ClientConn is free to call these methods -// concurrently and the ccBalancerWrapper ensures that calls from the ClientConn -// to the Balancer happen in order by performing them in the serializer, without -// any mutexes held. -// -// ccBalancerWrapper also implements the balancer.ClientConn interface and is -// passed to the Balancer implementations. It invokes unexported methods on the -// ClientConn to handle these calls from the Balancer. -// -// It uses the gracefulswitch.Balancer internally to ensure that balancer -// switches happen in a graceful manner. -type ccBalancerWrapper struct { - // The following fields are initialized when the wrapper is created and are - // read-only afterwards, and therefore can be accessed without a mutex. - cc *ClientConn - opts balancer.BuildOptions - serializer *grpcsync.CallbackSerializer - serializerCancel context.CancelFunc - - // The following fields are only accessed within the serializer or during - // initialization. - curBalancerName string - balancer *gracefulswitch.Balancer - - // The following field is protected by mu. Caller must take cc.mu before - // taking mu. - mu sync.Mutex - closed bool -} - -// newCCBalancerWrapper creates a new balancer wrapper in idle state. The -// underlying balancer is not created until the updateClientConnState() method -// is invoked. -func newCCBalancerWrapper(cc *ClientConn) *ccBalancerWrapper { - ctx, cancel := context.WithCancel(cc.ctx) - ccb := &ccBalancerWrapper{ - cc: cc, - opts: balancer.BuildOptions{ - DialCreds: cc.dopts.copts.TransportCredentials, - CredsBundle: cc.dopts.copts.CredsBundle, - Dialer: cc.dopts.copts.Dialer, - Authority: cc.authority, - CustomUserAgent: cc.dopts.copts.UserAgent, - ChannelzParent: cc.channelz, - Target: cc.parsedTarget, - }, - serializer: grpcsync.NewCallbackSerializer(ctx), - serializerCancel: cancel, - } - ccb.balancer = gracefulswitch.NewBalancer(ccb, ccb.opts) - return ccb -} - -// updateClientConnState is invoked by grpc to push a ClientConnState update to -// the underlying balancer. This is always executed from the serializer, so -// it is safe to call into the balancer here. -func (ccb *ccBalancerWrapper) updateClientConnState(ccs *balancer.ClientConnState) error { - errCh := make(chan error) - ok := ccb.serializer.Schedule(func(ctx context.Context) { - defer close(errCh) - if ctx.Err() != nil || ccb.balancer == nil { - return - } - name := gracefulswitch.ChildName(ccs.BalancerConfig) - if ccb.curBalancerName != name { - ccb.curBalancerName = name - channelz.Infof(logger, ccb.cc.channelz, "Channel switches to new LB policy %q", name) - } - err := ccb.balancer.UpdateClientConnState(*ccs) - if logger.V(2) && err != nil { - logger.Infof("error from balancer.UpdateClientConnState: %v", err) - } - errCh <- err - }) - if !ok { - return nil - } - return <-errCh -} - -// resolverError is invoked by grpc to push a resolver error to the underlying -// balancer. The call to the balancer is executed from the serializer. -func (ccb *ccBalancerWrapper) resolverError(err error) { - ccb.serializer.Schedule(func(ctx context.Context) { - if ctx.Err() != nil || ccb.balancer == nil { - return - } - ccb.balancer.ResolverError(err) - }) -} - -// close initiates async shutdown of the wrapper. cc.mu must be held when -// calling this function. To determine the wrapper has finished shutting down, -// the channel should block on ccb.serializer.Done() without cc.mu held. -func (ccb *ccBalancerWrapper) close() { - ccb.mu.Lock() - ccb.closed = true - ccb.mu.Unlock() - channelz.Info(logger, ccb.cc.channelz, "ccBalancerWrapper: closing") - ccb.serializer.Schedule(func(context.Context) { - if ccb.balancer == nil { - return - } - ccb.balancer.Close() - ccb.balancer = nil - }) - ccb.serializerCancel() -} - -// exitIdle invokes the balancer's exitIdle method in the serializer. -func (ccb *ccBalancerWrapper) exitIdle() { - ccb.serializer.Schedule(func(ctx context.Context) { - if ctx.Err() != nil || ccb.balancer == nil { - return - } - ccb.balancer.ExitIdle() - }) -} - -func (ccb *ccBalancerWrapper) NewSubConn(addrs []resolver.Address, opts balancer.NewSubConnOptions) (balancer.SubConn, error) { - ccb.cc.mu.Lock() - defer ccb.cc.mu.Unlock() - - ccb.mu.Lock() - if ccb.closed { - ccb.mu.Unlock() - return nil, fmt.Errorf("balancer is being closed; no new SubConns allowed") - } - ccb.mu.Unlock() - - if len(addrs) == 0 { - return nil, fmt.Errorf("grpc: cannot create SubConn with empty address list") - } - ac, err := ccb.cc.newAddrConnLocked(addrs, opts) - if err != nil { - channelz.Warningf(logger, ccb.cc.channelz, "acBalancerWrapper: NewSubConn: failed to newAddrConn: %v", err) - return nil, err - } - acbw := &acBalancerWrapper{ - ccb: ccb, - ac: ac, - producers: make(map[balancer.ProducerBuilder]*refCountedProducer), - stateListener: opts.StateListener, - } - ac.acbw = acbw - return acbw, nil -} - -func (ccb *ccBalancerWrapper) RemoveSubConn(sc balancer.SubConn) { - // The graceful switch balancer will never call this. - logger.Errorf("ccb RemoveSubConn(%v) called unexpectedly, sc") -} - -func (ccb *ccBalancerWrapper) UpdateAddresses(sc balancer.SubConn, addrs []resolver.Address) { - acbw, ok := sc.(*acBalancerWrapper) - if !ok { - return - } - acbw.UpdateAddresses(addrs) -} - -func (ccb *ccBalancerWrapper) UpdateState(s balancer.State) { - ccb.cc.mu.Lock() - defer ccb.cc.mu.Unlock() - - ccb.mu.Lock() - if ccb.closed { - ccb.mu.Unlock() - return - } - ccb.mu.Unlock() - // Update picker before updating state. Even though the ordering here does - // not matter, it can lead to multiple calls of Pick in the common start-up - // case where we wait for ready and then perform an RPC. If the picker is - // updated later, we could call the "connecting" picker when the state is - // updated, and then call the "ready" picker after the picker gets updated. - - // Note that there is no need to check if the balancer wrapper was closed, - // as we know the graceful switch LB policy will not call cc if it has been - // closed. - ccb.cc.pickerWrapper.updatePicker(s.Picker) - ccb.cc.csMgr.updateState(s.ConnectivityState) -} - -func (ccb *ccBalancerWrapper) ResolveNow(o resolver.ResolveNowOptions) { - ccb.cc.mu.RLock() - defer ccb.cc.mu.RUnlock() - - ccb.mu.Lock() - if ccb.closed { - ccb.mu.Unlock() - return - } - ccb.mu.Unlock() - ccb.cc.resolveNowLocked(o) -} - -func (ccb *ccBalancerWrapper) Target() string { - return ccb.cc.target -} - -// acBalancerWrapper is a wrapper on top of ac for balancers. -// It implements balancer.SubConn interface. -type acBalancerWrapper struct { - ac *addrConn // read-only - ccb *ccBalancerWrapper // read-only - stateListener func(balancer.SubConnState) - - mu sync.Mutex - producers map[balancer.ProducerBuilder]*refCountedProducer -} - -// updateState is invoked by grpc to push a subConn state update to the -// underlying balancer. -func (acbw *acBalancerWrapper) updateState(s connectivity.State, err error) { - acbw.ccb.serializer.Schedule(func(ctx context.Context) { - if ctx.Err() != nil || acbw.ccb.balancer == nil { - return - } - // Even though it is optional for balancers, gracefulswitch ensures - // opts.StateListener is set, so this cannot ever be nil. - // TODO: delete this comment when UpdateSubConnState is removed. - acbw.stateListener(balancer.SubConnState{ConnectivityState: s, ConnectionError: err}) - }) -} - -func (acbw *acBalancerWrapper) String() string { - return fmt.Sprintf("SubConn(id:%d)", acbw.ac.channelz.ID) -} - -func (acbw *acBalancerWrapper) UpdateAddresses(addrs []resolver.Address) { - acbw.ac.updateAddrs(addrs) -} - -func (acbw *acBalancerWrapper) Connect() { - go acbw.ac.connect() -} - -func (acbw *acBalancerWrapper) Shutdown() { - acbw.ccb.cc.removeAddrConn(acbw.ac, errConnDrain) -} - -// NewStream begins a streaming RPC on the addrConn. If the addrConn is not -// ready, blocks until it is or ctx expires. Returns an error when the context -// expires or the addrConn is shut down. -func (acbw *acBalancerWrapper) NewStream(ctx context.Context, desc *StreamDesc, method string, opts ...CallOption) (ClientStream, error) { - transport, err := acbw.ac.getTransport(ctx) - if err != nil { - return nil, err - } - return newNonRetryClientStream(ctx, desc, method, transport, acbw.ac, opts...) -} - -// Invoke performs a unary RPC. If the addrConn is not ready, returns -// errSubConnNotReady. -func (acbw *acBalancerWrapper) Invoke(ctx context.Context, method string, args any, reply any, opts ...CallOption) error { - cs, err := acbw.NewStream(ctx, unaryStreamDesc, method, opts...) - if err != nil { - return err - } - if err := cs.SendMsg(args); err != nil { - return err - } - return cs.RecvMsg(reply) -} - -type refCountedProducer struct { - producer balancer.Producer - refs int // number of current refs to the producer - close func() // underlying producer's close function -} - -func (acbw *acBalancerWrapper) GetOrBuildProducer(pb balancer.ProducerBuilder) (balancer.Producer, func()) { - acbw.mu.Lock() - defer acbw.mu.Unlock() - - // Look up existing producer from this builder. - pData := acbw.producers[pb] - if pData == nil { - // Not found; create a new one and add it to the producers map. - p, close := pb.Build(acbw) - pData = &refCountedProducer{producer: p, close: close} - acbw.producers[pb] = pData - } - // Account for this new reference. - pData.refs++ - - // Return a cleanup function wrapped in a OnceFunc to remove this reference - // and delete the refCountedProducer from the map if the total reference - // count goes to zero. - unref := func() { - acbw.mu.Lock() - pData.refs-- - if pData.refs == 0 { - defer pData.close() // Run outside the acbw mutex - delete(acbw.producers, pb) - } - acbw.mu.Unlock() - } - return pData.producer, grpcsync.OnceFunc(unref) -} diff --git a/vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go b/vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go deleted file mode 100644 index 856c75dd4..000000000 --- a/vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go +++ /dev/null @@ -1,1183 +0,0 @@ -// Copyright 2018 The gRPC Authors -// All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// The canonical version of this proto can be found at -// https://github.com/grpc/grpc-proto/blob/master/grpc/binlog/v1/binarylog.proto - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.32.0 -// protoc v4.25.2 -// source: grpc/binlog/v1/binarylog.proto - -package grpc_binarylog_v1 - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - durationpb "google.golang.org/protobuf/types/known/durationpb" - timestamppb "google.golang.org/protobuf/types/known/timestamppb" - 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) -) - -// Enumerates the type of event -// Note the terminology is different from the RPC semantics -// definition, but the same meaning is expressed here. -type GrpcLogEntry_EventType int32 - -const ( - GrpcLogEntry_EVENT_TYPE_UNKNOWN GrpcLogEntry_EventType = 0 - // Header sent from client to server - GrpcLogEntry_EVENT_TYPE_CLIENT_HEADER GrpcLogEntry_EventType = 1 - // Header sent from server to client - GrpcLogEntry_EVENT_TYPE_SERVER_HEADER GrpcLogEntry_EventType = 2 - // Message sent from client to server - GrpcLogEntry_EVENT_TYPE_CLIENT_MESSAGE GrpcLogEntry_EventType = 3 - // Message sent from server to client - GrpcLogEntry_EVENT_TYPE_SERVER_MESSAGE GrpcLogEntry_EventType = 4 - // A signal that client is done sending - GrpcLogEntry_EVENT_TYPE_CLIENT_HALF_CLOSE GrpcLogEntry_EventType = 5 - // Trailer indicates the end of the RPC. - // On client side, this event means a trailer was either received - // from the network or the gRPC library locally generated a status - // to inform the application about a failure. - // On server side, this event means the server application requested - // to send a trailer. Note: EVENT_TYPE_CANCEL may still arrive after - // this due to races on server side. - GrpcLogEntry_EVENT_TYPE_SERVER_TRAILER GrpcLogEntry_EventType = 6 - // A signal that the RPC is cancelled. On client side, this - // indicates the client application requests a cancellation. - // On server side, this indicates that cancellation was detected. - // Note: This marks the end of the RPC. Events may arrive after - // this due to races. For example, on client side a trailer - // may arrive even though the application requested to cancel the RPC. - GrpcLogEntry_EVENT_TYPE_CANCEL GrpcLogEntry_EventType = 7 -) - -// Enum value maps for GrpcLogEntry_EventType. -var ( - GrpcLogEntry_EventType_name = map[int32]string{ - 0: "EVENT_TYPE_UNKNOWN", - 1: "EVENT_TYPE_CLIENT_HEADER", - 2: "EVENT_TYPE_SERVER_HEADER", - 3: "EVENT_TYPE_CLIENT_MESSAGE", - 4: "EVENT_TYPE_SERVER_MESSAGE", - 5: "EVENT_TYPE_CLIENT_HALF_CLOSE", - 6: "EVENT_TYPE_SERVER_TRAILER", - 7: "EVENT_TYPE_CANCEL", - } - GrpcLogEntry_EventType_value = map[string]int32{ - "EVENT_TYPE_UNKNOWN": 0, - "EVENT_TYPE_CLIENT_HEADER": 1, - "EVENT_TYPE_SERVER_HEADER": 2, - "EVENT_TYPE_CLIENT_MESSAGE": 3, - "EVENT_TYPE_SERVER_MESSAGE": 4, - "EVENT_TYPE_CLIENT_HALF_CLOSE": 5, - "EVENT_TYPE_SERVER_TRAILER": 6, - "EVENT_TYPE_CANCEL": 7, - } -) - -func (x GrpcLogEntry_EventType) Enum() *GrpcLogEntry_EventType { - p := new(GrpcLogEntry_EventType) - *p = x - return p -} - -func (x GrpcLogEntry_EventType) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (GrpcLogEntry_EventType) Descriptor() protoreflect.EnumDescriptor { - return file_grpc_binlog_v1_binarylog_proto_enumTypes[0].Descriptor() -} - -func (GrpcLogEntry_EventType) Type() protoreflect.EnumType { - return &file_grpc_binlog_v1_binarylog_proto_enumTypes[0] -} - -func (x GrpcLogEntry_EventType) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use GrpcLogEntry_EventType.Descriptor instead. -func (GrpcLogEntry_EventType) EnumDescriptor() ([]byte, []int) { - return file_grpc_binlog_v1_binarylog_proto_rawDescGZIP(), []int{0, 0} -} - -// Enumerates the entity that generates the log entry -type GrpcLogEntry_Logger int32 - -const ( - GrpcLogEntry_LOGGER_UNKNOWN GrpcLogEntry_Logger = 0 - GrpcLogEntry_LOGGER_CLIENT GrpcLogEntry_Logger = 1 - GrpcLogEntry_LOGGER_SERVER GrpcLogEntry_Logger = 2 -) - -// Enum value maps for GrpcLogEntry_Logger. -var ( - GrpcLogEntry_Logger_name = map[int32]string{ - 0: "LOGGER_UNKNOWN", - 1: "LOGGER_CLIENT", - 2: "LOGGER_SERVER", - } - GrpcLogEntry_Logger_value = map[string]int32{ - "LOGGER_UNKNOWN": 0, - "LOGGER_CLIENT": 1, - "LOGGER_SERVER": 2, - } -) - -func (x GrpcLogEntry_Logger) Enum() *GrpcLogEntry_Logger { - p := new(GrpcLogEntry_Logger) - *p = x - return p -} - -func (x GrpcLogEntry_Logger) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (GrpcLogEntry_Logger) Descriptor() protoreflect.EnumDescriptor { - return file_grpc_binlog_v1_binarylog_proto_enumTypes[1].Descriptor() -} - -func (GrpcLogEntry_Logger) Type() protoreflect.EnumType { - return &file_grpc_binlog_v1_binarylog_proto_enumTypes[1] -} - -func (x GrpcLogEntry_Logger) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use GrpcLogEntry_Logger.Descriptor instead. -func (GrpcLogEntry_Logger) EnumDescriptor() ([]byte, []int) { - return file_grpc_binlog_v1_binarylog_proto_rawDescGZIP(), []int{0, 1} -} - -type Address_Type int32 - -const ( - Address_TYPE_UNKNOWN Address_Type = 0 - // address is in 1.2.3.4 form - Address_TYPE_IPV4 Address_Type = 1 - // address is in IPv6 canonical form (RFC5952 section 4) - // The scope is NOT included in the address string. - Address_TYPE_IPV6 Address_Type = 2 - // address is UDS string - Address_TYPE_UNIX Address_Type = 3 -) - -// Enum value maps for Address_Type. -var ( - Address_Type_name = map[int32]string{ - 0: "TYPE_UNKNOWN", - 1: "TYPE_IPV4", - 2: "TYPE_IPV6", - 3: "TYPE_UNIX", - } - Address_Type_value = map[string]int32{ - "TYPE_UNKNOWN": 0, - "TYPE_IPV4": 1, - "TYPE_IPV6": 2, - "TYPE_UNIX": 3, - } -) - -func (x Address_Type) Enum() *Address_Type { - p := new(Address_Type) - *p = x - return p -} - -func (x Address_Type) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (Address_Type) Descriptor() protoreflect.EnumDescriptor { - return file_grpc_binlog_v1_binarylog_proto_enumTypes[2].Descriptor() -} - -func (Address_Type) Type() protoreflect.EnumType { - return &file_grpc_binlog_v1_binarylog_proto_enumTypes[2] -} - -func (x Address_Type) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use Address_Type.Descriptor instead. -func (Address_Type) EnumDescriptor() ([]byte, []int) { - return file_grpc_binlog_v1_binarylog_proto_rawDescGZIP(), []int{7, 0} -} - -// Log entry we store in binary logs -type GrpcLogEntry struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The timestamp of the binary log message - Timestamp *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - // Uniquely identifies a call. The value must not be 0 in order to disambiguate - // from an unset value. - // Each call may have several log entries, they will all have the same call_id. - // Nothing is guaranteed about their value other than they are unique across - // different RPCs in the same gRPC process. - CallId uint64 `protobuf:"varint,2,opt,name=call_id,json=callId,proto3" json:"call_id,omitempty"` - // The entry sequence id for this call. The first GrpcLogEntry has a - // value of 1, to disambiguate from an unset value. The purpose of - // this field is to detect missing entries in environments where - // durability or ordering is not guaranteed. - SequenceIdWithinCall uint64 `protobuf:"varint,3,opt,name=sequence_id_within_call,json=sequenceIdWithinCall,proto3" json:"sequence_id_within_call,omitempty"` - Type GrpcLogEntry_EventType `protobuf:"varint,4,opt,name=type,proto3,enum=grpc.binarylog.v1.GrpcLogEntry_EventType" json:"type,omitempty"` - Logger GrpcLogEntry_Logger `protobuf:"varint,5,opt,name=logger,proto3,enum=grpc.binarylog.v1.GrpcLogEntry_Logger" json:"logger,omitempty"` // One of the above Logger enum - // The logger uses one of the following fields to record the payload, - // according to the type of the log entry. - // - // Types that are assignable to Payload: - // - // *GrpcLogEntry_ClientHeader - // *GrpcLogEntry_ServerHeader - // *GrpcLogEntry_Message - // *GrpcLogEntry_Trailer - Payload isGrpcLogEntry_Payload `protobuf_oneof:"payload"` - // true if payload does not represent the full message or metadata. - PayloadTruncated bool `protobuf:"varint,10,opt,name=payload_truncated,json=payloadTruncated,proto3" json:"payload_truncated,omitempty"` - // Peer address information, will only be recorded on the first - // incoming event. On client side, peer is logged on - // EVENT_TYPE_SERVER_HEADER normally or EVENT_TYPE_SERVER_TRAILER in - // the case of trailers-only. On server side, peer is always - // logged on EVENT_TYPE_CLIENT_HEADER. - Peer *Address `protobuf:"bytes,11,opt,name=peer,proto3" json:"peer,omitempty"` -} - -func (x *GrpcLogEntry) Reset() { - *x = GrpcLogEntry{} - if protoimpl.UnsafeEnabled { - mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GrpcLogEntry) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GrpcLogEntry) ProtoMessage() {} - -func (x *GrpcLogEntry) ProtoReflect() protoreflect.Message { - mi := &file_grpc_binlog_v1_binarylog_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 GrpcLogEntry.ProtoReflect.Descriptor instead. -func (*GrpcLogEntry) Descriptor() ([]byte, []int) { - return file_grpc_binlog_v1_binarylog_proto_rawDescGZIP(), []int{0} -} - -func (x *GrpcLogEntry) GetTimestamp() *timestamppb.Timestamp { - if x != nil { - return x.Timestamp - } - return nil -} - -func (x *GrpcLogEntry) GetCallId() uint64 { - if x != nil { - return x.CallId - } - return 0 -} - -func (x *GrpcLogEntry) GetSequenceIdWithinCall() uint64 { - if x != nil { - return x.SequenceIdWithinCall - } - return 0 -} - -func (x *GrpcLogEntry) GetType() GrpcLogEntry_EventType { - if x != nil { - return x.Type - } - return GrpcLogEntry_EVENT_TYPE_UNKNOWN -} - -func (x *GrpcLogEntry) GetLogger() GrpcLogEntry_Logger { - if x != nil { - return x.Logger - } - return GrpcLogEntry_LOGGER_UNKNOWN -} - -func (m *GrpcLogEntry) GetPayload() isGrpcLogEntry_Payload { - if m != nil { - return m.Payload - } - return nil -} - -func (x *GrpcLogEntry) GetClientHeader() *ClientHeader { - if x, ok := x.GetPayload().(*GrpcLogEntry_ClientHeader); ok { - return x.ClientHeader - } - return nil -} - -func (x *GrpcLogEntry) GetServerHeader() *ServerHeader { - if x, ok := x.GetPayload().(*GrpcLogEntry_ServerHeader); ok { - return x.ServerHeader - } - return nil -} - -func (x *GrpcLogEntry) GetMessage() *Message { - if x, ok := x.GetPayload().(*GrpcLogEntry_Message); ok { - return x.Message - } - return nil -} - -func (x *GrpcLogEntry) GetTrailer() *Trailer { - if x, ok := x.GetPayload().(*GrpcLogEntry_Trailer); ok { - return x.Trailer - } - return nil -} - -func (x *GrpcLogEntry) GetPayloadTruncated() bool { - if x != nil { - return x.PayloadTruncated - } - return false -} - -func (x *GrpcLogEntry) GetPeer() *Address { - if x != nil { - return x.Peer - } - return nil -} - -type isGrpcLogEntry_Payload interface { - isGrpcLogEntry_Payload() -} - -type GrpcLogEntry_ClientHeader struct { - ClientHeader *ClientHeader `protobuf:"bytes,6,opt,name=client_header,json=clientHeader,proto3,oneof"` -} - -type GrpcLogEntry_ServerHeader struct { - ServerHeader *ServerHeader `protobuf:"bytes,7,opt,name=server_header,json=serverHeader,proto3,oneof"` -} - -type GrpcLogEntry_Message struct { - // Used by EVENT_TYPE_CLIENT_MESSAGE, EVENT_TYPE_SERVER_MESSAGE - Message *Message `protobuf:"bytes,8,opt,name=message,proto3,oneof"` -} - -type GrpcLogEntry_Trailer struct { - Trailer *Trailer `protobuf:"bytes,9,opt,name=trailer,proto3,oneof"` -} - -func (*GrpcLogEntry_ClientHeader) isGrpcLogEntry_Payload() {} - -func (*GrpcLogEntry_ServerHeader) isGrpcLogEntry_Payload() {} - -func (*GrpcLogEntry_Message) isGrpcLogEntry_Payload() {} - -func (*GrpcLogEntry_Trailer) isGrpcLogEntry_Payload() {} - -type ClientHeader struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // This contains only the metadata from the application. - Metadata *Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` - // The name of the RPC method, which looks something like: - // // - // Note the leading "/" character. - MethodName string `protobuf:"bytes,2,opt,name=method_name,json=methodName,proto3" json:"method_name,omitempty"` - // A single process may be used to run multiple virtual - // servers with different identities. - // The authority is the name of such a server identity. - // It is typically a portion of the URI in the form of - // or : . - Authority string `protobuf:"bytes,3,opt,name=authority,proto3" json:"authority,omitempty"` - // the RPC timeout - Timeout *durationpb.Duration `protobuf:"bytes,4,opt,name=timeout,proto3" json:"timeout,omitempty"` -} - -func (x *ClientHeader) Reset() { - *x = ClientHeader{} - if protoimpl.UnsafeEnabled { - mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ClientHeader) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ClientHeader) ProtoMessage() {} - -func (x *ClientHeader) ProtoReflect() protoreflect.Message { - mi := &file_grpc_binlog_v1_binarylog_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 ClientHeader.ProtoReflect.Descriptor instead. -func (*ClientHeader) Descriptor() ([]byte, []int) { - return file_grpc_binlog_v1_binarylog_proto_rawDescGZIP(), []int{1} -} - -func (x *ClientHeader) GetMetadata() *Metadata { - if x != nil { - return x.Metadata - } - return nil -} - -func (x *ClientHeader) GetMethodName() string { - if x != nil { - return x.MethodName - } - return "" -} - -func (x *ClientHeader) GetAuthority() string { - if x != nil { - return x.Authority - } - return "" -} - -func (x *ClientHeader) GetTimeout() *durationpb.Duration { - if x != nil { - return x.Timeout - } - return nil -} - -type ServerHeader struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // This contains only the metadata from the application. - Metadata *Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` -} - -func (x *ServerHeader) Reset() { - *x = ServerHeader{} - if protoimpl.UnsafeEnabled { - mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ServerHeader) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ServerHeader) ProtoMessage() {} - -func (x *ServerHeader) ProtoReflect() protoreflect.Message { - mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[2] - 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 ServerHeader.ProtoReflect.Descriptor instead. -func (*ServerHeader) Descriptor() ([]byte, []int) { - return file_grpc_binlog_v1_binarylog_proto_rawDescGZIP(), []int{2} -} - -func (x *ServerHeader) GetMetadata() *Metadata { - if x != nil { - return x.Metadata - } - return nil -} - -type Trailer struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // This contains only the metadata from the application. - Metadata *Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` - // The gRPC status code. - StatusCode uint32 `protobuf:"varint,2,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - // An original status message before any transport specific - // encoding. - StatusMessage string `protobuf:"bytes,3,opt,name=status_message,json=statusMessage,proto3" json:"status_message,omitempty"` - // The value of the 'grpc-status-details-bin' metadata key. If - // present, this is always an encoded 'google.rpc.Status' message. - StatusDetails []byte `protobuf:"bytes,4,opt,name=status_details,json=statusDetails,proto3" json:"status_details,omitempty"` -} - -func (x *Trailer) Reset() { - *x = Trailer{} - if protoimpl.UnsafeEnabled { - mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Trailer) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Trailer) ProtoMessage() {} - -func (x *Trailer) ProtoReflect() protoreflect.Message { - mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[3] - 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 Trailer.ProtoReflect.Descriptor instead. -func (*Trailer) Descriptor() ([]byte, []int) { - return file_grpc_binlog_v1_binarylog_proto_rawDescGZIP(), []int{3} -} - -func (x *Trailer) GetMetadata() *Metadata { - if x != nil { - return x.Metadata - } - return nil -} - -func (x *Trailer) GetStatusCode() uint32 { - if x != nil { - return x.StatusCode - } - return 0 -} - -func (x *Trailer) GetStatusMessage() string { - if x != nil { - return x.StatusMessage - } - return "" -} - -func (x *Trailer) GetStatusDetails() []byte { - if x != nil { - return x.StatusDetails - } - return nil -} - -// Message payload, used by CLIENT_MESSAGE and SERVER_MESSAGE -type Message struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Length of the message. It may not be the same as the length of the - // data field, as the logging payload can be truncated or omitted. - Length uint32 `protobuf:"varint,1,opt,name=length,proto3" json:"length,omitempty"` - // May be truncated or omitted. - Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` -} - -func (x *Message) Reset() { - *x = Message{} - if protoimpl.UnsafeEnabled { - mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Message) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Message) ProtoMessage() {} - -func (x *Message) ProtoReflect() protoreflect.Message { - mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[4] - 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 Message.ProtoReflect.Descriptor instead. -func (*Message) Descriptor() ([]byte, []int) { - return file_grpc_binlog_v1_binarylog_proto_rawDescGZIP(), []int{4} -} - -func (x *Message) GetLength() uint32 { - if x != nil { - return x.Length - } - return 0 -} - -func (x *Message) GetData() []byte { - if x != nil { - return x.Data - } - return nil -} - -// A list of metadata pairs, used in the payload of client header, -// server header, and server trailer. -// Implementations may omit some entries to honor the header limits -// of GRPC_BINARY_LOG_CONFIG. -// -// Header keys added by gRPC are omitted. To be more specific, -// implementations will not log the following entries, and this is -// not to be treated as a truncation: -// - entries handled by grpc that are not user visible, such as those -// that begin with 'grpc-' (with exception of grpc-trace-bin) -// or keys like 'lb-token' -// - transport specific entries, including but not limited to: -// ':path', ':authority', 'content-encoding', 'user-agent', 'te', etc -// - entries added for call credentials -// -// Implementations must always log grpc-trace-bin if it is present. -// Practically speaking it will only be visible on server side because -// grpc-trace-bin is managed by low level client side mechanisms -// inaccessible from the application level. On server side, the -// header is just a normal metadata key. -// The pair will not count towards the size limit. -type Metadata struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Entry []*MetadataEntry `protobuf:"bytes,1,rep,name=entry,proto3" json:"entry,omitempty"` -} - -func (x *Metadata) Reset() { - *x = Metadata{} - if protoimpl.UnsafeEnabled { - mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Metadata) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Metadata) ProtoMessage() {} - -func (x *Metadata) ProtoReflect() protoreflect.Message { - mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[5] - 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 Metadata.ProtoReflect.Descriptor instead. -func (*Metadata) Descriptor() ([]byte, []int) { - return file_grpc_binlog_v1_binarylog_proto_rawDescGZIP(), []int{5} -} - -func (x *Metadata) GetEntry() []*MetadataEntry { - if x != nil { - return x.Entry - } - return nil -} - -// A metadata key value pair -type MetadataEntry struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` -} - -func (x *MetadataEntry) Reset() { - *x = MetadataEntry{} - if protoimpl.UnsafeEnabled { - mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *MetadataEntry) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*MetadataEntry) ProtoMessage() {} - -func (x *MetadataEntry) ProtoReflect() protoreflect.Message { - mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[6] - 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 MetadataEntry.ProtoReflect.Descriptor instead. -func (*MetadataEntry) Descriptor() ([]byte, []int) { - return file_grpc_binlog_v1_binarylog_proto_rawDescGZIP(), []int{6} -} - -func (x *MetadataEntry) GetKey() string { - if x != nil { - return x.Key - } - return "" -} - -func (x *MetadataEntry) GetValue() []byte { - if x != nil { - return x.Value - } - return nil -} - -// Address information -type Address struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Type Address_Type `protobuf:"varint,1,opt,name=type,proto3,enum=grpc.binarylog.v1.Address_Type" json:"type,omitempty"` - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` - // only for TYPE_IPV4 and TYPE_IPV6 - IpPort uint32 `protobuf:"varint,3,opt,name=ip_port,json=ipPort,proto3" json:"ip_port,omitempty"` -} - -func (x *Address) Reset() { - *x = Address{} - if protoimpl.UnsafeEnabled { - mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Address) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Address) ProtoMessage() {} - -func (x *Address) ProtoReflect() protoreflect.Message { - mi := &file_grpc_binlog_v1_binarylog_proto_msgTypes[7] - 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 Address.ProtoReflect.Descriptor instead. -func (*Address) Descriptor() ([]byte, []int) { - return file_grpc_binlog_v1_binarylog_proto_rawDescGZIP(), []int{7} -} - -func (x *Address) GetType() Address_Type { - if x != nil { - return x.Type - } - return Address_TYPE_UNKNOWN -} - -func (x *Address) GetAddress() string { - if x != nil { - return x.Address - } - return "" -} - -func (x *Address) GetIpPort() uint32 { - if x != nil { - return x.IpPort - } - return 0 -} - -var File_grpc_binlog_v1_binarylog_proto protoreflect.FileDescriptor - -var file_grpc_binlog_v1_binarylog_proto_rawDesc = []byte{ - 0x0a, 0x1e, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x62, 0x69, 0x6e, 0x6c, 0x6f, 0x67, 0x2f, 0x76, 0x31, - 0x2f, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x12, 0x11, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, - 0x2e, 0x76, 0x31, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbb, 0x07, 0x0a, 0x0c, 0x47, 0x72, 0x70, 0x63, 0x4c, 0x6f, 0x67, - 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, - 0x17, 0x0a, 0x07, 0x63, 0x61, 0x6c, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x06, 0x63, 0x61, 0x6c, 0x6c, 0x49, 0x64, 0x12, 0x35, 0x0a, 0x17, 0x73, 0x65, 0x71, 0x75, - 0x65, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x69, 0x6e, 0x5f, 0x63, - 0x61, 0x6c, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x14, 0x73, 0x65, 0x71, 0x75, 0x65, - 0x6e, 0x63, 0x65, 0x49, 0x64, 0x57, 0x69, 0x74, 0x68, 0x69, 0x6e, 0x43, 0x61, 0x6c, 0x6c, 0x12, - 0x3d, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x29, 0x2e, - 0x67, 0x72, 0x70, 0x63, 0x2e, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x2e, 0x76, - 0x31, 0x2e, 0x47, 0x72, 0x70, 0x63, 0x4c, 0x6f, 0x67, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x2e, 0x45, - 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x3e, - 0x0a, 0x06, 0x6c, 0x6f, 0x67, 0x67, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, - 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x2e, - 0x76, 0x31, 0x2e, 0x47, 0x72, 0x70, 0x63, 0x4c, 0x6f, 0x67, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x2e, - 0x4c, 0x6f, 0x67, 0x67, 0x65, 0x72, 0x52, 0x06, 0x6c, 0x6f, 0x67, 0x67, 0x65, 0x72, 0x12, 0x46, - 0x0a, 0x0d, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x62, 0x69, 0x6e, - 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, - 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x48, 0x00, 0x52, 0x0c, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, - 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x46, 0x0a, 0x0d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, - 0x67, 0x72, 0x70, 0x63, 0x2e, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x2e, 0x76, - 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x48, 0x00, - 0x52, 0x0c, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x36, - 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, - 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x07, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x36, 0x0a, 0x07, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x65, - 0x72, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x62, - 0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61, 0x69, - 0x6c, 0x65, 0x72, 0x48, 0x00, 0x52, 0x07, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x65, 0x72, 0x12, 0x2b, - 0x0a, 0x11, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x74, 0x72, 0x75, 0x6e, 0x63, 0x61, - 0x74, 0x65, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x70, 0x61, 0x79, 0x6c, 0x6f, - 0x61, 0x64, 0x54, 0x72, 0x75, 0x6e, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x2e, 0x0a, 0x04, 0x70, - 0x65, 0x65, 0x72, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x72, 0x70, 0x63, - 0x2e, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x64, - 0x64, 0x72, 0x65, 0x73, 0x73, 0x52, 0x04, 0x70, 0x65, 0x65, 0x72, 0x22, 0xf5, 0x01, 0x0a, 0x09, - 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x12, 0x45, 0x56, 0x45, - 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, - 0x00, 0x12, 0x1c, 0x0a, 0x18, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, - 0x43, 0x4c, 0x49, 0x45, 0x4e, 0x54, 0x5f, 0x48, 0x45, 0x41, 0x44, 0x45, 0x52, 0x10, 0x01, 0x12, - 0x1c, 0x0a, 0x18, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x45, - 0x52, 0x56, 0x45, 0x52, 0x5f, 0x48, 0x45, 0x41, 0x44, 0x45, 0x52, 0x10, 0x02, 0x12, 0x1d, 0x0a, - 0x19, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x43, 0x4c, 0x49, 0x45, - 0x4e, 0x54, 0x5f, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x10, 0x03, 0x12, 0x1d, 0x0a, 0x19, - 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x45, 0x52, 0x56, 0x45, - 0x52, 0x5f, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x10, 0x04, 0x12, 0x20, 0x0a, 0x1c, 0x45, - 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x43, 0x4c, 0x49, 0x45, 0x4e, 0x54, - 0x5f, 0x48, 0x41, 0x4c, 0x46, 0x5f, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x10, 0x05, 0x12, 0x1d, 0x0a, - 0x19, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x45, 0x52, 0x56, - 0x45, 0x52, 0x5f, 0x54, 0x52, 0x41, 0x49, 0x4c, 0x45, 0x52, 0x10, 0x06, 0x12, 0x15, 0x0a, 0x11, - 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x43, 0x41, 0x4e, 0x43, 0x45, - 0x4c, 0x10, 0x07, 0x22, 0x42, 0x0a, 0x06, 0x4c, 0x6f, 0x67, 0x67, 0x65, 0x72, 0x12, 0x12, 0x0a, - 0x0e, 0x4c, 0x4f, 0x47, 0x47, 0x45, 0x52, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, - 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x4c, 0x4f, 0x47, 0x47, 0x45, 0x52, 0x5f, 0x43, 0x4c, 0x49, 0x45, - 0x4e, 0x54, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x4c, 0x4f, 0x47, 0x47, 0x45, 0x52, 0x5f, 0x53, - 0x45, 0x52, 0x56, 0x45, 0x52, 0x10, 0x02, 0x42, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, - 0x61, 0x64, 0x22, 0xbb, 0x01, 0x0a, 0x0c, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, - 0x64, 0x65, 0x72, 0x12, 0x37, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x62, 0x69, 0x6e, - 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1f, 0x0a, 0x0b, - 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0a, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, - 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x33, 0x0a, 0x07, 0x74, - 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, - 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, - 0x22, 0x47, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, - 0x12, 0x37, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, - 0x6c, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, - 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x22, 0xb1, 0x01, 0x0a, 0x07, 0x54, 0x72, - 0x61, 0x69, 0x6c, 0x65, 0x72, 0x12, 0x37, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, - 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x62, - 0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x74, 0x61, - 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1f, - 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, - 0x25, 0x0a, 0x0e, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x5f, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x22, 0x35, 0x0a, - 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x65, 0x6e, 0x67, - 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, - 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x22, 0x42, 0x0a, 0x08, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0x12, 0x36, 0x0a, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x20, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, - 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, - 0x79, 0x52, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x22, 0x37, 0x0a, 0x0d, 0x4d, 0x65, 0x74, 0x61, - 0x64, 0x61, 0x74, 0x61, 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, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x22, 0xb8, 0x01, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x33, 0x0a, - 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1f, 0x2e, 0x67, 0x72, - 0x70, 0x63, 0x2e, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x2e, - 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, - 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x17, 0x0a, 0x07, - 0x69, 0x70, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x69, - 0x70, 0x50, 0x6f, 0x72, 0x74, 0x22, 0x45, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, - 0x0c, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, - 0x0d, 0x0a, 0x09, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x49, 0x50, 0x56, 0x34, 0x10, 0x01, 0x12, 0x0d, - 0x0a, 0x09, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x49, 0x50, 0x56, 0x36, 0x10, 0x02, 0x12, 0x0d, 0x0a, - 0x09, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x49, 0x58, 0x10, 0x03, 0x42, 0x5c, 0x0a, 0x14, - 0x69, 0x6f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, - 0x67, 0x2e, 0x76, 0x31, 0x42, 0x0e, 0x42, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x4c, 0x6f, 0x67, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x32, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, - 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x62, - 0x69, 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x62, 0x69, - 0x6e, 0x61, 0x72, 0x79, 0x6c, 0x6f, 0x67, 0x5f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, -} - -var ( - file_grpc_binlog_v1_binarylog_proto_rawDescOnce sync.Once - file_grpc_binlog_v1_binarylog_proto_rawDescData = file_grpc_binlog_v1_binarylog_proto_rawDesc -) - -func file_grpc_binlog_v1_binarylog_proto_rawDescGZIP() []byte { - file_grpc_binlog_v1_binarylog_proto_rawDescOnce.Do(func() { - file_grpc_binlog_v1_binarylog_proto_rawDescData = protoimpl.X.CompressGZIP(file_grpc_binlog_v1_binarylog_proto_rawDescData) - }) - return file_grpc_binlog_v1_binarylog_proto_rawDescData -} - -var file_grpc_binlog_v1_binarylog_proto_enumTypes = make([]protoimpl.EnumInfo, 3) -var file_grpc_binlog_v1_binarylog_proto_msgTypes = make([]protoimpl.MessageInfo, 8) -var file_grpc_binlog_v1_binarylog_proto_goTypes = []interface{}{ - (GrpcLogEntry_EventType)(0), // 0: grpc.binarylog.v1.GrpcLogEntry.EventType - (GrpcLogEntry_Logger)(0), // 1: grpc.binarylog.v1.GrpcLogEntry.Logger - (Address_Type)(0), // 2: grpc.binarylog.v1.Address.Type - (*GrpcLogEntry)(nil), // 3: grpc.binarylog.v1.GrpcLogEntry - (*ClientHeader)(nil), // 4: grpc.binarylog.v1.ClientHeader - (*ServerHeader)(nil), // 5: grpc.binarylog.v1.ServerHeader - (*Trailer)(nil), // 6: grpc.binarylog.v1.Trailer - (*Message)(nil), // 7: grpc.binarylog.v1.Message - (*Metadata)(nil), // 8: grpc.binarylog.v1.Metadata - (*MetadataEntry)(nil), // 9: grpc.binarylog.v1.MetadataEntry - (*Address)(nil), // 10: grpc.binarylog.v1.Address - (*timestamppb.Timestamp)(nil), // 11: google.protobuf.Timestamp - (*durationpb.Duration)(nil), // 12: google.protobuf.Duration -} -var file_grpc_binlog_v1_binarylog_proto_depIdxs = []int32{ - 11, // 0: grpc.binarylog.v1.GrpcLogEntry.timestamp:type_name -> google.protobuf.Timestamp - 0, // 1: grpc.binarylog.v1.GrpcLogEntry.type:type_name -> grpc.binarylog.v1.GrpcLogEntry.EventType - 1, // 2: grpc.binarylog.v1.GrpcLogEntry.logger:type_name -> grpc.binarylog.v1.GrpcLogEntry.Logger - 4, // 3: grpc.binarylog.v1.GrpcLogEntry.client_header:type_name -> grpc.binarylog.v1.ClientHeader - 5, // 4: grpc.binarylog.v1.GrpcLogEntry.server_header:type_name -> grpc.binarylog.v1.ServerHeader - 7, // 5: grpc.binarylog.v1.GrpcLogEntry.message:type_name -> grpc.binarylog.v1.Message - 6, // 6: grpc.binarylog.v1.GrpcLogEntry.trailer:type_name -> grpc.binarylog.v1.Trailer - 10, // 7: grpc.binarylog.v1.GrpcLogEntry.peer:type_name -> grpc.binarylog.v1.Address - 8, // 8: grpc.binarylog.v1.ClientHeader.metadata:type_name -> grpc.binarylog.v1.Metadata - 12, // 9: grpc.binarylog.v1.ClientHeader.timeout:type_name -> google.protobuf.Duration - 8, // 10: grpc.binarylog.v1.ServerHeader.metadata:type_name -> grpc.binarylog.v1.Metadata - 8, // 11: grpc.binarylog.v1.Trailer.metadata:type_name -> grpc.binarylog.v1.Metadata - 9, // 12: grpc.binarylog.v1.Metadata.entry:type_name -> grpc.binarylog.v1.MetadataEntry - 2, // 13: grpc.binarylog.v1.Address.type:type_name -> grpc.binarylog.v1.Address.Type - 14, // [14:14] is the sub-list for method output_type - 14, // [14:14] is the sub-list for method input_type - 14, // [14:14] is the sub-list for extension type_name - 14, // [14:14] is the sub-list for extension extendee - 0, // [0:14] is the sub-list for field type_name -} - -func init() { file_grpc_binlog_v1_binarylog_proto_init() } -func file_grpc_binlog_v1_binarylog_proto_init() { - if File_grpc_binlog_v1_binarylog_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_grpc_binlog_v1_binarylog_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GrpcLogEntry); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_grpc_binlog_v1_binarylog_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ClientHeader); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_grpc_binlog_v1_binarylog_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ServerHeader); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_grpc_binlog_v1_binarylog_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Trailer); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_grpc_binlog_v1_binarylog_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Message); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_grpc_binlog_v1_binarylog_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Metadata); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_grpc_binlog_v1_binarylog_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MetadataEntry); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_grpc_binlog_v1_binarylog_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Address); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_grpc_binlog_v1_binarylog_proto_msgTypes[0].OneofWrappers = []interface{}{ - (*GrpcLogEntry_ClientHeader)(nil), - (*GrpcLogEntry_ServerHeader)(nil), - (*GrpcLogEntry_Message)(nil), - (*GrpcLogEntry_Trailer)(nil), - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_grpc_binlog_v1_binarylog_proto_rawDesc, - NumEnums: 3, - NumMessages: 8, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_grpc_binlog_v1_binarylog_proto_goTypes, - DependencyIndexes: file_grpc_binlog_v1_binarylog_proto_depIdxs, - EnumInfos: file_grpc_binlog_v1_binarylog_proto_enumTypes, - MessageInfos: file_grpc_binlog_v1_binarylog_proto_msgTypes, - }.Build() - File_grpc_binlog_v1_binarylog_proto = out.File - file_grpc_binlog_v1_binarylog_proto_rawDesc = nil - file_grpc_binlog_v1_binarylog_proto_goTypes = nil - file_grpc_binlog_v1_binarylog_proto_depIdxs = nil -} diff --git a/vendor/google.golang.org/grpc/call.go b/vendor/google.golang.org/grpc/call.go deleted file mode 100644 index 788c89c16..000000000 --- a/vendor/google.golang.org/grpc/call.go +++ /dev/null @@ -1,74 +0,0 @@ -/* - * - * Copyright 2014 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpc - -import ( - "context" -) - -// Invoke sends the RPC request on the wire and returns after response is -// received. This is typically called by generated code. -// -// All errors returned by Invoke are compatible with the status package. -func (cc *ClientConn) Invoke(ctx context.Context, method string, args, reply any, opts ...CallOption) error { - // allow interceptor to see all applicable call options, which means those - // configured as defaults from dial option as well as per-call options - opts = combine(cc.dopts.callOptions, opts) - - if cc.dopts.unaryInt != nil { - return cc.dopts.unaryInt(ctx, method, args, reply, cc, invoke, opts...) - } - return invoke(ctx, method, args, reply, cc, opts...) -} - -func combine(o1 []CallOption, o2 []CallOption) []CallOption { - // we don't use append because o1 could have extra capacity whose - // elements would be overwritten, which could cause inadvertent - // sharing (and race conditions) between concurrent calls - if len(o1) == 0 { - return o2 - } else if len(o2) == 0 { - return o1 - } - ret := make([]CallOption, len(o1)+len(o2)) - copy(ret, o1) - copy(ret[len(o1):], o2) - return ret -} - -// Invoke sends the RPC request on the wire and returns after response is -// received. This is typically called by generated code. -// -// DEPRECATED: Use ClientConn.Invoke instead. -func Invoke(ctx context.Context, method string, args, reply any, cc *ClientConn, opts ...CallOption) error { - return cc.Invoke(ctx, method, args, reply, opts...) -} - -var unaryStreamDesc = &StreamDesc{ServerStreams: false, ClientStreams: false} - -func invoke(ctx context.Context, method string, req, reply any, cc *ClientConn, opts ...CallOption) error { - cs, err := newClientStream(ctx, unaryStreamDesc, cc, method, opts...) - if err != nil { - return err - } - if err := cs.SendMsg(req); err != nil { - return err - } - return cs.RecvMsg(reply) -} diff --git a/vendor/google.golang.org/grpc/channelz/channelz.go b/vendor/google.golang.org/grpc/channelz/channelz.go deleted file mode 100644 index 32b7fa579..000000000 --- a/vendor/google.golang.org/grpc/channelz/channelz.go +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * Copyright 2020 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package channelz exports internals of the channelz implementation as required -// by other gRPC packages. -// -// The implementation of the channelz spec as defined in -// https://github.com/grpc/proposal/blob/master/A14-channelz.md, is provided by -// the `internal/channelz` package. -// -// # Experimental -// -// Notice: All APIs in this package are experimental and may be removed in a -// later release. -package channelz - -import "google.golang.org/grpc/internal/channelz" - -// Identifier is an opaque identifier which uniquely identifies an entity in the -// channelz database. -type Identifier = channelz.Identifier diff --git a/vendor/google.golang.org/grpc/clientconn.go b/vendor/google.golang.org/grpc/clientconn.go deleted file mode 100644 index c7f260711..000000000 --- a/vendor/google.golang.org/grpc/clientconn.go +++ /dev/null @@ -1,1827 +0,0 @@ -/* - * - * Copyright 2014 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpc - -import ( - "context" - "errors" - "fmt" - "math" - "net/url" - "strings" - "sync" - "sync/atomic" - "time" - - "google.golang.org/grpc/balancer" - "google.golang.org/grpc/balancer/base" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/connectivity" - "google.golang.org/grpc/internal" - "google.golang.org/grpc/internal/channelz" - "google.golang.org/grpc/internal/grpcsync" - "google.golang.org/grpc/internal/idle" - "google.golang.org/grpc/internal/pretty" - iresolver "google.golang.org/grpc/internal/resolver" - "google.golang.org/grpc/internal/transport" - "google.golang.org/grpc/keepalive" - "google.golang.org/grpc/resolver" - "google.golang.org/grpc/serviceconfig" - "google.golang.org/grpc/status" - - _ "google.golang.org/grpc/balancer/roundrobin" // To register roundrobin. - _ "google.golang.org/grpc/internal/resolver/passthrough" // To register passthrough resolver. - _ "google.golang.org/grpc/internal/resolver/unix" // To register unix resolver. - _ "google.golang.org/grpc/resolver/dns" // To register dns resolver. -) - -const ( - // minimum time to give a connection to complete - minConnectTimeout = 20 * time.Second -) - -var ( - // ErrClientConnClosing indicates that the operation is illegal because - // the ClientConn is closing. - // - // Deprecated: this error should not be relied upon by users; use the status - // code of Canceled instead. - ErrClientConnClosing = status.Error(codes.Canceled, "grpc: the client connection is closing") - // errConnDrain indicates that the connection starts to be drained and does not accept any new RPCs. - errConnDrain = errors.New("grpc: the connection is drained") - // errConnClosing indicates that the connection is closing. - errConnClosing = errors.New("grpc: the connection is closing") - // errConnIdling indicates the connection is being closed as the channel - // is moving to an idle mode due to inactivity. - errConnIdling = errors.New("grpc: the connection is closing due to channel idleness") - // invalidDefaultServiceConfigErrPrefix is used to prefix the json parsing error for the default - // service config. - invalidDefaultServiceConfigErrPrefix = "grpc: the provided default service config is invalid" -) - -// The following errors are returned from Dial and DialContext -var ( - // errNoTransportSecurity indicates that there is no transport security - // being set for ClientConn. Users should either set one or explicitly - // call WithInsecure DialOption to disable security. - errNoTransportSecurity = errors.New("grpc: no transport security set (use grpc.WithTransportCredentials(insecure.NewCredentials()) explicitly or set credentials)") - // errTransportCredsAndBundle indicates that creds bundle is used together - // with other individual Transport Credentials. - errTransportCredsAndBundle = errors.New("grpc: credentials.Bundle may not be used with individual TransportCredentials") - // errNoTransportCredsInBundle indicated that the configured creds bundle - // returned a transport credentials which was nil. - errNoTransportCredsInBundle = errors.New("grpc: credentials.Bundle must return non-nil transport credentials") - // errTransportCredentialsMissing indicates that users want to transmit - // security information (e.g., OAuth2 token) which requires secure - // connection on an insecure connection. - errTransportCredentialsMissing = errors.New("grpc: the credentials require transport level security (use grpc.WithTransportCredentials() to set)") -) - -const ( - defaultClientMaxReceiveMessageSize = 1024 * 1024 * 4 - defaultClientMaxSendMessageSize = math.MaxInt32 - // http2IOBufSize specifies the buffer size for sending frames. - defaultWriteBufSize = 32 * 1024 - defaultReadBufSize = 32 * 1024 -) - -type defaultConfigSelector struct { - sc *ServiceConfig -} - -func (dcs *defaultConfigSelector) SelectConfig(rpcInfo iresolver.RPCInfo) (*iresolver.RPCConfig, error) { - return &iresolver.RPCConfig{ - Context: rpcInfo.Context, - MethodConfig: getMethodConfig(dcs.sc, rpcInfo.Method), - }, nil -} - -// NewClient creates a new gRPC "channel" for the target URI provided. No I/O -// is performed. Use of the ClientConn for RPCs will automatically cause it to -// connect. Connect may be used to manually create a connection, but for most -// users this is unnecessary. -// -// The target name syntax is defined in -// https://github.com/grpc/grpc/blob/master/doc/naming.md. e.g. to use dns -// resolver, a "dns:///" prefix should be applied to the target. -// -// The DialOptions returned by WithBlock, WithTimeout, and -// WithReturnConnectionError are ignored by this function. -func NewClient(target string, opts ...DialOption) (conn *ClientConn, err error) { - cc := &ClientConn{ - target: target, - conns: make(map[*addrConn]struct{}), - dopts: defaultDialOptions(), - } - - cc.retryThrottler.Store((*retryThrottler)(nil)) - cc.safeConfigSelector.UpdateConfigSelector(&defaultConfigSelector{nil}) - cc.ctx, cc.cancel = context.WithCancel(context.Background()) - - // Apply dial options. - disableGlobalOpts := false - for _, opt := range opts { - if _, ok := opt.(*disableGlobalDialOptions); ok { - disableGlobalOpts = true - break - } - } - - if !disableGlobalOpts { - for _, opt := range globalDialOptions { - opt.apply(&cc.dopts) - } - } - - for _, opt := range opts { - opt.apply(&cc.dopts) - } - chainUnaryClientInterceptors(cc) - chainStreamClientInterceptors(cc) - - if err := cc.validateTransportCredentials(); err != nil { - return nil, err - } - - if cc.dopts.defaultServiceConfigRawJSON != nil { - scpr := parseServiceConfig(*cc.dopts.defaultServiceConfigRawJSON) - if scpr.Err != nil { - return nil, fmt.Errorf("%s: %v", invalidDefaultServiceConfigErrPrefix, scpr.Err) - } - cc.dopts.defaultServiceConfig, _ = scpr.Config.(*ServiceConfig) - } - cc.mkp = cc.dopts.copts.KeepaliveParams - - // Register ClientConn with channelz. - cc.channelzRegistration(target) - - // TODO: Ideally it should be impossible to error from this function after - // channelz registration. This will require removing some channelz logs - // from the following functions that can error. Errors can be returned to - // the user, and successful logs can be emitted here, after the checks have - // passed and channelz is subsequently registered. - - // Determine the resolver to use. - if err := cc.parseTargetAndFindResolver(); err != nil { - channelz.RemoveEntry(cc.channelz.ID) - return nil, err - } - if err = cc.determineAuthority(); err != nil { - channelz.RemoveEntry(cc.channelz.ID) - return nil, err - } - - cc.csMgr = newConnectivityStateManager(cc.ctx, cc.channelz) - cc.pickerWrapper = newPickerWrapper(cc.dopts.copts.StatsHandlers) - - cc.initIdleStateLocked() // Safe to call without the lock, since nothing else has a reference to cc. - cc.idlenessMgr = idle.NewManager((*idler)(cc), cc.dopts.idleTimeout) - return cc, nil -} - -// Dial calls DialContext(context.Background(), target, opts...). -func Dial(target string, opts ...DialOption) (*ClientConn, error) { - return DialContext(context.Background(), target, opts...) -} - -// DialContext calls NewClient and then exits idle mode. If WithBlock(true) is -// used, it calls Connect and WaitForStateChange until either the context -// expires or the state of the ClientConn is Ready. -// -// One subtle difference between NewClient and Dial and DialContext is that the -// former uses "dns" as the default name resolver, while the latter use -// "passthrough" for backward compatibility. This distinction should not matter -// to most users, but could matter to legacy users that specify a custom dialer -// and expect it to receive the target string directly. -func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *ClientConn, err error) { - // At the end of this method, we kick the channel out of idle, rather than - // waiting for the first rpc. - opts = append([]DialOption{withDefaultScheme("passthrough")}, opts...) - cc, err := NewClient(target, opts...) - if err != nil { - return nil, err - } - - // We start the channel off in idle mode, but kick it out of idle now, - // instead of waiting for the first RPC. This is the legacy behavior of - // Dial. - defer func() { - if err != nil { - cc.Close() - } - }() - - // This creates the name resolver, load balancer, etc. - if err := cc.idlenessMgr.ExitIdleMode(); err != nil { - return nil, err - } - - // Return now for non-blocking dials. - if !cc.dopts.block { - return cc, nil - } - - if cc.dopts.timeout > 0 { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, cc.dopts.timeout) - defer cancel() - } - defer func() { - select { - case <-ctx.Done(): - switch { - case ctx.Err() == err: - conn = nil - case err == nil || !cc.dopts.returnLastError: - conn, err = nil, ctx.Err() - default: - conn, err = nil, fmt.Errorf("%v: %v", ctx.Err(), err) - } - default: - } - }() - - // A blocking dial blocks until the clientConn is ready. - for { - s := cc.GetState() - if s == connectivity.Idle { - cc.Connect() - } - if s == connectivity.Ready { - return cc, nil - } else if cc.dopts.copts.FailOnNonTempDialError && s == connectivity.TransientFailure { - if err = cc.connectionError(); err != nil { - terr, ok := err.(interface { - Temporary() bool - }) - if ok && !terr.Temporary() { - return nil, err - } - } - } - if !cc.WaitForStateChange(ctx, s) { - // ctx got timeout or canceled. - if err = cc.connectionError(); err != nil && cc.dopts.returnLastError { - return nil, err - } - return nil, ctx.Err() - } - } -} - -// addTraceEvent is a helper method to add a trace event on the channel. If the -// channel is a nested one, the same event is also added on the parent channel. -func (cc *ClientConn) addTraceEvent(msg string) { - ted := &channelz.TraceEvent{ - Desc: fmt.Sprintf("Channel %s", msg), - Severity: channelz.CtInfo, - } - if cc.dopts.channelzParent != nil { - ted.Parent = &channelz.TraceEvent{ - Desc: fmt.Sprintf("Nested channel(id:%d) %s", cc.channelz.ID, msg), - Severity: channelz.CtInfo, - } - } - channelz.AddTraceEvent(logger, cc.channelz, 0, ted) -} - -type idler ClientConn - -func (i *idler) EnterIdleMode() { - (*ClientConn)(i).enterIdleMode() -} - -func (i *idler) ExitIdleMode() error { - return (*ClientConn)(i).exitIdleMode() -} - -// exitIdleMode moves the channel out of idle mode by recreating the name -// resolver and load balancer. This should never be called directly; use -// cc.idlenessMgr.ExitIdleMode instead. -func (cc *ClientConn) exitIdleMode() (err error) { - cc.mu.Lock() - if cc.conns == nil { - cc.mu.Unlock() - return errConnClosing - } - cc.mu.Unlock() - - // This needs to be called without cc.mu because this builds a new resolver - // which might update state or report error inline, which would then need to - // acquire cc.mu. - if err := cc.resolverWrapper.start(); err != nil { - return err - } - - cc.addTraceEvent("exiting idle mode") - return nil -} - -// initIdleStateLocked initializes common state to how it should be while idle. -func (cc *ClientConn) initIdleStateLocked() { - cc.resolverWrapper = newCCResolverWrapper(cc) - cc.balancerWrapper = newCCBalancerWrapper(cc) - cc.firstResolveEvent = grpcsync.NewEvent() - // cc.conns == nil is a proxy for the ClientConn being closed. So, instead - // of setting it to nil here, we recreate the map. This also means that we - // don't have to do this when exiting idle mode. - cc.conns = make(map[*addrConn]struct{}) -} - -// enterIdleMode puts the channel in idle mode, and as part of it shuts down the -// name resolver, load balancer, and any subchannels. This should never be -// called directly; use cc.idlenessMgr.EnterIdleMode instead. -func (cc *ClientConn) enterIdleMode() { - cc.mu.Lock() - - if cc.conns == nil { - cc.mu.Unlock() - return - } - - conns := cc.conns - - rWrapper := cc.resolverWrapper - rWrapper.close() - cc.pickerWrapper.reset() - bWrapper := cc.balancerWrapper - bWrapper.close() - cc.csMgr.updateState(connectivity.Idle) - cc.addTraceEvent("entering idle mode") - - cc.initIdleStateLocked() - - cc.mu.Unlock() - - // Block until the name resolver and LB policy are closed. - <-rWrapper.serializer.Done() - <-bWrapper.serializer.Done() - - // Close all subchannels after the LB policy is closed. - for ac := range conns { - ac.tearDown(errConnIdling) - } -} - -// validateTransportCredentials performs a series of checks on the configured -// transport credentials. It returns a non-nil error if any of these conditions -// are met: -// - no transport creds and no creds bundle is configured -// - both transport creds and creds bundle are configured -// - creds bundle is configured, but it lacks a transport credentials -// - insecure transport creds configured alongside call creds that require -// transport level security -// -// If none of the above conditions are met, the configured credentials are -// deemed valid and a nil error is returned. -func (cc *ClientConn) validateTransportCredentials() error { - if cc.dopts.copts.TransportCredentials == nil && cc.dopts.copts.CredsBundle == nil { - return errNoTransportSecurity - } - if cc.dopts.copts.TransportCredentials != nil && cc.dopts.copts.CredsBundle != nil { - return errTransportCredsAndBundle - } - if cc.dopts.copts.CredsBundle != nil && cc.dopts.copts.CredsBundle.TransportCredentials() == nil { - return errNoTransportCredsInBundle - } - transportCreds := cc.dopts.copts.TransportCredentials - if transportCreds == nil { - transportCreds = cc.dopts.copts.CredsBundle.TransportCredentials() - } - if transportCreds.Info().SecurityProtocol == "insecure" { - for _, cd := range cc.dopts.copts.PerRPCCredentials { - if cd.RequireTransportSecurity() { - return errTransportCredentialsMissing - } - } - } - return nil -} - -// channelzRegistration registers the newly created ClientConn with channelz and -// stores the returned identifier in `cc.channelz`. A channelz trace event is -// emitted for ClientConn creation. If the newly created ClientConn is a nested -// one, i.e a valid parent ClientConn ID is specified via a dial option, the -// trace event is also added to the parent. -// -// Doesn't grab cc.mu as this method is expected to be called only at Dial time. -func (cc *ClientConn) channelzRegistration(target string) { - parentChannel, _ := cc.dopts.channelzParent.(*channelz.Channel) - cc.channelz = channelz.RegisterChannel(parentChannel, target) - cc.addTraceEvent("created") -} - -// chainUnaryClientInterceptors chains all unary client interceptors into one. -func chainUnaryClientInterceptors(cc *ClientConn) { - interceptors := cc.dopts.chainUnaryInts - // Prepend dopts.unaryInt to the chaining interceptors if it exists, since unaryInt will - // be executed before any other chained interceptors. - if cc.dopts.unaryInt != nil { - interceptors = append([]UnaryClientInterceptor{cc.dopts.unaryInt}, interceptors...) - } - var chainedInt UnaryClientInterceptor - if len(interceptors) == 0 { - chainedInt = nil - } else if len(interceptors) == 1 { - chainedInt = interceptors[0] - } else { - chainedInt = func(ctx context.Context, method string, req, reply any, cc *ClientConn, invoker UnaryInvoker, opts ...CallOption) error { - return interceptors[0](ctx, method, req, reply, cc, getChainUnaryInvoker(interceptors, 0, invoker), opts...) - } - } - cc.dopts.unaryInt = chainedInt -} - -// getChainUnaryInvoker recursively generate the chained unary invoker. -func getChainUnaryInvoker(interceptors []UnaryClientInterceptor, curr int, finalInvoker UnaryInvoker) UnaryInvoker { - if curr == len(interceptors)-1 { - return finalInvoker - } - return func(ctx context.Context, method string, req, reply any, cc *ClientConn, opts ...CallOption) error { - return interceptors[curr+1](ctx, method, req, reply, cc, getChainUnaryInvoker(interceptors, curr+1, finalInvoker), opts...) - } -} - -// chainStreamClientInterceptors chains all stream client interceptors into one. -func chainStreamClientInterceptors(cc *ClientConn) { - interceptors := cc.dopts.chainStreamInts - // Prepend dopts.streamInt to the chaining interceptors if it exists, since streamInt will - // be executed before any other chained interceptors. - if cc.dopts.streamInt != nil { - interceptors = append([]StreamClientInterceptor{cc.dopts.streamInt}, interceptors...) - } - var chainedInt StreamClientInterceptor - if len(interceptors) == 0 { - chainedInt = nil - } else if len(interceptors) == 1 { - chainedInt = interceptors[0] - } else { - chainedInt = func(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, streamer Streamer, opts ...CallOption) (ClientStream, error) { - return interceptors[0](ctx, desc, cc, method, getChainStreamer(interceptors, 0, streamer), opts...) - } - } - cc.dopts.streamInt = chainedInt -} - -// getChainStreamer recursively generate the chained client stream constructor. -func getChainStreamer(interceptors []StreamClientInterceptor, curr int, finalStreamer Streamer) Streamer { - if curr == len(interceptors)-1 { - return finalStreamer - } - return func(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, opts ...CallOption) (ClientStream, error) { - return interceptors[curr+1](ctx, desc, cc, method, getChainStreamer(interceptors, curr+1, finalStreamer), opts...) - } -} - -// newConnectivityStateManager creates an connectivityStateManager with -// the specified channel. -func newConnectivityStateManager(ctx context.Context, channel *channelz.Channel) *connectivityStateManager { - return &connectivityStateManager{ - channelz: channel, - pubSub: grpcsync.NewPubSub(ctx), - } -} - -// connectivityStateManager keeps the connectivity.State of ClientConn. -// This struct will eventually be exported so the balancers can access it. -// -// TODO: If possible, get rid of the `connectivityStateManager` type, and -// provide this functionality using the `PubSub`, to avoid keeping track of -// the connectivity state at two places. -type connectivityStateManager struct { - mu sync.Mutex - state connectivity.State - notifyChan chan struct{} - channelz *channelz.Channel - pubSub *grpcsync.PubSub -} - -// updateState updates the connectivity.State of ClientConn. -// If there's a change it notifies goroutines waiting on state change to -// happen. -func (csm *connectivityStateManager) updateState(state connectivity.State) { - csm.mu.Lock() - defer csm.mu.Unlock() - if csm.state == connectivity.Shutdown { - return - } - if csm.state == state { - return - } - csm.state = state - csm.channelz.ChannelMetrics.State.Store(&state) - csm.pubSub.Publish(state) - - channelz.Infof(logger, csm.channelz, "Channel Connectivity change to %v", state) - if csm.notifyChan != nil { - // There are other goroutines waiting on this channel. - close(csm.notifyChan) - csm.notifyChan = nil - } -} - -func (csm *connectivityStateManager) getState() connectivity.State { - csm.mu.Lock() - defer csm.mu.Unlock() - return csm.state -} - -func (csm *connectivityStateManager) getNotifyChan() <-chan struct{} { - csm.mu.Lock() - defer csm.mu.Unlock() - if csm.notifyChan == nil { - csm.notifyChan = make(chan struct{}) - } - return csm.notifyChan -} - -// ClientConnInterface defines the functions clients need to perform unary and -// streaming RPCs. It is implemented by *ClientConn, and is only intended to -// be referenced by generated code. -type ClientConnInterface interface { - // Invoke performs a unary RPC and returns after the response is received - // into reply. - Invoke(ctx context.Context, method string, args any, reply any, opts ...CallOption) error - // NewStream begins a streaming RPC. - NewStream(ctx context.Context, desc *StreamDesc, method string, opts ...CallOption) (ClientStream, error) -} - -// Assert *ClientConn implements ClientConnInterface. -var _ ClientConnInterface = (*ClientConn)(nil) - -// ClientConn represents a virtual connection to a conceptual endpoint, to -// perform RPCs. -// -// A ClientConn is free to have zero or more actual connections to the endpoint -// based on configuration, load, etc. It is also free to determine which actual -// endpoints to use and may change it every RPC, permitting client-side load -// balancing. -// -// A ClientConn encapsulates a range of functionality including name -// resolution, TCP connection establishment (with retries and backoff) and TLS -// handshakes. It also handles errors on established connections by -// re-resolving the name and reconnecting. -type ClientConn struct { - ctx context.Context // Initialized using the background context at dial time. - cancel context.CancelFunc // Cancelled on close. - - // The following are initialized at dial time, and are read-only after that. - target string // User's dial target. - parsedTarget resolver.Target // See parseTargetAndFindResolver(). - authority string // See determineAuthority(). - dopts dialOptions // Default and user specified dial options. - channelz *channelz.Channel // Channelz object. - resolverBuilder resolver.Builder // See parseTargetAndFindResolver(). - idlenessMgr *idle.Manager - - // The following provide their own synchronization, and therefore don't - // require cc.mu to be held to access them. - csMgr *connectivityStateManager - pickerWrapper *pickerWrapper - safeConfigSelector iresolver.SafeConfigSelector - retryThrottler atomic.Value // Updated from service config. - - // mu protects the following fields. - // TODO: split mu so the same mutex isn't used for everything. - mu sync.RWMutex - resolverWrapper *ccResolverWrapper // Always recreated whenever entering idle to simplify Close. - balancerWrapper *ccBalancerWrapper // Always recreated whenever entering idle to simplify Close. - sc *ServiceConfig // Latest service config received from the resolver. - conns map[*addrConn]struct{} // Set to nil on close. - mkp keepalive.ClientParameters // May be updated upon receipt of a GoAway. - // firstResolveEvent is used to track whether the name resolver sent us at - // least one update. RPCs block on this event. May be accessed without mu - // if we know we cannot be asked to enter idle mode while accessing it (e.g. - // when the idle manager has already been closed, or if we are already - // entering idle mode). - firstResolveEvent *grpcsync.Event - - lceMu sync.Mutex // protects lastConnectionError - lastConnectionError error -} - -// WaitForStateChange waits until the connectivity.State of ClientConn changes from sourceState or -// ctx expires. A true value is returned in former case and false in latter. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func (cc *ClientConn) WaitForStateChange(ctx context.Context, sourceState connectivity.State) bool { - ch := cc.csMgr.getNotifyChan() - if cc.csMgr.getState() != sourceState { - return true - } - select { - case <-ctx.Done(): - return false - case <-ch: - return true - } -} - -// GetState returns the connectivity.State of ClientConn. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a later -// release. -func (cc *ClientConn) GetState() connectivity.State { - return cc.csMgr.getState() -} - -// Connect causes all subchannels in the ClientConn to attempt to connect if -// the channel is idle. Does not wait for the connection attempts to begin -// before returning. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a later -// release. -func (cc *ClientConn) Connect() { - if err := cc.idlenessMgr.ExitIdleMode(); err != nil { - cc.addTraceEvent(err.Error()) - return - } - // If the ClientConn was not in idle mode, we need to call ExitIdle on the - // LB policy so that connections can be created. - cc.mu.Lock() - cc.balancerWrapper.exitIdle() - cc.mu.Unlock() -} - -// waitForResolvedAddrs blocks until the resolver has provided addresses or the -// context expires. Returns nil unless the context expires first; otherwise -// returns a status error based on the context. -func (cc *ClientConn) waitForResolvedAddrs(ctx context.Context) error { - // This is on the RPC path, so we use a fast path to avoid the - // more-expensive "select" below after the resolver has returned once. - if cc.firstResolveEvent.HasFired() { - return nil - } - select { - case <-cc.firstResolveEvent.Done(): - return nil - case <-ctx.Done(): - return status.FromContextError(ctx.Err()).Err() - case <-cc.ctx.Done(): - return ErrClientConnClosing - } -} - -var emptyServiceConfig *ServiceConfig - -func init() { - balancer.Register(pickfirstBuilder{}) - cfg := parseServiceConfig("{}") - if cfg.Err != nil { - panic(fmt.Sprintf("impossible error parsing empty service config: %v", cfg.Err)) - } - emptyServiceConfig = cfg.Config.(*ServiceConfig) - - internal.SubscribeToConnectivityStateChanges = func(cc *ClientConn, s grpcsync.Subscriber) func() { - return cc.csMgr.pubSub.Subscribe(s) - } - internal.EnterIdleModeForTesting = func(cc *ClientConn) { - cc.idlenessMgr.EnterIdleModeForTesting() - } - internal.ExitIdleModeForTesting = func(cc *ClientConn) error { - return cc.idlenessMgr.ExitIdleMode() - } -} - -func (cc *ClientConn) maybeApplyDefaultServiceConfig() { - if cc.sc != nil { - cc.applyServiceConfigAndBalancer(cc.sc, nil) - return - } - if cc.dopts.defaultServiceConfig != nil { - cc.applyServiceConfigAndBalancer(cc.dopts.defaultServiceConfig, &defaultConfigSelector{cc.dopts.defaultServiceConfig}) - } else { - cc.applyServiceConfigAndBalancer(emptyServiceConfig, &defaultConfigSelector{emptyServiceConfig}) - } -} - -func (cc *ClientConn) updateResolverStateAndUnlock(s resolver.State, err error) error { - defer cc.firstResolveEvent.Fire() - // Check if the ClientConn is already closed. Some fields (e.g. - // balancerWrapper) are set to nil when closing the ClientConn, and could - // cause nil pointer panic if we don't have this check. - if cc.conns == nil { - cc.mu.Unlock() - return nil - } - - if err != nil { - // May need to apply the initial service config in case the resolver - // doesn't support service configs, or doesn't provide a service config - // with the new addresses. - cc.maybeApplyDefaultServiceConfig() - - cc.balancerWrapper.resolverError(err) - - // No addresses are valid with err set; return early. - cc.mu.Unlock() - return balancer.ErrBadResolverState - } - - var ret error - if cc.dopts.disableServiceConfig { - channelz.Infof(logger, cc.channelz, "ignoring service config from resolver (%v) and applying the default because service config is disabled", s.ServiceConfig) - cc.maybeApplyDefaultServiceConfig() - } else if s.ServiceConfig == nil { - cc.maybeApplyDefaultServiceConfig() - // TODO: do we need to apply a failing LB policy if there is no - // default, per the error handling design? - } else { - if sc, ok := s.ServiceConfig.Config.(*ServiceConfig); s.ServiceConfig.Err == nil && ok { - configSelector := iresolver.GetConfigSelector(s) - if configSelector != nil { - if len(s.ServiceConfig.Config.(*ServiceConfig).Methods) != 0 { - channelz.Infof(logger, cc.channelz, "method configs in service config will be ignored due to presence of config selector") - } - } else { - configSelector = &defaultConfigSelector{sc} - } - cc.applyServiceConfigAndBalancer(sc, configSelector) - } else { - ret = balancer.ErrBadResolverState - if cc.sc == nil { - // Apply the failing LB only if we haven't received valid service config - // from the name resolver in the past. - cc.applyFailingLBLocked(s.ServiceConfig) - cc.mu.Unlock() - return ret - } - } - } - - var balCfg serviceconfig.LoadBalancingConfig - if cc.sc != nil && cc.sc.lbConfig != nil { - balCfg = cc.sc.lbConfig - } - bw := cc.balancerWrapper - cc.mu.Unlock() - - uccsErr := bw.updateClientConnState(&balancer.ClientConnState{ResolverState: s, BalancerConfig: balCfg}) - if ret == nil { - ret = uccsErr // prefer ErrBadResolver state since any other error is - // currently meaningless to the caller. - } - return ret -} - -// applyFailingLBLocked is akin to configuring an LB policy on the channel which -// always fails RPCs. Here, an actual LB policy is not configured, but an always -// erroring picker is configured, which returns errors with information about -// what was invalid in the received service config. A config selector with no -// service config is configured, and the connectivity state of the channel is -// set to TransientFailure. -func (cc *ClientConn) applyFailingLBLocked(sc *serviceconfig.ParseResult) { - var err error - if sc.Err != nil { - err = status.Errorf(codes.Unavailable, "error parsing service config: %v", sc.Err) - } else { - err = status.Errorf(codes.Unavailable, "illegal service config type: %T", sc.Config) - } - cc.safeConfigSelector.UpdateConfigSelector(&defaultConfigSelector{nil}) - cc.pickerWrapper.updatePicker(base.NewErrPicker(err)) - cc.csMgr.updateState(connectivity.TransientFailure) -} - -// Makes a copy of the input addresses slice and clears out the balancer -// attributes field. Addresses are passed during subconn creation and address -// update operations. In both cases, we will clear the balancer attributes by -// calling this function, and therefore we will be able to use the Equal method -// provided by the resolver.Address type for comparison. -func copyAddressesWithoutBalancerAttributes(in []resolver.Address) []resolver.Address { - out := make([]resolver.Address, len(in)) - for i := range in { - out[i] = in[i] - out[i].BalancerAttributes = nil - } - return out -} - -// newAddrConnLocked creates an addrConn for addrs and adds it to cc.conns. -// -// Caller needs to make sure len(addrs) > 0. -func (cc *ClientConn) newAddrConnLocked(addrs []resolver.Address, opts balancer.NewSubConnOptions) (*addrConn, error) { - if cc.conns == nil { - return nil, ErrClientConnClosing - } - - ac := &addrConn{ - state: connectivity.Idle, - cc: cc, - addrs: copyAddressesWithoutBalancerAttributes(addrs), - scopts: opts, - dopts: cc.dopts, - channelz: channelz.RegisterSubChannel(cc.channelz, ""), - resetBackoff: make(chan struct{}), - stateChan: make(chan struct{}), - } - ac.ctx, ac.cancel = context.WithCancel(cc.ctx) - - channelz.AddTraceEvent(logger, ac.channelz, 0, &channelz.TraceEvent{ - Desc: "Subchannel created", - Severity: channelz.CtInfo, - Parent: &channelz.TraceEvent{ - Desc: fmt.Sprintf("Subchannel(id:%d) created", ac.channelz.ID), - Severity: channelz.CtInfo, - }, - }) - - // Track ac in cc. This needs to be done before any getTransport(...) is called. - cc.conns[ac] = struct{}{} - return ac, nil -} - -// removeAddrConn removes the addrConn in the subConn from clientConn. -// It also tears down the ac with the given error. -func (cc *ClientConn) removeAddrConn(ac *addrConn, err error) { - cc.mu.Lock() - if cc.conns == nil { - cc.mu.Unlock() - return - } - delete(cc.conns, ac) - cc.mu.Unlock() - ac.tearDown(err) -} - -// Target returns the target string of the ClientConn. -func (cc *ClientConn) Target() string { - return cc.target -} - -// CanonicalTarget returns the canonical target string of the ClientConn. -func (cc *ClientConn) CanonicalTarget() string { - return cc.parsedTarget.String() -} - -func (cc *ClientConn) incrCallsStarted() { - cc.channelz.ChannelMetrics.CallsStarted.Add(1) - cc.channelz.ChannelMetrics.LastCallStartedTimestamp.Store(time.Now().UnixNano()) -} - -func (cc *ClientConn) incrCallsSucceeded() { - cc.channelz.ChannelMetrics.CallsSucceeded.Add(1) -} - -func (cc *ClientConn) incrCallsFailed() { - cc.channelz.ChannelMetrics.CallsFailed.Add(1) -} - -// connect starts creating a transport. -// It does nothing if the ac is not IDLE. -// TODO(bar) Move this to the addrConn section. -func (ac *addrConn) connect() error { - ac.mu.Lock() - if ac.state == connectivity.Shutdown { - if logger.V(2) { - logger.Infof("connect called on shutdown addrConn; ignoring.") - } - ac.mu.Unlock() - return errConnClosing - } - if ac.state != connectivity.Idle { - if logger.V(2) { - logger.Infof("connect called on addrConn in non-idle state (%v); ignoring.", ac.state) - } - ac.mu.Unlock() - return nil - } - ac.mu.Unlock() - - ac.resetTransport() - return nil -} - -func equalAddresses(a, b []resolver.Address) bool { - if len(a) != len(b) { - return false - } - for i, v := range a { - if !v.Equal(b[i]) { - return false - } - } - return true -} - -// updateAddrs updates ac.addrs with the new addresses list and handles active -// connections or connection attempts. -func (ac *addrConn) updateAddrs(addrs []resolver.Address) { - ac.mu.Lock() - channelz.Infof(logger, ac.channelz, "addrConn: updateAddrs curAddr: %v, addrs: %v", pretty.ToJSON(ac.curAddr), pretty.ToJSON(addrs)) - - addrs = copyAddressesWithoutBalancerAttributes(addrs) - if equalAddresses(ac.addrs, addrs) { - ac.mu.Unlock() - return - } - - ac.addrs = addrs - - if ac.state == connectivity.Shutdown || - ac.state == connectivity.TransientFailure || - ac.state == connectivity.Idle { - // We were not connecting, so do nothing but update the addresses. - ac.mu.Unlock() - return - } - - if ac.state == connectivity.Ready { - // Try to find the connected address. - for _, a := range addrs { - a.ServerName = ac.cc.getServerName(a) - if a.Equal(ac.curAddr) { - // We are connected to a valid address, so do nothing but - // update the addresses. - ac.mu.Unlock() - return - } - } - } - - // We are either connected to the wrong address or currently connecting. - // Stop the current iteration and restart. - - ac.cancel() - ac.ctx, ac.cancel = context.WithCancel(ac.cc.ctx) - - // We have to defer here because GracefulClose => onClose, which requires - // locking ac.mu. - if ac.transport != nil { - defer ac.transport.GracefulClose() - ac.transport = nil - } - - if len(addrs) == 0 { - ac.updateConnectivityState(connectivity.Idle, nil) - } - - ac.mu.Unlock() - - // Since we were connecting/connected, we should start a new connection - // attempt. - go ac.resetTransport() -} - -// getServerName determines the serverName to be used in the connection -// handshake. The default value for the serverName is the authority on the -// ClientConn, which either comes from the user's dial target or through an -// authority override specified using the WithAuthority dial option. Name -// resolvers can specify a per-address override for the serverName through the -// resolver.Address.ServerName field which is used only if the WithAuthority -// dial option was not used. The rationale is that per-address authority -// overrides specified by the name resolver can represent a security risk, while -// an override specified by the user is more dependable since they probably know -// what they are doing. -func (cc *ClientConn) getServerName(addr resolver.Address) string { - if cc.dopts.authority != "" { - return cc.dopts.authority - } - if addr.ServerName != "" { - return addr.ServerName - } - return cc.authority -} - -func getMethodConfig(sc *ServiceConfig, method string) MethodConfig { - if sc == nil { - return MethodConfig{} - } - if m, ok := sc.Methods[method]; ok { - return m - } - i := strings.LastIndex(method, "/") - if m, ok := sc.Methods[method[:i+1]]; ok { - return m - } - return sc.Methods[""] -} - -// GetMethodConfig gets the method config of the input method. -// If there's an exact match for input method (i.e. /service/method), we return -// the corresponding MethodConfig. -// If there isn't an exact match for the input method, we look for the service's default -// config under the service (i.e /service/) and then for the default for all services (empty string). -// -// If there is a default MethodConfig for the service, we return it. -// Otherwise, we return an empty MethodConfig. -func (cc *ClientConn) GetMethodConfig(method string) MethodConfig { - // TODO: Avoid the locking here. - cc.mu.RLock() - defer cc.mu.RUnlock() - return getMethodConfig(cc.sc, method) -} - -func (cc *ClientConn) healthCheckConfig() *healthCheckConfig { - cc.mu.RLock() - defer cc.mu.RUnlock() - if cc.sc == nil { - return nil - } - return cc.sc.healthCheckConfig -} - -func (cc *ClientConn) getTransport(ctx context.Context, failfast bool, method string) (transport.ClientTransport, balancer.PickResult, error) { - return cc.pickerWrapper.pick(ctx, failfast, balancer.PickInfo{ - Ctx: ctx, - FullMethodName: method, - }) -} - -func (cc *ClientConn) applyServiceConfigAndBalancer(sc *ServiceConfig, configSelector iresolver.ConfigSelector) { - if sc == nil { - // should never reach here. - return - } - cc.sc = sc - if configSelector != nil { - cc.safeConfigSelector.UpdateConfigSelector(configSelector) - } - - if cc.sc.retryThrottling != nil { - newThrottler := &retryThrottler{ - tokens: cc.sc.retryThrottling.MaxTokens, - max: cc.sc.retryThrottling.MaxTokens, - thresh: cc.sc.retryThrottling.MaxTokens / 2, - ratio: cc.sc.retryThrottling.TokenRatio, - } - cc.retryThrottler.Store(newThrottler) - } else { - cc.retryThrottler.Store((*retryThrottler)(nil)) - } -} - -func (cc *ClientConn) resolveNow(o resolver.ResolveNowOptions) { - cc.mu.RLock() - cc.resolverWrapper.resolveNow(o) - cc.mu.RUnlock() -} - -func (cc *ClientConn) resolveNowLocked(o resolver.ResolveNowOptions) { - cc.resolverWrapper.resolveNow(o) -} - -// ResetConnectBackoff wakes up all subchannels in transient failure and causes -// them to attempt another connection immediately. It also resets the backoff -// times used for subsequent attempts regardless of the current state. -// -// In general, this function should not be used. Typical service or network -// outages result in a reasonable client reconnection strategy by default. -// However, if a previously unavailable network becomes available, this may be -// used to trigger an immediate reconnect. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func (cc *ClientConn) ResetConnectBackoff() { - cc.mu.Lock() - conns := cc.conns - cc.mu.Unlock() - for ac := range conns { - ac.resetConnectBackoff() - } -} - -// Close tears down the ClientConn and all underlying connections. -func (cc *ClientConn) Close() error { - defer func() { - cc.cancel() - <-cc.csMgr.pubSub.Done() - }() - - // Prevent calls to enter/exit idle immediately, and ensure we are not - // currently entering/exiting idle mode. - cc.idlenessMgr.Close() - - cc.mu.Lock() - if cc.conns == nil { - cc.mu.Unlock() - return ErrClientConnClosing - } - - conns := cc.conns - cc.conns = nil - cc.csMgr.updateState(connectivity.Shutdown) - - // We can safely unlock and continue to access all fields now as - // cc.conns==nil, preventing any further operations on cc. - cc.mu.Unlock() - - cc.resolverWrapper.close() - // The order of closing matters here since the balancer wrapper assumes the - // picker is closed before it is closed. - cc.pickerWrapper.close() - cc.balancerWrapper.close() - - <-cc.resolverWrapper.serializer.Done() - <-cc.balancerWrapper.serializer.Done() - - for ac := range conns { - ac.tearDown(ErrClientConnClosing) - } - cc.addTraceEvent("deleted") - // TraceEvent needs to be called before RemoveEntry, as TraceEvent may add - // trace reference to the entity being deleted, and thus prevent it from being - // deleted right away. - channelz.RemoveEntry(cc.channelz.ID) - - return nil -} - -// addrConn is a network connection to a given address. -type addrConn struct { - ctx context.Context - cancel context.CancelFunc - - cc *ClientConn - dopts dialOptions - acbw *acBalancerWrapper - scopts balancer.NewSubConnOptions - - // transport is set when there's a viable transport (note: ac state may not be READY as LB channel - // health checking may require server to report healthy to set ac to READY), and is reset - // to nil when the current transport should no longer be used to create a stream (e.g. after GoAway - // is received, transport is closed, ac has been torn down). - transport transport.ClientTransport // The current transport. - - mu sync.Mutex - curAddr resolver.Address // The current address. - addrs []resolver.Address // All addresses that the resolver resolved to. - - // Use updateConnectivityState for updating addrConn's connectivity state. - state connectivity.State - stateChan chan struct{} // closed and recreated on every state change. - - backoffIdx int // Needs to be stateful for resetConnectBackoff. - resetBackoff chan struct{} - - channelz *channelz.SubChannel -} - -// Note: this requires a lock on ac.mu. -func (ac *addrConn) updateConnectivityState(s connectivity.State, lastErr error) { - if ac.state == s { - return - } - // When changing states, reset the state change channel. - close(ac.stateChan) - ac.stateChan = make(chan struct{}) - ac.state = s - ac.channelz.ChannelMetrics.State.Store(&s) - if lastErr == nil { - channelz.Infof(logger, ac.channelz, "Subchannel Connectivity change to %v", s) - } else { - channelz.Infof(logger, ac.channelz, "Subchannel Connectivity change to %v, last error: %s", s, lastErr) - } - ac.acbw.updateState(s, lastErr) -} - -// adjustParams updates parameters used to create transports upon -// receiving a GoAway. -func (ac *addrConn) adjustParams(r transport.GoAwayReason) { - switch r { - case transport.GoAwayTooManyPings: - v := 2 * ac.dopts.copts.KeepaliveParams.Time - ac.cc.mu.Lock() - if v > ac.cc.mkp.Time { - ac.cc.mkp.Time = v - } - ac.cc.mu.Unlock() - } -} - -func (ac *addrConn) resetTransport() { - ac.mu.Lock() - acCtx := ac.ctx - if acCtx.Err() != nil { - ac.mu.Unlock() - return - } - - addrs := ac.addrs - backoffFor := ac.dopts.bs.Backoff(ac.backoffIdx) - // This will be the duration that dial gets to finish. - dialDuration := minConnectTimeout - if ac.dopts.minConnectTimeout != nil { - dialDuration = ac.dopts.minConnectTimeout() - } - - if dialDuration < backoffFor { - // Give dial more time as we keep failing to connect. - dialDuration = backoffFor - } - // We can potentially spend all the time trying the first address, and - // if the server accepts the connection and then hangs, the following - // addresses will never be tried. - // - // The spec doesn't mention what should be done for multiple addresses. - // https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md#proposed-backoff-algorithm - connectDeadline := time.Now().Add(dialDuration) - - ac.updateConnectivityState(connectivity.Connecting, nil) - ac.mu.Unlock() - - if err := ac.tryAllAddrs(acCtx, addrs, connectDeadline); err != nil { - ac.cc.resolveNow(resolver.ResolveNowOptions{}) - ac.mu.Lock() - if acCtx.Err() != nil { - // addrConn was torn down. - ac.mu.Unlock() - return - } - // After exhausting all addresses, the addrConn enters - // TRANSIENT_FAILURE. - ac.updateConnectivityState(connectivity.TransientFailure, err) - - // Backoff. - b := ac.resetBackoff - ac.mu.Unlock() - - timer := time.NewTimer(backoffFor) - select { - case <-timer.C: - ac.mu.Lock() - ac.backoffIdx++ - ac.mu.Unlock() - case <-b: - timer.Stop() - case <-acCtx.Done(): - timer.Stop() - return - } - - ac.mu.Lock() - if acCtx.Err() == nil { - ac.updateConnectivityState(connectivity.Idle, err) - } - ac.mu.Unlock() - return - } - // Success; reset backoff. - ac.mu.Lock() - ac.backoffIdx = 0 - ac.mu.Unlock() -} - -// tryAllAddrs tries to creates a connection to the addresses, and stop when at -// the first successful one. It returns an error if no address was successfully -// connected, or updates ac appropriately with the new transport. -func (ac *addrConn) tryAllAddrs(ctx context.Context, addrs []resolver.Address, connectDeadline time.Time) error { - var firstConnErr error - for _, addr := range addrs { - if ctx.Err() != nil { - return errConnClosing - } - ac.mu.Lock() - - ac.cc.mu.RLock() - ac.dopts.copts.KeepaliveParams = ac.cc.mkp - ac.cc.mu.RUnlock() - - copts := ac.dopts.copts - if ac.scopts.CredsBundle != nil { - copts.CredsBundle = ac.scopts.CredsBundle - } - ac.mu.Unlock() - - channelz.Infof(logger, ac.channelz, "Subchannel picks a new address %q to connect", addr.Addr) - - err := ac.createTransport(ctx, addr, copts, connectDeadline) - if err == nil { - return nil - } - if firstConnErr == nil { - firstConnErr = err - } - ac.cc.updateConnectionError(err) - } - - // Couldn't connect to any address. - return firstConnErr -} - -// createTransport creates a connection to addr. It returns an error if the -// address was not successfully connected, or updates ac appropriately with the -// new transport. -func (ac *addrConn) createTransport(ctx context.Context, addr resolver.Address, copts transport.ConnectOptions, connectDeadline time.Time) error { - addr.ServerName = ac.cc.getServerName(addr) - hctx, hcancel := context.WithCancel(ctx) - - onClose := func(r transport.GoAwayReason) { - ac.mu.Lock() - defer ac.mu.Unlock() - // adjust params based on GoAwayReason - ac.adjustParams(r) - if ctx.Err() != nil { - // Already shut down or connection attempt canceled. tearDown() or - // updateAddrs() already cleared the transport and canceled hctx - // via ac.ctx, and we expected this connection to be closed, so do - // nothing here. - return - } - hcancel() - if ac.transport == nil { - // We're still connecting to this address, which could error. Do - // not update the connectivity state or resolve; these will happen - // at the end of the tryAllAddrs connection loop in the event of an - // error. - return - } - ac.transport = nil - // Refresh the name resolver on any connection loss. - ac.cc.resolveNow(resolver.ResolveNowOptions{}) - // Always go idle and wait for the LB policy to initiate a new - // connection attempt. - ac.updateConnectivityState(connectivity.Idle, nil) - } - - connectCtx, cancel := context.WithDeadline(ctx, connectDeadline) - defer cancel() - copts.ChannelzParent = ac.channelz - - newTr, err := transport.NewClientTransport(connectCtx, ac.cc.ctx, addr, copts, onClose) - if err != nil { - if logger.V(2) { - logger.Infof("Creating new client transport to %q: %v", addr, err) - } - // newTr is either nil, or closed. - hcancel() - channelz.Warningf(logger, ac.channelz, "grpc: addrConn.createTransport failed to connect to %s. Err: %v", addr, err) - return err - } - - ac.mu.Lock() - defer ac.mu.Unlock() - if ctx.Err() != nil { - // This can happen if the subConn was removed while in `Connecting` - // state. tearDown() would have set the state to `Shutdown`, but - // would not have closed the transport since ac.transport would not - // have been set at that point. - // - // We run this in a goroutine because newTr.Close() calls onClose() - // inline, which requires locking ac.mu. - // - // The error we pass to Close() is immaterial since there are no open - // streams at this point, so no trailers with error details will be sent - // out. We just need to pass a non-nil error. - // - // This can also happen when updateAddrs is called during a connection - // attempt. - go newTr.Close(transport.ErrConnClosing) - return nil - } - if hctx.Err() != nil { - // onClose was already called for this connection, but the connection - // was successfully established first. Consider it a success and set - // the new state to Idle. - ac.updateConnectivityState(connectivity.Idle, nil) - return nil - } - ac.curAddr = addr - ac.transport = newTr - ac.startHealthCheck(hctx) // Will set state to READY if appropriate. - return nil -} - -// startHealthCheck starts the health checking stream (RPC) to watch the health -// stats of this connection if health checking is requested and configured. -// -// LB channel health checking is enabled when all requirements below are met: -// 1. it is not disabled by the user with the WithDisableHealthCheck DialOption -// 2. internal.HealthCheckFunc is set by importing the grpc/health package -// 3. a service config with non-empty healthCheckConfig field is provided -// 4. the load balancer requests it -// -// It sets addrConn to READY if the health checking stream is not started. -// -// Caller must hold ac.mu. -func (ac *addrConn) startHealthCheck(ctx context.Context) { - var healthcheckManagingState bool - defer func() { - if !healthcheckManagingState { - ac.updateConnectivityState(connectivity.Ready, nil) - } - }() - - if ac.cc.dopts.disableHealthCheck { - return - } - healthCheckConfig := ac.cc.healthCheckConfig() - if healthCheckConfig == nil { - return - } - if !ac.scopts.HealthCheckEnabled { - return - } - healthCheckFunc := ac.cc.dopts.healthCheckFunc - if healthCheckFunc == nil { - // The health package is not imported to set health check function. - // - // TODO: add a link to the health check doc in the error message. - channelz.Error(logger, ac.channelz, "Health check is requested but health check function is not set.") - return - } - - healthcheckManagingState = true - - // Set up the health check helper functions. - currentTr := ac.transport - newStream := func(method string) (any, error) { - ac.mu.Lock() - if ac.transport != currentTr { - ac.mu.Unlock() - return nil, status.Error(codes.Canceled, "the provided transport is no longer valid to use") - } - ac.mu.Unlock() - return newNonRetryClientStream(ctx, &StreamDesc{ServerStreams: true}, method, currentTr, ac) - } - setConnectivityState := func(s connectivity.State, lastErr error) { - ac.mu.Lock() - defer ac.mu.Unlock() - if ac.transport != currentTr { - return - } - ac.updateConnectivityState(s, lastErr) - } - // Start the health checking stream. - go func() { - err := ac.cc.dopts.healthCheckFunc(ctx, newStream, setConnectivityState, healthCheckConfig.ServiceName) - if err != nil { - if status.Code(err) == codes.Unimplemented { - channelz.Error(logger, ac.channelz, "Subchannel health check is unimplemented at server side, thus health check is disabled") - } else { - channelz.Errorf(logger, ac.channelz, "Health checking failed: %v", err) - } - } - }() -} - -func (ac *addrConn) resetConnectBackoff() { - ac.mu.Lock() - close(ac.resetBackoff) - ac.backoffIdx = 0 - ac.resetBackoff = make(chan struct{}) - ac.mu.Unlock() -} - -// getReadyTransport returns the transport if ac's state is READY or nil if not. -func (ac *addrConn) getReadyTransport() transport.ClientTransport { - ac.mu.Lock() - defer ac.mu.Unlock() - if ac.state == connectivity.Ready { - return ac.transport - } - return nil -} - -// getTransport waits until the addrconn is ready and returns the transport. -// If the context expires first, returns an appropriate status. If the -// addrConn is stopped first, returns an Unavailable status error. -func (ac *addrConn) getTransport(ctx context.Context) (transport.ClientTransport, error) { - for ctx.Err() == nil { - ac.mu.Lock() - t, state, sc := ac.transport, ac.state, ac.stateChan - ac.mu.Unlock() - if state == connectivity.Ready { - return t, nil - } - if state == connectivity.Shutdown { - return nil, status.Errorf(codes.Unavailable, "SubConn shutting down") - } - - select { - case <-ctx.Done(): - case <-sc: - } - } - return nil, status.FromContextError(ctx.Err()).Err() -} - -// tearDown starts to tear down the addrConn. -// -// Note that tearDown doesn't remove ac from ac.cc.conns, so the addrConn struct -// will leak. In most cases, call cc.removeAddrConn() instead. -func (ac *addrConn) tearDown(err error) { - ac.mu.Lock() - if ac.state == connectivity.Shutdown { - ac.mu.Unlock() - return - } - curTr := ac.transport - ac.transport = nil - // We have to set the state to Shutdown before anything else to prevent races - // between setting the state and logic that waits on context cancellation / etc. - ac.updateConnectivityState(connectivity.Shutdown, nil) - ac.cancel() - ac.curAddr = resolver.Address{} - - channelz.AddTraceEvent(logger, ac.channelz, 0, &channelz.TraceEvent{ - Desc: "Subchannel deleted", - Severity: channelz.CtInfo, - Parent: &channelz.TraceEvent{ - Desc: fmt.Sprintf("Subchannel(id:%d) deleted", ac.channelz.ID), - Severity: channelz.CtInfo, - }, - }) - // TraceEvent needs to be called before RemoveEntry, as TraceEvent may add - // trace reference to the entity being deleted, and thus prevent it from - // being deleted right away. - channelz.RemoveEntry(ac.channelz.ID) - ac.mu.Unlock() - - // We have to release the lock before the call to GracefulClose/Close here - // because both of them call onClose(), which requires locking ac.mu. - if curTr != nil { - if err == errConnDrain { - // Close the transport gracefully when the subConn is being shutdown. - // - // GracefulClose() may be executed multiple times if: - // - multiple GoAway frames are received from the server - // - there are concurrent name resolver or balancer triggered - // address removal and GoAway - curTr.GracefulClose() - } else { - // Hard close the transport when the channel is entering idle or is - // being shutdown. In the case where the channel is being shutdown, - // closing of transports is also taken care of by cancelation of cc.ctx. - // But in the case where the channel is entering idle, we need to - // explicitly close the transports here. Instead of distinguishing - // between these two cases, it is simpler to close the transport - // unconditionally here. - curTr.Close(err) - } - } -} - -type retryThrottler struct { - max float64 - thresh float64 - ratio float64 - - mu sync.Mutex - tokens float64 // TODO(dfawley): replace with atomic and remove lock. -} - -// throttle subtracts a retry token from the pool and returns whether a retry -// should be throttled (disallowed) based upon the retry throttling policy in -// the service config. -func (rt *retryThrottler) throttle() bool { - if rt == nil { - return false - } - rt.mu.Lock() - defer rt.mu.Unlock() - rt.tokens-- - if rt.tokens < 0 { - rt.tokens = 0 - } - return rt.tokens <= rt.thresh -} - -func (rt *retryThrottler) successfulRPC() { - if rt == nil { - return - } - rt.mu.Lock() - defer rt.mu.Unlock() - rt.tokens += rt.ratio - if rt.tokens > rt.max { - rt.tokens = rt.max - } -} - -func (ac *addrConn) incrCallsStarted() { - ac.channelz.ChannelMetrics.CallsStarted.Add(1) - ac.channelz.ChannelMetrics.LastCallStartedTimestamp.Store(time.Now().UnixNano()) -} - -func (ac *addrConn) incrCallsSucceeded() { - ac.channelz.ChannelMetrics.CallsSucceeded.Add(1) -} - -func (ac *addrConn) incrCallsFailed() { - ac.channelz.ChannelMetrics.CallsFailed.Add(1) -} - -// ErrClientConnTimeout indicates that the ClientConn cannot establish the -// underlying connections within the specified timeout. -// -// Deprecated: This error is never returned by grpc and should not be -// referenced by users. -var ErrClientConnTimeout = errors.New("grpc: timed out when dialing") - -// getResolver finds the scheme in the cc's resolvers or the global registry. -// scheme should always be lowercase (typically by virtue of url.Parse() -// performing proper RFC3986 behavior). -func (cc *ClientConn) getResolver(scheme string) resolver.Builder { - for _, rb := range cc.dopts.resolvers { - if scheme == rb.Scheme() { - return rb - } - } - return resolver.Get(scheme) -} - -func (cc *ClientConn) updateConnectionError(err error) { - cc.lceMu.Lock() - cc.lastConnectionError = err - cc.lceMu.Unlock() -} - -func (cc *ClientConn) connectionError() error { - cc.lceMu.Lock() - defer cc.lceMu.Unlock() - return cc.lastConnectionError -} - -// parseTargetAndFindResolver parses the user's dial target and stores the -// parsed target in `cc.parsedTarget`. -// -// The resolver to use is determined based on the scheme in the parsed target -// and the same is stored in `cc.resolverBuilder`. -// -// Doesn't grab cc.mu as this method is expected to be called only at Dial time. -func (cc *ClientConn) parseTargetAndFindResolver() error { - channelz.Infof(logger, cc.channelz, "original dial target is: %q", cc.target) - - var rb resolver.Builder - parsedTarget, err := parseTarget(cc.target) - if err != nil { - channelz.Infof(logger, cc.channelz, "dial target %q parse failed: %v", cc.target, err) - } else { - channelz.Infof(logger, cc.channelz, "parsed dial target is: %#v", parsedTarget) - rb = cc.getResolver(parsedTarget.URL.Scheme) - if rb != nil { - cc.parsedTarget = parsedTarget - cc.resolverBuilder = rb - return nil - } - } - - // We are here because the user's dial target did not contain a scheme or - // specified an unregistered scheme. We should fallback to the default - // scheme, except when a custom dialer is specified in which case, we should - // always use passthrough scheme. For either case, we need to respect any overridden - // global defaults set by the user. - defScheme := cc.dopts.defaultScheme - if internal.UserSetDefaultScheme { - defScheme = resolver.GetDefaultScheme() - } - - channelz.Infof(logger, cc.channelz, "fallback to scheme %q", defScheme) - canonicalTarget := defScheme + ":///" + cc.target - - parsedTarget, err = parseTarget(canonicalTarget) - if err != nil { - channelz.Infof(logger, cc.channelz, "dial target %q parse failed: %v", canonicalTarget, err) - return err - } - channelz.Infof(logger, cc.channelz, "parsed dial target is: %+v", parsedTarget) - rb = cc.getResolver(parsedTarget.URL.Scheme) - if rb == nil { - return fmt.Errorf("could not get resolver for default scheme: %q", parsedTarget.URL.Scheme) - } - cc.parsedTarget = parsedTarget - cc.resolverBuilder = rb - return nil -} - -// parseTarget uses RFC 3986 semantics to parse the given target into a -// resolver.Target struct containing url. Query params are stripped from the -// endpoint. -func parseTarget(target string) (resolver.Target, error) { - u, err := url.Parse(target) - if err != nil { - return resolver.Target{}, err - } - - return resolver.Target{URL: *u}, nil -} - -// encodeAuthority escapes the authority string based on valid chars defined in -// https://datatracker.ietf.org/doc/html/rfc3986#section-3.2. -func encodeAuthority(authority string) string { - const upperhex = "0123456789ABCDEF" - - // Return for characters that must be escaped as per - // Valid chars are mentioned here: - // https://datatracker.ietf.org/doc/html/rfc3986#section-3.2 - shouldEscape := func(c byte) bool { - // Alphanum are always allowed. - if 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z' || '0' <= c && c <= '9' { - return false - } - switch c { - case '-', '_', '.', '~': // Unreserved characters - return false - case '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=': // Subdelim characters - return false - case ':', '[', ']', '@': // Authority related delimeters - return false - } - // Everything else must be escaped. - return true - } - - hexCount := 0 - for i := 0; i < len(authority); i++ { - c := authority[i] - if shouldEscape(c) { - hexCount++ - } - } - - if hexCount == 0 { - return authority - } - - required := len(authority) + 2*hexCount - t := make([]byte, required) - - j := 0 - // This logic is a barebones version of escape in the go net/url library. - for i := 0; i < len(authority); i++ { - switch c := authority[i]; { - case shouldEscape(c): - t[j] = '%' - t[j+1] = upperhex[c>>4] - t[j+2] = upperhex[c&15] - j += 3 - default: - t[j] = authority[i] - j++ - } - } - return string(t) -} - -// Determine channel authority. The order of precedence is as follows: -// - user specified authority override using `WithAuthority` dial option -// - creds' notion of server name for the authentication handshake -// - endpoint from dial target of the form "scheme://[authority]/endpoint" -// -// Stores the determined authority in `cc.authority`. -// -// Returns a non-nil error if the authority returned by the transport -// credentials do not match the authority configured through the dial option. -// -// Doesn't grab cc.mu as this method is expected to be called only at Dial time. -func (cc *ClientConn) determineAuthority() error { - dopts := cc.dopts - // Historically, we had two options for users to specify the serverName or - // authority for a channel. One was through the transport credentials - // (either in its constructor, or through the OverrideServerName() method). - // The other option (for cases where WithInsecure() dial option was used) - // was to use the WithAuthority() dial option. - // - // A few things have changed since: - // - `insecure` package with an implementation of the `TransportCredentials` - // interface for the insecure case - // - WithAuthority() dial option support for secure credentials - authorityFromCreds := "" - if creds := dopts.copts.TransportCredentials; creds != nil && creds.Info().ServerName != "" { - authorityFromCreds = creds.Info().ServerName - } - authorityFromDialOption := dopts.authority - if (authorityFromCreds != "" && authorityFromDialOption != "") && authorityFromCreds != authorityFromDialOption { - return fmt.Errorf("ClientConn's authority from transport creds %q and dial option %q don't match", authorityFromCreds, authorityFromDialOption) - } - - endpoint := cc.parsedTarget.Endpoint() - if authorityFromDialOption != "" { - cc.authority = authorityFromDialOption - } else if authorityFromCreds != "" { - cc.authority = authorityFromCreds - } else if auth, ok := cc.resolverBuilder.(resolver.AuthorityOverrider); ok { - cc.authority = auth.OverrideAuthority(cc.parsedTarget) - } else if strings.HasPrefix(endpoint, ":") { - cc.authority = "localhost" + endpoint - } else { - cc.authority = encodeAuthority(endpoint) - } - channelz.Infof(logger, cc.channelz, "Channel authority set to %q", cc.authority) - return nil -} diff --git a/vendor/google.golang.org/grpc/codec.go b/vendor/google.golang.org/grpc/codec.go deleted file mode 100644 index 411e3dfd4..000000000 --- a/vendor/google.golang.org/grpc/codec.go +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * Copyright 2014 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpc - -import ( - "google.golang.org/grpc/encoding" - _ "google.golang.org/grpc/encoding/proto" // to register the Codec for "proto" -) - -// baseCodec contains the functionality of both Codec and encoding.Codec, but -// omits the name/string, which vary between the two and are not needed for -// anything besides the registry in the encoding package. -type baseCodec interface { - Marshal(v any) ([]byte, error) - Unmarshal(data []byte, v any) error -} - -var _ baseCodec = Codec(nil) -var _ baseCodec = encoding.Codec(nil) - -// Codec defines the interface gRPC uses to encode and decode messages. -// Note that implementations of this interface must be thread safe; -// a Codec's methods can be called from concurrent goroutines. -// -// Deprecated: use encoding.Codec instead. -type Codec interface { - // Marshal returns the wire format of v. - Marshal(v any) ([]byte, error) - // Unmarshal parses the wire format into v. - Unmarshal(data []byte, v any) error - // String returns the name of the Codec implementation. This is unused by - // gRPC. - String() string -} diff --git a/vendor/google.golang.org/grpc/codegen.sh b/vendor/google.golang.org/grpc/codegen.sh deleted file mode 100644 index 4cdc6ba7c..000000000 --- a/vendor/google.golang.org/grpc/codegen.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -# This script serves as an example to demonstrate how to generate the gRPC-Go -# interface and the related messages from .proto file. -# -# It assumes the installation of i) Google proto buffer compiler at -# https://github.com/google/protobuf (after v2.6.1) and ii) the Go codegen -# plugin at https://github.com/golang/protobuf (after 2015-02-20). If you have -# not, please install them first. -# -# We recommend running this script at $GOPATH/src. -# -# If this is not what you need, feel free to make your own scripts. Again, this -# script is for demonstration purpose. -# -proto=$1 -protoc --go_out=plugins=grpc:. $proto diff --git a/vendor/google.golang.org/grpc/codes/code_string.go b/vendor/google.golang.org/grpc/codes/code_string.go deleted file mode 100644 index 934fac2b0..000000000 --- a/vendor/google.golang.org/grpc/codes/code_string.go +++ /dev/null @@ -1,111 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package codes - -import ( - "strconv" - - "google.golang.org/grpc/internal" -) - -func init() { - internal.CanonicalString = canonicalString -} - -func (c Code) String() string { - switch c { - case OK: - return "OK" - case Canceled: - return "Canceled" - case Unknown: - return "Unknown" - case InvalidArgument: - return "InvalidArgument" - case DeadlineExceeded: - return "DeadlineExceeded" - case NotFound: - return "NotFound" - case AlreadyExists: - return "AlreadyExists" - case PermissionDenied: - return "PermissionDenied" - case ResourceExhausted: - return "ResourceExhausted" - case FailedPrecondition: - return "FailedPrecondition" - case Aborted: - return "Aborted" - case OutOfRange: - return "OutOfRange" - case Unimplemented: - return "Unimplemented" - case Internal: - return "Internal" - case Unavailable: - return "Unavailable" - case DataLoss: - return "DataLoss" - case Unauthenticated: - return "Unauthenticated" - default: - return "Code(" + strconv.FormatInt(int64(c), 10) + ")" - } -} - -func canonicalString(c Code) string { - switch c { - case OK: - return "OK" - case Canceled: - return "CANCELLED" - case Unknown: - return "UNKNOWN" - case InvalidArgument: - return "INVALID_ARGUMENT" - case DeadlineExceeded: - return "DEADLINE_EXCEEDED" - case NotFound: - return "NOT_FOUND" - case AlreadyExists: - return "ALREADY_EXISTS" - case PermissionDenied: - return "PERMISSION_DENIED" - case ResourceExhausted: - return "RESOURCE_EXHAUSTED" - case FailedPrecondition: - return "FAILED_PRECONDITION" - case Aborted: - return "ABORTED" - case OutOfRange: - return "OUT_OF_RANGE" - case Unimplemented: - return "UNIMPLEMENTED" - case Internal: - return "INTERNAL" - case Unavailable: - return "UNAVAILABLE" - case DataLoss: - return "DATA_LOSS" - case Unauthenticated: - return "UNAUTHENTICATED" - default: - return "CODE(" + strconv.FormatInt(int64(c), 10) + ")" - } -} diff --git a/vendor/google.golang.org/grpc/codes/codes.go b/vendor/google.golang.org/grpc/codes/codes.go deleted file mode 100644 index 08476ad1f..000000000 --- a/vendor/google.golang.org/grpc/codes/codes.go +++ /dev/null @@ -1,250 +0,0 @@ -/* - * - * Copyright 2014 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package codes defines the canonical error codes used by gRPC. It is -// consistent across various languages. -package codes // import "google.golang.org/grpc/codes" - -import ( - "fmt" - "strconv" -) - -// A Code is a status code defined according to the [gRPC documentation]. -// -// Only the codes defined as consts in this package are valid codes. Do not use -// other code values. Behavior of other codes is implementation-specific and -// interoperability between implementations is not guaranteed. -// -// [gRPC documentation]: https://github.com/grpc/grpc/blob/master/doc/statuscodes.md -type Code uint32 - -const ( - // OK is returned on success. - OK Code = 0 - - // Canceled indicates the operation was canceled (typically by the caller). - // - // The gRPC framework will generate this error code when cancellation - // is requested. - Canceled Code = 1 - - // Unknown error. An example of where this error may be returned is - // if a Status value received from another address space belongs to - // an error-space that is not known in this address space. Also - // errors raised by APIs that do not return enough error information - // may be converted to this error. - // - // The gRPC framework will generate this error code in the above two - // mentioned cases. - Unknown Code = 2 - - // InvalidArgument indicates client specified an invalid argument. - // Note that this differs from FailedPrecondition. It indicates arguments - // that are problematic regardless of the state of the system - // (e.g., a malformed file name). - // - // This error code will not be generated by the gRPC framework. - InvalidArgument Code = 3 - - // DeadlineExceeded means operation expired before completion. - // For operations that change the state of the system, this error may be - // returned even if the operation has completed successfully. For - // example, a successful response from a server could have been delayed - // long enough for the deadline to expire. - // - // The gRPC framework will generate this error code when the deadline is - // exceeded. - DeadlineExceeded Code = 4 - - // NotFound means some requested entity (e.g., file or directory) was - // not found. - // - // This error code will not be generated by the gRPC framework. - NotFound Code = 5 - - // AlreadyExists means an attempt to create an entity failed because one - // already exists. - // - // This error code will not be generated by the gRPC framework. - AlreadyExists Code = 6 - - // PermissionDenied indicates the caller does not have permission to - // execute the specified operation. It must not be used for rejections - // caused by exhausting some resource (use ResourceExhausted - // instead for those errors). It must not be - // used if the caller cannot be identified (use Unauthenticated - // instead for those errors). - // - // This error code will not be generated by the gRPC core framework, - // but expect authentication middleware to use it. - PermissionDenied Code = 7 - - // ResourceExhausted indicates some resource has been exhausted, perhaps - // a per-user quota, or perhaps the entire file system is out of space. - // - // This error code will be generated by the gRPC framework in - // out-of-memory and server overload situations, or when a message is - // larger than the configured maximum size. - ResourceExhausted Code = 8 - - // FailedPrecondition indicates operation was rejected because the - // system is not in a state required for the operation's execution. - // For example, directory to be deleted may be non-empty, an rmdir - // operation is applied to a non-directory, etc. - // - // A litmus test that may help a service implementor in deciding - // between FailedPrecondition, Aborted, and Unavailable: - // (a) Use Unavailable if the client can retry just the failing call. - // (b) Use Aborted if the client should retry at a higher-level - // (e.g., restarting a read-modify-write sequence). - // (c) Use FailedPrecondition if the client should not retry until - // the system state has been explicitly fixed. E.g., if an "rmdir" - // fails because the directory is non-empty, FailedPrecondition - // should be returned since the client should not retry unless - // they have first fixed up the directory by deleting files from it. - // (d) Use FailedPrecondition if the client performs conditional - // REST Get/Update/Delete on a resource and the resource on the - // server does not match the condition. E.g., conflicting - // read-modify-write on the same resource. - // - // This error code will not be generated by the gRPC framework. - FailedPrecondition Code = 9 - - // Aborted indicates the operation was aborted, typically due to a - // concurrency issue like sequencer check failures, transaction aborts, - // etc. - // - // See litmus test above for deciding between FailedPrecondition, - // Aborted, and Unavailable. - // - // This error code will not be generated by the gRPC framework. - Aborted Code = 10 - - // OutOfRange means operation was attempted past the valid range. - // E.g., seeking or reading past end of file. - // - // Unlike InvalidArgument, this error indicates a problem that may - // be fixed if the system state changes. For example, a 32-bit file - // system will generate InvalidArgument if asked to read at an - // offset that is not in the range [0,2^32-1], but it will generate - // OutOfRange if asked to read from an offset past the current - // file size. - // - // There is a fair bit of overlap between FailedPrecondition and - // OutOfRange. We recommend using OutOfRange (the more specific - // error) when it applies so that callers who are iterating through - // a space can easily look for an OutOfRange error to detect when - // they are done. - // - // This error code will not be generated by the gRPC framework. - OutOfRange Code = 11 - - // Unimplemented indicates operation is not implemented or not - // supported/enabled in this service. - // - // This error code will be generated by the gRPC framework. Most - // commonly, you will see this error code when a method implementation - // is missing on the server. It can also be generated for unknown - // compression algorithms or a disagreement as to whether an RPC should - // be streaming. - Unimplemented Code = 12 - - // Internal errors. Means some invariants expected by underlying - // system has been broken. If you see one of these errors, - // something is very broken. - // - // This error code will be generated by the gRPC framework in several - // internal error conditions. - Internal Code = 13 - - // Unavailable indicates the service is currently unavailable. - // This is a most likely a transient condition and may be corrected - // by retrying with a backoff. Note that it is not always safe to retry - // non-idempotent operations. - // - // See litmus test above for deciding between FailedPrecondition, - // Aborted, and Unavailable. - // - // This error code will be generated by the gRPC framework during - // abrupt shutdown of a server process or network connection. - Unavailable Code = 14 - - // DataLoss indicates unrecoverable data loss or corruption. - // - // This error code will not be generated by the gRPC framework. - DataLoss Code = 15 - - // Unauthenticated indicates the request does not have valid - // authentication credentials for the operation. - // - // The gRPC framework will generate this error code when the - // authentication metadata is invalid or a Credentials callback fails, - // but also expect authentication middleware to generate it. - Unauthenticated Code = 16 - - _maxCode = 17 -) - -var strToCode = map[string]Code{ - `"OK"`: OK, - `"CANCELLED"`:/* [sic] */ Canceled, - `"UNKNOWN"`: Unknown, - `"INVALID_ARGUMENT"`: InvalidArgument, - `"DEADLINE_EXCEEDED"`: DeadlineExceeded, - `"NOT_FOUND"`: NotFound, - `"ALREADY_EXISTS"`: AlreadyExists, - `"PERMISSION_DENIED"`: PermissionDenied, - `"RESOURCE_EXHAUSTED"`: ResourceExhausted, - `"FAILED_PRECONDITION"`: FailedPrecondition, - `"ABORTED"`: Aborted, - `"OUT_OF_RANGE"`: OutOfRange, - `"UNIMPLEMENTED"`: Unimplemented, - `"INTERNAL"`: Internal, - `"UNAVAILABLE"`: Unavailable, - `"DATA_LOSS"`: DataLoss, - `"UNAUTHENTICATED"`: Unauthenticated, -} - -// UnmarshalJSON unmarshals b into the Code. -func (c *Code) UnmarshalJSON(b []byte) error { - // From json.Unmarshaler: By convention, to approximate the behavior of - // Unmarshal itself, Unmarshalers implement UnmarshalJSON([]byte("null")) as - // a no-op. - if string(b) == "null" { - return nil - } - if c == nil { - return fmt.Errorf("nil receiver passed to UnmarshalJSON") - } - - if ci, err := strconv.ParseUint(string(b), 10, 32); err == nil { - if ci >= _maxCode { - return fmt.Errorf("invalid code: %q", ci) - } - - *c = Code(ci) - return nil - } - - if jc, ok := strToCode[string(b)]; ok { - *c = jc - return nil - } - return fmt.Errorf("invalid code: %q", string(b)) -} diff --git a/vendor/google.golang.org/grpc/connectivity/connectivity.go b/vendor/google.golang.org/grpc/connectivity/connectivity.go deleted file mode 100644 index 4a8992642..000000000 --- a/vendor/google.golang.org/grpc/connectivity/connectivity.go +++ /dev/null @@ -1,94 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package connectivity defines connectivity semantics. -// For details, see https://github.com/grpc/grpc/blob/master/doc/connectivity-semantics-and-api.md. -package connectivity - -import ( - "google.golang.org/grpc/grpclog" -) - -var logger = grpclog.Component("core") - -// State indicates the state of connectivity. -// It can be the state of a ClientConn or SubConn. -type State int - -func (s State) String() string { - switch s { - case Idle: - return "IDLE" - case Connecting: - return "CONNECTING" - case Ready: - return "READY" - case TransientFailure: - return "TRANSIENT_FAILURE" - case Shutdown: - return "SHUTDOWN" - default: - logger.Errorf("unknown connectivity state: %d", s) - return "INVALID_STATE" - } -} - -const ( - // Idle indicates the ClientConn is idle. - Idle State = iota - // Connecting indicates the ClientConn is connecting. - Connecting - // Ready indicates the ClientConn is ready for work. - Ready - // TransientFailure indicates the ClientConn has seen a failure but expects to recover. - TransientFailure - // Shutdown indicates the ClientConn has started shutting down. - Shutdown -) - -// ServingMode indicates the current mode of operation of the server. -// -// Only xDS enabled gRPC servers currently report their serving mode. -type ServingMode int - -const ( - // ServingModeStarting indicates that the server is starting up. - ServingModeStarting ServingMode = iota - // ServingModeServing indicates that the server contains all required - // configuration and is serving RPCs. - ServingModeServing - // ServingModeNotServing indicates that the server is not accepting new - // connections. Existing connections will be closed gracefully, allowing - // in-progress RPCs to complete. A server enters this mode when it does not - // contain the required configuration to serve RPCs. - ServingModeNotServing -) - -func (s ServingMode) String() string { - switch s { - case ServingModeStarting: - return "STARTING" - case ServingModeServing: - return "SERVING" - case ServingModeNotServing: - return "NOT_SERVING" - default: - logger.Errorf("unknown serving mode: %d", s) - return "INVALID_MODE" - } -} diff --git a/vendor/google.golang.org/grpc/credentials/credentials.go b/vendor/google.golang.org/grpc/credentials/credentials.go deleted file mode 100644 index f6b55c68b..000000000 --- a/vendor/google.golang.org/grpc/credentials/credentials.go +++ /dev/null @@ -1,291 +0,0 @@ -/* - * - * Copyright 2014 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package credentials implements various credentials supported by gRPC library, -// which encapsulate all the state needed by a client to authenticate with a -// server and make various assertions, e.g., about the client's identity, role, -// or whether it is authorized to make a particular call. -package credentials // import "google.golang.org/grpc/credentials" - -import ( - "context" - "errors" - "fmt" - "net" - - "google.golang.org/grpc/attributes" - icredentials "google.golang.org/grpc/internal/credentials" - "google.golang.org/protobuf/protoadapt" -) - -// PerRPCCredentials defines the common interface for the credentials which need to -// attach security information to every RPC (e.g., oauth2). -type PerRPCCredentials interface { - // GetRequestMetadata gets the current request metadata, refreshing tokens - // if required. This should be called by the transport layer on each - // request, and the data should be populated in headers or other - // context. If a status code is returned, it will be used as the status for - // the RPC (restricted to an allowable set of codes as defined by gRFC - // A54). uri is the URI of the entry point for the request. When supported - // by the underlying implementation, ctx can be used for timeout and - // cancellation. Additionally, RequestInfo data will be available via ctx - // to this call. TODO(zhaoq): Define the set of the qualified keys instead - // of leaving it as an arbitrary string. - GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) - // RequireTransportSecurity indicates whether the credentials requires - // transport security. - RequireTransportSecurity() bool -} - -// SecurityLevel defines the protection level on an established connection. -// -// This API is experimental. -type SecurityLevel int - -const ( - // InvalidSecurityLevel indicates an invalid security level. - // The zero SecurityLevel value is invalid for backward compatibility. - InvalidSecurityLevel SecurityLevel = iota - // NoSecurity indicates a connection is insecure. - NoSecurity - // IntegrityOnly indicates a connection only provides integrity protection. - IntegrityOnly - // PrivacyAndIntegrity indicates a connection provides both privacy and integrity protection. - PrivacyAndIntegrity -) - -// String returns SecurityLevel in a string format. -func (s SecurityLevel) String() string { - switch s { - case NoSecurity: - return "NoSecurity" - case IntegrityOnly: - return "IntegrityOnly" - case PrivacyAndIntegrity: - return "PrivacyAndIntegrity" - } - return fmt.Sprintf("invalid SecurityLevel: %v", int(s)) -} - -// CommonAuthInfo contains authenticated information common to AuthInfo implementations. -// It should be embedded in a struct implementing AuthInfo to provide additional information -// about the credentials. -// -// This API is experimental. -type CommonAuthInfo struct { - SecurityLevel SecurityLevel -} - -// GetCommonAuthInfo returns the pointer to CommonAuthInfo struct. -func (c CommonAuthInfo) GetCommonAuthInfo() CommonAuthInfo { - return c -} - -// ProtocolInfo provides information regarding the gRPC wire protocol version, -// security protocol, security protocol version in use, server name, etc. -type ProtocolInfo struct { - // ProtocolVersion is the gRPC wire protocol version. - ProtocolVersion string - // SecurityProtocol is the security protocol in use. - SecurityProtocol string - // SecurityVersion is the security protocol version. It is a static version string from the - // credentials, not a value that reflects per-connection protocol negotiation. To retrieve - // details about the credentials used for a connection, use the Peer's AuthInfo field instead. - // - // Deprecated: please use Peer.AuthInfo. - SecurityVersion string - // ServerName is the user-configured server name. - ServerName string -} - -// AuthInfo defines the common interface for the auth information the users are interested in. -// A struct that implements AuthInfo should embed CommonAuthInfo by including additional -// information about the credentials in it. -type AuthInfo interface { - AuthType() string -} - -// ErrConnDispatched indicates that rawConn has been dispatched out of gRPC -// and the caller should not close rawConn. -var ErrConnDispatched = errors.New("credentials: rawConn is dispatched out of gRPC") - -// TransportCredentials defines the common interface for all the live gRPC wire -// protocols and supported transport security protocols (e.g., TLS, SSL). -type TransportCredentials interface { - // ClientHandshake does the authentication handshake specified by the - // corresponding authentication protocol on rawConn for clients. It returns - // the authenticated connection and the corresponding auth information - // about the connection. The auth information should embed CommonAuthInfo - // to return additional information about the credentials. Implementations - // must use the provided context to implement timely cancellation. gRPC - // will try to reconnect if the error returned is a temporary error - // (io.EOF, context.DeadlineExceeded or err.Temporary() == true). If the - // returned error is a wrapper error, implementations should make sure that - // the error implements Temporary() to have the correct retry behaviors. - // Additionally, ClientHandshakeInfo data will be available via the context - // passed to this call. - // - // The second argument to this method is the `:authority` header value used - // while creating new streams on this connection after authentication - // succeeds. Implementations must use this as the server name during the - // authentication handshake. - // - // If the returned net.Conn is closed, it MUST close the net.Conn provided. - ClientHandshake(context.Context, string, net.Conn) (net.Conn, AuthInfo, error) - // ServerHandshake does the authentication handshake for servers. It returns - // the authenticated connection and the corresponding auth information about - // the connection. The auth information should embed CommonAuthInfo to return additional information - // about the credentials. - // - // If the returned net.Conn is closed, it MUST close the net.Conn provided. - ServerHandshake(net.Conn) (net.Conn, AuthInfo, error) - // Info provides the ProtocolInfo of this TransportCredentials. - Info() ProtocolInfo - // Clone makes a copy of this TransportCredentials. - Clone() TransportCredentials - // OverrideServerName specifies the value used for the following: - // - verifying the hostname on the returned certificates - // - as SNI in the client's handshake to support virtual hosting - // - as the value for `:authority` header at stream creation time - // - // Deprecated: use grpc.WithAuthority instead. Will be supported - // throughout 1.x. - OverrideServerName(string) error -} - -// Bundle is a combination of TransportCredentials and PerRPCCredentials. -// -// It also contains a mode switching method, so it can be used as a combination -// of different credential policies. -// -// Bundle cannot be used together with individual TransportCredentials. -// PerRPCCredentials from Bundle will be appended to other PerRPCCredentials. -// -// This API is experimental. -type Bundle interface { - // TransportCredentials returns the transport credentials from the Bundle. - // - // Implementations must return non-nil transport credentials. If transport - // security is not needed by the Bundle, implementations may choose to - // return insecure.NewCredentials(). - TransportCredentials() TransportCredentials - - // PerRPCCredentials returns the per-RPC credentials from the Bundle. - // - // May be nil if per-RPC credentials are not needed. - PerRPCCredentials() PerRPCCredentials - - // NewWithMode should make a copy of Bundle, and switch mode. Modifying the - // existing Bundle may cause races. - // - // NewWithMode returns nil if the requested mode is not supported. - NewWithMode(mode string) (Bundle, error) -} - -// RequestInfo contains request data attached to the context passed to GetRequestMetadata calls. -// -// This API is experimental. -type RequestInfo struct { - // The method passed to Invoke or NewStream for this RPC. (For proto methods, this has the format "/some.Service/Method") - Method string - // AuthInfo contains the information from a security handshake (TransportCredentials.ClientHandshake, TransportCredentials.ServerHandshake) - AuthInfo AuthInfo -} - -// RequestInfoFromContext extracts the RequestInfo from the context if it exists. -// -// This API is experimental. -func RequestInfoFromContext(ctx context.Context) (ri RequestInfo, ok bool) { - ri, ok = icredentials.RequestInfoFromContext(ctx).(RequestInfo) - return ri, ok -} - -// ClientHandshakeInfo holds data to be passed to ClientHandshake. This makes -// it possible to pass arbitrary data to the handshaker from gRPC, resolver, -// balancer etc. Individual credential implementations control the actual -// format of the data that they are willing to receive. -// -// This API is experimental. -type ClientHandshakeInfo struct { - // Attributes contains the attributes for the address. It could be provided - // by the gRPC, resolver, balancer etc. - Attributes *attributes.Attributes -} - -// ClientHandshakeInfoFromContext returns the ClientHandshakeInfo struct stored -// in ctx. -// -// This API is experimental. -func ClientHandshakeInfoFromContext(ctx context.Context) ClientHandshakeInfo { - chi, _ := icredentials.ClientHandshakeInfoFromContext(ctx).(ClientHandshakeInfo) - return chi -} - -// CheckSecurityLevel checks if a connection's security level is greater than or equal to the specified one. -// It returns success if 1) the condition is satisified or 2) AuthInfo struct does not implement GetCommonAuthInfo() method -// or 3) CommonAuthInfo.SecurityLevel has an invalid zero value. For 2) and 3), it is for the purpose of backward-compatibility. -// -// This API is experimental. -func CheckSecurityLevel(ai AuthInfo, level SecurityLevel) error { - type internalInfo interface { - GetCommonAuthInfo() CommonAuthInfo - } - if ai == nil { - return errors.New("AuthInfo is nil") - } - if ci, ok := ai.(internalInfo); ok { - // CommonAuthInfo.SecurityLevel has an invalid value. - if ci.GetCommonAuthInfo().SecurityLevel == InvalidSecurityLevel { - return nil - } - if ci.GetCommonAuthInfo().SecurityLevel < level { - return fmt.Errorf("requires SecurityLevel %v; connection has %v", level, ci.GetCommonAuthInfo().SecurityLevel) - } - } - // The condition is satisfied or AuthInfo struct does not implement GetCommonAuthInfo() method. - return nil -} - -// ChannelzSecurityInfo defines the interface that security protocols should implement -// in order to provide security info to channelz. -// -// This API is experimental. -type ChannelzSecurityInfo interface { - GetSecurityValue() ChannelzSecurityValue -} - -// ChannelzSecurityValue defines the interface that GetSecurityValue() return value -// should satisfy. This interface should only be satisfied by *TLSChannelzSecurityValue -// and *OtherChannelzSecurityValue. -// -// This API is experimental. -type ChannelzSecurityValue interface { - isChannelzSecurityValue() -} - -// OtherChannelzSecurityValue defines the struct that non-TLS protocol should return -// from GetSecurityValue(), which contains protocol specific security info. Note -// the Value field will be sent to users of channelz requesting channel info, and -// thus sensitive info should better be avoided. -// -// This API is experimental. -type OtherChannelzSecurityValue struct { - ChannelzSecurityValue - Name string - Value protoadapt.MessageV1 -} diff --git a/vendor/google.golang.org/grpc/credentials/insecure/insecure.go b/vendor/google.golang.org/grpc/credentials/insecure/insecure.go deleted file mode 100644 index 82bee1443..000000000 --- a/vendor/google.golang.org/grpc/credentials/insecure/insecure.go +++ /dev/null @@ -1,98 +0,0 @@ -/* - * - * Copyright 2020 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package insecure provides an implementation of the -// credentials.TransportCredentials interface which disables transport security. -package insecure - -import ( - "context" - "net" - - "google.golang.org/grpc/credentials" -) - -// NewCredentials returns a credentials which disables transport security. -// -// Note that using this credentials with per-RPC credentials which require -// transport security is incompatible and will cause grpc.Dial() to fail. -func NewCredentials() credentials.TransportCredentials { - return insecureTC{} -} - -// insecureTC implements the insecure transport credentials. The handshake -// methods simply return the passed in net.Conn and set the security level to -// NoSecurity. -type insecureTC struct{} - -func (insecureTC) ClientHandshake(ctx context.Context, _ string, conn net.Conn) (net.Conn, credentials.AuthInfo, error) { - return conn, info{credentials.CommonAuthInfo{SecurityLevel: credentials.NoSecurity}}, nil -} - -func (insecureTC) ServerHandshake(conn net.Conn) (net.Conn, credentials.AuthInfo, error) { - return conn, info{credentials.CommonAuthInfo{SecurityLevel: credentials.NoSecurity}}, nil -} - -func (insecureTC) Info() credentials.ProtocolInfo { - return credentials.ProtocolInfo{SecurityProtocol: "insecure"} -} - -func (insecureTC) Clone() credentials.TransportCredentials { - return insecureTC{} -} - -func (insecureTC) OverrideServerName(string) error { - return nil -} - -// info contains the auth information for an insecure connection. -// It implements the AuthInfo interface. -type info struct { - credentials.CommonAuthInfo -} - -// AuthType returns the type of info as a string. -func (info) AuthType() string { - return "insecure" -} - -// insecureBundle implements an insecure bundle. -// An insecure bundle provides a thin wrapper around insecureTC to support -// the credentials.Bundle interface. -type insecureBundle struct{} - -// NewBundle returns a bundle with disabled transport security and no per rpc credential. -func NewBundle() credentials.Bundle { - return insecureBundle{} -} - -// NewWithMode returns a new insecure Bundle. The mode is ignored. -func (insecureBundle) NewWithMode(string) (credentials.Bundle, error) { - return insecureBundle{}, nil -} - -// PerRPCCredentials returns an nil implementation as insecure -// bundle does not support a per rpc credential. -func (insecureBundle) PerRPCCredentials() credentials.PerRPCCredentials { - return nil -} - -// TransportCredentials returns the underlying insecure transport credential. -func (insecureBundle) TransportCredentials() credentials.TransportCredentials { - return NewCredentials() -} diff --git a/vendor/google.golang.org/grpc/credentials/tls.go b/vendor/google.golang.org/grpc/credentials/tls.go deleted file mode 100644 index 5dafd34ed..000000000 --- a/vendor/google.golang.org/grpc/credentials/tls.go +++ /dev/null @@ -1,251 +0,0 @@ -/* - * - * Copyright 2014 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package credentials - -import ( - "context" - "crypto/tls" - "crypto/x509" - "fmt" - "net" - "net/url" - "os" - - credinternal "google.golang.org/grpc/internal/credentials" -) - -// TLSInfo contains the auth information for a TLS authenticated connection. -// It implements the AuthInfo interface. -type TLSInfo struct { - State tls.ConnectionState - CommonAuthInfo - // This API is experimental. - SPIFFEID *url.URL -} - -// AuthType returns the type of TLSInfo as a string. -func (t TLSInfo) AuthType() string { - return "tls" -} - -// cipherSuiteLookup returns the string version of a TLS cipher suite ID. -func cipherSuiteLookup(cipherSuiteID uint16) string { - for _, s := range tls.CipherSuites() { - if s.ID == cipherSuiteID { - return s.Name - } - } - for _, s := range tls.InsecureCipherSuites() { - if s.ID == cipherSuiteID { - return s.Name - } - } - return fmt.Sprintf("unknown ID: %v", cipherSuiteID) -} - -// GetSecurityValue returns security info requested by channelz. -func (t TLSInfo) GetSecurityValue() ChannelzSecurityValue { - v := &TLSChannelzSecurityValue{ - StandardName: cipherSuiteLookup(t.State.CipherSuite), - } - // Currently there's no way to get LocalCertificate info from tls package. - if len(t.State.PeerCertificates) > 0 { - v.RemoteCertificate = t.State.PeerCertificates[0].Raw - } - return v -} - -// tlsCreds is the credentials required for authenticating a connection using TLS. -type tlsCreds struct { - // TLS configuration - config *tls.Config -} - -func (c tlsCreds) Info() ProtocolInfo { - return ProtocolInfo{ - SecurityProtocol: "tls", - SecurityVersion: "1.2", - ServerName: c.config.ServerName, - } -} - -func (c *tlsCreds) ClientHandshake(ctx context.Context, authority string, rawConn net.Conn) (_ net.Conn, _ AuthInfo, err error) { - // use local cfg to avoid clobbering ServerName if using multiple endpoints - cfg := credinternal.CloneTLSConfig(c.config) - if cfg.ServerName == "" { - serverName, _, err := net.SplitHostPort(authority) - if err != nil { - // If the authority had no host port or if the authority cannot be parsed, use it as-is. - serverName = authority - } - cfg.ServerName = serverName - } - conn := tls.Client(rawConn, cfg) - errChannel := make(chan error, 1) - go func() { - errChannel <- conn.Handshake() - close(errChannel) - }() - select { - case err := <-errChannel: - if err != nil { - conn.Close() - return nil, nil, err - } - case <-ctx.Done(): - conn.Close() - return nil, nil, ctx.Err() - } - tlsInfo := TLSInfo{ - State: conn.ConnectionState(), - CommonAuthInfo: CommonAuthInfo{ - SecurityLevel: PrivacyAndIntegrity, - }, - } - id := credinternal.SPIFFEIDFromState(conn.ConnectionState()) - if id != nil { - tlsInfo.SPIFFEID = id - } - return credinternal.WrapSyscallConn(rawConn, conn), tlsInfo, nil -} - -func (c *tlsCreds) ServerHandshake(rawConn net.Conn) (net.Conn, AuthInfo, error) { - conn := tls.Server(rawConn, c.config) - if err := conn.Handshake(); err != nil { - conn.Close() - return nil, nil, err - } - tlsInfo := TLSInfo{ - State: conn.ConnectionState(), - CommonAuthInfo: CommonAuthInfo{ - SecurityLevel: PrivacyAndIntegrity, - }, - } - id := credinternal.SPIFFEIDFromState(conn.ConnectionState()) - if id != nil { - tlsInfo.SPIFFEID = id - } - return credinternal.WrapSyscallConn(rawConn, conn), tlsInfo, nil -} - -func (c *tlsCreds) Clone() TransportCredentials { - return NewTLS(c.config) -} - -func (c *tlsCreds) OverrideServerName(serverNameOverride string) error { - c.config.ServerName = serverNameOverride - return nil -} - -// The following cipher suites are forbidden for use with HTTP/2 by -// https://datatracker.ietf.org/doc/html/rfc7540#appendix-A -var tls12ForbiddenCipherSuites = map[uint16]struct{}{ - tls.TLS_RSA_WITH_AES_128_CBC_SHA: {}, - tls.TLS_RSA_WITH_AES_256_CBC_SHA: {}, - tls.TLS_RSA_WITH_AES_128_GCM_SHA256: {}, - tls.TLS_RSA_WITH_AES_256_GCM_SHA384: {}, - tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA: {}, - tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA: {}, - tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA: {}, - tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA: {}, -} - -// NewTLS uses c to construct a TransportCredentials based on TLS. -func NewTLS(c *tls.Config) TransportCredentials { - tc := &tlsCreds{credinternal.CloneTLSConfig(c)} - tc.config.NextProtos = credinternal.AppendH2ToNextProtos(tc.config.NextProtos) - // If the user did not configure a MinVersion and did not configure a - // MaxVersion < 1.2, use MinVersion=1.2, which is required by - // https://datatracker.ietf.org/doc/html/rfc7540#section-9.2 - if tc.config.MinVersion == 0 && (tc.config.MaxVersion == 0 || tc.config.MaxVersion >= tls.VersionTLS12) { - tc.config.MinVersion = tls.VersionTLS12 - } - // If the user did not configure CipherSuites, use all "secure" cipher - // suites reported by the TLS package, but remove some explicitly forbidden - // by https://datatracker.ietf.org/doc/html/rfc7540#appendix-A - if tc.config.CipherSuites == nil { - for _, cs := range tls.CipherSuites() { - if _, ok := tls12ForbiddenCipherSuites[cs.ID]; !ok { - tc.config.CipherSuites = append(tc.config.CipherSuites, cs.ID) - } - } - } - return tc -} - -// NewClientTLSFromCert constructs TLS credentials from the provided root -// certificate authority certificate(s) to validate server connections. If -// certificates to establish the identity of the client need to be included in -// the credentials (eg: for mTLS), use NewTLS instead, where a complete -// tls.Config can be specified. -// serverNameOverride is for testing only. If set to a non empty string, -// it will override the virtual host name of authority (e.g. :authority header -// field) in requests. -func NewClientTLSFromCert(cp *x509.CertPool, serverNameOverride string) TransportCredentials { - return NewTLS(&tls.Config{ServerName: serverNameOverride, RootCAs: cp}) -} - -// NewClientTLSFromFile constructs TLS credentials from the provided root -// certificate authority certificate file(s) to validate server connections. If -// certificates to establish the identity of the client need to be included in -// the credentials (eg: for mTLS), use NewTLS instead, where a complete -// tls.Config can be specified. -// serverNameOverride is for testing only. If set to a non empty string, -// it will override the virtual host name of authority (e.g. :authority header -// field) in requests. -func NewClientTLSFromFile(certFile, serverNameOverride string) (TransportCredentials, error) { - b, err := os.ReadFile(certFile) - if err != nil { - return nil, err - } - cp := x509.NewCertPool() - if !cp.AppendCertsFromPEM(b) { - return nil, fmt.Errorf("credentials: failed to append certificates") - } - return NewTLS(&tls.Config{ServerName: serverNameOverride, RootCAs: cp}), nil -} - -// NewServerTLSFromCert constructs TLS credentials from the input certificate for server. -func NewServerTLSFromCert(cert *tls.Certificate) TransportCredentials { - return NewTLS(&tls.Config{Certificates: []tls.Certificate{*cert}}) -} - -// NewServerTLSFromFile constructs TLS credentials from the input certificate file and key -// file for server. -func NewServerTLSFromFile(certFile, keyFile string) (TransportCredentials, error) { - cert, err := tls.LoadX509KeyPair(certFile, keyFile) - if err != nil { - return nil, err - } - return NewTLS(&tls.Config{Certificates: []tls.Certificate{cert}}), nil -} - -// TLSChannelzSecurityValue defines the struct that TLS protocol should return -// from GetSecurityValue(), containing security info like cipher and certificate used. -// -// # Experimental -// -// Notice: This type is EXPERIMENTAL and may be changed or removed in a -// later release. -type TLSChannelzSecurityValue struct { - ChannelzSecurityValue - StandardName string - LocalCertificate []byte - RemoteCertificate []byte -} diff --git a/vendor/google.golang.org/grpc/dialoptions.go b/vendor/google.golang.org/grpc/dialoptions.go deleted file mode 100644 index 402493224..000000000 --- a/vendor/google.golang.org/grpc/dialoptions.go +++ /dev/null @@ -1,726 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpc - -import ( - "context" - "net" - "time" - - "google.golang.org/grpc/backoff" - "google.golang.org/grpc/channelz" - "google.golang.org/grpc/credentials" - "google.golang.org/grpc/credentials/insecure" - "google.golang.org/grpc/internal" - internalbackoff "google.golang.org/grpc/internal/backoff" - "google.golang.org/grpc/internal/binarylog" - "google.golang.org/grpc/internal/transport" - "google.golang.org/grpc/keepalive" - "google.golang.org/grpc/resolver" - "google.golang.org/grpc/stats" -) - -func init() { - internal.AddGlobalDialOptions = func(opt ...DialOption) { - globalDialOptions = append(globalDialOptions, opt...) - } - internal.ClearGlobalDialOptions = func() { - globalDialOptions = nil - } - internal.WithBinaryLogger = withBinaryLogger - internal.JoinDialOptions = newJoinDialOption - internal.DisableGlobalDialOptions = newDisableGlobalDialOptions - internal.WithRecvBufferPool = withRecvBufferPool -} - -// dialOptions configure a Dial call. dialOptions are set by the DialOption -// values passed to Dial. -type dialOptions struct { - unaryInt UnaryClientInterceptor - streamInt StreamClientInterceptor - - chainUnaryInts []UnaryClientInterceptor - chainStreamInts []StreamClientInterceptor - - cp Compressor - dc Decompressor - bs internalbackoff.Strategy - block bool - returnLastError bool - timeout time.Duration - authority string - binaryLogger binarylog.Logger - copts transport.ConnectOptions - callOptions []CallOption - channelzParent channelz.Identifier - disableServiceConfig bool - disableRetry bool - disableHealthCheck bool - healthCheckFunc internal.HealthChecker - minConnectTimeout func() time.Duration - defaultServiceConfig *ServiceConfig // defaultServiceConfig is parsed from defaultServiceConfigRawJSON. - defaultServiceConfigRawJSON *string - resolvers []resolver.Builder - idleTimeout time.Duration - recvBufferPool SharedBufferPool - defaultScheme string -} - -// DialOption configures how we set up the connection. -type DialOption interface { - apply(*dialOptions) -} - -var globalDialOptions []DialOption - -// EmptyDialOption does not alter the dial configuration. It can be embedded in -// another structure to build custom dial options. -// -// # Experimental -// -// Notice: This type is EXPERIMENTAL and may be changed or removed in a -// later release. -type EmptyDialOption struct{} - -func (EmptyDialOption) apply(*dialOptions) {} - -type disableGlobalDialOptions struct{} - -func (disableGlobalDialOptions) apply(*dialOptions) {} - -// newDisableGlobalDialOptions returns a DialOption that prevents the ClientConn -// from applying the global DialOptions (set via AddGlobalDialOptions). -func newDisableGlobalDialOptions() DialOption { - return &disableGlobalDialOptions{} -} - -// funcDialOption wraps a function that modifies dialOptions into an -// implementation of the DialOption interface. -type funcDialOption struct { - f func(*dialOptions) -} - -func (fdo *funcDialOption) apply(do *dialOptions) { - fdo.f(do) -} - -func newFuncDialOption(f func(*dialOptions)) *funcDialOption { - return &funcDialOption{ - f: f, - } -} - -type joinDialOption struct { - opts []DialOption -} - -func (jdo *joinDialOption) apply(do *dialOptions) { - for _, opt := range jdo.opts { - opt.apply(do) - } -} - -func newJoinDialOption(opts ...DialOption) DialOption { - return &joinDialOption{opts: opts} -} - -// WithSharedWriteBuffer allows reusing per-connection transport write buffer. -// If this option is set to true every connection will release the buffer after -// flushing the data on the wire. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func WithSharedWriteBuffer(val bool) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.copts.SharedWriteBuffer = val - }) -} - -// WithWriteBufferSize determines how much data can be batched before doing a -// write on the wire. The default value for this buffer is 32KB. -// -// Zero or negative values will disable the write buffer such that each write -// will be on underlying connection. Note: A Send call may not directly -// translate to a write. -func WithWriteBufferSize(s int) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.copts.WriteBufferSize = s - }) -} - -// WithReadBufferSize lets you set the size of read buffer, this determines how -// much data can be read at most for each read syscall. -// -// The default value for this buffer is 32KB. Zero or negative values will -// disable read buffer for a connection so data framer can access the -// underlying conn directly. -func WithReadBufferSize(s int) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.copts.ReadBufferSize = s - }) -} - -// WithInitialWindowSize returns a DialOption which sets the value for initial -// window size on a stream. The lower bound for window size is 64K and any value -// smaller than that will be ignored. -func WithInitialWindowSize(s int32) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.copts.InitialWindowSize = s - }) -} - -// WithInitialConnWindowSize returns a DialOption which sets the value for -// initial window size on a connection. The lower bound for window size is 64K -// and any value smaller than that will be ignored. -func WithInitialConnWindowSize(s int32) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.copts.InitialConnWindowSize = s - }) -} - -// WithMaxMsgSize returns a DialOption which sets the maximum message size the -// client can receive. -// -// Deprecated: use WithDefaultCallOptions(MaxCallRecvMsgSize(s)) instead. Will -// be supported throughout 1.x. -func WithMaxMsgSize(s int) DialOption { - return WithDefaultCallOptions(MaxCallRecvMsgSize(s)) -} - -// WithDefaultCallOptions returns a DialOption which sets the default -// CallOptions for calls over the connection. -func WithDefaultCallOptions(cos ...CallOption) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.callOptions = append(o.callOptions, cos...) - }) -} - -// WithCodec returns a DialOption which sets a codec for message marshaling and -// unmarshaling. -// -// Deprecated: use WithDefaultCallOptions(ForceCodec(_)) instead. Will be -// supported throughout 1.x. -func WithCodec(c Codec) DialOption { - return WithDefaultCallOptions(CallCustomCodec(c)) -} - -// WithCompressor returns a DialOption which sets a Compressor to use for -// message compression. It has lower priority than the compressor set by the -// UseCompressor CallOption. -// -// Deprecated: use UseCompressor instead. Will be supported throughout 1.x. -func WithCompressor(cp Compressor) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.cp = cp - }) -} - -// WithDecompressor returns a DialOption which sets a Decompressor to use for -// incoming message decompression. If incoming response messages are encoded -// using the decompressor's Type(), it will be used. Otherwise, the message -// encoding will be used to look up the compressor registered via -// encoding.RegisterCompressor, which will then be used to decompress the -// message. If no compressor is registered for the encoding, an Unimplemented -// status error will be returned. -// -// Deprecated: use encoding.RegisterCompressor instead. Will be supported -// throughout 1.x. -func WithDecompressor(dc Decompressor) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.dc = dc - }) -} - -// WithConnectParams configures the ClientConn to use the provided ConnectParams -// for creating and maintaining connections to servers. -// -// The backoff configuration specified as part of the ConnectParams overrides -// all defaults specified in -// https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md. Consider -// using the backoff.DefaultConfig as a base, in cases where you want to -// override only a subset of the backoff configuration. -func WithConnectParams(p ConnectParams) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.bs = internalbackoff.Exponential{Config: p.Backoff} - o.minConnectTimeout = func() time.Duration { - return p.MinConnectTimeout - } - }) -} - -// WithBackoffMaxDelay configures the dialer to use the provided maximum delay -// when backing off after failed connection attempts. -// -// Deprecated: use WithConnectParams instead. Will be supported throughout 1.x. -func WithBackoffMaxDelay(md time.Duration) DialOption { - return WithBackoffConfig(BackoffConfig{MaxDelay: md}) -} - -// WithBackoffConfig configures the dialer to use the provided backoff -// parameters after connection failures. -// -// Deprecated: use WithConnectParams instead. Will be supported throughout 1.x. -func WithBackoffConfig(b BackoffConfig) DialOption { - bc := backoff.DefaultConfig - bc.MaxDelay = b.MaxDelay - return withBackoff(internalbackoff.Exponential{Config: bc}) -} - -// withBackoff sets the backoff strategy used for connectRetryNum after a failed -// connection attempt. -// -// This can be exported if arbitrary backoff strategies are allowed by gRPC. -func withBackoff(bs internalbackoff.Strategy) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.bs = bs - }) -} - -// WithBlock returns a DialOption which makes callers of Dial block until the -// underlying connection is up. Without this, Dial returns immediately and -// connecting the server happens in background. -// -// Use of this feature is not recommended. For more information, please see: -// https://github.com/grpc/grpc-go/blob/master/Documentation/anti-patterns.md -func WithBlock() DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.block = true - }) -} - -// WithReturnConnectionError returns a DialOption which makes the client connection -// return a string containing both the last connection error that occurred and -// the context.DeadlineExceeded error. -// Implies WithBlock() -// -// Use of this feature is not recommended. For more information, please see: -// https://github.com/grpc/grpc-go/blob/master/Documentation/anti-patterns.md -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func WithReturnConnectionError() DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.block = true - o.returnLastError = true - }) -} - -// WithInsecure returns a DialOption which disables transport security for this -// ClientConn. Under the hood, it uses insecure.NewCredentials(). -// -// Note that using this DialOption with per-RPC credentials (through -// WithCredentialsBundle or WithPerRPCCredentials) which require transport -// security is incompatible and will cause grpc.Dial() to fail. -// -// Deprecated: use WithTransportCredentials and insecure.NewCredentials() -// instead. Will be supported throughout 1.x. -func WithInsecure() DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.copts.TransportCredentials = insecure.NewCredentials() - }) -} - -// WithNoProxy returns a DialOption which disables the use of proxies for this -// ClientConn. This is ignored if WithDialer or WithContextDialer are used. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func WithNoProxy() DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.copts.UseProxy = false - }) -} - -// WithTransportCredentials returns a DialOption which configures a connection -// level security credentials (e.g., TLS/SSL). This should not be used together -// with WithCredentialsBundle. -func WithTransportCredentials(creds credentials.TransportCredentials) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.copts.TransportCredentials = creds - }) -} - -// WithPerRPCCredentials returns a DialOption which sets credentials and places -// auth state on each outbound RPC. -func WithPerRPCCredentials(creds credentials.PerRPCCredentials) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.copts.PerRPCCredentials = append(o.copts.PerRPCCredentials, creds) - }) -} - -// WithCredentialsBundle returns a DialOption to set a credentials bundle for -// the ClientConn.WithCreds. This should not be used together with -// WithTransportCredentials. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func WithCredentialsBundle(b credentials.Bundle) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.copts.CredsBundle = b - }) -} - -// WithTimeout returns a DialOption that configures a timeout for dialing a -// ClientConn initially. This is valid if and only if WithBlock() is present. -// -// Deprecated: use DialContext instead of Dial and context.WithTimeout -// instead. Will be supported throughout 1.x. -func WithTimeout(d time.Duration) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.timeout = d - }) -} - -// WithContextDialer returns a DialOption that sets a dialer to create -// connections. If FailOnNonTempDialError() is set to true, and an error is -// returned by f, gRPC checks the error's Temporary() method to decide if it -// should try to reconnect to the network address. -// -// Note: All supported releases of Go (as of December 2023) override the OS -// defaults for TCP keepalive time and interval to 15s. To enable TCP keepalive -// with OS defaults for keepalive time and interval, use a net.Dialer that sets -// the KeepAlive field to a negative value, and sets the SO_KEEPALIVE socket -// option to true from the Control field. For a concrete example of how to do -// this, see internal.NetDialerWithTCPKeepalive(). -// -// For more information, please see [issue 23459] in the Go github repo. -// -// [issue 23459]: https://github.com/golang/go/issues/23459 -func WithContextDialer(f func(context.Context, string) (net.Conn, error)) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.copts.Dialer = f - }) -} - -func init() { - internal.WithHealthCheckFunc = withHealthCheckFunc -} - -// WithDialer returns a DialOption that specifies a function to use for dialing -// network addresses. If FailOnNonTempDialError() is set to true, and an error -// is returned by f, gRPC checks the error's Temporary() method to decide if it -// should try to reconnect to the network address. -// -// Deprecated: use WithContextDialer instead. Will be supported throughout -// 1.x. -func WithDialer(f func(string, time.Duration) (net.Conn, error)) DialOption { - return WithContextDialer( - func(ctx context.Context, addr string) (net.Conn, error) { - if deadline, ok := ctx.Deadline(); ok { - return f(addr, time.Until(deadline)) - } - return f(addr, 0) - }) -} - -// WithStatsHandler returns a DialOption that specifies the stats handler for -// all the RPCs and underlying network connections in this ClientConn. -func WithStatsHandler(h stats.Handler) DialOption { - return newFuncDialOption(func(o *dialOptions) { - if h == nil { - logger.Error("ignoring nil parameter in grpc.WithStatsHandler ClientOption") - // Do not allow a nil stats handler, which would otherwise cause - // panics. - return - } - o.copts.StatsHandlers = append(o.copts.StatsHandlers, h) - }) -} - -// withBinaryLogger returns a DialOption that specifies the binary logger for -// this ClientConn. -func withBinaryLogger(bl binarylog.Logger) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.binaryLogger = bl - }) -} - -// FailOnNonTempDialError returns a DialOption that specifies if gRPC fails on -// non-temporary dial errors. If f is true, and dialer returns a non-temporary -// error, gRPC will fail the connection to the network address and won't try to -// reconnect. The default value of FailOnNonTempDialError is false. -// -// FailOnNonTempDialError only affects the initial dial, and does not do -// anything useful unless you are also using WithBlock(). -// -// Use of this feature is not recommended. For more information, please see: -// https://github.com/grpc/grpc-go/blob/master/Documentation/anti-patterns.md -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func FailOnNonTempDialError(f bool) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.copts.FailOnNonTempDialError = f - }) -} - -// WithUserAgent returns a DialOption that specifies a user agent string for all -// the RPCs. -func WithUserAgent(s string) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.copts.UserAgent = s + " " + grpcUA - }) -} - -// WithKeepaliveParams returns a DialOption that specifies keepalive parameters -// for the client transport. -func WithKeepaliveParams(kp keepalive.ClientParameters) DialOption { - if kp.Time < internal.KeepaliveMinPingTime { - logger.Warningf("Adjusting keepalive ping interval to minimum period of %v", internal.KeepaliveMinPingTime) - kp.Time = internal.KeepaliveMinPingTime - } - return newFuncDialOption(func(o *dialOptions) { - o.copts.KeepaliveParams = kp - }) -} - -// WithUnaryInterceptor returns a DialOption that specifies the interceptor for -// unary RPCs. -func WithUnaryInterceptor(f UnaryClientInterceptor) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.unaryInt = f - }) -} - -// WithChainUnaryInterceptor returns a DialOption that specifies the chained -// interceptor for unary RPCs. The first interceptor will be the outer most, -// while the last interceptor will be the inner most wrapper around the real call. -// All interceptors added by this method will be chained, and the interceptor -// defined by WithUnaryInterceptor will always be prepended to the chain. -func WithChainUnaryInterceptor(interceptors ...UnaryClientInterceptor) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.chainUnaryInts = append(o.chainUnaryInts, interceptors...) - }) -} - -// WithStreamInterceptor returns a DialOption that specifies the interceptor for -// streaming RPCs. -func WithStreamInterceptor(f StreamClientInterceptor) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.streamInt = f - }) -} - -// WithChainStreamInterceptor returns a DialOption that specifies the chained -// interceptor for streaming RPCs. The first interceptor will be the outer most, -// while the last interceptor will be the inner most wrapper around the real call. -// All interceptors added by this method will be chained, and the interceptor -// defined by WithStreamInterceptor will always be prepended to the chain. -func WithChainStreamInterceptor(interceptors ...StreamClientInterceptor) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.chainStreamInts = append(o.chainStreamInts, interceptors...) - }) -} - -// WithAuthority returns a DialOption that specifies the value to be used as the -// :authority pseudo-header and as the server name in authentication handshake. -func WithAuthority(a string) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.authority = a - }) -} - -// WithChannelzParentID returns a DialOption that specifies the channelz ID of -// current ClientConn's parent. This function is used in nested channel creation -// (e.g. grpclb dial). -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func WithChannelzParentID(c channelz.Identifier) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.channelzParent = c - }) -} - -// WithDisableServiceConfig returns a DialOption that causes gRPC to ignore any -// service config provided by the resolver and provides a hint to the resolver -// to not fetch service configs. -// -// Note that this dial option only disables service config from resolver. If -// default service config is provided, gRPC will use the default service config. -func WithDisableServiceConfig() DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.disableServiceConfig = true - }) -} - -// WithDefaultServiceConfig returns a DialOption that configures the default -// service config, which will be used in cases where: -// -// 1. WithDisableServiceConfig is also used, or -// -// 2. The name resolver does not provide a service config or provides an -// invalid service config. -// -// The parameter s is the JSON representation of the default service config. -// For more information about service configs, see: -// https://github.com/grpc/grpc/blob/master/doc/service_config.md -// For a simple example of usage, see: -// examples/features/load_balancing/client/main.go -func WithDefaultServiceConfig(s string) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.defaultServiceConfigRawJSON = &s - }) -} - -// WithDisableRetry returns a DialOption that disables retries, even if the -// service config enables them. This does not impact transparent retries, which -// will happen automatically if no data is written to the wire or if the RPC is -// unprocessed by the remote server. -func WithDisableRetry() DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.disableRetry = true - }) -} - -// WithMaxHeaderListSize returns a DialOption that specifies the maximum -// (uncompressed) size of header list that the client is prepared to accept. -func WithMaxHeaderListSize(s uint32) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.copts.MaxHeaderListSize = &s - }) -} - -// WithDisableHealthCheck disables the LB channel health checking for all -// SubConns of this ClientConn. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func WithDisableHealthCheck() DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.disableHealthCheck = true - }) -} - -// withHealthCheckFunc replaces the default health check function with the -// provided one. It makes tests easier to change the health check function. -// -// For testing purpose only. -func withHealthCheckFunc(f internal.HealthChecker) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.healthCheckFunc = f - }) -} - -func defaultDialOptions() dialOptions { - return dialOptions{ - copts: transport.ConnectOptions{ - ReadBufferSize: defaultReadBufSize, - WriteBufferSize: defaultWriteBufSize, - UseProxy: true, - UserAgent: grpcUA, - }, - bs: internalbackoff.DefaultExponential, - healthCheckFunc: internal.HealthCheckFunc, - idleTimeout: 30 * time.Minute, - recvBufferPool: nopBufferPool{}, - defaultScheme: "dns", - } -} - -// withGetMinConnectDeadline specifies the function that clientconn uses to -// get minConnectDeadline. This can be used to make connection attempts happen -// faster/slower. -// -// For testing purpose only. -func withMinConnectDeadline(f func() time.Duration) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.minConnectTimeout = f - }) -} - -// withDefaultScheme is used to allow Dial to use "passthrough" as the default -// name resolver, while NewClient uses "dns" otherwise. -func withDefaultScheme(s string) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.defaultScheme = s - }) -} - -// WithResolvers allows a list of resolver implementations to be registered -// locally with the ClientConn without needing to be globally registered via -// resolver.Register. They will be matched against the scheme used for the -// current Dial only, and will take precedence over the global registry. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func WithResolvers(rs ...resolver.Builder) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.resolvers = append(o.resolvers, rs...) - }) -} - -// WithIdleTimeout returns a DialOption that configures an idle timeout for the -// channel. If the channel is idle for the configured timeout, i.e there are no -// ongoing RPCs and no new RPCs are initiated, the channel will enter idle mode -// and as a result the name resolver and load balancer will be shut down. The -// channel will exit idle mode when the Connect() method is called or when an -// RPC is initiated. -// -// A default timeout of 30 minutes will be used if this dial option is not set -// at dial time and idleness can be disabled by passing a timeout of zero. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func WithIdleTimeout(d time.Duration) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.idleTimeout = d - }) -} - -// WithRecvBufferPool returns a DialOption that configures the ClientConn -// to use the provided shared buffer pool for parsing incoming messages. Depending -// on the application's workload, this could result in reduced memory allocation. -// -// If you are unsure about how to implement a memory pool but want to utilize one, -// begin with grpc.NewSharedBufferPool. -// -// Note: The shared buffer pool feature will not be active if any of the following -// options are used: WithStatsHandler, EnableTracing, or binary logging. In such -// cases, the shared buffer pool will be ignored. -// -// Deprecated: use experimental.WithRecvBufferPool instead. Will be deleted in -// v1.60.0 or later. -func WithRecvBufferPool(bufferPool SharedBufferPool) DialOption { - return withRecvBufferPool(bufferPool) -} - -func withRecvBufferPool(bufferPool SharedBufferPool) DialOption { - return newFuncDialOption(func(o *dialOptions) { - o.recvBufferPool = bufferPool - }) -} diff --git a/vendor/google.golang.org/grpc/doc.go b/vendor/google.golang.org/grpc/doc.go deleted file mode 100644 index 0022859ad..000000000 --- a/vendor/google.golang.org/grpc/doc.go +++ /dev/null @@ -1,26 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -//go:generate ./regenerate.sh - -/* -Package grpc implements an RPC system called gRPC. - -See grpc.io for more information about gRPC. -*/ -package grpc // import "google.golang.org/grpc" diff --git a/vendor/google.golang.org/grpc/encoding/encoding.go b/vendor/google.golang.org/grpc/encoding/encoding.go deleted file mode 100644 index 5ebf88d71..000000000 --- a/vendor/google.golang.org/grpc/encoding/encoding.go +++ /dev/null @@ -1,130 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package encoding defines the interface for the compressor and codec, and -// functions to register and retrieve compressors and codecs. -// -// # Experimental -// -// Notice: This package is EXPERIMENTAL and may be changed or removed in a -// later release. -package encoding - -import ( - "io" - "strings" - - "google.golang.org/grpc/internal/grpcutil" -) - -// Identity specifies the optional encoding for uncompressed streams. -// It is intended for grpc internal use only. -const Identity = "identity" - -// Compressor is used for compressing and decompressing when sending or -// receiving messages. -// -// If a Compressor implements `DecompressedSize(compressedBytes []byte) int`, -// gRPC will invoke it to determine the size of the buffer allocated for the -// result of decompression. A return value of -1 indicates unknown size. -type Compressor interface { - // Compress writes the data written to wc to w after compressing it. If an - // error occurs while initializing the compressor, that error is returned - // instead. - Compress(w io.Writer) (io.WriteCloser, error) - // Decompress reads data from r, decompresses it, and provides the - // uncompressed data via the returned io.Reader. If an error occurs while - // initializing the decompressor, that error is returned instead. - Decompress(r io.Reader) (io.Reader, error) - // Name is the name of the compression codec and is used to set the content - // coding header. The result must be static; the result cannot change - // between calls. - Name() string -} - -var registeredCompressor = make(map[string]Compressor) - -// RegisterCompressor registers the compressor with gRPC by its name. It can -// be activated when sending an RPC via grpc.UseCompressor(). It will be -// automatically accessed when receiving a message based on the content coding -// header. Servers also use it to send a response with the same encoding as -// the request. -// -// NOTE: this function must only be called during initialization time (i.e. in -// an init() function), and is not thread-safe. If multiple Compressors are -// registered with the same name, the one registered last will take effect. -func RegisterCompressor(c Compressor) { - registeredCompressor[c.Name()] = c - if !grpcutil.IsCompressorNameRegistered(c.Name()) { - grpcutil.RegisteredCompressorNames = append(grpcutil.RegisteredCompressorNames, c.Name()) - } -} - -// GetCompressor returns Compressor for the given compressor name. -func GetCompressor(name string) Compressor { - return registeredCompressor[name] -} - -// Codec defines the interface gRPC uses to encode and decode messages. Note -// that implementations of this interface must be thread safe; a Codec's -// methods can be called from concurrent goroutines. -type Codec interface { - // Marshal returns the wire format of v. - Marshal(v any) ([]byte, error) - // Unmarshal parses the wire format into v. - Unmarshal(data []byte, v any) error - // Name returns the name of the Codec implementation. The returned string - // will be used as part of content type in transmission. The result must be - // static; the result cannot change between calls. - Name() string -} - -var registeredCodecs = make(map[string]Codec) - -// RegisterCodec registers the provided Codec for use with all gRPC clients and -// servers. -// -// The Codec will be stored and looked up by result of its Name() method, which -// should match the content-subtype of the encoding handled by the Codec. This -// is case-insensitive, and is stored and looked up as lowercase. If the -// result of calling Name() is an empty string, RegisterCodec will panic. See -// Content-Type on -// https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests for -// more details. -// -// NOTE: this function must only be called during initialization time (i.e. in -// an init() function), and is not thread-safe. If multiple Codecs are -// registered with the same name, the one registered last will take effect. -func RegisterCodec(codec Codec) { - if codec == nil { - panic("cannot register a nil Codec") - } - if codec.Name() == "" { - panic("cannot register Codec with empty string result for Name()") - } - contentSubtype := strings.ToLower(codec.Name()) - registeredCodecs[contentSubtype] = codec -} - -// GetCodec gets a registered Codec by content-subtype, or nil if no Codec is -// registered for the content-subtype. -// -// The content-subtype is expected to be lowercase. -func GetCodec(contentSubtype string) Codec { - return registeredCodecs[contentSubtype] -} diff --git a/vendor/google.golang.org/grpc/encoding/proto/proto.go b/vendor/google.golang.org/grpc/encoding/proto/proto.go deleted file mode 100644 index 66d5cdf03..000000000 --- a/vendor/google.golang.org/grpc/encoding/proto/proto.go +++ /dev/null @@ -1,72 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package proto defines the protobuf codec. Importing this package will -// register the codec. -package proto - -import ( - "fmt" - - "google.golang.org/grpc/encoding" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/protoadapt" -) - -// Name is the name registered for the proto compressor. -const Name = "proto" - -func init() { - encoding.RegisterCodec(codec{}) -} - -// codec is a Codec implementation with protobuf. It is the default codec for gRPC. -type codec struct{} - -func (codec) Marshal(v any) ([]byte, error) { - vv := messageV2Of(v) - if vv == nil { - return nil, fmt.Errorf("failed to marshal, message is %T, want proto.Message", v) - } - - return proto.Marshal(vv) -} - -func (codec) Unmarshal(data []byte, v any) error { - vv := messageV2Of(v) - if vv == nil { - return fmt.Errorf("failed to unmarshal, message is %T, want proto.Message", v) - } - - return proto.Unmarshal(data, vv) -} - -func messageV2Of(v any) proto.Message { - switch v := v.(type) { - case protoadapt.MessageV1: - return protoadapt.MessageV2Of(v) - case protoadapt.MessageV2: - return v - } - - return nil -} - -func (codec) Name() string { - return Name -} diff --git a/vendor/google.golang.org/grpc/grpclog/component.go b/vendor/google.golang.org/grpc/grpclog/component.go deleted file mode 100644 index ac73c9ced..000000000 --- a/vendor/google.golang.org/grpc/grpclog/component.go +++ /dev/null @@ -1,117 +0,0 @@ -/* - * - * Copyright 2020 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpclog - -import ( - "fmt" - - "google.golang.org/grpc/internal/grpclog" -) - -// componentData records the settings for a component. -type componentData struct { - name string -} - -var cache = map[string]*componentData{} - -func (c *componentData) InfoDepth(depth int, args ...any) { - args = append([]any{"[" + string(c.name) + "]"}, args...) - grpclog.InfoDepth(depth+1, args...) -} - -func (c *componentData) WarningDepth(depth int, args ...any) { - args = append([]any{"[" + string(c.name) + "]"}, args...) - grpclog.WarningDepth(depth+1, args...) -} - -func (c *componentData) ErrorDepth(depth int, args ...any) { - args = append([]any{"[" + string(c.name) + "]"}, args...) - grpclog.ErrorDepth(depth+1, args...) -} - -func (c *componentData) FatalDepth(depth int, args ...any) { - args = append([]any{"[" + string(c.name) + "]"}, args...) - grpclog.FatalDepth(depth+1, args...) -} - -func (c *componentData) Info(args ...any) { - c.InfoDepth(1, args...) -} - -func (c *componentData) Warning(args ...any) { - c.WarningDepth(1, args...) -} - -func (c *componentData) Error(args ...any) { - c.ErrorDepth(1, args...) -} - -func (c *componentData) Fatal(args ...any) { - c.FatalDepth(1, args...) -} - -func (c *componentData) Infof(format string, args ...any) { - c.InfoDepth(1, fmt.Sprintf(format, args...)) -} - -func (c *componentData) Warningf(format string, args ...any) { - c.WarningDepth(1, fmt.Sprintf(format, args...)) -} - -func (c *componentData) Errorf(format string, args ...any) { - c.ErrorDepth(1, fmt.Sprintf(format, args...)) -} - -func (c *componentData) Fatalf(format string, args ...any) { - c.FatalDepth(1, fmt.Sprintf(format, args...)) -} - -func (c *componentData) Infoln(args ...any) { - c.InfoDepth(1, args...) -} - -func (c *componentData) Warningln(args ...any) { - c.WarningDepth(1, args...) -} - -func (c *componentData) Errorln(args ...any) { - c.ErrorDepth(1, args...) -} - -func (c *componentData) Fatalln(args ...any) { - c.FatalDepth(1, args...) -} - -func (c *componentData) V(l int) bool { - return V(l) -} - -// Component creates a new component and returns it for logging. If a component -// with the name already exists, nothing will be created and it will be -// returned. SetLoggerV2 will panic if it is called with a logger created by -// Component. -func Component(componentName string) DepthLoggerV2 { - if cData, ok := cache[componentName]; ok { - return cData - } - c := &componentData{componentName} - cache[componentName] = c - return c -} diff --git a/vendor/google.golang.org/grpc/grpclog/grpclog.go b/vendor/google.golang.org/grpc/grpclog/grpclog.go deleted file mode 100644 index 16928c9cb..000000000 --- a/vendor/google.golang.org/grpc/grpclog/grpclog.go +++ /dev/null @@ -1,132 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package grpclog defines logging for grpc. -// -// All logs in transport and grpclb packages only go to verbose level 2. -// All logs in other packages in grpc are logged in spite of the verbosity level. -// -// In the default logger, -// severity level can be set by environment variable GRPC_GO_LOG_SEVERITY_LEVEL, -// verbosity level can be set by GRPC_GO_LOG_VERBOSITY_LEVEL. -package grpclog // import "google.golang.org/grpc/grpclog" - -import ( - "os" - - "google.golang.org/grpc/internal/grpclog" -) - -func init() { - SetLoggerV2(newLoggerV2()) -} - -// V reports whether verbosity level l is at least the requested verbose level. -func V(l int) bool { - return grpclog.Logger.V(l) -} - -// Info logs to the INFO log. -func Info(args ...any) { - grpclog.Logger.Info(args...) -} - -// Infof logs to the INFO log. Arguments are handled in the manner of fmt.Printf. -func Infof(format string, args ...any) { - grpclog.Logger.Infof(format, args...) -} - -// Infoln logs to the INFO log. Arguments are handled in the manner of fmt.Println. -func Infoln(args ...any) { - grpclog.Logger.Infoln(args...) -} - -// Warning logs to the WARNING log. -func Warning(args ...any) { - grpclog.Logger.Warning(args...) -} - -// Warningf logs to the WARNING log. Arguments are handled in the manner of fmt.Printf. -func Warningf(format string, args ...any) { - grpclog.Logger.Warningf(format, args...) -} - -// Warningln logs to the WARNING log. Arguments are handled in the manner of fmt.Println. -func Warningln(args ...any) { - grpclog.Logger.Warningln(args...) -} - -// Error logs to the ERROR log. -func Error(args ...any) { - grpclog.Logger.Error(args...) -} - -// Errorf logs to the ERROR log. Arguments are handled in the manner of fmt.Printf. -func Errorf(format string, args ...any) { - grpclog.Logger.Errorf(format, args...) -} - -// Errorln logs to the ERROR log. Arguments are handled in the manner of fmt.Println. -func Errorln(args ...any) { - grpclog.Logger.Errorln(args...) -} - -// Fatal logs to the FATAL log. Arguments are handled in the manner of fmt.Print. -// It calls os.Exit() with exit code 1. -func Fatal(args ...any) { - grpclog.Logger.Fatal(args...) - // Make sure fatal logs will exit. - os.Exit(1) -} - -// Fatalf logs to the FATAL log. Arguments are handled in the manner of fmt.Printf. -// It calls os.Exit() with exit code 1. -func Fatalf(format string, args ...any) { - grpclog.Logger.Fatalf(format, args...) - // Make sure fatal logs will exit. - os.Exit(1) -} - -// Fatalln logs to the FATAL log. Arguments are handled in the manner of fmt.Println. -// It calle os.Exit()) with exit code 1. -func Fatalln(args ...any) { - grpclog.Logger.Fatalln(args...) - // Make sure fatal logs will exit. - os.Exit(1) -} - -// Print prints to the logger. Arguments are handled in the manner of fmt.Print. -// -// Deprecated: use Info. -func Print(args ...any) { - grpclog.Logger.Info(args...) -} - -// Printf prints to the logger. Arguments are handled in the manner of fmt.Printf. -// -// Deprecated: use Infof. -func Printf(format string, args ...any) { - grpclog.Logger.Infof(format, args...) -} - -// Println prints to the logger. Arguments are handled in the manner of fmt.Println. -// -// Deprecated: use Infoln. -func Println(args ...any) { - grpclog.Logger.Infoln(args...) -} diff --git a/vendor/google.golang.org/grpc/grpclog/logger.go b/vendor/google.golang.org/grpc/grpclog/logger.go deleted file mode 100644 index b1674d826..000000000 --- a/vendor/google.golang.org/grpc/grpclog/logger.go +++ /dev/null @@ -1,87 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpclog - -import "google.golang.org/grpc/internal/grpclog" - -// Logger mimics golang's standard Logger as an interface. -// -// Deprecated: use LoggerV2. -type Logger interface { - Fatal(args ...any) - Fatalf(format string, args ...any) - Fatalln(args ...any) - Print(args ...any) - Printf(format string, args ...any) - Println(args ...any) -} - -// SetLogger sets the logger that is used in grpc. Call only from -// init() functions. -// -// Deprecated: use SetLoggerV2. -func SetLogger(l Logger) { - grpclog.Logger = &loggerWrapper{Logger: l} -} - -// loggerWrapper wraps Logger into a LoggerV2. -type loggerWrapper struct { - Logger -} - -func (g *loggerWrapper) Info(args ...any) { - g.Logger.Print(args...) -} - -func (g *loggerWrapper) Infoln(args ...any) { - g.Logger.Println(args...) -} - -func (g *loggerWrapper) Infof(format string, args ...any) { - g.Logger.Printf(format, args...) -} - -func (g *loggerWrapper) Warning(args ...any) { - g.Logger.Print(args...) -} - -func (g *loggerWrapper) Warningln(args ...any) { - g.Logger.Println(args...) -} - -func (g *loggerWrapper) Warningf(format string, args ...any) { - g.Logger.Printf(format, args...) -} - -func (g *loggerWrapper) Error(args ...any) { - g.Logger.Print(args...) -} - -func (g *loggerWrapper) Errorln(args ...any) { - g.Logger.Println(args...) -} - -func (g *loggerWrapper) Errorf(format string, args ...any) { - g.Logger.Printf(format, args...) -} - -func (g *loggerWrapper) V(l int) bool { - // Returns true for all verbose level. - return true -} diff --git a/vendor/google.golang.org/grpc/grpclog/loggerv2.go b/vendor/google.golang.org/grpc/grpclog/loggerv2.go deleted file mode 100644 index ecfd36d71..000000000 --- a/vendor/google.golang.org/grpc/grpclog/loggerv2.go +++ /dev/null @@ -1,258 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpclog - -import ( - "encoding/json" - "fmt" - "io" - "log" - "os" - "strconv" - "strings" - - "google.golang.org/grpc/internal/grpclog" -) - -// LoggerV2 does underlying logging work for grpclog. -type LoggerV2 interface { - // Info logs to INFO log. Arguments are handled in the manner of fmt.Print. - Info(args ...any) - // Infoln logs to INFO log. Arguments are handled in the manner of fmt.Println. - Infoln(args ...any) - // Infof logs to INFO log. Arguments are handled in the manner of fmt.Printf. - Infof(format string, args ...any) - // Warning logs to WARNING log. Arguments are handled in the manner of fmt.Print. - Warning(args ...any) - // Warningln logs to WARNING log. Arguments are handled in the manner of fmt.Println. - Warningln(args ...any) - // Warningf logs to WARNING log. Arguments are handled in the manner of fmt.Printf. - Warningf(format string, args ...any) - // Error logs to ERROR log. Arguments are handled in the manner of fmt.Print. - Error(args ...any) - // Errorln logs to ERROR log. Arguments are handled in the manner of fmt.Println. - Errorln(args ...any) - // Errorf logs to ERROR log. Arguments are handled in the manner of fmt.Printf. - Errorf(format string, args ...any) - // Fatal logs to ERROR log. Arguments are handled in the manner of fmt.Print. - // gRPC ensures that all Fatal logs will exit with os.Exit(1). - // Implementations may also call os.Exit() with a non-zero exit code. - Fatal(args ...any) - // Fatalln logs to ERROR log. Arguments are handled in the manner of fmt.Println. - // gRPC ensures that all Fatal logs will exit with os.Exit(1). - // Implementations may also call os.Exit() with a non-zero exit code. - Fatalln(args ...any) - // Fatalf logs to ERROR log. Arguments are handled in the manner of fmt.Printf. - // gRPC ensures that all Fatal logs will exit with os.Exit(1). - // Implementations may also call os.Exit() with a non-zero exit code. - Fatalf(format string, args ...any) - // V reports whether verbosity level l is at least the requested verbose level. - V(l int) bool -} - -// SetLoggerV2 sets logger that is used in grpc to a V2 logger. -// Not mutex-protected, should be called before any gRPC functions. -func SetLoggerV2(l LoggerV2) { - if _, ok := l.(*componentData); ok { - panic("cannot use component logger as grpclog logger") - } - grpclog.Logger = l - grpclog.DepthLogger, _ = l.(grpclog.DepthLoggerV2) -} - -const ( - // infoLog indicates Info severity. - infoLog int = iota - // warningLog indicates Warning severity. - warningLog - // errorLog indicates Error severity. - errorLog - // fatalLog indicates Fatal severity. - fatalLog -) - -// severityName contains the string representation of each severity. -var severityName = []string{ - infoLog: "INFO", - warningLog: "WARNING", - errorLog: "ERROR", - fatalLog: "FATAL", -} - -// loggerT is the default logger used by grpclog. -type loggerT struct { - m []*log.Logger - v int - jsonFormat bool -} - -// NewLoggerV2 creates a loggerV2 with the provided writers. -// Fatal logs will be written to errorW, warningW, infoW, followed by exit(1). -// Error logs will be written to errorW, warningW and infoW. -// Warning logs will be written to warningW and infoW. -// Info logs will be written to infoW. -func NewLoggerV2(infoW, warningW, errorW io.Writer) LoggerV2 { - return newLoggerV2WithConfig(infoW, warningW, errorW, loggerV2Config{}) -} - -// NewLoggerV2WithVerbosity creates a loggerV2 with the provided writers and -// verbosity level. -func NewLoggerV2WithVerbosity(infoW, warningW, errorW io.Writer, v int) LoggerV2 { - return newLoggerV2WithConfig(infoW, warningW, errorW, loggerV2Config{verbose: v}) -} - -type loggerV2Config struct { - verbose int - jsonFormat bool -} - -func newLoggerV2WithConfig(infoW, warningW, errorW io.Writer, c loggerV2Config) LoggerV2 { - var m []*log.Logger - flag := log.LstdFlags - if c.jsonFormat { - flag = 0 - } - m = append(m, log.New(infoW, "", flag)) - m = append(m, log.New(io.MultiWriter(infoW, warningW), "", flag)) - ew := io.MultiWriter(infoW, warningW, errorW) // ew will be used for error and fatal. - m = append(m, log.New(ew, "", flag)) - m = append(m, log.New(ew, "", flag)) - return &loggerT{m: m, v: c.verbose, jsonFormat: c.jsonFormat} -} - -// newLoggerV2 creates a loggerV2 to be used as default logger. -// All logs are written to stderr. -func newLoggerV2() LoggerV2 { - errorW := io.Discard - warningW := io.Discard - infoW := io.Discard - - logLevel := os.Getenv("GRPC_GO_LOG_SEVERITY_LEVEL") - switch logLevel { - case "", "ERROR", "error": // If env is unset, set level to ERROR. - errorW = os.Stderr - case "WARNING", "warning": - warningW = os.Stderr - case "INFO", "info": - infoW = os.Stderr - } - - var v int - vLevel := os.Getenv("GRPC_GO_LOG_VERBOSITY_LEVEL") - if vl, err := strconv.Atoi(vLevel); err == nil { - v = vl - } - - jsonFormat := strings.EqualFold(os.Getenv("GRPC_GO_LOG_FORMATTER"), "json") - - return newLoggerV2WithConfig(infoW, warningW, errorW, loggerV2Config{ - verbose: v, - jsonFormat: jsonFormat, - }) -} - -func (g *loggerT) output(severity int, s string) { - sevStr := severityName[severity] - if !g.jsonFormat { - g.m[severity].Output(2, fmt.Sprintf("%v: %v", sevStr, s)) - return - } - // TODO: we can also include the logging component, but that needs more - // (API) changes. - b, _ := json.Marshal(map[string]string{ - "severity": sevStr, - "message": s, - }) - g.m[severity].Output(2, string(b)) -} - -func (g *loggerT) Info(args ...any) { - g.output(infoLog, fmt.Sprint(args...)) -} - -func (g *loggerT) Infoln(args ...any) { - g.output(infoLog, fmt.Sprintln(args...)) -} - -func (g *loggerT) Infof(format string, args ...any) { - g.output(infoLog, fmt.Sprintf(format, args...)) -} - -func (g *loggerT) Warning(args ...any) { - g.output(warningLog, fmt.Sprint(args...)) -} - -func (g *loggerT) Warningln(args ...any) { - g.output(warningLog, fmt.Sprintln(args...)) -} - -func (g *loggerT) Warningf(format string, args ...any) { - g.output(warningLog, fmt.Sprintf(format, args...)) -} - -func (g *loggerT) Error(args ...any) { - g.output(errorLog, fmt.Sprint(args...)) -} - -func (g *loggerT) Errorln(args ...any) { - g.output(errorLog, fmt.Sprintln(args...)) -} - -func (g *loggerT) Errorf(format string, args ...any) { - g.output(errorLog, fmt.Sprintf(format, args...)) -} - -func (g *loggerT) Fatal(args ...any) { - g.output(fatalLog, fmt.Sprint(args...)) - os.Exit(1) -} - -func (g *loggerT) Fatalln(args ...any) { - g.output(fatalLog, fmt.Sprintln(args...)) - os.Exit(1) -} - -func (g *loggerT) Fatalf(format string, args ...any) { - g.output(fatalLog, fmt.Sprintf(format, args...)) - os.Exit(1) -} - -func (g *loggerT) V(l int) bool { - return l <= g.v -} - -// DepthLoggerV2 logs at a specified call frame. If a LoggerV2 also implements -// DepthLoggerV2, the below functions will be called with the appropriate stack -// depth set for trivial functions the logger may ignore. -// -// # Experimental -// -// Notice: This type is EXPERIMENTAL and may be changed or removed in a -// later release. -type DepthLoggerV2 interface { - LoggerV2 - // InfoDepth logs to INFO log at the specified depth. Arguments are handled in the manner of fmt.Println. - InfoDepth(depth int, args ...any) - // WarningDepth logs to WARNING log at the specified depth. Arguments are handled in the manner of fmt.Println. - WarningDepth(depth int, args ...any) - // ErrorDepth logs to ERROR log at the specified depth. Arguments are handled in the manner of fmt.Println. - ErrorDepth(depth int, args ...any) - // FatalDepth logs to FATAL log at the specified depth. Arguments are handled in the manner of fmt.Println. - FatalDepth(depth int, args ...any) -} diff --git a/vendor/google.golang.org/grpc/interceptor.go b/vendor/google.golang.org/grpc/interceptor.go deleted file mode 100644 index 877d78fc3..000000000 --- a/vendor/google.golang.org/grpc/interceptor.go +++ /dev/null @@ -1,104 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpc - -import ( - "context" -) - -// UnaryInvoker is called by UnaryClientInterceptor to complete RPCs. -type UnaryInvoker func(ctx context.Context, method string, req, reply any, cc *ClientConn, opts ...CallOption) error - -// UnaryClientInterceptor intercepts the execution of a unary RPC on the client. -// Unary interceptors can be specified as a DialOption, using -// WithUnaryInterceptor() or WithChainUnaryInterceptor(), when creating a -// ClientConn. When a unary interceptor(s) is set on a ClientConn, gRPC -// delegates all unary RPC invocations to the interceptor, and it is the -// responsibility of the interceptor to call invoker to complete the processing -// of the RPC. -// -// method is the RPC name. req and reply are the corresponding request and -// response messages. cc is the ClientConn on which the RPC was invoked. invoker -// is the handler to complete the RPC and it is the responsibility of the -// interceptor to call it. opts contain all applicable call options, including -// defaults from the ClientConn as well as per-call options. -// -// The returned error must be compatible with the status package. -type UnaryClientInterceptor func(ctx context.Context, method string, req, reply any, cc *ClientConn, invoker UnaryInvoker, opts ...CallOption) error - -// Streamer is called by StreamClientInterceptor to create a ClientStream. -type Streamer func(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, opts ...CallOption) (ClientStream, error) - -// StreamClientInterceptor intercepts the creation of a ClientStream. Stream -// interceptors can be specified as a DialOption, using WithStreamInterceptor() -// or WithChainStreamInterceptor(), when creating a ClientConn. When a stream -// interceptor(s) is set on the ClientConn, gRPC delegates all stream creations -// to the interceptor, and it is the responsibility of the interceptor to call -// streamer. -// -// desc contains a description of the stream. cc is the ClientConn on which the -// RPC was invoked. streamer is the handler to create a ClientStream and it is -// the responsibility of the interceptor to call it. opts contain all applicable -// call options, including defaults from the ClientConn as well as per-call -// options. -// -// StreamClientInterceptor may return a custom ClientStream to intercept all I/O -// operations. The returned error must be compatible with the status package. -type StreamClientInterceptor func(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, streamer Streamer, opts ...CallOption) (ClientStream, error) - -// UnaryServerInfo consists of various information about a unary RPC on -// server side. All per-rpc information may be mutated by the interceptor. -type UnaryServerInfo struct { - // Server is the service implementation the user provides. This is read-only. - Server any - // FullMethod is the full RPC method string, i.e., /package.service/method. - FullMethod string -} - -// UnaryHandler defines the handler invoked by UnaryServerInterceptor to complete the normal -// execution of a unary RPC. -// -// If a UnaryHandler returns an error, it should either be produced by the -// status package, or be one of the context errors. Otherwise, gRPC will use -// codes.Unknown as the status code and err.Error() as the status message of the -// RPC. -type UnaryHandler func(ctx context.Context, req any) (any, error) - -// UnaryServerInterceptor provides a hook to intercept the execution of a unary RPC on the server. info -// contains all the information of this RPC the interceptor can operate on. And handler is the wrapper -// of the service method implementation. It is the responsibility of the interceptor to invoke handler -// to complete the RPC. -type UnaryServerInterceptor func(ctx context.Context, req any, info *UnaryServerInfo, handler UnaryHandler) (resp any, err error) - -// StreamServerInfo consists of various information about a streaming RPC on -// server side. All per-rpc information may be mutated by the interceptor. -type StreamServerInfo struct { - // FullMethod is the full RPC method string, i.e., /package.service/method. - FullMethod string - // IsClientStream indicates whether the RPC is a client streaming RPC. - IsClientStream bool - // IsServerStream indicates whether the RPC is a server streaming RPC. - IsServerStream bool -} - -// StreamServerInterceptor provides a hook to intercept the execution of a streaming RPC on the server. -// info contains all the information of this RPC the interceptor can operate on. And handler is the -// service method implementation. It is the responsibility of the interceptor to invoke handler to -// complete the RPC. -type StreamServerInterceptor func(srv any, ss ServerStream, info *StreamServerInfo, handler StreamHandler) error diff --git a/vendor/google.golang.org/grpc/internal/backoff/backoff.go b/vendor/google.golang.org/grpc/internal/backoff/backoff.go deleted file mode 100644 index fed1c011a..000000000 --- a/vendor/google.golang.org/grpc/internal/backoff/backoff.go +++ /dev/null @@ -1,109 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package backoff implement the backoff strategy for gRPC. -// -// This is kept in internal until the gRPC project decides whether or not to -// allow alternative backoff strategies. -package backoff - -import ( - "context" - "errors" - "time" - - grpcbackoff "google.golang.org/grpc/backoff" - "google.golang.org/grpc/internal/grpcrand" -) - -// Strategy defines the methodology for backing off after a grpc connection -// failure. -type Strategy interface { - // Backoff returns the amount of time to wait before the next retry given - // the number of consecutive failures. - Backoff(retries int) time.Duration -} - -// DefaultExponential is an exponential backoff implementation using the -// default values for all the configurable knobs defined in -// https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md. -var DefaultExponential = Exponential{Config: grpcbackoff.DefaultConfig} - -// Exponential implements exponential backoff algorithm as defined in -// https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md. -type Exponential struct { - // Config contains all options to configure the backoff algorithm. - Config grpcbackoff.Config -} - -// Backoff returns the amount of time to wait before the next retry given the -// number of retries. -func (bc Exponential) Backoff(retries int) time.Duration { - if retries == 0 { - return bc.Config.BaseDelay - } - backoff, max := float64(bc.Config.BaseDelay), float64(bc.Config.MaxDelay) - for backoff < max && retries > 0 { - backoff *= bc.Config.Multiplier - retries-- - } - if backoff > max { - backoff = max - } - // Randomize backoff delays so that if a cluster of requests start at - // the same time, they won't operate in lockstep. - backoff *= 1 + bc.Config.Jitter*(grpcrand.Float64()*2-1) - if backoff < 0 { - return 0 - } - return time.Duration(backoff) -} - -// ErrResetBackoff is the error to be returned by the function executed by RunF, -// to instruct the latter to reset its backoff state. -var ErrResetBackoff = errors.New("reset backoff state") - -// RunF provides a convenient way to run a function f repeatedly until the -// context expires or f returns a non-nil error that is not ErrResetBackoff. -// When f returns ErrResetBackoff, RunF continues to run f, but resets its -// backoff state before doing so. backoff accepts an integer representing the -// number of retries, and returns the amount of time to backoff. -func RunF(ctx context.Context, f func() error, backoff func(int) time.Duration) { - attempt := 0 - timer := time.NewTimer(0) - for ctx.Err() == nil { - select { - case <-timer.C: - case <-ctx.Done(): - timer.Stop() - return - } - - err := f() - if errors.Is(err, ErrResetBackoff) { - timer.Reset(0) - attempt = 0 - continue - } - if err != nil { - return - } - timer.Reset(backoff(attempt)) - attempt++ - } -} diff --git a/vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/config.go b/vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/config.go deleted file mode 100644 index 6bf7f8739..000000000 --- a/vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/config.go +++ /dev/null @@ -1,83 +0,0 @@ -/* - * - * Copyright 2024 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package gracefulswitch - -import ( - "encoding/json" - "fmt" - - "google.golang.org/grpc/balancer" - "google.golang.org/grpc/serviceconfig" -) - -type lbConfig struct { - serviceconfig.LoadBalancingConfig - - childBuilder balancer.Builder - childConfig serviceconfig.LoadBalancingConfig -} - -func ChildName(l serviceconfig.LoadBalancingConfig) string { - return l.(*lbConfig).childBuilder.Name() -} - -// ParseConfig parses a child config list and returns a LB config for the -// gracefulswitch Balancer. -// -// cfg is expected to be a json.RawMessage containing a JSON array of LB policy -// names + configs as the format of the "loadBalancingConfig" field in -// ServiceConfig. It returns a type that should be passed to -// UpdateClientConnState in the BalancerConfig field. -func ParseConfig(cfg json.RawMessage) (serviceconfig.LoadBalancingConfig, error) { - var lbCfg []map[string]json.RawMessage - if err := json.Unmarshal(cfg, &lbCfg); err != nil { - return nil, err - } - for i, e := range lbCfg { - if len(e) != 1 { - return nil, fmt.Errorf("expected a JSON struct with one entry; received entry %v at index %d", e, i) - } - - var name string - var jsonCfg json.RawMessage - for name, jsonCfg = range e { - } - - builder := balancer.Get(name) - if builder == nil { - // Skip unregistered balancer names. - continue - } - - parser, ok := builder.(balancer.ConfigParser) - if !ok { - // This is a valid child with no config. - return &lbConfig{childBuilder: builder}, nil - } - - cfg, err := parser.ParseConfig(jsonCfg) - if err != nil { - return nil, fmt.Errorf("error parsing config for policy %q: %v", name, err) - } - - return &lbConfig{childBuilder: builder, childConfig: cfg}, nil - } - - return nil, fmt.Errorf("no supported policies found in config: %v", string(cfg)) -} diff --git a/vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/gracefulswitch.go b/vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/gracefulswitch.go deleted file mode 100644 index 45d5e50ea..000000000 --- a/vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/gracefulswitch.go +++ /dev/null @@ -1,420 +0,0 @@ -/* - * - * Copyright 2022 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package gracefulswitch implements a graceful switch load balancer. -package gracefulswitch - -import ( - "errors" - "fmt" - "sync" - - "google.golang.org/grpc/balancer" - "google.golang.org/grpc/balancer/base" - "google.golang.org/grpc/connectivity" - "google.golang.org/grpc/resolver" -) - -var errBalancerClosed = errors.New("gracefulSwitchBalancer is closed") -var _ balancer.Balancer = (*Balancer)(nil) - -// NewBalancer returns a graceful switch Balancer. -func NewBalancer(cc balancer.ClientConn, opts balancer.BuildOptions) *Balancer { - return &Balancer{ - cc: cc, - bOpts: opts, - } -} - -// Balancer is a utility to gracefully switch from one balancer to -// a new balancer. It implements the balancer.Balancer interface. -type Balancer struct { - bOpts balancer.BuildOptions - cc balancer.ClientConn - - // mu protects the following fields and all fields within balancerCurrent - // and balancerPending. mu does not need to be held when calling into the - // child balancers, as all calls into these children happen only as a direct - // result of a call into the gracefulSwitchBalancer, which are also - // guaranteed to be synchronous. There is one exception: an UpdateState call - // from a child balancer when current and pending are populated can lead to - // calling Close() on the current. To prevent that racing with an - // UpdateSubConnState from the channel, we hold currentMu during Close and - // UpdateSubConnState calls. - mu sync.Mutex - balancerCurrent *balancerWrapper - balancerPending *balancerWrapper - closed bool // set to true when this balancer is closed - - // currentMu must be locked before mu. This mutex guards against this - // sequence of events: UpdateSubConnState() called, finds the - // balancerCurrent, gives up lock, updateState comes in, causes Close() on - // balancerCurrent before the UpdateSubConnState is called on the - // balancerCurrent. - currentMu sync.Mutex -} - -// swap swaps out the current lb with the pending lb and updates the ClientConn. -// The caller must hold gsb.mu. -func (gsb *Balancer) swap() { - gsb.cc.UpdateState(gsb.balancerPending.lastState) - cur := gsb.balancerCurrent - gsb.balancerCurrent = gsb.balancerPending - gsb.balancerPending = nil - go func() { - gsb.currentMu.Lock() - defer gsb.currentMu.Unlock() - cur.Close() - }() -} - -// Helper function that checks if the balancer passed in is current or pending. -// The caller must hold gsb.mu. -func (gsb *Balancer) balancerCurrentOrPending(bw *balancerWrapper) bool { - return bw == gsb.balancerCurrent || bw == gsb.balancerPending -} - -// SwitchTo initializes the graceful switch process, which completes based on -// connectivity state changes on the current/pending balancer. Thus, the switch -// process is not complete when this method returns. This method must be called -// synchronously alongside the rest of the balancer.Balancer methods this -// Graceful Switch Balancer implements. -// -// Deprecated: use ParseConfig and pass a parsed config to UpdateClientConnState -// to cause the Balancer to automatically change to the new child when necessary. -func (gsb *Balancer) SwitchTo(builder balancer.Builder) error { - _, err := gsb.switchTo(builder) - return err -} - -func (gsb *Balancer) switchTo(builder balancer.Builder) (*balancerWrapper, error) { - gsb.mu.Lock() - if gsb.closed { - gsb.mu.Unlock() - return nil, errBalancerClosed - } - bw := &balancerWrapper{ - builder: builder, - gsb: gsb, - lastState: balancer.State{ - ConnectivityState: connectivity.Connecting, - Picker: base.NewErrPicker(balancer.ErrNoSubConnAvailable), - }, - subconns: make(map[balancer.SubConn]bool), - } - balToClose := gsb.balancerPending // nil if there is no pending balancer - if gsb.balancerCurrent == nil { - gsb.balancerCurrent = bw - } else { - gsb.balancerPending = bw - } - gsb.mu.Unlock() - balToClose.Close() - // This function takes a builder instead of a balancer because builder.Build - // can call back inline, and this utility needs to handle the callbacks. - newBalancer := builder.Build(bw, gsb.bOpts) - if newBalancer == nil { - // This is illegal and should never happen; we clear the balancerWrapper - // we were constructing if it happens to avoid a potential panic. - gsb.mu.Lock() - if gsb.balancerPending != nil { - gsb.balancerPending = nil - } else { - gsb.balancerCurrent = nil - } - gsb.mu.Unlock() - return nil, balancer.ErrBadResolverState - } - - // This write doesn't need to take gsb.mu because this field never gets read - // or written to on any calls from the current or pending. Calls from grpc - // to this balancer are guaranteed to be called synchronously, so this - // bw.Balancer field will never be forwarded to until this SwitchTo() - // function returns. - bw.Balancer = newBalancer - return bw, nil -} - -// Returns nil if the graceful switch balancer is closed. -func (gsb *Balancer) latestBalancer() *balancerWrapper { - gsb.mu.Lock() - defer gsb.mu.Unlock() - if gsb.balancerPending != nil { - return gsb.balancerPending - } - return gsb.balancerCurrent -} - -// UpdateClientConnState forwards the update to the latest balancer created. -// -// If the state's BalancerConfig is the config returned by a call to -// gracefulswitch.ParseConfig, then this function will automatically SwitchTo -// the balancer indicated by the config before forwarding its config to it, if -// necessary. -func (gsb *Balancer) UpdateClientConnState(state balancer.ClientConnState) error { - // The resolver data is only relevant to the most recent LB Policy. - balToUpdate := gsb.latestBalancer() - - gsbCfg, ok := state.BalancerConfig.(*lbConfig) - if ok { - // Switch to the child in the config unless it is already active. - if balToUpdate == nil || gsbCfg.childBuilder.Name() != balToUpdate.builder.Name() { - var err error - balToUpdate, err = gsb.switchTo(gsbCfg.childBuilder) - if err != nil { - return fmt.Errorf("could not switch to new child balancer: %w", err) - } - } - // Unwrap the child balancer's config. - state.BalancerConfig = gsbCfg.childConfig - } - - if balToUpdate == nil { - return errBalancerClosed - } - - // Perform this call without gsb.mu to prevent deadlocks if the child calls - // back into the channel. The latest balancer can never be closed during a - // call from the channel, even without gsb.mu held. - return balToUpdate.UpdateClientConnState(state) -} - -// ResolverError forwards the error to the latest balancer created. -func (gsb *Balancer) ResolverError(err error) { - // The resolver data is only relevant to the most recent LB Policy. - balToUpdate := gsb.latestBalancer() - if balToUpdate == nil { - gsb.cc.UpdateState(balancer.State{ - ConnectivityState: connectivity.TransientFailure, - Picker: base.NewErrPicker(err), - }) - return - } - // Perform this call without gsb.mu to prevent deadlocks if the child calls - // back into the channel. The latest balancer can never be closed during a - // call from the channel, even without gsb.mu held. - balToUpdate.ResolverError(err) -} - -// ExitIdle forwards the call to the latest balancer created. -// -// If the latest balancer does not support ExitIdle, the subConns are -// re-connected to manually. -func (gsb *Balancer) ExitIdle() { - balToUpdate := gsb.latestBalancer() - if balToUpdate == nil { - return - } - // There is no need to protect this read with a mutex, as the write to the - // Balancer field happens in SwitchTo, which completes before this can be - // called. - if ei, ok := balToUpdate.Balancer.(balancer.ExitIdler); ok { - ei.ExitIdle() - return - } - gsb.mu.Lock() - defer gsb.mu.Unlock() - for sc := range balToUpdate.subconns { - sc.Connect() - } -} - -// updateSubConnState forwards the update to the appropriate child. -func (gsb *Balancer) updateSubConnState(sc balancer.SubConn, state balancer.SubConnState, cb func(balancer.SubConnState)) { - gsb.currentMu.Lock() - defer gsb.currentMu.Unlock() - gsb.mu.Lock() - // Forward update to the appropriate child. Even if there is a pending - // balancer, the current balancer should continue to get SubConn updates to - // maintain the proper state while the pending is still connecting. - var balToUpdate *balancerWrapper - if gsb.balancerCurrent != nil && gsb.balancerCurrent.subconns[sc] { - balToUpdate = gsb.balancerCurrent - } else if gsb.balancerPending != nil && gsb.balancerPending.subconns[sc] { - balToUpdate = gsb.balancerPending - } - if balToUpdate == nil { - // SubConn belonged to a stale lb policy that has not yet fully closed, - // or the balancer was already closed. - gsb.mu.Unlock() - return - } - if state.ConnectivityState == connectivity.Shutdown { - delete(balToUpdate.subconns, sc) - } - gsb.mu.Unlock() - if cb != nil { - cb(state) - } else { - balToUpdate.UpdateSubConnState(sc, state) - } -} - -// UpdateSubConnState forwards the update to the appropriate child. -func (gsb *Balancer) UpdateSubConnState(sc balancer.SubConn, state balancer.SubConnState) { - gsb.updateSubConnState(sc, state, nil) -} - -// Close closes any active child balancers. -func (gsb *Balancer) Close() { - gsb.mu.Lock() - gsb.closed = true - currentBalancerToClose := gsb.balancerCurrent - gsb.balancerCurrent = nil - pendingBalancerToClose := gsb.balancerPending - gsb.balancerPending = nil - gsb.mu.Unlock() - - currentBalancerToClose.Close() - pendingBalancerToClose.Close() -} - -// balancerWrapper wraps a balancer.Balancer, and overrides some Balancer -// methods to help cleanup SubConns created by the wrapped balancer. -// -// It implements the balancer.ClientConn interface and is passed down in that -// capacity to the wrapped balancer. It maintains a set of subConns created by -// the wrapped balancer and calls from the latter to create/update/shutdown -// SubConns update this set before being forwarded to the parent ClientConn. -// State updates from the wrapped balancer can result in invocation of the -// graceful switch logic. -type balancerWrapper struct { - balancer.Balancer - gsb *Balancer - builder balancer.Builder - - lastState balancer.State - subconns map[balancer.SubConn]bool // subconns created by this balancer -} - -// Close closes the underlying LB policy and shuts down the subconns it -// created. bw must not be referenced via balancerCurrent or balancerPending in -// gsb when called. gsb.mu must not be held. Does not panic with a nil -// receiver. -func (bw *balancerWrapper) Close() { - // before Close is called. - if bw == nil { - return - } - // There is no need to protect this read with a mutex, as Close() is - // impossible to be called concurrently with the write in SwitchTo(). The - // callsites of Close() for this balancer in Graceful Switch Balancer will - // never be called until SwitchTo() returns. - bw.Balancer.Close() - bw.gsb.mu.Lock() - for sc := range bw.subconns { - sc.Shutdown() - } - bw.gsb.mu.Unlock() -} - -func (bw *balancerWrapper) UpdateState(state balancer.State) { - // Hold the mutex for this entire call to ensure it cannot occur - // concurrently with other updateState() calls. This causes updates to - // lastState and calls to cc.UpdateState to happen atomically. - bw.gsb.mu.Lock() - defer bw.gsb.mu.Unlock() - bw.lastState = state - - if !bw.gsb.balancerCurrentOrPending(bw) { - return - } - - if bw == bw.gsb.balancerCurrent { - // In the case that the current balancer exits READY, and there is a pending - // balancer, you can forward the pending balancer's cached State up to - // ClientConn and swap the pending into the current. This is because there - // is no reason to gracefully switch from and keep using the old policy as - // the ClientConn is not connected to any backends. - if state.ConnectivityState != connectivity.Ready && bw.gsb.balancerPending != nil { - bw.gsb.swap() - return - } - // Even if there is a pending balancer waiting to be gracefully switched to, - // continue to forward current balancer updates to the Client Conn. Ignoring - // state + picker from the current would cause undefined behavior/cause the - // system to behave incorrectly from the current LB policies perspective. - // Also, the current LB is still being used by grpc to choose SubConns per - // RPC, and thus should use the most updated form of the current balancer. - bw.gsb.cc.UpdateState(state) - return - } - // This method is now dealing with a state update from the pending balancer. - // If the current balancer is currently in a state other than READY, the new - // policy can be swapped into place immediately. This is because there is no - // reason to gracefully switch from and keep using the old policy as the - // ClientConn is not connected to any backends. - if state.ConnectivityState != connectivity.Connecting || bw.gsb.balancerCurrent.lastState.ConnectivityState != connectivity.Ready { - bw.gsb.swap() - } -} - -func (bw *balancerWrapper) NewSubConn(addrs []resolver.Address, opts balancer.NewSubConnOptions) (balancer.SubConn, error) { - bw.gsb.mu.Lock() - if !bw.gsb.balancerCurrentOrPending(bw) { - bw.gsb.mu.Unlock() - return nil, fmt.Errorf("%T at address %p that called NewSubConn is deleted", bw, bw) - } - bw.gsb.mu.Unlock() - - var sc balancer.SubConn - oldListener := opts.StateListener - opts.StateListener = func(state balancer.SubConnState) { bw.gsb.updateSubConnState(sc, state, oldListener) } - sc, err := bw.gsb.cc.NewSubConn(addrs, opts) - if err != nil { - return nil, err - } - bw.gsb.mu.Lock() - if !bw.gsb.balancerCurrentOrPending(bw) { // balancer was closed during this call - sc.Shutdown() - bw.gsb.mu.Unlock() - return nil, fmt.Errorf("%T at address %p that called NewSubConn is deleted", bw, bw) - } - bw.subconns[sc] = true - bw.gsb.mu.Unlock() - return sc, nil -} - -func (bw *balancerWrapper) ResolveNow(opts resolver.ResolveNowOptions) { - // Ignore ResolveNow requests from anything other than the most recent - // balancer, because older balancers were already removed from the config. - if bw != bw.gsb.latestBalancer() { - return - } - bw.gsb.cc.ResolveNow(opts) -} - -func (bw *balancerWrapper) RemoveSubConn(sc balancer.SubConn) { - // Note: existing third party balancers may call this, so it must remain - // until RemoveSubConn is fully removed. - sc.Shutdown() -} - -func (bw *balancerWrapper) UpdateAddresses(sc balancer.SubConn, addrs []resolver.Address) { - bw.gsb.mu.Lock() - if !bw.gsb.balancerCurrentOrPending(bw) { - bw.gsb.mu.Unlock() - return - } - bw.gsb.mu.Unlock() - bw.gsb.cc.UpdateAddresses(sc, addrs) -} - -func (bw *balancerWrapper) Target() string { - return bw.gsb.cc.Target() -} diff --git a/vendor/google.golang.org/grpc/internal/balancerload/load.go b/vendor/google.golang.org/grpc/internal/balancerload/load.go deleted file mode 100644 index 94a08d687..000000000 --- a/vendor/google.golang.org/grpc/internal/balancerload/load.go +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Package balancerload defines APIs to parse server loads in trailers. The -// parsed loads are sent to balancers in DoneInfo. -package balancerload - -import ( - "google.golang.org/grpc/metadata" -) - -// Parser converts loads from metadata into a concrete type. -type Parser interface { - // Parse parses loads from metadata. - Parse(md metadata.MD) any -} - -var parser Parser - -// SetParser sets the load parser. -// -// Not mutex-protected, should be called before any gRPC functions. -func SetParser(lr Parser) { - parser = lr -} - -// Parse calls parser.Read(). -func Parse(md metadata.MD) any { - if parser == nil { - return nil - } - return parser.Parse(md) -} diff --git a/vendor/google.golang.org/grpc/internal/binarylog/binarylog.go b/vendor/google.golang.org/grpc/internal/binarylog/binarylog.go deleted file mode 100644 index 755fdebc1..000000000 --- a/vendor/google.golang.org/grpc/internal/binarylog/binarylog.go +++ /dev/null @@ -1,192 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package binarylog implementation binary logging as defined in -// https://github.com/grpc/proposal/blob/master/A16-binary-logging.md. -package binarylog - -import ( - "fmt" - "os" - - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/internal/grpcutil" -) - -var grpclogLogger = grpclog.Component("binarylog") - -// Logger specifies MethodLoggers for method names with a Log call that -// takes a context. -// -// This is used in the 1.0 release of gcp/observability, and thus must not be -// deleted or changed. -type Logger interface { - GetMethodLogger(methodName string) MethodLogger -} - -// binLogger is the global binary logger for the binary. One of this should be -// built at init time from the configuration (environment variable or flags). -// -// It is used to get a MethodLogger for each individual method. -var binLogger Logger - -// SetLogger sets the binary logger. -// -// Only call this at init time. -func SetLogger(l Logger) { - binLogger = l -} - -// GetLogger gets the binary logger. -// -// Only call this at init time. -func GetLogger() Logger { - return binLogger -} - -// GetMethodLogger returns the MethodLogger for the given methodName. -// -// methodName should be in the format of "/service/method". -// -// Each MethodLogger returned by this method is a new instance. This is to -// generate sequence id within the call. -func GetMethodLogger(methodName string) MethodLogger { - if binLogger == nil { - return nil - } - return binLogger.GetMethodLogger(methodName) -} - -func init() { - const envStr = "GRPC_BINARY_LOG_FILTER" - configStr := os.Getenv(envStr) - binLogger = NewLoggerFromConfigString(configStr) -} - -// MethodLoggerConfig contains the setting for logging behavior of a method -// logger. Currently, it contains the max length of header and message. -type MethodLoggerConfig struct { - // Max length of header and message. - Header, Message uint64 -} - -// LoggerConfig contains the config for loggers to create method loggers. -type LoggerConfig struct { - All *MethodLoggerConfig - Services map[string]*MethodLoggerConfig - Methods map[string]*MethodLoggerConfig - - Blacklist map[string]struct{} -} - -type logger struct { - config LoggerConfig -} - -// NewLoggerFromConfig builds a logger with the given LoggerConfig. -func NewLoggerFromConfig(config LoggerConfig) Logger { - return &logger{config: config} -} - -// newEmptyLogger creates an empty logger. The map fields need to be filled in -// using the set* functions. -func newEmptyLogger() *logger { - return &logger{} -} - -// Set method logger for "*". -func (l *logger) setDefaultMethodLogger(ml *MethodLoggerConfig) error { - if l.config.All != nil { - return fmt.Errorf("conflicting global rules found") - } - l.config.All = ml - return nil -} - -// Set method logger for "service/*". -// -// New MethodLogger with same service overrides the old one. -func (l *logger) setServiceMethodLogger(service string, ml *MethodLoggerConfig) error { - if _, ok := l.config.Services[service]; ok { - return fmt.Errorf("conflicting service rules for service %v found", service) - } - if l.config.Services == nil { - l.config.Services = make(map[string]*MethodLoggerConfig) - } - l.config.Services[service] = ml - return nil -} - -// Set method logger for "service/method". -// -// New MethodLogger with same method overrides the old one. -func (l *logger) setMethodMethodLogger(method string, ml *MethodLoggerConfig) error { - if _, ok := l.config.Blacklist[method]; ok { - return fmt.Errorf("conflicting blacklist rules for method %v found", method) - } - if _, ok := l.config.Methods[method]; ok { - return fmt.Errorf("conflicting method rules for method %v found", method) - } - if l.config.Methods == nil { - l.config.Methods = make(map[string]*MethodLoggerConfig) - } - l.config.Methods[method] = ml - return nil -} - -// Set blacklist method for "-service/method". -func (l *logger) setBlacklist(method string) error { - if _, ok := l.config.Blacklist[method]; ok { - return fmt.Errorf("conflicting blacklist rules for method %v found", method) - } - if _, ok := l.config.Methods[method]; ok { - return fmt.Errorf("conflicting method rules for method %v found", method) - } - if l.config.Blacklist == nil { - l.config.Blacklist = make(map[string]struct{}) - } - l.config.Blacklist[method] = struct{}{} - return nil -} - -// getMethodLogger returns the MethodLogger for the given methodName. -// -// methodName should be in the format of "/service/method". -// -// Each MethodLogger returned by this method is a new instance. This is to -// generate sequence id within the call. -func (l *logger) GetMethodLogger(methodName string) MethodLogger { - s, m, err := grpcutil.ParseMethod(methodName) - if err != nil { - grpclogLogger.Infof("binarylogging: failed to parse %q: %v", methodName, err) - return nil - } - if ml, ok := l.config.Methods[s+"/"+m]; ok { - return NewTruncatingMethodLogger(ml.Header, ml.Message) - } - if _, ok := l.config.Blacklist[s+"/"+m]; ok { - return nil - } - if ml, ok := l.config.Services[s]; ok { - return NewTruncatingMethodLogger(ml.Header, ml.Message) - } - if l.config.All == nil { - return nil - } - return NewTruncatingMethodLogger(l.config.All.Header, l.config.All.Message) -} diff --git a/vendor/google.golang.org/grpc/internal/binarylog/binarylog_testutil.go b/vendor/google.golang.org/grpc/internal/binarylog/binarylog_testutil.go deleted file mode 100644 index 1ee00a39a..000000000 --- a/vendor/google.golang.org/grpc/internal/binarylog/binarylog_testutil.go +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// This file contains exported variables/functions that are exported for testing -// only. -// -// An ideal way for this would be to put those in a *_test.go but in binarylog -// package. But this doesn't work with staticcheck with go module. Error was: -// "MdToMetadataProto not declared by package binarylog". This could be caused -// by the way staticcheck looks for files for a certain package, which doesn't -// support *_test.go files. -// -// Move those to binary_test.go when staticcheck is fixed. - -package binarylog - -var ( - // AllLogger is a logger that logs all headers/messages for all RPCs. It's - // for testing only. - AllLogger = NewLoggerFromConfigString("*") - // MdToMetadataProto converts metadata to a binary logging proto message. - // It's for testing only. - MdToMetadataProto = mdToMetadataProto - // AddrToProto converts an address to a binary logging proto message. It's - // for testing only. - AddrToProto = addrToProto -) diff --git a/vendor/google.golang.org/grpc/internal/binarylog/env_config.go b/vendor/google.golang.org/grpc/internal/binarylog/env_config.go deleted file mode 100644 index f9e80e27a..000000000 --- a/vendor/google.golang.org/grpc/internal/binarylog/env_config.go +++ /dev/null @@ -1,208 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package binarylog - -import ( - "errors" - "fmt" - "regexp" - "strconv" - "strings" -) - -// NewLoggerFromConfigString reads the string and build a logger. It can be used -// to build a new logger and assign it to binarylog.Logger. -// -// Example filter config strings: -// - "" Nothing will be logged -// - "*" All headers and messages will be fully logged. -// - "*{h}" Only headers will be logged. -// - "*{m:256}" Only the first 256 bytes of each message will be logged. -// - "Foo/*" Logs every method in service Foo -// - "Foo/*,-Foo/Bar" Logs every method in service Foo except method /Foo/Bar -// - "Foo/*,Foo/Bar{m:256}" Logs the first 256 bytes of each message in method -// /Foo/Bar, logs all headers and messages in every other method in service -// Foo. -// -// If two configs exist for one certain method or service, the one specified -// later overrides the previous config. -func NewLoggerFromConfigString(s string) Logger { - if s == "" { - return nil - } - l := newEmptyLogger() - methods := strings.Split(s, ",") - for _, method := range methods { - if err := l.fillMethodLoggerWithConfigString(method); err != nil { - grpclogLogger.Warningf("failed to parse binary log config: %v", err) - return nil - } - } - return l -} - -// fillMethodLoggerWithConfigString parses config, creates TruncatingMethodLogger and adds -// it to the right map in the logger. -func (l *logger) fillMethodLoggerWithConfigString(config string) error { - // "" is invalid. - if config == "" { - return errors.New("empty string is not a valid method binary logging config") - } - - // "-service/method", blacklist, no * or {} allowed. - if config[0] == '-' { - s, m, suffix, err := parseMethodConfigAndSuffix(config[1:]) - if err != nil { - return fmt.Errorf("invalid config: %q, %v", config, err) - } - if m == "*" { - return fmt.Errorf("invalid config: %q, %v", config, "* not allowed in blacklist config") - } - if suffix != "" { - return fmt.Errorf("invalid config: %q, %v", config, "header/message limit not allowed in blacklist config") - } - if err := l.setBlacklist(s + "/" + m); err != nil { - return fmt.Errorf("invalid config: %v", err) - } - return nil - } - - // "*{h:256;m:256}" - if config[0] == '*' { - hdr, msg, err := parseHeaderMessageLengthConfig(config[1:]) - if err != nil { - return fmt.Errorf("invalid config: %q, %v", config, err) - } - if err := l.setDefaultMethodLogger(&MethodLoggerConfig{Header: hdr, Message: msg}); err != nil { - return fmt.Errorf("invalid config: %v", err) - } - return nil - } - - s, m, suffix, err := parseMethodConfigAndSuffix(config) - if err != nil { - return fmt.Errorf("invalid config: %q, %v", config, err) - } - hdr, msg, err := parseHeaderMessageLengthConfig(suffix) - if err != nil { - return fmt.Errorf("invalid header/message length config: %q, %v", suffix, err) - } - if m == "*" { - if err := l.setServiceMethodLogger(s, &MethodLoggerConfig{Header: hdr, Message: msg}); err != nil { - return fmt.Errorf("invalid config: %v", err) - } - } else { - if err := l.setMethodMethodLogger(s+"/"+m, &MethodLoggerConfig{Header: hdr, Message: msg}); err != nil { - return fmt.Errorf("invalid config: %v", err) - } - } - return nil -} - -const ( - // TODO: this const is only used by env_config now. But could be useful for - // other config. Move to binarylog.go if necessary. - maxUInt = ^uint64(0) - - // For "p.s/m" plus any suffix. Suffix will be parsed again. See test for - // expected output. - longMethodConfigRegexpStr = `^([\w./]+)/((?:\w+)|[*])(.+)?$` - - // For suffix from above, "{h:123,m:123}". See test for expected output. - optionalLengthRegexpStr = `(?::(\d+))?` // Optional ":123". - headerConfigRegexpStr = `^{h` + optionalLengthRegexpStr + `}$` - messageConfigRegexpStr = `^{m` + optionalLengthRegexpStr + `}$` - headerMessageConfigRegexpStr = `^{h` + optionalLengthRegexpStr + `;m` + optionalLengthRegexpStr + `}$` -) - -var ( - longMethodConfigRegexp = regexp.MustCompile(longMethodConfigRegexpStr) - headerConfigRegexp = regexp.MustCompile(headerConfigRegexpStr) - messageConfigRegexp = regexp.MustCompile(messageConfigRegexpStr) - headerMessageConfigRegexp = regexp.MustCompile(headerMessageConfigRegexpStr) -) - -// Turn "service/method{h;m}" into "service", "method", "{h;m}". -func parseMethodConfigAndSuffix(c string) (service, method, suffix string, _ error) { - // Regexp result: - // - // in: "p.s/m{h:123,m:123}", - // out: []string{"p.s/m{h:123,m:123}", "p.s", "m", "{h:123,m:123}"}, - match := longMethodConfigRegexp.FindStringSubmatch(c) - if match == nil { - return "", "", "", fmt.Errorf("%q contains invalid substring", c) - } - service = match[1] - method = match[2] - suffix = match[3] - return -} - -// Turn "{h:123;m:345}" into 123, 345. -// -// Return maxUInt if length is unspecified. -func parseHeaderMessageLengthConfig(c string) (hdrLenStr, msgLenStr uint64, err error) { - if c == "" { - return maxUInt, maxUInt, nil - } - // Header config only. - if match := headerConfigRegexp.FindStringSubmatch(c); match != nil { - if s := match[1]; s != "" { - hdrLenStr, err = strconv.ParseUint(s, 10, 64) - if err != nil { - return 0, 0, fmt.Errorf("failed to convert %q to uint", s) - } - return hdrLenStr, 0, nil - } - return maxUInt, 0, nil - } - - // Message config only. - if match := messageConfigRegexp.FindStringSubmatch(c); match != nil { - if s := match[1]; s != "" { - msgLenStr, err = strconv.ParseUint(s, 10, 64) - if err != nil { - return 0, 0, fmt.Errorf("failed to convert %q to uint", s) - } - return 0, msgLenStr, nil - } - return 0, maxUInt, nil - } - - // Header and message config both. - if match := headerMessageConfigRegexp.FindStringSubmatch(c); match != nil { - // Both hdr and msg are specified, but one or two of them might be empty. - hdrLenStr = maxUInt - msgLenStr = maxUInt - if s := match[1]; s != "" { - hdrLenStr, err = strconv.ParseUint(s, 10, 64) - if err != nil { - return 0, 0, fmt.Errorf("failed to convert %q to uint", s) - } - } - if s := match[2]; s != "" { - msgLenStr, err = strconv.ParseUint(s, 10, 64) - if err != nil { - return 0, 0, fmt.Errorf("failed to convert %q to uint", s) - } - } - return hdrLenStr, msgLenStr, nil - } - return 0, 0, fmt.Errorf("%q contains invalid substring", c) -} diff --git a/vendor/google.golang.org/grpc/internal/binarylog/method_logger.go b/vendor/google.golang.org/grpc/internal/binarylog/method_logger.go deleted file mode 100644 index e8456a77c..000000000 --- a/vendor/google.golang.org/grpc/internal/binarylog/method_logger.go +++ /dev/null @@ -1,446 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package binarylog - -import ( - "context" - "net" - "strings" - "sync/atomic" - "time" - - binlogpb "google.golang.org/grpc/binarylog/grpc_binarylog_v1" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/types/known/durationpb" - "google.golang.org/protobuf/types/known/timestamppb" -) - -type callIDGenerator struct { - id uint64 -} - -func (g *callIDGenerator) next() uint64 { - id := atomic.AddUint64(&g.id, 1) - return id -} - -// reset is for testing only, and doesn't need to be thread safe. -func (g *callIDGenerator) reset() { - g.id = 0 -} - -var idGen callIDGenerator - -// MethodLogger is the sub-logger for each method. -// -// This is used in the 1.0 release of gcp/observability, and thus must not be -// deleted or changed. -type MethodLogger interface { - Log(context.Context, LogEntryConfig) -} - -// TruncatingMethodLogger is a method logger that truncates headers and messages -// based on configured fields. -type TruncatingMethodLogger struct { - headerMaxLen, messageMaxLen uint64 - - callID uint64 - idWithinCallGen *callIDGenerator - - sink Sink // TODO(blog): make this plugable. -} - -// NewTruncatingMethodLogger returns a new truncating method logger. -// -// This is used in the 1.0 release of gcp/observability, and thus must not be -// deleted or changed. -func NewTruncatingMethodLogger(h, m uint64) *TruncatingMethodLogger { - return &TruncatingMethodLogger{ - headerMaxLen: h, - messageMaxLen: m, - - callID: idGen.next(), - idWithinCallGen: &callIDGenerator{}, - - sink: DefaultSink, // TODO(blog): make it plugable. - } -} - -// Build is an internal only method for building the proto message out of the -// input event. It's made public to enable other library to reuse as much logic -// in TruncatingMethodLogger as possible. -func (ml *TruncatingMethodLogger) Build(c LogEntryConfig) *binlogpb.GrpcLogEntry { - m := c.toProto() - timestamp := timestamppb.Now() - m.Timestamp = timestamp - m.CallId = ml.callID - m.SequenceIdWithinCall = ml.idWithinCallGen.next() - - switch pay := m.Payload.(type) { - case *binlogpb.GrpcLogEntry_ClientHeader: - m.PayloadTruncated = ml.truncateMetadata(pay.ClientHeader.GetMetadata()) - case *binlogpb.GrpcLogEntry_ServerHeader: - m.PayloadTruncated = ml.truncateMetadata(pay.ServerHeader.GetMetadata()) - case *binlogpb.GrpcLogEntry_Message: - m.PayloadTruncated = ml.truncateMessage(pay.Message) - } - return m -} - -// Log creates a proto binary log entry, and logs it to the sink. -func (ml *TruncatingMethodLogger) Log(ctx context.Context, c LogEntryConfig) { - ml.sink.Write(ml.Build(c)) -} - -func (ml *TruncatingMethodLogger) truncateMetadata(mdPb *binlogpb.Metadata) (truncated bool) { - if ml.headerMaxLen == maxUInt { - return false - } - var ( - bytesLimit = ml.headerMaxLen - index int - ) - // At the end of the loop, index will be the first entry where the total - // size is greater than the limit: - // - // len(entry[:index]) <= ml.hdr && len(entry[:index+1]) > ml.hdr. - for ; index < len(mdPb.Entry); index++ { - entry := mdPb.Entry[index] - if entry.Key == "grpc-trace-bin" { - // "grpc-trace-bin" is a special key. It's kept in the log entry, - // but not counted towards the size limit. - continue - } - currentEntryLen := uint64(len(entry.GetKey())) + uint64(len(entry.GetValue())) - if currentEntryLen > bytesLimit { - break - } - bytesLimit -= currentEntryLen - } - truncated = index < len(mdPb.Entry) - mdPb.Entry = mdPb.Entry[:index] - return truncated -} - -func (ml *TruncatingMethodLogger) truncateMessage(msgPb *binlogpb.Message) (truncated bool) { - if ml.messageMaxLen == maxUInt { - return false - } - if ml.messageMaxLen >= uint64(len(msgPb.Data)) { - return false - } - msgPb.Data = msgPb.Data[:ml.messageMaxLen] - return true -} - -// LogEntryConfig represents the configuration for binary log entry. -// -// This is used in the 1.0 release of gcp/observability, and thus must not be -// deleted or changed. -type LogEntryConfig interface { - toProto() *binlogpb.GrpcLogEntry -} - -// ClientHeader configs the binary log entry to be a ClientHeader entry. -type ClientHeader struct { - OnClientSide bool - Header metadata.MD - MethodName string - Authority string - Timeout time.Duration - // PeerAddr is required only when it's on server side. - PeerAddr net.Addr -} - -func (c *ClientHeader) toProto() *binlogpb.GrpcLogEntry { - // This function doesn't need to set all the fields (e.g. seq ID). The Log - // function will set the fields when necessary. - clientHeader := &binlogpb.ClientHeader{ - Metadata: mdToMetadataProto(c.Header), - MethodName: c.MethodName, - Authority: c.Authority, - } - if c.Timeout > 0 { - clientHeader.Timeout = durationpb.New(c.Timeout) - } - ret := &binlogpb.GrpcLogEntry{ - Type: binlogpb.GrpcLogEntry_EVENT_TYPE_CLIENT_HEADER, - Payload: &binlogpb.GrpcLogEntry_ClientHeader{ - ClientHeader: clientHeader, - }, - } - if c.OnClientSide { - ret.Logger = binlogpb.GrpcLogEntry_LOGGER_CLIENT - } else { - ret.Logger = binlogpb.GrpcLogEntry_LOGGER_SERVER - } - if c.PeerAddr != nil { - ret.Peer = addrToProto(c.PeerAddr) - } - return ret -} - -// ServerHeader configs the binary log entry to be a ServerHeader entry. -type ServerHeader struct { - OnClientSide bool - Header metadata.MD - // PeerAddr is required only when it's on client side. - PeerAddr net.Addr -} - -func (c *ServerHeader) toProto() *binlogpb.GrpcLogEntry { - ret := &binlogpb.GrpcLogEntry{ - Type: binlogpb.GrpcLogEntry_EVENT_TYPE_SERVER_HEADER, - Payload: &binlogpb.GrpcLogEntry_ServerHeader{ - ServerHeader: &binlogpb.ServerHeader{ - Metadata: mdToMetadataProto(c.Header), - }, - }, - } - if c.OnClientSide { - ret.Logger = binlogpb.GrpcLogEntry_LOGGER_CLIENT - } else { - ret.Logger = binlogpb.GrpcLogEntry_LOGGER_SERVER - } - if c.PeerAddr != nil { - ret.Peer = addrToProto(c.PeerAddr) - } - return ret -} - -// ClientMessage configs the binary log entry to be a ClientMessage entry. -type ClientMessage struct { - OnClientSide bool - // Message can be a proto.Message or []byte. Other messages formats are not - // supported. - Message any -} - -func (c *ClientMessage) toProto() *binlogpb.GrpcLogEntry { - var ( - data []byte - err error - ) - if m, ok := c.Message.(proto.Message); ok { - data, err = proto.Marshal(m) - if err != nil { - grpclogLogger.Infof("binarylogging: failed to marshal proto message: %v", err) - } - } else if b, ok := c.Message.([]byte); ok { - data = b - } else { - grpclogLogger.Infof("binarylogging: message to log is neither proto.message nor []byte") - } - ret := &binlogpb.GrpcLogEntry{ - Type: binlogpb.GrpcLogEntry_EVENT_TYPE_CLIENT_MESSAGE, - Payload: &binlogpb.GrpcLogEntry_Message{ - Message: &binlogpb.Message{ - Length: uint32(len(data)), - Data: data, - }, - }, - } - if c.OnClientSide { - ret.Logger = binlogpb.GrpcLogEntry_LOGGER_CLIENT - } else { - ret.Logger = binlogpb.GrpcLogEntry_LOGGER_SERVER - } - return ret -} - -// ServerMessage configs the binary log entry to be a ServerMessage entry. -type ServerMessage struct { - OnClientSide bool - // Message can be a proto.Message or []byte. Other messages formats are not - // supported. - Message any -} - -func (c *ServerMessage) toProto() *binlogpb.GrpcLogEntry { - var ( - data []byte - err error - ) - if m, ok := c.Message.(proto.Message); ok { - data, err = proto.Marshal(m) - if err != nil { - grpclogLogger.Infof("binarylogging: failed to marshal proto message: %v", err) - } - } else if b, ok := c.Message.([]byte); ok { - data = b - } else { - grpclogLogger.Infof("binarylogging: message to log is neither proto.message nor []byte") - } - ret := &binlogpb.GrpcLogEntry{ - Type: binlogpb.GrpcLogEntry_EVENT_TYPE_SERVER_MESSAGE, - Payload: &binlogpb.GrpcLogEntry_Message{ - Message: &binlogpb.Message{ - Length: uint32(len(data)), - Data: data, - }, - }, - } - if c.OnClientSide { - ret.Logger = binlogpb.GrpcLogEntry_LOGGER_CLIENT - } else { - ret.Logger = binlogpb.GrpcLogEntry_LOGGER_SERVER - } - return ret -} - -// ClientHalfClose configs the binary log entry to be a ClientHalfClose entry. -type ClientHalfClose struct { - OnClientSide bool -} - -func (c *ClientHalfClose) toProto() *binlogpb.GrpcLogEntry { - ret := &binlogpb.GrpcLogEntry{ - Type: binlogpb.GrpcLogEntry_EVENT_TYPE_CLIENT_HALF_CLOSE, - Payload: nil, // No payload here. - } - if c.OnClientSide { - ret.Logger = binlogpb.GrpcLogEntry_LOGGER_CLIENT - } else { - ret.Logger = binlogpb.GrpcLogEntry_LOGGER_SERVER - } - return ret -} - -// ServerTrailer configs the binary log entry to be a ServerTrailer entry. -type ServerTrailer struct { - OnClientSide bool - Trailer metadata.MD - // Err is the status error. - Err error - // PeerAddr is required only when it's on client side and the RPC is trailer - // only. - PeerAddr net.Addr -} - -func (c *ServerTrailer) toProto() *binlogpb.GrpcLogEntry { - st, ok := status.FromError(c.Err) - if !ok { - grpclogLogger.Info("binarylogging: error in trailer is not a status error") - } - var ( - detailsBytes []byte - err error - ) - stProto := st.Proto() - if stProto != nil && len(stProto.Details) != 0 { - detailsBytes, err = proto.Marshal(stProto) - if err != nil { - grpclogLogger.Infof("binarylogging: failed to marshal status proto: %v", err) - } - } - ret := &binlogpb.GrpcLogEntry{ - Type: binlogpb.GrpcLogEntry_EVENT_TYPE_SERVER_TRAILER, - Payload: &binlogpb.GrpcLogEntry_Trailer{ - Trailer: &binlogpb.Trailer{ - Metadata: mdToMetadataProto(c.Trailer), - StatusCode: uint32(st.Code()), - StatusMessage: st.Message(), - StatusDetails: detailsBytes, - }, - }, - } - if c.OnClientSide { - ret.Logger = binlogpb.GrpcLogEntry_LOGGER_CLIENT - } else { - ret.Logger = binlogpb.GrpcLogEntry_LOGGER_SERVER - } - if c.PeerAddr != nil { - ret.Peer = addrToProto(c.PeerAddr) - } - return ret -} - -// Cancel configs the binary log entry to be a Cancel entry. -type Cancel struct { - OnClientSide bool -} - -func (c *Cancel) toProto() *binlogpb.GrpcLogEntry { - ret := &binlogpb.GrpcLogEntry{ - Type: binlogpb.GrpcLogEntry_EVENT_TYPE_CANCEL, - Payload: nil, - } - if c.OnClientSide { - ret.Logger = binlogpb.GrpcLogEntry_LOGGER_CLIENT - } else { - ret.Logger = binlogpb.GrpcLogEntry_LOGGER_SERVER - } - return ret -} - -// metadataKeyOmit returns whether the metadata entry with this key should be -// omitted. -func metadataKeyOmit(key string) bool { - switch key { - case "lb-token", ":path", ":authority", "content-encoding", "content-type", "user-agent", "te": - return true - case "grpc-trace-bin": // grpc-trace-bin is special because it's visiable to users. - return false - } - return strings.HasPrefix(key, "grpc-") -} - -func mdToMetadataProto(md metadata.MD) *binlogpb.Metadata { - ret := &binlogpb.Metadata{} - for k, vv := range md { - if metadataKeyOmit(k) { - continue - } - for _, v := range vv { - ret.Entry = append(ret.Entry, - &binlogpb.MetadataEntry{ - Key: k, - Value: []byte(v), - }, - ) - } - } - return ret -} - -func addrToProto(addr net.Addr) *binlogpb.Address { - ret := &binlogpb.Address{} - switch a := addr.(type) { - case *net.TCPAddr: - if a.IP.To4() != nil { - ret.Type = binlogpb.Address_TYPE_IPV4 - } else if a.IP.To16() != nil { - ret.Type = binlogpb.Address_TYPE_IPV6 - } else { - ret.Type = binlogpb.Address_TYPE_UNKNOWN - // Do not set address and port fields. - break - } - ret.Address = a.IP.String() - ret.IpPort = uint32(a.Port) - case *net.UnixAddr: - ret.Type = binlogpb.Address_TYPE_UNIX - ret.Address = a.String() - default: - ret.Type = binlogpb.Address_TYPE_UNKNOWN - } - return ret -} diff --git a/vendor/google.golang.org/grpc/internal/binarylog/sink.go b/vendor/google.golang.org/grpc/internal/binarylog/sink.go deleted file mode 100644 index 9ea598b14..000000000 --- a/vendor/google.golang.org/grpc/internal/binarylog/sink.go +++ /dev/null @@ -1,170 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package binarylog - -import ( - "bufio" - "encoding/binary" - "io" - "sync" - "time" - - binlogpb "google.golang.org/grpc/binarylog/grpc_binarylog_v1" - "google.golang.org/protobuf/proto" -) - -var ( - // DefaultSink is the sink where the logs will be written to. It's exported - // for the binarylog package to update. - DefaultSink Sink = &noopSink{} // TODO(blog): change this default (file in /tmp). -) - -// Sink writes log entry into the binary log sink. -// -// sink is a copy of the exported binarylog.Sink, to avoid circular dependency. -type Sink interface { - // Write will be called to write the log entry into the sink. - // - // It should be thread-safe so it can be called in parallel. - Write(*binlogpb.GrpcLogEntry) error - // Close will be called when the Sink is replaced by a new Sink. - Close() error -} - -type noopSink struct{} - -func (ns *noopSink) Write(*binlogpb.GrpcLogEntry) error { return nil } -func (ns *noopSink) Close() error { return nil } - -// newWriterSink creates a binary log sink with the given writer. -// -// Write() marshals the proto message and writes it to the given writer. Each -// message is prefixed with a 4 byte big endian unsigned integer as the length. -// -// No buffer is done, Close() doesn't try to close the writer. -func newWriterSink(w io.Writer) Sink { - return &writerSink{out: w} -} - -type writerSink struct { - out io.Writer -} - -func (ws *writerSink) Write(e *binlogpb.GrpcLogEntry) error { - b, err := proto.Marshal(e) - if err != nil { - grpclogLogger.Errorf("binary logging: failed to marshal proto message: %v", err) - return err - } - hdr := make([]byte, 4) - binary.BigEndian.PutUint32(hdr, uint32(len(b))) - if _, err := ws.out.Write(hdr); err != nil { - return err - } - if _, err := ws.out.Write(b); err != nil { - return err - } - return nil -} - -func (ws *writerSink) Close() error { return nil } - -type bufferedSink struct { - mu sync.Mutex - closer io.Closer - out Sink // out is built on buf. - buf *bufio.Writer // buf is kept for flush. - flusherStarted bool - - writeTicker *time.Ticker - done chan struct{} -} - -func (fs *bufferedSink) Write(e *binlogpb.GrpcLogEntry) error { - fs.mu.Lock() - defer fs.mu.Unlock() - if !fs.flusherStarted { - // Start the write loop when Write is called. - fs.startFlushGoroutine() - fs.flusherStarted = true - } - if err := fs.out.Write(e); err != nil { - return err - } - return nil -} - -const ( - bufFlushDuration = 60 * time.Second -) - -func (fs *bufferedSink) startFlushGoroutine() { - fs.writeTicker = time.NewTicker(bufFlushDuration) - go func() { - for { - select { - case <-fs.done: - return - case <-fs.writeTicker.C: - } - fs.mu.Lock() - if err := fs.buf.Flush(); err != nil { - grpclogLogger.Warningf("failed to flush to Sink: %v", err) - } - fs.mu.Unlock() - } - }() -} - -func (fs *bufferedSink) Close() error { - fs.mu.Lock() - defer fs.mu.Unlock() - if fs.writeTicker != nil { - fs.writeTicker.Stop() - } - close(fs.done) - if err := fs.buf.Flush(); err != nil { - grpclogLogger.Warningf("failed to flush to Sink: %v", err) - } - if err := fs.closer.Close(); err != nil { - grpclogLogger.Warningf("failed to close the underlying WriterCloser: %v", err) - } - if err := fs.out.Close(); err != nil { - grpclogLogger.Warningf("failed to close the Sink: %v", err) - } - return nil -} - -// NewBufferedSink creates a binary log sink with the given WriteCloser. -// -// Write() marshals the proto message and writes it to the given writer. Each -// message is prefixed with a 4 byte big endian unsigned integer as the length. -// -// Content is kept in a buffer, and is flushed every 60 seconds. -// -// Close closes the WriteCloser. -func NewBufferedSink(o io.WriteCloser) Sink { - bufW := bufio.NewWriter(o) - return &bufferedSink{ - closer: o, - out: newWriterSink(bufW), - buf: bufW, - done: make(chan struct{}), - } -} diff --git a/vendor/google.golang.org/grpc/internal/buffer/unbounded.go b/vendor/google.golang.org/grpc/internal/buffer/unbounded.go deleted file mode 100644 index 11f91668a..000000000 --- a/vendor/google.golang.org/grpc/internal/buffer/unbounded.go +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package buffer provides an implementation of an unbounded buffer. -package buffer - -import ( - "errors" - "sync" -) - -// Unbounded is an implementation of an unbounded buffer which does not use -// extra goroutines. This is typically used for passing updates from one entity -// to another within gRPC. -// -// All methods on this type are thread-safe and don't block on anything except -// the underlying mutex used for synchronization. -// -// Unbounded supports values of any type to be stored in it by using a channel -// of `any`. This means that a call to Put() incurs an extra memory allocation, -// and also that users need a type assertion while reading. For performance -// critical code paths, using Unbounded is strongly discouraged and defining a -// new type specific implementation of this buffer is preferred. See -// internal/transport/transport.go for an example of this. -type Unbounded struct { - c chan any - closed bool - closing bool - mu sync.Mutex - backlog []any -} - -// NewUnbounded returns a new instance of Unbounded. -func NewUnbounded() *Unbounded { - return &Unbounded{c: make(chan any, 1)} -} - -var errBufferClosed = errors.New("Put called on closed buffer.Unbounded") - -// Put adds t to the unbounded buffer. -func (b *Unbounded) Put(t any) error { - b.mu.Lock() - defer b.mu.Unlock() - if b.closing { - return errBufferClosed - } - if len(b.backlog) == 0 { - select { - case b.c <- t: - return nil - default: - } - } - b.backlog = append(b.backlog, t) - return nil -} - -// Load sends the earliest buffered data, if any, onto the read channel returned -// by Get(). Users are expected to call this every time they successfully read a -// value from the read channel. -func (b *Unbounded) Load() { - b.mu.Lock() - defer b.mu.Unlock() - if len(b.backlog) > 0 { - select { - case b.c <- b.backlog[0]: - b.backlog[0] = nil - b.backlog = b.backlog[1:] - default: - } - } else if b.closing && !b.closed { - close(b.c) - } -} - -// Get returns a read channel on which values added to the buffer, via Put(), -// are sent on. -// -// Upon reading a value from this channel, users are expected to call Load() to -// send the next buffered value onto the channel if there is any. -// -// If the unbounded buffer is closed, the read channel returned by this method -// is closed after all data is drained. -func (b *Unbounded) Get() <-chan any { - return b.c -} - -// Close closes the unbounded buffer. No subsequent data may be Put(), and the -// channel returned from Get() will be closed after all the data is read and -// Load() is called for the final time. -func (b *Unbounded) Close() { - b.mu.Lock() - defer b.mu.Unlock() - if b.closing { - return - } - b.closing = true - if len(b.backlog) == 0 { - b.closed = true - close(b.c) - } -} diff --git a/vendor/google.golang.org/grpc/internal/channelz/channel.go b/vendor/google.golang.org/grpc/internal/channelz/channel.go deleted file mode 100644 index d7e9e1d54..000000000 --- a/vendor/google.golang.org/grpc/internal/channelz/channel.go +++ /dev/null @@ -1,255 +0,0 @@ -/* - * - * Copyright 2024 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package channelz - -import ( - "fmt" - "sync/atomic" - - "google.golang.org/grpc/connectivity" -) - -// Channel represents a channel within channelz, which includes metrics and -// internal channelz data, such as channelz id, child list, etc. -type Channel struct { - Entity - // ID is the channelz id of this channel. - ID int64 - // RefName is the human readable reference string of this channel. - RefName string - - closeCalled bool - nestedChans map[int64]string - subChans map[int64]string - Parent *Channel - trace *ChannelTrace - // traceRefCount is the number of trace events that reference this channel. - // Non-zero traceRefCount means the trace of this channel cannot be deleted. - traceRefCount int32 - - ChannelMetrics ChannelMetrics -} - -// Implemented to make Channel implement the Identifier interface used for -// nesting. -func (c *Channel) channelzIdentifier() {} - -func (c *Channel) String() string { - if c.Parent == nil { - return fmt.Sprintf("Channel #%d", c.ID) - } - return fmt.Sprintf("%s Channel #%d", c.Parent, c.ID) -} - -func (c *Channel) id() int64 { - return c.ID -} - -func (c *Channel) SubChans() map[int64]string { - db.mu.RLock() - defer db.mu.RUnlock() - return copyMap(c.subChans) -} - -func (c *Channel) NestedChans() map[int64]string { - db.mu.RLock() - defer db.mu.RUnlock() - return copyMap(c.nestedChans) -} - -func (c *Channel) Trace() *ChannelTrace { - db.mu.RLock() - defer db.mu.RUnlock() - return c.trace.copy() -} - -type ChannelMetrics struct { - // The current connectivity state of the channel. - State atomic.Pointer[connectivity.State] - // The target this channel originally tried to connect to. May be absent - Target atomic.Pointer[string] - // The number of calls started on the channel. - CallsStarted atomic.Int64 - // The number of calls that have completed with an OK status. - CallsSucceeded atomic.Int64 - // The number of calls that have a completed with a non-OK status. - CallsFailed atomic.Int64 - // The last time a call was started on the channel. - LastCallStartedTimestamp atomic.Int64 -} - -// CopyFrom copies the metrics in o to c. For testing only. -func (c *ChannelMetrics) CopyFrom(o *ChannelMetrics) { - c.State.Store(o.State.Load()) - c.Target.Store(o.Target.Load()) - c.CallsStarted.Store(o.CallsStarted.Load()) - c.CallsSucceeded.Store(o.CallsSucceeded.Load()) - c.CallsFailed.Store(o.CallsFailed.Load()) - c.LastCallStartedTimestamp.Store(o.LastCallStartedTimestamp.Load()) -} - -// Equal returns true iff the metrics of c are the same as the metrics of o. -// For testing only. -func (c *ChannelMetrics) Equal(o any) bool { - oc, ok := o.(*ChannelMetrics) - if !ok { - return false - } - if (c.State.Load() == nil) != (oc.State.Load() == nil) { - return false - } - if c.State.Load() != nil && *c.State.Load() != *oc.State.Load() { - return false - } - if (c.Target.Load() == nil) != (oc.Target.Load() == nil) { - return false - } - if c.Target.Load() != nil && *c.Target.Load() != *oc.Target.Load() { - return false - } - return c.CallsStarted.Load() == oc.CallsStarted.Load() && - c.CallsFailed.Load() == oc.CallsFailed.Load() && - c.CallsSucceeded.Load() == oc.CallsSucceeded.Load() && - c.LastCallStartedTimestamp.Load() == oc.LastCallStartedTimestamp.Load() -} - -func strFromPointer(s *string) string { - if s == nil { - return "" - } - return *s -} - -func (c *ChannelMetrics) String() string { - return fmt.Sprintf("State: %v, Target: %s, CallsStarted: %v, CallsSucceeded: %v, CallsFailed: %v, LastCallStartedTimestamp: %v", - c.State.Load(), strFromPointer(c.Target.Load()), c.CallsStarted.Load(), c.CallsSucceeded.Load(), c.CallsFailed.Load(), c.LastCallStartedTimestamp.Load(), - ) -} - -func NewChannelMetricForTesting(state connectivity.State, target string, started, succeeded, failed, timestamp int64) *ChannelMetrics { - c := &ChannelMetrics{} - c.State.Store(&state) - c.Target.Store(&target) - c.CallsStarted.Store(started) - c.CallsSucceeded.Store(succeeded) - c.CallsFailed.Store(failed) - c.LastCallStartedTimestamp.Store(timestamp) - return c -} - -func (c *Channel) addChild(id int64, e entry) { - switch v := e.(type) { - case *SubChannel: - c.subChans[id] = v.RefName - case *Channel: - c.nestedChans[id] = v.RefName - default: - logger.Errorf("cannot add a child (id = %d) of type %T to a channel", id, e) - } -} - -func (c *Channel) deleteChild(id int64) { - delete(c.subChans, id) - delete(c.nestedChans, id) - c.deleteSelfIfReady() -} - -func (c *Channel) triggerDelete() { - c.closeCalled = true - c.deleteSelfIfReady() -} - -func (c *Channel) getParentID() int64 { - if c.Parent == nil { - return -1 - } - return c.Parent.ID -} - -// deleteSelfFromTree tries to delete the channel from the channelz entry relation tree, which means -// deleting the channel reference from its parent's child list. -// -// In order for a channel to be deleted from the tree, it must meet the criteria that, removal of the -// corresponding grpc object has been invoked, and the channel does not have any children left. -// -// The returned boolean value indicates whether the channel has been successfully deleted from tree. -func (c *Channel) deleteSelfFromTree() (deleted bool) { - if !c.closeCalled || len(c.subChans)+len(c.nestedChans) != 0 { - return false - } - // not top channel - if c.Parent != nil { - c.Parent.deleteChild(c.ID) - } - return true -} - -// deleteSelfFromMap checks whether it is valid to delete the channel from the map, which means -// deleting the channel from channelz's tracking entirely. Users can no longer use id to query the -// channel, and its memory will be garbage collected. -// -// The trace reference count of the channel must be 0 in order to be deleted from the map. This is -// specified in the channel tracing gRFC that as long as some other trace has reference to an entity, -// the trace of the referenced entity must not be deleted. In order to release the resource allocated -// by grpc, the reference to the grpc object is reset to a dummy object. -// -// deleteSelfFromMap must be called after deleteSelfFromTree returns true. -// -// It returns a bool to indicate whether the channel can be safely deleted from map. -func (c *Channel) deleteSelfFromMap() (delete bool) { - return c.getTraceRefCount() == 0 -} - -// deleteSelfIfReady tries to delete the channel itself from the channelz database. -// The delete process includes two steps: -// 1. delete the channel from the entry relation tree, i.e. delete the channel reference from its -// parent's child list. -// 2. delete the channel from the map, i.e. delete the channel entirely from channelz. Lookup by id -// will return entry not found error. -func (c *Channel) deleteSelfIfReady() { - if !c.deleteSelfFromTree() { - return - } - if !c.deleteSelfFromMap() { - return - } - db.deleteEntry(c.ID) - c.trace.clear() -} - -func (c *Channel) getChannelTrace() *ChannelTrace { - return c.trace -} - -func (c *Channel) incrTraceRefCount() { - atomic.AddInt32(&c.traceRefCount, 1) -} - -func (c *Channel) decrTraceRefCount() { - atomic.AddInt32(&c.traceRefCount, -1) -} - -func (c *Channel) getTraceRefCount() int { - i := atomic.LoadInt32(&c.traceRefCount) - return int(i) -} - -func (c *Channel) getRefName() string { - return c.RefName -} diff --git a/vendor/google.golang.org/grpc/internal/channelz/channelmap.go b/vendor/google.golang.org/grpc/internal/channelz/channelmap.go deleted file mode 100644 index dfe18b089..000000000 --- a/vendor/google.golang.org/grpc/internal/channelz/channelmap.go +++ /dev/null @@ -1,402 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package channelz - -import ( - "fmt" - "sort" - "sync" - "time" -) - -// entry represents a node in the channelz database. -type entry interface { - // addChild adds a child e, whose channelz id is id to child list - addChild(id int64, e entry) - // deleteChild deletes a child with channelz id to be id from child list - deleteChild(id int64) - // triggerDelete tries to delete self from channelz database. However, if - // child list is not empty, then deletion from the database is on hold until - // the last child is deleted from database. - triggerDelete() - // deleteSelfIfReady check whether triggerDelete() has been called before, - // and whether child list is now empty. If both conditions are met, then - // delete self from database. - deleteSelfIfReady() - // getParentID returns parent ID of the entry. 0 value parent ID means no parent. - getParentID() int64 - Entity -} - -// channelMap is the storage data structure for channelz. -// -// Methods of channelMap can be divided in two two categories with respect to -// locking. -// -// 1. Methods acquire the global lock. -// 2. Methods that can only be called when global lock is held. -// -// A second type of method need always to be called inside a first type of method. -type channelMap struct { - mu sync.RWMutex - topLevelChannels map[int64]struct{} - channels map[int64]*Channel - subChannels map[int64]*SubChannel - sockets map[int64]*Socket - servers map[int64]*Server -} - -func newChannelMap() *channelMap { - return &channelMap{ - topLevelChannels: make(map[int64]struct{}), - channels: make(map[int64]*Channel), - subChannels: make(map[int64]*SubChannel), - sockets: make(map[int64]*Socket), - servers: make(map[int64]*Server), - } -} - -func (c *channelMap) addServer(id int64, s *Server) { - c.mu.Lock() - defer c.mu.Unlock() - s.cm = c - c.servers[id] = s -} - -func (c *channelMap) addChannel(id int64, cn *Channel, isTopChannel bool, pid int64) { - c.mu.Lock() - defer c.mu.Unlock() - cn.trace.cm = c - c.channels[id] = cn - if isTopChannel { - c.topLevelChannels[id] = struct{}{} - } else if p := c.channels[pid]; p != nil { - p.addChild(id, cn) - } else { - logger.Infof("channel %d references invalid parent ID %d", id, pid) - } -} - -func (c *channelMap) addSubChannel(id int64, sc *SubChannel, pid int64) { - c.mu.Lock() - defer c.mu.Unlock() - sc.trace.cm = c - c.subChannels[id] = sc - if p := c.channels[pid]; p != nil { - p.addChild(id, sc) - } else { - logger.Infof("subchannel %d references invalid parent ID %d", id, pid) - } -} - -func (c *channelMap) addSocket(s *Socket) { - c.mu.Lock() - defer c.mu.Unlock() - s.cm = c - c.sockets[s.ID] = s - if s.Parent == nil { - logger.Infof("normal socket %d has no parent", s.ID) - } - s.Parent.(entry).addChild(s.ID, s) -} - -// removeEntry triggers the removal of an entry, which may not indeed delete the -// entry, if it has to wait on the deletion of its children and until no other -// entity's channel trace references it. It may lead to a chain of entry -// deletion. For example, deleting the last socket of a gracefully shutting down -// server will lead to the server being also deleted. -func (c *channelMap) removeEntry(id int64) { - c.mu.Lock() - defer c.mu.Unlock() - c.findEntry(id).triggerDelete() -} - -// tracedChannel represents tracing operations which are present on both -// channels and subChannels. -type tracedChannel interface { - getChannelTrace() *ChannelTrace - incrTraceRefCount() - decrTraceRefCount() - getRefName() string -} - -// c.mu must be held by the caller -func (c *channelMap) decrTraceRefCount(id int64) { - e := c.findEntry(id) - if v, ok := e.(tracedChannel); ok { - v.decrTraceRefCount() - e.deleteSelfIfReady() - } -} - -// c.mu must be held by the caller. -func (c *channelMap) findEntry(id int64) entry { - if v, ok := c.channels[id]; ok { - return v - } - if v, ok := c.subChannels[id]; ok { - return v - } - if v, ok := c.servers[id]; ok { - return v - } - if v, ok := c.sockets[id]; ok { - return v - } - return &dummyEntry{idNotFound: id} -} - -// c.mu must be held by the caller -// -// deleteEntry deletes an entry from the channelMap. Before calling this method, -// caller must check this entry is ready to be deleted, i.e removeEntry() has -// been called on it, and no children still exist. -func (c *channelMap) deleteEntry(id int64) entry { - if v, ok := c.sockets[id]; ok { - delete(c.sockets, id) - return v - } - if v, ok := c.subChannels[id]; ok { - delete(c.subChannels, id) - return v - } - if v, ok := c.channels[id]; ok { - delete(c.channels, id) - delete(c.topLevelChannels, id) - return v - } - if v, ok := c.servers[id]; ok { - delete(c.servers, id) - return v - } - return &dummyEntry{idNotFound: id} -} - -func (c *channelMap) traceEvent(id int64, desc *TraceEvent) { - c.mu.Lock() - defer c.mu.Unlock() - child := c.findEntry(id) - childTC, ok := child.(tracedChannel) - if !ok { - return - } - childTC.getChannelTrace().append(&traceEvent{Desc: desc.Desc, Severity: desc.Severity, Timestamp: time.Now()}) - if desc.Parent != nil { - parent := c.findEntry(child.getParentID()) - var chanType RefChannelType - switch child.(type) { - case *Channel: - chanType = RefChannel - case *SubChannel: - chanType = RefSubChannel - } - if parentTC, ok := parent.(tracedChannel); ok { - parentTC.getChannelTrace().append(&traceEvent{ - Desc: desc.Parent.Desc, - Severity: desc.Parent.Severity, - Timestamp: time.Now(), - RefID: id, - RefName: childTC.getRefName(), - RefType: chanType, - }) - childTC.incrTraceRefCount() - } - } -} - -type int64Slice []int64 - -func (s int64Slice) Len() int { return len(s) } -func (s int64Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } -func (s int64Slice) Less(i, j int) bool { return s[i] < s[j] } - -func copyMap(m map[int64]string) map[int64]string { - n := make(map[int64]string) - for k, v := range m { - n[k] = v - } - return n -} - -func min(a, b int) int { - if a < b { - return a - } - return b -} - -func (c *channelMap) getTopChannels(id int64, maxResults int) ([]*Channel, bool) { - if maxResults <= 0 { - maxResults = EntriesPerPage - } - c.mu.RLock() - defer c.mu.RUnlock() - l := int64(len(c.topLevelChannels)) - ids := make([]int64, 0, l) - - for k := range c.topLevelChannels { - ids = append(ids, k) - } - sort.Sort(int64Slice(ids)) - idx := sort.Search(len(ids), func(i int) bool { return ids[i] >= id }) - end := true - var t []*Channel - for _, v := range ids[idx:] { - if len(t) == maxResults { - end = false - break - } - if cn, ok := c.channels[v]; ok { - t = append(t, cn) - } - } - return t, end -} - -func (c *channelMap) getServers(id int64, maxResults int) ([]*Server, bool) { - if maxResults <= 0 { - maxResults = EntriesPerPage - } - c.mu.RLock() - defer c.mu.RUnlock() - ids := make([]int64, 0, len(c.servers)) - for k := range c.servers { - ids = append(ids, k) - } - sort.Sort(int64Slice(ids)) - idx := sort.Search(len(ids), func(i int) bool { return ids[i] >= id }) - end := true - var s []*Server - for _, v := range ids[idx:] { - if len(s) == maxResults { - end = false - break - } - if svr, ok := c.servers[v]; ok { - s = append(s, svr) - } - } - return s, end -} - -func (c *channelMap) getServerSockets(id int64, startID int64, maxResults int) ([]*Socket, bool) { - if maxResults <= 0 { - maxResults = EntriesPerPage - } - c.mu.RLock() - defer c.mu.RUnlock() - svr, ok := c.servers[id] - if !ok { - // server with id doesn't exist. - return nil, true - } - svrskts := svr.sockets - ids := make([]int64, 0, len(svrskts)) - sks := make([]*Socket, 0, min(len(svrskts), maxResults)) - for k := range svrskts { - ids = append(ids, k) - } - sort.Sort(int64Slice(ids)) - idx := sort.Search(len(ids), func(i int) bool { return ids[i] >= startID }) - end := true - for _, v := range ids[idx:] { - if len(sks) == maxResults { - end = false - break - } - if ns, ok := c.sockets[v]; ok { - sks = append(sks, ns) - } - } - return sks, end -} - -func (c *channelMap) getChannel(id int64) *Channel { - c.mu.RLock() - defer c.mu.RUnlock() - return c.channels[id] -} - -func (c *channelMap) getSubChannel(id int64) *SubChannel { - c.mu.RLock() - defer c.mu.RUnlock() - return c.subChannels[id] -} - -func (c *channelMap) getSocket(id int64) *Socket { - c.mu.RLock() - defer c.mu.RUnlock() - return c.sockets[id] -} - -func (c *channelMap) getServer(id int64) *Server { - c.mu.RLock() - defer c.mu.RUnlock() - return c.servers[id] -} - -type dummyEntry struct { - // dummyEntry is a fake entry to handle entry not found case. - idNotFound int64 - Entity -} - -func (d *dummyEntry) String() string { - return fmt.Sprintf("non-existent entity #%d", d.idNotFound) -} - -func (d *dummyEntry) ID() int64 { return d.idNotFound } - -func (d *dummyEntry) addChild(id int64, e entry) { - // Note: It is possible for a normal program to reach here under race - // condition. For example, there could be a race between ClientConn.Close() - // info being propagated to addrConn and http2Client. ClientConn.Close() - // cancel the context and result in http2Client to error. The error info is - // then caught by transport monitor and before addrConn.tearDown() is called - // in side ClientConn.Close(). Therefore, the addrConn will create a new - // transport. And when registering the new transport in channelz, its parent - // addrConn could have already been torn down and deleted from channelz - // tracking, and thus reach the code here. - logger.Infof("attempt to add child of type %T with id %d to a parent (id=%d) that doesn't currently exist", e, id, d.idNotFound) -} - -func (d *dummyEntry) deleteChild(id int64) { - // It is possible for a normal program to reach here under race condition. - // Refer to the example described in addChild(). - logger.Infof("attempt to delete child with id %d from a parent (id=%d) that doesn't currently exist", id, d.idNotFound) -} - -func (d *dummyEntry) triggerDelete() { - logger.Warningf("attempt to delete an entry (id=%d) that doesn't currently exist", d.idNotFound) -} - -func (*dummyEntry) deleteSelfIfReady() { - // code should not reach here. deleteSelfIfReady is always called on an existing entry. -} - -func (*dummyEntry) getParentID() int64 { - return 0 -} - -// Entity is implemented by all channelz types. -type Entity interface { - isEntity() - fmt.Stringer - id() int64 -} diff --git a/vendor/google.golang.org/grpc/internal/channelz/funcs.go b/vendor/google.golang.org/grpc/internal/channelz/funcs.go deleted file mode 100644 index 03e24e150..000000000 --- a/vendor/google.golang.org/grpc/internal/channelz/funcs.go +++ /dev/null @@ -1,230 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package channelz defines internal APIs for enabling channelz service, entry -// registration/deletion, and accessing channelz data. It also defines channelz -// metric struct formats. -package channelz - -import ( - "sync/atomic" - "time" - - "google.golang.org/grpc/internal" -) - -var ( - // IDGen is the global channelz entity ID generator. It should not be used - // outside this package except by tests. - IDGen IDGenerator - - db *channelMap = newChannelMap() - // EntriesPerPage defines the number of channelz entries to be shown on a web page. - EntriesPerPage = 50 - curState int32 -) - -// TurnOn turns on channelz data collection. -func TurnOn() { - atomic.StoreInt32(&curState, 1) -} - -func init() { - internal.ChannelzTurnOffForTesting = func() { - atomic.StoreInt32(&curState, 0) - } -} - -// IsOn returns whether channelz data collection is on. -func IsOn() bool { - return atomic.LoadInt32(&curState) == 1 -} - -// GetTopChannels returns a slice of top channel's ChannelMetric, along with a -// boolean indicating whether there's more top channels to be queried for. -// -// The arg id specifies that only top channel with id at or above it will be -// included in the result. The returned slice is up to a length of the arg -// maxResults or EntriesPerPage if maxResults is zero, and is sorted in ascending -// id order. -func GetTopChannels(id int64, maxResults int) ([]*Channel, bool) { - return db.getTopChannels(id, maxResults) -} - -// GetServers returns a slice of server's ServerMetric, along with a -// boolean indicating whether there's more servers to be queried for. -// -// The arg id specifies that only server with id at or above it will be included -// in the result. The returned slice is up to a length of the arg maxResults or -// EntriesPerPage if maxResults is zero, and is sorted in ascending id order. -func GetServers(id int64, maxResults int) ([]*Server, bool) { - return db.getServers(id, maxResults) -} - -// GetServerSockets returns a slice of server's (identified by id) normal socket's -// SocketMetrics, along with a boolean indicating whether there's more sockets to -// be queried for. -// -// The arg startID specifies that only sockets with id at or above it will be -// included in the result. The returned slice is up to a length of the arg maxResults -// or EntriesPerPage if maxResults is zero, and is sorted in ascending id order. -func GetServerSockets(id int64, startID int64, maxResults int) ([]*Socket, bool) { - return db.getServerSockets(id, startID, maxResults) -} - -// GetChannel returns the Channel for the channel (identified by id). -func GetChannel(id int64) *Channel { - return db.getChannel(id) -} - -// GetSubChannel returns the SubChannel for the subchannel (identified by id). -func GetSubChannel(id int64) *SubChannel { - return db.getSubChannel(id) -} - -// GetSocket returns the Socket for the socket (identified by id). -func GetSocket(id int64) *Socket { - return db.getSocket(id) -} - -// GetServer returns the ServerMetric for the server (identified by id). -func GetServer(id int64) *Server { - return db.getServer(id) -} - -// RegisterChannel registers the given channel c in the channelz database with -// target as its target and reference name, and adds it to the child list of its -// parent. parent == nil means no parent. -// -// Returns a unique channelz identifier assigned to this channel. -// -// If channelz is not turned ON, the channelz database is not mutated. -func RegisterChannel(parent *Channel, target string) *Channel { - id := IDGen.genID() - - if !IsOn() { - return &Channel{ID: id} - } - - isTopChannel := parent == nil - - cn := &Channel{ - ID: id, - RefName: target, - nestedChans: make(map[int64]string), - subChans: make(map[int64]string), - Parent: parent, - trace: &ChannelTrace{CreationTime: time.Now(), Events: make([]*traceEvent, 0, getMaxTraceEntry())}, - } - cn.ChannelMetrics.Target.Store(&target) - db.addChannel(id, cn, isTopChannel, cn.getParentID()) - return cn -} - -// RegisterSubChannel registers the given subChannel c in the channelz database -// with ref as its reference name, and adds it to the child list of its parent -// (identified by pid). -// -// Returns a unique channelz identifier assigned to this subChannel. -// -// If channelz is not turned ON, the channelz database is not mutated. -func RegisterSubChannel(parent *Channel, ref string) *SubChannel { - id := IDGen.genID() - sc := &SubChannel{ - ID: id, - RefName: ref, - parent: parent, - } - - if !IsOn() { - return sc - } - - sc.sockets = make(map[int64]string) - sc.trace = &ChannelTrace{CreationTime: time.Now(), Events: make([]*traceEvent, 0, getMaxTraceEntry())} - db.addSubChannel(id, sc, parent.ID) - return sc -} - -// RegisterServer registers the given server s in channelz database. It returns -// the unique channelz tracking id assigned to this server. -// -// If channelz is not turned ON, the channelz database is not mutated. -func RegisterServer(ref string) *Server { - id := IDGen.genID() - if !IsOn() { - return &Server{ID: id} - } - - svr := &Server{ - RefName: ref, - sockets: make(map[int64]string), - listenSockets: make(map[int64]string), - ID: id, - } - db.addServer(id, svr) - return svr -} - -// RegisterSocket registers the given normal socket s in channelz database -// with ref as its reference name, and adds it to the child list of its parent -// (identified by skt.Parent, which must be set). It returns the unique channelz -// tracking id assigned to this normal socket. -// -// If channelz is not turned ON, the channelz database is not mutated. -func RegisterSocket(skt *Socket) *Socket { - skt.ID = IDGen.genID() - if IsOn() { - db.addSocket(skt) - } - return skt -} - -// RemoveEntry removes an entry with unique channelz tracking id to be id from -// channelz database. -// -// If channelz is not turned ON, this function is a no-op. -func RemoveEntry(id int64) { - if !IsOn() { - return - } - db.removeEntry(id) -} - -// IDGenerator is an incrementing atomic that tracks IDs for channelz entities. -type IDGenerator struct { - id int64 -} - -// Reset resets the generated ID back to zero. Should only be used at -// initialization or by tests sensitive to the ID number. -func (i *IDGenerator) Reset() { - atomic.StoreInt64(&i.id, 0) -} - -func (i *IDGenerator) genID() int64 { - return atomic.AddInt64(&i.id, 1) -} - -// Identifier is an opaque channelz identifier used to expose channelz symbols -// outside of grpc. Currently only implemented by Channel since no other -// types require exposure outside grpc. -type Identifier interface { - Entity - channelzIdentifier() -} diff --git a/vendor/google.golang.org/grpc/internal/channelz/logging.go b/vendor/google.golang.org/grpc/internal/channelz/logging.go deleted file mode 100644 index ee4d72125..000000000 --- a/vendor/google.golang.org/grpc/internal/channelz/logging.go +++ /dev/null @@ -1,75 +0,0 @@ -/* - * - * Copyright 2020 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package channelz - -import ( - "fmt" - - "google.golang.org/grpc/grpclog" -) - -var logger = grpclog.Component("channelz") - -// Info logs and adds a trace event if channelz is on. -func Info(l grpclog.DepthLoggerV2, e Entity, args ...any) { - AddTraceEvent(l, e, 1, &TraceEvent{ - Desc: fmt.Sprint(args...), - Severity: CtInfo, - }) -} - -// Infof logs and adds a trace event if channelz is on. -func Infof(l grpclog.DepthLoggerV2, e Entity, format string, args ...any) { - AddTraceEvent(l, e, 1, &TraceEvent{ - Desc: fmt.Sprintf(format, args...), - Severity: CtInfo, - }) -} - -// Warning logs and adds a trace event if channelz is on. -func Warning(l grpclog.DepthLoggerV2, e Entity, args ...any) { - AddTraceEvent(l, e, 1, &TraceEvent{ - Desc: fmt.Sprint(args...), - Severity: CtWarning, - }) -} - -// Warningf logs and adds a trace event if channelz is on. -func Warningf(l grpclog.DepthLoggerV2, e Entity, format string, args ...any) { - AddTraceEvent(l, e, 1, &TraceEvent{ - Desc: fmt.Sprintf(format, args...), - Severity: CtWarning, - }) -} - -// Error logs and adds a trace event if channelz is on. -func Error(l grpclog.DepthLoggerV2, e Entity, args ...any) { - AddTraceEvent(l, e, 1, &TraceEvent{ - Desc: fmt.Sprint(args...), - Severity: CtError, - }) -} - -// Errorf logs and adds a trace event if channelz is on. -func Errorf(l grpclog.DepthLoggerV2, e Entity, format string, args ...any) { - AddTraceEvent(l, e, 1, &TraceEvent{ - Desc: fmt.Sprintf(format, args...), - Severity: CtError, - }) -} diff --git a/vendor/google.golang.org/grpc/internal/channelz/server.go b/vendor/google.golang.org/grpc/internal/channelz/server.go deleted file mode 100644 index cdfc49d6e..000000000 --- a/vendor/google.golang.org/grpc/internal/channelz/server.go +++ /dev/null @@ -1,119 +0,0 @@ -/* - * - * Copyright 2024 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package channelz - -import ( - "fmt" - "sync/atomic" -) - -// Server is the channelz representation of a server. -type Server struct { - Entity - ID int64 - RefName string - - ServerMetrics ServerMetrics - - closeCalled bool - sockets map[int64]string - listenSockets map[int64]string - cm *channelMap -} - -// ServerMetrics defines a struct containing metrics for servers. -type ServerMetrics struct { - // The number of incoming calls started on the server. - CallsStarted atomic.Int64 - // The number of incoming calls that have completed with an OK status. - CallsSucceeded atomic.Int64 - // The number of incoming calls that have a completed with a non-OK status. - CallsFailed atomic.Int64 - // The last time a call was started on the server. - LastCallStartedTimestamp atomic.Int64 -} - -// NewServerMetricsForTesting returns an initialized ServerMetrics. -func NewServerMetricsForTesting(started, succeeded, failed, timestamp int64) *ServerMetrics { - sm := &ServerMetrics{} - sm.CallsStarted.Store(started) - sm.CallsSucceeded.Store(succeeded) - sm.CallsFailed.Store(failed) - sm.LastCallStartedTimestamp.Store(timestamp) - return sm -} - -func (sm *ServerMetrics) CopyFrom(o *ServerMetrics) { - sm.CallsStarted.Store(o.CallsStarted.Load()) - sm.CallsSucceeded.Store(o.CallsSucceeded.Load()) - sm.CallsFailed.Store(o.CallsFailed.Load()) - sm.LastCallStartedTimestamp.Store(o.LastCallStartedTimestamp.Load()) -} - -// ListenSockets returns the listening sockets for s. -func (s *Server) ListenSockets() map[int64]string { - db.mu.RLock() - defer db.mu.RUnlock() - return copyMap(s.listenSockets) -} - -// String returns a printable description of s. -func (s *Server) String() string { - return fmt.Sprintf("Server #%d", s.ID) -} - -func (s *Server) id() int64 { - return s.ID -} - -func (s *Server) addChild(id int64, e entry) { - switch v := e.(type) { - case *Socket: - switch v.SocketType { - case SocketTypeNormal: - s.sockets[id] = v.RefName - case SocketTypeListen: - s.listenSockets[id] = v.RefName - } - default: - logger.Errorf("cannot add a child (id = %d) of type %T to a server", id, e) - } -} - -func (s *Server) deleteChild(id int64) { - delete(s.sockets, id) - delete(s.listenSockets, id) - s.deleteSelfIfReady() -} - -func (s *Server) triggerDelete() { - s.closeCalled = true - s.deleteSelfIfReady() -} - -func (s *Server) deleteSelfIfReady() { - if !s.closeCalled || len(s.sockets)+len(s.listenSockets) != 0 { - return - } - s.cm.deleteEntry(s.ID) -} - -func (s *Server) getParentID() int64 { - return 0 -} diff --git a/vendor/google.golang.org/grpc/internal/channelz/socket.go b/vendor/google.golang.org/grpc/internal/channelz/socket.go deleted file mode 100644 index fa64834b2..000000000 --- a/vendor/google.golang.org/grpc/internal/channelz/socket.go +++ /dev/null @@ -1,130 +0,0 @@ -/* - * - * Copyright 2024 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package channelz - -import ( - "fmt" - "net" - "sync/atomic" - - "google.golang.org/grpc/credentials" -) - -// SocketMetrics defines the struct that the implementor of Socket interface -// should return from ChannelzMetric(). -type SocketMetrics struct { - // The number of streams that have been started. - StreamsStarted atomic.Int64 - // The number of streams that have ended successfully: - // On client side, receiving frame with eos bit set. - // On server side, sending frame with eos bit set. - StreamsSucceeded atomic.Int64 - // The number of streams that have ended unsuccessfully: - // On client side, termination without receiving frame with eos bit set. - // On server side, termination without sending frame with eos bit set. - StreamsFailed atomic.Int64 - // The number of messages successfully sent on this socket. - MessagesSent atomic.Int64 - MessagesReceived atomic.Int64 - // The number of keep alives sent. This is typically implemented with HTTP/2 - // ping messages. - KeepAlivesSent atomic.Int64 - // The last time a stream was created by this endpoint. Usually unset for - // servers. - LastLocalStreamCreatedTimestamp atomic.Int64 - // The last time a stream was created by the remote endpoint. Usually unset - // for clients. - LastRemoteStreamCreatedTimestamp atomic.Int64 - // The last time a message was sent by this endpoint. - LastMessageSentTimestamp atomic.Int64 - // The last time a message was received by this endpoint. - LastMessageReceivedTimestamp atomic.Int64 -} - -// EphemeralSocketMetrics are metrics that change rapidly and are tracked -// outside of channelz. -type EphemeralSocketMetrics struct { - // The amount of window, granted to the local endpoint by the remote endpoint. - // This may be slightly out of date due to network latency. This does NOT - // include stream level or TCP level flow control info. - LocalFlowControlWindow int64 - // The amount of window, granted to the remote endpoint by the local endpoint. - // This may be slightly out of date due to network latency. This does NOT - // include stream level or TCP level flow control info. - RemoteFlowControlWindow int64 -} - -type SocketType string - -const ( - SocketTypeNormal = "NormalSocket" - SocketTypeListen = "ListenSocket" -) - -type Socket struct { - Entity - SocketType SocketType - ID int64 - Parent Entity - cm *channelMap - SocketMetrics SocketMetrics - EphemeralMetrics func() *EphemeralSocketMetrics - - RefName string - // The locally bound address. Immutable. - LocalAddr net.Addr - // The remote bound address. May be absent. Immutable. - RemoteAddr net.Addr - // Optional, represents the name of the remote endpoint, if different than - // the original target name. Immutable. - RemoteName string - // Immutable. - SocketOptions *SocketOptionData - // Immutable. - Security credentials.ChannelzSecurityValue -} - -func (ls *Socket) String() string { - return fmt.Sprintf("%s %s #%d", ls.Parent, ls.SocketType, ls.ID) -} - -func (ls *Socket) id() int64 { - return ls.ID -} - -func (ls *Socket) addChild(id int64, e entry) { - logger.Errorf("cannot add a child (id = %d) of type %T to a listen socket", id, e) -} - -func (ls *Socket) deleteChild(id int64) { - logger.Errorf("cannot delete a child (id = %d) from a listen socket", id) -} - -func (ls *Socket) triggerDelete() { - ls.cm.deleteEntry(ls.ID) - ls.Parent.(entry).deleteChild(ls.ID) -} - -func (ls *Socket) deleteSelfIfReady() { - logger.Errorf("cannot call deleteSelfIfReady on a listen socket") -} - -func (ls *Socket) getParentID() int64 { - return ls.Parent.id() -} diff --git a/vendor/google.golang.org/grpc/internal/channelz/subchannel.go b/vendor/google.golang.org/grpc/internal/channelz/subchannel.go deleted file mode 100644 index 3b88e4cba..000000000 --- a/vendor/google.golang.org/grpc/internal/channelz/subchannel.go +++ /dev/null @@ -1,151 +0,0 @@ -/* - * - * Copyright 2024 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package channelz - -import ( - "fmt" - "sync/atomic" -) - -// SubChannel is the channelz representation of a subchannel. -type SubChannel struct { - Entity - // ID is the channelz id of this subchannel. - ID int64 - // RefName is the human readable reference string of this subchannel. - RefName string - closeCalled bool - sockets map[int64]string - parent *Channel - trace *ChannelTrace - traceRefCount int32 - - ChannelMetrics ChannelMetrics -} - -func (sc *SubChannel) String() string { - return fmt.Sprintf("%s SubChannel #%d", sc.parent, sc.ID) -} - -func (sc *SubChannel) id() int64 { - return sc.ID -} - -func (sc *SubChannel) Sockets() map[int64]string { - db.mu.RLock() - defer db.mu.RUnlock() - return copyMap(sc.sockets) -} - -func (sc *SubChannel) Trace() *ChannelTrace { - db.mu.RLock() - defer db.mu.RUnlock() - return sc.trace.copy() -} - -func (sc *SubChannel) addChild(id int64, e entry) { - if v, ok := e.(*Socket); ok && v.SocketType == SocketTypeNormal { - sc.sockets[id] = v.RefName - } else { - logger.Errorf("cannot add a child (id = %d) of type %T to a subChannel", id, e) - } -} - -func (sc *SubChannel) deleteChild(id int64) { - delete(sc.sockets, id) - sc.deleteSelfIfReady() -} - -func (sc *SubChannel) triggerDelete() { - sc.closeCalled = true - sc.deleteSelfIfReady() -} - -func (sc *SubChannel) getParentID() int64 { - return sc.parent.ID -} - -// deleteSelfFromTree tries to delete the subchannel from the channelz entry relation tree, which -// means deleting the subchannel reference from its parent's child list. -// -// In order for a subchannel to be deleted from the tree, it must meet the criteria that, removal of -// the corresponding grpc object has been invoked, and the subchannel does not have any children left. -// -// The returned boolean value indicates whether the channel has been successfully deleted from tree. -func (sc *SubChannel) deleteSelfFromTree() (deleted bool) { - if !sc.closeCalled || len(sc.sockets) != 0 { - return false - } - sc.parent.deleteChild(sc.ID) - return true -} - -// deleteSelfFromMap checks whether it is valid to delete the subchannel from the map, which means -// deleting the subchannel from channelz's tracking entirely. Users can no longer use id to query -// the subchannel, and its memory will be garbage collected. -// -// The trace reference count of the subchannel must be 0 in order to be deleted from the map. This is -// specified in the channel tracing gRFC that as long as some other trace has reference to an entity, -// the trace of the referenced entity must not be deleted. In order to release the resource allocated -// by grpc, the reference to the grpc object is reset to a dummy object. -// -// deleteSelfFromMap must be called after deleteSelfFromTree returns true. -// -// It returns a bool to indicate whether the channel can be safely deleted from map. -func (sc *SubChannel) deleteSelfFromMap() (delete bool) { - return sc.getTraceRefCount() == 0 -} - -// deleteSelfIfReady tries to delete the subchannel itself from the channelz database. -// The delete process includes two steps: -// 1. delete the subchannel from the entry relation tree, i.e. delete the subchannel reference from -// its parent's child list. -// 2. delete the subchannel from the map, i.e. delete the subchannel entirely from channelz. Lookup -// by id will return entry not found error. -func (sc *SubChannel) deleteSelfIfReady() { - if !sc.deleteSelfFromTree() { - return - } - if !sc.deleteSelfFromMap() { - return - } - db.deleteEntry(sc.ID) - sc.trace.clear() -} - -func (sc *SubChannel) getChannelTrace() *ChannelTrace { - return sc.trace -} - -func (sc *SubChannel) incrTraceRefCount() { - atomic.AddInt32(&sc.traceRefCount, 1) -} - -func (sc *SubChannel) decrTraceRefCount() { - atomic.AddInt32(&sc.traceRefCount, -1) -} - -func (sc *SubChannel) getTraceRefCount() int { - i := atomic.LoadInt32(&sc.traceRefCount) - return int(i) -} - -func (sc *SubChannel) getRefName() string { - return sc.RefName -} diff --git a/vendor/google.golang.org/grpc/internal/channelz/syscall_linux.go b/vendor/google.golang.org/grpc/internal/channelz/syscall_linux.go deleted file mode 100644 index 5ac73ff83..000000000 --- a/vendor/google.golang.org/grpc/internal/channelz/syscall_linux.go +++ /dev/null @@ -1,65 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package channelz - -import ( - "syscall" - - "golang.org/x/sys/unix" -) - -// SocketOptionData defines the struct to hold socket option data, and related -// getter function to obtain info from fd. -type SocketOptionData struct { - Linger *unix.Linger - RecvTimeout *unix.Timeval - SendTimeout *unix.Timeval - TCPInfo *unix.TCPInfo -} - -// Getsockopt defines the function to get socket options requested by channelz. -// It is to be passed to syscall.RawConn.Control(). -func (s *SocketOptionData) Getsockopt(fd uintptr) { - if v, err := unix.GetsockoptLinger(int(fd), syscall.SOL_SOCKET, syscall.SO_LINGER); err == nil { - s.Linger = v - } - if v, err := unix.GetsockoptTimeval(int(fd), syscall.SOL_SOCKET, syscall.SO_RCVTIMEO); err == nil { - s.RecvTimeout = v - } - if v, err := unix.GetsockoptTimeval(int(fd), syscall.SOL_SOCKET, syscall.SO_SNDTIMEO); err == nil { - s.SendTimeout = v - } - if v, err := unix.GetsockoptTCPInfo(int(fd), syscall.SOL_TCP, syscall.TCP_INFO); err == nil { - s.TCPInfo = v - } -} - -// GetSocketOption gets the socket option info of the conn. -func GetSocketOption(socket any) *SocketOptionData { - c, ok := socket.(syscall.Conn) - if !ok { - return nil - } - data := &SocketOptionData{} - if rawConn, err := c.SyscallConn(); err == nil { - rawConn.Control(data.Getsockopt) - return data - } - return nil -} diff --git a/vendor/google.golang.org/grpc/internal/channelz/syscall_nonlinux.go b/vendor/google.golang.org/grpc/internal/channelz/syscall_nonlinux.go deleted file mode 100644 index d1ed8df6a..000000000 --- a/vendor/google.golang.org/grpc/internal/channelz/syscall_nonlinux.go +++ /dev/null @@ -1,47 +0,0 @@ -//go:build !linux - -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package channelz - -import ( - "sync" -) - -var once sync.Once - -// SocketOptionData defines the struct to hold socket option data, and related -// getter function to obtain info from fd. -// Windows OS doesn't support Socket Option -type SocketOptionData struct { -} - -// Getsockopt defines the function to get socket options requested by channelz. -// It is to be passed to syscall.RawConn.Control(). -// Windows OS doesn't support Socket Option -func (s *SocketOptionData) Getsockopt(fd uintptr) { - once.Do(func() { - logger.Warning("Channelz: socket options are not supported on non-linux environments") - }) -} - -// GetSocketOption gets the socket option info of the conn. -func GetSocketOption(c any) *SocketOptionData { - return nil -} diff --git a/vendor/google.golang.org/grpc/internal/channelz/trace.go b/vendor/google.golang.org/grpc/internal/channelz/trace.go deleted file mode 100644 index 36b867403..000000000 --- a/vendor/google.golang.org/grpc/internal/channelz/trace.go +++ /dev/null @@ -1,204 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package channelz - -import ( - "fmt" - "sync" - "sync/atomic" - "time" - - "google.golang.org/grpc/grpclog" -) - -const ( - defaultMaxTraceEntry int32 = 30 -) - -var maxTraceEntry = defaultMaxTraceEntry - -// SetMaxTraceEntry sets maximum number of trace entries per entity (i.e. -// channel/subchannel). Setting it to 0 will disable channel tracing. -func SetMaxTraceEntry(i int32) { - atomic.StoreInt32(&maxTraceEntry, i) -} - -// ResetMaxTraceEntryToDefault resets the maximum number of trace entries per -// entity to default. -func ResetMaxTraceEntryToDefault() { - atomic.StoreInt32(&maxTraceEntry, defaultMaxTraceEntry) -} - -func getMaxTraceEntry() int { - i := atomic.LoadInt32(&maxTraceEntry) - return int(i) -} - -// traceEvent is an internal representation of a single trace event -type traceEvent struct { - // Desc is a simple description of the trace event. - Desc string - // Severity states the severity of this trace event. - Severity Severity - // Timestamp is the event time. - Timestamp time.Time - // RefID is the id of the entity that gets referenced in the event. RefID is 0 if no other entity is - // involved in this event. - // e.g. SubChannel (id: 4[]) Created. --> RefID = 4, RefName = "" (inside []) - RefID int64 - // RefName is the reference name for the entity that gets referenced in the event. - RefName string - // RefType indicates the referenced entity type, i.e Channel or SubChannel. - RefType RefChannelType -} - -// TraceEvent is what the caller of AddTraceEvent should provide to describe the -// event to be added to the channel trace. -// -// The Parent field is optional. It is used for an event that will be recorded -// in the entity's parent trace. -type TraceEvent struct { - Desc string - Severity Severity - Parent *TraceEvent -} - -type ChannelTrace struct { - cm *channelMap - clearCalled bool - CreationTime time.Time - EventNum int64 - mu sync.Mutex - Events []*traceEvent -} - -func (c *ChannelTrace) copy() *ChannelTrace { - return &ChannelTrace{ - CreationTime: c.CreationTime, - EventNum: c.EventNum, - Events: append(([]*traceEvent)(nil), c.Events...), - } -} - -func (c *ChannelTrace) append(e *traceEvent) { - c.mu.Lock() - if len(c.Events) == getMaxTraceEntry() { - del := c.Events[0] - c.Events = c.Events[1:] - if del.RefID != 0 { - // start recursive cleanup in a goroutine to not block the call originated from grpc. - go func() { - // need to acquire c.cm.mu lock to call the unlocked attemptCleanup func. - c.cm.mu.Lock() - c.cm.decrTraceRefCount(del.RefID) - c.cm.mu.Unlock() - }() - } - } - e.Timestamp = time.Now() - c.Events = append(c.Events, e) - c.EventNum++ - c.mu.Unlock() -} - -func (c *ChannelTrace) clear() { - if c.clearCalled { - return - } - c.clearCalled = true - c.mu.Lock() - for _, e := range c.Events { - if e.RefID != 0 { - // caller should have already held the c.cm.mu lock. - c.cm.decrTraceRefCount(e.RefID) - } - } - c.mu.Unlock() -} - -// Severity is the severity level of a trace event. -// The canonical enumeration of all valid values is here: -// https://github.com/grpc/grpc-proto/blob/9b13d199cc0d4703c7ea26c9c330ba695866eb23/grpc/channelz/v1/channelz.proto#L126. -type Severity int - -const ( - // CtUnknown indicates unknown severity of a trace event. - CtUnknown Severity = iota - // CtInfo indicates info level severity of a trace event. - CtInfo - // CtWarning indicates warning level severity of a trace event. - CtWarning - // CtError indicates error level severity of a trace event. - CtError -) - -// RefChannelType is the type of the entity being referenced in a trace event. -type RefChannelType int - -const ( - // RefUnknown indicates an unknown entity type, the zero value for this type. - RefUnknown RefChannelType = iota - // RefChannel indicates the referenced entity is a Channel. - RefChannel - // RefSubChannel indicates the referenced entity is a SubChannel. - RefSubChannel - // RefServer indicates the referenced entity is a Server. - RefServer - // RefListenSocket indicates the referenced entity is a ListenSocket. - RefListenSocket - // RefNormalSocket indicates the referenced entity is a NormalSocket. - RefNormalSocket -) - -var refChannelTypeToString = map[RefChannelType]string{ - RefUnknown: "Unknown", - RefChannel: "Channel", - RefSubChannel: "SubChannel", - RefServer: "Server", - RefListenSocket: "ListenSocket", - RefNormalSocket: "NormalSocket", -} - -func (r RefChannelType) String() string { - return refChannelTypeToString[r] -} - -// AddTraceEvent adds trace related to the entity with specified id, using the -// provided TraceEventDesc. -// -// If channelz is not turned ON, this will simply log the event descriptions. -func AddTraceEvent(l grpclog.DepthLoggerV2, e Entity, depth int, desc *TraceEvent) { - // Log only the trace description associated with the bottom most entity. - d := fmt.Sprintf("[%s]%s", e, desc.Desc) - switch desc.Severity { - case CtUnknown, CtInfo: - l.InfoDepth(depth+1, d) - case CtWarning: - l.WarningDepth(depth+1, d) - case CtError: - l.ErrorDepth(depth+1, d) - } - - if getMaxTraceEntry() == 0 { - return - } - if IsOn() { - db.traceEvent(e.id(), desc) - } -} diff --git a/vendor/google.golang.org/grpc/internal/credentials/credentials.go b/vendor/google.golang.org/grpc/internal/credentials/credentials.go deleted file mode 100644 index 9deee7f65..000000000 --- a/vendor/google.golang.org/grpc/internal/credentials/credentials.go +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2021 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package credentials - -import ( - "context" -) - -// requestInfoKey is a struct to be used as the key to store RequestInfo in a -// context. -type requestInfoKey struct{} - -// NewRequestInfoContext creates a context with ri. -func NewRequestInfoContext(ctx context.Context, ri any) context.Context { - return context.WithValue(ctx, requestInfoKey{}, ri) -} - -// RequestInfoFromContext extracts the RequestInfo from ctx. -func RequestInfoFromContext(ctx context.Context) any { - return ctx.Value(requestInfoKey{}) -} - -// clientHandshakeInfoKey is a struct used as the key to store -// ClientHandshakeInfo in a context. -type clientHandshakeInfoKey struct{} - -// ClientHandshakeInfoFromContext extracts the ClientHandshakeInfo from ctx. -func ClientHandshakeInfoFromContext(ctx context.Context) any { - return ctx.Value(clientHandshakeInfoKey{}) -} - -// NewClientHandshakeInfoContext creates a context with chi. -func NewClientHandshakeInfoContext(ctx context.Context, chi any) context.Context { - return context.WithValue(ctx, clientHandshakeInfoKey{}, chi) -} diff --git a/vendor/google.golang.org/grpc/internal/credentials/spiffe.go b/vendor/google.golang.org/grpc/internal/credentials/spiffe.go deleted file mode 100644 index 25ade6230..000000000 --- a/vendor/google.golang.org/grpc/internal/credentials/spiffe.go +++ /dev/null @@ -1,75 +0,0 @@ -/* - * - * Copyright 2020 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package credentials defines APIs for parsing SPIFFE ID. -// -// All APIs in this package are experimental. -package credentials - -import ( - "crypto/tls" - "crypto/x509" - "net/url" - - "google.golang.org/grpc/grpclog" -) - -var logger = grpclog.Component("credentials") - -// SPIFFEIDFromState parses the SPIFFE ID from State. If the SPIFFE ID format -// is invalid, return nil with warning. -func SPIFFEIDFromState(state tls.ConnectionState) *url.URL { - if len(state.PeerCertificates) == 0 || len(state.PeerCertificates[0].URIs) == 0 { - return nil - } - return SPIFFEIDFromCert(state.PeerCertificates[0]) -} - -// SPIFFEIDFromCert parses the SPIFFE ID from x509.Certificate. If the SPIFFE -// ID format is invalid, return nil with warning. -func SPIFFEIDFromCert(cert *x509.Certificate) *url.URL { - if cert == nil || cert.URIs == nil { - return nil - } - var spiffeID *url.URL - for _, uri := range cert.URIs { - if uri == nil || uri.Scheme != "spiffe" || uri.Opaque != "" || (uri.User != nil && uri.User.Username() != "") { - continue - } - // From this point, we assume the uri is intended for a SPIFFE ID. - if len(uri.String()) > 2048 { - logger.Warning("invalid SPIFFE ID: total ID length larger than 2048 bytes") - return nil - } - if len(uri.Host) == 0 || len(uri.Path) == 0 { - logger.Warning("invalid SPIFFE ID: domain or workload ID is empty") - return nil - } - if len(uri.Host) > 255 { - logger.Warning("invalid SPIFFE ID: domain length larger than 255 characters") - return nil - } - // A valid SPIFFE certificate can only have exactly one URI SAN field. - if len(cert.URIs) > 1 { - logger.Warning("invalid SPIFFE ID: multiple URI SANs") - return nil - } - spiffeID = uri - } - return spiffeID -} diff --git a/vendor/google.golang.org/grpc/internal/credentials/syscallconn.go b/vendor/google.golang.org/grpc/internal/credentials/syscallconn.go deleted file mode 100644 index 2919632d6..000000000 --- a/vendor/google.golang.org/grpc/internal/credentials/syscallconn.go +++ /dev/null @@ -1,58 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package credentials - -import ( - "net" - "syscall" -) - -type sysConn = syscall.Conn - -// syscallConn keeps reference of rawConn to support syscall.Conn for channelz. -// SyscallConn() (the method in interface syscall.Conn) is explicitly -// implemented on this type, -// -// Interface syscall.Conn is implemented by most net.Conn implementations (e.g. -// TCPConn, UnixConn), but is not part of net.Conn interface. So wrapper conns -// that embed net.Conn don't implement syscall.Conn. (Side note: tls.Conn -// doesn't embed net.Conn, so even if syscall.Conn is part of net.Conn, it won't -// help here). -type syscallConn struct { - net.Conn - // sysConn is a type alias of syscall.Conn. It's necessary because the name - // `Conn` collides with `net.Conn`. - sysConn -} - -// WrapSyscallConn tries to wrap rawConn and newConn into a net.Conn that -// implements syscall.Conn. rawConn will be used to support syscall, and newConn -// will be used for read/write. -// -// This function returns newConn if rawConn doesn't implement syscall.Conn. -func WrapSyscallConn(rawConn, newConn net.Conn) net.Conn { - sysConn, ok := rawConn.(syscall.Conn) - if !ok { - return newConn - } - return &syscallConn{ - Conn: newConn, - sysConn: sysConn, - } -} diff --git a/vendor/google.golang.org/grpc/internal/credentials/util.go b/vendor/google.golang.org/grpc/internal/credentials/util.go deleted file mode 100644 index f792fd22c..000000000 --- a/vendor/google.golang.org/grpc/internal/credentials/util.go +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * Copyright 2020 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package credentials - -import ( - "crypto/tls" -) - -const alpnProtoStrH2 = "h2" - -// AppendH2ToNextProtos appends h2 to next protos. -func AppendH2ToNextProtos(ps []string) []string { - for _, p := range ps { - if p == alpnProtoStrH2 { - return ps - } - } - ret := make([]string, 0, len(ps)+1) - ret = append(ret, ps...) - return append(ret, alpnProtoStrH2) -} - -// CloneTLSConfig returns a shallow clone of the exported -// fields of cfg, ignoring the unexported sync.Once, which -// contains a mutex and must not be copied. -// -// If cfg is nil, a new zero tls.Config is returned. -// -// TODO: inline this function if possible. -func CloneTLSConfig(cfg *tls.Config) *tls.Config { - if cfg == nil { - return &tls.Config{} - } - - return cfg.Clone() -} diff --git a/vendor/google.golang.org/grpc/internal/envconfig/envconfig.go b/vendor/google.golang.org/grpc/internal/envconfig/envconfig.go deleted file mode 100644 index 685a3cb41..000000000 --- a/vendor/google.golang.org/grpc/internal/envconfig/envconfig.go +++ /dev/null @@ -1,69 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package envconfig contains grpc settings configured by environment variables. -package envconfig - -import ( - "os" - "strconv" - "strings" -) - -var ( - // TXTErrIgnore is set if TXT errors should be ignored ("GRPC_GO_IGNORE_TXT_ERRORS" is not "false"). - TXTErrIgnore = boolFromEnv("GRPC_GO_IGNORE_TXT_ERRORS", true) - // AdvertiseCompressors is set if registered compressor should be advertised - // ("GRPC_GO_ADVERTISE_COMPRESSORS" is not "false"). - AdvertiseCompressors = boolFromEnv("GRPC_GO_ADVERTISE_COMPRESSORS", true) - // RingHashCap indicates the maximum ring size which defaults to 4096 - // entries but may be overridden by setting the environment variable - // "GRPC_RING_HASH_CAP". This does not override the default bounds - // checking which NACKs configs specifying ring sizes > 8*1024*1024 (~8M). - RingHashCap = uint64FromEnv("GRPC_RING_HASH_CAP", 4096, 1, 8*1024*1024) - // LeastRequestLB is set if we should support the least_request_experimental - // LB policy, which can be enabled by setting the environment variable - // "GRPC_EXPERIMENTAL_ENABLE_LEAST_REQUEST" to "true". - LeastRequestLB = boolFromEnv("GRPC_EXPERIMENTAL_ENABLE_LEAST_REQUEST", false) - // ALTSMaxConcurrentHandshakes is the maximum number of concurrent ALTS - // handshakes that can be performed. - ALTSMaxConcurrentHandshakes = uint64FromEnv("GRPC_ALTS_MAX_CONCURRENT_HANDSHAKES", 100, 1, 100) -) - -func boolFromEnv(envVar string, def bool) bool { - if def { - // The default is true; return true unless the variable is "false". - return !strings.EqualFold(os.Getenv(envVar), "false") - } - // The default is false; return false unless the variable is "true". - return strings.EqualFold(os.Getenv(envVar), "true") -} - -func uint64FromEnv(envVar string, def, min, max uint64) uint64 { - v, err := strconv.ParseUint(os.Getenv(envVar), 10, 64) - if err != nil { - return def - } - if v < min { - return min - } - if v > max { - return max - } - return v -} diff --git a/vendor/google.golang.org/grpc/internal/envconfig/observability.go b/vendor/google.golang.org/grpc/internal/envconfig/observability.go deleted file mode 100644 index dd314cfb1..000000000 --- a/vendor/google.golang.org/grpc/internal/envconfig/observability.go +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * Copyright 2022 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package envconfig - -import "os" - -const ( - envObservabilityConfig = "GRPC_GCP_OBSERVABILITY_CONFIG" - envObservabilityConfigFile = "GRPC_GCP_OBSERVABILITY_CONFIG_FILE" -) - -var ( - // ObservabilityConfig is the json configuration for the gcp/observability - // package specified directly in the envObservabilityConfig env var. - // - // This is used in the 1.0 release of gcp/observability, and thus must not be - // deleted or changed. - ObservabilityConfig = os.Getenv(envObservabilityConfig) - // ObservabilityConfigFile is the json configuration for the - // gcp/observability specified in a file with the location specified in - // envObservabilityConfigFile env var. - // - // This is used in the 1.0 release of gcp/observability, and thus must not be - // deleted or changed. - ObservabilityConfigFile = os.Getenv(envObservabilityConfigFile) -) diff --git a/vendor/google.golang.org/grpc/internal/envconfig/xds.go b/vendor/google.golang.org/grpc/internal/envconfig/xds.go deleted file mode 100644 index 29f234acb..000000000 --- a/vendor/google.golang.org/grpc/internal/envconfig/xds.go +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * Copyright 2020 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package envconfig - -import ( - "os" -) - -const ( - // XDSBootstrapFileNameEnv is the env variable to set bootstrap file name. - // Do not use this and read from env directly. Its value is read and kept in - // variable XDSBootstrapFileName. - // - // When both bootstrap FileName and FileContent are set, FileName is used. - XDSBootstrapFileNameEnv = "GRPC_XDS_BOOTSTRAP" - // XDSBootstrapFileContentEnv is the env variable to set bootstrap file - // content. Do not use this and read from env directly. Its value is read - // and kept in variable XDSBootstrapFileContent. - // - // When both bootstrap FileName and FileContent are set, FileName is used. - XDSBootstrapFileContentEnv = "GRPC_XDS_BOOTSTRAP_CONFIG" -) - -var ( - // XDSBootstrapFileName holds the name of the file which contains xDS - // bootstrap configuration. Users can specify the location of the bootstrap - // file by setting the environment variable "GRPC_XDS_BOOTSTRAP". - // - // When both bootstrap FileName and FileContent are set, FileName is used. - XDSBootstrapFileName = os.Getenv(XDSBootstrapFileNameEnv) - // XDSBootstrapFileContent holds the content of the xDS bootstrap - // configuration. Users can specify the bootstrap config by setting the - // environment variable "GRPC_XDS_BOOTSTRAP_CONFIG". - // - // When both bootstrap FileName and FileContent are set, FileName is used. - XDSBootstrapFileContent = os.Getenv(XDSBootstrapFileContentEnv) - - // C2PResolverTestOnlyTrafficDirectorURI is the TD URI for testing. - C2PResolverTestOnlyTrafficDirectorURI = os.Getenv("GRPC_TEST_ONLY_GOOGLE_C2P_RESOLVER_TRAFFIC_DIRECTOR_URI") -) diff --git a/vendor/google.golang.org/grpc/internal/experimental.go b/vendor/google.golang.org/grpc/internal/experimental.go deleted file mode 100644 index 7f7044e17..000000000 --- a/vendor/google.golang.org/grpc/internal/experimental.go +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2023 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package internal - -var ( - // WithRecvBufferPool is implemented by the grpc package and returns a dial - // option to configure a shared buffer pool for a grpc.ClientConn. - WithRecvBufferPool any // func (grpc.SharedBufferPool) grpc.DialOption - - // RecvBufferPool is implemented by the grpc package and returns a server - // option to configure a shared buffer pool for a grpc.Server. - RecvBufferPool any // func (grpc.SharedBufferPool) grpc.ServerOption -) diff --git a/vendor/google.golang.org/grpc/internal/grpclog/grpclog.go b/vendor/google.golang.org/grpc/internal/grpclog/grpclog.go deleted file mode 100644 index bfc45102a..000000000 --- a/vendor/google.golang.org/grpc/internal/grpclog/grpclog.go +++ /dev/null @@ -1,126 +0,0 @@ -/* - * - * Copyright 2020 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package grpclog (internal) defines depth logging for grpc. -package grpclog - -import ( - "os" -) - -// Logger is the logger used for the non-depth log functions. -var Logger LoggerV2 - -// DepthLogger is the logger used for the depth log functions. -var DepthLogger DepthLoggerV2 - -// InfoDepth logs to the INFO log at the specified depth. -func InfoDepth(depth int, args ...any) { - if DepthLogger != nil { - DepthLogger.InfoDepth(depth, args...) - } else { - Logger.Infoln(args...) - } -} - -// WarningDepth logs to the WARNING log at the specified depth. -func WarningDepth(depth int, args ...any) { - if DepthLogger != nil { - DepthLogger.WarningDepth(depth, args...) - } else { - Logger.Warningln(args...) - } -} - -// ErrorDepth logs to the ERROR log at the specified depth. -func ErrorDepth(depth int, args ...any) { - if DepthLogger != nil { - DepthLogger.ErrorDepth(depth, args...) - } else { - Logger.Errorln(args...) - } -} - -// FatalDepth logs to the FATAL log at the specified depth. -func FatalDepth(depth int, args ...any) { - if DepthLogger != nil { - DepthLogger.FatalDepth(depth, args...) - } else { - Logger.Fatalln(args...) - } - os.Exit(1) -} - -// LoggerV2 does underlying logging work for grpclog. -// This is a copy of the LoggerV2 defined in the external grpclog package. It -// is defined here to avoid a circular dependency. -type LoggerV2 interface { - // Info logs to INFO log. Arguments are handled in the manner of fmt.Print. - Info(args ...any) - // Infoln logs to INFO log. Arguments are handled in the manner of fmt.Println. - Infoln(args ...any) - // Infof logs to INFO log. Arguments are handled in the manner of fmt.Printf. - Infof(format string, args ...any) - // Warning logs to WARNING log. Arguments are handled in the manner of fmt.Print. - Warning(args ...any) - // Warningln logs to WARNING log. Arguments are handled in the manner of fmt.Println. - Warningln(args ...any) - // Warningf logs to WARNING log. Arguments are handled in the manner of fmt.Printf. - Warningf(format string, args ...any) - // Error logs to ERROR log. Arguments are handled in the manner of fmt.Print. - Error(args ...any) - // Errorln logs to ERROR log. Arguments are handled in the manner of fmt.Println. - Errorln(args ...any) - // Errorf logs to ERROR log. Arguments are handled in the manner of fmt.Printf. - Errorf(format string, args ...any) - // Fatal logs to ERROR log. Arguments are handled in the manner of fmt.Print. - // gRPC ensures that all Fatal logs will exit with os.Exit(1). - // Implementations may also call os.Exit() with a non-zero exit code. - Fatal(args ...any) - // Fatalln logs to ERROR log. Arguments are handled in the manner of fmt.Println. - // gRPC ensures that all Fatal logs will exit with os.Exit(1). - // Implementations may also call os.Exit() with a non-zero exit code. - Fatalln(args ...any) - // Fatalf logs to ERROR log. Arguments are handled in the manner of fmt.Printf. - // gRPC ensures that all Fatal logs will exit with os.Exit(1). - // Implementations may also call os.Exit() with a non-zero exit code. - Fatalf(format string, args ...any) - // V reports whether verbosity level l is at least the requested verbose level. - V(l int) bool -} - -// DepthLoggerV2 logs at a specified call frame. If a LoggerV2 also implements -// DepthLoggerV2, the below functions will be called with the appropriate stack -// depth set for trivial functions the logger may ignore. -// This is a copy of the DepthLoggerV2 defined in the external grpclog package. -// It is defined here to avoid a circular dependency. -// -// # Experimental -// -// Notice: This type is EXPERIMENTAL and may be changed or removed in a -// later release. -type DepthLoggerV2 interface { - // InfoDepth logs to INFO log at the specified depth. Arguments are handled in the manner of fmt.Println. - InfoDepth(depth int, args ...any) - // WarningDepth logs to WARNING log at the specified depth. Arguments are handled in the manner of fmt.Println. - WarningDepth(depth int, args ...any) - // ErrorDepth logs to ERROR log at the specified depth. Arguments are handled in the manner of fmt.Println. - ErrorDepth(depth int, args ...any) - // FatalDepth logs to FATAL log at the specified depth. Arguments are handled in the manner of fmt.Println. - FatalDepth(depth int, args ...any) -} diff --git a/vendor/google.golang.org/grpc/internal/grpclog/prefixLogger.go b/vendor/google.golang.org/grpc/internal/grpclog/prefixLogger.go deleted file mode 100644 index faa998de7..000000000 --- a/vendor/google.golang.org/grpc/internal/grpclog/prefixLogger.go +++ /dev/null @@ -1,93 +0,0 @@ -/* - * - * Copyright 2020 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpclog - -import ( - "fmt" -) - -// PrefixLogger does logging with a prefix. -// -// Logging method on a nil logs without any prefix. -type PrefixLogger struct { - logger DepthLoggerV2 - prefix string -} - -// Infof does info logging. -func (pl *PrefixLogger) Infof(format string, args ...any) { - if pl != nil { - // Handle nil, so the tests can pass in a nil logger. - format = pl.prefix + format - pl.logger.InfoDepth(1, fmt.Sprintf(format, args...)) - return - } - InfoDepth(1, fmt.Sprintf(format, args...)) -} - -// Warningf does warning logging. -func (pl *PrefixLogger) Warningf(format string, args ...any) { - if pl != nil { - format = pl.prefix + format - pl.logger.WarningDepth(1, fmt.Sprintf(format, args...)) - return - } - WarningDepth(1, fmt.Sprintf(format, args...)) -} - -// Errorf does error logging. -func (pl *PrefixLogger) Errorf(format string, args ...any) { - if pl != nil { - format = pl.prefix + format - pl.logger.ErrorDepth(1, fmt.Sprintf(format, args...)) - return - } - ErrorDepth(1, fmt.Sprintf(format, args...)) -} - -// Debugf does info logging at verbose level 2. -func (pl *PrefixLogger) Debugf(format string, args ...any) { - // TODO(6044): Refactor interfaces LoggerV2 and DepthLogger, and maybe - // rewrite PrefixLogger a little to ensure that we don't use the global - // `Logger` here, and instead use the `logger` field. - if !Logger.V(2) { - return - } - if pl != nil { - // Handle nil, so the tests can pass in a nil logger. - format = pl.prefix + format - pl.logger.InfoDepth(1, fmt.Sprintf(format, args...)) - return - } - InfoDepth(1, fmt.Sprintf(format, args...)) - -} - -// V reports whether verbosity level l is at least the requested verbose level. -func (pl *PrefixLogger) V(l int) bool { - // TODO(6044): Refactor interfaces LoggerV2 and DepthLogger, and maybe - // rewrite PrefixLogger a little to ensure that we don't use the global - // `Logger` here, and instead use the `logger` field. - return Logger.V(l) -} - -// NewPrefixLogger creates a prefix logger with the given prefix. -func NewPrefixLogger(logger DepthLoggerV2, prefix string) *PrefixLogger { - return &PrefixLogger{logger: logger, prefix: prefix} -} diff --git a/vendor/google.golang.org/grpc/internal/grpcrand/grpcrand.go b/vendor/google.golang.org/grpc/internal/grpcrand/grpcrand.go deleted file mode 100644 index 0126d6b51..000000000 --- a/vendor/google.golang.org/grpc/internal/grpcrand/grpcrand.go +++ /dev/null @@ -1,100 +0,0 @@ -//go:build !go1.21 - -// TODO: when this file is deleted (after Go 1.20 support is dropped), delete -// all of grpcrand and call the rand package directly. - -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package grpcrand implements math/rand functions in a concurrent-safe way -// with a global random source, independent of math/rand's global source. -package grpcrand - -import ( - "math/rand" - "sync" - "time" -) - -var ( - r = rand.New(rand.NewSource(time.Now().UnixNano())) - mu sync.Mutex -) - -// Int implements rand.Int on the grpcrand global source. -func Int() int { - mu.Lock() - defer mu.Unlock() - return r.Int() -} - -// Int63n implements rand.Int63n on the grpcrand global source. -func Int63n(n int64) int64 { - mu.Lock() - defer mu.Unlock() - return r.Int63n(n) -} - -// Intn implements rand.Intn on the grpcrand global source. -func Intn(n int) int { - mu.Lock() - defer mu.Unlock() - return r.Intn(n) -} - -// Int31n implements rand.Int31n on the grpcrand global source. -func Int31n(n int32) int32 { - mu.Lock() - defer mu.Unlock() - return r.Int31n(n) -} - -// Float64 implements rand.Float64 on the grpcrand global source. -func Float64() float64 { - mu.Lock() - defer mu.Unlock() - return r.Float64() -} - -// Uint64 implements rand.Uint64 on the grpcrand global source. -func Uint64() uint64 { - mu.Lock() - defer mu.Unlock() - return r.Uint64() -} - -// Uint32 implements rand.Uint32 on the grpcrand global source. -func Uint32() uint32 { - mu.Lock() - defer mu.Unlock() - return r.Uint32() -} - -// ExpFloat64 implements rand.ExpFloat64 on the grpcrand global source. -func ExpFloat64() float64 { - mu.Lock() - defer mu.Unlock() - return r.ExpFloat64() -} - -// Shuffle implements rand.Shuffle on the grpcrand global source. -var Shuffle = func(n int, f func(int, int)) { - mu.Lock() - defer mu.Unlock() - r.Shuffle(n, f) -} diff --git a/vendor/google.golang.org/grpc/internal/grpcrand/grpcrand_go1.21.go b/vendor/google.golang.org/grpc/internal/grpcrand/grpcrand_go1.21.go deleted file mode 100644 index c37299af1..000000000 --- a/vendor/google.golang.org/grpc/internal/grpcrand/grpcrand_go1.21.go +++ /dev/null @@ -1,73 +0,0 @@ -//go:build go1.21 - -/* - * - * Copyright 2024 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package grpcrand implements math/rand functions in a concurrent-safe way -// with a global random source, independent of math/rand's global source. -package grpcrand - -import "math/rand" - -// This implementation will be used for Go version 1.21 or newer. -// For older versions, the original implementation with mutex will be used. - -// Int implements rand.Int on the grpcrand global source. -func Int() int { - return rand.Int() -} - -// Int63n implements rand.Int63n on the grpcrand global source. -func Int63n(n int64) int64 { - return rand.Int63n(n) -} - -// Intn implements rand.Intn on the grpcrand global source. -func Intn(n int) int { - return rand.Intn(n) -} - -// Int31n implements rand.Int31n on the grpcrand global source. -func Int31n(n int32) int32 { - return rand.Int31n(n) -} - -// Float64 implements rand.Float64 on the grpcrand global source. -func Float64() float64 { - return rand.Float64() -} - -// Uint64 implements rand.Uint64 on the grpcrand global source. -func Uint64() uint64 { - return rand.Uint64() -} - -// Uint32 implements rand.Uint32 on the grpcrand global source. -func Uint32() uint32 { - return rand.Uint32() -} - -// ExpFloat64 implements rand.ExpFloat64 on the grpcrand global source. -func ExpFloat64() float64 { - return rand.ExpFloat64() -} - -// Shuffle implements rand.Shuffle on the grpcrand global source. -var Shuffle = func(n int, f func(int, int)) { - rand.Shuffle(n, f) -} diff --git a/vendor/google.golang.org/grpc/internal/grpcsync/callback_serializer.go b/vendor/google.golang.org/grpc/internal/grpcsync/callback_serializer.go deleted file mode 100644 index f7f40a16a..000000000 --- a/vendor/google.golang.org/grpc/internal/grpcsync/callback_serializer.go +++ /dev/null @@ -1,100 +0,0 @@ -/* - * - * Copyright 2022 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpcsync - -import ( - "context" - - "google.golang.org/grpc/internal/buffer" -) - -// CallbackSerializer provides a mechanism to schedule callbacks in a -// synchronized manner. It provides a FIFO guarantee on the order of execution -// of scheduled callbacks. New callbacks can be scheduled by invoking the -// Schedule() method. -// -// This type is safe for concurrent access. -type CallbackSerializer struct { - // done is closed once the serializer is shut down completely, i.e all - // scheduled callbacks are executed and the serializer has deallocated all - // its resources. - done chan struct{} - - callbacks *buffer.Unbounded -} - -// NewCallbackSerializer returns a new CallbackSerializer instance. The provided -// context will be passed to the scheduled callbacks. Users should cancel the -// provided context to shutdown the CallbackSerializer. It is guaranteed that no -// callbacks will be added once this context is canceled, and any pending un-run -// callbacks will be executed before the serializer is shut down. -func NewCallbackSerializer(ctx context.Context) *CallbackSerializer { - cs := &CallbackSerializer{ - done: make(chan struct{}), - callbacks: buffer.NewUnbounded(), - } - go cs.run(ctx) - return cs -} - -// Schedule adds a callback to be scheduled after existing callbacks are run. -// -// Callbacks are expected to honor the context when performing any blocking -// operations, and should return early when the context is canceled. -// -// Return value indicates if the callback was successfully added to the list of -// callbacks to be executed by the serializer. It is not possible to add -// callbacks once the context passed to NewCallbackSerializer is cancelled. -func (cs *CallbackSerializer) Schedule(f func(ctx context.Context)) bool { - return cs.callbacks.Put(f) == nil -} - -func (cs *CallbackSerializer) run(ctx context.Context) { - defer close(cs.done) - - // TODO: when Go 1.21 is the oldest supported version, this loop and Close - // can be replaced with: - // - // context.AfterFunc(ctx, cs.callbacks.Close) - for ctx.Err() == nil { - select { - case <-ctx.Done(): - // Do nothing here. Next iteration of the for loop will not happen, - // since ctx.Err() would be non-nil. - case cb := <-cs.callbacks.Get(): - cs.callbacks.Load() - cb.(func(context.Context))(ctx) - } - } - - // Close the buffer to prevent new callbacks from being added. - cs.callbacks.Close() - - // Run all pending callbacks. - for cb := range cs.callbacks.Get() { - cs.callbacks.Load() - cb.(func(context.Context))(ctx) - } -} - -// Done returns a channel that is closed after the context passed to -// NewCallbackSerializer is canceled and all callbacks have been executed. -func (cs *CallbackSerializer) Done() <-chan struct{} { - return cs.done -} diff --git a/vendor/google.golang.org/grpc/internal/grpcsync/event.go b/vendor/google.golang.org/grpc/internal/grpcsync/event.go deleted file mode 100644 index fbe697c37..000000000 --- a/vendor/google.golang.org/grpc/internal/grpcsync/event.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package grpcsync implements additional synchronization primitives built upon -// the sync package. -package grpcsync - -import ( - "sync" - "sync/atomic" -) - -// Event represents a one-time event that may occur in the future. -type Event struct { - fired int32 - c chan struct{} - o sync.Once -} - -// Fire causes e to complete. It is safe to call multiple times, and -// concurrently. It returns true iff this call to Fire caused the signaling -// channel returned by Done to close. -func (e *Event) Fire() bool { - ret := false - e.o.Do(func() { - atomic.StoreInt32(&e.fired, 1) - close(e.c) - ret = true - }) - return ret -} - -// Done returns a channel that will be closed when Fire is called. -func (e *Event) Done() <-chan struct{} { - return e.c -} - -// HasFired returns true if Fire has been called. -func (e *Event) HasFired() bool { - return atomic.LoadInt32(&e.fired) == 1 -} - -// NewEvent returns a new, ready-to-use Event. -func NewEvent() *Event { - return &Event{c: make(chan struct{})} -} diff --git a/vendor/google.golang.org/grpc/internal/grpcsync/oncefunc.go b/vendor/google.golang.org/grpc/internal/grpcsync/oncefunc.go deleted file mode 100644 index 6635f7bca..000000000 --- a/vendor/google.golang.org/grpc/internal/grpcsync/oncefunc.go +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * Copyright 2022 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpcsync - -import ( - "sync" -) - -// OnceFunc returns a function wrapping f which ensures f is only executed -// once even if the returned function is executed multiple times. -func OnceFunc(f func()) func() { - var once sync.Once - return func() { - once.Do(f) - } -} diff --git a/vendor/google.golang.org/grpc/internal/grpcsync/pubsub.go b/vendor/google.golang.org/grpc/internal/grpcsync/pubsub.go deleted file mode 100644 index aef8cec1a..000000000 --- a/vendor/google.golang.org/grpc/internal/grpcsync/pubsub.go +++ /dev/null @@ -1,121 +0,0 @@ -/* - * - * Copyright 2023 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpcsync - -import ( - "context" - "sync" -) - -// Subscriber represents an entity that is subscribed to messages published on -// a PubSub. It wraps the callback to be invoked by the PubSub when a new -// message is published. -type Subscriber interface { - // OnMessage is invoked when a new message is published. Implementations - // must not block in this method. - OnMessage(msg any) -} - -// PubSub is a simple one-to-many publish-subscribe system that supports -// messages of arbitrary type. It guarantees that messages are delivered in -// the same order in which they were published. -// -// Publisher invokes the Publish() method to publish new messages, while -// subscribers interested in receiving these messages register a callback -// via the Subscribe() method. -// -// Once a PubSub is stopped, no more messages can be published, but any pending -// published messages will be delivered to the subscribers. Done may be used -// to determine when all published messages have been delivered. -type PubSub struct { - cs *CallbackSerializer - - // Access to the below fields are guarded by this mutex. - mu sync.Mutex - msg any - subscribers map[Subscriber]bool -} - -// NewPubSub returns a new PubSub instance. Users should cancel the -// provided context to shutdown the PubSub. -func NewPubSub(ctx context.Context) *PubSub { - return &PubSub{ - cs: NewCallbackSerializer(ctx), - subscribers: map[Subscriber]bool{}, - } -} - -// Subscribe registers the provided Subscriber to the PubSub. -// -// If the PubSub contains a previously published message, the Subscriber's -// OnMessage() callback will be invoked asynchronously with the existing -// message to begin with, and subsequently for every newly published message. -// -// The caller is responsible for invoking the returned cancel function to -// unsubscribe itself from the PubSub. -func (ps *PubSub) Subscribe(sub Subscriber) (cancel func()) { - ps.mu.Lock() - defer ps.mu.Unlock() - - ps.subscribers[sub] = true - - if ps.msg != nil { - msg := ps.msg - ps.cs.Schedule(func(context.Context) { - ps.mu.Lock() - defer ps.mu.Unlock() - if !ps.subscribers[sub] { - return - } - sub.OnMessage(msg) - }) - } - - return func() { - ps.mu.Lock() - defer ps.mu.Unlock() - delete(ps.subscribers, sub) - } -} - -// Publish publishes the provided message to the PubSub, and invokes -// callbacks registered by subscribers asynchronously. -func (ps *PubSub) Publish(msg any) { - ps.mu.Lock() - defer ps.mu.Unlock() - - ps.msg = msg - for sub := range ps.subscribers { - s := sub - ps.cs.Schedule(func(context.Context) { - ps.mu.Lock() - defer ps.mu.Unlock() - if !ps.subscribers[s] { - return - } - s.OnMessage(msg) - }) - } -} - -// Done returns a channel that is closed after the context passed to NewPubSub -// is canceled and all updates have been sent to subscribers. -func (ps *PubSub) Done() <-chan struct{} { - return ps.cs.Done() -} diff --git a/vendor/google.golang.org/grpc/internal/grpcutil/compressor.go b/vendor/google.golang.org/grpc/internal/grpcutil/compressor.go deleted file mode 100644 index 9f4090967..000000000 --- a/vendor/google.golang.org/grpc/internal/grpcutil/compressor.go +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * Copyright 2022 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpcutil - -import ( - "strings" - - "google.golang.org/grpc/internal/envconfig" -) - -// RegisteredCompressorNames holds names of the registered compressors. -var RegisteredCompressorNames []string - -// IsCompressorNameRegistered returns true when name is available in registry. -func IsCompressorNameRegistered(name string) bool { - for _, compressor := range RegisteredCompressorNames { - if compressor == name { - return true - } - } - return false -} - -// RegisteredCompressors returns a string of registered compressor names -// separated by comma. -func RegisteredCompressors() string { - if !envconfig.AdvertiseCompressors { - return "" - } - return strings.Join(RegisteredCompressorNames, ",") -} diff --git a/vendor/google.golang.org/grpc/internal/grpcutil/encode_duration.go b/vendor/google.golang.org/grpc/internal/grpcutil/encode_duration.go deleted file mode 100644 index b25b0baec..000000000 --- a/vendor/google.golang.org/grpc/internal/grpcutil/encode_duration.go +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * Copyright 2020 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpcutil - -import ( - "strconv" - "time" -) - -const maxTimeoutValue int64 = 100000000 - 1 - -// div does integer division and round-up the result. Note that this is -// equivalent to (d+r-1)/r but has less chance to overflow. -func div(d, r time.Duration) int64 { - if d%r > 0 { - return int64(d/r + 1) - } - return int64(d / r) -} - -// EncodeDuration encodes the duration to the format grpc-timeout header -// accepts. -// -// https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests -func EncodeDuration(t time.Duration) string { - // TODO: This is simplistic and not bandwidth efficient. Improve it. - if t <= 0 { - return "0n" - } - if d := div(t, time.Nanosecond); d <= maxTimeoutValue { - return strconv.FormatInt(d, 10) + "n" - } - if d := div(t, time.Microsecond); d <= maxTimeoutValue { - return strconv.FormatInt(d, 10) + "u" - } - if d := div(t, time.Millisecond); d <= maxTimeoutValue { - return strconv.FormatInt(d, 10) + "m" - } - if d := div(t, time.Second); d <= maxTimeoutValue { - return strconv.FormatInt(d, 10) + "S" - } - if d := div(t, time.Minute); d <= maxTimeoutValue { - return strconv.FormatInt(d, 10) + "M" - } - // Note that maxTimeoutValue * time.Hour > MaxInt64. - return strconv.FormatInt(div(t, time.Hour), 10) + "H" -} diff --git a/vendor/google.golang.org/grpc/internal/grpcutil/grpcutil.go b/vendor/google.golang.org/grpc/internal/grpcutil/grpcutil.go deleted file mode 100644 index e2f948e8f..000000000 --- a/vendor/google.golang.org/grpc/internal/grpcutil/grpcutil.go +++ /dev/null @@ -1,20 +0,0 @@ -/* - * - * Copyright 2021 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package grpcutil provides utility functions used across the gRPC codebase. -package grpcutil diff --git a/vendor/google.golang.org/grpc/internal/grpcutil/metadata.go b/vendor/google.golang.org/grpc/internal/grpcutil/metadata.go deleted file mode 100644 index 6f22bd891..000000000 --- a/vendor/google.golang.org/grpc/internal/grpcutil/metadata.go +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * Copyright 2020 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpcutil - -import ( - "context" - - "google.golang.org/grpc/metadata" -) - -type mdExtraKey struct{} - -// WithExtraMetadata creates a new context with incoming md attached. -func WithExtraMetadata(ctx context.Context, md metadata.MD) context.Context { - return context.WithValue(ctx, mdExtraKey{}, md) -} - -// ExtraMetadata returns the incoming metadata in ctx if it exists. The -// returned MD should not be modified. Writing to it may cause races. -// Modification should be made to copies of the returned MD. -func ExtraMetadata(ctx context.Context) (md metadata.MD, ok bool) { - md, ok = ctx.Value(mdExtraKey{}).(metadata.MD) - return -} diff --git a/vendor/google.golang.org/grpc/internal/grpcutil/method.go b/vendor/google.golang.org/grpc/internal/grpcutil/method.go deleted file mode 100644 index ec62b4775..000000000 --- a/vendor/google.golang.org/grpc/internal/grpcutil/method.go +++ /dev/null @@ -1,88 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpcutil - -import ( - "errors" - "strings" -) - -// ParseMethod splits service and method from the input. It expects format -// "/service/method". -func ParseMethod(methodName string) (service, method string, _ error) { - if !strings.HasPrefix(methodName, "/") { - return "", "", errors.New("invalid method name: should start with /") - } - methodName = methodName[1:] - - pos := strings.LastIndex(methodName, "/") - if pos < 0 { - return "", "", errors.New("invalid method name: suffix /method is missing") - } - return methodName[:pos], methodName[pos+1:], nil -} - -// baseContentType is the base content-type for gRPC. This is a valid -// content-type on it's own, but can also include a content-subtype such as -// "proto" as a suffix after "+" or ";". See -// https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests -// for more details. -const baseContentType = "application/grpc" - -// ContentSubtype returns the content-subtype for the given content-type. The -// given content-type must be a valid content-type that starts with -// "application/grpc". A content-subtype will follow "application/grpc" after a -// "+" or ";". See -// https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests for -// more details. -// -// If contentType is not a valid content-type for gRPC, the boolean -// will be false, otherwise true. If content-type == "application/grpc", -// "application/grpc+", or "application/grpc;", the boolean will be true, -// but no content-subtype will be returned. -// -// contentType is assumed to be lowercase already. -func ContentSubtype(contentType string) (string, bool) { - if contentType == baseContentType { - return "", true - } - if !strings.HasPrefix(contentType, baseContentType) { - return "", false - } - // guaranteed since != baseContentType and has baseContentType prefix - switch contentType[len(baseContentType)] { - case '+', ';': - // this will return true for "application/grpc+" or "application/grpc;" - // which the previous validContentType function tested to be valid, so we - // just say that no content-subtype is specified in this case - return contentType[len(baseContentType)+1:], true - default: - return "", false - } -} - -// ContentType builds full content type with the given sub-type. -// -// contentSubtype is assumed to be lowercase -func ContentType(contentSubtype string) string { - if contentSubtype == "" { - return baseContentType - } - return baseContentType + "+" + contentSubtype -} diff --git a/vendor/google.golang.org/grpc/internal/grpcutil/regex.go b/vendor/google.golang.org/grpc/internal/grpcutil/regex.go deleted file mode 100644 index 7a092b2b8..000000000 --- a/vendor/google.golang.org/grpc/internal/grpcutil/regex.go +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * Copyright 2021 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpcutil - -import "regexp" - -// FullMatchWithRegex returns whether the full text matches the regex provided. -func FullMatchWithRegex(re *regexp.Regexp, text string) bool { - if len(text) == 0 { - return re.MatchString(text) - } - re.Longest() - rem := re.FindString(text) - return len(rem) == len(text) -} diff --git a/vendor/google.golang.org/grpc/internal/idle/idle.go b/vendor/google.golang.org/grpc/internal/idle/idle.go deleted file mode 100644 index fe49cb74c..000000000 --- a/vendor/google.golang.org/grpc/internal/idle/idle.go +++ /dev/null @@ -1,278 +0,0 @@ -/* - * - * Copyright 2023 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package idle contains a component for managing idleness (entering and exiting) -// based on RPC activity. -package idle - -import ( - "fmt" - "math" - "sync" - "sync/atomic" - "time" -) - -// For overriding in unit tests. -var timeAfterFunc = func(d time.Duration, f func()) *time.Timer { - return time.AfterFunc(d, f) -} - -// Enforcer is the functionality provided by grpc.ClientConn to enter -// and exit from idle mode. -type Enforcer interface { - ExitIdleMode() error - EnterIdleMode() -} - -// Manager implements idleness detection and calls the configured Enforcer to -// enter/exit idle mode when appropriate. Must be created by NewManager. -type Manager struct { - // State accessed atomically. - lastCallEndTime int64 // Unix timestamp in nanos; time when the most recent RPC completed. - activeCallsCount int32 // Count of active RPCs; -math.MaxInt32 means channel is idle or is trying to get there. - activeSinceLastTimerCheck int32 // Boolean; True if there was an RPC since the last timer callback. - closed int32 // Boolean; True when the manager is closed. - - // Can be accessed without atomics or mutex since these are set at creation - // time and read-only after that. - enforcer Enforcer // Functionality provided by grpc.ClientConn. - timeout time.Duration - - // idleMu is used to guarantee mutual exclusion in two scenarios: - // - Opposing intentions: - // - a: Idle timeout has fired and handleIdleTimeout() is trying to put - // the channel in idle mode because the channel has been inactive. - // - b: At the same time an RPC is made on the channel, and OnCallBegin() - // is trying to prevent the channel from going idle. - // - Competing intentions: - // - The channel is in idle mode and there are multiple RPCs starting at - // the same time, all trying to move the channel out of idle. Only one - // of them should succeed in doing so, while the other RPCs should - // piggyback on the first one and be successfully handled. - idleMu sync.RWMutex - actuallyIdle bool - timer *time.Timer -} - -// NewManager creates a new idleness manager implementation for the -// given idle timeout. It begins in idle mode. -func NewManager(enforcer Enforcer, timeout time.Duration) *Manager { - return &Manager{ - enforcer: enforcer, - timeout: timeout, - actuallyIdle: true, - activeCallsCount: -math.MaxInt32, - } -} - -// resetIdleTimerLocked resets the idle timer to the given duration. Called -// when exiting idle mode or when the timer fires and we need to reset it. -func (m *Manager) resetIdleTimerLocked(d time.Duration) { - if m.isClosed() || m.timeout == 0 || m.actuallyIdle { - return - } - - // It is safe to ignore the return value from Reset() because this method is - // only ever called from the timer callback or when exiting idle mode. - if m.timer != nil { - m.timer.Stop() - } - m.timer = timeAfterFunc(d, m.handleIdleTimeout) -} - -func (m *Manager) resetIdleTimer(d time.Duration) { - m.idleMu.Lock() - defer m.idleMu.Unlock() - m.resetIdleTimerLocked(d) -} - -// handleIdleTimeout is the timer callback that is invoked upon expiry of the -// configured idle timeout. The channel is considered inactive if there are no -// ongoing calls and no RPC activity since the last time the timer fired. -func (m *Manager) handleIdleTimeout() { - if m.isClosed() { - return - } - - if atomic.LoadInt32(&m.activeCallsCount) > 0 { - m.resetIdleTimer(m.timeout) - return - } - - // There has been activity on the channel since we last got here. Reset the - // timer and return. - if atomic.LoadInt32(&m.activeSinceLastTimerCheck) == 1 { - // Set the timer to fire after a duration of idle timeout, calculated - // from the time the most recent RPC completed. - atomic.StoreInt32(&m.activeSinceLastTimerCheck, 0) - m.resetIdleTimer(time.Duration(atomic.LoadInt64(&m.lastCallEndTime)-time.Now().UnixNano()) + m.timeout) - return - } - - // Now that we've checked that there has been no activity, attempt to enter - // idle mode, which is very likely to succeed. - if m.tryEnterIdleMode() { - // Successfully entered idle mode. No timer needed until we exit idle. - return - } - - // Failed to enter idle mode due to a concurrent RPC that kept the channel - // active, or because of an error from the channel. Undo the attempt to - // enter idle, and reset the timer to try again later. - m.resetIdleTimer(m.timeout) -} - -// tryEnterIdleMode instructs the channel to enter idle mode. But before -// that, it performs a last minute check to ensure that no new RPC has come in, -// making the channel active. -// -// Return value indicates whether or not the channel moved to idle mode. -// -// Holds idleMu which ensures mutual exclusion with exitIdleMode. -func (m *Manager) tryEnterIdleMode() bool { - // Setting the activeCallsCount to -math.MaxInt32 indicates to OnCallBegin() - // that the channel is either in idle mode or is trying to get there. - if !atomic.CompareAndSwapInt32(&m.activeCallsCount, 0, -math.MaxInt32) { - // This CAS operation can fail if an RPC started after we checked for - // activity in the timer handler, or one was ongoing from before the - // last time the timer fired, or if a test is attempting to enter idle - // mode without checking. In all cases, abort going into idle mode. - return false - } - // N.B. if we fail to enter idle mode after this, we must re-add - // math.MaxInt32 to m.activeCallsCount. - - m.idleMu.Lock() - defer m.idleMu.Unlock() - - if atomic.LoadInt32(&m.activeCallsCount) != -math.MaxInt32 { - // We raced and lost to a new RPC. Very rare, but stop entering idle. - atomic.AddInt32(&m.activeCallsCount, math.MaxInt32) - return false - } - if atomic.LoadInt32(&m.activeSinceLastTimerCheck) == 1 { - // A very short RPC could have come in (and also finished) after we - // checked for calls count and activity in handleIdleTimeout(), but - // before the CAS operation. So, we need to check for activity again. - atomic.AddInt32(&m.activeCallsCount, math.MaxInt32) - return false - } - - // No new RPCs have come in since we set the active calls count value to - // -math.MaxInt32. And since we have the lock, it is safe to enter idle mode - // unconditionally now. - m.enforcer.EnterIdleMode() - m.actuallyIdle = true - return true -} - -func (m *Manager) EnterIdleModeForTesting() { - m.tryEnterIdleMode() -} - -// OnCallBegin is invoked at the start of every RPC. -func (m *Manager) OnCallBegin() error { - if m.isClosed() { - return nil - } - - if atomic.AddInt32(&m.activeCallsCount, 1) > 0 { - // Channel is not idle now. Set the activity bit and allow the call. - atomic.StoreInt32(&m.activeSinceLastTimerCheck, 1) - return nil - } - - // Channel is either in idle mode or is in the process of moving to idle - // mode. Attempt to exit idle mode to allow this RPC. - if err := m.ExitIdleMode(); err != nil { - // Undo the increment to calls count, and return an error causing the - // RPC to fail. - atomic.AddInt32(&m.activeCallsCount, -1) - return err - } - - atomic.StoreInt32(&m.activeSinceLastTimerCheck, 1) - return nil -} - -// ExitIdleMode instructs m to call the enforcer's ExitIdleMode and update m's -// internal state. -func (m *Manager) ExitIdleMode() error { - // Holds idleMu which ensures mutual exclusion with tryEnterIdleMode. - m.idleMu.Lock() - defer m.idleMu.Unlock() - - if m.isClosed() || !m.actuallyIdle { - // This can happen in three scenarios: - // - handleIdleTimeout() set the calls count to -math.MaxInt32 and called - // tryEnterIdleMode(). But before the latter could grab the lock, an RPC - // came in and OnCallBegin() noticed that the calls count is negative. - // - Channel is in idle mode, and multiple new RPCs come in at the same - // time, all of them notice a negative calls count in OnCallBegin and get - // here. The first one to get the lock would got the channel to exit idle. - // - Channel is not in idle mode, and the user calls Connect which calls - // m.ExitIdleMode. - // - // In any case, there is nothing to do here. - return nil - } - - if err := m.enforcer.ExitIdleMode(); err != nil { - return fmt.Errorf("failed to exit idle mode: %w", err) - } - - // Undo the idle entry process. This also respects any new RPC attempts. - atomic.AddInt32(&m.activeCallsCount, math.MaxInt32) - m.actuallyIdle = false - - // Start a new timer to fire after the configured idle timeout. - m.resetIdleTimerLocked(m.timeout) - return nil -} - -// OnCallEnd is invoked at the end of every RPC. -func (m *Manager) OnCallEnd() { - if m.isClosed() { - return - } - - // Record the time at which the most recent call finished. - atomic.StoreInt64(&m.lastCallEndTime, time.Now().UnixNano()) - - // Decrement the active calls count. This count can temporarily go negative - // when the timer callback is in the process of moving the channel to idle - // mode, but one or more RPCs come in and complete before the timer callback - // can get done with the process of moving to idle mode. - atomic.AddInt32(&m.activeCallsCount, -1) -} - -func (m *Manager) isClosed() bool { - return atomic.LoadInt32(&m.closed) == 1 -} - -func (m *Manager) Close() { - atomic.StoreInt32(&m.closed, 1) - - m.idleMu.Lock() - if m.timer != nil { - m.timer.Stop() - m.timer = nil - } - m.idleMu.Unlock() -} diff --git a/vendor/google.golang.org/grpc/internal/internal.go b/vendor/google.golang.org/grpc/internal/internal.go deleted file mode 100644 index 48d24bdb4..000000000 --- a/vendor/google.golang.org/grpc/internal/internal.go +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package internal contains gRPC-internal code, to avoid polluting -// the godoc of the top-level grpc package. It must not import any grpc -// symbols to avoid circular dependencies. -package internal - -import ( - "context" - "time" - - "google.golang.org/grpc/connectivity" - "google.golang.org/grpc/serviceconfig" -) - -var ( - // WithHealthCheckFunc is set by dialoptions.go - WithHealthCheckFunc any // func (HealthChecker) DialOption - // HealthCheckFunc is used to provide client-side LB channel health checking - HealthCheckFunc HealthChecker - // BalancerUnregister is exported by package balancer to unregister a balancer. - BalancerUnregister func(name string) - // KeepaliveMinPingTime is the minimum ping interval. This must be 10s by - // default, but tests may wish to set it lower for convenience. - KeepaliveMinPingTime = 10 * time.Second - // KeepaliveMinServerPingTime is the minimum ping interval for servers. - // This must be 1s by default, but tests may wish to set it lower for - // convenience. - KeepaliveMinServerPingTime = time.Second - // ParseServiceConfig parses a JSON representation of the service config. - ParseServiceConfig any // func(string) *serviceconfig.ParseResult - // EqualServiceConfigForTesting is for testing service config generation and - // parsing. Both a and b should be returned by ParseServiceConfig. - // This function compares the config without rawJSON stripped, in case the - // there's difference in white space. - EqualServiceConfigForTesting func(a, b serviceconfig.Config) bool - // GetCertificateProviderBuilder returns the registered builder for the - // given name. This is set by package certprovider for use from xDS - // bootstrap code while parsing certificate provider configs in the - // bootstrap file. - GetCertificateProviderBuilder any // func(string) certprovider.Builder - // GetXDSHandshakeInfoForTesting returns a pointer to the xds.HandshakeInfo - // stored in the passed in attributes. This is set by - // credentials/xds/xds.go. - GetXDSHandshakeInfoForTesting any // func (*attributes.Attributes) *unsafe.Pointer - // GetServerCredentials returns the transport credentials configured on a - // gRPC server. An xDS-enabled server needs to know what type of credentials - // is configured on the underlying gRPC server. This is set by server.go. - GetServerCredentials any // func (*grpc.Server) credentials.TransportCredentials - // CanonicalString returns the canonical string of the code defined here: - // https://github.com/grpc/grpc/blob/master/doc/statuscodes.md. - // - // This is used in the 1.0 release of gcp/observability, and thus must not be - // deleted or changed. - CanonicalString any // func (codes.Code) string - // IsRegisteredMethod returns whether the passed in method is registered as - // a method on the server. - IsRegisteredMethod any // func(*grpc.Server, string) bool - // ServerFromContext returns the server from the context. - ServerFromContext any // func(context.Context) *grpc.Server - // AddGlobalServerOptions adds an array of ServerOption that will be - // effective globally for newly created servers. The priority will be: 1. - // user-provided; 2. this method; 3. default values. - // - // This is used in the 1.0 release of gcp/observability, and thus must not be - // deleted or changed. - AddGlobalServerOptions any // func(opt ...ServerOption) - // ClearGlobalServerOptions clears the array of extra ServerOption. This - // method is useful in testing and benchmarking. - // - // This is used in the 1.0 release of gcp/observability, and thus must not be - // deleted or changed. - ClearGlobalServerOptions func() - // AddGlobalDialOptions adds an array of DialOption that will be effective - // globally for newly created client channels. The priority will be: 1. - // user-provided; 2. this method; 3. default values. - // - // This is used in the 1.0 release of gcp/observability, and thus must not be - // deleted or changed. - AddGlobalDialOptions any // func(opt ...DialOption) - // DisableGlobalDialOptions returns a DialOption that prevents the - // ClientConn from applying the global DialOptions (set via - // AddGlobalDialOptions). - // - // This is used in the 1.0 release of gcp/observability, and thus must not be - // deleted or changed. - DisableGlobalDialOptions any // func() grpc.DialOption - // ClearGlobalDialOptions clears the array of extra DialOption. This - // method is useful in testing and benchmarking. - // - // This is used in the 1.0 release of gcp/observability, and thus must not be - // deleted or changed. - ClearGlobalDialOptions func() - // JoinDialOptions combines the dial options passed as arguments into a - // single dial option. - JoinDialOptions any // func(...grpc.DialOption) grpc.DialOption - // JoinServerOptions combines the server options passed as arguments into a - // single server option. - JoinServerOptions any // func(...grpc.ServerOption) grpc.ServerOption - - // WithBinaryLogger returns a DialOption that specifies the binary logger - // for a ClientConn. - // - // This is used in the 1.0 release of gcp/observability, and thus must not be - // deleted or changed. - WithBinaryLogger any // func(binarylog.Logger) grpc.DialOption - // BinaryLogger returns a ServerOption that can set the binary logger for a - // server. - // - // This is used in the 1.0 release of gcp/observability, and thus must not be - // deleted or changed. - BinaryLogger any // func(binarylog.Logger) grpc.ServerOption - - // SubscribeToConnectivityStateChanges adds a grpcsync.Subscriber to a provided grpc.ClientConn - SubscribeToConnectivityStateChanges any // func(*grpc.ClientConn, grpcsync.Subscriber) - - // NewXDSResolverWithConfigForTesting creates a new xds resolver builder using - // the provided xds bootstrap config instead of the global configuration from - // the supported environment variables. The resolver.Builder is meant to be - // used in conjunction with the grpc.WithResolvers DialOption. - // - // Testing Only - // - // This function should ONLY be used for testing and may not work with some - // other features, including the CSDS service. - NewXDSResolverWithConfigForTesting any // func([]byte) (resolver.Builder, error) - - // RegisterRLSClusterSpecifierPluginForTesting registers the RLS Cluster - // Specifier Plugin for testing purposes, regardless of the XDSRLS environment - // variable. - // - // TODO: Remove this function once the RLS env var is removed. - RegisterRLSClusterSpecifierPluginForTesting func() - - // UnregisterRLSClusterSpecifierPluginForTesting unregisters the RLS Cluster - // Specifier Plugin for testing purposes. This is needed because there is no way - // to unregister the RLS Cluster Specifier Plugin after registering it solely - // for testing purposes using RegisterRLSClusterSpecifierPluginForTesting(). - // - // TODO: Remove this function once the RLS env var is removed. - UnregisterRLSClusterSpecifierPluginForTesting func() - - // RegisterRBACHTTPFilterForTesting registers the RBAC HTTP Filter for testing - // purposes, regardless of the RBAC environment variable. - // - // TODO: Remove this function once the RBAC env var is removed. - RegisterRBACHTTPFilterForTesting func() - - // UnregisterRBACHTTPFilterForTesting unregisters the RBAC HTTP Filter for - // testing purposes. This is needed because there is no way to unregister the - // HTTP Filter after registering it solely for testing purposes using - // RegisterRBACHTTPFilterForTesting(). - // - // TODO: Remove this function once the RBAC env var is removed. - UnregisterRBACHTTPFilterForTesting func() - - // ORCAAllowAnyMinReportingInterval is for examples/orca use ONLY. - ORCAAllowAnyMinReportingInterval any // func(so *orca.ServiceOptions) - - // GRPCResolverSchemeExtraMetadata determines when gRPC will add extra - // metadata to RPCs. - GRPCResolverSchemeExtraMetadata string = "xds" - - // EnterIdleModeForTesting gets the ClientConn to enter IDLE mode. - EnterIdleModeForTesting any // func(*grpc.ClientConn) - - // ExitIdleModeForTesting gets the ClientConn to exit IDLE mode. - ExitIdleModeForTesting any // func(*grpc.ClientConn) error - - ChannelzTurnOffForTesting func() - - // TriggerXDSResourceNameNotFoundForTesting triggers the resource-not-found - // error for a given resource type and name. This is usually triggered when - // the associated watch timer fires. For testing purposes, having this - // function makes events more predictable than relying on timer events. - TriggerXDSResourceNameNotFoundForTesting any // func(func(xdsresource.Type, string), string, string) error - - // TriggerXDSResourceNameNotFoundClient invokes the testing xDS Client - // singleton to invoke resource not found for a resource type name and - // resource name. - TriggerXDSResourceNameNotFoundClient any // func(string, string) error - - // FromOutgoingContextRaw returns the un-merged, intermediary contents of metadata.rawMD. - FromOutgoingContextRaw any // func(context.Context) (metadata.MD, [][]string, bool) - - // UserSetDefaultScheme is set to true if the user has overridden the default resolver scheme. - UserSetDefaultScheme bool = false -) - -// HealthChecker defines the signature of the client-side LB channel health checking function. -// -// The implementation is expected to create a health checking RPC stream by -// calling newStream(), watch for the health status of serviceName, and report -// it's health back by calling setConnectivityState(). -// -// The health checking protocol is defined at: -// https://github.com/grpc/grpc/blob/master/doc/health-checking.md -type HealthChecker func(ctx context.Context, newStream func(string) (any, error), setConnectivityState func(connectivity.State, error), serviceName string) error - -const ( - // CredsBundleModeFallback switches GoogleDefaultCreds to fallback mode. - CredsBundleModeFallback = "fallback" - // CredsBundleModeBalancer switches GoogleDefaultCreds to grpclb balancer - // mode. - CredsBundleModeBalancer = "balancer" - // CredsBundleModeBackendFromBalancer switches GoogleDefaultCreds to mode - // that supports backend returned by grpclb balancer. - CredsBundleModeBackendFromBalancer = "backend-from-balancer" -) - -// RLSLoadBalancingPolicyName is the name of the RLS LB policy. -// -// It currently has an experimental suffix which would be removed once -// end-to-end testing of the policy is completed. -const RLSLoadBalancingPolicyName = "rls_experimental" diff --git a/vendor/google.golang.org/grpc/internal/metadata/metadata.go b/vendor/google.golang.org/grpc/internal/metadata/metadata.go deleted file mode 100644 index 900bfb716..000000000 --- a/vendor/google.golang.org/grpc/internal/metadata/metadata.go +++ /dev/null @@ -1,132 +0,0 @@ -/* - * - * Copyright 2020 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package metadata contains functions to set and get metadata from addresses. -// -// This package is experimental. -package metadata - -import ( - "fmt" - "strings" - - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/resolver" -) - -type mdKeyType string - -const mdKey = mdKeyType("grpc.internal.address.metadata") - -type mdValue metadata.MD - -func (m mdValue) Equal(o any) bool { - om, ok := o.(mdValue) - if !ok { - return false - } - if len(m) != len(om) { - return false - } - for k, v := range m { - ov := om[k] - if len(ov) != len(v) { - return false - } - for i, ve := range v { - if ov[i] != ve { - return false - } - } - } - return true -} - -// Get returns the metadata of addr. -func Get(addr resolver.Address) metadata.MD { - attrs := addr.Attributes - if attrs == nil { - return nil - } - md, _ := attrs.Value(mdKey).(mdValue) - return metadata.MD(md) -} - -// Set sets (overrides) the metadata in addr. -// -// When a SubConn is created with this address, the RPCs sent on it will all -// have this metadata. -func Set(addr resolver.Address, md metadata.MD) resolver.Address { - addr.Attributes = addr.Attributes.WithValue(mdKey, mdValue(md)) - return addr -} - -// Validate validates every pair in md with ValidatePair. -func Validate(md metadata.MD) error { - for k, vals := range md { - if err := ValidatePair(k, vals...); err != nil { - return err - } - } - return nil -} - -// hasNotPrintable return true if msg contains any characters which are not in %x20-%x7E -func hasNotPrintable(msg string) bool { - // for i that saving a conversion if not using for range - for i := 0; i < len(msg); i++ { - if msg[i] < 0x20 || msg[i] > 0x7E { - return true - } - } - return false -} - -// ValidatePair validate a key-value pair with the following rules (the pseudo-header will be skipped) : -// -// - key must contain one or more characters. -// - the characters in the key must be contained in [0-9 a-z _ - .]. -// - if the key ends with a "-bin" suffix, no validation of the corresponding value is performed. -// - the characters in the every value must be printable (in [%x20-%x7E]). -func ValidatePair(key string, vals ...string) error { - // key should not be empty - if key == "" { - return fmt.Errorf("there is an empty key in the header") - } - // pseudo-header will be ignored - if key[0] == ':' { - return nil - } - // check key, for i that saving a conversion if not using for range - for i := 0; i < len(key); i++ { - r := key[i] - if !(r >= 'a' && r <= 'z') && !(r >= '0' && r <= '9') && r != '.' && r != '-' && r != '_' { - return fmt.Errorf("header key %q contains illegal characters not in [0-9a-z-_.]", key) - } - } - if strings.HasSuffix(key, "-bin") { - return nil - } - // check value - for _, val := range vals { - if hasNotPrintable(val) { - return fmt.Errorf("header key %q contains value with non-printable ASCII characters", key) - } - } - return nil -} diff --git a/vendor/google.golang.org/grpc/internal/pretty/pretty.go b/vendor/google.golang.org/grpc/internal/pretty/pretty.go deleted file mode 100644 index dbee7a60d..000000000 --- a/vendor/google.golang.org/grpc/internal/pretty/pretty.go +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * Copyright 2021 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package pretty defines helper functions to pretty-print structs for logging. -package pretty - -import ( - "bytes" - "encoding/json" - "fmt" - - "google.golang.org/protobuf/encoding/protojson" - "google.golang.org/protobuf/protoadapt" -) - -const jsonIndent = " " - -// ToJSON marshals the input into a json string. -// -// If marshal fails, it falls back to fmt.Sprintf("%+v"). -func ToJSON(e any) string { - if ee, ok := e.(protoadapt.MessageV1); ok { - e = protoadapt.MessageV2Of(ee) - } - - if ee, ok := e.(protoadapt.MessageV2); ok { - mm := protojson.MarshalOptions{ - Indent: jsonIndent, - Multiline: true, - } - ret, err := mm.Marshal(ee) - if err != nil { - // This may fail for proto.Anys, e.g. for xDS v2, LDS, the v2 - // messages are not imported, and this will fail because the message - // is not found. - return fmt.Sprintf("%+v", ee) - } - return string(ret) - } - - ret, err := json.MarshalIndent(e, "", jsonIndent) - if err != nil { - return fmt.Sprintf("%+v", e) - } - return string(ret) -} - -// FormatJSON formats the input json bytes with indentation. -// -// If Indent fails, it returns the unchanged input as string. -func FormatJSON(b []byte) string { - var out bytes.Buffer - err := json.Indent(&out, b, "", jsonIndent) - if err != nil { - return string(b) - } - return out.String() -} diff --git a/vendor/google.golang.org/grpc/internal/resolver/config_selector.go b/vendor/google.golang.org/grpc/internal/resolver/config_selector.go deleted file mode 100644 index f0603871c..000000000 --- a/vendor/google.golang.org/grpc/internal/resolver/config_selector.go +++ /dev/null @@ -1,167 +0,0 @@ -/* - * - * Copyright 2020 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package resolver provides internal resolver-related functionality. -package resolver - -import ( - "context" - "sync" - - "google.golang.org/grpc/internal/serviceconfig" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/resolver" -) - -// ConfigSelector controls what configuration to use for every RPC. -type ConfigSelector interface { - // Selects the configuration for the RPC, or terminates it using the error. - // This error will be converted by the gRPC library to a status error with - // code UNKNOWN if it is not returned as a status error. - SelectConfig(RPCInfo) (*RPCConfig, error) -} - -// RPCInfo contains RPC information needed by a ConfigSelector. -type RPCInfo struct { - // Context is the user's context for the RPC and contains headers and - // application timeout. It is passed for interception purposes and for - // efficiency reasons. SelectConfig should not be blocking. - Context context.Context - Method string // i.e. "/Service/Method" -} - -// RPCConfig describes the configuration to use for each RPC. -type RPCConfig struct { - // The context to use for the remainder of the RPC; can pass info to LB - // policy or affect timeout or metadata. - Context context.Context - MethodConfig serviceconfig.MethodConfig // configuration to use for this RPC - OnCommitted func() // Called when the RPC has been committed (retries no longer possible) - Interceptor ClientInterceptor -} - -// ClientStream is the same as grpc.ClientStream, but defined here for circular -// dependency reasons. -type ClientStream interface { - // Header returns the header metadata received from the server if there - // is any. It blocks if the metadata is not ready to read. - Header() (metadata.MD, error) - // Trailer returns the trailer metadata from the server, if there is any. - // It must only be called after stream.CloseAndRecv has returned, or - // stream.Recv has returned a non-nil error (including io.EOF). - Trailer() metadata.MD - // CloseSend closes the send direction of the stream. It closes the stream - // when non-nil error is met. It is also not safe to call CloseSend - // concurrently with SendMsg. - CloseSend() error - // Context returns the context for this stream. - // - // It should not be called until after Header or RecvMsg has returned. Once - // called, subsequent client-side retries are disabled. - Context() context.Context - // SendMsg is generally called by generated code. On error, SendMsg aborts - // the stream. If the error was generated by the client, the status is - // returned directly; otherwise, io.EOF is returned and the status of - // the stream may be discovered using RecvMsg. - // - // SendMsg blocks until: - // - There is sufficient flow control to schedule m with the transport, or - // - The stream is done, or - // - The stream breaks. - // - // SendMsg does not wait until the message is received by the server. An - // untimely stream closure may result in lost messages. To ensure delivery, - // users should ensure the RPC completed successfully using RecvMsg. - // - // It is safe to have a goroutine calling SendMsg and another goroutine - // calling RecvMsg on the same stream at the same time, but it is not safe - // to call SendMsg on the same stream in different goroutines. It is also - // not safe to call CloseSend concurrently with SendMsg. - SendMsg(m any) error - // RecvMsg blocks until it receives a message into m or the stream is - // done. It returns io.EOF when the stream completes successfully. On - // any other error, the stream is aborted and the error contains the RPC - // status. - // - // It is safe to have a goroutine calling SendMsg and another goroutine - // calling RecvMsg on the same stream at the same time, but it is not - // safe to call RecvMsg on the same stream in different goroutines. - RecvMsg(m any) error -} - -// ClientInterceptor is an interceptor for gRPC client streams. -type ClientInterceptor interface { - // NewStream produces a ClientStream for an RPC which may optionally use - // the provided function to produce a stream for delegation. Note: - // RPCInfo.Context should not be used (will be nil). - // - // done is invoked when the RPC is finished using its connection, or could - // not be assigned a connection. RPC operations may still occur on - // ClientStream after done is called, since the interceptor is invoked by - // application-layer operations. done must never be nil when called. - NewStream(ctx context.Context, ri RPCInfo, done func(), newStream func(ctx context.Context, done func()) (ClientStream, error)) (ClientStream, error) -} - -// ServerInterceptor is an interceptor for incoming RPC's on gRPC server side. -type ServerInterceptor interface { - // AllowRPC checks if an incoming RPC is allowed to proceed based on - // information about connection RPC was received on, and HTTP Headers. This - // information will be piped into context. - AllowRPC(ctx context.Context) error // TODO: Make this a real interceptor for filters such as rate limiting. -} - -type csKeyType string - -const csKey = csKeyType("grpc.internal.resolver.configSelector") - -// SetConfigSelector sets the config selector in state and returns the new -// state. -func SetConfigSelector(state resolver.State, cs ConfigSelector) resolver.State { - state.Attributes = state.Attributes.WithValue(csKey, cs) - return state -} - -// GetConfigSelector retrieves the config selector from state, if present, and -// returns it or nil if absent. -func GetConfigSelector(state resolver.State) ConfigSelector { - cs, _ := state.Attributes.Value(csKey).(ConfigSelector) - return cs -} - -// SafeConfigSelector allows for safe switching of ConfigSelector -// implementations such that previous values are guaranteed to not be in use -// when UpdateConfigSelector returns. -type SafeConfigSelector struct { - mu sync.RWMutex - cs ConfigSelector -} - -// UpdateConfigSelector swaps to the provided ConfigSelector and blocks until -// all uses of the previous ConfigSelector have completed. -func (scs *SafeConfigSelector) UpdateConfigSelector(cs ConfigSelector) { - scs.mu.Lock() - defer scs.mu.Unlock() - scs.cs = cs -} - -// SelectConfig defers to the current ConfigSelector in scs. -func (scs *SafeConfigSelector) SelectConfig(r RPCInfo) (*RPCConfig, error) { - scs.mu.RLock() - defer scs.mu.RUnlock() - return scs.cs.SelectConfig(r) -} diff --git a/vendor/google.golang.org/grpc/internal/resolver/dns/dns_resolver.go b/vendor/google.golang.org/grpc/internal/resolver/dns/dns_resolver.go deleted file mode 100644 index abab35e25..000000000 --- a/vendor/google.golang.org/grpc/internal/resolver/dns/dns_resolver.go +++ /dev/null @@ -1,450 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package dns implements a dns resolver to be installed as the default resolver -// in grpc. -package dns - -import ( - "context" - "encoding/json" - "fmt" - "net" - "os" - "strconv" - "strings" - "sync" - "time" - - grpclbstate "google.golang.org/grpc/balancer/grpclb/state" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/internal/backoff" - "google.golang.org/grpc/internal/envconfig" - "google.golang.org/grpc/internal/grpcrand" - "google.golang.org/grpc/internal/resolver/dns/internal" - "google.golang.org/grpc/resolver" - "google.golang.org/grpc/serviceconfig" -) - -// EnableSRVLookups controls whether the DNS resolver attempts to fetch gRPCLB -// addresses from SRV records. Must not be changed after init time. -var EnableSRVLookups = false - -// ResolvingTimeout specifies the maximum duration for a DNS resolution request. -// If the timeout expires before a response is received, the request will be canceled. -// -// It is recommended to set this value at application startup. Avoid modifying this variable -// after initialization as it's not thread-safe for concurrent modification. -var ResolvingTimeout = 30 * time.Second - -var logger = grpclog.Component("dns") - -func init() { - resolver.Register(NewBuilder()) - internal.TimeAfterFunc = time.After - internal.NewNetResolver = newNetResolver - internal.AddressDialer = addressDialer -} - -const ( - defaultPort = "443" - defaultDNSSvrPort = "53" - golang = "GO" - // txtPrefix is the prefix string to be prepended to the host name for txt - // record lookup. - txtPrefix = "_grpc_config." - // In DNS, service config is encoded in a TXT record via the mechanism - // described in RFC-1464 using the attribute name grpc_config. - txtAttribute = "grpc_config=" -) - -var addressDialer = func(address string) func(context.Context, string, string) (net.Conn, error) { - return func(ctx context.Context, network, _ string) (net.Conn, error) { - var dialer net.Dialer - return dialer.DialContext(ctx, network, address) - } -} - -var newNetResolver = func(authority string) (internal.NetResolver, error) { - if authority == "" { - return net.DefaultResolver, nil - } - - host, port, err := parseTarget(authority, defaultDNSSvrPort) - if err != nil { - return nil, err - } - - authorityWithPort := net.JoinHostPort(host, port) - - return &net.Resolver{ - PreferGo: true, - Dial: internal.AddressDialer(authorityWithPort), - }, nil -} - -// NewBuilder creates a dnsBuilder which is used to factory DNS resolvers. -func NewBuilder() resolver.Builder { - return &dnsBuilder{} -} - -type dnsBuilder struct{} - -// Build creates and starts a DNS resolver that watches the name resolution of -// the target. -func (b *dnsBuilder) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (resolver.Resolver, error) { - host, port, err := parseTarget(target.Endpoint(), defaultPort) - if err != nil { - return nil, err - } - - // IP address. - if ipAddr, ok := formatIP(host); ok { - addr := []resolver.Address{{Addr: ipAddr + ":" + port}} - cc.UpdateState(resolver.State{Addresses: addr}) - return deadResolver{}, nil - } - - // DNS address (non-IP). - ctx, cancel := context.WithCancel(context.Background()) - d := &dnsResolver{ - host: host, - port: port, - ctx: ctx, - cancel: cancel, - cc: cc, - rn: make(chan struct{}, 1), - disableServiceConfig: opts.DisableServiceConfig, - } - - d.resolver, err = internal.NewNetResolver(target.URL.Host) - if err != nil { - return nil, err - } - - d.wg.Add(1) - go d.watcher() - return d, nil -} - -// Scheme returns the naming scheme of this resolver builder, which is "dns". -func (b *dnsBuilder) Scheme() string { - return "dns" -} - -// deadResolver is a resolver that does nothing. -type deadResolver struct{} - -func (deadResolver) ResolveNow(resolver.ResolveNowOptions) {} - -func (deadResolver) Close() {} - -// dnsResolver watches for the name resolution update for a non-IP target. -type dnsResolver struct { - host string - port string - resolver internal.NetResolver - ctx context.Context - cancel context.CancelFunc - cc resolver.ClientConn - // rn channel is used by ResolveNow() to force an immediate resolution of the - // target. - rn chan struct{} - // wg is used to enforce Close() to return after the watcher() goroutine has - // finished. Otherwise, data race will be possible. [Race Example] in - // dns_resolver_test we replace the real lookup functions with mocked ones to - // facilitate testing. If Close() doesn't wait for watcher() goroutine - // finishes, race detector sometimes will warns lookup (READ the lookup - // function pointers) inside watcher() goroutine has data race with - // replaceNetFunc (WRITE the lookup function pointers). - wg sync.WaitGroup - disableServiceConfig bool -} - -// ResolveNow invoke an immediate resolution of the target that this -// dnsResolver watches. -func (d *dnsResolver) ResolveNow(resolver.ResolveNowOptions) { - select { - case d.rn <- struct{}{}: - default: - } -} - -// Close closes the dnsResolver. -func (d *dnsResolver) Close() { - d.cancel() - d.wg.Wait() -} - -func (d *dnsResolver) watcher() { - defer d.wg.Done() - backoffIndex := 1 - for { - state, err := d.lookup() - if err != nil { - // Report error to the underlying grpc.ClientConn. - d.cc.ReportError(err) - } else { - err = d.cc.UpdateState(*state) - } - - var waitTime time.Duration - if err == nil { - // Success resolving, wait for the next ResolveNow. However, also wait 30 - // seconds at the very least to prevent constantly re-resolving. - backoffIndex = 1 - waitTime = internal.MinResolutionRate - select { - case <-d.ctx.Done(): - return - case <-d.rn: - } - } else { - // Poll on an error found in DNS Resolver or an error received from - // ClientConn. - waitTime = backoff.DefaultExponential.Backoff(backoffIndex) - backoffIndex++ - } - select { - case <-d.ctx.Done(): - return - case <-internal.TimeAfterFunc(waitTime): - } - } -} - -func (d *dnsResolver) lookupSRV(ctx context.Context) ([]resolver.Address, error) { - if !EnableSRVLookups { - return nil, nil - } - var newAddrs []resolver.Address - _, srvs, err := d.resolver.LookupSRV(ctx, "grpclb", "tcp", d.host) - if err != nil { - err = handleDNSError(err, "SRV") // may become nil - return nil, err - } - for _, s := range srvs { - lbAddrs, err := d.resolver.LookupHost(ctx, s.Target) - if err != nil { - err = handleDNSError(err, "A") // may become nil - if err == nil { - // If there are other SRV records, look them up and ignore this - // one that does not exist. - continue - } - return nil, err - } - for _, a := range lbAddrs { - ip, ok := formatIP(a) - if !ok { - return nil, fmt.Errorf("dns: error parsing A record IP address %v", a) - } - addr := ip + ":" + strconv.Itoa(int(s.Port)) - newAddrs = append(newAddrs, resolver.Address{Addr: addr, ServerName: s.Target}) - } - } - return newAddrs, nil -} - -func handleDNSError(err error, lookupType string) error { - dnsErr, ok := err.(*net.DNSError) - if ok && !dnsErr.IsTimeout && !dnsErr.IsTemporary { - // Timeouts and temporary errors should be communicated to gRPC to - // attempt another DNS query (with backoff). Other errors should be - // suppressed (they may represent the absence of a TXT record). - return nil - } - if err != nil { - err = fmt.Errorf("dns: %v record lookup error: %v", lookupType, err) - logger.Info(err) - } - return err -} - -func (d *dnsResolver) lookupTXT(ctx context.Context) *serviceconfig.ParseResult { - ss, err := d.resolver.LookupTXT(ctx, txtPrefix+d.host) - if err != nil { - if envconfig.TXTErrIgnore { - return nil - } - if err = handleDNSError(err, "TXT"); err != nil { - return &serviceconfig.ParseResult{Err: err} - } - return nil - } - var res string - for _, s := range ss { - res += s - } - - // TXT record must have "grpc_config=" attribute in order to be used as - // service config. - if !strings.HasPrefix(res, txtAttribute) { - logger.Warningf("dns: TXT record %v missing %v attribute", res, txtAttribute) - // This is not an error; it is the equivalent of not having a service - // config. - return nil - } - sc := canaryingSC(strings.TrimPrefix(res, txtAttribute)) - return d.cc.ParseServiceConfig(sc) -} - -func (d *dnsResolver) lookupHost(ctx context.Context) ([]resolver.Address, error) { - addrs, err := d.resolver.LookupHost(ctx, d.host) - if err != nil { - err = handleDNSError(err, "A") - return nil, err - } - newAddrs := make([]resolver.Address, 0, len(addrs)) - for _, a := range addrs { - ip, ok := formatIP(a) - if !ok { - return nil, fmt.Errorf("dns: error parsing A record IP address %v", a) - } - addr := ip + ":" + d.port - newAddrs = append(newAddrs, resolver.Address{Addr: addr}) - } - return newAddrs, nil -} - -func (d *dnsResolver) lookup() (*resolver.State, error) { - ctx, cancel := context.WithTimeout(d.ctx, ResolvingTimeout) - defer cancel() - srv, srvErr := d.lookupSRV(ctx) - addrs, hostErr := d.lookupHost(ctx) - if hostErr != nil && (srvErr != nil || len(srv) == 0) { - return nil, hostErr - } - - state := resolver.State{Addresses: addrs} - if len(srv) > 0 { - state = grpclbstate.Set(state, &grpclbstate.State{BalancerAddresses: srv}) - } - if !d.disableServiceConfig { - state.ServiceConfig = d.lookupTXT(ctx) - } - return &state, nil -} - -// formatIP returns ok = false if addr is not a valid textual representation of -// an IP address. If addr is an IPv4 address, return the addr and ok = true. -// If addr is an IPv6 address, return the addr enclosed in square brackets and -// ok = true. -func formatIP(addr string) (addrIP string, ok bool) { - ip := net.ParseIP(addr) - if ip == nil { - return "", false - } - if ip.To4() != nil { - return addr, true - } - return "[" + addr + "]", true -} - -// parseTarget takes the user input target string and default port, returns -// formatted host and port info. If target doesn't specify a port, set the port -// to be the defaultPort. If target is in IPv6 format and host-name is enclosed -// in square brackets, brackets are stripped when setting the host. -// examples: -// target: "www.google.com" defaultPort: "443" returns host: "www.google.com", port: "443" -// target: "ipv4-host:80" defaultPort: "443" returns host: "ipv4-host", port: "80" -// target: "[ipv6-host]" defaultPort: "443" returns host: "ipv6-host", port: "443" -// target: ":80" defaultPort: "443" returns host: "localhost", port: "80" -func parseTarget(target, defaultPort string) (host, port string, err error) { - if target == "" { - return "", "", internal.ErrMissingAddr - } - if ip := net.ParseIP(target); ip != nil { - // target is an IPv4 or IPv6(without brackets) address - return target, defaultPort, nil - } - if host, port, err = net.SplitHostPort(target); err == nil { - if port == "" { - // If the port field is empty (target ends with colon), e.g. "[::1]:", - // this is an error. - return "", "", internal.ErrEndsWithColon - } - // target has port, i.e ipv4-host:port, [ipv6-host]:port, host-name:port - if host == "" { - // Keep consistent with net.Dial(): If the host is empty, as in ":80", - // the local system is assumed. - host = "localhost" - } - return host, port, nil - } - if host, port, err = net.SplitHostPort(target + ":" + defaultPort); err == nil { - // target doesn't have port - return host, port, nil - } - return "", "", fmt.Errorf("invalid target address %v, error info: %v", target, err) -} - -type rawChoice struct { - ClientLanguage *[]string `json:"clientLanguage,omitempty"` - Percentage *int `json:"percentage,omitempty"` - ClientHostName *[]string `json:"clientHostName,omitempty"` - ServiceConfig *json.RawMessage `json:"serviceConfig,omitempty"` -} - -func containsString(a *[]string, b string) bool { - if a == nil { - return true - } - for _, c := range *a { - if c == b { - return true - } - } - return false -} - -func chosenByPercentage(a *int) bool { - if a == nil { - return true - } - return grpcrand.Intn(100)+1 <= *a -} - -func canaryingSC(js string) string { - if js == "" { - return "" - } - var rcs []rawChoice - err := json.Unmarshal([]byte(js), &rcs) - if err != nil { - logger.Warningf("dns: error parsing service config json: %v", err) - return "" - } - cliHostname, err := os.Hostname() - if err != nil { - logger.Warningf("dns: error getting client hostname: %v", err) - return "" - } - var sc string - for _, c := range rcs { - if !containsString(c.ClientLanguage, golang) || - !chosenByPercentage(c.Percentage) || - !containsString(c.ClientHostName, cliHostname) || - c.ServiceConfig == nil { - continue - } - sc = string(*c.ServiceConfig) - break - } - return sc -} diff --git a/vendor/google.golang.org/grpc/internal/resolver/dns/internal/internal.go b/vendor/google.golang.org/grpc/internal/resolver/dns/internal/internal.go deleted file mode 100644 index c7fc557d0..000000000 --- a/vendor/google.golang.org/grpc/internal/resolver/dns/internal/internal.go +++ /dev/null @@ -1,70 +0,0 @@ -/* - * - * Copyright 2023 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package internal contains functionality internal to the dns resolver package. -package internal - -import ( - "context" - "errors" - "net" - "time" -) - -// NetResolver groups the methods on net.Resolver that are used by the DNS -// resolver implementation. This allows the default net.Resolver instance to be -// overidden from tests. -type NetResolver interface { - LookupHost(ctx context.Context, host string) (addrs []string, err error) - LookupSRV(ctx context.Context, service, proto, name string) (cname string, addrs []*net.SRV, err error) - LookupTXT(ctx context.Context, name string) (txts []string, err error) -} - -var ( - // ErrMissingAddr is the error returned when building a DNS resolver when - // the provided target name is empty. - ErrMissingAddr = errors.New("dns resolver: missing address") - - // ErrEndsWithColon is the error returned when building a DNS resolver when - // the provided target name ends with a colon that is supposed to be the - // separator between host and port. E.g. "::" is a valid address as it is - // an IPv6 address (host only) and "[::]:" is invalid as it ends with a - // colon as the host and port separator - ErrEndsWithColon = errors.New("dns resolver: missing port after port-separator colon") -) - -// The following vars are overridden from tests. -var ( - // MinResolutionRate is the minimum rate at which re-resolutions are - // allowed. This helps to prevent excessive re-resolution. - MinResolutionRate = 30 * time.Second - - // TimeAfterFunc is used by the DNS resolver to wait for the given duration - // to elapse. In non-test code, this is implemented by time.After. In test - // code, this can be used to control the amount of time the resolver is - // blocked waiting for the duration to elapse. - TimeAfterFunc func(time.Duration) <-chan time.Time - - // NewNetResolver returns the net.Resolver instance for the given target. - NewNetResolver func(string) (NetResolver, error) - - // AddressDialer is the dialer used to dial the DNS server. It accepts the - // Host portion of the URL corresponding to the user's dial target and - // returns a dial function. - AddressDialer func(address string) func(context.Context, string, string) (net.Conn, error) -) diff --git a/vendor/google.golang.org/grpc/internal/resolver/passthrough/passthrough.go b/vendor/google.golang.org/grpc/internal/resolver/passthrough/passthrough.go deleted file mode 100644 index afac56572..000000000 --- a/vendor/google.golang.org/grpc/internal/resolver/passthrough/passthrough.go +++ /dev/null @@ -1,64 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package passthrough implements a pass-through resolver. It sends the target -// name without scheme back to gRPC as resolved address. -package passthrough - -import ( - "errors" - - "google.golang.org/grpc/resolver" -) - -const scheme = "passthrough" - -type passthroughBuilder struct{} - -func (*passthroughBuilder) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (resolver.Resolver, error) { - if target.Endpoint() == "" && opts.Dialer == nil { - return nil, errors.New("passthrough: received empty target in Build()") - } - r := &passthroughResolver{ - target: target, - cc: cc, - } - r.start() - return r, nil -} - -func (*passthroughBuilder) Scheme() string { - return scheme -} - -type passthroughResolver struct { - target resolver.Target - cc resolver.ClientConn -} - -func (r *passthroughResolver) start() { - r.cc.UpdateState(resolver.State{Addresses: []resolver.Address{{Addr: r.target.Endpoint()}}}) -} - -func (*passthroughResolver) ResolveNow(o resolver.ResolveNowOptions) {} - -func (*passthroughResolver) Close() {} - -func init() { - resolver.Register(&passthroughBuilder{}) -} diff --git a/vendor/google.golang.org/grpc/internal/resolver/unix/unix.go b/vendor/google.golang.org/grpc/internal/resolver/unix/unix.go deleted file mode 100644 index 27cd81af9..000000000 --- a/vendor/google.golang.org/grpc/internal/resolver/unix/unix.go +++ /dev/null @@ -1,78 +0,0 @@ -/* - * - * Copyright 2020 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package unix implements a resolver for unix targets. -package unix - -import ( - "fmt" - - "google.golang.org/grpc/internal/transport/networktype" - "google.golang.org/grpc/resolver" -) - -const unixScheme = "unix" -const unixAbstractScheme = "unix-abstract" - -type builder struct { - scheme string -} - -func (b *builder) Build(target resolver.Target, cc resolver.ClientConn, _ resolver.BuildOptions) (resolver.Resolver, error) { - if target.URL.Host != "" { - return nil, fmt.Errorf("invalid (non-empty) authority: %v", target.URL.Host) - } - - // gRPC was parsing the dial target manually before PR #4817, and we - // switched to using url.Parse() in that PR. To avoid breaking existing - // resolver implementations we ended up stripping the leading "/" from the - // endpoint. This obviously does not work for the "unix" scheme. Hence we - // end up using the parsed URL instead. - endpoint := target.URL.Path - if endpoint == "" { - endpoint = target.URL.Opaque - } - addr := resolver.Address{Addr: endpoint} - if b.scheme == unixAbstractScheme { - // We can not prepend \0 as c++ gRPC does, as in Golang '@' is used to signify we do - // not want trailing \0 in address. - addr.Addr = "@" + addr.Addr - } - cc.UpdateState(resolver.State{Addresses: []resolver.Address{networktype.Set(addr, "unix")}}) - return &nopResolver{}, nil -} - -func (b *builder) Scheme() string { - return b.scheme -} - -func (b *builder) OverrideAuthority(resolver.Target) string { - return "localhost" -} - -type nopResolver struct { -} - -func (*nopResolver) ResolveNow(resolver.ResolveNowOptions) {} - -func (*nopResolver) Close() {} - -func init() { - resolver.Register(&builder{scheme: unixScheme}) - resolver.Register(&builder{scheme: unixAbstractScheme}) -} diff --git a/vendor/google.golang.org/grpc/internal/serviceconfig/duration.go b/vendor/google.golang.org/grpc/internal/serviceconfig/duration.go deleted file mode 100644 index 11d82afcc..000000000 --- a/vendor/google.golang.org/grpc/internal/serviceconfig/duration.go +++ /dev/null @@ -1,130 +0,0 @@ -/* - * - * Copyright 2023 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package serviceconfig - -import ( - "encoding/json" - "fmt" - "math" - "strconv" - "strings" - "time" -) - -// Duration defines JSON marshal and unmarshal methods to conform to the -// protobuf JSON spec defined [here]. -// -// [here]: https://protobuf.dev/reference/protobuf/google.protobuf/#duration -type Duration time.Duration - -func (d Duration) String() string { - return fmt.Sprint(time.Duration(d)) -} - -// MarshalJSON converts from d to a JSON string output. -func (d Duration) MarshalJSON() ([]byte, error) { - ns := time.Duration(d).Nanoseconds() - sec := ns / int64(time.Second) - ns = ns % int64(time.Second) - - var sign string - if sec < 0 || ns < 0 { - sign, sec, ns = "-", -1*sec, -1*ns - } - - // Generated output always contains 0, 3, 6, or 9 fractional digits, - // depending on required precision. - str := fmt.Sprintf("%s%d.%09d", sign, sec, ns) - str = strings.TrimSuffix(str, "000") - str = strings.TrimSuffix(str, "000") - str = strings.TrimSuffix(str, ".000") - return []byte(fmt.Sprintf("\"%ss\"", str)), nil -} - -// UnmarshalJSON unmarshals b as a duration JSON string into d. -func (d *Duration) UnmarshalJSON(b []byte) error { - var s string - if err := json.Unmarshal(b, &s); err != nil { - return err - } - if !strings.HasSuffix(s, "s") { - return fmt.Errorf("malformed duration %q: missing seconds unit", s) - } - neg := false - if s[0] == '-' { - neg = true - s = s[1:] - } - ss := strings.SplitN(s[:len(s)-1], ".", 3) - if len(ss) > 2 { - return fmt.Errorf("malformed duration %q: too many decimals", s) - } - // hasDigits is set if either the whole or fractional part of the number is - // present, since both are optional but one is required. - hasDigits := false - var sec, ns int64 - if len(ss[0]) > 0 { - var err error - if sec, err = strconv.ParseInt(ss[0], 10, 64); err != nil { - return fmt.Errorf("malformed duration %q: %v", s, err) - } - // Maximum seconds value per the durationpb spec. - const maxProtoSeconds = 315_576_000_000 - if sec > maxProtoSeconds { - return fmt.Errorf("out of range: %q", s) - } - hasDigits = true - } - if len(ss) == 2 && len(ss[1]) > 0 { - if len(ss[1]) > 9 { - return fmt.Errorf("malformed duration %q: too many digits after decimal", s) - } - var err error - if ns, err = strconv.ParseInt(ss[1], 10, 64); err != nil { - return fmt.Errorf("malformed duration %q: %v", s, err) - } - for i := 9; i > len(ss[1]); i-- { - ns *= 10 - } - hasDigits = true - } - if !hasDigits { - return fmt.Errorf("malformed duration %q: contains no numbers", s) - } - - if neg { - sec *= -1 - ns *= -1 - } - - // Maximum/minimum seconds/nanoseconds representable by Go's time.Duration. - const maxSeconds = math.MaxInt64 / int64(time.Second) - const maxNanosAtMaxSeconds = math.MaxInt64 % int64(time.Second) - const minSeconds = math.MinInt64 / int64(time.Second) - const minNanosAtMinSeconds = math.MinInt64 % int64(time.Second) - - if sec > maxSeconds || (sec == maxSeconds && ns >= maxNanosAtMaxSeconds) { - *d = Duration(math.MaxInt64) - } else if sec < minSeconds || (sec == minSeconds && ns <= minNanosAtMinSeconds) { - *d = Duration(math.MinInt64) - } else { - *d = Duration(sec*int64(time.Second) + ns) - } - return nil -} diff --git a/vendor/google.golang.org/grpc/internal/serviceconfig/serviceconfig.go b/vendor/google.golang.org/grpc/internal/serviceconfig/serviceconfig.go deleted file mode 100644 index 51e733e49..000000000 --- a/vendor/google.golang.org/grpc/internal/serviceconfig/serviceconfig.go +++ /dev/null @@ -1,180 +0,0 @@ -/* - * - * Copyright 2020 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package serviceconfig contains utility functions to parse service config. -package serviceconfig - -import ( - "encoding/json" - "fmt" - "time" - - "google.golang.org/grpc/balancer" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - externalserviceconfig "google.golang.org/grpc/serviceconfig" -) - -var logger = grpclog.Component("core") - -// BalancerConfig wraps the name and config associated with one load balancing -// policy. It corresponds to a single entry of the loadBalancingConfig field -// from ServiceConfig. -// -// It implements the json.Unmarshaler interface. -// -// https://github.com/grpc/grpc-proto/blob/54713b1e8bc6ed2d4f25fb4dff527842150b91b2/grpc/service_config/service_config.proto#L247 -type BalancerConfig struct { - Name string - Config externalserviceconfig.LoadBalancingConfig -} - -type intermediateBalancerConfig []map[string]json.RawMessage - -// MarshalJSON implements the json.Marshaler interface. -// -// It marshals the balancer and config into a length-1 slice -// ([]map[string]config). -func (bc *BalancerConfig) MarshalJSON() ([]byte, error) { - if bc.Config == nil { - // If config is nil, return empty config `{}`. - return []byte(fmt.Sprintf(`[{%q: %v}]`, bc.Name, "{}")), nil - } - c, err := json.Marshal(bc.Config) - if err != nil { - return nil, err - } - return []byte(fmt.Sprintf(`[{%q: %s}]`, bc.Name, c)), nil -} - -// UnmarshalJSON implements the json.Unmarshaler interface. -// -// ServiceConfig contains a list of loadBalancingConfigs, each with a name and -// config. This method iterates through that list in order, and stops at the -// first policy that is supported. -// - If the config for the first supported policy is invalid, the whole service -// config is invalid. -// - If the list doesn't contain any supported policy, the whole service config -// is invalid. -func (bc *BalancerConfig) UnmarshalJSON(b []byte) error { - var ir intermediateBalancerConfig - err := json.Unmarshal(b, &ir) - if err != nil { - return err - } - - var names []string - for i, lbcfg := range ir { - if len(lbcfg) != 1 { - return fmt.Errorf("invalid loadBalancingConfig: entry %v does not contain exactly 1 policy/config pair: %q", i, lbcfg) - } - - var ( - name string - jsonCfg json.RawMessage - ) - // Get the key:value pair from the map. We have already made sure that - // the map contains a single entry. - for name, jsonCfg = range lbcfg { - } - - names = append(names, name) - builder := balancer.Get(name) - if builder == nil { - // If the balancer is not registered, move on to the next config. - // This is not an error. - continue - } - bc.Name = name - - parser, ok := builder.(balancer.ConfigParser) - if !ok { - if string(jsonCfg) != "{}" { - logger.Warningf("non-empty balancer configuration %q, but balancer does not implement ParseConfig", string(jsonCfg)) - } - // Stop at this, though the builder doesn't support parsing config. - return nil - } - - cfg, err := parser.ParseConfig(jsonCfg) - if err != nil { - return fmt.Errorf("error parsing loadBalancingConfig for policy %q: %v", name, err) - } - bc.Config = cfg - return nil - } - // This is reached when the for loop iterates over all entries, but didn't - // return. This means we had a loadBalancingConfig slice but did not - // encounter a registered policy. The config is considered invalid in this - // case. - return fmt.Errorf("invalid loadBalancingConfig: no supported policies found in %v", names) -} - -// MethodConfig defines the configuration recommended by the service providers for a -// particular method. -type MethodConfig struct { - // WaitForReady indicates whether RPCs sent to this method should wait until - // the connection is ready by default (!failfast). The value specified via the - // gRPC client API will override the value set here. - WaitForReady *bool - // Timeout is the default timeout for RPCs sent to this method. The actual - // deadline used will be the minimum of the value specified here and the value - // set by the application via the gRPC client API. If either one is not set, - // then the other will be used. If neither is set, then the RPC has no deadline. - Timeout *time.Duration - // MaxReqSize is the maximum allowed payload size for an individual request in a - // stream (client->server) in bytes. The size which is measured is the serialized - // payload after per-message compression (but before stream compression) in bytes. - // The actual value used is the minimum of the value specified here and the value set - // by the application via the gRPC client API. If either one is not set, then the other - // will be used. If neither is set, then the built-in default is used. - MaxReqSize *int - // MaxRespSize is the maximum allowed payload size for an individual response in a - // stream (server->client) in bytes. - MaxRespSize *int - // RetryPolicy configures retry options for the method. - RetryPolicy *RetryPolicy -} - -// RetryPolicy defines the go-native version of the retry policy defined by the -// service config here: -// https://github.com/grpc/proposal/blob/master/A6-client-retries.md#integration-with-service-config -type RetryPolicy struct { - // MaxAttempts is the maximum number of attempts, including the original RPC. - // - // This field is required and must be two or greater. - MaxAttempts int - - // Exponential backoff parameters. The initial retry attempt will occur at - // random(0, initialBackoff). In general, the nth attempt will occur at - // random(0, - // min(initialBackoff*backoffMultiplier**(n-1), maxBackoff)). - // - // These fields are required and must be greater than zero. - InitialBackoff time.Duration - MaxBackoff time.Duration - BackoffMultiplier float64 - - // The set of status codes which may be retried. - // - // Status codes are specified as strings, e.g., "UNAVAILABLE". - // - // This field is required and must be non-empty. - // Note: a set is used to store this for easy lookup. - RetryableStatusCodes map[codes.Code]bool -} diff --git a/vendor/google.golang.org/grpc/internal/status/status.go b/vendor/google.golang.org/grpc/internal/status/status.go deleted file mode 100644 index c7dbc8205..000000000 --- a/vendor/google.golang.org/grpc/internal/status/status.go +++ /dev/null @@ -1,205 +0,0 @@ -/* - * - * Copyright 2020 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package status implements errors returned by gRPC. These errors are -// serialized and transmitted on the wire between server and client, and allow -// for additional data to be transmitted via the Details field in the status -// proto. gRPC service handlers should return an error created by this -// package, and gRPC clients should expect a corresponding error to be -// returned from the RPC call. -// -// This package upholds the invariants that a non-nil error may not -// contain an OK code, and an OK code must result in a nil error. -package status - -import ( - "errors" - "fmt" - - spb "google.golang.org/genproto/googleapis/rpc/status" - "google.golang.org/grpc/codes" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/protoadapt" - "google.golang.org/protobuf/types/known/anypb" -) - -// Status represents an RPC status code, message, and details. It is immutable -// and should be created with New, Newf, or FromProto. -type Status struct { - s *spb.Status -} - -// NewWithProto returns a new status including details from statusProto. This -// is meant to be used by the gRPC library only. -func NewWithProto(code codes.Code, message string, statusProto []string) *Status { - if len(statusProto) != 1 { - // No grpc-status-details bin header, or multiple; just ignore. - return &Status{s: &spb.Status{Code: int32(code), Message: message}} - } - st := &spb.Status{} - if err := proto.Unmarshal([]byte(statusProto[0]), st); err != nil { - // Probably not a google.rpc.Status proto; do not provide details. - return &Status{s: &spb.Status{Code: int32(code), Message: message}} - } - if st.Code == int32(code) { - // The codes match between the grpc-status header and the - // grpc-status-details-bin header; use the full details proto. - return &Status{s: st} - } - return &Status{ - s: &spb.Status{ - Code: int32(codes.Internal), - Message: fmt.Sprintf( - "grpc-status-details-bin mismatch: grpc-status=%v, grpc-message=%q, grpc-status-details-bin=%+v", - code, message, st, - ), - }, - } -} - -// New returns a Status representing c and msg. -func New(c codes.Code, msg string) *Status { - return &Status{s: &spb.Status{Code: int32(c), Message: msg}} -} - -// Newf returns New(c, fmt.Sprintf(format, a...)). -func Newf(c codes.Code, format string, a ...any) *Status { - return New(c, fmt.Sprintf(format, a...)) -} - -// FromProto returns a Status representing s. -func FromProto(s *spb.Status) *Status { - return &Status{s: proto.Clone(s).(*spb.Status)} -} - -// Err returns an error representing c and msg. If c is OK, returns nil. -func Err(c codes.Code, msg string) error { - return New(c, msg).Err() -} - -// Errorf returns Error(c, fmt.Sprintf(format, a...)). -func Errorf(c codes.Code, format string, a ...any) error { - return Err(c, fmt.Sprintf(format, a...)) -} - -// Code returns the status code contained in s. -func (s *Status) Code() codes.Code { - if s == nil || s.s == nil { - return codes.OK - } - return codes.Code(s.s.Code) -} - -// Message returns the message contained in s. -func (s *Status) Message() string { - if s == nil || s.s == nil { - return "" - } - return s.s.Message -} - -// Proto returns s's status as an spb.Status proto message. -func (s *Status) Proto() *spb.Status { - if s == nil { - return nil - } - return proto.Clone(s.s).(*spb.Status) -} - -// Err returns an immutable error representing s; returns nil if s.Code() is OK. -func (s *Status) Err() error { - if s.Code() == codes.OK { - return nil - } - return &Error{s: s} -} - -// WithDetails returns a new status with the provided details messages appended to the status. -// If any errors are encountered, it returns nil and the first error encountered. -func (s *Status) WithDetails(details ...protoadapt.MessageV1) (*Status, error) { - if s.Code() == codes.OK { - return nil, errors.New("no error details for status with code OK") - } - // s.Code() != OK implies that s.Proto() != nil. - p := s.Proto() - for _, detail := range details { - any, err := anypb.New(protoadapt.MessageV2Of(detail)) - if err != nil { - return nil, err - } - p.Details = append(p.Details, any) - } - return &Status{s: p}, nil -} - -// Details returns a slice of details messages attached to the status. -// If a detail cannot be decoded, the error is returned in place of the detail. -func (s *Status) Details() []any { - if s == nil || s.s == nil { - return nil - } - details := make([]any, 0, len(s.s.Details)) - for _, any := range s.s.Details { - detail, err := any.UnmarshalNew() - if err != nil { - details = append(details, err) - continue - } - details = append(details, detail) - } - return details -} - -func (s *Status) String() string { - return fmt.Sprintf("rpc error: code = %s desc = %s", s.Code(), s.Message()) -} - -// Error wraps a pointer of a status proto. It implements error and Status, -// and a nil *Error should never be returned by this package. -type Error struct { - s *Status -} - -func (e *Error) Error() string { - return e.s.String() -} - -// GRPCStatus returns the Status represented by se. -func (e *Error) GRPCStatus() *Status { - return e.s -} - -// Is implements future error.Is functionality. -// A Error is equivalent if the code and message are identical. -func (e *Error) Is(target error) bool { - tse, ok := target.(*Error) - if !ok { - return false - } - return proto.Equal(e.s.s, tse.s.s) -} - -// IsRestrictedControlPlaneCode returns whether the status includes a code -// restricted for control plane usage as defined by gRFC A54. -func IsRestrictedControlPlaneCode(s *Status) bool { - switch s.Code() { - case codes.InvalidArgument, codes.NotFound, codes.AlreadyExists, codes.FailedPrecondition, codes.Aborted, codes.OutOfRange, codes.DataLoss: - return true - } - return false -} diff --git a/vendor/google.golang.org/grpc/internal/syscall/syscall_linux.go b/vendor/google.golang.org/grpc/internal/syscall/syscall_linux.go deleted file mode 100644 index b3a72276d..000000000 --- a/vendor/google.golang.org/grpc/internal/syscall/syscall_linux.go +++ /dev/null @@ -1,112 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package syscall provides functionalities that grpc uses to get low-level operating system -// stats/info. -package syscall - -import ( - "fmt" - "net" - "syscall" - "time" - - "golang.org/x/sys/unix" - "google.golang.org/grpc/grpclog" -) - -var logger = grpclog.Component("core") - -// GetCPUTime returns the how much CPU time has passed since the start of this process. -func GetCPUTime() int64 { - var ts unix.Timespec - if err := unix.ClockGettime(unix.CLOCK_PROCESS_CPUTIME_ID, &ts); err != nil { - logger.Fatal(err) - } - return ts.Nano() -} - -// Rusage is an alias for syscall.Rusage under linux environment. -type Rusage = syscall.Rusage - -// GetRusage returns the resource usage of current process. -func GetRusage() *Rusage { - rusage := new(Rusage) - syscall.Getrusage(syscall.RUSAGE_SELF, rusage) - return rusage -} - -// CPUTimeDiff returns the differences of user CPU time and system CPU time used -// between two Rusage structs. -func CPUTimeDiff(first *Rusage, latest *Rusage) (float64, float64) { - var ( - utimeDiffs = latest.Utime.Sec - first.Utime.Sec - utimeDiffus = latest.Utime.Usec - first.Utime.Usec - stimeDiffs = latest.Stime.Sec - first.Stime.Sec - stimeDiffus = latest.Stime.Usec - first.Stime.Usec - ) - - uTimeElapsed := float64(utimeDiffs) + float64(utimeDiffus)*1.0e-6 - sTimeElapsed := float64(stimeDiffs) + float64(stimeDiffus)*1.0e-6 - - return uTimeElapsed, sTimeElapsed -} - -// SetTCPUserTimeout sets the TCP user timeout on a connection's socket -func SetTCPUserTimeout(conn net.Conn, timeout time.Duration) error { - tcpconn, ok := conn.(*net.TCPConn) - if !ok { - // not a TCP connection. exit early - return nil - } - rawConn, err := tcpconn.SyscallConn() - if err != nil { - return fmt.Errorf("error getting raw connection: %v", err) - } - err = rawConn.Control(func(fd uintptr) { - err = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, unix.TCP_USER_TIMEOUT, int(timeout/time.Millisecond)) - }) - if err != nil { - return fmt.Errorf("error setting option on socket: %v", err) - } - - return nil -} - -// GetTCPUserTimeout gets the TCP user timeout on a connection's socket -func GetTCPUserTimeout(conn net.Conn) (opt int, err error) { - tcpconn, ok := conn.(*net.TCPConn) - if !ok { - err = fmt.Errorf("conn is not *net.TCPConn. got %T", conn) - return - } - rawConn, err := tcpconn.SyscallConn() - if err != nil { - err = fmt.Errorf("error getting raw connection: %v", err) - return - } - err = rawConn.Control(func(fd uintptr) { - opt, err = syscall.GetsockoptInt(int(fd), syscall.IPPROTO_TCP, unix.TCP_USER_TIMEOUT) - }) - if err != nil { - err = fmt.Errorf("error getting option on socket: %v", err) - return - } - - return -} diff --git a/vendor/google.golang.org/grpc/internal/syscall/syscall_nonlinux.go b/vendor/google.golang.org/grpc/internal/syscall/syscall_nonlinux.go deleted file mode 100644 index 999f52cd7..000000000 --- a/vendor/google.golang.org/grpc/internal/syscall/syscall_nonlinux.go +++ /dev/null @@ -1,77 +0,0 @@ -//go:build !linux -// +build !linux - -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package syscall provides functionalities that grpc uses to get low-level -// operating system stats/info. -package syscall - -import ( - "net" - "sync" - "time" - - "google.golang.org/grpc/grpclog" -) - -var once sync.Once -var logger = grpclog.Component("core") - -func log() { - once.Do(func() { - logger.Info("CPU time info is unavailable on non-linux environments.") - }) -} - -// GetCPUTime returns the how much CPU time has passed since the start of this -// process. It always returns 0 under non-linux environments. -func GetCPUTime() int64 { - log() - return 0 -} - -// Rusage is an empty struct under non-linux environments. -type Rusage struct{} - -// GetRusage is a no-op function under non-linux environments. -func GetRusage() *Rusage { - log() - return nil -} - -// CPUTimeDiff returns the differences of user CPU time and system CPU time used -// between two Rusage structs. It a no-op function for non-linux environments. -func CPUTimeDiff(first *Rusage, latest *Rusage) (float64, float64) { - log() - return 0, 0 -} - -// SetTCPUserTimeout is a no-op function under non-linux environments. -func SetTCPUserTimeout(conn net.Conn, timeout time.Duration) error { - log() - return nil -} - -// GetTCPUserTimeout is a no-op function under non-linux environments. -// A negative return value indicates the operation is not supported -func GetTCPUserTimeout(conn net.Conn) (int, error) { - log() - return -1, nil -} diff --git a/vendor/google.golang.org/grpc/internal/tcp_keepalive_others.go b/vendor/google.golang.org/grpc/internal/tcp_keepalive_others.go deleted file mode 100644 index 4f347edd4..000000000 --- a/vendor/google.golang.org/grpc/internal/tcp_keepalive_others.go +++ /dev/null @@ -1,29 +0,0 @@ -//go:build !unix && !windows - -/* - * Copyright 2023 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package internal - -import ( - "net" -) - -// NetDialerWithTCPKeepalive returns a vanilla net.Dialer on non-unix platforms. -func NetDialerWithTCPKeepalive() *net.Dialer { - return &net.Dialer{} -} diff --git a/vendor/google.golang.org/grpc/internal/tcp_keepalive_unix.go b/vendor/google.golang.org/grpc/internal/tcp_keepalive_unix.go deleted file mode 100644 index 078137b7f..000000000 --- a/vendor/google.golang.org/grpc/internal/tcp_keepalive_unix.go +++ /dev/null @@ -1,54 +0,0 @@ -//go:build unix - -/* - * Copyright 2023 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package internal - -import ( - "net" - "syscall" - "time" - - "golang.org/x/sys/unix" -) - -// NetDialerWithTCPKeepalive returns a net.Dialer that enables TCP keepalives on -// the underlying connection with OS default values for keepalive parameters. -// -// TODO: Once https://github.com/golang/go/issues/62254 lands, and the -// appropriate Go version becomes less than our least supported Go version, we -// should look into using the new API to make things more straightforward. -func NetDialerWithTCPKeepalive() *net.Dialer { - return &net.Dialer{ - // Setting a negative value here prevents the Go stdlib from overriding - // the values of TCP keepalive time and interval. It also prevents the - // Go stdlib from enabling TCP keepalives by default. - KeepAlive: time.Duration(-1), - // This method is called after the underlying network socket is created, - // but before dialing the socket (or calling its connect() method). The - // combination of unconditionally enabling TCP keepalives here, and - // disabling the overriding of TCP keepalive parameters by setting the - // KeepAlive field to a negative value above, results in OS defaults for - // the TCP keealive interval and time parameters. - Control: func(_, _ string, c syscall.RawConn) error { - return c.Control(func(fd uintptr) { - unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_KEEPALIVE, 1) - }) - }, - } -} diff --git a/vendor/google.golang.org/grpc/internal/tcp_keepalive_windows.go b/vendor/google.golang.org/grpc/internal/tcp_keepalive_windows.go deleted file mode 100644 index fd7d43a89..000000000 --- a/vendor/google.golang.org/grpc/internal/tcp_keepalive_windows.go +++ /dev/null @@ -1,54 +0,0 @@ -//go:build windows - -/* - * Copyright 2023 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package internal - -import ( - "net" - "syscall" - "time" - - "golang.org/x/sys/windows" -) - -// NetDialerWithTCPKeepalive returns a net.Dialer that enables TCP keepalives on -// the underlying connection with OS default values for keepalive parameters. -// -// TODO: Once https://github.com/golang/go/issues/62254 lands, and the -// appropriate Go version becomes less than our least supported Go version, we -// should look into using the new API to make things more straightforward. -func NetDialerWithTCPKeepalive() *net.Dialer { - return &net.Dialer{ - // Setting a negative value here prevents the Go stdlib from overriding - // the values of TCP keepalive time and interval. It also prevents the - // Go stdlib from enabling TCP keepalives by default. - KeepAlive: time.Duration(-1), - // This method is called after the underlying network socket is created, - // but before dialing the socket (or calling its connect() method). The - // combination of unconditionally enabling TCP keepalives here, and - // disabling the overriding of TCP keepalive parameters by setting the - // KeepAlive field to a negative value above, results in OS defaults for - // the TCP keealive interval and time parameters. - Control: func(_, _ string, c syscall.RawConn) error { - return c.Control(func(fd uintptr) { - windows.SetsockoptInt(windows.Handle(fd), windows.SOL_SOCKET, windows.SO_KEEPALIVE, 1) - }) - }, - } -} diff --git a/vendor/google.golang.org/grpc/internal/transport/bdp_estimator.go b/vendor/google.golang.org/grpc/internal/transport/bdp_estimator.go deleted file mode 100644 index 070680edb..000000000 --- a/vendor/google.golang.org/grpc/internal/transport/bdp_estimator.go +++ /dev/null @@ -1,141 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package transport - -import ( - "sync" - "time" -) - -const ( - // bdpLimit is the maximum value the flow control windows will be increased - // to. TCP typically limits this to 4MB, but some systems go up to 16MB. - // Since this is only a limit, it is safe to make it optimistic. - bdpLimit = (1 << 20) * 16 - // alpha is a constant factor used to keep a moving average - // of RTTs. - alpha = 0.9 - // If the current bdp sample is greater than or equal to - // our beta * our estimated bdp and the current bandwidth - // sample is the maximum bandwidth observed so far, we - // increase our bbp estimate by a factor of gamma. - beta = 0.66 - // To put our bdp to be smaller than or equal to twice the real BDP, - // we should multiply our current sample with 4/3, however to round things out - // we use 2 as the multiplication factor. - gamma = 2 -) - -// Adding arbitrary data to ping so that its ack can be identified. -// Easter-egg: what does the ping message say? -var bdpPing = &ping{data: [8]byte{2, 4, 16, 16, 9, 14, 7, 7}} - -type bdpEstimator struct { - // sentAt is the time when the ping was sent. - sentAt time.Time - - mu sync.Mutex - // bdp is the current bdp estimate. - bdp uint32 - // sample is the number of bytes received in one measurement cycle. - sample uint32 - // bwMax is the maximum bandwidth noted so far (bytes/sec). - bwMax float64 - // bool to keep track of the beginning of a new measurement cycle. - isSent bool - // Callback to update the window sizes. - updateFlowControl func(n uint32) - // sampleCount is the number of samples taken so far. - sampleCount uint64 - // round trip time (seconds) - rtt float64 -} - -// timesnap registers the time bdp ping was sent out so that -// network rtt can be calculated when its ack is received. -// It is called (by controller) when the bdpPing is -// being written on the wire. -func (b *bdpEstimator) timesnap(d [8]byte) { - if bdpPing.data != d { - return - } - b.sentAt = time.Now() -} - -// add adds bytes to the current sample for calculating bdp. -// It returns true only if a ping must be sent. This can be used -// by the caller (handleData) to make decision about batching -// a window update with it. -func (b *bdpEstimator) add(n uint32) bool { - b.mu.Lock() - defer b.mu.Unlock() - if b.bdp == bdpLimit { - return false - } - if !b.isSent { - b.isSent = true - b.sample = n - b.sentAt = time.Time{} - b.sampleCount++ - return true - } - b.sample += n - return false -} - -// calculate is called when an ack for a bdp ping is received. -// Here we calculate the current bdp and bandwidth sample and -// decide if the flow control windows should go up. -func (b *bdpEstimator) calculate(d [8]byte) { - // Check if the ping acked for was the bdp ping. - if bdpPing.data != d { - return - } - b.mu.Lock() - rttSample := time.Since(b.sentAt).Seconds() - if b.sampleCount < 10 { - // Bootstrap rtt with an average of first 10 rtt samples. - b.rtt += (rttSample - b.rtt) / float64(b.sampleCount) - } else { - // Heed to the recent past more. - b.rtt += (rttSample - b.rtt) * float64(alpha) - } - b.isSent = false - // The number of bytes accumulated so far in the sample is smaller - // than or equal to 1.5 times the real BDP on a saturated connection. - bwCurrent := float64(b.sample) / (b.rtt * float64(1.5)) - if bwCurrent > b.bwMax { - b.bwMax = bwCurrent - } - // If the current sample (which is smaller than or equal to the 1.5 times the real BDP) is - // greater than or equal to 2/3rd our perceived bdp AND this is the maximum bandwidth seen so far, we - // should update our perception of the network BDP. - if float64(b.sample) >= beta*float64(b.bdp) && bwCurrent == b.bwMax && b.bdp != bdpLimit { - sampleFloat := float64(b.sample) - b.bdp = uint32(gamma * sampleFloat) - if b.bdp > bdpLimit { - b.bdp = bdpLimit - } - bdp := b.bdp - b.mu.Unlock() - b.updateFlowControl(bdp) - return - } - b.mu.Unlock() -} diff --git a/vendor/google.golang.org/grpc/internal/transport/controlbuf.go b/vendor/google.golang.org/grpc/internal/transport/controlbuf.go deleted file mode 100644 index 83c382982..000000000 --- a/vendor/google.golang.org/grpc/internal/transport/controlbuf.go +++ /dev/null @@ -1,1006 +0,0 @@ -/* - * - * Copyright 2014 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package transport - -import ( - "bytes" - "errors" - "fmt" - "net" - "runtime" - "strconv" - "sync" - "sync/atomic" - - "golang.org/x/net/http2" - "golang.org/x/net/http2/hpack" - "google.golang.org/grpc/internal/grpclog" - "google.golang.org/grpc/internal/grpcutil" - "google.golang.org/grpc/status" -) - -var updateHeaderTblSize = func(e *hpack.Encoder, v uint32) { - e.SetMaxDynamicTableSizeLimit(v) -} - -type itemNode struct { - it any - next *itemNode -} - -type itemList struct { - head *itemNode - tail *itemNode -} - -func (il *itemList) enqueue(i any) { - n := &itemNode{it: i} - if il.tail == nil { - il.head, il.tail = n, n - return - } - il.tail.next = n - il.tail = n -} - -// peek returns the first item in the list without removing it from the -// list. -func (il *itemList) peek() any { - return il.head.it -} - -func (il *itemList) dequeue() any { - if il.head == nil { - return nil - } - i := il.head.it - il.head = il.head.next - if il.head == nil { - il.tail = nil - } - return i -} - -func (il *itemList) dequeueAll() *itemNode { - h := il.head - il.head, il.tail = nil, nil - return h -} - -func (il *itemList) isEmpty() bool { - return il.head == nil -} - -// The following defines various control items which could flow through -// the control buffer of transport. They represent different aspects of -// control tasks, e.g., flow control, settings, streaming resetting, etc. - -// maxQueuedTransportResponseFrames is the most queued "transport response" -// frames we will buffer before preventing new reads from occurring on the -// transport. These are control frames sent in response to client requests, -// such as RST_STREAM due to bad headers or settings acks. -const maxQueuedTransportResponseFrames = 50 - -type cbItem interface { - isTransportResponseFrame() bool -} - -// registerStream is used to register an incoming stream with loopy writer. -type registerStream struct { - streamID uint32 - wq *writeQuota -} - -func (*registerStream) isTransportResponseFrame() bool { return false } - -// headerFrame is also used to register stream on the client-side. -type headerFrame struct { - streamID uint32 - hf []hpack.HeaderField - endStream bool // Valid on server side. - initStream func(uint32) error // Used only on the client side. - onWrite func() - wq *writeQuota // write quota for the stream created. - cleanup *cleanupStream // Valid on the server side. - onOrphaned func(error) // Valid on client-side -} - -func (h *headerFrame) isTransportResponseFrame() bool { - return h.cleanup != nil && h.cleanup.rst // Results in a RST_STREAM -} - -type cleanupStream struct { - streamID uint32 - rst bool - rstCode http2.ErrCode - onWrite func() -} - -func (c *cleanupStream) isTransportResponseFrame() bool { return c.rst } // Results in a RST_STREAM - -type earlyAbortStream struct { - httpStatus uint32 - streamID uint32 - contentSubtype string - status *status.Status - rst bool -} - -func (*earlyAbortStream) isTransportResponseFrame() bool { return false } - -type dataFrame struct { - streamID uint32 - endStream bool - h []byte - d []byte - // onEachWrite is called every time - // a part of d is written out. - onEachWrite func() -} - -func (*dataFrame) isTransportResponseFrame() bool { return false } - -type incomingWindowUpdate struct { - streamID uint32 - increment uint32 -} - -func (*incomingWindowUpdate) isTransportResponseFrame() bool { return false } - -type outgoingWindowUpdate struct { - streamID uint32 - increment uint32 -} - -func (*outgoingWindowUpdate) isTransportResponseFrame() bool { - return false // window updates are throttled by thresholds -} - -type incomingSettings struct { - ss []http2.Setting -} - -func (*incomingSettings) isTransportResponseFrame() bool { return true } // Results in a settings ACK - -type outgoingSettings struct { - ss []http2.Setting -} - -func (*outgoingSettings) isTransportResponseFrame() bool { return false } - -type incomingGoAway struct { -} - -func (*incomingGoAway) isTransportResponseFrame() bool { return false } - -type goAway struct { - code http2.ErrCode - debugData []byte - headsUp bool - closeConn error // if set, loopyWriter will exit, resulting in conn closure -} - -func (*goAway) isTransportResponseFrame() bool { return false } - -type ping struct { - ack bool - data [8]byte -} - -func (*ping) isTransportResponseFrame() bool { return true } - -type outFlowControlSizeRequest struct { - resp chan uint32 -} - -func (*outFlowControlSizeRequest) isTransportResponseFrame() bool { return false } - -// closeConnection is an instruction to tell the loopy writer to flush the -// framer and exit, which will cause the transport's connection to be closed -// (by the client or server). The transport itself will close after the reader -// encounters the EOF caused by the connection closure. -type closeConnection struct{} - -func (closeConnection) isTransportResponseFrame() bool { return false } - -type outStreamState int - -const ( - active outStreamState = iota - empty - waitingOnStreamQuota -) - -type outStream struct { - id uint32 - state outStreamState - itl *itemList - bytesOutStanding int - wq *writeQuota - - next *outStream - prev *outStream -} - -func (s *outStream) deleteSelf() { - if s.prev != nil { - s.prev.next = s.next - } - if s.next != nil { - s.next.prev = s.prev - } - s.next, s.prev = nil, nil -} - -type outStreamList struct { - // Following are sentinel objects that mark the - // beginning and end of the list. They do not - // contain any item lists. All valid objects are - // inserted in between them. - // This is needed so that an outStream object can - // deleteSelf() in O(1) time without knowing which - // list it belongs to. - head *outStream - tail *outStream -} - -func newOutStreamList() *outStreamList { - head, tail := new(outStream), new(outStream) - head.next = tail - tail.prev = head - return &outStreamList{ - head: head, - tail: tail, - } -} - -func (l *outStreamList) enqueue(s *outStream) { - e := l.tail.prev - e.next = s - s.prev = e - s.next = l.tail - l.tail.prev = s -} - -// remove from the beginning of the list. -func (l *outStreamList) dequeue() *outStream { - b := l.head.next - if b == l.tail { - return nil - } - b.deleteSelf() - return b -} - -// controlBuffer is a way to pass information to loopy. -// Information is passed as specific struct types called control frames. -// A control frame not only represents data, messages or headers to be sent out -// but can also be used to instruct loopy to update its internal state. -// It shouldn't be confused with an HTTP2 frame, although some of the control frames -// like dataFrame and headerFrame do go out on wire as HTTP2 frames. -type controlBuffer struct { - ch chan struct{} - done <-chan struct{} - mu sync.Mutex - consumerWaiting bool - list *itemList - err error - - // transportResponseFrames counts the number of queued items that represent - // the response of an action initiated by the peer. trfChan is created - // when transportResponseFrames >= maxQueuedTransportResponseFrames and is - // closed and nilled when transportResponseFrames drops below the - // threshold. Both fields are protected by mu. - transportResponseFrames int - trfChan atomic.Value // chan struct{} -} - -func newControlBuffer(done <-chan struct{}) *controlBuffer { - return &controlBuffer{ - ch: make(chan struct{}, 1), - list: &itemList{}, - done: done, - } -} - -// throttle blocks if there are too many incomingSettings/cleanupStreams in the -// controlbuf. -func (c *controlBuffer) throttle() { - ch, _ := c.trfChan.Load().(chan struct{}) - if ch != nil { - select { - case <-ch: - case <-c.done: - } - } -} - -func (c *controlBuffer) put(it cbItem) error { - _, err := c.executeAndPut(nil, it) - return err -} - -func (c *controlBuffer) executeAndPut(f func(it any) bool, it cbItem) (bool, error) { - var wakeUp bool - c.mu.Lock() - if c.err != nil { - c.mu.Unlock() - return false, c.err - } - if f != nil { - if !f(it) { // f wasn't successful - c.mu.Unlock() - return false, nil - } - } - if c.consumerWaiting { - wakeUp = true - c.consumerWaiting = false - } - c.list.enqueue(it) - if it.isTransportResponseFrame() { - c.transportResponseFrames++ - if c.transportResponseFrames == maxQueuedTransportResponseFrames { - // We are adding the frame that puts us over the threshold; create - // a throttling channel. - c.trfChan.Store(make(chan struct{})) - } - } - c.mu.Unlock() - if wakeUp { - select { - case c.ch <- struct{}{}: - default: - } - } - return true, nil -} - -// Note argument f should never be nil. -func (c *controlBuffer) execute(f func(it any) bool, it any) (bool, error) { - c.mu.Lock() - if c.err != nil { - c.mu.Unlock() - return false, c.err - } - if !f(it) { // f wasn't successful - c.mu.Unlock() - return false, nil - } - c.mu.Unlock() - return true, nil -} - -func (c *controlBuffer) get(block bool) (any, error) { - for { - c.mu.Lock() - if c.err != nil { - c.mu.Unlock() - return nil, c.err - } - if !c.list.isEmpty() { - h := c.list.dequeue().(cbItem) - if h.isTransportResponseFrame() { - if c.transportResponseFrames == maxQueuedTransportResponseFrames { - // We are removing the frame that put us over the - // threshold; close and clear the throttling channel. - ch := c.trfChan.Load().(chan struct{}) - close(ch) - c.trfChan.Store((chan struct{})(nil)) - } - c.transportResponseFrames-- - } - c.mu.Unlock() - return h, nil - } - if !block { - c.mu.Unlock() - return nil, nil - } - c.consumerWaiting = true - c.mu.Unlock() - select { - case <-c.ch: - case <-c.done: - return nil, errors.New("transport closed by client") - } - } -} - -func (c *controlBuffer) finish() { - c.mu.Lock() - if c.err != nil { - c.mu.Unlock() - return - } - c.err = ErrConnClosing - // There may be headers for streams in the control buffer. - // These streams need to be cleaned out since the transport - // is still not aware of these yet. - for head := c.list.dequeueAll(); head != nil; head = head.next { - hdr, ok := head.it.(*headerFrame) - if !ok { - continue - } - if hdr.onOrphaned != nil { // It will be nil on the server-side. - hdr.onOrphaned(ErrConnClosing) - } - } - // In case throttle() is currently in flight, it needs to be unblocked. - // Otherwise, the transport may not close, since the transport is closed by - // the reader encountering the connection error. - ch, _ := c.trfChan.Load().(chan struct{}) - if ch != nil { - close(ch) - } - c.trfChan.Store((chan struct{})(nil)) - c.mu.Unlock() -} - -type side int - -const ( - clientSide side = iota - serverSide -) - -// Loopy receives frames from the control buffer. -// Each frame is handled individually; most of the work done by loopy goes -// into handling data frames. Loopy maintains a queue of active streams, and each -// stream maintains a queue of data frames; as loopy receives data frames -// it gets added to the queue of the relevant stream. -// Loopy goes over this list of active streams by processing one node every iteration, -// thereby closely resemebling to a round-robin scheduling over all streams. While -// processing a stream, loopy writes out data bytes from this stream capped by the min -// of http2MaxFrameLen, connection-level flow control and stream-level flow control. -type loopyWriter struct { - side side - cbuf *controlBuffer - sendQuota uint32 - oiws uint32 // outbound initial window size. - // estdStreams is map of all established streams that are not cleaned-up yet. - // On client-side, this is all streams whose headers were sent out. - // On server-side, this is all streams whose headers were received. - estdStreams map[uint32]*outStream // Established streams. - // activeStreams is a linked-list of all streams that have data to send and some - // stream-level flow control quota. - // Each of these streams internally have a list of data items(and perhaps trailers - // on the server-side) to be sent out. - activeStreams *outStreamList - framer *framer - hBuf *bytes.Buffer // The buffer for HPACK encoding. - hEnc *hpack.Encoder // HPACK encoder. - bdpEst *bdpEstimator - draining bool - conn net.Conn - logger *grpclog.PrefixLogger - - // Side-specific handlers - ssGoAwayHandler func(*goAway) (bool, error) -} - -func newLoopyWriter(s side, fr *framer, cbuf *controlBuffer, bdpEst *bdpEstimator, conn net.Conn, logger *grpclog.PrefixLogger) *loopyWriter { - var buf bytes.Buffer - l := &loopyWriter{ - side: s, - cbuf: cbuf, - sendQuota: defaultWindowSize, - oiws: defaultWindowSize, - estdStreams: make(map[uint32]*outStream), - activeStreams: newOutStreamList(), - framer: fr, - hBuf: &buf, - hEnc: hpack.NewEncoder(&buf), - bdpEst: bdpEst, - conn: conn, - logger: logger, - } - return l -} - -const minBatchSize = 1000 - -// run should be run in a separate goroutine. -// It reads control frames from controlBuf and processes them by: -// 1. Updating loopy's internal state, or/and -// 2. Writing out HTTP2 frames on the wire. -// -// Loopy keeps all active streams with data to send in a linked-list. -// All streams in the activeStreams linked-list must have both: -// 1. Data to send, and -// 2. Stream level flow control quota available. -// -// In each iteration of run loop, other than processing the incoming control -// frame, loopy calls processData, which processes one node from the -// activeStreams linked-list. This results in writing of HTTP2 frames into an -// underlying write buffer. When there's no more control frames to read from -// controlBuf, loopy flushes the write buffer. As an optimization, to increase -// the batch size for each flush, loopy yields the processor, once if the batch -// size is too low to give stream goroutines a chance to fill it up. -// -// Upon exiting, if the error causing the exit is not an I/O error, run() -// flushes the underlying connection. The connection is always left open to -// allow different closing behavior on the client and server. -func (l *loopyWriter) run() (err error) { - defer func() { - if l.logger.V(logLevel) { - l.logger.Infof("loopyWriter exiting with error: %v", err) - } - if !isIOError(err) { - l.framer.writer.Flush() - } - l.cbuf.finish() - }() - for { - it, err := l.cbuf.get(true) - if err != nil { - return err - } - if err = l.handle(it); err != nil { - return err - } - if _, err = l.processData(); err != nil { - return err - } - gosched := true - hasdata: - for { - it, err := l.cbuf.get(false) - if err != nil { - return err - } - if it != nil { - if err = l.handle(it); err != nil { - return err - } - if _, err = l.processData(); err != nil { - return err - } - continue hasdata - } - isEmpty, err := l.processData() - if err != nil { - return err - } - if !isEmpty { - continue hasdata - } - if gosched { - gosched = false - if l.framer.writer.offset < minBatchSize { - runtime.Gosched() - continue hasdata - } - } - l.framer.writer.Flush() - break hasdata - } - } -} - -func (l *loopyWriter) outgoingWindowUpdateHandler(w *outgoingWindowUpdate) error { - return l.framer.fr.WriteWindowUpdate(w.streamID, w.increment) -} - -func (l *loopyWriter) incomingWindowUpdateHandler(w *incomingWindowUpdate) { - // Otherwise update the quota. - if w.streamID == 0 { - l.sendQuota += w.increment - return - } - // Find the stream and update it. - if str, ok := l.estdStreams[w.streamID]; ok { - str.bytesOutStanding -= int(w.increment) - if strQuota := int(l.oiws) - str.bytesOutStanding; strQuota > 0 && str.state == waitingOnStreamQuota { - str.state = active - l.activeStreams.enqueue(str) - return - } - } -} - -func (l *loopyWriter) outgoingSettingsHandler(s *outgoingSettings) error { - return l.framer.fr.WriteSettings(s.ss...) -} - -func (l *loopyWriter) incomingSettingsHandler(s *incomingSettings) error { - l.applySettings(s.ss) - return l.framer.fr.WriteSettingsAck() -} - -func (l *loopyWriter) registerStreamHandler(h *registerStream) { - str := &outStream{ - id: h.streamID, - state: empty, - itl: &itemList{}, - wq: h.wq, - } - l.estdStreams[h.streamID] = str -} - -func (l *loopyWriter) headerHandler(h *headerFrame) error { - if l.side == serverSide { - str, ok := l.estdStreams[h.streamID] - if !ok { - if l.logger.V(logLevel) { - l.logger.Infof("Unrecognized streamID %d in loopyWriter", h.streamID) - } - return nil - } - // Case 1.A: Server is responding back with headers. - if !h.endStream { - return l.writeHeader(h.streamID, h.endStream, h.hf, h.onWrite) - } - // else: Case 1.B: Server wants to close stream. - - if str.state != empty { // either active or waiting on stream quota. - // add it str's list of items. - str.itl.enqueue(h) - return nil - } - if err := l.writeHeader(h.streamID, h.endStream, h.hf, h.onWrite); err != nil { - return err - } - return l.cleanupStreamHandler(h.cleanup) - } - // Case 2: Client wants to originate stream. - str := &outStream{ - id: h.streamID, - state: empty, - itl: &itemList{}, - wq: h.wq, - } - return l.originateStream(str, h) -} - -func (l *loopyWriter) originateStream(str *outStream, hdr *headerFrame) error { - // l.draining is set when handling GoAway. In which case, we want to avoid - // creating new streams. - if l.draining { - // TODO: provide a better error with the reason we are in draining. - hdr.onOrphaned(errStreamDrain) - return nil - } - if err := hdr.initStream(str.id); err != nil { - return err - } - if err := l.writeHeader(str.id, hdr.endStream, hdr.hf, hdr.onWrite); err != nil { - return err - } - l.estdStreams[str.id] = str - return nil -} - -func (l *loopyWriter) writeHeader(streamID uint32, endStream bool, hf []hpack.HeaderField, onWrite func()) error { - if onWrite != nil { - onWrite() - } - l.hBuf.Reset() - for _, f := range hf { - if err := l.hEnc.WriteField(f); err != nil { - if l.logger.V(logLevel) { - l.logger.Warningf("Encountered error while encoding headers: %v", err) - } - } - } - var ( - err error - endHeaders, first bool - ) - first = true - for !endHeaders { - size := l.hBuf.Len() - if size > http2MaxFrameLen { - size = http2MaxFrameLen - } else { - endHeaders = true - } - if first { - first = false - err = l.framer.fr.WriteHeaders(http2.HeadersFrameParam{ - StreamID: streamID, - BlockFragment: l.hBuf.Next(size), - EndStream: endStream, - EndHeaders: endHeaders, - }) - } else { - err = l.framer.fr.WriteContinuation( - streamID, - endHeaders, - l.hBuf.Next(size), - ) - } - if err != nil { - return err - } - } - return nil -} - -func (l *loopyWriter) preprocessData(df *dataFrame) { - str, ok := l.estdStreams[df.streamID] - if !ok { - return - } - // If we got data for a stream it means that - // stream was originated and the headers were sent out. - str.itl.enqueue(df) - if str.state == empty { - str.state = active - l.activeStreams.enqueue(str) - } -} - -func (l *loopyWriter) pingHandler(p *ping) error { - if !p.ack { - l.bdpEst.timesnap(p.data) - } - return l.framer.fr.WritePing(p.ack, p.data) - -} - -func (l *loopyWriter) outFlowControlSizeRequestHandler(o *outFlowControlSizeRequest) { - o.resp <- l.sendQuota -} - -func (l *loopyWriter) cleanupStreamHandler(c *cleanupStream) error { - c.onWrite() - if str, ok := l.estdStreams[c.streamID]; ok { - // On the server side it could be a trailers-only response or - // a RST_STREAM before stream initialization thus the stream might - // not be established yet. - delete(l.estdStreams, c.streamID) - str.deleteSelf() - } - if c.rst { // If RST_STREAM needs to be sent. - if err := l.framer.fr.WriteRSTStream(c.streamID, c.rstCode); err != nil { - return err - } - } - if l.draining && len(l.estdStreams) == 0 { - // Flush and close the connection; we are done with it. - return errors.New("finished processing active streams while in draining mode") - } - return nil -} - -func (l *loopyWriter) earlyAbortStreamHandler(eas *earlyAbortStream) error { - if l.side == clientSide { - return errors.New("earlyAbortStream not handled on client") - } - // In case the caller forgets to set the http status, default to 200. - if eas.httpStatus == 0 { - eas.httpStatus = 200 - } - headerFields := []hpack.HeaderField{ - {Name: ":status", Value: strconv.Itoa(int(eas.httpStatus))}, - {Name: "content-type", Value: grpcutil.ContentType(eas.contentSubtype)}, - {Name: "grpc-status", Value: strconv.Itoa(int(eas.status.Code()))}, - {Name: "grpc-message", Value: encodeGrpcMessage(eas.status.Message())}, - } - - if err := l.writeHeader(eas.streamID, true, headerFields, nil); err != nil { - return err - } - if eas.rst { - if err := l.framer.fr.WriteRSTStream(eas.streamID, http2.ErrCodeNo); err != nil { - return err - } - } - return nil -} - -func (l *loopyWriter) incomingGoAwayHandler(*incomingGoAway) error { - if l.side == clientSide { - l.draining = true - if len(l.estdStreams) == 0 { - // Flush and close the connection; we are done with it. - return errors.New("received GOAWAY with no active streams") - } - } - return nil -} - -func (l *loopyWriter) goAwayHandler(g *goAway) error { - // Handling of outgoing GoAway is very specific to side. - if l.ssGoAwayHandler != nil { - draining, err := l.ssGoAwayHandler(g) - if err != nil { - return err - } - l.draining = draining - } - return nil -} - -func (l *loopyWriter) handle(i any) error { - switch i := i.(type) { - case *incomingWindowUpdate: - l.incomingWindowUpdateHandler(i) - case *outgoingWindowUpdate: - return l.outgoingWindowUpdateHandler(i) - case *incomingSettings: - return l.incomingSettingsHandler(i) - case *outgoingSettings: - return l.outgoingSettingsHandler(i) - case *headerFrame: - return l.headerHandler(i) - case *registerStream: - l.registerStreamHandler(i) - case *cleanupStream: - return l.cleanupStreamHandler(i) - case *earlyAbortStream: - return l.earlyAbortStreamHandler(i) - case *incomingGoAway: - return l.incomingGoAwayHandler(i) - case *dataFrame: - l.preprocessData(i) - case *ping: - return l.pingHandler(i) - case *goAway: - return l.goAwayHandler(i) - case *outFlowControlSizeRequest: - l.outFlowControlSizeRequestHandler(i) - case closeConnection: - // Just return a non-I/O error and run() will flush and close the - // connection. - return ErrConnClosing - default: - return fmt.Errorf("transport: unknown control message type %T", i) - } - return nil -} - -func (l *loopyWriter) applySettings(ss []http2.Setting) { - for _, s := range ss { - switch s.ID { - case http2.SettingInitialWindowSize: - o := l.oiws - l.oiws = s.Val - if o < l.oiws { - // If the new limit is greater make all depleted streams active. - for _, stream := range l.estdStreams { - if stream.state == waitingOnStreamQuota { - stream.state = active - l.activeStreams.enqueue(stream) - } - } - } - case http2.SettingHeaderTableSize: - updateHeaderTblSize(l.hEnc, s.Val) - } - } -} - -// processData removes the first stream from active streams, writes out at most 16KB -// of its data and then puts it at the end of activeStreams if there's still more data -// to be sent and stream has some stream-level flow control. -func (l *loopyWriter) processData() (bool, error) { - if l.sendQuota == 0 { - return true, nil - } - str := l.activeStreams.dequeue() // Remove the first stream. - if str == nil { - return true, nil - } - dataItem := str.itl.peek().(*dataFrame) // Peek at the first data item this stream. - // A data item is represented by a dataFrame, since it later translates into - // multiple HTTP2 data frames. - // Every dataFrame has two buffers; h that keeps grpc-message header and d that is actual data. - // As an optimization to keep wire traffic low, data from d is copied to h to make as big as the - // maximum possible HTTP2 frame size. - - if len(dataItem.h) == 0 && len(dataItem.d) == 0 { // Empty data frame - // Client sends out empty data frame with endStream = true - if err := l.framer.fr.WriteData(dataItem.streamID, dataItem.endStream, nil); err != nil { - return false, err - } - str.itl.dequeue() // remove the empty data item from stream - if str.itl.isEmpty() { - str.state = empty - } else if trailer, ok := str.itl.peek().(*headerFrame); ok { // the next item is trailers. - if err := l.writeHeader(trailer.streamID, trailer.endStream, trailer.hf, trailer.onWrite); err != nil { - return false, err - } - if err := l.cleanupStreamHandler(trailer.cleanup); err != nil { - return false, err - } - } else { - l.activeStreams.enqueue(str) - } - return false, nil - } - var ( - buf []byte - ) - // Figure out the maximum size we can send - maxSize := http2MaxFrameLen - if strQuota := int(l.oiws) - str.bytesOutStanding; strQuota <= 0 { // stream-level flow control. - str.state = waitingOnStreamQuota - return false, nil - } else if maxSize > strQuota { - maxSize = strQuota - } - if maxSize > int(l.sendQuota) { // connection-level flow control. - maxSize = int(l.sendQuota) - } - // Compute how much of the header and data we can send within quota and max frame length - hSize := min(maxSize, len(dataItem.h)) - dSize := min(maxSize-hSize, len(dataItem.d)) - if hSize != 0 { - if dSize == 0 { - buf = dataItem.h - } else { - // We can add some data to grpc message header to distribute bytes more equally across frames. - // Copy on the stack to avoid generating garbage - var localBuf [http2MaxFrameLen]byte - copy(localBuf[:hSize], dataItem.h) - copy(localBuf[hSize:], dataItem.d[:dSize]) - buf = localBuf[:hSize+dSize] - } - } else { - buf = dataItem.d - } - - size := hSize + dSize - - // Now that outgoing flow controls are checked we can replenish str's write quota - str.wq.replenish(size) - var endStream bool - // If this is the last data message on this stream and all of it can be written in this iteration. - if dataItem.endStream && len(dataItem.h)+len(dataItem.d) <= size { - endStream = true - } - if dataItem.onEachWrite != nil { - dataItem.onEachWrite() - } - if err := l.framer.fr.WriteData(dataItem.streamID, endStream, buf[:size]); err != nil { - return false, err - } - str.bytesOutStanding += size - l.sendQuota -= uint32(size) - dataItem.h = dataItem.h[hSize:] - dataItem.d = dataItem.d[dSize:] - - if len(dataItem.h) == 0 && len(dataItem.d) == 0 { // All the data from that message was written out. - str.itl.dequeue() - } - if str.itl.isEmpty() { - str.state = empty - } else if trailer, ok := str.itl.peek().(*headerFrame); ok { // The next item is trailers. - if err := l.writeHeader(trailer.streamID, trailer.endStream, trailer.hf, trailer.onWrite); err != nil { - return false, err - } - if err := l.cleanupStreamHandler(trailer.cleanup); err != nil { - return false, err - } - } else if int(l.oiws)-str.bytesOutStanding <= 0 { // Ran out of stream quota. - str.state = waitingOnStreamQuota - } else { // Otherwise add it back to the list of active streams. - l.activeStreams.enqueue(str) - } - return false, nil -} - -func min(a, b int) int { - if a < b { - return a - } - return b -} diff --git a/vendor/google.golang.org/grpc/internal/transport/defaults.go b/vendor/google.golang.org/grpc/internal/transport/defaults.go deleted file mode 100644 index bc8ee0747..000000000 --- a/vendor/google.golang.org/grpc/internal/transport/defaults.go +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package transport - -import ( - "math" - "time" -) - -const ( - // The default value of flow control window size in HTTP2 spec. - defaultWindowSize = 65535 - // The initial window size for flow control. - initialWindowSize = defaultWindowSize // for an RPC - infinity = time.Duration(math.MaxInt64) - defaultClientKeepaliveTime = infinity - defaultClientKeepaliveTimeout = 20 * time.Second - defaultMaxStreamsClient = 100 - defaultMaxConnectionIdle = infinity - defaultMaxConnectionAge = infinity - defaultMaxConnectionAgeGrace = infinity - defaultServerKeepaliveTime = 2 * time.Hour - defaultServerKeepaliveTimeout = 20 * time.Second - defaultKeepalivePolicyMinTime = 5 * time.Minute - // max window limit set by HTTP2 Specs. - maxWindowSize = math.MaxInt32 - // defaultWriteQuota is the default value for number of data - // bytes that each stream can schedule before some of it being - // flushed out. - defaultWriteQuota = 64 * 1024 - defaultClientMaxHeaderListSize = uint32(16 << 20) - defaultServerMaxHeaderListSize = uint32(16 << 20) -) - -// MaxStreamID is the upper bound for the stream ID before the current -// transport gracefully closes and new transport is created for subsequent RPCs. -// This is set to 75% of 2^31-1. Streams are identified with an unsigned 31-bit -// integer. It's exported so that tests can override it. -var MaxStreamID = uint32(math.MaxInt32 * 3 / 4) diff --git a/vendor/google.golang.org/grpc/internal/transport/flowcontrol.go b/vendor/google.golang.org/grpc/internal/transport/flowcontrol.go deleted file mode 100644 index 97198c515..000000000 --- a/vendor/google.golang.org/grpc/internal/transport/flowcontrol.go +++ /dev/null @@ -1,215 +0,0 @@ -/* - * - * Copyright 2014 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package transport - -import ( - "fmt" - "math" - "sync" - "sync/atomic" -) - -// writeQuota is a soft limit on the amount of data a stream can -// schedule before some of it is written out. -type writeQuota struct { - quota int32 - // get waits on read from when quota goes less than or equal to zero. - // replenish writes on it when quota goes positive again. - ch chan struct{} - // done is triggered in error case. - done <-chan struct{} - // replenish is called by loopyWriter to give quota back to. - // It is implemented as a field so that it can be updated - // by tests. - replenish func(n int) -} - -func newWriteQuota(sz int32, done <-chan struct{}) *writeQuota { - w := &writeQuota{ - quota: sz, - ch: make(chan struct{}, 1), - done: done, - } - w.replenish = w.realReplenish - return w -} - -func (w *writeQuota) get(sz int32) error { - for { - if atomic.LoadInt32(&w.quota) > 0 { - atomic.AddInt32(&w.quota, -sz) - return nil - } - select { - case <-w.ch: - continue - case <-w.done: - return errStreamDone - } - } -} - -func (w *writeQuota) realReplenish(n int) { - sz := int32(n) - a := atomic.AddInt32(&w.quota, sz) - b := a - sz - if b <= 0 && a > 0 { - select { - case w.ch <- struct{}{}: - default: - } - } -} - -type trInFlow struct { - limit uint32 - unacked uint32 - effectiveWindowSize uint32 -} - -func (f *trInFlow) newLimit(n uint32) uint32 { - d := n - f.limit - f.limit = n - f.updateEffectiveWindowSize() - return d -} - -func (f *trInFlow) onData(n uint32) uint32 { - f.unacked += n - if f.unacked >= f.limit/4 { - w := f.unacked - f.unacked = 0 - f.updateEffectiveWindowSize() - return w - } - f.updateEffectiveWindowSize() - return 0 -} - -func (f *trInFlow) reset() uint32 { - w := f.unacked - f.unacked = 0 - f.updateEffectiveWindowSize() - return w -} - -func (f *trInFlow) updateEffectiveWindowSize() { - atomic.StoreUint32(&f.effectiveWindowSize, f.limit-f.unacked) -} - -func (f *trInFlow) getSize() uint32 { - return atomic.LoadUint32(&f.effectiveWindowSize) -} - -// TODO(mmukhi): Simplify this code. -// inFlow deals with inbound flow control -type inFlow struct { - mu sync.Mutex - // The inbound flow control limit for pending data. - limit uint32 - // pendingData is the overall data which have been received but not been - // consumed by applications. - pendingData uint32 - // The amount of data the application has consumed but grpc has not sent - // window update for them. Used to reduce window update frequency. - pendingUpdate uint32 - // delta is the extra window update given by receiver when an application - // is reading data bigger in size than the inFlow limit. - delta uint32 -} - -// newLimit updates the inflow window to a new value n. -// It assumes that n is always greater than the old limit. -func (f *inFlow) newLimit(n uint32) { - f.mu.Lock() - f.limit = n - f.mu.Unlock() -} - -func (f *inFlow) maybeAdjust(n uint32) uint32 { - if n > uint32(math.MaxInt32) { - n = uint32(math.MaxInt32) - } - f.mu.Lock() - defer f.mu.Unlock() - // estSenderQuota is the receiver's view of the maximum number of bytes the sender - // can send without a window update. - estSenderQuota := int32(f.limit - (f.pendingData + f.pendingUpdate)) - // estUntransmittedData is the maximum number of bytes the sends might not have put - // on the wire yet. A value of 0 or less means that we have already received all or - // more bytes than the application is requesting to read. - estUntransmittedData := int32(n - f.pendingData) // Casting into int32 since it could be negative. - // This implies that unless we send a window update, the sender won't be able to send all the bytes - // for this message. Therefore we must send an update over the limit since there's an active read - // request from the application. - if estUntransmittedData > estSenderQuota { - // Sender's window shouldn't go more than 2^31 - 1 as specified in the HTTP spec. - if f.limit+n > maxWindowSize { - f.delta = maxWindowSize - f.limit - } else { - // Send a window update for the whole message and not just the difference between - // estUntransmittedData and estSenderQuota. This will be helpful in case the message - // is padded; We will fallback on the current available window(at least a 1/4th of the limit). - f.delta = n - } - return f.delta - } - return 0 -} - -// onData is invoked when some data frame is received. It updates pendingData. -func (f *inFlow) onData(n uint32) error { - f.mu.Lock() - f.pendingData += n - if f.pendingData+f.pendingUpdate > f.limit+f.delta { - limit := f.limit - rcvd := f.pendingData + f.pendingUpdate - f.mu.Unlock() - return fmt.Errorf("received %d-bytes data exceeding the limit %d bytes", rcvd, limit) - } - f.mu.Unlock() - return nil -} - -// onRead is invoked when the application reads the data. It returns the window size -// to be sent to the peer. -func (f *inFlow) onRead(n uint32) uint32 { - f.mu.Lock() - if f.pendingData == 0 { - f.mu.Unlock() - return 0 - } - f.pendingData -= n - if n > f.delta { - n -= f.delta - f.delta = 0 - } else { - f.delta -= n - n = 0 - } - f.pendingUpdate += n - if f.pendingUpdate >= f.limit/4 { - wu := f.pendingUpdate - f.pendingUpdate = 0 - f.mu.Unlock() - return wu - } - f.mu.Unlock() - return 0 -} diff --git a/vendor/google.golang.org/grpc/internal/transport/handler_server.go b/vendor/google.golang.org/grpc/internal/transport/handler_server.go deleted file mode 100644 index 4a3ddce29..000000000 --- a/vendor/google.golang.org/grpc/internal/transport/handler_server.go +++ /dev/null @@ -1,489 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// This file is the implementation of a gRPC server using HTTP/2 which -// uses the standard Go http2 Server implementation (via the -// http.Handler interface), rather than speaking low-level HTTP/2 -// frames itself. It is the implementation of *grpc.Server.ServeHTTP. - -package transport - -import ( - "bytes" - "context" - "errors" - "fmt" - "io" - "net" - "net/http" - "strings" - "sync" - "time" - - "golang.org/x/net/http2" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/credentials" - "google.golang.org/grpc/internal/grpclog" - "google.golang.org/grpc/internal/grpcutil" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/peer" - "google.golang.org/grpc/stats" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" -) - -// NewServerHandlerTransport returns a ServerTransport handling gRPC from -// inside an http.Handler, or writes an HTTP error to w and returns an error. -// It requires that the http Server supports HTTP/2. -func NewServerHandlerTransport(w http.ResponseWriter, r *http.Request, stats []stats.Handler) (ServerTransport, error) { - if r.Method != http.MethodPost { - w.Header().Set("Allow", http.MethodPost) - msg := fmt.Sprintf("invalid gRPC request method %q", r.Method) - http.Error(w, msg, http.StatusMethodNotAllowed) - return nil, errors.New(msg) - } - contentType := r.Header.Get("Content-Type") - // TODO: do we assume contentType is lowercase? we did before - contentSubtype, validContentType := grpcutil.ContentSubtype(contentType) - if !validContentType { - msg := fmt.Sprintf("invalid gRPC request content-type %q", contentType) - http.Error(w, msg, http.StatusUnsupportedMediaType) - return nil, errors.New(msg) - } - if r.ProtoMajor != 2 { - msg := "gRPC requires HTTP/2" - http.Error(w, msg, http.StatusHTTPVersionNotSupported) - return nil, errors.New(msg) - } - if _, ok := w.(http.Flusher); !ok { - msg := "gRPC requires a ResponseWriter supporting http.Flusher" - http.Error(w, msg, http.StatusInternalServerError) - return nil, errors.New(msg) - } - - var localAddr net.Addr - if la := r.Context().Value(http.LocalAddrContextKey); la != nil { - localAddr, _ = la.(net.Addr) - } - var authInfo credentials.AuthInfo - if r.TLS != nil { - authInfo = credentials.TLSInfo{State: *r.TLS, CommonAuthInfo: credentials.CommonAuthInfo{SecurityLevel: credentials.PrivacyAndIntegrity}} - } - p := peer.Peer{ - Addr: strAddr(r.RemoteAddr), - LocalAddr: localAddr, - AuthInfo: authInfo, - } - st := &serverHandlerTransport{ - rw: w, - req: r, - closedCh: make(chan struct{}), - writes: make(chan func()), - peer: p, - contentType: contentType, - contentSubtype: contentSubtype, - stats: stats, - } - st.logger = prefixLoggerForServerHandlerTransport(st) - - if v := r.Header.Get("grpc-timeout"); v != "" { - to, err := decodeTimeout(v) - if err != nil { - msg := fmt.Sprintf("malformed grpc-timeout: %v", err) - http.Error(w, msg, http.StatusBadRequest) - return nil, status.Error(codes.Internal, msg) - } - st.timeoutSet = true - st.timeout = to - } - - metakv := []string{"content-type", contentType} - if r.Host != "" { - metakv = append(metakv, ":authority", r.Host) - } - for k, vv := range r.Header { - k = strings.ToLower(k) - if isReservedHeader(k) && !isWhitelistedHeader(k) { - continue - } - for _, v := range vv { - v, err := decodeMetadataHeader(k, v) - if err != nil { - msg := fmt.Sprintf("malformed binary metadata %q in header %q: %v", v, k, err) - http.Error(w, msg, http.StatusBadRequest) - return nil, status.Error(codes.Internal, msg) - } - metakv = append(metakv, k, v) - } - } - st.headerMD = metadata.Pairs(metakv...) - - return st, nil -} - -// serverHandlerTransport is an implementation of ServerTransport -// which replies to exactly one gRPC request (exactly one HTTP request), -// using the net/http.Handler interface. This http.Handler is guaranteed -// at this point to be speaking over HTTP/2, so it's able to speak valid -// gRPC. -type serverHandlerTransport struct { - rw http.ResponseWriter - req *http.Request - timeoutSet bool - timeout time.Duration - - headerMD metadata.MD - - peer peer.Peer - - closeOnce sync.Once - closedCh chan struct{} // closed on Close - - // writes is a channel of code to run serialized in the - // ServeHTTP (HandleStreams) goroutine. The channel is closed - // when WriteStatus is called. - writes chan func() - - // block concurrent WriteStatus calls - // e.g. grpc/(*serverStream).SendMsg/RecvMsg - writeStatusMu sync.Mutex - - // we just mirror the request content-type - contentType string - // we store both contentType and contentSubtype so we don't keep recreating them - // TODO make sure this is consistent across handler_server and http2_server - contentSubtype string - - stats []stats.Handler - logger *grpclog.PrefixLogger -} - -func (ht *serverHandlerTransport) Close(err error) { - ht.closeOnce.Do(func() { - if ht.logger.V(logLevel) { - ht.logger.Infof("Closing: %v", err) - } - close(ht.closedCh) - }) -} - -func (ht *serverHandlerTransport) Peer() *peer.Peer { - return &peer.Peer{ - Addr: ht.peer.Addr, - LocalAddr: ht.peer.LocalAddr, - AuthInfo: ht.peer.AuthInfo, - } -} - -// strAddr is a net.Addr backed by either a TCP "ip:port" string, or -// the empty string if unknown. -type strAddr string - -func (a strAddr) Network() string { - if a != "" { - // Per the documentation on net/http.Request.RemoteAddr, if this is - // set, it's set to the IP:port of the peer (hence, TCP): - // https://golang.org/pkg/net/http/#Request - // - // If we want to support Unix sockets later, we can - // add our own grpc-specific convention within the - // grpc codebase to set RemoteAddr to a different - // format, or probably better: we can attach it to the - // context and use that from serverHandlerTransport.RemoteAddr. - return "tcp" - } - return "" -} - -func (a strAddr) String() string { return string(a) } - -// do runs fn in the ServeHTTP goroutine. -func (ht *serverHandlerTransport) do(fn func()) error { - select { - case <-ht.closedCh: - return ErrConnClosing - case ht.writes <- fn: - return nil - } -} - -func (ht *serverHandlerTransport) WriteStatus(s *Stream, st *status.Status) error { - ht.writeStatusMu.Lock() - defer ht.writeStatusMu.Unlock() - - headersWritten := s.updateHeaderSent() - err := ht.do(func() { - if !headersWritten { - ht.writePendingHeaders(s) - } - - // And flush, in case no header or body has been sent yet. - // This forces a separation of headers and trailers if this is the - // first call (for example, in end2end tests's TestNoService). - ht.rw.(http.Flusher).Flush() - - h := ht.rw.Header() - h.Set("Grpc-Status", fmt.Sprintf("%d", st.Code())) - if m := st.Message(); m != "" { - h.Set("Grpc-Message", encodeGrpcMessage(m)) - } - - s.hdrMu.Lock() - if p := st.Proto(); p != nil && len(p.Details) > 0 { - delete(s.trailer, grpcStatusDetailsBinHeader) - stBytes, err := proto.Marshal(p) - if err != nil { - // TODO: return error instead, when callers are able to handle it. - panic(err) - } - - h.Set(grpcStatusDetailsBinHeader, encodeBinHeader(stBytes)) - } - - if len(s.trailer) > 0 { - for k, vv := range s.trailer { - // Clients don't tolerate reading restricted headers after some non restricted ones were sent. - if isReservedHeader(k) { - continue - } - for _, v := range vv { - // http2 ResponseWriter mechanism to send undeclared Trailers after - // the headers have possibly been written. - h.Add(http2.TrailerPrefix+k, encodeMetadataHeader(k, v)) - } - } - } - s.hdrMu.Unlock() - }) - - if err == nil { // transport has not been closed - // Note: The trailer fields are compressed with hpack after this call returns. - // No WireLength field is set here. - for _, sh := range ht.stats { - sh.HandleRPC(s.Context(), &stats.OutTrailer{ - Trailer: s.trailer.Copy(), - }) - } - } - ht.Close(errors.New("finished writing status")) - return err -} - -// writePendingHeaders sets common and custom headers on the first -// write call (Write, WriteHeader, or WriteStatus) -func (ht *serverHandlerTransport) writePendingHeaders(s *Stream) { - ht.writeCommonHeaders(s) - ht.writeCustomHeaders(s) -} - -// writeCommonHeaders sets common headers on the first write -// call (Write, WriteHeader, or WriteStatus). -func (ht *serverHandlerTransport) writeCommonHeaders(s *Stream) { - h := ht.rw.Header() - h["Date"] = nil // suppress Date to make tests happy; TODO: restore - h.Set("Content-Type", ht.contentType) - - // Predeclare trailers we'll set later in WriteStatus (after the body). - // This is a SHOULD in the HTTP RFC, and the way you add (known) - // Trailers per the net/http.ResponseWriter contract. - // See https://golang.org/pkg/net/http/#ResponseWriter - // and https://golang.org/pkg/net/http/#example_ResponseWriter_trailers - h.Add("Trailer", "Grpc-Status") - h.Add("Trailer", "Grpc-Message") - h.Add("Trailer", "Grpc-Status-Details-Bin") - - if s.sendCompress != "" { - h.Set("Grpc-Encoding", s.sendCompress) - } -} - -// writeCustomHeaders sets custom headers set on the stream via SetHeader -// on the first write call (Write, WriteHeader, or WriteStatus) -func (ht *serverHandlerTransport) writeCustomHeaders(s *Stream) { - h := ht.rw.Header() - - s.hdrMu.Lock() - for k, vv := range s.header { - if isReservedHeader(k) { - continue - } - for _, v := range vv { - h.Add(k, encodeMetadataHeader(k, v)) - } - } - - s.hdrMu.Unlock() -} - -func (ht *serverHandlerTransport) Write(s *Stream, hdr []byte, data []byte, opts *Options) error { - headersWritten := s.updateHeaderSent() - return ht.do(func() { - if !headersWritten { - ht.writePendingHeaders(s) - } - ht.rw.Write(hdr) - ht.rw.Write(data) - ht.rw.(http.Flusher).Flush() - }) -} - -func (ht *serverHandlerTransport) WriteHeader(s *Stream, md metadata.MD) error { - if err := s.SetHeader(md); err != nil { - return err - } - - headersWritten := s.updateHeaderSent() - err := ht.do(func() { - if !headersWritten { - ht.writePendingHeaders(s) - } - - ht.rw.WriteHeader(200) - ht.rw.(http.Flusher).Flush() - }) - - if err == nil { - for _, sh := range ht.stats { - // Note: The header fields are compressed with hpack after this call returns. - // No WireLength field is set here. - sh.HandleRPC(s.Context(), &stats.OutHeader{ - Header: md.Copy(), - Compression: s.sendCompress, - }) - } - } - return err -} - -func (ht *serverHandlerTransport) HandleStreams(ctx context.Context, startStream func(*Stream)) { - // With this transport type there will be exactly 1 stream: this HTTP request. - var cancel context.CancelFunc - if ht.timeoutSet { - ctx, cancel = context.WithTimeout(ctx, ht.timeout) - } else { - ctx, cancel = context.WithCancel(ctx) - } - - // requestOver is closed when the status has been written via WriteStatus. - requestOver := make(chan struct{}) - go func() { - select { - case <-requestOver: - case <-ht.closedCh: - case <-ht.req.Context().Done(): - } - cancel() - ht.Close(errors.New("request is done processing")) - }() - - ctx = metadata.NewIncomingContext(ctx, ht.headerMD) - req := ht.req - s := &Stream{ - id: 0, // irrelevant - ctx: ctx, - requestRead: func(int) {}, - cancel: cancel, - buf: newRecvBuffer(), - st: ht, - method: req.URL.Path, - recvCompress: req.Header.Get("grpc-encoding"), - contentSubtype: ht.contentSubtype, - headerWireLength: 0, // won't have access to header wire length until golang/go#18997. - } - s.trReader = &transportReader{ - reader: &recvBufferReader{ctx: s.ctx, ctxDone: s.ctx.Done(), recv: s.buf, freeBuffer: func(*bytes.Buffer) {}}, - windowHandler: func(int) {}, - } - - // readerDone is closed when the Body.Read-ing goroutine exits. - readerDone := make(chan struct{}) - go func() { - defer close(readerDone) - - // TODO: minimize garbage, optimize recvBuffer code/ownership - const readSize = 8196 - for buf := make([]byte, readSize); ; { - n, err := req.Body.Read(buf) - if n > 0 { - s.buf.put(recvMsg{buffer: bytes.NewBuffer(buf[:n:n])}) - buf = buf[n:] - } - if err != nil { - s.buf.put(recvMsg{err: mapRecvMsgError(err)}) - return - } - if len(buf) == 0 { - buf = make([]byte, readSize) - } - } - }() - - // startStream is provided by the *grpc.Server's serveStreams. - // It starts a goroutine serving s and exits immediately. - // The goroutine that is started is the one that then calls - // into ht, calling WriteHeader, Write, WriteStatus, Close, etc. - startStream(s) - - ht.runStream() - close(requestOver) - - // Wait for reading goroutine to finish. - req.Body.Close() - <-readerDone -} - -func (ht *serverHandlerTransport) runStream() { - for { - select { - case fn := <-ht.writes: - fn() - case <-ht.closedCh: - return - } - } -} - -func (ht *serverHandlerTransport) IncrMsgSent() {} - -func (ht *serverHandlerTransport) IncrMsgRecv() {} - -func (ht *serverHandlerTransport) Drain(debugData string) { - panic("Drain() is not implemented") -} - -// mapRecvMsgError returns the non-nil err into the appropriate -// error value as expected by callers of *grpc.parser.recvMsg. -// In particular, in can only be: -// - io.EOF -// - io.ErrUnexpectedEOF -// - of type transport.ConnectionError -// - an error from the status package -func mapRecvMsgError(err error) error { - if err == io.EOF || err == io.ErrUnexpectedEOF { - return err - } - if se, ok := err.(http2.StreamError); ok { - if code, ok := http2ErrConvTab[se.Code]; ok { - return status.Error(code, se.Error()) - } - } - if strings.Contains(err.Error(), "body closed by handler") { - return status.Error(codes.Canceled, err.Error()) - } - return connectionErrorf(true, err, err.Error()) -} diff --git a/vendor/google.golang.org/grpc/internal/transport/http2_client.go b/vendor/google.golang.org/grpc/internal/transport/http2_client.go deleted file mode 100644 index deba0c4d9..000000000 --- a/vendor/google.golang.org/grpc/internal/transport/http2_client.go +++ /dev/null @@ -1,1788 +0,0 @@ -/* - * - * Copyright 2014 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package transport - -import ( - "context" - "fmt" - "io" - "math" - "net" - "net/http" - "path/filepath" - "strconv" - "strings" - "sync" - "sync/atomic" - "time" - - "golang.org/x/net/http2" - "golang.org/x/net/http2/hpack" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/credentials" - "google.golang.org/grpc/internal" - "google.golang.org/grpc/internal/channelz" - icredentials "google.golang.org/grpc/internal/credentials" - "google.golang.org/grpc/internal/grpclog" - "google.golang.org/grpc/internal/grpcsync" - "google.golang.org/grpc/internal/grpcutil" - imetadata "google.golang.org/grpc/internal/metadata" - istatus "google.golang.org/grpc/internal/status" - isyscall "google.golang.org/grpc/internal/syscall" - "google.golang.org/grpc/internal/transport/networktype" - "google.golang.org/grpc/keepalive" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/peer" - "google.golang.org/grpc/resolver" - "google.golang.org/grpc/stats" - "google.golang.org/grpc/status" -) - -// clientConnectionCounter counts the number of connections a client has -// initiated (equal to the number of http2Clients created). Must be accessed -// atomically. -var clientConnectionCounter uint64 - -var metadataFromOutgoingContextRaw = internal.FromOutgoingContextRaw.(func(context.Context) (metadata.MD, [][]string, bool)) - -// http2Client implements the ClientTransport interface with HTTP2. -type http2Client struct { - lastRead int64 // Keep this field 64-bit aligned. Accessed atomically. - ctx context.Context - cancel context.CancelFunc - ctxDone <-chan struct{} // Cache the ctx.Done() chan. - userAgent string - // address contains the resolver returned address for this transport. - // If the `ServerName` field is set, it takes precedence over `CallHdr.Host` - // passed to `NewStream`, when determining the :authority header. - address resolver.Address - md metadata.MD - conn net.Conn // underlying communication channel - loopy *loopyWriter - remoteAddr net.Addr - localAddr net.Addr - authInfo credentials.AuthInfo // auth info about the connection - - readerDone chan struct{} // sync point to enable testing. - writerDone chan struct{} // sync point to enable testing. - // goAway is closed to notify the upper layer (i.e., addrConn.transportMonitor) - // that the server sent GoAway on this transport. - goAway chan struct{} - - framer *framer - // controlBuf delivers all the control related tasks (e.g., window - // updates, reset streams, and various settings) to the controller. - // Do not access controlBuf with mu held. - controlBuf *controlBuffer - fc *trInFlow - // The scheme used: https if TLS is on, http otherwise. - scheme string - - isSecure bool - - perRPCCreds []credentials.PerRPCCredentials - - kp keepalive.ClientParameters - keepaliveEnabled bool - - statsHandlers []stats.Handler - - initialWindowSize int32 - - // configured by peer through SETTINGS_MAX_HEADER_LIST_SIZE - maxSendHeaderListSize *uint32 - - bdpEst *bdpEstimator - - maxConcurrentStreams uint32 - streamQuota int64 - streamsQuotaAvailable chan struct{} - waitingStreams uint32 - nextID uint32 - registeredCompressors string - - // Do not access controlBuf with mu held. - mu sync.Mutex // guard the following variables - state transportState - activeStreams map[uint32]*Stream - // prevGoAway ID records the Last-Stream-ID in the previous GOAway frame. - prevGoAwayID uint32 - // goAwayReason records the http2.ErrCode and debug data received with the - // GoAway frame. - goAwayReason GoAwayReason - // goAwayDebugMessage contains a detailed human readable string about a - // GoAway frame, useful for error messages. - goAwayDebugMessage string - // A condition variable used to signal when the keepalive goroutine should - // go dormant. The condition for dormancy is based on the number of active - // streams and the `PermitWithoutStream` keepalive client parameter. And - // since the number of active streams is guarded by the above mutex, we use - // the same for this condition variable as well. - kpDormancyCond *sync.Cond - // A boolean to track whether the keepalive goroutine is dormant or not. - // This is checked before attempting to signal the above condition - // variable. - kpDormant bool - - channelz *channelz.Socket - - onClose func(GoAwayReason) - - bufferPool *bufferPool - - connectionID uint64 - logger *grpclog.PrefixLogger -} - -func dial(ctx context.Context, fn func(context.Context, string) (net.Conn, error), addr resolver.Address, useProxy bool, grpcUA string) (net.Conn, error) { - address := addr.Addr - networkType, ok := networktype.Get(addr) - if fn != nil { - // Special handling for unix scheme with custom dialer. Back in the day, - // we did not have a unix resolver and therefore targets with a unix - // scheme would end up using the passthrough resolver. So, user's used a - // custom dialer in this case and expected the original dial target to - // be passed to the custom dialer. Now, we have a unix resolver. But if - // a custom dialer is specified, we want to retain the old behavior in - // terms of the address being passed to the custom dialer. - if networkType == "unix" && !strings.HasPrefix(address, "\x00") { - // Supported unix targets are either "unix://absolute-path" or - // "unix:relative-path". - if filepath.IsAbs(address) { - return fn(ctx, "unix://"+address) - } - return fn(ctx, "unix:"+address) - } - return fn(ctx, address) - } - if !ok { - networkType, address = parseDialTarget(address) - } - if networkType == "tcp" && useProxy { - return proxyDial(ctx, address, grpcUA) - } - return internal.NetDialerWithTCPKeepalive().DialContext(ctx, networkType, address) -} - -func isTemporary(err error) bool { - switch err := err.(type) { - case interface { - Temporary() bool - }: - return err.Temporary() - case interface { - Timeout() bool - }: - // Timeouts may be resolved upon retry, and are thus treated as - // temporary. - return err.Timeout() - } - return true -} - -// newHTTP2Client constructs a connected ClientTransport to addr based on HTTP2 -// and starts to receive messages on it. Non-nil error returns if construction -// fails. -func newHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts ConnectOptions, onClose func(GoAwayReason)) (_ *http2Client, err error) { - scheme := "http" - ctx, cancel := context.WithCancel(ctx) - defer func() { - if err != nil { - cancel() - } - }() - - // gRPC, resolver, balancer etc. can specify arbitrary data in the - // Attributes field of resolver.Address, which is shoved into connectCtx - // and passed to the dialer and credential handshaker. This makes it possible for - // address specific arbitrary data to reach custom dialers and credential handshakers. - connectCtx = icredentials.NewClientHandshakeInfoContext(connectCtx, credentials.ClientHandshakeInfo{Attributes: addr.Attributes}) - - conn, err := dial(connectCtx, opts.Dialer, addr, opts.UseProxy, opts.UserAgent) - if err != nil { - if opts.FailOnNonTempDialError { - return nil, connectionErrorf(isTemporary(err), err, "transport: error while dialing: %v", err) - } - return nil, connectionErrorf(true, err, "transport: Error while dialing: %v", err) - } - - // Any further errors will close the underlying connection - defer func(conn net.Conn) { - if err != nil { - conn.Close() - } - }(conn) - - // The following defer and goroutine monitor the connectCtx for cancelation - // and deadline. On context expiration, the connection is hard closed and - // this function will naturally fail as a result. Otherwise, the defer - // waits for the goroutine to exit to prevent the context from being - // monitored (and to prevent the connection from ever being closed) after - // returning from this function. - ctxMonitorDone := grpcsync.NewEvent() - newClientCtx, newClientDone := context.WithCancel(connectCtx) - defer func() { - newClientDone() // Awaken the goroutine below if connectCtx hasn't expired. - <-ctxMonitorDone.Done() // Wait for the goroutine below to exit. - }() - go func(conn net.Conn) { - defer ctxMonitorDone.Fire() // Signal this goroutine has exited. - <-newClientCtx.Done() // Block until connectCtx expires or the defer above executes. - if err := connectCtx.Err(); err != nil { - // connectCtx expired before exiting the function. Hard close the connection. - if logger.V(logLevel) { - logger.Infof("Aborting due to connect deadline expiring: %v", err) - } - conn.Close() - } - }(conn) - - kp := opts.KeepaliveParams - // Validate keepalive parameters. - if kp.Time == 0 { - kp.Time = defaultClientKeepaliveTime - } - if kp.Timeout == 0 { - kp.Timeout = defaultClientKeepaliveTimeout - } - keepaliveEnabled := false - if kp.Time != infinity { - if err = isyscall.SetTCPUserTimeout(conn, kp.Timeout); err != nil { - return nil, connectionErrorf(false, err, "transport: failed to set TCP_USER_TIMEOUT: %v", err) - } - keepaliveEnabled = true - } - var ( - isSecure bool - authInfo credentials.AuthInfo - ) - transportCreds := opts.TransportCredentials - perRPCCreds := opts.PerRPCCredentials - - if b := opts.CredsBundle; b != nil { - if t := b.TransportCredentials(); t != nil { - transportCreds = t - } - if t := b.PerRPCCredentials(); t != nil { - perRPCCreds = append(perRPCCreds, t) - } - } - if transportCreds != nil { - conn, authInfo, err = transportCreds.ClientHandshake(connectCtx, addr.ServerName, conn) - if err != nil { - return nil, connectionErrorf(isTemporary(err), err, "transport: authentication handshake failed: %v", err) - } - for _, cd := range perRPCCreds { - if cd.RequireTransportSecurity() { - if ci, ok := authInfo.(interface { - GetCommonAuthInfo() credentials.CommonAuthInfo - }); ok { - secLevel := ci.GetCommonAuthInfo().SecurityLevel - if secLevel != credentials.InvalidSecurityLevel && secLevel < credentials.PrivacyAndIntegrity { - return nil, connectionErrorf(true, nil, "transport: cannot send secure credentials on an insecure connection") - } - } - } - } - isSecure = true - if transportCreds.Info().SecurityProtocol == "tls" { - scheme = "https" - } - } - dynamicWindow := true - icwz := int32(initialWindowSize) - if opts.InitialConnWindowSize >= defaultWindowSize { - icwz = opts.InitialConnWindowSize - dynamicWindow = false - } - writeBufSize := opts.WriteBufferSize - readBufSize := opts.ReadBufferSize - maxHeaderListSize := defaultClientMaxHeaderListSize - if opts.MaxHeaderListSize != nil { - maxHeaderListSize = *opts.MaxHeaderListSize - } - - t := &http2Client{ - ctx: ctx, - ctxDone: ctx.Done(), // Cache Done chan. - cancel: cancel, - userAgent: opts.UserAgent, - registeredCompressors: grpcutil.RegisteredCompressors(), - address: addr, - conn: conn, - remoteAddr: conn.RemoteAddr(), - localAddr: conn.LocalAddr(), - authInfo: authInfo, - readerDone: make(chan struct{}), - writerDone: make(chan struct{}), - goAway: make(chan struct{}), - framer: newFramer(conn, writeBufSize, readBufSize, opts.SharedWriteBuffer, maxHeaderListSize), - fc: &trInFlow{limit: uint32(icwz)}, - scheme: scheme, - activeStreams: make(map[uint32]*Stream), - isSecure: isSecure, - perRPCCreds: perRPCCreds, - kp: kp, - statsHandlers: opts.StatsHandlers, - initialWindowSize: initialWindowSize, - nextID: 1, - maxConcurrentStreams: defaultMaxStreamsClient, - streamQuota: defaultMaxStreamsClient, - streamsQuotaAvailable: make(chan struct{}, 1), - keepaliveEnabled: keepaliveEnabled, - bufferPool: newBufferPool(), - onClose: onClose, - } - var czSecurity credentials.ChannelzSecurityValue - if au, ok := authInfo.(credentials.ChannelzSecurityInfo); ok { - czSecurity = au.GetSecurityValue() - } - t.channelz = channelz.RegisterSocket( - &channelz.Socket{ - SocketType: channelz.SocketTypeNormal, - Parent: opts.ChannelzParent, - SocketMetrics: channelz.SocketMetrics{}, - EphemeralMetrics: t.socketMetrics, - LocalAddr: t.localAddr, - RemoteAddr: t.remoteAddr, - SocketOptions: channelz.GetSocketOption(t.conn), - Security: czSecurity, - }) - t.logger = prefixLoggerForClientTransport(t) - // Add peer information to the http2client context. - t.ctx = peer.NewContext(t.ctx, t.getPeer()) - - if md, ok := addr.Metadata.(*metadata.MD); ok { - t.md = *md - } else if md := imetadata.Get(addr); md != nil { - t.md = md - } - t.controlBuf = newControlBuffer(t.ctxDone) - if opts.InitialWindowSize >= defaultWindowSize { - t.initialWindowSize = opts.InitialWindowSize - dynamicWindow = false - } - if dynamicWindow { - t.bdpEst = &bdpEstimator{ - bdp: initialWindowSize, - updateFlowControl: t.updateFlowControl, - } - } - for _, sh := range t.statsHandlers { - t.ctx = sh.TagConn(t.ctx, &stats.ConnTagInfo{ - RemoteAddr: t.remoteAddr, - LocalAddr: t.localAddr, - }) - connBegin := &stats.ConnBegin{ - Client: true, - } - sh.HandleConn(t.ctx, connBegin) - } - if t.keepaliveEnabled { - t.kpDormancyCond = sync.NewCond(&t.mu) - go t.keepalive() - } - - // Start the reader goroutine for incoming messages. Each transport has a - // dedicated goroutine which reads HTTP2 frames from the network. Then it - // dispatches the frame to the corresponding stream entity. When the - // server preface is received, readerErrCh is closed. If an error occurs - // first, an error is pushed to the channel. This must be checked before - // returning from this function. - readerErrCh := make(chan error, 1) - go t.reader(readerErrCh) - defer func() { - if err == nil { - err = <-readerErrCh - } - if err != nil { - t.Close(err) - } - }() - - // Send connection preface to server. - n, err := t.conn.Write(clientPreface) - if err != nil { - err = connectionErrorf(true, err, "transport: failed to write client preface: %v", err) - return nil, err - } - if n != len(clientPreface) { - err = connectionErrorf(true, nil, "transport: preface mismatch, wrote %d bytes; want %d", n, len(clientPreface)) - return nil, err - } - var ss []http2.Setting - - if t.initialWindowSize != defaultWindowSize { - ss = append(ss, http2.Setting{ - ID: http2.SettingInitialWindowSize, - Val: uint32(t.initialWindowSize), - }) - } - if opts.MaxHeaderListSize != nil { - ss = append(ss, http2.Setting{ - ID: http2.SettingMaxHeaderListSize, - Val: *opts.MaxHeaderListSize, - }) - } - err = t.framer.fr.WriteSettings(ss...) - if err != nil { - err = connectionErrorf(true, err, "transport: failed to write initial settings frame: %v", err) - return nil, err - } - // Adjust the connection flow control window if needed. - if delta := uint32(icwz - defaultWindowSize); delta > 0 { - if err := t.framer.fr.WriteWindowUpdate(0, delta); err != nil { - err = connectionErrorf(true, err, "transport: failed to write window update: %v", err) - return nil, err - } - } - - t.connectionID = atomic.AddUint64(&clientConnectionCounter, 1) - - if err := t.framer.writer.Flush(); err != nil { - return nil, err - } - go func() { - t.loopy = newLoopyWriter(clientSide, t.framer, t.controlBuf, t.bdpEst, t.conn, t.logger) - if err := t.loopy.run(); !isIOError(err) { - // Immediately close the connection, as the loopy writer returns - // when there are no more active streams and we were draining (the - // server sent a GOAWAY). For I/O errors, the reader will hit it - // after draining any remaining incoming data. - t.conn.Close() - } - close(t.writerDone) - }() - return t, nil -} - -func (t *http2Client) newStream(ctx context.Context, callHdr *CallHdr) *Stream { - // TODO(zhaoq): Handle uint32 overflow of Stream.id. - s := &Stream{ - ct: t, - done: make(chan struct{}), - method: callHdr.Method, - sendCompress: callHdr.SendCompress, - buf: newRecvBuffer(), - headerChan: make(chan struct{}), - contentSubtype: callHdr.ContentSubtype, - doneFunc: callHdr.DoneFunc, - } - s.wq = newWriteQuota(defaultWriteQuota, s.done) - s.requestRead = func(n int) { - t.adjustWindow(s, uint32(n)) - } - // The client side stream context should have exactly the same life cycle with the user provided context. - // That means, s.ctx should be read-only. And s.ctx is done iff ctx is done. - // So we use the original context here instead of creating a copy. - s.ctx = ctx - s.trReader = &transportReader{ - reader: &recvBufferReader{ - ctx: s.ctx, - ctxDone: s.ctx.Done(), - recv: s.buf, - closeStream: func(err error) { - t.CloseStream(s, err) - }, - freeBuffer: t.bufferPool.put, - }, - windowHandler: func(n int) { - t.updateWindow(s, uint32(n)) - }, - } - return s -} - -func (t *http2Client) getPeer() *peer.Peer { - return &peer.Peer{ - Addr: t.remoteAddr, - AuthInfo: t.authInfo, // Can be nil - LocalAddr: t.localAddr, - } -} - -func (t *http2Client) createHeaderFields(ctx context.Context, callHdr *CallHdr) ([]hpack.HeaderField, error) { - aud := t.createAudience(callHdr) - ri := credentials.RequestInfo{ - Method: callHdr.Method, - AuthInfo: t.authInfo, - } - ctxWithRequestInfo := icredentials.NewRequestInfoContext(ctx, ri) - authData, err := t.getTrAuthData(ctxWithRequestInfo, aud) - if err != nil { - return nil, err - } - callAuthData, err := t.getCallAuthData(ctxWithRequestInfo, aud, callHdr) - if err != nil { - return nil, err - } - // TODO(mmukhi): Benchmark if the performance gets better if count the metadata and other header fields - // first and create a slice of that exact size. - // Make the slice of certain predictable size to reduce allocations made by append. - hfLen := 7 // :method, :scheme, :path, :authority, content-type, user-agent, te - hfLen += len(authData) + len(callAuthData) - headerFields := make([]hpack.HeaderField, 0, hfLen) - headerFields = append(headerFields, hpack.HeaderField{Name: ":method", Value: "POST"}) - headerFields = append(headerFields, hpack.HeaderField{Name: ":scheme", Value: t.scheme}) - headerFields = append(headerFields, hpack.HeaderField{Name: ":path", Value: callHdr.Method}) - headerFields = append(headerFields, hpack.HeaderField{Name: ":authority", Value: callHdr.Host}) - headerFields = append(headerFields, hpack.HeaderField{Name: "content-type", Value: grpcutil.ContentType(callHdr.ContentSubtype)}) - headerFields = append(headerFields, hpack.HeaderField{Name: "user-agent", Value: t.userAgent}) - headerFields = append(headerFields, hpack.HeaderField{Name: "te", Value: "trailers"}) - if callHdr.PreviousAttempts > 0 { - headerFields = append(headerFields, hpack.HeaderField{Name: "grpc-previous-rpc-attempts", Value: strconv.Itoa(callHdr.PreviousAttempts)}) - } - - registeredCompressors := t.registeredCompressors - if callHdr.SendCompress != "" { - headerFields = append(headerFields, hpack.HeaderField{Name: "grpc-encoding", Value: callHdr.SendCompress}) - // Include the outgoing compressor name when compressor is not registered - // via encoding.RegisterCompressor. This is possible when client uses - // WithCompressor dial option. - if !grpcutil.IsCompressorNameRegistered(callHdr.SendCompress) { - if registeredCompressors != "" { - registeredCompressors += "," - } - registeredCompressors += callHdr.SendCompress - } - } - - if registeredCompressors != "" { - headerFields = append(headerFields, hpack.HeaderField{Name: "grpc-accept-encoding", Value: registeredCompressors}) - } - if dl, ok := ctx.Deadline(); ok { - // Send out timeout regardless its value. The server can detect timeout context by itself. - // TODO(mmukhi): Perhaps this field should be updated when actually writing out to the wire. - timeout := time.Until(dl) - headerFields = append(headerFields, hpack.HeaderField{Name: "grpc-timeout", Value: grpcutil.EncodeDuration(timeout)}) - } - for k, v := range authData { - headerFields = append(headerFields, hpack.HeaderField{Name: k, Value: encodeMetadataHeader(k, v)}) - } - for k, v := range callAuthData { - headerFields = append(headerFields, hpack.HeaderField{Name: k, Value: encodeMetadataHeader(k, v)}) - } - if b := stats.OutgoingTags(ctx); b != nil { - headerFields = append(headerFields, hpack.HeaderField{Name: "grpc-tags-bin", Value: encodeBinHeader(b)}) - } - if b := stats.OutgoingTrace(ctx); b != nil { - headerFields = append(headerFields, hpack.HeaderField{Name: "grpc-trace-bin", Value: encodeBinHeader(b)}) - } - - if md, added, ok := metadataFromOutgoingContextRaw(ctx); ok { - var k string - for k, vv := range md { - // HTTP doesn't allow you to set pseudoheaders after non pseudoheaders were set. - if isReservedHeader(k) { - continue - } - for _, v := range vv { - headerFields = append(headerFields, hpack.HeaderField{Name: k, Value: encodeMetadataHeader(k, v)}) - } - } - for _, vv := range added { - for i, v := range vv { - if i%2 == 0 { - k = strings.ToLower(v) - continue - } - // HTTP doesn't allow you to set pseudoheaders after non pseudoheaders were set. - if isReservedHeader(k) { - continue - } - headerFields = append(headerFields, hpack.HeaderField{Name: k, Value: encodeMetadataHeader(k, v)}) - } - } - } - for k, vv := range t.md { - if isReservedHeader(k) { - continue - } - for _, v := range vv { - headerFields = append(headerFields, hpack.HeaderField{Name: k, Value: encodeMetadataHeader(k, v)}) - } - } - return headerFields, nil -} - -func (t *http2Client) createAudience(callHdr *CallHdr) string { - // Create an audience string only if needed. - if len(t.perRPCCreds) == 0 && callHdr.Creds == nil { - return "" - } - // Construct URI required to get auth request metadata. - // Omit port if it is the default one. - host := strings.TrimSuffix(callHdr.Host, ":443") - pos := strings.LastIndex(callHdr.Method, "/") - if pos == -1 { - pos = len(callHdr.Method) - } - return "https://" + host + callHdr.Method[:pos] -} - -func (t *http2Client) getTrAuthData(ctx context.Context, audience string) (map[string]string, error) { - if len(t.perRPCCreds) == 0 { - return nil, nil - } - authData := map[string]string{} - for _, c := range t.perRPCCreds { - data, err := c.GetRequestMetadata(ctx, audience) - if err != nil { - if st, ok := status.FromError(err); ok { - // Restrict the code to the list allowed by gRFC A54. - if istatus.IsRestrictedControlPlaneCode(st) { - err = status.Errorf(codes.Internal, "transport: received per-RPC creds error with illegal status: %v", err) - } - return nil, err - } - - return nil, status.Errorf(codes.Unauthenticated, "transport: per-RPC creds failed due to error: %v", err) - } - for k, v := range data { - // Capital header names are illegal in HTTP/2. - k = strings.ToLower(k) - authData[k] = v - } - } - return authData, nil -} - -func (t *http2Client) getCallAuthData(ctx context.Context, audience string, callHdr *CallHdr) (map[string]string, error) { - var callAuthData map[string]string - // Check if credentials.PerRPCCredentials were provided via call options. - // Note: if these credentials are provided both via dial options and call - // options, then both sets of credentials will be applied. - if callCreds := callHdr.Creds; callCreds != nil { - if callCreds.RequireTransportSecurity() { - ri, _ := credentials.RequestInfoFromContext(ctx) - if !t.isSecure || credentials.CheckSecurityLevel(ri.AuthInfo, credentials.PrivacyAndIntegrity) != nil { - return nil, status.Error(codes.Unauthenticated, "transport: cannot send secure credentials on an insecure connection") - } - } - data, err := callCreds.GetRequestMetadata(ctx, audience) - if err != nil { - if st, ok := status.FromError(err); ok { - // Restrict the code to the list allowed by gRFC A54. - if istatus.IsRestrictedControlPlaneCode(st) { - err = status.Errorf(codes.Internal, "transport: received per-RPC creds error with illegal status: %v", err) - } - return nil, err - } - return nil, status.Errorf(codes.Internal, "transport: per-RPC creds failed due to error: %v", err) - } - callAuthData = make(map[string]string, len(data)) - for k, v := range data { - // Capital header names are illegal in HTTP/2 - k = strings.ToLower(k) - callAuthData[k] = v - } - } - return callAuthData, nil -} - -// NewStreamError wraps an error and reports additional information. Typically -// NewStream errors result in transparent retry, as they mean nothing went onto -// the wire. However, there are two notable exceptions: -// -// 1. If the stream headers violate the max header list size allowed by the -// server. It's possible this could succeed on another transport, even if -// it's unlikely, but do not transparently retry. -// 2. If the credentials errored when requesting their headers. In this case, -// it's possible a retry can fix the problem, but indefinitely transparently -// retrying is not appropriate as it is likely the credentials, if they can -// eventually succeed, would need I/O to do so. -type NewStreamError struct { - Err error - - AllowTransparentRetry bool -} - -func (e NewStreamError) Error() string { - return e.Err.Error() -} - -// NewStream creates a stream and registers it into the transport as "active" -// streams. All non-nil errors returned will be *NewStreamError. -func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (*Stream, error) { - ctx = peer.NewContext(ctx, t.getPeer()) - - // ServerName field of the resolver returned address takes precedence over - // Host field of CallHdr to determine the :authority header. This is because, - // the ServerName field takes precedence for server authentication during - // TLS handshake, and the :authority header should match the value used - // for server authentication. - if t.address.ServerName != "" { - newCallHdr := *callHdr - newCallHdr.Host = t.address.ServerName - callHdr = &newCallHdr - } - - headerFields, err := t.createHeaderFields(ctx, callHdr) - if err != nil { - return nil, &NewStreamError{Err: err, AllowTransparentRetry: false} - } - s := t.newStream(ctx, callHdr) - cleanup := func(err error) { - if s.swapState(streamDone) == streamDone { - // If it was already done, return. - return - } - // The stream was unprocessed by the server. - atomic.StoreUint32(&s.unprocessed, 1) - s.write(recvMsg{err: err}) - close(s.done) - // If headerChan isn't closed, then close it. - if atomic.CompareAndSwapUint32(&s.headerChanClosed, 0, 1) { - close(s.headerChan) - } - } - hdr := &headerFrame{ - hf: headerFields, - endStream: false, - initStream: func(id uint32) error { - t.mu.Lock() - // TODO: handle transport closure in loopy instead and remove this - // initStream is never called when transport is draining. - if t.state == closing { - t.mu.Unlock() - cleanup(ErrConnClosing) - return ErrConnClosing - } - if channelz.IsOn() { - t.channelz.SocketMetrics.StreamsStarted.Add(1) - t.channelz.SocketMetrics.LastLocalStreamCreatedTimestamp.Store(time.Now().UnixNano()) - } - // If the keepalive goroutine has gone dormant, wake it up. - if t.kpDormant { - t.kpDormancyCond.Signal() - } - t.mu.Unlock() - return nil - }, - onOrphaned: cleanup, - wq: s.wq, - } - firstTry := true - var ch chan struct{} - transportDrainRequired := false - checkForStreamQuota := func(it any) bool { - if t.streamQuota <= 0 { // Can go negative if server decreases it. - if firstTry { - t.waitingStreams++ - } - ch = t.streamsQuotaAvailable - return false - } - if !firstTry { - t.waitingStreams-- - } - t.streamQuota-- - h := it.(*headerFrame) - h.streamID = t.nextID - t.nextID += 2 - - // Drain client transport if nextID > MaxStreamID which signals gRPC that - // the connection is closed and a new one must be created for subsequent RPCs. - transportDrainRequired = t.nextID > MaxStreamID - - s.id = h.streamID - s.fc = &inFlow{limit: uint32(t.initialWindowSize)} - t.mu.Lock() - if t.state == draining || t.activeStreams == nil { // Can be niled from Close(). - t.mu.Unlock() - return false // Don't create a stream if the transport is already closed. - } - t.activeStreams[s.id] = s - t.mu.Unlock() - if t.streamQuota > 0 && t.waitingStreams > 0 { - select { - case t.streamsQuotaAvailable <- struct{}{}: - default: - } - } - return true - } - var hdrListSizeErr error - checkForHeaderListSize := func(it any) bool { - if t.maxSendHeaderListSize == nil { - return true - } - hdrFrame := it.(*headerFrame) - var sz int64 - for _, f := range hdrFrame.hf { - if sz += int64(f.Size()); sz > int64(*t.maxSendHeaderListSize) { - hdrListSizeErr = status.Errorf(codes.Internal, "header list size to send violates the maximum size (%d bytes) set by server", *t.maxSendHeaderListSize) - return false - } - } - return true - } - for { - success, err := t.controlBuf.executeAndPut(func(it any) bool { - return checkForHeaderListSize(it) && checkForStreamQuota(it) - }, hdr) - if err != nil { - // Connection closed. - return nil, &NewStreamError{Err: err, AllowTransparentRetry: true} - } - if success { - break - } - if hdrListSizeErr != nil { - return nil, &NewStreamError{Err: hdrListSizeErr} - } - firstTry = false - select { - case <-ch: - case <-ctx.Done(): - return nil, &NewStreamError{Err: ContextErr(ctx.Err())} - case <-t.goAway: - return nil, &NewStreamError{Err: errStreamDrain, AllowTransparentRetry: true} - case <-t.ctx.Done(): - return nil, &NewStreamError{Err: ErrConnClosing, AllowTransparentRetry: true} - } - } - if len(t.statsHandlers) != 0 { - header, ok := metadata.FromOutgoingContext(ctx) - if ok { - header.Set("user-agent", t.userAgent) - } else { - header = metadata.Pairs("user-agent", t.userAgent) - } - for _, sh := range t.statsHandlers { - // Note: The header fields are compressed with hpack after this call returns. - // No WireLength field is set here. - // Note: Creating a new stats object to prevent pollution. - outHeader := &stats.OutHeader{ - Client: true, - FullMethod: callHdr.Method, - RemoteAddr: t.remoteAddr, - LocalAddr: t.localAddr, - Compression: callHdr.SendCompress, - Header: header, - } - sh.HandleRPC(s.ctx, outHeader) - } - } - if transportDrainRequired { - if t.logger.V(logLevel) { - t.logger.Infof("Draining transport: t.nextID > MaxStreamID") - } - t.GracefulClose() - } - return s, nil -} - -// CloseStream clears the footprint of a stream when the stream is not needed any more. -// This must not be executed in reader's goroutine. -func (t *http2Client) CloseStream(s *Stream, err error) { - var ( - rst bool - rstCode http2.ErrCode - ) - if err != nil { - rst = true - rstCode = http2.ErrCodeCancel - } - t.closeStream(s, err, rst, rstCode, status.Convert(err), nil, false) -} - -func (t *http2Client) closeStream(s *Stream, err error, rst bool, rstCode http2.ErrCode, st *status.Status, mdata map[string][]string, eosReceived bool) { - // Set stream status to done. - if s.swapState(streamDone) == streamDone { - // If it was already done, return. If multiple closeStream calls - // happen simultaneously, wait for the first to finish. - <-s.done - return - } - // status and trailers can be updated here without any synchronization because the stream goroutine will - // only read it after it sees an io.EOF error from read or write and we'll write those errors - // only after updating this. - s.status = st - if len(mdata) > 0 { - s.trailer = mdata - } - if err != nil { - // This will unblock reads eventually. - s.write(recvMsg{err: err}) - } - // If headerChan isn't closed, then close it. - if atomic.CompareAndSwapUint32(&s.headerChanClosed, 0, 1) { - s.noHeaders = true - close(s.headerChan) - } - cleanup := &cleanupStream{ - streamID: s.id, - onWrite: func() { - t.mu.Lock() - if t.activeStreams != nil { - delete(t.activeStreams, s.id) - } - t.mu.Unlock() - if channelz.IsOn() { - if eosReceived { - t.channelz.SocketMetrics.StreamsSucceeded.Add(1) - } else { - t.channelz.SocketMetrics.StreamsFailed.Add(1) - } - } - }, - rst: rst, - rstCode: rstCode, - } - addBackStreamQuota := func(any) bool { - t.streamQuota++ - if t.streamQuota > 0 && t.waitingStreams > 0 { - select { - case t.streamsQuotaAvailable <- struct{}{}: - default: - } - } - return true - } - t.controlBuf.executeAndPut(addBackStreamQuota, cleanup) - // This will unblock write. - close(s.done) - if s.doneFunc != nil { - s.doneFunc() - } -} - -// Close kicks off the shutdown process of the transport. This should be called -// only once on a transport. Once it is called, the transport should not be -// accessed any more. -func (t *http2Client) Close(err error) { - t.mu.Lock() - // Make sure we only close once. - if t.state == closing { - t.mu.Unlock() - return - } - if t.logger.V(logLevel) { - t.logger.Infof("Closing: %v", err) - } - // Call t.onClose ASAP to prevent the client from attempting to create new - // streams. - if t.state != draining { - t.onClose(GoAwayInvalid) - } - t.state = closing - streams := t.activeStreams - t.activeStreams = nil - if t.kpDormant { - // If the keepalive goroutine is blocked on this condition variable, we - // should unblock it so that the goroutine eventually exits. - t.kpDormancyCond.Signal() - } - t.mu.Unlock() - t.controlBuf.finish() - t.cancel() - t.conn.Close() - channelz.RemoveEntry(t.channelz.ID) - // Append info about previous goaways if there were any, since this may be important - // for understanding the root cause for this connection to be closed. - _, goAwayDebugMessage := t.GetGoAwayReason() - - var st *status.Status - if len(goAwayDebugMessage) > 0 { - st = status.Newf(codes.Unavailable, "closing transport due to: %v, received prior goaway: %v", err, goAwayDebugMessage) - err = st.Err() - } else { - st = status.New(codes.Unavailable, err.Error()) - } - - // Notify all active streams. - for _, s := range streams { - t.closeStream(s, err, false, http2.ErrCodeNo, st, nil, false) - } - for _, sh := range t.statsHandlers { - connEnd := &stats.ConnEnd{ - Client: true, - } - sh.HandleConn(t.ctx, connEnd) - } -} - -// GracefulClose sets the state to draining, which prevents new streams from -// being created and causes the transport to be closed when the last active -// stream is closed. If there are no active streams, the transport is closed -// immediately. This does nothing if the transport is already draining or -// closing. -func (t *http2Client) GracefulClose() { - t.mu.Lock() - // Make sure we move to draining only from active. - if t.state == draining || t.state == closing { - t.mu.Unlock() - return - } - if t.logger.V(logLevel) { - t.logger.Infof("GracefulClose called") - } - t.onClose(GoAwayInvalid) - t.state = draining - active := len(t.activeStreams) - t.mu.Unlock() - if active == 0 { - t.Close(connectionErrorf(true, nil, "no active streams left to process while draining")) - return - } - t.controlBuf.put(&incomingGoAway{}) -} - -// Write formats the data into HTTP2 data frame(s) and sends it out. The caller -// should proceed only if Write returns nil. -func (t *http2Client) Write(s *Stream, hdr []byte, data []byte, opts *Options) error { - if opts.Last { - // If it's the last message, update stream state. - if !s.compareAndSwapState(streamActive, streamWriteDone) { - return errStreamDone - } - } else if s.getState() != streamActive { - return errStreamDone - } - df := &dataFrame{ - streamID: s.id, - endStream: opts.Last, - h: hdr, - d: data, - } - if hdr != nil || data != nil { // If it's not an empty data frame, check quota. - if err := s.wq.get(int32(len(hdr) + len(data))); err != nil { - return err - } - } - return t.controlBuf.put(df) -} - -func (t *http2Client) getStream(f http2.Frame) *Stream { - t.mu.Lock() - s := t.activeStreams[f.Header().StreamID] - t.mu.Unlock() - return s -} - -// adjustWindow sends out extra window update over the initial window size -// of stream if the application is requesting data larger in size than -// the window. -func (t *http2Client) adjustWindow(s *Stream, n uint32) { - if w := s.fc.maybeAdjust(n); w > 0 { - t.controlBuf.put(&outgoingWindowUpdate{streamID: s.id, increment: w}) - } -} - -// updateWindow adjusts the inbound quota for the stream. -// Window updates will be sent out when the cumulative quota -// exceeds the corresponding threshold. -func (t *http2Client) updateWindow(s *Stream, n uint32) { - if w := s.fc.onRead(n); w > 0 { - t.controlBuf.put(&outgoingWindowUpdate{streamID: s.id, increment: w}) - } -} - -// updateFlowControl updates the incoming flow control windows -// for the transport and the stream based on the current bdp -// estimation. -func (t *http2Client) updateFlowControl(n uint32) { - updateIWS := func(any) bool { - t.initialWindowSize = int32(n) - t.mu.Lock() - for _, s := range t.activeStreams { - s.fc.newLimit(n) - } - t.mu.Unlock() - return true - } - t.controlBuf.executeAndPut(updateIWS, &outgoingWindowUpdate{streamID: 0, increment: t.fc.newLimit(n)}) - t.controlBuf.put(&outgoingSettings{ - ss: []http2.Setting{ - { - ID: http2.SettingInitialWindowSize, - Val: n, - }, - }, - }) -} - -func (t *http2Client) handleData(f *http2.DataFrame) { - size := f.Header().Length - var sendBDPPing bool - if t.bdpEst != nil { - sendBDPPing = t.bdpEst.add(size) - } - // Decouple connection's flow control from application's read. - // An update on connection's flow control should not depend on - // whether user application has read the data or not. Such a - // restriction is already imposed on the stream's flow control, - // and therefore the sender will be blocked anyways. - // Decoupling the connection flow control will prevent other - // active(fast) streams from starving in presence of slow or - // inactive streams. - // - if w := t.fc.onData(size); w > 0 { - t.controlBuf.put(&outgoingWindowUpdate{ - streamID: 0, - increment: w, - }) - } - if sendBDPPing { - // Avoid excessive ping detection (e.g. in an L7 proxy) - // by sending a window update prior to the BDP ping. - - if w := t.fc.reset(); w > 0 { - t.controlBuf.put(&outgoingWindowUpdate{ - streamID: 0, - increment: w, - }) - } - - t.controlBuf.put(bdpPing) - } - // Select the right stream to dispatch. - s := t.getStream(f) - if s == nil { - return - } - if size > 0 { - if err := s.fc.onData(size); err != nil { - t.closeStream(s, io.EOF, true, http2.ErrCodeFlowControl, status.New(codes.Internal, err.Error()), nil, false) - return - } - if f.Header().Flags.Has(http2.FlagDataPadded) { - if w := s.fc.onRead(size - uint32(len(f.Data()))); w > 0 { - t.controlBuf.put(&outgoingWindowUpdate{s.id, w}) - } - } - // TODO(bradfitz, zhaoq): A copy is required here because there is no - // guarantee f.Data() is consumed before the arrival of next frame. - // Can this copy be eliminated? - if len(f.Data()) > 0 { - buffer := t.bufferPool.get() - buffer.Reset() - buffer.Write(f.Data()) - s.write(recvMsg{buffer: buffer}) - } - } - // The server has closed the stream without sending trailers. Record that - // the read direction is closed, and set the status appropriately. - if f.StreamEnded() { - t.closeStream(s, io.EOF, false, http2.ErrCodeNo, status.New(codes.Internal, "server closed the stream without sending trailers"), nil, true) - } -} - -func (t *http2Client) handleRSTStream(f *http2.RSTStreamFrame) { - s := t.getStream(f) - if s == nil { - return - } - if f.ErrCode == http2.ErrCodeRefusedStream { - // The stream was unprocessed by the server. - atomic.StoreUint32(&s.unprocessed, 1) - } - statusCode, ok := http2ErrConvTab[f.ErrCode] - if !ok { - if t.logger.V(logLevel) { - t.logger.Infof("Received a RST_STREAM frame with code %q, but found no mapped gRPC status", f.ErrCode) - } - statusCode = codes.Unknown - } - if statusCode == codes.Canceled { - if d, ok := s.ctx.Deadline(); ok && !d.After(time.Now()) { - // Our deadline was already exceeded, and that was likely the cause - // of this cancelation. Alter the status code accordingly. - statusCode = codes.DeadlineExceeded - } - } - t.closeStream(s, io.EOF, false, http2.ErrCodeNo, status.Newf(statusCode, "stream terminated by RST_STREAM with error code: %v", f.ErrCode), nil, false) -} - -func (t *http2Client) handleSettings(f *http2.SettingsFrame, isFirst bool) { - if f.IsAck() { - return - } - var maxStreams *uint32 - var ss []http2.Setting - var updateFuncs []func() - f.ForeachSetting(func(s http2.Setting) error { - switch s.ID { - case http2.SettingMaxConcurrentStreams: - maxStreams = new(uint32) - *maxStreams = s.Val - case http2.SettingMaxHeaderListSize: - updateFuncs = append(updateFuncs, func() { - t.maxSendHeaderListSize = new(uint32) - *t.maxSendHeaderListSize = s.Val - }) - default: - ss = append(ss, s) - } - return nil - }) - if isFirst && maxStreams == nil { - maxStreams = new(uint32) - *maxStreams = math.MaxUint32 - } - sf := &incomingSettings{ - ss: ss, - } - if maxStreams != nil { - updateStreamQuota := func() { - delta := int64(*maxStreams) - int64(t.maxConcurrentStreams) - t.maxConcurrentStreams = *maxStreams - t.streamQuota += delta - if delta > 0 && t.waitingStreams > 0 { - close(t.streamsQuotaAvailable) // wake all of them up. - t.streamsQuotaAvailable = make(chan struct{}, 1) - } - } - updateFuncs = append(updateFuncs, updateStreamQuota) - } - t.controlBuf.executeAndPut(func(any) bool { - for _, f := range updateFuncs { - f() - } - return true - }, sf) -} - -func (t *http2Client) handlePing(f *http2.PingFrame) { - if f.IsAck() { - // Maybe it's a BDP ping. - if t.bdpEst != nil { - t.bdpEst.calculate(f.Data) - } - return - } - pingAck := &ping{ack: true} - copy(pingAck.data[:], f.Data[:]) - t.controlBuf.put(pingAck) -} - -func (t *http2Client) handleGoAway(f *http2.GoAwayFrame) { - t.mu.Lock() - if t.state == closing { - t.mu.Unlock() - return - } - if f.ErrCode == http2.ErrCodeEnhanceYourCalm && string(f.DebugData()) == "too_many_pings" { - // When a client receives a GOAWAY with error code ENHANCE_YOUR_CALM and debug - // data equal to ASCII "too_many_pings", it should log the occurrence at a log level that is - // enabled by default and double the configure KEEPALIVE_TIME used for new connections - // on that channel. - logger.Errorf("Client received GoAway with error code ENHANCE_YOUR_CALM and debug data equal to ASCII \"too_many_pings\".") - } - id := f.LastStreamID - if id > 0 && id%2 == 0 { - t.mu.Unlock() - t.Close(connectionErrorf(true, nil, "received goaway with non-zero even-numbered numbered stream id: %v", id)) - return - } - // A client can receive multiple GoAways from the server (see - // https://github.com/grpc/grpc-go/issues/1387). The idea is that the first - // GoAway will be sent with an ID of MaxInt32 and the second GoAway will be - // sent after an RTT delay with the ID of the last stream the server will - // process. - // - // Therefore, when we get the first GoAway we don't necessarily close any - // streams. While in case of second GoAway we close all streams created after - // the GoAwayId. This way streams that were in-flight while the GoAway from - // server was being sent don't get killed. - select { - case <-t.goAway: // t.goAway has been closed (i.e.,multiple GoAways). - // If there are multiple GoAways the first one should always have an ID greater than the following ones. - if id > t.prevGoAwayID { - t.mu.Unlock() - t.Close(connectionErrorf(true, nil, "received goaway with stream id: %v, which exceeds stream id of previous goaway: %v", id, t.prevGoAwayID)) - return - } - default: - t.setGoAwayReason(f) - close(t.goAway) - defer t.controlBuf.put(&incomingGoAway{}) // Defer as t.mu is currently held. - // Notify the clientconn about the GOAWAY before we set the state to - // draining, to allow the client to stop attempting to create streams - // before disallowing new streams on this connection. - if t.state != draining { - t.onClose(t.goAwayReason) - t.state = draining - } - } - // All streams with IDs greater than the GoAwayId - // and smaller than the previous GoAway ID should be killed. - upperLimit := t.prevGoAwayID - if upperLimit == 0 { // This is the first GoAway Frame. - upperLimit = math.MaxUint32 // Kill all streams after the GoAway ID. - } - - t.prevGoAwayID = id - if len(t.activeStreams) == 0 { - t.mu.Unlock() - t.Close(connectionErrorf(true, nil, "received goaway and there are no active streams")) - return - } - - streamsToClose := make([]*Stream, 0) - for streamID, stream := range t.activeStreams { - if streamID > id && streamID <= upperLimit { - // The stream was unprocessed by the server. - atomic.StoreUint32(&stream.unprocessed, 1) - streamsToClose = append(streamsToClose, stream) - } - } - t.mu.Unlock() - // Called outside t.mu because closeStream can take controlBuf's mu, which - // could induce deadlock and is not allowed. - for _, stream := range streamsToClose { - t.closeStream(stream, errStreamDrain, false, http2.ErrCodeNo, statusGoAway, nil, false) - } -} - -// setGoAwayReason sets the value of t.goAwayReason based -// on the GoAway frame received. -// It expects a lock on transport's mutex to be held by -// the caller. -func (t *http2Client) setGoAwayReason(f *http2.GoAwayFrame) { - t.goAwayReason = GoAwayNoReason - switch f.ErrCode { - case http2.ErrCodeEnhanceYourCalm: - if string(f.DebugData()) == "too_many_pings" { - t.goAwayReason = GoAwayTooManyPings - } - } - if len(f.DebugData()) == 0 { - t.goAwayDebugMessage = fmt.Sprintf("code: %s", f.ErrCode) - } else { - t.goAwayDebugMessage = fmt.Sprintf("code: %s, debug data: %q", f.ErrCode, string(f.DebugData())) - } -} - -func (t *http2Client) GetGoAwayReason() (GoAwayReason, string) { - t.mu.Lock() - defer t.mu.Unlock() - return t.goAwayReason, t.goAwayDebugMessage -} - -func (t *http2Client) handleWindowUpdate(f *http2.WindowUpdateFrame) { - t.controlBuf.put(&incomingWindowUpdate{ - streamID: f.Header().StreamID, - increment: f.Increment, - }) -} - -// operateHeaders takes action on the decoded headers. -func (t *http2Client) operateHeaders(frame *http2.MetaHeadersFrame) { - s := t.getStream(frame) - if s == nil { - return - } - endStream := frame.StreamEnded() - atomic.StoreUint32(&s.bytesReceived, 1) - initialHeader := atomic.LoadUint32(&s.headerChanClosed) == 0 - - if !initialHeader && !endStream { - // As specified by gRPC over HTTP2, a HEADERS frame (and associated CONTINUATION frames) can only appear at the start or end of a stream. Therefore, second HEADERS frame must have EOS bit set. - st := status.New(codes.Internal, "a HEADERS frame cannot appear in the middle of a stream") - t.closeStream(s, st.Err(), true, http2.ErrCodeProtocol, st, nil, false) - return - } - - // frame.Truncated is set to true when framer detects that the current header - // list size hits MaxHeaderListSize limit. - if frame.Truncated { - se := status.New(codes.Internal, "peer header list size exceeded limit") - t.closeStream(s, se.Err(), true, http2.ErrCodeFrameSize, se, nil, endStream) - return - } - - var ( - // If a gRPC Response-Headers has already been received, then it means - // that the peer is speaking gRPC and we are in gRPC mode. - isGRPC = !initialHeader - mdata = make(map[string][]string) - contentTypeErr = "malformed header: missing HTTP content-type" - grpcMessage string - recvCompress string - httpStatusCode *int - httpStatusErr string - rawStatusCode = codes.Unknown - // headerError is set if an error is encountered while parsing the headers - headerError string - ) - - if initialHeader { - httpStatusErr = "malformed header: missing HTTP status" - } - - for _, hf := range frame.Fields { - switch hf.Name { - case "content-type": - if _, validContentType := grpcutil.ContentSubtype(hf.Value); !validContentType { - contentTypeErr = fmt.Sprintf("transport: received unexpected content-type %q", hf.Value) - break - } - contentTypeErr = "" - mdata[hf.Name] = append(mdata[hf.Name], hf.Value) - isGRPC = true - case "grpc-encoding": - recvCompress = hf.Value - case "grpc-status": - code, err := strconv.ParseInt(hf.Value, 10, 32) - if err != nil { - se := status.New(codes.Internal, fmt.Sprintf("transport: malformed grpc-status: %v", err)) - t.closeStream(s, se.Err(), true, http2.ErrCodeProtocol, se, nil, endStream) - return - } - rawStatusCode = codes.Code(uint32(code)) - case "grpc-message": - grpcMessage = decodeGrpcMessage(hf.Value) - case ":status": - if hf.Value == "200" { - httpStatusErr = "" - statusCode := 200 - httpStatusCode = &statusCode - break - } - - c, err := strconv.ParseInt(hf.Value, 10, 32) - if err != nil { - se := status.New(codes.Internal, fmt.Sprintf("transport: malformed http-status: %v", err)) - t.closeStream(s, se.Err(), true, http2.ErrCodeProtocol, se, nil, endStream) - return - } - statusCode := int(c) - httpStatusCode = &statusCode - - httpStatusErr = fmt.Sprintf( - "unexpected HTTP status code received from server: %d (%s)", - statusCode, - http.StatusText(statusCode), - ) - default: - if isReservedHeader(hf.Name) && !isWhitelistedHeader(hf.Name) { - break - } - v, err := decodeMetadataHeader(hf.Name, hf.Value) - if err != nil { - headerError = fmt.Sprintf("transport: malformed %s: %v", hf.Name, err) - logger.Warningf("Failed to decode metadata header (%q, %q): %v", hf.Name, hf.Value, err) - break - } - mdata[hf.Name] = append(mdata[hf.Name], v) - } - } - - if !isGRPC || httpStatusErr != "" { - var code = codes.Internal // when header does not include HTTP status, return INTERNAL - - if httpStatusCode != nil { - var ok bool - code, ok = HTTPStatusConvTab[*httpStatusCode] - if !ok { - code = codes.Unknown - } - } - var errs []string - if httpStatusErr != "" { - errs = append(errs, httpStatusErr) - } - if contentTypeErr != "" { - errs = append(errs, contentTypeErr) - } - // Verify the HTTP response is a 200. - se := status.New(code, strings.Join(errs, "; ")) - t.closeStream(s, se.Err(), true, http2.ErrCodeProtocol, se, nil, endStream) - return - } - - if headerError != "" { - se := status.New(codes.Internal, headerError) - t.closeStream(s, se.Err(), true, http2.ErrCodeProtocol, se, nil, endStream) - return - } - - // For headers, set them in s.header and close headerChan. For trailers or - // trailers-only, closeStream will set the trailers and close headerChan as - // needed. - if !endStream { - // If headerChan hasn't been closed yet (expected, given we checked it - // above, but something else could have potentially closed the whole - // stream). - if atomic.CompareAndSwapUint32(&s.headerChanClosed, 0, 1) { - s.headerValid = true - // These values can be set without any synchronization because - // stream goroutine will read it only after seeing a closed - // headerChan which we'll close after setting this. - s.recvCompress = recvCompress - if len(mdata) > 0 { - s.header = mdata - } - close(s.headerChan) - } - } - - for _, sh := range t.statsHandlers { - if !endStream { - inHeader := &stats.InHeader{ - Client: true, - WireLength: int(frame.Header().Length), - Header: metadata.MD(mdata).Copy(), - Compression: s.recvCompress, - } - sh.HandleRPC(s.ctx, inHeader) - } else { - inTrailer := &stats.InTrailer{ - Client: true, - WireLength: int(frame.Header().Length), - Trailer: metadata.MD(mdata).Copy(), - } - sh.HandleRPC(s.ctx, inTrailer) - } - } - - if !endStream { - return - } - - status := istatus.NewWithProto(rawStatusCode, grpcMessage, mdata[grpcStatusDetailsBinHeader]) - - // If client received END_STREAM from server while stream was still active, - // send RST_STREAM. - rstStream := s.getState() == streamActive - t.closeStream(s, io.EOF, rstStream, http2.ErrCodeNo, status, mdata, true) -} - -// readServerPreface reads and handles the initial settings frame from the -// server. -func (t *http2Client) readServerPreface() error { - frame, err := t.framer.fr.ReadFrame() - if err != nil { - return connectionErrorf(true, err, "error reading server preface: %v", err) - } - sf, ok := frame.(*http2.SettingsFrame) - if !ok { - return connectionErrorf(true, nil, "initial http2 frame from server is not a settings frame: %T", frame) - } - t.handleSettings(sf, true) - return nil -} - -// reader verifies the server preface and reads all subsequent data from -// network connection. If the server preface is not read successfully, an -// error is pushed to errCh; otherwise errCh is closed with no error. -func (t *http2Client) reader(errCh chan<- error) { - defer close(t.readerDone) - - if err := t.readServerPreface(); err != nil { - errCh <- err - return - } - close(errCh) - if t.keepaliveEnabled { - atomic.StoreInt64(&t.lastRead, time.Now().UnixNano()) - } - - // loop to keep reading incoming messages on this transport. - for { - t.controlBuf.throttle() - frame, err := t.framer.fr.ReadFrame() - if t.keepaliveEnabled { - atomic.StoreInt64(&t.lastRead, time.Now().UnixNano()) - } - if err != nil { - // Abort an active stream if the http2.Framer returns a - // http2.StreamError. This can happen only if the server's response - // is malformed http2. - if se, ok := err.(http2.StreamError); ok { - t.mu.Lock() - s := t.activeStreams[se.StreamID] - t.mu.Unlock() - if s != nil { - // use error detail to provide better err message - code := http2ErrConvTab[se.Code] - errorDetail := t.framer.fr.ErrorDetail() - var msg string - if errorDetail != nil { - msg = errorDetail.Error() - } else { - msg = "received invalid frame" - } - t.closeStream(s, status.Error(code, msg), true, http2.ErrCodeProtocol, status.New(code, msg), nil, false) - } - continue - } else { - // Transport error. - t.Close(connectionErrorf(true, err, "error reading from server: %v", err)) - return - } - } - switch frame := frame.(type) { - case *http2.MetaHeadersFrame: - t.operateHeaders(frame) - case *http2.DataFrame: - t.handleData(frame) - case *http2.RSTStreamFrame: - t.handleRSTStream(frame) - case *http2.SettingsFrame: - t.handleSettings(frame, false) - case *http2.PingFrame: - t.handlePing(frame) - case *http2.GoAwayFrame: - t.handleGoAway(frame) - case *http2.WindowUpdateFrame: - t.handleWindowUpdate(frame) - default: - if logger.V(logLevel) { - logger.Errorf("transport: http2Client.reader got unhandled frame type %v.", frame) - } - } - } -} - -func minTime(a, b time.Duration) time.Duration { - if a < b { - return a - } - return b -} - -// keepalive running in a separate goroutine makes sure the connection is alive by sending pings. -func (t *http2Client) keepalive() { - p := &ping{data: [8]byte{}} - // True iff a ping has been sent, and no data has been received since then. - outstandingPing := false - // Amount of time remaining before which we should receive an ACK for the - // last sent ping. - timeoutLeft := time.Duration(0) - // Records the last value of t.lastRead before we go block on the timer. - // This is required to check for read activity since then. - prevNano := time.Now().UnixNano() - timer := time.NewTimer(t.kp.Time) - for { - select { - case <-timer.C: - lastRead := atomic.LoadInt64(&t.lastRead) - if lastRead > prevNano { - // There has been read activity since the last time we were here. - outstandingPing = false - // Next timer should fire at kp.Time seconds from lastRead time. - timer.Reset(time.Duration(lastRead) + t.kp.Time - time.Duration(time.Now().UnixNano())) - prevNano = lastRead - continue - } - if outstandingPing && timeoutLeft <= 0 { - t.Close(connectionErrorf(true, nil, "keepalive ping failed to receive ACK within timeout")) - return - } - t.mu.Lock() - if t.state == closing { - // If the transport is closing, we should exit from the - // keepalive goroutine here. If not, we could have a race - // between the call to Signal() from Close() and the call to - // Wait() here, whereby the keepalive goroutine ends up - // blocking on the condition variable which will never be - // signalled again. - t.mu.Unlock() - return - } - if len(t.activeStreams) < 1 && !t.kp.PermitWithoutStream { - // If a ping was sent out previously (because there were active - // streams at that point) which wasn't acked and its timeout - // hadn't fired, but we got here and are about to go dormant, - // we should make sure that we unconditionally send a ping once - // we awaken. - outstandingPing = false - t.kpDormant = true - t.kpDormancyCond.Wait() - } - t.kpDormant = false - t.mu.Unlock() - - // We get here either because we were dormant and a new stream was - // created which unblocked the Wait() call, or because the - // keepalive timer expired. In both cases, we need to send a ping. - if !outstandingPing { - if channelz.IsOn() { - t.channelz.SocketMetrics.KeepAlivesSent.Add(1) - } - t.controlBuf.put(p) - timeoutLeft = t.kp.Timeout - outstandingPing = true - } - // The amount of time to sleep here is the minimum of kp.Time and - // timeoutLeft. This will ensure that we wait only for kp.Time - // before sending out the next ping (for cases where the ping is - // acked). - sleepDuration := minTime(t.kp.Time, timeoutLeft) - timeoutLeft -= sleepDuration - timer.Reset(sleepDuration) - case <-t.ctx.Done(): - if !timer.Stop() { - <-timer.C - } - return - } - } -} - -func (t *http2Client) Error() <-chan struct{} { - return t.ctx.Done() -} - -func (t *http2Client) GoAway() <-chan struct{} { - return t.goAway -} - -func (t *http2Client) socketMetrics() *channelz.EphemeralSocketMetrics { - return &channelz.EphemeralSocketMetrics{ - LocalFlowControlWindow: int64(t.fc.getSize()), - RemoteFlowControlWindow: t.getOutFlowWindow(), - } -} - -func (t *http2Client) RemoteAddr() net.Addr { return t.remoteAddr } - -func (t *http2Client) IncrMsgSent() { - t.channelz.SocketMetrics.MessagesSent.Add(1) - t.channelz.SocketMetrics.LastMessageSentTimestamp.Store(time.Now().UnixNano()) -} - -func (t *http2Client) IncrMsgRecv() { - t.channelz.SocketMetrics.MessagesReceived.Add(1) - t.channelz.SocketMetrics.LastMessageReceivedTimestamp.Store(time.Now().UnixNano()) -} - -func (t *http2Client) getOutFlowWindow() int64 { - resp := make(chan uint32, 1) - timer := time.NewTimer(time.Second) - defer timer.Stop() - t.controlBuf.put(&outFlowControlSizeRequest{resp}) - select { - case sz := <-resp: - return int64(sz) - case <-t.ctxDone: - return -1 - case <-timer.C: - return -2 - } -} - -func (t *http2Client) stateForTesting() transportState { - t.mu.Lock() - defer t.mu.Unlock() - return t.state -} diff --git a/vendor/google.golang.org/grpc/internal/transport/http2_server.go b/vendor/google.golang.org/grpc/internal/transport/http2_server.go deleted file mode 100644 index d582e0471..000000000 --- a/vendor/google.golang.org/grpc/internal/transport/http2_server.go +++ /dev/null @@ -1,1460 +0,0 @@ -/* - * - * Copyright 2014 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package transport - -import ( - "bytes" - "context" - "errors" - "fmt" - "io" - "math" - "net" - "net/http" - "strconv" - "sync" - "sync/atomic" - "time" - - "golang.org/x/net/http2" - "golang.org/x/net/http2/hpack" - "google.golang.org/grpc/internal/grpclog" - "google.golang.org/grpc/internal/grpcutil" - "google.golang.org/grpc/internal/pretty" - "google.golang.org/grpc/internal/syscall" - "google.golang.org/protobuf/proto" - - "google.golang.org/grpc/codes" - "google.golang.org/grpc/credentials" - "google.golang.org/grpc/internal/channelz" - "google.golang.org/grpc/internal/grpcrand" - "google.golang.org/grpc/internal/grpcsync" - "google.golang.org/grpc/keepalive" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/peer" - "google.golang.org/grpc/stats" - "google.golang.org/grpc/status" - "google.golang.org/grpc/tap" -) - -var ( - // ErrIllegalHeaderWrite indicates that setting header is illegal because of - // the stream's state. - ErrIllegalHeaderWrite = status.Error(codes.Internal, "transport: SendHeader called multiple times") - // ErrHeaderListSizeLimitViolation indicates that the header list size is larger - // than the limit set by peer. - ErrHeaderListSizeLimitViolation = status.Error(codes.Internal, "transport: trying to send header list size larger than the limit set by peer") -) - -// serverConnectionCounter counts the number of connections a server has seen -// (equal to the number of http2Servers created). Must be accessed atomically. -var serverConnectionCounter uint64 - -// http2Server implements the ServerTransport interface with HTTP2. -type http2Server struct { - lastRead int64 // Keep this field 64-bit aligned. Accessed atomically. - done chan struct{} - conn net.Conn - loopy *loopyWriter - readerDone chan struct{} // sync point to enable testing. - loopyWriterDone chan struct{} - peer peer.Peer - inTapHandle tap.ServerInHandle - framer *framer - // The max number of concurrent streams. - maxStreams uint32 - // controlBuf delivers all the control related tasks (e.g., window - // updates, reset streams, and various settings) to the controller. - controlBuf *controlBuffer - fc *trInFlow - stats []stats.Handler - // Keepalive and max-age parameters for the server. - kp keepalive.ServerParameters - // Keepalive enforcement policy. - kep keepalive.EnforcementPolicy - // The time instance last ping was received. - lastPingAt time.Time - // Number of times the client has violated keepalive ping policy so far. - pingStrikes uint8 - // Flag to signify that number of ping strikes should be reset to 0. - // This is set whenever data or header frames are sent. - // 1 means yes. - resetPingStrikes uint32 // Accessed atomically. - initialWindowSize int32 - bdpEst *bdpEstimator - maxSendHeaderListSize *uint32 - - mu sync.Mutex // guard the following - - // drainEvent is initialized when Drain() is called the first time. After - // which the server writes out the first GoAway(with ID 2^31-1) frame. Then - // an independent goroutine will be launched to later send the second - // GoAway. During this time we don't want to write another first GoAway(with - // ID 2^31 -1) frame. Thus call to Drain() will be a no-op if drainEvent is - // already initialized since draining is already underway. - drainEvent *grpcsync.Event - state transportState - activeStreams map[uint32]*Stream - // idle is the time instant when the connection went idle. - // This is either the beginning of the connection or when the number of - // RPCs go down to 0. - // When the connection is busy, this value is set to 0. - idle time.Time - - // Fields below are for channelz metric collection. - channelz *channelz.Socket - bufferPool *bufferPool - - connectionID uint64 - - // maxStreamMu guards the maximum stream ID - // This lock may not be taken if mu is already held. - maxStreamMu sync.Mutex - maxStreamID uint32 // max stream ID ever seen - - logger *grpclog.PrefixLogger -} - -// NewServerTransport creates a http2 transport with conn and configuration -// options from config. -// -// It returns a non-nil transport and a nil error on success. On failure, it -// returns a nil transport and a non-nil error. For a special case where the -// underlying conn gets closed before the client preface could be read, it -// returns a nil transport and a nil error. -func NewServerTransport(conn net.Conn, config *ServerConfig) (_ ServerTransport, err error) { - var authInfo credentials.AuthInfo - rawConn := conn - if config.Credentials != nil { - var err error - conn, authInfo, err = config.Credentials.ServerHandshake(rawConn) - if err != nil { - // ErrConnDispatched means that the connection was dispatched away - // from gRPC; those connections should be left open. io.EOF means - // the connection was closed before handshaking completed, which can - // happen naturally from probers. Return these errors directly. - if err == credentials.ErrConnDispatched || err == io.EOF { - return nil, err - } - return nil, connectionErrorf(false, err, "ServerHandshake(%q) failed: %v", rawConn.RemoteAddr(), err) - } - } - writeBufSize := config.WriteBufferSize - readBufSize := config.ReadBufferSize - maxHeaderListSize := defaultServerMaxHeaderListSize - if config.MaxHeaderListSize != nil { - maxHeaderListSize = *config.MaxHeaderListSize - } - framer := newFramer(conn, writeBufSize, readBufSize, config.SharedWriteBuffer, maxHeaderListSize) - // Send initial settings as connection preface to client. - isettings := []http2.Setting{{ - ID: http2.SettingMaxFrameSize, - Val: http2MaxFrameLen, - }} - if config.MaxStreams != math.MaxUint32 { - isettings = append(isettings, http2.Setting{ - ID: http2.SettingMaxConcurrentStreams, - Val: config.MaxStreams, - }) - } - dynamicWindow := true - iwz := int32(initialWindowSize) - if config.InitialWindowSize >= defaultWindowSize { - iwz = config.InitialWindowSize - dynamicWindow = false - } - icwz := int32(initialWindowSize) - if config.InitialConnWindowSize >= defaultWindowSize { - icwz = config.InitialConnWindowSize - dynamicWindow = false - } - if iwz != defaultWindowSize { - isettings = append(isettings, http2.Setting{ - ID: http2.SettingInitialWindowSize, - Val: uint32(iwz)}) - } - if config.MaxHeaderListSize != nil { - isettings = append(isettings, http2.Setting{ - ID: http2.SettingMaxHeaderListSize, - Val: *config.MaxHeaderListSize, - }) - } - if config.HeaderTableSize != nil { - isettings = append(isettings, http2.Setting{ - ID: http2.SettingHeaderTableSize, - Val: *config.HeaderTableSize, - }) - } - if err := framer.fr.WriteSettings(isettings...); err != nil { - return nil, connectionErrorf(false, err, "transport: %v", err) - } - // Adjust the connection flow control window if needed. - if delta := uint32(icwz - defaultWindowSize); delta > 0 { - if err := framer.fr.WriteWindowUpdate(0, delta); err != nil { - return nil, connectionErrorf(false, err, "transport: %v", err) - } - } - kp := config.KeepaliveParams - if kp.MaxConnectionIdle == 0 { - kp.MaxConnectionIdle = defaultMaxConnectionIdle - } - if kp.MaxConnectionAge == 0 { - kp.MaxConnectionAge = defaultMaxConnectionAge - } - // Add a jitter to MaxConnectionAge. - kp.MaxConnectionAge += getJitter(kp.MaxConnectionAge) - if kp.MaxConnectionAgeGrace == 0 { - kp.MaxConnectionAgeGrace = defaultMaxConnectionAgeGrace - } - if kp.Time == 0 { - kp.Time = defaultServerKeepaliveTime - } - if kp.Timeout == 0 { - kp.Timeout = defaultServerKeepaliveTimeout - } - if kp.Time != infinity { - if err = syscall.SetTCPUserTimeout(rawConn, kp.Timeout); err != nil { - return nil, connectionErrorf(false, err, "transport: failed to set TCP_USER_TIMEOUT: %v", err) - } - } - kep := config.KeepalivePolicy - if kep.MinTime == 0 { - kep.MinTime = defaultKeepalivePolicyMinTime - } - - done := make(chan struct{}) - peer := peer.Peer{ - Addr: conn.RemoteAddr(), - LocalAddr: conn.LocalAddr(), - AuthInfo: authInfo, - } - t := &http2Server{ - done: done, - conn: conn, - peer: peer, - framer: framer, - readerDone: make(chan struct{}), - loopyWriterDone: make(chan struct{}), - maxStreams: config.MaxStreams, - inTapHandle: config.InTapHandle, - fc: &trInFlow{limit: uint32(icwz)}, - state: reachable, - activeStreams: make(map[uint32]*Stream), - stats: config.StatsHandlers, - kp: kp, - idle: time.Now(), - kep: kep, - initialWindowSize: iwz, - bufferPool: newBufferPool(), - } - var czSecurity credentials.ChannelzSecurityValue - if au, ok := authInfo.(credentials.ChannelzSecurityInfo); ok { - czSecurity = au.GetSecurityValue() - } - t.channelz = channelz.RegisterSocket( - &channelz.Socket{ - SocketType: channelz.SocketTypeNormal, - Parent: config.ChannelzParent, - SocketMetrics: channelz.SocketMetrics{}, - EphemeralMetrics: t.socketMetrics, - LocalAddr: t.peer.LocalAddr, - RemoteAddr: t.peer.Addr, - SocketOptions: channelz.GetSocketOption(t.conn), - Security: czSecurity, - }, - ) - t.logger = prefixLoggerForServerTransport(t) - - t.controlBuf = newControlBuffer(t.done) - if dynamicWindow { - t.bdpEst = &bdpEstimator{ - bdp: initialWindowSize, - updateFlowControl: t.updateFlowControl, - } - } - - t.connectionID = atomic.AddUint64(&serverConnectionCounter, 1) - t.framer.writer.Flush() - - defer func() { - if err != nil { - t.Close(err) - } - }() - - // Check the validity of client preface. - preface := make([]byte, len(clientPreface)) - if _, err := io.ReadFull(t.conn, preface); err != nil { - // In deployments where a gRPC server runs behind a cloud load balancer - // which performs regular TCP level health checks, the connection is - // closed immediately by the latter. Returning io.EOF here allows the - // grpc server implementation to recognize this scenario and suppress - // logging to reduce spam. - if err == io.EOF { - return nil, io.EOF - } - return nil, connectionErrorf(false, err, "transport: http2Server.HandleStreams failed to receive the preface from client: %v", err) - } - if !bytes.Equal(preface, clientPreface) { - return nil, connectionErrorf(false, nil, "transport: http2Server.HandleStreams received bogus greeting from client: %q", preface) - } - - frame, err := t.framer.fr.ReadFrame() - if err == io.EOF || err == io.ErrUnexpectedEOF { - return nil, err - } - if err != nil { - return nil, connectionErrorf(false, err, "transport: http2Server.HandleStreams failed to read initial settings frame: %v", err) - } - atomic.StoreInt64(&t.lastRead, time.Now().UnixNano()) - sf, ok := frame.(*http2.SettingsFrame) - if !ok { - return nil, connectionErrorf(false, nil, "transport: http2Server.HandleStreams saw invalid preface type %T from client", frame) - } - t.handleSettings(sf) - - go func() { - t.loopy = newLoopyWriter(serverSide, t.framer, t.controlBuf, t.bdpEst, t.conn, t.logger) - t.loopy.ssGoAwayHandler = t.outgoingGoAwayHandler - err := t.loopy.run() - close(t.loopyWriterDone) - if !isIOError(err) { - // Close the connection if a non-I/O error occurs (for I/O errors - // the reader will also encounter the error and close). Wait 1 - // second before closing the connection, or when the reader is done - // (i.e. the client already closed the connection or a connection - // error occurred). This avoids the potential problem where there - // is unread data on the receive side of the connection, which, if - // closed, would lead to a TCP RST instead of FIN, and the client - // encountering errors. For more info: - // https://github.com/grpc/grpc-go/issues/5358 - timer := time.NewTimer(time.Second) - defer timer.Stop() - select { - case <-t.readerDone: - case <-timer.C: - } - t.conn.Close() - } - }() - go t.keepalive() - return t, nil -} - -// operateHeaders takes action on the decoded headers. Returns an error if fatal -// error encountered and transport needs to close, otherwise returns nil. -func (t *http2Server) operateHeaders(ctx context.Context, frame *http2.MetaHeadersFrame, handle func(*Stream)) error { - // Acquire max stream ID lock for entire duration - t.maxStreamMu.Lock() - defer t.maxStreamMu.Unlock() - - streamID := frame.Header().StreamID - - // frame.Truncated is set to true when framer detects that the current header - // list size hits MaxHeaderListSize limit. - if frame.Truncated { - t.controlBuf.put(&cleanupStream{ - streamID: streamID, - rst: true, - rstCode: http2.ErrCodeFrameSize, - onWrite: func() {}, - }) - return nil - } - - if streamID%2 != 1 || streamID <= t.maxStreamID { - // illegal gRPC stream id. - return fmt.Errorf("received an illegal stream id: %v. headers frame: %+v", streamID, frame) - } - t.maxStreamID = streamID - - buf := newRecvBuffer() - s := &Stream{ - id: streamID, - st: t, - buf: buf, - fc: &inFlow{limit: uint32(t.initialWindowSize)}, - headerWireLength: int(frame.Header().Length), - } - var ( - // if false, content-type was missing or invalid - isGRPC = false - contentType = "" - mdata = make(metadata.MD, len(frame.Fields)) - httpMethod string - // these are set if an error is encountered while parsing the headers - protocolError bool - headerError *status.Status - - timeoutSet bool - timeout time.Duration - ) - - for _, hf := range frame.Fields { - switch hf.Name { - case "content-type": - contentSubtype, validContentType := grpcutil.ContentSubtype(hf.Value) - if !validContentType { - contentType = hf.Value - break - } - mdata[hf.Name] = append(mdata[hf.Name], hf.Value) - s.contentSubtype = contentSubtype - isGRPC = true - - case "grpc-accept-encoding": - mdata[hf.Name] = append(mdata[hf.Name], hf.Value) - if hf.Value == "" { - continue - } - compressors := hf.Value - if s.clientAdvertisedCompressors != "" { - compressors = s.clientAdvertisedCompressors + "," + compressors - } - s.clientAdvertisedCompressors = compressors - case "grpc-encoding": - s.recvCompress = hf.Value - case ":method": - httpMethod = hf.Value - case ":path": - s.method = hf.Value - case "grpc-timeout": - timeoutSet = true - var err error - if timeout, err = decodeTimeout(hf.Value); err != nil { - headerError = status.Newf(codes.Internal, "malformed grpc-timeout: %v", err) - } - // "Transports must consider requests containing the Connection header - // as malformed." - A41 - case "connection": - if t.logger.V(logLevel) { - t.logger.Infof("Received a HEADERS frame with a :connection header which makes the request malformed, as per the HTTP/2 spec") - } - protocolError = true - default: - if isReservedHeader(hf.Name) && !isWhitelistedHeader(hf.Name) { - break - } - v, err := decodeMetadataHeader(hf.Name, hf.Value) - if err != nil { - headerError = status.Newf(codes.Internal, "malformed binary metadata %q in header %q: %v", hf.Value, hf.Name, err) - t.logger.Warningf("Failed to decode metadata header (%q, %q): %v", hf.Name, hf.Value, err) - break - } - mdata[hf.Name] = append(mdata[hf.Name], v) - } - } - - // "If multiple Host headers or multiple :authority headers are present, the - // request must be rejected with an HTTP status code 400 as required by Host - // validation in RFC 7230 §5.4, gRPC status code INTERNAL, or RST_STREAM - // with HTTP/2 error code PROTOCOL_ERROR." - A41. Since this is a HTTP/2 - // error, this takes precedence over a client not speaking gRPC. - if len(mdata[":authority"]) > 1 || len(mdata["host"]) > 1 { - errMsg := fmt.Sprintf("num values of :authority: %v, num values of host: %v, both must only have 1 value as per HTTP/2 spec", len(mdata[":authority"]), len(mdata["host"])) - if t.logger.V(logLevel) { - t.logger.Infof("Aborting the stream early: %v", errMsg) - } - t.controlBuf.put(&earlyAbortStream{ - httpStatus: http.StatusBadRequest, - streamID: streamID, - contentSubtype: s.contentSubtype, - status: status.New(codes.Internal, errMsg), - rst: !frame.StreamEnded(), - }) - return nil - } - - if protocolError { - t.controlBuf.put(&cleanupStream{ - streamID: streamID, - rst: true, - rstCode: http2.ErrCodeProtocol, - onWrite: func() {}, - }) - return nil - } - if !isGRPC { - t.controlBuf.put(&earlyAbortStream{ - httpStatus: http.StatusUnsupportedMediaType, - streamID: streamID, - contentSubtype: s.contentSubtype, - status: status.Newf(codes.InvalidArgument, "invalid gRPC request content-type %q", contentType), - rst: !frame.StreamEnded(), - }) - return nil - } - if headerError != nil { - t.controlBuf.put(&earlyAbortStream{ - httpStatus: http.StatusBadRequest, - streamID: streamID, - contentSubtype: s.contentSubtype, - status: headerError, - rst: !frame.StreamEnded(), - }) - return nil - } - - // "If :authority is missing, Host must be renamed to :authority." - A41 - if len(mdata[":authority"]) == 0 { - // No-op if host isn't present, no eventual :authority header is a valid - // RPC. - if host, ok := mdata["host"]; ok { - mdata[":authority"] = host - delete(mdata, "host") - } - } else { - // "If :authority is present, Host must be discarded" - A41 - delete(mdata, "host") - } - - if frame.StreamEnded() { - // s is just created by the caller. No lock needed. - s.state = streamReadDone - } - if timeoutSet { - s.ctx, s.cancel = context.WithTimeout(ctx, timeout) - } else { - s.ctx, s.cancel = context.WithCancel(ctx) - } - - // Attach the received metadata to the context. - if len(mdata) > 0 { - s.ctx = metadata.NewIncomingContext(s.ctx, mdata) - if statsTags := mdata["grpc-tags-bin"]; len(statsTags) > 0 { - s.ctx = stats.SetIncomingTags(s.ctx, []byte(statsTags[len(statsTags)-1])) - } - if statsTrace := mdata["grpc-trace-bin"]; len(statsTrace) > 0 { - s.ctx = stats.SetIncomingTrace(s.ctx, []byte(statsTrace[len(statsTrace)-1])) - } - } - t.mu.Lock() - if t.state != reachable { - t.mu.Unlock() - s.cancel() - return nil - } - if uint32(len(t.activeStreams)) >= t.maxStreams { - t.mu.Unlock() - t.controlBuf.put(&cleanupStream{ - streamID: streamID, - rst: true, - rstCode: http2.ErrCodeRefusedStream, - onWrite: func() {}, - }) - s.cancel() - return nil - } - if httpMethod != http.MethodPost { - t.mu.Unlock() - errMsg := fmt.Sprintf("Received a HEADERS frame with :method %q which should be POST", httpMethod) - if t.logger.V(logLevel) { - t.logger.Infof("Aborting the stream early: %v", errMsg) - } - t.controlBuf.put(&earlyAbortStream{ - httpStatus: 405, - streamID: streamID, - contentSubtype: s.contentSubtype, - status: status.New(codes.Internal, errMsg), - rst: !frame.StreamEnded(), - }) - s.cancel() - return nil - } - if t.inTapHandle != nil { - var err error - if s.ctx, err = t.inTapHandle(s.ctx, &tap.Info{FullMethodName: s.method, Header: mdata}); err != nil { - t.mu.Unlock() - if t.logger.V(logLevel) { - t.logger.Infof("Aborting the stream early due to InTapHandle failure: %v", err) - } - stat, ok := status.FromError(err) - if !ok { - stat = status.New(codes.PermissionDenied, err.Error()) - } - t.controlBuf.put(&earlyAbortStream{ - httpStatus: 200, - streamID: s.id, - contentSubtype: s.contentSubtype, - status: stat, - rst: !frame.StreamEnded(), - }) - return nil - } - } - t.activeStreams[streamID] = s - if len(t.activeStreams) == 1 { - t.idle = time.Time{} - } - t.mu.Unlock() - if channelz.IsOn() { - t.channelz.SocketMetrics.StreamsStarted.Add(1) - t.channelz.SocketMetrics.LastRemoteStreamCreatedTimestamp.Store(time.Now().UnixNano()) - } - s.requestRead = func(n int) { - t.adjustWindow(s, uint32(n)) - } - s.ctxDone = s.ctx.Done() - s.wq = newWriteQuota(defaultWriteQuota, s.ctxDone) - s.trReader = &transportReader{ - reader: &recvBufferReader{ - ctx: s.ctx, - ctxDone: s.ctxDone, - recv: s.buf, - freeBuffer: t.bufferPool.put, - }, - windowHandler: func(n int) { - t.updateWindow(s, uint32(n)) - }, - } - // Register the stream with loopy. - t.controlBuf.put(®isterStream{ - streamID: s.id, - wq: s.wq, - }) - handle(s) - return nil -} - -// HandleStreams receives incoming streams using the given handler. This is -// typically run in a separate goroutine. -// traceCtx attaches trace to ctx and returns the new context. -func (t *http2Server) HandleStreams(ctx context.Context, handle func(*Stream)) { - defer func() { - close(t.readerDone) - <-t.loopyWriterDone - }() - for { - t.controlBuf.throttle() - frame, err := t.framer.fr.ReadFrame() - atomic.StoreInt64(&t.lastRead, time.Now().UnixNano()) - if err != nil { - if se, ok := err.(http2.StreamError); ok { - if t.logger.V(logLevel) { - t.logger.Warningf("Encountered http2.StreamError: %v", se) - } - t.mu.Lock() - s := t.activeStreams[se.StreamID] - t.mu.Unlock() - if s != nil { - t.closeStream(s, true, se.Code, false) - } else { - t.controlBuf.put(&cleanupStream{ - streamID: se.StreamID, - rst: true, - rstCode: se.Code, - onWrite: func() {}, - }) - } - continue - } - t.Close(err) - return - } - switch frame := frame.(type) { - case *http2.MetaHeadersFrame: - if err := t.operateHeaders(ctx, frame, handle); err != nil { - // Any error processing client headers, e.g. invalid stream ID, - // is considered a protocol violation. - t.controlBuf.put(&goAway{ - code: http2.ErrCodeProtocol, - debugData: []byte(err.Error()), - closeConn: err, - }) - continue - } - case *http2.DataFrame: - t.handleData(frame) - case *http2.RSTStreamFrame: - t.handleRSTStream(frame) - case *http2.SettingsFrame: - t.handleSettings(frame) - case *http2.PingFrame: - t.handlePing(frame) - case *http2.WindowUpdateFrame: - t.handleWindowUpdate(frame) - case *http2.GoAwayFrame: - // TODO: Handle GoAway from the client appropriately. - default: - if t.logger.V(logLevel) { - t.logger.Infof("Received unsupported frame type %T", frame) - } - } - } -} - -func (t *http2Server) getStream(f http2.Frame) (*Stream, bool) { - t.mu.Lock() - defer t.mu.Unlock() - if t.activeStreams == nil { - // The transport is closing. - return nil, false - } - s, ok := t.activeStreams[f.Header().StreamID] - if !ok { - // The stream is already done. - return nil, false - } - return s, true -} - -// adjustWindow sends out extra window update over the initial window size -// of stream if the application is requesting data larger in size than -// the window. -func (t *http2Server) adjustWindow(s *Stream, n uint32) { - if w := s.fc.maybeAdjust(n); w > 0 { - t.controlBuf.put(&outgoingWindowUpdate{streamID: s.id, increment: w}) - } - -} - -// updateWindow adjusts the inbound quota for the stream and the transport. -// Window updates will deliver to the controller for sending when -// the cumulative quota exceeds the corresponding threshold. -func (t *http2Server) updateWindow(s *Stream, n uint32) { - if w := s.fc.onRead(n); w > 0 { - t.controlBuf.put(&outgoingWindowUpdate{streamID: s.id, - increment: w, - }) - } -} - -// updateFlowControl updates the incoming flow control windows -// for the transport and the stream based on the current bdp -// estimation. -func (t *http2Server) updateFlowControl(n uint32) { - t.mu.Lock() - for _, s := range t.activeStreams { - s.fc.newLimit(n) - } - t.initialWindowSize = int32(n) - t.mu.Unlock() - t.controlBuf.put(&outgoingWindowUpdate{ - streamID: 0, - increment: t.fc.newLimit(n), - }) - t.controlBuf.put(&outgoingSettings{ - ss: []http2.Setting{ - { - ID: http2.SettingInitialWindowSize, - Val: n, - }, - }, - }) - -} - -func (t *http2Server) handleData(f *http2.DataFrame) { - size := f.Header().Length - var sendBDPPing bool - if t.bdpEst != nil { - sendBDPPing = t.bdpEst.add(size) - } - // Decouple connection's flow control from application's read. - // An update on connection's flow control should not depend on - // whether user application has read the data or not. Such a - // restriction is already imposed on the stream's flow control, - // and therefore the sender will be blocked anyways. - // Decoupling the connection flow control will prevent other - // active(fast) streams from starving in presence of slow or - // inactive streams. - if w := t.fc.onData(size); w > 0 { - t.controlBuf.put(&outgoingWindowUpdate{ - streamID: 0, - increment: w, - }) - } - if sendBDPPing { - // Avoid excessive ping detection (e.g. in an L7 proxy) - // by sending a window update prior to the BDP ping. - if w := t.fc.reset(); w > 0 { - t.controlBuf.put(&outgoingWindowUpdate{ - streamID: 0, - increment: w, - }) - } - t.controlBuf.put(bdpPing) - } - // Select the right stream to dispatch. - s, ok := t.getStream(f) - if !ok { - return - } - if s.getState() == streamReadDone { - t.closeStream(s, true, http2.ErrCodeStreamClosed, false) - return - } - if size > 0 { - if err := s.fc.onData(size); err != nil { - t.closeStream(s, true, http2.ErrCodeFlowControl, false) - return - } - if f.Header().Flags.Has(http2.FlagDataPadded) { - if w := s.fc.onRead(size - uint32(len(f.Data()))); w > 0 { - t.controlBuf.put(&outgoingWindowUpdate{s.id, w}) - } - } - // TODO(bradfitz, zhaoq): A copy is required here because there is no - // guarantee f.Data() is consumed before the arrival of next frame. - // Can this copy be eliminated? - if len(f.Data()) > 0 { - buffer := t.bufferPool.get() - buffer.Reset() - buffer.Write(f.Data()) - s.write(recvMsg{buffer: buffer}) - } - } - if f.StreamEnded() { - // Received the end of stream from the client. - s.compareAndSwapState(streamActive, streamReadDone) - s.write(recvMsg{err: io.EOF}) - } -} - -func (t *http2Server) handleRSTStream(f *http2.RSTStreamFrame) { - // If the stream is not deleted from the transport's active streams map, then do a regular close stream. - if s, ok := t.getStream(f); ok { - t.closeStream(s, false, 0, false) - return - } - // If the stream is already deleted from the active streams map, then put a cleanupStream item into controlbuf to delete the stream from loopy writer's established streams map. - t.controlBuf.put(&cleanupStream{ - streamID: f.Header().StreamID, - rst: false, - rstCode: 0, - onWrite: func() {}, - }) -} - -func (t *http2Server) handleSettings(f *http2.SettingsFrame) { - if f.IsAck() { - return - } - var ss []http2.Setting - var updateFuncs []func() - f.ForeachSetting(func(s http2.Setting) error { - switch s.ID { - case http2.SettingMaxHeaderListSize: - updateFuncs = append(updateFuncs, func() { - t.maxSendHeaderListSize = new(uint32) - *t.maxSendHeaderListSize = s.Val - }) - default: - ss = append(ss, s) - } - return nil - }) - t.controlBuf.executeAndPut(func(any) bool { - for _, f := range updateFuncs { - f() - } - return true - }, &incomingSettings{ - ss: ss, - }) -} - -const ( - maxPingStrikes = 2 - defaultPingTimeout = 2 * time.Hour -) - -func (t *http2Server) handlePing(f *http2.PingFrame) { - if f.IsAck() { - if f.Data == goAwayPing.data && t.drainEvent != nil { - t.drainEvent.Fire() - return - } - // Maybe it's a BDP ping. - if t.bdpEst != nil { - t.bdpEst.calculate(f.Data) - } - return - } - pingAck := &ping{ack: true} - copy(pingAck.data[:], f.Data[:]) - t.controlBuf.put(pingAck) - - now := time.Now() - defer func() { - t.lastPingAt = now - }() - // A reset ping strikes means that we don't need to check for policy - // violation for this ping and the pingStrikes counter should be set - // to 0. - if atomic.CompareAndSwapUint32(&t.resetPingStrikes, 1, 0) { - t.pingStrikes = 0 - return - } - t.mu.Lock() - ns := len(t.activeStreams) - t.mu.Unlock() - if ns < 1 && !t.kep.PermitWithoutStream { - // Keepalive shouldn't be active thus, this new ping should - // have come after at least defaultPingTimeout. - if t.lastPingAt.Add(defaultPingTimeout).After(now) { - t.pingStrikes++ - } - } else { - // Check if keepalive policy is respected. - if t.lastPingAt.Add(t.kep.MinTime).After(now) { - t.pingStrikes++ - } - } - - if t.pingStrikes > maxPingStrikes { - // Send goaway and close the connection. - t.controlBuf.put(&goAway{code: http2.ErrCodeEnhanceYourCalm, debugData: []byte("too_many_pings"), closeConn: errors.New("got too many pings from the client")}) - } -} - -func (t *http2Server) handleWindowUpdate(f *http2.WindowUpdateFrame) { - t.controlBuf.put(&incomingWindowUpdate{ - streamID: f.Header().StreamID, - increment: f.Increment, - }) -} - -func appendHeaderFieldsFromMD(headerFields []hpack.HeaderField, md metadata.MD) []hpack.HeaderField { - for k, vv := range md { - if isReservedHeader(k) { - // Clients don't tolerate reading restricted headers after some non restricted ones were sent. - continue - } - for _, v := range vv { - headerFields = append(headerFields, hpack.HeaderField{Name: k, Value: encodeMetadataHeader(k, v)}) - } - } - return headerFields -} - -func (t *http2Server) checkForHeaderListSize(it any) bool { - if t.maxSendHeaderListSize == nil { - return true - } - hdrFrame := it.(*headerFrame) - var sz int64 - for _, f := range hdrFrame.hf { - if sz += int64(f.Size()); sz > int64(*t.maxSendHeaderListSize) { - if t.logger.V(logLevel) { - t.logger.Infof("Header list size to send violates the maximum size (%d bytes) set by client", *t.maxSendHeaderListSize) - } - return false - } - } - return true -} - -func (t *http2Server) streamContextErr(s *Stream) error { - select { - case <-t.done: - return ErrConnClosing - default: - } - return ContextErr(s.ctx.Err()) -} - -// WriteHeader sends the header metadata md back to the client. -func (t *http2Server) WriteHeader(s *Stream, md metadata.MD) error { - s.hdrMu.Lock() - defer s.hdrMu.Unlock() - if s.getState() == streamDone { - return t.streamContextErr(s) - } - - if s.updateHeaderSent() { - return ErrIllegalHeaderWrite - } - - if md.Len() > 0 { - if s.header.Len() > 0 { - s.header = metadata.Join(s.header, md) - } else { - s.header = md - } - } - if err := t.writeHeaderLocked(s); err != nil { - switch e := err.(type) { - case ConnectionError: - return status.Error(codes.Unavailable, e.Desc) - default: - return status.Convert(err).Err() - } - } - return nil -} - -func (t *http2Server) setResetPingStrikes() { - atomic.StoreUint32(&t.resetPingStrikes, 1) -} - -func (t *http2Server) writeHeaderLocked(s *Stream) error { - // TODO(mmukhi): Benchmark if the performance gets better if count the metadata and other header fields - // first and create a slice of that exact size. - headerFields := make([]hpack.HeaderField, 0, 2) // at least :status, content-type will be there if none else. - headerFields = append(headerFields, hpack.HeaderField{Name: ":status", Value: "200"}) - headerFields = append(headerFields, hpack.HeaderField{Name: "content-type", Value: grpcutil.ContentType(s.contentSubtype)}) - if s.sendCompress != "" { - headerFields = append(headerFields, hpack.HeaderField{Name: "grpc-encoding", Value: s.sendCompress}) - } - headerFields = appendHeaderFieldsFromMD(headerFields, s.header) - success, err := t.controlBuf.executeAndPut(t.checkForHeaderListSize, &headerFrame{ - streamID: s.id, - hf: headerFields, - endStream: false, - onWrite: t.setResetPingStrikes, - }) - if !success { - if err != nil { - return err - } - t.closeStream(s, true, http2.ErrCodeInternal, false) - return ErrHeaderListSizeLimitViolation - } - for _, sh := range t.stats { - // Note: Headers are compressed with hpack after this call returns. - // No WireLength field is set here. - outHeader := &stats.OutHeader{ - Header: s.header.Copy(), - Compression: s.sendCompress, - } - sh.HandleRPC(s.Context(), outHeader) - } - return nil -} - -// WriteStatus sends stream status to the client and terminates the stream. -// There is no further I/O operations being able to perform on this stream. -// TODO(zhaoq): Now it indicates the end of entire stream. Revisit if early -// OK is adopted. -func (t *http2Server) WriteStatus(s *Stream, st *status.Status) error { - s.hdrMu.Lock() - defer s.hdrMu.Unlock() - - if s.getState() == streamDone { - return nil - } - - // TODO(mmukhi): Benchmark if the performance gets better if count the metadata and other header fields - // first and create a slice of that exact size. - headerFields := make([]hpack.HeaderField, 0, 2) // grpc-status and grpc-message will be there if none else. - if !s.updateHeaderSent() { // No headers have been sent. - if len(s.header) > 0 { // Send a separate header frame. - if err := t.writeHeaderLocked(s); err != nil { - return err - } - } else { // Send a trailer only response. - headerFields = append(headerFields, hpack.HeaderField{Name: ":status", Value: "200"}) - headerFields = append(headerFields, hpack.HeaderField{Name: "content-type", Value: grpcutil.ContentType(s.contentSubtype)}) - } - } - headerFields = append(headerFields, hpack.HeaderField{Name: "grpc-status", Value: strconv.Itoa(int(st.Code()))}) - headerFields = append(headerFields, hpack.HeaderField{Name: "grpc-message", Value: encodeGrpcMessage(st.Message())}) - - if p := st.Proto(); p != nil && len(p.Details) > 0 { - // Do not use the user's grpc-status-details-bin (if present) if we are - // even attempting to set our own. - delete(s.trailer, grpcStatusDetailsBinHeader) - stBytes, err := proto.Marshal(p) - if err != nil { - // TODO: return error instead, when callers are able to handle it. - t.logger.Errorf("Failed to marshal rpc status: %s, error: %v", pretty.ToJSON(p), err) - } else { - headerFields = append(headerFields, hpack.HeaderField{Name: grpcStatusDetailsBinHeader, Value: encodeBinHeader(stBytes)}) - } - } - - // Attach the trailer metadata. - headerFields = appendHeaderFieldsFromMD(headerFields, s.trailer) - trailingHeader := &headerFrame{ - streamID: s.id, - hf: headerFields, - endStream: true, - onWrite: t.setResetPingStrikes, - } - - success, err := t.controlBuf.execute(t.checkForHeaderListSize, trailingHeader) - if !success { - if err != nil { - return err - } - t.closeStream(s, true, http2.ErrCodeInternal, false) - return ErrHeaderListSizeLimitViolation - } - // Send a RST_STREAM after the trailers if the client has not already half-closed. - rst := s.getState() == streamActive - t.finishStream(s, rst, http2.ErrCodeNo, trailingHeader, true) - for _, sh := range t.stats { - // Note: The trailer fields are compressed with hpack after this call returns. - // No WireLength field is set here. - sh.HandleRPC(s.Context(), &stats.OutTrailer{ - Trailer: s.trailer.Copy(), - }) - } - return nil -} - -// Write converts the data into HTTP2 data frame and sends it out. Non-nil error -// is returns if it fails (e.g., framing error, transport error). -func (t *http2Server) Write(s *Stream, hdr []byte, data []byte, opts *Options) error { - if !s.isHeaderSent() { // Headers haven't been written yet. - if err := t.WriteHeader(s, nil); err != nil { - return err - } - } else { - // Writing headers checks for this condition. - if s.getState() == streamDone { - return t.streamContextErr(s) - } - } - df := &dataFrame{ - streamID: s.id, - h: hdr, - d: data, - onEachWrite: t.setResetPingStrikes, - } - if err := s.wq.get(int32(len(hdr) + len(data))); err != nil { - return t.streamContextErr(s) - } - return t.controlBuf.put(df) -} - -// keepalive running in a separate goroutine does the following: -// 1. Gracefully closes an idle connection after a duration of keepalive.MaxConnectionIdle. -// 2. Gracefully closes any connection after a duration of keepalive.MaxConnectionAge. -// 3. Forcibly closes a connection after an additive period of keepalive.MaxConnectionAgeGrace over keepalive.MaxConnectionAge. -// 4. Makes sure a connection is alive by sending pings with a frequency of keepalive.Time and closes a non-responsive connection -// after an additional duration of keepalive.Timeout. -func (t *http2Server) keepalive() { - p := &ping{} - // True iff a ping has been sent, and no data has been received since then. - outstandingPing := false - // Amount of time remaining before which we should receive an ACK for the - // last sent ping. - kpTimeoutLeft := time.Duration(0) - // Records the last value of t.lastRead before we go block on the timer. - // This is required to check for read activity since then. - prevNano := time.Now().UnixNano() - // Initialize the different timers to their default values. - idleTimer := time.NewTimer(t.kp.MaxConnectionIdle) - ageTimer := time.NewTimer(t.kp.MaxConnectionAge) - kpTimer := time.NewTimer(t.kp.Time) - defer func() { - // We need to drain the underlying channel in these timers after a call - // to Stop(), only if we are interested in resetting them. Clearly we - // are not interested in resetting them here. - idleTimer.Stop() - ageTimer.Stop() - kpTimer.Stop() - }() - - for { - select { - case <-idleTimer.C: - t.mu.Lock() - idle := t.idle - if idle.IsZero() { // The connection is non-idle. - t.mu.Unlock() - idleTimer.Reset(t.kp.MaxConnectionIdle) - continue - } - val := t.kp.MaxConnectionIdle - time.Since(idle) - t.mu.Unlock() - if val <= 0 { - // The connection has been idle for a duration of keepalive.MaxConnectionIdle or more. - // Gracefully close the connection. - t.Drain("max_idle") - return - } - idleTimer.Reset(val) - case <-ageTimer.C: - t.Drain("max_age") - ageTimer.Reset(t.kp.MaxConnectionAgeGrace) - select { - case <-ageTimer.C: - // Close the connection after grace period. - if t.logger.V(logLevel) { - t.logger.Infof("Closing server transport due to maximum connection age") - } - t.controlBuf.put(closeConnection{}) - case <-t.done: - } - return - case <-kpTimer.C: - lastRead := atomic.LoadInt64(&t.lastRead) - if lastRead > prevNano { - // There has been read activity since the last time we were - // here. Setup the timer to fire at kp.Time seconds from - // lastRead time and continue. - outstandingPing = false - kpTimer.Reset(time.Duration(lastRead) + t.kp.Time - time.Duration(time.Now().UnixNano())) - prevNano = lastRead - continue - } - if outstandingPing && kpTimeoutLeft <= 0 { - t.Close(fmt.Errorf("keepalive ping not acked within timeout %s", t.kp.Time)) - return - } - if !outstandingPing { - if channelz.IsOn() { - t.channelz.SocketMetrics.KeepAlivesSent.Add(1) - } - t.controlBuf.put(p) - kpTimeoutLeft = t.kp.Timeout - outstandingPing = true - } - // The amount of time to sleep here is the minimum of kp.Time and - // timeoutLeft. This will ensure that we wait only for kp.Time - // before sending out the next ping (for cases where the ping is - // acked). - sleepDuration := minTime(t.kp.Time, kpTimeoutLeft) - kpTimeoutLeft -= sleepDuration - kpTimer.Reset(sleepDuration) - case <-t.done: - return - } - } -} - -// Close starts shutting down the http2Server transport. -// TODO(zhaoq): Now the destruction is not blocked on any pending streams. This -// could cause some resource issue. Revisit this later. -func (t *http2Server) Close(err error) { - t.mu.Lock() - if t.state == closing { - t.mu.Unlock() - return - } - if t.logger.V(logLevel) { - t.logger.Infof("Closing: %v", err) - } - t.state = closing - streams := t.activeStreams - t.activeStreams = nil - t.mu.Unlock() - t.controlBuf.finish() - close(t.done) - if err := t.conn.Close(); err != nil && t.logger.V(logLevel) { - t.logger.Infof("Error closing underlying net.Conn during Close: %v", err) - } - channelz.RemoveEntry(t.channelz.ID) - // Cancel all active streams. - for _, s := range streams { - s.cancel() - } -} - -// deleteStream deletes the stream s from transport's active streams. -func (t *http2Server) deleteStream(s *Stream, eosReceived bool) { - - t.mu.Lock() - if _, ok := t.activeStreams[s.id]; ok { - delete(t.activeStreams, s.id) - if len(t.activeStreams) == 0 { - t.idle = time.Now() - } - } - t.mu.Unlock() - - if channelz.IsOn() { - if eosReceived { - t.channelz.SocketMetrics.StreamsSucceeded.Add(1) - } else { - t.channelz.SocketMetrics.StreamsFailed.Add(1) - } - } -} - -// finishStream closes the stream and puts the trailing headerFrame into controlbuf. -func (t *http2Server) finishStream(s *Stream, rst bool, rstCode http2.ErrCode, hdr *headerFrame, eosReceived bool) { - // In case stream sending and receiving are invoked in separate - // goroutines (e.g., bi-directional streaming), cancel needs to be - // called to interrupt the potential blocking on other goroutines. - s.cancel() - - oldState := s.swapState(streamDone) - if oldState == streamDone { - // If the stream was already done, return. - return - } - - hdr.cleanup = &cleanupStream{ - streamID: s.id, - rst: rst, - rstCode: rstCode, - onWrite: func() { - t.deleteStream(s, eosReceived) - }, - } - t.controlBuf.put(hdr) -} - -// closeStream clears the footprint of a stream when the stream is not needed any more. -func (t *http2Server) closeStream(s *Stream, rst bool, rstCode http2.ErrCode, eosReceived bool) { - // In case stream sending and receiving are invoked in separate - // goroutines (e.g., bi-directional streaming), cancel needs to be - // called to interrupt the potential blocking on other goroutines. - s.cancel() - - s.swapState(streamDone) - t.deleteStream(s, eosReceived) - - t.controlBuf.put(&cleanupStream{ - streamID: s.id, - rst: rst, - rstCode: rstCode, - onWrite: func() {}, - }) -} - -func (t *http2Server) Drain(debugData string) { - t.mu.Lock() - defer t.mu.Unlock() - if t.drainEvent != nil { - return - } - t.drainEvent = grpcsync.NewEvent() - t.controlBuf.put(&goAway{code: http2.ErrCodeNo, debugData: []byte(debugData), headsUp: true}) -} - -var goAwayPing = &ping{data: [8]byte{1, 6, 1, 8, 0, 3, 3, 9}} - -// Handles outgoing GoAway and returns true if loopy needs to put itself -// in draining mode. -func (t *http2Server) outgoingGoAwayHandler(g *goAway) (bool, error) { - t.maxStreamMu.Lock() - t.mu.Lock() - if t.state == closing { // TODO(mmukhi): This seems unnecessary. - t.mu.Unlock() - t.maxStreamMu.Unlock() - // The transport is closing. - return false, ErrConnClosing - } - if !g.headsUp { - // Stop accepting more streams now. - t.state = draining - sid := t.maxStreamID - retErr := g.closeConn - if len(t.activeStreams) == 0 { - retErr = errors.New("second GOAWAY written and no active streams left to process") - } - t.mu.Unlock() - t.maxStreamMu.Unlock() - if err := t.framer.fr.WriteGoAway(sid, g.code, g.debugData); err != nil { - return false, err - } - t.framer.writer.Flush() - if retErr != nil { - return false, retErr - } - return true, nil - } - t.mu.Unlock() - t.maxStreamMu.Unlock() - // For a graceful close, send out a GoAway with stream ID of MaxUInt32, - // Follow that with a ping and wait for the ack to come back or a timer - // to expire. During this time accept new streams since they might have - // originated before the GoAway reaches the client. - // After getting the ack or timer expiration send out another GoAway this - // time with an ID of the max stream server intends to process. - if err := t.framer.fr.WriteGoAway(math.MaxUint32, http2.ErrCodeNo, g.debugData); err != nil { - return false, err - } - if err := t.framer.fr.WritePing(false, goAwayPing.data); err != nil { - return false, err - } - go func() { - timer := time.NewTimer(5 * time.Second) - defer timer.Stop() - select { - case <-t.drainEvent.Done(): - case <-timer.C: - case <-t.done: - return - } - t.controlBuf.put(&goAway{code: g.code, debugData: g.debugData}) - }() - return false, nil -} - -func (t *http2Server) socketMetrics() *channelz.EphemeralSocketMetrics { - return &channelz.EphemeralSocketMetrics{ - LocalFlowControlWindow: int64(t.fc.getSize()), - RemoteFlowControlWindow: t.getOutFlowWindow(), - } -} - -func (t *http2Server) IncrMsgSent() { - t.channelz.SocketMetrics.MessagesSent.Add(1) - t.channelz.SocketMetrics.LastMessageSentTimestamp.Add(1) -} - -func (t *http2Server) IncrMsgRecv() { - t.channelz.SocketMetrics.MessagesReceived.Add(1) - t.channelz.SocketMetrics.LastMessageReceivedTimestamp.Add(1) -} - -func (t *http2Server) getOutFlowWindow() int64 { - resp := make(chan uint32, 1) - timer := time.NewTimer(time.Second) - defer timer.Stop() - t.controlBuf.put(&outFlowControlSizeRequest{resp}) - select { - case sz := <-resp: - return int64(sz) - case <-t.done: - return -1 - case <-timer.C: - return -2 - } -} - -// Peer returns the peer of the transport. -func (t *http2Server) Peer() *peer.Peer { - return &peer.Peer{ - Addr: t.peer.Addr, - LocalAddr: t.peer.LocalAddr, - AuthInfo: t.peer.AuthInfo, // Can be nil - } -} - -func getJitter(v time.Duration) time.Duration { - if v == infinity { - return 0 - } - // Generate a jitter between +/- 10% of the value. - r := int64(v / 10) - j := grpcrand.Int63n(2*r) - r - return time.Duration(j) -} - -type connectionKey struct{} - -// GetConnection gets the connection from the context. -func GetConnection(ctx context.Context) net.Conn { - conn, _ := ctx.Value(connectionKey{}).(net.Conn) - return conn -} - -// SetConnection adds the connection to the context to be able to get -// information about the destination ip and port for an incoming RPC. This also -// allows any unary or streaming interceptors to see the connection. -func SetConnection(ctx context.Context, conn net.Conn) context.Context { - return context.WithValue(ctx, connectionKey{}, conn) -} diff --git a/vendor/google.golang.org/grpc/internal/transport/http_util.go b/vendor/google.golang.org/grpc/internal/transport/http_util.go deleted file mode 100644 index 39cef3bd4..000000000 --- a/vendor/google.golang.org/grpc/internal/transport/http_util.go +++ /dev/null @@ -1,464 +0,0 @@ -/* - * - * Copyright 2014 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package transport - -import ( - "bufio" - "encoding/base64" - "errors" - "fmt" - "io" - "math" - "net" - "net/http" - "net/url" - "strconv" - "strings" - "sync" - "time" - "unicode/utf8" - - "golang.org/x/net/http2" - "golang.org/x/net/http2/hpack" - "google.golang.org/grpc/codes" -) - -const ( - // http2MaxFrameLen specifies the max length of a HTTP2 frame. - http2MaxFrameLen = 16384 // 16KB frame - // https://httpwg.org/specs/rfc7540.html#SettingValues - http2InitHeaderTableSize = 4096 -) - -var ( - clientPreface = []byte(http2.ClientPreface) - http2ErrConvTab = map[http2.ErrCode]codes.Code{ - http2.ErrCodeNo: codes.Internal, - http2.ErrCodeProtocol: codes.Internal, - http2.ErrCodeInternal: codes.Internal, - http2.ErrCodeFlowControl: codes.ResourceExhausted, - http2.ErrCodeSettingsTimeout: codes.Internal, - http2.ErrCodeStreamClosed: codes.Internal, - http2.ErrCodeFrameSize: codes.Internal, - http2.ErrCodeRefusedStream: codes.Unavailable, - http2.ErrCodeCancel: codes.Canceled, - http2.ErrCodeCompression: codes.Internal, - http2.ErrCodeConnect: codes.Internal, - http2.ErrCodeEnhanceYourCalm: codes.ResourceExhausted, - http2.ErrCodeInadequateSecurity: codes.PermissionDenied, - http2.ErrCodeHTTP11Required: codes.Internal, - } - // HTTPStatusConvTab is the HTTP status code to gRPC error code conversion table. - HTTPStatusConvTab = map[int]codes.Code{ - // 400 Bad Request - INTERNAL. - http.StatusBadRequest: codes.Internal, - // 401 Unauthorized - UNAUTHENTICATED. - http.StatusUnauthorized: codes.Unauthenticated, - // 403 Forbidden - PERMISSION_DENIED. - http.StatusForbidden: codes.PermissionDenied, - // 404 Not Found - UNIMPLEMENTED. - http.StatusNotFound: codes.Unimplemented, - // 429 Too Many Requests - UNAVAILABLE. - http.StatusTooManyRequests: codes.Unavailable, - // 502 Bad Gateway - UNAVAILABLE. - http.StatusBadGateway: codes.Unavailable, - // 503 Service Unavailable - UNAVAILABLE. - http.StatusServiceUnavailable: codes.Unavailable, - // 504 Gateway timeout - UNAVAILABLE. - http.StatusGatewayTimeout: codes.Unavailable, - } -) - -var grpcStatusDetailsBinHeader = "grpc-status-details-bin" - -// isReservedHeader checks whether hdr belongs to HTTP2 headers -// reserved by gRPC protocol. Any other headers are classified as the -// user-specified metadata. -func isReservedHeader(hdr string) bool { - if hdr != "" && hdr[0] == ':' { - return true - } - switch hdr { - case "content-type", - "user-agent", - "grpc-message-type", - "grpc-encoding", - "grpc-message", - "grpc-status", - "grpc-timeout", - // Intentionally exclude grpc-previous-rpc-attempts and - // grpc-retry-pushback-ms, which are "reserved", but their API - // intentionally works via metadata. - "te": - return true - default: - return false - } -} - -// isWhitelistedHeader checks whether hdr should be propagated into metadata -// visible to users, even though it is classified as "reserved", above. -func isWhitelistedHeader(hdr string) bool { - switch hdr { - case ":authority", "user-agent": - return true - default: - return false - } -} - -const binHdrSuffix = "-bin" - -func encodeBinHeader(v []byte) string { - return base64.RawStdEncoding.EncodeToString(v) -} - -func decodeBinHeader(v string) ([]byte, error) { - if len(v)%4 == 0 { - // Input was padded, or padding was not necessary. - return base64.StdEncoding.DecodeString(v) - } - return base64.RawStdEncoding.DecodeString(v) -} - -func encodeMetadataHeader(k, v string) string { - if strings.HasSuffix(k, binHdrSuffix) { - return encodeBinHeader(([]byte)(v)) - } - return v -} - -func decodeMetadataHeader(k, v string) (string, error) { - if strings.HasSuffix(k, binHdrSuffix) { - b, err := decodeBinHeader(v) - return string(b), err - } - return v, nil -} - -type timeoutUnit uint8 - -const ( - hour timeoutUnit = 'H' - minute timeoutUnit = 'M' - second timeoutUnit = 'S' - millisecond timeoutUnit = 'm' - microsecond timeoutUnit = 'u' - nanosecond timeoutUnit = 'n' -) - -func timeoutUnitToDuration(u timeoutUnit) (d time.Duration, ok bool) { - switch u { - case hour: - return time.Hour, true - case minute: - return time.Minute, true - case second: - return time.Second, true - case millisecond: - return time.Millisecond, true - case microsecond: - return time.Microsecond, true - case nanosecond: - return time.Nanosecond, true - default: - } - return -} - -func decodeTimeout(s string) (time.Duration, error) { - size := len(s) - if size < 2 { - return 0, fmt.Errorf("transport: timeout string is too short: %q", s) - } - if size > 9 { - // Spec allows for 8 digits plus the unit. - return 0, fmt.Errorf("transport: timeout string is too long: %q", s) - } - unit := timeoutUnit(s[size-1]) - d, ok := timeoutUnitToDuration(unit) - if !ok { - return 0, fmt.Errorf("transport: timeout unit is not recognized: %q", s) - } - t, err := strconv.ParseInt(s[:size-1], 10, 64) - if err != nil { - return 0, err - } - const maxHours = math.MaxInt64 / int64(time.Hour) - if d == time.Hour && t > maxHours { - // This timeout would overflow math.MaxInt64; clamp it. - return time.Duration(math.MaxInt64), nil - } - return d * time.Duration(t), nil -} - -const ( - spaceByte = ' ' - tildeByte = '~' - percentByte = '%' -) - -// encodeGrpcMessage is used to encode status code in header field -// "grpc-message". It does percent encoding and also replaces invalid utf-8 -// characters with Unicode replacement character. -// -// It checks to see if each individual byte in msg is an allowable byte, and -// then either percent encoding or passing it through. When percent encoding, -// the byte is converted into hexadecimal notation with a '%' prepended. -func encodeGrpcMessage(msg string) string { - if msg == "" { - return "" - } - lenMsg := len(msg) - for i := 0; i < lenMsg; i++ { - c := msg[i] - if !(c >= spaceByte && c <= tildeByte && c != percentByte) { - return encodeGrpcMessageUnchecked(msg) - } - } - return msg -} - -func encodeGrpcMessageUnchecked(msg string) string { - var sb strings.Builder - for len(msg) > 0 { - r, size := utf8.DecodeRuneInString(msg) - for _, b := range []byte(string(r)) { - if size > 1 { - // If size > 1, r is not ascii. Always do percent encoding. - fmt.Fprintf(&sb, "%%%02X", b) - continue - } - - // The for loop is necessary even if size == 1. r could be - // utf8.RuneError. - // - // fmt.Sprintf("%%%02X", utf8.RuneError) gives "%FFFD". - if b >= spaceByte && b <= tildeByte && b != percentByte { - sb.WriteByte(b) - } else { - fmt.Fprintf(&sb, "%%%02X", b) - } - } - msg = msg[size:] - } - return sb.String() -} - -// decodeGrpcMessage decodes the msg encoded by encodeGrpcMessage. -func decodeGrpcMessage(msg string) string { - if msg == "" { - return "" - } - lenMsg := len(msg) - for i := 0; i < lenMsg; i++ { - if msg[i] == percentByte && i+2 < lenMsg { - return decodeGrpcMessageUnchecked(msg) - } - } - return msg -} - -func decodeGrpcMessageUnchecked(msg string) string { - var sb strings.Builder - lenMsg := len(msg) - for i := 0; i < lenMsg; i++ { - c := msg[i] - if c == percentByte && i+2 < lenMsg { - parsed, err := strconv.ParseUint(msg[i+1:i+3], 16, 8) - if err != nil { - sb.WriteByte(c) - } else { - sb.WriteByte(byte(parsed)) - i += 2 - } - } else { - sb.WriteByte(c) - } - } - return sb.String() -} - -type bufWriter struct { - pool *sync.Pool - buf []byte - offset int - batchSize int - conn net.Conn - err error -} - -func newBufWriter(conn net.Conn, batchSize int, pool *sync.Pool) *bufWriter { - w := &bufWriter{ - batchSize: batchSize, - conn: conn, - pool: pool, - } - // this indicates that we should use non shared buf - if pool == nil { - w.buf = make([]byte, batchSize) - } - return w -} - -func (w *bufWriter) Write(b []byte) (n int, err error) { - if w.err != nil { - return 0, w.err - } - if w.batchSize == 0 { // Buffer has been disabled. - n, err = w.conn.Write(b) - return n, toIOError(err) - } - if w.buf == nil { - b := w.pool.Get().(*[]byte) - w.buf = *b - } - for len(b) > 0 { - nn := copy(w.buf[w.offset:], b) - b = b[nn:] - w.offset += nn - n += nn - if w.offset >= w.batchSize { - err = w.flushKeepBuffer() - } - } - return n, err -} - -func (w *bufWriter) Flush() error { - err := w.flushKeepBuffer() - // Only release the buffer if we are in a "shared" mode - if w.buf != nil && w.pool != nil { - b := w.buf - w.pool.Put(&b) - w.buf = nil - } - return err -} - -func (w *bufWriter) flushKeepBuffer() error { - if w.err != nil { - return w.err - } - if w.offset == 0 { - return nil - } - _, w.err = w.conn.Write(w.buf[:w.offset]) - w.err = toIOError(w.err) - w.offset = 0 - return w.err -} - -type ioError struct { - error -} - -func (i ioError) Unwrap() error { - return i.error -} - -func isIOError(err error) bool { - return errors.As(err, &ioError{}) -} - -func toIOError(err error) error { - if err == nil { - return nil - } - return ioError{error: err} -} - -type framer struct { - writer *bufWriter - fr *http2.Framer -} - -var writeBufferPoolMap map[int]*sync.Pool = make(map[int]*sync.Pool) -var writeBufferMutex sync.Mutex - -func newFramer(conn net.Conn, writeBufferSize, readBufferSize int, sharedWriteBuffer bool, maxHeaderListSize uint32) *framer { - if writeBufferSize < 0 { - writeBufferSize = 0 - } - var r io.Reader = conn - if readBufferSize > 0 { - r = bufio.NewReaderSize(r, readBufferSize) - } - var pool *sync.Pool - if sharedWriteBuffer { - pool = getWriteBufferPool(writeBufferSize) - } - w := newBufWriter(conn, writeBufferSize, pool) - f := &framer{ - writer: w, - fr: http2.NewFramer(w, r), - } - f.fr.SetMaxReadFrameSize(http2MaxFrameLen) - // Opt-in to Frame reuse API on framer to reduce garbage. - // Frames aren't safe to read from after a subsequent call to ReadFrame. - f.fr.SetReuseFrames() - f.fr.MaxHeaderListSize = maxHeaderListSize - f.fr.ReadMetaHeaders = hpack.NewDecoder(http2InitHeaderTableSize, nil) - return f -} - -func getWriteBufferPool(size int) *sync.Pool { - writeBufferMutex.Lock() - defer writeBufferMutex.Unlock() - pool, ok := writeBufferPoolMap[size] - if ok { - return pool - } - pool = &sync.Pool{ - New: func() any { - b := make([]byte, size) - return &b - }, - } - writeBufferPoolMap[size] = pool - return pool -} - -// parseDialTarget returns the network and address to pass to dialer. -func parseDialTarget(target string) (string, string) { - net := "tcp" - m1 := strings.Index(target, ":") - m2 := strings.Index(target, ":/") - // handle unix:addr which will fail with url.Parse - if m1 >= 0 && m2 < 0 { - if n := target[0:m1]; n == "unix" { - return n, target[m1+1:] - } - } - if m2 >= 0 { - t, err := url.Parse(target) - if err != nil { - return net, target - } - scheme := t.Scheme - addr := t.Path - if scheme == "unix" { - if addr == "" { - addr = t.Host - } - return scheme, addr - } - } - return net, target -} diff --git a/vendor/google.golang.org/grpc/internal/transport/logging.go b/vendor/google.golang.org/grpc/internal/transport/logging.go deleted file mode 100644 index 42ed2b07a..000000000 --- a/vendor/google.golang.org/grpc/internal/transport/logging.go +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * Copyright 2023 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package transport - -import ( - "fmt" - - "google.golang.org/grpc/grpclog" - internalgrpclog "google.golang.org/grpc/internal/grpclog" -) - -var logger = grpclog.Component("transport") - -func prefixLoggerForServerTransport(p *http2Server) *internalgrpclog.PrefixLogger { - return internalgrpclog.NewPrefixLogger(logger, fmt.Sprintf("[server-transport %p] ", p)) -} - -func prefixLoggerForServerHandlerTransport(p *serverHandlerTransport) *internalgrpclog.PrefixLogger { - return internalgrpclog.NewPrefixLogger(logger, fmt.Sprintf("[server-handler-transport %p] ", p)) -} - -func prefixLoggerForClientTransport(p *http2Client) *internalgrpclog.PrefixLogger { - return internalgrpclog.NewPrefixLogger(logger, fmt.Sprintf("[client-transport %p] ", p)) -} diff --git a/vendor/google.golang.org/grpc/internal/transport/networktype/networktype.go b/vendor/google.golang.org/grpc/internal/transport/networktype/networktype.go deleted file mode 100644 index c11b52782..000000000 --- a/vendor/google.golang.org/grpc/internal/transport/networktype/networktype.go +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * Copyright 2020 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package networktype declares the network type to be used in the default -// dialer. Attribute of a resolver.Address. -package networktype - -import ( - "google.golang.org/grpc/resolver" -) - -// keyType is the key to use for storing State in Attributes. -type keyType string - -const key = keyType("grpc.internal.transport.networktype") - -// Set returns a copy of the provided address with attributes containing networkType. -func Set(address resolver.Address, networkType string) resolver.Address { - address.Attributes = address.Attributes.WithValue(key, networkType) - return address -} - -// Get returns the network type in the resolver.Address and true, or "", false -// if not present. -func Get(address resolver.Address) (string, bool) { - v := address.Attributes.Value(key) - if v == nil { - return "", false - } - return v.(string), true -} diff --git a/vendor/google.golang.org/grpc/internal/transport/proxy.go b/vendor/google.golang.org/grpc/internal/transport/proxy.go deleted file mode 100644 index 24fa10325..000000000 --- a/vendor/google.golang.org/grpc/internal/transport/proxy.go +++ /dev/null @@ -1,144 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package transport - -import ( - "bufio" - "context" - "encoding/base64" - "fmt" - "io" - "net" - "net/http" - "net/http/httputil" - "net/url" - - "google.golang.org/grpc/internal" -) - -const proxyAuthHeaderKey = "Proxy-Authorization" - -var ( - // The following variable will be overwritten in the tests. - httpProxyFromEnvironment = http.ProxyFromEnvironment -) - -func mapAddress(address string) (*url.URL, error) { - req := &http.Request{ - URL: &url.URL{ - Scheme: "https", - Host: address, - }, - } - url, err := httpProxyFromEnvironment(req) - if err != nil { - return nil, err - } - return url, nil -} - -// To read a response from a net.Conn, http.ReadResponse() takes a bufio.Reader. -// It's possible that this reader reads more than what's need for the response and stores -// those bytes in the buffer. -// bufConn wraps the original net.Conn and the bufio.Reader to make sure we don't lose the -// bytes in the buffer. -type bufConn struct { - net.Conn - r io.Reader -} - -func (c *bufConn) Read(b []byte) (int, error) { - return c.r.Read(b) -} - -func basicAuth(username, password string) string { - auth := username + ":" + password - return base64.StdEncoding.EncodeToString([]byte(auth)) -} - -func doHTTPConnectHandshake(ctx context.Context, conn net.Conn, backendAddr string, proxyURL *url.URL, grpcUA string) (_ net.Conn, err error) { - defer func() { - if err != nil { - conn.Close() - } - }() - - req := &http.Request{ - Method: http.MethodConnect, - URL: &url.URL{Host: backendAddr}, - Header: map[string][]string{"User-Agent": {grpcUA}}, - } - if t := proxyURL.User; t != nil { - u := t.Username() - p, _ := t.Password() - req.Header.Add(proxyAuthHeaderKey, "Basic "+basicAuth(u, p)) - } - - if err := sendHTTPRequest(ctx, req, conn); err != nil { - return nil, fmt.Errorf("failed to write the HTTP request: %v", err) - } - - r := bufio.NewReader(conn) - resp, err := http.ReadResponse(r, req) - if err != nil { - return nil, fmt.Errorf("reading server HTTP response: %v", err) - } - defer resp.Body.Close() - if resp.StatusCode != http.StatusOK { - dump, err := httputil.DumpResponse(resp, true) - if err != nil { - return nil, fmt.Errorf("failed to do connect handshake, status code: %s", resp.Status) - } - return nil, fmt.Errorf("failed to do connect handshake, response: %q", dump) - } - - return &bufConn{Conn: conn, r: r}, nil -} - -// proxyDial dials, connecting to a proxy first if necessary. Checks if a proxy -// is necessary, dials, does the HTTP CONNECT handshake, and returns the -// connection. -func proxyDial(ctx context.Context, addr string, grpcUA string) (net.Conn, error) { - newAddr := addr - proxyURL, err := mapAddress(addr) - if err != nil { - return nil, err - } - if proxyURL != nil { - newAddr = proxyURL.Host - } - - conn, err := internal.NetDialerWithTCPKeepalive().DialContext(ctx, "tcp", newAddr) - if err != nil { - return nil, err - } - if proxyURL == nil { - // proxy is disabled if proxyURL is nil. - return conn, err - } - return doHTTPConnectHandshake(ctx, conn, addr, proxyURL, grpcUA) -} - -func sendHTTPRequest(ctx context.Context, req *http.Request, conn net.Conn) error { - req = req.WithContext(ctx) - if err := req.Write(conn); err != nil { - return fmt.Errorf("failed to write the HTTP request: %v", err) - } - return nil -} diff --git a/vendor/google.golang.org/grpc/internal/transport/transport.go b/vendor/google.golang.org/grpc/internal/transport/transport.go deleted file mode 100644 index 0d2a6e47f..000000000 --- a/vendor/google.golang.org/grpc/internal/transport/transport.go +++ /dev/null @@ -1,832 +0,0 @@ -/* - * - * Copyright 2014 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package transport defines and implements message oriented communication -// channel to complete various transactions (e.g., an RPC). It is meant for -// grpc-internal usage and is not intended to be imported directly by users. -package transport - -import ( - "bytes" - "context" - "errors" - "fmt" - "io" - "net" - "strings" - "sync" - "sync/atomic" - "time" - - "google.golang.org/grpc/codes" - "google.golang.org/grpc/credentials" - "google.golang.org/grpc/internal/channelz" - "google.golang.org/grpc/keepalive" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/peer" - "google.golang.org/grpc/resolver" - "google.golang.org/grpc/stats" - "google.golang.org/grpc/status" - "google.golang.org/grpc/tap" -) - -const logLevel = 2 - -type bufferPool struct { - pool sync.Pool -} - -func newBufferPool() *bufferPool { - return &bufferPool{ - pool: sync.Pool{ - New: func() any { - return new(bytes.Buffer) - }, - }, - } -} - -func (p *bufferPool) get() *bytes.Buffer { - return p.pool.Get().(*bytes.Buffer) -} - -func (p *bufferPool) put(b *bytes.Buffer) { - p.pool.Put(b) -} - -// recvMsg represents the received msg from the transport. All transport -// protocol specific info has been removed. -type recvMsg struct { - buffer *bytes.Buffer - // nil: received some data - // io.EOF: stream is completed. data is nil. - // other non-nil error: transport failure. data is nil. - err error -} - -// recvBuffer is an unbounded channel of recvMsg structs. -// -// Note: recvBuffer differs from buffer.Unbounded only in the fact that it -// holds a channel of recvMsg structs instead of objects implementing "item" -// interface. recvBuffer is written to much more often and using strict recvMsg -// structs helps avoid allocation in "recvBuffer.put" -type recvBuffer struct { - c chan recvMsg - mu sync.Mutex - backlog []recvMsg - err error -} - -func newRecvBuffer() *recvBuffer { - b := &recvBuffer{ - c: make(chan recvMsg, 1), - } - return b -} - -func (b *recvBuffer) put(r recvMsg) { - b.mu.Lock() - if b.err != nil { - b.mu.Unlock() - // An error had occurred earlier, don't accept more - // data or errors. - return - } - b.err = r.err - if len(b.backlog) == 0 { - select { - case b.c <- r: - b.mu.Unlock() - return - default: - } - } - b.backlog = append(b.backlog, r) - b.mu.Unlock() -} - -func (b *recvBuffer) load() { - b.mu.Lock() - if len(b.backlog) > 0 { - select { - case b.c <- b.backlog[0]: - b.backlog[0] = recvMsg{} - b.backlog = b.backlog[1:] - default: - } - } - b.mu.Unlock() -} - -// get returns the channel that receives a recvMsg in the buffer. -// -// Upon receipt of a recvMsg, the caller should call load to send another -// recvMsg onto the channel if there is any. -func (b *recvBuffer) get() <-chan recvMsg { - return b.c -} - -// recvBufferReader implements io.Reader interface to read the data from -// recvBuffer. -type recvBufferReader struct { - closeStream func(error) // Closes the client transport stream with the given error and nil trailer metadata. - ctx context.Context - ctxDone <-chan struct{} // cache of ctx.Done() (for performance). - recv *recvBuffer - last *bytes.Buffer // Stores the remaining data in the previous calls. - err error - freeBuffer func(*bytes.Buffer) -} - -// Read reads the next len(p) bytes from last. If last is drained, it tries to -// read additional data from recv. It blocks if there no additional data available -// in recv. If Read returns any non-nil error, it will continue to return that error. -func (r *recvBufferReader) Read(p []byte) (n int, err error) { - if r.err != nil { - return 0, r.err - } - if r.last != nil { - // Read remaining data left in last call. - copied, _ := r.last.Read(p) - if r.last.Len() == 0 { - r.freeBuffer(r.last) - r.last = nil - } - return copied, nil - } - if r.closeStream != nil { - n, r.err = r.readClient(p) - } else { - n, r.err = r.read(p) - } - return n, r.err -} - -func (r *recvBufferReader) read(p []byte) (n int, err error) { - select { - case <-r.ctxDone: - return 0, ContextErr(r.ctx.Err()) - case m := <-r.recv.get(): - return r.readAdditional(m, p) - } -} - -func (r *recvBufferReader) readClient(p []byte) (n int, err error) { - // If the context is canceled, then closes the stream with nil metadata. - // closeStream writes its error parameter to r.recv as a recvMsg. - // r.readAdditional acts on that message and returns the necessary error. - select { - case <-r.ctxDone: - // Note that this adds the ctx error to the end of recv buffer, and - // reads from the head. This will delay the error until recv buffer is - // empty, thus will delay ctx cancellation in Recv(). - // - // It's done this way to fix a race between ctx cancel and trailer. The - // race was, stream.Recv() may return ctx error if ctxDone wins the - // race, but stream.Trailer() may return a non-nil md because the stream - // was not marked as done when trailer is received. This closeStream - // call will mark stream as done, thus fix the race. - // - // TODO: delaying ctx error seems like a unnecessary side effect. What - // we really want is to mark the stream as done, and return ctx error - // faster. - r.closeStream(ContextErr(r.ctx.Err())) - m := <-r.recv.get() - return r.readAdditional(m, p) - case m := <-r.recv.get(): - return r.readAdditional(m, p) - } -} - -func (r *recvBufferReader) readAdditional(m recvMsg, p []byte) (n int, err error) { - r.recv.load() - if m.err != nil { - return 0, m.err - } - copied, _ := m.buffer.Read(p) - if m.buffer.Len() == 0 { - r.freeBuffer(m.buffer) - r.last = nil - } else { - r.last = m.buffer - } - return copied, nil -} - -type streamState uint32 - -const ( - streamActive streamState = iota - streamWriteDone // EndStream sent - streamReadDone // EndStream received - streamDone // the entire stream is finished. -) - -// Stream represents an RPC in the transport layer. -type Stream struct { - id uint32 - st ServerTransport // nil for client side Stream - ct *http2Client // nil for server side Stream - ctx context.Context // the associated context of the stream - cancel context.CancelFunc // always nil for client side Stream - done chan struct{} // closed at the end of stream to unblock writers. On the client side. - doneFunc func() // invoked at the end of stream on client side. - ctxDone <-chan struct{} // same as done chan but for server side. Cache of ctx.Done() (for performance) - method string // the associated RPC method of the stream - recvCompress string - sendCompress string - buf *recvBuffer - trReader io.Reader - fc *inFlow - wq *writeQuota - - // Holds compressor names passed in grpc-accept-encoding metadata from the - // client. This is empty for the client side stream. - clientAdvertisedCompressors string - // Callback to state application's intentions to read data. This - // is used to adjust flow control, if needed. - requestRead func(int) - - headerChan chan struct{} // closed to indicate the end of header metadata. - headerChanClosed uint32 // set when headerChan is closed. Used to avoid closing headerChan multiple times. - // headerValid indicates whether a valid header was received. Only - // meaningful after headerChan is closed (always call waitOnHeader() before - // reading its value). Not valid on server side. - headerValid bool - headerWireLength int // Only set on server side. - - // hdrMu protects header and trailer metadata on the server-side. - hdrMu sync.Mutex - // On client side, header keeps the received header metadata. - // - // On server side, header keeps the header set by SetHeader(). The complete - // header will merged into this after t.WriteHeader() is called. - header metadata.MD - trailer metadata.MD // the key-value map of trailer metadata. - - noHeaders bool // set if the client never received headers (set only after the stream is done). - - // On the server-side, headerSent is atomically set to 1 when the headers are sent out. - headerSent uint32 - - state streamState - - // On client-side it is the status error received from the server. - // On server-side it is unused. - status *status.Status - - bytesReceived uint32 // indicates whether any bytes have been received on this stream - unprocessed uint32 // set if the server sends a refused stream or GOAWAY including this stream - - // contentSubtype is the content-subtype for requests. - // this must be lowercase or the behavior is undefined. - contentSubtype string -} - -// isHeaderSent is only valid on the server-side. -func (s *Stream) isHeaderSent() bool { - return atomic.LoadUint32(&s.headerSent) == 1 -} - -// updateHeaderSent updates headerSent and returns true -// if it was alreay set. It is valid only on server-side. -func (s *Stream) updateHeaderSent() bool { - return atomic.SwapUint32(&s.headerSent, 1) == 1 -} - -func (s *Stream) swapState(st streamState) streamState { - return streamState(atomic.SwapUint32((*uint32)(&s.state), uint32(st))) -} - -func (s *Stream) compareAndSwapState(oldState, newState streamState) bool { - return atomic.CompareAndSwapUint32((*uint32)(&s.state), uint32(oldState), uint32(newState)) -} - -func (s *Stream) getState() streamState { - return streamState(atomic.LoadUint32((*uint32)(&s.state))) -} - -func (s *Stream) waitOnHeader() { - if s.headerChan == nil { - // On the server headerChan is always nil since a stream originates - // only after having received headers. - return - } - select { - case <-s.ctx.Done(): - // Close the stream to prevent headers/trailers from changing after - // this function returns. - s.ct.CloseStream(s, ContextErr(s.ctx.Err())) - // headerChan could possibly not be closed yet if closeStream raced - // with operateHeaders; wait until it is closed explicitly here. - <-s.headerChan - case <-s.headerChan: - } -} - -// RecvCompress returns the compression algorithm applied to the inbound -// message. It is empty string if there is no compression applied. -func (s *Stream) RecvCompress() string { - s.waitOnHeader() - return s.recvCompress -} - -// SetSendCompress sets the compression algorithm to the stream. -func (s *Stream) SetSendCompress(name string) error { - if s.isHeaderSent() || s.getState() == streamDone { - return errors.New("transport: set send compressor called after headers sent or stream done") - } - - s.sendCompress = name - return nil -} - -// SendCompress returns the send compressor name. -func (s *Stream) SendCompress() string { - return s.sendCompress -} - -// ClientAdvertisedCompressors returns the compressor names advertised by the -// client via grpc-accept-encoding header. -func (s *Stream) ClientAdvertisedCompressors() []string { - values := strings.Split(s.clientAdvertisedCompressors, ",") - for i, v := range values { - values[i] = strings.TrimSpace(v) - } - return values -} - -// Done returns a channel which is closed when it receives the final status -// from the server. -func (s *Stream) Done() <-chan struct{} { - return s.done -} - -// Header returns the header metadata of the stream. -// -// On client side, it acquires the key-value pairs of header metadata once it is -// available. It blocks until i) the metadata is ready or ii) there is no header -// metadata or iii) the stream is canceled/expired. -// -// On server side, it returns the out header after t.WriteHeader is called. It -// does not block and must not be called until after WriteHeader. -func (s *Stream) Header() (metadata.MD, error) { - if s.headerChan == nil { - // On server side, return the header in stream. It will be the out - // header after t.WriteHeader is called. - return s.header.Copy(), nil - } - s.waitOnHeader() - - if !s.headerValid || s.noHeaders { - return nil, s.status.Err() - } - - return s.header.Copy(), nil -} - -// TrailersOnly blocks until a header or trailers-only frame is received and -// then returns true if the stream was trailers-only. If the stream ends -// before headers are received, returns true, nil. Client-side only. -func (s *Stream) TrailersOnly() bool { - s.waitOnHeader() - return s.noHeaders -} - -// Trailer returns the cached trailer metedata. Note that if it is not called -// after the entire stream is done, it could return an empty MD. Client -// side only. -// It can be safely read only after stream has ended that is either read -// or write have returned io.EOF. -func (s *Stream) Trailer() metadata.MD { - c := s.trailer.Copy() - return c -} - -// ContentSubtype returns the content-subtype for a request. For example, a -// content-subtype of "proto" will result in a content-type of -// "application/grpc+proto". This will always be lowercase. See -// https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests for -// more details. -func (s *Stream) ContentSubtype() string { - return s.contentSubtype -} - -// Context returns the context of the stream. -func (s *Stream) Context() context.Context { - return s.ctx -} - -// SetContext sets the context of the stream. This will be deleted once the -// stats handler callouts all move to gRPC layer. -func (s *Stream) SetContext(ctx context.Context) { - s.ctx = ctx -} - -// Method returns the method for the stream. -func (s *Stream) Method() string { - return s.method -} - -// Status returns the status received from the server. -// Status can be read safely only after the stream has ended, -// that is, after Done() is closed. -func (s *Stream) Status() *status.Status { - return s.status -} - -// HeaderWireLength returns the size of the headers of the stream as received -// from the wire. Valid only on the server. -func (s *Stream) HeaderWireLength() int { - return s.headerWireLength -} - -// SetHeader sets the header metadata. This can be called multiple times. -// Server side only. -// This should not be called in parallel to other data writes. -func (s *Stream) SetHeader(md metadata.MD) error { - if md.Len() == 0 { - return nil - } - if s.isHeaderSent() || s.getState() == streamDone { - return ErrIllegalHeaderWrite - } - s.hdrMu.Lock() - s.header = metadata.Join(s.header, md) - s.hdrMu.Unlock() - return nil -} - -// SendHeader sends the given header metadata. The given metadata is -// combined with any metadata set by previous calls to SetHeader and -// then written to the transport stream. -func (s *Stream) SendHeader(md metadata.MD) error { - return s.st.WriteHeader(s, md) -} - -// SetTrailer sets the trailer metadata which will be sent with the RPC status -// by the server. This can be called multiple times. Server side only. -// This should not be called parallel to other data writes. -func (s *Stream) SetTrailer(md metadata.MD) error { - if md.Len() == 0 { - return nil - } - if s.getState() == streamDone { - return ErrIllegalHeaderWrite - } - s.hdrMu.Lock() - s.trailer = metadata.Join(s.trailer, md) - s.hdrMu.Unlock() - return nil -} - -func (s *Stream) write(m recvMsg) { - s.buf.put(m) -} - -// Read reads all p bytes from the wire for this stream. -func (s *Stream) Read(p []byte) (n int, err error) { - // Don't request a read if there was an error earlier - if er := s.trReader.(*transportReader).er; er != nil { - return 0, er - } - s.requestRead(len(p)) - return io.ReadFull(s.trReader, p) -} - -// tranportReader reads all the data available for this Stream from the transport and -// passes them into the decoder, which converts them into a gRPC message stream. -// The error is io.EOF when the stream is done or another non-nil error if -// the stream broke. -type transportReader struct { - reader io.Reader - // The handler to control the window update procedure for both this - // particular stream and the associated transport. - windowHandler func(int) - er error -} - -func (t *transportReader) Read(p []byte) (n int, err error) { - n, err = t.reader.Read(p) - if err != nil { - t.er = err - return - } - t.windowHandler(n) - return -} - -// BytesReceived indicates whether any bytes have been received on this stream. -func (s *Stream) BytesReceived() bool { - return atomic.LoadUint32(&s.bytesReceived) == 1 -} - -// Unprocessed indicates whether the server did not process this stream -- -// i.e. it sent a refused stream or GOAWAY including this stream ID. -func (s *Stream) Unprocessed() bool { - return atomic.LoadUint32(&s.unprocessed) == 1 -} - -// GoString is implemented by Stream so context.String() won't -// race when printing %#v. -func (s *Stream) GoString() string { - return fmt.Sprintf("", s, s.method) -} - -// state of transport -type transportState int - -const ( - reachable transportState = iota - closing - draining -) - -// ServerConfig consists of all the configurations to establish a server transport. -type ServerConfig struct { - MaxStreams uint32 - ConnectionTimeout time.Duration - Credentials credentials.TransportCredentials - InTapHandle tap.ServerInHandle - StatsHandlers []stats.Handler - KeepaliveParams keepalive.ServerParameters - KeepalivePolicy keepalive.EnforcementPolicy - InitialWindowSize int32 - InitialConnWindowSize int32 - WriteBufferSize int - ReadBufferSize int - SharedWriteBuffer bool - ChannelzParent *channelz.Server - MaxHeaderListSize *uint32 - HeaderTableSize *uint32 -} - -// ConnectOptions covers all relevant options for communicating with the server. -type ConnectOptions struct { - // UserAgent is the application user agent. - UserAgent string - // Dialer specifies how to dial a network address. - Dialer func(context.Context, string) (net.Conn, error) - // FailOnNonTempDialError specifies if gRPC fails on non-temporary dial errors. - FailOnNonTempDialError bool - // PerRPCCredentials stores the PerRPCCredentials required to issue RPCs. - PerRPCCredentials []credentials.PerRPCCredentials - // TransportCredentials stores the Authenticator required to setup a client - // connection. Only one of TransportCredentials and CredsBundle is non-nil. - TransportCredentials credentials.TransportCredentials - // CredsBundle is the credentials bundle to be used. Only one of - // TransportCredentials and CredsBundle is non-nil. - CredsBundle credentials.Bundle - // KeepaliveParams stores the keepalive parameters. - KeepaliveParams keepalive.ClientParameters - // StatsHandlers stores the handler for stats. - StatsHandlers []stats.Handler - // InitialWindowSize sets the initial window size for a stream. - InitialWindowSize int32 - // InitialConnWindowSize sets the initial window size for a connection. - InitialConnWindowSize int32 - // WriteBufferSize sets the size of write buffer which in turn determines how much data can be batched before it's written on the wire. - WriteBufferSize int - // ReadBufferSize sets the size of read buffer, which in turn determines how much data can be read at most for one read syscall. - ReadBufferSize int - // SharedWriteBuffer indicates whether connections should reuse write buffer - SharedWriteBuffer bool - // ChannelzParent sets the addrConn id which initiated the creation of this client transport. - ChannelzParent *channelz.SubChannel - // MaxHeaderListSize sets the max (uncompressed) size of header list that is prepared to be received. - MaxHeaderListSize *uint32 - // UseProxy specifies if a proxy should be used. - UseProxy bool -} - -// NewClientTransport establishes the transport with the required ConnectOptions -// and returns it to the caller. -func NewClientTransport(connectCtx, ctx context.Context, addr resolver.Address, opts ConnectOptions, onClose func(GoAwayReason)) (ClientTransport, error) { - return newHTTP2Client(connectCtx, ctx, addr, opts, onClose) -} - -// Options provides additional hints and information for message -// transmission. -type Options struct { - // Last indicates whether this write is the last piece for - // this stream. - Last bool -} - -// CallHdr carries the information of a particular RPC. -type CallHdr struct { - // Host specifies the peer's host. - Host string - - // Method specifies the operation to perform. - Method string - - // SendCompress specifies the compression algorithm applied on - // outbound message. - SendCompress string - - // Creds specifies credentials.PerRPCCredentials for a call. - Creds credentials.PerRPCCredentials - - // ContentSubtype specifies the content-subtype for a request. For example, a - // content-subtype of "proto" will result in a content-type of - // "application/grpc+proto". The value of ContentSubtype must be all - // lowercase, otherwise the behavior is undefined. See - // https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests - // for more details. - ContentSubtype string - - PreviousAttempts int // value of grpc-previous-rpc-attempts header to set - - DoneFunc func() // called when the stream is finished -} - -// ClientTransport is the common interface for all gRPC client-side transport -// implementations. -type ClientTransport interface { - // Close tears down this transport. Once it returns, the transport - // should not be accessed any more. The caller must make sure this - // is called only once. - Close(err error) - - // GracefulClose starts to tear down the transport: the transport will stop - // accepting new RPCs and NewStream will return error. Once all streams are - // finished, the transport will close. - // - // It does not block. - GracefulClose() - - // Write sends the data for the given stream. A nil stream indicates - // the write is to be performed on the transport as a whole. - Write(s *Stream, hdr []byte, data []byte, opts *Options) error - - // NewStream creates a Stream for an RPC. - NewStream(ctx context.Context, callHdr *CallHdr) (*Stream, error) - - // CloseStream clears the footprint of a stream when the stream is - // not needed any more. The err indicates the error incurred when - // CloseStream is called. Must be called when a stream is finished - // unless the associated transport is closing. - CloseStream(stream *Stream, err error) - - // Error returns a channel that is closed when some I/O error - // happens. Typically the caller should have a goroutine to monitor - // this in order to take action (e.g., close the current transport - // and create a new one) in error case. It should not return nil - // once the transport is initiated. - Error() <-chan struct{} - - // GoAway returns a channel that is closed when ClientTransport - // receives the draining signal from the server (e.g., GOAWAY frame in - // HTTP/2). - GoAway() <-chan struct{} - - // GetGoAwayReason returns the reason why GoAway frame was received, along - // with a human readable string with debug info. - GetGoAwayReason() (GoAwayReason, string) - - // RemoteAddr returns the remote network address. - RemoteAddr() net.Addr - - // IncrMsgSent increments the number of message sent through this transport. - IncrMsgSent() - - // IncrMsgRecv increments the number of message received through this transport. - IncrMsgRecv() -} - -// ServerTransport is the common interface for all gRPC server-side transport -// implementations. -// -// Methods may be called concurrently from multiple goroutines, but -// Write methods for a given Stream will be called serially. -type ServerTransport interface { - // HandleStreams receives incoming streams using the given handler. - HandleStreams(context.Context, func(*Stream)) - - // WriteHeader sends the header metadata for the given stream. - // WriteHeader may not be called on all streams. - WriteHeader(s *Stream, md metadata.MD) error - - // Write sends the data for the given stream. - // Write may not be called on all streams. - Write(s *Stream, hdr []byte, data []byte, opts *Options) error - - // WriteStatus sends the status of a stream to the client. WriteStatus is - // the final call made on a stream and always occurs. - WriteStatus(s *Stream, st *status.Status) error - - // Close tears down the transport. Once it is called, the transport - // should not be accessed any more. All the pending streams and their - // handlers will be terminated asynchronously. - Close(err error) - - // Peer returns the peer of the server transport. - Peer() *peer.Peer - - // Drain notifies the client this ServerTransport stops accepting new RPCs. - Drain(debugData string) - - // IncrMsgSent increments the number of message sent through this transport. - IncrMsgSent() - - // IncrMsgRecv increments the number of message received through this transport. - IncrMsgRecv() -} - -// connectionErrorf creates an ConnectionError with the specified error description. -func connectionErrorf(temp bool, e error, format string, a ...any) ConnectionError { - return ConnectionError{ - Desc: fmt.Sprintf(format, a...), - temp: temp, - err: e, - } -} - -// ConnectionError is an error that results in the termination of the -// entire connection and the retry of all the active streams. -type ConnectionError struct { - Desc string - temp bool - err error -} - -func (e ConnectionError) Error() string { - return fmt.Sprintf("connection error: desc = %q", e.Desc) -} - -// Temporary indicates if this connection error is temporary or fatal. -func (e ConnectionError) Temporary() bool { - return e.temp -} - -// Origin returns the original error of this connection error. -func (e ConnectionError) Origin() error { - // Never return nil error here. - // If the original error is nil, return itself. - if e.err == nil { - return e - } - return e.err -} - -// Unwrap returns the original error of this connection error or nil when the -// origin is nil. -func (e ConnectionError) Unwrap() error { - return e.err -} - -var ( - // ErrConnClosing indicates that the transport is closing. - ErrConnClosing = connectionErrorf(true, nil, "transport is closing") - // errStreamDrain indicates that the stream is rejected because the - // connection is draining. This could be caused by goaway or balancer - // removing the address. - errStreamDrain = status.Error(codes.Unavailable, "the connection is draining") - // errStreamDone is returned from write at the client side to indiacte application - // layer of an error. - errStreamDone = errors.New("the stream is done") - // StatusGoAway indicates that the server sent a GOAWAY that included this - // stream's ID in unprocessed RPCs. - statusGoAway = status.New(codes.Unavailable, "the stream is rejected because server is draining the connection") -) - -// GoAwayReason contains the reason for the GoAway frame received. -type GoAwayReason uint8 - -const ( - // GoAwayInvalid indicates that no GoAway frame is received. - GoAwayInvalid GoAwayReason = 0 - // GoAwayNoReason is the default value when GoAway frame is received. - GoAwayNoReason GoAwayReason = 1 - // GoAwayTooManyPings indicates that a GoAway frame with - // ErrCodeEnhanceYourCalm was received and that the debug data said - // "too_many_pings". - GoAwayTooManyPings GoAwayReason = 2 -) - -// ContextErr converts the error from context package into a status error. -func ContextErr(err error) error { - switch err { - case context.DeadlineExceeded: - return status.Error(codes.DeadlineExceeded, err.Error()) - case context.Canceled: - return status.Error(codes.Canceled, err.Error()) - } - return status.Errorf(codes.Internal, "Unexpected error from context packet: %v", err) -} diff --git a/vendor/google.golang.org/grpc/keepalive/keepalive.go b/vendor/google.golang.org/grpc/keepalive/keepalive.go deleted file mode 100644 index 34d31b5e7..000000000 --- a/vendor/google.golang.org/grpc/keepalive/keepalive.go +++ /dev/null @@ -1,85 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package keepalive defines configurable parameters for point-to-point -// healthcheck. -package keepalive - -import ( - "time" -) - -// ClientParameters is used to set keepalive parameters on the client-side. -// These configure how the client will actively probe to notice when a -// connection is broken and send pings so intermediaries will be aware of the -// liveness of the connection. Make sure these parameters are set in -// coordination with the keepalive policy on the server, as incompatible -// settings can result in closing of connection. -type ClientParameters struct { - // After a duration of this time if the client doesn't see any activity it - // pings the server to see if the transport is still alive. - // If set below 10s, a minimum value of 10s will be used instead. - Time time.Duration // The current default value is infinity. - // After having pinged for keepalive check, the client waits for a duration - // of Timeout and if no activity is seen even after that the connection is - // closed. - Timeout time.Duration // The current default value is 20 seconds. - // If true, client sends keepalive pings even with no active RPCs. If false, - // when there are no active RPCs, Time and Timeout will be ignored and no - // keepalive pings will be sent. - PermitWithoutStream bool // false by default. -} - -// ServerParameters is used to set keepalive and max-age parameters on the -// server-side. -type ServerParameters struct { - // MaxConnectionIdle is a duration for the amount of time after which an - // idle connection would be closed by sending a GoAway. Idleness duration is - // defined since the most recent time the number of outstanding RPCs became - // zero or the connection establishment. - MaxConnectionIdle time.Duration // The current default value is infinity. - // MaxConnectionAge is a duration for the maximum amount of time a - // connection may exist before it will be closed by sending a GoAway. A - // random jitter of +/-10% will be added to MaxConnectionAge to spread out - // connection storms. - MaxConnectionAge time.Duration // The current default value is infinity. - // MaxConnectionAgeGrace is an additive period after MaxConnectionAge after - // which the connection will be forcibly closed. - MaxConnectionAgeGrace time.Duration // The current default value is infinity. - // After a duration of this time if the server doesn't see any activity it - // pings the client to see if the transport is still alive. - // If set below 1s, a minimum value of 1s will be used instead. - Time time.Duration // The current default value is 2 hours. - // After having pinged for keepalive check, the server waits for a duration - // of Timeout and if no activity is seen even after that the connection is - // closed. - Timeout time.Duration // The current default value is 20 seconds. -} - -// EnforcementPolicy is used to set keepalive enforcement policy on the -// server-side. Server will close connection with a client that violates this -// policy. -type EnforcementPolicy struct { - // MinTime is the minimum amount of time a client should wait before sending - // a keepalive ping. - MinTime time.Duration // The current default value is 5 minutes. - // If true, server allows keepalive pings even when there are no active - // streams(RPCs). If false, and client sends ping when there are no active - // streams, server will send GOAWAY and close the connection. - PermitWithoutStream bool // false by default. -} diff --git a/vendor/google.golang.org/grpc/metadata/metadata.go b/vendor/google.golang.org/grpc/metadata/metadata.go deleted file mode 100644 index 1e9485fd6..000000000 --- a/vendor/google.golang.org/grpc/metadata/metadata.go +++ /dev/null @@ -1,300 +0,0 @@ -/* - * - * Copyright 2014 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package metadata define the structure of the metadata supported by gRPC library. -// Please refer to https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md -// for more information about custom-metadata. -package metadata // import "google.golang.org/grpc/metadata" - -import ( - "context" - "fmt" - "strings" - - "google.golang.org/grpc/internal" -) - -func init() { - internal.FromOutgoingContextRaw = fromOutgoingContextRaw -} - -// DecodeKeyValue returns k, v, nil. -// -// Deprecated: use k and v directly instead. -func DecodeKeyValue(k, v string) (string, string, error) { - return k, v, nil -} - -// MD is a mapping from metadata keys to values. Users should use the following -// two convenience functions New and Pairs to generate MD. -type MD map[string][]string - -// New creates an MD from a given key-value map. -// -// Only the following ASCII characters are allowed in keys: -// - digits: 0-9 -// - uppercase letters: A-Z (normalized to lower) -// - lowercase letters: a-z -// - special characters: -_. -// -// Uppercase letters are automatically converted to lowercase. -// -// Keys beginning with "grpc-" are reserved for grpc-internal use only and may -// result in errors if set in metadata. -func New(m map[string]string) MD { - md := make(MD, len(m)) - for k, val := range m { - key := strings.ToLower(k) - md[key] = append(md[key], val) - } - return md -} - -// Pairs returns an MD formed by the mapping of key, value ... -// Pairs panics if len(kv) is odd. -// -// Only the following ASCII characters are allowed in keys: -// - digits: 0-9 -// - uppercase letters: A-Z (normalized to lower) -// - lowercase letters: a-z -// - special characters: -_. -// -// Uppercase letters are automatically converted to lowercase. -// -// Keys beginning with "grpc-" are reserved for grpc-internal use only and may -// result in errors if set in metadata. -func Pairs(kv ...string) MD { - if len(kv)%2 == 1 { - panic(fmt.Sprintf("metadata: Pairs got the odd number of input pairs for metadata: %d", len(kv))) - } - md := make(MD, len(kv)/2) - for i := 0; i < len(kv); i += 2 { - key := strings.ToLower(kv[i]) - md[key] = append(md[key], kv[i+1]) - } - return md -} - -// Len returns the number of items in md. -func (md MD) Len() int { - return len(md) -} - -// Copy returns a copy of md. -func (md MD) Copy() MD { - out := make(MD, len(md)) - for k, v := range md { - out[k] = copyOf(v) - } - return out -} - -// Get obtains the values for a given key. -// -// k is converted to lowercase before searching in md. -func (md MD) Get(k string) []string { - k = strings.ToLower(k) - return md[k] -} - -// Set sets the value of a given key with a slice of values. -// -// k is converted to lowercase before storing in md. -func (md MD) Set(k string, vals ...string) { - if len(vals) == 0 { - return - } - k = strings.ToLower(k) - md[k] = vals -} - -// Append adds the values to key k, not overwriting what was already stored at -// that key. -// -// k is converted to lowercase before storing in md. -func (md MD) Append(k string, vals ...string) { - if len(vals) == 0 { - return - } - k = strings.ToLower(k) - md[k] = append(md[k], vals...) -} - -// Delete removes the values for a given key k which is converted to lowercase -// before removing it from md. -func (md MD) Delete(k string) { - k = strings.ToLower(k) - delete(md, k) -} - -// Join joins any number of mds into a single MD. -// -// The order of values for each key is determined by the order in which the mds -// containing those values are presented to Join. -func Join(mds ...MD) MD { - out := MD{} - for _, md := range mds { - for k, v := range md { - out[k] = append(out[k], v...) - } - } - return out -} - -type mdIncomingKey struct{} -type mdOutgoingKey struct{} - -// NewIncomingContext creates a new context with incoming md attached. md must -// not be modified after calling this function. -func NewIncomingContext(ctx context.Context, md MD) context.Context { - return context.WithValue(ctx, mdIncomingKey{}, md) -} - -// NewOutgoingContext creates a new context with outgoing md attached. If used -// in conjunction with AppendToOutgoingContext, NewOutgoingContext will -// overwrite any previously-appended metadata. md must not be modified after -// calling this function. -func NewOutgoingContext(ctx context.Context, md MD) context.Context { - return context.WithValue(ctx, mdOutgoingKey{}, rawMD{md: md}) -} - -// AppendToOutgoingContext returns a new context with the provided kv merged -// with any existing metadata in the context. Please refer to the documentation -// of Pairs for a description of kv. -func AppendToOutgoingContext(ctx context.Context, kv ...string) context.Context { - if len(kv)%2 == 1 { - panic(fmt.Sprintf("metadata: AppendToOutgoingContext got an odd number of input pairs for metadata: %d", len(kv))) - } - md, _ := ctx.Value(mdOutgoingKey{}).(rawMD) - added := make([][]string, len(md.added)+1) - copy(added, md.added) - kvCopy := make([]string, 0, len(kv)) - for i := 0; i < len(kv); i += 2 { - kvCopy = append(kvCopy, strings.ToLower(kv[i]), kv[i+1]) - } - added[len(added)-1] = kvCopy - return context.WithValue(ctx, mdOutgoingKey{}, rawMD{md: md.md, added: added}) -} - -// FromIncomingContext returns the incoming metadata in ctx if it exists. -// -// All keys in the returned MD are lowercase. -func FromIncomingContext(ctx context.Context) (MD, bool) { - md, ok := ctx.Value(mdIncomingKey{}).(MD) - if !ok { - return nil, false - } - out := make(MD, len(md)) - for k, v := range md { - // We need to manually convert all keys to lower case, because MD is a - // map, and there's no guarantee that the MD attached to the context is - // created using our helper functions. - key := strings.ToLower(k) - out[key] = copyOf(v) - } - return out, true -} - -// ValueFromIncomingContext returns the metadata value corresponding to the metadata -// key from the incoming metadata if it exists. Keys are matched in a case insensitive -// manner. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func ValueFromIncomingContext(ctx context.Context, key string) []string { - md, ok := ctx.Value(mdIncomingKey{}).(MD) - if !ok { - return nil - } - - if v, ok := md[key]; ok { - return copyOf(v) - } - for k, v := range md { - // Case insenitive comparison: MD is a map, and there's no guarantee - // that the MD attached to the context is created using our helper - // functions. - if strings.EqualFold(k, key) { - return copyOf(v) - } - } - return nil -} - -func copyOf(v []string) []string { - vals := make([]string, len(v)) - copy(vals, v) - return vals -} - -// fromOutgoingContextRaw returns the un-merged, intermediary contents of rawMD. -// -// Remember to perform strings.ToLower on the keys, for both the returned MD (MD -// is a map, there's no guarantee it's created using our helper functions) and -// the extra kv pairs (AppendToOutgoingContext doesn't turn them into -// lowercase). -func fromOutgoingContextRaw(ctx context.Context) (MD, [][]string, bool) { - raw, ok := ctx.Value(mdOutgoingKey{}).(rawMD) - if !ok { - return nil, nil, false - } - - return raw.md, raw.added, true -} - -// FromOutgoingContext returns the outgoing metadata in ctx if it exists. -// -// All keys in the returned MD are lowercase. -func FromOutgoingContext(ctx context.Context) (MD, bool) { - raw, ok := ctx.Value(mdOutgoingKey{}).(rawMD) - if !ok { - return nil, false - } - - mdSize := len(raw.md) - for i := range raw.added { - mdSize += len(raw.added[i]) / 2 - } - - out := make(MD, mdSize) - for k, v := range raw.md { - // We need to manually convert all keys to lower case, because MD is a - // map, and there's no guarantee that the MD attached to the context is - // created using our helper functions. - key := strings.ToLower(k) - out[key] = copyOf(v) - } - for _, added := range raw.added { - if len(added)%2 == 1 { - panic(fmt.Sprintf("metadata: FromOutgoingContext got an odd number of input pairs for metadata: %d", len(added))) - } - - for i := 0; i < len(added); i += 2 { - key := strings.ToLower(added[i]) - out[key] = append(out[key], added[i+1]) - } - } - return out, ok -} - -type rawMD struct { - md MD - added [][]string -} diff --git a/vendor/google.golang.org/grpc/peer/peer.go b/vendor/google.golang.org/grpc/peer/peer.go deleted file mode 100644 index a821ff9b2..000000000 --- a/vendor/google.golang.org/grpc/peer/peer.go +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * Copyright 2014 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package peer defines various peer information associated with RPCs and -// corresponding utils. -package peer - -import ( - "context" - "net" - - "google.golang.org/grpc/credentials" -) - -// Peer contains the information of the peer for an RPC, such as the address -// and authentication information. -type Peer struct { - // Addr is the peer address. - Addr net.Addr - // LocalAddr is the local address. - LocalAddr net.Addr - // AuthInfo is the authentication information of the transport. - // It is nil if there is no transport security being used. - AuthInfo credentials.AuthInfo -} - -type peerKey struct{} - -// NewContext creates a new context with peer information attached. -func NewContext(ctx context.Context, p *Peer) context.Context { - return context.WithValue(ctx, peerKey{}, p) -} - -// FromContext returns the peer information in ctx if it exists. -func FromContext(ctx context.Context) (p *Peer, ok bool) { - p, ok = ctx.Value(peerKey{}).(*Peer) - return -} diff --git a/vendor/google.golang.org/grpc/picker_wrapper.go b/vendor/google.golang.org/grpc/picker_wrapper.go deleted file mode 100644 index bf56faa76..000000000 --- a/vendor/google.golang.org/grpc/picker_wrapper.go +++ /dev/null @@ -1,223 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpc - -import ( - "context" - "io" - "sync" - - "google.golang.org/grpc/balancer" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/internal/channelz" - istatus "google.golang.org/grpc/internal/status" - "google.golang.org/grpc/internal/transport" - "google.golang.org/grpc/stats" - "google.golang.org/grpc/status" -) - -// pickerWrapper is a wrapper of balancer.Picker. It blocks on certain pick -// actions and unblock when there's a picker update. -type pickerWrapper struct { - mu sync.Mutex - done bool - blockingCh chan struct{} - picker balancer.Picker - statsHandlers []stats.Handler // to record blocking picker calls -} - -func newPickerWrapper(statsHandlers []stats.Handler) *pickerWrapper { - return &pickerWrapper{ - blockingCh: make(chan struct{}), - statsHandlers: statsHandlers, - } -} - -// updatePicker is called by UpdateBalancerState. It unblocks all blocked pick. -func (pw *pickerWrapper) updatePicker(p balancer.Picker) { - pw.mu.Lock() - if pw.done { - pw.mu.Unlock() - return - } - pw.picker = p - // pw.blockingCh should never be nil. - close(pw.blockingCh) - pw.blockingCh = make(chan struct{}) - pw.mu.Unlock() -} - -// doneChannelzWrapper performs the following: -// - increments the calls started channelz counter -// - wraps the done function in the passed in result to increment the calls -// failed or calls succeeded channelz counter before invoking the actual -// done function. -func doneChannelzWrapper(acbw *acBalancerWrapper, result *balancer.PickResult) { - ac := acbw.ac - ac.incrCallsStarted() - done := result.Done - result.Done = func(b balancer.DoneInfo) { - if b.Err != nil && b.Err != io.EOF { - ac.incrCallsFailed() - } else { - ac.incrCallsSucceeded() - } - if done != nil { - done(b) - } - } -} - -// pick returns the transport that will be used for the RPC. -// It may block in the following cases: -// - there's no picker -// - the current picker returns ErrNoSubConnAvailable -// - the current picker returns other errors and failfast is false. -// - the subConn returned by the current picker is not READY -// When one of these situations happens, pick blocks until the picker gets updated. -func (pw *pickerWrapper) pick(ctx context.Context, failfast bool, info balancer.PickInfo) (transport.ClientTransport, balancer.PickResult, error) { - var ch chan struct{} - - var lastPickErr error - - for { - pw.mu.Lock() - if pw.done { - pw.mu.Unlock() - return nil, balancer.PickResult{}, ErrClientConnClosing - } - - if pw.picker == nil { - ch = pw.blockingCh - } - if ch == pw.blockingCh { - // This could happen when either: - // - pw.picker is nil (the previous if condition), or - // - has called pick on the current picker. - pw.mu.Unlock() - select { - case <-ctx.Done(): - var errStr string - if lastPickErr != nil { - errStr = "latest balancer error: " + lastPickErr.Error() - } else { - errStr = ctx.Err().Error() - } - switch ctx.Err() { - case context.DeadlineExceeded: - return nil, balancer.PickResult{}, status.Error(codes.DeadlineExceeded, errStr) - case context.Canceled: - return nil, balancer.PickResult{}, status.Error(codes.Canceled, errStr) - } - case <-ch: - } - continue - } - - // If the channel is set, it means that the pick call had to wait for a - // new picker at some point. Either it's the first iteration and this - // function received the first picker, or a picker errored with - // ErrNoSubConnAvailable or errored with failfast set to false, which - // will trigger a continue to the next iteration. In the first case this - // conditional will hit if this call had to block (the channel is set). - // In the second case, the only way it will get to this conditional is - // if there is a new picker. - if ch != nil { - for _, sh := range pw.statsHandlers { - sh.HandleRPC(ctx, &stats.PickerUpdated{}) - } - } - - ch = pw.blockingCh - p := pw.picker - pw.mu.Unlock() - - pickResult, err := p.Pick(info) - if err != nil { - if err == balancer.ErrNoSubConnAvailable { - continue - } - if st, ok := status.FromError(err); ok { - // Status error: end the RPC unconditionally with this status. - // First restrict the code to the list allowed by gRFC A54. - if istatus.IsRestrictedControlPlaneCode(st) { - err = status.Errorf(codes.Internal, "received picker error with illegal status: %v", err) - } - return nil, balancer.PickResult{}, dropError{error: err} - } - // For all other errors, wait for ready RPCs should block and other - // RPCs should fail with unavailable. - if !failfast { - lastPickErr = err - continue - } - return nil, balancer.PickResult{}, status.Error(codes.Unavailable, err.Error()) - } - - acbw, ok := pickResult.SubConn.(*acBalancerWrapper) - if !ok { - logger.Errorf("subconn returned from pick is type %T, not *acBalancerWrapper", pickResult.SubConn) - continue - } - if t := acbw.ac.getReadyTransport(); t != nil { - if channelz.IsOn() { - doneChannelzWrapper(acbw, &pickResult) - return t, pickResult, nil - } - return t, pickResult, nil - } - if pickResult.Done != nil { - // Calling done with nil error, no bytes sent and no bytes received. - // DoneInfo with default value works. - pickResult.Done(balancer.DoneInfo{}) - } - logger.Infof("blockingPicker: the picked transport is not ready, loop back to repick") - // If ok == false, ac.state is not READY. - // A valid picker always returns READY subConn. This means the state of ac - // just changed, and picker will be updated shortly. - // continue back to the beginning of the for loop to repick. - } -} - -func (pw *pickerWrapper) close() { - pw.mu.Lock() - defer pw.mu.Unlock() - if pw.done { - return - } - pw.done = true - close(pw.blockingCh) -} - -// reset clears the pickerWrapper and prepares it for being used again when idle -// mode is exited. -func (pw *pickerWrapper) reset() { - pw.mu.Lock() - defer pw.mu.Unlock() - if pw.done { - return - } - pw.blockingCh = make(chan struct{}) -} - -// dropError is a wrapper error that indicates the LB policy wishes to drop the -// RPC and not retry it. -type dropError struct { - error -} diff --git a/vendor/google.golang.org/grpc/pickfirst.go b/vendor/google.golang.org/grpc/pickfirst.go deleted file mode 100644 index e3ea42ba9..000000000 --- a/vendor/google.golang.org/grpc/pickfirst.go +++ /dev/null @@ -1,241 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpc - -import ( - "encoding/json" - "errors" - "fmt" - - "google.golang.org/grpc/balancer" - "google.golang.org/grpc/connectivity" - internalgrpclog "google.golang.org/grpc/internal/grpclog" - "google.golang.org/grpc/internal/grpcrand" - "google.golang.org/grpc/internal/pretty" - "google.golang.org/grpc/resolver" - "google.golang.org/grpc/serviceconfig" -) - -const ( - // PickFirstBalancerName is the name of the pick_first balancer. - PickFirstBalancerName = "pick_first" - logPrefix = "[pick-first-lb %p] " -) - -type pickfirstBuilder struct{} - -func (pickfirstBuilder) Build(cc balancer.ClientConn, opt balancer.BuildOptions) balancer.Balancer { - b := &pickfirstBalancer{cc: cc} - b.logger = internalgrpclog.NewPrefixLogger(logger, fmt.Sprintf(logPrefix, b)) - return b -} - -func (pickfirstBuilder) Name() string { - return PickFirstBalancerName -} - -type pfConfig struct { - serviceconfig.LoadBalancingConfig `json:"-"` - - // If set to true, instructs the LB policy to shuffle the order of the list - // of addresses received from the name resolver before attempting to - // connect to them. - ShuffleAddressList bool `json:"shuffleAddressList"` -} - -func (pickfirstBuilder) ParseConfig(js json.RawMessage) (serviceconfig.LoadBalancingConfig, error) { - var cfg pfConfig - if err := json.Unmarshal(js, &cfg); err != nil { - return nil, fmt.Errorf("pickfirst: unable to unmarshal LB policy config: %s, error: %v", string(js), err) - } - return cfg, nil -} - -type pickfirstBalancer struct { - logger *internalgrpclog.PrefixLogger - state connectivity.State - cc balancer.ClientConn - subConn balancer.SubConn -} - -func (b *pickfirstBalancer) ResolverError(err error) { - if b.logger.V(2) { - b.logger.Infof("Received error from the name resolver: %v", err) - } - if b.subConn == nil { - b.state = connectivity.TransientFailure - } - - if b.state != connectivity.TransientFailure { - // The picker will not change since the balancer does not currently - // report an error. - return - } - b.cc.UpdateState(balancer.State{ - ConnectivityState: connectivity.TransientFailure, - Picker: &picker{err: fmt.Errorf("name resolver error: %v", err)}, - }) -} - -func (b *pickfirstBalancer) UpdateClientConnState(state balancer.ClientConnState) error { - addrs := state.ResolverState.Addresses - if len(addrs) == 0 { - // The resolver reported an empty address list. Treat it like an error by - // calling b.ResolverError. - if b.subConn != nil { - // Shut down the old subConn. All addresses were removed, so it is - // no longer valid. - b.subConn.Shutdown() - b.subConn = nil - } - b.ResolverError(errors.New("produced zero addresses")) - return balancer.ErrBadResolverState - } - - // We don't have to guard this block with the env var because ParseConfig - // already does so. - cfg, ok := state.BalancerConfig.(pfConfig) - if state.BalancerConfig != nil && !ok { - return fmt.Errorf("pickfirst: received illegal BalancerConfig (type %T): %v", state.BalancerConfig, state.BalancerConfig) - } - if cfg.ShuffleAddressList { - addrs = append([]resolver.Address{}, addrs...) - grpcrand.Shuffle(len(addrs), func(i, j int) { addrs[i], addrs[j] = addrs[j], addrs[i] }) - } - - if b.logger.V(2) { - b.logger.Infof("Received new config %s, resolver state %s", pretty.ToJSON(cfg), pretty.ToJSON(state.ResolverState)) - } - - if b.subConn != nil { - b.cc.UpdateAddresses(b.subConn, addrs) - return nil - } - - var subConn balancer.SubConn - subConn, err := b.cc.NewSubConn(addrs, balancer.NewSubConnOptions{ - StateListener: func(state balancer.SubConnState) { - b.updateSubConnState(subConn, state) - }, - }) - if err != nil { - if b.logger.V(2) { - b.logger.Infof("Failed to create new SubConn: %v", err) - } - b.state = connectivity.TransientFailure - b.cc.UpdateState(balancer.State{ - ConnectivityState: connectivity.TransientFailure, - Picker: &picker{err: fmt.Errorf("error creating connection: %v", err)}, - }) - return balancer.ErrBadResolverState - } - b.subConn = subConn - b.state = connectivity.Idle - b.cc.UpdateState(balancer.State{ - ConnectivityState: connectivity.Connecting, - Picker: &picker{err: balancer.ErrNoSubConnAvailable}, - }) - b.subConn.Connect() - return nil -} - -// UpdateSubConnState is unused as a StateListener is always registered when -// creating SubConns. -func (b *pickfirstBalancer) UpdateSubConnState(subConn balancer.SubConn, state balancer.SubConnState) { - b.logger.Errorf("UpdateSubConnState(%v, %+v) called unexpectedly", subConn, state) -} - -func (b *pickfirstBalancer) updateSubConnState(subConn balancer.SubConn, state balancer.SubConnState) { - if b.logger.V(2) { - b.logger.Infof("Received SubConn state update: %p, %+v", subConn, state) - } - if b.subConn != subConn { - if b.logger.V(2) { - b.logger.Infof("Ignored state change because subConn is not recognized") - } - return - } - if state.ConnectivityState == connectivity.Shutdown { - b.subConn = nil - return - } - - switch state.ConnectivityState { - case connectivity.Ready: - b.cc.UpdateState(balancer.State{ - ConnectivityState: state.ConnectivityState, - Picker: &picker{result: balancer.PickResult{SubConn: subConn}}, - }) - case connectivity.Connecting: - if b.state == connectivity.TransientFailure { - // We stay in TransientFailure until we are Ready. See A62. - return - } - b.cc.UpdateState(balancer.State{ - ConnectivityState: state.ConnectivityState, - Picker: &picker{err: balancer.ErrNoSubConnAvailable}, - }) - case connectivity.Idle: - if b.state == connectivity.TransientFailure { - // We stay in TransientFailure until we are Ready. Also kick the - // subConn out of Idle into Connecting. See A62. - b.subConn.Connect() - return - } - b.cc.UpdateState(balancer.State{ - ConnectivityState: state.ConnectivityState, - Picker: &idlePicker{subConn: subConn}, - }) - case connectivity.TransientFailure: - b.cc.UpdateState(balancer.State{ - ConnectivityState: state.ConnectivityState, - Picker: &picker{err: state.ConnectionError}, - }) - } - b.state = state.ConnectivityState -} - -func (b *pickfirstBalancer) Close() { -} - -func (b *pickfirstBalancer) ExitIdle() { - if b.subConn != nil && b.state == connectivity.Idle { - b.subConn.Connect() - } -} - -type picker struct { - result balancer.PickResult - err error -} - -func (p *picker) Pick(balancer.PickInfo) (balancer.PickResult, error) { - return p.result, p.err -} - -// idlePicker is used when the SubConn is IDLE and kicks the SubConn into -// CONNECTING when Pick is called. -type idlePicker struct { - subConn balancer.SubConn -} - -func (i *idlePicker) Pick(balancer.PickInfo) (balancer.PickResult, error) { - i.subConn.Connect() - return balancer.PickResult{}, balancer.ErrNoSubConnAvailable -} diff --git a/vendor/google.golang.org/grpc/preloader.go b/vendor/google.golang.org/grpc/preloader.go deleted file mode 100644 index 73bd63364..000000000 --- a/vendor/google.golang.org/grpc/preloader.go +++ /dev/null @@ -1,67 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpc - -import ( - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -// PreparedMsg is responsible for creating a Marshalled and Compressed object. -// -// # Experimental -// -// Notice: This type is EXPERIMENTAL and may be changed or removed in a -// later release. -type PreparedMsg struct { - // Struct for preparing msg before sending them - encodedData []byte - hdr []byte - payload []byte -} - -// Encode marshalls and compresses the message using the codec and compressor for the stream. -func (p *PreparedMsg) Encode(s Stream, msg any) error { - ctx := s.Context() - rpcInfo, ok := rpcInfoFromContext(ctx) - if !ok { - return status.Errorf(codes.Internal, "grpc: unable to get rpcInfo") - } - - // check if the context has the relevant information to prepareMsg - if rpcInfo.preloaderInfo == nil { - return status.Errorf(codes.Internal, "grpc: rpcInfo.preloaderInfo is nil") - } - if rpcInfo.preloaderInfo.codec == nil { - return status.Errorf(codes.Internal, "grpc: rpcInfo.preloaderInfo.codec is nil") - } - - // prepare the msg - data, err := encode(rpcInfo.preloaderInfo.codec, msg) - if err != nil { - return err - } - p.encodedData = data - compData, err := compress(data, rpcInfo.preloaderInfo.cp, rpcInfo.preloaderInfo.comp) - if err != nil { - return err - } - p.hdr, p.payload = msgHeader(data, compData) - return nil -} diff --git a/vendor/google.golang.org/grpc/regenerate.sh b/vendor/google.golang.org/grpc/regenerate.sh deleted file mode 100644 index a6f26c8ab..000000000 --- a/vendor/google.golang.org/grpc/regenerate.sh +++ /dev/null @@ -1,123 +0,0 @@ -#!/bin/bash -# Copyright 2020 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eu -o pipefail - -WORKDIR=$(mktemp -d) - -function finish { - rm -rf "$WORKDIR" -} -trap finish EXIT - -export GOBIN=${WORKDIR}/bin -export PATH=${GOBIN}:${PATH} -mkdir -p ${GOBIN} - -echo "remove existing generated files" -# grpc_testing_not_regenerate/*.pb.go is not re-generated, -# see grpc_testing_not_regenerate/README.md for details. -rm -f $(find . -name '*.pb.go' | grep -v 'grpc_testing_not_regenerate') - -echo "go install google.golang.org/protobuf/cmd/protoc-gen-go" -(cd test/tools && go install google.golang.org/protobuf/cmd/protoc-gen-go) - -echo "go install cmd/protoc-gen-go-grpc" -(cd cmd/protoc-gen-go-grpc && go install .) - -echo "git clone https://github.com/grpc/grpc-proto" -git clone --quiet https://github.com/grpc/grpc-proto ${WORKDIR}/grpc-proto - -echo "git clone https://github.com/protocolbuffers/protobuf" -git clone --quiet https://github.com/protocolbuffers/protobuf ${WORKDIR}/protobuf - -# Pull in code.proto as a proto dependency -mkdir -p ${WORKDIR}/googleapis/google/rpc -echo "curl https://raw.githubusercontent.com/googleapis/googleapis/master/google/rpc/code.proto" -curl --silent https://raw.githubusercontent.com/googleapis/googleapis/master/google/rpc/code.proto > ${WORKDIR}/googleapis/google/rpc/code.proto - -mkdir -p ${WORKDIR}/out - -# Generates sources without the embed requirement -LEGACY_SOURCES=( - ${WORKDIR}/grpc-proto/grpc/binlog/v1/binarylog.proto - ${WORKDIR}/grpc-proto/grpc/channelz/v1/channelz.proto - ${WORKDIR}/grpc-proto/grpc/health/v1/health.proto - ${WORKDIR}/grpc-proto/grpc/lb/v1/load_balancer.proto - profiling/proto/service.proto - ${WORKDIR}/grpc-proto/grpc/reflection/v1alpha/reflection.proto - ${WORKDIR}/grpc-proto/grpc/reflection/v1/reflection.proto -) - -# Generates only the new gRPC Service symbols -SOURCES=( - $(git ls-files --exclude-standard --cached --others "*.proto" | grep -v '^\(profiling/proto/service.proto\|reflection/grpc_reflection_v1alpha/reflection.proto\)$') - ${WORKDIR}/grpc-proto/grpc/gcp/altscontext.proto - ${WORKDIR}/grpc-proto/grpc/gcp/handshaker.proto - ${WORKDIR}/grpc-proto/grpc/gcp/transport_security_common.proto - ${WORKDIR}/grpc-proto/grpc/lookup/v1/rls.proto - ${WORKDIR}/grpc-proto/grpc/lookup/v1/rls_config.proto - ${WORKDIR}/grpc-proto/grpc/testing/*.proto - ${WORKDIR}/grpc-proto/grpc/core/*.proto -) - -# These options of the form 'Mfoo.proto=bar' instruct the codegen to use an -# import path of 'bar' in the generated code when 'foo.proto' is imported in -# one of the sources. -# -# Note that the protos listed here are all for testing purposes. All protos to -# be used externally should have a go_package option (and they don't need to be -# listed here). -OPTS=Mgrpc/core/stats.proto=google.golang.org/grpc/interop/grpc_testing/core,\ -Mgrpc/testing/benchmark_service.proto=google.golang.org/grpc/interop/grpc_testing,\ -Mgrpc/testing/stats.proto=google.golang.org/grpc/interop/grpc_testing,\ -Mgrpc/testing/report_qps_scenario_service.proto=google.golang.org/grpc/interop/grpc_testing,\ -Mgrpc/testing/messages.proto=google.golang.org/grpc/interop/grpc_testing,\ -Mgrpc/testing/worker_service.proto=google.golang.org/grpc/interop/grpc_testing,\ -Mgrpc/testing/control.proto=google.golang.org/grpc/interop/grpc_testing,\ -Mgrpc/testing/test.proto=google.golang.org/grpc/interop/grpc_testing,\ -Mgrpc/testing/payloads.proto=google.golang.org/grpc/interop/grpc_testing,\ -Mgrpc/testing/empty.proto=google.golang.org/grpc/interop/grpc_testing - -for src in ${SOURCES[@]}; do - echo "protoc ${src}" - protoc --go_out=${OPTS}:${WORKDIR}/out --go-grpc_out=${OPTS}:${WORKDIR}/out \ - -I"." \ - -I${WORKDIR}/grpc-proto \ - -I${WORKDIR}/googleapis \ - -I${WORKDIR}/protobuf/src \ - ${src} -done - -for src in ${LEGACY_SOURCES[@]}; do - echo "protoc ${src}" - protoc --go_out=${OPTS}:${WORKDIR}/out --go-grpc_out=${OPTS},require_unimplemented_servers=false:${WORKDIR}/out \ - -I"." \ - -I${WORKDIR}/grpc-proto \ - -I${WORKDIR}/googleapis \ - -I${WORKDIR}/protobuf/src \ - ${src} -done - -# The go_package option in grpc/lookup/v1/rls.proto doesn't match the -# current location. Move it into the right place. -mkdir -p ${WORKDIR}/out/google.golang.org/grpc/internal/proto/grpc_lookup_v1 -mv ${WORKDIR}/out/google.golang.org/grpc/lookup/grpc_lookup_v1/* ${WORKDIR}/out/google.golang.org/grpc/internal/proto/grpc_lookup_v1 - -# grpc_testing_not_regenerate/*.pb.go are not re-generated, -# see grpc_testing_not_regenerate/README.md for details. -rm ${WORKDIR}/out/google.golang.org/grpc/reflection/grpc_testing_not_regenerate/*.pb.go - -cp -R ${WORKDIR}/out/google.golang.org/grpc/* . diff --git a/vendor/google.golang.org/grpc/resolver/dns/dns_resolver.go b/vendor/google.golang.org/grpc/resolver/dns/dns_resolver.go deleted file mode 100644 index b54a3a322..000000000 --- a/vendor/google.golang.org/grpc/resolver/dns/dns_resolver.go +++ /dev/null @@ -1,54 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package dns implements a dns resolver to be installed as the default resolver -// in grpc. -// -// Deprecated: this package is imported by grpc and should not need to be -// imported directly by users. -package dns - -import ( - "time" - - "google.golang.org/grpc/internal/resolver/dns" - "google.golang.org/grpc/resolver" -) - -// SetResolvingTimeout sets the maximum duration for DNS resolution requests. -// -// This function affects the global timeout used by all channels using the DNS -// name resolver scheme. -// -// It must be called only at application startup, before any gRPC calls are -// made. Modifying this value after initialization is not thread-safe. -// -// The default value is 30 seconds. Setting the timeout too low may result in -// premature timeouts during resolution, while setting it too high may lead to -// unnecessary delays in service discovery. Choose a value appropriate for your -// specific needs and network environment. -func SetResolvingTimeout(timeout time.Duration) { - dns.ResolvingTimeout = timeout -} - -// NewBuilder creates a dnsBuilder which is used to factory DNS resolvers. -// -// Deprecated: import grpc and use resolver.Get("dns") instead. -func NewBuilder() resolver.Builder { - return dns.NewBuilder() -} diff --git a/vendor/google.golang.org/grpc/resolver/map.go b/vendor/google.golang.org/grpc/resolver/map.go deleted file mode 100644 index ada5b9bb7..000000000 --- a/vendor/google.golang.org/grpc/resolver/map.go +++ /dev/null @@ -1,251 +0,0 @@ -/* - * - * Copyright 2021 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package resolver - -type addressMapEntry struct { - addr Address - value any -} - -// AddressMap is a map of addresses to arbitrary values taking into account -// Attributes. BalancerAttributes are ignored, as are Metadata and Type. -// Multiple accesses may not be performed concurrently. Must be created via -// NewAddressMap; do not construct directly. -type AddressMap struct { - // The underlying map is keyed by an Address with fields that we don't care - // about being set to their zero values. The only fields that we care about - // are `Addr`, `ServerName` and `Attributes`. Since we need to be able to - // distinguish between addresses with same `Addr` and `ServerName`, but - // different `Attributes`, we cannot store the `Attributes` in the map key. - // - // The comparison operation for structs work as follows: - // Struct values are comparable if all their fields are comparable. Two - // struct values are equal if their corresponding non-blank fields are equal. - // - // The value type of the map contains a slice of addresses which match the key - // in their `Addr` and `ServerName` fields and contain the corresponding value - // associated with them. - m map[Address]addressMapEntryList -} - -func toMapKey(addr *Address) Address { - return Address{Addr: addr.Addr, ServerName: addr.ServerName} -} - -type addressMapEntryList []*addressMapEntry - -// NewAddressMap creates a new AddressMap. -func NewAddressMap() *AddressMap { - return &AddressMap{m: make(map[Address]addressMapEntryList)} -} - -// find returns the index of addr in the addressMapEntry slice, or -1 if not -// present. -func (l addressMapEntryList) find(addr Address) int { - for i, entry := range l { - // Attributes are the only thing to match on here, since `Addr` and - // `ServerName` are already equal. - if entry.addr.Attributes.Equal(addr.Attributes) { - return i - } - } - return -1 -} - -// Get returns the value for the address in the map, if present. -func (a *AddressMap) Get(addr Address) (value any, ok bool) { - addrKey := toMapKey(&addr) - entryList := a.m[addrKey] - if entry := entryList.find(addr); entry != -1 { - return entryList[entry].value, true - } - return nil, false -} - -// Set updates or adds the value to the address in the map. -func (a *AddressMap) Set(addr Address, value any) { - addrKey := toMapKey(&addr) - entryList := a.m[addrKey] - if entry := entryList.find(addr); entry != -1 { - entryList[entry].value = value - return - } - a.m[addrKey] = append(entryList, &addressMapEntry{addr: addr, value: value}) -} - -// Delete removes addr from the map. -func (a *AddressMap) Delete(addr Address) { - addrKey := toMapKey(&addr) - entryList := a.m[addrKey] - entry := entryList.find(addr) - if entry == -1 { - return - } - if len(entryList) == 1 { - entryList = nil - } else { - copy(entryList[entry:], entryList[entry+1:]) - entryList = entryList[:len(entryList)-1] - } - a.m[addrKey] = entryList -} - -// Len returns the number of entries in the map. -func (a *AddressMap) Len() int { - ret := 0 - for _, entryList := range a.m { - ret += len(entryList) - } - return ret -} - -// Keys returns a slice of all current map keys. -func (a *AddressMap) Keys() []Address { - ret := make([]Address, 0, a.Len()) - for _, entryList := range a.m { - for _, entry := range entryList { - ret = append(ret, entry.addr) - } - } - return ret -} - -// Values returns a slice of all current map values. -func (a *AddressMap) Values() []any { - ret := make([]any, 0, a.Len()) - for _, entryList := range a.m { - for _, entry := range entryList { - ret = append(ret, entry.value) - } - } - return ret -} - -type endpointNode struct { - addrs map[string]struct{} -} - -// Equal returns whether the unordered set of addrs are the same between the -// endpoint nodes. -func (en *endpointNode) Equal(en2 *endpointNode) bool { - if len(en.addrs) != len(en2.addrs) { - return false - } - for addr := range en.addrs { - if _, ok := en2.addrs[addr]; !ok { - return false - } - } - return true -} - -func toEndpointNode(endpoint Endpoint) endpointNode { - en := make(map[string]struct{}) - for _, addr := range endpoint.Addresses { - en[addr.Addr] = struct{}{} - } - return endpointNode{ - addrs: en, - } -} - -// EndpointMap is a map of endpoints to arbitrary values keyed on only the -// unordered set of address strings within an endpoint. This map is not thread -// safe, thus it is unsafe to access concurrently. Must be created via -// NewEndpointMap; do not construct directly. -type EndpointMap struct { - endpoints map[*endpointNode]any -} - -// NewEndpointMap creates a new EndpointMap. -func NewEndpointMap() *EndpointMap { - return &EndpointMap{ - endpoints: make(map[*endpointNode]any), - } -} - -// Get returns the value for the address in the map, if present. -func (em *EndpointMap) Get(e Endpoint) (value any, ok bool) { - en := toEndpointNode(e) - if endpoint := em.find(en); endpoint != nil { - return em.endpoints[endpoint], true - } - return nil, false -} - -// Set updates or adds the value to the address in the map. -func (em *EndpointMap) Set(e Endpoint, value any) { - en := toEndpointNode(e) - if endpoint := em.find(en); endpoint != nil { - em.endpoints[endpoint] = value - return - } - em.endpoints[&en] = value -} - -// Len returns the number of entries in the map. -func (em *EndpointMap) Len() int { - return len(em.endpoints) -} - -// Keys returns a slice of all current map keys, as endpoints specifying the -// addresses present in the endpoint keys, in which uniqueness is determined by -// the unordered set of addresses. Thus, endpoint information returned is not -// the full endpoint data (drops duplicated addresses and attributes) but can be -// used for EndpointMap accesses. -func (em *EndpointMap) Keys() []Endpoint { - ret := make([]Endpoint, 0, len(em.endpoints)) - for en := range em.endpoints { - var endpoint Endpoint - for addr := range en.addrs { - endpoint.Addresses = append(endpoint.Addresses, Address{Addr: addr}) - } - ret = append(ret, endpoint) - } - return ret -} - -// Values returns a slice of all current map values. -func (em *EndpointMap) Values() []any { - ret := make([]any, 0, len(em.endpoints)) - for _, val := range em.endpoints { - ret = append(ret, val) - } - return ret -} - -// find returns a pointer to the endpoint node in em if the endpoint node is -// already present. If not found, nil is returned. The comparisons are done on -// the unordered set of addresses within an endpoint. -func (em EndpointMap) find(e endpointNode) *endpointNode { - for endpoint := range em.endpoints { - if e.Equal(endpoint) { - return endpoint - } - } - return nil -} - -// Delete removes the specified endpoint from the map. -func (em *EndpointMap) Delete(e Endpoint) { - en := toEndpointNode(e) - if entry := em.find(en); entry != nil { - delete(em.endpoints, entry) - } -} diff --git a/vendor/google.golang.org/grpc/resolver/resolver.go b/vendor/google.golang.org/grpc/resolver/resolver.go deleted file mode 100644 index 202854511..000000000 --- a/vendor/google.golang.org/grpc/resolver/resolver.go +++ /dev/null @@ -1,332 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package resolver defines APIs for name resolution in gRPC. -// All APIs in this package are experimental. -package resolver - -import ( - "context" - "fmt" - "net" - "net/url" - "strings" - - "google.golang.org/grpc/attributes" - "google.golang.org/grpc/credentials" - "google.golang.org/grpc/internal" - "google.golang.org/grpc/serviceconfig" -) - -var ( - // m is a map from scheme to resolver builder. - m = make(map[string]Builder) - // defaultScheme is the default scheme to use. - defaultScheme = "passthrough" -) - -// TODO(bar) install dns resolver in init(){}. - -// Register registers the resolver builder to the resolver map. b.Scheme will -// be used as the scheme registered with this builder. The registry is case -// sensitive, and schemes should not contain any uppercase characters. -// -// NOTE: this function must only be called during initialization time (i.e. in -// an init() function), and is not thread-safe. If multiple Resolvers are -// registered with the same name, the one registered last will take effect. -func Register(b Builder) { - m[b.Scheme()] = b -} - -// Get returns the resolver builder registered with the given scheme. -// -// If no builder is register with the scheme, nil will be returned. -func Get(scheme string) Builder { - if b, ok := m[scheme]; ok { - return b - } - return nil -} - -// SetDefaultScheme sets the default scheme that will be used. The default -// scheme is initially set to "passthrough". -// -// NOTE: this function must only be called during initialization time (i.e. in -// an init() function), and is not thread-safe. The scheme set last overrides -// previously set values. -func SetDefaultScheme(scheme string) { - defaultScheme = scheme - internal.UserSetDefaultScheme = true -} - -// GetDefaultScheme gets the default scheme that will be used by grpc.Dial. If -// SetDefaultScheme is never called, the default scheme used by grpc.NewClient is "dns" instead. -func GetDefaultScheme() string { - return defaultScheme -} - -// Address represents a server the client connects to. -// -// # Experimental -// -// Notice: This type is EXPERIMENTAL and may be changed or removed in a -// later release. -type Address struct { - // Addr is the server address on which a connection will be established. - Addr string - - // ServerName is the name of this address. - // If non-empty, the ServerName is used as the transport certification authority for - // the address, instead of the hostname from the Dial target string. In most cases, - // this should not be set. - // - // WARNING: ServerName must only be populated with trusted values. It - // is insecure to populate it with data from untrusted inputs since untrusted - // values could be used to bypass the authority checks performed by TLS. - ServerName string - - // Attributes contains arbitrary data about this address intended for - // consumption by the SubConn. - Attributes *attributes.Attributes - - // BalancerAttributes contains arbitrary data about this address intended - // for consumption by the LB policy. These attributes do not affect SubConn - // creation, connection establishment, handshaking, etc. - // - // Deprecated: when an Address is inside an Endpoint, this field should not - // be used, and it will eventually be removed entirely. - BalancerAttributes *attributes.Attributes - - // Metadata is the information associated with Addr, which may be used - // to make load balancing decision. - // - // Deprecated: use Attributes instead. - Metadata any -} - -// Equal returns whether a and o are identical. Metadata is compared directly, -// not with any recursive introspection. -// -// This method compares all fields of the address. When used to tell apart -// addresses during subchannel creation or connection establishment, it might be -// more appropriate for the caller to implement custom equality logic. -func (a Address) Equal(o Address) bool { - return a.Addr == o.Addr && a.ServerName == o.ServerName && - a.Attributes.Equal(o.Attributes) && - a.BalancerAttributes.Equal(o.BalancerAttributes) && - a.Metadata == o.Metadata -} - -// String returns JSON formatted string representation of the address. -func (a Address) String() string { - var sb strings.Builder - sb.WriteString(fmt.Sprintf("{Addr: %q, ", a.Addr)) - sb.WriteString(fmt.Sprintf("ServerName: %q, ", a.ServerName)) - if a.Attributes != nil { - sb.WriteString(fmt.Sprintf("Attributes: %v, ", a.Attributes.String())) - } - if a.BalancerAttributes != nil { - sb.WriteString(fmt.Sprintf("BalancerAttributes: %v", a.BalancerAttributes.String())) - } - sb.WriteString("}") - return sb.String() -} - -// BuildOptions includes additional information for the builder to create -// the resolver. -type BuildOptions struct { - // DisableServiceConfig indicates whether a resolver implementation should - // fetch service config data. - DisableServiceConfig bool - // DialCreds is the transport credentials used by the ClientConn for - // communicating with the target gRPC service (set via - // WithTransportCredentials). In cases where a name resolution service - // requires the same credentials, the resolver may use this field. In most - // cases though, it is not appropriate, and this field may be ignored. - DialCreds credentials.TransportCredentials - // CredsBundle is the credentials bundle used by the ClientConn for - // communicating with the target gRPC service (set via - // WithCredentialsBundle). In cases where a name resolution service - // requires the same credentials, the resolver may use this field. In most - // cases though, it is not appropriate, and this field may be ignored. - CredsBundle credentials.Bundle - // Dialer is the custom dialer used by the ClientConn for dialling the - // target gRPC service (set via WithDialer). In cases where a name - // resolution service requires the same dialer, the resolver may use this - // field. In most cases though, it is not appropriate, and this field may - // be ignored. - Dialer func(context.Context, string) (net.Conn, error) - // Authority is the effective authority of the clientconn for which the - // resolver is built. - Authority string -} - -// An Endpoint is one network endpoint, or server, which may have multiple -// addresses with which it can be accessed. -type Endpoint struct { - // Addresses contains a list of addresses used to access this endpoint. - Addresses []Address - - // Attributes contains arbitrary data about this endpoint intended for - // consumption by the LB policy. - Attributes *attributes.Attributes -} - -// State contains the current Resolver state relevant to the ClientConn. -type State struct { - // Addresses is the latest set of resolved addresses for the target. - // - // If a resolver sets Addresses but does not set Endpoints, one Endpoint - // will be created for each Address before the State is passed to the LB - // policy. The BalancerAttributes of each entry in Addresses will be set - // in Endpoints.Attributes, and be cleared in the Endpoint's Address's - // BalancerAttributes. - // - // Soon, Addresses will be deprecated and replaced fully by Endpoints. - Addresses []Address - - // Endpoints is the latest set of resolved endpoints for the target. - // - // If a resolver produces a State containing Endpoints but not Addresses, - // it must take care to ensure the LB policies it selects will support - // Endpoints. - Endpoints []Endpoint - - // ServiceConfig contains the result from parsing the latest service - // config. If it is nil, it indicates no service config is present or the - // resolver does not provide service configs. - ServiceConfig *serviceconfig.ParseResult - - // Attributes contains arbitrary data about the resolver intended for - // consumption by the load balancing policy. - Attributes *attributes.Attributes -} - -// ClientConn contains the callbacks for resolver to notify any updates -// to the gRPC ClientConn. -// -// This interface is to be implemented by gRPC. Users should not need a -// brand new implementation of this interface. For the situations like -// testing, the new implementation should embed this interface. This allows -// gRPC to add new methods to this interface. -type ClientConn interface { - // UpdateState updates the state of the ClientConn appropriately. - // - // If an error is returned, the resolver should try to resolve the - // target again. The resolver should use a backoff timer to prevent - // overloading the server with requests. If a resolver is certain that - // reresolving will not change the result, e.g. because it is - // a watch-based resolver, returned errors can be ignored. - // - // If the resolved State is the same as the last reported one, calling - // UpdateState can be omitted. - UpdateState(State) error - // ReportError notifies the ClientConn that the Resolver encountered an - // error. The ClientConn will notify the load balancer and begin calling - // ResolveNow on the Resolver with exponential backoff. - ReportError(error) - // NewAddress is called by resolver to notify ClientConn a new list - // of resolved addresses. - // The address list should be the complete list of resolved addresses. - // - // Deprecated: Use UpdateState instead. - NewAddress(addresses []Address) - // ParseServiceConfig parses the provided service config and returns an - // object that provides the parsed config. - ParseServiceConfig(serviceConfigJSON string) *serviceconfig.ParseResult -} - -// Target represents a target for gRPC, as specified in: -// https://github.com/grpc/grpc/blob/master/doc/naming.md. -// It is parsed from the target string that gets passed into Dial or DialContext -// by the user. And gRPC passes it to the resolver and the balancer. -// -// If the target follows the naming spec, and the parsed scheme is registered -// with gRPC, we will parse the target string according to the spec. If the -// target does not contain a scheme or if the parsed scheme is not registered -// (i.e. no corresponding resolver available to resolve the endpoint), we will -// apply the default scheme, and will attempt to reparse it. -type Target struct { - // URL contains the parsed dial target with an optional default scheme added - // to it if the original dial target contained no scheme or contained an - // unregistered scheme. Any query params specified in the original dial - // target can be accessed from here. - URL url.URL -} - -// Endpoint retrieves endpoint without leading "/" from either `URL.Path` -// or `URL.Opaque`. The latter is used when the former is empty. -func (t Target) Endpoint() string { - endpoint := t.URL.Path - if endpoint == "" { - endpoint = t.URL.Opaque - } - // For targets of the form "[scheme]://[authority]/endpoint, the endpoint - // value returned from url.Parse() contains a leading "/". Although this is - // in accordance with RFC 3986, we do not want to break existing resolver - // implementations which expect the endpoint without the leading "/". So, we - // end up stripping the leading "/" here. But this will result in an - // incorrect parsing for something like "unix:///path/to/socket". Since we - // own the "unix" resolver, we can workaround in the unix resolver by using - // the `URL` field. - return strings.TrimPrefix(endpoint, "/") -} - -// String returns the canonical string representation of Target. -func (t Target) String() string { - return t.URL.Scheme + "://" + t.URL.Host + "/" + t.Endpoint() -} - -// Builder creates a resolver that will be used to watch name resolution updates. -type Builder interface { - // Build creates a new resolver for the given target. - // - // gRPC dial calls Build synchronously, and fails if the returned error is - // not nil. - Build(target Target, cc ClientConn, opts BuildOptions) (Resolver, error) - // Scheme returns the scheme supported by this resolver. Scheme is defined - // at https://github.com/grpc/grpc/blob/master/doc/naming.md. The returned - // string should not contain uppercase characters, as they will not match - // the parsed target's scheme as defined in RFC 3986. - Scheme() string -} - -// ResolveNowOptions includes additional information for ResolveNow. -type ResolveNowOptions struct{} - -// Resolver watches for the updates on the specified target. -// Updates include address updates and service config updates. -type Resolver interface { - // ResolveNow will be called by gRPC to try to resolve the target name - // again. It's just a hint, resolver can ignore this if it's not necessary. - // - // It could be called multiple times concurrently. - ResolveNow(ResolveNowOptions) - // Close closes the resolver. - Close() -} - -// AuthorityOverrider is implemented by Builders that wish to override the -// default authority for the ClientConn. -// By default, the authority used is target.Endpoint(). -type AuthorityOverrider interface { - // OverrideAuthority returns the authority to use for a ClientConn with the - // given target. The implementation must generate it without blocking, - // typically in line, and must keep it unchanged. - OverrideAuthority(Target) string -} diff --git a/vendor/google.golang.org/grpc/resolver_wrapper.go b/vendor/google.golang.org/grpc/resolver_wrapper.go deleted file mode 100644 index 9dcc9780f..000000000 --- a/vendor/google.golang.org/grpc/resolver_wrapper.go +++ /dev/null @@ -1,198 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpc - -import ( - "context" - "strings" - "sync" - - "google.golang.org/grpc/internal/channelz" - "google.golang.org/grpc/internal/grpcsync" - "google.golang.org/grpc/internal/pretty" - "google.golang.org/grpc/resolver" - "google.golang.org/grpc/serviceconfig" -) - -// ccResolverWrapper is a wrapper on top of cc for resolvers. -// It implements resolver.ClientConn interface. -type ccResolverWrapper struct { - // The following fields are initialized when the wrapper is created and are - // read-only afterwards, and therefore can be accessed without a mutex. - cc *ClientConn - ignoreServiceConfig bool - serializer *grpcsync.CallbackSerializer - serializerCancel context.CancelFunc - - resolver resolver.Resolver // only accessed within the serializer - - // The following fields are protected by mu. Caller must take cc.mu before - // taking mu. - mu sync.Mutex - curState resolver.State - closed bool -} - -// newCCResolverWrapper initializes the ccResolverWrapper. It can only be used -// after calling start, which builds the resolver. -func newCCResolverWrapper(cc *ClientConn) *ccResolverWrapper { - ctx, cancel := context.WithCancel(cc.ctx) - return &ccResolverWrapper{ - cc: cc, - ignoreServiceConfig: cc.dopts.disableServiceConfig, - serializer: grpcsync.NewCallbackSerializer(ctx), - serializerCancel: cancel, - } -} - -// start builds the name resolver using the resolver.Builder in cc and returns -// any error encountered. It must always be the first operation performed on -// any newly created ccResolverWrapper, except that close may be called instead. -func (ccr *ccResolverWrapper) start() error { - errCh := make(chan error) - ccr.serializer.Schedule(func(ctx context.Context) { - if ctx.Err() != nil { - return - } - opts := resolver.BuildOptions{ - DisableServiceConfig: ccr.cc.dopts.disableServiceConfig, - DialCreds: ccr.cc.dopts.copts.TransportCredentials, - CredsBundle: ccr.cc.dopts.copts.CredsBundle, - Dialer: ccr.cc.dopts.copts.Dialer, - Authority: ccr.cc.authority, - } - var err error - ccr.resolver, err = ccr.cc.resolverBuilder.Build(ccr.cc.parsedTarget, ccr, opts) - errCh <- err - }) - return <-errCh -} - -func (ccr *ccResolverWrapper) resolveNow(o resolver.ResolveNowOptions) { - ccr.serializer.Schedule(func(ctx context.Context) { - if ctx.Err() != nil || ccr.resolver == nil { - return - } - ccr.resolver.ResolveNow(o) - }) -} - -// close initiates async shutdown of the wrapper. To determine the wrapper has -// finished shutting down, the channel should block on ccr.serializer.Done() -// without cc.mu held. -func (ccr *ccResolverWrapper) close() { - channelz.Info(logger, ccr.cc.channelz, "Closing the name resolver") - ccr.mu.Lock() - ccr.closed = true - ccr.mu.Unlock() - - ccr.serializer.Schedule(func(context.Context) { - if ccr.resolver == nil { - return - } - ccr.resolver.Close() - ccr.resolver = nil - }) - ccr.serializerCancel() -} - -// UpdateState is called by resolver implementations to report new state to gRPC -// which includes addresses and service config. -func (ccr *ccResolverWrapper) UpdateState(s resolver.State) error { - ccr.cc.mu.Lock() - ccr.mu.Lock() - if ccr.closed { - ccr.mu.Unlock() - ccr.cc.mu.Unlock() - return nil - } - if s.Endpoints == nil { - s.Endpoints = make([]resolver.Endpoint, 0, len(s.Addresses)) - for _, a := range s.Addresses { - ep := resolver.Endpoint{Addresses: []resolver.Address{a}, Attributes: a.BalancerAttributes} - ep.Addresses[0].BalancerAttributes = nil - s.Endpoints = append(s.Endpoints, ep) - } - } - ccr.addChannelzTraceEvent(s) - ccr.curState = s - ccr.mu.Unlock() - return ccr.cc.updateResolverStateAndUnlock(s, nil) -} - -// ReportError is called by resolver implementations to report errors -// encountered during name resolution to gRPC. -func (ccr *ccResolverWrapper) ReportError(err error) { - ccr.cc.mu.Lock() - ccr.mu.Lock() - if ccr.closed { - ccr.mu.Unlock() - ccr.cc.mu.Unlock() - return - } - ccr.mu.Unlock() - channelz.Warningf(logger, ccr.cc.channelz, "ccResolverWrapper: reporting error to cc: %v", err) - ccr.cc.updateResolverStateAndUnlock(resolver.State{}, err) -} - -// NewAddress is called by the resolver implementation to send addresses to -// gRPC. -func (ccr *ccResolverWrapper) NewAddress(addrs []resolver.Address) { - ccr.cc.mu.Lock() - ccr.mu.Lock() - if ccr.closed { - ccr.mu.Unlock() - ccr.cc.mu.Unlock() - return - } - s := resolver.State{Addresses: addrs, ServiceConfig: ccr.curState.ServiceConfig} - ccr.addChannelzTraceEvent(s) - ccr.curState = s - ccr.mu.Unlock() - ccr.cc.updateResolverStateAndUnlock(s, nil) -} - -// ParseServiceConfig is called by resolver implementations to parse a JSON -// representation of the service config. -func (ccr *ccResolverWrapper) ParseServiceConfig(scJSON string) *serviceconfig.ParseResult { - return parseServiceConfig(scJSON) -} - -// addChannelzTraceEvent adds a channelz trace event containing the new -// state received from resolver implementations. -func (ccr *ccResolverWrapper) addChannelzTraceEvent(s resolver.State) { - var updates []string - var oldSC, newSC *ServiceConfig - var oldOK, newOK bool - if ccr.curState.ServiceConfig != nil { - oldSC, oldOK = ccr.curState.ServiceConfig.Config.(*ServiceConfig) - } - if s.ServiceConfig != nil { - newSC, newOK = s.ServiceConfig.Config.(*ServiceConfig) - } - if oldOK != newOK || (oldOK && newOK && oldSC.rawJSONString != newSC.rawJSONString) { - updates = append(updates, "service config updated") - } - if len(ccr.curState.Addresses) > 0 && len(s.Addresses) == 0 { - updates = append(updates, "resolver returned an empty address list") - } else if len(ccr.curState.Addresses) == 0 && len(s.Addresses) > 0 { - updates = append(updates, "resolver returned new addresses") - } - channelz.Infof(logger, ccr.cc.channelz, "Resolver state updated: %s (%v)", pretty.ToJSON(s), strings.Join(updates, "; ")) -} diff --git a/vendor/google.golang.org/grpc/rpc_util.go b/vendor/google.golang.org/grpc/rpc_util.go deleted file mode 100644 index 998e251dd..000000000 --- a/vendor/google.golang.org/grpc/rpc_util.go +++ /dev/null @@ -1,981 +0,0 @@ -/* - * - * Copyright 2014 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpc - -import ( - "bytes" - "compress/gzip" - "context" - "encoding/binary" - "fmt" - "io" - "math" - "strings" - "sync" - "time" - - "google.golang.org/grpc/codes" - "google.golang.org/grpc/credentials" - "google.golang.org/grpc/encoding" - "google.golang.org/grpc/encoding/proto" - "google.golang.org/grpc/internal/transport" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/peer" - "google.golang.org/grpc/stats" - "google.golang.org/grpc/status" -) - -// Compressor defines the interface gRPC uses to compress a message. -// -// Deprecated: use package encoding. -type Compressor interface { - // Do compresses p into w. - Do(w io.Writer, p []byte) error - // Type returns the compression algorithm the Compressor uses. - Type() string -} - -type gzipCompressor struct { - pool sync.Pool -} - -// NewGZIPCompressor creates a Compressor based on GZIP. -// -// Deprecated: use package encoding/gzip. -func NewGZIPCompressor() Compressor { - c, _ := NewGZIPCompressorWithLevel(gzip.DefaultCompression) - return c -} - -// NewGZIPCompressorWithLevel is like NewGZIPCompressor but specifies the gzip compression level instead -// of assuming DefaultCompression. -// -// The error returned will be nil if the level is valid. -// -// Deprecated: use package encoding/gzip. -func NewGZIPCompressorWithLevel(level int) (Compressor, error) { - if level < gzip.DefaultCompression || level > gzip.BestCompression { - return nil, fmt.Errorf("grpc: invalid compression level: %d", level) - } - return &gzipCompressor{ - pool: sync.Pool{ - New: func() any { - w, err := gzip.NewWriterLevel(io.Discard, level) - if err != nil { - panic(err) - } - return w - }, - }, - }, nil -} - -func (c *gzipCompressor) Do(w io.Writer, p []byte) error { - z := c.pool.Get().(*gzip.Writer) - defer c.pool.Put(z) - z.Reset(w) - if _, err := z.Write(p); err != nil { - return err - } - return z.Close() -} - -func (c *gzipCompressor) Type() string { - return "gzip" -} - -// Decompressor defines the interface gRPC uses to decompress a message. -// -// Deprecated: use package encoding. -type Decompressor interface { - // Do reads the data from r and uncompress them. - Do(r io.Reader) ([]byte, error) - // Type returns the compression algorithm the Decompressor uses. - Type() string -} - -type gzipDecompressor struct { - pool sync.Pool -} - -// NewGZIPDecompressor creates a Decompressor based on GZIP. -// -// Deprecated: use package encoding/gzip. -func NewGZIPDecompressor() Decompressor { - return &gzipDecompressor{} -} - -func (d *gzipDecompressor) Do(r io.Reader) ([]byte, error) { - var z *gzip.Reader - switch maybeZ := d.pool.Get().(type) { - case nil: - newZ, err := gzip.NewReader(r) - if err != nil { - return nil, err - } - z = newZ - case *gzip.Reader: - z = maybeZ - if err := z.Reset(r); err != nil { - d.pool.Put(z) - return nil, err - } - } - - defer func() { - z.Close() - d.pool.Put(z) - }() - return io.ReadAll(z) -} - -func (d *gzipDecompressor) Type() string { - return "gzip" -} - -// callInfo contains all related configuration and information about an RPC. -type callInfo struct { - compressorType string - failFast bool - maxReceiveMessageSize *int - maxSendMessageSize *int - creds credentials.PerRPCCredentials - contentSubtype string - codec baseCodec - maxRetryRPCBufferSize int - onFinish []func(err error) -} - -func defaultCallInfo() *callInfo { - return &callInfo{ - failFast: true, - maxRetryRPCBufferSize: 256 * 1024, // 256KB - } -} - -// CallOption configures a Call before it starts or extracts information from -// a Call after it completes. -type CallOption interface { - // before is called before the call is sent to any server. If before - // returns a non-nil error, the RPC fails with that error. - before(*callInfo) error - - // after is called after the call has completed. after cannot return an - // error, so any failures should be reported via output parameters. - after(*callInfo, *csAttempt) -} - -// EmptyCallOption does not alter the Call configuration. -// It can be embedded in another structure to carry satellite data for use -// by interceptors. -type EmptyCallOption struct{} - -func (EmptyCallOption) before(*callInfo) error { return nil } -func (EmptyCallOption) after(*callInfo, *csAttempt) {} - -// StaticMethod returns a CallOption which specifies that a call is being made -// to a method that is static, which means the method is known at compile time -// and doesn't change at runtime. This can be used as a signal to stats plugins -// that this method is safe to include as a key to a measurement. -func StaticMethod() CallOption { - return StaticMethodCallOption{} -} - -// StaticMethodCallOption is a CallOption that specifies that a call comes -// from a static method. -type StaticMethodCallOption struct { - EmptyCallOption -} - -// Header returns a CallOptions that retrieves the header metadata -// for a unary RPC. -func Header(md *metadata.MD) CallOption { - return HeaderCallOption{HeaderAddr: md} -} - -// HeaderCallOption is a CallOption for collecting response header metadata. -// The metadata field will be populated *after* the RPC completes. -// -// # Experimental -// -// Notice: This type is EXPERIMENTAL and may be changed or removed in a -// later release. -type HeaderCallOption struct { - HeaderAddr *metadata.MD -} - -func (o HeaderCallOption) before(c *callInfo) error { return nil } -func (o HeaderCallOption) after(c *callInfo, attempt *csAttempt) { - *o.HeaderAddr, _ = attempt.s.Header() -} - -// Trailer returns a CallOptions that retrieves the trailer metadata -// for a unary RPC. -func Trailer(md *metadata.MD) CallOption { - return TrailerCallOption{TrailerAddr: md} -} - -// TrailerCallOption is a CallOption for collecting response trailer metadata. -// The metadata field will be populated *after* the RPC completes. -// -// # Experimental -// -// Notice: This type is EXPERIMENTAL and may be changed or removed in a -// later release. -type TrailerCallOption struct { - TrailerAddr *metadata.MD -} - -func (o TrailerCallOption) before(c *callInfo) error { return nil } -func (o TrailerCallOption) after(c *callInfo, attempt *csAttempt) { - *o.TrailerAddr = attempt.s.Trailer() -} - -// Peer returns a CallOption that retrieves peer information for a unary RPC. -// The peer field will be populated *after* the RPC completes. -func Peer(p *peer.Peer) CallOption { - return PeerCallOption{PeerAddr: p} -} - -// PeerCallOption is a CallOption for collecting the identity of the remote -// peer. The peer field will be populated *after* the RPC completes. -// -// # Experimental -// -// Notice: This type is EXPERIMENTAL and may be changed or removed in a -// later release. -type PeerCallOption struct { - PeerAddr *peer.Peer -} - -func (o PeerCallOption) before(c *callInfo) error { return nil } -func (o PeerCallOption) after(c *callInfo, attempt *csAttempt) { - if x, ok := peer.FromContext(attempt.s.Context()); ok { - *o.PeerAddr = *x - } -} - -// WaitForReady configures the action to take when an RPC is attempted on broken -// connections or unreachable servers. If waitForReady is false and the -// connection is in the TRANSIENT_FAILURE state, the RPC will fail -// immediately. Otherwise, the RPC client will block the call until a -// connection is available (or the call is canceled or times out) and will -// retry the call if it fails due to a transient error. gRPC will not retry if -// data was written to the wire unless the server indicates it did not process -// the data. Please refer to -// https://github.com/grpc/grpc/blob/master/doc/wait-for-ready.md. -// -// By default, RPCs don't "wait for ready". -func WaitForReady(waitForReady bool) CallOption { - return FailFastCallOption{FailFast: !waitForReady} -} - -// FailFast is the opposite of WaitForReady. -// -// Deprecated: use WaitForReady. -func FailFast(failFast bool) CallOption { - return FailFastCallOption{FailFast: failFast} -} - -// FailFastCallOption is a CallOption for indicating whether an RPC should fail -// fast or not. -// -// # Experimental -// -// Notice: This type is EXPERIMENTAL and may be changed or removed in a -// later release. -type FailFastCallOption struct { - FailFast bool -} - -func (o FailFastCallOption) before(c *callInfo) error { - c.failFast = o.FailFast - return nil -} -func (o FailFastCallOption) after(c *callInfo, attempt *csAttempt) {} - -// OnFinish returns a CallOption that configures a callback to be called when -// the call completes. The error passed to the callback is the status of the -// RPC, and may be nil. The onFinish callback provided will only be called once -// by gRPC. This is mainly used to be used by streaming interceptors, to be -// notified when the RPC completes along with information about the status of -// the RPC. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func OnFinish(onFinish func(err error)) CallOption { - return OnFinishCallOption{ - OnFinish: onFinish, - } -} - -// OnFinishCallOption is CallOption that indicates a callback to be called when -// the call completes. -// -// # Experimental -// -// Notice: This type is EXPERIMENTAL and may be changed or removed in a -// later release. -type OnFinishCallOption struct { - OnFinish func(error) -} - -func (o OnFinishCallOption) before(c *callInfo) error { - c.onFinish = append(c.onFinish, o.OnFinish) - return nil -} - -func (o OnFinishCallOption) after(c *callInfo, attempt *csAttempt) {} - -// MaxCallRecvMsgSize returns a CallOption which sets the maximum message size -// in bytes the client can receive. If this is not set, gRPC uses the default -// 4MB. -func MaxCallRecvMsgSize(bytes int) CallOption { - return MaxRecvMsgSizeCallOption{MaxRecvMsgSize: bytes} -} - -// MaxRecvMsgSizeCallOption is a CallOption that indicates the maximum message -// size in bytes the client can receive. -// -// # Experimental -// -// Notice: This type is EXPERIMENTAL and may be changed or removed in a -// later release. -type MaxRecvMsgSizeCallOption struct { - MaxRecvMsgSize int -} - -func (o MaxRecvMsgSizeCallOption) before(c *callInfo) error { - c.maxReceiveMessageSize = &o.MaxRecvMsgSize - return nil -} -func (o MaxRecvMsgSizeCallOption) after(c *callInfo, attempt *csAttempt) {} - -// MaxCallSendMsgSize returns a CallOption which sets the maximum message size -// in bytes the client can send. If this is not set, gRPC uses the default -// `math.MaxInt32`. -func MaxCallSendMsgSize(bytes int) CallOption { - return MaxSendMsgSizeCallOption{MaxSendMsgSize: bytes} -} - -// MaxSendMsgSizeCallOption is a CallOption that indicates the maximum message -// size in bytes the client can send. -// -// # Experimental -// -// Notice: This type is EXPERIMENTAL and may be changed or removed in a -// later release. -type MaxSendMsgSizeCallOption struct { - MaxSendMsgSize int -} - -func (o MaxSendMsgSizeCallOption) before(c *callInfo) error { - c.maxSendMessageSize = &o.MaxSendMsgSize - return nil -} -func (o MaxSendMsgSizeCallOption) after(c *callInfo, attempt *csAttempt) {} - -// PerRPCCredentials returns a CallOption that sets credentials.PerRPCCredentials -// for a call. -func PerRPCCredentials(creds credentials.PerRPCCredentials) CallOption { - return PerRPCCredsCallOption{Creds: creds} -} - -// PerRPCCredsCallOption is a CallOption that indicates the per-RPC -// credentials to use for the call. -// -// # Experimental -// -// Notice: This type is EXPERIMENTAL and may be changed or removed in a -// later release. -type PerRPCCredsCallOption struct { - Creds credentials.PerRPCCredentials -} - -func (o PerRPCCredsCallOption) before(c *callInfo) error { - c.creds = o.Creds - return nil -} -func (o PerRPCCredsCallOption) after(c *callInfo, attempt *csAttempt) {} - -// UseCompressor returns a CallOption which sets the compressor used when -// sending the request. If WithCompressor is also set, UseCompressor has -// higher priority. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func UseCompressor(name string) CallOption { - return CompressorCallOption{CompressorType: name} -} - -// CompressorCallOption is a CallOption that indicates the compressor to use. -// -// # Experimental -// -// Notice: This type is EXPERIMENTAL and may be changed or removed in a -// later release. -type CompressorCallOption struct { - CompressorType string -} - -func (o CompressorCallOption) before(c *callInfo) error { - c.compressorType = o.CompressorType - return nil -} -func (o CompressorCallOption) after(c *callInfo, attempt *csAttempt) {} - -// CallContentSubtype returns a CallOption that will set the content-subtype -// for a call. For example, if content-subtype is "json", the Content-Type over -// the wire will be "application/grpc+json". The content-subtype is converted -// to lowercase before being included in Content-Type. See Content-Type on -// https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests for -// more details. -// -// If ForceCodec is not also used, the content-subtype will be used to look up -// the Codec to use in the registry controlled by RegisterCodec. See the -// documentation on RegisterCodec for details on registration. The lookup of -// content-subtype is case-insensitive. If no such Codec is found, the call -// will result in an error with code codes.Internal. -// -// If ForceCodec is also used, that Codec will be used for all request and -// response messages, with the content-subtype set to the given contentSubtype -// here for requests. -func CallContentSubtype(contentSubtype string) CallOption { - return ContentSubtypeCallOption{ContentSubtype: strings.ToLower(contentSubtype)} -} - -// ContentSubtypeCallOption is a CallOption that indicates the content-subtype -// used for marshaling messages. -// -// # Experimental -// -// Notice: This type is EXPERIMENTAL and may be changed or removed in a -// later release. -type ContentSubtypeCallOption struct { - ContentSubtype string -} - -func (o ContentSubtypeCallOption) before(c *callInfo) error { - c.contentSubtype = o.ContentSubtype - return nil -} -func (o ContentSubtypeCallOption) after(c *callInfo, attempt *csAttempt) {} - -// ForceCodec returns a CallOption that will set codec to be used for all -// request and response messages for a call. The result of calling Name() will -// be used as the content-subtype after converting to lowercase, unless -// CallContentSubtype is also used. -// -// See Content-Type on -// https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests for -// more details. Also see the documentation on RegisterCodec and -// CallContentSubtype for more details on the interaction between Codec and -// content-subtype. -// -// This function is provided for advanced users; prefer to use only -// CallContentSubtype to select a registered codec instead. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func ForceCodec(codec encoding.Codec) CallOption { - return ForceCodecCallOption{Codec: codec} -} - -// ForceCodecCallOption is a CallOption that indicates the codec used for -// marshaling messages. -// -// # Experimental -// -// Notice: This type is EXPERIMENTAL and may be changed or removed in a -// later release. -type ForceCodecCallOption struct { - Codec encoding.Codec -} - -func (o ForceCodecCallOption) before(c *callInfo) error { - c.codec = o.Codec - return nil -} -func (o ForceCodecCallOption) after(c *callInfo, attempt *csAttempt) {} - -// CallCustomCodec behaves like ForceCodec, but accepts a grpc.Codec instead of -// an encoding.Codec. -// -// Deprecated: use ForceCodec instead. -func CallCustomCodec(codec Codec) CallOption { - return CustomCodecCallOption{Codec: codec} -} - -// CustomCodecCallOption is a CallOption that indicates the codec used for -// marshaling messages. -// -// # Experimental -// -// Notice: This type is EXPERIMENTAL and may be changed or removed in a -// later release. -type CustomCodecCallOption struct { - Codec Codec -} - -func (o CustomCodecCallOption) before(c *callInfo) error { - c.codec = o.Codec - return nil -} -func (o CustomCodecCallOption) after(c *callInfo, attempt *csAttempt) {} - -// MaxRetryRPCBufferSize returns a CallOption that limits the amount of memory -// used for buffering this RPC's requests for retry purposes. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func MaxRetryRPCBufferSize(bytes int) CallOption { - return MaxRetryRPCBufferSizeCallOption{bytes} -} - -// MaxRetryRPCBufferSizeCallOption is a CallOption indicating the amount of -// memory to be used for caching this RPC for retry purposes. -// -// # Experimental -// -// Notice: This type is EXPERIMENTAL and may be changed or removed in a -// later release. -type MaxRetryRPCBufferSizeCallOption struct { - MaxRetryRPCBufferSize int -} - -func (o MaxRetryRPCBufferSizeCallOption) before(c *callInfo) error { - c.maxRetryRPCBufferSize = o.MaxRetryRPCBufferSize - return nil -} -func (o MaxRetryRPCBufferSizeCallOption) after(c *callInfo, attempt *csAttempt) {} - -// The format of the payload: compressed or not? -type payloadFormat uint8 - -const ( - compressionNone payloadFormat = 0 // no compression - compressionMade payloadFormat = 1 // compressed -) - -// parser reads complete gRPC messages from the underlying reader. -type parser struct { - // r is the underlying reader. - // See the comment on recvMsg for the permissible - // error types. - r io.Reader - - // The header of a gRPC message. Find more detail at - // https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md - header [5]byte - - // recvBufferPool is the pool of shared receive buffers. - recvBufferPool SharedBufferPool -} - -// recvMsg reads a complete gRPC message from the stream. -// -// It returns the message and its payload (compression/encoding) -// format. The caller owns the returned msg memory. -// -// If there is an error, possible values are: -// - io.EOF, when no messages remain -// - io.ErrUnexpectedEOF -// - of type transport.ConnectionError -// - an error from the status package -// -// No other error values or types must be returned, which also means -// that the underlying io.Reader must not return an incompatible -// error. -func (p *parser) recvMsg(maxReceiveMessageSize int) (pf payloadFormat, msg []byte, err error) { - if _, err := p.r.Read(p.header[:]); err != nil { - return 0, nil, err - } - - pf = payloadFormat(p.header[0]) - length := binary.BigEndian.Uint32(p.header[1:]) - - if length == 0 { - return pf, nil, nil - } - if int64(length) > int64(maxInt) { - return 0, nil, status.Errorf(codes.ResourceExhausted, "grpc: received message larger than max length allowed on current machine (%d vs. %d)", length, maxInt) - } - if int(length) > maxReceiveMessageSize { - return 0, nil, status.Errorf(codes.ResourceExhausted, "grpc: received message larger than max (%d vs. %d)", length, maxReceiveMessageSize) - } - msg = p.recvBufferPool.Get(int(length)) - if _, err := p.r.Read(msg); err != nil { - if err == io.EOF { - err = io.ErrUnexpectedEOF - } - return 0, nil, err - } - return pf, msg, nil -} - -// encode serializes msg and returns a buffer containing the message, or an -// error if it is too large to be transmitted by grpc. If msg is nil, it -// generates an empty message. -func encode(c baseCodec, msg any) ([]byte, error) { - if msg == nil { // NOTE: typed nils will not be caught by this check - return nil, nil - } - b, err := c.Marshal(msg) - if err != nil { - return nil, status.Errorf(codes.Internal, "grpc: error while marshaling: %v", err.Error()) - } - if uint(len(b)) > math.MaxUint32 { - return nil, status.Errorf(codes.ResourceExhausted, "grpc: message too large (%d bytes)", len(b)) - } - return b, nil -} - -// compress returns the input bytes compressed by compressor or cp. -// If both compressors are nil, or if the message has zero length, returns nil, -// indicating no compression was done. -// -// TODO(dfawley): eliminate cp parameter by wrapping Compressor in an encoding.Compressor. -func compress(in []byte, cp Compressor, compressor encoding.Compressor) ([]byte, error) { - if compressor == nil && cp == nil { - return nil, nil - } - if len(in) == 0 { - return nil, nil - } - wrapErr := func(err error) error { - return status.Errorf(codes.Internal, "grpc: error while compressing: %v", err.Error()) - } - cbuf := &bytes.Buffer{} - if compressor != nil { - z, err := compressor.Compress(cbuf) - if err != nil { - return nil, wrapErr(err) - } - if _, err := z.Write(in); err != nil { - return nil, wrapErr(err) - } - if err := z.Close(); err != nil { - return nil, wrapErr(err) - } - } else { - if err := cp.Do(cbuf, in); err != nil { - return nil, wrapErr(err) - } - } - return cbuf.Bytes(), nil -} - -const ( - payloadLen = 1 - sizeLen = 4 - headerLen = payloadLen + sizeLen -) - -// msgHeader returns a 5-byte header for the message being transmitted and the -// payload, which is compData if non-nil or data otherwise. -func msgHeader(data, compData []byte) (hdr []byte, payload []byte) { - hdr = make([]byte, headerLen) - if compData != nil { - hdr[0] = byte(compressionMade) - data = compData - } else { - hdr[0] = byte(compressionNone) - } - - // Write length of payload into buf - binary.BigEndian.PutUint32(hdr[payloadLen:], uint32(len(data))) - return hdr, data -} - -func outPayload(client bool, msg any, data, payload []byte, t time.Time) *stats.OutPayload { - return &stats.OutPayload{ - Client: client, - Payload: msg, - Data: data, - Length: len(data), - WireLength: len(payload) + headerLen, - CompressedLength: len(payload), - SentTime: t, - } -} - -func checkRecvPayload(pf payloadFormat, recvCompress string, haveCompressor bool) *status.Status { - switch pf { - case compressionNone: - case compressionMade: - if recvCompress == "" || recvCompress == encoding.Identity { - return status.New(codes.Internal, "grpc: compressed flag set with identity or empty encoding") - } - if !haveCompressor { - return status.Newf(codes.Unimplemented, "grpc: Decompressor is not installed for grpc-encoding %q", recvCompress) - } - default: - return status.Newf(codes.Internal, "grpc: received unexpected payload format %d", pf) - } - return nil -} - -type payloadInfo struct { - compressedLength int // The compressed length got from wire. - uncompressedBytes []byte -} - -// recvAndDecompress reads a message from the stream, decompressing it if necessary. -// -// Cancelling the returned cancel function releases the buffer back to the pool. So the caller should cancel as soon as -// the buffer is no longer needed. -func recvAndDecompress(p *parser, s *transport.Stream, dc Decompressor, maxReceiveMessageSize int, payInfo *payloadInfo, compressor encoding.Compressor, -) (uncompressedBuf []byte, cancel func(), err error) { - pf, compressedBuf, err := p.recvMsg(maxReceiveMessageSize) - if err != nil { - return nil, nil, err - } - - if st := checkRecvPayload(pf, s.RecvCompress(), compressor != nil || dc != nil); st != nil { - return nil, nil, st.Err() - } - - var size int - if pf == compressionMade { - // To match legacy behavior, if the decompressor is set by WithDecompressor or RPCDecompressor, - // use this decompressor as the default. - if dc != nil { - uncompressedBuf, err = dc.Do(bytes.NewReader(compressedBuf)) - size = len(uncompressedBuf) - } else { - uncompressedBuf, size, err = decompress(compressor, compressedBuf, maxReceiveMessageSize) - } - if err != nil { - return nil, nil, status.Errorf(codes.Internal, "grpc: failed to decompress the received message: %v", err) - } - if size > maxReceiveMessageSize { - // TODO: Revisit the error code. Currently keep it consistent with java - // implementation. - return nil, nil, status.Errorf(codes.ResourceExhausted, "grpc: received message after decompression larger than max (%d vs. %d)", size, maxReceiveMessageSize) - } - } else { - uncompressedBuf = compressedBuf - } - - if payInfo != nil { - payInfo.compressedLength = len(compressedBuf) - payInfo.uncompressedBytes = uncompressedBuf - - cancel = func() {} - } else { - cancel = func() { - p.recvBufferPool.Put(&compressedBuf) - } - } - - return uncompressedBuf, cancel, nil -} - -// Using compressor, decompress d, returning data and size. -// Optionally, if data will be over maxReceiveMessageSize, just return the size. -func decompress(compressor encoding.Compressor, d []byte, maxReceiveMessageSize int) ([]byte, int, error) { - dcReader, err := compressor.Decompress(bytes.NewReader(d)) - if err != nil { - return nil, 0, err - } - if sizer, ok := compressor.(interface { - DecompressedSize(compressedBytes []byte) int - }); ok { - if size := sizer.DecompressedSize(d); size >= 0 { - if size > maxReceiveMessageSize { - return nil, size, nil - } - // size is used as an estimate to size the buffer, but we - // will read more data if available. - // +MinRead so ReadFrom will not reallocate if size is correct. - // - // TODO: If we ensure that the buffer size is the same as the DecompressedSize, - // we can also utilize the recv buffer pool here. - buf := bytes.NewBuffer(make([]byte, 0, size+bytes.MinRead)) - bytesRead, err := buf.ReadFrom(io.LimitReader(dcReader, int64(maxReceiveMessageSize)+1)) - return buf.Bytes(), int(bytesRead), err - } - } - // Read from LimitReader with limit max+1. So if the underlying - // reader is over limit, the result will be bigger than max. - d, err = io.ReadAll(io.LimitReader(dcReader, int64(maxReceiveMessageSize)+1)) - return d, len(d), err -} - -// For the two compressor parameters, both should not be set, but if they are, -// dc takes precedence over compressor. -// TODO(dfawley): wrap the old compressor/decompressor using the new API? -func recv(p *parser, c baseCodec, s *transport.Stream, dc Decompressor, m any, maxReceiveMessageSize int, payInfo *payloadInfo, compressor encoding.Compressor) error { - buf, cancel, err := recvAndDecompress(p, s, dc, maxReceiveMessageSize, payInfo, compressor) - if err != nil { - return err - } - defer cancel() - - if err := c.Unmarshal(buf, m); err != nil { - return status.Errorf(codes.Internal, "grpc: failed to unmarshal the received message: %v", err) - } - return nil -} - -// Information about RPC -type rpcInfo struct { - failfast bool - preloaderInfo *compressorInfo -} - -// Information about Preloader -// Responsible for storing codec, and compressors -// If stream (s) has context s.Context which stores rpcInfo that has non nil -// pointers to codec, and compressors, then we can use preparedMsg for Async message prep -// and reuse marshalled bytes -type compressorInfo struct { - codec baseCodec - cp Compressor - comp encoding.Compressor -} - -type rpcInfoContextKey struct{} - -func newContextWithRPCInfo(ctx context.Context, failfast bool, codec baseCodec, cp Compressor, comp encoding.Compressor) context.Context { - return context.WithValue(ctx, rpcInfoContextKey{}, &rpcInfo{ - failfast: failfast, - preloaderInfo: &compressorInfo{ - codec: codec, - cp: cp, - comp: comp, - }, - }) -} - -func rpcInfoFromContext(ctx context.Context) (s *rpcInfo, ok bool) { - s, ok = ctx.Value(rpcInfoContextKey{}).(*rpcInfo) - return -} - -// Code returns the error code for err if it was produced by the rpc system. -// Otherwise, it returns codes.Unknown. -// -// Deprecated: use status.Code instead. -func Code(err error) codes.Code { - return status.Code(err) -} - -// ErrorDesc returns the error description of err if it was produced by the rpc system. -// Otherwise, it returns err.Error() or empty string when err is nil. -// -// Deprecated: use status.Convert and Message method instead. -func ErrorDesc(err error) string { - return status.Convert(err).Message() -} - -// Errorf returns an error containing an error code and a description; -// Errorf returns nil if c is OK. -// -// Deprecated: use status.Errorf instead. -func Errorf(c codes.Code, format string, a ...any) error { - return status.Errorf(c, format, a...) -} - -var errContextCanceled = status.Error(codes.Canceled, context.Canceled.Error()) -var errContextDeadline = status.Error(codes.DeadlineExceeded, context.DeadlineExceeded.Error()) - -// toRPCErr converts an error into an error from the status package. -func toRPCErr(err error) error { - switch err { - case nil, io.EOF: - return err - case context.DeadlineExceeded: - return errContextDeadline - case context.Canceled: - return errContextCanceled - case io.ErrUnexpectedEOF: - return status.Error(codes.Internal, err.Error()) - } - - switch e := err.(type) { - case transport.ConnectionError: - return status.Error(codes.Unavailable, e.Desc) - case *transport.NewStreamError: - return toRPCErr(e.Err) - } - - if _, ok := status.FromError(err); ok { - return err - } - - return status.Error(codes.Unknown, err.Error()) -} - -// setCallInfoCodec should only be called after CallOptions have been applied. -func setCallInfoCodec(c *callInfo) error { - if c.codec != nil { - // codec was already set by a CallOption; use it, but set the content - // subtype if it is not set. - if c.contentSubtype == "" { - // c.codec is a baseCodec to hide the difference between grpc.Codec and - // encoding.Codec (Name vs. String method name). We only support - // setting content subtype from encoding.Codec to avoid a behavior - // change with the deprecated version. - if ec, ok := c.codec.(encoding.Codec); ok { - c.contentSubtype = strings.ToLower(ec.Name()) - } - } - return nil - } - - if c.contentSubtype == "" { - // No codec specified in CallOptions; use proto by default. - c.codec = encoding.GetCodec(proto.Name) - return nil - } - - // c.contentSubtype is already lowercased in CallContentSubtype - c.codec = encoding.GetCodec(c.contentSubtype) - if c.codec == nil { - return status.Errorf(codes.Internal, "no codec registered for content-subtype %s", c.contentSubtype) - } - return nil -} - -// The SupportPackageIsVersion variables are referenced from generated protocol -// buffer files to ensure compatibility with the gRPC version used. The latest -// support package version is 7. -// -// Older versions are kept for compatibility. -// -// These constants should not be referenced from any other code. -const ( - SupportPackageIsVersion3 = true - SupportPackageIsVersion4 = true - SupportPackageIsVersion5 = true - SupportPackageIsVersion6 = true - SupportPackageIsVersion7 = true - SupportPackageIsVersion8 = true -) - -const grpcUA = "grpc-go/" + Version diff --git a/vendor/google.golang.org/grpc/server.go b/vendor/google.golang.org/grpc/server.go deleted file mode 100644 index fd4558daa..000000000 --- a/vendor/google.golang.org/grpc/server.go +++ /dev/null @@ -1,2183 +0,0 @@ -/* - * - * Copyright 2014 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpc - -import ( - "context" - "errors" - "fmt" - "io" - "math" - "net" - "net/http" - "reflect" - "runtime" - "strings" - "sync" - "sync/atomic" - "time" - - "google.golang.org/grpc/codes" - "google.golang.org/grpc/credentials" - "google.golang.org/grpc/encoding" - "google.golang.org/grpc/encoding/proto" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/internal" - "google.golang.org/grpc/internal/binarylog" - "google.golang.org/grpc/internal/channelz" - "google.golang.org/grpc/internal/grpcsync" - "google.golang.org/grpc/internal/grpcutil" - "google.golang.org/grpc/internal/transport" - "google.golang.org/grpc/keepalive" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/peer" - "google.golang.org/grpc/stats" - "google.golang.org/grpc/status" - "google.golang.org/grpc/tap" -) - -const ( - defaultServerMaxReceiveMessageSize = 1024 * 1024 * 4 - defaultServerMaxSendMessageSize = math.MaxInt32 - - // Server transports are tracked in a map which is keyed on listener - // address. For regular gRPC traffic, connections are accepted in Serve() - // through a call to Accept(), and we use the actual listener address as key - // when we add it to the map. But for connections received through - // ServeHTTP(), we do not have a listener and hence use this dummy value. - listenerAddressForServeHTTP = "listenerAddressForServeHTTP" -) - -func init() { - internal.GetServerCredentials = func(srv *Server) credentials.TransportCredentials { - return srv.opts.creds - } - internal.IsRegisteredMethod = func(srv *Server, method string) bool { - return srv.isRegisteredMethod(method) - } - internal.ServerFromContext = serverFromContext - internal.AddGlobalServerOptions = func(opt ...ServerOption) { - globalServerOptions = append(globalServerOptions, opt...) - } - internal.ClearGlobalServerOptions = func() { - globalServerOptions = nil - } - internal.BinaryLogger = binaryLogger - internal.JoinServerOptions = newJoinServerOption - internal.RecvBufferPool = recvBufferPool -} - -var statusOK = status.New(codes.OK, "") -var logger = grpclog.Component("core") - -type methodHandler func(srv any, ctx context.Context, dec func(any) error, interceptor UnaryServerInterceptor) (any, error) - -// MethodDesc represents an RPC service's method specification. -type MethodDesc struct { - MethodName string - Handler methodHandler -} - -// ServiceDesc represents an RPC service's specification. -type ServiceDesc struct { - ServiceName string - // The pointer to the service interface. Used to check whether the user - // provided implementation satisfies the interface requirements. - HandlerType any - Methods []MethodDesc - Streams []StreamDesc - Metadata any -} - -// serviceInfo wraps information about a service. It is very similar to -// ServiceDesc and is constructed from it for internal purposes. -type serviceInfo struct { - // Contains the implementation for the methods in this service. - serviceImpl any - methods map[string]*MethodDesc - streams map[string]*StreamDesc - mdata any -} - -// Server is a gRPC server to serve RPC requests. -type Server struct { - opts serverOptions - - mu sync.Mutex // guards following - lis map[net.Listener]bool - // conns contains all active server transports. It is a map keyed on a - // listener address with the value being the set of active transports - // belonging to that listener. - conns map[string]map[transport.ServerTransport]bool - serve bool - drain bool - cv *sync.Cond // signaled when connections close for GracefulStop - services map[string]*serviceInfo // service name -> service info - events traceEventLog - - quit *grpcsync.Event - done *grpcsync.Event - channelzRemoveOnce sync.Once - serveWG sync.WaitGroup // counts active Serve goroutines for Stop/GracefulStop - handlersWG sync.WaitGroup // counts active method handler goroutines - - channelz *channelz.Server - - serverWorkerChannel chan func() - serverWorkerChannelClose func() -} - -type serverOptions struct { - creds credentials.TransportCredentials - codec baseCodec - cp Compressor - dc Decompressor - unaryInt UnaryServerInterceptor - streamInt StreamServerInterceptor - chainUnaryInts []UnaryServerInterceptor - chainStreamInts []StreamServerInterceptor - binaryLogger binarylog.Logger - inTapHandle tap.ServerInHandle - statsHandlers []stats.Handler - maxConcurrentStreams uint32 - maxReceiveMessageSize int - maxSendMessageSize int - unknownStreamDesc *StreamDesc - keepaliveParams keepalive.ServerParameters - keepalivePolicy keepalive.EnforcementPolicy - initialWindowSize int32 - initialConnWindowSize int32 - writeBufferSize int - readBufferSize int - sharedWriteBuffer bool - connectionTimeout time.Duration - maxHeaderListSize *uint32 - headerTableSize *uint32 - numServerWorkers uint32 - recvBufferPool SharedBufferPool - waitForHandlers bool -} - -var defaultServerOptions = serverOptions{ - maxConcurrentStreams: math.MaxUint32, - maxReceiveMessageSize: defaultServerMaxReceiveMessageSize, - maxSendMessageSize: defaultServerMaxSendMessageSize, - connectionTimeout: 120 * time.Second, - writeBufferSize: defaultWriteBufSize, - readBufferSize: defaultReadBufSize, - recvBufferPool: nopBufferPool{}, -} -var globalServerOptions []ServerOption - -// A ServerOption sets options such as credentials, codec and keepalive parameters, etc. -type ServerOption interface { - apply(*serverOptions) -} - -// EmptyServerOption does not alter the server configuration. It can be embedded -// in another structure to build custom server options. -// -// # Experimental -// -// Notice: This type is EXPERIMENTAL and may be changed or removed in a -// later release. -type EmptyServerOption struct{} - -func (EmptyServerOption) apply(*serverOptions) {} - -// funcServerOption wraps a function that modifies serverOptions into an -// implementation of the ServerOption interface. -type funcServerOption struct { - f func(*serverOptions) -} - -func (fdo *funcServerOption) apply(do *serverOptions) { - fdo.f(do) -} - -func newFuncServerOption(f func(*serverOptions)) *funcServerOption { - return &funcServerOption{ - f: f, - } -} - -// joinServerOption provides a way to combine arbitrary number of server -// options into one. -type joinServerOption struct { - opts []ServerOption -} - -func (mdo *joinServerOption) apply(do *serverOptions) { - for _, opt := range mdo.opts { - opt.apply(do) - } -} - -func newJoinServerOption(opts ...ServerOption) ServerOption { - return &joinServerOption{opts: opts} -} - -// SharedWriteBuffer allows reusing per-connection transport write buffer. -// If this option is set to true every connection will release the buffer after -// flushing the data on the wire. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func SharedWriteBuffer(val bool) ServerOption { - return newFuncServerOption(func(o *serverOptions) { - o.sharedWriteBuffer = val - }) -} - -// WriteBufferSize determines how much data can be batched before doing a write -// on the wire. The default value for this buffer is 32KB. Zero or negative -// values will disable the write buffer such that each write will be on underlying -// connection. Note: A Send call may not directly translate to a write. -func WriteBufferSize(s int) ServerOption { - return newFuncServerOption(func(o *serverOptions) { - o.writeBufferSize = s - }) -} - -// ReadBufferSize lets you set the size of read buffer, this determines how much -// data can be read at most for one read syscall. The default value for this -// buffer is 32KB. Zero or negative values will disable read buffer for a -// connection so data framer can access the underlying conn directly. -func ReadBufferSize(s int) ServerOption { - return newFuncServerOption(func(o *serverOptions) { - o.readBufferSize = s - }) -} - -// InitialWindowSize returns a ServerOption that sets window size for stream. -// The lower bound for window size is 64K and any value smaller than that will be ignored. -func InitialWindowSize(s int32) ServerOption { - return newFuncServerOption(func(o *serverOptions) { - o.initialWindowSize = s - }) -} - -// InitialConnWindowSize returns a ServerOption that sets window size for a connection. -// The lower bound for window size is 64K and any value smaller than that will be ignored. -func InitialConnWindowSize(s int32) ServerOption { - return newFuncServerOption(func(o *serverOptions) { - o.initialConnWindowSize = s - }) -} - -// KeepaliveParams returns a ServerOption that sets keepalive and max-age parameters for the server. -func KeepaliveParams(kp keepalive.ServerParameters) ServerOption { - if kp.Time > 0 && kp.Time < internal.KeepaliveMinServerPingTime { - logger.Warning("Adjusting keepalive ping interval to minimum period of 1s") - kp.Time = internal.KeepaliveMinServerPingTime - } - - return newFuncServerOption(func(o *serverOptions) { - o.keepaliveParams = kp - }) -} - -// KeepaliveEnforcementPolicy returns a ServerOption that sets keepalive enforcement policy for the server. -func KeepaliveEnforcementPolicy(kep keepalive.EnforcementPolicy) ServerOption { - return newFuncServerOption(func(o *serverOptions) { - o.keepalivePolicy = kep - }) -} - -// CustomCodec returns a ServerOption that sets a codec for message marshaling and unmarshaling. -// -// This will override any lookups by content-subtype for Codecs registered with RegisterCodec. -// -// Deprecated: register codecs using encoding.RegisterCodec. The server will -// automatically use registered codecs based on the incoming requests' headers. -// See also -// https://github.com/grpc/grpc-go/blob/master/Documentation/encoding.md#using-a-codec. -// Will be supported throughout 1.x. -func CustomCodec(codec Codec) ServerOption { - return newFuncServerOption(func(o *serverOptions) { - o.codec = codec - }) -} - -// ForceServerCodec returns a ServerOption that sets a codec for message -// marshaling and unmarshaling. -// -// This will override any lookups by content-subtype for Codecs registered -// with RegisterCodec. -// -// See Content-Type on -// https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests for -// more details. Also see the documentation on RegisterCodec and -// CallContentSubtype for more details on the interaction between encoding.Codec -// and content-subtype. -// -// This function is provided for advanced users; prefer to register codecs -// using encoding.RegisterCodec. -// The server will automatically use registered codecs based on the incoming -// requests' headers. See also -// https://github.com/grpc/grpc-go/blob/master/Documentation/encoding.md#using-a-codec. -// Will be supported throughout 1.x. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func ForceServerCodec(codec encoding.Codec) ServerOption { - return newFuncServerOption(func(o *serverOptions) { - o.codec = codec - }) -} - -// RPCCompressor returns a ServerOption that sets a compressor for outbound -// messages. For backward compatibility, all outbound messages will be sent -// using this compressor, regardless of incoming message compression. By -// default, server messages will be sent using the same compressor with which -// request messages were sent. -// -// Deprecated: use encoding.RegisterCompressor instead. Will be supported -// throughout 1.x. -func RPCCompressor(cp Compressor) ServerOption { - return newFuncServerOption(func(o *serverOptions) { - o.cp = cp - }) -} - -// RPCDecompressor returns a ServerOption that sets a decompressor for inbound -// messages. It has higher priority than decompressors registered via -// encoding.RegisterCompressor. -// -// Deprecated: use encoding.RegisterCompressor instead. Will be supported -// throughout 1.x. -func RPCDecompressor(dc Decompressor) ServerOption { - return newFuncServerOption(func(o *serverOptions) { - o.dc = dc - }) -} - -// MaxMsgSize returns a ServerOption to set the max message size in bytes the server can receive. -// If this is not set, gRPC uses the default limit. -// -// Deprecated: use MaxRecvMsgSize instead. Will be supported throughout 1.x. -func MaxMsgSize(m int) ServerOption { - return MaxRecvMsgSize(m) -} - -// MaxRecvMsgSize returns a ServerOption to set the max message size in bytes the server can receive. -// If this is not set, gRPC uses the default 4MB. -func MaxRecvMsgSize(m int) ServerOption { - return newFuncServerOption(func(o *serverOptions) { - o.maxReceiveMessageSize = m - }) -} - -// MaxSendMsgSize returns a ServerOption to set the max message size in bytes the server can send. -// If this is not set, gRPC uses the default `math.MaxInt32`. -func MaxSendMsgSize(m int) ServerOption { - return newFuncServerOption(func(o *serverOptions) { - o.maxSendMessageSize = m - }) -} - -// MaxConcurrentStreams returns a ServerOption that will apply a limit on the number -// of concurrent streams to each ServerTransport. -func MaxConcurrentStreams(n uint32) ServerOption { - if n == 0 { - n = math.MaxUint32 - } - return newFuncServerOption(func(o *serverOptions) { - o.maxConcurrentStreams = n - }) -} - -// Creds returns a ServerOption that sets credentials for server connections. -func Creds(c credentials.TransportCredentials) ServerOption { - return newFuncServerOption(func(o *serverOptions) { - o.creds = c - }) -} - -// UnaryInterceptor returns a ServerOption that sets the UnaryServerInterceptor for the -// server. Only one unary interceptor can be installed. The construction of multiple -// interceptors (e.g., chaining) can be implemented at the caller. -func UnaryInterceptor(i UnaryServerInterceptor) ServerOption { - return newFuncServerOption(func(o *serverOptions) { - if o.unaryInt != nil { - panic("The unary server interceptor was already set and may not be reset.") - } - o.unaryInt = i - }) -} - -// ChainUnaryInterceptor returns a ServerOption that specifies the chained interceptor -// for unary RPCs. The first interceptor will be the outer most, -// while the last interceptor will be the inner most wrapper around the real call. -// All unary interceptors added by this method will be chained. -func ChainUnaryInterceptor(interceptors ...UnaryServerInterceptor) ServerOption { - return newFuncServerOption(func(o *serverOptions) { - o.chainUnaryInts = append(o.chainUnaryInts, interceptors...) - }) -} - -// StreamInterceptor returns a ServerOption that sets the StreamServerInterceptor for the -// server. Only one stream interceptor can be installed. -func StreamInterceptor(i StreamServerInterceptor) ServerOption { - return newFuncServerOption(func(o *serverOptions) { - if o.streamInt != nil { - panic("The stream server interceptor was already set and may not be reset.") - } - o.streamInt = i - }) -} - -// ChainStreamInterceptor returns a ServerOption that specifies the chained interceptor -// for streaming RPCs. The first interceptor will be the outer most, -// while the last interceptor will be the inner most wrapper around the real call. -// All stream interceptors added by this method will be chained. -func ChainStreamInterceptor(interceptors ...StreamServerInterceptor) ServerOption { - return newFuncServerOption(func(o *serverOptions) { - o.chainStreamInts = append(o.chainStreamInts, interceptors...) - }) -} - -// InTapHandle returns a ServerOption that sets the tap handle for all the server -// transport to be created. Only one can be installed. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func InTapHandle(h tap.ServerInHandle) ServerOption { - return newFuncServerOption(func(o *serverOptions) { - if o.inTapHandle != nil { - panic("The tap handle was already set and may not be reset.") - } - o.inTapHandle = h - }) -} - -// StatsHandler returns a ServerOption that sets the stats handler for the server. -func StatsHandler(h stats.Handler) ServerOption { - return newFuncServerOption(func(o *serverOptions) { - if h == nil { - logger.Error("ignoring nil parameter in grpc.StatsHandler ServerOption") - // Do not allow a nil stats handler, which would otherwise cause - // panics. - return - } - o.statsHandlers = append(o.statsHandlers, h) - }) -} - -// binaryLogger returns a ServerOption that can set the binary logger for the -// server. -func binaryLogger(bl binarylog.Logger) ServerOption { - return newFuncServerOption(func(o *serverOptions) { - o.binaryLogger = bl - }) -} - -// UnknownServiceHandler returns a ServerOption that allows for adding a custom -// unknown service handler. The provided method is a bidi-streaming RPC service -// handler that will be invoked instead of returning the "unimplemented" gRPC -// error whenever a request is received for an unregistered service or method. -// The handling function and stream interceptor (if set) have full access to -// the ServerStream, including its Context. -func UnknownServiceHandler(streamHandler StreamHandler) ServerOption { - return newFuncServerOption(func(o *serverOptions) { - o.unknownStreamDesc = &StreamDesc{ - StreamName: "unknown_service_handler", - Handler: streamHandler, - // We need to assume that the users of the streamHandler will want to use both. - ClientStreams: true, - ServerStreams: true, - } - }) -} - -// ConnectionTimeout returns a ServerOption that sets the timeout for -// connection establishment (up to and including HTTP/2 handshaking) for all -// new connections. If this is not set, the default is 120 seconds. A zero or -// negative value will result in an immediate timeout. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func ConnectionTimeout(d time.Duration) ServerOption { - return newFuncServerOption(func(o *serverOptions) { - o.connectionTimeout = d - }) -} - -// MaxHeaderListSize returns a ServerOption that sets the max (uncompressed) size -// of header list that the server is prepared to accept. -func MaxHeaderListSize(s uint32) ServerOption { - return newFuncServerOption(func(o *serverOptions) { - o.maxHeaderListSize = &s - }) -} - -// HeaderTableSize returns a ServerOption that sets the size of dynamic -// header table for stream. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func HeaderTableSize(s uint32) ServerOption { - return newFuncServerOption(func(o *serverOptions) { - o.headerTableSize = &s - }) -} - -// NumStreamWorkers returns a ServerOption that sets the number of worker -// goroutines that should be used to process incoming streams. Setting this to -// zero (default) will disable workers and spawn a new goroutine for each -// stream. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func NumStreamWorkers(numServerWorkers uint32) ServerOption { - // TODO: If/when this API gets stabilized (i.e. stream workers become the - // only way streams are processed), change the behavior of the zero value to - // a sane default. Preliminary experiments suggest that a value equal to the - // number of CPUs available is most performant; requires thorough testing. - return newFuncServerOption(func(o *serverOptions) { - o.numServerWorkers = numServerWorkers - }) -} - -// WaitForHandlers cause Stop to wait until all outstanding method handlers have -// exited before returning. If false, Stop will return as soon as all -// connections have closed, but method handlers may still be running. By -// default, Stop does not wait for method handlers to return. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func WaitForHandlers(w bool) ServerOption { - return newFuncServerOption(func(o *serverOptions) { - o.waitForHandlers = w - }) -} - -// RecvBufferPool returns a ServerOption that configures the server -// to use the provided shared buffer pool for parsing incoming messages. Depending -// on the application's workload, this could result in reduced memory allocation. -// -// If you are unsure about how to implement a memory pool but want to utilize one, -// begin with grpc.NewSharedBufferPool. -// -// Note: The shared buffer pool feature will not be active if any of the following -// options are used: StatsHandler, EnableTracing, or binary logging. In such -// cases, the shared buffer pool will be ignored. -// -// Deprecated: use experimental.WithRecvBufferPool instead. Will be deleted in -// v1.60.0 or later. -func RecvBufferPool(bufferPool SharedBufferPool) ServerOption { - return recvBufferPool(bufferPool) -} - -func recvBufferPool(bufferPool SharedBufferPool) ServerOption { - return newFuncServerOption(func(o *serverOptions) { - o.recvBufferPool = bufferPool - }) -} - -// serverWorkerResetThreshold defines how often the stack must be reset. Every -// N requests, by spawning a new goroutine in its place, a worker can reset its -// stack so that large stacks don't live in memory forever. 2^16 should allow -// each goroutine stack to live for at least a few seconds in a typical -// workload (assuming a QPS of a few thousand requests/sec). -const serverWorkerResetThreshold = 1 << 16 - -// serverWorkers blocks on a *transport.Stream channel forever and waits for -// data to be fed by serveStreams. This allows multiple requests to be -// processed by the same goroutine, removing the need for expensive stack -// re-allocations (see the runtime.morestack problem [1]). -// -// [1] https://github.com/golang/go/issues/18138 -func (s *Server) serverWorker() { - for completed := 0; completed < serverWorkerResetThreshold; completed++ { - f, ok := <-s.serverWorkerChannel - if !ok { - return - } - f() - } - go s.serverWorker() -} - -// initServerWorkers creates worker goroutines and a channel to process incoming -// connections to reduce the time spent overall on runtime.morestack. -func (s *Server) initServerWorkers() { - s.serverWorkerChannel = make(chan func()) - s.serverWorkerChannelClose = grpcsync.OnceFunc(func() { - close(s.serverWorkerChannel) - }) - for i := uint32(0); i < s.opts.numServerWorkers; i++ { - go s.serverWorker() - } -} - -// NewServer creates a gRPC server which has no service registered and has not -// started to accept requests yet. -func NewServer(opt ...ServerOption) *Server { - opts := defaultServerOptions - for _, o := range globalServerOptions { - o.apply(&opts) - } - for _, o := range opt { - o.apply(&opts) - } - s := &Server{ - lis: make(map[net.Listener]bool), - opts: opts, - conns: make(map[string]map[transport.ServerTransport]bool), - services: make(map[string]*serviceInfo), - quit: grpcsync.NewEvent(), - done: grpcsync.NewEvent(), - channelz: channelz.RegisterServer(""), - } - chainUnaryServerInterceptors(s) - chainStreamServerInterceptors(s) - s.cv = sync.NewCond(&s.mu) - if EnableTracing { - _, file, line, _ := runtime.Caller(1) - s.events = newTraceEventLog("grpc.Server", fmt.Sprintf("%s:%d", file, line)) - } - - if s.opts.numServerWorkers > 0 { - s.initServerWorkers() - } - - channelz.Info(logger, s.channelz, "Server created") - return s -} - -// printf records an event in s's event log, unless s has been stopped. -// REQUIRES s.mu is held. -func (s *Server) printf(format string, a ...any) { - if s.events != nil { - s.events.Printf(format, a...) - } -} - -// errorf records an error in s's event log, unless s has been stopped. -// REQUIRES s.mu is held. -func (s *Server) errorf(format string, a ...any) { - if s.events != nil { - s.events.Errorf(format, a...) - } -} - -// ServiceRegistrar wraps a single method that supports service registration. It -// enables users to pass concrete types other than grpc.Server to the service -// registration methods exported by the IDL generated code. -type ServiceRegistrar interface { - // RegisterService registers a service and its implementation to the - // concrete type implementing this interface. It may not be called - // once the server has started serving. - // desc describes the service and its methods and handlers. impl is the - // service implementation which is passed to the method handlers. - RegisterService(desc *ServiceDesc, impl any) -} - -// RegisterService registers a service and its implementation to the gRPC -// server. It is called from the IDL generated code. This must be called before -// invoking Serve. If ss is non-nil (for legacy code), its type is checked to -// ensure it implements sd.HandlerType. -func (s *Server) RegisterService(sd *ServiceDesc, ss any) { - if ss != nil { - ht := reflect.TypeOf(sd.HandlerType).Elem() - st := reflect.TypeOf(ss) - if !st.Implements(ht) { - logger.Fatalf("grpc: Server.RegisterService found the handler of type %v that does not satisfy %v", st, ht) - } - } - s.register(sd, ss) -} - -func (s *Server) register(sd *ServiceDesc, ss any) { - s.mu.Lock() - defer s.mu.Unlock() - s.printf("RegisterService(%q)", sd.ServiceName) - if s.serve { - logger.Fatalf("grpc: Server.RegisterService after Server.Serve for %q", sd.ServiceName) - } - if _, ok := s.services[sd.ServiceName]; ok { - logger.Fatalf("grpc: Server.RegisterService found duplicate service registration for %q", sd.ServiceName) - } - info := &serviceInfo{ - serviceImpl: ss, - methods: make(map[string]*MethodDesc), - streams: make(map[string]*StreamDesc), - mdata: sd.Metadata, - } - for i := range sd.Methods { - d := &sd.Methods[i] - info.methods[d.MethodName] = d - } - for i := range sd.Streams { - d := &sd.Streams[i] - info.streams[d.StreamName] = d - } - s.services[sd.ServiceName] = info -} - -// MethodInfo contains the information of an RPC including its method name and type. -type MethodInfo struct { - // Name is the method name only, without the service name or package name. - Name string - // IsClientStream indicates whether the RPC is a client streaming RPC. - IsClientStream bool - // IsServerStream indicates whether the RPC is a server streaming RPC. - IsServerStream bool -} - -// ServiceInfo contains unary RPC method info, streaming RPC method info and metadata for a service. -type ServiceInfo struct { - Methods []MethodInfo - // Metadata is the metadata specified in ServiceDesc when registering service. - Metadata any -} - -// GetServiceInfo returns a map from service names to ServiceInfo. -// Service names include the package names, in the form of .. -func (s *Server) GetServiceInfo() map[string]ServiceInfo { - ret := make(map[string]ServiceInfo) - for n, srv := range s.services { - methods := make([]MethodInfo, 0, len(srv.methods)+len(srv.streams)) - for m := range srv.methods { - methods = append(methods, MethodInfo{ - Name: m, - IsClientStream: false, - IsServerStream: false, - }) - } - for m, d := range srv.streams { - methods = append(methods, MethodInfo{ - Name: m, - IsClientStream: d.ClientStreams, - IsServerStream: d.ServerStreams, - }) - } - - ret[n] = ServiceInfo{ - Methods: methods, - Metadata: srv.mdata, - } - } - return ret -} - -// ErrServerStopped indicates that the operation is now illegal because of -// the server being stopped. -var ErrServerStopped = errors.New("grpc: the server has been stopped") - -type listenSocket struct { - net.Listener - channelz *channelz.Socket -} - -func (l *listenSocket) Close() error { - err := l.Listener.Close() - channelz.RemoveEntry(l.channelz.ID) - channelz.Info(logger, l.channelz, "ListenSocket deleted") - return err -} - -// Serve accepts incoming connections on the listener lis, creating a new -// ServerTransport and service goroutine for each. The service goroutines -// read gRPC requests and then call the registered handlers to reply to them. -// Serve returns when lis.Accept fails with fatal errors. lis will be closed when -// this method returns. -// Serve will return a non-nil error unless Stop or GracefulStop is called. -// -// Note: All supported releases of Go (as of December 2023) override the OS -// defaults for TCP keepalive time and interval to 15s. To enable TCP keepalive -// with OS defaults for keepalive time and interval, callers need to do the -// following two things: -// - pass a net.Listener created by calling the Listen method on a -// net.ListenConfig with the `KeepAlive` field set to a negative value. This -// will result in the Go standard library not overriding OS defaults for TCP -// keepalive interval and time. But this will also result in the Go standard -// library not enabling TCP keepalives by default. -// - override the Accept method on the passed in net.Listener and set the -// SO_KEEPALIVE socket option to enable TCP keepalives, with OS defaults. -func (s *Server) Serve(lis net.Listener) error { - s.mu.Lock() - s.printf("serving") - s.serve = true - if s.lis == nil { - // Serve called after Stop or GracefulStop. - s.mu.Unlock() - lis.Close() - return ErrServerStopped - } - - s.serveWG.Add(1) - defer func() { - s.serveWG.Done() - if s.quit.HasFired() { - // Stop or GracefulStop called; block until done and return nil. - <-s.done.Done() - } - }() - - ls := &listenSocket{ - Listener: lis, - channelz: channelz.RegisterSocket(&channelz.Socket{ - SocketType: channelz.SocketTypeListen, - Parent: s.channelz, - RefName: lis.Addr().String(), - LocalAddr: lis.Addr(), - SocketOptions: channelz.GetSocketOption(lis)}, - ), - } - s.lis[ls] = true - - defer func() { - s.mu.Lock() - if s.lis != nil && s.lis[ls] { - ls.Close() - delete(s.lis, ls) - } - s.mu.Unlock() - }() - - s.mu.Unlock() - channelz.Info(logger, ls.channelz, "ListenSocket created") - - var tempDelay time.Duration // how long to sleep on accept failure - for { - rawConn, err := lis.Accept() - if err != nil { - if ne, ok := err.(interface { - Temporary() bool - }); ok && ne.Temporary() { - if tempDelay == 0 { - tempDelay = 5 * time.Millisecond - } else { - tempDelay *= 2 - } - if max := 1 * time.Second; tempDelay > max { - tempDelay = max - } - s.mu.Lock() - s.printf("Accept error: %v; retrying in %v", err, tempDelay) - s.mu.Unlock() - timer := time.NewTimer(tempDelay) - select { - case <-timer.C: - case <-s.quit.Done(): - timer.Stop() - return nil - } - continue - } - s.mu.Lock() - s.printf("done serving; Accept = %v", err) - s.mu.Unlock() - - if s.quit.HasFired() { - return nil - } - return err - } - tempDelay = 0 - // Start a new goroutine to deal with rawConn so we don't stall this Accept - // loop goroutine. - // - // Make sure we account for the goroutine so GracefulStop doesn't nil out - // s.conns before this conn can be added. - s.serveWG.Add(1) - go func() { - s.handleRawConn(lis.Addr().String(), rawConn) - s.serveWG.Done() - }() - } -} - -// handleRawConn forks a goroutine to handle a just-accepted connection that -// has not had any I/O performed on it yet. -func (s *Server) handleRawConn(lisAddr string, rawConn net.Conn) { - if s.quit.HasFired() { - rawConn.Close() - return - } - rawConn.SetDeadline(time.Now().Add(s.opts.connectionTimeout)) - - // Finish handshaking (HTTP2) - st := s.newHTTP2Transport(rawConn) - rawConn.SetDeadline(time.Time{}) - if st == nil { - return - } - - if cc, ok := rawConn.(interface { - PassServerTransport(transport.ServerTransport) - }); ok { - cc.PassServerTransport(st) - } - - if !s.addConn(lisAddr, st) { - return - } - go func() { - s.serveStreams(context.Background(), st, rawConn) - s.removeConn(lisAddr, st) - }() -} - -// newHTTP2Transport sets up a http/2 transport (using the -// gRPC http2 server transport in transport/http2_server.go). -func (s *Server) newHTTP2Transport(c net.Conn) transport.ServerTransport { - config := &transport.ServerConfig{ - MaxStreams: s.opts.maxConcurrentStreams, - ConnectionTimeout: s.opts.connectionTimeout, - Credentials: s.opts.creds, - InTapHandle: s.opts.inTapHandle, - StatsHandlers: s.opts.statsHandlers, - KeepaliveParams: s.opts.keepaliveParams, - KeepalivePolicy: s.opts.keepalivePolicy, - InitialWindowSize: s.opts.initialWindowSize, - InitialConnWindowSize: s.opts.initialConnWindowSize, - WriteBufferSize: s.opts.writeBufferSize, - ReadBufferSize: s.opts.readBufferSize, - SharedWriteBuffer: s.opts.sharedWriteBuffer, - ChannelzParent: s.channelz, - MaxHeaderListSize: s.opts.maxHeaderListSize, - HeaderTableSize: s.opts.headerTableSize, - } - st, err := transport.NewServerTransport(c, config) - if err != nil { - s.mu.Lock() - s.errorf("NewServerTransport(%q) failed: %v", c.RemoteAddr(), err) - s.mu.Unlock() - // ErrConnDispatched means that the connection was dispatched away from - // gRPC; those connections should be left open. - if err != credentials.ErrConnDispatched { - // Don't log on ErrConnDispatched and io.EOF to prevent log spam. - if err != io.EOF { - channelz.Info(logger, s.channelz, "grpc: Server.Serve failed to create ServerTransport: ", err) - } - c.Close() - } - return nil - } - - return st -} - -func (s *Server) serveStreams(ctx context.Context, st transport.ServerTransport, rawConn net.Conn) { - ctx = transport.SetConnection(ctx, rawConn) - ctx = peer.NewContext(ctx, st.Peer()) - for _, sh := range s.opts.statsHandlers { - ctx = sh.TagConn(ctx, &stats.ConnTagInfo{ - RemoteAddr: st.Peer().Addr, - LocalAddr: st.Peer().LocalAddr, - }) - sh.HandleConn(ctx, &stats.ConnBegin{}) - } - - defer func() { - st.Close(errors.New("finished serving streams for the server transport")) - for _, sh := range s.opts.statsHandlers { - sh.HandleConn(ctx, &stats.ConnEnd{}) - } - }() - - streamQuota := newHandlerQuota(s.opts.maxConcurrentStreams) - st.HandleStreams(ctx, func(stream *transport.Stream) { - s.handlersWG.Add(1) - streamQuota.acquire() - f := func() { - defer streamQuota.release() - defer s.handlersWG.Done() - s.handleStream(st, stream) - } - - if s.opts.numServerWorkers > 0 { - select { - case s.serverWorkerChannel <- f: - return - default: - // If all stream workers are busy, fallback to the default code path. - } - } - go f() - }) -} - -var _ http.Handler = (*Server)(nil) - -// ServeHTTP implements the Go standard library's http.Handler -// interface by responding to the gRPC request r, by looking up -// the requested gRPC method in the gRPC server s. -// -// The provided HTTP request must have arrived on an HTTP/2 -// connection. When using the Go standard library's server, -// practically this means that the Request must also have arrived -// over TLS. -// -// To share one port (such as 443 for https) between gRPC and an -// existing http.Handler, use a root http.Handler such as: -// -// if r.ProtoMajor == 2 && strings.HasPrefix( -// r.Header.Get("Content-Type"), "application/grpc") { -// grpcServer.ServeHTTP(w, r) -// } else { -// yourMux.ServeHTTP(w, r) -// } -// -// Note that ServeHTTP uses Go's HTTP/2 server implementation which is totally -// separate from grpc-go's HTTP/2 server. Performance and features may vary -// between the two paths. ServeHTTP does not support some gRPC features -// available through grpc-go's HTTP/2 server. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { - st, err := transport.NewServerHandlerTransport(w, r, s.opts.statsHandlers) - if err != nil { - // Errors returned from transport.NewServerHandlerTransport have - // already been written to w. - return - } - if !s.addConn(listenerAddressForServeHTTP, st) { - return - } - defer s.removeConn(listenerAddressForServeHTTP, st) - s.serveStreams(r.Context(), st, nil) -} - -func (s *Server) addConn(addr string, st transport.ServerTransport) bool { - s.mu.Lock() - defer s.mu.Unlock() - if s.conns == nil { - st.Close(errors.New("Server.addConn called when server has already been stopped")) - return false - } - if s.drain { - // Transport added after we drained our existing conns: drain it - // immediately. - st.Drain("") - } - - if s.conns[addr] == nil { - // Create a map entry if this is the first connection on this listener. - s.conns[addr] = make(map[transport.ServerTransport]bool) - } - s.conns[addr][st] = true - return true -} - -func (s *Server) removeConn(addr string, st transport.ServerTransport) { - s.mu.Lock() - defer s.mu.Unlock() - - conns := s.conns[addr] - if conns != nil { - delete(conns, st) - if len(conns) == 0 { - // If the last connection for this address is being removed, also - // remove the map entry corresponding to the address. This is used - // in GracefulStop() when waiting for all connections to be closed. - delete(s.conns, addr) - } - s.cv.Broadcast() - } -} - -func (s *Server) incrCallsStarted() { - s.channelz.ServerMetrics.CallsStarted.Add(1) - s.channelz.ServerMetrics.LastCallStartedTimestamp.Store(time.Now().UnixNano()) -} - -func (s *Server) incrCallsSucceeded() { - s.channelz.ServerMetrics.CallsSucceeded.Add(1) -} - -func (s *Server) incrCallsFailed() { - s.channelz.ServerMetrics.CallsFailed.Add(1) -} - -func (s *Server) sendResponse(ctx context.Context, t transport.ServerTransport, stream *transport.Stream, msg any, cp Compressor, opts *transport.Options, comp encoding.Compressor) error { - data, err := encode(s.getCodec(stream.ContentSubtype()), msg) - if err != nil { - channelz.Error(logger, s.channelz, "grpc: server failed to encode response: ", err) - return err - } - compData, err := compress(data, cp, comp) - if err != nil { - channelz.Error(logger, s.channelz, "grpc: server failed to compress response: ", err) - return err - } - hdr, payload := msgHeader(data, compData) - // TODO(dfawley): should we be checking len(data) instead? - if len(payload) > s.opts.maxSendMessageSize { - return status.Errorf(codes.ResourceExhausted, "grpc: trying to send message larger than max (%d vs. %d)", len(payload), s.opts.maxSendMessageSize) - } - err = t.Write(stream, hdr, payload, opts) - if err == nil { - for _, sh := range s.opts.statsHandlers { - sh.HandleRPC(ctx, outPayload(false, msg, data, payload, time.Now())) - } - } - return err -} - -// chainUnaryServerInterceptors chains all unary server interceptors into one. -func chainUnaryServerInterceptors(s *Server) { - // Prepend opts.unaryInt to the chaining interceptors if it exists, since unaryInt will - // be executed before any other chained interceptors. - interceptors := s.opts.chainUnaryInts - if s.opts.unaryInt != nil { - interceptors = append([]UnaryServerInterceptor{s.opts.unaryInt}, s.opts.chainUnaryInts...) - } - - var chainedInt UnaryServerInterceptor - if len(interceptors) == 0 { - chainedInt = nil - } else if len(interceptors) == 1 { - chainedInt = interceptors[0] - } else { - chainedInt = chainUnaryInterceptors(interceptors) - } - - s.opts.unaryInt = chainedInt -} - -func chainUnaryInterceptors(interceptors []UnaryServerInterceptor) UnaryServerInterceptor { - return func(ctx context.Context, req any, info *UnaryServerInfo, handler UnaryHandler) (any, error) { - return interceptors[0](ctx, req, info, getChainUnaryHandler(interceptors, 0, info, handler)) - } -} - -func getChainUnaryHandler(interceptors []UnaryServerInterceptor, curr int, info *UnaryServerInfo, finalHandler UnaryHandler) UnaryHandler { - if curr == len(interceptors)-1 { - return finalHandler - } - return func(ctx context.Context, req any) (any, error) { - return interceptors[curr+1](ctx, req, info, getChainUnaryHandler(interceptors, curr+1, info, finalHandler)) - } -} - -func (s *Server) processUnaryRPC(ctx context.Context, t transport.ServerTransport, stream *transport.Stream, info *serviceInfo, md *MethodDesc, trInfo *traceInfo) (err error) { - shs := s.opts.statsHandlers - if len(shs) != 0 || trInfo != nil || channelz.IsOn() { - if channelz.IsOn() { - s.incrCallsStarted() - } - var statsBegin *stats.Begin - for _, sh := range shs { - beginTime := time.Now() - statsBegin = &stats.Begin{ - BeginTime: beginTime, - IsClientStream: false, - IsServerStream: false, - } - sh.HandleRPC(ctx, statsBegin) - } - if trInfo != nil { - trInfo.tr.LazyLog(&trInfo.firstLine, false) - } - // The deferred error handling for tracing, stats handler and channelz are - // combined into one function to reduce stack usage -- a defer takes ~56-64 - // bytes on the stack, so overflowing the stack will require a stack - // re-allocation, which is expensive. - // - // To maintain behavior similar to separate deferred statements, statements - // should be executed in the reverse order. That is, tracing first, stats - // handler second, and channelz last. Note that panics *within* defers will - // lead to different behavior, but that's an acceptable compromise; that - // would be undefined behavior territory anyway. - defer func() { - if trInfo != nil { - if err != nil && err != io.EOF { - trInfo.tr.LazyLog(&fmtStringer{"%v", []any{err}}, true) - trInfo.tr.SetError() - } - trInfo.tr.Finish() - } - - for _, sh := range shs { - end := &stats.End{ - BeginTime: statsBegin.BeginTime, - EndTime: time.Now(), - } - if err != nil && err != io.EOF { - end.Error = toRPCErr(err) - } - sh.HandleRPC(ctx, end) - } - - if channelz.IsOn() { - if err != nil && err != io.EOF { - s.incrCallsFailed() - } else { - s.incrCallsSucceeded() - } - } - }() - } - var binlogs []binarylog.MethodLogger - if ml := binarylog.GetMethodLogger(stream.Method()); ml != nil { - binlogs = append(binlogs, ml) - } - if s.opts.binaryLogger != nil { - if ml := s.opts.binaryLogger.GetMethodLogger(stream.Method()); ml != nil { - binlogs = append(binlogs, ml) - } - } - if len(binlogs) != 0 { - md, _ := metadata.FromIncomingContext(ctx) - logEntry := &binarylog.ClientHeader{ - Header: md, - MethodName: stream.Method(), - PeerAddr: nil, - } - if deadline, ok := ctx.Deadline(); ok { - logEntry.Timeout = time.Until(deadline) - if logEntry.Timeout < 0 { - logEntry.Timeout = 0 - } - } - if a := md[":authority"]; len(a) > 0 { - logEntry.Authority = a[0] - } - if peer, ok := peer.FromContext(ctx); ok { - logEntry.PeerAddr = peer.Addr - } - for _, binlog := range binlogs { - binlog.Log(ctx, logEntry) - } - } - - // comp and cp are used for compression. decomp and dc are used for - // decompression. If comp and decomp are both set, they are the same; - // however they are kept separate to ensure that at most one of the - // compressor/decompressor variable pairs are set for use later. - var comp, decomp encoding.Compressor - var cp Compressor - var dc Decompressor - var sendCompressorName string - - // If dc is set and matches the stream's compression, use it. Otherwise, try - // to find a matching registered compressor for decomp. - if rc := stream.RecvCompress(); s.opts.dc != nil && s.opts.dc.Type() == rc { - dc = s.opts.dc - } else if rc != "" && rc != encoding.Identity { - decomp = encoding.GetCompressor(rc) - if decomp == nil { - st := status.Newf(codes.Unimplemented, "grpc: Decompressor is not installed for grpc-encoding %q", rc) - t.WriteStatus(stream, st) - return st.Err() - } - } - - // If cp is set, use it. Otherwise, attempt to compress the response using - // the incoming message compression method. - // - // NOTE: this needs to be ahead of all handling, https://github.com/grpc/grpc-go/issues/686. - if s.opts.cp != nil { - cp = s.opts.cp - sendCompressorName = cp.Type() - } else if rc := stream.RecvCompress(); rc != "" && rc != encoding.Identity { - // Legacy compressor not specified; attempt to respond with same encoding. - comp = encoding.GetCompressor(rc) - if comp != nil { - sendCompressorName = comp.Name() - } - } - - if sendCompressorName != "" { - if err := stream.SetSendCompress(sendCompressorName); err != nil { - return status.Errorf(codes.Internal, "grpc: failed to set send compressor: %v", err) - } - } - - var payInfo *payloadInfo - if len(shs) != 0 || len(binlogs) != 0 { - payInfo = &payloadInfo{} - } - - d, cancel, err := recvAndDecompress(&parser{r: stream, recvBufferPool: s.opts.recvBufferPool}, stream, dc, s.opts.maxReceiveMessageSize, payInfo, decomp) - if err != nil { - if e := t.WriteStatus(stream, status.Convert(err)); e != nil { - channelz.Warningf(logger, s.channelz, "grpc: Server.processUnaryRPC failed to write status: %v", e) - } - return err - } - if channelz.IsOn() { - t.IncrMsgRecv() - } - df := func(v any) error { - defer cancel() - - if err := s.getCodec(stream.ContentSubtype()).Unmarshal(d, v); err != nil { - return status.Errorf(codes.Internal, "grpc: error unmarshalling request: %v", err) - } - for _, sh := range shs { - sh.HandleRPC(ctx, &stats.InPayload{ - RecvTime: time.Now(), - Payload: v, - Length: len(d), - WireLength: payInfo.compressedLength + headerLen, - CompressedLength: payInfo.compressedLength, - Data: d, - }) - } - if len(binlogs) != 0 { - cm := &binarylog.ClientMessage{ - Message: d, - } - for _, binlog := range binlogs { - binlog.Log(ctx, cm) - } - } - if trInfo != nil { - trInfo.tr.LazyLog(&payload{sent: false, msg: v}, true) - } - return nil - } - ctx = NewContextWithServerTransportStream(ctx, stream) - reply, appErr := md.Handler(info.serviceImpl, ctx, df, s.opts.unaryInt) - if appErr != nil { - appStatus, ok := status.FromError(appErr) - if !ok { - // Convert non-status application error to a status error with code - // Unknown, but handle context errors specifically. - appStatus = status.FromContextError(appErr) - appErr = appStatus.Err() - } - if trInfo != nil { - trInfo.tr.LazyLog(stringer(appStatus.Message()), true) - trInfo.tr.SetError() - } - if e := t.WriteStatus(stream, appStatus); e != nil { - channelz.Warningf(logger, s.channelz, "grpc: Server.processUnaryRPC failed to write status: %v", e) - } - if len(binlogs) != 0 { - if h, _ := stream.Header(); h.Len() > 0 { - // Only log serverHeader if there was header. Otherwise it can - // be trailer only. - sh := &binarylog.ServerHeader{ - Header: h, - } - for _, binlog := range binlogs { - binlog.Log(ctx, sh) - } - } - st := &binarylog.ServerTrailer{ - Trailer: stream.Trailer(), - Err: appErr, - } - for _, binlog := range binlogs { - binlog.Log(ctx, st) - } - } - return appErr - } - if trInfo != nil { - trInfo.tr.LazyLog(stringer("OK"), false) - } - opts := &transport.Options{Last: true} - - // Server handler could have set new compressor by calling SetSendCompressor. - // In case it is set, we need to use it for compressing outbound message. - if stream.SendCompress() != sendCompressorName { - comp = encoding.GetCompressor(stream.SendCompress()) - } - if err := s.sendResponse(ctx, t, stream, reply, cp, opts, comp); err != nil { - if err == io.EOF { - // The entire stream is done (for unary RPC only). - return err - } - if sts, ok := status.FromError(err); ok { - if e := t.WriteStatus(stream, sts); e != nil { - channelz.Warningf(logger, s.channelz, "grpc: Server.processUnaryRPC failed to write status: %v", e) - } - } else { - switch st := err.(type) { - case transport.ConnectionError: - // Nothing to do here. - default: - panic(fmt.Sprintf("grpc: Unexpected error (%T) from sendResponse: %v", st, st)) - } - } - if len(binlogs) != 0 { - h, _ := stream.Header() - sh := &binarylog.ServerHeader{ - Header: h, - } - st := &binarylog.ServerTrailer{ - Trailer: stream.Trailer(), - Err: appErr, - } - for _, binlog := range binlogs { - binlog.Log(ctx, sh) - binlog.Log(ctx, st) - } - } - return err - } - if len(binlogs) != 0 { - h, _ := stream.Header() - sh := &binarylog.ServerHeader{ - Header: h, - } - sm := &binarylog.ServerMessage{ - Message: reply, - } - for _, binlog := range binlogs { - binlog.Log(ctx, sh) - binlog.Log(ctx, sm) - } - } - if channelz.IsOn() { - t.IncrMsgSent() - } - if trInfo != nil { - trInfo.tr.LazyLog(&payload{sent: true, msg: reply}, true) - } - // TODO: Should we be logging if writing status failed here, like above? - // Should the logging be in WriteStatus? Should we ignore the WriteStatus - // error or allow the stats handler to see it? - if len(binlogs) != 0 { - st := &binarylog.ServerTrailer{ - Trailer: stream.Trailer(), - Err: appErr, - } - for _, binlog := range binlogs { - binlog.Log(ctx, st) - } - } - return t.WriteStatus(stream, statusOK) -} - -// chainStreamServerInterceptors chains all stream server interceptors into one. -func chainStreamServerInterceptors(s *Server) { - // Prepend opts.streamInt to the chaining interceptors if it exists, since streamInt will - // be executed before any other chained interceptors. - interceptors := s.opts.chainStreamInts - if s.opts.streamInt != nil { - interceptors = append([]StreamServerInterceptor{s.opts.streamInt}, s.opts.chainStreamInts...) - } - - var chainedInt StreamServerInterceptor - if len(interceptors) == 0 { - chainedInt = nil - } else if len(interceptors) == 1 { - chainedInt = interceptors[0] - } else { - chainedInt = chainStreamInterceptors(interceptors) - } - - s.opts.streamInt = chainedInt -} - -func chainStreamInterceptors(interceptors []StreamServerInterceptor) StreamServerInterceptor { - return func(srv any, ss ServerStream, info *StreamServerInfo, handler StreamHandler) error { - return interceptors[0](srv, ss, info, getChainStreamHandler(interceptors, 0, info, handler)) - } -} - -func getChainStreamHandler(interceptors []StreamServerInterceptor, curr int, info *StreamServerInfo, finalHandler StreamHandler) StreamHandler { - if curr == len(interceptors)-1 { - return finalHandler - } - return func(srv any, stream ServerStream) error { - return interceptors[curr+1](srv, stream, info, getChainStreamHandler(interceptors, curr+1, info, finalHandler)) - } -} - -func (s *Server) processStreamingRPC(ctx context.Context, t transport.ServerTransport, stream *transport.Stream, info *serviceInfo, sd *StreamDesc, trInfo *traceInfo) (err error) { - if channelz.IsOn() { - s.incrCallsStarted() - } - shs := s.opts.statsHandlers - var statsBegin *stats.Begin - if len(shs) != 0 { - beginTime := time.Now() - statsBegin = &stats.Begin{ - BeginTime: beginTime, - IsClientStream: sd.ClientStreams, - IsServerStream: sd.ServerStreams, - } - for _, sh := range shs { - sh.HandleRPC(ctx, statsBegin) - } - } - ctx = NewContextWithServerTransportStream(ctx, stream) - ss := &serverStream{ - ctx: ctx, - t: t, - s: stream, - p: &parser{r: stream, recvBufferPool: s.opts.recvBufferPool}, - codec: s.getCodec(stream.ContentSubtype()), - maxReceiveMessageSize: s.opts.maxReceiveMessageSize, - maxSendMessageSize: s.opts.maxSendMessageSize, - trInfo: trInfo, - statsHandler: shs, - } - - if len(shs) != 0 || trInfo != nil || channelz.IsOn() { - // See comment in processUnaryRPC on defers. - defer func() { - if trInfo != nil { - ss.mu.Lock() - if err != nil && err != io.EOF { - ss.trInfo.tr.LazyLog(&fmtStringer{"%v", []any{err}}, true) - ss.trInfo.tr.SetError() - } - ss.trInfo.tr.Finish() - ss.trInfo.tr = nil - ss.mu.Unlock() - } - - if len(shs) != 0 { - end := &stats.End{ - BeginTime: statsBegin.BeginTime, - EndTime: time.Now(), - } - if err != nil && err != io.EOF { - end.Error = toRPCErr(err) - } - for _, sh := range shs { - sh.HandleRPC(ctx, end) - } - } - - if channelz.IsOn() { - if err != nil && err != io.EOF { - s.incrCallsFailed() - } else { - s.incrCallsSucceeded() - } - } - }() - } - - if ml := binarylog.GetMethodLogger(stream.Method()); ml != nil { - ss.binlogs = append(ss.binlogs, ml) - } - if s.opts.binaryLogger != nil { - if ml := s.opts.binaryLogger.GetMethodLogger(stream.Method()); ml != nil { - ss.binlogs = append(ss.binlogs, ml) - } - } - if len(ss.binlogs) != 0 { - md, _ := metadata.FromIncomingContext(ctx) - logEntry := &binarylog.ClientHeader{ - Header: md, - MethodName: stream.Method(), - PeerAddr: nil, - } - if deadline, ok := ctx.Deadline(); ok { - logEntry.Timeout = time.Until(deadline) - if logEntry.Timeout < 0 { - logEntry.Timeout = 0 - } - } - if a := md[":authority"]; len(a) > 0 { - logEntry.Authority = a[0] - } - if peer, ok := peer.FromContext(ss.Context()); ok { - logEntry.PeerAddr = peer.Addr - } - for _, binlog := range ss.binlogs { - binlog.Log(ctx, logEntry) - } - } - - // If dc is set and matches the stream's compression, use it. Otherwise, try - // to find a matching registered compressor for decomp. - if rc := stream.RecvCompress(); s.opts.dc != nil && s.opts.dc.Type() == rc { - ss.dc = s.opts.dc - } else if rc != "" && rc != encoding.Identity { - ss.decomp = encoding.GetCompressor(rc) - if ss.decomp == nil { - st := status.Newf(codes.Unimplemented, "grpc: Decompressor is not installed for grpc-encoding %q", rc) - t.WriteStatus(ss.s, st) - return st.Err() - } - } - - // If cp is set, use it. Otherwise, attempt to compress the response using - // the incoming message compression method. - // - // NOTE: this needs to be ahead of all handling, https://github.com/grpc/grpc-go/issues/686. - if s.opts.cp != nil { - ss.cp = s.opts.cp - ss.sendCompressorName = s.opts.cp.Type() - } else if rc := stream.RecvCompress(); rc != "" && rc != encoding.Identity { - // Legacy compressor not specified; attempt to respond with same encoding. - ss.comp = encoding.GetCompressor(rc) - if ss.comp != nil { - ss.sendCompressorName = rc - } - } - - if ss.sendCompressorName != "" { - if err := stream.SetSendCompress(ss.sendCompressorName); err != nil { - return status.Errorf(codes.Internal, "grpc: failed to set send compressor: %v", err) - } - } - - ss.ctx = newContextWithRPCInfo(ss.ctx, false, ss.codec, ss.cp, ss.comp) - - if trInfo != nil { - trInfo.tr.LazyLog(&trInfo.firstLine, false) - } - var appErr error - var server any - if info != nil { - server = info.serviceImpl - } - if s.opts.streamInt == nil { - appErr = sd.Handler(server, ss) - } else { - info := &StreamServerInfo{ - FullMethod: stream.Method(), - IsClientStream: sd.ClientStreams, - IsServerStream: sd.ServerStreams, - } - appErr = s.opts.streamInt(server, ss, info, sd.Handler) - } - if appErr != nil { - appStatus, ok := status.FromError(appErr) - if !ok { - // Convert non-status application error to a status error with code - // Unknown, but handle context errors specifically. - appStatus = status.FromContextError(appErr) - appErr = appStatus.Err() - } - if trInfo != nil { - ss.mu.Lock() - ss.trInfo.tr.LazyLog(stringer(appStatus.Message()), true) - ss.trInfo.tr.SetError() - ss.mu.Unlock() - } - if len(ss.binlogs) != 0 { - st := &binarylog.ServerTrailer{ - Trailer: ss.s.Trailer(), - Err: appErr, - } - for _, binlog := range ss.binlogs { - binlog.Log(ctx, st) - } - } - t.WriteStatus(ss.s, appStatus) - // TODO: Should we log an error from WriteStatus here and below? - return appErr - } - if trInfo != nil { - ss.mu.Lock() - ss.trInfo.tr.LazyLog(stringer("OK"), false) - ss.mu.Unlock() - } - if len(ss.binlogs) != 0 { - st := &binarylog.ServerTrailer{ - Trailer: ss.s.Trailer(), - Err: appErr, - } - for _, binlog := range ss.binlogs { - binlog.Log(ctx, st) - } - } - return t.WriteStatus(ss.s, statusOK) -} - -func (s *Server) handleStream(t transport.ServerTransport, stream *transport.Stream) { - ctx := stream.Context() - ctx = contextWithServer(ctx, s) - var ti *traceInfo - if EnableTracing { - tr := newTrace("grpc.Recv."+methodFamily(stream.Method()), stream.Method()) - ctx = newTraceContext(ctx, tr) - ti = &traceInfo{ - tr: tr, - firstLine: firstLine{ - client: false, - remoteAddr: t.Peer().Addr, - }, - } - if dl, ok := ctx.Deadline(); ok { - ti.firstLine.deadline = time.Until(dl) - } - } - - sm := stream.Method() - if sm != "" && sm[0] == '/' { - sm = sm[1:] - } - pos := strings.LastIndex(sm, "/") - if pos == -1 { - if ti != nil { - ti.tr.LazyLog(&fmtStringer{"Malformed method name %q", []any{sm}}, true) - ti.tr.SetError() - } - errDesc := fmt.Sprintf("malformed method name: %q", stream.Method()) - if err := t.WriteStatus(stream, status.New(codes.Unimplemented, errDesc)); err != nil { - if ti != nil { - ti.tr.LazyLog(&fmtStringer{"%v", []any{err}}, true) - ti.tr.SetError() - } - channelz.Warningf(logger, s.channelz, "grpc: Server.handleStream failed to write status: %v", err) - } - if ti != nil { - ti.tr.Finish() - } - return - } - service := sm[:pos] - method := sm[pos+1:] - - md, _ := metadata.FromIncomingContext(ctx) - for _, sh := range s.opts.statsHandlers { - ctx = sh.TagRPC(ctx, &stats.RPCTagInfo{FullMethodName: stream.Method()}) - sh.HandleRPC(ctx, &stats.InHeader{ - FullMethod: stream.Method(), - RemoteAddr: t.Peer().Addr, - LocalAddr: t.Peer().LocalAddr, - Compression: stream.RecvCompress(), - WireLength: stream.HeaderWireLength(), - Header: md, - }) - } - // To have calls in stream callouts work. Will delete once all stats handler - // calls come from the gRPC layer. - stream.SetContext(ctx) - - srv, knownService := s.services[service] - if knownService { - if md, ok := srv.methods[method]; ok { - s.processUnaryRPC(ctx, t, stream, srv, md, ti) - return - } - if sd, ok := srv.streams[method]; ok { - s.processStreamingRPC(ctx, t, stream, srv, sd, ti) - return - } - } - // Unknown service, or known server unknown method. - if unknownDesc := s.opts.unknownStreamDesc; unknownDesc != nil { - s.processStreamingRPC(ctx, t, stream, nil, unknownDesc, ti) - return - } - var errDesc string - if !knownService { - errDesc = fmt.Sprintf("unknown service %v", service) - } else { - errDesc = fmt.Sprintf("unknown method %v for service %v", method, service) - } - if ti != nil { - ti.tr.LazyPrintf("%s", errDesc) - ti.tr.SetError() - } - if err := t.WriteStatus(stream, status.New(codes.Unimplemented, errDesc)); err != nil { - if ti != nil { - ti.tr.LazyLog(&fmtStringer{"%v", []any{err}}, true) - ti.tr.SetError() - } - channelz.Warningf(logger, s.channelz, "grpc: Server.handleStream failed to write status: %v", err) - } - if ti != nil { - ti.tr.Finish() - } -} - -// The key to save ServerTransportStream in the context. -type streamKey struct{} - -// NewContextWithServerTransportStream creates a new context from ctx and -// attaches stream to it. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func NewContextWithServerTransportStream(ctx context.Context, stream ServerTransportStream) context.Context { - return context.WithValue(ctx, streamKey{}, stream) -} - -// ServerTransportStream is a minimal interface that a transport stream must -// implement. This can be used to mock an actual transport stream for tests of -// handler code that use, for example, grpc.SetHeader (which requires some -// stream to be in context). -// -// See also NewContextWithServerTransportStream. -// -// # Experimental -// -// Notice: This type is EXPERIMENTAL and may be changed or removed in a -// later release. -type ServerTransportStream interface { - Method() string - SetHeader(md metadata.MD) error - SendHeader(md metadata.MD) error - SetTrailer(md metadata.MD) error -} - -// ServerTransportStreamFromContext returns the ServerTransportStream saved in -// ctx. Returns nil if the given context has no stream associated with it -// (which implies it is not an RPC invocation context). -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func ServerTransportStreamFromContext(ctx context.Context) ServerTransportStream { - s, _ := ctx.Value(streamKey{}).(ServerTransportStream) - return s -} - -// Stop stops the gRPC server. It immediately closes all open -// connections and listeners. -// It cancels all active RPCs on the server side and the corresponding -// pending RPCs on the client side will get notified by connection -// errors. -func (s *Server) Stop() { - s.stop(false) -} - -// GracefulStop stops the gRPC server gracefully. It stops the server from -// accepting new connections and RPCs and blocks until all the pending RPCs are -// finished. -func (s *Server) GracefulStop() { - s.stop(true) -} - -func (s *Server) stop(graceful bool) { - s.quit.Fire() - defer s.done.Fire() - - s.channelzRemoveOnce.Do(func() { channelz.RemoveEntry(s.channelz.ID) }) - s.mu.Lock() - s.closeListenersLocked() - // Wait for serving threads to be ready to exit. Only then can we be sure no - // new conns will be created. - s.mu.Unlock() - s.serveWG.Wait() - - s.mu.Lock() - defer s.mu.Unlock() - - if graceful { - s.drainAllServerTransportsLocked() - } else { - s.closeServerTransportsLocked() - } - - for len(s.conns) != 0 { - s.cv.Wait() - } - s.conns = nil - - if s.opts.numServerWorkers > 0 { - // Closing the channel (only once, via grpcsync.OnceFunc) after all the - // connections have been closed above ensures that there are no - // goroutines executing the callback passed to st.HandleStreams (where - // the channel is written to). - s.serverWorkerChannelClose() - } - - if graceful || s.opts.waitForHandlers { - s.handlersWG.Wait() - } - - if s.events != nil { - s.events.Finish() - s.events = nil - } -} - -// s.mu must be held by the caller. -func (s *Server) closeServerTransportsLocked() { - for _, conns := range s.conns { - for st := range conns { - st.Close(errors.New("Server.Stop called")) - } - } -} - -// s.mu must be held by the caller. -func (s *Server) drainAllServerTransportsLocked() { - if !s.drain { - for _, conns := range s.conns { - for st := range conns { - st.Drain("graceful_stop") - } - } - s.drain = true - } -} - -// s.mu must be held by the caller. -func (s *Server) closeListenersLocked() { - for lis := range s.lis { - lis.Close() - } - s.lis = nil -} - -// contentSubtype must be lowercase -// cannot return nil -func (s *Server) getCodec(contentSubtype string) baseCodec { - if s.opts.codec != nil { - return s.opts.codec - } - if contentSubtype == "" { - return encoding.GetCodec(proto.Name) - } - codec := encoding.GetCodec(contentSubtype) - if codec == nil { - logger.Warningf("Unsupported codec %q. Defaulting to %q for now. This will start to fail in future releases.", contentSubtype, proto.Name) - return encoding.GetCodec(proto.Name) - } - return codec -} - -type serverKey struct{} - -// serverFromContext gets the Server from the context. -func serverFromContext(ctx context.Context) *Server { - s, _ := ctx.Value(serverKey{}).(*Server) - return s -} - -// contextWithServer sets the Server in the context. -func contextWithServer(ctx context.Context, server *Server) context.Context { - return context.WithValue(ctx, serverKey{}, server) -} - -// isRegisteredMethod returns whether the passed in method is registered as a -// method on the server. /service/method and service/method will match if the -// service and method are registered on the server. -func (s *Server) isRegisteredMethod(serviceMethod string) bool { - if serviceMethod != "" && serviceMethod[0] == '/' { - serviceMethod = serviceMethod[1:] - } - pos := strings.LastIndex(serviceMethod, "/") - if pos == -1 { // Invalid method name syntax. - return false - } - service := serviceMethod[:pos] - method := serviceMethod[pos+1:] - srv, knownService := s.services[service] - if knownService { - if _, ok := srv.methods[method]; ok { - return true - } - if _, ok := srv.streams[method]; ok { - return true - } - } - return false -} - -// SetHeader sets the header metadata to be sent from the server to the client. -// The context provided must be the context passed to the server's handler. -// -// Streaming RPCs should prefer the SetHeader method of the ServerStream. -// -// When called multiple times, all the provided metadata will be merged. All -// the metadata will be sent out when one of the following happens: -// -// - grpc.SendHeader is called, or for streaming handlers, stream.SendHeader. -// - The first response message is sent. For unary handlers, this occurs when -// the handler returns; for streaming handlers, this can happen when stream's -// SendMsg method is called. -// - An RPC status is sent out (error or success). This occurs when the handler -// returns. -// -// SetHeader will fail if called after any of the events above. -// -// The error returned is compatible with the status package. However, the -// status code will often not match the RPC status as seen by the client -// application, and therefore, should not be relied upon for this purpose. -func SetHeader(ctx context.Context, md metadata.MD) error { - if md.Len() == 0 { - return nil - } - stream := ServerTransportStreamFromContext(ctx) - if stream == nil { - return status.Errorf(codes.Internal, "grpc: failed to fetch the stream from the context %v", ctx) - } - return stream.SetHeader(md) -} - -// SendHeader sends header metadata. It may be called at most once, and may not -// be called after any event that causes headers to be sent (see SetHeader for -// a complete list). The provided md and headers set by SetHeader() will be -// sent. -// -// The error returned is compatible with the status package. However, the -// status code will often not match the RPC status as seen by the client -// application, and therefore, should not be relied upon for this purpose. -func SendHeader(ctx context.Context, md metadata.MD) error { - stream := ServerTransportStreamFromContext(ctx) - if stream == nil { - return status.Errorf(codes.Internal, "grpc: failed to fetch the stream from the context %v", ctx) - } - if err := stream.SendHeader(md); err != nil { - return toRPCErr(err) - } - return nil -} - -// SetSendCompressor sets a compressor for outbound messages from the server. -// It must not be called after any event that causes headers to be sent -// (see ServerStream.SetHeader for the complete list). Provided compressor is -// used when below conditions are met: -// -// - compressor is registered via encoding.RegisterCompressor -// - compressor name must exist in the client advertised compressor names -// sent in grpc-accept-encoding header. Use ClientSupportedCompressors to -// get client supported compressor names. -// -// The context provided must be the context passed to the server's handler. -// It must be noted that compressor name encoding.Identity disables the -// outbound compression. -// By default, server messages will be sent using the same compressor with -// which request messages were sent. -// -// It is not safe to call SetSendCompressor concurrently with SendHeader and -// SendMsg. -// -// # Experimental -// -// Notice: This function is EXPERIMENTAL and may be changed or removed in a -// later release. -func SetSendCompressor(ctx context.Context, name string) error { - stream, ok := ServerTransportStreamFromContext(ctx).(*transport.Stream) - if !ok || stream == nil { - return fmt.Errorf("failed to fetch the stream from the given context") - } - - if err := validateSendCompressor(name, stream.ClientAdvertisedCompressors()); err != nil { - return fmt.Errorf("unable to set send compressor: %w", err) - } - - return stream.SetSendCompress(name) -} - -// ClientSupportedCompressors returns compressor names advertised by the client -// via grpc-accept-encoding header. -// -// The context provided must be the context passed to the server's handler. -// -// # Experimental -// -// Notice: This function is EXPERIMENTAL and may be changed or removed in a -// later release. -func ClientSupportedCompressors(ctx context.Context) ([]string, error) { - stream, ok := ServerTransportStreamFromContext(ctx).(*transport.Stream) - if !ok || stream == nil { - return nil, fmt.Errorf("failed to fetch the stream from the given context %v", ctx) - } - - return stream.ClientAdvertisedCompressors(), nil -} - -// SetTrailer sets the trailer metadata that will be sent when an RPC returns. -// When called more than once, all the provided metadata will be merged. -// -// The error returned is compatible with the status package. However, the -// status code will often not match the RPC status as seen by the client -// application, and therefore, should not be relied upon for this purpose. -func SetTrailer(ctx context.Context, md metadata.MD) error { - if md.Len() == 0 { - return nil - } - stream := ServerTransportStreamFromContext(ctx) - if stream == nil { - return status.Errorf(codes.Internal, "grpc: failed to fetch the stream from the context %v", ctx) - } - return stream.SetTrailer(md) -} - -// Method returns the method string for the server context. The returned -// string is in the format of "/service/method". -func Method(ctx context.Context) (string, bool) { - s := ServerTransportStreamFromContext(ctx) - if s == nil { - return "", false - } - return s.Method(), true -} - -// validateSendCompressor returns an error when given compressor name cannot be -// handled by the server or the client based on the advertised compressors. -func validateSendCompressor(name string, clientCompressors []string) error { - if name == encoding.Identity { - return nil - } - - if !grpcutil.IsCompressorNameRegistered(name) { - return fmt.Errorf("compressor not registered %q", name) - } - - for _, c := range clientCompressors { - if c == name { - return nil // found match - } - } - return fmt.Errorf("client does not support compressor %q", name) -} - -// atomicSemaphore implements a blocking, counting semaphore. acquire should be -// called synchronously; release may be called asynchronously. -type atomicSemaphore struct { - n atomic.Int64 - wait chan struct{} -} - -func (q *atomicSemaphore) acquire() { - if q.n.Add(-1) < 0 { - // We ran out of quota. Block until a release happens. - <-q.wait - } -} - -func (q *atomicSemaphore) release() { - // N.B. the "<= 0" check below should allow for this to work with multiple - // concurrent calls to acquire, but also note that with synchronous calls to - // acquire, as our system does, n will never be less than -1. There are - // fairness issues (queuing) to consider if this was to be generalized. - if q.n.Add(1) <= 0 { - // An acquire was waiting on us. Unblock it. - q.wait <- struct{}{} - } -} - -func newHandlerQuota(n uint32) *atomicSemaphore { - a := &atomicSemaphore{wait: make(chan struct{}, 1)} - a.n.Store(int64(n)) - return a -} diff --git a/vendor/google.golang.org/grpc/service_config.go b/vendor/google.golang.org/grpc/service_config.go deleted file mode 100644 index 2b35c5d21..000000000 --- a/vendor/google.golang.org/grpc/service_config.go +++ /dev/null @@ -1,354 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpc - -import ( - "encoding/json" - "errors" - "fmt" - "reflect" - "time" - - "google.golang.org/grpc/balancer" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/internal" - "google.golang.org/grpc/internal/balancer/gracefulswitch" - internalserviceconfig "google.golang.org/grpc/internal/serviceconfig" - "google.golang.org/grpc/serviceconfig" -) - -const maxInt = int(^uint(0) >> 1) - -// MethodConfig defines the configuration recommended by the service providers for a -// particular method. -// -// Deprecated: Users should not use this struct. Service config should be received -// through name resolver, as specified here -// https://github.com/grpc/grpc/blob/master/doc/service_config.md -type MethodConfig = internalserviceconfig.MethodConfig - -// ServiceConfig is provided by the service provider and contains parameters for how -// clients that connect to the service should behave. -// -// Deprecated: Users should not use this struct. Service config should be received -// through name resolver, as specified here -// https://github.com/grpc/grpc/blob/master/doc/service_config.md -type ServiceConfig struct { - serviceconfig.Config - - // lbConfig is the service config's load balancing configuration. If - // lbConfig and LB are both present, lbConfig will be used. - lbConfig serviceconfig.LoadBalancingConfig - - // Methods contains a map for the methods in this service. If there is an - // exact match for a method (i.e. /service/method) in the map, use the - // corresponding MethodConfig. If there's no exact match, look for the - // default config for the service (/service/) and use the corresponding - // MethodConfig if it exists. Otherwise, the method has no MethodConfig to - // use. - Methods map[string]MethodConfig - - // If a retryThrottlingPolicy is provided, gRPC will automatically throttle - // retry attempts and hedged RPCs when the client’s ratio of failures to - // successes exceeds a threshold. - // - // For each server name, the gRPC client will maintain a token_count which is - // initially set to maxTokens, and can take values between 0 and maxTokens. - // - // Every outgoing RPC (regardless of service or method invoked) will change - // token_count as follows: - // - // - Every failed RPC will decrement the token_count by 1. - // - Every successful RPC will increment the token_count by tokenRatio. - // - // If token_count is less than or equal to maxTokens / 2, then RPCs will not - // be retried and hedged RPCs will not be sent. - retryThrottling *retryThrottlingPolicy - // healthCheckConfig must be set as one of the requirement to enable LB channel - // health check. - healthCheckConfig *healthCheckConfig - // rawJSONString stores service config json string that get parsed into - // this service config struct. - rawJSONString string -} - -// healthCheckConfig defines the go-native version of the LB channel health check config. -type healthCheckConfig struct { - // serviceName is the service name to use in the health-checking request. - ServiceName string -} - -type jsonRetryPolicy struct { - MaxAttempts int - InitialBackoff internalserviceconfig.Duration - MaxBackoff internalserviceconfig.Duration - BackoffMultiplier float64 - RetryableStatusCodes []codes.Code -} - -// retryThrottlingPolicy defines the go-native version of the retry throttling -// policy defined by the service config here: -// https://github.com/grpc/proposal/blob/master/A6-client-retries.md#integration-with-service-config -type retryThrottlingPolicy struct { - // The number of tokens starts at maxTokens. The token_count will always be - // between 0 and maxTokens. - // - // This field is required and must be greater than zero. - MaxTokens float64 - // The amount of tokens to add on each successful RPC. Typically this will - // be some number between 0 and 1, e.g., 0.1. - // - // This field is required and must be greater than zero. Up to 3 decimal - // places are supported. - TokenRatio float64 -} - -type jsonName struct { - Service string - Method string -} - -var ( - errDuplicatedName = errors.New("duplicated name") - errEmptyServiceNonEmptyMethod = errors.New("cannot combine empty 'service' and non-empty 'method'") -) - -func (j jsonName) generatePath() (string, error) { - if j.Service == "" { - if j.Method != "" { - return "", errEmptyServiceNonEmptyMethod - } - return "", nil - } - res := "/" + j.Service + "/" - if j.Method != "" { - res += j.Method - } - return res, nil -} - -// TODO(lyuxuan): delete this struct after cleaning up old service config implementation. -type jsonMC struct { - Name *[]jsonName - WaitForReady *bool - Timeout *internalserviceconfig.Duration - MaxRequestMessageBytes *int64 - MaxResponseMessageBytes *int64 - RetryPolicy *jsonRetryPolicy -} - -// TODO(lyuxuan): delete this struct after cleaning up old service config implementation. -type jsonSC struct { - LoadBalancingPolicy *string - LoadBalancingConfig *json.RawMessage - MethodConfig *[]jsonMC - RetryThrottling *retryThrottlingPolicy - HealthCheckConfig *healthCheckConfig -} - -func init() { - internal.ParseServiceConfig = parseServiceConfig -} -func parseServiceConfig(js string) *serviceconfig.ParseResult { - if len(js) == 0 { - return &serviceconfig.ParseResult{Err: fmt.Errorf("no JSON service config provided")} - } - var rsc jsonSC - err := json.Unmarshal([]byte(js), &rsc) - if err != nil { - logger.Warningf("grpc: unmarshaling service config %s: %v", js, err) - return &serviceconfig.ParseResult{Err: err} - } - sc := ServiceConfig{ - Methods: make(map[string]MethodConfig), - retryThrottling: rsc.RetryThrottling, - healthCheckConfig: rsc.HealthCheckConfig, - rawJSONString: js, - } - c := rsc.LoadBalancingConfig - if c == nil { - name := PickFirstBalancerName - if rsc.LoadBalancingPolicy != nil { - name = *rsc.LoadBalancingPolicy - } - if balancer.Get(name) == nil { - name = PickFirstBalancerName - } - cfg := []map[string]any{{name: struct{}{}}} - strCfg, err := json.Marshal(cfg) - if err != nil { - return &serviceconfig.ParseResult{Err: fmt.Errorf("unexpected error marshaling simple LB config: %w", err)} - } - r := json.RawMessage(strCfg) - c = &r - } - cfg, err := gracefulswitch.ParseConfig(*c) - if err != nil { - return &serviceconfig.ParseResult{Err: err} - } - sc.lbConfig = cfg - - if rsc.MethodConfig == nil { - return &serviceconfig.ParseResult{Config: &sc} - } - - paths := map[string]struct{}{} - for _, m := range *rsc.MethodConfig { - if m.Name == nil { - continue - } - - mc := MethodConfig{ - WaitForReady: m.WaitForReady, - Timeout: (*time.Duration)(m.Timeout), - } - if mc.RetryPolicy, err = convertRetryPolicy(m.RetryPolicy); err != nil { - logger.Warningf("grpc: unmarshaling service config %s: %v", js, err) - return &serviceconfig.ParseResult{Err: err} - } - if m.MaxRequestMessageBytes != nil { - if *m.MaxRequestMessageBytes > int64(maxInt) { - mc.MaxReqSize = newInt(maxInt) - } else { - mc.MaxReqSize = newInt(int(*m.MaxRequestMessageBytes)) - } - } - if m.MaxResponseMessageBytes != nil { - if *m.MaxResponseMessageBytes > int64(maxInt) { - mc.MaxRespSize = newInt(maxInt) - } else { - mc.MaxRespSize = newInt(int(*m.MaxResponseMessageBytes)) - } - } - for i, n := range *m.Name { - path, err := n.generatePath() - if err != nil { - logger.Warningf("grpc: error unmarshaling service config %s due to methodConfig[%d]: %v", js, i, err) - return &serviceconfig.ParseResult{Err: err} - } - - if _, ok := paths[path]; ok { - err = errDuplicatedName - logger.Warningf("grpc: error unmarshaling service config %s due to methodConfig[%d]: %v", js, i, err) - return &serviceconfig.ParseResult{Err: err} - } - paths[path] = struct{}{} - sc.Methods[path] = mc - } - } - - if sc.retryThrottling != nil { - if mt := sc.retryThrottling.MaxTokens; mt <= 0 || mt > 1000 { - return &serviceconfig.ParseResult{Err: fmt.Errorf("invalid retry throttling config: maxTokens (%v) out of range (0, 1000]", mt)} - } - if tr := sc.retryThrottling.TokenRatio; tr <= 0 { - return &serviceconfig.ParseResult{Err: fmt.Errorf("invalid retry throttling config: tokenRatio (%v) may not be negative", tr)} - } - } - return &serviceconfig.ParseResult{Config: &sc} -} - -func convertRetryPolicy(jrp *jsonRetryPolicy) (p *internalserviceconfig.RetryPolicy, err error) { - if jrp == nil { - return nil, nil - } - - if jrp.MaxAttempts <= 1 || - jrp.InitialBackoff <= 0 || - jrp.MaxBackoff <= 0 || - jrp.BackoffMultiplier <= 0 || - len(jrp.RetryableStatusCodes) == 0 { - logger.Warningf("grpc: ignoring retry policy %v due to illegal configuration", jrp) - return nil, nil - } - - rp := &internalserviceconfig.RetryPolicy{ - MaxAttempts: jrp.MaxAttempts, - InitialBackoff: time.Duration(jrp.InitialBackoff), - MaxBackoff: time.Duration(jrp.MaxBackoff), - BackoffMultiplier: jrp.BackoffMultiplier, - RetryableStatusCodes: make(map[codes.Code]bool), - } - if rp.MaxAttempts > 5 { - // TODO(retry): Make the max maxAttempts configurable. - rp.MaxAttempts = 5 - } - for _, code := range jrp.RetryableStatusCodes { - rp.RetryableStatusCodes[code] = true - } - return rp, nil -} - -func min(a, b *int) *int { - if *a < *b { - return a - } - return b -} - -func getMaxSize(mcMax, doptMax *int, defaultVal int) *int { - if mcMax == nil && doptMax == nil { - return &defaultVal - } - if mcMax != nil && doptMax != nil { - return min(mcMax, doptMax) - } - if mcMax != nil { - return mcMax - } - return doptMax -} - -func newInt(b int) *int { - return &b -} - -func init() { - internal.EqualServiceConfigForTesting = equalServiceConfig -} - -// equalServiceConfig compares two configs. The rawJSONString field is ignored, -// because they may diff in white spaces. -// -// If any of them is NOT *ServiceConfig, return false. -func equalServiceConfig(a, b serviceconfig.Config) bool { - if a == nil && b == nil { - return true - } - aa, ok := a.(*ServiceConfig) - if !ok { - return false - } - bb, ok := b.(*ServiceConfig) - if !ok { - return false - } - aaRaw := aa.rawJSONString - aa.rawJSONString = "" - bbRaw := bb.rawJSONString - bb.rawJSONString = "" - defer func() { - aa.rawJSONString = aaRaw - bb.rawJSONString = bbRaw - }() - // Using reflect.DeepEqual instead of cmp.Equal because many balancer - // configs are unexported, and cmp.Equal cannot compare unexported fields - // from unexported structs. - return reflect.DeepEqual(aa, bb) -} diff --git a/vendor/google.golang.org/grpc/serviceconfig/serviceconfig.go b/vendor/google.golang.org/grpc/serviceconfig/serviceconfig.go deleted file mode 100644 index 35e7a20a0..000000000 --- a/vendor/google.golang.org/grpc/serviceconfig/serviceconfig.go +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package serviceconfig defines types and methods for operating on gRPC -// service configs. -// -// # Experimental -// -// Notice: This package is EXPERIMENTAL and may be changed or removed in a -// later release. -package serviceconfig - -// Config represents an opaque data structure holding a service config. -type Config interface { - isServiceConfig() -} - -// LoadBalancingConfig represents an opaque data structure holding a load -// balancing config. -type LoadBalancingConfig interface { - isLoadBalancingConfig() -} - -// ParseResult contains a service config or an error. Exactly one must be -// non-nil. -type ParseResult struct { - Config Config - Err error -} diff --git a/vendor/google.golang.org/grpc/shared_buffer_pool.go b/vendor/google.golang.org/grpc/shared_buffer_pool.go deleted file mode 100644 index 48a64cfe8..000000000 --- a/vendor/google.golang.org/grpc/shared_buffer_pool.go +++ /dev/null @@ -1,154 +0,0 @@ -/* - * - * Copyright 2023 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpc - -import "sync" - -// SharedBufferPool is a pool of buffers that can be shared, resulting in -// decreased memory allocation. Currently, in gRPC-go, it is only utilized -// for parsing incoming messages. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -type SharedBufferPool interface { - // Get returns a buffer with specified length from the pool. - // - // The returned byte slice may be not zero initialized. - Get(length int) []byte - - // Put returns a buffer to the pool. - Put(*[]byte) -} - -// NewSharedBufferPool creates a simple SharedBufferPool with buckets -// of different sizes to optimize memory usage. This prevents the pool from -// wasting large amounts of memory, even when handling messages of varying sizes. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -func NewSharedBufferPool() SharedBufferPool { - return &simpleSharedBufferPool{ - pools: [poolArraySize]simpleSharedBufferChildPool{ - newBytesPool(level0PoolMaxSize), - newBytesPool(level1PoolMaxSize), - newBytesPool(level2PoolMaxSize), - newBytesPool(level3PoolMaxSize), - newBytesPool(level4PoolMaxSize), - newBytesPool(0), - }, - } -} - -// simpleSharedBufferPool is a simple implementation of SharedBufferPool. -type simpleSharedBufferPool struct { - pools [poolArraySize]simpleSharedBufferChildPool -} - -func (p *simpleSharedBufferPool) Get(size int) []byte { - return p.pools[p.poolIdx(size)].Get(size) -} - -func (p *simpleSharedBufferPool) Put(bs *[]byte) { - p.pools[p.poolIdx(cap(*bs))].Put(bs) -} - -func (p *simpleSharedBufferPool) poolIdx(size int) int { - switch { - case size <= level0PoolMaxSize: - return level0PoolIdx - case size <= level1PoolMaxSize: - return level1PoolIdx - case size <= level2PoolMaxSize: - return level2PoolIdx - case size <= level3PoolMaxSize: - return level3PoolIdx - case size <= level4PoolMaxSize: - return level4PoolIdx - default: - return levelMaxPoolIdx - } -} - -const ( - level0PoolMaxSize = 16 // 16 B - level1PoolMaxSize = level0PoolMaxSize * 16 // 256 B - level2PoolMaxSize = level1PoolMaxSize * 16 // 4 KB - level3PoolMaxSize = level2PoolMaxSize * 16 // 64 KB - level4PoolMaxSize = level3PoolMaxSize * 16 // 1 MB -) - -const ( - level0PoolIdx = iota - level1PoolIdx - level2PoolIdx - level3PoolIdx - level4PoolIdx - levelMaxPoolIdx - poolArraySize -) - -type simpleSharedBufferChildPool interface { - Get(size int) []byte - Put(any) -} - -type bufferPool struct { - sync.Pool - - defaultSize int -} - -func (p *bufferPool) Get(size int) []byte { - bs := p.Pool.Get().(*[]byte) - - if cap(*bs) < size { - p.Pool.Put(bs) - - return make([]byte, size) - } - - return (*bs)[:size] -} - -func newBytesPool(size int) simpleSharedBufferChildPool { - return &bufferPool{ - Pool: sync.Pool{ - New: func() any { - bs := make([]byte, size) - return &bs - }, - }, - defaultSize: size, - } -} - -// nopBufferPool is a buffer pool just makes new buffer without pooling. -type nopBufferPool struct { -} - -func (nopBufferPool) Get(length int) []byte { - return make([]byte, length) -} - -func (nopBufferPool) Put(*[]byte) { -} diff --git a/vendor/google.golang.org/grpc/stats/handlers.go b/vendor/google.golang.org/grpc/stats/handlers.go deleted file mode 100644 index dc03731e4..000000000 --- a/vendor/google.golang.org/grpc/stats/handlers.go +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package stats - -import ( - "context" - "net" -) - -// ConnTagInfo defines the relevant information needed by connection context tagger. -type ConnTagInfo struct { - // RemoteAddr is the remote address of the corresponding connection. - RemoteAddr net.Addr - // LocalAddr is the local address of the corresponding connection. - LocalAddr net.Addr -} - -// RPCTagInfo defines the relevant information needed by RPC context tagger. -type RPCTagInfo struct { - // FullMethodName is the RPC method in the format of /package.service/method. - FullMethodName string - // FailFast indicates if this RPC is failfast. - // This field is only valid on client side, it's always false on server side. - FailFast bool -} - -// Handler defines the interface for the related stats handling (e.g., RPCs, connections). -type Handler interface { - // TagRPC can attach some information to the given context. - // The context used for the rest lifetime of the RPC will be derived from - // the returned context. - TagRPC(context.Context, *RPCTagInfo) context.Context - // HandleRPC processes the RPC stats. - HandleRPC(context.Context, RPCStats) - - // TagConn can attach some information to the given context. - // The returned context will be used for stats handling. - // For conn stats handling, the context used in HandleConn for this - // connection will be derived from the context returned. - // For RPC stats handling, - // - On server side, the context used in HandleRPC for all RPCs on this - // connection will be derived from the context returned. - // - On client side, the context is not derived from the context returned. - TagConn(context.Context, *ConnTagInfo) context.Context - // HandleConn processes the Conn stats. - HandleConn(context.Context, ConnStats) -} diff --git a/vendor/google.golang.org/grpc/stats/stats.go b/vendor/google.golang.org/grpc/stats/stats.go deleted file mode 100644 index 4ab70e2d4..000000000 --- a/vendor/google.golang.org/grpc/stats/stats.go +++ /dev/null @@ -1,343 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package stats is for collecting and reporting various network and RPC stats. -// This package is for monitoring purpose only. All fields are read-only. -// All APIs are experimental. -package stats // import "google.golang.org/grpc/stats" - -import ( - "context" - "net" - "time" - - "google.golang.org/grpc/metadata" -) - -// RPCStats contains stats information about RPCs. -type RPCStats interface { - isRPCStats() - // IsClient returns true if this RPCStats is from client side. - IsClient() bool -} - -// Begin contains stats when an RPC attempt begins. -// FailFast is only valid if this Begin is from client side. -type Begin struct { - // Client is true if this Begin is from client side. - Client bool - // BeginTime is the time when the RPC attempt begins. - BeginTime time.Time - // FailFast indicates if this RPC is failfast. - FailFast bool - // IsClientStream indicates whether the RPC is a client streaming RPC. - IsClientStream bool - // IsServerStream indicates whether the RPC is a server streaming RPC. - IsServerStream bool - // IsTransparentRetryAttempt indicates whether this attempt was initiated - // due to transparently retrying a previous attempt. - IsTransparentRetryAttempt bool -} - -// IsClient indicates if the stats information is from client side. -func (s *Begin) IsClient() bool { return s.Client } - -func (s *Begin) isRPCStats() {} - -// PickerUpdated indicates that the LB policy provided a new picker while the -// RPC was waiting for one. -type PickerUpdated struct{} - -// IsClient indicates if the stats information is from client side. Only Client -// Side interfaces with a Picker, thus always returns true. -func (*PickerUpdated) IsClient() bool { return true } - -func (*PickerUpdated) isRPCStats() {} - -// InPayload contains the information for an incoming payload. -type InPayload struct { - // Client is true if this InPayload is from client side. - Client bool - // Payload is the payload with original type. - Payload any - // Data is the serialized message payload. - Data []byte - - // Length is the size of the uncompressed payload data. Does not include any - // framing (gRPC or HTTP/2). - Length int - // CompressedLength is the size of the compressed payload data. Does not - // include any framing (gRPC or HTTP/2). Same as Length if compression not - // enabled. - CompressedLength int - // WireLength is the size of the compressed payload data plus gRPC framing. - // Does not include HTTP/2 framing. - WireLength int - - // RecvTime is the time when the payload is received. - RecvTime time.Time -} - -// IsClient indicates if the stats information is from client side. -func (s *InPayload) IsClient() bool { return s.Client } - -func (s *InPayload) isRPCStats() {} - -// InHeader contains stats when a header is received. -type InHeader struct { - // Client is true if this InHeader is from client side. - Client bool - // WireLength is the wire length of header. - WireLength int - // Compression is the compression algorithm used for the RPC. - Compression string - // Header contains the header metadata received. - Header metadata.MD - - // The following fields are valid only if Client is false. - // FullMethod is the full RPC method string, i.e., /package.service/method. - FullMethod string - // RemoteAddr is the remote address of the corresponding connection. - RemoteAddr net.Addr - // LocalAddr is the local address of the corresponding connection. - LocalAddr net.Addr -} - -// IsClient indicates if the stats information is from client side. -func (s *InHeader) IsClient() bool { return s.Client } - -func (s *InHeader) isRPCStats() {} - -// InTrailer contains stats when a trailer is received. -type InTrailer struct { - // Client is true if this InTrailer is from client side. - Client bool - // WireLength is the wire length of trailer. - WireLength int - // Trailer contains the trailer metadata received from the server. This - // field is only valid if this InTrailer is from the client side. - Trailer metadata.MD -} - -// IsClient indicates if the stats information is from client side. -func (s *InTrailer) IsClient() bool { return s.Client } - -func (s *InTrailer) isRPCStats() {} - -// OutPayload contains the information for an outgoing payload. -type OutPayload struct { - // Client is true if this OutPayload is from client side. - Client bool - // Payload is the payload with original type. - Payload any - // Data is the serialized message payload. - Data []byte - // Length is the size of the uncompressed payload data. Does not include any - // framing (gRPC or HTTP/2). - Length int - // CompressedLength is the size of the compressed payload data. Does not - // include any framing (gRPC or HTTP/2). Same as Length if compression not - // enabled. - CompressedLength int - // WireLength is the size of the compressed payload data plus gRPC framing. - // Does not include HTTP/2 framing. - WireLength int - // SentTime is the time when the payload is sent. - SentTime time.Time -} - -// IsClient indicates if this stats information is from client side. -func (s *OutPayload) IsClient() bool { return s.Client } - -func (s *OutPayload) isRPCStats() {} - -// OutHeader contains stats when a header is sent. -type OutHeader struct { - // Client is true if this OutHeader is from client side. - Client bool - // Compression is the compression algorithm used for the RPC. - Compression string - // Header contains the header metadata sent. - Header metadata.MD - - // The following fields are valid only if Client is true. - // FullMethod is the full RPC method string, i.e., /package.service/method. - FullMethod string - // RemoteAddr is the remote address of the corresponding connection. - RemoteAddr net.Addr - // LocalAddr is the local address of the corresponding connection. - LocalAddr net.Addr -} - -// IsClient indicates if this stats information is from client side. -func (s *OutHeader) IsClient() bool { return s.Client } - -func (s *OutHeader) isRPCStats() {} - -// OutTrailer contains stats when a trailer is sent. -type OutTrailer struct { - // Client is true if this OutTrailer is from client side. - Client bool - // WireLength is the wire length of trailer. - // - // Deprecated: This field is never set. The length is not known when this message is - // emitted because the trailer fields are compressed with hpack after that. - WireLength int - // Trailer contains the trailer metadata sent to the client. This - // field is only valid if this OutTrailer is from the server side. - Trailer metadata.MD -} - -// IsClient indicates if this stats information is from client side. -func (s *OutTrailer) IsClient() bool { return s.Client } - -func (s *OutTrailer) isRPCStats() {} - -// End contains stats when an RPC ends. -type End struct { - // Client is true if this End is from client side. - Client bool - // BeginTime is the time when the RPC began. - BeginTime time.Time - // EndTime is the time when the RPC ends. - EndTime time.Time - // Trailer contains the trailer metadata received from the server. This - // field is only valid if this End is from the client side. - // Deprecated: use Trailer in InTrailer instead. - Trailer metadata.MD - // Error is the error the RPC ended with. It is an error generated from - // status.Status and can be converted back to status.Status using - // status.FromError if non-nil. - Error error -} - -// IsClient indicates if this is from client side. -func (s *End) IsClient() bool { return s.Client } - -func (s *End) isRPCStats() {} - -// ConnStats contains stats information about connections. -type ConnStats interface { - isConnStats() - // IsClient returns true if this ConnStats is from client side. - IsClient() bool -} - -// ConnBegin contains the stats of a connection when it is established. -type ConnBegin struct { - // Client is true if this ConnBegin is from client side. - Client bool -} - -// IsClient indicates if this is from client side. -func (s *ConnBegin) IsClient() bool { return s.Client } - -func (s *ConnBegin) isConnStats() {} - -// ConnEnd contains the stats of a connection when it ends. -type ConnEnd struct { - // Client is true if this ConnEnd is from client side. - Client bool -} - -// IsClient indicates if this is from client side. -func (s *ConnEnd) IsClient() bool { return s.Client } - -func (s *ConnEnd) isConnStats() {} - -type incomingTagsKey struct{} -type outgoingTagsKey struct{} - -// SetTags attaches stats tagging data to the context, which will be sent in -// the outgoing RPC with the header grpc-tags-bin. Subsequent calls to -// SetTags will overwrite the values from earlier calls. -// -// NOTE: this is provided only for backward compatibility with existing clients -// and will likely be removed in an upcoming release. New uses should transmit -// this type of data using metadata with a different, non-reserved (i.e. does -// not begin with "grpc-") header name. -func SetTags(ctx context.Context, b []byte) context.Context { - return context.WithValue(ctx, outgoingTagsKey{}, b) -} - -// Tags returns the tags from the context for the inbound RPC. -// -// NOTE: this is provided only for backward compatibility with existing clients -// and will likely be removed in an upcoming release. New uses should transmit -// this type of data using metadata with a different, non-reserved (i.e. does -// not begin with "grpc-") header name. -func Tags(ctx context.Context) []byte { - b, _ := ctx.Value(incomingTagsKey{}).([]byte) - return b -} - -// SetIncomingTags attaches stats tagging data to the context, to be read by -// the application (not sent in outgoing RPCs). -// -// This is intended for gRPC-internal use ONLY. -func SetIncomingTags(ctx context.Context, b []byte) context.Context { - return context.WithValue(ctx, incomingTagsKey{}, b) -} - -// OutgoingTags returns the tags from the context for the outbound RPC. -// -// This is intended for gRPC-internal use ONLY. -func OutgoingTags(ctx context.Context) []byte { - b, _ := ctx.Value(outgoingTagsKey{}).([]byte) - return b -} - -type incomingTraceKey struct{} -type outgoingTraceKey struct{} - -// SetTrace attaches stats tagging data to the context, which will be sent in -// the outgoing RPC with the header grpc-trace-bin. Subsequent calls to -// SetTrace will overwrite the values from earlier calls. -// -// NOTE: this is provided only for backward compatibility with existing clients -// and will likely be removed in an upcoming release. New uses should transmit -// this type of data using metadata with a different, non-reserved (i.e. does -// not begin with "grpc-") header name. -func SetTrace(ctx context.Context, b []byte) context.Context { - return context.WithValue(ctx, outgoingTraceKey{}, b) -} - -// Trace returns the trace from the context for the inbound RPC. -// -// NOTE: this is provided only for backward compatibility with existing clients -// and will likely be removed in an upcoming release. New uses should transmit -// this type of data using metadata with a different, non-reserved (i.e. does -// not begin with "grpc-") header name. -func Trace(ctx context.Context) []byte { - b, _ := ctx.Value(incomingTraceKey{}).([]byte) - return b -} - -// SetIncomingTrace attaches stats tagging data to the context, to be read by -// the application (not sent in outgoing RPCs). It is intended for -// gRPC-internal use. -func SetIncomingTrace(ctx context.Context, b []byte) context.Context { - return context.WithValue(ctx, incomingTraceKey{}, b) -} - -// OutgoingTrace returns the trace from the context for the outbound RPC. It is -// intended for gRPC-internal use. -func OutgoingTrace(ctx context.Context) []byte { - b, _ := ctx.Value(outgoingTraceKey{}).([]byte) - return b -} diff --git a/vendor/google.golang.org/grpc/status/status.go b/vendor/google.golang.org/grpc/status/status.go deleted file mode 100644 index a93360efb..000000000 --- a/vendor/google.golang.org/grpc/status/status.go +++ /dev/null @@ -1,162 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package status implements errors returned by gRPC. These errors are -// serialized and transmitted on the wire between server and client, and allow -// for additional data to be transmitted via the Details field in the status -// proto. gRPC service handlers should return an error created by this -// package, and gRPC clients should expect a corresponding error to be -// returned from the RPC call. -// -// This package upholds the invariants that a non-nil error may not -// contain an OK code, and an OK code must result in a nil error. -package status - -import ( - "context" - "errors" - "fmt" - - spb "google.golang.org/genproto/googleapis/rpc/status" - - "google.golang.org/grpc/codes" - "google.golang.org/grpc/internal/status" -) - -// Status references google.golang.org/grpc/internal/status. It represents an -// RPC status code, message, and details. It is immutable and should be -// created with New, Newf, or FromProto. -// https://godoc.org/google.golang.org/grpc/internal/status -type Status = status.Status - -// New returns a Status representing c and msg. -func New(c codes.Code, msg string) *Status { - return status.New(c, msg) -} - -// Newf returns New(c, fmt.Sprintf(format, a...)). -func Newf(c codes.Code, format string, a ...any) *Status { - return New(c, fmt.Sprintf(format, a...)) -} - -// Error returns an error representing c and msg. If c is OK, returns nil. -func Error(c codes.Code, msg string) error { - return New(c, msg).Err() -} - -// Errorf returns Error(c, fmt.Sprintf(format, a...)). -func Errorf(c codes.Code, format string, a ...any) error { - return Error(c, fmt.Sprintf(format, a...)) -} - -// ErrorProto returns an error representing s. If s.Code is OK, returns nil. -func ErrorProto(s *spb.Status) error { - return FromProto(s).Err() -} - -// FromProto returns a Status representing s. -func FromProto(s *spb.Status) *Status { - return status.FromProto(s) -} - -// FromError returns a Status representation of err. -// -// - If err was produced by this package or implements the method `GRPCStatus() -// *Status` and `GRPCStatus()` does not return nil, or if err wraps a type -// satisfying this, the Status from `GRPCStatus()` is returned. For wrapped -// errors, the message returned contains the entire err.Error() text and not -// just the wrapped status. In that case, ok is true. -// -// - If err is nil, a Status is returned with codes.OK and no message, and ok -// is true. -// -// - If err implements the method `GRPCStatus() *Status` and `GRPCStatus()` -// returns nil (which maps to Codes.OK), or if err wraps a type -// satisfying this, a Status is returned with codes.Unknown and err's -// Error() message, and ok is false. -// -// - Otherwise, err is an error not compatible with this package. In this -// case, a Status is returned with codes.Unknown and err's Error() message, -// and ok is false. -func FromError(err error) (s *Status, ok bool) { - if err == nil { - return nil, true - } - type grpcstatus interface{ GRPCStatus() *Status } - if gs, ok := err.(grpcstatus); ok { - grpcStatus := gs.GRPCStatus() - if grpcStatus == nil { - // Error has status nil, which maps to codes.OK. There - // is no sensible behavior for this, so we turn it into - // an error with codes.Unknown and discard the existing - // status. - return New(codes.Unknown, err.Error()), false - } - return grpcStatus, true - } - var gs grpcstatus - if errors.As(err, &gs) { - grpcStatus := gs.GRPCStatus() - if grpcStatus == nil { - // Error wraps an error that has status nil, which maps - // to codes.OK. There is no sensible behavior for this, - // so we turn it into an error with codes.Unknown and - // discard the existing status. - return New(codes.Unknown, err.Error()), false - } - p := grpcStatus.Proto() - p.Message = err.Error() - return status.FromProto(p), true - } - return New(codes.Unknown, err.Error()), false -} - -// Convert is a convenience function which removes the need to handle the -// boolean return value from FromError. -func Convert(err error) *Status { - s, _ := FromError(err) - return s -} - -// Code returns the Code of the error if it is a Status error or if it wraps a -// Status error. If that is not the case, it returns codes.OK if err is nil, or -// codes.Unknown otherwise. -func Code(err error) codes.Code { - // Don't use FromError to avoid allocation of OK status. - if err == nil { - return codes.OK - } - - return Convert(err).Code() -} - -// FromContextError converts a context error or wrapped context error into a -// Status. It returns a Status with codes.OK if err is nil, or a Status with -// codes.Unknown if err is non-nil and not a context error. -func FromContextError(err error) *Status { - if err == nil { - return nil - } - if errors.Is(err, context.DeadlineExceeded) { - return New(codes.DeadlineExceeded, err.Error()) - } - if errors.Is(err, context.Canceled) { - return New(codes.Canceled, err.Error()) - } - return New(codes.Unknown, err.Error()) -} diff --git a/vendor/google.golang.org/grpc/stream.go b/vendor/google.golang.org/grpc/stream.go deleted file mode 100644 index d939ffc63..000000000 --- a/vendor/google.golang.org/grpc/stream.go +++ /dev/null @@ -1,1781 +0,0 @@ -/* - * - * Copyright 2014 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpc - -import ( - "context" - "errors" - "io" - "math" - "strconv" - "sync" - "time" - - "google.golang.org/grpc/balancer" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/encoding" - "google.golang.org/grpc/internal" - "google.golang.org/grpc/internal/balancerload" - "google.golang.org/grpc/internal/binarylog" - "google.golang.org/grpc/internal/channelz" - "google.golang.org/grpc/internal/grpcrand" - "google.golang.org/grpc/internal/grpcutil" - imetadata "google.golang.org/grpc/internal/metadata" - iresolver "google.golang.org/grpc/internal/resolver" - "google.golang.org/grpc/internal/serviceconfig" - istatus "google.golang.org/grpc/internal/status" - "google.golang.org/grpc/internal/transport" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/peer" - "google.golang.org/grpc/stats" - "google.golang.org/grpc/status" -) - -var metadataFromOutgoingContextRaw = internal.FromOutgoingContextRaw.(func(context.Context) (metadata.MD, [][]string, bool)) - -// StreamHandler defines the handler called by gRPC server to complete the -// execution of a streaming RPC. -// -// If a StreamHandler returns an error, it should either be produced by the -// status package, or be one of the context errors. Otherwise, gRPC will use -// codes.Unknown as the status code and err.Error() as the status message of the -// RPC. -type StreamHandler func(srv any, stream ServerStream) error - -// StreamDesc represents a streaming RPC service's method specification. Used -// on the server when registering services and on the client when initiating -// new streams. -type StreamDesc struct { - // StreamName and Handler are only used when registering handlers on a - // server. - StreamName string // the name of the method excluding the service - Handler StreamHandler // the handler called for the method - - // ServerStreams and ClientStreams are used for registering handlers on a - // server as well as defining RPC behavior when passed to NewClientStream - // and ClientConn.NewStream. At least one must be true. - ServerStreams bool // indicates the server can perform streaming sends - ClientStreams bool // indicates the client can perform streaming sends -} - -// Stream defines the common interface a client or server stream has to satisfy. -// -// Deprecated: See ClientStream and ServerStream documentation instead. -type Stream interface { - // Deprecated: See ClientStream and ServerStream documentation instead. - Context() context.Context - // Deprecated: See ClientStream and ServerStream documentation instead. - SendMsg(m any) error - // Deprecated: See ClientStream and ServerStream documentation instead. - RecvMsg(m any) error -} - -// ClientStream defines the client-side behavior of a streaming RPC. -// -// All errors returned from ClientStream methods are compatible with the -// status package. -type ClientStream interface { - // Header returns the header metadata received from the server if there - // is any. It blocks if the metadata is not ready to read. If the metadata - // is nil and the error is also nil, then the stream was terminated without - // headers, and the status can be discovered by calling RecvMsg. - Header() (metadata.MD, error) - // Trailer returns the trailer metadata from the server, if there is any. - // It must only be called after stream.CloseAndRecv has returned, or - // stream.Recv has returned a non-nil error (including io.EOF). - Trailer() metadata.MD - // CloseSend closes the send direction of the stream. It closes the stream - // when non-nil error is met. It is also not safe to call CloseSend - // concurrently with SendMsg. - CloseSend() error - // Context returns the context for this stream. - // - // It should not be called until after Header or RecvMsg has returned. Once - // called, subsequent client-side retries are disabled. - Context() context.Context - // SendMsg is generally called by generated code. On error, SendMsg aborts - // the stream. If the error was generated by the client, the status is - // returned directly; otherwise, io.EOF is returned and the status of - // the stream may be discovered using RecvMsg. - // - // SendMsg blocks until: - // - There is sufficient flow control to schedule m with the transport, or - // - The stream is done, or - // - The stream breaks. - // - // SendMsg does not wait until the message is received by the server. An - // untimely stream closure may result in lost messages. To ensure delivery, - // users should ensure the RPC completed successfully using RecvMsg. - // - // It is safe to have a goroutine calling SendMsg and another goroutine - // calling RecvMsg on the same stream at the same time, but it is not safe - // to call SendMsg on the same stream in different goroutines. It is also - // not safe to call CloseSend concurrently with SendMsg. - // - // It is not safe to modify the message after calling SendMsg. Tracing - // libraries and stats handlers may use the message lazily. - SendMsg(m any) error - // RecvMsg blocks until it receives a message into m or the stream is - // done. It returns io.EOF when the stream completes successfully. On - // any other error, the stream is aborted and the error contains the RPC - // status. - // - // It is safe to have a goroutine calling SendMsg and another goroutine - // calling RecvMsg on the same stream at the same time, but it is not - // safe to call RecvMsg on the same stream in different goroutines. - RecvMsg(m any) error -} - -// NewStream creates a new Stream for the client side. This is typically -// called by generated code. ctx is used for the lifetime of the stream. -// -// To ensure resources are not leaked due to the stream returned, one of the following -// actions must be performed: -// -// 1. Call Close on the ClientConn. -// 2. Cancel the context provided. -// 3. Call RecvMsg until a non-nil error is returned. A protobuf-generated -// client-streaming RPC, for instance, might use the helper function -// CloseAndRecv (note that CloseSend does not Recv, therefore is not -// guaranteed to release all resources). -// 4. Receive a non-nil, non-io.EOF error from Header or SendMsg. -// -// If none of the above happen, a goroutine and a context will be leaked, and grpc -// will not call the optionally-configured stats handler with a stats.End message. -func (cc *ClientConn) NewStream(ctx context.Context, desc *StreamDesc, method string, opts ...CallOption) (ClientStream, error) { - // allow interceptor to see all applicable call options, which means those - // configured as defaults from dial option as well as per-call options - opts = combine(cc.dopts.callOptions, opts) - - if cc.dopts.streamInt != nil { - return cc.dopts.streamInt(ctx, desc, cc, method, newClientStream, opts...) - } - return newClientStream(ctx, desc, cc, method, opts...) -} - -// NewClientStream is a wrapper for ClientConn.NewStream. -func NewClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, opts ...CallOption) (ClientStream, error) { - return cc.NewStream(ctx, desc, method, opts...) -} - -func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, opts ...CallOption) (_ ClientStream, err error) { - // Start tracking the RPC for idleness purposes. This is where a stream is - // created for both streaming and unary RPCs, and hence is a good place to - // track active RPC count. - if err := cc.idlenessMgr.OnCallBegin(); err != nil { - return nil, err - } - // Add a calloption, to decrement the active call count, that gets executed - // when the RPC completes. - opts = append([]CallOption{OnFinish(func(error) { cc.idlenessMgr.OnCallEnd() })}, opts...) - - if md, added, ok := metadataFromOutgoingContextRaw(ctx); ok { - // validate md - if err := imetadata.Validate(md); err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - // validate added - for _, kvs := range added { - for i := 0; i < len(kvs); i += 2 { - if err := imetadata.ValidatePair(kvs[i], kvs[i+1]); err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - } - } - } - if channelz.IsOn() { - cc.incrCallsStarted() - defer func() { - if err != nil { - cc.incrCallsFailed() - } - }() - } - // Provide an opportunity for the first RPC to see the first service config - // provided by the resolver. - if err := cc.waitForResolvedAddrs(ctx); err != nil { - return nil, err - } - - var mc serviceconfig.MethodConfig - var onCommit func() - var newStream = func(ctx context.Context, done func()) (iresolver.ClientStream, error) { - return newClientStreamWithParams(ctx, desc, cc, method, mc, onCommit, done, opts...) - } - - rpcInfo := iresolver.RPCInfo{Context: ctx, Method: method} - rpcConfig, err := cc.safeConfigSelector.SelectConfig(rpcInfo) - if err != nil { - if st, ok := status.FromError(err); ok { - // Restrict the code to the list allowed by gRFC A54. - if istatus.IsRestrictedControlPlaneCode(st) { - err = status.Errorf(codes.Internal, "config selector returned illegal status: %v", err) - } - return nil, err - } - return nil, toRPCErr(err) - } - - if rpcConfig != nil { - if rpcConfig.Context != nil { - ctx = rpcConfig.Context - } - mc = rpcConfig.MethodConfig - onCommit = rpcConfig.OnCommitted - if rpcConfig.Interceptor != nil { - rpcInfo.Context = nil - ns := newStream - newStream = func(ctx context.Context, done func()) (iresolver.ClientStream, error) { - cs, err := rpcConfig.Interceptor.NewStream(ctx, rpcInfo, done, ns) - if err != nil { - return nil, toRPCErr(err) - } - return cs, nil - } - } - } - - return newStream(ctx, func() {}) -} - -func newClientStreamWithParams(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, mc serviceconfig.MethodConfig, onCommit, doneFunc func(), opts ...CallOption) (_ iresolver.ClientStream, err error) { - c := defaultCallInfo() - if mc.WaitForReady != nil { - c.failFast = !*mc.WaitForReady - } - - // Possible context leak: - // The cancel function for the child context we create will only be called - // when RecvMsg returns a non-nil error, if the ClientConn is closed, or if - // an error is generated by SendMsg. - // https://github.com/grpc/grpc-go/issues/1818. - var cancel context.CancelFunc - if mc.Timeout != nil && *mc.Timeout >= 0 { - ctx, cancel = context.WithTimeout(ctx, *mc.Timeout) - } else { - ctx, cancel = context.WithCancel(ctx) - } - defer func() { - if err != nil { - cancel() - } - }() - - for _, o := range opts { - if err := o.before(c); err != nil { - return nil, toRPCErr(err) - } - } - c.maxSendMessageSize = getMaxSize(mc.MaxReqSize, c.maxSendMessageSize, defaultClientMaxSendMessageSize) - c.maxReceiveMessageSize = getMaxSize(mc.MaxRespSize, c.maxReceiveMessageSize, defaultClientMaxReceiveMessageSize) - if err := setCallInfoCodec(c); err != nil { - return nil, err - } - - callHdr := &transport.CallHdr{ - Host: cc.authority, - Method: method, - ContentSubtype: c.contentSubtype, - DoneFunc: doneFunc, - } - - // Set our outgoing compression according to the UseCompressor CallOption, if - // set. In that case, also find the compressor from the encoding package. - // Otherwise, use the compressor configured by the WithCompressor DialOption, - // if set. - var cp Compressor - var comp encoding.Compressor - if ct := c.compressorType; ct != "" { - callHdr.SendCompress = ct - if ct != encoding.Identity { - comp = encoding.GetCompressor(ct) - if comp == nil { - return nil, status.Errorf(codes.Internal, "grpc: Compressor is not installed for requested grpc-encoding %q", ct) - } - } - } else if cc.dopts.cp != nil { - callHdr.SendCompress = cc.dopts.cp.Type() - cp = cc.dopts.cp - } - if c.creds != nil { - callHdr.Creds = c.creds - } - - cs := &clientStream{ - callHdr: callHdr, - ctx: ctx, - methodConfig: &mc, - opts: opts, - callInfo: c, - cc: cc, - desc: desc, - codec: c.codec, - cp: cp, - comp: comp, - cancel: cancel, - firstAttempt: true, - onCommit: onCommit, - } - if !cc.dopts.disableRetry { - cs.retryThrottler = cc.retryThrottler.Load().(*retryThrottler) - } - if ml := binarylog.GetMethodLogger(method); ml != nil { - cs.binlogs = append(cs.binlogs, ml) - } - if cc.dopts.binaryLogger != nil { - if ml := cc.dopts.binaryLogger.GetMethodLogger(method); ml != nil { - cs.binlogs = append(cs.binlogs, ml) - } - } - - // Pick the transport to use and create a new stream on the transport. - // Assign cs.attempt upon success. - op := func(a *csAttempt) error { - if err := a.getTransport(); err != nil { - return err - } - if err := a.newStream(); err != nil { - return err - } - // Because this operation is always called either here (while creating - // the clientStream) or by the retry code while locked when replaying - // the operation, it is safe to access cs.attempt directly. - cs.attempt = a - return nil - } - if err := cs.withRetry(op, func() { cs.bufferForRetryLocked(0, op) }); err != nil { - return nil, err - } - - if len(cs.binlogs) != 0 { - md, _ := metadata.FromOutgoingContext(ctx) - logEntry := &binarylog.ClientHeader{ - OnClientSide: true, - Header: md, - MethodName: method, - Authority: cs.cc.authority, - } - if deadline, ok := ctx.Deadline(); ok { - logEntry.Timeout = time.Until(deadline) - if logEntry.Timeout < 0 { - logEntry.Timeout = 0 - } - } - for _, binlog := range cs.binlogs { - binlog.Log(cs.ctx, logEntry) - } - } - - if desc != unaryStreamDesc { - // Listen on cc and stream contexts to cleanup when the user closes the - // ClientConn or cancels the stream context. In all other cases, an error - // should already be injected into the recv buffer by the transport, which - // the client will eventually receive, and then we will cancel the stream's - // context in clientStream.finish. - go func() { - select { - case <-cc.ctx.Done(): - cs.finish(ErrClientConnClosing) - case <-ctx.Done(): - cs.finish(toRPCErr(ctx.Err())) - } - }() - } - return cs, nil -} - -// newAttemptLocked creates a new csAttempt without a transport or stream. -func (cs *clientStream) newAttemptLocked(isTransparent bool) (*csAttempt, error) { - if err := cs.ctx.Err(); err != nil { - return nil, toRPCErr(err) - } - if err := cs.cc.ctx.Err(); err != nil { - return nil, ErrClientConnClosing - } - - ctx := newContextWithRPCInfo(cs.ctx, cs.callInfo.failFast, cs.callInfo.codec, cs.cp, cs.comp) - method := cs.callHdr.Method - var beginTime time.Time - shs := cs.cc.dopts.copts.StatsHandlers - for _, sh := range shs { - ctx = sh.TagRPC(ctx, &stats.RPCTagInfo{FullMethodName: method, FailFast: cs.callInfo.failFast}) - beginTime = time.Now() - begin := &stats.Begin{ - Client: true, - BeginTime: beginTime, - FailFast: cs.callInfo.failFast, - IsClientStream: cs.desc.ClientStreams, - IsServerStream: cs.desc.ServerStreams, - IsTransparentRetryAttempt: isTransparent, - } - sh.HandleRPC(ctx, begin) - } - - var trInfo *traceInfo - if EnableTracing { - trInfo = &traceInfo{ - tr: newTrace("grpc.Sent."+methodFamily(method), method), - firstLine: firstLine{ - client: true, - }, - } - if deadline, ok := ctx.Deadline(); ok { - trInfo.firstLine.deadline = time.Until(deadline) - } - trInfo.tr.LazyLog(&trInfo.firstLine, false) - ctx = newTraceContext(ctx, trInfo.tr) - } - - if cs.cc.parsedTarget.URL.Scheme == internal.GRPCResolverSchemeExtraMetadata { - // Add extra metadata (metadata that will be added by transport) to context - // so the balancer can see them. - ctx = grpcutil.WithExtraMetadata(ctx, metadata.Pairs( - "content-type", grpcutil.ContentType(cs.callHdr.ContentSubtype), - )) - } - - return &csAttempt{ - ctx: ctx, - beginTime: beginTime, - cs: cs, - dc: cs.cc.dopts.dc, - statsHandlers: shs, - trInfo: trInfo, - }, nil -} - -func (a *csAttempt) getTransport() error { - cs := a.cs - - var err error - a.t, a.pickResult, err = cs.cc.getTransport(a.ctx, cs.callInfo.failFast, cs.callHdr.Method) - if err != nil { - if de, ok := err.(dropError); ok { - err = de.error - a.drop = true - } - return err - } - if a.trInfo != nil { - a.trInfo.firstLine.SetRemoteAddr(a.t.RemoteAddr()) - } - return nil -} - -func (a *csAttempt) newStream() error { - cs := a.cs - cs.callHdr.PreviousAttempts = cs.numRetries - - // Merge metadata stored in PickResult, if any, with existing call metadata. - // It is safe to overwrite the csAttempt's context here, since all state - // maintained in it are local to the attempt. When the attempt has to be - // retried, a new instance of csAttempt will be created. - if a.pickResult.Metadata != nil { - // We currently do not have a function it the metadata package which - // merges given metadata with existing metadata in a context. Existing - // function `AppendToOutgoingContext()` takes a variadic argument of key - // value pairs. - // - // TODO: Make it possible to retrieve key value pairs from metadata.MD - // in a form passable to AppendToOutgoingContext(), or create a version - // of AppendToOutgoingContext() that accepts a metadata.MD. - md, _ := metadata.FromOutgoingContext(a.ctx) - md = metadata.Join(md, a.pickResult.Metadata) - a.ctx = metadata.NewOutgoingContext(a.ctx, md) - } - - s, err := a.t.NewStream(a.ctx, cs.callHdr) - if err != nil { - nse, ok := err.(*transport.NewStreamError) - if !ok { - // Unexpected. - return err - } - - if nse.AllowTransparentRetry { - a.allowTransparentRetry = true - } - - // Unwrap and convert error. - return toRPCErr(nse.Err) - } - a.s = s - a.p = &parser{r: s, recvBufferPool: a.cs.cc.dopts.recvBufferPool} - return nil -} - -// clientStream implements a client side Stream. -type clientStream struct { - callHdr *transport.CallHdr - opts []CallOption - callInfo *callInfo - cc *ClientConn - desc *StreamDesc - - codec baseCodec - cp Compressor - comp encoding.Compressor - - cancel context.CancelFunc // cancels all attempts - - sentLast bool // sent an end stream - - methodConfig *MethodConfig - - ctx context.Context // the application's context, wrapped by stats/tracing - - retryThrottler *retryThrottler // The throttler active when the RPC began. - - binlogs []binarylog.MethodLogger - // serverHeaderBinlogged is a boolean for whether server header has been - // logged. Server header will be logged when the first time one of those - // happens: stream.Header(), stream.Recv(). - // - // It's only read and used by Recv() and Header(), so it doesn't need to be - // synchronized. - serverHeaderBinlogged bool - - mu sync.Mutex - firstAttempt bool // if true, transparent retry is valid - numRetries int // exclusive of transparent retry attempt(s) - numRetriesSincePushback int // retries since pushback; to reset backoff - finished bool // TODO: replace with atomic cmpxchg or sync.Once? - // attempt is the active client stream attempt. - // The only place where it is written is the newAttemptLocked method and this method never writes nil. - // So, attempt can be nil only inside newClientStream function when clientStream is first created. - // One of the first things done after clientStream's creation, is to call newAttemptLocked which either - // assigns a non nil value to the attempt or returns an error. If an error is returned from newAttemptLocked, - // then newClientStream calls finish on the clientStream and returns. So, finish method is the only - // place where we need to check if the attempt is nil. - attempt *csAttempt - // TODO(hedging): hedging will have multiple attempts simultaneously. - committed bool // active attempt committed for retry? - onCommit func() - buffer []func(a *csAttempt) error // operations to replay on retry - bufferSize int // current size of buffer -} - -// csAttempt implements a single transport stream attempt within a -// clientStream. -type csAttempt struct { - ctx context.Context - cs *clientStream - t transport.ClientTransport - s *transport.Stream - p *parser - pickResult balancer.PickResult - - finished bool - dc Decompressor - decomp encoding.Compressor - decompSet bool - - mu sync.Mutex // guards trInfo.tr - // trInfo may be nil (if EnableTracing is false). - // trInfo.tr is set when created (if EnableTracing is true), - // and cleared when the finish method is called. - trInfo *traceInfo - - statsHandlers []stats.Handler - beginTime time.Time - - // set for newStream errors that may be transparently retried - allowTransparentRetry bool - // set for pick errors that are returned as a status - drop bool -} - -func (cs *clientStream) commitAttemptLocked() { - if !cs.committed && cs.onCommit != nil { - cs.onCommit() - } - cs.committed = true - cs.buffer = nil -} - -func (cs *clientStream) commitAttempt() { - cs.mu.Lock() - cs.commitAttemptLocked() - cs.mu.Unlock() -} - -// shouldRetry returns nil if the RPC should be retried; otherwise it returns -// the error that should be returned by the operation. If the RPC should be -// retried, the bool indicates whether it is being retried transparently. -func (a *csAttempt) shouldRetry(err error) (bool, error) { - cs := a.cs - - if cs.finished || cs.committed || a.drop { - // RPC is finished or committed or was dropped by the picker; cannot retry. - return false, err - } - if a.s == nil && a.allowTransparentRetry { - return true, nil - } - // Wait for the trailers. - unprocessed := false - if a.s != nil { - <-a.s.Done() - unprocessed = a.s.Unprocessed() - } - if cs.firstAttempt && unprocessed { - // First attempt, stream unprocessed: transparently retry. - return true, nil - } - if cs.cc.dopts.disableRetry { - return false, err - } - - pushback := 0 - hasPushback := false - if a.s != nil { - if !a.s.TrailersOnly() { - return false, err - } - - // TODO(retry): Move down if the spec changes to not check server pushback - // before considering this a failure for throttling. - sps := a.s.Trailer()["grpc-retry-pushback-ms"] - if len(sps) == 1 { - var e error - if pushback, e = strconv.Atoi(sps[0]); e != nil || pushback < 0 { - channelz.Infof(logger, cs.cc.channelz, "Server retry pushback specified to abort (%q).", sps[0]) - cs.retryThrottler.throttle() // This counts as a failure for throttling. - return false, err - } - hasPushback = true - } else if len(sps) > 1 { - channelz.Warningf(logger, cs.cc.channelz, "Server retry pushback specified multiple values (%q); not retrying.", sps) - cs.retryThrottler.throttle() // This counts as a failure for throttling. - return false, err - } - } - - var code codes.Code - if a.s != nil { - code = a.s.Status().Code() - } else { - code = status.Code(err) - } - - rp := cs.methodConfig.RetryPolicy - if rp == nil || !rp.RetryableStatusCodes[code] { - return false, err - } - - // Note: the ordering here is important; we count this as a failure - // only if the code matched a retryable code. - if cs.retryThrottler.throttle() { - return false, err - } - if cs.numRetries+1 >= rp.MaxAttempts { - return false, err - } - - var dur time.Duration - if hasPushback { - dur = time.Millisecond * time.Duration(pushback) - cs.numRetriesSincePushback = 0 - } else { - fact := math.Pow(rp.BackoffMultiplier, float64(cs.numRetriesSincePushback)) - cur := float64(rp.InitialBackoff) * fact - if max := float64(rp.MaxBackoff); cur > max { - cur = max - } - dur = time.Duration(grpcrand.Int63n(int64(cur))) - cs.numRetriesSincePushback++ - } - - // TODO(dfawley): we could eagerly fail here if dur puts us past the - // deadline, but unsure if it is worth doing. - t := time.NewTimer(dur) - select { - case <-t.C: - cs.numRetries++ - return false, nil - case <-cs.ctx.Done(): - t.Stop() - return false, status.FromContextError(cs.ctx.Err()).Err() - } -} - -// Returns nil if a retry was performed and succeeded; error otherwise. -func (cs *clientStream) retryLocked(attempt *csAttempt, lastErr error) error { - for { - attempt.finish(toRPCErr(lastErr)) - isTransparent, err := attempt.shouldRetry(lastErr) - if err != nil { - cs.commitAttemptLocked() - return err - } - cs.firstAttempt = false - attempt, err = cs.newAttemptLocked(isTransparent) - if err != nil { - // Only returns error if the clientconn is closed or the context of - // the stream is canceled. - return err - } - // Note that the first op in the replay buffer always sets cs.attempt - // if it is able to pick a transport and create a stream. - if lastErr = cs.replayBufferLocked(attempt); lastErr == nil { - return nil - } - } -} - -func (cs *clientStream) Context() context.Context { - cs.commitAttempt() - // No need to lock before using attempt, since we know it is committed and - // cannot change. - if cs.attempt.s != nil { - return cs.attempt.s.Context() - } - return cs.ctx -} - -func (cs *clientStream) withRetry(op func(a *csAttempt) error, onSuccess func()) error { - cs.mu.Lock() - for { - if cs.committed { - cs.mu.Unlock() - // toRPCErr is used in case the error from the attempt comes from - // NewClientStream, which intentionally doesn't return a status - // error to allow for further inspection; all other errors should - // already be status errors. - return toRPCErr(op(cs.attempt)) - } - if len(cs.buffer) == 0 { - // For the first op, which controls creation of the stream and - // assigns cs.attempt, we need to create a new attempt inline - // before executing the first op. On subsequent ops, the attempt - // is created immediately before replaying the ops. - var err error - if cs.attempt, err = cs.newAttemptLocked(false /* isTransparent */); err != nil { - cs.mu.Unlock() - cs.finish(err) - return err - } - } - a := cs.attempt - cs.mu.Unlock() - err := op(a) - cs.mu.Lock() - if a != cs.attempt { - // We started another attempt already. - continue - } - if err == io.EOF { - <-a.s.Done() - } - if err == nil || (err == io.EOF && a.s.Status().Code() == codes.OK) { - onSuccess() - cs.mu.Unlock() - return err - } - if err := cs.retryLocked(a, err); err != nil { - cs.mu.Unlock() - return err - } - } -} - -func (cs *clientStream) Header() (metadata.MD, error) { - var m metadata.MD - err := cs.withRetry(func(a *csAttempt) error { - var err error - m, err = a.s.Header() - return toRPCErr(err) - }, cs.commitAttemptLocked) - - if m == nil && err == nil { - // The stream ended with success. Finish the clientStream. - err = io.EOF - } - - if err != nil { - cs.finish(err) - // Do not return the error. The user should get it by calling Recv(). - return nil, nil - } - - if len(cs.binlogs) != 0 && !cs.serverHeaderBinlogged && m != nil { - // Only log if binary log is on and header has not been logged, and - // there is actually headers to log. - logEntry := &binarylog.ServerHeader{ - OnClientSide: true, - Header: m, - PeerAddr: nil, - } - if peer, ok := peer.FromContext(cs.Context()); ok { - logEntry.PeerAddr = peer.Addr - } - cs.serverHeaderBinlogged = true - for _, binlog := range cs.binlogs { - binlog.Log(cs.ctx, logEntry) - } - } - - return m, nil -} - -func (cs *clientStream) Trailer() metadata.MD { - // On RPC failure, we never need to retry, because usage requires that - // RecvMsg() returned a non-nil error before calling this function is valid. - // We would have retried earlier if necessary. - // - // Commit the attempt anyway, just in case users are not following those - // directions -- it will prevent races and should not meaningfully impact - // performance. - cs.commitAttempt() - if cs.attempt.s == nil { - return nil - } - return cs.attempt.s.Trailer() -} - -func (cs *clientStream) replayBufferLocked(attempt *csAttempt) error { - for _, f := range cs.buffer { - if err := f(attempt); err != nil { - return err - } - } - return nil -} - -func (cs *clientStream) bufferForRetryLocked(sz int, op func(a *csAttempt) error) { - // Note: we still will buffer if retry is disabled (for transparent retries). - if cs.committed { - return - } - cs.bufferSize += sz - if cs.bufferSize > cs.callInfo.maxRetryRPCBufferSize { - cs.commitAttemptLocked() - return - } - cs.buffer = append(cs.buffer, op) -} - -func (cs *clientStream) SendMsg(m any) (err error) { - defer func() { - if err != nil && err != io.EOF { - // Call finish on the client stream for errors generated by this SendMsg - // call, as these indicate problems created by this client. (Transport - // errors are converted to an io.EOF error in csAttempt.sendMsg; the real - // error will be returned from RecvMsg eventually in that case, or be - // retried.) - cs.finish(err) - } - }() - if cs.sentLast { - return status.Errorf(codes.Internal, "SendMsg called after CloseSend") - } - if !cs.desc.ClientStreams { - cs.sentLast = true - } - - // load hdr, payload, data - hdr, payload, data, err := prepareMsg(m, cs.codec, cs.cp, cs.comp) - if err != nil { - return err - } - - // TODO(dfawley): should we be checking len(data) instead? - if len(payload) > *cs.callInfo.maxSendMessageSize { - return status.Errorf(codes.ResourceExhausted, "trying to send message larger than max (%d vs. %d)", len(payload), *cs.callInfo.maxSendMessageSize) - } - op := func(a *csAttempt) error { - return a.sendMsg(m, hdr, payload, data) - } - err = cs.withRetry(op, func() { cs.bufferForRetryLocked(len(hdr)+len(payload), op) }) - if len(cs.binlogs) != 0 && err == nil { - cm := &binarylog.ClientMessage{ - OnClientSide: true, - Message: data, - } - for _, binlog := range cs.binlogs { - binlog.Log(cs.ctx, cm) - } - } - return err -} - -func (cs *clientStream) RecvMsg(m any) error { - if len(cs.binlogs) != 0 && !cs.serverHeaderBinlogged { - // Call Header() to binary log header if it's not already logged. - cs.Header() - } - var recvInfo *payloadInfo - if len(cs.binlogs) != 0 { - recvInfo = &payloadInfo{} - } - err := cs.withRetry(func(a *csAttempt) error { - return a.recvMsg(m, recvInfo) - }, cs.commitAttemptLocked) - if len(cs.binlogs) != 0 && err == nil { - sm := &binarylog.ServerMessage{ - OnClientSide: true, - Message: recvInfo.uncompressedBytes, - } - for _, binlog := range cs.binlogs { - binlog.Log(cs.ctx, sm) - } - } - if err != nil || !cs.desc.ServerStreams { - // err != nil or non-server-streaming indicates end of stream. - cs.finish(err) - } - return err -} - -func (cs *clientStream) CloseSend() error { - if cs.sentLast { - // TODO: return an error and finish the stream instead, due to API misuse? - return nil - } - cs.sentLast = true - op := func(a *csAttempt) error { - a.t.Write(a.s, nil, nil, &transport.Options{Last: true}) - // Always return nil; io.EOF is the only error that might make sense - // instead, but there is no need to signal the client to call RecvMsg - // as the only use left for the stream after CloseSend is to call - // RecvMsg. This also matches historical behavior. - return nil - } - cs.withRetry(op, func() { cs.bufferForRetryLocked(0, op) }) - if len(cs.binlogs) != 0 { - chc := &binarylog.ClientHalfClose{ - OnClientSide: true, - } - for _, binlog := range cs.binlogs { - binlog.Log(cs.ctx, chc) - } - } - // We never returned an error here for reasons. - return nil -} - -func (cs *clientStream) finish(err error) { - if err == io.EOF { - // Ending a stream with EOF indicates a success. - err = nil - } - cs.mu.Lock() - if cs.finished { - cs.mu.Unlock() - return - } - cs.finished = true - for _, onFinish := range cs.callInfo.onFinish { - onFinish(err) - } - cs.commitAttemptLocked() - if cs.attempt != nil { - cs.attempt.finish(err) - // after functions all rely upon having a stream. - if cs.attempt.s != nil { - for _, o := range cs.opts { - o.after(cs.callInfo, cs.attempt) - } - } - } - - cs.mu.Unlock() - // Only one of cancel or trailer needs to be logged. - if len(cs.binlogs) != 0 { - switch err { - case errContextCanceled, errContextDeadline, ErrClientConnClosing: - c := &binarylog.Cancel{ - OnClientSide: true, - } - for _, binlog := range cs.binlogs { - binlog.Log(cs.ctx, c) - } - default: - logEntry := &binarylog.ServerTrailer{ - OnClientSide: true, - Trailer: cs.Trailer(), - Err: err, - } - if peer, ok := peer.FromContext(cs.Context()); ok { - logEntry.PeerAddr = peer.Addr - } - for _, binlog := range cs.binlogs { - binlog.Log(cs.ctx, logEntry) - } - } - } - if err == nil { - cs.retryThrottler.successfulRPC() - } - if channelz.IsOn() { - if err != nil { - cs.cc.incrCallsFailed() - } else { - cs.cc.incrCallsSucceeded() - } - } - cs.cancel() -} - -func (a *csAttempt) sendMsg(m any, hdr, payld, data []byte) error { - cs := a.cs - if a.trInfo != nil { - a.mu.Lock() - if a.trInfo.tr != nil { - a.trInfo.tr.LazyLog(&payload{sent: true, msg: m}, true) - } - a.mu.Unlock() - } - if err := a.t.Write(a.s, hdr, payld, &transport.Options{Last: !cs.desc.ClientStreams}); err != nil { - if !cs.desc.ClientStreams { - // For non-client-streaming RPCs, we return nil instead of EOF on error - // because the generated code requires it. finish is not called; RecvMsg() - // will call it with the stream's status independently. - return nil - } - return io.EOF - } - for _, sh := range a.statsHandlers { - sh.HandleRPC(a.ctx, outPayload(true, m, data, payld, time.Now())) - } - if channelz.IsOn() { - a.t.IncrMsgSent() - } - return nil -} - -func (a *csAttempt) recvMsg(m any, payInfo *payloadInfo) (err error) { - cs := a.cs - if len(a.statsHandlers) != 0 && payInfo == nil { - payInfo = &payloadInfo{} - } - - if !a.decompSet { - // Block until we receive headers containing received message encoding. - if ct := a.s.RecvCompress(); ct != "" && ct != encoding.Identity { - if a.dc == nil || a.dc.Type() != ct { - // No configured decompressor, or it does not match the incoming - // message encoding; attempt to find a registered compressor that does. - a.dc = nil - a.decomp = encoding.GetCompressor(ct) - } - } else { - // No compression is used; disable our decompressor. - a.dc = nil - } - // Only initialize this state once per stream. - a.decompSet = true - } - err = recv(a.p, cs.codec, a.s, a.dc, m, *cs.callInfo.maxReceiveMessageSize, payInfo, a.decomp) - if err != nil { - if err == io.EOF { - if statusErr := a.s.Status().Err(); statusErr != nil { - return statusErr - } - return io.EOF // indicates successful end of stream. - } - - return toRPCErr(err) - } - if a.trInfo != nil { - a.mu.Lock() - if a.trInfo.tr != nil { - a.trInfo.tr.LazyLog(&payload{sent: false, msg: m}, true) - } - a.mu.Unlock() - } - for _, sh := range a.statsHandlers { - sh.HandleRPC(a.ctx, &stats.InPayload{ - Client: true, - RecvTime: time.Now(), - Payload: m, - // TODO truncate large payload. - Data: payInfo.uncompressedBytes, - WireLength: payInfo.compressedLength + headerLen, - CompressedLength: payInfo.compressedLength, - Length: len(payInfo.uncompressedBytes), - }) - } - if channelz.IsOn() { - a.t.IncrMsgRecv() - } - if cs.desc.ServerStreams { - // Subsequent messages should be received by subsequent RecvMsg calls. - return nil - } - // Special handling for non-server-stream rpcs. - // This recv expects EOF or errors, so we don't collect inPayload. - err = recv(a.p, cs.codec, a.s, a.dc, m, *cs.callInfo.maxReceiveMessageSize, nil, a.decomp) - if err == nil { - return toRPCErr(errors.New("grpc: client streaming protocol violation: get , want ")) - } - if err == io.EOF { - return a.s.Status().Err() // non-server streaming Recv returns nil on success - } - return toRPCErr(err) -} - -func (a *csAttempt) finish(err error) { - a.mu.Lock() - if a.finished { - a.mu.Unlock() - return - } - a.finished = true - if err == io.EOF { - // Ending a stream with EOF indicates a success. - err = nil - } - var tr metadata.MD - if a.s != nil { - a.t.CloseStream(a.s, err) - tr = a.s.Trailer() - } - - if a.pickResult.Done != nil { - br := false - if a.s != nil { - br = a.s.BytesReceived() - } - a.pickResult.Done(balancer.DoneInfo{ - Err: err, - Trailer: tr, - BytesSent: a.s != nil, - BytesReceived: br, - ServerLoad: balancerload.Parse(tr), - }) - } - for _, sh := range a.statsHandlers { - end := &stats.End{ - Client: true, - BeginTime: a.beginTime, - EndTime: time.Now(), - Trailer: tr, - Error: err, - } - sh.HandleRPC(a.ctx, end) - } - if a.trInfo != nil && a.trInfo.tr != nil { - if err == nil { - a.trInfo.tr.LazyPrintf("RPC: [OK]") - } else { - a.trInfo.tr.LazyPrintf("RPC: [%v]", err) - a.trInfo.tr.SetError() - } - a.trInfo.tr.Finish() - a.trInfo.tr = nil - } - a.mu.Unlock() -} - -// newClientStream creates a ClientStream with the specified transport, on the -// given addrConn. -// -// It's expected that the given transport is either the same one in addrConn, or -// is already closed. To avoid race, transport is specified separately, instead -// of using ac.transpot. -// -// Main difference between this and ClientConn.NewStream: -// - no retry -// - no service config (or wait for service config) -// - no tracing or stats -func newNonRetryClientStream(ctx context.Context, desc *StreamDesc, method string, t transport.ClientTransport, ac *addrConn, opts ...CallOption) (_ ClientStream, err error) { - if t == nil { - // TODO: return RPC error here? - return nil, errors.New("transport provided is nil") - } - // defaultCallInfo contains unnecessary info(i.e. failfast, maxRetryRPCBufferSize), so we just initialize an empty struct. - c := &callInfo{} - - // Possible context leak: - // The cancel function for the child context we create will only be called - // when RecvMsg returns a non-nil error, if the ClientConn is closed, or if - // an error is generated by SendMsg. - // https://github.com/grpc/grpc-go/issues/1818. - ctx, cancel := context.WithCancel(ctx) - defer func() { - if err != nil { - cancel() - } - }() - - for _, o := range opts { - if err := o.before(c); err != nil { - return nil, toRPCErr(err) - } - } - c.maxReceiveMessageSize = getMaxSize(nil, c.maxReceiveMessageSize, defaultClientMaxReceiveMessageSize) - c.maxSendMessageSize = getMaxSize(nil, c.maxSendMessageSize, defaultServerMaxSendMessageSize) - if err := setCallInfoCodec(c); err != nil { - return nil, err - } - - callHdr := &transport.CallHdr{ - Host: ac.cc.authority, - Method: method, - ContentSubtype: c.contentSubtype, - } - - // Set our outgoing compression according to the UseCompressor CallOption, if - // set. In that case, also find the compressor from the encoding package. - // Otherwise, use the compressor configured by the WithCompressor DialOption, - // if set. - var cp Compressor - var comp encoding.Compressor - if ct := c.compressorType; ct != "" { - callHdr.SendCompress = ct - if ct != encoding.Identity { - comp = encoding.GetCompressor(ct) - if comp == nil { - return nil, status.Errorf(codes.Internal, "grpc: Compressor is not installed for requested grpc-encoding %q", ct) - } - } - } else if ac.cc.dopts.cp != nil { - callHdr.SendCompress = ac.cc.dopts.cp.Type() - cp = ac.cc.dopts.cp - } - if c.creds != nil { - callHdr.Creds = c.creds - } - - // Use a special addrConnStream to avoid retry. - as := &addrConnStream{ - callHdr: callHdr, - ac: ac, - ctx: ctx, - cancel: cancel, - opts: opts, - callInfo: c, - desc: desc, - codec: c.codec, - cp: cp, - comp: comp, - t: t, - } - - s, err := as.t.NewStream(as.ctx, as.callHdr) - if err != nil { - err = toRPCErr(err) - return nil, err - } - as.s = s - as.p = &parser{r: s, recvBufferPool: ac.dopts.recvBufferPool} - ac.incrCallsStarted() - if desc != unaryStreamDesc { - // Listen on stream context to cleanup when the stream context is - // canceled. Also listen for the addrConn's context in case the - // addrConn is closed or reconnects to a different address. In all - // other cases, an error should already be injected into the recv - // buffer by the transport, which the client will eventually receive, - // and then we will cancel the stream's context in - // addrConnStream.finish. - go func() { - ac.mu.Lock() - acCtx := ac.ctx - ac.mu.Unlock() - select { - case <-acCtx.Done(): - as.finish(status.Error(codes.Canceled, "grpc: the SubConn is closing")) - case <-ctx.Done(): - as.finish(toRPCErr(ctx.Err())) - } - }() - } - return as, nil -} - -type addrConnStream struct { - s *transport.Stream - ac *addrConn - callHdr *transport.CallHdr - cancel context.CancelFunc - opts []CallOption - callInfo *callInfo - t transport.ClientTransport - ctx context.Context - sentLast bool - desc *StreamDesc - codec baseCodec - cp Compressor - comp encoding.Compressor - decompSet bool - dc Decompressor - decomp encoding.Compressor - p *parser - mu sync.Mutex - finished bool -} - -func (as *addrConnStream) Header() (metadata.MD, error) { - m, err := as.s.Header() - if err != nil { - as.finish(toRPCErr(err)) - } - return m, err -} - -func (as *addrConnStream) Trailer() metadata.MD { - return as.s.Trailer() -} - -func (as *addrConnStream) CloseSend() error { - if as.sentLast { - // TODO: return an error and finish the stream instead, due to API misuse? - return nil - } - as.sentLast = true - - as.t.Write(as.s, nil, nil, &transport.Options{Last: true}) - // Always return nil; io.EOF is the only error that might make sense - // instead, but there is no need to signal the client to call RecvMsg - // as the only use left for the stream after CloseSend is to call - // RecvMsg. This also matches historical behavior. - return nil -} - -func (as *addrConnStream) Context() context.Context { - return as.s.Context() -} - -func (as *addrConnStream) SendMsg(m any) (err error) { - defer func() { - if err != nil && err != io.EOF { - // Call finish on the client stream for errors generated by this SendMsg - // call, as these indicate problems created by this client. (Transport - // errors are converted to an io.EOF error in csAttempt.sendMsg; the real - // error will be returned from RecvMsg eventually in that case, or be - // retried.) - as.finish(err) - } - }() - if as.sentLast { - return status.Errorf(codes.Internal, "SendMsg called after CloseSend") - } - if !as.desc.ClientStreams { - as.sentLast = true - } - - // load hdr, payload, data - hdr, payld, _, err := prepareMsg(m, as.codec, as.cp, as.comp) - if err != nil { - return err - } - - // TODO(dfawley): should we be checking len(data) instead? - if len(payld) > *as.callInfo.maxSendMessageSize { - return status.Errorf(codes.ResourceExhausted, "trying to send message larger than max (%d vs. %d)", len(payld), *as.callInfo.maxSendMessageSize) - } - - if err := as.t.Write(as.s, hdr, payld, &transport.Options{Last: !as.desc.ClientStreams}); err != nil { - if !as.desc.ClientStreams { - // For non-client-streaming RPCs, we return nil instead of EOF on error - // because the generated code requires it. finish is not called; RecvMsg() - // will call it with the stream's status independently. - return nil - } - return io.EOF - } - - if channelz.IsOn() { - as.t.IncrMsgSent() - } - return nil -} - -func (as *addrConnStream) RecvMsg(m any) (err error) { - defer func() { - if err != nil || !as.desc.ServerStreams { - // err != nil or non-server-streaming indicates end of stream. - as.finish(err) - } - }() - - if !as.decompSet { - // Block until we receive headers containing received message encoding. - if ct := as.s.RecvCompress(); ct != "" && ct != encoding.Identity { - if as.dc == nil || as.dc.Type() != ct { - // No configured decompressor, or it does not match the incoming - // message encoding; attempt to find a registered compressor that does. - as.dc = nil - as.decomp = encoding.GetCompressor(ct) - } - } else { - // No compression is used; disable our decompressor. - as.dc = nil - } - // Only initialize this state once per stream. - as.decompSet = true - } - err = recv(as.p, as.codec, as.s, as.dc, m, *as.callInfo.maxReceiveMessageSize, nil, as.decomp) - if err != nil { - if err == io.EOF { - if statusErr := as.s.Status().Err(); statusErr != nil { - return statusErr - } - return io.EOF // indicates successful end of stream. - } - return toRPCErr(err) - } - - if channelz.IsOn() { - as.t.IncrMsgRecv() - } - if as.desc.ServerStreams { - // Subsequent messages should be received by subsequent RecvMsg calls. - return nil - } - - // Special handling for non-server-stream rpcs. - // This recv expects EOF or errors, so we don't collect inPayload. - err = recv(as.p, as.codec, as.s, as.dc, m, *as.callInfo.maxReceiveMessageSize, nil, as.decomp) - if err == nil { - return toRPCErr(errors.New("grpc: client streaming protocol violation: get , want ")) - } - if err == io.EOF { - return as.s.Status().Err() // non-server streaming Recv returns nil on success - } - return toRPCErr(err) -} - -func (as *addrConnStream) finish(err error) { - as.mu.Lock() - if as.finished { - as.mu.Unlock() - return - } - as.finished = true - if err == io.EOF { - // Ending a stream with EOF indicates a success. - err = nil - } - if as.s != nil { - as.t.CloseStream(as.s, err) - } - - if err != nil { - as.ac.incrCallsFailed() - } else { - as.ac.incrCallsSucceeded() - } - as.cancel() - as.mu.Unlock() -} - -// ServerStream defines the server-side behavior of a streaming RPC. -// -// Errors returned from ServerStream methods are compatible with the status -// package. However, the status code will often not match the RPC status as -// seen by the client application, and therefore, should not be relied upon for -// this purpose. -type ServerStream interface { - // SetHeader sets the header metadata. It may be called multiple times. - // When call multiple times, all the provided metadata will be merged. - // All the metadata will be sent out when one of the following happens: - // - ServerStream.SendHeader() is called; - // - The first response is sent out; - // - An RPC status is sent out (error or success). - SetHeader(metadata.MD) error - // SendHeader sends the header metadata. - // The provided md and headers set by SetHeader() will be sent. - // It fails if called multiple times. - SendHeader(metadata.MD) error - // SetTrailer sets the trailer metadata which will be sent with the RPC status. - // When called more than once, all the provided metadata will be merged. - SetTrailer(metadata.MD) - // Context returns the context for this stream. - Context() context.Context - // SendMsg sends a message. On error, SendMsg aborts the stream and the - // error is returned directly. - // - // SendMsg blocks until: - // - There is sufficient flow control to schedule m with the transport, or - // - The stream is done, or - // - The stream breaks. - // - // SendMsg does not wait until the message is received by the client. An - // untimely stream closure may result in lost messages. - // - // It is safe to have a goroutine calling SendMsg and another goroutine - // calling RecvMsg on the same stream at the same time, but it is not safe - // to call SendMsg on the same stream in different goroutines. - // - // It is not safe to modify the message after calling SendMsg. Tracing - // libraries and stats handlers may use the message lazily. - SendMsg(m any) error - // RecvMsg blocks until it receives a message into m or the stream is - // done. It returns io.EOF when the client has performed a CloseSend. On - // any non-EOF error, the stream is aborted and the error contains the - // RPC status. - // - // It is safe to have a goroutine calling SendMsg and another goroutine - // calling RecvMsg on the same stream at the same time, but it is not - // safe to call RecvMsg on the same stream in different goroutines. - RecvMsg(m any) error -} - -// serverStream implements a server side Stream. -type serverStream struct { - ctx context.Context - t transport.ServerTransport - s *transport.Stream - p *parser - codec baseCodec - - cp Compressor - dc Decompressor - comp encoding.Compressor - decomp encoding.Compressor - - sendCompressorName string - - maxReceiveMessageSize int - maxSendMessageSize int - trInfo *traceInfo - - statsHandler []stats.Handler - - binlogs []binarylog.MethodLogger - // serverHeaderBinlogged indicates whether server header has been logged. It - // will happen when one of the following two happens: stream.SendHeader(), - // stream.Send(). - // - // It's only checked in send and sendHeader, doesn't need to be - // synchronized. - serverHeaderBinlogged bool - - mu sync.Mutex // protects trInfo.tr after the service handler runs. -} - -func (ss *serverStream) Context() context.Context { - return ss.ctx -} - -func (ss *serverStream) SetHeader(md metadata.MD) error { - if md.Len() == 0 { - return nil - } - err := imetadata.Validate(md) - if err != nil { - return status.Error(codes.Internal, err.Error()) - } - return ss.s.SetHeader(md) -} - -func (ss *serverStream) SendHeader(md metadata.MD) error { - err := imetadata.Validate(md) - if err != nil { - return status.Error(codes.Internal, err.Error()) - } - - err = ss.t.WriteHeader(ss.s, md) - if len(ss.binlogs) != 0 && !ss.serverHeaderBinlogged { - h, _ := ss.s.Header() - sh := &binarylog.ServerHeader{ - Header: h, - } - ss.serverHeaderBinlogged = true - for _, binlog := range ss.binlogs { - binlog.Log(ss.ctx, sh) - } - } - return err -} - -func (ss *serverStream) SetTrailer(md metadata.MD) { - if md.Len() == 0 { - return - } - if err := imetadata.Validate(md); err != nil { - logger.Errorf("stream: failed to validate md when setting trailer, err: %v", err) - } - ss.s.SetTrailer(md) -} - -func (ss *serverStream) SendMsg(m any) (err error) { - defer func() { - if ss.trInfo != nil { - ss.mu.Lock() - if ss.trInfo.tr != nil { - if err == nil { - ss.trInfo.tr.LazyLog(&payload{sent: true, msg: m}, true) - } else { - ss.trInfo.tr.LazyLog(&fmtStringer{"%v", []any{err}}, true) - ss.trInfo.tr.SetError() - } - } - ss.mu.Unlock() - } - if err != nil && err != io.EOF { - st, _ := status.FromError(toRPCErr(err)) - ss.t.WriteStatus(ss.s, st) - // Non-user specified status was sent out. This should be an error - // case (as a server side Cancel maybe). - // - // This is not handled specifically now. User will return a final - // status from the service handler, we will log that error instead. - // This behavior is similar to an interceptor. - } - if channelz.IsOn() && err == nil { - ss.t.IncrMsgSent() - } - }() - - // Server handler could have set new compressor by calling SetSendCompressor. - // In case it is set, we need to use it for compressing outbound message. - if sendCompressorsName := ss.s.SendCompress(); sendCompressorsName != ss.sendCompressorName { - ss.comp = encoding.GetCompressor(sendCompressorsName) - ss.sendCompressorName = sendCompressorsName - } - - // load hdr, payload, data - hdr, payload, data, err := prepareMsg(m, ss.codec, ss.cp, ss.comp) - if err != nil { - return err - } - - // TODO(dfawley): should we be checking len(data) instead? - if len(payload) > ss.maxSendMessageSize { - return status.Errorf(codes.ResourceExhausted, "trying to send message larger than max (%d vs. %d)", len(payload), ss.maxSendMessageSize) - } - if err := ss.t.Write(ss.s, hdr, payload, &transport.Options{Last: false}); err != nil { - return toRPCErr(err) - } - if len(ss.binlogs) != 0 { - if !ss.serverHeaderBinlogged { - h, _ := ss.s.Header() - sh := &binarylog.ServerHeader{ - Header: h, - } - ss.serverHeaderBinlogged = true - for _, binlog := range ss.binlogs { - binlog.Log(ss.ctx, sh) - } - } - sm := &binarylog.ServerMessage{ - Message: data, - } - for _, binlog := range ss.binlogs { - binlog.Log(ss.ctx, sm) - } - } - if len(ss.statsHandler) != 0 { - for _, sh := range ss.statsHandler { - sh.HandleRPC(ss.s.Context(), outPayload(false, m, data, payload, time.Now())) - } - } - return nil -} - -func (ss *serverStream) RecvMsg(m any) (err error) { - defer func() { - if ss.trInfo != nil { - ss.mu.Lock() - if ss.trInfo.tr != nil { - if err == nil { - ss.trInfo.tr.LazyLog(&payload{sent: false, msg: m}, true) - } else if err != io.EOF { - ss.trInfo.tr.LazyLog(&fmtStringer{"%v", []any{err}}, true) - ss.trInfo.tr.SetError() - } - } - ss.mu.Unlock() - } - if err != nil && err != io.EOF { - st, _ := status.FromError(toRPCErr(err)) - ss.t.WriteStatus(ss.s, st) - // Non-user specified status was sent out. This should be an error - // case (as a server side Cancel maybe). - // - // This is not handled specifically now. User will return a final - // status from the service handler, we will log that error instead. - // This behavior is similar to an interceptor. - } - if channelz.IsOn() && err == nil { - ss.t.IncrMsgRecv() - } - }() - var payInfo *payloadInfo - if len(ss.statsHandler) != 0 || len(ss.binlogs) != 0 { - payInfo = &payloadInfo{} - } - if err := recv(ss.p, ss.codec, ss.s, ss.dc, m, ss.maxReceiveMessageSize, payInfo, ss.decomp); err != nil { - if err == io.EOF { - if len(ss.binlogs) != 0 { - chc := &binarylog.ClientHalfClose{} - for _, binlog := range ss.binlogs { - binlog.Log(ss.ctx, chc) - } - } - return err - } - if err == io.ErrUnexpectedEOF { - err = status.Errorf(codes.Internal, io.ErrUnexpectedEOF.Error()) - } - return toRPCErr(err) - } - if len(ss.statsHandler) != 0 { - for _, sh := range ss.statsHandler { - sh.HandleRPC(ss.s.Context(), &stats.InPayload{ - RecvTime: time.Now(), - Payload: m, - // TODO truncate large payload. - Data: payInfo.uncompressedBytes, - Length: len(payInfo.uncompressedBytes), - WireLength: payInfo.compressedLength + headerLen, - CompressedLength: payInfo.compressedLength, - }) - } - } - if len(ss.binlogs) != 0 { - cm := &binarylog.ClientMessage{ - Message: payInfo.uncompressedBytes, - } - for _, binlog := range ss.binlogs { - binlog.Log(ss.ctx, cm) - } - } - return nil -} - -// MethodFromServerStream returns the method string for the input stream. -// The returned string is in the format of "/service/method". -func MethodFromServerStream(stream ServerStream) (string, bool) { - return Method(stream.Context()) -} - -// prepareMsg returns the hdr, payload and data -// using the compressors passed or using the -// passed preparedmsg -func prepareMsg(m any, codec baseCodec, cp Compressor, comp encoding.Compressor) (hdr, payload, data []byte, err error) { - if preparedMsg, ok := m.(*PreparedMsg); ok { - return preparedMsg.hdr, preparedMsg.payload, preparedMsg.encodedData, nil - } - // The input interface is not a prepared msg. - // Marshal and Compress the data at this point - data, err = encode(codec, m) - if err != nil { - return nil, nil, nil, err - } - compData, err := compress(data, cp, comp) - if err != nil { - return nil, nil, nil, err - } - hdr, payload = msgHeader(data, compData) - return hdr, payload, data, nil -} diff --git a/vendor/google.golang.org/grpc/tap/tap.go b/vendor/google.golang.org/grpc/tap/tap.go deleted file mode 100644 index 07f012576..000000000 --- a/vendor/google.golang.org/grpc/tap/tap.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package tap defines the function handles which are executed on the transport -// layer of gRPC-Go and related information. -// -// # Experimental -// -// Notice: This API is EXPERIMENTAL and may be changed or removed in a -// later release. -package tap - -import ( - "context" - - "google.golang.org/grpc/metadata" -) - -// Info defines the relevant information needed by the handles. -type Info struct { - // FullMethodName is the string of grpc method (in the format of - // /package.service/method). - FullMethodName string - - // Header contains the header metadata received. - Header metadata.MD - - // TODO: More to be added. -} - -// ServerInHandle defines the function which runs before a new stream is -// created on the server side. If it returns a non-nil error, the stream will -// not be created and an error will be returned to the client. If the error -// returned is a status error, that status code and message will be used, -// otherwise PermissionDenied will be the code and err.Error() will be the -// message. -// -// It's intended to be used in situations where you don't want to waste the -// resources to accept the new stream (e.g. rate-limiting). For other general -// usages, please use interceptors. -// -// Note that it is executed in the per-connection I/O goroutine(s) instead of -// per-RPC goroutine. Therefore, users should NOT have any -// blocking/time-consuming work in this handle. Otherwise all the RPCs would -// slow down. Also, for the same reason, this handle won't be called -// concurrently by gRPC. -type ServerInHandle func(ctx context.Context, info *Info) (context.Context, error) diff --git a/vendor/google.golang.org/grpc/trace.go b/vendor/google.golang.org/grpc/trace.go deleted file mode 100644 index 10f4f798f..000000000 --- a/vendor/google.golang.org/grpc/trace.go +++ /dev/null @@ -1,143 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpc - -import ( - "bytes" - "fmt" - "io" - "net" - "strings" - "sync" - "time" -) - -// EnableTracing controls whether to trace RPCs using the golang.org/x/net/trace package. -// This should only be set before any RPCs are sent or received by this program. -var EnableTracing bool - -// methodFamily returns the trace family for the given method. -// It turns "/pkg.Service/GetFoo" into "pkg.Service". -func methodFamily(m string) string { - m = strings.TrimPrefix(m, "/") // remove leading slash - if i := strings.Index(m, "/"); i >= 0 { - m = m[:i] // remove everything from second slash - } - return m -} - -// traceEventLog mirrors golang.org/x/net/trace.EventLog. -// -// It exists in order to avoid importing x/net/trace on grpcnotrace builds. -type traceEventLog interface { - Printf(format string, a ...any) - Errorf(format string, a ...any) - Finish() -} - -// traceLog mirrors golang.org/x/net/trace.Trace. -// -// It exists in order to avoid importing x/net/trace on grpcnotrace builds. -type traceLog interface { - LazyLog(x fmt.Stringer, sensitive bool) - LazyPrintf(format string, a ...any) - SetError() - SetRecycler(f func(any)) - SetTraceInfo(traceID, spanID uint64) - SetMaxEvents(m int) - Finish() -} - -// traceInfo contains tracing information for an RPC. -type traceInfo struct { - tr traceLog - firstLine firstLine -} - -// firstLine is the first line of an RPC trace. -// It may be mutated after construction; remoteAddr specifically may change -// during client-side use. -type firstLine struct { - mu sync.Mutex - client bool // whether this is a client (outgoing) RPC - remoteAddr net.Addr - deadline time.Duration // may be zero -} - -func (f *firstLine) SetRemoteAddr(addr net.Addr) { - f.mu.Lock() - f.remoteAddr = addr - f.mu.Unlock() -} - -func (f *firstLine) String() string { - f.mu.Lock() - defer f.mu.Unlock() - - var line bytes.Buffer - io.WriteString(&line, "RPC: ") - if f.client { - io.WriteString(&line, "to") - } else { - io.WriteString(&line, "from") - } - fmt.Fprintf(&line, " %v deadline:", f.remoteAddr) - if f.deadline != 0 { - fmt.Fprint(&line, f.deadline) - } else { - io.WriteString(&line, "none") - } - return line.String() -} - -const truncateSize = 100 - -func truncate(x string, l int) string { - if l > len(x) { - return x - } - return x[:l] -} - -// payload represents an RPC request or response payload. -type payload struct { - sent bool // whether this is an outgoing payload - msg any // e.g. a proto.Message - // TODO(dsymonds): add stringifying info to codec, and limit how much we hold here? -} - -func (p payload) String() string { - if p.sent { - return truncate(fmt.Sprintf("sent: %v", p.msg), truncateSize) - } - return truncate(fmt.Sprintf("recv: %v", p.msg), truncateSize) -} - -type fmtStringer struct { - format string - a []any -} - -func (f *fmtStringer) String() string { - return fmt.Sprintf(f.format, f.a...) -} - -type stringer string - -func (s stringer) String() string { return string(s) } diff --git a/vendor/google.golang.org/grpc/trace_notrace.go b/vendor/google.golang.org/grpc/trace_notrace.go deleted file mode 100644 index 1da3a2308..000000000 --- a/vendor/google.golang.org/grpc/trace_notrace.go +++ /dev/null @@ -1,52 +0,0 @@ -//go:build grpcnotrace - -/* - * - * Copyright 2024 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpc - -// grpcnotrace can be used to avoid importing golang.org/x/net/trace, which in -// turn enables binaries using gRPC-Go for dead code elimination, which can -// yield 10-15% improvements in binary size when tracing is not needed. - -import ( - "context" - "fmt" -) - -type notrace struct{} - -func (notrace) LazyLog(x fmt.Stringer, sensitive bool) {} -func (notrace) LazyPrintf(format string, a ...any) {} -func (notrace) SetError() {} -func (notrace) SetRecycler(f func(any)) {} -func (notrace) SetTraceInfo(traceID, spanID uint64) {} -func (notrace) SetMaxEvents(m int) {} -func (notrace) Finish() {} - -func newTrace(family, title string) traceLog { - return notrace{} -} - -func newTraceContext(ctx context.Context, tr traceLog) context.Context { - return ctx -} - -func newTraceEventLog(family, title string) traceEventLog { - return nil -} diff --git a/vendor/google.golang.org/grpc/trace_withtrace.go b/vendor/google.golang.org/grpc/trace_withtrace.go deleted file mode 100644 index 88d6e8571..000000000 --- a/vendor/google.golang.org/grpc/trace_withtrace.go +++ /dev/null @@ -1,39 +0,0 @@ -//go:build !grpcnotrace - -/* - * - * Copyright 2024 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpc - -import ( - "context" - - t "golang.org/x/net/trace" -) - -func newTrace(family, title string) traceLog { - return t.New(family, title) -} - -func newTraceContext(ctx context.Context, tr traceLog) context.Context { - return t.NewContext(ctx, tr) -} - -func newTraceEventLog(family, title string) traceEventLog { - return t.NewEventLog(family, title) -} diff --git a/vendor/google.golang.org/grpc/version.go b/vendor/google.golang.org/grpc/version.go deleted file mode 100644 index 2556f7583..000000000 --- a/vendor/google.golang.org/grpc/version.go +++ /dev/null @@ -1,22 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package grpc - -// Version is the current grpc version. -const Version = "1.63.2" diff --git a/vendor/google.golang.org/grpc/vet.sh b/vendor/google.golang.org/grpc/vet.sh deleted file mode 100644 index 7e6b92e49..000000000 --- a/vendor/google.golang.org/grpc/vet.sh +++ /dev/null @@ -1,195 +0,0 @@ -#!/bin/bash - -set -ex # Exit on error; debugging enabled. -set -o pipefail # Fail a pipe if any sub-command fails. - -# not makes sure the command passed to it does not exit with a return code of 0. -not() { - # This is required instead of the earlier (! $COMMAND) because subshells and - # pipefail don't work the same on Darwin as in Linux. - ! "$@" -} - -die() { - echo "$@" >&2 - exit 1 -} - -fail_on_output() { - tee /dev/stderr | not read -} - -# Check to make sure it's safe to modify the user's git repo. -git status --porcelain | fail_on_output - -# Undo any edits made by this script. -cleanup() { - git reset --hard HEAD -} -trap cleanup EXIT - -PATH="${HOME}/go/bin:${GOROOT}/bin:${PATH}" -go version - -if [[ "$1" = "-install" ]]; then - # Install the pinned versions as defined in module tools. - pushd ./test/tools - go install \ - golang.org/x/tools/cmd/goimports \ - honnef.co/go/tools/cmd/staticcheck \ - github.com/client9/misspell/cmd/misspell - popd - if [[ -z "${VET_SKIP_PROTO}" ]]; then - if [[ "${GITHUB_ACTIONS}" = "true" ]]; then - PROTOBUF_VERSION=25.2 # a.k.a. v4.22.0 in pb.go files. - PROTOC_FILENAME=protoc-${PROTOBUF_VERSION}-linux-x86_64.zip - pushd /home/runner/go - wget https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/${PROTOC_FILENAME} - unzip ${PROTOC_FILENAME} - bin/protoc --version - popd - elif not which protoc > /dev/null; then - die "Please install protoc into your path" - fi - fi - exit 0 -elif [[ "$#" -ne 0 ]]; then - die "Unknown argument(s): $*" -fi - -# - Check that generated proto files are up to date. -if [[ -z "${VET_SKIP_PROTO}" ]]; then - make proto && git status --porcelain 2>&1 | fail_on_output || \ - (git status; git --no-pager diff; exit 1) -fi - -if [[ -n "${VET_ONLY_PROTO}" ]]; then - exit 0 -fi - -# - Ensure all source files contain a copyright message. -# (Done in two parts because Darwin "git grep" has broken support for compound -# exclusion matches.) -(grep -L "DO NOT EDIT" $(git grep -L "\(Copyright [0-9]\{4,\} gRPC authors\)" -- '*.go') || true) | fail_on_output - -# - Make sure all tests in grpc and grpc/test use leakcheck via Teardown. -not grep 'func Test[^(]' *_test.go -not grep 'func Test[^(]' test/*.go - -# - Check for typos in test function names -git grep 'func (s) ' -- "*_test.go" | not grep -v 'func (s) Test' -git grep 'func [A-Z]' -- "*_test.go" | not grep -v 'func Test\|Benchmark\|Example' - -# - Do not import x/net/context. -not git grep -l 'x/net/context' -- "*.go" - -# - Do not use time.After except in tests. It has the potential to leak the -# timer since there is no way to stop it early. -git grep -l 'time.After(' -- "*.go" | not grep -v '_test.go\|test_utils\|testutils' - -# - Do not import math/rand for real library code. Use internal/grpcrand for -# thread safety. -git grep -l '"math/rand"' -- "*.go" 2>&1 | not grep -v '^examples\|^interop/stress\|grpcrand\|^benchmark\|wrr_test' - -# - Do not use "interface{}"; use "any" instead. -git grep -l 'interface{}' -- "*.go" 2>&1 | not grep -v '\.pb\.go\|protoc-gen-go-grpc\|grpc_testing_not_regenerate' - -# - Do not call grpclog directly. Use grpclog.Component instead. -git grep -l -e 'grpclog.I' --or -e 'grpclog.W' --or -e 'grpclog.E' --or -e 'grpclog.F' --or -e 'grpclog.V' -- "*.go" | not grep -v '^grpclog/component.go\|^internal/grpctest/tlogger_test.go' - -# - Ensure all ptypes proto packages are renamed when importing. -not git grep "\(import \|^\s*\)\"github.com/golang/protobuf/ptypes/" -- "*.go" - -# - Ensure all usages of grpc_testing package are renamed when importing. -not git grep "\(import \|^\s*\)\"google.golang.org/grpc/interop/grpc_testing" -- "*.go" - -# - Ensure all xds proto imports are renamed to *pb or *grpc. -git grep '"github.com/envoyproxy/go-control-plane/envoy' -- '*.go' ':(exclude)*.pb.go' | not grep -v 'pb "\|grpc "' - -misspell -error . - -# - gofmt, goimports, go vet, go mod tidy. -# Perform these checks on each module inside gRPC. -for MOD_FILE in $(find . -name 'go.mod'); do - MOD_DIR=$(dirname ${MOD_FILE}) - pushd ${MOD_DIR} - go vet -all ./... | fail_on_output - gofmt -s -d -l . 2>&1 | fail_on_output - goimports -l . 2>&1 | not grep -vE "\.pb\.go" - - go mod tidy -compat=1.19 - git status --porcelain 2>&1 | fail_on_output || \ - (git status; git --no-pager diff; exit 1) - popd -done - -# - Collection of static analysis checks -SC_OUT="$(mktemp)" -staticcheck -go 1.19 -checks 'all' ./... > "${SC_OUT}" || true - -# Error for anything other than checks that need exclusions. -grep -v "(ST1000)" "${SC_OUT}" | grep -v "(SA1019)" | grep -v "(ST1003)" | not grep -v "(ST1019)\|\(other import of\)" - -# Exclude underscore checks for generated code. -grep "(ST1003)" "${SC_OUT}" | not grep -v '\(.pb.go:\)\|\(code_string_test.go:\)\|\(grpc_testing_not_regenerate\)' - -# Error for duplicate imports not including grpc protos. -grep "(ST1019)\|\(other import of\)" "${SC_OUT}" | not grep -Fv 'XXXXX PleaseIgnoreUnused -channelz/grpc_channelz_v1" -go-control-plane/envoy -grpclb/grpc_lb_v1" -health/grpc_health_v1" -interop/grpc_testing" -orca/v3" -proto/grpc_gcp" -proto/grpc_lookup_v1" -reflection/grpc_reflection_v1" -reflection/grpc_reflection_v1alpha" -XXXXX PleaseIgnoreUnused' - -# Error for any package comments not in generated code. -grep "(ST1000)" "${SC_OUT}" | not grep -v "\.pb\.go:" - -# Only ignore the following deprecated types/fields/functions and exclude -# generated code. -grep "(SA1019)" "${SC_OUT}" | not grep -Fv 'XXXXX PleaseIgnoreUnused -XXXXX Protobuf related deprecation errors: -"github.com/golang/protobuf -.pb.go: -grpc_testing_not_regenerate -: ptypes. -proto.RegisterType -XXXXX gRPC internal usage deprecation errors: -"google.golang.org/grpc -: grpc. -: v1alpha. -: v1alphareflectionpb. -BalancerAttributes is deprecated: -CredsBundle is deprecated: -Metadata is deprecated: use Attributes instead. -NewSubConn is deprecated: -OverrideServerName is deprecated: -RemoveSubConn is deprecated: -SecurityVersion is deprecated: -Target is deprecated: Use the Target field in the BuildOptions instead. -UpdateAddresses is deprecated: -UpdateSubConnState is deprecated: -balancer.ErrTransientFailure is deprecated: -grpc/reflection/v1alpha/reflection.proto -SwitchTo is deprecated: -XXXXX xDS deprecated fields we support -.ExactMatch -.PrefixMatch -.SafeRegexMatch -.SuffixMatch -GetContainsMatch -GetExactMatch -GetMatchSubjectAltNames -GetPrefixMatch -GetSafeRegexMatch -GetSuffixMatch -GetTlsCertificateCertificateProviderInstance -GetValidationContextCertificateProviderInstance -XXXXX PleaseIgnoreUnused' - -echo SUCCESS diff --git a/vendor/google.golang.org/protobuf/encoding/protojson/decode.go b/vendor/google.golang.org/protobuf/encoding/protojson/decode.go deleted file mode 100644 index f47902371..000000000 --- a/vendor/google.golang.org/protobuf/encoding/protojson/decode.go +++ /dev/null @@ -1,685 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package protojson - -import ( - "encoding/base64" - "fmt" - "math" - "strconv" - "strings" - - "google.golang.org/protobuf/encoding/protowire" - "google.golang.org/protobuf/internal/encoding/json" - "google.golang.org/protobuf/internal/encoding/messageset" - "google.golang.org/protobuf/internal/errors" - "google.golang.org/protobuf/internal/flags" - "google.golang.org/protobuf/internal/genid" - "google.golang.org/protobuf/internal/pragma" - "google.golang.org/protobuf/internal/set" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/reflect/protoreflect" - "google.golang.org/protobuf/reflect/protoregistry" -) - -// Unmarshal reads the given []byte into the given [proto.Message]. -// The provided message must be mutable (e.g., a non-nil pointer to a message). -func Unmarshal(b []byte, m proto.Message) error { - return UnmarshalOptions{}.Unmarshal(b, m) -} - -// UnmarshalOptions is a configurable JSON format parser. -type UnmarshalOptions struct { - pragma.NoUnkeyedLiterals - - // If AllowPartial is set, input for messages that will result in missing - // required fields will not return an error. - AllowPartial bool - - // If DiscardUnknown is set, unknown fields and enum name values are ignored. - DiscardUnknown bool - - // Resolver is used for looking up types when unmarshaling - // google.protobuf.Any messages or extension fields. - // If nil, this defaults to using protoregistry.GlobalTypes. - Resolver interface { - protoregistry.MessageTypeResolver - protoregistry.ExtensionTypeResolver - } - - // RecursionLimit limits how deeply messages may be nested. - // If zero, a default limit is applied. - RecursionLimit int -} - -// Unmarshal reads the given []byte and populates the given [proto.Message] -// using options in the UnmarshalOptions object. -// It will clear the message first before setting the fields. -// If it returns an error, the given message may be partially set. -// The provided message must be mutable (e.g., a non-nil pointer to a message). -func (o UnmarshalOptions) Unmarshal(b []byte, m proto.Message) error { - return o.unmarshal(b, m) -} - -// unmarshal is a centralized function that all unmarshal operations go through. -// For profiling purposes, avoid changing the name of this function or -// introducing other code paths for unmarshal that do not go through this. -func (o UnmarshalOptions) unmarshal(b []byte, m proto.Message) error { - proto.Reset(m) - - if o.Resolver == nil { - o.Resolver = protoregistry.GlobalTypes - } - if o.RecursionLimit == 0 { - o.RecursionLimit = protowire.DefaultRecursionLimit - } - - dec := decoder{json.NewDecoder(b), o} - if err := dec.unmarshalMessage(m.ProtoReflect(), false); err != nil { - return err - } - - // Check for EOF. - tok, err := dec.Read() - if err != nil { - return err - } - if tok.Kind() != json.EOF { - return dec.unexpectedTokenError(tok) - } - - if o.AllowPartial { - return nil - } - return proto.CheckInitialized(m) -} - -type decoder struct { - *json.Decoder - opts UnmarshalOptions -} - -// newError returns an error object with position info. -func (d decoder) newError(pos int, f string, x ...interface{}) error { - line, column := d.Position(pos) - head := fmt.Sprintf("(line %d:%d): ", line, column) - return errors.New(head+f, x...) -} - -// unexpectedTokenError returns a syntax error for the given unexpected token. -func (d decoder) unexpectedTokenError(tok json.Token) error { - return d.syntaxError(tok.Pos(), "unexpected token %s", tok.RawString()) -} - -// syntaxError returns a syntax error for given position. -func (d decoder) syntaxError(pos int, f string, x ...interface{}) error { - line, column := d.Position(pos) - head := fmt.Sprintf("syntax error (line %d:%d): ", line, column) - return errors.New(head+f, x...) -} - -// unmarshalMessage unmarshals a message into the given protoreflect.Message. -func (d decoder) unmarshalMessage(m protoreflect.Message, skipTypeURL bool) error { - d.opts.RecursionLimit-- - if d.opts.RecursionLimit < 0 { - return errors.New("exceeded max recursion depth") - } - if unmarshal := wellKnownTypeUnmarshaler(m.Descriptor().FullName()); unmarshal != nil { - return unmarshal(d, m) - } - - tok, err := d.Read() - if err != nil { - return err - } - if tok.Kind() != json.ObjectOpen { - return d.unexpectedTokenError(tok) - } - - messageDesc := m.Descriptor() - if !flags.ProtoLegacy && messageset.IsMessageSet(messageDesc) { - return errors.New("no support for proto1 MessageSets") - } - - var seenNums set.Ints - var seenOneofs set.Ints - fieldDescs := messageDesc.Fields() - for { - // Read field name. - tok, err := d.Read() - if err != nil { - return err - } - switch tok.Kind() { - default: - return d.unexpectedTokenError(tok) - case json.ObjectClose: - return nil - case json.Name: - // Continue below. - } - - name := tok.Name() - // Unmarshaling a non-custom embedded message in Any will contain the - // JSON field "@type" which should be skipped because it is not a field - // of the embedded message, but simply an artifact of the Any format. - if skipTypeURL && name == "@type" { - d.Read() - continue - } - - // Get the FieldDescriptor. - var fd protoreflect.FieldDescriptor - if strings.HasPrefix(name, "[") && strings.HasSuffix(name, "]") { - // Only extension names are in [name] format. - extName := protoreflect.FullName(name[1 : len(name)-1]) - extType, err := d.opts.Resolver.FindExtensionByName(extName) - if err != nil && err != protoregistry.NotFound { - return d.newError(tok.Pos(), "unable to resolve %s: %v", tok.RawString(), err) - } - if extType != nil { - fd = extType.TypeDescriptor() - if !messageDesc.ExtensionRanges().Has(fd.Number()) || fd.ContainingMessage().FullName() != messageDesc.FullName() { - return d.newError(tok.Pos(), "message %v cannot be extended by %v", messageDesc.FullName(), fd.FullName()) - } - } - } else { - // The name can either be the JSON name or the proto field name. - fd = fieldDescs.ByJSONName(name) - if fd == nil { - fd = fieldDescs.ByTextName(name) - } - } - if flags.ProtoLegacy { - if fd != nil && fd.IsWeak() && fd.Message().IsPlaceholder() { - fd = nil // reset since the weak reference is not linked in - } - } - - if fd == nil { - // Field is unknown. - if d.opts.DiscardUnknown { - if err := d.skipJSONValue(); err != nil { - return err - } - continue - } - return d.newError(tok.Pos(), "unknown field %v", tok.RawString()) - } - - // Do not allow duplicate fields. - num := uint64(fd.Number()) - if seenNums.Has(num) { - return d.newError(tok.Pos(), "duplicate field %v", tok.RawString()) - } - seenNums.Set(num) - - // No need to set values for JSON null unless the field type is - // google.protobuf.Value or google.protobuf.NullValue. - if tok, _ := d.Peek(); tok.Kind() == json.Null && !isKnownValue(fd) && !isNullValue(fd) { - d.Read() - continue - } - - switch { - case fd.IsList(): - list := m.Mutable(fd).List() - if err := d.unmarshalList(list, fd); err != nil { - return err - } - case fd.IsMap(): - mmap := m.Mutable(fd).Map() - if err := d.unmarshalMap(mmap, fd); err != nil { - return err - } - default: - // If field is a oneof, check if it has already been set. - if od := fd.ContainingOneof(); od != nil { - idx := uint64(od.Index()) - if seenOneofs.Has(idx) { - return d.newError(tok.Pos(), "error parsing %s, oneof %v is already set", tok.RawString(), od.FullName()) - } - seenOneofs.Set(idx) - } - - // Required or optional fields. - if err := d.unmarshalSingular(m, fd); err != nil { - return err - } - } - } -} - -func isKnownValue(fd protoreflect.FieldDescriptor) bool { - md := fd.Message() - return md != nil && md.FullName() == genid.Value_message_fullname -} - -func isNullValue(fd protoreflect.FieldDescriptor) bool { - ed := fd.Enum() - return ed != nil && ed.FullName() == genid.NullValue_enum_fullname -} - -// unmarshalSingular unmarshals to the non-repeated field specified -// by the given FieldDescriptor. -func (d decoder) unmarshalSingular(m protoreflect.Message, fd protoreflect.FieldDescriptor) error { - var val protoreflect.Value - var err error - switch fd.Kind() { - case protoreflect.MessageKind, protoreflect.GroupKind: - val = m.NewField(fd) - err = d.unmarshalMessage(val.Message(), false) - default: - val, err = d.unmarshalScalar(fd) - } - - if err != nil { - return err - } - if val.IsValid() { - m.Set(fd, val) - } - return nil -} - -// unmarshalScalar unmarshals to a scalar/enum protoreflect.Value specified by -// the given FieldDescriptor. -func (d decoder) unmarshalScalar(fd protoreflect.FieldDescriptor) (protoreflect.Value, error) { - const b32 int = 32 - const b64 int = 64 - - tok, err := d.Read() - if err != nil { - return protoreflect.Value{}, err - } - - kind := fd.Kind() - switch kind { - case protoreflect.BoolKind: - if tok.Kind() == json.Bool { - return protoreflect.ValueOfBool(tok.Bool()), nil - } - - case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind: - if v, ok := unmarshalInt(tok, b32); ok { - return v, nil - } - - case protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind: - if v, ok := unmarshalInt(tok, b64); ok { - return v, nil - } - - case protoreflect.Uint32Kind, protoreflect.Fixed32Kind: - if v, ok := unmarshalUint(tok, b32); ok { - return v, nil - } - - case protoreflect.Uint64Kind, protoreflect.Fixed64Kind: - if v, ok := unmarshalUint(tok, b64); ok { - return v, nil - } - - case protoreflect.FloatKind: - if v, ok := unmarshalFloat(tok, b32); ok { - return v, nil - } - - case protoreflect.DoubleKind: - if v, ok := unmarshalFloat(tok, b64); ok { - return v, nil - } - - case protoreflect.StringKind: - if tok.Kind() == json.String { - return protoreflect.ValueOfString(tok.ParsedString()), nil - } - - case protoreflect.BytesKind: - if v, ok := unmarshalBytes(tok); ok { - return v, nil - } - - case protoreflect.EnumKind: - if v, ok := unmarshalEnum(tok, fd, d.opts.DiscardUnknown); ok { - return v, nil - } - - default: - panic(fmt.Sprintf("unmarshalScalar: invalid scalar kind %v", kind)) - } - - return protoreflect.Value{}, d.newError(tok.Pos(), "invalid value for %v type: %v", kind, tok.RawString()) -} - -func unmarshalInt(tok json.Token, bitSize int) (protoreflect.Value, bool) { - switch tok.Kind() { - case json.Number: - return getInt(tok, bitSize) - - case json.String: - // Decode number from string. - s := strings.TrimSpace(tok.ParsedString()) - if len(s) != len(tok.ParsedString()) { - return protoreflect.Value{}, false - } - dec := json.NewDecoder([]byte(s)) - tok, err := dec.Read() - if err != nil { - return protoreflect.Value{}, false - } - return getInt(tok, bitSize) - } - return protoreflect.Value{}, false -} - -func getInt(tok json.Token, bitSize int) (protoreflect.Value, bool) { - n, ok := tok.Int(bitSize) - if !ok { - return protoreflect.Value{}, false - } - if bitSize == 32 { - return protoreflect.ValueOfInt32(int32(n)), true - } - return protoreflect.ValueOfInt64(n), true -} - -func unmarshalUint(tok json.Token, bitSize int) (protoreflect.Value, bool) { - switch tok.Kind() { - case json.Number: - return getUint(tok, bitSize) - - case json.String: - // Decode number from string. - s := strings.TrimSpace(tok.ParsedString()) - if len(s) != len(tok.ParsedString()) { - return protoreflect.Value{}, false - } - dec := json.NewDecoder([]byte(s)) - tok, err := dec.Read() - if err != nil { - return protoreflect.Value{}, false - } - return getUint(tok, bitSize) - } - return protoreflect.Value{}, false -} - -func getUint(tok json.Token, bitSize int) (protoreflect.Value, bool) { - n, ok := tok.Uint(bitSize) - if !ok { - return protoreflect.Value{}, false - } - if bitSize == 32 { - return protoreflect.ValueOfUint32(uint32(n)), true - } - return protoreflect.ValueOfUint64(n), true -} - -func unmarshalFloat(tok json.Token, bitSize int) (protoreflect.Value, bool) { - switch tok.Kind() { - case json.Number: - return getFloat(tok, bitSize) - - case json.String: - s := tok.ParsedString() - switch s { - case "NaN": - if bitSize == 32 { - return protoreflect.ValueOfFloat32(float32(math.NaN())), true - } - return protoreflect.ValueOfFloat64(math.NaN()), true - case "Infinity": - if bitSize == 32 { - return protoreflect.ValueOfFloat32(float32(math.Inf(+1))), true - } - return protoreflect.ValueOfFloat64(math.Inf(+1)), true - case "-Infinity": - if bitSize == 32 { - return protoreflect.ValueOfFloat32(float32(math.Inf(-1))), true - } - return protoreflect.ValueOfFloat64(math.Inf(-1)), true - } - - // Decode number from string. - if len(s) != len(strings.TrimSpace(s)) { - return protoreflect.Value{}, false - } - dec := json.NewDecoder([]byte(s)) - tok, err := dec.Read() - if err != nil { - return protoreflect.Value{}, false - } - return getFloat(tok, bitSize) - } - return protoreflect.Value{}, false -} - -func getFloat(tok json.Token, bitSize int) (protoreflect.Value, bool) { - n, ok := tok.Float(bitSize) - if !ok { - return protoreflect.Value{}, false - } - if bitSize == 32 { - return protoreflect.ValueOfFloat32(float32(n)), true - } - return protoreflect.ValueOfFloat64(n), true -} - -func unmarshalBytes(tok json.Token) (protoreflect.Value, bool) { - if tok.Kind() != json.String { - return protoreflect.Value{}, false - } - - s := tok.ParsedString() - enc := base64.StdEncoding - if strings.ContainsAny(s, "-_") { - enc = base64.URLEncoding - } - if len(s)%4 != 0 { - enc = enc.WithPadding(base64.NoPadding) - } - b, err := enc.DecodeString(s) - if err != nil { - return protoreflect.Value{}, false - } - return protoreflect.ValueOfBytes(b), true -} - -func unmarshalEnum(tok json.Token, fd protoreflect.FieldDescriptor, discardUnknown bool) (protoreflect.Value, bool) { - switch tok.Kind() { - case json.String: - // Lookup EnumNumber based on name. - s := tok.ParsedString() - if enumVal := fd.Enum().Values().ByName(protoreflect.Name(s)); enumVal != nil { - return protoreflect.ValueOfEnum(enumVal.Number()), true - } - if discardUnknown { - return protoreflect.Value{}, true - } - - case json.Number: - if n, ok := tok.Int(32); ok { - return protoreflect.ValueOfEnum(protoreflect.EnumNumber(n)), true - } - - case json.Null: - // This is only valid for google.protobuf.NullValue. - if isNullValue(fd) { - return protoreflect.ValueOfEnum(0), true - } - } - - return protoreflect.Value{}, false -} - -func (d decoder) unmarshalList(list protoreflect.List, fd protoreflect.FieldDescriptor) error { - tok, err := d.Read() - if err != nil { - return err - } - if tok.Kind() != json.ArrayOpen { - return d.unexpectedTokenError(tok) - } - - switch fd.Kind() { - case protoreflect.MessageKind, protoreflect.GroupKind: - for { - tok, err := d.Peek() - if err != nil { - return err - } - - if tok.Kind() == json.ArrayClose { - d.Read() - return nil - } - - val := list.NewElement() - if err := d.unmarshalMessage(val.Message(), false); err != nil { - return err - } - list.Append(val) - } - default: - for { - tok, err := d.Peek() - if err != nil { - return err - } - - if tok.Kind() == json.ArrayClose { - d.Read() - return nil - } - - val, err := d.unmarshalScalar(fd) - if err != nil { - return err - } - if val.IsValid() { - list.Append(val) - } - } - } - - return nil -} - -func (d decoder) unmarshalMap(mmap protoreflect.Map, fd protoreflect.FieldDescriptor) error { - tok, err := d.Read() - if err != nil { - return err - } - if tok.Kind() != json.ObjectOpen { - return d.unexpectedTokenError(tok) - } - - // Determine ahead whether map entry is a scalar type or a message type in - // order to call the appropriate unmarshalMapValue func inside the for loop - // below. - var unmarshalMapValue func() (protoreflect.Value, error) - switch fd.MapValue().Kind() { - case protoreflect.MessageKind, protoreflect.GroupKind: - unmarshalMapValue = func() (protoreflect.Value, error) { - val := mmap.NewValue() - if err := d.unmarshalMessage(val.Message(), false); err != nil { - return protoreflect.Value{}, err - } - return val, nil - } - default: - unmarshalMapValue = func() (protoreflect.Value, error) { - return d.unmarshalScalar(fd.MapValue()) - } - } - -Loop: - for { - // Read field name. - tok, err := d.Read() - if err != nil { - return err - } - switch tok.Kind() { - default: - return d.unexpectedTokenError(tok) - case json.ObjectClose: - break Loop - case json.Name: - // Continue. - } - - // Unmarshal field name. - pkey, err := d.unmarshalMapKey(tok, fd.MapKey()) - if err != nil { - return err - } - - // Check for duplicate field name. - if mmap.Has(pkey) { - return d.newError(tok.Pos(), "duplicate map key %v", tok.RawString()) - } - - // Read and unmarshal field value. - pval, err := unmarshalMapValue() - if err != nil { - return err - } - if pval.IsValid() { - mmap.Set(pkey, pval) - } - } - - return nil -} - -// unmarshalMapKey converts given token of Name kind into a protoreflect.MapKey. -// A map key type is any integral or string type. -func (d decoder) unmarshalMapKey(tok json.Token, fd protoreflect.FieldDescriptor) (protoreflect.MapKey, error) { - const b32 = 32 - const b64 = 64 - const base10 = 10 - - name := tok.Name() - kind := fd.Kind() - switch kind { - case protoreflect.StringKind: - return protoreflect.ValueOfString(name).MapKey(), nil - - case protoreflect.BoolKind: - switch name { - case "true": - return protoreflect.ValueOfBool(true).MapKey(), nil - case "false": - return protoreflect.ValueOfBool(false).MapKey(), nil - } - - case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind: - if n, err := strconv.ParseInt(name, base10, b32); err == nil { - return protoreflect.ValueOfInt32(int32(n)).MapKey(), nil - } - - case protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind: - if n, err := strconv.ParseInt(name, base10, b64); err == nil { - return protoreflect.ValueOfInt64(int64(n)).MapKey(), nil - } - - case protoreflect.Uint32Kind, protoreflect.Fixed32Kind: - if n, err := strconv.ParseUint(name, base10, b32); err == nil { - return protoreflect.ValueOfUint32(uint32(n)).MapKey(), nil - } - - case protoreflect.Uint64Kind, protoreflect.Fixed64Kind: - if n, err := strconv.ParseUint(name, base10, b64); err == nil { - return protoreflect.ValueOfUint64(uint64(n)).MapKey(), nil - } - - default: - panic(fmt.Sprintf("invalid kind for map key: %v", kind)) - } - - return protoreflect.MapKey{}, d.newError(tok.Pos(), "invalid value for %v key: %s", kind, tok.RawString()) -} diff --git a/vendor/google.golang.org/protobuf/encoding/protojson/doc.go b/vendor/google.golang.org/protobuf/encoding/protojson/doc.go deleted file mode 100644 index ae71007c1..000000000 --- a/vendor/google.golang.org/protobuf/encoding/protojson/doc.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package protojson marshals and unmarshals protocol buffer messages as JSON -// format. It follows the guide at -// https://protobuf.dev/programming-guides/proto3#json. -// -// This package produces a different output than the standard [encoding/json] -// package, which does not operate correctly on protocol buffer messages. -package protojson diff --git a/vendor/google.golang.org/protobuf/encoding/protojson/encode.go b/vendor/google.golang.org/protobuf/encoding/protojson/encode.go deleted file mode 100644 index 29846df22..000000000 --- a/vendor/google.golang.org/protobuf/encoding/protojson/encode.go +++ /dev/null @@ -1,382 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package protojson - -import ( - "encoding/base64" - "fmt" - - "google.golang.org/protobuf/internal/encoding/json" - "google.golang.org/protobuf/internal/encoding/messageset" - "google.golang.org/protobuf/internal/errors" - "google.golang.org/protobuf/internal/filedesc" - "google.golang.org/protobuf/internal/flags" - "google.golang.org/protobuf/internal/genid" - "google.golang.org/protobuf/internal/order" - "google.golang.org/protobuf/internal/pragma" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/reflect/protoreflect" - "google.golang.org/protobuf/reflect/protoregistry" -) - -const defaultIndent = " " - -// Format formats the message as a multiline string. -// This function is only intended for human consumption and ignores errors. -// Do not depend on the output being stable. Its output will change across -// different builds of your program, even when using the same version of the -// protobuf module. -func Format(m proto.Message) string { - return MarshalOptions{Multiline: true}.Format(m) -} - -// Marshal writes the given [proto.Message] in JSON format using default options. -// Do not depend on the output being stable. Its output will change across -// different builds of your program, even when using the same version of the -// protobuf module. -func Marshal(m proto.Message) ([]byte, error) { - return MarshalOptions{}.Marshal(m) -} - -// MarshalOptions is a configurable JSON format marshaler. -type MarshalOptions struct { - pragma.NoUnkeyedLiterals - - // Multiline specifies whether the marshaler should format the output in - // indented-form with every textual element on a new line. - // If Indent is an empty string, then an arbitrary indent is chosen. - Multiline bool - - // Indent specifies the set of indentation characters to use in a multiline - // formatted output such that every entry is preceded by Indent and - // terminated by a newline. If non-empty, then Multiline is treated as true. - // Indent can only be composed of space or tab characters. - Indent string - - // AllowPartial allows messages that have missing required fields to marshal - // without returning an error. If AllowPartial is false (the default), - // Marshal will return error if there are any missing required fields. - AllowPartial bool - - // UseProtoNames uses proto field name instead of lowerCamelCase name in JSON - // field names. - UseProtoNames bool - - // UseEnumNumbers emits enum values as numbers. - UseEnumNumbers bool - - // EmitUnpopulated specifies whether to emit unpopulated fields. It does not - // emit unpopulated oneof fields or unpopulated extension fields. - // The JSON value emitted for unpopulated fields are as follows: - // ╔═══════╤════════════════════════════╗ - // ║ JSON │ Protobuf field ║ - // ╠═══════╪════════════════════════════╣ - // ║ false │ proto3 boolean fields ║ - // ║ 0 │ proto3 numeric fields ║ - // ║ "" │ proto3 string/bytes fields ║ - // ║ null │ proto2 scalar fields ║ - // ║ null │ message fields ║ - // ║ [] │ list fields ║ - // ║ {} │ map fields ║ - // ╚═══════╧════════════════════════════╝ - EmitUnpopulated bool - - // EmitDefaultValues specifies whether to emit default-valued primitive fields, - // empty lists, and empty maps. The fields affected are as follows: - // ╔═══════╤════════════════════════════════════════╗ - // ║ JSON │ Protobuf field ║ - // ╠═══════╪════════════════════════════════════════╣ - // ║ false │ non-optional scalar boolean fields ║ - // ║ 0 │ non-optional scalar numeric fields ║ - // ║ "" │ non-optional scalar string/byte fields ║ - // ║ [] │ empty repeated fields ║ - // ║ {} │ empty map fields ║ - // ╚═══════╧════════════════════════════════════════╝ - // - // Behaves similarly to EmitUnpopulated, but does not emit "null"-value fields, - // i.e. presence-sensing fields that are omitted will remain omitted to preserve - // presence-sensing. - // EmitUnpopulated takes precedence over EmitDefaultValues since the former generates - // a strict superset of the latter. - EmitDefaultValues bool - - // Resolver is used for looking up types when expanding google.protobuf.Any - // messages. If nil, this defaults to using protoregistry.GlobalTypes. - Resolver interface { - protoregistry.ExtensionTypeResolver - protoregistry.MessageTypeResolver - } -} - -// Format formats the message as a string. -// This method is only intended for human consumption and ignores errors. -// Do not depend on the output being stable. Its output will change across -// different builds of your program, even when using the same version of the -// protobuf module. -func (o MarshalOptions) Format(m proto.Message) string { - if m == nil || !m.ProtoReflect().IsValid() { - return "" // invalid syntax, but okay since this is for debugging - } - o.AllowPartial = true - b, _ := o.Marshal(m) - return string(b) -} - -// Marshal marshals the given [proto.Message] in the JSON format using options in -// Do not depend on the output being stable. Its output will change across -// different builds of your program, even when using the same version of the -// protobuf module. -func (o MarshalOptions) Marshal(m proto.Message) ([]byte, error) { - return o.marshal(nil, m) -} - -// MarshalAppend appends the JSON format encoding of m to b, -// returning the result. -func (o MarshalOptions) MarshalAppend(b []byte, m proto.Message) ([]byte, error) { - return o.marshal(b, m) -} - -// marshal is a centralized function that all marshal operations go through. -// For profiling purposes, avoid changing the name of this function or -// introducing other code paths for marshal that do not go through this. -func (o MarshalOptions) marshal(b []byte, m proto.Message) ([]byte, error) { - if o.Multiline && o.Indent == "" { - o.Indent = defaultIndent - } - if o.Resolver == nil { - o.Resolver = protoregistry.GlobalTypes - } - - internalEnc, err := json.NewEncoder(b, o.Indent) - if err != nil { - return nil, err - } - - // Treat nil message interface as an empty message, - // in which case the output in an empty JSON object. - if m == nil { - return append(b, '{', '}'), nil - } - - enc := encoder{internalEnc, o} - if err := enc.marshalMessage(m.ProtoReflect(), ""); err != nil { - return nil, err - } - if o.AllowPartial { - return enc.Bytes(), nil - } - return enc.Bytes(), proto.CheckInitialized(m) -} - -type encoder struct { - *json.Encoder - opts MarshalOptions -} - -// typeFieldDesc is a synthetic field descriptor used for the "@type" field. -var typeFieldDesc = func() protoreflect.FieldDescriptor { - var fd filedesc.Field - fd.L0.FullName = "@type" - fd.L0.Index = -1 - fd.L1.Cardinality = protoreflect.Optional - fd.L1.Kind = protoreflect.StringKind - return &fd -}() - -// typeURLFieldRanger wraps a protoreflect.Message and modifies its Range method -// to additionally iterate over a synthetic field for the type URL. -type typeURLFieldRanger struct { - order.FieldRanger - typeURL string -} - -func (m typeURLFieldRanger) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if !f(typeFieldDesc, protoreflect.ValueOfString(m.typeURL)) { - return - } - m.FieldRanger.Range(f) -} - -// unpopulatedFieldRanger wraps a protoreflect.Message and modifies its Range -// method to additionally iterate over unpopulated fields. -type unpopulatedFieldRanger struct { - protoreflect.Message - - skipNull bool -} - -func (m unpopulatedFieldRanger) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - fds := m.Descriptor().Fields() - for i := 0; i < fds.Len(); i++ { - fd := fds.Get(i) - if m.Has(fd) || fd.ContainingOneof() != nil { - continue // ignore populated fields and fields within a oneofs - } - - v := m.Get(fd) - isProto2Scalar := fd.Syntax() == protoreflect.Proto2 && fd.Default().IsValid() - isSingularMessage := fd.Cardinality() != protoreflect.Repeated && fd.Message() != nil - if isProto2Scalar || isSingularMessage { - if m.skipNull { - continue - } - v = protoreflect.Value{} // use invalid value to emit null - } - if !f(fd, v) { - return - } - } - m.Message.Range(f) -} - -// marshalMessage marshals the fields in the given protoreflect.Message. -// If the typeURL is non-empty, then a synthetic "@type" field is injected -// containing the URL as the value. -func (e encoder) marshalMessage(m protoreflect.Message, typeURL string) error { - if !flags.ProtoLegacy && messageset.IsMessageSet(m.Descriptor()) { - return errors.New("no support for proto1 MessageSets") - } - - if marshal := wellKnownTypeMarshaler(m.Descriptor().FullName()); marshal != nil { - return marshal(e, m) - } - - e.StartObject() - defer e.EndObject() - - var fields order.FieldRanger = m - switch { - case e.opts.EmitUnpopulated: - fields = unpopulatedFieldRanger{Message: m, skipNull: false} - case e.opts.EmitDefaultValues: - fields = unpopulatedFieldRanger{Message: m, skipNull: true} - } - if typeURL != "" { - fields = typeURLFieldRanger{fields, typeURL} - } - - var err error - order.RangeFields(fields, order.IndexNameFieldOrder, func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool { - name := fd.JSONName() - if e.opts.UseProtoNames { - name = fd.TextName() - } - - if err = e.WriteName(name); err != nil { - return false - } - if err = e.marshalValue(v, fd); err != nil { - return false - } - return true - }) - return err -} - -// marshalValue marshals the given protoreflect.Value. -func (e encoder) marshalValue(val protoreflect.Value, fd protoreflect.FieldDescriptor) error { - switch { - case fd.IsList(): - return e.marshalList(val.List(), fd) - case fd.IsMap(): - return e.marshalMap(val.Map(), fd) - default: - return e.marshalSingular(val, fd) - } -} - -// marshalSingular marshals the given non-repeated field value. This includes -// all scalar types, enums, messages, and groups. -func (e encoder) marshalSingular(val protoreflect.Value, fd protoreflect.FieldDescriptor) error { - if !val.IsValid() { - e.WriteNull() - return nil - } - - switch kind := fd.Kind(); kind { - case protoreflect.BoolKind: - e.WriteBool(val.Bool()) - - case protoreflect.StringKind: - if e.WriteString(val.String()) != nil { - return errors.InvalidUTF8(string(fd.FullName())) - } - - case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind: - e.WriteInt(val.Int()) - - case protoreflect.Uint32Kind, protoreflect.Fixed32Kind: - e.WriteUint(val.Uint()) - - case protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Uint64Kind, - protoreflect.Sfixed64Kind, protoreflect.Fixed64Kind: - // 64-bit integers are written out as JSON string. - e.WriteString(val.String()) - - case protoreflect.FloatKind: - // Encoder.WriteFloat handles the special numbers NaN and infinites. - e.WriteFloat(val.Float(), 32) - - case protoreflect.DoubleKind: - // Encoder.WriteFloat handles the special numbers NaN and infinites. - e.WriteFloat(val.Float(), 64) - - case protoreflect.BytesKind: - e.WriteString(base64.StdEncoding.EncodeToString(val.Bytes())) - - case protoreflect.EnumKind: - if fd.Enum().FullName() == genid.NullValue_enum_fullname { - e.WriteNull() - } else { - desc := fd.Enum().Values().ByNumber(val.Enum()) - if e.opts.UseEnumNumbers || desc == nil { - e.WriteInt(int64(val.Enum())) - } else { - e.WriteString(string(desc.Name())) - } - } - - case protoreflect.MessageKind, protoreflect.GroupKind: - if err := e.marshalMessage(val.Message(), ""); err != nil { - return err - } - - default: - panic(fmt.Sprintf("%v has unknown kind: %v", fd.FullName(), kind)) - } - return nil -} - -// marshalList marshals the given protoreflect.List. -func (e encoder) marshalList(list protoreflect.List, fd protoreflect.FieldDescriptor) error { - e.StartArray() - defer e.EndArray() - - for i := 0; i < list.Len(); i++ { - item := list.Get(i) - if err := e.marshalSingular(item, fd); err != nil { - return err - } - } - return nil -} - -// marshalMap marshals given protoreflect.Map. -func (e encoder) marshalMap(mmap protoreflect.Map, fd protoreflect.FieldDescriptor) error { - e.StartObject() - defer e.EndObject() - - var err error - order.RangeEntries(mmap, order.GenericKeyOrder, func(k protoreflect.MapKey, v protoreflect.Value) bool { - if err = e.WriteName(k.String()); err != nil { - return false - } - if err = e.marshalSingular(v, fd.MapValue()); err != nil { - return false - } - return true - }) - return err -} diff --git a/vendor/google.golang.org/protobuf/encoding/protojson/well_known_types.go b/vendor/google.golang.org/protobuf/encoding/protojson/well_known_types.go deleted file mode 100644 index 4b177c820..000000000 --- a/vendor/google.golang.org/protobuf/encoding/protojson/well_known_types.go +++ /dev/null @@ -1,876 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package protojson - -import ( - "bytes" - "fmt" - "math" - "strconv" - "strings" - "time" - - "google.golang.org/protobuf/internal/encoding/json" - "google.golang.org/protobuf/internal/errors" - "google.golang.org/protobuf/internal/genid" - "google.golang.org/protobuf/internal/strs" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/reflect/protoreflect" -) - -type marshalFunc func(encoder, protoreflect.Message) error - -// wellKnownTypeMarshaler returns a marshal function if the message type -// has specialized serialization behavior. It returns nil otherwise. -func wellKnownTypeMarshaler(name protoreflect.FullName) marshalFunc { - if name.Parent() == genid.GoogleProtobuf_package { - switch name.Name() { - case genid.Any_message_name: - return encoder.marshalAny - case genid.Timestamp_message_name: - return encoder.marshalTimestamp - case genid.Duration_message_name: - return encoder.marshalDuration - case genid.BoolValue_message_name, - genid.Int32Value_message_name, - genid.Int64Value_message_name, - genid.UInt32Value_message_name, - genid.UInt64Value_message_name, - genid.FloatValue_message_name, - genid.DoubleValue_message_name, - genid.StringValue_message_name, - genid.BytesValue_message_name: - return encoder.marshalWrapperType - case genid.Struct_message_name: - return encoder.marshalStruct - case genid.ListValue_message_name: - return encoder.marshalListValue - case genid.Value_message_name: - return encoder.marshalKnownValue - case genid.FieldMask_message_name: - return encoder.marshalFieldMask - case genid.Empty_message_name: - return encoder.marshalEmpty - } - } - return nil -} - -type unmarshalFunc func(decoder, protoreflect.Message) error - -// wellKnownTypeUnmarshaler returns a unmarshal function if the message type -// has specialized serialization behavior. It returns nil otherwise. -func wellKnownTypeUnmarshaler(name protoreflect.FullName) unmarshalFunc { - if name.Parent() == genid.GoogleProtobuf_package { - switch name.Name() { - case genid.Any_message_name: - return decoder.unmarshalAny - case genid.Timestamp_message_name: - return decoder.unmarshalTimestamp - case genid.Duration_message_name: - return decoder.unmarshalDuration - case genid.BoolValue_message_name, - genid.Int32Value_message_name, - genid.Int64Value_message_name, - genid.UInt32Value_message_name, - genid.UInt64Value_message_name, - genid.FloatValue_message_name, - genid.DoubleValue_message_name, - genid.StringValue_message_name, - genid.BytesValue_message_name: - return decoder.unmarshalWrapperType - case genid.Struct_message_name: - return decoder.unmarshalStruct - case genid.ListValue_message_name: - return decoder.unmarshalListValue - case genid.Value_message_name: - return decoder.unmarshalKnownValue - case genid.FieldMask_message_name: - return decoder.unmarshalFieldMask - case genid.Empty_message_name: - return decoder.unmarshalEmpty - } - } - return nil -} - -// The JSON representation of an Any message uses the regular representation of -// the deserialized, embedded message, with an additional field `@type` which -// contains the type URL. If the embedded message type is well-known and has a -// custom JSON representation, that representation will be embedded adding a -// field `value` which holds the custom JSON in addition to the `@type` field. - -func (e encoder) marshalAny(m protoreflect.Message) error { - fds := m.Descriptor().Fields() - fdType := fds.ByNumber(genid.Any_TypeUrl_field_number) - fdValue := fds.ByNumber(genid.Any_Value_field_number) - - if !m.Has(fdType) { - if !m.Has(fdValue) { - // If message is empty, marshal out empty JSON object. - e.StartObject() - e.EndObject() - return nil - } else { - // Return error if type_url field is not set, but value is set. - return errors.New("%s: %v is not set", genid.Any_message_fullname, genid.Any_TypeUrl_field_name) - } - } - - typeVal := m.Get(fdType) - valueVal := m.Get(fdValue) - - // Resolve the type in order to unmarshal value field. - typeURL := typeVal.String() - emt, err := e.opts.Resolver.FindMessageByURL(typeURL) - if err != nil { - return errors.New("%s: unable to resolve %q: %v", genid.Any_message_fullname, typeURL, err) - } - - em := emt.New() - err = proto.UnmarshalOptions{ - AllowPartial: true, // never check required fields inside an Any - Resolver: e.opts.Resolver, - }.Unmarshal(valueVal.Bytes(), em.Interface()) - if err != nil { - return errors.New("%s: unable to unmarshal %q: %v", genid.Any_message_fullname, typeURL, err) - } - - // If type of value has custom JSON encoding, marshal out a field "value" - // with corresponding custom JSON encoding of the embedded message as a - // field. - if marshal := wellKnownTypeMarshaler(emt.Descriptor().FullName()); marshal != nil { - e.StartObject() - defer e.EndObject() - - // Marshal out @type field. - e.WriteName("@type") - if err := e.WriteString(typeURL); err != nil { - return err - } - - e.WriteName("value") - return marshal(e, em) - } - - // Else, marshal out the embedded message's fields in this Any object. - if err := e.marshalMessage(em, typeURL); err != nil { - return err - } - - return nil -} - -func (d decoder) unmarshalAny(m protoreflect.Message) error { - // Peek to check for json.ObjectOpen to avoid advancing a read. - start, err := d.Peek() - if err != nil { - return err - } - if start.Kind() != json.ObjectOpen { - return d.unexpectedTokenError(start) - } - - // Use another decoder to parse the unread bytes for @type field. This - // avoids advancing a read from current decoder because the current JSON - // object may contain the fields of the embedded type. - dec := decoder{d.Clone(), UnmarshalOptions{RecursionLimit: d.opts.RecursionLimit}} - tok, err := findTypeURL(dec) - switch err { - case errEmptyObject: - // An empty JSON object translates to an empty Any message. - d.Read() // Read json.ObjectOpen. - d.Read() // Read json.ObjectClose. - return nil - - case errMissingType: - if d.opts.DiscardUnknown { - // Treat all fields as unknowns, similar to an empty object. - return d.skipJSONValue() - } - // Use start.Pos() for line position. - return d.newError(start.Pos(), err.Error()) - - default: - if err != nil { - return err - } - } - - typeURL := tok.ParsedString() - emt, err := d.opts.Resolver.FindMessageByURL(typeURL) - if err != nil { - return d.newError(tok.Pos(), "unable to resolve %v: %q", tok.RawString(), err) - } - - // Create new message for the embedded message type and unmarshal into it. - em := emt.New() - if unmarshal := wellKnownTypeUnmarshaler(emt.Descriptor().FullName()); unmarshal != nil { - // If embedded message is a custom type, - // unmarshal the JSON "value" field into it. - if err := d.unmarshalAnyValue(unmarshal, em); err != nil { - return err - } - } else { - // Else unmarshal the current JSON object into it. - if err := d.unmarshalMessage(em, true); err != nil { - return err - } - } - // Serialize the embedded message and assign the resulting bytes to the - // proto value field. - b, err := proto.MarshalOptions{ - AllowPartial: true, // No need to check required fields inside an Any. - Deterministic: true, - }.Marshal(em.Interface()) - if err != nil { - return d.newError(start.Pos(), "error in marshaling Any.value field: %v", err) - } - - fds := m.Descriptor().Fields() - fdType := fds.ByNumber(genid.Any_TypeUrl_field_number) - fdValue := fds.ByNumber(genid.Any_Value_field_number) - - m.Set(fdType, protoreflect.ValueOfString(typeURL)) - m.Set(fdValue, protoreflect.ValueOfBytes(b)) - return nil -} - -var errEmptyObject = fmt.Errorf(`empty object`) -var errMissingType = fmt.Errorf(`missing "@type" field`) - -// findTypeURL returns the token for the "@type" field value from the given -// JSON bytes. It is expected that the given bytes start with json.ObjectOpen. -// It returns errEmptyObject if the JSON object is empty or errMissingType if -// @type field does not exist. It returns other error if the @type field is not -// valid or other decoding issues. -func findTypeURL(d decoder) (json.Token, error) { - var typeURL string - var typeTok json.Token - numFields := 0 - // Skip start object. - d.Read() - -Loop: - for { - tok, err := d.Read() - if err != nil { - return json.Token{}, err - } - - switch tok.Kind() { - case json.ObjectClose: - if typeURL == "" { - // Did not find @type field. - if numFields > 0 { - return json.Token{}, errMissingType - } - return json.Token{}, errEmptyObject - } - break Loop - - case json.Name: - numFields++ - if tok.Name() != "@type" { - // Skip value. - if err := d.skipJSONValue(); err != nil { - return json.Token{}, err - } - continue - } - - // Return error if this was previously set already. - if typeURL != "" { - return json.Token{}, d.newError(tok.Pos(), `duplicate "@type" field`) - } - // Read field value. - tok, err := d.Read() - if err != nil { - return json.Token{}, err - } - if tok.Kind() != json.String { - return json.Token{}, d.newError(tok.Pos(), `@type field value is not a string: %v`, tok.RawString()) - } - typeURL = tok.ParsedString() - if typeURL == "" { - return json.Token{}, d.newError(tok.Pos(), `@type field contains empty value`) - } - typeTok = tok - } - } - - return typeTok, nil -} - -// skipJSONValue parses a JSON value (null, boolean, string, number, object and -// array) in order to advance the read to the next JSON value. It relies on -// the decoder returning an error if the types are not in valid sequence. -func (d decoder) skipJSONValue() error { - var open int - for { - tok, err := d.Read() - if err != nil { - return err - } - switch tok.Kind() { - case json.ObjectClose, json.ArrayClose: - open-- - case json.ObjectOpen, json.ArrayOpen: - open++ - if open > d.opts.RecursionLimit { - return errors.New("exceeded max recursion depth") - } - case json.EOF: - // This can only happen if there's a bug in Decoder.Read. - // Avoid an infinite loop if this does happen. - return errors.New("unexpected EOF") - } - if open == 0 { - return nil - } - } -} - -// unmarshalAnyValue unmarshals the given custom-type message from the JSON -// object's "value" field. -func (d decoder) unmarshalAnyValue(unmarshal unmarshalFunc, m protoreflect.Message) error { - // Skip ObjectOpen, and start reading the fields. - d.Read() - - var found bool // Used for detecting duplicate "value". - for { - tok, err := d.Read() - if err != nil { - return err - } - switch tok.Kind() { - case json.ObjectClose: - if !found { - return d.newError(tok.Pos(), `missing "value" field`) - } - return nil - - case json.Name: - switch tok.Name() { - case "@type": - // Skip the value as this was previously parsed already. - d.Read() - - case "value": - if found { - return d.newError(tok.Pos(), `duplicate "value" field`) - } - // Unmarshal the field value into the given message. - if err := unmarshal(d, m); err != nil { - return err - } - found = true - - default: - if d.opts.DiscardUnknown { - if err := d.skipJSONValue(); err != nil { - return err - } - continue - } - return d.newError(tok.Pos(), "unknown field %v", tok.RawString()) - } - } - } -} - -// Wrapper types are encoded as JSON primitives like string, number or boolean. - -func (e encoder) marshalWrapperType(m protoreflect.Message) error { - fd := m.Descriptor().Fields().ByNumber(genid.WrapperValue_Value_field_number) - val := m.Get(fd) - return e.marshalSingular(val, fd) -} - -func (d decoder) unmarshalWrapperType(m protoreflect.Message) error { - fd := m.Descriptor().Fields().ByNumber(genid.WrapperValue_Value_field_number) - val, err := d.unmarshalScalar(fd) - if err != nil { - return err - } - m.Set(fd, val) - return nil -} - -// The JSON representation for Empty is an empty JSON object. - -func (e encoder) marshalEmpty(protoreflect.Message) error { - e.StartObject() - e.EndObject() - return nil -} - -func (d decoder) unmarshalEmpty(protoreflect.Message) error { - tok, err := d.Read() - if err != nil { - return err - } - if tok.Kind() != json.ObjectOpen { - return d.unexpectedTokenError(tok) - } - - for { - tok, err := d.Read() - if err != nil { - return err - } - switch tok.Kind() { - case json.ObjectClose: - return nil - - case json.Name: - if d.opts.DiscardUnknown { - if err := d.skipJSONValue(); err != nil { - return err - } - continue - } - return d.newError(tok.Pos(), "unknown field %v", tok.RawString()) - - default: - return d.unexpectedTokenError(tok) - } - } -} - -// The JSON representation for Struct is a JSON object that contains the encoded -// Struct.fields map and follows the serialization rules for a map. - -func (e encoder) marshalStruct(m protoreflect.Message) error { - fd := m.Descriptor().Fields().ByNumber(genid.Struct_Fields_field_number) - return e.marshalMap(m.Get(fd).Map(), fd) -} - -func (d decoder) unmarshalStruct(m protoreflect.Message) error { - fd := m.Descriptor().Fields().ByNumber(genid.Struct_Fields_field_number) - return d.unmarshalMap(m.Mutable(fd).Map(), fd) -} - -// The JSON representation for ListValue is JSON array that contains the encoded -// ListValue.values repeated field and follows the serialization rules for a -// repeated field. - -func (e encoder) marshalListValue(m protoreflect.Message) error { - fd := m.Descriptor().Fields().ByNumber(genid.ListValue_Values_field_number) - return e.marshalList(m.Get(fd).List(), fd) -} - -func (d decoder) unmarshalListValue(m protoreflect.Message) error { - fd := m.Descriptor().Fields().ByNumber(genid.ListValue_Values_field_number) - return d.unmarshalList(m.Mutable(fd).List(), fd) -} - -// The JSON representation for a Value is dependent on the oneof field that is -// set. Each of the field in the oneof has its own custom serialization rule. A -// Value message needs to be a oneof field set, else it is an error. - -func (e encoder) marshalKnownValue(m protoreflect.Message) error { - od := m.Descriptor().Oneofs().ByName(genid.Value_Kind_oneof_name) - fd := m.WhichOneof(od) - if fd == nil { - return errors.New("%s: none of the oneof fields is set", genid.Value_message_fullname) - } - if fd.Number() == genid.Value_NumberValue_field_number { - if v := m.Get(fd).Float(); math.IsNaN(v) || math.IsInf(v, 0) { - return errors.New("%s: invalid %v value", genid.Value_NumberValue_field_fullname, v) - } - } - return e.marshalSingular(m.Get(fd), fd) -} - -func (d decoder) unmarshalKnownValue(m protoreflect.Message) error { - tok, err := d.Peek() - if err != nil { - return err - } - - var fd protoreflect.FieldDescriptor - var val protoreflect.Value - switch tok.Kind() { - case json.Null: - d.Read() - fd = m.Descriptor().Fields().ByNumber(genid.Value_NullValue_field_number) - val = protoreflect.ValueOfEnum(0) - - case json.Bool: - tok, err := d.Read() - if err != nil { - return err - } - fd = m.Descriptor().Fields().ByNumber(genid.Value_BoolValue_field_number) - val = protoreflect.ValueOfBool(tok.Bool()) - - case json.Number: - tok, err := d.Read() - if err != nil { - return err - } - fd = m.Descriptor().Fields().ByNumber(genid.Value_NumberValue_field_number) - var ok bool - val, ok = unmarshalFloat(tok, 64) - if !ok { - return d.newError(tok.Pos(), "invalid %v: %v", genid.Value_message_fullname, tok.RawString()) - } - - case json.String: - // A JSON string may have been encoded from the number_value field, - // e.g. "NaN", "Infinity", etc. Parsing a proto double type also allows - // for it to be in JSON string form. Given this custom encoding spec, - // however, there is no way to identify that and hence a JSON string is - // always assigned to the string_value field, which means that certain - // encoding cannot be parsed back to the same field. - tok, err := d.Read() - if err != nil { - return err - } - fd = m.Descriptor().Fields().ByNumber(genid.Value_StringValue_field_number) - val = protoreflect.ValueOfString(tok.ParsedString()) - - case json.ObjectOpen: - fd = m.Descriptor().Fields().ByNumber(genid.Value_StructValue_field_number) - val = m.NewField(fd) - if err := d.unmarshalStruct(val.Message()); err != nil { - return err - } - - case json.ArrayOpen: - fd = m.Descriptor().Fields().ByNumber(genid.Value_ListValue_field_number) - val = m.NewField(fd) - if err := d.unmarshalListValue(val.Message()); err != nil { - return err - } - - default: - return d.newError(tok.Pos(), "invalid %v: %v", genid.Value_message_fullname, tok.RawString()) - } - - m.Set(fd, val) - return nil -} - -// The JSON representation for a Duration is a JSON string that ends in the -// suffix "s" (indicating seconds) and is preceded by the number of seconds, -// with nanoseconds expressed as fractional seconds. -// -// Durations less than one second are represented with a 0 seconds field and a -// positive or negative nanos field. For durations of one second or more, a -// non-zero value for the nanos field must be of the same sign as the seconds -// field. -// -// Duration.seconds must be from -315,576,000,000 to +315,576,000,000 inclusive. -// Duration.nanos must be from -999,999,999 to +999,999,999 inclusive. - -const ( - secondsInNanos = 999999999 - maxSecondsInDuration = 315576000000 -) - -func (e encoder) marshalDuration(m protoreflect.Message) error { - fds := m.Descriptor().Fields() - fdSeconds := fds.ByNumber(genid.Duration_Seconds_field_number) - fdNanos := fds.ByNumber(genid.Duration_Nanos_field_number) - - secsVal := m.Get(fdSeconds) - nanosVal := m.Get(fdNanos) - secs := secsVal.Int() - nanos := nanosVal.Int() - if secs < -maxSecondsInDuration || secs > maxSecondsInDuration { - return errors.New("%s: seconds out of range %v", genid.Duration_message_fullname, secs) - } - if nanos < -secondsInNanos || nanos > secondsInNanos { - return errors.New("%s: nanos out of range %v", genid.Duration_message_fullname, nanos) - } - if (secs > 0 && nanos < 0) || (secs < 0 && nanos > 0) { - return errors.New("%s: signs of seconds and nanos do not match", genid.Duration_message_fullname) - } - // Generated output always contains 0, 3, 6, or 9 fractional digits, - // depending on required precision, followed by the suffix "s". - var sign string - if secs < 0 || nanos < 0 { - sign, secs, nanos = "-", -1*secs, -1*nanos - } - x := fmt.Sprintf("%s%d.%09d", sign, secs, nanos) - x = strings.TrimSuffix(x, "000") - x = strings.TrimSuffix(x, "000") - x = strings.TrimSuffix(x, ".000") - e.WriteString(x + "s") - return nil -} - -func (d decoder) unmarshalDuration(m protoreflect.Message) error { - tok, err := d.Read() - if err != nil { - return err - } - if tok.Kind() != json.String { - return d.unexpectedTokenError(tok) - } - - secs, nanos, ok := parseDuration(tok.ParsedString()) - if !ok { - return d.newError(tok.Pos(), "invalid %v value %v", genid.Duration_message_fullname, tok.RawString()) - } - // Validate seconds. No need to validate nanos because parseDuration would - // have covered that already. - if secs < -maxSecondsInDuration || secs > maxSecondsInDuration { - return d.newError(tok.Pos(), "%v value out of range: %v", genid.Duration_message_fullname, tok.RawString()) - } - - fds := m.Descriptor().Fields() - fdSeconds := fds.ByNumber(genid.Duration_Seconds_field_number) - fdNanos := fds.ByNumber(genid.Duration_Nanos_field_number) - - m.Set(fdSeconds, protoreflect.ValueOfInt64(secs)) - m.Set(fdNanos, protoreflect.ValueOfInt32(nanos)) - return nil -} - -// parseDuration parses the given input string for seconds and nanoseconds value -// for the Duration JSON format. The format is a decimal number with a suffix -// 's'. It can have optional plus/minus sign. There needs to be at least an -// integer or fractional part. Fractional part is limited to 9 digits only for -// nanoseconds precision, regardless of whether there are trailing zero digits. -// Example values are 1s, 0.1s, 1.s, .1s, +1s, -1s, -.1s. -func parseDuration(input string) (int64, int32, bool) { - b := []byte(input) - size := len(b) - if size < 2 { - return 0, 0, false - } - if b[size-1] != 's' { - return 0, 0, false - } - b = b[:size-1] - - // Read optional plus/minus symbol. - var neg bool - switch b[0] { - case '-': - neg = true - b = b[1:] - case '+': - b = b[1:] - } - if len(b) == 0 { - return 0, 0, false - } - - // Read the integer part. - var intp []byte - switch { - case b[0] == '0': - b = b[1:] - - case '1' <= b[0] && b[0] <= '9': - intp = b[0:] - b = b[1:] - n := 1 - for len(b) > 0 && '0' <= b[0] && b[0] <= '9' { - n++ - b = b[1:] - } - intp = intp[:n] - - case b[0] == '.': - // Continue below. - - default: - return 0, 0, false - } - - hasFrac := false - var frac [9]byte - if len(b) > 0 { - if b[0] != '.' { - return 0, 0, false - } - // Read the fractional part. - b = b[1:] - n := 0 - for len(b) > 0 && n < 9 && '0' <= b[0] && b[0] <= '9' { - frac[n] = b[0] - n++ - b = b[1:] - } - // It is not valid if there are more bytes left. - if len(b) > 0 { - return 0, 0, false - } - // Pad fractional part with 0s. - for i := n; i < 9; i++ { - frac[i] = '0' - } - hasFrac = true - } - - var secs int64 - if len(intp) > 0 { - var err error - secs, err = strconv.ParseInt(string(intp), 10, 64) - if err != nil { - return 0, 0, false - } - } - - var nanos int64 - if hasFrac { - nanob := bytes.TrimLeft(frac[:], "0") - if len(nanob) > 0 { - var err error - nanos, err = strconv.ParseInt(string(nanob), 10, 32) - if err != nil { - return 0, 0, false - } - } - } - - if neg { - if secs > 0 { - secs = -secs - } - if nanos > 0 { - nanos = -nanos - } - } - return secs, int32(nanos), true -} - -// The JSON representation for a Timestamp is a JSON string in the RFC 3339 -// format, i.e. "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" where -// {year} is always expressed using four digits while {month}, {day}, {hour}, -// {min}, and {sec} are zero-padded to two digits each. The fractional seconds, -// which can go up to 9 digits, up to 1 nanosecond resolution, is optional. The -// "Z" suffix indicates the timezone ("UTC"); the timezone is required. Encoding -// should always use UTC (as indicated by "Z") and a decoder should be able to -// accept both UTC and other timezones (as indicated by an offset). -// -// Timestamp.seconds must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z -// inclusive. -// Timestamp.nanos must be from 0 to 999,999,999 inclusive. - -const ( - maxTimestampSeconds = 253402300799 - minTimestampSeconds = -62135596800 -) - -func (e encoder) marshalTimestamp(m protoreflect.Message) error { - fds := m.Descriptor().Fields() - fdSeconds := fds.ByNumber(genid.Timestamp_Seconds_field_number) - fdNanos := fds.ByNumber(genid.Timestamp_Nanos_field_number) - - secsVal := m.Get(fdSeconds) - nanosVal := m.Get(fdNanos) - secs := secsVal.Int() - nanos := nanosVal.Int() - if secs < minTimestampSeconds || secs > maxTimestampSeconds { - return errors.New("%s: seconds out of range %v", genid.Timestamp_message_fullname, secs) - } - if nanos < 0 || nanos > secondsInNanos { - return errors.New("%s: nanos out of range %v", genid.Timestamp_message_fullname, nanos) - } - // Uses RFC 3339, where generated output will be Z-normalized and uses 0, 3, - // 6 or 9 fractional digits. - t := time.Unix(secs, nanos).UTC() - x := t.Format("2006-01-02T15:04:05.000000000") - x = strings.TrimSuffix(x, "000") - x = strings.TrimSuffix(x, "000") - x = strings.TrimSuffix(x, ".000") - e.WriteString(x + "Z") - return nil -} - -func (d decoder) unmarshalTimestamp(m protoreflect.Message) error { - tok, err := d.Read() - if err != nil { - return err - } - if tok.Kind() != json.String { - return d.unexpectedTokenError(tok) - } - - s := tok.ParsedString() - t, err := time.Parse(time.RFC3339Nano, s) - if err != nil { - return d.newError(tok.Pos(), "invalid %v value %v", genid.Timestamp_message_fullname, tok.RawString()) - } - // Validate seconds. - secs := t.Unix() - if secs < minTimestampSeconds || secs > maxTimestampSeconds { - return d.newError(tok.Pos(), "%v value out of range: %v", genid.Timestamp_message_fullname, tok.RawString()) - } - // Validate subseconds. - i := strings.LastIndexByte(s, '.') // start of subsecond field - j := strings.LastIndexAny(s, "Z-+") // start of timezone field - if i >= 0 && j >= i && j-i > len(".999999999") { - return d.newError(tok.Pos(), "invalid %v value %v", genid.Timestamp_message_fullname, tok.RawString()) - } - - fds := m.Descriptor().Fields() - fdSeconds := fds.ByNumber(genid.Timestamp_Seconds_field_number) - fdNanos := fds.ByNumber(genid.Timestamp_Nanos_field_number) - - m.Set(fdSeconds, protoreflect.ValueOfInt64(secs)) - m.Set(fdNanos, protoreflect.ValueOfInt32(int32(t.Nanosecond()))) - return nil -} - -// The JSON representation for a FieldMask is a JSON string where paths are -// separated by a comma. Fields name in each path are converted to/from -// lower-camel naming conventions. Encoding should fail if the path name would -// end up differently after a round-trip. - -func (e encoder) marshalFieldMask(m protoreflect.Message) error { - fd := m.Descriptor().Fields().ByNumber(genid.FieldMask_Paths_field_number) - list := m.Get(fd).List() - paths := make([]string, 0, list.Len()) - - for i := 0; i < list.Len(); i++ { - s := list.Get(i).String() - if !protoreflect.FullName(s).IsValid() { - return errors.New("%s contains invalid path: %q", genid.FieldMask_Paths_field_fullname, s) - } - // Return error if conversion to camelCase is not reversible. - cc := strs.JSONCamelCase(s) - if s != strs.JSONSnakeCase(cc) { - return errors.New("%s contains irreversible value %q", genid.FieldMask_Paths_field_fullname, s) - } - paths = append(paths, cc) - } - - e.WriteString(strings.Join(paths, ",")) - return nil -} - -func (d decoder) unmarshalFieldMask(m protoreflect.Message) error { - tok, err := d.Read() - if err != nil { - return err - } - if tok.Kind() != json.String { - return d.unexpectedTokenError(tok) - } - str := strings.TrimSpace(tok.ParsedString()) - if str == "" { - return nil - } - paths := strings.Split(str, ",") - - fd := m.Descriptor().Fields().ByNumber(genid.FieldMask_Paths_field_number) - list := m.Mutable(fd).List() - - for _, s0 := range paths { - s := strs.JSONSnakeCase(s0) - if strings.Contains(s0, "_") || !protoreflect.FullName(s).IsValid() { - return d.newError(tok.Pos(), "%v contains invalid path: %q", genid.FieldMask_Paths_field_fullname, s0) - } - list.Append(protoreflect.ValueOfString(s)) - } - return nil -} diff --git a/vendor/google.golang.org/protobuf/internal/encoding/json/decode.go b/vendor/google.golang.org/protobuf/internal/encoding/json/decode.go deleted file mode 100644 index d2b3ac031..000000000 --- a/vendor/google.golang.org/protobuf/internal/encoding/json/decode.go +++ /dev/null @@ -1,340 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package json - -import ( - "bytes" - "fmt" - "io" - "regexp" - "unicode/utf8" - - "google.golang.org/protobuf/internal/errors" -) - -// call specifies which Decoder method was invoked. -type call uint8 - -const ( - readCall call = iota - peekCall -) - -const unexpectedFmt = "unexpected token %s" - -// ErrUnexpectedEOF means that EOF was encountered in the middle of the input. -var ErrUnexpectedEOF = errors.New("%v", io.ErrUnexpectedEOF) - -// Decoder is a token-based JSON decoder. -type Decoder struct { - // lastCall is last method called, either readCall or peekCall. - // Initial value is readCall. - lastCall call - - // lastToken contains the last read token. - lastToken Token - - // lastErr contains the last read error. - lastErr error - - // openStack is a stack containing ObjectOpen and ArrayOpen values. The - // top of stack represents the object or the array the current value is - // directly located in. - openStack []Kind - - // orig is used in reporting line and column. - orig []byte - // in contains the unconsumed input. - in []byte -} - -// NewDecoder returns a Decoder to read the given []byte. -func NewDecoder(b []byte) *Decoder { - return &Decoder{orig: b, in: b} -} - -// Peek looks ahead and returns the next token kind without advancing a read. -func (d *Decoder) Peek() (Token, error) { - defer func() { d.lastCall = peekCall }() - if d.lastCall == readCall { - d.lastToken, d.lastErr = d.Read() - } - return d.lastToken, d.lastErr -} - -// Read returns the next JSON token. -// It will return an error if there is no valid token. -func (d *Decoder) Read() (Token, error) { - const scalar = Null | Bool | Number | String - - defer func() { d.lastCall = readCall }() - if d.lastCall == peekCall { - return d.lastToken, d.lastErr - } - - tok, err := d.parseNext() - if err != nil { - return Token{}, err - } - - switch tok.kind { - case EOF: - if len(d.openStack) != 0 || - d.lastToken.kind&scalar|ObjectClose|ArrayClose == 0 { - return Token{}, ErrUnexpectedEOF - } - - case Null: - if !d.isValueNext() { - return Token{}, d.newSyntaxError(tok.pos, unexpectedFmt, tok.RawString()) - } - - case Bool, Number: - if !d.isValueNext() { - return Token{}, d.newSyntaxError(tok.pos, unexpectedFmt, tok.RawString()) - } - - case String: - if d.isValueNext() { - break - } - // This string token should only be for a field name. - if d.lastToken.kind&(ObjectOpen|comma) == 0 { - return Token{}, d.newSyntaxError(tok.pos, unexpectedFmt, tok.RawString()) - } - if len(d.in) == 0 { - return Token{}, ErrUnexpectedEOF - } - if c := d.in[0]; c != ':' { - return Token{}, d.newSyntaxError(d.currPos(), `unexpected character %s, missing ":" after field name`, string(c)) - } - tok.kind = Name - d.consume(1) - - case ObjectOpen, ArrayOpen: - if !d.isValueNext() { - return Token{}, d.newSyntaxError(tok.pos, unexpectedFmt, tok.RawString()) - } - d.openStack = append(d.openStack, tok.kind) - - case ObjectClose: - if len(d.openStack) == 0 || - d.lastToken.kind&(Name|comma) != 0 || - d.openStack[len(d.openStack)-1] != ObjectOpen { - return Token{}, d.newSyntaxError(tok.pos, unexpectedFmt, tok.RawString()) - } - d.openStack = d.openStack[:len(d.openStack)-1] - - case ArrayClose: - if len(d.openStack) == 0 || - d.lastToken.kind == comma || - d.openStack[len(d.openStack)-1] != ArrayOpen { - return Token{}, d.newSyntaxError(tok.pos, unexpectedFmt, tok.RawString()) - } - d.openStack = d.openStack[:len(d.openStack)-1] - - case comma: - if len(d.openStack) == 0 || - d.lastToken.kind&(scalar|ObjectClose|ArrayClose) == 0 { - return Token{}, d.newSyntaxError(tok.pos, unexpectedFmt, tok.RawString()) - } - } - - // Update d.lastToken only after validating token to be in the right sequence. - d.lastToken = tok - - if d.lastToken.kind == comma { - return d.Read() - } - return tok, nil -} - -// Any sequence that looks like a non-delimiter (for error reporting). -var errRegexp = regexp.MustCompile(`^([-+._a-zA-Z0-9]{1,32}|.)`) - -// parseNext parses for the next JSON token. It returns a Token object for -// different types, except for Name. It does not handle whether the next token -// is in a valid sequence or not. -func (d *Decoder) parseNext() (Token, error) { - // Trim leading spaces. - d.consume(0) - - in := d.in - if len(in) == 0 { - return d.consumeToken(EOF, 0), nil - } - - switch in[0] { - case 'n': - if n := matchWithDelim("null", in); n != 0 { - return d.consumeToken(Null, n), nil - } - - case 't': - if n := matchWithDelim("true", in); n != 0 { - return d.consumeBoolToken(true, n), nil - } - - case 'f': - if n := matchWithDelim("false", in); n != 0 { - return d.consumeBoolToken(false, n), nil - } - - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - if n, ok := parseNumber(in); ok { - return d.consumeToken(Number, n), nil - } - - case '"': - s, n, err := d.parseString(in) - if err != nil { - return Token{}, err - } - return d.consumeStringToken(s, n), nil - - case '{': - return d.consumeToken(ObjectOpen, 1), nil - - case '}': - return d.consumeToken(ObjectClose, 1), nil - - case '[': - return d.consumeToken(ArrayOpen, 1), nil - - case ']': - return d.consumeToken(ArrayClose, 1), nil - - case ',': - return d.consumeToken(comma, 1), nil - } - return Token{}, d.newSyntaxError(d.currPos(), "invalid value %s", errRegexp.Find(in)) -} - -// newSyntaxError returns an error with line and column information useful for -// syntax errors. -func (d *Decoder) newSyntaxError(pos int, f string, x ...interface{}) error { - e := errors.New(f, x...) - line, column := d.Position(pos) - return errors.New("syntax error (line %d:%d): %v", line, column, e) -} - -// Position returns line and column number of given index of the original input. -// It will panic if index is out of range. -func (d *Decoder) Position(idx int) (line int, column int) { - b := d.orig[:idx] - line = bytes.Count(b, []byte("\n")) + 1 - if i := bytes.LastIndexByte(b, '\n'); i >= 0 { - b = b[i+1:] - } - column = utf8.RuneCount(b) + 1 // ignore multi-rune characters - return line, column -} - -// currPos returns the current index position of d.in from d.orig. -func (d *Decoder) currPos() int { - return len(d.orig) - len(d.in) -} - -// matchWithDelim matches s with the input b and verifies that the match -// terminates with a delimiter of some form (e.g., r"[^-+_.a-zA-Z0-9]"). -// As a special case, EOF is considered a delimiter. It returns the length of s -// if there is a match, else 0. -func matchWithDelim(s string, b []byte) int { - if !bytes.HasPrefix(b, []byte(s)) { - return 0 - } - - n := len(s) - if n < len(b) && isNotDelim(b[n]) { - return 0 - } - return n -} - -// isNotDelim returns true if given byte is a not delimiter character. -func isNotDelim(c byte) bool { - return (c == '-' || c == '+' || c == '.' || c == '_' || - ('a' <= c && c <= 'z') || - ('A' <= c && c <= 'Z') || - ('0' <= c && c <= '9')) -} - -// consume consumes n bytes of input and any subsequent whitespace. -func (d *Decoder) consume(n int) { - d.in = d.in[n:] - for len(d.in) > 0 { - switch d.in[0] { - case ' ', '\n', '\r', '\t': - d.in = d.in[1:] - default: - return - } - } -} - -// isValueNext returns true if next type should be a JSON value: Null, -// Number, String or Bool. -func (d *Decoder) isValueNext() bool { - if len(d.openStack) == 0 { - return d.lastToken.kind == 0 - } - - start := d.openStack[len(d.openStack)-1] - switch start { - case ObjectOpen: - return d.lastToken.kind&Name != 0 - case ArrayOpen: - return d.lastToken.kind&(ArrayOpen|comma) != 0 - } - panic(fmt.Sprintf( - "unreachable logic in Decoder.isValueNext, lastToken.kind: %v, openStack: %v", - d.lastToken.kind, start)) -} - -// consumeToken constructs a Token for given Kind with raw value derived from -// current d.in and given size, and consumes the given size-length of it. -func (d *Decoder) consumeToken(kind Kind, size int) Token { - tok := Token{ - kind: kind, - raw: d.in[:size], - pos: len(d.orig) - len(d.in), - } - d.consume(size) - return tok -} - -// consumeBoolToken constructs a Token for a Bool kind with raw value derived from -// current d.in and given size. -func (d *Decoder) consumeBoolToken(b bool, size int) Token { - tok := Token{ - kind: Bool, - raw: d.in[:size], - pos: len(d.orig) - len(d.in), - boo: b, - } - d.consume(size) - return tok -} - -// consumeStringToken constructs a Token for a String kind with raw value derived -// from current d.in and given size. -func (d *Decoder) consumeStringToken(s string, size int) Token { - tok := Token{ - kind: String, - raw: d.in[:size], - pos: len(d.orig) - len(d.in), - str: s, - } - d.consume(size) - return tok -} - -// Clone returns a copy of the Decoder for use in reading ahead the next JSON -// object, array or other values without affecting current Decoder. -func (d *Decoder) Clone() *Decoder { - ret := *d - ret.openStack = append([]Kind(nil), ret.openStack...) - return &ret -} diff --git a/vendor/google.golang.org/protobuf/internal/encoding/json/decode_number.go b/vendor/google.golang.org/protobuf/internal/encoding/json/decode_number.go deleted file mode 100644 index 2999d7133..000000000 --- a/vendor/google.golang.org/protobuf/internal/encoding/json/decode_number.go +++ /dev/null @@ -1,254 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package json - -import ( - "bytes" - "strconv" -) - -// parseNumber reads the given []byte for a valid JSON number. If it is valid, -// it returns the number of bytes. Parsing logic follows the definition in -// https://tools.ietf.org/html/rfc7159#section-6, and is based off -// encoding/json.isValidNumber function. -func parseNumber(input []byte) (int, bool) { - var n int - - s := input - if len(s) == 0 { - return 0, false - } - - // Optional - - if s[0] == '-' { - s = s[1:] - n++ - if len(s) == 0 { - return 0, false - } - } - - // Digits - switch { - case s[0] == '0': - s = s[1:] - n++ - - case '1' <= s[0] && s[0] <= '9': - s = s[1:] - n++ - for len(s) > 0 && '0' <= s[0] && s[0] <= '9' { - s = s[1:] - n++ - } - - default: - return 0, false - } - - // . followed by 1 or more digits. - if len(s) >= 2 && s[0] == '.' && '0' <= s[1] && s[1] <= '9' { - s = s[2:] - n += 2 - for len(s) > 0 && '0' <= s[0] && s[0] <= '9' { - s = s[1:] - n++ - } - } - - // e or E followed by an optional - or + and - // 1 or more digits. - if len(s) >= 2 && (s[0] == 'e' || s[0] == 'E') { - s = s[1:] - n++ - if s[0] == '+' || s[0] == '-' { - s = s[1:] - n++ - if len(s) == 0 { - return 0, false - } - } - for len(s) > 0 && '0' <= s[0] && s[0] <= '9' { - s = s[1:] - n++ - } - } - - // Check that next byte is a delimiter or it is at the end. - if n < len(input) && isNotDelim(input[n]) { - return 0, false - } - - return n, true -} - -// numberParts is the result of parsing out a valid JSON number. It contains -// the parts of a number. The parts are used for integer conversion. -type numberParts struct { - neg bool - intp []byte - frac []byte - exp []byte -} - -// parseNumber constructs numberParts from given []byte. The logic here is -// similar to consumeNumber above with the difference of having to construct -// numberParts. The slice fields in numberParts are subslices of the input. -func parseNumberParts(input []byte) (numberParts, bool) { - var neg bool - var intp []byte - var frac []byte - var exp []byte - - s := input - if len(s) == 0 { - return numberParts{}, false - } - - // Optional - - if s[0] == '-' { - neg = true - s = s[1:] - if len(s) == 0 { - return numberParts{}, false - } - } - - // Digits - switch { - case s[0] == '0': - // Skip first 0 and no need to store. - s = s[1:] - - case '1' <= s[0] && s[0] <= '9': - intp = s - n := 1 - s = s[1:] - for len(s) > 0 && '0' <= s[0] && s[0] <= '9' { - s = s[1:] - n++ - } - intp = intp[:n] - - default: - return numberParts{}, false - } - - // . followed by 1 or more digits. - if len(s) >= 2 && s[0] == '.' && '0' <= s[1] && s[1] <= '9' { - frac = s[1:] - n := 1 - s = s[2:] - for len(s) > 0 && '0' <= s[0] && s[0] <= '9' { - s = s[1:] - n++ - } - frac = frac[:n] - } - - // e or E followed by an optional - or + and - // 1 or more digits. - if len(s) >= 2 && (s[0] == 'e' || s[0] == 'E') { - s = s[1:] - exp = s - n := 0 - if s[0] == '+' || s[0] == '-' { - s = s[1:] - n++ - if len(s) == 0 { - return numberParts{}, false - } - } - for len(s) > 0 && '0' <= s[0] && s[0] <= '9' { - s = s[1:] - n++ - } - exp = exp[:n] - } - - return numberParts{ - neg: neg, - intp: intp, - frac: bytes.TrimRight(frac, "0"), // Remove unnecessary 0s to the right. - exp: exp, - }, true -} - -// normalizeToIntString returns an integer string in normal form without the -// E-notation for given numberParts. It will return false if it is not an -// integer or if the exponent exceeds than max/min int value. -func normalizeToIntString(n numberParts) (string, bool) { - intpSize := len(n.intp) - fracSize := len(n.frac) - - if intpSize == 0 && fracSize == 0 { - return "0", true - } - - var exp int - if len(n.exp) > 0 { - i, err := strconv.ParseInt(string(n.exp), 10, 32) - if err != nil { - return "", false - } - exp = int(i) - } - - var num []byte - if exp >= 0 { - // For positive E, shift fraction digits into integer part and also pad - // with zeroes as needed. - - // If there are more digits in fraction than the E value, then the - // number is not an integer. - if fracSize > exp { - return "", false - } - - // Make sure resulting digits are within max value limit to avoid - // unnecessarily constructing a large byte slice that may simply fail - // later on. - const maxDigits = 20 // Max uint64 value has 20 decimal digits. - if intpSize+exp > maxDigits { - return "", false - } - - // Set cap to make a copy of integer part when appended. - num = n.intp[:len(n.intp):len(n.intp)] - num = append(num, n.frac...) - for i := 0; i < exp-fracSize; i++ { - num = append(num, '0') - } - } else { - // For negative E, shift digits in integer part out. - - // If there are fractions, then the number is not an integer. - if fracSize > 0 { - return "", false - } - - // index is where the decimal point will be after adjusting for negative - // exponent. - index := intpSize + exp - if index < 0 { - return "", false - } - - num = n.intp - // If any of the digits being shifted to the right of the decimal point - // is non-zero, then the number is not an integer. - for i := index; i < intpSize; i++ { - if num[i] != '0' { - return "", false - } - } - num = num[:index] - } - - if n.neg { - return "-" + string(num), true - } - return string(num), true -} diff --git a/vendor/google.golang.org/protobuf/internal/encoding/json/decode_string.go b/vendor/google.golang.org/protobuf/internal/encoding/json/decode_string.go deleted file mode 100644 index f7fea7d8d..000000000 --- a/vendor/google.golang.org/protobuf/internal/encoding/json/decode_string.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package json - -import ( - "strconv" - "unicode" - "unicode/utf16" - "unicode/utf8" - - "google.golang.org/protobuf/internal/strs" -) - -func (d *Decoder) parseString(in []byte) (string, int, error) { - in0 := in - if len(in) == 0 { - return "", 0, ErrUnexpectedEOF - } - if in[0] != '"' { - return "", 0, d.newSyntaxError(d.currPos(), "invalid character %q at start of string", in[0]) - } - in = in[1:] - i := indexNeedEscapeInBytes(in) - in, out := in[i:], in[:i:i] // set cap to prevent mutations - for len(in) > 0 { - switch r, n := utf8.DecodeRune(in); { - case r == utf8.RuneError && n == 1: - return "", 0, d.newSyntaxError(d.currPos(), "invalid UTF-8 in string") - case r < ' ': - return "", 0, d.newSyntaxError(d.currPos(), "invalid character %q in string", r) - case r == '"': - in = in[1:] - n := len(in0) - len(in) - return string(out), n, nil - case r == '\\': - if len(in) < 2 { - return "", 0, ErrUnexpectedEOF - } - switch r := in[1]; r { - case '"', '\\', '/': - in, out = in[2:], append(out, r) - case 'b': - in, out = in[2:], append(out, '\b') - case 'f': - in, out = in[2:], append(out, '\f') - case 'n': - in, out = in[2:], append(out, '\n') - case 'r': - in, out = in[2:], append(out, '\r') - case 't': - in, out = in[2:], append(out, '\t') - case 'u': - if len(in) < 6 { - return "", 0, ErrUnexpectedEOF - } - v, err := strconv.ParseUint(string(in[2:6]), 16, 16) - if err != nil { - return "", 0, d.newSyntaxError(d.currPos(), "invalid escape code %q in string", in[:6]) - } - in = in[6:] - - r := rune(v) - if utf16.IsSurrogate(r) { - if len(in) < 6 { - return "", 0, ErrUnexpectedEOF - } - v, err := strconv.ParseUint(string(in[2:6]), 16, 16) - r = utf16.DecodeRune(r, rune(v)) - if in[0] != '\\' || in[1] != 'u' || - r == unicode.ReplacementChar || err != nil { - return "", 0, d.newSyntaxError(d.currPos(), "invalid escape code %q in string", in[:6]) - } - in = in[6:] - } - out = append(out, string(r)...) - default: - return "", 0, d.newSyntaxError(d.currPos(), "invalid escape code %q in string", in[:2]) - } - default: - i := indexNeedEscapeInBytes(in[n:]) - in, out = in[n+i:], append(out, in[:n+i]...) - } - } - return "", 0, ErrUnexpectedEOF -} - -// indexNeedEscapeInBytes returns the index of the character that needs -// escaping. If no characters need escaping, this returns the input length. -func indexNeedEscapeInBytes(b []byte) int { return indexNeedEscapeInString(strs.UnsafeString(b)) } diff --git a/vendor/google.golang.org/protobuf/internal/encoding/json/decode_token.go b/vendor/google.golang.org/protobuf/internal/encoding/json/decode_token.go deleted file mode 100644 index 50578d659..000000000 --- a/vendor/google.golang.org/protobuf/internal/encoding/json/decode_token.go +++ /dev/null @@ -1,192 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package json - -import ( - "bytes" - "fmt" - "strconv" -) - -// Kind represents a token kind expressible in the JSON format. -type Kind uint16 - -const ( - Invalid Kind = (1 << iota) / 2 - EOF - Null - Bool - Number - String - Name - ObjectOpen - ObjectClose - ArrayOpen - ArrayClose - - // comma is only for parsing in between tokens and - // does not need to be exported. - comma -) - -func (k Kind) String() string { - switch k { - case EOF: - return "eof" - case Null: - return "null" - case Bool: - return "bool" - case Number: - return "number" - case String: - return "string" - case ObjectOpen: - return "{" - case ObjectClose: - return "}" - case Name: - return "name" - case ArrayOpen: - return "[" - case ArrayClose: - return "]" - case comma: - return "," - } - return "" -} - -// Token provides a parsed token kind and value. -// -// Values are provided by the difference accessor methods. The accessor methods -// Name, Bool, and ParsedString will panic if called on the wrong kind. There -// are different accessor methods for the Number kind for converting to the -// appropriate Go numeric type and those methods have the ok return value. -type Token struct { - // Token kind. - kind Kind - // pos provides the position of the token in the original input. - pos int - // raw bytes of the serialized token. - // This is a subslice into the original input. - raw []byte - // boo is parsed boolean value. - boo bool - // str is parsed string value. - str string -} - -// Kind returns the token kind. -func (t Token) Kind() Kind { - return t.kind -} - -// RawString returns the read value in string. -func (t Token) RawString() string { - return string(t.raw) -} - -// Pos returns the token position from the input. -func (t Token) Pos() int { - return t.pos -} - -// Name returns the object name if token is Name, else it panics. -func (t Token) Name() string { - if t.kind == Name { - return t.str - } - panic(fmt.Sprintf("Token is not a Name: %v", t.RawString())) -} - -// Bool returns the bool value if token kind is Bool, else it panics. -func (t Token) Bool() bool { - if t.kind == Bool { - return t.boo - } - panic(fmt.Sprintf("Token is not a Bool: %v", t.RawString())) -} - -// ParsedString returns the string value for a JSON string token or the read -// value in string if token is not a string. -func (t Token) ParsedString() string { - if t.kind == String { - return t.str - } - panic(fmt.Sprintf("Token is not a String: %v", t.RawString())) -} - -// Float returns the floating-point number if token kind is Number. -// -// The floating-point precision is specified by the bitSize parameter: 32 for -// float32 or 64 for float64. If bitSize=32, the result still has type float64, -// but it will be convertible to float32 without changing its value. It will -// return false if the number exceeds the floating point limits for given -// bitSize. -func (t Token) Float(bitSize int) (float64, bool) { - if t.kind != Number { - return 0, false - } - f, err := strconv.ParseFloat(t.RawString(), bitSize) - if err != nil { - return 0, false - } - return f, true -} - -// Int returns the signed integer number if token is Number. -// -// The given bitSize specifies the integer type that the result must fit into. -// It returns false if the number is not an integer value or if the result -// exceeds the limits for given bitSize. -func (t Token) Int(bitSize int) (int64, bool) { - s, ok := t.getIntStr() - if !ok { - return 0, false - } - n, err := strconv.ParseInt(s, 10, bitSize) - if err != nil { - return 0, false - } - return n, true -} - -// Uint returns the signed integer number if token is Number. -// -// The given bitSize specifies the unsigned integer type that the result must -// fit into. It returns false if the number is not an unsigned integer value -// or if the result exceeds the limits for given bitSize. -func (t Token) Uint(bitSize int) (uint64, bool) { - s, ok := t.getIntStr() - if !ok { - return 0, false - } - n, err := strconv.ParseUint(s, 10, bitSize) - if err != nil { - return 0, false - } - return n, true -} - -func (t Token) getIntStr() (string, bool) { - if t.kind != Number { - return "", false - } - parts, ok := parseNumberParts(t.raw) - if !ok { - return "", false - } - return normalizeToIntString(parts) -} - -// TokenEquals returns true if given Tokens are equal, else false. -func TokenEquals(x, y Token) bool { - return x.kind == y.kind && - x.pos == y.pos && - bytes.Equal(x.raw, y.raw) && - x.boo == y.boo && - x.str == y.str -} diff --git a/vendor/google.golang.org/protobuf/internal/encoding/json/encode.go b/vendor/google.golang.org/protobuf/internal/encoding/json/encode.go deleted file mode 100644 index 934f2dcb3..000000000 --- a/vendor/google.golang.org/protobuf/internal/encoding/json/encode.go +++ /dev/null @@ -1,278 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package json - -import ( - "math" - "math/bits" - "strconv" - "strings" - "unicode/utf8" - - "google.golang.org/protobuf/internal/detrand" - "google.golang.org/protobuf/internal/errors" -) - -// kind represents an encoding type. -type kind uint8 - -const ( - _ kind = (1 << iota) / 2 - name - scalar - objectOpen - objectClose - arrayOpen - arrayClose -) - -// Encoder provides methods to write out JSON constructs and values. The user is -// responsible for producing valid sequences of JSON constructs and values. -type Encoder struct { - indent string - lastKind kind - indents []byte - out []byte -} - -// NewEncoder returns an Encoder. -// -// If indent is a non-empty string, it causes every entry for an Array or Object -// to be preceded by the indent and trailed by a newline. -func NewEncoder(buf []byte, indent string) (*Encoder, error) { - e := &Encoder{ - out: buf, - } - if len(indent) > 0 { - if strings.Trim(indent, " \t") != "" { - return nil, errors.New("indent may only be composed of space or tab characters") - } - e.indent = indent - } - return e, nil -} - -// Bytes returns the content of the written bytes. -func (e *Encoder) Bytes() []byte { - return e.out -} - -// WriteNull writes out the null value. -func (e *Encoder) WriteNull() { - e.prepareNext(scalar) - e.out = append(e.out, "null"...) -} - -// WriteBool writes out the given boolean value. -func (e *Encoder) WriteBool(b bool) { - e.prepareNext(scalar) - if b { - e.out = append(e.out, "true"...) - } else { - e.out = append(e.out, "false"...) - } -} - -// WriteString writes out the given string in JSON string value. Returns error -// if input string contains invalid UTF-8. -func (e *Encoder) WriteString(s string) error { - e.prepareNext(scalar) - var err error - if e.out, err = appendString(e.out, s); err != nil { - return err - } - return nil -} - -// Sentinel error used for indicating invalid UTF-8. -var errInvalidUTF8 = errors.New("invalid UTF-8") - -func appendString(out []byte, in string) ([]byte, error) { - out = append(out, '"') - i := indexNeedEscapeInString(in) - in, out = in[i:], append(out, in[:i]...) - for len(in) > 0 { - switch r, n := utf8.DecodeRuneInString(in); { - case r == utf8.RuneError && n == 1: - return out, errInvalidUTF8 - case r < ' ' || r == '"' || r == '\\': - out = append(out, '\\') - switch r { - case '"', '\\': - out = append(out, byte(r)) - case '\b': - out = append(out, 'b') - case '\f': - out = append(out, 'f') - case '\n': - out = append(out, 'n') - case '\r': - out = append(out, 'r') - case '\t': - out = append(out, 't') - default: - out = append(out, 'u') - out = append(out, "0000"[1+(bits.Len32(uint32(r))-1)/4:]...) - out = strconv.AppendUint(out, uint64(r), 16) - } - in = in[n:] - default: - i := indexNeedEscapeInString(in[n:]) - in, out = in[n+i:], append(out, in[:n+i]...) - } - } - out = append(out, '"') - return out, nil -} - -// indexNeedEscapeInString returns the index of the character that needs -// escaping. If no characters need escaping, this returns the input length. -func indexNeedEscapeInString(s string) int { - for i, r := range s { - if r < ' ' || r == '\\' || r == '"' || r == utf8.RuneError { - return i - } - } - return len(s) -} - -// WriteFloat writes out the given float and bitSize in JSON number value. -func (e *Encoder) WriteFloat(n float64, bitSize int) { - e.prepareNext(scalar) - e.out = appendFloat(e.out, n, bitSize) -} - -// appendFloat formats given float in bitSize, and appends to the given []byte. -func appendFloat(out []byte, n float64, bitSize int) []byte { - switch { - case math.IsNaN(n): - return append(out, `"NaN"`...) - case math.IsInf(n, +1): - return append(out, `"Infinity"`...) - case math.IsInf(n, -1): - return append(out, `"-Infinity"`...) - } - - // JSON number formatting logic based on encoding/json. - // See floatEncoder.encode for reference. - fmt := byte('f') - if abs := math.Abs(n); abs != 0 { - if bitSize == 64 && (abs < 1e-6 || abs >= 1e21) || - bitSize == 32 && (float32(abs) < 1e-6 || float32(abs) >= 1e21) { - fmt = 'e' - } - } - out = strconv.AppendFloat(out, n, fmt, -1, bitSize) - if fmt == 'e' { - n := len(out) - if n >= 4 && out[n-4] == 'e' && out[n-3] == '-' && out[n-2] == '0' { - out[n-2] = out[n-1] - out = out[:n-1] - } - } - return out -} - -// WriteInt writes out the given signed integer in JSON number value. -func (e *Encoder) WriteInt(n int64) { - e.prepareNext(scalar) - e.out = strconv.AppendInt(e.out, n, 10) -} - -// WriteUint writes out the given unsigned integer in JSON number value. -func (e *Encoder) WriteUint(n uint64) { - e.prepareNext(scalar) - e.out = strconv.AppendUint(e.out, n, 10) -} - -// StartObject writes out the '{' symbol. -func (e *Encoder) StartObject() { - e.prepareNext(objectOpen) - e.out = append(e.out, '{') -} - -// EndObject writes out the '}' symbol. -func (e *Encoder) EndObject() { - e.prepareNext(objectClose) - e.out = append(e.out, '}') -} - -// WriteName writes out the given string in JSON string value and the name -// separator ':'. Returns error if input string contains invalid UTF-8, which -// should not be likely as protobuf field names should be valid. -func (e *Encoder) WriteName(s string) error { - e.prepareNext(name) - var err error - // Append to output regardless of error. - e.out, err = appendString(e.out, s) - e.out = append(e.out, ':') - return err -} - -// StartArray writes out the '[' symbol. -func (e *Encoder) StartArray() { - e.prepareNext(arrayOpen) - e.out = append(e.out, '[') -} - -// EndArray writes out the ']' symbol. -func (e *Encoder) EndArray() { - e.prepareNext(arrayClose) - e.out = append(e.out, ']') -} - -// prepareNext adds possible comma and indentation for the next value based -// on last type and indent option. It also updates lastKind to next. -func (e *Encoder) prepareNext(next kind) { - defer func() { - // Set lastKind to next. - e.lastKind = next - }() - - if len(e.indent) == 0 { - // Need to add comma on the following condition. - if e.lastKind&(scalar|objectClose|arrayClose) != 0 && - next&(name|scalar|objectOpen|arrayOpen) != 0 { - e.out = append(e.out, ',') - // For single-line output, add a random extra space after each - // comma to make output unstable. - if detrand.Bool() { - e.out = append(e.out, ' ') - } - } - return - } - - switch { - case e.lastKind&(objectOpen|arrayOpen) != 0: - // If next type is NOT closing, add indent and newline. - if next&(objectClose|arrayClose) == 0 { - e.indents = append(e.indents, e.indent...) - e.out = append(e.out, '\n') - e.out = append(e.out, e.indents...) - } - - case e.lastKind&(scalar|objectClose|arrayClose) != 0: - switch { - // If next type is either a value or name, add comma and newline. - case next&(name|scalar|objectOpen|arrayOpen) != 0: - e.out = append(e.out, ',', '\n') - - // If next type is a closing object or array, adjust indentation. - case next&(objectClose|arrayClose) != 0: - e.indents = e.indents[:len(e.indents)-len(e.indent)] - e.out = append(e.out, '\n') - } - e.out = append(e.out, e.indents...) - - case e.lastKind&name != 0: - e.out = append(e.out, ' ') - // For multi-line output, add a random extra space after key: to make - // output unstable. - if detrand.Bool() { - e.out = append(e.out, ' ') - } - } -} diff --git a/vendor/google.golang.org/protobuf/protoadapt/convert.go b/vendor/google.golang.org/protobuf/protoadapt/convert.go deleted file mode 100644 index ea276d15a..000000000 --- a/vendor/google.golang.org/protobuf/protoadapt/convert.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2023 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package protoadapt bridges the original and new proto APIs. -package protoadapt - -import ( - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/runtime/protoiface" - "google.golang.org/protobuf/runtime/protoimpl" -) - -// MessageV1 is the original [github.com/golang/protobuf/proto.Message] type. -type MessageV1 = protoiface.MessageV1 - -// MessageV2 is the [google.golang.org/protobuf/proto.Message] type used by the -// current [google.golang.org/protobuf] module, adding support for reflection. -type MessageV2 = proto.Message - -// MessageV1Of converts a v2 message to a v1 message. -// It returns nil if m is nil. -func MessageV1Of(m MessageV2) MessageV1 { - return protoimpl.X.ProtoMessageV1Of(m) -} - -// MessageV2Of converts a v1 message to a v2 message. -// It returns nil if m is nil. -func MessageV2Of(m MessageV1) MessageV2 { - return protoimpl.X.ProtoMessageV2Of(m) -} diff --git a/vendor/google.golang.org/protobuf/types/dynamicpb/dynamic.go b/vendor/google.golang.org/protobuf/types/dynamicpb/dynamic.go deleted file mode 100644 index 39b024b46..000000000 --- a/vendor/google.golang.org/protobuf/types/dynamicpb/dynamic.go +++ /dev/null @@ -1,718 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package dynamicpb creates protocol buffer messages using runtime type information. -package dynamicpb - -import ( - "math" - - "google.golang.org/protobuf/internal/errors" - "google.golang.org/protobuf/reflect/protoreflect" - "google.golang.org/protobuf/runtime/protoiface" - "google.golang.org/protobuf/runtime/protoimpl" -) - -// enum is a dynamic protoreflect.Enum. -type enum struct { - num protoreflect.EnumNumber - typ protoreflect.EnumType -} - -func (e enum) Descriptor() protoreflect.EnumDescriptor { return e.typ.Descriptor() } -func (e enum) Type() protoreflect.EnumType { return e.typ } -func (e enum) Number() protoreflect.EnumNumber { return e.num } - -// enumType is a dynamic protoreflect.EnumType. -type enumType struct { - desc protoreflect.EnumDescriptor -} - -// NewEnumType creates a new EnumType with the provided descriptor. -// -// EnumTypes created by this package are equal if their descriptors are equal. -// That is, if ed1 == ed2, then NewEnumType(ed1) == NewEnumType(ed2). -// -// Enum values created by the EnumType are equal if their numbers are equal. -func NewEnumType(desc protoreflect.EnumDescriptor) protoreflect.EnumType { - return enumType{desc} -} - -func (et enumType) New(n protoreflect.EnumNumber) protoreflect.Enum { return enum{n, et} } -func (et enumType) Descriptor() protoreflect.EnumDescriptor { return et.desc } - -// extensionType is a dynamic protoreflect.ExtensionType. -type extensionType struct { - desc extensionTypeDescriptor -} - -// A Message is a dynamically constructed protocol buffer message. -// -// Message implements the [google.golang.org/protobuf/proto.Message] interface, -// and may be used with all standard proto package functions -// such as Marshal, Unmarshal, and so forth. -// -// Message also implements the [protoreflect.Message] interface. -// See the [protoreflect] package documentation for that interface for how to -// get and set fields and otherwise interact with the contents of a Message. -// -// Reflection API functions which construct messages, such as NewField, -// return new dynamic messages of the appropriate type. Functions which take -// messages, such as Set for a message-value field, will accept any message -// with a compatible type. -// -// Operations which modify a Message are not safe for concurrent use. -type Message struct { - typ messageType - known map[protoreflect.FieldNumber]protoreflect.Value - ext map[protoreflect.FieldNumber]protoreflect.FieldDescriptor - unknown protoreflect.RawFields -} - -var ( - _ protoreflect.Message = (*Message)(nil) - _ protoreflect.ProtoMessage = (*Message)(nil) - _ protoiface.MessageV1 = (*Message)(nil) -) - -// NewMessage creates a new message with the provided descriptor. -func NewMessage(desc protoreflect.MessageDescriptor) *Message { - return &Message{ - typ: messageType{desc}, - known: make(map[protoreflect.FieldNumber]protoreflect.Value), - ext: make(map[protoreflect.FieldNumber]protoreflect.FieldDescriptor), - } -} - -// ProtoMessage implements the legacy message interface. -func (m *Message) ProtoMessage() {} - -// ProtoReflect implements the [protoreflect.ProtoMessage] interface. -func (m *Message) ProtoReflect() protoreflect.Message { - return m -} - -// String returns a string representation of a message. -func (m *Message) String() string { - return protoimpl.X.MessageStringOf(m) -} - -// Reset clears the message to be empty, but preserves the dynamic message type. -func (m *Message) Reset() { - m.known = make(map[protoreflect.FieldNumber]protoreflect.Value) - m.ext = make(map[protoreflect.FieldNumber]protoreflect.FieldDescriptor) - m.unknown = nil -} - -// Descriptor returns the message descriptor. -func (m *Message) Descriptor() protoreflect.MessageDescriptor { - return m.typ.desc -} - -// Type returns the message type. -func (m *Message) Type() protoreflect.MessageType { - return m.typ -} - -// New returns a newly allocated empty message with the same descriptor. -// See [protoreflect.Message] for details. -func (m *Message) New() protoreflect.Message { - return m.Type().New() -} - -// Interface returns the message. -// See [protoreflect.Message] for details. -func (m *Message) Interface() protoreflect.ProtoMessage { - return m -} - -// ProtoMethods is an internal detail of the [protoreflect.Message] interface. -// Users should never call this directly. -func (m *Message) ProtoMethods() *protoiface.Methods { - return nil -} - -// Range visits every populated field in undefined order. -// See [protoreflect.Message] for details. -func (m *Message) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - for num, v := range m.known { - fd := m.ext[num] - if fd == nil { - fd = m.Descriptor().Fields().ByNumber(num) - } - if !isSet(fd, v) { - continue - } - if !f(fd, v) { - return - } - } -} - -// Has reports whether a field is populated. -// See [protoreflect.Message] for details. -func (m *Message) Has(fd protoreflect.FieldDescriptor) bool { - m.checkField(fd) - if fd.IsExtension() && m.ext[fd.Number()] != fd { - return false - } - v, ok := m.known[fd.Number()] - if !ok { - return false - } - return isSet(fd, v) -} - -// Clear clears a field. -// See [protoreflect.Message] for details. -func (m *Message) Clear(fd protoreflect.FieldDescriptor) { - m.checkField(fd) - num := fd.Number() - delete(m.known, num) - delete(m.ext, num) -} - -// Get returns the value of a field. -// See [protoreflect.Message] for details. -func (m *Message) Get(fd protoreflect.FieldDescriptor) protoreflect.Value { - m.checkField(fd) - num := fd.Number() - if fd.IsExtension() { - if fd != m.ext[num] { - return fd.(protoreflect.ExtensionTypeDescriptor).Type().Zero() - } - return m.known[num] - } - if v, ok := m.known[num]; ok { - switch { - case fd.IsMap(): - if v.Map().Len() > 0 { - return v - } - case fd.IsList(): - if v.List().Len() > 0 { - return v - } - default: - return v - } - } - switch { - case fd.IsMap(): - return protoreflect.ValueOfMap(&dynamicMap{desc: fd}) - case fd.IsList(): - return protoreflect.ValueOfList(emptyList{desc: fd}) - case fd.Message() != nil: - return protoreflect.ValueOfMessage(&Message{typ: messageType{fd.Message()}}) - case fd.Kind() == protoreflect.BytesKind: - return protoreflect.ValueOfBytes(append([]byte(nil), fd.Default().Bytes()...)) - default: - return fd.Default() - } -} - -// Mutable returns a mutable reference to a repeated, map, or message field. -// See [protoreflect.Message] for details. -func (m *Message) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { - m.checkField(fd) - if !fd.IsMap() && !fd.IsList() && fd.Message() == nil { - panic(errors.New("%v: getting mutable reference to non-composite type", fd.FullName())) - } - if m.known == nil { - panic(errors.New("%v: modification of read-only message", fd.FullName())) - } - num := fd.Number() - if fd.IsExtension() { - if fd != m.ext[num] { - m.ext[num] = fd - m.known[num] = fd.(protoreflect.ExtensionTypeDescriptor).Type().New() - } - return m.known[num] - } - if v, ok := m.known[num]; ok { - return v - } - m.clearOtherOneofFields(fd) - m.known[num] = m.NewField(fd) - if fd.IsExtension() { - m.ext[num] = fd - } - return m.known[num] -} - -// Set stores a value in a field. -// See [protoreflect.Message] for details. -func (m *Message) Set(fd protoreflect.FieldDescriptor, v protoreflect.Value) { - m.checkField(fd) - if m.known == nil { - panic(errors.New("%v: modification of read-only message", fd.FullName())) - } - if fd.IsExtension() { - isValid := true - switch { - case !fd.(protoreflect.ExtensionTypeDescriptor).Type().IsValidValue(v): - isValid = false - case fd.IsList(): - isValid = v.List().IsValid() - case fd.IsMap(): - isValid = v.Map().IsValid() - case fd.Message() != nil: - isValid = v.Message().IsValid() - } - if !isValid { - panic(errors.New("%v: assigning invalid type %T", fd.FullName(), v.Interface())) - } - m.ext[fd.Number()] = fd - } else { - typecheck(fd, v) - } - m.clearOtherOneofFields(fd) - m.known[fd.Number()] = v -} - -func (m *Message) clearOtherOneofFields(fd protoreflect.FieldDescriptor) { - od := fd.ContainingOneof() - if od == nil { - return - } - num := fd.Number() - for i := 0; i < od.Fields().Len(); i++ { - if n := od.Fields().Get(i).Number(); n != num { - delete(m.known, n) - } - } -} - -// NewField returns a new value for assignable to the field of a given descriptor. -// See [protoreflect.Message] for details. -func (m *Message) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { - m.checkField(fd) - switch { - case fd.IsExtension(): - return fd.(protoreflect.ExtensionTypeDescriptor).Type().New() - case fd.IsMap(): - return protoreflect.ValueOfMap(&dynamicMap{ - desc: fd, - mapv: make(map[interface{}]protoreflect.Value), - }) - case fd.IsList(): - return protoreflect.ValueOfList(&dynamicList{desc: fd}) - case fd.Message() != nil: - return protoreflect.ValueOfMessage(NewMessage(fd.Message()).ProtoReflect()) - default: - return fd.Default() - } -} - -// WhichOneof reports which field in a oneof is populated, returning nil if none are populated. -// See [protoreflect.Message] for details. -func (m *Message) WhichOneof(od protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { - for i := 0; i < od.Fields().Len(); i++ { - fd := od.Fields().Get(i) - if m.Has(fd) { - return fd - } - } - return nil -} - -// GetUnknown returns the raw unknown fields. -// See [protoreflect.Message] for details. -func (m *Message) GetUnknown() protoreflect.RawFields { - return m.unknown -} - -// SetUnknown sets the raw unknown fields. -// See [protoreflect.Message] for details. -func (m *Message) SetUnknown(r protoreflect.RawFields) { - if m.known == nil { - panic(errors.New("%v: modification of read-only message", m.typ.desc.FullName())) - } - m.unknown = r -} - -// IsValid reports whether the message is valid. -// See [protoreflect.Message] for details. -func (m *Message) IsValid() bool { - return m.known != nil -} - -func (m *Message) checkField(fd protoreflect.FieldDescriptor) { - if fd.IsExtension() && fd.ContainingMessage().FullName() == m.Descriptor().FullName() { - if _, ok := fd.(protoreflect.ExtensionTypeDescriptor); !ok { - panic(errors.New("%v: extension field descriptor does not implement ExtensionTypeDescriptor", fd.FullName())) - } - return - } - if fd.Parent() == m.Descriptor() { - return - } - fields := m.Descriptor().Fields() - index := fd.Index() - if index >= fields.Len() || fields.Get(index) != fd { - panic(errors.New("%v: field descriptor does not belong to this message", fd.FullName())) - } -} - -type messageType struct { - desc protoreflect.MessageDescriptor -} - -// NewMessageType creates a new MessageType with the provided descriptor. -// -// MessageTypes created by this package are equal if their descriptors are equal. -// That is, if md1 == md2, then NewMessageType(md1) == NewMessageType(md2). -func NewMessageType(desc protoreflect.MessageDescriptor) protoreflect.MessageType { - return messageType{desc} -} - -func (mt messageType) New() protoreflect.Message { return NewMessage(mt.desc) } -func (mt messageType) Zero() protoreflect.Message { return &Message{typ: messageType{mt.desc}} } -func (mt messageType) Descriptor() protoreflect.MessageDescriptor { return mt.desc } -func (mt messageType) Enum(i int) protoreflect.EnumType { - if ed := mt.desc.Fields().Get(i).Enum(); ed != nil { - return NewEnumType(ed) - } - return nil -} -func (mt messageType) Message(i int) protoreflect.MessageType { - if md := mt.desc.Fields().Get(i).Message(); md != nil { - return NewMessageType(md) - } - return nil -} - -type emptyList struct { - desc protoreflect.FieldDescriptor -} - -func (x emptyList) Len() int { return 0 } -func (x emptyList) Get(n int) protoreflect.Value { panic(errors.New("out of range")) } -func (x emptyList) Set(n int, v protoreflect.Value) { - panic(errors.New("modification of immutable list")) -} -func (x emptyList) Append(v protoreflect.Value) { panic(errors.New("modification of immutable list")) } -func (x emptyList) AppendMutable() protoreflect.Value { - panic(errors.New("modification of immutable list")) -} -func (x emptyList) Truncate(n int) { panic(errors.New("modification of immutable list")) } -func (x emptyList) NewElement() protoreflect.Value { return newListEntry(x.desc) } -func (x emptyList) IsValid() bool { return false } - -type dynamicList struct { - desc protoreflect.FieldDescriptor - list []protoreflect.Value -} - -func (x *dynamicList) Len() int { - return len(x.list) -} - -func (x *dynamicList) Get(n int) protoreflect.Value { - return x.list[n] -} - -func (x *dynamicList) Set(n int, v protoreflect.Value) { - typecheckSingular(x.desc, v) - x.list[n] = v -} - -func (x *dynamicList) Append(v protoreflect.Value) { - typecheckSingular(x.desc, v) - x.list = append(x.list, v) -} - -func (x *dynamicList) AppendMutable() protoreflect.Value { - if x.desc.Message() == nil { - panic(errors.New("%v: invalid AppendMutable on list with non-message type", x.desc.FullName())) - } - v := x.NewElement() - x.Append(v) - return v -} - -func (x *dynamicList) Truncate(n int) { - // Zero truncated elements to avoid keeping data live. - for i := n; i < len(x.list); i++ { - x.list[i] = protoreflect.Value{} - } - x.list = x.list[:n] -} - -func (x *dynamicList) NewElement() protoreflect.Value { - return newListEntry(x.desc) -} - -func (x *dynamicList) IsValid() bool { - return true -} - -type dynamicMap struct { - desc protoreflect.FieldDescriptor - mapv map[interface{}]protoreflect.Value -} - -func (x *dynamicMap) Get(k protoreflect.MapKey) protoreflect.Value { return x.mapv[k.Interface()] } -func (x *dynamicMap) Set(k protoreflect.MapKey, v protoreflect.Value) { - typecheckSingular(x.desc.MapKey(), k.Value()) - typecheckSingular(x.desc.MapValue(), v) - x.mapv[k.Interface()] = v -} -func (x *dynamicMap) Has(k protoreflect.MapKey) bool { return x.Get(k).IsValid() } -func (x *dynamicMap) Clear(k protoreflect.MapKey) { delete(x.mapv, k.Interface()) } -func (x *dynamicMap) Mutable(k protoreflect.MapKey) protoreflect.Value { - if x.desc.MapValue().Message() == nil { - panic(errors.New("%v: invalid Mutable on map with non-message value type", x.desc.FullName())) - } - v := x.Get(k) - if !v.IsValid() { - v = x.NewValue() - x.Set(k, v) - } - return v -} -func (x *dynamicMap) Len() int { return len(x.mapv) } -func (x *dynamicMap) NewValue() protoreflect.Value { - if md := x.desc.MapValue().Message(); md != nil { - return protoreflect.ValueOfMessage(NewMessage(md).ProtoReflect()) - } - return x.desc.MapValue().Default() -} -func (x *dynamicMap) IsValid() bool { - return x.mapv != nil -} - -func (x *dynamicMap) Range(f func(protoreflect.MapKey, protoreflect.Value) bool) { - for k, v := range x.mapv { - if !f(protoreflect.ValueOf(k).MapKey(), v) { - return - } - } -} - -func isSet(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool { - switch { - case fd.IsMap(): - return v.Map().Len() > 0 - case fd.IsList(): - return v.List().Len() > 0 - case fd.ContainingOneof() != nil: - return true - case !fd.HasPresence() && !fd.IsExtension(): - switch fd.Kind() { - case protoreflect.BoolKind: - return v.Bool() - case protoreflect.EnumKind: - return v.Enum() != 0 - case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed32Kind, protoreflect.Sfixed64Kind: - return v.Int() != 0 - case protoreflect.Uint32Kind, protoreflect.Uint64Kind, protoreflect.Fixed32Kind, protoreflect.Fixed64Kind: - return v.Uint() != 0 - case protoreflect.FloatKind, protoreflect.DoubleKind: - return v.Float() != 0 || math.Signbit(v.Float()) - case protoreflect.StringKind: - return v.String() != "" - case protoreflect.BytesKind: - return len(v.Bytes()) > 0 - } - } - return true -} - -func typecheck(fd protoreflect.FieldDescriptor, v protoreflect.Value) { - if err := typeIsValid(fd, v); err != nil { - panic(err) - } -} - -func typeIsValid(fd protoreflect.FieldDescriptor, v protoreflect.Value) error { - switch { - case !v.IsValid(): - return errors.New("%v: assigning invalid value", fd.FullName()) - case fd.IsMap(): - if mapv, ok := v.Interface().(*dynamicMap); !ok || mapv.desc != fd || !mapv.IsValid() { - return errors.New("%v: assigning invalid type %T", fd.FullName(), v.Interface()) - } - return nil - case fd.IsList(): - switch list := v.Interface().(type) { - case *dynamicList: - if list.desc == fd && list.IsValid() { - return nil - } - case emptyList: - if list.desc == fd && list.IsValid() { - return nil - } - } - return errors.New("%v: assigning invalid type %T", fd.FullName(), v.Interface()) - default: - return singularTypeIsValid(fd, v) - } -} - -func typecheckSingular(fd protoreflect.FieldDescriptor, v protoreflect.Value) { - if err := singularTypeIsValid(fd, v); err != nil { - panic(err) - } -} - -func singularTypeIsValid(fd protoreflect.FieldDescriptor, v protoreflect.Value) error { - vi := v.Interface() - var ok bool - switch fd.Kind() { - case protoreflect.BoolKind: - _, ok = vi.(bool) - case protoreflect.EnumKind: - // We could check against the valid set of enum values, but do not. - _, ok = vi.(protoreflect.EnumNumber) - case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind: - _, ok = vi.(int32) - case protoreflect.Uint32Kind, protoreflect.Fixed32Kind: - _, ok = vi.(uint32) - case protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind: - _, ok = vi.(int64) - case protoreflect.Uint64Kind, protoreflect.Fixed64Kind: - _, ok = vi.(uint64) - case protoreflect.FloatKind: - _, ok = vi.(float32) - case protoreflect.DoubleKind: - _, ok = vi.(float64) - case protoreflect.StringKind: - _, ok = vi.(string) - case protoreflect.BytesKind: - _, ok = vi.([]byte) - case protoreflect.MessageKind, protoreflect.GroupKind: - var m protoreflect.Message - m, ok = vi.(protoreflect.Message) - if ok && m.Descriptor().FullName() != fd.Message().FullName() { - return errors.New("%v: assigning invalid message type %v", fd.FullName(), m.Descriptor().FullName()) - } - if dm, ok := vi.(*Message); ok && dm.known == nil { - return errors.New("%v: assigning invalid zero-value message", fd.FullName()) - } - } - if !ok { - return errors.New("%v: assigning invalid type %T", fd.FullName(), v.Interface()) - } - return nil -} - -func newListEntry(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.Kind() { - case protoreflect.BoolKind: - return protoreflect.ValueOfBool(false) - case protoreflect.EnumKind: - return protoreflect.ValueOfEnum(fd.Enum().Values().Get(0).Number()) - case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind: - return protoreflect.ValueOfInt32(0) - case protoreflect.Uint32Kind, protoreflect.Fixed32Kind: - return protoreflect.ValueOfUint32(0) - case protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind: - return protoreflect.ValueOfInt64(0) - case protoreflect.Uint64Kind, protoreflect.Fixed64Kind: - return protoreflect.ValueOfUint64(0) - case protoreflect.FloatKind: - return protoreflect.ValueOfFloat32(0) - case protoreflect.DoubleKind: - return protoreflect.ValueOfFloat64(0) - case protoreflect.StringKind: - return protoreflect.ValueOfString("") - case protoreflect.BytesKind: - return protoreflect.ValueOfBytes(nil) - case protoreflect.MessageKind, protoreflect.GroupKind: - return protoreflect.ValueOfMessage(NewMessage(fd.Message()).ProtoReflect()) - } - panic(errors.New("%v: unknown kind %v", fd.FullName(), fd.Kind())) -} - -// NewExtensionType creates a new ExtensionType with the provided descriptor. -// -// Dynamic ExtensionTypes with the same descriptor compare as equal. That is, -// if xd1 == xd2, then NewExtensionType(xd1) == NewExtensionType(xd2). -// -// The InterfaceOf and ValueOf methods of the extension type are defined as: -// -// func (xt extensionType) ValueOf(iv interface{}) protoreflect.Value { -// return protoreflect.ValueOf(iv) -// } -// -// func (xt extensionType) InterfaceOf(v protoreflect.Value) interface{} { -// return v.Interface() -// } -// -// The Go type used by the proto.GetExtension and proto.SetExtension functions -// is determined by these methods, and is therefore equivalent to the Go type -// used to represent a protoreflect.Value. See the protoreflect.Value -// documentation for more details. -func NewExtensionType(desc protoreflect.ExtensionDescriptor) protoreflect.ExtensionType { - if xt, ok := desc.(protoreflect.ExtensionTypeDescriptor); ok { - desc = xt.Descriptor() - } - return extensionType{extensionTypeDescriptor{desc}} -} - -func (xt extensionType) New() protoreflect.Value { - switch { - case xt.desc.IsMap(): - return protoreflect.ValueOfMap(&dynamicMap{ - desc: xt.desc, - mapv: make(map[interface{}]protoreflect.Value), - }) - case xt.desc.IsList(): - return protoreflect.ValueOfList(&dynamicList{desc: xt.desc}) - case xt.desc.Message() != nil: - return protoreflect.ValueOfMessage(NewMessage(xt.desc.Message())) - default: - return xt.desc.Default() - } -} - -func (xt extensionType) Zero() protoreflect.Value { - switch { - case xt.desc.IsMap(): - return protoreflect.ValueOfMap(&dynamicMap{desc: xt.desc}) - case xt.desc.Cardinality() == protoreflect.Repeated: - return protoreflect.ValueOfList(emptyList{desc: xt.desc}) - case xt.desc.Message() != nil: - return protoreflect.ValueOfMessage(&Message{typ: messageType{xt.desc.Message()}}) - default: - return xt.desc.Default() - } -} - -func (xt extensionType) TypeDescriptor() protoreflect.ExtensionTypeDescriptor { - return xt.desc -} - -func (xt extensionType) ValueOf(iv interface{}) protoreflect.Value { - v := protoreflect.ValueOf(iv) - typecheck(xt.desc, v) - return v -} - -func (xt extensionType) InterfaceOf(v protoreflect.Value) interface{} { - typecheck(xt.desc, v) - return v.Interface() -} - -func (xt extensionType) IsValidInterface(iv interface{}) bool { - return typeIsValid(xt.desc, protoreflect.ValueOf(iv)) == nil -} - -func (xt extensionType) IsValidValue(v protoreflect.Value) bool { - return typeIsValid(xt.desc, v) == nil -} - -type extensionTypeDescriptor struct { - protoreflect.ExtensionDescriptor -} - -func (xt extensionTypeDescriptor) Type() protoreflect.ExtensionType { - return extensionType{xt} -} - -func (xt extensionTypeDescriptor) Descriptor() protoreflect.ExtensionDescriptor { - return xt.ExtensionDescriptor -} diff --git a/vendor/google.golang.org/protobuf/types/dynamicpb/types.go b/vendor/google.golang.org/protobuf/types/dynamicpb/types.go deleted file mode 100644 index c432817bb..000000000 --- a/vendor/google.golang.org/protobuf/types/dynamicpb/types.go +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright 2023 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package dynamicpb - -import ( - "fmt" - "strings" - "sync" - "sync/atomic" - - "google.golang.org/protobuf/internal/errors" - "google.golang.org/protobuf/reflect/protoreflect" - "google.golang.org/protobuf/reflect/protoregistry" -) - -type extField struct { - name protoreflect.FullName - number protoreflect.FieldNumber -} - -// A Types is a collection of dynamically constructed descriptors. -// Its methods are safe for concurrent use. -// -// Types implements [protoregistry.MessageTypeResolver] and [protoregistry.ExtensionTypeResolver]. -// A Types may be used as a [google.golang.org/protobuf/proto.UnmarshalOptions.Resolver]. -type Types struct { - // atomicExtFiles is used with sync/atomic and hence must be the first word - // of the struct to guarantee 64-bit alignment. - // - // TODO(stapelberg): once we only support Go 1.19 and newer, switch this - // field to be of type atomic.Uint64 to guarantee alignment on - // stack-allocated values, too. - atomicExtFiles uint64 - extMu sync.Mutex - - files *protoregistry.Files - - extensionsByMessage map[extField]protoreflect.ExtensionDescriptor -} - -// NewTypes creates a new Types registry with the provided files. -// The Files registry is retained, and changes to Files will be reflected in Types. -// It is not safe to concurrently change the Files while calling Types methods. -func NewTypes(f *protoregistry.Files) *Types { - return &Types{ - files: f, - } -} - -// FindEnumByName looks up an enum by its full name; -// e.g., "google.protobuf.Field.Kind". -// -// This returns (nil, [protoregistry.NotFound]) if not found. -func (t *Types) FindEnumByName(name protoreflect.FullName) (protoreflect.EnumType, error) { - d, err := t.files.FindDescriptorByName(name) - if err != nil { - return nil, err - } - ed, ok := d.(protoreflect.EnumDescriptor) - if !ok { - return nil, errors.New("found wrong type: got %v, want enum", descName(d)) - } - return NewEnumType(ed), nil -} - -// FindExtensionByName looks up an extension field by the field's full name. -// Note that this is the full name of the field as determined by -// where the extension is declared and is unrelated to the full name of the -// message being extended. -// -// This returns (nil, [protoregistry.NotFound]) if not found. -func (t *Types) FindExtensionByName(name protoreflect.FullName) (protoreflect.ExtensionType, error) { - d, err := t.files.FindDescriptorByName(name) - if err != nil { - return nil, err - } - xd, ok := d.(protoreflect.ExtensionDescriptor) - if !ok { - return nil, errors.New("found wrong type: got %v, want extension", descName(d)) - } - return NewExtensionType(xd), nil -} - -// FindExtensionByNumber looks up an extension field by the field number -// within some parent message, identified by full name. -// -// This returns (nil, [protoregistry.NotFound]) if not found. -func (t *Types) FindExtensionByNumber(message protoreflect.FullName, field protoreflect.FieldNumber) (protoreflect.ExtensionType, error) { - // Construct the extension number map lazily, since not every user will need it. - // Update the map if new files are added to the registry. - if atomic.LoadUint64(&t.atomicExtFiles) != uint64(t.files.NumFiles()) { - t.updateExtensions() - } - xd := t.extensionsByMessage[extField{message, field}] - if xd == nil { - return nil, protoregistry.NotFound - } - return NewExtensionType(xd), nil -} - -// FindMessageByName looks up a message by its full name; -// e.g. "google.protobuf.Any". -// -// This returns (nil, [protoregistry.NotFound]) if not found. -func (t *Types) FindMessageByName(name protoreflect.FullName) (protoreflect.MessageType, error) { - d, err := t.files.FindDescriptorByName(name) - if err != nil { - return nil, err - } - md, ok := d.(protoreflect.MessageDescriptor) - if !ok { - return nil, errors.New("found wrong type: got %v, want message", descName(d)) - } - return NewMessageType(md), nil -} - -// FindMessageByURL looks up a message by a URL identifier. -// See documentation on google.protobuf.Any.type_url for the URL format. -// -// This returns (nil, [protoregistry.NotFound]) if not found. -func (t *Types) FindMessageByURL(url string) (protoreflect.MessageType, error) { - // This function is similar to FindMessageByName but - // truncates anything before and including '/' in the URL. - message := protoreflect.FullName(url) - if i := strings.LastIndexByte(url, '/'); i >= 0 { - message = message[i+len("/"):] - } - return t.FindMessageByName(message) -} - -func (t *Types) updateExtensions() { - t.extMu.Lock() - defer t.extMu.Unlock() - if atomic.LoadUint64(&t.atomicExtFiles) == uint64(t.files.NumFiles()) { - return - } - defer atomic.StoreUint64(&t.atomicExtFiles, uint64(t.files.NumFiles())) - t.files.RangeFiles(func(fd protoreflect.FileDescriptor) bool { - t.registerExtensions(fd.Extensions()) - t.registerExtensionsInMessages(fd.Messages()) - return true - }) -} - -func (t *Types) registerExtensionsInMessages(mds protoreflect.MessageDescriptors) { - count := mds.Len() - for i := 0; i < count; i++ { - md := mds.Get(i) - t.registerExtensions(md.Extensions()) - t.registerExtensionsInMessages(md.Messages()) - } -} - -func (t *Types) registerExtensions(xds protoreflect.ExtensionDescriptors) { - count := xds.Len() - for i := 0; i < count; i++ { - xd := xds.Get(i) - field := xd.Number() - message := xd.ContainingMessage().FullName() - if t.extensionsByMessage == nil { - t.extensionsByMessage = make(map[extField]protoreflect.ExtensionDescriptor) - } - t.extensionsByMessage[extField{message, field}] = xd - } -} - -func descName(d protoreflect.Descriptor) string { - switch d.(type) { - case protoreflect.EnumDescriptor: - return "enum" - case protoreflect.EnumValueDescriptor: - return "enum value" - case protoreflect.MessageDescriptor: - return "message" - case protoreflect.ExtensionDescriptor: - return "extension" - case protoreflect.ServiceDescriptor: - return "service" - default: - return fmt.Sprintf("%T", d) - } -} diff --git a/vendor/google.golang.org/protobuf/types/known/durationpb/duration.pb.go b/vendor/google.golang.org/protobuf/types/known/durationpb/duration.pb.go deleted file mode 100644 index df709a8dd..000000000 --- a/vendor/google.golang.org/protobuf/types/known/durationpb/duration.pb.go +++ /dev/null @@ -1,374 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: google/protobuf/duration.proto - -// Package durationpb contains generated types for google/protobuf/duration.proto. -// -// The Duration message represents a signed span of time. -// -// # Conversion to a Go Duration -// -// The AsDuration method can be used to convert a Duration message to a -// standard Go time.Duration value: -// -// d := dur.AsDuration() -// ... // make use of d as a time.Duration -// -// Converting to a time.Duration is a common operation so that the extensive -// set of time-based operations provided by the time package can be leveraged. -// See https://golang.org/pkg/time for more information. -// -// The AsDuration method performs the conversion on a best-effort basis. -// Durations with denormal values (e.g., nanoseconds beyond -99999999 and -// +99999999, inclusive; or seconds and nanoseconds with opposite signs) -// are normalized during the conversion to a time.Duration. To manually check for -// invalid Duration per the documented limitations in duration.proto, -// additionally call the CheckValid method: -// -// if err := dur.CheckValid(); err != nil { -// ... // handle error -// } -// -// Note that the documented limitations in duration.proto does not protect a -// Duration from overflowing the representable range of a time.Duration in Go. -// The AsDuration method uses saturation arithmetic such that an overflow clamps -// the resulting value to the closest representable value (e.g., math.MaxInt64 -// for positive overflow and math.MinInt64 for negative overflow). -// -// # Conversion from a Go Duration -// -// The durationpb.New function can be used to construct a Duration message -// from a standard Go time.Duration value: -// -// dur := durationpb.New(d) -// ... // make use of d as a *durationpb.Duration -package durationpb - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - math "math" - reflect "reflect" - sync "sync" - time "time" -) - -// A Duration represents a signed, fixed-length span of time represented -// as a count of seconds and fractions of seconds at nanosecond -// resolution. It is independent of any calendar and concepts like "day" -// or "month". It is related to Timestamp in that the difference between -// two Timestamp values is a Duration and it can be added or subtracted -// from a Timestamp. Range is approximately +-10,000 years. -// -// # Examples -// -// Example 1: Compute Duration from two Timestamps in pseudo code. -// -// Timestamp start = ...; -// Timestamp end = ...; -// Duration duration = ...; -// -// duration.seconds = end.seconds - start.seconds; -// duration.nanos = end.nanos - start.nanos; -// -// if (duration.seconds < 0 && duration.nanos > 0) { -// duration.seconds += 1; -// duration.nanos -= 1000000000; -// } else if (duration.seconds > 0 && duration.nanos < 0) { -// duration.seconds -= 1; -// duration.nanos += 1000000000; -// } -// -// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. -// -// Timestamp start = ...; -// Duration duration = ...; -// Timestamp end = ...; -// -// end.seconds = start.seconds + duration.seconds; -// end.nanos = start.nanos + duration.nanos; -// -// if (end.nanos < 0) { -// end.seconds -= 1; -// end.nanos += 1000000000; -// } else if (end.nanos >= 1000000000) { -// end.seconds += 1; -// end.nanos -= 1000000000; -// } -// -// Example 3: Compute Duration from datetime.timedelta in Python. -// -// td = datetime.timedelta(days=3, minutes=10) -// duration = Duration() -// duration.FromTimedelta(td) -// -// # JSON Mapping -// -// In JSON format, the Duration type is encoded as a string rather than an -// object, where the string ends in the suffix "s" (indicating seconds) and -// is preceded by the number of seconds, with nanoseconds expressed as -// fractional seconds. For example, 3 seconds with 0 nanoseconds should be -// encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should -// be expressed in JSON format as "3.000000001s", and 3 seconds and 1 -// microsecond should be expressed in JSON format as "3.000001s". -type Duration struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Signed seconds of the span of time. Must be from -315,576,000,000 - // to +315,576,000,000 inclusive. Note: these bounds are computed from: - // 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years - Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"` - // Signed fractions of a second at nanosecond resolution of the span - // of time. Durations less than one second are represented with a 0 - // `seconds` field and a positive or negative `nanos` field. For durations - // of one second or more, a non-zero value for the `nanos` field must be - // of the same sign as the `seconds` field. Must be from -999,999,999 - // to +999,999,999 inclusive. - Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"` -} - -// New constructs a new Duration from the provided time.Duration. -func New(d time.Duration) *Duration { - nanos := d.Nanoseconds() - secs := nanos / 1e9 - nanos -= secs * 1e9 - return &Duration{Seconds: int64(secs), Nanos: int32(nanos)} -} - -// AsDuration converts x to a time.Duration, -// returning the closest duration value in the event of overflow. -func (x *Duration) AsDuration() time.Duration { - secs := x.GetSeconds() - nanos := x.GetNanos() - d := time.Duration(secs) * time.Second - overflow := d/time.Second != time.Duration(secs) - d += time.Duration(nanos) * time.Nanosecond - overflow = overflow || (secs < 0 && nanos < 0 && d > 0) - overflow = overflow || (secs > 0 && nanos > 0 && d < 0) - if overflow { - switch { - case secs < 0: - return time.Duration(math.MinInt64) - case secs > 0: - return time.Duration(math.MaxInt64) - } - } - return d -} - -// IsValid reports whether the duration is valid. -// It is equivalent to CheckValid == nil. -func (x *Duration) IsValid() bool { - return x.check() == 0 -} - -// CheckValid returns an error if the duration is invalid. -// In particular, it checks whether the value is within the range of -// -10000 years to +10000 years inclusive. -// An error is reported for a nil Duration. -func (x *Duration) CheckValid() error { - switch x.check() { - case invalidNil: - return protoimpl.X.NewError("invalid nil Duration") - case invalidUnderflow: - return protoimpl.X.NewError("duration (%v) exceeds -10000 years", x) - case invalidOverflow: - return protoimpl.X.NewError("duration (%v) exceeds +10000 years", x) - case invalidNanosRange: - return protoimpl.X.NewError("duration (%v) has out-of-range nanos", x) - case invalidNanosSign: - return protoimpl.X.NewError("duration (%v) has seconds and nanos with different signs", x) - default: - return nil - } -} - -const ( - _ = iota - invalidNil - invalidUnderflow - invalidOverflow - invalidNanosRange - invalidNanosSign -) - -func (x *Duration) check() uint { - const absDuration = 315576000000 // 10000yr * 365.25day/yr * 24hr/day * 60min/hr * 60sec/min - secs := x.GetSeconds() - nanos := x.GetNanos() - switch { - case x == nil: - return invalidNil - case secs < -absDuration: - return invalidUnderflow - case secs > +absDuration: - return invalidOverflow - case nanos <= -1e9 || nanos >= +1e9: - return invalidNanosRange - case (secs > 0 && nanos < 0) || (secs < 0 && nanos > 0): - return invalidNanosSign - default: - return 0 - } -} - -func (x *Duration) Reset() { - *x = Duration{} - if protoimpl.UnsafeEnabled { - mi := &file_google_protobuf_duration_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Duration) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Duration) ProtoMessage() {} - -func (x *Duration) ProtoReflect() protoreflect.Message { - mi := &file_google_protobuf_duration_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 Duration.ProtoReflect.Descriptor instead. -func (*Duration) Descriptor() ([]byte, []int) { - return file_google_protobuf_duration_proto_rawDescGZIP(), []int{0} -} - -func (x *Duration) GetSeconds() int64 { - if x != nil { - return x.Seconds - } - return 0 -} - -func (x *Duration) GetNanos() int32 { - if x != nil { - return x.Nanos - } - return 0 -} - -var File_google_protobuf_duration_proto protoreflect.FileDescriptor - -var file_google_protobuf_duration_proto_rawDesc = []byte{ - 0x0a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x12, 0x0f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x22, 0x3a, 0x0a, 0x08, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, - 0x07, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, - 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x61, 0x6e, 0x6f, 0x73, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6e, 0x61, 0x6e, 0x6f, 0x73, 0x42, 0x83, 0x01, - 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x42, 0x0d, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x31, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, - 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x2f, 0x64, - 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x70, 0x62, 0xf8, 0x01, 0x01, 0xa2, 0x02, 0x03, 0x47, - 0x50, 0x42, 0xaa, 0x02, 0x1e, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x79, - 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_google_protobuf_duration_proto_rawDescOnce sync.Once - file_google_protobuf_duration_proto_rawDescData = file_google_protobuf_duration_proto_rawDesc -) - -func file_google_protobuf_duration_proto_rawDescGZIP() []byte { - file_google_protobuf_duration_proto_rawDescOnce.Do(func() { - file_google_protobuf_duration_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_protobuf_duration_proto_rawDescData) - }) - return file_google_protobuf_duration_proto_rawDescData -} - -var file_google_protobuf_duration_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_google_protobuf_duration_proto_goTypes = []interface{}{ - (*Duration)(nil), // 0: google.protobuf.Duration -} -var file_google_protobuf_duration_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_google_protobuf_duration_proto_init() } -func file_google_protobuf_duration_proto_init() { - if File_google_protobuf_duration_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_google_protobuf_duration_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Duration); 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_google_protobuf_duration_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_google_protobuf_duration_proto_goTypes, - DependencyIndexes: file_google_protobuf_duration_proto_depIdxs, - MessageInfos: file_google_protobuf_duration_proto_msgTypes, - }.Build() - File_google_protobuf_duration_proto = out.File - file_google_protobuf_duration_proto_rawDesc = nil - file_google_protobuf_duration_proto_goTypes = nil - file_google_protobuf_duration_proto_depIdxs = nil -} diff --git a/vendor/google.golang.org/protobuf/types/known/emptypb/empty.pb.go b/vendor/google.golang.org/protobuf/types/known/emptypb/empty.pb.go deleted file mode 100644 index 9a7277ba3..000000000 --- a/vendor/google.golang.org/protobuf/types/known/emptypb/empty.pb.go +++ /dev/null @@ -1,166 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: google/protobuf/empty.proto - -package emptypb - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -// A generic empty message that you can re-use to avoid defining duplicated -// empty messages in your APIs. A typical example is to use it as the request -// or the response type of an API method. For instance: -// -// service Foo { -// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); -// } -type Empty struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *Empty) Reset() { - *x = Empty{} - if protoimpl.UnsafeEnabled { - mi := &file_google_protobuf_empty_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Empty) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Empty) ProtoMessage() {} - -func (x *Empty) ProtoReflect() protoreflect.Message { - mi := &file_google_protobuf_empty_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 Empty.ProtoReflect.Descriptor instead. -func (*Empty) Descriptor() ([]byte, []int) { - return file_google_protobuf_empty_proto_rawDescGZIP(), []int{0} -} - -var File_google_protobuf_empty_proto protoreflect.FileDescriptor - -var file_google_protobuf_empty_proto_rawDesc = []byte{ - 0x0a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x22, 0x07, - 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x42, 0x7d, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x42, 0x0a, - 0x45, 0x6d, 0x70, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x6b, - 0x6e, 0x6f, 0x77, 0x6e, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x70, 0x62, 0xf8, 0x01, 0x01, 0xa2, - 0x02, 0x03, 0x47, 0x50, 0x42, 0xaa, 0x02, 0x1e, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f, 0x77, - 0x6e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_google_protobuf_empty_proto_rawDescOnce sync.Once - file_google_protobuf_empty_proto_rawDescData = file_google_protobuf_empty_proto_rawDesc -) - -func file_google_protobuf_empty_proto_rawDescGZIP() []byte { - file_google_protobuf_empty_proto_rawDescOnce.Do(func() { - file_google_protobuf_empty_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_protobuf_empty_proto_rawDescData) - }) - return file_google_protobuf_empty_proto_rawDescData -} - -var file_google_protobuf_empty_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_google_protobuf_empty_proto_goTypes = []interface{}{ - (*Empty)(nil), // 0: google.protobuf.Empty -} -var file_google_protobuf_empty_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_google_protobuf_empty_proto_init() } -func file_google_protobuf_empty_proto_init() { - if File_google_protobuf_empty_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_google_protobuf_empty_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Empty); 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_google_protobuf_empty_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_google_protobuf_empty_proto_goTypes, - DependencyIndexes: file_google_protobuf_empty_proto_depIdxs, - MessageInfos: file_google_protobuf_empty_proto_msgTypes, - }.Build() - File_google_protobuf_empty_proto = out.File - file_google_protobuf_empty_proto_rawDesc = nil - file_google_protobuf_empty_proto_goTypes = nil - file_google_protobuf_empty_proto_depIdxs = nil -} diff --git a/vendor/google.golang.org/protobuf/types/known/structpb/struct.pb.go b/vendor/google.golang.org/protobuf/types/known/structpb/struct.pb.go deleted file mode 100644 index d2bac8b88..000000000 --- a/vendor/google.golang.org/protobuf/types/known/structpb/struct.pb.go +++ /dev/null @@ -1,810 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: google/protobuf/struct.proto - -// Package structpb contains generated types for google/protobuf/struct.proto. -// -// The messages (i.e., Value, Struct, and ListValue) defined in struct.proto are -// used to represent arbitrary JSON. The Value message represents a JSON value, -// the Struct message represents a JSON object, and the ListValue message -// represents a JSON array. See https://json.org for more information. -// -// The Value, Struct, and ListValue types have generated MarshalJSON and -// UnmarshalJSON methods such that they serialize JSON equivalent to what the -// messages themselves represent. Use of these types with the -// "google.golang.org/protobuf/encoding/protojson" package -// ensures that they will be serialized as their JSON equivalent. -// -// # Conversion to and from a Go interface -// -// The standard Go "encoding/json" package has functionality to serialize -// arbitrary types to a large degree. The Value.AsInterface, Struct.AsMap, and -// ListValue.AsSlice methods can convert the protobuf message representation into -// a form represented by interface{}, map[string]interface{}, and []interface{}. -// This form can be used with other packages that operate on such data structures -// and also directly with the standard json package. -// -// In order to convert the interface{}, map[string]interface{}, and []interface{} -// forms back as Value, Struct, and ListValue messages, use the NewStruct, -// NewList, and NewValue constructor functions. -// -// # Example usage -// -// Consider the following example JSON object: -// -// { -// "firstName": "John", -// "lastName": "Smith", -// "isAlive": true, -// "age": 27, -// "address": { -// "streetAddress": "21 2nd Street", -// "city": "New York", -// "state": "NY", -// "postalCode": "10021-3100" -// }, -// "phoneNumbers": [ -// { -// "type": "home", -// "number": "212 555-1234" -// }, -// { -// "type": "office", -// "number": "646 555-4567" -// } -// ], -// "children": [], -// "spouse": null -// } -// -// To construct a Value message representing the above JSON object: -// -// m, err := structpb.NewValue(map[string]interface{}{ -// "firstName": "John", -// "lastName": "Smith", -// "isAlive": true, -// "age": 27, -// "address": map[string]interface{}{ -// "streetAddress": "21 2nd Street", -// "city": "New York", -// "state": "NY", -// "postalCode": "10021-3100", -// }, -// "phoneNumbers": []interface{}{ -// map[string]interface{}{ -// "type": "home", -// "number": "212 555-1234", -// }, -// map[string]interface{}{ -// "type": "office", -// "number": "646 555-4567", -// }, -// }, -// "children": []interface{}{}, -// "spouse": nil, -// }) -// if err != nil { -// ... // handle error -// } -// ... // make use of m as a *structpb.Value -package structpb - -import ( - base64 "encoding/base64" - protojson "google.golang.org/protobuf/encoding/protojson" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - math "math" - reflect "reflect" - sync "sync" - utf8 "unicode/utf8" -) - -// `NullValue` is a singleton enumeration to represent the null value for the -// `Value` type union. -// -// The JSON representation for `NullValue` is JSON `null`. -type NullValue int32 - -const ( - // Null value. - NullValue_NULL_VALUE NullValue = 0 -) - -// Enum value maps for NullValue. -var ( - NullValue_name = map[int32]string{ - 0: "NULL_VALUE", - } - NullValue_value = map[string]int32{ - "NULL_VALUE": 0, - } -) - -func (x NullValue) Enum() *NullValue { - p := new(NullValue) - *p = x - return p -} - -func (x NullValue) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (NullValue) Descriptor() protoreflect.EnumDescriptor { - return file_google_protobuf_struct_proto_enumTypes[0].Descriptor() -} - -func (NullValue) Type() protoreflect.EnumType { - return &file_google_protobuf_struct_proto_enumTypes[0] -} - -func (x NullValue) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use NullValue.Descriptor instead. -func (NullValue) EnumDescriptor() ([]byte, []int) { - return file_google_protobuf_struct_proto_rawDescGZIP(), []int{0} -} - -// `Struct` represents a structured data value, consisting of fields -// which map to dynamically typed values. In some languages, `Struct` -// might be supported by a native representation. For example, in -// scripting languages like JS a struct is represented as an -// object. The details of that representation are described together -// with the proto support for the language. -// -// The JSON representation for `Struct` is JSON object. -type Struct struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Unordered map of dynamically typed values. - Fields map[string]*Value `protobuf:"bytes,1,rep,name=fields,proto3" json:"fields,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` -} - -// NewStruct constructs a Struct from a general-purpose Go map. -// The map keys must be valid UTF-8. -// The map values are converted using NewValue. -func NewStruct(v map[string]interface{}) (*Struct, error) { - x := &Struct{Fields: make(map[string]*Value, len(v))} - for k, v := range v { - if !utf8.ValidString(k) { - return nil, protoimpl.X.NewError("invalid UTF-8 in string: %q", k) - } - var err error - x.Fields[k], err = NewValue(v) - if err != nil { - return nil, err - } - } - return x, nil -} - -// AsMap converts x to a general-purpose Go map. -// The map values are converted by calling Value.AsInterface. -func (x *Struct) AsMap() map[string]interface{} { - f := x.GetFields() - vs := make(map[string]interface{}, len(f)) - for k, v := range f { - vs[k] = v.AsInterface() - } - return vs -} - -func (x *Struct) MarshalJSON() ([]byte, error) { - return protojson.Marshal(x) -} - -func (x *Struct) UnmarshalJSON(b []byte) error { - return protojson.Unmarshal(b, x) -} - -func (x *Struct) Reset() { - *x = Struct{} - if protoimpl.UnsafeEnabled { - mi := &file_google_protobuf_struct_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Struct) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Struct) ProtoMessage() {} - -func (x *Struct) ProtoReflect() protoreflect.Message { - mi := &file_google_protobuf_struct_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 Struct.ProtoReflect.Descriptor instead. -func (*Struct) Descriptor() ([]byte, []int) { - return file_google_protobuf_struct_proto_rawDescGZIP(), []int{0} -} - -func (x *Struct) GetFields() map[string]*Value { - if x != nil { - return x.Fields - } - return nil -} - -// `Value` represents a dynamically typed value which can be either -// null, a number, a string, a boolean, a recursive struct value, or a -// list of values. A producer of value is expected to set one of these -// variants. Absence of any variant indicates an error. -// -// The JSON representation for `Value` is JSON value. -type Value struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The kind of value. - // - // Types that are assignable to Kind: - // - // *Value_NullValue - // *Value_NumberValue - // *Value_StringValue - // *Value_BoolValue - // *Value_StructValue - // *Value_ListValue - Kind isValue_Kind `protobuf_oneof:"kind"` -} - -// NewValue constructs a Value from a general-purpose Go interface. -// -// ╔════════════════════════╤════════════════════════════════════════════╗ -// ║ Go type │ Conversion ║ -// ╠════════════════════════╪════════════════════════════════════════════╣ -// ║ nil │ stored as NullValue ║ -// ║ bool │ stored as BoolValue ║ -// ║ int, int32, int64 │ stored as NumberValue ║ -// ║ uint, uint32, uint64 │ stored as NumberValue ║ -// ║ float32, float64 │ stored as NumberValue ║ -// ║ string │ stored as StringValue; must be valid UTF-8 ║ -// ║ []byte │ stored as StringValue; base64-encoded ║ -// ║ map[string]interface{} │ stored as StructValue ║ -// ║ []interface{} │ stored as ListValue ║ -// ╚════════════════════════╧════════════════════════════════════════════╝ -// -// When converting an int64 or uint64 to a NumberValue, numeric precision loss -// is possible since they are stored as a float64. -func NewValue(v interface{}) (*Value, error) { - switch v := v.(type) { - case nil: - return NewNullValue(), nil - case bool: - return NewBoolValue(v), nil - case int: - return NewNumberValue(float64(v)), nil - case int32: - return NewNumberValue(float64(v)), nil - case int64: - return NewNumberValue(float64(v)), nil - case uint: - return NewNumberValue(float64(v)), nil - case uint32: - return NewNumberValue(float64(v)), nil - case uint64: - return NewNumberValue(float64(v)), nil - case float32: - return NewNumberValue(float64(v)), nil - case float64: - return NewNumberValue(float64(v)), nil - case string: - if !utf8.ValidString(v) { - return nil, protoimpl.X.NewError("invalid UTF-8 in string: %q", v) - } - return NewStringValue(v), nil - case []byte: - s := base64.StdEncoding.EncodeToString(v) - return NewStringValue(s), nil - case map[string]interface{}: - v2, err := NewStruct(v) - if err != nil { - return nil, err - } - return NewStructValue(v2), nil - case []interface{}: - v2, err := NewList(v) - if err != nil { - return nil, err - } - return NewListValue(v2), nil - default: - return nil, protoimpl.X.NewError("invalid type: %T", v) - } -} - -// NewNullValue constructs a new null Value. -func NewNullValue() *Value { - return &Value{Kind: &Value_NullValue{NullValue: NullValue_NULL_VALUE}} -} - -// NewBoolValue constructs a new boolean Value. -func NewBoolValue(v bool) *Value { - return &Value{Kind: &Value_BoolValue{BoolValue: v}} -} - -// NewNumberValue constructs a new number Value. -func NewNumberValue(v float64) *Value { - return &Value{Kind: &Value_NumberValue{NumberValue: v}} -} - -// NewStringValue constructs a new string Value. -func NewStringValue(v string) *Value { - return &Value{Kind: &Value_StringValue{StringValue: v}} -} - -// NewStructValue constructs a new struct Value. -func NewStructValue(v *Struct) *Value { - return &Value{Kind: &Value_StructValue{StructValue: v}} -} - -// NewListValue constructs a new list Value. -func NewListValue(v *ListValue) *Value { - return &Value{Kind: &Value_ListValue{ListValue: v}} -} - -// AsInterface converts x to a general-purpose Go interface. -// -// Calling Value.MarshalJSON and "encoding/json".Marshal on this output produce -// semantically equivalent JSON (assuming no errors occur). -// -// Floating-point values (i.e., "NaN", "Infinity", and "-Infinity") are -// converted as strings to remain compatible with MarshalJSON. -func (x *Value) AsInterface() interface{} { - switch v := x.GetKind().(type) { - case *Value_NumberValue: - if v != nil { - switch { - case math.IsNaN(v.NumberValue): - return "NaN" - case math.IsInf(v.NumberValue, +1): - return "Infinity" - case math.IsInf(v.NumberValue, -1): - return "-Infinity" - default: - return v.NumberValue - } - } - case *Value_StringValue: - if v != nil { - return v.StringValue - } - case *Value_BoolValue: - if v != nil { - return v.BoolValue - } - case *Value_StructValue: - if v != nil { - return v.StructValue.AsMap() - } - case *Value_ListValue: - if v != nil { - return v.ListValue.AsSlice() - } - } - return nil -} - -func (x *Value) MarshalJSON() ([]byte, error) { - return protojson.Marshal(x) -} - -func (x *Value) UnmarshalJSON(b []byte) error { - return protojson.Unmarshal(b, x) -} - -func (x *Value) Reset() { - *x = Value{} - if protoimpl.UnsafeEnabled { - mi := &file_google_protobuf_struct_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Value) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Value) ProtoMessage() {} - -func (x *Value) ProtoReflect() protoreflect.Message { - mi := &file_google_protobuf_struct_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 Value.ProtoReflect.Descriptor instead. -func (*Value) Descriptor() ([]byte, []int) { - return file_google_protobuf_struct_proto_rawDescGZIP(), []int{1} -} - -func (m *Value) GetKind() isValue_Kind { - if m != nil { - return m.Kind - } - return nil -} - -func (x *Value) GetNullValue() NullValue { - if x, ok := x.GetKind().(*Value_NullValue); ok { - return x.NullValue - } - return NullValue_NULL_VALUE -} - -func (x *Value) GetNumberValue() float64 { - if x, ok := x.GetKind().(*Value_NumberValue); ok { - return x.NumberValue - } - return 0 -} - -func (x *Value) GetStringValue() string { - if x, ok := x.GetKind().(*Value_StringValue); ok { - return x.StringValue - } - return "" -} - -func (x *Value) GetBoolValue() bool { - if x, ok := x.GetKind().(*Value_BoolValue); ok { - return x.BoolValue - } - return false -} - -func (x *Value) GetStructValue() *Struct { - if x, ok := x.GetKind().(*Value_StructValue); ok { - return x.StructValue - } - return nil -} - -func (x *Value) GetListValue() *ListValue { - if x, ok := x.GetKind().(*Value_ListValue); ok { - return x.ListValue - } - return nil -} - -type isValue_Kind interface { - isValue_Kind() -} - -type Value_NullValue struct { - // Represents a null value. - NullValue NullValue `protobuf:"varint,1,opt,name=null_value,json=nullValue,proto3,enum=google.protobuf.NullValue,oneof"` -} - -type Value_NumberValue struct { - // Represents a double value. - NumberValue float64 `protobuf:"fixed64,2,opt,name=number_value,json=numberValue,proto3,oneof"` -} - -type Value_StringValue struct { - // Represents a string value. - StringValue string `protobuf:"bytes,3,opt,name=string_value,json=stringValue,proto3,oneof"` -} - -type Value_BoolValue struct { - // Represents a boolean value. - BoolValue bool `protobuf:"varint,4,opt,name=bool_value,json=boolValue,proto3,oneof"` -} - -type Value_StructValue struct { - // Represents a structured value. - StructValue *Struct `protobuf:"bytes,5,opt,name=struct_value,json=structValue,proto3,oneof"` -} - -type Value_ListValue struct { - // Represents a repeated `Value`. - ListValue *ListValue `protobuf:"bytes,6,opt,name=list_value,json=listValue,proto3,oneof"` -} - -func (*Value_NullValue) isValue_Kind() {} - -func (*Value_NumberValue) isValue_Kind() {} - -func (*Value_StringValue) isValue_Kind() {} - -func (*Value_BoolValue) isValue_Kind() {} - -func (*Value_StructValue) isValue_Kind() {} - -func (*Value_ListValue) isValue_Kind() {} - -// `ListValue` is a wrapper around a repeated field of values. -// -// The JSON representation for `ListValue` is JSON array. -type ListValue struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Repeated field of dynamically typed values. - Values []*Value `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"` -} - -// NewList constructs a ListValue from a general-purpose Go slice. -// The slice elements are converted using NewValue. -func NewList(v []interface{}) (*ListValue, error) { - x := &ListValue{Values: make([]*Value, len(v))} - for i, v := range v { - var err error - x.Values[i], err = NewValue(v) - if err != nil { - return nil, err - } - } - return x, nil -} - -// AsSlice converts x to a general-purpose Go slice. -// The slice elements are converted by calling Value.AsInterface. -func (x *ListValue) AsSlice() []interface{} { - vals := x.GetValues() - vs := make([]interface{}, len(vals)) - for i, v := range vals { - vs[i] = v.AsInterface() - } - return vs -} - -func (x *ListValue) MarshalJSON() ([]byte, error) { - return protojson.Marshal(x) -} - -func (x *ListValue) UnmarshalJSON(b []byte) error { - return protojson.Unmarshal(b, x) -} - -func (x *ListValue) Reset() { - *x = ListValue{} - if protoimpl.UnsafeEnabled { - mi := &file_google_protobuf_struct_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListValue) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListValue) ProtoMessage() {} - -func (x *ListValue) ProtoReflect() protoreflect.Message { - mi := &file_google_protobuf_struct_proto_msgTypes[2] - 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 ListValue.ProtoReflect.Descriptor instead. -func (*ListValue) Descriptor() ([]byte, []int) { - return file_google_protobuf_struct_proto_rawDescGZIP(), []int{2} -} - -func (x *ListValue) GetValues() []*Value { - if x != nil { - return x.Values - } - return nil -} - -var File_google_protobuf_struct_proto protoreflect.FileDescriptor - -var file_google_protobuf_struct_proto_rawDesc = []byte{ - 0x0a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x22, - 0x98, 0x01, 0x0a, 0x06, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x12, 0x3b, 0x0a, 0x06, 0x66, 0x69, - 0x65, 0x6c, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, - 0x75, 0x63, 0x74, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, - 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x1a, 0x51, 0x0a, 0x0b, 0x46, 0x69, 0x65, 0x6c, 0x64, - 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xb2, 0x02, 0x0a, 0x05, 0x56, - 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3b, 0x0a, 0x0a, 0x6e, 0x75, 0x6c, 0x6c, 0x5f, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4e, 0x75, 0x6c, 0x6c, 0x56, - 0x61, 0x6c, 0x75, 0x65, 0x48, 0x00, 0x52, 0x09, 0x6e, 0x75, 0x6c, 0x6c, 0x56, 0x61, 0x6c, 0x75, - 0x65, 0x12, 0x23, 0x0a, 0x0c, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x48, 0x00, 0x52, 0x0b, 0x6e, 0x75, 0x6d, 0x62, 0x65, - 0x72, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x23, 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, - 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0b, - 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1f, 0x0a, 0x0a, 0x62, - 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x48, - 0x00, 0x52, 0x09, 0x62, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3c, 0x0a, 0x0c, - 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x48, 0x00, 0x52, 0x0b, 0x73, - 0x74, 0x72, 0x75, 0x63, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3b, 0x0a, 0x0a, 0x6c, 0x69, - 0x73, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x48, 0x00, 0x52, 0x09, 0x6c, 0x69, - 0x73, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x06, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x22, - 0x3b, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x2e, 0x0a, 0x06, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, - 0x61, 0x6c, 0x75, 0x65, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x2a, 0x1b, 0x0a, 0x09, - 0x4e, 0x75, 0x6c, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x0e, 0x0a, 0x0a, 0x4e, 0x55, 0x4c, - 0x4c, 0x5f, 0x56, 0x41, 0x4c, 0x55, 0x45, 0x10, 0x00, 0x42, 0x7f, 0x0a, 0x13, 0x63, 0x6f, 0x6d, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x42, 0x0b, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, - 0x2f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, - 0x72, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x79, 0x70, 0x65, - 0x73, 0x2f, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x70, 0x62, - 0xf8, 0x01, 0x01, 0xa2, 0x02, 0x03, 0x47, 0x50, 0x42, 0xaa, 0x02, 0x1e, 0x47, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x65, 0x6c, 0x6c, - 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, -} - -var ( - file_google_protobuf_struct_proto_rawDescOnce sync.Once - file_google_protobuf_struct_proto_rawDescData = file_google_protobuf_struct_proto_rawDesc -) - -func file_google_protobuf_struct_proto_rawDescGZIP() []byte { - file_google_protobuf_struct_proto_rawDescOnce.Do(func() { - file_google_protobuf_struct_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_protobuf_struct_proto_rawDescData) - }) - return file_google_protobuf_struct_proto_rawDescData -} - -var file_google_protobuf_struct_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_google_protobuf_struct_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_google_protobuf_struct_proto_goTypes = []interface{}{ - (NullValue)(0), // 0: google.protobuf.NullValue - (*Struct)(nil), // 1: google.protobuf.Struct - (*Value)(nil), // 2: google.protobuf.Value - (*ListValue)(nil), // 3: google.protobuf.ListValue - nil, // 4: google.protobuf.Struct.FieldsEntry -} -var file_google_protobuf_struct_proto_depIdxs = []int32{ - 4, // 0: google.protobuf.Struct.fields:type_name -> google.protobuf.Struct.FieldsEntry - 0, // 1: google.protobuf.Value.null_value:type_name -> google.protobuf.NullValue - 1, // 2: google.protobuf.Value.struct_value:type_name -> google.protobuf.Struct - 3, // 3: google.protobuf.Value.list_value:type_name -> google.protobuf.ListValue - 2, // 4: google.protobuf.ListValue.values:type_name -> google.protobuf.Value - 2, // 5: google.protobuf.Struct.FieldsEntry.value:type_name -> google.protobuf.Value - 6, // [6:6] is the sub-list for method output_type - 6, // [6:6] is the sub-list for method input_type - 6, // [6:6] is the sub-list for extension type_name - 6, // [6:6] is the sub-list for extension extendee - 0, // [0:6] is the sub-list for field type_name -} - -func init() { file_google_protobuf_struct_proto_init() } -func file_google_protobuf_struct_proto_init() { - if File_google_protobuf_struct_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_google_protobuf_struct_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Struct); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_protobuf_struct_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Value); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_protobuf_struct_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListValue); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_google_protobuf_struct_proto_msgTypes[1].OneofWrappers = []interface{}{ - (*Value_NullValue)(nil), - (*Value_NumberValue)(nil), - (*Value_StringValue)(nil), - (*Value_BoolValue)(nil), - (*Value_StructValue)(nil), - (*Value_ListValue)(nil), - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_google_protobuf_struct_proto_rawDesc, - NumEnums: 1, - NumMessages: 4, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_google_protobuf_struct_proto_goTypes, - DependencyIndexes: file_google_protobuf_struct_proto_depIdxs, - EnumInfos: file_google_protobuf_struct_proto_enumTypes, - MessageInfos: file_google_protobuf_struct_proto_msgTypes, - }.Build() - File_google_protobuf_struct_proto = out.File - file_google_protobuf_struct_proto_rawDesc = nil - file_google_protobuf_struct_proto_goTypes = nil - file_google_protobuf_struct_proto_depIdxs = nil -} diff --git a/vendor/google.golang.org/protobuf/types/known/wrapperspb/wrappers.pb.go b/vendor/google.golang.org/protobuf/types/known/wrapperspb/wrappers.pb.go deleted file mode 100644 index 762a87130..000000000 --- a/vendor/google.golang.org/protobuf/types/known/wrapperspb/wrappers.pb.go +++ /dev/null @@ -1,760 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Wrappers for primitive (non-message) types. These types are useful -// for embedding primitives in the `google.protobuf.Any` type and for places -// where we need to distinguish between the absence of a primitive -// typed field and its default value. -// -// These wrappers have no meaningful use within repeated fields as they lack -// the ability to detect presence on individual elements. -// These wrappers have no meaningful use within a map or a oneof since -// individual entries of a map or fields of a oneof can already detect presence. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: google/protobuf/wrappers.proto - -package wrapperspb - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -// Wrapper message for `double`. -// -// The JSON representation for `DoubleValue` is JSON number. -type DoubleValue struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The double value. - Value float64 `protobuf:"fixed64,1,opt,name=value,proto3" json:"value,omitempty"` -} - -// Double stores v in a new DoubleValue and returns a pointer to it. -func Double(v float64) *DoubleValue { - return &DoubleValue{Value: v} -} - -func (x *DoubleValue) Reset() { - *x = DoubleValue{} - if protoimpl.UnsafeEnabled { - mi := &file_google_protobuf_wrappers_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoubleValue) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoubleValue) ProtoMessage() {} - -func (x *DoubleValue) ProtoReflect() protoreflect.Message { - mi := &file_google_protobuf_wrappers_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 DoubleValue.ProtoReflect.Descriptor instead. -func (*DoubleValue) Descriptor() ([]byte, []int) { - return file_google_protobuf_wrappers_proto_rawDescGZIP(), []int{0} -} - -func (x *DoubleValue) GetValue() float64 { - if x != nil { - return x.Value - } - return 0 -} - -// Wrapper message for `float`. -// -// The JSON representation for `FloatValue` is JSON number. -type FloatValue struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The float value. - Value float32 `protobuf:"fixed32,1,opt,name=value,proto3" json:"value,omitempty"` -} - -// Float stores v in a new FloatValue and returns a pointer to it. -func Float(v float32) *FloatValue { - return &FloatValue{Value: v} -} - -func (x *FloatValue) Reset() { - *x = FloatValue{} - if protoimpl.UnsafeEnabled { - mi := &file_google_protobuf_wrappers_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *FloatValue) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*FloatValue) ProtoMessage() {} - -func (x *FloatValue) ProtoReflect() protoreflect.Message { - mi := &file_google_protobuf_wrappers_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 FloatValue.ProtoReflect.Descriptor instead. -func (*FloatValue) Descriptor() ([]byte, []int) { - return file_google_protobuf_wrappers_proto_rawDescGZIP(), []int{1} -} - -func (x *FloatValue) GetValue() float32 { - if x != nil { - return x.Value - } - return 0 -} - -// Wrapper message for `int64`. -// -// The JSON representation for `Int64Value` is JSON string. -type Int64Value struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The int64 value. - Value int64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` -} - -// Int64 stores v in a new Int64Value and returns a pointer to it. -func Int64(v int64) *Int64Value { - return &Int64Value{Value: v} -} - -func (x *Int64Value) Reset() { - *x = Int64Value{} - if protoimpl.UnsafeEnabled { - mi := &file_google_protobuf_wrappers_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Int64Value) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Int64Value) ProtoMessage() {} - -func (x *Int64Value) ProtoReflect() protoreflect.Message { - mi := &file_google_protobuf_wrappers_proto_msgTypes[2] - 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 Int64Value.ProtoReflect.Descriptor instead. -func (*Int64Value) Descriptor() ([]byte, []int) { - return file_google_protobuf_wrappers_proto_rawDescGZIP(), []int{2} -} - -func (x *Int64Value) GetValue() int64 { - if x != nil { - return x.Value - } - return 0 -} - -// Wrapper message for `uint64`. -// -// The JSON representation for `UInt64Value` is JSON string. -type UInt64Value struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The uint64 value. - Value uint64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` -} - -// UInt64 stores v in a new UInt64Value and returns a pointer to it. -func UInt64(v uint64) *UInt64Value { - return &UInt64Value{Value: v} -} - -func (x *UInt64Value) Reset() { - *x = UInt64Value{} - if protoimpl.UnsafeEnabled { - mi := &file_google_protobuf_wrappers_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *UInt64Value) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UInt64Value) ProtoMessage() {} - -func (x *UInt64Value) ProtoReflect() protoreflect.Message { - mi := &file_google_protobuf_wrappers_proto_msgTypes[3] - 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 UInt64Value.ProtoReflect.Descriptor instead. -func (*UInt64Value) Descriptor() ([]byte, []int) { - return file_google_protobuf_wrappers_proto_rawDescGZIP(), []int{3} -} - -func (x *UInt64Value) GetValue() uint64 { - if x != nil { - return x.Value - } - return 0 -} - -// Wrapper message for `int32`. -// -// The JSON representation for `Int32Value` is JSON number. -type Int32Value struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The int32 value. - Value int32 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` -} - -// Int32 stores v in a new Int32Value and returns a pointer to it. -func Int32(v int32) *Int32Value { - return &Int32Value{Value: v} -} - -func (x *Int32Value) Reset() { - *x = Int32Value{} - if protoimpl.UnsafeEnabled { - mi := &file_google_protobuf_wrappers_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Int32Value) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Int32Value) ProtoMessage() {} - -func (x *Int32Value) ProtoReflect() protoreflect.Message { - mi := &file_google_protobuf_wrappers_proto_msgTypes[4] - 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 Int32Value.ProtoReflect.Descriptor instead. -func (*Int32Value) Descriptor() ([]byte, []int) { - return file_google_protobuf_wrappers_proto_rawDescGZIP(), []int{4} -} - -func (x *Int32Value) GetValue() int32 { - if x != nil { - return x.Value - } - return 0 -} - -// Wrapper message for `uint32`. -// -// The JSON representation for `UInt32Value` is JSON number. -type UInt32Value struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The uint32 value. - Value uint32 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` -} - -// UInt32 stores v in a new UInt32Value and returns a pointer to it. -func UInt32(v uint32) *UInt32Value { - return &UInt32Value{Value: v} -} - -func (x *UInt32Value) Reset() { - *x = UInt32Value{} - if protoimpl.UnsafeEnabled { - mi := &file_google_protobuf_wrappers_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *UInt32Value) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UInt32Value) ProtoMessage() {} - -func (x *UInt32Value) ProtoReflect() protoreflect.Message { - mi := &file_google_protobuf_wrappers_proto_msgTypes[5] - 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 UInt32Value.ProtoReflect.Descriptor instead. -func (*UInt32Value) Descriptor() ([]byte, []int) { - return file_google_protobuf_wrappers_proto_rawDescGZIP(), []int{5} -} - -func (x *UInt32Value) GetValue() uint32 { - if x != nil { - return x.Value - } - return 0 -} - -// Wrapper message for `bool`. -// -// The JSON representation for `BoolValue` is JSON `true` and `false`. -type BoolValue struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The bool value. - Value bool `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` -} - -// Bool stores v in a new BoolValue and returns a pointer to it. -func Bool(v bool) *BoolValue { - return &BoolValue{Value: v} -} - -func (x *BoolValue) Reset() { - *x = BoolValue{} - if protoimpl.UnsafeEnabled { - mi := &file_google_protobuf_wrappers_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *BoolValue) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*BoolValue) ProtoMessage() {} - -func (x *BoolValue) ProtoReflect() protoreflect.Message { - mi := &file_google_protobuf_wrappers_proto_msgTypes[6] - 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 BoolValue.ProtoReflect.Descriptor instead. -func (*BoolValue) Descriptor() ([]byte, []int) { - return file_google_protobuf_wrappers_proto_rawDescGZIP(), []int{6} -} - -func (x *BoolValue) GetValue() bool { - if x != nil { - return x.Value - } - return false -} - -// Wrapper message for `string`. -// -// The JSON representation for `StringValue` is JSON string. -type StringValue struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The string value. - Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` -} - -// String stores v in a new StringValue and returns a pointer to it. -func String(v string) *StringValue { - return &StringValue{Value: v} -} - -func (x *StringValue) Reset() { - *x = StringValue{} - if protoimpl.UnsafeEnabled { - mi := &file_google_protobuf_wrappers_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *StringValue) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*StringValue) ProtoMessage() {} - -func (x *StringValue) ProtoReflect() protoreflect.Message { - mi := &file_google_protobuf_wrappers_proto_msgTypes[7] - 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 StringValue.ProtoReflect.Descriptor instead. -func (*StringValue) Descriptor() ([]byte, []int) { - return file_google_protobuf_wrappers_proto_rawDescGZIP(), []int{7} -} - -func (x *StringValue) GetValue() string { - if x != nil { - return x.Value - } - return "" -} - -// Wrapper message for `bytes`. -// -// The JSON representation for `BytesValue` is JSON string. -type BytesValue struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The bytes value. - Value []byte `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` -} - -// Bytes stores v in a new BytesValue and returns a pointer to it. -func Bytes(v []byte) *BytesValue { - return &BytesValue{Value: v} -} - -func (x *BytesValue) Reset() { - *x = BytesValue{} - if protoimpl.UnsafeEnabled { - mi := &file_google_protobuf_wrappers_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *BytesValue) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*BytesValue) ProtoMessage() {} - -func (x *BytesValue) ProtoReflect() protoreflect.Message { - mi := &file_google_protobuf_wrappers_proto_msgTypes[8] - 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 BytesValue.ProtoReflect.Descriptor instead. -func (*BytesValue) Descriptor() ([]byte, []int) { - return file_google_protobuf_wrappers_proto_rawDescGZIP(), []int{8} -} - -func (x *BytesValue) GetValue() []byte { - if x != nil { - return x.Value - } - return nil -} - -var File_google_protobuf_wrappers_proto protoreflect.FileDescriptor - -var file_google_protobuf_wrappers_proto_rawDesc = []byte{ - 0x0a, 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, - 0x12, 0x0f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x22, 0x23, 0x0a, 0x0b, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, - 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x22, 0x0a, 0x0a, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x56, - 0x61, 0x6c, 0x75, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x02, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x22, 0x0a, 0x0a, 0x49, 0x6e, - 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x23, - 0x0a, 0x0b, 0x55, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x14, 0x0a, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x22, 0x22, 0x0a, 0x0a, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, - 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x23, 0x0a, 0x0b, 0x55, 0x49, 0x6e, 0x74, 0x33, - 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x21, 0x0a, 0x09, - 0x42, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, - 0x23, 0x0a, 0x0b, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x14, - 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x22, 0x22, 0x0a, 0x0a, 0x42, 0x79, 0x74, 0x65, 0x73, 0x56, 0x61, 0x6c, - 0x75, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x83, 0x01, 0x0a, 0x13, 0x63, 0x6f, 0x6d, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x42, 0x0d, 0x57, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x31, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, - 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x79, - 0x70, 0x65, 0x73, 0x2f, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, - 0x72, 0x73, 0x70, 0x62, 0xf8, 0x01, 0x01, 0xa2, 0x02, 0x03, 0x47, 0x50, 0x42, 0xaa, 0x02, 0x1e, - 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x57, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_google_protobuf_wrappers_proto_rawDescOnce sync.Once - file_google_protobuf_wrappers_proto_rawDescData = file_google_protobuf_wrappers_proto_rawDesc -) - -func file_google_protobuf_wrappers_proto_rawDescGZIP() []byte { - file_google_protobuf_wrappers_proto_rawDescOnce.Do(func() { - file_google_protobuf_wrappers_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_protobuf_wrappers_proto_rawDescData) - }) - return file_google_protobuf_wrappers_proto_rawDescData -} - -var file_google_protobuf_wrappers_proto_msgTypes = make([]protoimpl.MessageInfo, 9) -var file_google_protobuf_wrappers_proto_goTypes = []interface{}{ - (*DoubleValue)(nil), // 0: google.protobuf.DoubleValue - (*FloatValue)(nil), // 1: google.protobuf.FloatValue - (*Int64Value)(nil), // 2: google.protobuf.Int64Value - (*UInt64Value)(nil), // 3: google.protobuf.UInt64Value - (*Int32Value)(nil), // 4: google.protobuf.Int32Value - (*UInt32Value)(nil), // 5: google.protobuf.UInt32Value - (*BoolValue)(nil), // 6: google.protobuf.BoolValue - (*StringValue)(nil), // 7: google.protobuf.StringValue - (*BytesValue)(nil), // 8: google.protobuf.BytesValue -} -var file_google_protobuf_wrappers_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_google_protobuf_wrappers_proto_init() } -func file_google_protobuf_wrappers_proto_init() { - if File_google_protobuf_wrappers_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_google_protobuf_wrappers_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoubleValue); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_protobuf_wrappers_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*FloatValue); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_protobuf_wrappers_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Int64Value); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_protobuf_wrappers_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UInt64Value); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_protobuf_wrappers_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Int32Value); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_protobuf_wrappers_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UInt32Value); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_protobuf_wrappers_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*BoolValue); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_protobuf_wrappers_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*StringValue); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_google_protobuf_wrappers_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*BytesValue); 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_google_protobuf_wrappers_proto_rawDesc, - NumEnums: 0, - NumMessages: 9, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_google_protobuf_wrappers_proto_goTypes, - DependencyIndexes: file_google_protobuf_wrappers_proto_depIdxs, - MessageInfos: file_google_protobuf_wrappers_proto_msgTypes, - }.Build() - File_google_protobuf_wrappers_proto = out.File - file_google_protobuf_wrappers_proto_rawDesc = nil - file_google_protobuf_wrappers_proto_goTypes = nil - file_google_protobuf_wrappers_proto_depIdxs = nil -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 639b4ecb7..1cb2d52ec 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -29,9 +29,6 @@ github.com/PaesslerAG/jsonpath # github.com/ajeddeloh/go-json v0.0.0-20200220154158-5ae607161559 ## explicit github.com/ajeddeloh/go-json -# github.com/antlr4-go/antlr/v4 v4.13.0 -## explicit; go 1.20 -github.com/antlr4-go/antlr/v4 # github.com/argoproj-labs/argocd-operator v0.10.0 ## explicit; go 1.21 github.com/argoproj-labs/argocd-operator/api/v1alpha1 @@ -286,29 +283,6 @@ github.com/golang/protobuf/proto # github.com/google/btree v1.1.2 ## explicit; go 1.18 github.com/google/btree -# github.com/google/cel-go v0.18.2 -## explicit; go 1.18 -github.com/google/cel-go/cel -github.com/google/cel-go/checker -github.com/google/cel-go/checker/decls -github.com/google/cel-go/common -github.com/google/cel-go/common/ast -github.com/google/cel-go/common/containers -github.com/google/cel-go/common/debug -github.com/google/cel-go/common/decls -github.com/google/cel-go/common/functions -github.com/google/cel-go/common/operators -github.com/google/cel-go/common/overloads -github.com/google/cel-go/common/runes -github.com/google/cel-go/common/stdlib -github.com/google/cel-go/common/types -github.com/google/cel-go/common/types/pb -github.com/google/cel-go/common/types/ref -github.com/google/cel-go/common/types/traits -github.com/google/cel-go/interpreter -github.com/google/cel-go/interpreter/functions -github.com/google/cel-go/parser -github.com/google/cel-go/parser/gen # github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 ## explicit; go 1.18 github.com/google/gnostic-models/compiler @@ -348,15 +322,6 @@ github.com/grafana/loki/operator/apis/loki/v1 # github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 ## explicit github.com/gregjones/httpcache -# github.com/h2non/filetype v1.1.3 -## explicit; go 1.13 -github.com/h2non/filetype -github.com/h2non/filetype/matchers -github.com/h2non/filetype/matchers/isobmff -github.com/h2non/filetype/types -# github.com/h2non/go-is-svg v0.0.0-20160927212452-35e8c4b0612c -## explicit -github.com/h2non/go-is-svg # github.com/hashicorp/errwrap v1.1.0 ## explicit github.com/hashicorp/errwrap @@ -579,7 +544,6 @@ github.com/onsi/ginkgo/v2/types ## explicit; go 1.20 github.com/onsi/gomega github.com/onsi/gomega/format -github.com/onsi/gomega/gstruct/errors github.com/onsi/gomega/internal github.com/onsi/gomega/internal/gutil github.com/onsi/gomega/matchers @@ -598,7 +562,7 @@ github.com/openshift-kni/cluster-group-upgrades-operator/pkg/generated/clientset github.com/openshift-kni/cluster-group-upgrades-operator/pkg/generated/clientset/versioned/scheme github.com/openshift-kni/cluster-group-upgrades-operator/pkg/generated/clientset/versioned/typed/clustergroupupgrades/v1alpha1 github.com/openshift-kni/cluster-group-upgrades-operator/pkg/generated/clientset/versioned/typed/clustergroupupgrades/v1alpha1/fake -# github.com/openshift-kni/eco-goinfra v0.0.0-20240809133315-01bbbf4c9ede +# github.com/openshift-kni/eco-goinfra v0.0.0-20240809150049-0634a7a9fb27 ## explicit; go 1.22 github.com/openshift-kni/eco-goinfra/pkg/apiservers github.com/openshift-kni/eco-goinfra/pkg/argocd @@ -694,6 +658,8 @@ github.com/openshift-kni/eco-goinfra/pkg/schemes/oadp/velero/pkg/restore github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1 github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1 +github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators +github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1 github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/version github.com/openshift-kni/eco-goinfra/pkg/secret github.com/openshift-kni/eco-goinfra/pkg/service @@ -929,31 +895,9 @@ github.com/openshift/ptp-operator/pkg/client/clientset/versioned/scheme github.com/openshift/ptp-operator/pkg/client/clientset/versioned/typed/ptp/v1 # github.com/operator-framework/api v0.23.0 ## explicit; go 1.21 -github.com/operator-framework/api/pkg/constraints github.com/operator-framework/api/pkg/lib/version github.com/operator-framework/api/pkg/operators -github.com/operator-framework/api/pkg/operators/v1 github.com/operator-framework/api/pkg/operators/v1alpha1 -github.com/operator-framework/api/pkg/operators/v1alpha2 -github.com/operator-framework/api/pkg/operators/v2 -# github.com/operator-framework/operator-lifecycle-manager v0.28.0 -## explicit; go 1.22 -github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/scheme -github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1 -github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1 -github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators -github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators/v1 -github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/scheme -github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned/typed/operators/v1 -# github.com/operator-framework/operator-registry v1.41.0 -## explicit; go 1.22 -github.com/operator-framework/operator-registry/alpha/model -github.com/operator-framework/operator-registry/alpha/property -github.com/operator-framework/operator-registry/pkg/api -github.com/operator-framework/operator-registry/pkg/image -github.com/operator-framework/operator-registry/pkg/lib/semver -github.com/operator-framework/operator-registry/pkg/prettyunmarshaler -github.com/operator-framework/operator-registry/pkg/registry # github.com/otiai10/copy v1.14.0 ## explicit; go 1.18 github.com/otiai10/copy @@ -1040,9 +984,6 @@ github.com/stmcginnis/gofish github.com/stmcginnis/gofish/common github.com/stmcginnis/gofish/redfish github.com/stmcginnis/gofish/swordfish -# github.com/stoewer/go-strcase v1.3.0 -## explicit; go 1.11 -github.com/stoewer/go-strcase # github.com/stolostron/cluster-lifecycle-api v0.0.0-20240109072430-f5fe6043d1f8 ## explicit; go 1.19 github.com/stolostron/cluster-lifecycle-api/helpers/imageregistry @@ -1148,9 +1089,7 @@ golang.org/x/net/http2 golang.org/x/net/http2/hpack golang.org/x/net/idna golang.org/x/net/internal/socks -golang.org/x/net/internal/timeseries golang.org/x/net/proxy -golang.org/x/net/trace # golang.org/x/oauth2 v0.20.0 ## explicit; go 1.18 golang.org/x/oauth2 @@ -1190,7 +1129,6 @@ golang.org/x/text/secure/bidirule golang.org/x/text/transform golang.org/x/text/unicode/bidi golang.org/x/text/unicode/norm -golang.org/x/text/width # golang.org/x/time v0.5.0 ## explicit; go 1.18 golang.org/x/time/rate @@ -1201,69 +1139,9 @@ golang.org/x/tools/go/ast/inspector # gomodules.xyz/jsonpatch/v2 v2.4.0 ## explicit; go 1.20 gomodules.xyz/jsonpatch/v2 -# google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda -## explicit; go 1.19 -google.golang.org/genproto/googleapis/api/expr/v1alpha1 -# google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be -## explicit; go 1.19 -google.golang.org/genproto/googleapis/rpc/status -# google.golang.org/grpc v1.63.2 -## explicit; go 1.19 -google.golang.org/grpc -google.golang.org/grpc/attributes -google.golang.org/grpc/backoff -google.golang.org/grpc/balancer -google.golang.org/grpc/balancer/base -google.golang.org/grpc/balancer/grpclb/state -google.golang.org/grpc/balancer/roundrobin -google.golang.org/grpc/binarylog/grpc_binarylog_v1 -google.golang.org/grpc/channelz -google.golang.org/grpc/codes -google.golang.org/grpc/connectivity -google.golang.org/grpc/credentials -google.golang.org/grpc/credentials/insecure -google.golang.org/grpc/encoding -google.golang.org/grpc/encoding/proto -google.golang.org/grpc/grpclog -google.golang.org/grpc/internal -google.golang.org/grpc/internal/backoff -google.golang.org/grpc/internal/balancer/gracefulswitch -google.golang.org/grpc/internal/balancerload -google.golang.org/grpc/internal/binarylog -google.golang.org/grpc/internal/buffer -google.golang.org/grpc/internal/channelz -google.golang.org/grpc/internal/credentials -google.golang.org/grpc/internal/envconfig -google.golang.org/grpc/internal/grpclog -google.golang.org/grpc/internal/grpcrand -google.golang.org/grpc/internal/grpcsync -google.golang.org/grpc/internal/grpcutil -google.golang.org/grpc/internal/idle -google.golang.org/grpc/internal/metadata -google.golang.org/grpc/internal/pretty -google.golang.org/grpc/internal/resolver -google.golang.org/grpc/internal/resolver/dns -google.golang.org/grpc/internal/resolver/dns/internal -google.golang.org/grpc/internal/resolver/passthrough -google.golang.org/grpc/internal/resolver/unix -google.golang.org/grpc/internal/serviceconfig -google.golang.org/grpc/internal/status -google.golang.org/grpc/internal/syscall -google.golang.org/grpc/internal/transport -google.golang.org/grpc/internal/transport/networktype -google.golang.org/grpc/keepalive -google.golang.org/grpc/metadata -google.golang.org/grpc/peer -google.golang.org/grpc/resolver -google.golang.org/grpc/resolver/dns -google.golang.org/grpc/serviceconfig -google.golang.org/grpc/stats -google.golang.org/grpc/status -google.golang.org/grpc/tap # google.golang.org/protobuf v1.34.1 ## explicit; go 1.17 google.golang.org/protobuf/encoding/protodelim -google.golang.org/protobuf/encoding/protojson google.golang.org/protobuf/encoding/prototext google.golang.org/protobuf/encoding/protowire google.golang.org/protobuf/internal/descfmt @@ -1272,7 +1150,6 @@ google.golang.org/protobuf/internal/detrand google.golang.org/protobuf/internal/editiondefaults google.golang.org/protobuf/internal/editionssupport google.golang.org/protobuf/internal/encoding/defval -google.golang.org/protobuf/internal/encoding/json google.golang.org/protobuf/internal/encoding/messageset google.golang.org/protobuf/internal/encoding/tag google.golang.org/protobuf/internal/encoding/text @@ -1288,21 +1165,15 @@ google.golang.org/protobuf/internal/set google.golang.org/protobuf/internal/strs google.golang.org/protobuf/internal/version google.golang.org/protobuf/proto -google.golang.org/protobuf/protoadapt google.golang.org/protobuf/reflect/protodesc google.golang.org/protobuf/reflect/protoreflect google.golang.org/protobuf/reflect/protoregistry google.golang.org/protobuf/runtime/protoiface google.golang.org/protobuf/runtime/protoimpl google.golang.org/protobuf/types/descriptorpb -google.golang.org/protobuf/types/dynamicpb google.golang.org/protobuf/types/gofeaturespb google.golang.org/protobuf/types/known/anypb -google.golang.org/protobuf/types/known/durationpb -google.golang.org/protobuf/types/known/emptypb -google.golang.org/protobuf/types/known/structpb google.golang.org/protobuf/types/known/timestamppb -google.golang.org/protobuf/types/known/wrapperspb # gopkg.in/evanphx/json-patch.v4 v4.12.0 ## explicit gopkg.in/evanphx/json-patch.v4