diff --git a/.github/ISSUE_TEMPLATE/release.md b/.github/ISSUE_TEMPLATE/release.md index b5962e40855..369713cf07e 100644 --- a/.github/ISSUE_TEMPLATE/release.md +++ b/.github/ISSUE_TEMPLATE/release.md @@ -14,8 +14,8 @@ labels: ["release"] ### At the beginning of the cycle - [ ] Obtain the Release coordinator's contact from the `@k6-browser` team and co-assign the issue to them. -- [ ] Create a new `release-v0.5x.0` long-lived branch and add a new release notes file using the available [template](/grafana/k6/tree/master/release%20notes/template.md) to the [repository's `release notes` folder](/grafana/k6/tree/master/release%20notes). -- [ ] Go through the potential [dependencies updates](Dependencies.md) and create a dedicated PR if any of them is relevant to this release. +- [ ] Create a new `release-v0.5x.0` long-lived branch and add a new release notes file using the available [template](https://github.com/grafana/k6/blob/master/release%20notes/template.md) to the [repository's `release notes` folder](https://github.com/grafana/k6/blob/master/release%20notes). +- [ ] Go through the potential [dependencies updates](https://github.com/grafana/k6/blob/master/Dependencies.md) and create a dedicated PR if any of them is relevant to this release. - [ ] Create a new `release-v0.5x.0` long-lived branch on the [grafana/k6-DefinitelyTyped](https://github.com/grafana/k6-DefinitelyTyped) fork repository. - [ ] Bump the version in [types/k6/package.json](https://github.com/grafana/k6-DefinitelyTyped/blob/master/types/k6/package.json#L4) to the next one. @@ -35,7 +35,7 @@ labels: ["release"] - [ ] Ask teams who might have contributed to the release (k6-browser, k6-ecosystem, k6-docs, k6-devrel teams, etc.) to contribute their notes and review the existing ones. - [ ] Remember to mention and thank [external contributors](https://github.com/search?q=user%3Agrafana+repo%3Ak6+milestone%3A%22v0.51.0%22+-author%3Amstoykov+-author%3Aoleiade+-author%3Ana--+-author%3Acodebien+-author%3Aolegbespalov+-author%3Aandrewslotin+-author%3Ajoanlopez+-author%3Aankur22+-author%3Ainancgumus+-author%3Aszkiba+-author%3Adependabot%5Bbot%5D&type=pullrequests). <-- Update the query with the correct milestone version. - [ ] Share the release notes PR with the k6 open-source teams. Request contributions from all affected teams (k6-browser, k6-chaos, k6-docs, k6-devrel, etc.) and any other stakeholders involved in the new release. -- [ ] Open a separate pull-request for bumping [the k6 Go project's version](https://github.com/grafana/k6/blob/master/lib/consts/consts.go#L11). +- [ ] Open a separate pull-request for bumping [the k6 Go project's version](https://github.com/grafana/k6/blob/master/lib/consts/consts.go#L11-L12). - [ ] Open a PR in the `DefinitelyTyped/DefinitelyTyped` repository, using the release branch created in the grafana/k6-DefinitelyTyped fork, to update the k6 type definitions for the new release. #### ~ 1 day before the release date @@ -51,7 +51,7 @@ labels: ["release"] #### In k6 repository -- [ ] Merge the PR bumping [the k6 Go project's version](https://github.com/grafana/k6/blob/9fa50b2d1f259cdccff5cc7bc18a236d31c345ac/lib/consts/consts.go#L11). +- [ ] Merge the PR bumping [the k6 Go project's version](https://github.com/grafana/k6/blob/master/lib/consts/consts.go#L11-L12). - [ ] Merge the release notes PR. - [ ] Pull locally the previously merged changes. - [ ] Create and push a new tag of the form `vX.Y.Z` using git: `git tag v0.5x.0 -m "v0.5x.0"`. diff --git a/.github/workflows/tc39.yml b/.github/workflows/tc39.yml index 11d96302dde..296f25f13bd 100644 --- a/.github/workflows/tc39.yml +++ b/.github/workflows/tc39.yml @@ -7,7 +7,7 @@ on: pull_request: paths: - 'js/**' - - 'vendor/github.com/dop251/goja/**' + - 'vendor/github.com/grafana/sobek/**' defaults: run: diff --git a/.github/workflows/xk6-tests/xk6-js-test/go.mod b/.github/workflows/xk6-tests/xk6-js-test/go.mod index 0f16105c03e..82aa64b237a 100644 --- a/.github/workflows/xk6-tests/xk6-js-test/go.mod +++ b/.github/workflows/xk6-tests/xk6-js-test/go.mod @@ -2,26 +2,45 @@ module github.com/grafana/xk6-js-test go 1.19 -require go.k6.io/k6 v0.47.0 +require go.k6.io/k6 v0.52.0 require ( + github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/dlclark/regexp2 v1.9.0 // indirect - github.com/dop251/goja v0.0.0-20230919151941-fc55792775de // indirect - github.com/fatih/color v1.15.0 // indirect - github.com/go-sourcemap/sourcemap v2.1.4-0.20211119122758-180fcef48034+incompatible // indirect - github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect + github.com/dop251/goja v0.0.0-20240610225006-393f6d42497b // indirect + github.com/evanw/esbuild v0.21.2 // indirect + github.com/fatih/color v1.16.0 // indirect + github.com/go-logr/logr v1.4.1 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-sourcemap/sourcemap v2.1.4+incompatible // indirect + github.com/google/pprof v0.0.0-20230728192033-2ba5b33183c6 // indirect + github.com/grafana/sobek v0.0.0-20240613124309-cb36746e8fee // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/mstoykov/atlas v0.0.0-20220811071828-388f114305dd // indirect github.com/onsi/ginkgo v1.16.5 // indirect github.com/onsi/gomega v1.27.1 // indirect github.com/serenize/snaker v0.0.0-20201027110005-a7ad2135616e // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/spf13/afero v1.1.2 // indirect - golang.org/x/sys v0.11.0 // indirect - golang.org/x/text v0.12.0 // indirect - golang.org/x/time v0.3.0 // indirect + go.opentelemetry.io/otel v1.24.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 // indirect + go.opentelemetry.io/otel/metric v1.24.0 // indirect + go.opentelemetry.io/otel/sdk v1.24.0 // indirect + go.opentelemetry.io/otel/trace v1.24.0 // indirect + go.opentelemetry.io/proto/otlp v1.1.0 // indirect + golang.org/x/net v0.26.0 // indirect + golang.org/x/sys v0.21.0 // indirect + golang.org/x/text v0.16.0 // indirect + golang.org/x/time v0.5.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect + google.golang.org/grpc v1.63.2 // indirect + google.golang.org/protobuf v1.33.0 // indirect gopkg.in/guregu/null.v3 v3.3.0 // indirect ) diff --git a/.github/workflows/xk6-tests/xk6-js-test/go.sum b/.github/workflows/xk6-tests/xk6-js-test/go.sum index 68df53ca5dd..1479d68d2de 100644 --- a/.github/workflows/xk6-tests/xk6-js-test/go.sum +++ b/.github/workflows/xk6-tests/xk6-js-test/go.sum @@ -1,28 +1,27 @@ -github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= -github.com/chzyer/logex v1.2.0/go.mod h1:9+9sk7u7pGNWYMkh0hdiL++6OeibzJccyQU4p4MedaY= -github.com/chzyer/readline v1.5.0/go.mod h1:x22KAscuvRqlLoK9CsoYsmxoXZMMFVyOl86cAH8qUic= -github.com/chzyer/test v0.0.0-20210722231415-061457976a23/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= +github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= +github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= -github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dlclark/regexp2 v1.9.0 h1:pTK/l/3qYIKaRXuHnEnIf7Y5NxfRPfpb7dis6/gdlVI= github.com/dlclark/regexp2 v1.9.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= -github.com/dop251/goja v0.0.0-20211022113120-dc8c55024d06/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= -github.com/dop251/goja v0.0.0-20230919151941-fc55792775de h1:lA38Xtzr1Wo+iQdkN2E11ziKXJYRxLlzK/e2/fdxoEI= -github.com/dop251/goja v0.0.0-20230919151941-fc55792775de/go.mod h1:QMWlm50DNe14hD7t24KEqZuUdC9sOTy8W6XbCU1mlw4= -github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y= -github.com/dop251/goja_nodejs v0.0.0-20211022123610-8dd9abb0616d/go.mod h1:DngW8aVqWbuLRMHItjPUyqdj+HWPvnQe8V8y1nDpIbM= -github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= -github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= +github.com/dop251/goja v0.0.0-20240610225006-393f6d42497b h1:fMKDnOAKCGXSZBphY/ilLtu7cmwMnjqE+xJxUkfkpCY= +github.com/dop251/goja v0.0.0-20240610225006-393f6d42497b/go.mod h1:o31y53rb/qiIAONF7w3FHJZRqqP3fzHUr1HqanthByw= +github.com/evanw/esbuild v0.21.2 h1:CLplcGi794CfHLVmUbvVfTMKkykm+nyIHU8SU60KUTA= +github.com/evanw/esbuild v0.21.2/go.mod h1:D2vIQZqV/vIf/VRHtViaUtViZmG7o+kKmlBfVQuRi48= +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/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= -github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= -github.com/go-sourcemap/sourcemap v2.1.4-0.20211119122758-180fcef48034+incompatible h1:bopx7t9jyUNX1ebhr0G4gtQWmUOgwQRI0QsYhdYLgkU= -github.com/go-sourcemap/sourcemap v2.1.4-0.20211119122758-180fcef48034+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/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-sourcemap/sourcemap v2.1.4+incompatible h1:a+iTbH5auLKxaNwQFg0B+TCYl6lbukKPc7b5x0n1s6Q= +github.com/go-sourcemap/sourcemap v2.1.4+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= @@ -31,36 +30,32 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/pprof v0.0.0-20230207041349-798e818bf904 h1:4/hN5RUoecvl+RmJRE2YxKWtnnQls6rQjjW5oV7qg2U= -github.com/google/pprof v0.0.0-20230207041349-798e818bf904/go.mod h1:uglQLonpP8qtYCYyzA+8c/9qtqgA3qsXGYqCPKARAFg= -github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/pprof v0.0.0-20230728192033-2ba5b33183c6 h1:ZgoomqkdjGbQ3+qQXCkvYMCDvGDNg2k5JJDjjdTB6jY= +github.com/google/pprof v0.0.0-20230728192033-2ba5b33183c6/go.mod h1:Jh3hGz2jkYak8qXPD19ryItVnUgpgeqzdkY/D0EaeuA= +github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= +github.com/grafana/sobek v0.0.0-20240613124309-cb36746e8fee h1:KjQPRiLoSZMz+oMdEyh8fE/rurMpx3lpRH8PIR66nzo= +github.com/grafana/sobek v0.0.0-20240613124309-cb36746e8fee/go.mod h1:4uA93vCOP7fFfkAEByuRieuU72pAc5DH05b71yCIVsQ= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 h1:Wqo399gCIufwto+VfwCSvsnfGpF/w5E9CNxSwbpD6No= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0/go.mod h1:qmOFXW2epJhM0qSnUUYpldc7gVz2KMQwJ/QYCDIa7XU= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= -github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= -github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mccutchen/go-httpbin v1.1.2-0.20190116014521-c5cb2f4802fa h1:lx8ZnNPwjkXSzOROz0cg69RlErRXs+L3eDkggASWKLo= github.com/mstoykov/atlas v0.0.0-20220811071828-388f114305dd h1:AC3N94irbx2kWGA8f/2Ks7EQl2LxKIRQYuT9IJDwgiI= github.com/mstoykov/atlas v0.0.0-20220811071828-388f114305dd/go.mod h1:9vRHVuLCjoFfE3GT06X0spdOAO+Zzo4AMjdIwUHBvAk= -github.com/mstoykov/envconfig v1.4.1-0.20220114105314-765c6d8c76f1 h1:94EkGmhXrVUEal+uLwFUf4fMXPhZpM5tYxuIsxrCCbI= +github.com/mstoykov/envconfig v1.5.0 h1:E2FgWf73BQt0ddgn7aoITkQHmgwAcHup1s//MsS5/f8= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= @@ -74,7 +69,6 @@ github.com/onsi/gomega v1.27.1 h1:rfztXRbg6nv/5f+Raen9RcGoSecHIFgBBLQK3Wdj754= github.com/onsi/gomega v1.27.1/go.mod h1:aHX5xOykVYzWOV4WqQy0sy8BQptgukenXpCXfadcIAw= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/serenize/snaker v0.0.0-20201027110005-a7ad2135616e h1:zWKUYT07mGmVBH+9UgnHXd/ekCK99C8EbDSAt5qsjXE= github.com/serenize/snaker v0.0.0-20201027110005-a7ad2135616e/go.mod h1:Yow6lPLSAXx2ifx470yD/nUe22Dv5vBvxK/UK9UUTVs= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= @@ -84,30 +78,42 @@ github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.k6.io/k6 v0.47.0 h1:o5rmxpFbdxzdL0xNqBtaGkHGzEnbnt8ixfBOxEGsHQY= -go.k6.io/k6 v0.47.0/go.mod h1:ulXsmMVRoCZzqV/ZgMeifJ9A484pKadqGT2sfR3eKQg= +go.k6.io/k6 v0.52.0 h1:VrwjSCrM4v61UptCeTPJjYE+Ebyy3xbtqVuAFYGVM2c= +go.k6.io/k6 v0.52.0/go.mod h1:Dr6udC+rZxT0Wu5wU98eOYpABU4e0Gc5Dx4MC5anJO8= +go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= +go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 h1:t6wl9SPayj+c7lEIFgm4ooDBZVb01IhLB4InpomhRw8= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0/go.mod h1:iSDOcsnSA5INXzZtwaBPrKp/lWu/V14Dd+llD0oI2EA= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 h1:Mw5xcxMwlqoJd97vwPxA8isEaIoxsta9/Q51+TTJLGE= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0/go.mod h1:CQNu9bj7o7mC6U7+CA/schKEYakYXWr79ucDHTMGhCM= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 h1:Xw8U6u2f8DK2XAkGRFV7BBLENgnTGX9i4rQRxJf+/vs= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0/go.mod h1:6KW1Fm6R/s6Z3PGXwSJN2K4eT6wQB3vXX6CVnYX9NmM= +go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= +go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= +go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw= +go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= +go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= +go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= +go.opentelemetry.io/proto/otlp v1.1.0 h1:2Di21piLrCqJ3U3eXGCTPHE9R8Nh+0uglSnOyxikMeI= +go.opentelemetry.io/proto/otlp v1.1.0/go.mod h1:GpBHCBWiqvVLDqmHZsoMM3C5ySeKTC7ej/RNTae6MdY= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= +golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= +golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -116,49 +122,41 @@ golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= -golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= -golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= +golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 h1:0nDDozoAU19Qb2HwhXadU8OcsiO/09cnTqhUtq2MEOM= -google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= +google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY= +google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de h1:jFNzHPIeuzhdRwVhbZdiym9q0ory/xY3sA+v2wPg8I0= +google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:5iCWqnniDlqZHrd3neWVTOwvh/v6s3232omMecelax8= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:cZGRis4/ot9uVm639a+rHCUaG0JJHEsdyzSQTMX+suY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY= +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/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= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/guregu/null.v3 v3.3.0 h1:8j3ggqq+NgKt/O7mbFVUFKUMWN+l1AmT5jQmJ6nPh2c= gopkg.in/guregu/null.v3 v3.3.0/go.mod h1:E4tX2Qe3h7QdL+uZ3a0vqvYwKQsRSQKM5V4YltdgH9Y= @@ -168,6 +166,5 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/Dependencies.md b/Dependencies.md index 3fb8a7f1087..7c4e704b2f6 100644 --- a/Dependencies.md +++ b/Dependencies.md @@ -18,7 +18,7 @@ Through the rest of the development cycle dependencies shouldn't be updated unle The last part predominantly goes for `golang.org/x/*` and particularly `golang.org/x/net` which usually have updates through the development of Go itself. -[Goja](https://github.com/dop251/goja) has special considerations as it's heavily used and bug fixes there or new features usually have high impact on k6. Which means that we usually try to update it whenever something new lands there. +[Sobek](https://github.com/grafana/sobek) has special considerations as it's heavily used and bug fixes there or new features usually have high impact on k6. Which means that we usually try to update it whenever something new lands there. As the stability of any k6 release is pretty essential, this should be done only when adequate testing can be done, and in general, the changelog for each dependency should be consulted on what has changed. @@ -55,10 +55,10 @@ You can use the command `modtools check --direct-only` provided you, to update i Commit dependencies one by one with a message like `Update from vX.Y.Z to vX.Y.Z` and a relevant changelog for k6. Sometimes that means "nothing of relevance for k6", sometimes it means a list of bug fixes or new features. It's preferable to make multiple PRs - in most cases you can split them in three: -- update for goja - which usually needs to happen. +- update for Sobek - which usually needs to happen. - update for `golang.org/x/*` - also again happen literally every release - everything else - this in general doesn't include more than 5-6 small updates. Further splitting is recommended if PRs become too big. -When updating goja it's recommended to run the tc39 tests in `js/tc39`. And if needed, update the breaking ones as explained in an [Introduction to a k6's TC39 testing](./js/tc39/README.md). +When updating Sobek it's recommended to run the tc39 tests in `js/tc39`. And if needed, update the breaking ones as explained in an [Introduction to a k6's TC39 testing](./js/tc39/README.md). diff --git a/cloudapi/insights/client.go b/cloudapi/insights/client.go index c9ed123c5fc..c30792551bc 100644 --- a/cloudapi/insights/client.go +++ b/cloudapi/insights/client.go @@ -147,6 +147,7 @@ func (c *Client) Dial(ctx context.Context) error { ctx, cancel := context.WithTimeout(ctx, c.cfg.ConnectConfig.Timeout) defer cancel() + //nolint:staticcheck // see https://github.com/grafana/k6/issues/3699 conn, err := grpc.DialContext(ctx, c.cfg.IngesterHost, opts...) if err != nil { return fmt.Errorf("failed to dial: %w", err) @@ -207,10 +208,12 @@ func dialOptionsFromClientConfig(cfg ClientConfig) ([]grpc.DialOption, error) { var opts []grpc.DialOption if cfg.ConnectConfig.Block { + //nolint:staticcheck // see https://github.com/grafana/k6/issues/3699 opts = append(opts, grpc.WithBlock()) } if cfg.ConnectConfig.FailOnNonTempDialError { + //nolint:staticcheck // see https://github.com/grafana/k6/issues/3699 opts = append(opts, grpc.FailOnNonTempDialError(true)) } diff --git a/cmd/config.go b/cmd/config.go index b5f84a3291a..f11d239486e 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -168,15 +168,13 @@ func readEnvConfig(envMap map[string]string) (Config, error) { // TODO: add better validation, more explicit default values and improve consistency between formats // TODO: accumulate all errors and differentiate between the layers? func getConsolidatedConfig(gs *state.GlobalState, cliConf Config, runnerOpts lib.Options) (conf Config, err error) { - // TODO: use errext.WithExitCodeIfNone(err, exitcodes.InvalidConfig) where it makes sense? - fileConf, err := readDiskConfig(gs) if err != nil { - return conf, err + return conf, errext.WithExitCodeIfNone(err, exitcodes.InvalidConfig) } envConf, err := readEnvConfig(gs.Env) if err != nil { - return conf, err + return conf, errext.WithExitCodeIfNone(err, exitcodes.InvalidConfig) } conf = cliConf.Apply(fileConf) diff --git a/cmd/run_test.go b/cmd/run_test.go index aa3661f2301..4b562359ccf 100644 --- a/cmd/run_test.go +++ b/cmd/run_test.go @@ -118,7 +118,9 @@ func TestRunScriptErrorsAndAbort(t *testing.T) { testFilename, name string expErr, expLogOutput string expExitCode exitcodes.ExitCode + configFilename string extraArgs []string + envVars map[string]string }{ { testFilename: "abort.js", @@ -146,6 +148,41 @@ func TestRunScriptErrorsAndAbort(t *testing.T) { expErr: "ReferenceError: someUndefinedVar is not defined", expExitCode: exitcodes.ScriptException, }, + { + testFilename: "invalidconfig/invalid_option.js", + name: "run should fail with exit status 104 if an invalid option value exists", + expErr: "this is an invalid type", + expExitCode: exitcodes.InvalidConfig, + }, + { + testFilename: "invalidconfig/option_env.js", + name: "run should fail with exit status 104 if an invalid option is set through env variable", + expErr: "envconfig.Process", + expExitCode: exitcodes.InvalidConfig, + envVars: map[string]string{ + "K6_DURATION": "fails", + }, + }, + { + testFilename: "invalidconfig/option_env.js", + name: "run should fail with exit status 104 if an invalid option is set through k6 variable", + expErr: "invalid duration", + expExitCode: exitcodes.InvalidConfig, + extraArgs: []string{"--env", "DURATION=fails"}, + }, + { + testFilename: "invalidconfig/option_env.js", + name: "run should fail with exit status 104 if an invalid option is set in a config file", + expErr: "invalid duration", + expExitCode: exitcodes.InvalidConfig, + configFilename: "invalidconfig/invalid.json", + }, + { + testFilename: "invalidconfig/invalid_scenario.js", + name: "run should fail with exit status 104 if an invalid scenario exists", + expErr: "specified executor type", + expExitCode: exitcodes.InvalidConfig, + }, { testFilename: "thresholds/non_existing_metric.js", name: "run should fail with exit status 104 on a threshold applied to a non existing metric", @@ -203,6 +240,16 @@ func TestRunScriptErrorsAndAbort(t *testing.T) { require.NoError(t, fsext.WriteFile(ts.FS, filepath.Join(ts.Cwd, tc.testFilename), testScript, 0o644)) ts.CmdArgs = append([]string{"k6", "run", tc.testFilename}, tc.extraArgs...) + if tc.configFilename != "" { + configFile, err := os.ReadFile(path.Join("testdata", tc.configFilename)) //nolint:forbidigo + require.NoError(t, err) + require.NoError(t, fsext.WriteFile(ts.FS, filepath.Join(ts.Cwd, tc.configFilename), configFile, 0o644)) + ts.Flags.ConfigFilePath = path.Join(ts.Cwd, tc.configFilename) + } + if tc.envVars != nil { + ts.Env = tc.envVars + } + ts.ExpectedExitCode = int(tc.expExitCode) newRootCommand(ts.GlobalState).execute() diff --git a/cmd/runtime_options.go b/cmd/runtime_options.go index 61e67cfdf0c..a636b2825fe 100644 --- a/cmd/runtime_options.go +++ b/cmd/runtime_options.go @@ -24,7 +24,7 @@ func runtimeOptionFlagSet(includeSysEnv bool) *pflag.FlagSet { flags.Bool("include-system-env-vars", includeSysEnv, "pass the real system environment variables to the runtime") flags.String("compatibility-mode", "extended", `JavaScript compiler compatibility mode, "extended" or "base" or "experimental_enhanced" -base: pure goja - Golang JS VM supporting ES5.1+ +base: pure Sobek - Golang JS VM supporting ES5.1+ extended: base + Babel with parts of ES2015 preset slower to compile in case the script uses syntax unsupported by base experimental_enhanced: esbuild-based transpiling for TypeScript and ES6+ support diff --git a/cmd/testdata/invalidconfig/invalid.json b/cmd/testdata/invalidconfig/invalid.json new file mode 100644 index 00000000000..ab405b20f3c --- /dev/null +++ b/cmd/testdata/invalidconfig/invalid.json @@ -0,0 +1,3 @@ +{ + "duration": "fails" +} diff --git a/cmd/testdata/invalidconfig/invalid_option.js b/cmd/testdata/invalidconfig/invalid_option.js new file mode 100644 index 00000000000..d1ee341ecf2 --- /dev/null +++ b/cmd/testdata/invalidconfig/invalid_option.js @@ -0,0 +1,5 @@ +export const options = { + vus: 'this is an invalid type', +} + +export default function () {} diff --git a/cmd/testdata/invalidconfig/invalid_scenario.js b/cmd/testdata/invalidconfig/invalid_scenario.js new file mode 100644 index 00000000000..35bb2c12b12 --- /dev/null +++ b/cmd/testdata/invalidconfig/invalid_scenario.js @@ -0,0 +1,22 @@ +export const options = { + scenarios: { + example_scenario: { + // name of the executor to use + executor: 'shared-iterations', + // common scenario configuration + startTime: '10s', + gracefulStop: '5s', + env: { EXAMPLEVAR: 'testing' }, + tags: { example_tag: 'testing' }, + + // executor-specific configuration + vus: 10, + iterations: 200, + maxDuration: '10s', + }, + another_scenario: { + /*...*/ + }, + }, + }; + \ No newline at end of file diff --git a/cmd/testdata/invalidconfig/option_env.js b/cmd/testdata/invalidconfig/option_env.js new file mode 100644 index 00000000000..79fdd0ff815 --- /dev/null +++ b/cmd/testdata/invalidconfig/option_env.js @@ -0,0 +1,10 @@ +import http from 'k6/http'; + +export const options = { + iterations: 1, + duration: __ENV.DURATION, +}; + +export default function () { + const res = http.get('https://test.k6.io'); +} diff --git a/cmd/tests/cmd_run_test.go b/cmd/tests/cmd_run_test.go index cbde1f17503..4d2c0f50d68 100644 --- a/cmd/tests/cmd_run_test.go +++ b/cmd/tests/cmd_run_test.go @@ -2383,3 +2383,32 @@ func TestSetupTimeout(t *testing.T) { t.Log(stderr) assert.Contains(t, stderr, "setup() execution timed out after 1 seconds") } + +func TestTypeScriptSupport(t *testing.T) { + t.Parallel() + depScript := ` + export default function(): number { + let p: number = 42; + return p; + } + ` + mainScript := ` + import bar from "./bar.ts"; + let s: string = "something"; + export default function() { + console.log(s, bar()); + }; + ` + + ts := NewGlobalTestState(t) + require.NoError(t, fsext.WriteFile(ts.FS, filepath.Join(ts.Cwd, "test.ts"), []byte(mainScript), 0o644)) + require.NoError(t, fsext.WriteFile(ts.FS, filepath.Join(ts.Cwd, "bar.ts"), []byte(depScript), 0o644)) + + ts.CmdArgs = []string{"k6", "run", "--compatibility-mode", "experimental_enhanced", "--quiet", "test.ts"} + + cmd.ExecuteWithGlobalState(ts.GlobalState) + + stderr := ts.Stderr.String() + t.Log(stderr) + assert.Contains(t, stderr, `something 42`) +} diff --git a/go.mod b/go.mod index 99ce9480cff..0e72bab190a 100644 --- a/go.mod +++ b/go.mod @@ -5,26 +5,25 @@ go 1.20 require ( github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 github.com/DataDog/datadog-go v0.0.0-20180330214955-e67964b4021a - github.com/PuerkitoBio/goquery v1.9.1 + github.com/PuerkitoBio/goquery v1.9.2 github.com/Soontao/goHttpDigestClient v0.0.0-20170320082612-6d28bb1415c5 github.com/andybalholm/brotli v1.1.0 - github.com/dop251/goja v0.0.0-20240610225006-393f6d42497b github.com/evanw/esbuild v0.21.2 - github.com/fatih/color v1.16.0 + github.com/fatih/color v1.17.0 github.com/go-sourcemap/sourcemap v2.1.4+incompatible github.com/golang/protobuf v1.5.4 github.com/gorilla/websocket v1.5.1 - github.com/grafana/sobek v0.0.0-20240613124309-cb36746e8fee - github.com/grafana/xk6-browser v1.6.0 - github.com/grafana/xk6-dashboard v0.7.4 + github.com/grafana/sobek v0.0.0-20240626131919-5be1e93c7efc + github.com/grafana/xk6-browser v1.6.1-0.20240701105714-29f6ef3049fe + github.com/grafana/xk6-dashboard v0.7.5 github.com/grafana/xk6-output-prometheus-remote v0.4.0 github.com/grafana/xk6-redis v0.3.0 github.com/grafana/xk6-webcrypto v0.4.0 - github.com/grafana/xk6-websockets v0.5.1 + github.com/grafana/xk6-websockets v0.6.0 github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 github.com/influxdata/influxdb1-client v0.0.0-20190402204710-8ff2fc3824fc - github.com/jhump/protoreflect v1.15.6 - github.com/klauspost/compress v1.17.7 + github.com/jhump/protoreflect v1.16.0 + github.com/klauspost/compress v1.17.9 github.com/mailru/easyjson v0.7.7 github.com/mattn/go-colorable v0.1.13 github.com/mattn/go-isatty v0.0.20 @@ -48,12 +47,12 @@ require ( go.opentelemetry.io/otel/trace v1.24.0 go.uber.org/goleak v1.3.0 golang.org/x/crypto v0.24.0 - golang.org/x/crypto/x509roots/fallback v0.0.0-20240604170348-d4e7c9cb6cb8 + golang.org/x/crypto/x509roots/fallback v0.0.0-20240624163532-1c7450041f58 golang.org/x/net v0.26.0 golang.org/x/term v0.21.0 golang.org/x/time v0.5.0 - google.golang.org/grpc v1.63.2 - google.golang.org/protobuf v1.33.0 + google.golang.org/grpc v1.64.0 + google.golang.org/protobuf v1.34.2 gopkg.in/guregu/null.v3 v3.3.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -63,7 +62,7 @@ require ( buf.build/gen/go/prometheus/prometheus/protocolbuffers/go v1.31.0-20230627135113-9a12bc2590d2.1 // indirect github.com/andybalholm/cascadia v1.3.2 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/bufbuild/protocompile v0.8.0 // indirect + github.com/bufbuild/protocompile v0.10.0 // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/chromedp/cdproto v0.0.0-20221023212508-67ada9507fb2 // indirect @@ -95,8 +94,8 @@ require ( golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.21.0 // indirect golang.org/x/text v0.16.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect gopkg.in/cenkalti/backoff.v1 v1.1.0 // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect ) diff --git a/go.sum b/go.sum index 78cedff99a2..c528d777933 100644 --- a/go.sum +++ b/go.sum @@ -8,8 +8,8 @@ github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358/go.mod h1:chxPXzS github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/DataDog/datadog-go v0.0.0-20180330214955-e67964b4021a h1:zpQSzEApXM0qkXcpdjeJ4OpnBWhD/X8zT/iT1wYLiVU= github.com/DataDog/datadog-go v0.0.0-20180330214955-e67964b4021a/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/PuerkitoBio/goquery v1.9.1 h1:mTL6XjbJTZdpfL+Gwl5U2h1l9yEkJjhmlTeV9VPW7UI= -github.com/PuerkitoBio/goquery v1.9.1/go.mod h1:cW1n6TmIMDoORQU5IU/P1T3tGFunOeXEpGP2WHRwkbY= +github.com/PuerkitoBio/goquery v1.9.2 h1:4/wZksC3KgkQw7SQgkKotmKljk0M6V8TUvA8Wb4yPeE= +github.com/PuerkitoBio/goquery v1.9.2/go.mod h1:GHPCaP0ODyyxqcNoFGYlAprUFH81NuRPd0GX3Zu2Mvk= github.com/Soontao/goHttpDigestClient v0.0.0-20170320082612-6d28bb1415c5 h1:k+1+doEm31k0rRjCjLnGG3YRkuO9ljaEyS2ajZd6GK8= github.com/Soontao/goHttpDigestClient v0.0.0-20170320082612-6d28bb1415c5/go.mod h1:5Q4+CyR7+Q3VMG8f78ou+QSX/BNUNUx5W48eFRat8DQ= github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= @@ -21,8 +21,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bsm/ginkgo/v2 v2.7.0 h1:ItPMPH90RbmZJt5GtkcNvIRuGEdwlBItdNVoyzaNQao= github.com/bsm/gomega v1.26.0 h1:LhQm+AFcgV2M0WyKroMASzAzCAJVpAxQXv4SaI9a69Y= -github.com/bufbuild/protocompile v0.8.0 h1:9Kp1q6OkS9L4nM3FYbr8vlJnEwtbpDPQlQOVXfR+78s= -github.com/bufbuild/protocompile v0.8.0/go.mod h1:+Etjg4guZoAqzVk2czwEQP12yaxLJ8DxuqCJ9qHdH94= +github.com/bufbuild/protocompile v0.10.0 h1:+jW/wnLMLxaCEG8AX9lD0bQ5v9h1RUiMKOBOT5ll9dM= +github.com/bufbuild/protocompile v0.10.0/go.mod h1:G9qQIQo0xZ6Uyj6CMNz0saGmx2so+KONo8/KrELABiY= github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= @@ -43,15 +43,14 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cu github.com/dlclark/regexp2 v1.9.0 h1:pTK/l/3qYIKaRXuHnEnIf7Y5NxfRPfpb7dis6/gdlVI= github.com/dlclark/regexp2 v1.9.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dop251/goja v0.0.0-20240610225006-393f6d42497b h1:fMKDnOAKCGXSZBphY/ilLtu7cmwMnjqE+xJxUkfkpCY= -github.com/dop251/goja v0.0.0-20240610225006-393f6d42497b/go.mod h1:o31y53rb/qiIAONF7w3FHJZRqqP3fzHUr1HqanthByw= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/evanw/esbuild v0.21.2 h1:CLplcGi794CfHLVmUbvVfTMKkykm+nyIHU8SU60KUTA= github.com/evanw/esbuild v0.21.2/go.mod h1:D2vIQZqV/vIf/VRHtViaUtViZmG7o+kKmlBfVQuRi48= -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/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= +github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= @@ -83,20 +82,20 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= -github.com/grafana/sobek v0.0.0-20240613124309-cb36746e8fee h1:KjQPRiLoSZMz+oMdEyh8fE/rurMpx3lpRH8PIR66nzo= -github.com/grafana/sobek v0.0.0-20240613124309-cb36746e8fee/go.mod h1:4uA93vCOP7fFfkAEByuRieuU72pAc5DH05b71yCIVsQ= -github.com/grafana/xk6-browser v1.6.0 h1:x8ZfBwiUJRRKNEw+Asr5ae9o2gFvYU1Ll/4dDMNIPZ8= -github.com/grafana/xk6-browser v1.6.0/go.mod h1:xLaGGhTMHIRsMvkVWFYh9RPy87kG2n4L4Or6DeI8U+o= -github.com/grafana/xk6-dashboard v0.7.4 h1:0ZRPTAXW+6A3Xqq/a/OaIZhxUt1SOMwUFff0IPwBHrs= -github.com/grafana/xk6-dashboard v0.7.4/go.mod h1:300QyQ+OQAYz/L/AzB5tKzPeBY5eKh2wl1NsRmCbsx4= +github.com/grafana/sobek v0.0.0-20240626131919-5be1e93c7efc h1:4aFnXIV4UQu+5NL3ZlmYxTZ5hVUXu/U/TKsvBUt5wsA= +github.com/grafana/sobek v0.0.0-20240626131919-5be1e93c7efc/go.mod h1:tUEHKWaMrxFGrMgjeAH85OEceCGQiSl6a/6Wckj/Vf4= +github.com/grafana/xk6-browser v1.6.1-0.20240701105714-29f6ef3049fe h1:uE7e1Lzris7YuM5mRLulkUGBIL9WmPHvLrA2RyZLyy8= +github.com/grafana/xk6-browser v1.6.1-0.20240701105714-29f6ef3049fe/go.mod h1:TNngUsbmV3I5NDVklGxjpAR2znEjYEsBtHQirGw8nAI= +github.com/grafana/xk6-dashboard v0.7.5 h1:TcILyffT/Ea/XD7xG1jMA5lwtusOPRbEQsQDHmO30Mk= +github.com/grafana/xk6-dashboard v0.7.5/go.mod h1:Y75F8xmgCraKT+pBzFH6me9AyH5PkXD+Bxo1dm6Il/M= github.com/grafana/xk6-output-prometheus-remote v0.4.0 h1:7k3xjuKaD9BwcX8iuu5v6PtAK1L53kvx1r8BaTUfRH4= github.com/grafana/xk6-output-prometheus-remote v0.4.0/go.mod h1:esXXthLoVp9JUdGkECRthESVYu0TQTR24wrx2nRM9ak= github.com/grafana/xk6-redis v0.3.0 h1:eV1YO0miPqGFilN8sL/3OdO6Mm+hZH2nsvJm5dkE0CM= github.com/grafana/xk6-redis v0.3.0/go.mod h1:3e/U9i1Nm3WEaMy4nZSGMjVf8ZsFau+aXurYJhJ7MfQ= github.com/grafana/xk6-webcrypto v0.4.0 h1:CXRGkvVg8snYEyGCq3d5XGzDPxTPJ1m5CS68jPdtZZk= github.com/grafana/xk6-webcrypto v0.4.0/go.mod h1:+THllImZ8OWlsFc8llWqvzzjottlGdXq/7rIQ16zmFs= -github.com/grafana/xk6-websockets v0.5.1 h1:wymI6UWpwDorv3mEInytrQjC9cmXYxQFygBOCMY1q6k= -github.com/grafana/xk6-websockets v0.5.1/go.mod h1:yPadv8R00MPCnV+GGSlYV/vwVgxKRCiiJoIfWsNGoQg= +github.com/grafana/xk6-websockets v0.6.0 h1:k1z8Xy4sGOB2+VF0q621MoNo0mYY12s8Cqqo5MMeO4w= +github.com/grafana/xk6-websockets v0.6.0/go.mod h1:D76ALTjp3bMugqx7ulseJ9TZrmSvDogieWxWXr8S0+A= github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8= github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 h1:Wqo399gCIufwto+VfwCSvsnfGpF/w5E9CNxSwbpD6No= @@ -105,14 +104,14 @@ github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NH github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/influxdata/influxdb1-client v0.0.0-20190402204710-8ff2fc3824fc h1:KpMgaYJRieDkHZJWY3LMafvtqS/U8xX6+lUN+OKpl/Y= github.com/influxdata/influxdb1-client v0.0.0-20190402204710-8ff2fc3824fc/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= -github.com/jhump/protoreflect v1.15.6 h1:WMYJbw2Wo+KOWwZFvgY0jMoVHM6i4XIvRs2RcBj5VmI= -github.com/jhump/protoreflect v1.15.6/go.mod h1:jCHoyYQIJnaabEYnbGwyo9hUqfyUMTbJw/tAut5t97E= +github.com/jhump/protoreflect v1.16.0 h1:54fZg+49widqXYQ0b+usAFHbMkBGR4PpXrsHc8+TBDg= +github.com/jhump/protoreflect v1.16.0/go.mod h1:oYPd7nPvcBw/5wlDfm/AVmU9zH9BgqGCI469pGxfj/8= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= -github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= +github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -219,8 +218,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= -golang.org/x/crypto/x509roots/fallback v0.0.0-20240604170348-d4e7c9cb6cb8 h1:+kWDWI3Eb5cPIOr4cP+R2RLDwK3/dXppL+7XmSOh2LA= -golang.org/x/crypto/x509roots/fallback v0.0.0-20240604170348-d4e7c9cb6cb8/go.mod h1:kNa9WdvYnzFwC79zRpLRMJbdEFlhyM5RPFBBZp/wWH8= +golang.org/x/crypto/x509roots/fallback v0.0.0-20240624163532-1c7450041f58 h1:FQBNkSe29+6BkKYNIXZkLKylo2wpq7HGYfxUlv8bfEk= +golang.org/x/crypto/x509roots/fallback v0.0.0-20240624163532-1c7450041f58/go.mod h1:kNa9WdvYnzFwC79zRpLRMJbdEFlhyM5RPFBBZp/wWH8= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -310,22 +309,21 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY= -google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de h1:jFNzHPIeuzhdRwVhbZdiym9q0ory/xY3sA+v2wPg8I0= -google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:5iCWqnniDlqZHrd3neWVTOwvh/v6s3232omMecelax8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:cZGRis4/ot9uVm639a+rHCUaG0JJHEsdyzSQTMX+suY= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY= +google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 h1:RFiFrvy37/mpSpdySBDrUdipW/dHwsRwh3J3+A9VgT4= +google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237/go.mod h1:Z5Iiy3jtmioajWHDGFk7CeugTyHtPvMHA4UTmUkyalE= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 h1:NnYq6UN9ReLM9/Y01KWNOWyI5xQ9kbIms5GGJVwS/Yc= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -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 v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY= +google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/cenkalti/backoff.v1 v1.1.0 h1:Arh75ttbsvlpVA7WtVpH4u9h6Zl46xuptxqLxPiSo4Y= gopkg.in/cenkalti/backoff.v1 v1.1.0/go.mod h1:J6Vskwqd+OMVJl8C33mmtxTBs2gyzfv7UDAkHu8BrjI= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/js/bundle.go b/js/bundle.go index 3f2db060253..97901a44477 100644 --- a/js/bundle.go +++ b/js/bundle.go @@ -14,6 +14,8 @@ import ( "github.com/sirupsen/logrus" "gopkg.in/guregu/null.v3" + "go.k6.io/k6/errext" + "go.k6.io/k6/errext/exitcodes" "go.k6.io/k6/event" "go.k6.io/k6/js/common" "go.k6.io/k6/js/compiler" @@ -191,7 +193,10 @@ func (b *Bundle) populateExports(updateOptions bool, exports *sobek.Object) erro dec.DisallowUnknownFields() if err := dec.Decode(&b.Options); err != nil { if uerr := json.Unmarshal(data, &b.Options); uerr != nil { - return uerr + return errext.WithAbortReasonIfNone( + errext.WithExitCodeIfNone(uerr, exitcodes.InvalidConfig), + errext.AbortedByScriptError, + ) } b.preInitState.Logger.WithError(err).Warn("There were unknown fields in the options exported in the script") } diff --git a/js/bundle_test.go b/js/bundle_test.go index 39526ac79c6..934171aa9ba 100644 --- a/js/bundle_test.go +++ b/js/bundle_test.go @@ -230,7 +230,7 @@ BigInt(1231412444)`, Expr, Error string }{ "Array": {`[]`, "json: cannot unmarshal array into Go value of type lib.Options"}, - "Function": {`function(){}`, "error parsing script options: json: unsupported type: func(goja.FunctionCall) goja.Value"}, + "Function": {`function(){}`, "error parsing script options: json: unsupported type: func(sobek.FunctionCall) sobek.Value"}, } for name, data := range invalidOptions { t.Run(name, func(t *testing.T) { diff --git a/js/common/bridge.go b/js/common/bridge.go index 5535ed161fd..6ac794b07e7 100644 --- a/js/common/bridge.go +++ b/js/common/bridge.go @@ -71,11 +71,11 @@ func MethodName(_ reflect.Type, m reflect.Method) string { type FieldNameMapper struct{} // FieldName is part of the sobek.FieldNameMapper interface -// https://godoc.org/github.com/dop251/goja#FieldNameMapper +// https://godoc.org/github.com/grafana/sobek#FieldNameMapper func (FieldNameMapper) FieldName(t reflect.Type, f reflect.StructField) string { return FieldName(t, f) } // MethodName is part of the sobek.FieldNameMapper interface -// https://godoc.org/github.com/dop251/goja#FieldNameMapper +// https://godoc.org/github.com/grafana/sobek#FieldNameMapper func (FieldNameMapper) MethodName(t reflect.Type, m reflect.Method) string { return MethodName(t, m) } diff --git a/js/common/interrupt_error.go b/js/common/interrupt_error.go index 0ed89f3239d..08ce051ade9 100644 --- a/js/common/interrupt_error.go +++ b/js/common/interrupt_error.go @@ -6,11 +6,11 @@ import ( "github.com/grafana/sobek" ) -// UnwrapGojaInterruptedError returns the internal error handled by sobek. +// UnwrapGojaInterruptedError returns the internal error handled by Sobek. func UnwrapGojaInterruptedError(err error) error { - var gojaErr *sobek.InterruptedError - if errors.As(err, &gojaErr) { - if e, ok := gojaErr.Value().(error); ok { + var sobekErr *sobek.InterruptedError + if errors.As(err, &sobekErr) { + if e, ok := sobekErr.Value().(error); ok { return e } } diff --git a/js/common/randsource.go b/js/common/randsource.go index 141e547071a..37ef398faa6 100644 --- a/js/common/randsource.go +++ b/js/common/randsource.go @@ -9,8 +9,8 @@ import ( "github.com/grafana/sobek" ) -// NewRandSource is copied from goja's source code: -// https://github.com/dop251/goja/blob/master/goja/main.go#L44 +// NewRandSource is copied from Sobek's source code: +// https://github.com/grafana/sobek/blob/master/sobek/main.go#L44 // The returned RandSource is NOT safe for concurrent use: // https://golang.org/pkg/math/rand/#NewSource func NewRandSource() sobek.RandSource { diff --git a/js/common/util.go b/js/common/util.go index 94e8cff0387..b1b1a46137f 100644 --- a/js/common/util.go +++ b/js/common/util.go @@ -17,7 +17,7 @@ func Throw(rt *sobek.Runtime, err error) { panic(rt.NewGoError(err)) // this catches the stack unlike rt.ToValue } -// GetReader tries to return an io.Reader value from an exported goja value. +// GetReader tries to return an io.Reader value from an exported Sobek value. func GetReader(data interface{}) (io.Reader, error) { switch r := data.(type) { case string: diff --git a/js/compiler/compiler.go b/js/compiler/compiler.go index 27860a5cb9b..105354034fa 100644 --- a/js/compiler/compiler.go +++ b/js/compiler/compiler.go @@ -14,9 +14,10 @@ import ( "sync" "time" - "github.com/dop251/goja/parser" "github.com/go-sourcemap/sourcemap" "github.com/grafana/sobek" + "github.com/grafana/sobek/ast" + "github.com/grafana/sobek/parser" "github.com/sirupsen/logrus" "go.k6.io/k6/lib" @@ -30,26 +31,26 @@ var ( // "presets": []string{"latest"}, "plugins": []interface{}{ // es2015 https://github.com/babel/babel/blob/v6.26.0/packages/babel-preset-es2015/src/index.js - // in goja + // in Sobek // []interface{}{"transform-es2015-template-literals", map[string]interface{}{"loose": false, "spec": false}}, - // "transform-es2015-literals", // in goja - // "transform-es2015-function-name", // in goja - // []interface{}{"transform-es2015-arrow-functions", map[string]interface{}{"spec": false}}, // in goja - // "transform-es2015-block-scoped-functions", // in goja - // []interface{}{"transform-es2015-classes", map[string]interface{}{"loose": false}}, // in goja - // "transform-es2015-object-super", // in goja - // "transform-es2015-shorthand-properties", // in goja - // "transform-es2015-duplicate-keys", // in goja - // []interface{}{"transform-es2015-computed-properties", map[string]interface{}{"loose": false}}, // in goja - // "transform-es2015-for-of", // in goja - // "transform-es2015-sticky-regex", // in goja - // "transform-es2015-unicode-regex", // in goja - // "check-es2015-constants", // in goja - // []interface{}{"transform-es2015-spread", map[string]interface{}{"loose": false}}, // in goja - // "transform-es2015-parameters", // in goja - // []interface{}{"transform-es2015-destructuring", map[string]interface{}{"loose": false}}, // in goja - // "transform-es2015-block-scoping", // in goja - // "transform-es2015-typeof-symbol", // in goja + // "transform-es2015-literals", // in Sobek + // "transform-es2015-function-name", // in Sobek + // []interface{}{"transform-es2015-arrow-functions", map[string]interface{}{"spec": false}}, // in Sobek + // "transform-es2015-block-scoped-functions", // in Sobek + // []interface{}{"transform-es2015-classes", map[string]interface{}{"loose": false}}, // in Sobek + // "transform-es2015-object-super", // in Sobek + // "transform-es2015-shorthand-properties", // in Sobek + // "transform-es2015-duplicate-keys", // in Sobek + // []interface{}{"transform-es2015-computed-properties", map[string]interface{}{"loose": false}}, // in Sobek + // "transform-es2015-for-of", // in Sobek + // "transform-es2015-sticky-regex", // in Sobek + // "transform-es2015-unicode-regex", // in Sobek + // "check-es2015-constants", // in Sobek + // []interface{}{"transform-es2015-spread", map[string]interface{}{"loose": false}}, // in Sobek + // "transform-es2015-parameters", // in Sobek + // []interface{}{"transform-es2015-destructuring", map[string]interface{}{"loose": false}}, // in Sobek + // "transform-es2015-block-scoping", // in Sobek + // "transform-es2015-typeof-symbol", // in Sobek // all the other module plugins are just dropped []interface{}{"transform-es2015-modules-commonjs", map[string]interface{}{"loose": false}}, // "transform-regenerator", // Doesn't really work unless regeneratorRuntime is also added @@ -58,7 +59,7 @@ var ( // "transform-exponentiation-operator", // es2017 https://github.com/babel/babel/blob/v6.26.0/packages/babel-preset-es2017/src/index.js - // "syntax-trailing-function-commas", // in goja + // "syntax-trailing-function-commas", // in Sobek // "transform-async-to-generator", // Doesn't really work unless regeneratorRuntime is also added }, "ast": false, @@ -159,102 +160,99 @@ type Options struct { Strict bool } -// compilationState is helper struct to keep the state of a compilation -type compilationState struct { +// parsingState is helper struct to keep the state of a compilation +type parsingState struct { // set when we couldn't load external source map so we can try parsing without loading it couldntLoadSourceMap bool // srcMap is the current full sourceMap that has been generated read so far - srcMap []byte - srcMapError error - wrapped bool // whether the original source is wrapped in a function to make it a commonjs module + srcMap []byte + srcMapError error + wrapped bool // whether the original source is wrapped in a function to make it a commonjs module + compatibilityMode lib.CompatibilityMode + logger logrus.FieldLogger + + loader func(string) ([]byte, error) compiler *Compiler } -// Compile the program in the given CompatibilityMode, wrapping it between pre and post code -// TODO isESM will be used once goja support ESM modules natively -func (c *Compiler) Compile(src, filename string, isESM bool) (*sobek.Program, string, error) { - return c.compileImpl(src, filename, !isESM, c.Options.CompatibilityMode, nil) +// Parse parses the provided source. It wraps as the same as CommonJS support. +// The returned program can be compiled directly by Sobek. +// Additionally, it returns the end code that has been parsed including any required transformations. +func (c *Compiler) Parse( + src, filename string, wrap bool, +) (prg *ast.Program, finalCode string, err error) { + state := &parsingState{ + loader: c.Options.SourceMapLoader, + wrapped: wrap, + compatibilityMode: c.Options.CompatibilityMode, + logger: c.logger, + compiler: c, + } + return state.parseImpl(src, filename, wrap) } -// sourceMapLoader is to be used with goja's WithSourceMapLoader +// sourceMapLoader is to be used with Sobek's WithSourceMapLoader // it not only gets the file from disk in the simple case, but also returns it if the map was generated from babel // additioanlly it fixes off by one error in commonjs dependencies due to having to wrap them in a function. -func (c *compilationState) sourceMapLoader(path string) ([]byte, error) { +func (ps *parsingState) sourceMapLoader(path string) ([]byte, error) { if path == sourceMapURLFromBabel { - if c.wrapped { - return c.increaseMappingsByOne(c.srcMap) + if ps.wrapped { + return ps.increaseMappingsByOne(ps.srcMap) } - return c.srcMap, nil + return ps.srcMap, nil } - c.srcMap, c.srcMapError = c.compiler.Options.SourceMapLoader(path) - if c.srcMapError != nil { - c.couldntLoadSourceMap = true - return nil, c.srcMapError + ps.srcMap, ps.srcMapError = ps.loader(path) + if ps.srcMapError != nil { + ps.couldntLoadSourceMap = true + return nil, ps.srcMapError } - _, c.srcMapError = sourcemap.Parse(path, c.srcMap) - if c.srcMapError != nil { - c.couldntLoadSourceMap = true - c.srcMap = nil - return nil, c.srcMapError + _, ps.srcMapError = sourcemap.Parse(path, ps.srcMap) + if ps.srcMapError != nil { + ps.couldntLoadSourceMap = true + ps.srcMap = nil + return nil, ps.srcMapError } - if c.wrapped { - return c.increaseMappingsByOne(c.srcMap) + if ps.wrapped { + return ps.increaseMappingsByOne(ps.srcMap) } - return c.srcMap, nil + return ps.srcMap, nil } -func (c *Compiler) compileImpl( - src, filename string, wrap bool, compatibilityMode lib.CompatibilityMode, srcMap []byte, -) (*sobek.Program, string, error) { +func (ps *parsingState) parseImpl(src, filename string, wrap bool) (*ast.Program, string, error) { code := src - state := compilationState{srcMap: srcMap, compiler: c, wrapped: wrap} - if wrap { - conditionalNewLine := "" - if index := strings.LastIndex(code, "//# sourceMappingURL="); index != -1 { - // the lines in the sourcemap (if available) will be fixed by increaseMappingsByOne - conditionalNewLine = "\n" - newCode, err := state.updateInlineSourceMap(code, index) - if err != nil { - c.logger.Warnf("while compiling %q, couldn't update its inline sourcemap which might lead "+ - "to some line numbers being off: %s", filename, err) - } else { - code = newCode - } - - // if there is no sourcemap - bork only the first line of code, but leave the remaining ones. - } - code = "(function(module, exports){" + conditionalNewLine + code + "\n})\n" + if wrap { // the lines in the sourcemap (if available) will be fixed by increaseMappingsByOne + code = ps.wrap(code, filename) + ps.wrapped = true } opts := parser.WithDisableSourceMaps - if c.Options.SourceMapLoader != nil { - opts = parser.WithSourceMapLoader(state.sourceMapLoader) + if ps.loader != nil { + opts = parser.WithSourceMapLoader(ps.sourceMapLoader) } - ast, err := parser.ParseFile(nil, filename, code, 0, opts) + prg, err := parser.ParseFile(nil, filename, code, 0, opts) - if state.couldntLoadSourceMap { - state.couldntLoadSourceMap = false // reset + if ps.couldntLoadSourceMap { + ps.couldntLoadSourceMap = false // reset // we probably don't want to abort scripts which have source maps but they can't be found, // this also will be a breaking change, so if we couldn't we retry with it disabled - c.logger.WithError(state.srcMapError).Warnf("Couldn't load source map for %s", filename) - ast, err = parser.ParseFile(nil, filename, code, 0, parser.WithDisableSourceMaps) + ps.logger.WithError(ps.srcMapError).Warnf("Couldn't load source map for %s", filename) + prg, err = parser.ParseFile(nil, filename, code, 0, parser.WithDisableSourceMaps) } if err == nil { - pgm, err := sobek.CompileAST(ast, c.Options.Strict) - return pgm, code, err + return prg, code, nil } - if compatibilityMode == lib.CompatibilityModeExtended { - code, state.srcMap, err = c.Transform(src, filename, state.srcMap) + if ps.compatibilityMode == lib.CompatibilityModeExtended { + code, ps.srcMap, err = ps.compiler.Transform(src, filename, ps.srcMap) if err != nil { return nil, code, err } - // the compatibility mode "decreases" here as we shouldn't transform twice - var prg *sobek.Program - prg, code, err = c.compileImpl(code, filename, wrap, lib.CompatibilityModeBase, state.srcMap) + ps.wrapped = false + ps.compatibilityMode = lib.CompatibilityModeBase + prg, code, err = ps.parseImpl(code, filename, wrap) if err == nil && strings.Contains(src, "module.exports") { - c.logger.Warningf( + ps.logger.Warningf( "During the compilation of %q, it has been detected that the file combines ECMAScript modules (ESM) "+ "import/export syntax with commonJS module.exports. "+ "Mixing these two module systems is non-standard and will not be supported anymore in future releases. "+ @@ -263,52 +261,41 @@ func (c *Compiler) compileImpl( } return prg, code, err } - - if compatibilityMode == lib.CompatibilityModeExperimentalEnhanced { - code, state.srcMap, err = esbuildTransform(src, filename) + if ps.compatibilityMode == lib.CompatibilityModeExperimentalEnhanced { + code, ps.srcMap, err = esbuildTransform(src, filename) if err != nil { - return nil, code, err + return nil, "", err } - if c.Options.SourceMapLoader != nil { + if ps.loader != nil { // This hack is required for the source map to work code += "\n//# sourceMappingURL=" + sourceMapURLFromBabel } - return c.compileImpl(code, filename, wrap, lib.CompatibilityModeBase, state.srcMap) + ps.wrapped = false + ps.compatibilityMode = lib.CompatibilityModeBase + return ps.parseImpl(code, filename, wrap) } - return nil, code, err + return nil, "", err } -type babel struct { - vm *sobek.Runtime - this sobek.Value - transform sobek.Callable - m sync.Mutex -} - -func newBabel() (*babel, error) { - onceBabelCode.Do(func() { - globalBabelCode, errGlobalBabelCode = sobek.Compile("", babelSrc, false) - }) - if errGlobalBabelCode != nil { - return nil, errGlobalBabelCode - } - vm := sobek.New() - _, err := vm.RunProgram(globalBabelCode) - if err != nil { - return nil, err - } +func (ps *parsingState) wrap(code, filename string) string { + conditionalNewLine := "" + if index := strings.LastIndex(code, "//# sourceMappingURL="); index != -1 { + // the lines in the sourcemap (if available) will be fixed by increaseMappingsByOne + conditionalNewLine = "\n" + newCode, err := ps.updateInlineSourceMap(code, index) + if err != nil { + ps.logger.Warnf("while compiling %q, couldn't update its inline sourcemap which might lead "+ + "to some line numbers being off: %s", filename, err) + } else { + code = newCode + } - this := vm.Get("Babel") - bObj := this.ToObject(vm) - result := &babel{vm: vm, this: this} - if err = vm.ExportTo(bObj.Get("transform"), &result.transform); err != nil { - return nil, err + // if there is no sourcemap - bork only the first line of code, but leave the remaining ones. } - - return result, err + return "(function(module, exports){" + conditionalNewLine + code + "\n})\n" } -func (c *compilationState) updateInlineSourceMap(code string, index int) (string, error) { +func (ps *parsingState) updateInlineSourceMap(code string, index int) (string, error) { nextnewline := strings.Index(code[index:], "\n") if nextnewline == -1 { nextnewline = len(code[index:]) @@ -321,19 +308,19 @@ func (c *compilationState) updateInlineSourceMap(code string, index int) (string if err != nil { return code, err } - b, err = c.increaseMappingsByOne(b) + b, err = ps.increaseMappingsByOne(b) if err != nil { return code, err } encoded := base64.StdEncoding.EncodeToString(b) - code = code[:index] + "//# sourcemappingurl=data:application/json;base64," + encoded + code[nextnewline:] + code = code[:index] + "//# sourceMappingURL=data:application/json;base64," + encoded + code[index+nextnewline:] } return code, nil } // increaseMappingsByOne increases the lines in the sourcemap by line so that it fixes the case where we need to wrap a // required file in a function to support/emulate commonjs -func (c *compilationState) increaseMappingsByOne(sourceMap []byte) ([]byte, error) { +func (ps *parsingState) increaseMappingsByOne(sourceMap []byte) ([]byte, error) { var err error m := make(map[string]interface{}) if err = json.Unmarshal(sourceMap, &m); err != nil { @@ -356,7 +343,7 @@ func (c *compilationState) increaseMappingsByOne(sourceMap []byte) ([]byte, erro } else { // we have mappings but it's not a string - this is some kind of error // we still won't abort the test but just not load the sourcemap - c.couldntLoadSourceMap = true + ps.couldntLoadSourceMap = true return nil, errors.New(`missing "mappings" in sourcemap`) } @@ -406,7 +393,7 @@ func (b *babel) transformImpl( return code, nil, nil } - // this is to make goja try to load a sourcemap. + // this is to make Sobek try to load a sourcemap. // it is a special url as it should never leak outside of this code // additionally the alternative support from babel is to embed *the whole* sourcemap at the end code += "\n//# sourceMappingURL=" + sourceMapURLFromBabel @@ -482,3 +469,33 @@ func verifySourceMapForBabel(srcMap []byte) error { } return nil } + +type babel struct { + vm *sobek.Runtime + this sobek.Value + transform sobek.Callable + m sync.Mutex +} + +func newBabel() (*babel, error) { + onceBabelCode.Do(func() { + globalBabelCode, errGlobalBabelCode = sobek.Compile("", babelSrc, false) + }) + if errGlobalBabelCode != nil { + return nil, errGlobalBabelCode + } + vm := sobek.New() + _, err := vm.RunProgram(globalBabelCode) + if err != nil { + return nil, err + } + + this := vm.Get("Babel") + bObj := this.ToObject(vm) + result := &babel{vm: vm, this: this} + if err = vm.ExportTo(bObj.Get("transform"), &result.transform); err != nil { + return nil, err + } + + return result, err +} diff --git a/js/compiler/compiler_test.go b/js/compiler/compiler_test.go index 89b44cc971d..47c48a4243f 100644 --- a/js/compiler/compiler_test.go +++ b/js/compiler/compiler_test.go @@ -70,9 +70,11 @@ func TestCompile(t *testing.T) { t.Parallel() c := New(testutils.NewLogger(t)) src := `1+(function() { return 2; })()` - pgm, code, err := c.Compile(src, "script.js", true) + prg, code, err := c.Parse(src, "script.js", false) require.NoError(t, err) assert.Equal(t, src, code) + pgm, err := sobek.CompileAST(prg, true) + require.NoError(t, err) v, err := sobek.New().RunProgram(pgm) require.NoError(t, err) assert.Equal(t, int64(3), v.Export()) @@ -82,18 +84,23 @@ func TestCompile(t *testing.T) { t.Parallel() c := New(testutils.NewLogger(t)) src := `exports.d=1+(function() { return 2; })()` - pgm, code, err := c.Compile(src, "script.js", false) + prg, code, err := c.Parse(src, "script.js", true) + require.NoError(t, err) + pgm, err := sobek.CompileAST(prg, true) require.NoError(t, err) assert.Equal(t, "(function(module, exports){exports.d=1+(function() { return 2; })()\n})\n", code) rt := sobek.New() v, err := rt.RunProgram(pgm) - require.NoError(t, err) - fn, ok := sobek.AssertFunction(v) - require.True(t, ok, "not a function") - exp := make(map[string]sobek.Value) - _, err = fn(sobek.Undefined(), sobek.Undefined(), rt.ToValue(exp)) - require.NoError(t, err) - assert.Equal(t, int64(3), exp["d"].Export()) + if assert.NoError(t, err) { + fn, ok := sobek.AssertFunction(v) + if assert.True(t, ok, "not a function") { + exp := make(map[string]sobek.Value) + _, err := fn(sobek.Undefined(), sobek.Undefined(), rt.ToValue(exp)) + if assert.NoError(t, err) { + assert.Equal(t, int64(3), exp["d"].Export()) + } + } + } }) t.Run("ES5 Invalid", func(t *testing.T) { @@ -101,7 +108,7 @@ func TestCompile(t *testing.T) { c := New(testutils.NewLogger(t)) src := `1+(function() { return 2; )()` c.Options.CompatibilityMode = lib.CompatibilityModeExtended - _, _, err := c.Compile(src, "script.js", false) + _, _, err := c.Parse(src, "script.js", false) assert.IsType(t, &sobek.Exception{}, err) assert.Contains(t, err.Error(), `SyntaxError: script.js: Unexpected token (1:26) > 1 | 1+(function() { return 2; )()`) @@ -110,10 +117,11 @@ func TestCompile(t *testing.T) { t.Parallel() c := New(testutils.NewLogger(t)) c.Options.CompatibilityMode = lib.CompatibilityModeExtended - pgm, code, err := c.Compile(`import "something"`, "script.js", true) + prg, code, err := c.Parse(`import "something"`, "script.js", false) + require.NoError(t, err) + assert.Equal(t, `"use strict";require("something");`, code) + pgm, err := sobek.CompileAST(prg, true) require.NoError(t, err) - assert.Equal(t, `"use strict";require("something");`, - code) rt := sobek.New() var requireCalled bool require.NoError(t, rt.Set("require", func(s string) { @@ -126,12 +134,13 @@ func TestCompile(t *testing.T) { }) t.Run("Wrap", func(t *testing.T) { + // This only works with `require` as wrapping means the import/export won't be top level and that is forbidden t.Parallel() c := New(testutils.NewLogger(t)) c.Options.CompatibilityMode = lib.CompatibilityModeExtended - pgm, code, err := c.Compile(`import "something";`, "script.js", false) + prg, code, err := c.Parse(`require("something");`, "script.js", true) require.NoError(t, err) - assert.Equal(t, `(function(module, exports){"use strict";require("something"); + assert.Equal(t, `(function(module, exports){require("something"); }) `, code) var requireCalled bool @@ -140,6 +149,9 @@ func TestCompile(t *testing.T) { assert.Equal(t, "something", s) requireCalled = true })) + + pgm, err := sobek.CompileAST(prg, true) + require.NoError(t, err) v, err := rt.RunProgram(pgm) require.NoError(t, err) fn, ok := sobek.AssertFunction(v) @@ -153,7 +165,7 @@ func TestCompile(t *testing.T) { t.Parallel() c := New(testutils.NewLogger(t)) c.Options.CompatibilityMode = lib.CompatibilityModeExtended - _, _, err := c.Compile(`1+(=>2)()`, "script.js", true) + _, _, err := c.Parse(`1+(=>2)()`, "script.js", false) assert.IsType(t, &sobek.Exception{}, err) assert.Contains(t, err.Error(), `SyntaxError: script.js: Unexpected token (1:3) > 1 | 1+(=>2)()`) @@ -167,8 +179,10 @@ func TestCorruptSourceMap(t *testing.T) { logger := logrus.New() logger.SetLevel(logrus.DebugLevel) logger.Out = io.Discard - hook := testutils.NewLogHook(logrus.InfoLevel, logrus.WarnLevel) - logger.AddHook(hook) + hook := testutils.SimpleLogrusHook{ + HookedLevels: []logrus.Level{logrus.InfoLevel, logrus.WarnLevel}, + } + logger.AddHook(&hook) compiler := New(logger) compiler.Options = Options{ @@ -177,7 +191,7 @@ func TestCorruptSourceMap(t *testing.T) { return corruptSourceMap, nil }, } - _, _, err := compiler.Compile("var s = 5;\n//# sourceMappingURL=somefile", "somefile", false) + _, _, err := compiler.Parse("var s = 5;\n//# sourceMappingURL=somefile", "somefile", false) require.NoError(t, err) entries := hook.Drain() require.Len(t, entries, 1) @@ -190,14 +204,17 @@ func TestCorruptSourceMap(t *testing.T) { func TestCorruptSourceMapOnlyForBabel(t *testing.T) { t.Parallel() + // This test is now kind of pointless // this a valid source map for the go implementation but babel doesn't like it corruptSourceMap := []byte(`{"mappings": ";"}`) logger := logrus.New() logger.SetLevel(logrus.DebugLevel) logger.Out = io.Discard - hook := testutils.NewLogHook(logrus.InfoLevel, logrus.WarnLevel) - logger.AddHook(hook) + hook := testutils.SimpleLogrusHook{ + HookedLevels: []logrus.Level{logrus.InfoLevel, logrus.WarnLevel}, + } + logger.AddHook(&hook) compiler := New(logger) compiler.Options = Options{ @@ -207,7 +224,9 @@ func TestCorruptSourceMapOnlyForBabel(t *testing.T) { return corruptSourceMap, nil }, } - _, _, err := compiler.Compile("import 'something';\n//# sourceMappingURL=somefile", "somefile", false) + prg, _, err := compiler.Parse("import 'something';\n//# sourceMappingURL=somefile", "somefile", false) + require.NoError(t, err) + _, err = sobek.CompileAST(prg, true) require.NoError(t, err) entries := hook.Drain() require.Len(t, entries, 1) @@ -226,8 +245,10 @@ func TestMinimalSourceMap(t *testing.T) { logger := logrus.New() logger.SetLevel(logrus.DebugLevel) logger.Out = io.Discard - hook := testutils.NewLogHook(logrus.InfoLevel, logrus.WarnLevel) - logger.AddHook(hook) + hook := testutils.SimpleLogrusHook{ + HookedLevels: []logrus.Level{logrus.InfoLevel, logrus.WarnLevel}, + } + logger.AddHook(&hook) compiler := New(logger) compiler.Options = Options{ @@ -237,7 +258,7 @@ func TestMinimalSourceMap(t *testing.T) { return corruptSourceMap, nil }, } - _, _, err := compiler.Compile("class s {};\n//# sourceMappingURL=somefile", "somefile", false) + _, _, err := compiler.Parse("class s {};\n//# sourceMappingURL=somefile", "somefile", false) require.NoError(t, err) require.Empty(t, hook.Drain()) } @@ -255,7 +276,7 @@ func TestMixingImportExport(t *testing.T) { CompatibilityMode: lib.CompatibilityModeExtended, Strict: true, } - _, _, err := compiler.Compile("export let s = 5;\nmodule.exports = 'something';", "somefile", false) + _, _, err := compiler.Parse("export let s = 5;\nmodule.exports = 'something';", "somefile", false) require.NoError(t, err) entries := hook.Drain() require.Len(t, entries, 1) diff --git a/js/compiler/enhanced.go b/js/compiler/enhanced.go index 228686a4424..0841448c417 100644 --- a/js/compiler/enhanced.go +++ b/js/compiler/enhanced.go @@ -3,9 +3,9 @@ package compiler import ( "path/filepath" - "github.com/dop251/goja/file" - "github.com/dop251/goja/parser" "github.com/evanw/esbuild/pkg/api" + "github.com/grafana/sobek/file" + "github.com/grafana/sobek/parser" ) func esbuildTransform(src, filename string) (code string, srcMap []byte, err error) { diff --git a/js/compiler/enhanced_test.go b/js/compiler/enhanced_test.go index 4e06f694d9c..6007c345056 100644 --- a/js/compiler/enhanced_test.go +++ b/js/compiler/enhanced_test.go @@ -4,8 +4,8 @@ import ( "errors" "testing" - "github.com/dop251/goja/parser" "github.com/grafana/sobek" + "github.com/grafana/sobek/parser" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.k6.io/k6/lib" @@ -61,7 +61,7 @@ func TestCompile_experimental_enhanced(t *testing.T) { c := New(testutils.NewLogger(t)) src := `1+(function() { return 2; )()` c.Options.CompatibilityMode = lib.CompatibilityModeExperimentalEnhanced - _, _, err := c.Compile(src, "script.js", false) + _, _, err := c.Parse(src, "script.js", false) assert.IsType(t, &parser.Error{}, err) assert.Contains(t, err.Error(), `script.js: Line 1:26 Unexpected ")"`) }) @@ -69,10 +69,12 @@ func TestCompile_experimental_enhanced(t *testing.T) { t.Parallel() c := New(testutils.NewLogger(t)) c.Options.CompatibilityMode = lib.CompatibilityModeExperimentalEnhanced - pgm, code, err := c.Compile(`import "something"`, "script.js", true) + prg, code, err := c.Parse(`import "something"`, "script.js", false) require.NoError(t, err) assert.Equal(t, `var import_something = require("something"); `, code) + pgm, err := sobek.CompileAST(prg, true) + require.NoError(t, err) rt := sobek.New() var requireCalled bool require.NoError(t, rt.Set("require", func(s string) { @@ -88,7 +90,7 @@ func TestCompile_experimental_enhanced(t *testing.T) { c := New(testutils.NewLogger(t)) c.Options.CompatibilityMode = lib.CompatibilityModeExperimentalEnhanced c.Options.SourceMapLoader = func(_ string) ([]byte, error) { return nil, nil } - _, code, err := c.Compile(`import "something"`, "script.js", true) + _, code, err := c.Parse(`import "something"`, "script.js", false) require.NoError(t, err) assert.Equal(t, `var import_something = require("something"); diff --git a/js/eventloop/eventloop.go b/js/eventloop/eventloop.go index 09a11cf60e5..038326c80ba 100644 --- a/js/eventloop/eventloop.go +++ b/js/eventloop/eventloop.go @@ -108,7 +108,7 @@ func (e *EventLoop) wakeup() { // This ensures that the actual work happens asynchronously, while the Promise // is immediately returned and the main thread resumes execution. It also // ensures that the Promise resolution happens safely back on the main thread -// once the async work is done, as required by goja and all other JS runtimes. +// once the async work is done, as required by Sobek and all other JS runtimes. // // TODO: rename to ReservePendingCallback or something more appropriate? func (e *EventLoop) RegisterCallback() (enqueueCallback func(func() error)) { @@ -132,7 +132,7 @@ func (e *EventLoop) RegisterCallback() (enqueueCallback func(func() error)) { } func (e *EventLoop) promiseRejectionTracker(p *sobek.Promise, op sobek.PromiseRejectionOperation) { - // No locking necessary here as the goja runtime will call this synchronously + // No locking necessary here as the Sobek runtime will call this synchronously // Read Notes on https://tc39.es/ecma262/#sec-host-promise-rejection-tracker if op == sobek.PromiseRejectionReject { e.pendingPromiseRejections[p] = struct{}{} diff --git a/js/module_loading_test.go b/js/module_loading_test.go index a9c303fe404..716fb2ba992 100644 --- a/js/module_loading_test.go +++ b/js/module_loading_test.go @@ -294,7 +294,7 @@ func TestLoadCycle(t *testing.T) { require.NoError(t, fsext.WriteFile(fileSystem, "/counter.js", []byte(` let main = require("./main.js"); exports.count = 5; - export function a() { + exports.a = function() { return main.message; } `), fs.ModePerm)) @@ -303,15 +303,14 @@ func TestLoadCycle(t *testing.T) { let counter = require("./counter.js"); let count = counter.count; let a = counter.a; - let message= "Eval complete"; - exports.message = message; + exports.message = "Eval complete"; - export default function() { + exports.default = function() { if (count != 5) { throw new Error("Wrong value of count "+ count); } let aMessage = a(); - if (aMessage != message) { + if (aMessage != exports.message) { throw new Error("Wrong value of a() "+ aMessage); } } @@ -683,3 +682,44 @@ func TestOptionsAreNotGloballyWritable(t *testing.T) { require.EqualValues(t, time.Minute*5, r2.GetOptions().MinIterationDuration.Duration) } + +func TestDefaultNamedExports(t *testing.T) { + t.Parallel() + _, err := getSimpleRunner(t, "/main.js", `export default function main() {}`, + lib.RuntimeOptions{CompatibilityMode: null.StringFrom("extended")}) + require.NoError(t, err) +} + +func TestStarImport(t *testing.T) { + t.Parallel() + fs := fsext.NewMemMapFs() + err := writeToFs(fs, map[string]any{ + "/commonjs_file.js": `exports.something = 5;`, + }) + require.NoError(t, err) + + r1, err := getSimpleRunner(t, "/script.js", ` + import * as cjs from "./commonjs_file.js"; // commonjs + import * as k6 from "k6"; // "new" go module + // TODO: test with basic go module maybe + + if (cjs.something != 5) { + throw "cjs.something has wrong value" + cjs.something; + } + if (typeof k6.sleep != "function") { + throw "k6.sleep has wrong type" + typeof k6.sleep; + } + export default () => {} + `, fs, lib.RuntimeOptions{CompatibilityMode: null.StringFrom("extended")}) + require.NoError(t, err) + + arc := r1.MakeArchive() + registry := metrics.NewRegistry() + builtinMetrics := metrics.RegisterBuiltinMetrics(registry) + _, err = NewFromArchive(&lib.TestPreInitState{ + Logger: testutils.NewLogger(t), + BuiltinMetrics: builtinMetrics, + Registry: registry, + }, arc) + require.NoError(t, err) +} diff --git a/js/modules/cjsmodule.go b/js/modules/cjsmodule.go index 495e0a9f63a..4612f1368c0 100644 --- a/js/modules/cjsmodule.go +++ b/js/modules/cjsmodule.go @@ -65,9 +65,14 @@ func (c *cjsModuleInstance) exports() *sobek.Object { // TODO: extract this to not make this package dependant on compilers. // this is potentially a moot point after ESM when the compiler will likely get mostly dropped. func cjsModuleFromString(fileURL *url.URL, data []byte, c *compiler.Compiler) (*cjsModule, error) { - pgm, _, err := c.Compile(string(data), fileURL.String(), false) + astProgram, _, err := c.Parse(string(data), fileURL.String(), true) if err != nil { return nil, err } + pgm, err := sobek.CompileAST(astProgram, true) + if err != nil { + return nil, err + } + return &cjsModule{prg: pgm, url: fileURL}, nil } diff --git a/js/modules/k6/data/data.go b/js/modules/k6/data/data.go index 9e5ad78fa8b..a67f1a9c7ba 100644 --- a/js/modules/k6/data/data.go +++ b/js/modules/k6/data/data.go @@ -111,11 +111,11 @@ func (s *sharedArrays) get(rt *sobek.Runtime, name string, call sobek.Callable) } func getShareArrayFromCall(rt *sobek.Runtime, call sobek.Callable) sharedArray { - gojaValue, err := call(sobek.Undefined()) + sobekValue, err := call(sobek.Undefined()) if err != nil { common.Throw(rt, err) } - obj := gojaValue.ToObject(rt) + obj := sobekValue.ToObject(rt) if obj.ClassName() != "Array" { common.Throw(rt, errors.New("only arrays can be made into SharedArray")) // TODO better error } diff --git a/js/modules/k6/execution/execution.go b/js/modules/k6/execution/execution.go index 6393b1d9c2f..236c177e73b 100644 --- a/js/modules/k6/execution/execution.go +++ b/js/modules/k6/execution/execution.go @@ -353,7 +353,7 @@ func (o *tagsDynamicObject) Get(key string) sobek.Value { } // Set a property value for the key. It returns true if succeed. String, Boolean -// and Number types are implicitly converted to the goja's relative string +// and Number types are implicitly converted to the Sobek's relative string // representation. An exception is raised in case a denied type is provided. func (o *tagsDynamicObject) Set(key string, val sobek.Value) bool { o.state.Tags.Modify(func(tagsAndMeta *metrics.TagsAndMeta) { @@ -410,7 +410,7 @@ func (o *metadataDynamicObject) Get(key string) sobek.Value { } // Set a property value for the key. It returns true if successful. String, Boolean -// and Number types are implicitly converted to the goja's relative string +// and Number types are implicitly converted to the Sobek's relative string // representation. An exception is raised in case a denied type is provided. func (o *metadataDynamicObject) Set(key string, val sobek.Value) bool { o.state.Tags.Modify(func(tagsAndMeta *metrics.TagsAndMeta) { diff --git a/js/modules/k6/experimental/streams/goja.go b/js/modules/k6/experimental/streams/goja.go index e9b3a04e75a..c194b6119c0 100644 --- a/js/modules/k6/experimental/streams/goja.go +++ b/js/modules/k6/experimental/streams/goja.go @@ -59,7 +59,7 @@ func promiseThen( return newPromise, nil } -// isNumber returns true if the given goja value holds a number +// isNumber returns true if the given sobek.Value holds a number func isNumber(value sobek.Value) bool { _, isFloat := value.Export().(float64) _, isInt := value.Export().(int64) diff --git a/js/modules/k6/experimental/streams/tests/checkout.sh b/js/modules/k6/experimental/streams/tests/checkout.sh index df42ab66ff5..8d753c457be 100755 --- a/js/modules/k6/experimental/streams/tests/checkout.sh +++ b/js/modules/k6/experimental/streams/tests/checkout.sh @@ -13,7 +13,7 @@ git sparse-checkout set resources streams git fetch origin --depth=1 "${sha}" git checkout ${sha} -# Apply custom patches needed to run the tests in k6/goja +# Apply custom patches needed to run the tests in k6/Sobek for patch in ../*.patch do git apply "$patch" diff --git a/js/modules/k6/grpc/client.go b/js/modules/k6/grpc/client.go index 2ff52484dc6..fdcd80048d0 100644 --- a/js/modules/k6/grpc/client.go +++ b/js/modules/k6/grpc/client.go @@ -385,7 +385,7 @@ func (c *Client) Close() error { return err } -// MethodInfo holds information on any parsed method descriptors that can be used by the goja VM +// MethodInfo holds information on any parsed method descriptors that can be used by the Sobek VM type MethodInfo struct { Package string Service string diff --git a/js/modules/k6/grpc/listeners.go b/js/modules/k6/grpc/listeners.go index c1bd336e42a..00ebb3b63fc 100644 --- a/js/modules/k6/grpc/listeners.go +++ b/js/modules/k6/grpc/listeners.go @@ -26,7 +26,7 @@ type eventListener struct { eventType string // this return sobek.value *and* error in order to return error on exception instead of panic - // https://pkg.go.dev/github.com/dop251/goja#hdr-Functions + // https://pkg.go.dev/github.com/grafana/sobek#hdr-Functions list []func(sobek.Value) (sobek.Value, error) } diff --git a/js/modules/k6/grpc/params_test.go b/js/modules/k6/grpc/params_test.go index 62929a98054..ef0c20c14ca 100644 --- a/js/modules/k6/grpc/params_test.go +++ b/js/modules/k6/grpc/params_test.go @@ -142,7 +142,7 @@ func TestCallParamsTimeOutParse(t *testing.T) { // newParamsTestRuntime creates a new test runtime // that could be used to test the params // it also moves to the VU context and creates the params -// goja value that could be used in the tests +// Sobek value that could be used in the tests func newParamsTestRuntime(t *testing.T, paramsJSON string) (*modulestest.Runtime, sobek.Value) { t.Helper() diff --git a/js/modules/k6/html/html.go b/js/modules/k6/html/html.go index 4630c1db065..8d2c3c2dbc2 100644 --- a/js/modules/k6/html/html.go +++ b/js/modules/k6/html/html.go @@ -79,9 +79,9 @@ func (s Selection) emptySelection() Selection { return s.Eq(s.Size()) } -func (s Selection) buildMatcher(v sobek.Value, gojaFn sobek.Callable) func(int, *goquery.Selection) bool { +func (s Selection) buildMatcher(v sobek.Value, sobekFn sobek.Callable) func(int, *goquery.Selection) bool { return func(idx int, sel *goquery.Selection) bool { - fnRes, fnErr := gojaFn(v, s.rt.ToValue(idx), s.rt.ToValue(sel)) + fnRes, fnErr := sobekFn(v, s.rt.ToValue(idx), s.rt.ToValue(sel)) if fnErr != nil { common.Throw(s.rt, fnErr) } @@ -181,12 +181,12 @@ func (s Selection) Has(arg interface{}) Selection { } func (s Selection) Not(v sobek.Value) Selection { - gojaFn, isFn := sobek.AssertFunction(v) + sobekFn, isFn := sobek.AssertFunction(v) if !isFn { return s.varargFnCall(v, s.sel.Not, s.sel.NotSelection, s.sel.NotNodes) } - return Selection{s.rt, s.sel.NotFunction(s.buildMatcher(v, gojaFn)), s.URL} + return Selection{s.rt, s.sel.NotFunction(s.buildMatcher(v, sobekFn)), s.URL} } func (s Selection) Next(def ...string) Selection { @@ -357,13 +357,13 @@ func (s Selection) Children(def ...string) Selection { } func (s Selection) Each(v sobek.Value) Selection { - gojaFn, isFn := sobek.AssertFunction(v) + sobekFn, isFn := sobek.AssertFunction(v) if !isFn { common.Throw(s.rt, errors.New("the argument to each() must be a function")) } fn := func(idx int, _ *goquery.Selection) { - if _, err := gojaFn(v, s.rt.ToValue(idx), selToElement(Selection{s.rt, s.sel.Eq(idx), s.URL})); err != nil { + if _, err := sobekFn(v, s.rt.ToValue(idx), selToElement(Selection{s.rt, s.sel.Eq(idx), s.URL})); err != nil { common.Throw(s.rt, fmt.Errorf("the function passed to each() failed: %w", err)) } } @@ -380,12 +380,12 @@ func (s Selection) Filter(v sobek.Value) Selection { return Selection{s.rt, s.sel.FilterSelection(val.sel), s.URL} } - gojaFn, isFn := sobek.AssertFunction(v) + sobekFn, isFn := sobek.AssertFunction(v) if !isFn { common.Throw(s.rt, errors.New("the argument to filter() must be a function, a selector or a selection")) } - return Selection{s.rt, s.sel.FilterFunction(s.buildMatcher(v, gojaFn)), s.URL} + return Selection{s.rt, s.sel.FilterFunction(s.buildMatcher(v, sobekFn)), s.URL} } func (s Selection) Is(v sobek.Value) bool { @@ -397,18 +397,18 @@ func (s Selection) Is(v sobek.Value) bool { return s.sel.IsSelection(val.sel) default: - gojaFn, isFn := sobek.AssertFunction(v) + sobekFn, isFn := sobek.AssertFunction(v) if !isFn { common.Throw(s.rt, errors.New("the argument to is() must be a function, a selector or a selection")) } - return s.sel.IsFunction(s.buildMatcher(v, gojaFn)) + return s.sel.IsFunction(s.buildMatcher(v, sobekFn)) } } // Map implements ES5 Array.prototype.map func (s Selection) Map(v sobek.Value) []sobek.Value { - gojaFn, isFn := sobek.AssertFunction(v) + sobekFn, isFn := sobek.AssertFunction(v) if !isFn { common.Throw(s.rt, errors.New("the argument to map() must be a function")) } @@ -417,7 +417,7 @@ func (s Selection) Map(v sobek.Value) []sobek.Value { s.sel.Each(func(idx int, sel *goquery.Selection) { selection := &Selection{sel: sel, URL: s.URL, rt: s.rt} - if fnRes, fnErr := gojaFn(v, s.rt.ToValue(idx), s.rt.ToValue(selection)); fnErr == nil { + if fnRes, fnErr := sobekFn(v, s.rt.ToValue(idx), s.rt.ToValue(selection)); fnErr == nil { values = append(values, fnRes) } }) diff --git a/js/modules/k6/http/cookiejar.go b/js/modules/k6/http/cookiejar.go index 4a68fbb2e87..3c41b4d7ed4 100644 --- a/js/modules/k6/http/cookiejar.go +++ b/js/modules/k6/http/cookiejar.go @@ -20,7 +20,7 @@ var ErrJarForbiddenInInitContext = common.NewInitContextError("Making cookie jar // CookieJar is cookiejar.Jar wrapper to be used in js scripts type CookieJar struct { moduleInstance *ModuleInstance - // js is to make it not be accessible from inside goja/js, the json is + // js is to make it not be accessible from inside Sobek/js, the json is // for when it is returned from setup(). Jar *cookiejar.Jar `js:"-" json:"-"` } diff --git a/js/modules/k6/http/response.go b/js/modules/k6/http/response.go index 38d291c872e..0cc04b51de6 100644 --- a/js/modules/k6/http/response.go +++ b/js/modules/k6/http/response.go @@ -16,7 +16,7 @@ import ( "go.k6.io/k6/lib/netext/httpext" ) -// Response is a representation of an HTTP response to be returned to the goja VM +// Response is a representation of an HTTP response to be returned to the Sobek VM type Response struct { *httpext.Response `js:"-"` client *Client @@ -61,7 +61,7 @@ func (res *Response) HTML(selector ...string) html.Selection { return sel } -// JSON parses the body of a response as JSON and returns it to the goja VM. +// JSON parses the body of a response as JSON and returns it to the Sobek VM. func (res *Response) JSON(selector ...string) sobek.Value { rt := res.client.moduleInstance.vu.Runtime() diff --git a/js/modules/k6/timers/timers.go b/js/modules/k6/timers/timers.go index 0c1879b90ae..a96fe11852a 100644 --- a/js/modules/k6/timers/timers.go +++ b/js/modules/k6/timers/timers.go @@ -64,7 +64,7 @@ func (*RootModule) NewModuleInstance(vu modules.VU) modules.Instance { func (e *Timers) Exports() modules.Exports { return modules.Exports{ Named: map[string]interface{}{ - // TODO the usage of `ToValue` here is so that goja doesn't do it automatically later + // TODO the usage of `ToValue` here is so that Sobek doesn't do it automatically later // which will effectively create new instance each time it is accessed. "setTimeout": e.vu.Runtime().ToValue(e.setTimeout), "clearTimeout": e.vu.Runtime().ToValue(e.clearTimeout), diff --git a/js/modules/require_impl.go b/js/modules/require_impl.go index f7236195c03..a641b71c7c8 100644 --- a/js/modules/require_impl.go +++ b/js/modules/require_impl.go @@ -43,7 +43,7 @@ func (r *LegacyRequireImpl) Require(specifier string) (*sobek.Object, error) { // // With native ESM this won't even be possible as `require` might not be called - instead an import // might be used in which case we won't be able to be doing this hack. In that case we either will - // need some goja specific helper or to use stack traces as goja_nodejs does. + // need some Sobek specific helper or to use stack traces. currentPWD := r.currentlyRequiredModule if specifier != "k6" && !strings.HasPrefix(specifier, "k6/") { defer func() { diff --git a/js/path_resolution_test.go b/js/path_resolution_test.go index 2ea156106e3..24200fefe48 100644 --- a/js/path_resolution_test.go +++ b/js/path_resolution_test.go @@ -64,6 +64,25 @@ func TestOpenPathResolution(t *testing.T) { `, }, }, + "space in path": { + fsMap: map[string]any{ + "/A/B D/data.txt": "data file", + "/A/C D/B/script.js": ` + // Here the path is relative to this module but to the one calling + module.exports = () => open("./../data.txt"); + `, + "/A/B D/B/script.js": ` + module.exports = require("./../../C D/B/script.js")(); + `, + "/A/A/A/A/script.js": ` + let data = require("./../../../B D/B/script.js"); + if (data != "data file") { + throw new Error("wrong content " + data); + } + export default function() {} + `, + }, + }, } for name, testCase := range testCases { diff --git a/js/promises/promises.go b/js/promises/promises.go index 89cc463a444..0c8e23f4a7d 100644 --- a/js/promises/promises.go +++ b/js/promises/promises.go @@ -8,7 +8,7 @@ import ( // New can be used to create promises that will be dispatched to k6's event loop. // -// Calling the function will create a goja promise and return its `resolve` and `reject` callbacks, wrapped +// Calling the function will create a Sobek promise and return its `resolve` and `reject` callbacks, wrapped // in such a way that it will block the k6 JavaScript runtime's event loop from exiting before they are // called, even if the promise isn't resolved by the time the current script ends executing. // diff --git a/js/runner.go b/js/runner.go index 64c116094b7..29deb508ea1 100644 --- a/js/runner.go +++ b/js/runner.go @@ -566,12 +566,12 @@ func (r *Runner) runPart( } //nolint:gochecknoglobals -var gojaPromiseType = reflect.TypeOf((*sobek.Promise)(nil)) +var sobekPromiseType = reflect.TypeOf((*sobek.Promise)(nil)) // unPromisify gets the result of v if it is a promise, otherwise returns v func unPromisify(v sobek.Value) sobek.Value { if !common.IsNullish(v) { - if v.ExportType() == gojaPromiseType { + if v.ExportType() == sobekPromiseType { p, ok := v.Export().(*sobek.Promise) if !ok { panic("Something that was promise did not export to a promise; this shouldn't happen") @@ -757,7 +757,7 @@ func (u *ActiveVU) RunOnce() error { u.incrIteration() if err := u.Runtime.Set("__ITER", u.iteration); err != nil { - panic(fmt.Errorf("error setting __ITER in goja runtime: %w", err)) + panic(fmt.Errorf("error setting __ITER in Sobek runtime: %w", err)) } ctx, cancel := context.WithCancel(u.RunContext) diff --git a/js/runner_test.go b/js/runner_test.go index f755d20b317..5324d7c6e4a 100644 --- a/js/runner_test.go +++ b/js/runner_test.go @@ -181,7 +181,7 @@ func TestOptionsSettingToScript(t *testing.T) { t.Run(fmt.Sprintf("Variant#%d", i), func(t *testing.T) { t.Parallel() data := variant + ` - exports.default = function() { + export default function() { if (!options) { throw new Error("Expected options to be defined!"); } @@ -549,7 +549,8 @@ func TestRunnerIntegrationImports(t *testing.T) { mod := mod t.Run(mod, func(t *testing.T) { t.Run("Source", func(t *testing.T) { - _, err := getSimpleRunner(t, "/script.js", fmt.Sprintf(`import "%s"; exports.default = function() {}`, mod), rtOpts) + _, err := getSimpleRunner(t, "/script.js", + fmt.Sprintf(`import "%s"; export default function() {}`, mod), rtOpts) require.NoError(t, err) }) }) @@ -563,8 +564,8 @@ func TestRunnerIntegrationImports(t *testing.T) { "Absolute": {"/path/script.js", "/path/to/lib.js"}, "Relative": {"/path/script.js", "./to/lib.js"}, "Adjacent": {"/path/to/script.js", "./lib.js"}, - "STDIN-Absolute": {"-", "/path/to/lib.js"}, - "STDIN-Relative": {"-", "./path/to/lib.js"}, + "STDIN-Absolute": {"/-", "/path/to/lib.js"}, + "STDIN-Relative": {"/-", "./path/to/lib.js"}, } for name, data := range testdata { name, data := name, data diff --git a/js/tc39/README.md b/js/tc39/README.md index cc1dbc21979..0a7f1b26d5a 100644 --- a/js/tc39/README.md +++ b/js/tc39/README.md @@ -1,6 +1,6 @@ # Introduction to a k6's TC39 testing -The point of this module is to test k6 goja+babel and k6 goja+esbuild combo against the tc39 test suite. +The point of this module is to test k6 Sobek+babel and k6 Sobek+esbuild combo against the tc39 test suite. Ways to use it: 1. run ./checkout.sh to checkout the last commit sha of [test262](https://github.com/tc39/test262) @@ -8,13 +8,13 @@ Ways to use it: 2. Run `go test &> out.log` The full list of failing tests, and the error, is in `breaking_test_errors-*.json`. All errors list there with the corresponding error will *not* be counted as errors - this is what the test expects, those specific errors. -Due to changes to goja it is not uncommon for the error to change, or there to be now a new error on previously passing test, or (hopefully) a test that was not passing but now is. +Due to changes to soben it is not uncommon for the error to change, or there to be now a new error on previously passing test, or (hopefully) a test that was not passing but now is. In all of those cases `breaking_test_errors-*.json` needs to be updated. Run the test with `-update` flag to update: `go test -update` NOTE: some text editors/IDEs will try to parse files ending in `json` as JSON, which given the size of `breaking_test_errors-*.json` might be a problem when it's not actually a JSON (before the edit). So it might be a better idea to name it something different if editing by hand and fix it later. -This is a modified version of [the code in the goja -repo](https://github.com/dop251/goja/blob/master/tc39_test.go) +This is a modified version of [the code in the original goja +repo](https://github.com/dop251/goja/blob/master/tc39_test.go) that Sobek was forked from. ## Reasons for recording breaking_test_errors.json diff --git a/js/tc39/breaking_test_errors-experimental_enhanced.json b/js/tc39/breaking_test_errors-experimental_enhanced.json index 7cab7aff117..23f5b50bc9a 100644 --- a/js/tc39/breaking_test_errors-experimental_enhanced.json +++ b/js/tc39/breaking_test_errors-experimental_enhanced.json @@ -36,11 +36,17 @@ "test/language/expressions/assignment/fn-name-lhs-cover.js-strict:true": "test/language/expressions/assignment/fn-name-lhs-cover.js: Test262Error: descriptor value should be ", "test/language/expressions/class/class-name-ident-await-escaped-module.js-strict:true": "test/language/expressions/class/class-name-ident-await-escaped-module.js: error is not an object (Test262: This statement should not be evaluated.)", "test/language/expressions/class/class-name-ident-await-module.js-strict:true": "test/language/expressions/class/class-name-ident-await-module.js: error is not an object (Test262: This statement should not be evaluated.)", + "test/language/expressions/class/cpn-class-expr-accessors-computed-property-name-from-integer-separators.js-strict:true": "test/language/expressions/class/cpn-class-expr-accessors-computed-property-name-from-integer-separators.js: SyntaxError: test/language/expressions/class/cpn-class-expr-accessors-computed-property-name-from-integer-separators.js: Identifier directly after number (40:8)\n 38 | \n 39 | let C = class {\n> 40 | get [1_2_3_4_5_6_7_8]() {\n | ^\n 41 | return 1_2_3_4_5_6_7_8;\n 42 | }\n 43 | ", + "test/language/expressions/class/cpn-class-expr-computed-property-name-from-integer-separators.js-strict:true": "test/language/expressions/class/cpn-class-expr-computed-property-name-from-integer-separators.js: SyntaxError: test/language/expressions/class/cpn-class-expr-computed-property-name-from-integer-separators.js: Identifier directly after number (40:4)\n 38 | \n 39 | let C = class {\n> 40 | [1_2_3_4_5_6_7_8]() {\n | ^\n 41 | return 1_2_3_4_5_6_7_8;\n 42 | }\n 43 | static [1_2_3_4_5_6_7_8]() { ", + "test/language/expressions/class/cpn-class-expr-fields-computed-property-name-from-integer-separators.js-strict:true": "test/language/expressions/class/cpn-class-expr-fields-computed-property-name-from-integer-separators.js: SyntaxError: test/language/expressions/class/cpn-class-expr-fields-computed-property-name-from-integer-separators.js: Identifier directly after number (40:4)\n 38 | \n 39 | let C = class {\n> 40 | [1_2_3_4_5_6_7_8] = 1_2_3_4_5_6_7_8;\n | ^\n 41 | \n 42 | static [1_2_3_4_5_6_7_8] = 1_2_3_4_5_6_7_8;\n 43 | }; ", + "test/language/expressions/class/cpn-class-expr-fields-methods-computed-property-name-from-integer-separators.js-strict:true": "test/language/expressions/class/cpn-class-expr-fields-methods-computed-property-name-from-integer-separators.js: SyntaxError: test/language/expressions/class/cpn-class-expr-fields-methods-computed-property-name-from-integer-separators.js: Identifier directly after number (40:4)\n 38 | \n 39 | let C = class {\n> 40 | [1_2_3_4_5_6_7_8] = () => {\n | ^\n 41 | return 1_2_3_4_5_6_7_8;\n 42 | };\n 43 | ", "test/language/expressions/class/elements/class-name-static-initializer-default-export.js-strict:true": "test/language/expressions/class/elements/class-name-static-initializer-default-export.js: Test262Error: Expected SameValue(«class_name_static_initializer_default_export_default», «default») to be true ", "test/language/expressions/class/elements/private-getter-is-not-a-own-property.js-strict:true": "test/language/expressions/class/elements/private-getter-is-not-a-own-property.js: TypeError: Object has no member '__lookupGetter__' ", "test/language/expressions/class/elements/private-setter-is-not-a-own-property.js-strict:true": "test/language/expressions/class/elements/private-setter-is-not-a-own-property.js: TypeError: Object has no member '__lookupSetter__' ", - "test/language/expressions/optional-chaining/iteration-statement-for-await-of.js-strict:true": "test/language/expressions/optional-chaining/iteration-statement-for-await-of.js: test/language/expressions/optional-chaining/iteration-statement-for-await-of.js: Line 19:7 Unexpected token await (and 9 more errors)", + "test/language/expressions/object/cpn-obj-lit-computed-property-name-from-integer-separators.js-strict:true": "test/language/expressions/object/cpn-obj-lit-computed-property-name-from-integer-separators.js: SyntaxError: test/language/expressions/object/cpn-obj-lit-computed-property-name-from-integer-separators.js: Identifier directly after number (29:4)\n 27 | \n 28 | let o = {\n> 29 | [1_2_3_4_5_6_7_8]: 1_2_3_4_5_6_7_8\n | ^\n 30 | };\n 31 | \n 32 | assert.sameValue( ", + "test/language/expressions/optional-chaining/iteration-statement-for-await-of.js-strict:true": "test/language/expressions/optional-chaining/iteration-statement-for-await-of.js: SyntaxError: test/language/expressions/optional-chaining/iteration-statement-for-await-of.js: Unexpected token, expected ( (31:6)\n 29 | async function checkAssertions() {\n 30 | let count = 0;\n> 31 | for await (const num of obj?.iterable) {\n | ^\n 32 | count += num;\n 33 | }\n 34 | assert.sameValue(3, count); ", "test/language/expressions/optional-chaining/member-expression.js-strict:true": "test/language/expressions/optional-chaining/member-expression.js: SyntaxError: Async generators are not supported yet ", + "test/language/literals/numeric/non-octal-decimal-integer.js-strict:false": "test/language/literals/numeric/non-octal-decimal-integer.js: SyntaxError: test/language/literals/numeric/non-octal-decimal-integer.js: Invalid number (28:17)\n 26 | // NonOctalDecimalIntegerLiteral ::\n 27 | // 0 NonOctalDigit\n> 28 | assert.sameValue(08, 8, '08');\n | ^\n 29 | assert.sameValue(09, 9, '09');\n 30 | \n 31 | // NonOctalDecimalIntegerLiteral :: ", "test/language/literals/regexp/S7.8.5_A1.1_T2.js-strict:true": "test/language/literals/regexp/S7.8.5_A1.1_T2.js: Test262Error: Code unit: d800 Expected SameValue(«\\ud800», «�») to be true ", "test/language/literals/regexp/S7.8.5_A1.4_T2.js-strict:true": "test/language/literals/regexp/S7.8.5_A1.4_T2.js: Test262Error: Code unit: d800 Expected SameValue(«\\\\\\ud800», «\\�») to be true ", "test/language/literals/regexp/S7.8.5_A2.1_T2.js-strict:true": "test/language/literals/regexp/S7.8.5_A2.1_T2.js: Test262Error: Code unit: d800 Expected SameValue(«nnnn\\ud800», «nnnn�») to be true ", @@ -103,11 +109,9 @@ "test/language/module-code/instn-named-bndng-dflt-gen-anon.js-strict:true": "test/language/module-code/instn-named-bndng-dflt-gen-anon.js: Test262Error: correct name is assigned Expected SameValue(«instn_named_bndng_dflt_gen_anon_default», «default») to be true ", "test/language/module-code/instn-named-bndng-dflt-named.js-strict:true": "test/language/module-code/instn-named-bndng-dflt-named.js: Test262Error: Expected a ReferenceError to be thrown but no exception was thrown at all ", "test/language/module-code/instn-named-bndng-dflt-star.js-strict:true": "test/language/module-code/instn-named-bndng-dflt-star.js: Test262Error: Expected a ReferenceError to be thrown but no exception was thrown at all ", - "test/language/module-code/instn-named-bndng-fun.js-strict:true": "test/language/module-code/instn-named-bndng-fun.js: Test262Error: binding rejects assignment Expected a TypeError to be thrown but no exception was thrown at all ", - "test/language/module-code/instn-named-bndng-gen.js-strict:true": "test/language/module-code/instn-named-bndng-gen.js: Test262Error: binding rejects assignment Expected a TypeError to be thrown but no exception was thrown at all ", "test/language/module-code/instn-named-bndng-let.js-strict:true": "test/language/module-code/instn-named-bndng-let.js: Test262Error: binding is created but not initialized Expected a ReferenceError to be thrown but no exception was thrown at all ", - "test/language/module-code/instn-named-bndng-trlng-comma.js-strict:true": "test/language/module-code/instn-named-bndng-trlng-comma.js: Test262Error: binding rejects assignment Expected a TypeError to be thrown but no exception was thrown at all ", - "test/language/module-code/instn-named-bndng-var.js-strict:true": "test/language/module-code/instn-named-bndng-var.js: Test262Error: binding rejects assignment Expected a TypeError to be thrown but no exception was thrown at all ", + "test/language/module-code/instn-named-bndng-trlng-comma.js-strict:true": "test/language/module-code/instn-named-bndng-trlng-comma.js: Test262Error: binding is initialized to `undefined` prior to module evaulation Expected SameValue(«23», «undefined») to be true ", + "test/language/module-code/instn-named-bndng-var.js-strict:true": "test/language/module-code/instn-named-bndng-var.js: Test262Error: binding is initialized to `undefined` prior to module evaulation Expected SameValue(«23», «undefined») to be true ", "test/language/module-code/instn-named-err-ambiguous-as.js-strict:true": "test/language/module-code/instn-named-err-ambiguous-as.js: Expected error: ", "test/language/module-code/instn-named-err-ambiguous.js-strict:true": "test/language/module-code/instn-named-err-ambiguous.js: Expected error: ", "test/language/module-code/instn-named-err-dflt-thru-star-as.js-strict:true": "test/language/module-code/instn-named-err-dflt-thru-star-as.js: Expected error: ", @@ -129,9 +133,8 @@ "test/language/module-code/instn-star-iee-cycle.js-strict:true": "test/language/module-code/instn-star-iee-cycle.js: TypeError: Cannot read property 'b' of undefined ", "test/language/module-code/namespace/Symbol.toStringTag.js-strict:true": "test/language/module-code/namespace/Symbol.toStringTag.js: Test262Error: Expected SameValue(«undefined», «Module») to be true ", "test/language/module-code/namespace/internals/define-own-property.js-strict:true": "test/language/module-code/namespace/internals/define-own-property.js: Test262Error: Reflect.defineProperty: local2 Expected SameValue(«true», «false») to be true ", - "test/language/module-code/namespace/internals/delete-exported-init.js-strict:true": "test/language/module-code/namespace/internals/delete-exported-init.js: Test262Error: delete: local1 Expected a TypeError to be thrown but no exception was thrown at all ", - "test/language/module-code/namespace/internals/delete-exported-uninit.js-strict:true": "test/language/module-code/namespace/internals/delete-exported-uninit.js: Test262Error: delete: local1 Expected a TypeError to be thrown but no exception was thrown at all ", - "test/language/module-code/namespace/internals/delete-non-exported.js-strict:true": "test/language/module-code/namespace/internals/delete-non-exported.js: Test262Error: delete: default ", + "test/language/module-code/namespace/internals/delete-exported-uninit.js-strict:true": "test/language/module-code/namespace/internals/delete-exported-uninit.js: Test262Error: binding unmodified: default Expected a ReferenceError to be thrown but no exception was thrown at all ", + "test/language/module-code/namespace/internals/delete-non-exported.js-strict:true": "test/language/module-code/namespace/internals/delete-non-exported.js: TypeError: Cannot delete property 'default' of [object Object] ", "test/language/module-code/namespace/internals/enumerate-binding-uninit.js-strict:true": "test/language/module-code/namespace/internals/enumerate-binding-uninit.js: Test262Error: Expected a ReferenceError but got a Test262Error ", "test/language/module-code/namespace/internals/get-own-property-str-found-init.js-strict:true": "test/language/module-code/namespace/internals/get-own-property-str-found-init.js: Test262Error: Expected SameValue(«undefined», «201») to be true ", "test/language/module-code/namespace/internals/get-own-property-str-found-uninit.js-strict:true": "test/language/module-code/namespace/internals/get-own-property-str-found-uninit.js: Test262Error: hasOwnProperty: local1 Expected a ReferenceError to be thrown but no exception was thrown at all ", @@ -149,12 +152,16 @@ "test/language/module-code/namespace/internals/own-property-keys-binding-types.js-strict:true": "test/language/module-code/namespace/internals/own-property-keys-binding-types.js: Test262Error: Expected SameValue(«8», «10») to be true ", "test/language/module-code/namespace/internals/own-property-keys-sort.js-strict:true": "test/language/module-code/namespace/internals/own-property-keys-sort.js: Test262Error: Expected SameValue(«17», «16») to be true ", "test/language/module-code/namespace/internals/set-prototype-of.js-strict:true": "test/language/module-code/namespace/internals/set-prototype-of.js: Test262Error: Expected a TypeError to be thrown but no exception was thrown at all ", - "test/language/module-code/namespace/internals/set.js-strict:true": "test/language/module-code/namespace/internals/set.js: Test262Error: AssignmentExpression: local1 Expected a TypeError to be thrown but no exception was thrown at all ", + "test/language/module-code/namespace/internals/set.js-strict:true": "test/language/module-code/namespace/internals/set.js: Test262Error: Reflect.set: local2 Expected SameValue(«true», «false») to be true ", "test/language/module-code/parse-err-hoist-lex-fun.js-strict:true": "test/language/module-code/parse-err-hoist-lex-fun.js: error is not an object (Test262: This statement should not be evaluated.)", "test/language/module-code/parse-err-return.js-strict:true": "test/language/module-code/parse-err-return.js: error is not an object (Test262: This statement should not be evaluated.)", "test/language/reserved-words/await-module.js-strict:true": "test/language/reserved-words/await-module.js: error is not an object (Test262: This statement should not be evaluated.)", "test/language/statements/class/class-name-ident-await-escaped-module.js-strict:true": "test/language/statements/class/class-name-ident-await-escaped-module.js: error is not an object (Test262: This statement should not be evaluated.)", "test/language/statements/class/class-name-ident-await-module.js-strict:true": "test/language/statements/class/class-name-ident-await-module.js: error is not an object (Test262: This statement should not be evaluated.)", + "test/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-integer-separators.js-strict:true": "test/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-integer-separators.js: SyntaxError: test/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-integer-separators.js: Identifier directly after number (40:8)\n 38 | \n 39 | class C {\n> 40 | get [1_2_3_4_5_6_7_8]() {\n | ^\n 41 | return 1_2_3_4_5_6_7_8;\n 42 | }\n 43 | ", + "test/language/statements/class/cpn-class-decl-computed-property-name-from-integer-separators.js-strict:true": "test/language/statements/class/cpn-class-decl-computed-property-name-from-integer-separators.js: SyntaxError: test/language/statements/class/cpn-class-decl-computed-property-name-from-integer-separators.js: Identifier directly after number (40:4)\n 38 | \n 39 | class C {\n> 40 | [1_2_3_4_5_6_7_8]() {\n | ^\n 41 | return 1_2_3_4_5_6_7_8;\n 42 | }\n 43 | static [1_2_3_4_5_6_7_8]() { ", + "test/language/statements/class/cpn-class-decl-fields-computed-property-name-from-integer-separators.js-strict:true": "test/language/statements/class/cpn-class-decl-fields-computed-property-name-from-integer-separators.js: SyntaxError: test/language/statements/class/cpn-class-decl-fields-computed-property-name-from-integer-separators.js: Identifier directly after number (40:4)\n 38 | \n 39 | let C = class {\n> 40 | [1_2_3_4_5_6_7_8] = 1_2_3_4_5_6_7_8;\n | ^\n 41 | \n 42 | static [1_2_3_4_5_6_7_8] = 1_2_3_4_5_6_7_8;\n 43 | }; ", + "test/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-integer-separators.js-strict:true": "test/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-integer-separators.js: SyntaxError: test/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-integer-separators.js: Identifier directly after number (40:4)\n 38 | \n 39 | let C = class {\n> 40 | [1_2_3_4_5_6_7_8] = () => {\n | ^\n 41 | return 1_2_3_4_5_6_7_8;\n 42 | };\n 43 | ", "test/language/statements/class/elements/private-getter-is-not-a-own-property.js-strict:true": "test/language/statements/class/elements/private-getter-is-not-a-own-property.js: TypeError: Object has no member '__lookupGetter__' ", "test/language/statements/class/elements/private-setter-is-not-a-own-property.js-strict:true": "test/language/statements/class/elements/private-setter-is-not-a-own-property.js: TypeError: Object has no member '__lookupSetter__' ", "test/language/statements/labeled/value-await-module-escaped.js-strict:true": "test/language/statements/labeled/value-await-module-escaped.js: error is not an object (Test262: This statement should not be evaluated.)", diff --git a/js/tc39/tc39_test.go b/js/tc39/tc39_test.go index 4f334da9667..c44f2395874 100644 --- a/js/tc39/tc39_test.go +++ b/js/tc39/tc39_test.go @@ -22,8 +22,8 @@ import ( "testing" "time" - "github.com/dop251/goja/parser" "github.com/grafana/sobek" + "github.com/grafana/sobek/parser" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.k6.io/k6/js/compiler" @@ -60,7 +60,7 @@ var ( "top-level-await", // not supported at all "String.prototype.replaceAll", // not supported at all, Stage 4 since 2020 - // from goja + // from Sobek "Symbol.asyncIterator", "regexp-named-groups", "regexp-dotall", @@ -412,11 +412,10 @@ func (ctx *tc39TestCtx) runTC39Test(t testing.TB, name, src string, meta *tc39Me _ = vm.Set("print", t.Log) } var early bool - var origErr error if meta.hasFlag("module") { - early, origErr, err = ctx.runTC39Module(name, src, meta.Includes, vm) + early, err = ctx.runTC39Module(name, src, meta.Includes, vm) } else { - early, origErr, err = ctx.runTC39Script(name, src, meta.Includes, vm, meta.Negative.Type != "") + early, err = ctx.runTC39Script(name, src, meta.Includes, vm, meta.Negative.Type != "") } if err == nil { @@ -447,9 +446,6 @@ func (ctx *tc39TestCtx) runTC39Test(t testing.TB, name, src string, meta *tc39Me errType := getErrType(name, err, failf) if errType != "" && errType != meta.Negative.Type { - if meta.Negative.Type == "SyntaxError" && origErr != nil && getErrType(name, origErr, failf) == meta.Negative.Type { - return - } // vm.vm.prg.dumpCode(t.Logf) failf("%s: unexpected error type (%s), expected (%s)", name, errType, meta.Negative.Type) return @@ -607,11 +603,7 @@ func (ctx *tc39TestCtx) compile(base, name string) (*sobek.Program, error) { return nil, err } - str := string(b) - comp := ctx.compilerPool.Get() - defer ctx.compilerPool.Put(comp) - comp.Options = compiler.Options{Strict: false, CompatibilityMode: ctx.compatibilityMode} - prg, _, err = comp.Compile(str, name, true) + prg, err = ctx.compileOnly(string(b), name, ctx.compatibilityMode) if err != nil { return nil, err } @@ -630,83 +622,82 @@ func (ctx *tc39TestCtx) runFile(base, name string, vm *sobek.Runtime) error { return err } -func (ctx *tc39TestCtx) runTC39Script(name, src string, includes []string, vm *sobek.Runtime, expectsError bool) (early bool, origErr, err error) { +func (ctx *tc39TestCtx) compileOnly(src, name string, compatibilityMode lib.CompatibilityMode) (*sobek.Program, error) { + comp := ctx.compilerPool.Get() + defer ctx.compilerPool.Put(comp) + comp.Options = compiler.Options{Strict: false, CompatibilityMode: compatibilityMode} + astProgram, _, err := comp.Parse(src, name, false) + if err != nil { + return nil, err + } + return sobek.CompileAST(astProgram, false) +} + +func (ctx *tc39TestCtx) runTC39Script(name, src string, includes []string, vm *sobek.Runtime, expectsError bool) (early bool, err error) { early = true err = ctx.runFile(ctx.base, path.Join("harness", "assert.js"), vm) if err != nil { - return early, origErr, err + return early, err } err = ctx.runFile(ctx.base, path.Join("harness", "sta.js"), vm) if err != nil { - return early, origErr, err + return early, err } for _, include := range includes { err = ctx.runFile(ctx.base, path.Join("harness", include), vm) if err != nil { - return early, origErr, err + return early, err } } - var p *sobek.Program - comp := ctx.compilerPool.Get() - defer ctx.compilerPool.Put(comp) - comp.Options = compiler.Options{Strict: false, CompatibilityMode: lib.CompatibilityModeBase} - p, _, err = comp.Compile(src, name, true) - origErr = err + p, err := ctx.compileOnly(src, name, lib.CompatibilityModeBase) if err != nil && !expectsError { - comp.Options.CompatibilityMode = ctx.compatibilityMode - p, _, err = comp.Compile(src, name, true) + p, err = ctx.compileOnly(src, name, lib.CompatibilityModeExtended) } - if err != nil { - return early, origErr, err + return early, err } early = false _, err = vm.RunProgram(p) - return early, origErr, err + return early, err } -func (ctx *tc39TestCtx) runTC39Module(name, src string, includes []string, vm *sobek.Runtime) (early bool, origErr, err error) { - currentFS := os.DirFS(".") - if err != nil { - panic(err) - } +func (ctx *tc39TestCtx) runTC39Module(name, src string, includes []string, vm *sobek.Runtime) (early bool, err error) { moduleRuntime := modulestest.NewRuntime(ctx.t) moduleRuntime.VU.RuntimeField = vm early = true err = ctx.runFile(ctx.base, path.Join("harness", "assert.js"), vm) if err != nil { - return early, origErr, err + return early, err } err = ctx.runFile(ctx.base, path.Join("harness", "sta.js"), vm) if err != nil { - return early, origErr, err + return early, err } for _, include := range includes { err = ctx.runFile(ctx.base, path.Join("harness", include), vm) if err != nil { - return early, origErr, err + return early, err } } comp := ctx.compilerPool.Get() defer ctx.compilerPool.Put(comp) comp.Options = compiler.Options{Strict: false, CompatibilityMode: ctx.compatibilityMode} - + u := &url.URL{Scheme: "file", Path: path.Join(ctx.base, name)} + base := u.JoinPath("..") mr := modules.NewModuleResolver(nil, func(specifier *url.URL, _ string) ([]byte, error) { - return fs.ReadFile(currentFS, specifier.Path[1:]) + return fs.ReadFile(os.DirFS("."), specifier.Path[1:]) }, comp) - u := &url.URL{Scheme: "file", Path: path.Join(ctx.base, name)} - base := u.JoinPath("..") ms := modules.NewModuleSystem(mr, moduleRuntime.VU) impl := modules.NewLegacyRequireImpl(moduleRuntime.VU, ms, *base) require.NoError(ctx.t, vm.Set("require", impl.Require)) @@ -718,7 +709,7 @@ func (ctx *tc39TestCtx) runTC39Module(name, src string, includes []string, vm *s URL: u, }) - return early, origErr, err + return early, err } func (ctx *tc39TestCtx) runTC39Tests(name string) { diff --git a/lib/netext/grpcext/conn.go b/lib/netext/grpcext/conn.go index 89fdcba763f..386a6a110ba 100644 --- a/lib/netext/grpcext/conn.go +++ b/lib/netext/grpcext/conn.go @@ -73,6 +73,7 @@ func DefaultOptions(getState func() *lib.State) []grpc.DialOption { return getState().Dialer.DialContext(ctx, "tcp", addr) } + //nolint:staticcheck // see https://github.com/grafana/k6/issues/3699 return []grpc.DialOption{ grpc.WithBlock(), grpc.FailOnNonTempDialError(true), @@ -84,6 +85,7 @@ func DefaultOptions(getState func() *lib.State) []grpc.DialOption { // Dial establish a gRPC connection. func Dial(ctx context.Context, addr string, options ...grpc.DialOption) (*Conn, error) { + //nolint:staticcheck // see https://github.com/grafana/k6/issues/3699 conn, err := grpc.DialContext(ctx, addr, options...) if err != nil { return nil, err @@ -151,7 +153,7 @@ func (c *Conn) Invoke( sterr := status.Convert(err) response.Status = sterr.Code() - // (rogchap) when you access a JSON property in goja, you are actually accessing the underling + // (rogchap) when you access a JSON property in Sobek, you are actually accessing the underling // Go type (struct, map, slice etc); because these are dynamic messages the Unmarshaled JSON does // not map back to a "real" field or value (as a normal Go type would). If we don't marshal and then // unmarshal back to a map, you will get "undefined" when accessing JSON properties, even when diff --git a/lib/netext/httpext/compression.go b/lib/netext/httpext/compression.go index 6716fb4ad5e..2268659efca 100644 --- a/lib/netext/httpext/compression.go +++ b/lib/netext/httpext/compression.go @@ -182,7 +182,7 @@ func readResponseBody( // Copy the data to a new slice before we return the buffer to the pool, // because buf.Bytes() points to the underlying buffer byte slice. // The ArrayBuffer wrapping will be done in the js/modules/k6/http - // package to avoid a reverse dependency, since it depends on goja. + // package to avoid a reverse dependency, since it depends on Sobek. binData := make([]byte, buf.Len()) copy(binData, buf.Bytes()) result = binData diff --git a/lib/runtime_options.go b/lib/runtime_options.go index d7f95b0bebd..cda7ccc7727 100644 --- a/lib/runtime_options.go +++ b/lib/runtime_options.go @@ -15,13 +15,13 @@ type CompatibilityMode uint8 const ( // CompatibilityModeExtended achieves ES6+ compatibility with Babel CompatibilityModeExtended CompatibilityMode = iota + 1 - // CompatibilityModeBase is standard goja ES5.1+ + // CompatibilityModeBase is standard Sobek ES5.1+ CompatibilityModeBase // CompatibilityModeExperimentalEnhanced achieves TypeScript and ES6+ compatibility with esbuild CompatibilityModeExperimentalEnhanced ) -// RuntimeOptions are settings passed onto the goja JS runtime +// RuntimeOptions are settings passed onto the Sobek JS runtime type RuntimeOptions struct { TestType null.String `json:"-"` diff --git a/vendor/github.com/PuerkitoBio/goquery/README.md b/vendor/github.com/PuerkitoBio/goquery/README.md index 96a8d48be06..767a0e11131 100644 --- a/vendor/github.com/PuerkitoBio/goquery/README.md +++ b/vendor/github.com/PuerkitoBio/goquery/README.md @@ -40,6 +40,7 @@ Please note that starting with version `v1.9.0` of goquery, Go 1.18+ is required **Note that goquery's API is now stable, and will not break.** +* **2024-04-29 (v1.9.2)** : Update `go.mod` dependencies. * **2024-02-29 (v1.9.1)** : Improve allocation and performance of the `Map` function and `Selection.Map` method, better document the cascadia differences (thanks [@jwilsson](https://github.com/jwilsson)). * **2024-02-22 (v1.9.0)** : Add a generic `Map` function, **goquery now requires Go version 1.18+** (thanks [@Fesaa](https://github.com/Fesaa)). * **2023-02-18 (v1.8.1)** : Update `go.mod` dependencies, update CI workflow. diff --git a/vendor/github.com/bufbuild/protocompile/.protoc_version b/vendor/github.com/bufbuild/protocompile/.protoc_version index a4194455377..facd73a3322 100644 --- a/vendor/github.com/bufbuild/protocompile/.protoc_version +++ b/vendor/github.com/bufbuild/protocompile/.protoc_version @@ -1 +1 @@ -25.0-rc2 +26.0 diff --git a/vendor/github.com/bufbuild/protocompile/LICENSE b/vendor/github.com/bufbuild/protocompile/LICENSE index 04cf1e316a6..553cbbf1b3a 100644 --- a/vendor/github.com/bufbuild/protocompile/LICENSE +++ b/vendor/github.com/bufbuild/protocompile/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2020-2022 Buf Technologies, Inc. + Copyright 2020-2024 Buf Technologies, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/vendor/github.com/bufbuild/protocompile/ast/doc.go b/vendor/github.com/bufbuild/protocompile/ast/doc.go index 801754df429..cda4068c414 100644 --- a/vendor/github.com/bufbuild/protocompile/ast/doc.go +++ b/vendor/github.com/bufbuild/protocompile/ast/doc.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/github.com/bufbuild/protocompile/ast/enum.go b/vendor/github.com/bufbuild/protocompile/ast/enum.go index 7f79161c432..1afd090576f 100644 --- a/vendor/github.com/bufbuild/protocompile/ast/enum.go +++ b/vendor/github.com/bufbuild/protocompile/ast/enum.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -76,6 +76,16 @@ func NewEnumNode(keyword *KeywordNode, name *IdentNode, openBrace *RuneNode, dec } } +func (n *EnumNode) RangeOptions(fn func(*OptionNode) bool) { + for _, decl := range n.Decls { + if opt, ok := decl.(*OptionNode); ok { + if !fn(opt) { + return + } + } + } +} + // EnumElement is an interface implemented by all AST nodes that can // appear in the body of an enum declaration. type EnumElement interface { @@ -92,7 +102,7 @@ var _ EnumElement = (*EmptyDeclNode)(nil) // enum values. This allows NoSourceNode to be used in place of *EnumValueNode // for some usages. type EnumValueDeclNode interface { - Node + NodeWithOptions GetName() Node GetNumber() Node } @@ -165,3 +175,11 @@ func (e *EnumValueNode) GetName() Node { func (e *EnumValueNode) GetNumber() Node { return e.Number } + +func (e *EnumValueNode) RangeOptions(fn func(*OptionNode) bool) { + for _, opt := range e.Options.Options { + if !fn(opt) { + return + } + } +} diff --git a/vendor/github.com/bufbuild/protocompile/ast/field.go b/vendor/github.com/bufbuild/protocompile/ast/field.go index 9a8063ffc31..f08a92c576e 100644 --- a/vendor/github.com/bufbuild/protocompile/ast/field.go +++ b/vendor/github.com/bufbuild/protocompile/ast/field.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ import "fmt" // This also allows NoSourceNode and SyntheticMapField to be used in place of // one of the above for some usages. type FieldDeclNode interface { - Node + NodeWithOptions FieldLabel() Node FieldName() Node FieldType() Node @@ -84,13 +84,13 @@ func NewFieldNode(label *KeywordNode, fieldType IdentValueNode, name *IdentNode, if name == nil { panic("name is nil") } - if equals == nil { - panic("equals is nil") + numChildren := 2 + if equals != nil { + numChildren++ } - if tag == nil { - panic("tag is nil") + if tag != nil { + numChildren++ } - numChildren := 4 if semicolon != nil { numChildren++ } @@ -104,7 +104,13 @@ func NewFieldNode(label *KeywordNode, fieldType IdentValueNode, name *IdentNode, if label != nil { children = append(children, label) } - children = append(children, fieldType, name, equals, tag) + children = append(children, fieldType, name) + if equals != nil { + children = append(children, equals) + } + if tag != nil { + children = append(children, tag) + } if opts != nil { children = append(children, opts) } @@ -145,6 +151,9 @@ func (n *FieldNode) FieldType() Node { } func (n *FieldNode) FieldTag() Node { + if n.Tag == nil { + return n + } return n.Tag } @@ -163,6 +172,14 @@ func (n *FieldNode) GetOptions() *CompactOptionsNode { return n.Options } +func (n *FieldNode) RangeOptions(fn func(*OptionNode) bool) { + for _, opt := range n.Options.Options { + if !fn(opt) { + return + } + } +} + // FieldLabel represents the label of a field, which indicates its cardinality // (i.e. whether it is optional, required, or repeated). type FieldLabel struct { @@ -237,22 +254,22 @@ func NewGroupNode(label *KeywordNode, keyword *KeywordNode, name *IdentNode, equ if name == nil { panic("name is nil") } - if equals == nil { - panic("equals is nil") - } - if tag == nil { - panic("tag is nil") - } if openBrace == nil { panic("openBrace is nil") } if closeBrace == nil { panic("closeBrace is nil") } - numChildren := 6 + len(decls) + numChildren := 4 + len(decls) if label != nil { numChildren++ } + if equals != nil { + numChildren++ + } + if tag != nil { + numChildren++ + } if opts != nil { numChildren++ } @@ -260,7 +277,13 @@ func NewGroupNode(label *KeywordNode, keyword *KeywordNode, name *IdentNode, equ if label != nil { children = append(children, label) } - children = append(children, keyword, name, equals, tag) + children = append(children, keyword, name) + if equals != nil { + children = append(children, equals) + } + if tag != nil { + children = append(children, tag) + } if opts != nil { children = append(children, opts) } @@ -302,6 +325,9 @@ func (n *GroupNode) FieldType() Node { } func (n *GroupNode) FieldTag() Node { + if n.Tag == nil { + return n + } return n.Tag } @@ -320,10 +346,40 @@ func (n *GroupNode) GetOptions() *CompactOptionsNode { return n.Options } -func (n *GroupNode) MessageName() Node { +func (n *GroupNode) RangeOptions(fn func(*OptionNode) bool) { + for _, opt := range n.Options.Options { + if !fn(opt) { + return + } + } +} + +func (n *GroupNode) AsMessage() *SyntheticGroupMessageNode { + return (*SyntheticGroupMessageNode)(n) +} + +// SyntheticGroupMessageNode is a view of a GroupNode that implements MessageDeclNode. +// Since a group field implicitly defines a message type, this node represents +// that message type while the corresponding GroupNode represents the field. +// +// This type is considered synthetic since it never appears in a file's AST, but +// is only returned from other accessors (e.g. GroupNode.AsMessage). +type SyntheticGroupMessageNode GroupNode + +func (n *SyntheticGroupMessageNode) MessageName() Node { return n.Name } +func (n *SyntheticGroupMessageNode) RangeOptions(fn func(*OptionNode) bool) { + for _, decl := range n.Decls { + if opt, ok := decl.(*OptionNode); ok { + if !fn(opt) { + return + } + } + } +} + // OneofDeclNode is a node in the AST that defines a oneof. There are // multiple types of AST nodes that declare oneofs: // - *OneofNode @@ -332,10 +388,14 @@ func (n *GroupNode) MessageName() Node { // This also allows NoSourceNode to be used in place of one of the above // for some usages. type OneofDeclNode interface { - Node + NodeWithOptions OneofName() Node } +var _ OneofDeclNode = (*OneofNode)(nil) +var _ OneofDeclNode = (*SyntheticOneof)(nil) +var _ OneofDeclNode = NoSourceNode{} + // OneofNode represents a one-of declaration. Example: // // oneof query { @@ -407,6 +467,16 @@ func (n *OneofNode) OneofName() Node { return n.Name } +func (n *OneofNode) RangeOptions(fn func(*OptionNode) bool) { + for _, decl := range n.Decls { + if opt, ok := decl.(*OptionNode); ok { + if !fn(opt) { + return + } + } + } +} + // OneofElement is an interface implemented by all AST nodes that can // appear in the body of a oneof declaration. type OneofElement interface { @@ -421,7 +491,11 @@ var _ OneofElement = (*EmptyDeclNode)(nil) // SyntheticOneof is not an actual node in the AST but a synthetic node // that represents the oneof implied by a proto3 optional field. +// +// This type is considered synthetic since it never appears in a file's AST, +// but is only returned from other functions (e.g. NewSyntheticOneof). type SyntheticOneof struct { + // The proto3 optional field that implies the presence of this oneof. Field *FieldNode } @@ -453,6 +527,9 @@ func (n *SyntheticOneof) OneofName() Node { return n.Field.FieldName() } +func (n *SyntheticOneof) RangeOptions(_ func(*OptionNode) bool) { +} + // MapTypeNode represents the type declaration for a map field. It defines // both the key and value types for the map. Example: // @@ -537,13 +614,13 @@ func NewMapFieldNode(mapType *MapTypeNode, name *IdentNode, equals *RuneNode, ta if name == nil { panic("name is nil") } - if equals == nil { - panic("equals is nil") + numChildren := 2 + if equals != nil { + numChildren++ } - if tag == nil { - panic("tag is nil") + if tag != nil { + numChildren++ } - numChildren := 4 if opts != nil { numChildren++ } @@ -551,7 +628,13 @@ func NewMapFieldNode(mapType *MapTypeNode, name *IdentNode, equals *RuneNode, ta numChildren++ } children := make([]Node, 0, numChildren) - children = append(children, mapType, name, equals, tag) + children = append(children, mapType, name) + if equals != nil { + children = append(children, equals) + } + if tag != nil { + children = append(children, tag) + } if opts != nil { children = append(children, opts) } @@ -585,6 +668,9 @@ func (n *MapFieldNode) FieldType() Node { } func (n *MapFieldNode) FieldTag() Node { + if n.Tag == nil { + return n + } return n.Tag } @@ -600,8 +686,16 @@ func (n *MapFieldNode) GetOptions() *CompactOptionsNode { return n.Options } -func (n *MapFieldNode) MessageName() Node { - return n.Name +func (n *MapFieldNode) RangeOptions(fn func(*OptionNode) bool) { + for _, opt := range n.Options.Options { + if !fn(opt) { + return + } + } +} + +func (n *MapFieldNode) AsMessage() *SyntheticMapEntryNode { + return (*SyntheticMapEntryNode)(n) } func (n *MapFieldNode) KeyField() *SyntheticMapField { @@ -612,9 +706,28 @@ func (n *MapFieldNode) ValueField() *SyntheticMapField { return NewSyntheticMapField(n.MapType.ValueType, 2) } +// SyntheticMapEntryNode is a view of a MapFieldNode that implements MessageDeclNode. +// Since a map field implicitly defines a message type for the map entry, +// this node represents that message type. +// +// This type is considered synthetic since it never appears in a file's AST, but +// is only returned from other accessors (e.g. MapFieldNode.AsMessage). +type SyntheticMapEntryNode MapFieldNode + +func (n *SyntheticMapEntryNode) MessageName() Node { + return n.Name +} + +func (n *SyntheticMapEntryNode) RangeOptions(_ func(*OptionNode) bool) { +} + // SyntheticMapField is not an actual node in the AST but a synthetic node // that implements FieldDeclNode. These are used to represent the implicit // field declarations of the "key" and "value" fields in a map entry. +// +// This type is considered synthetic since it never appears in a file's AST, +// but is only returned from other accessors and functions (e.g. +// MapFieldNode.KeyField, MapFieldNode.ValueField, and NewSyntheticMapField). type SyntheticMapField struct { Ident IdentValueNode Tag *UintLiteralNode @@ -660,6 +773,9 @@ func (n *SyntheticMapField) FieldType() Node { } func (n *SyntheticMapField) FieldTag() Node { + if n.Tag == nil { + return n + } return n.Tag } @@ -674,3 +790,6 @@ func (n *SyntheticMapField) GetGroupKeyword() Node { func (n *SyntheticMapField) GetOptions() *CompactOptionsNode { return nil } + +func (n *SyntheticMapField) RangeOptions(_ func(*OptionNode) bool) { +} diff --git a/vendor/github.com/bufbuild/protocompile/ast/file.go b/vendor/github.com/bufbuild/protocompile/ast/file.go index 9c00a643e7a..8e94234fb47 100644 --- a/vendor/github.com/bufbuild/protocompile/ast/file.go +++ b/vendor/github.com/bufbuild/protocompile/ast/file.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ import "fmt" // FileDeclNode is a placeholder interface for AST nodes that represent files. // This allows NoSourceNode to be used in place of *FileNode for some usages. type FileDeclNode interface { - Node + NodeWithOptions Name() string NodeInfo(n Node) NodeInfo } @@ -136,6 +136,16 @@ func (f *FileNode) Tokens() Sequence[Token] { return f.fileInfo.Tokens() } +func (f *FileNode) RangeOptions(fn func(*OptionNode) bool) { + for _, decl := range f.Decls { + if opt, ok := decl.(*OptionNode); ok { + if !fn(opt) { + return + } + } + } +} + // FileElement is an interface implemented by all AST nodes that are // allowed as top-level declarations in the file. type FileElement interface { diff --git a/vendor/github.com/bufbuild/protocompile/ast/file_info.go b/vendor/github.com/bufbuild/protocompile/ast/file_info.go index 1a6b6b5a190..7c2d90497f3 100644 --- a/vendor/github.com/bufbuild/protocompile/ast/file_info.go +++ b/vendor/github.com/bufbuild/protocompile/ast/file_info.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/github.com/bufbuild/protocompile/ast/identifiers.go b/vendor/github.com/bufbuild/protocompile/ast/identifiers.go index 238a7b6f06e..511389d78c8 100644 --- a/vendor/github.com/bufbuild/protocompile/ast/identifiers.go +++ b/vendor/github.com/bufbuild/protocompile/ast/identifiers.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/github.com/bufbuild/protocompile/ast/message.go b/vendor/github.com/bufbuild/protocompile/ast/message.go index 92c410e1880..4d21af11dae 100644 --- a/vendor/github.com/bufbuild/protocompile/ast/message.go +++ b/vendor/github.com/bufbuild/protocompile/ast/message.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -19,19 +19,19 @@ import "fmt" // MessageDeclNode is a node in the AST that defines a message type. This // includes normal message fields as well as implicit messages: // - *MessageNode -// - *GroupNode (the group is a field and inline message type) -// - *MapFieldNode (map fields implicitly define a MapEntry message type) +// - *SyntheticGroupMessageNode (the group is a field and inline message type) +// - *SyntheticMapEntryNode (map fields implicitly define a MapEntry message type) // // This also allows NoSourceNode to be used in place of one of the above // for some usages. type MessageDeclNode interface { - Node + NodeWithOptions MessageName() Node } var _ MessageDeclNode = (*MessageNode)(nil) -var _ MessageDeclNode = (*GroupNode)(nil) -var _ MessageDeclNode = (*MapFieldNode)(nil) +var _ MessageDeclNode = (*SyntheticGroupMessageNode)(nil) +var _ MessageDeclNode = (*SyntheticMapEntryNode)(nil) var _ MessageDeclNode = NoSourceNode{} // MessageNode represents a message declaration. Example: @@ -92,6 +92,16 @@ func (n *MessageNode) MessageName() Node { return n.Name } +func (n *MessageNode) RangeOptions(fn func(*OptionNode) bool) { + for _, decl := range n.Decls { + if opt, ok := decl.(*OptionNode); ok { + if !fn(opt) { + return + } + } + } +} + // MessageBody represents the body of a message. It is used by both // MessageNodes and GroupNodes. type MessageBody struct { diff --git a/vendor/github.com/bufbuild/protocompile/ast/no_source.go b/vendor/github.com/bufbuild/protocompile/ast/no_source.go index dfe3c726f07..8b16091114f 100644 --- a/vendor/github.com/bufbuild/protocompile/ast/no_source.go +++ b/vendor/github.com/bufbuild/protocompile/ast/no_source.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -124,6 +124,10 @@ func (n NoSourceNode) MessageName() Node { return n } +func (n NoSourceNode) OneofName() Node { + return n +} + func (n NoSourceNode) GetInputType() Node { return n } @@ -135,3 +139,6 @@ func (n NoSourceNode) GetOutputType() Node { func (n NoSourceNode) Value() interface{} { return nil } + +func (n NoSourceNode) RangeOptions(func(*OptionNode) bool) { +} diff --git a/vendor/github.com/bufbuild/protocompile/ast/node.go b/vendor/github.com/bufbuild/protocompile/ast/node.go index 7a1b4c868af..abb76430965 100644 --- a/vendor/github.com/bufbuild/protocompile/ast/node.go +++ b/vendor/github.com/bufbuild/protocompile/ast/node.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/github.com/bufbuild/protocompile/ast/options.go b/vendor/github.com/bufbuild/protocompile/ast/options.go index 2bf35537e79..224c8704264 100644 --- a/vendor/github.com/bufbuild/protocompile/ast/options.go +++ b/vendor/github.com/bufbuild/protocompile/ast/options.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -43,12 +43,12 @@ type OptionNode struct { Semicolon *RuneNode // absent for compact options } -func (n *OptionNode) fileElement() {} -func (n *OptionNode) msgElement() {} -func (n *OptionNode) oneofElement() {} -func (n *OptionNode) enumElement() {} -func (n *OptionNode) serviceElement() {} -func (n *OptionNode) methodElement() {} +func (*OptionNode) fileElement() {} +func (*OptionNode) msgElement() {} +func (*OptionNode) oneofElement() {} +func (*OptionNode) enumElement() {} +func (*OptionNode) serviceElement() {} +func (*OptionNode) methodElement() {} // NewOptionNode creates a new *OptionNode for a full option declaration (as // used in files, messages, oneofs, enums, services, and methods). All arguments @@ -393,3 +393,21 @@ func (e *CompactOptionsNode) GetElements() []*OptionNode { } return e.Options } + +// NodeWithOptions represents a node in the AST that contains +// option statements. +type NodeWithOptions interface { + Node + RangeOptions(func(*OptionNode) bool) +} + +var _ NodeWithOptions = FileDeclNode(nil) +var _ NodeWithOptions = MessageDeclNode(nil) +var _ NodeWithOptions = OneofDeclNode(nil) +var _ NodeWithOptions = (*EnumNode)(nil) +var _ NodeWithOptions = (*ServiceNode)(nil) +var _ NodeWithOptions = RPCDeclNode(nil) +var _ NodeWithOptions = FieldDeclNode(nil) +var _ NodeWithOptions = EnumValueDeclNode(nil) +var _ NodeWithOptions = (*ExtensionRangeNode)(nil) +var _ NodeWithOptions = NoSourceNode{} diff --git a/vendor/github.com/bufbuild/protocompile/ast/ranges.go b/vendor/github.com/bufbuild/protocompile/ast/ranges.go index fe05d0816ea..7e46758935b 100644 --- a/vendor/github.com/bufbuild/protocompile/ast/ranges.go +++ b/vendor/github.com/bufbuild/protocompile/ast/ranges.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ type ExtensionRangeNode struct { Semicolon *RuneNode } -func (e *ExtensionRangeNode) msgElement() {} +func (*ExtensionRangeNode) msgElement() {} // NewExtensionRangeNode creates a new *ExtensionRangeNode. All args must be // non-nil except opts, which may be nil. @@ -90,6 +90,14 @@ func NewExtensionRangeNode(keyword *KeywordNode, ranges []*RangeNode, commas []* } } +func (e *ExtensionRangeNode) RangeOptions(fn func(*OptionNode) bool) { + for _, opt := range e.Options.Options { + if !fn(opt) { + return + } + } +} + // RangeDeclNode is a placeholder interface for AST nodes that represent // numeric values. This allows NoSourceNode to be used in place of *RangeNode // for some usages. diff --git a/vendor/github.com/bufbuild/protocompile/ast/service.go b/vendor/github.com/bufbuild/protocompile/ast/service.go index ca3e1ebbec3..9a17f93e773 100644 --- a/vendor/github.com/bufbuild/protocompile/ast/service.go +++ b/vendor/github.com/bufbuild/protocompile/ast/service.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -76,6 +76,16 @@ func NewServiceNode(keyword *KeywordNode, name *IdentNode, openBrace *RuneNode, } } +func (n *ServiceNode) RangeOptions(fn func(*OptionNode) bool) { + for _, decl := range n.Decls { + if opt, ok := decl.(*OptionNode); ok { + if !fn(opt) { + return + } + } + } +} + // ServiceElement is an interface implemented by all AST nodes that can // appear in the body of a service declaration. type ServiceElement interface { @@ -91,7 +101,7 @@ var _ ServiceElement = (*EmptyDeclNode)(nil) // declarations. This allows NoSourceNode to be used in place of *RPCNode // for some usages. type RPCDeclNode interface { - Node + NodeWithOptions GetName() Node GetInputType() Node GetOutputType() Node @@ -231,6 +241,16 @@ func (n *RPCNode) GetOutputType() Node { return n.Output.MessageType } +func (n *RPCNode) RangeOptions(fn func(*OptionNode) bool) { + for _, decl := range n.Decls { + if opt, ok := decl.(*OptionNode); ok { + if !fn(opt) { + return + } + } + } +} + // RPCElement is an interface implemented by all AST nodes that can // appear in the body of an rpc declaration (aka method). type RPCElement interface { diff --git a/vendor/github.com/bufbuild/protocompile/ast/values.go b/vendor/github.com/bufbuild/protocompile/ast/values.go index 2cbcc68616e..4ca79eb53fd 100644 --- a/vendor/github.com/bufbuild/protocompile/ast/values.go +++ b/vendor/github.com/bufbuild/protocompile/ast/values.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/github.com/bufbuild/protocompile/ast/walk.go b/vendor/github.com/bufbuild/protocompile/ast/walk.go index cfbf88e12f7..29125b84b19 100644 --- a/vendor/github.com/bufbuild/protocompile/ast/walk.go +++ b/vendor/github.com/bufbuild/protocompile/ast/walk.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -255,6 +255,13 @@ func VisitChildren(n CompositeNode, v Visitor) error { // // Visitors can be supplied to a Walk operation or passed to a call // to Visit or VisitChildren. +// +// Note that there are some AST node types defined in this package +// that do not have corresponding visit methods. These are synthetic +// node types, that have specialized use from the parser, but never +// appear in an actual AST (which is always rooted at FileNode). +// These include SyntheticMapField, SyntheticOneof, +// SyntheticGroupMessageNode, and SyntheticMapEntryNode. type Visitor interface { // VisitFileNode is invoked when visiting a *FileNode in the AST. VisitFileNode(*FileNode) error diff --git a/vendor/github.com/bufbuild/protocompile/compiler.go b/vendor/github.com/bufbuild/protocompile/compiler.go index 70c9327f893..b95f733ec63 100644 --- a/vendor/github.com/bufbuild/protocompile/compiler.go +++ b/vendor/github.com/bufbuild/protocompile/compiler.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -585,7 +585,7 @@ func (t *task) link(parseRes parser.Result, deps linker.Files, overrideDescripto return nil, err } // now that options are interpreted, we can do some additional checks - if err := file.ValidateOptions(t.h); err != nil { + if err := file.ValidateOptions(t.h, t.e.sym); err != nil { return nil, err } if t.r.explicitFile { diff --git a/vendor/github.com/bufbuild/protocompile/doc.go b/vendor/github.com/bufbuild/protocompile/doc.go index 5629fce87f2..40067b309f0 100644 --- a/vendor/github.com/bufbuild/protocompile/doc.go +++ b/vendor/github.com/bufbuild/protocompile/doc.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/github.com/bufbuild/protocompile/go.work b/vendor/github.com/bufbuild/protocompile/go.work index 66a7c7f2ac3..48dfa6f8ed2 100644 --- a/vendor/github.com/bufbuild/protocompile/go.work +++ b/vendor/github.com/bufbuild/protocompile/go.work @@ -1,4 +1,4 @@ -go 1.19 +go 1.20 use ( . diff --git a/vendor/github.com/bufbuild/protocompile/go.work.sum b/vendor/github.com/bufbuild/protocompile/go.work.sum index fc9921e3829..eb88ec6984e 100644 --- a/vendor/github.com/bufbuild/protocompile/go.work.sum +++ b/vendor/github.com/bufbuild/protocompile/go.work.sum @@ -1,3 +1,4 @@ +cloud.google.com/go v0.26.0 h1:e0WKqKTd5BnrG8aKH3J3h+QvEIQtSUcf2n5UZ5ZgLtQ= cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= @@ -15,21 +16,29 @@ cloud.google.com/go/compute v1.3.0/go.mod h1:cCZiE1NHEtai4wiufUhW8I8S1JKkAnhnQJW cloud.google.com/go/compute v1.5.0/go.mod h1:9SMHyhJlzhlkJqrPAc839t2BZFTSk6Jdj6mkzQJeu0M= cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz/FMzPu0s= cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/bufbuild/protocompile v0.2.1-0.20230123224550-da57cd758c2f/go.mod h1:tleDrpPTlLUVmgnEoN6qBliKWqJaZFJXqZdFjTd+ocU= +github.com/census-instrumentation/opencensus-proto v0.2.1 h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403 h1:cqQfy1jclcSy/FwLjemeg3SR1yaINm74aQyupQ0Bl8M= github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d h1:QyzYnTnPE15SQyUeqU6qLbWxMkwyAyu+vGksa0b7j00= github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= +github.com/envoyproxy/protoc-gen-validate v0.1.0 h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= +github.com/golang/mock v1.1.1 h1:G5FRp8JnTd7RQH5kemVNlMeyXQAztQ3mOWV95KxsXH8= github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= @@ -42,6 +51,7 @@ github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= @@ -49,18 +59,28 @@ github.com/googleapis/gax-go/v2 v2.2.0/go.mod h1:as02EH8zWkzwUoLbBaFeQ+arQaj/Oth github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99EXz9pXxye9YM= github.com/googleapis/gax-go/v2 v2.4.0/go.mod h1:XOTVJ59hdnfJLIP/dh8n5CGryZR2LxK9wbMD5+iXC6c= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/jhump/gopoet v0.1.0 h1:gYjOPnzHd2nzB37xYQZxj4EIQNpBrBskRqQQ3q4ZgSg= +github.com/jhump/goprotoc v0.5.0 h1:Y1UgUX+txUznfqcGdDef8ZOVlyQvnV0pKWZH08RmZuo= github.com/jhump/protoreflect v1.15.0 h1:U5T5/2LF0AZQFP9T4W5GfBjBaTruomrKobiR4E+oA/Q= github.com/jhump/protoreflect v1.15.0/go.mod h1:qww51KYjD2hoCl/ohxw5cK2LSssFczrbO1t8Ld2TENs= +github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 h1:XQyxROzUlZH+WIQwySDgnISgOivlhjIEwaQaJEJrrN0= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mod v0.6.0-dev.0.20211013180041-c96bc1413d57 h1:LQmS1nU0twXLA96Kt7U9qtHJEbBk3z6Q0V4UXjZkpr4= +golang.org/x/mod v0.6.0-dev.0.20211013180041-c96bc1413d57/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= @@ -73,6 +93,7 @@ golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs= golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= @@ -102,15 +123,23 @@ golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= +golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= +golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.8-0.20211029000441-d6a9af8af023 h1:0c3L82FDQ5rt1bjTBlchS8t6RQ6299/+5bWMnRLh+uI= +golang.org/x/tools v0.1.8-0.20211029000441-d6a9af8af023/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= @@ -132,6 +161,7 @@ google.golang.org/api v0.74.0/go.mod h1:ZpfMZOVRMywNyvJFeqL9HRWBgAuRfSjJFpe9QtRR google.golang.org/api v0.75.0/go.mod h1:pU9QmyHLnzlpar1Mjt4IbapUCy8J+6HD6GeELN69ljA= google.golang.org/api v0.78.0/go.mod h1:1Sg78yoMLOhlQTeF+ARBoytAcH1NNyyl390YMy6rKmw= google.golang.org/api v0.81.0/go.mod h1:FA6Mb/bZxj706H2j+j2d6mHEEaHBmbbWnkfvmorOCko= +google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= @@ -190,4 +220,6 @@ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc h1:/hemPrYIhOhy8zYrNj+069zDB68us2sMGsfkFJO0iZs= diff --git a/vendor/github.com/bufbuild/protocompile/internal/editions.go b/vendor/github.com/bufbuild/protocompile/internal/editions.go index bf6bf45f710..aa0d0adc891 100644 --- a/vendor/github.com/bufbuild/protocompile/internal/editions.go +++ b/vendor/github.com/bufbuild/protocompile/internal/editions.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,7 +14,18 @@ package internal +import "google.golang.org/protobuf/types/descriptorpb" + // AllowEditions is set to true in tests to enable editions syntax for testing. // This will be removed and editions will be allowed by non-test code once the // implementation is complete. var AllowEditions = false + +// SupportedEditions is the exhaustive set of editions that protocompile +// can support. We don't allow it to compile future/unknown editions, to +// make sure we don't generate incorrect descriptors, in the event that +// a future edition introduces a change or new feature that requires +// new logic in the compiler. +var SupportedEditions = map[string]descriptorpb.Edition{ + "2023": descriptorpb.Edition_EDITION_2023, +} diff --git a/vendor/github.com/bufbuild/protocompile/internal/message_context.go b/vendor/github.com/bufbuild/protocompile/internal/message_context.go index 6e380d8a07b..52acbdfdd56 100644 --- a/vendor/github.com/bufbuild/protocompile/internal/message_context.go +++ b/vendor/github.com/bufbuild/protocompile/internal/message_context.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/github.com/bufbuild/protocompile/internal/norace.go b/vendor/github.com/bufbuild/protocompile/internal/norace.go index 8e72b2a0dfa..2acf4e468fb 100644 --- a/vendor/github.com/bufbuild/protocompile/internal/norace.go +++ b/vendor/github.com/bufbuild/protocompile/internal/norace.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/github.com/bufbuild/protocompile/internal/options.go b/vendor/github.com/bufbuild/protocompile/internal/options.go index e518e1ed9e1..d9671f2b8bf 100644 --- a/vendor/github.com/bufbuild/protocompile/internal/options.go +++ b/vendor/github.com/bufbuild/protocompile/internal/options.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/github.com/bufbuild/protocompile/internal/race.go b/vendor/github.com/bufbuild/protocompile/internal/race.go index 403782586f3..e70e414db5b 100644 --- a/vendor/github.com/bufbuild/protocompile/internal/race.go +++ b/vendor/github.com/bufbuild/protocompile/internal/race.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/github.com/bufbuild/protocompile/internal/tags.go b/vendor/github.com/bufbuild/protocompile/internal/tags.go index 387df7f3950..179728f0867 100644 --- a/vendor/github.com/bufbuild/protocompile/internal/tags.go +++ b/vendor/github.com/bufbuild/protocompile/internal/tags.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -61,6 +61,12 @@ const ( // FileOptionsTag is the tag number of the options element in a file // descriptor proto. FileOptionsTag = 8 + // FileOptionsJavaStringCheckUTF8Tag is the tag number of the java_string_check_utf8 + // field in the FileOptions proto. + FileOptionsJavaStringCheckUTF8Tag = 27 + // FileOptionsFeaturesTag is the tag number of the features field in the + // FileOptions proto. + FileOptionsFeaturesTag = 50 // FileSourceCodeInfoTag is the tag number of the source code info element // in a file descriptor proto. FileSourceCodeInfoTag = 9 @@ -97,6 +103,9 @@ const ( // MessageOptionsTag is the tag number of the options element in a message // descriptor proto. MessageOptionsTag = 7 + // MessageOptionsFeaturesTag is the tag number of the features field in the + // MessageOptions proto. + MessageOptionsFeaturesTag = 12 // MessageOneofsTag is the tag number of the one-ofs element in a message // descriptor proto. MessageOneofsTag = 8 @@ -115,6 +124,30 @@ const ( // ExtensionRangeOptionsTag is the tag number of the options element in an // extension range proto. ExtensionRangeOptionsTag = 3 + // ExtensionRangeOptionsDeclarationTag is the tag number of the declaration + // field in the ExtensionRangeOptions proto. + ExtensionRangeOptionsDeclarationTag = 2 + // ExtensionRangeOptionsVerificationTag is the tag number of the verification + // field in the ExtensionRangeOptions proto. + ExtensionRangeOptionsVerificationTag = 3 + // ExtensionRangeOptionsDeclarationNumberTag is the tag number of the number + // field in the ExtensionRangeOptions.Declaration proto. + ExtensionRangeOptionsDeclarationNumberTag = 1 + // ExtensionRangeOptionsDeclarationFullNameTag is the tag number of the full_name + // field in the ExtensionRangeOptions.Declaration proto. + ExtensionRangeOptionsDeclarationFullNameTag = 2 + // ExtensionRangeOptionsDeclarationTypeTag is the tag number of the type + // field in the ExtensionRangeOptions.Declaration proto. + ExtensionRangeOptionsDeclarationTypeTag = 3 + // ExtensionRangeOptionsDeclarationReservedTag is the tag number of the reserved + // field in the ExtensionRangeOptions.Declaration proto. + ExtensionRangeOptionsDeclarationReservedTag = 5 + // ExtensionRangeOptionsDeclarationRepeatedTag is the tag number of the repeated + // field in the ExtensionRangeOptions.Declaration proto. + ExtensionRangeOptionsDeclarationRepeatedTag = 6 + // ExtensionRangeOptionsFeaturesTag is the tag number of the features field in the + // ExtensionRangeOptions proto. + ExtensionRangeOptionsFeaturesTag = 50 // ReservedRangeStartTag is the tag number of the start index in a reserved // range proto. This field number is the same for both "flavors" of reserved // ranges: DescriptorProto.ReservedRange and EnumDescriptorProto.EnumReservedRange. @@ -147,6 +180,24 @@ const ( // FieldOptionsTag is the tag number of the options element in a field // descriptor proto. FieldOptionsTag = 8 + // FieldOptionsCTypeTag is the number of the ctype field in the + // FieldOptions proto. + FieldOptionsCTypeTag = 1 + // FieldOptionsPackedTag is the number of the packed field in the + // FieldOptions proto. + FieldOptionsPackedTag = 2 + // FieldOptionsLazyTag is the number of the lazy field in the + // FieldOptions proto. + FieldOptionsLazyTag = 5 + // FieldOptionsJSTypeTag is the number of the jstype field in the + // FieldOptions proto. + FieldOptionsJSTypeTag = 6 + // FieldOptionsUnverifiedLazyTag is the number of the unverified_lazy + // field in the FieldOptions proto. + FieldOptionsUnverifiedLazyTag = 15 + // FieldOptionsFeaturesTag is the tag number of the features field in the + // FieldOptions proto. + FieldOptionsFeaturesTag = 21 // FieldOneofIndexTag is the tag number of the oneof index element in a // field descriptor proto. FieldOneofIndexTag = 9 @@ -162,6 +213,9 @@ const ( // OneofOptionsTag is the tag number of the options element in a one-of // descriptor proto. OneofOptionsTag = 2 + // OneofOptionsFeaturesTag is the tag number of the features field in the + // OneofOptions proto. + OneofOptionsFeaturesTag = 1 // EnumNameTag is the tag number of the name element in an enum descriptor // proto. EnumNameTag = 1 @@ -171,6 +225,9 @@ const ( // EnumOptionsTag is the tag number of the options element in an enum // descriptor proto. EnumOptionsTag = 3 + // EnumOptionsFeaturesTag is the tag number of the features field in the + // EnumOptions proto. + EnumOptionsFeaturesTag = 7 // EnumReservedRangesTag is the tag number of the reserved ranges element in // an enum descriptor proto. EnumReservedRangesTag = 4 @@ -186,6 +243,9 @@ const ( // EnumValOptionsTag is the tag number of the options element in an enum // value descriptor proto. EnumValOptionsTag = 3 + // EnumValOptionsFeaturesTag is the tag number of the features field in the + // EnumValueOptions proto. + EnumValOptionsFeaturesTag = 2 // ServiceNameTag is the tag number of the name element in a service // descriptor proto. ServiceNameTag = 1 @@ -195,6 +255,9 @@ const ( // ServiceOptionsTag is the tag number of the options element in a service // descriptor proto. ServiceOptionsTag = 3 + // ServiceOptionsFeaturesTag is the tag number of the features field in the + // ServiceOptions proto. + ServiceOptionsFeaturesTag = 34 // MethodNameTag is the tag number of the name element in a method // descriptor proto. MethodNameTag = 1 @@ -207,6 +270,9 @@ const ( // MethodOptionsTag is the tag number of the options element in a method // descriptor proto. MethodOptionsTag = 4 + // MethodOptionsFeaturesTag is the tag number of the features field in the + // MethodOptions proto. + MethodOptionsFeaturesTag = 35 // MethodInputStreamTag is the tag number of the input stream flag in a // method descriptor proto. MethodInputStreamTag = 5 @@ -243,4 +309,28 @@ const ( // UninterpretedNameNameTag is the tag number of the name element in an // uninterpreted option name proto. UninterpretedNameNameTag = 1 + + // AnyTypeURLTag is the tag number of the type_url field of the Any proto. + AnyTypeURLTag = 1 + // AnyValueTag is the tag number of the value field of the Any proto. + AnyValueTag = 2 + + // FeatureSetFieldPresenceTag is the tag number of the field_presence field + // in the FeatureSet proto. + FeatureSetFieldPresenceTag = 1 + // FeatureSetEnumTypeTag is the tag number of the enum_type field in the + // FeatureSet proto. + FeatureSetEnumTypeTag = 2 + // FeatureSetRepeatedFieldEncodingTag is the tag number of the repeated_field_encoding + // field in the FeatureSet proto. + FeatureSetRepeatedFieldEncodingTag = 3 + // FeatureSetUTF8ValidationTag is the tag number of the utf8_validation field + // in the FeatureSet proto. + FeatureSetUTF8ValidationTag = 4 + // FeatureSetMessageEncodingTag is the tag number of the message_encoding + // field in the FeatureSet proto. + FeatureSetMessageEncodingTag = 5 + // FeatureSetJSONFormatTag is the tag number of the json_format field in + // the FeatureSet proto. + FeatureSetJSONFormatTag = 6 ) diff --git a/vendor/github.com/bufbuild/protocompile/internal/types.go b/vendor/github.com/bufbuild/protocompile/internal/types.go index 4115aac899e..04090a820e1 100644 --- a/vendor/github.com/bufbuild/protocompile/internal/types.go +++ b/vendor/github.com/bufbuild/protocompile/internal/types.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/github.com/bufbuild/protocompile/internal/util.go b/vendor/github.com/bufbuild/protocompile/internal/util.go index c437d7fb294..569cb3f1cbd 100644 --- a/vendor/github.com/bufbuild/protocompile/internal/util.go +++ b/vendor/github.com/bufbuild/protocompile/internal/util.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -219,6 +219,23 @@ func ComputePath(d protoreflect.Descriptor) (protoreflect.SourcePath, bool) { } } +// CanPack returns true if a repeated field of the given kind +// can use packed encoding. +func CanPack(k protoreflect.Kind) bool { + switch k { + case protoreflect.MessageKind, protoreflect.GroupKind, protoreflect.StringKind, protoreflect.BytesKind: + return false + default: + return true + } +} + +func ClonePath(path protoreflect.SourcePath) protoreflect.SourcePath { + clone := make(protoreflect.SourcePath, len(path)) + copy(clone, path) + return clone +} + func reverse(p protoreflect.SourcePath) protoreflect.SourcePath { for i, j := 0, len(p)-1; i < j; i, j = i+1, j-1 { p[i], p[j] = p[j], p[i] diff --git a/vendor/github.com/bufbuild/protocompile/linker/descriptors.go b/vendor/github.com/bufbuild/protocompile/linker/descriptors.go index d4f82fbdc03..b15d5715137 100644 --- a/vendor/github.com/bufbuild/protocompile/linker/descriptors.go +++ b/vendor/github.com/bufbuild/protocompile/linker/descriptors.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -151,11 +151,6 @@ type result struct { // interpreting options. usedImports map[string]struct{} - // A map of descriptor options messages to their pre-serialized bytes (using - // a canonical serialization format based on how protoc renders options to - // bytes). - optionBytes map[proto.Message][]byte - // A map of AST nodes that represent identifiers in ast.FieldReferenceNodes // to their fully-qualified name. The identifiers are for field names in // message literals (in option values) that are extension fields. These names @@ -201,11 +196,26 @@ func (r *result) Syntax() protoreflect.Syntax { return protoreflect.Proto2 case "proto3": return protoreflect.Proto3 + case "editions": + return protoreflect.Editions default: return 0 // ??? } } +func (r *result) Edition() int32 { + switch r.Syntax() { + case protoreflect.Proto2: + return int32(descriptorpb.Edition_EDITION_PROTO2) + case protoreflect.Proto3: + return int32(descriptorpb.Edition_EDITION_PROTO3) + case protoreflect.Editions: + return int32(r.FileDescriptorProto().GetEdition()) + default: + return int32(descriptorpb.Edition_EDITION_UNKNOWN) // ??? + } +} + func (r *result) Name() protoreflect.Name { return "" } @@ -301,141 +311,6 @@ func asSourceLocations(srcInfoProtos []*descriptorpb.SourceCodeInfo_Location) [] return locs } -// AddOptionBytes associates the given opts (an options message encoded in the -// binary format) with the given options protobuf message. The protobuf message -// should exist in the hierarchy of this result's FileDescriptorProto. This -// allows the FileDescriptorProto to be marshaled to bytes in a way that -// preserves the way options are defined in source (just as is done by protoc, -// but not possible when only using the generated Go types and standard -// marshaling APIs in the protobuf runtime). -func (r *result) AddOptionBytes(pm proto.Message, opts []byte) { - if r.optionBytes == nil { - r.optionBytes = map[proto.Message][]byte{} - } - r.optionBytes[pm] = append(r.optionBytes[pm], opts...) -} - -func (r *result) CanonicalProto() *descriptorpb.FileDescriptorProto { - origFd := r.FileDescriptorProto() - // make a copy that we can mutate - fd := proto.Clone(origFd).(*descriptorpb.FileDescriptorProto) //nolint:errcheck - - r.storeOptionBytesInFile(fd, origFd) - - return fd -} - -func (r *result) storeOptionBytes(opts, origOpts proto.Message) { - optionBytes := r.optionBytes[origOpts] - if len(optionBytes) == 0 { - // If we don't know about this options message, leave it alone. - return - } - proto.Reset(opts) - opts.ProtoReflect().SetUnknown(optionBytes) -} - -func (r *result) storeOptionBytesInFile(fd, origFd *descriptorpb.FileDescriptorProto) { - if fd.Options != nil { - r.storeOptionBytes(fd.Options, origFd.Options) - } - - for i, md := range fd.MessageType { - origMd := origFd.MessageType[i] - r.storeOptionBytesInMessage(md, origMd) - } - - for i, ed := range fd.EnumType { - origEd := origFd.EnumType[i] - r.storeOptionBytesInEnum(ed, origEd) - } - - for i, exd := range fd.Extension { - origExd := origFd.Extension[i] - r.storeOptionBytesInField(exd, origExd) - } - - for i, sd := range fd.Service { - origSd := origFd.Service[i] - if sd.Options != nil { - r.storeOptionBytes(sd.Options, origSd.Options) - } - - for j, mtd := range sd.Method { - origMtd := origSd.Method[j] - if mtd.Options != nil { - r.storeOptionBytes(mtd.Options, origMtd.Options) - } - } - } -} - -func (r *result) storeOptionBytesInMessage(md, origMd *descriptorpb.DescriptorProto) { - if md.GetOptions().GetMapEntry() { - // Map entry messages are synthesized. They won't have any option bytes - // since they don't actually appear in the source and thus have any option - // declarations in the source. - return - } - - if md.Options != nil { - r.storeOptionBytes(md.Options, origMd.Options) - } - - for i, fld := range md.Field { - origFld := origMd.Field[i] - r.storeOptionBytesInField(fld, origFld) - } - - for i, ood := range md.OneofDecl { - origOod := origMd.OneofDecl[i] - if ood.Options != nil { - r.storeOptionBytes(ood.Options, origOod.Options) - } - } - - for i, exr := range md.ExtensionRange { - origExr := origMd.ExtensionRange[i] - if exr.Options != nil { - r.storeOptionBytes(exr.Options, origExr.Options) - } - } - - for i, nmd := range md.NestedType { - origNmd := origMd.NestedType[i] - r.storeOptionBytesInMessage(nmd, origNmd) - } - - for i, ed := range md.EnumType { - origEd := origMd.EnumType[i] - r.storeOptionBytesInEnum(ed, origEd) - } - - for i, exd := range md.Extension { - origExd := origMd.Extension[i] - r.storeOptionBytesInField(exd, origExd) - } -} - -func (r *result) storeOptionBytesInEnum(ed, origEd *descriptorpb.EnumDescriptorProto) { - if ed.Options != nil { - r.storeOptionBytes(ed.Options, origEd.Options) - } - - for i, evd := range ed.Value { - origEvd := origEd.Value[i] - if evd.Options != nil { - r.storeOptionBytes(evd.Options, origEvd.Options) - } - } -} - -func (r *result) storeOptionBytesInField(fld, origFld *descriptorpb.FieldDescriptorProto) { - if fld.Options != nil { - r.storeOptionBytes(fld.Options, origFld.Options) - } -} - type fileImports struct { protoreflect.FileImports files []protoreflect.FileImport @@ -856,6 +731,11 @@ func (e *enumDescriptor) ReservedRanges() protoreflect.EnumRanges { return e.rsvdRanges } +func (e *enumDescriptor) IsClosed() bool { + enumType := resolveFeature(e, enumTypeField) + return descriptorpb.FeatureSet_EnumType(enumType.Enum()) == descriptorpb.FeatureSet_CLOSED +} + type enumRanges struct { protoreflect.EnumRanges ranges [][2]protoreflect.EnumNumber @@ -1167,6 +1047,14 @@ func (f *fldDescriptor) Cardinality() protoreflect.Cardinality { case descriptorpb.FieldDescriptorProto_LABEL_REQUIRED: return protoreflect.Required case descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL: + if f.Syntax() == protoreflect.Editions { + // Editions does not use label to indicate required. It instead + // uses a feature, and label is always optional. + fieldPresence := descriptorpb.FeatureSet_FieldPresence(resolveFeature(f, fieldPresenceField).Enum()) + if fieldPresence == descriptorpb.FeatureSet_LEGACY_REQUIRED { + return protoreflect.Required + } + } return protoreflect.Optional default: return 0 @@ -1174,6 +1062,14 @@ func (f *fldDescriptor) Cardinality() protoreflect.Cardinality { } func (f *fldDescriptor) Kind() protoreflect.Kind { + if f.proto.GetType() == descriptorpb.FieldDescriptorProto_TYPE_MESSAGE && f.Syntax() == protoreflect.Editions { + // In editions, "group encoding" (aka "delimited encoding") is toggled + // via a feature. So we report group kind when that feature is enabled. + messageEncoding := resolveFeature(f, messageEncodingField) + if descriptorpb.FeatureSet_MessageEncoding(messageEncoding.Enum()) == descriptorpb.FeatureSet_DELIMITED { + return protoreflect.GroupKind + } + } return protoreflect.Kind(f.proto.GetType()) } @@ -1199,10 +1095,13 @@ func (f *fldDescriptor) HasPresence() bool { if f.proto.GetLabel() == descriptorpb.FieldDescriptorProto_LABEL_REPEATED { return false } - return f.IsExtension() || - f.Syntax() == protoreflect.Proto2 || + if f.IsExtension() || f.Kind() == protoreflect.MessageKind || f.Kind() == protoreflect.GroupKind || - f.proto.OneofIndex != nil + f.proto.OneofIndex != nil { + return true + } + fieldPresence := descriptorpb.FeatureSet_FieldPresence(resolveFeature(f, fieldPresenceField).Enum()) + return fieldPresence == descriptorpb.FeatureSet_EXPLICIT || fieldPresence == descriptorpb.FeatureSet_LEGACY_REQUIRED } func (f *fldDescriptor) IsExtension() bool { @@ -1229,30 +1128,16 @@ func (f *fldDescriptor) IsWeak() bool { } func (f *fldDescriptor) IsPacked() bool { - opts := f.proto.GetOptions() - if opts.GetPacked() { - return true - } - if opts != nil && opts.Packed != nil { - // explicitly not packed - return false - } - - // proto3 defaults to packed for repeated scalar numeric fields - if f.file.Syntax() != protoreflect.Proto3 { - return false - } - if f.proto.GetLabel() != descriptorpb.FieldDescriptorProto_LABEL_REPEATED { + if f.Cardinality() != protoreflect.Repeated || !internal.CanPack(f.Kind()) { return false } - switch f.proto.GetType() { - case descriptorpb.FieldDescriptorProto_TYPE_GROUP, descriptorpb.FieldDescriptorProto_TYPE_MESSAGE, - descriptorpb.FieldDescriptorProto_TYPE_BYTES, descriptorpb.FieldDescriptorProto_TYPE_STRING: - return false - default: - // all others can be packed - return true + opts := f.proto.GetOptions() + if opts != nil && opts.Packed != nil { + // packed option is set explicitly + return *opts.Packed } + fieldEncoding := resolveFeature(f, repeatedFieldEncodingField) + return descriptorpb.FeatureSet_RepeatedFieldEncoding(fieldEncoding.Enum()) == descriptorpb.FeatureSet_PACKED } func (f *fldDescriptor) IsList() bool { diff --git a/vendor/github.com/bufbuild/protocompile/linker/doc.go b/vendor/github.com/bufbuild/protocompile/linker/doc.go index 1467c701656..93e68d9cad0 100644 --- a/vendor/github.com/bufbuild/protocompile/linker/doc.go +++ b/vendor/github.com/bufbuild/protocompile/linker/doc.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/github.com/bufbuild/protocompile/linker/editions.go b/vendor/github.com/bufbuild/protocompile/linker/editions.go new file mode 100644 index 00000000000..341a38a41dc --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/linker/editions.go @@ -0,0 +1,177 @@ +// Copyright 2020-2024 Buf Technologies, 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. + +package linker + +import ( + "fmt" + "sync" + + "google.golang.org/protobuf/encoding/prototext" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/reflect/protoregistry" + "google.golang.org/protobuf/types/descriptorpb" +) + +var ( + editionDefaults map[descriptorpb.Edition]*descriptorpb.FeatureSet + editionDefaultsInit sync.Once + + featureSetDescriptor = (*descriptorpb.FeatureSet)(nil).ProtoReflect().Descriptor() + fieldPresenceField = featureSetDescriptor.Fields().ByName("field_presence") + repeatedFieldEncodingField = featureSetDescriptor.Fields().ByName("repeated_field_encoding") + messageEncodingField = featureSetDescriptor.Fields().ByName("message_encoding") + enumTypeField = featureSetDescriptor.Fields().ByName("enum_type") + jsonFormatField = featureSetDescriptor.Fields().ByName("json_format") +) + +type hasFeatures interface { + GetFeatures() *descriptorpb.FeatureSet +} + +var _ hasFeatures = (*descriptorpb.FileOptions)(nil) +var _ hasFeatures = (*descriptorpb.MessageOptions)(nil) +var _ hasFeatures = (*descriptorpb.FieldOptions)(nil) +var _ hasFeatures = (*descriptorpb.OneofOptions)(nil) +var _ hasFeatures = (*descriptorpb.ExtensionRangeOptions)(nil) +var _ hasFeatures = (*descriptorpb.EnumOptions)(nil) +var _ hasFeatures = (*descriptorpb.EnumValueOptions)(nil) +var _ hasFeatures = (*descriptorpb.ServiceOptions)(nil) +var _ hasFeatures = (*descriptorpb.MethodOptions)(nil) + +// resolveFeature resolves a feature for the given descriptor. It uses the function +// to extract a value from a feature set. The function should return false as the +// second argument if the first value it returns was not actually present in the +// feature set. +func resolveFeature(d protoreflect.Descriptor, field protoreflect.FieldDescriptor) protoreflect.Value { + edition := getEdition(d) + if edition == descriptorpb.Edition_EDITION_PROTO2 || edition == descriptorpb.Edition_EDITION_PROTO3 { + // these syntax levels can't specify features, so we can short-circuit the search + // through the descriptor hierarchy for feature overrides + defaults := getEditionDefaults(edition) + return defaults.ProtoReflect().Get(field) // returns default value if field is not present + } + for { + var features *descriptorpb.FeatureSet + if withFeatures, ok := d.Options().(hasFeatures); ok { + // It should not be possible for 'ok' to ever be false... + features = withFeatures.GetFeatures() + } + featuresRef := features.ProtoReflect() + if featuresRef.Has(field) { + return featuresRef.Get(field) + } + parent := d.Parent() + if parent == nil { + // We've reached the end of the inheritance chain. So we fall back to a default. + defaults := getEditionDefaults(edition) + return defaults.ProtoReflect().Get(field) + } + d = parent + } +} + +type hasEdition interface { + // Edition returns the numeric value of a google.protobuf.Edition enum + // value that corresponds to the edition of this file. If the file does + // not use editions, it should return the enum value that corresponds + // to the syntax level, EDITION_PROTO2 or EDITION_PROTO3. + Edition() int32 +} + +var _ hasEdition = (*result)(nil) + +func getEdition(d protoreflect.Descriptor) descriptorpb.Edition { + withEdition, ok := d.ParentFile().(hasEdition) + if !ok { + // The parent file should always be a *result, so we should + // never be able to actually get in here. If we somehow did + // have another implementation of protoreflect.FileDescriptor, + // it doesn't provide a way to get the edition, other than the + // potentially expensive step of generating a FileDescriptorProto + // and then querying for the edition from that. :/ + return descriptorpb.Edition_EDITION_UNKNOWN + } + return descriptorpb.Edition(withEdition.Edition()) +} + +func getEditionDefaults(edition descriptorpb.Edition) *descriptorpb.FeatureSet { + editionDefaultsInit.Do(func() { + editionDefaults = make(map[descriptorpb.Edition]*descriptorpb.FeatureSet, len(descriptorpb.Edition_name)) + // Compute default for all known editions in descriptorpb. + for editionInt := range descriptorpb.Edition_name { + edition := descriptorpb.Edition(editionInt) + defaults := &descriptorpb.FeatureSet{} + defaultsRef := defaults.ProtoReflect() + fields := defaultsRef.Descriptor().Fields() + // Note: we are not computing defaults for extensions. Those are not needed + // by anything in the compiler, so we can get away with just computing + // defaults for these static, non-extension fields. + for i, length := 0, fields.Len(); i < length; i++ { + field := fields.Get(i) + opts, ok := field.Options().(*descriptorpb.FieldOptions) + if !ok { + continue // this is most likely impossible + } + maxEdition := descriptorpb.Edition(-1) + var maxVal string + for _, def := range opts.EditionDefaults { + if def.GetEdition() <= edition && def.GetEdition() > maxEdition { + maxEdition = def.GetEdition() + maxVal = def.GetValue() + } + } + if maxEdition == -1 { + // no matching default found + continue + } + // We use a typed nil so that it won't fall back to the global registry. Features + // should not use extensions or google.protobuf.Any, so a nil *Types is fine. + unmarshaler := prototext.UnmarshalOptions{Resolver: (*protoregistry.Types)(nil)} + // The string value is in the text format: either a field value literal or a + // message literal. (Repeated and map features aren't supported, so there's no + // array or map literal syntax to worry about.) + if field.Kind() == protoreflect.MessageKind || field.Kind() == protoreflect.GroupKind { + fldVal := defaultsRef.NewField(field) + err := unmarshaler.Unmarshal([]byte(maxVal), fldVal.Message().Interface()) + if err != nil { + continue // should we fail somehow?? + } + defaultsRef.Set(field, fldVal) + continue + } + // The value is the textformat for the field. But prototext doesn't provide a way + // to unmarshal a single field value. To work around, we unmarshal into the enclosing + // message, so we prefix the value with the field name. + maxVal = fmt.Sprintf("%s: %s", field.Name(), maxVal) + // Sadly, prototext doesn't support a Merge option. So we can't merge the value + // directly into the supplied msg. We have to instead unmarshal into an empty + // message and then use that to set the field in the supplied msg. :( + empty := defaultsRef.Type().New() + err := unmarshaler.Unmarshal([]byte(maxVal), empty.Interface()) + if err != nil { + continue // should we fail somehow?? + } + defaultsRef.Set(field, empty.Get(field)) + } + editionDefaults[edition] = defaults + } + }) + return editionDefaults[edition] +} + +func isJSONCompliant(d protoreflect.Descriptor) bool { + jsonFormat := resolveFeature(d, jsonFormatField) + return descriptorpb.FeatureSet_JsonFormat(jsonFormat.Enum()) == descriptorpb.FeatureSet_ALLOW +} diff --git a/vendor/github.com/bufbuild/protocompile/linker/files.go b/vendor/github.com/bufbuild/protocompile/linker/files.go index b2f84887a67..6b2d32467c8 100644 --- a/vendor/github.com/bufbuild/protocompile/linker/files.go +++ b/vendor/github.com/bufbuild/protocompile/linker/files.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/github.com/bufbuild/protocompile/linker/linker.go b/vendor/github.com/bufbuild/protocompile/linker/linker.go index cb70e84e399..a4da97e76f6 100644 --- a/vendor/github.com/bufbuild/protocompile/linker/linker.go +++ b/vendor/github.com/bufbuild/protocompile/linker/linker.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ import ( "fmt" "google.golang.org/protobuf/reflect/protoreflect" - "google.golang.org/protobuf/types/descriptorpb" "github.com/bufbuild/protocompile/ast" "github.com/bufbuild/protocompile/parser" @@ -115,7 +114,7 @@ type Result interface { // be done after options are interpreted. Any errors or warnings encountered // will be reported via the given handler. If any error is reported, this // function returns a non-nil error. - ValidateOptions(handler *reporter.Handler) error + ValidateOptions(handler *reporter.Handler, symbols *Symbols) error // CheckForUnusedImports is used to report warnings for unused imports. This // should be called after options have been interpreted. Otherwise, the logic // could incorrectly report imports as unused if the only symbol used were a @@ -128,30 +127,6 @@ type Result interface { // interpreting options (which is done after linking). PopulateSourceCodeInfo() - // CanonicalProto returns the file descriptor proto in a form that - // will be serialized in a canonical way. The "canonical" way matches - // the way that "protoc" emits option values, which is a way that - // mostly matches the way options are defined in source, including - // ordering and de-structuring. Unlike the FileDescriptorProto() method, - // this method is more expensive and results in a new descriptor proto - // being constructed with each call. - // - // The returned value will have all options (fields of the various - // descriptorpb.*Options message types) represented via unrecognized - // fields. So the returned value will serialize as desired, but it - // is otherwise not useful since all option values are treated as - // unknown. - // - // Note that CanonicalProto is a no-op if the options in this file - // were not interpreted by this module (e.g. the underlying descriptor - // proto was provided, with options already interpreted, instead of - // parsed from source). If the underlying descriptor proto was provided, - // but with a mix of interpreted and uninterpreted options, this method - // will effectively clear the already-interpreted fields and only the - // options actually interpreted by the compile operation will be - // retained. - CanonicalProto() *descriptorpb.FileDescriptorProto - // RemoveAST drops the AST information from this result. RemoveAST() } diff --git a/vendor/github.com/bufbuild/protocompile/linker/pathkey_no_unsafe.go b/vendor/github.com/bufbuild/protocompile/linker/pathkey_no_unsafe.go index 5dcf3c8fad6..e00debc662e 100644 --- a/vendor/github.com/bufbuild/protocompile/linker/pathkey_no_unsafe.go +++ b/vendor/github.com/bufbuild/protocompile/linker/pathkey_no_unsafe.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/github.com/bufbuild/protocompile/linker/pathkey_unsafe.go b/vendor/github.com/bufbuild/protocompile/linker/pathkey_unsafe.go index 62861bb0793..aa33e74fa46 100644 --- a/vendor/github.com/bufbuild/protocompile/linker/pathkey_unsafe.go +++ b/vendor/github.com/bufbuild/protocompile/linker/pathkey_unsafe.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/github.com/bufbuild/protocompile/linker/resolve.go b/vendor/github.com/bufbuild/protocompile/linker/resolve.go index 438a8cd6564..7d25cbdbdc0 100644 --- a/vendor/github.com/bufbuild/protocompile/linker/resolve.go +++ b/vendor/github.com/bufbuild/protocompile/linker/resolve.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -394,12 +394,6 @@ func resolveFieldTypes(f *fldDescriptor, handler *reporter.Handler, s *Symbols, } f.msgType = dsc case protoreflect.EnumDescriptor: - proto3 := r.Syntax() == protoreflect.Proto3 - enumIsProto3 := dsc.Syntax() == protoreflect.Proto3 - if fld.GetExtendee() == "" && proto3 && !enumIsProto3 { - // fields in a proto3 message cannot refer to proto2 enums - return handler.HandleErrorf(file.NodeInfo(node.FieldType()), "%s: cannot use proto2 enum %s in a proto3 message", scope, fld.GetTypeName()) - } typeName := "." + string(dsc.FullName()) if fld.GetTypeName() != typeName { fld.TypeName = proto.String(typeName) diff --git a/vendor/github.com/bufbuild/protocompile/linker/symbols.go b/vendor/github.com/bufbuild/protocompile/linker/symbols.go index 94baa9cae9c..8a66af06e45 100644 --- a/vendor/github.com/bufbuild/protocompile/linker/symbols.go +++ b/vendor/github.com/bufbuild/protocompile/linker/symbols.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -38,6 +38,14 @@ const unknownFilePath = "" // This type is thread-safe. type Symbols struct { pkgTrie packageSymbols + + // We don't know the packages for these symbols, so we can't + // keep them in the pkgTrie. In vast majority of cases, this + // will always be empty/unused. When used, it ensures that + // multiple extension declarations don't refer to the same + // extension. + extDeclsMu sync.Mutex + extDecls map[protoreflect.FullName]extDecl } type packageSymbols struct { @@ -59,6 +67,12 @@ type symbolEntry struct { isPackage bool } +type extDecl struct { + pos ast.SourcePos + extendee protoreflect.FullName + tag protoreflect.FieldNumber +} + // Import populates the symbol table with all symbols/elements and extension // tags present in the given file descriptor. If s is nil or if fd has already // been imported into s, this returns immediately without doing anything. If any @@ -69,6 +83,10 @@ func (s *Symbols) Import(fd protoreflect.FileDescriptor, handler *reporter.Handl return nil } + if f, ok := fd.(protoreflect.FileImport); ok { + // unwrap any import instance + fd = f.FileDescriptor + } if f, ok := fd.(*file); ok { // unwrap any file instance fd = f.FileDescriptor @@ -540,6 +558,9 @@ func (s *packageSymbols) commitResultLocked(r *result) { s.files[r] = struct{}{} } +// AddExtension records the given extension, which is used to ensure that no two files +// attempt to extend the same message using the same tag. The given pkg should be the +// package that defines extendee. func (s *Symbols) AddExtension(pkg, extendee protoreflect.FullName, tag protoreflect.FieldNumber, span ast.SourceSpan, handler *reporter.Handler) error { if pkg != "" { if !strings.HasPrefix(string(extendee), string(pkg)+".") { @@ -558,17 +579,38 @@ func (s *packageSymbols) addExtension(extendee protoreflect.FullName, tag protor s.mu.Lock() defer s.mu.Unlock() + extNum := extNumber{extendee: extendee, tag: tag} + if existing, ok := s.exts[extNum]; ok { + return handler.HandleErrorf(span, "extension with tag %d for message %s already defined at %v", tag, extendee, existing) + } + if s.exts == nil { s.exts = map[extNumber]ast.SourcePos{} } + s.exts[extNum] = span.Start() + return nil +} - extNum := extNumber{extendee: extendee, tag: tag} - if existing, ok := s.exts[extNum]; ok { - if err := handler.HandleErrorf(span, "extension with tag %d for message %s already defined at %v", tag, extendee, existing); err != nil { - return err +// AddExtensionDeclaration records the given extension declaration, which is used to +// ensure that no two declarations refer to the same extension. +func (s *Symbols) AddExtensionDeclaration(extension, extendee protoreflect.FullName, tag protoreflect.FieldNumber, span ast.SourceSpan, handler *reporter.Handler) error { + s.extDeclsMu.Lock() + defer s.extDeclsMu.Unlock() + existing, ok := s.extDecls[extension] + if ok { + if existing.extendee == extendee && existing.tag == tag { + // This is a declaration that has already been added. Ignore. + return nil } - } else { - s.exts[extNum] = span.Start() + return handler.HandleErrorf(span, "extension %s already declared as extending %s with tag %d at %v", extension, existing.extendee, existing.tag, existing.pos) + } + if s.extDecls == nil { + s.extDecls = map[protoreflect.FullName]extDecl{} + } + s.extDecls[extension] = extDecl{ + pos: span.Start(), + extendee: extendee, + tag: tag, } return nil } diff --git a/vendor/github.com/bufbuild/protocompile/linker/validate.go b/vendor/github.com/bufbuild/protocompile/linker/validate.go index 32c735905e0..f9dad2edf8d 100644 --- a/vendor/github.com/bufbuild/protocompile/linker/validate.go +++ b/vendor/github.com/bufbuild/protocompile/linker/validate.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package linker import ( "fmt" + "math" "strings" "unicode" "unicode/utf8" @@ -23,33 +24,34 @@ import ( "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/types/descriptorpb" + "github.com/bufbuild/protocompile/ast" "github.com/bufbuild/protocompile/internal" + "github.com/bufbuild/protocompile/protoutil" "github.com/bufbuild/protocompile/reporter" "github.com/bufbuild/protocompile/walk" ) // ValidateOptions runs some validation checks on the result that can only // be done after options are interpreted. -func (r *result) ValidateOptions(handler *reporter.Handler) error { +func (r *result) ValidateOptions(handler *reporter.Handler, symbols *Symbols) error { + if err := r.validateFile(handler); err != nil { + return err + } return walk.Descriptors(r, func(d protoreflect.Descriptor) error { switch d := d.(type) { case protoreflect.FieldDescriptor: - if d.IsExtension() { - if err := r.validateExtension(d, handler); err != nil { - return err - } - } - if err := r.validatePacked(d, handler); err != nil { + if err := r.validateField(d, handler); err != nil { return err } case protoreflect.MessageDescriptor: - md := d.(*msgDescriptor) //nolint:errcheck - if err := r.validateJSONNamesInMessage(md.proto, handler); err != nil { + if symbols == nil { + symbols = &Symbols{} + } + if err := r.validateMessage(d, handler, symbols); err != nil { return err } case protoreflect.EnumDescriptor: - ed := d.(*enumDescriptor) //nolint:errcheck - if err := r.validateJSONNamesInEnum(ed.proto, handler); err != nil { + if err := r.validateEnum(d, handler); err != nil { return err } } @@ -57,45 +59,298 @@ func (r *result) ValidateOptions(handler *reporter.Handler) error { }) } -func (r *result) validateExtension(fld protoreflect.FieldDescriptor, handler *reporter.Handler) error { - // NB: It's a little gross that we don't enforce these in validateBasic(). - // But it requires linking to resolve the extendee, so we can interrogate - // its descriptor. +func (r *result) validateFile(handler *reporter.Handler) error { + opts := r.FileDescriptorProto().GetOptions() + if opts.GetOptimizeFor() != descriptorpb.FileOptions_LITE_RUNTIME { + // Non-lite files may not import lite files. + imports := r.Imports() + for i, length := 0, imports.Len(); i < length; i++ { + dep := imports.Get(i) + depOpts, ok := dep.Options().(*descriptorpb.FileOptions) + if !ok { + continue // what else to do? + } + if depOpts.GetOptimizeFor() == descriptorpb.FileOptions_LITE_RUNTIME { + err := handler.HandleErrorf(r.getImportLocation(dep.Path()), "a file that does not use optimize_for=LITE_RUNTIME may not import file %q that does", dep.Path()) + if err != nil { + return err + } + } + } + } + if isEditions(r) { + // Validate features + if opts.GetFeatures().GetFieldPresence() == descriptorpb.FeatureSet_LEGACY_REQUIRED { + span := r.findOptionSpan(r, internal.FileOptionsFeaturesTag, internal.FeatureSetFieldPresenceTag) + err := handler.HandleErrorf(span, "LEGACY_REQUIRED field presence cannot be set as the default for a file") + if err != nil { + return err + } + } + if opts != nil && opts.JavaStringCheckUtf8 != nil { + span := r.findOptionSpan(r, internal.FileOptionsJavaStringCheckUTF8Tag) + err := handler.HandleErrorf(span, `file option java_string_check_utf8 is not allowed with editions; import "google/protobuf/java_features.proto" and use (pb.java).utf8_validation instead`) + if err != nil { + return err + } + } + } + return nil +} + +func (r *result) validateField(fld protoreflect.FieldDescriptor, handler *reporter.Handler) error { if xtd, ok := fld.(protoreflect.ExtensionTypeDescriptor); ok { fld = xtd.Descriptor() } - fd := fld.(*fldDescriptor) //nolint:errcheck - if fld.ContainingMessage().Options().(*descriptorpb.MessageOptions).GetMessageSetWireFormat() { + fd, ok := fld.(*fldDescriptor) + if !ok { + // should not be possible + return fmt.Errorf("field descriptor is wrong type: expecting %T, got %T", (*fldDescriptor)(nil), fld) + } + + if err := r.validatePacked(fd, handler); err != nil { + return err + } + if fd.Kind() == protoreflect.EnumKind { + requiresOpen := !fd.IsList() && !fd.HasPresence() + if requiresOpen && fd.Enum().IsClosed() { + // Fields in a proto3 message cannot refer to proto2 enums. + // In editions, this translates to implicit presence fields + // not being able to refer to closed enums. + // TODO: This really should be based solely on whether the enum's first + // value is zero, NOT based on if it's open vs closed. + // https://github.com/protocolbuffers/protobuf/issues/16249 + file := r.FileNode() + info := file.NodeInfo(r.FieldNode(fd.proto).FieldType()) + if err := handler.HandleErrorf(info, "cannot use closed enum %s in a field with implicit presence", fd.Enum().FullName()); err != nil { + return err + } + } + } + if fd.HasDefault() && !fd.HasPresence() { + span := r.findScalarOptionSpan(r.FieldNode(fd.proto), "default") + err := handler.HandleErrorf(span, "default value is not allowed on fields with implicit presence") + if err != nil { + return err + } + } + if fd.proto.Options != nil && fd.proto.Options.Ctype != nil { + if descriptorpb.Edition(r.Edition()) >= descriptorpb.Edition_EDITION_2024 { + // We don't support edition 2024 yet, but we went ahead and mimic'ed this check + // from protoc, which currently has experimental support for 2024. + span := r.findOptionSpan(fd, internal.FieldOptionsCTypeTag) + if err := handler.HandleErrorf(span, "ctype option cannot be used as of edition 2024; use features.string_type instead"); err != nil { + return err + } + } else if descriptorpb.Edition(r.Edition()) == descriptorpb.Edition_EDITION_2023 { + if fld.Kind() != protoreflect.StringKind && fld.Kind() != protoreflect.BytesKind { + span := r.findOptionSpan(fd, internal.FieldOptionsCTypeTag) + if err := handler.HandleErrorf(span, "ctype option can only be used on string and bytes fields"); err != nil { + return err + } + } + if fd.proto.Options.GetCtype() == descriptorpb.FieldOptions_CORD && fd.IsExtension() { + span := r.findOptionSpan(fd, internal.FieldOptionsCTypeTag) + if err := handler.HandleErrorf(span, "ctype option cannot be CORD for extension fields"); err != nil { + return err + } + } + } + } + if (fd.proto.Options.GetLazy() || fd.proto.Options.GetUnverifiedLazy()) && fd.Kind() != protoreflect.MessageKind { + var span ast.SourceSpan + var optionName string + if fd.proto.Options.GetLazy() { + span = r.findOptionSpan(fd, internal.FieldOptionsLazyTag) + optionName = "lazy" + } else { + span = r.findOptionSpan(fd, internal.FieldOptionsUnverifiedLazyTag) + optionName = "unverified_lazy" + } + var suffix string + if fd.Kind() == protoreflect.GroupKind { + if isEditions(r) { + suffix = " that use length-prefixed encoding" + } else { + suffix = ", not groups" + } + } + if err := handler.HandleErrorf(span, "%s option can only be used with message fields%s", optionName, suffix); err != nil { + return err + } + } + if fd.proto.Options.GetJstype() != descriptorpb.FieldOptions_JS_NORMAL { + switch fd.Kind() { + case protoreflect.Int64Kind, protoreflect.Uint64Kind, protoreflect.Sint64Kind, + protoreflect.Fixed64Kind, protoreflect.Sfixed64Kind: + // allowed only for 64-bit integer types + default: + span := r.findOptionSpan(fd, internal.FieldOptionsJSTypeTag) + err := handler.HandleErrorf(span, "only 64-bit integer fields (int64, uint64, sint64, fixed64, and sfixed64) can specify a jstype other than JS_NORMAL") + if err != nil { + return err + } + } + } + if isEditions(r) { + if err := r.validateFieldFeatures(fd, handler); err != nil { + return err + } + } + + if fld.IsExtension() { + // More checks if this is an extension field. + if err := r.validateExtension(fd, handler); err != nil { + return err + } + } + + return nil +} + +func (r *result) validateExtension(fd *fldDescriptor, handler *reporter.Handler) error { + // NB: It's a little gross that we don't enforce these in validateBasic(). + // But it requires linking to resolve the extendee, so we can interrogate + // its descriptor. + msg := fd.ContainingMessage() + if msg.Options().(*descriptorpb.MessageOptions).GetMessageSetWireFormat() { // Message set wire format requires that all extensions be messages // themselves (no scalar extensions) - if fld.Kind() != protoreflect.MessageKind { + if fd.Kind() != protoreflect.MessageKind { file := r.FileNode() info := file.NodeInfo(r.FieldNode(fd.proto).FieldType()) - return handler.HandleErrorf(info, "messages with message-set wire format cannot contain scalar extensions, only messages") + err := handler.HandleErrorf(info, "messages with message-set wire format cannot contain scalar extensions, only messages") + if err != nil { + return err + } } - if fld.Cardinality() == protoreflect.Repeated { + if fd.Cardinality() == protoreflect.Repeated { file := r.FileNode() info := file.NodeInfo(r.FieldNode(fd.proto).FieldLabel()) - return handler.HandleErrorf(info, "messages with message-set wire format cannot contain repeated extensions, only optional") + err := handler.HandleErrorf(info, "messages with message-set wire format cannot contain repeated extensions, only optional") + if err != nil { + return err + } } - } else if fld.Number() > internal.MaxNormalTag { + } else if fd.Number() > internal.MaxNormalTag { // In validateBasic() we just made sure these were within bounds for any message. But // now that things are linked, we can check if the extendee is messageset wire format // and, if not, enforce tighter limit. file := r.FileNode() info := file.NodeInfo(r.FieldNode(fd.proto).FieldTag()) - return handler.HandleErrorf(info, "tag number %d is higher than max allowed tag number (%d)", fld.Number(), internal.MaxNormalTag) + err := handler.HandleErrorf(info, "tag number %d is higher than max allowed tag number (%d)", fd.Number(), internal.MaxNormalTag) + if err != nil { + return err + } + } + + fileOpts := r.FileDescriptorProto().GetOptions() + if fileOpts.GetOptimizeFor() == descriptorpb.FileOptions_LITE_RUNTIME { + extendeeFileOpts, _ := msg.ParentFile().Options().(*descriptorpb.FileOptions) + if extendeeFileOpts.GetOptimizeFor() != descriptorpb.FileOptions_LITE_RUNTIME { + file := r.FileNode() + info := file.NodeInfo(r.FieldNode(fd.proto)) + err := handler.HandleErrorf(info, "extensions in a file that uses optimize_for=LITE_RUNTIME may not extend messages in file %q which does not", msg.ParentFile().Path()) + if err != nil { + return err + } + } + } + + // If the extendee uses extension declarations, make sure this extension matches. + md := protoutil.ProtoFromMessageDescriptor(msg) + for i, extRange := range md.ExtensionRange { + if int32(fd.Number()) < extRange.GetStart() || int32(fd.Number()) >= extRange.GetEnd() { + continue + } + extRangeOpts := extRange.GetOptions() + if extRangeOpts == nil { + break + } + if extRangeOpts.GetVerification() == descriptorpb.ExtensionRangeOptions_UNVERIFIED { + break + } + var found bool + for j, extDecl := range extRangeOpts.Declaration { + if extDecl.GetNumber() != int32(fd.Number()) { + continue + } + found = true + if extDecl.GetReserved() { + file := r.FileNode() + info := file.NodeInfo(r.FieldNode(fd.proto).FieldTag()) + span, _ := findExtensionRangeOptionSpan(msg.ParentFile(), msg, i, extRange, + internal.ExtensionRangeOptionsDeclarationTag, int32(j), internal.ExtensionRangeOptionsDeclarationReservedTag) + err := handler.HandleErrorf(info, "cannot use field number %d for an extension because it is reserved in declaration at %v", + fd.Number(), span.Start()) + if err != nil { + return err + } + break + } + if extDecl.GetFullName() != "."+string(fd.FullName()) { + file := r.FileNode() + info := file.NodeInfo(r.FieldNode(fd.proto).FieldName()) + span, _ := findExtensionRangeOptionSpan(msg.ParentFile(), msg, i, extRange, + internal.ExtensionRangeOptionsDeclarationTag, int32(j), internal.ExtensionRangeOptionsDeclarationFullNameTag) + err := handler.HandleErrorf(info, "expected extension with number %d to be named %s, not %s, per declaration at %v", + fd.Number(), extDecl.GetFullName(), fd.FullName(), span.Start()) + if err != nil { + return err + } + } + if extDecl.GetType() != getTypeName(fd) { + file := r.FileNode() + info := file.NodeInfo(r.FieldNode(fd.proto).FieldType()) + span, _ := findExtensionRangeOptionSpan(msg.ParentFile(), msg, i, extRange, + internal.ExtensionRangeOptionsDeclarationTag, int32(j), internal.ExtensionRangeOptionsDeclarationTypeTag) + err := handler.HandleErrorf(info, "expected extension with number %d to have type %s, not %s, per declaration at %v", + fd.Number(), extDecl.GetType(), getTypeName(fd), span.Start()) + if err != nil { + return err + } + } + if extDecl.GetRepeated() != (fd.Cardinality() == protoreflect.Repeated) { + expected, actual := "repeated", "optional" + if !extDecl.GetRepeated() { + expected, actual = actual, expected + } + file := r.FileNode() + info := file.NodeInfo(r.FieldNode(fd.proto).FieldLabel()) + span, _ := findExtensionRangeOptionSpan(msg.ParentFile(), msg, i, extRange, + internal.ExtensionRangeOptionsDeclarationTag, int32(j), internal.ExtensionRangeOptionsDeclarationRepeatedTag) + err := handler.HandleErrorf(info, "expected extension with number %d to be %s, not %s, per declaration at %v", + fd.Number(), expected, actual, span.Start()) + if err != nil { + return err + } + } + break + } + if !found { + file := r.FileNode() + info := file.NodeInfo(r.FieldNode(fd.proto).FieldTag()) + span, _ := findExtensionRangeOptionSpan(fd.ParentFile(), msg, i, extRange, + internal.ExtensionRangeOptionsVerificationTag) + err := handler.HandleErrorf(info, "expected extension with number %d to be declared in type %s, but no declaration found at %v", + fd.Number(), fd.ContainingMessage().FullName(), span.Start()) + if err != nil { + return err + } + } } return nil } -func (r *result) validatePacked(fld protoreflect.FieldDescriptor, handler *reporter.Handler) error { - if xtd, ok := fld.(protoreflect.ExtensionTypeDescriptor); ok { - fld = xtd.Descriptor() +func (r *result) validatePacked(fd *fldDescriptor, handler *reporter.Handler) error { + if fd.proto.Options != nil && fd.proto.Options.Packed != nil && isEditions(r) { + span := r.findOptionSpan(fd, internal.FieldOptionsPackedTag) + err := handler.HandleErrorf(span, "packed option cannot be used with editions; use features.repeated_field_encoding=PACKED instead") + if err != nil { + return err + } } - - fd := fld.(*fldDescriptor) //nolint:errcheck if !fd.proto.GetOptions().GetPacked() { // if packed isn't true, nothing to validate return nil @@ -113,46 +368,157 @@ func (r *result) validatePacked(fld protoreflect.FieldDescriptor, handler *repor descriptorpb.FieldDescriptorProto_TYPE_MESSAGE, descriptorpb.FieldDescriptorProto_TYPE_GROUP: file := r.FileNode() info := file.NodeInfo(r.FieldNode(fd.proto).FieldType()) - return handler.HandleErrorf(info, "packed option is only allowed on numeric, boolean, and enum fields") + err := handler.HandleErrorf(info, "packed option is only allowed on numeric, boolean, and enum fields") + if err != nil { + return err + } } return nil } -func (r *result) validateJSONNamesInMessage(md *descriptorpb.DescriptorProto, handler *reporter.Handler) error { +func (r *result) validateFieldFeatures(fld *fldDescriptor, handler *reporter.Handler) error { + if msg, ok := fld.Parent().(*msgDescriptor); ok && msg.proto.GetOptions().GetMapEntry() { + // Skip validating features on fields of synthetic map entry messages. + // We blindly propagate them from the map field's features, but some may + // really only apply to the map field and not to a key or value entry field. + return nil + } + features := fld.proto.GetOptions().GetFeatures() + if features == nil { + // No features to validate. + return nil + } + if features.FieldPresence != nil { + switch { + case fld.proto.OneofIndex != nil: + span := r.findOptionSpan(fld, internal.FieldOptionsFeaturesTag, internal.FeatureSetFieldPresenceTag) + if err := handler.HandleErrorf(span, "oneof fields may not specify field presence"); err != nil { + return err + } + case fld.Cardinality() == protoreflect.Repeated: + span := r.findOptionSpan(fld, internal.FieldOptionsFeaturesTag, internal.FeatureSetFieldPresenceTag) + if err := handler.HandleErrorf(span, "repeated fields may not specify field presence"); err != nil { + return err + } + case fld.IsExtension(): + span := r.findOptionSpan(fld, internal.FieldOptionsFeaturesTag, internal.FeatureSetFieldPresenceTag) + if err := handler.HandleErrorf(span, "extension fields may not specify field presence"); err != nil { + return err + } + case fld.Message() != nil && features.GetFieldPresence() == descriptorpb.FeatureSet_IMPLICIT: + span := r.findOptionSpan(fld, internal.FieldOptionsFeaturesTag, internal.FeatureSetFieldPresenceTag) + if err := handler.HandleErrorf(span, "message fields may not specify implicit presence"); err != nil { + return err + } + } + } + if features.RepeatedFieldEncoding != nil { + if fld.Cardinality() != protoreflect.Repeated { + span := r.findOptionSpan(fld, internal.FieldOptionsFeaturesTag, internal.FeatureSetRepeatedFieldEncodingTag) + if err := handler.HandleErrorf(span, "only repeated fields may specify repeated field encoding"); err != nil { + return err + } + } else if !internal.CanPack(fld.Kind()) && features.GetRepeatedFieldEncoding() == descriptorpb.FeatureSet_PACKED { + span := r.findOptionSpan(fld, internal.FieldOptionsFeaturesTag, internal.FeatureSetRepeatedFieldEncodingTag) + if err := handler.HandleErrorf(span, "only repeated primitive fields may specify packed encoding"); err != nil { + return err + } + } + } + if features.Utf8Validation != nil { + isMap := fld.IsMap() + if (!isMap && fld.Kind() != protoreflect.StringKind) || + (isMap && + fld.MapKey().Kind() != protoreflect.StringKind && + fld.MapValue().Kind() != protoreflect.StringKind) { + span := r.findOptionSpan(fld, internal.FieldOptionsFeaturesTag, internal.FeatureSetUTF8ValidationTag) + if err := handler.HandleErrorf(span, "only string fields may specify UTF8 validation"); err != nil { + return err + } + } + } + if features.MessageEncoding != nil { + if fld.Message() == nil || fld.IsMap() { + span := r.findOptionSpan(fld, internal.FieldOptionsFeaturesTag, internal.FeatureSetMessageEncodingTag) + if err := handler.HandleErrorf(span, "only message fields may specify message encoding"); err != nil { + return err + } + } + } + return nil +} + +func (r *result) validateMessage(d protoreflect.MessageDescriptor, handler *reporter.Handler, symbols *Symbols) error { + md, ok := d.(*msgDescriptor) + if !ok { + // should not be possible + return fmt.Errorf("message descriptor is wrong type: expecting %T, got %T", (*msgDescriptor)(nil), d) + } + + if err := r.validateJSONNamesInMessage(md, handler); err != nil { + return err + } + + return r.validateExtensionDeclarations(md, handler, symbols) +} + +func (r *result) validateJSONNamesInMessage(md *msgDescriptor, handler *reporter.Handler) error { if err := r.validateFieldJSONNames(md, false, handler); err != nil { return err } if err := r.validateFieldJSONNames(md, true, handler); err != nil { return err } + return nil +} - for _, nmd := range md.GetNestedType() { - if err := r.validateJSONNamesInMessage(nmd, handler); err != nil { - return err - } +func (r *result) validateEnum(d protoreflect.EnumDescriptor, handler *reporter.Handler) error { + ed, ok := d.(*enumDescriptor) + if !ok { + // should not be possible + return fmt.Errorf("enum descriptor is wrong type: expecting %T, got %T", (*enumDescriptor)(nil), d) } - for _, ed := range md.GetEnumType() { - if err := r.validateJSONNamesInEnum(ed, handler); err != nil { + + firstValue := ed.Values().Get(0) + if !ed.IsClosed() && firstValue.Number() != 0 { + // TODO: This check doesn't really belong here. Whether the + // first value is zero s/b orthogonal to whether the + // allowed values are open or closed. + // https://github.com/protocolbuffers/protobuf/issues/16249 + file := r.FileNode() + evd, ok := firstValue.(*enValDescriptor) + if !ok { + // should not be possible + return fmt.Errorf("enum value descriptor is wrong type: expecting %T, got %T", (*enValDescriptor)(nil), firstValue) + } + info := file.NodeInfo(r.EnumValueNode(evd.proto).GetNumber()) + if err := handler.HandleErrorf(info, "first value of open enum %s must have numeric value zero", ed.FullName()); err != nil { return err } } + + if err := r.validateJSONNamesInEnum(ed, handler); err != nil { + return err + } + return nil } -func (r *result) validateJSONNamesInEnum(ed *descriptorpb.EnumDescriptorProto, handler *reporter.Handler) error { +func (r *result) validateJSONNamesInEnum(ed *enumDescriptor, handler *reporter.Handler) error { seen := map[string]*descriptorpb.EnumValueDescriptorProto{} - for _, evd := range ed.GetValue() { - scope := "enum value " + ed.GetName() + "." + evd.GetName() + for _, evd := range ed.proto.GetValue() { + scope := "enum value " + ed.proto.GetName() + "." + evd.GetName() - name := canonicalEnumValueName(evd.GetName(), ed.GetName()) + name := canonicalEnumValueName(evd.GetName(), ed.proto.GetName()) if existing, ok := seen[name]; ok && evd.GetNumber() != existing.GetNumber() { fldNode := r.EnumValueNode(evd) existingNode := r.EnumValueNode(existing) conflictErr := fmt.Errorf("%s: camel-case name (with optional enum name prefix removed) %q conflicts with camel-case name of enum value %s, defined at %v", scope, name, existing.GetName(), r.FileNode().NodeInfo(existingNode).Start()) - // Since proto2 did not originally have a JSON format, we report conflicts as just warnings - if r.Syntax() != protoreflect.Proto3 { + // Since proto2 did not originally have a JSON format, we report conflicts as just warnings. + // With editions, not fully supporting JSON is allowed via feature: json_format == BEST_EFFORT + if !isJSONCompliant(ed) { handler.HandleWarningWithPos(r.FileNode().NodeInfo(fldNode), conflictErr) } else if err := handler.HandleErrorf(r.FileNode().NodeInfo(fldNode), conflictErr.Error()); err != nil { return err @@ -164,7 +530,7 @@ func (r *result) validateJSONNamesInEnum(ed *descriptorpb.EnumDescriptorProto, h return nil } -func (r *result) validateFieldJSONNames(md *descriptorpb.DescriptorProto, useCustom bool, handler *reporter.Handler) error { +func (r *result) validateFieldJSONNames(md *msgDescriptor, useCustom bool, handler *reporter.Handler) error { type jsonName struct { source *descriptorpb.FieldDescriptorProto // true if orig is a custom JSON name (vs. the field's default JSON name) @@ -172,8 +538,8 @@ func (r *result) validateFieldJSONNames(md *descriptorpb.DescriptorProto, useCus } seen := map[string]jsonName{} - for _, fd := range md.GetField() { - scope := "field " + md.GetName() + "." + fd.GetName() + for _, fd := range md.proto.GetField() { + scope := "field " + md.proto.GetName() + "." + fd.GetName() defaultName := internal.JSONName(fd.GetName()) name := defaultName custom := false @@ -203,7 +569,8 @@ func (r *result) validateFieldJSONNames(md *descriptorpb.DescriptorProto, useCus // Since proto2 did not originally have default JSON names, we report conflicts // between default names (neither is a custom name) as just warnings. - if r.Syntax() != protoreflect.Proto3 && !custom && !existing.custom { + // With editions, not fully supporting JSON is allowed via feature: json_format == BEST_EFFORT + if !isJSONCompliant(md) && !custom && !existing.custom { handler.HandleWarning(conflictErr) } else if err := handler.HandleError(conflictErr); err != nil { return err @@ -216,6 +583,145 @@ func (r *result) validateFieldJSONNames(md *descriptorpb.DescriptorProto, useCus return nil } +func (r *result) validateExtensionDeclarations(md *msgDescriptor, handler *reporter.Handler, symbols *Symbols) error { + for i, extRange := range md.proto.ExtensionRange { + opts := extRange.GetOptions() + if len(opts.GetDeclaration()) == 0 { + // nothing to check + continue + } + if len(opts.GetDeclaration()) > 0 && opts.GetVerification() == descriptorpb.ExtensionRangeOptions_UNVERIFIED { + span, ok := findExtensionRangeOptionSpan(r, md, i, extRange, internal.ExtensionRangeOptionsVerificationTag) + if !ok { + span, _ = findExtensionRangeOptionSpan(r, md, i, extRange, internal.ExtensionRangeOptionsDeclarationTag, 0) + } + if err := handler.HandleErrorf(span, "extension range cannot have declarations and have verification of UNVERIFIED"); err != nil { + return err + } + } + declsByTag := map[int32]ast.SourcePos{} + for i, extDecl := range extRange.GetOptions().GetDeclaration() { + if extDecl.Number == nil { + span, _ := findExtensionRangeOptionSpan(r, md, i, extRange, internal.ExtensionRangeOptionsDeclarationTag, int32(i)) + if err := handler.HandleErrorf(span, "extension declaration is missing required field number"); err != nil { + return err + } + } else { + extensionNumberSpan, _ := findExtensionRangeOptionSpan(r, md, i, extRange, + internal.ExtensionRangeOptionsDeclarationTag, int32(i), internal.ExtensionRangeOptionsDeclarationNumberTag) + if extDecl.GetNumber() < extRange.GetStart() || extDecl.GetNumber() >= extRange.GetEnd() { + // Number is out of range. + // See if one of the other ranges on the same extends statement includes the number, + // so we can provide a helpful message. + var suffix string + if extRange, ok := r.ExtensionsNode(extRange).(*ast.ExtensionRangeNode); ok { + for _, rng := range extRange.Ranges { + start, _ := rng.StartVal.AsInt64() + var end int64 + switch { + case rng.Max != nil: + end = math.MaxInt64 + case rng.EndVal != nil: + end, _ = rng.EndVal.AsInt64() + default: + end = start + } + if int64(extDecl.GetNumber()) >= start && int64(extDecl.GetNumber()) <= end { + // Found another range that matches + suffix = "; when using declarations, extends statements should indicate only a single span of field numbers" + break + } + } + } + err := handler.HandleErrorf(extensionNumberSpan, "extension declaration has number outside the range: %d not in [%d,%d]%s", + extDecl.GetNumber(), extRange.GetStart(), extRange.GetEnd()-1, suffix) + if err != nil { + return err + } + } else { + // Valid number; make sure it's not a duplicate + if existing, ok := declsByTag[extDecl.GetNumber()]; ok { + err := handler.HandleErrorf(extensionNumberSpan, "extension for tag number %d already declared at %v", + extDecl.GetNumber(), existing) + if err != nil { + return err + } + } else { + declsByTag[extDecl.GetNumber()] = extensionNumberSpan.Start() + } + } + } + + if extDecl.GetReserved() { + if extDecl.FullName != nil { + span, _ := findExtensionRangeOptionSpan(r, md, i, extRange, + internal.ExtensionRangeOptionsDeclarationTag, int32(i), internal.ExtensionRangeOptionsDeclarationFullNameTag) + if err := handler.HandleErrorf(span, "extension declaration is marked reserved so full_name should not be present"); err != nil { + return err + } + } + if extDecl.Type != nil { + span, _ := findExtensionRangeOptionSpan(r, md, i, extRange, + internal.ExtensionRangeOptionsDeclarationTag, int32(i), internal.ExtensionRangeOptionsDeclarationTypeTag) + if err := handler.HandleErrorf(span, "extension declaration is marked reserved so type should not be present"); err != nil { + return err + } + } + continue + } + + if extDecl.FullName == nil { + span, _ := findExtensionRangeOptionSpan(r, md, i, extRange, internal.ExtensionRangeOptionsDeclarationTag, int32(i)) + if err := handler.HandleErrorf(span, "extension declaration that is not marked reserved must have a full_name"); err != nil { + return err + } + } + var extensionFullName protoreflect.FullName + extensionNameSpan, _ := findExtensionRangeOptionSpan(r, md, i, extRange, + internal.ExtensionRangeOptionsDeclarationTag, int32(i), internal.ExtensionRangeOptionsDeclarationFullNameTag) + if !strings.HasPrefix(extDecl.GetFullName(), ".") { + if err := handler.HandleErrorf(extensionNameSpan, "extension declaration full name %q should start with a leading dot (.)", extDecl.GetFullName()); err != nil { + return err + } + extensionFullName = protoreflect.FullName(extDecl.GetFullName()) + } else { + extensionFullName = protoreflect.FullName(extDecl.GetFullName()[1:]) + } + if !extensionFullName.IsValid() { + if err := handler.HandleErrorf(extensionNameSpan, "extension declaration full name %q is not a valid qualified name", extDecl.GetFullName()); err != nil { + return err + } + } + if err := symbols.AddExtensionDeclaration(extensionFullName, md.FullName(), protoreflect.FieldNumber(extDecl.GetNumber()), extensionNameSpan, handler); err != nil { + return err + } + + if extDecl.Type == nil { + span, _ := findExtensionRangeOptionSpan(r, md, i, extRange, internal.ExtensionRangeOptionsDeclarationTag, int32(i)) + if err := handler.HandleErrorf(span, "extension declaration that is not marked reserved must have a type"); err != nil { + return err + } + } + if strings.HasPrefix(extDecl.GetType(), ".") { + if !protoreflect.FullName(extDecl.GetType()[1:]).IsValid() { + span, _ := findExtensionRangeOptionSpan(r, md, i, extRange, + internal.ExtensionRangeOptionsDeclarationTag, int32(i), internal.ExtensionRangeOptionsDeclarationTypeTag) + if err := handler.HandleErrorf(span, "extension declaration type %q is not a valid qualified name", extDecl.GetType()); err != nil { + return err + } + } + } else if !isBuiltinTypeName(extDecl.GetType()) { + span, _ := findExtensionRangeOptionSpan(r, md, i, extRange, + internal.ExtensionRangeOptionsDeclarationTag, int32(i), internal.ExtensionRangeOptionsDeclarationTypeTag) + if err := handler.HandleErrorf(span, "extension declaration type %q must be a builtin type or start with a leading dot (.)", extDecl.GetType()); err != nil { + return err + } + } + } + } + return nil +} + func (r *result) hasCustomJSONName(fdProto *descriptorpb.FieldDescriptorProto) bool { // if we have the AST, we can more precisely determine if there was a custom // JSON named defined, even if it is explicitly configured to tbe the same @@ -302,3 +808,345 @@ func enumValCamelCase(name string) string { } return string(js) } + +func isBuiltinTypeName(typeName string) bool { + switch typeName { + case "int32", "int64", "uint32", "uint64", "sint32", "sint64", + "fixed32", "fixed64", "sfixed32", "sfixed64", + "bool", "double", "float", "string", "bytes": + return true + default: + return false + } +} + +func getTypeName(fd protoreflect.FieldDescriptor) string { + switch fd.Kind() { + case protoreflect.MessageKind, protoreflect.GroupKind: + return "." + string(fd.Message().FullName()) + case protoreflect.EnumKind: + return "." + string(fd.Enum().FullName()) + default: + return fd.Kind().String() + } +} + +func findExtensionRangeOptionSpan( + file protoreflect.FileDescriptor, + extended protoreflect.MessageDescriptor, + extRangeIndex int, + extRange *descriptorpb.DescriptorProto_ExtensionRange, + path ...int32, +) (ast.SourceSpan, bool) { + // NB: Typically, we have an AST for a file and NOT source code info, because the + // compiler validates options before computing source code info. However, we might + // be validating an extension (whose source/AST we have), but whose extendee (and + // thus extension range options for declarations) could be in some other file, which + // could be provided to the compiler as an already-compiled descriptor. So this + // function can fallback to using source code info if an AST is not available. + + if r, ok := file.(Result); ok && r.AST() != nil { + // Find the location using the AST, which will generally be higher fidelity + // than what we might find in a file descriptor's source code info. + exts := r.ExtensionsNode(extRange) + return findOptionSpan(r.FileNode(), exts, extRange.Options.ProtoReflect().Descriptor(), path...) + } + + srcLocs := file.SourceLocations() + if srcLocs.Len() == 0 { + // no source code info, can't do any better than the filename. We + // return true as the boolean so the caller doesn't try again with + // an alternate path, since we won't be able to do any better. + return ast.UnknownSpan(file.Path()), true + } + msgPath, ok := internal.ComputePath(extended) + if !ok { + // Same as above: return true since no subsequent query can do better. + return ast.UnknownSpan(file.Path()), true + } + + //nolint:gocritic // intentionally assigning to different slice variables + extRangePath := append(msgPath, internal.MessageExtensionRangesTag, int32(extRangeIndex)) + optsPath := append(extRangePath, internal.ExtensionRangeOptionsTag) //nolint:gocritic + fullPath := append(optsPath, path...) //nolint:gocritic + srcLoc := srcLocs.ByPath(fullPath) + if srcLoc.Path != nil { + // found it + return asSpan(file.Path(), srcLoc), true + } + + // Slow path to find closest match :/ + // We look for longest matching path that is at least len(extRangePath) + // long. If we find a path that is longer (meaning a path that points INSIDE + // the request element), accept the first such location. + var bestMatch protoreflect.SourceLocation + var bestMatchPathLen int + for i, length := 0, srcLocs.Len(); i < length; i++ { + srcLoc := srcLocs.Get(i) + if len(srcLoc.Path) >= len(extRangePath) && + isDescendantPath(fullPath, srcLoc.Path) && + len(srcLoc.Path) > bestMatchPathLen { + bestMatch = srcLoc + bestMatchPathLen = len(srcLoc.Path) + } else if isDescendantPath(srcLoc.Path, path) { + return asSpan(file.Path(), srcLoc), false + } + } + if bestMatchPathLen > 0 { + return asSpan(file.Path(), bestMatch), false + } + return ast.UnknownSpan(file.Path()), false +} + +func (r *result) findScalarOptionSpan( + root ast.NodeWithOptions, + name string, +) ast.SourceSpan { + match := ast.Node(root) + root.RangeOptions(func(n *ast.OptionNode) bool { + if len(n.Name.Parts) == 1 && !n.Name.Parts[0].IsExtension() && + string(n.Name.Parts[0].Name.AsIdentifier()) == name { + match = n + return false + } + return true + }) + return r.FileNode().NodeInfo(match) +} + +func (r *result) findOptionSpan( + d protoutil.DescriptorProtoWrapper, + path ...int32, +) ast.SourceSpan { + node := r.Node(d.AsProto()) + nodeWithOpts, ok := node.(ast.NodeWithOptions) + if !ok { + return r.FileNode().NodeInfo(node) + } + span, _ := findOptionSpan(r.FileNode(), nodeWithOpts, d.Options().ProtoReflect().Descriptor(), path...) + return span +} + +func findOptionSpan( + file ast.FileDeclNode, + root ast.NodeWithOptions, + md protoreflect.MessageDescriptor, + path ...int32, +) (ast.SourceSpan, bool) { + bestMatch := ast.Node(root) + var bestMatchLen int + var repeatedIndices []int + root.RangeOptions(func(n *ast.OptionNode) bool { + desc := md + limit := len(n.Name.Parts) + if limit > len(path) { + limit = len(path) + } + var nextIsIndex bool + for i := 0; i < limit; i++ { + if desc == nil || nextIsIndex { + // Can't match anymore. Try next option. + return true + } + wantField := desc.Fields().ByNumber(protoreflect.FieldNumber(path[i])) + if wantField == nil { + // Should not be possible... next option won't fare any better since + // it's a disagreement between given path and given descriptor so bail. + return false + } + if n.Name.Parts[i].Open != nil || + string(n.Name.Parts[i].Name.AsIdentifier()) != string(wantField.Name()) { + // This is an extension/custom option or indicates the wrong name. + // Try the next one. + return true + } + desc = wantField.Message() + nextIsIndex = wantField.Cardinality() == protoreflect.Repeated + } + // If we made it this far, we've matched everything so far. + if len(n.Name.Parts) >= len(path) { + // Either an exact match (if equal) or this option points *inside* the + // item we care about (if greater). Either way, the first such result + // is a keeper. + bestMatch = n.Name.Parts[len(path)-1] + bestMatchLen = len(n.Name.Parts) + return false + } + // We've got more path elements to try to match with the value. + match, matchLen := findMatchingValueNode( + desc, + path[len(n.Name.Parts):], + nextIsIndex, + 0, + &repeatedIndices, + n, + n.Val) + if match != nil { + totalMatchLen := matchLen + len(n.Name.Parts) + if totalMatchLen > bestMatchLen { + bestMatch, bestMatchLen = match, totalMatchLen + } + } + return bestMatchLen != len(path) // no exact match, so keep looking + }) + return file.NodeInfo(bestMatch), bestMatchLen == len(path) +} + +func findMatchingValueNode( + md protoreflect.MessageDescriptor, + path protoreflect.SourcePath, + currIsRepeated bool, + repeatedCount int, + repeatedIndices *[]int, + node ast.Node, + val ast.ValueNode, +) (ast.Node, int) { + var matchLen int + var index int + if currIsRepeated { + // Compute the index of the current value (or, if an array literal, the + // index of the first value in the array). + if len(*repeatedIndices) > repeatedCount { + (*repeatedIndices)[repeatedCount]++ + index = (*repeatedIndices)[repeatedCount] + } else { + *repeatedIndices = append(*repeatedIndices, 0) + index = 0 + } + repeatedCount++ + } + + if arrayVal, ok := val.(*ast.ArrayLiteralNode); ok { + if !currIsRepeated { + // This should not happen. + return nil, 0 + } + offset := int(path[0]) - index + if offset >= len(arrayVal.Elements) { + // The index we are looking for is not in this array. + return nil, 0 + } + elem := arrayVal.Elements[offset] + // We've matched the index! + matchLen++ + path = path[1:] + // Recurse into array element. + nextMatch, nextMatchLen := findMatchingValueNode( + md, + path, + false, + repeatedCount, + repeatedIndices, + elem, + elem, + ) + return nextMatch, nextMatchLen + matchLen + } + + if currIsRepeated { + if index != int(path[0]) { + // Not a match! + return nil, 0 + } + // We've matched the index! + matchLen++ + path = path[1:] + if len(path) == 0 { + // We're done matching! + return node, matchLen + } + } + + msgValue, ok := val.(*ast.MessageLiteralNode) + if !ok { + // We can't go any further + return node, matchLen + } + + var wantField protoreflect.FieldDescriptor + if md != nil { + wantField = md.Fields().ByNumber(protoreflect.FieldNumber(path[0])) + } + if wantField == nil { + // Should not be possible... next option won't fare any better since + // it's a disagreement between given path and given descriptor so bail. + return nil, 0 + } + for _, field := range msgValue.Elements { + if field.Name.Open != nil || + string(field.Name.Name.AsIdentifier()) != string(wantField.Name()) { + // This is an extension/custom option or indicates the wrong name. + // Try the next one. + continue + } + // We've matched this field. + matchLen++ + path = path[1:] + if len(path) == 0 { + // Perfect match! + return field, matchLen + } + nextMatch, nextMatchLen := findMatchingValueNode( + wantField.Message(), + path, + wantField.Cardinality() == protoreflect.Repeated, + repeatedCount, + repeatedIndices, + field, + field.Val, + ) + return nextMatch, nextMatchLen + matchLen + } + + // If we didn't find the right field, just return what we have so far. + return node, matchLen +} + +func isDescendantPath(descendant, ancestor protoreflect.SourcePath) bool { + if len(descendant) < len(ancestor) { + return false + } + for i := range ancestor { + if descendant[i] != ancestor[i] { + return false + } + } + return true +} + +func asSpan(file string, srcLoc protoreflect.SourceLocation) ast.SourceSpan { + return ast.NewSourceSpan( + ast.SourcePos{ + Filename: file, + Line: srcLoc.StartLine + 1, + Col: srcLoc.StartColumn + 1, + }, + ast.SourcePos{ + Filename: file, + Line: srcLoc.EndLine + 1, + Col: srcLoc.EndColumn + 1, + }, + ) +} + +func (r *result) getImportLocation(path string) ast.SourceSpan { + node, ok := r.FileNode().(*ast.FileNode) + if !ok { + return ast.UnknownSpan(path) + } + for _, decl := range node.Decls { + imp, ok := decl.(*ast.ImportNode) + if !ok { + continue + } + if imp.Name.AsString() == path { + return node.NodeInfo(imp.Name) + } + } + // Couldn't find it? Should never happen... + return ast.UnknownSpan(path) +} + +func isEditions(r *result) bool { + return descriptorpb.Edition(r.Edition()) >= descriptorpb.Edition_EDITION_2023 +} diff --git a/vendor/github.com/bufbuild/protocompile/options/options.go b/vendor/github.com/bufbuild/protocompile/options/options.go index 222fe8e169e..103531af2c5 100644 --- a/vendor/github.com/bufbuild/protocompile/options/options.go +++ b/vendor/github.com/bufbuild/protocompile/options/options.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -30,11 +30,9 @@ import ( "errors" "fmt" "math" - "sort" "strings" "google.golang.org/protobuf/encoding/prototext" - "google.golang.org/protobuf/encoding/protowire" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/reflect/protoregistry" @@ -62,11 +60,11 @@ var ( type interpreter struct { file file resolver linker.Resolver - container optionsContainer overrideDescriptorProto linker.File lenient bool reporter *reporter.Handler index sourceinfo.OptionIndex + pathBuffer []int32 } type file interface { @@ -138,59 +136,72 @@ func InterpretUnlinkedOptions(parsed parser.Result, opts ...InterpreterOption) ( func interpretOptions(lenient bool, file file, res linker.Resolver, handler *reporter.Handler, interpOpts []InterpreterOption) (sourceinfo.OptionIndex, error) { interp := interpreter{ - file: file, - resolver: res, - lenient: lenient, - reporter: handler, - index: sourceinfo.OptionIndex{}, + file: file, + resolver: res, + lenient: lenient, + reporter: handler, + index: sourceinfo.OptionIndex{}, + pathBuffer: make([]int32, 0, 16), } - interp.container, _ = file.(optionsContainer) for _, opt := range interpOpts { opt(&interp) } + // We have to do this in two phases. First we interpret non-custom options. + // This allows us to handle standard options and features that may needed to + // correctly reference the custom options in the second phase. + if err := interp.interpretFileOptions(file, false); err != nil { + return nil, err + } + // Now we can do custom options. + if err := interp.interpretFileOptions(file, true); err != nil { + return nil, err + } + return interp.index, nil +} +func (interp *interpreter) interpretFileOptions(file file, customOpts bool) error { fd := file.FileDescriptorProto() prefix := fd.GetPackage() if prefix != "" { prefix += "." } - err := interpretElementOptions(&interp, fd.GetName(), targetTypeFile, fd) + err := interpretElementOptions(interp, fd.GetName(), targetTypeFile, fd, customOpts) if err != nil { - return nil, err + return err } for _, md := range fd.GetMessageType() { fqn := prefix + md.GetName() - if err := interp.interpretMessageOptions(fqn, md); err != nil { - return nil, err + if err := interp.interpretMessageOptions(fqn, md, customOpts); err != nil { + return err } } for _, fld := range fd.GetExtension() { fqn := prefix + fld.GetName() - if err := interp.interpretFieldOptions(fqn, fld); err != nil { - return nil, err + if err := interp.interpretFieldOptions(fqn, fld, customOpts); err != nil { + return err } } for _, ed := range fd.GetEnumType() { fqn := prefix + ed.GetName() - if err := interp.interpretEnumOptions(fqn, ed); err != nil { - return nil, err + if err := interp.interpretEnumOptions(fqn, ed, customOpts); err != nil { + return err } } for _, sd := range fd.GetService() { fqn := prefix + sd.GetName() - err := interpretElementOptions(&interp, fqn, targetTypeService, sd) + err := interpretElementOptions(interp, fqn, targetTypeService, sd, customOpts) if err != nil { - return nil, err + return err } for _, mtd := range sd.GetMethod() { mtdFqn := fqn + "." + mtd.GetName() - err := interpretElementOptions(&interp, mtdFqn, targetTypeMethod, mtd) + err := interpretElementOptions(interp, mtdFqn, targetTypeMethod, mtd, customOpts) if err != nil { - return nil, err + return err } } } - return interp.index, nil + return nil } func resolveDescriptor[T protoreflect.Descriptor](res linker.Resolver, name string) T { @@ -245,46 +256,46 @@ func (interp *interpreter) nodeInfo(n ast.Node) ast.NodeInfo { return interp.file.FileNode().NodeInfo(n) } -func (interp *interpreter) interpretMessageOptions(fqn string, md *descriptorpb.DescriptorProto) error { - err := interpretElementOptions(interp, fqn, targetTypeMessage, md) +func (interp *interpreter) interpretMessageOptions(fqn string, md *descriptorpb.DescriptorProto, customOpts bool) error { + err := interpretElementOptions(interp, fqn, targetTypeMessage, md, customOpts) if err != nil { return err } for _, fld := range md.GetField() { fldFqn := fqn + "." + fld.GetName() - if err := interp.interpretFieldOptions(fldFqn, fld); err != nil { + if err := interp.interpretFieldOptions(fldFqn, fld, customOpts); err != nil { return err } } for _, ood := range md.GetOneofDecl() { oodFqn := fqn + "." + ood.GetName() - err := interpretElementOptions(interp, oodFqn, targetTypeOneof, ood) + err := interpretElementOptions(interp, oodFqn, targetTypeOneof, ood, customOpts) if err != nil { return err } } for _, fld := range md.GetExtension() { fldFqn := fqn + "." + fld.GetName() - if err := interp.interpretFieldOptions(fldFqn, fld); err != nil { + if err := interp.interpretFieldOptions(fldFqn, fld, customOpts); err != nil { return err } } for _, er := range md.GetExtensionRange() { erFqn := fmt.Sprintf("%s.%d-%d", fqn, er.GetStart(), er.GetEnd()) - err := interpretElementOptions(interp, erFqn, targetTypeExtensionRange, er) + err := interpretElementOptions(interp, erFqn, targetTypeExtensionRange, er, customOpts) if err != nil { return err } } for _, nmd := range md.GetNestedType() { nmdFqn := fqn + "." + nmd.GetName() - if err := interp.interpretMessageOptions(nmdFqn, nmd); err != nil { + if err := interp.interpretMessageOptions(nmdFqn, nmd, customOpts); err != nil { return err } } for _, ed := range md.GetEnumType() { edFqn := fqn + "." + ed.GetName() - if err := interp.interpretEnumOptions(edFqn, ed); err != nil { + if err := interp.interpretEnumOptions(edFqn, ed, customOpts); err != nil { return err } } @@ -328,12 +339,12 @@ func (interp *interpreter) interpretMessageOptions(fqn string, md *descriptorpb. var emptyFieldOptions = &descriptorpb.FieldOptions{} -func (interp *interpreter) interpretFieldOptions(fqn string, fld *descriptorpb.FieldDescriptorProto) error { +func (interp *interpreter) interpretFieldOptions(fqn string, fld *descriptorpb.FieldDescriptorProto, customOpts bool) error { opts := fld.GetOptions() emptyOptionsAlreadyPresent := opts != nil && len(opts.GetUninterpretedOption()) == 0 - // First process pseudo-options - if len(opts.GetUninterpretedOption()) > 0 { + // For non-custom phase, first process pseudo-options + if len(opts.GetUninterpretedOption()) > 0 && !customOpts { if err := interp.interpretFieldPseudoOptions(fqn, fld, opts); err != nil { return err } @@ -351,7 +362,7 @@ func (interp *interpreter) interpretFieldOptions(fqn string, fld *descriptorpb.F } // Then process actual options. - return interpretElementOptions(interp, fqn, targetTypeField, fld) + return interpretElementOptions(interp, fqn, targetTypeField, fld, customOpts) } func (interp *interpreter) interpretFieldPseudoOptions(fqn string, fld *descriptorpb.FieldDescriptorProto, opts *descriptorpb.FieldOptions) error { @@ -508,14 +519,14 @@ func encodeDefaultBytes(b []byte) string { return buf.String() } -func (interp *interpreter) interpretEnumOptions(fqn string, ed *descriptorpb.EnumDescriptorProto) error { - err := interpretElementOptions(interp, fqn, targetTypeEnum, ed) +func (interp *interpreter) interpretEnumOptions(fqn string, ed *descriptorpb.EnumDescriptorProto, customOpts bool) error { + err := interpretElementOptions(interp, fqn, targetTypeEnum, ed, customOpts) if err != nil { return err } for _, evd := range ed.GetValue() { evdFqn := fqn + "." + evd.GetName() - err := interpretElementOptions(interp, evdFqn, targetTypeEnumValue, evd) + err := interpretElementOptions(interp, evdFqn, targetTypeEnumValue, evd, customOpts) if err != nil { return err } @@ -523,328 +534,17 @@ func (interp *interpreter) interpretEnumOptions(fqn string, ed *descriptorpb.Enu return nil } -// interpretedOption represents the result of interpreting an option. -// This includes metadata that allows the option to be serialized to -// bytes in a way that is deterministic and can preserve the structure -// of the source (the way the options are de-structured and the order in -// which options appear). -type interpretedOption struct { - unknown bool - pathPrefix []int32 - interpretedField -} - -func (o *interpretedOption) toSourceInfo() *sourceinfo.OptionSourceInfo { - return o.interpretedField.toSourceInfo(o.pathPrefix) -} - -func (o *interpretedOption) appendOptionBytes(b []byte) ([]byte, error) { - return o.appendOptionBytesWithPath(b, o.pathPrefix) -} - -func (o *interpretedOption) appendOptionBytesWithPath(b []byte, path []int32) ([]byte, error) { - if len(path) == 0 { - return appendOptionBytesSingle(b, &o.interpretedField) - } - // NB: if we add functions to compute sizes of the options first, we could - // allocate precisely sized slice up front, which would be more efficient than - // repeated creation/growing/concatenation. - enclosed, err := o.appendOptionBytesWithPath(nil, path[1:]) - if err != nil { - return nil, err - } - b = protowire.AppendTag(b, protowire.Number(path[0]), protowire.BytesType) - return protowire.AppendBytes(b, enclosed), nil -} - -// interpretedField represents a field in an options message that is the -// result of interpreting an option. This is used for the option value -// itself as well as for subfields when an option value is a message -// literal. -type interpretedField struct { - // the AST node for this field -- an [*ast.OptionNode] for top-level options, - // an [*ast.MessageFieldNode] for fields in a message literal, or nil for - // synthetic field values (for keys or values in map entries that were - // omitted from source). - node ast.Node - // field number - number int32 - // index of this element inside a repeated field; only set if repeated == true - index int32 - // true if this is a repeated field - repeated bool - // true if this is a repeated field that stores scalar values in packed form - packed bool - // the field's kind - kind protoreflect.Kind - - value interpretedFieldValue -} - -func (f *interpretedField) path(prefix []int32) []int32 { - path := make([]int32, 0, len(prefix)+2) - path = append(path, prefix...) - path = append(path, f.number) - if f.repeated { - path = append(path, f.index) - } - return path -} - -func (f *interpretedField) toSourceInfo(prefix []int32) *sourceinfo.OptionSourceInfo { - path := f.path(prefix) - var children sourceinfo.OptionChildrenSourceInfo - if len(f.value.msgListVal) > 0 { - elements := make([]sourceinfo.OptionSourceInfo, len(f.value.msgListVal)) - for i, msgVal := range f.value.msgListVal { - // With an array literal, the index in path is that of the first element. - elementPath := append(([]int32)(nil), path...) - elementPath[len(elementPath)-1] += int32(i) - elements[i].Path = elementPath - elements[i].Children = msgSourceInfo(elementPath, msgVal) - } - children = &sourceinfo.ArrayLiteralSourceInfo{Elements: elements} - } else if len(f.value.msgVal) > 0 { - children = msgSourceInfo(path, f.value.msgVal) - } - return &sourceinfo.OptionSourceInfo{ - Path: path, - Children: children, - } -} - -func msgSourceInfo(prefix []int32, fields []*interpretedField) *sourceinfo.MessageLiteralSourceInfo { - fieldInfo := map[*ast.MessageFieldNode]*sourceinfo.OptionSourceInfo{} - for _, field := range fields { - msgFieldNode, ok := field.node.(*ast.MessageFieldNode) - if !ok { - continue - } - fieldInfo[msgFieldNode] = field.toSourceInfo(prefix) - } - return &sourceinfo.MessageLiteralSourceInfo{Fields: fieldInfo} -} - -// interpretedFieldValue is a wrapper around protoreflect.Value that -// includes extra metadata. -type interpretedFieldValue struct { - // the bytes for this field value if already pre-serialized - // (when this is set, the other fields are ignored) - preserialized []byte - - // the field value - val protoreflect.Value - // if true, this value is a list of values, not a singular value - isList bool - // non-nil for singular message values - msgVal []*interpretedField - // non-nil for non-empty lists of message values - msgListVal [][]*interpretedField -} - -func appendOptionBytes(b []byte, flds []*interpretedField) ([]byte, error) { - // protoc emits messages sorted by field number - if len(flds) > 1 { - sort.SliceStable(flds, func(i, j int) bool { - return flds[i].number < flds[j].number - }) - } - - for i := 0; i < len(flds); i++ { - f := flds[i] - if f.value.preserialized != nil { - b = append(b, f.value.preserialized...) - continue - } - switch { - case f.packed && canPack(f.kind): - // for packed repeated numeric fields, all runs of values are merged into one packed list - num := f.number - j := i - for j < len(flds) && flds[j].number == num { - j++ - } - // now flds[i:j] is the range of contiguous fields for the same field number - enclosed, err := appendOptionBytesPacked(nil, f.kind, flds[i:j]) - if err != nil { - return nil, err - } - b = protowire.AppendTag(b, protowire.Number(f.number), protowire.BytesType) - b = protowire.AppendBytes(b, enclosed) - // skip over the other subsequent fields we just serialized - i = j - 1 - case f.value.isList: - // if not packed, then emit one value at a time - single := *f - single.value.isList = false - single.value.msgListVal = nil - l := f.value.val.List() - for i := 0; i < l.Len(); i++ { - single.value.val = l.Get(i) - if f.kind == protoreflect.MessageKind || f.kind == protoreflect.GroupKind { - single.value.msgVal = f.value.msgListVal[i] - } - var err error - b, err = appendOptionBytesSingle(b, &single) - if err != nil { - return nil, err - } - } - default: - // simple singular value - var err error - b, err = appendOptionBytesSingle(b, f) - if err != nil { - return nil, err - } - } - } - - return b, nil -} - -func canPack(k protoreflect.Kind) bool { - switch k { - case protoreflect.MessageKind, protoreflect.GroupKind, protoreflect.StringKind, protoreflect.BytesKind: - return false - default: - return true - } -} - -func appendOptionBytesPacked(b []byte, k protoreflect.Kind, flds []*interpretedField) ([]byte, error) { - for i := range flds { - val := flds[i].value - if val.isList { - l := val.val.List() - var err error - b, err = appendNumericValueBytesPacked(b, k, l) - if err != nil { - return nil, err - } - } else { - var err error - b, err = appendNumericValueBytes(b, k, val.val) - if err != nil { - return nil, err - } - } - } - return b, nil -} - -func appendOptionBytesSingle(b []byte, f *interpretedField) ([]byte, error) { - if f.value.preserialized != nil { - return append(b, f.value.preserialized...), nil - } - num := protowire.Number(f.number) - switch f.kind { - case protoreflect.MessageKind: - enclosed, err := appendOptionBytes(nil, f.value.msgVal) - if err != nil { - return nil, err - } - b = protowire.AppendTag(b, num, protowire.BytesType) - return protowire.AppendBytes(b, enclosed), nil - - case protoreflect.GroupKind: - b = protowire.AppendTag(b, num, protowire.StartGroupType) - var err error - b, err = appendOptionBytes(b, f.value.msgVal) - if err != nil { - return nil, err - } - return protowire.AppendTag(b, num, protowire.EndGroupType), nil - - case protoreflect.StringKind: - b = protowire.AppendTag(b, num, protowire.BytesType) - return protowire.AppendString(b, f.value.val.String()), nil - - case protoreflect.BytesKind: - b = protowire.AppendTag(b, num, protowire.BytesType) - return protowire.AppendBytes(b, f.value.val.Bytes()), nil - - case protoreflect.Int32Kind, protoreflect.Int64Kind, protoreflect.Uint32Kind, protoreflect.Uint64Kind, - protoreflect.Sint32Kind, protoreflect.Sint64Kind, protoreflect.EnumKind, protoreflect.BoolKind: - b = protowire.AppendTag(b, num, protowire.VarintType) - return appendNumericValueBytes(b, f.kind, f.value.val) - - case protoreflect.Fixed32Kind, protoreflect.Sfixed32Kind, protoreflect.FloatKind: - b = protowire.AppendTag(b, num, protowire.Fixed32Type) - return appendNumericValueBytes(b, f.kind, f.value.val) - - case protoreflect.Fixed64Kind, protoreflect.Sfixed64Kind, protoreflect.DoubleKind: - b = protowire.AppendTag(b, num, protowire.Fixed64Type) - return appendNumericValueBytes(b, f.kind, f.value.val) - - default: - return nil, fmt.Errorf("unknown field kind: %v", f.kind) - } -} - -func appendNumericValueBytesPacked(b []byte, k protoreflect.Kind, l protoreflect.List) ([]byte, error) { - for i := 0; i < l.Len(); i++ { - var err error - b, err = appendNumericValueBytes(b, k, l.Get(i)) - if err != nil { - return nil, err - } - } - return b, nil -} - -func appendNumericValueBytes(b []byte, k protoreflect.Kind, v protoreflect.Value) ([]byte, error) { - switch k { - case protoreflect.Int32Kind, protoreflect.Int64Kind: - return protowire.AppendVarint(b, uint64(v.Int())), nil - case protoreflect.Uint32Kind, protoreflect.Uint64Kind: - return protowire.AppendVarint(b, v.Uint()), nil - case protoreflect.Sint32Kind, protoreflect.Sint64Kind: - return protowire.AppendVarint(b, protowire.EncodeZigZag(v.Int())), nil - case protoreflect.Fixed32Kind: - return protowire.AppendFixed32(b, uint32(v.Uint())), nil - case protoreflect.Fixed64Kind: - return protowire.AppendFixed64(b, v.Uint()), nil - case protoreflect.Sfixed32Kind: - return protowire.AppendFixed32(b, uint32(v.Int())), nil - case protoreflect.Sfixed64Kind: - return protowire.AppendFixed64(b, uint64(v.Int())), nil - case protoreflect.FloatKind: - return protowire.AppendFixed32(b, math.Float32bits(float32(v.Float()))), nil - case protoreflect.DoubleKind: - return protowire.AppendFixed64(b, math.Float64bits(v.Float())), nil - case protoreflect.BoolKind: - return protowire.AppendVarint(b, protowire.EncodeBool(v.Bool())), nil - case protoreflect.EnumKind: - return protowire.AppendVarint(b, uint64(v.Enum())), nil - default: - return nil, fmt.Errorf("unknown field kind: %v", k) - } -} - -// optionsContainer may be optionally implemented by a linker.Result. It is -// not part of the linker.Result interface as it is meant only for internal use. -// This allows the option interpreter step to store extra metadata about the -// serialized structure of options. -type optionsContainer interface { - // AddOptionBytes adds the given pre-serialized option bytes to a file, - // associated with the given options message. The type of the given message - // should be an options message, for example *descriptorpb.MessageOptions. - // This value should be part of the message hierarchy whose root is the - // *descriptorpb.FileDescriptorProto that corresponds to this result. - AddOptionBytes(pm proto.Message, opts []byte) -} - func interpretElementOptions[Elem elementType[OptsStruct, Opts], OptsStruct any, Opts optionsType[OptsStruct]]( interp *interpreter, fqn string, target *targetType[Elem, OptsStruct, Opts], elem Elem, + customOpts bool, ) error { opts := elem.GetOptions() uo := opts.GetUninterpretedOption() if len(uo) > 0 { - remain, err := interp.interpretOptions(fqn, target.t, elem, opts, uo) + remain, err := interp.interpretOptions(fqn, target.t, elem, opts, uo, customOpts) if err != nil { return err } @@ -863,6 +563,7 @@ func (interp *interpreter) interpretOptions( targetType descriptorpb.FieldOptions_OptionTargetType, element, opts proto.Message, uninterpreted []*descriptorpb.UninterpretedOption, + customOpts bool, ) ([]*descriptorpb.UninterpretedOption, error) { optsDesc := opts.ProtoReflect().Descriptor() optsFqn := string(optsDesc.FullName()) @@ -885,9 +586,13 @@ func (interp *interpreter) interpretOptions( ElementType: descriptorType(element), } var remain []*descriptorpb.UninterpretedOption - results := make([]*interpretedOption, 0, len(uninterpreted)) - var featuresInfo []*interpretedOption + var features []*ast.OptionNode for _, uo := range uninterpreted { + if uo.Name[0].GetIsExtension() != customOpts { + // We're not looking at these this phase. + remain = append(remain, uo) + continue + } node := interp.file.OptionNode(uo) if !uo.Name[0].GetIsExtension() && uo.Name[0].GetNamePart() == "uninterpreted_option" { if interp.lenient { @@ -900,7 +605,7 @@ func (interp *interpreter) interpretOptions( } } mc.Option = uo - res, err := interp.interpretField(mc, msg, uo, 0, nil) + srcInfo, err := interp.interpretField(mc, msg, uo, 0, interp.pathBuffer) if err != nil { if interp.lenient { remain = append(remain, uo) @@ -908,18 +613,17 @@ func (interp *interpreter) interpretOptions( } return nil, err } - res.unknown = !isKnownField(optsDesc, res) - results = append(results, res) - if !uo.Name[0].GetIsExtension() && uo.Name[0].GetNamePart() == featuresFieldName { - featuresInfo = append(featuresInfo, res) - } if optn, ok := node.(*ast.OptionNode); ok { - si := res.toSourceInfo() - interp.index[optn] = si + if !uo.Name[0].GetIsExtension() && uo.Name[0].GetNamePart() == featuresFieldName { + features = append(features, optn) + } + if srcInfo != nil { + interp.index[optn] = srcInfo + } } } - if err := interp.validateFeatures(targetType, msg, featuresInfo); err != nil && !interp.lenient { + if err := interp.validateFeatures(targetType, msg, features); err != nil && !interp.lenient { return nil, err } @@ -938,14 +642,6 @@ func (interp *interpreter) interpretOptions( proto.Reset(opts) proto.Merge(opts, optsClone) - if interp.container != nil { - b, err := interp.toOptionBytes(mc, results) - if err != nil { - return nil, err - } - interp.container.AddOptionBytes(opts, b) - } - return remain, nil } @@ -962,21 +658,13 @@ func (interp *interpreter) interpretOptions( return nil, interp.reporter.HandleError(reporter.Error(interp.nodeInfo(node), err)) } - if interp.container != nil { - b, err := interp.toOptionBytes(mc, results) - if err != nil { - return nil, err - } - interp.container.AddOptionBytes(opts, b) - } - - return nil, nil + return remain, nil } func (interp *interpreter) validateFeatures( targetType descriptorpb.FieldOptions_OptionTargetType, opts protoreflect.Message, - featuresInfo []*interpretedOption, + features []*ast.OptionNode, ) error { fld := opts.Descriptor().Fields().ByName(featuresFieldName) if fld == nil { @@ -988,9 +676,9 @@ func (interp *interpreter) validateFeatures( // TODO: should this return an error? return nil } - features := opts.Get(fld).Message() + featureSet := opts.Get(fld).Message() var err error - features.Range(func(featureField protoreflect.FieldDescriptor, _ protoreflect.Value) bool { + featureSet.Range(func(featureField protoreflect.FieldDescriptor, _ protoreflect.Value) bool { opts, ok := featureField.Options().(*descriptorpb.FieldOptions) if !ok { return true @@ -1008,7 +696,7 @@ func (interp *interpreter) validateFeatures( for i, t := range opts.Targets { allowedTypes[i] = targetTypeString(t) } - pos := interp.positionOfFeature(featuresInfo, fld.Number(), featureField.Number()) + pos := interp.positionOfFeature(features, featuresFieldName, featureField.Name()) if len(opts.Targets) == 1 && opts.Targets[0] == descriptorpb.FieldOptions_TARGET_TYPE_UNKNOWN { err = interp.reporter.HandleErrorf(pos, "feature field %q may not be used explicitly", featureField.Name()) } else { @@ -1020,55 +708,51 @@ func (interp *interpreter) validateFeatures( return err } -func (interp *interpreter) positionOfFeature(featuresInfo []*interpretedOption, fieldNumbers ...protoreflect.FieldNumber) ast.SourceSpan { +func (interp *interpreter) positionOfFeature(features []*ast.OptionNode, fieldNames ...protoreflect.Name) ast.SourceSpan { if interp.file.AST() == nil { return ast.UnknownSpan(interp.file.FileDescriptorProto().GetName()) } - for _, info := range featuresInfo { - matched, remainingNumbers, node := matchInterpretedOption(info, fieldNumbers) + for _, feature := range features { + matched, remainingNames, nodePos, nodeValue := matchInterpretedOption(feature, fieldNames) if !matched { continue } - if len(remainingNumbers) > 0 { - node = findInterpretedFieldForFeature(&(info.interpretedField), remainingNumbers) + if len(remainingNames) > 0 { + nodePos = findInterpretedFieldForFeature(nodePos, nodeValue, remainingNames) } - if node != nil { - return interp.file.FileNode().NodeInfo(node) + if nodePos != nil { + return interp.file.FileNode().NodeInfo(nodePos) } } return ast.UnknownSpan(interp.file.FileDescriptorProto().GetName()) } -func matchInterpretedOption(info *interpretedOption, path []protoreflect.FieldNumber) (bool, []protoreflect.FieldNumber, ast.Node) { - for i := 0; i < len(path) && i < len(info.pathPrefix); i++ { - if info.pathPrefix[i] != int32(path[i]) { - return false, nil, nil +func matchInterpretedOption(node *ast.OptionNode, path []protoreflect.Name) (bool, []protoreflect.Name, ast.Node, ast.ValueNode) { + for i := 0; i < len(path) && i < len(node.Name.Parts); i++ { + part := node.Name.Parts[i] + if !part.IsExtension() && protoreflect.Name(part.Name.AsIdentifier()) != path[i] { + return false, nil, nil, nil } } - if len(path) <= len(info.pathPrefix) { - // no more path elements to match - node := info.node - if optsNode, ok := node.(*ast.OptionNode); ok { - // Do we need to check this? It should always be true... - if len(optsNode.Name.Parts) == len(info.pathPrefix)+1 { - node = optsNode.Name.Parts[len(path)-1] - } - } - return true, nil, node + if len(path) <= len(node.Name.Parts) { + // No more path elements to match. Report location + // of the final element of path inside option name. + return true, nil, node.Name.Parts[len(path)-1], node.Val } - if info.number != int32(path[len(info.pathPrefix)]) { - return false, nil, nil - } - return true, path[len(info.pathPrefix)+1:], info.node + return true, path[len(node.Name.Parts):], node.Name.Parts[len(node.Name.Parts)-1], node.Val } -func findInterpretedFieldForFeature(opt *interpretedField, path []protoreflect.FieldNumber) ast.Node { +func findInterpretedFieldForFeature(nodePos ast.Node, nodeValue ast.ValueNode, path []protoreflect.Name) ast.Node { if len(path) == 0 { - return opt.node + return nodePos } - for _, fld := range opt.value.msgVal { - if fld.number == int32(path[0]) { - if res := findInterpretedFieldForFeature(fld, path[1:]); res != nil { + msgNode, ok := nodeValue.(*ast.MessageLiteralNode) + if !ok { + return nil + } + for _, fldNode := range msgNode.Elements { + if fldNode.Name.Open == nil && protoreflect.Name(fldNode.Name.Name.AsIdentifier()) == path[0] { + if res := findInterpretedFieldForFeature(fldNode.Name, fldNode.Val, path[1:]); res != nil { return res } } @@ -1076,68 +760,6 @@ func findInterpretedFieldForFeature(opt *interpretedField, path []protoreflect.F return nil } -// isKnownField returns true if the given option is for a known field of the -// given options message descriptor and will be serialized using the expected -// wire type for that known field. -func isKnownField(desc protoreflect.MessageDescriptor, opt *interpretedOption) bool { - var num int32 - if len(opt.pathPrefix) > 0 { - num = opt.pathPrefix[0] - } else { - num = opt.number - } - fd := desc.Fields().ByNumber(protoreflect.FieldNumber(num)) - if fd == nil { - return false - } - - // Before the full wire type check, we do a quick check that will usually pass - // and allow us to short-circuit the logic below. - if fd.IsList() == opt.repeated && fd.Kind() == opt.kind { - return true - } - - // We figure out the wire type this interpreted field will use when serialized. - var wireType protowire.Type - switch { - case len(opt.pathPrefix) > 0: - // If path prefix exists, this field is nested inside a message. - // And messages use bytes wire type. - wireType = protowire.BytesType - case opt.repeated && opt.packed && canPack(opt.kind): - // Packed repeated numeric scalars use bytes wire type. - wireType = protowire.BytesType - default: - wireType = wireTypeForKind(opt.kind) - } - - // And then we see if the wire type we just determined is compatible with - // the field descriptor we found. - if fd.IsList() && canPack(fd.Kind()) && wireType == protowire.BytesType { - // Even if fd.IsPacked() is false, bytes type is still accepted for - // repeated scalar numerics, so that changing a repeated field from - // packed to not-packed (or vice versa) is a compatible change. - return true - } - return wireType == wireTypeForKind(fd.Kind()) -} - -func wireTypeForKind(kind protoreflect.Kind) protowire.Type { - switch kind { - case protoreflect.StringKind, protoreflect.BytesKind, protoreflect.MessageKind: - return protowire.BytesType - case protoreflect.GroupKind: - return protowire.StartGroupType - case protoreflect.Fixed32Kind, protoreflect.Sfixed32Kind, protoreflect.FloatKind: - return protowire.Fixed32Type - case protoreflect.Fixed64Kind, protoreflect.Sfixed64Kind, protoreflect.DoubleKind: - return protowire.Fixed64Type - default: - // everything else uses varint - return protowire.VarintType - } -} - func targetTypeString(t descriptorpb.FieldOptions_OptionTargetType) string { return strings.ToLower(strings.ReplaceAll(strings.TrimPrefix(t.String(), "TARGET_TYPE_"), "_", " ")) } @@ -1159,35 +781,6 @@ func cloneInto(dest proto.Message, src proto.Message, res linker.Resolver) error return proto.UnmarshalOptions{Resolver: res}.Unmarshal(data, dest) } -func (interp *interpreter) toOptionBytes(mc *internal.MessageContext, results []*interpretedOption) ([]byte, error) { - // protoc emits non-custom options in tag order and then - // the rest are emitted in the order they are defined in source - sort.SliceStable(results, func(i, j int) bool { - if !results[i].unknown && results[j].unknown { - return true - } - if !results[i].unknown && !results[j].unknown { - return results[i].number < results[j].number - } - return false - }) - var b []byte - for _, res := range results { - var err error - b, err = res.appendOptionBytes(b) - if err != nil { - if _, ok := err.(reporter.ErrorWithPos); !ok { - span := ast.UnknownSpan(interp.file.AST().Name()) - err = reporter.Errorf(span, "%sfailed to encode options: %w", mc, err) - } - if err := interp.reporter.HandleError(err); err != nil { - return nil, err - } - } - } - return b, nil -} - func validateRecursive(msg protoreflect.Message, prefix string) error { flds := msg.Descriptor().Fields() var missingFields []string @@ -1247,7 +840,13 @@ func validateRecursive(msg protoreflect.Message, prefix string) error { // msg must be an options message. For nameIndex > 0, msg is a nested message inside of the // options message. The given pathPrefix is the path (sequence of field numbers and indices // with a FileDescriptorProto as the start) up to but not including the given nameIndex. -func (interp *interpreter) interpretField(mc *internal.MessageContext, msg protoreflect.Message, opt *descriptorpb.UninterpretedOption, nameIndex int, pathPrefix []int32) (*interpretedOption, error) { +func (interp *interpreter) interpretField( + mc *internal.MessageContext, + msg protoreflect.Message, + opt *descriptorpb.UninterpretedOption, + nameIndex int, + pathPrefix []int32, +) (*sourceinfo.OptionSourceInfo, error) { var fld protoreflect.FieldDescriptor nm := opt.GetName()[nameIndex] node := interp.file.OptionNamePartNode(nm) @@ -1278,6 +877,7 @@ func (interp *interpreter) interpretField(mc *internal.MessageContext, msg proto mc, nm.GetNamePart(), msg.Descriptor().FullName()) } } + pathPrefix = append(pathPrefix, int32(fld.Number())) if len(opt.GetName()) > nameIndex+1 { nextnm := opt.GetName()[nameIndex+1] @@ -1311,223 +911,191 @@ func (interp *interpreter) interpretField(mc *internal.MessageContext, msg proto msg.Set(fld, fldVal) } // recurse to set next part of name - return interp.interpretField(mc, fdm, opt, nameIndex+1, append(pathPrefix, int32(fld.Number()))) + return interp.interpretField(mc, fdm, opt, nameIndex+1, pathPrefix) } optNode := interp.file.OptionNode(opt) optValNode := optNode.GetValue() - var val interpretedFieldValue - var index int + var srcInfo *sourceinfo.OptionSourceInfo var err error if optValNode.Value() == nil { - // We don't have an AST, so we get the value from the uninterpreted option proto. - // It's okay that we don't populate index as it is used to populate source code info, - // which can't be done without an AST. - val, err = interp.setOptionFieldFromProto(mc, msg, fld, node, opt, optValNode) + err = interp.setOptionFieldFromProto(mc, msg, fld, node, opt, optValNode) + srcInfoVal := newSrcInfo(pathPrefix, nil) + srcInfo = &srcInfoVal } else { - val, index, err = interp.setOptionField(mc, msg, fld, node, optValNode, false) + srcInfo, err = interp.setOptionField(mc, msg, fld, node, optValNode, false, pathPrefix) } if err != nil { return nil, interp.reporter.HandleError(err) } - return &interpretedOption{ - pathPrefix: pathPrefix, - interpretedField: interpretedField{ - node: optNode, - number: int32(fld.Number()), - index: int32(index), - kind: fld.Kind(), - repeated: fld.Cardinality() == protoreflect.Repeated, - value: val, - // NB: don't set packed here in a top-level option - // (only values in message literals will be serialized - // in packed format) - }, - }, nil + + return srcInfo, nil } // setOptionField sets the value for field fld in the given message msg to the value represented // by AST node val. The given name is the AST node that corresponds to the name of fld. On success, // it returns additional metadata about the field that was set. -func (interp *interpreter) setOptionField(mc *internal.MessageContext, msg protoreflect.Message, fld protoreflect.FieldDescriptor, name ast.Node, val ast.ValueNode, insideMsgLiteral bool) (interpretedFieldValue, int, error) { +func (interp *interpreter) setOptionField( + mc *internal.MessageContext, + msg protoreflect.Message, + fld protoreflect.FieldDescriptor, + name ast.Node, + val ast.ValueNode, + insideMsgLiteral bool, + pathPrefix []int32, +) (*sourceinfo.OptionSourceInfo, error) { v := val.Value() if sl, ok := v.([]ast.ValueNode); ok { // handle slices a little differently than the others if fld.Cardinality() != protoreflect.Repeated { - return interpretedFieldValue{}, 0, reporter.Errorf(interp.nodeInfo(val), "%vvalue is an array but field is not repeated", mc) + return nil, reporter.Errorf(interp.nodeInfo(val), "%vvalue is an array but field is not repeated", mc) } origPath := mc.OptAggPath defer func() { mc.OptAggPath = origPath }() - var resVal listValue - var resMsgVals [][]*interpretedField + childVals := make([]sourceinfo.OptionSourceInfo, len(sl)) var firstIndex int + if fld.IsMap() { + firstIndex = msg.Get(fld).Map().Len() + } else { + firstIndex = msg.Get(fld).List().Len() + } for index, item := range sl { mc.OptAggPath = fmt.Sprintf("%s[%d]", origPath, index) - value, err := interp.fieldValue(mc, msg, fld, item, insideMsgLiteral) + value, srcInfo, err := interp.fieldValue(mc, msg, fld, item, insideMsgLiteral, append(pathPrefix, int32(firstIndex+index))) if err != nil { - return interpretedFieldValue{}, 0, err + return nil, err } if fld.IsMap() { mv := msg.Mutable(fld).Map() - if index == 0 { - firstIndex = mv.Len() - } - setMapEntry(fld, msg, mv, &value) + setMapEntry(fld, msg, mv, value.Message()) } else { lv := msg.Mutable(fld).List() - if index == 0 { - firstIndex = lv.Len() - } - lv.Append(value.val) - } - resVal = append(resVal, value.val) - if value.msgVal != nil { - resMsgVals = append(resMsgVals, value.msgVal) + lv.Append(value) } + childVals[index] = srcInfo } - return interpretedFieldValue{ - isList: true, - val: protoreflect.ValueOfList(&resVal), - msgListVal: resMsgVals, - }, firstIndex, nil + srcInfo := newSrcInfo(append(pathPrefix, int32(firstIndex)), &sourceinfo.ArrayLiteralSourceInfo{Elements: childVals}) + return &srcInfo, nil } - value, err := interp.fieldValue(mc, msg, fld, val, insideMsgLiteral) + if fld.IsMap() { + pathPrefix = append(pathPrefix, int32(msg.Get(fld).Map().Len())) + } else if fld.IsList() { + pathPrefix = append(pathPrefix, int32(msg.Get(fld).List().Len())) + } + + value, srcInfo, err := interp.fieldValue(mc, msg, fld, val, insideMsgLiteral, pathPrefix) if err != nil { - return interpretedFieldValue{}, 0, err + return nil, err } if ood := fld.ContainingOneof(); ood != nil { existingFld := msg.WhichOneof(ood) if existingFld != nil && existingFld.Number() != fld.Number() { - return interpretedFieldValue{}, 0, reporter.Errorf(interp.nodeInfo(name), "%voneof %q already has field %q set", mc, ood.Name(), fieldName(existingFld)) + return nil, reporter.Errorf(interp.nodeInfo(name), "%voneof %q already has field %q set", mc, ood.Name(), fieldName(existingFld)) } } - var index int switch { case fld.IsMap(): mv := msg.Mutable(fld).Map() - index = mv.Len() - setMapEntry(fld, msg, mv, &value) + setMapEntry(fld, msg, mv, value.Message()) case fld.IsList(): lv := msg.Mutable(fld).List() - index = lv.Len() - lv.Append(value.val) + lv.Append(value) default: if msg.Has(fld) { - return interpretedFieldValue{}, 0, reporter.Errorf(interp.nodeInfo(name), "%vnon-repeated option field %s already set", mc, fieldName(fld)) + return nil, reporter.Errorf(interp.nodeInfo(name), "%vnon-repeated option field %s already set", mc, fieldName(fld)) } - msg.Set(fld, value.val) + msg.Set(fld, value) } - return value, index, nil + return &srcInfo, nil } // setOptionFieldFromProto sets the value for field fld in the given message msg to the value // represented by the given uninterpreted option. The given ast.Node, if non-nil, will be used // to report source positions in error messages. On success, it returns additional metadata // about the field that was set. -func (interp *interpreter) setOptionFieldFromProto(mc *internal.MessageContext, msg protoreflect.Message, fld protoreflect.FieldDescriptor, name ast.Node, opt *descriptorpb.UninterpretedOption, node ast.Node) (interpretedFieldValue, error) { +func (interp *interpreter) setOptionFieldFromProto( + mc *internal.MessageContext, + msg protoreflect.Message, + fld protoreflect.FieldDescriptor, + name ast.Node, + opt *descriptorpb.UninterpretedOption, + node ast.Node, +) error { k := fld.Kind() - var value interpretedFieldValue + var value protoreflect.Value switch k { case protoreflect.EnumKind: num, _, err := interp.enumFieldValueFromProto(mc, fld.Enum(), opt, node) if err != nil { - return interpretedFieldValue{}, err + return err } - value = interpretedFieldValue{val: protoreflect.ValueOfEnum(num)} + value = protoreflect.ValueOfEnum(num) case protoreflect.MessageKind, protoreflect.GroupKind: if opt.AggregateValue == nil { - return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(node), "%vexpecting message, got %s", mc, optionValueKind(opt)) + return reporter.Errorf(interp.nodeInfo(node), "%vexpecting message, got %s", mc, optionValueKind(opt)) } // We must parse the text format from the aggregate value string - fmd := fld.Message() - tmpMsg := dynamicpb.NewMessage(fmd) + var elem protoreflect.Message + switch { + case fld.IsMap(): + elem = dynamicpb.NewMessage(fld.Message()) + case fld.IsList(): + elem = msg.Get(fld).List().NewElement().Message() + default: + elem = msg.NewField(fld).Message() + } err := prototext.UnmarshalOptions{ Resolver: &msgLiteralResolver{interp: interp, pkg: fld.ParentFile().Package()}, AllowPartial: true, - }.Unmarshal([]byte(opt.GetAggregateValue()), tmpMsg) - if err != nil { - return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(node), "%vfailed to parse message literal %w", mc, err) - } - msgData, err := proto.MarshalOptions{ - AllowPartial: true, - }.Marshal(tmpMsg) + }.Unmarshal([]byte(opt.GetAggregateValue()), elem.Interface()) if err != nil { - return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(node), "%vfailed to serialize data from message literal %w", mc, err) + return reporter.Errorf(interp.nodeInfo(node), "%vfailed to parse message literal %w", mc, err) } - var data []byte - if k == protoreflect.GroupKind { - data = protowire.AppendTag(data, fld.Number(), protowire.StartGroupType) - data = append(data, msgData...) - data = protowire.AppendTag(data, fld.Number(), protowire.EndGroupType) - } else { - data = protowire.AppendTag(nil, fld.Number(), protowire.BytesType) - data = protowire.AppendBytes(data, msgData) - } - // NB: At this point, the serialized fields may no longer be in the same - // order as in the text literal. So for this case, the linker result's - // CanonicalProto won't be in *quite* the right order. ¯\_(ツ)_/¯ - value = interpretedFieldValue{preserialized: data} + value = protoreflect.ValueOfMessage(elem) default: v, err := interp.scalarFieldValueFromProto(mc, descriptorpb.FieldDescriptorProto_Type(k), opt, node) if err != nil { - return interpretedFieldValue{}, err + return err } - value = interpretedFieldValue{val: protoreflect.ValueOf(v)} + value = protoreflect.ValueOf(v) } if ood := fld.ContainingOneof(); ood != nil { existingFld := msg.WhichOneof(ood) if existingFld != nil && existingFld.Number() != fld.Number() { - return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(name), "%voneof %q already has field %q set", mc, ood.Name(), fieldName(existingFld)) + return reporter.Errorf(interp.nodeInfo(name), "%voneof %q already has field %q set", mc, ood.Name(), fieldName(existingFld)) } } switch { - case value.preserialized != nil: - if !fld.IsList() && !fld.IsMap() && msg.Has(fld) { - return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(name), "%vnon-repeated option field %s already set", mc, fieldName(fld)) - } - // We have to merge the bytes for this field into the message. - // TODO: if a map field, error if key for this entry already set? - err := proto.UnmarshalOptions{ - Resolver: &msgLiteralResolver{interp: interp, pkg: fld.ParentFile().Package()}, - AllowPartial: true, - Merge: true, - }.Unmarshal(value.preserialized, msg.Interface()) - if err != nil { - return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(name), "%v failed to set value for field %v: %w", mc, fieldName(fld), err) - } + case fld.IsMap(): + mv := msg.Mutable(fld).Map() + setMapEntry(fld, msg, mv, value.Message()) case fld.IsList(): - msg.Mutable(fld).List().Append(value.val) + msg.Mutable(fld).List().Append(value) default: if msg.Has(fld) { - return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(name), "%vnon-repeated option field %s already set", mc, fieldName(fld)) + return reporter.Errorf(interp.nodeInfo(name), "%vnon-repeated option field %s already set", mc, fieldName(fld)) } - msg.Set(fld, value.val) + msg.Set(fld, value) } - return value, nil + return nil } -func setMapEntry(fld protoreflect.FieldDescriptor, msg protoreflect.Message, mapVal protoreflect.Map, value *interpretedFieldValue) { - entry := value.val.Message() +func setMapEntry( + fld protoreflect.FieldDescriptor, + msg protoreflect.Message, + mapVal protoreflect.Map, + entry protoreflect.Message, +) { keyFld, valFld := fld.MapKey(), fld.MapValue() - // if an entry is missing a key or value, we add in an explicit - // zero value to msgVals to match protoc (which also odds these - // in even if not present in source) - if !entry.Has(keyFld) { - // put key before value - value.msgVal = append(append(([]*interpretedField)(nil), zeroValue(keyFld)), value.msgVal...) - } - if !entry.Has(valFld) { - value.msgVal = append(value.msgVal, zeroValue(valFld)) - } key := entry.Get(keyFld) val := entry.Get(valFld) if fld.MapValue().Kind() == protoreflect.MessageKind { @@ -1556,84 +1124,6 @@ func setMapEntry(fld protoreflect.FieldDescriptor, msg protoreflect.Message, map mapVal.Set(key.MapKey(), val) } -// zeroValue returns the zero value for the field types as a *interpretedField. -// The given fld must NOT be a repeated field. -func zeroValue(fld protoreflect.FieldDescriptor) *interpretedField { - var val protoreflect.Value - var msgVal []*interpretedField - switch fld.Kind() { - case protoreflect.MessageKind, protoreflect.GroupKind: - // needs to be non-nil, but empty - msgVal = []*interpretedField{} - msg := dynamicpb.NewMessage(fld.Message()) - val = protoreflect.ValueOfMessage(msg) - case protoreflect.EnumKind: - val = protoreflect.ValueOfEnum(0) - case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind: - val = protoreflect.ValueOfInt32(0) - case protoreflect.Uint32Kind, protoreflect.Fixed32Kind: - val = protoreflect.ValueOfUint32(0) - case protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind: - val = protoreflect.ValueOfInt64(0) - case protoreflect.Uint64Kind, protoreflect.Fixed64Kind: - val = protoreflect.ValueOfUint64(0) - case protoreflect.BoolKind: - val = protoreflect.ValueOfBool(false) - case protoreflect.FloatKind: - val = protoreflect.ValueOfFloat32(0) - case protoreflect.DoubleKind: - val = protoreflect.ValueOfFloat64(0) - case protoreflect.BytesKind: - val = protoreflect.ValueOfBytes(nil) - case protoreflect.StringKind: - val = protoreflect.ValueOfString("") - } - return &interpretedField{ - number: int32(fld.Number()), - kind: fld.Kind(), - value: interpretedFieldValue{ - val: val, - msgVal: msgVal, - }, - } -} - -type listValue []protoreflect.Value - -var _ protoreflect.List = (*listValue)(nil) - -func (l listValue) Len() int { - return len(l) -} - -func (l listValue) Get(i int) protoreflect.Value { - return l[i] -} - -func (l listValue) Set(i int, value protoreflect.Value) { - l[i] = value -} - -func (l *listValue) Append(value protoreflect.Value) { - *l = append(*l, value) -} - -func (l listValue) AppendMutable() protoreflect.Value { - panic("AppendMutable not supported") -} - -func (l *listValue) Truncate(i int) { - *l = (*l)[:i] -} - -func (l listValue) NewElement() protoreflect.Value { - panic("NewElement not supported") -} - -func (l listValue) IsValid() bool { - return true -} - type msgLiteralResolver struct { interp *interpreter pkg protoreflect.FullName @@ -1736,15 +1226,22 @@ func optionValueKind(opt *descriptorpb.UninterpretedOption) string { // fieldValue computes a compile-time value (constant or list or message literal) for the given // AST node val. The value in val must be assignable to the field fld. -func (interp *interpreter) fieldValue(mc *internal.MessageContext, msg protoreflect.Message, fld protoreflect.FieldDescriptor, val ast.ValueNode, insideMsgLiteral bool) (interpretedFieldValue, error) { +func (interp *interpreter) fieldValue( + mc *internal.MessageContext, + msg protoreflect.Message, + fld protoreflect.FieldDescriptor, + val ast.ValueNode, + insideMsgLiteral bool, + pathPrefix []int32, +) (protoreflect.Value, sourceinfo.OptionSourceInfo, error) { k := fld.Kind() switch k { case protoreflect.EnumKind: num, _, err := interp.enumFieldValue(mc, fld.Enum(), val, insideMsgLiteral) if err != nil { - return interpretedFieldValue{}, err + return protoreflect.Value{}, sourceinfo.OptionSourceInfo{}, err } - return interpretedFieldValue{val: protoreflect.ValueOfEnum(num)}, nil + return protoreflect.ValueOfEnum(num), newSrcInfo(pathPrefix, nil), nil case protoreflect.MessageKind, protoreflect.GroupKind: v := val.Value() @@ -1762,22 +1259,28 @@ func (interp *interpreter) fieldValue(mc *internal.MessageContext, msg protorefl // Normal message field childMsg = msg.NewField(fld).Message() } - return interp.messageLiteralValue(mc, aggs, childMsg) + return interp.messageLiteralValue(mc, aggs, childMsg, pathPrefix) } - return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(val), "%vexpecting message, got %s", mc, valueKind(v)) + return protoreflect.Value{}, sourceinfo.OptionSourceInfo{}, + reporter.Errorf(interp.nodeInfo(val), "%vexpecting message, got %s", mc, valueKind(v)) default: v, err := interp.scalarFieldValue(mc, descriptorpb.FieldDescriptorProto_Type(k), val, insideMsgLiteral) if err != nil { - return interpretedFieldValue{}, err + return protoreflect.Value{}, sourceinfo.OptionSourceInfo{}, err } - return interpretedFieldValue{val: protoreflect.ValueOf(v)}, nil + return protoreflect.ValueOf(v), newSrcInfo(pathPrefix, nil), nil } } // enumFieldValue resolves the given AST node val as an enum value descriptor. If the given // value is not a valid identifier (or number if allowed), an error is returned instead. -func (interp *interpreter) enumFieldValue(mc *internal.MessageContext, ed protoreflect.EnumDescriptor, val ast.ValueNode, allowNumber bool) (protoreflect.EnumNumber, protoreflect.Name, error) { +func (interp *interpreter) enumFieldValue( + mc *internal.MessageContext, + ed protoreflect.EnumDescriptor, + val ast.ValueNode, + allowNumber bool, +) (protoreflect.EnumNumber, protoreflect.Name, error) { v := val.Value() var num protoreflect.EnumNumber switch v := v.(type) { @@ -1811,8 +1314,8 @@ func (interp *interpreter) enumFieldValue(mc *internal.MessageContext, ed protor if ev != nil { return num, ev.Name(), nil } - if ed.Syntax() != protoreflect.Proto3 { - return 0, "", reporter.Errorf(interp.nodeInfo(val), "%vclosed enum %s has no value with number %d", mc, ed.FullName(), num) + if ed.IsClosed() { + return num, "", reporter.Errorf(interp.nodeInfo(val), "%vclosed enum %s has no value with number %d", mc, ed.FullName(), num) } // unknown value, but enum is open, so we allow it and return blank name return num, "", nil @@ -1820,7 +1323,12 @@ func (interp *interpreter) enumFieldValue(mc *internal.MessageContext, ed protor // enumFieldValueFromProto resolves the given uninterpreted option value as an enum value descriptor. // If the given value is not a valid identifier, an error is returned instead. -func (interp *interpreter) enumFieldValueFromProto(mc *internal.MessageContext, ed protoreflect.EnumDescriptor, opt *descriptorpb.UninterpretedOption, node ast.Node) (protoreflect.EnumNumber, protoreflect.Name, error) { +func (interp *interpreter) enumFieldValueFromProto( + mc *internal.MessageContext, + ed protoreflect.EnumDescriptor, + opt *descriptorpb.UninterpretedOption, + node ast.Node, +) (protoreflect.EnumNumber, protoreflect.Name, error) { // We don't have to worry about allowing numbers because numbers are never allowed // in uninterpreted values; they are only allowed inside aggregate values (i.e. // message literals). @@ -1839,7 +1347,12 @@ func (interp *interpreter) enumFieldValueFromProto(mc *internal.MessageContext, // scalarFieldValue resolves the given AST node val as a value whose type is assignable to a // field with the given fldType. -func (interp *interpreter) scalarFieldValue(mc *internal.MessageContext, fldType descriptorpb.FieldDescriptorProto_Type, val ast.ValueNode, insideMsgLiteral bool) (interface{}, error) { +func (interp *interpreter) scalarFieldValue( + mc *internal.MessageContext, + fldType descriptorpb.FieldDescriptorProto_Type, + val ast.ValueNode, + insideMsgLiteral bool, +) (interface{}, error) { v := val.Value() switch fldType { case descriptorpb.FieldDescriptorProto_TYPE_BOOL: @@ -1972,7 +1485,12 @@ func (interp *interpreter) scalarFieldValue(mc *internal.MessageContext, fldType // scalarFieldValue resolves the given uninterpreted option value as a value whose type is // assignable to a field with the given fldType. -func (interp *interpreter) scalarFieldValueFromProto(mc *internal.MessageContext, fldType descriptorpb.FieldDescriptorProto_Type, opt *descriptorpb.UninterpretedOption, node ast.Node) (interface{}, error) { +func (interp *interpreter) scalarFieldValueFromProto( + mc *internal.MessageContext, + fldType descriptorpb.FieldDescriptorProto_Type, + opt *descriptorpb.UninterpretedOption, + node ast.Node, +) (interface{}, error) { switch fldType { case descriptorpb.FieldDescriptorProto_TYPE_BOOL: if opt.IdentifierValue != nil { @@ -2121,17 +1639,18 @@ func descriptorType(m proto.Message) string { } } -func (interp *interpreter) messageLiteralValue(mc *internal.MessageContext, fieldNodes []*ast.MessageFieldNode, msg protoreflect.Message) (interpretedFieldValue, error) { +func (interp *interpreter) messageLiteralValue( + mc *internal.MessageContext, + fieldNodes []*ast.MessageFieldNode, + msg protoreflect.Message, + pathPrefix []int32, +) (protoreflect.Value, sourceinfo.OptionSourceInfo, error) { fmd := msg.Descriptor() origPath := mc.OptAggPath defer func() { mc.OptAggPath = origPath }() - // NB: we don't want to leave this nil, even if the - // message is empty, because that indicates to - // caller that the result is not a message - flds := make([]*interpretedField, 0, len(fieldNodes)) - var foundAnyNode bool + flds := make(map[*ast.MessageFieldNode]*sourceinfo.OptionSourceInfo, len(fieldNodes)) for _, fieldNode := range fieldNodes { if origPath == "" { mc.OptAggPath = fieldNode.Name.Value() @@ -2139,13 +1658,14 @@ func (interp *interpreter) messageLiteralValue(mc *internal.MessageContext, fiel mc.OptAggPath = origPath + "." + fieldNode.Name.Value() } if fieldNode.Name.IsAnyTypeReference() { - if fmd.FullName() != "google.protobuf.Any" { - return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(fieldNode.Name.URLPrefix), "%vtype references are only allowed for google.protobuf.Any, but this type is %s", mc, fmd.FullName()) + if len(fieldNodes) > 1 { + return protoreflect.Value{}, sourceinfo.OptionSourceInfo{}, + reporter.Errorf(interp.nodeInfo(fieldNode.Name.URLPrefix), "%vany type references cannot be repeated or mixed with other fields", mc) } - if foundAnyNode { - return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(fieldNode.Name.URLPrefix), "%vmultiple any type references are not allowed", mc) + if fmd.FullName() != "google.protobuf.Any" { + return protoreflect.Value{}, sourceinfo.OptionSourceInfo{}, + reporter.Errorf(interp.nodeInfo(fieldNode.Name.URLPrefix), "%vtype references are only allowed for google.protobuf.Any, but this type is %s", mc, fmd.FullName()) } - foundAnyNode = true urlPrefix := fieldNode.Name.URLPrefix.AsIdentifier() msgName := fieldNode.Name.Name.AsIdentifier() fullURL := fmt.Sprintf("%s/%s", urlPrefix, msgName) @@ -2154,41 +1674,48 @@ func (interp *interpreter) messageLiteralValue(mc *internal.MessageContext, fiel // URLs into message descriptors. The default resolver would be // implemented as below, only accepting "type.googleapis.com" and // "type.googleprod.com" as hosts/prefixes and using the compiled - // file's transitive closure to find the named message. + // file's transitive closure to find the named message, since that + // is what protoc does. if urlPrefix != "type.googleapis.com" && urlPrefix != "type.googleprod.com" { - return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(fieldNode.Name.URLPrefix), "%vcould not resolve type reference %s", mc, fullURL) + return protoreflect.Value{}, sourceinfo.OptionSourceInfo{}, + reporter.Errorf(interp.nodeInfo(fieldNode.Name.URLPrefix), "%vcould not resolve type reference %s", mc, fullURL) } anyFields, ok := fieldNode.Val.Value().([]*ast.MessageFieldNode) if !ok { - return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(fieldNode.Val), "%vtype references for google.protobuf.Any must have message literal value", mc) + return protoreflect.Value{}, sourceinfo.OptionSourceInfo{}, + reporter.Errorf(interp.nodeInfo(fieldNode.Val), "%vtype references for google.protobuf.Any must have message literal value", mc) } anyMd := resolveDescriptor[protoreflect.MessageDescriptor](interp.resolver, string(msgName)) if anyMd == nil { - return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(fieldNode.Name.URLPrefix), "%vcould not resolve type reference %s", mc, fullURL) + return protoreflect.Value{}, sourceinfo.OptionSourceInfo{}, + reporter.Errorf(interp.nodeInfo(fieldNode.Name.URLPrefix), "%vcould not resolve type reference %s", mc, fullURL) } // parse the message value - msgVal, err := interp.messageLiteralValue(mc, anyFields, dynamicpb.NewMessage(anyMd)) + msgVal, valueSrcInfo, err := interp.messageLiteralValue(mc, anyFields, dynamicpb.NewMessage(anyMd), append(pathPrefix, internal.AnyValueTag)) if err != nil { - return interpretedFieldValue{}, err + return protoreflect.Value{}, sourceinfo.OptionSourceInfo{}, err } - // Any is defined with two fields: - // string type_url = 1 - // bytes value = 2 - typeURLDescriptor := fmd.Fields().ByNumber(1) + typeURLDescriptor := fmd.Fields().ByNumber(internal.AnyTypeURLTag) if typeURLDescriptor == nil || typeURLDescriptor.Kind() != protoreflect.StringKind { - return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(fieldNode.Name), "%vfailed to set type_url string field on Any: %w", mc, err) + return protoreflect.Value{}, sourceinfo.OptionSourceInfo{}, + reporter.Errorf(interp.nodeInfo(fieldNode.Name), "%vfailed to set type_url string field on Any: %w", mc, err) } - msg.Set(typeURLDescriptor, protoreflect.ValueOfString(fullURL)) - valueDescriptor := fmd.Fields().ByNumber(2) + typeURLVal := protoreflect.ValueOfString(fullURL) + msg.Set(typeURLDescriptor, typeURLVal) + valueDescriptor := fmd.Fields().ByNumber(internal.AnyValueTag) if valueDescriptor == nil || valueDescriptor.Kind() != protoreflect.BytesKind { - return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(fieldNode.Name), "%vfailed to set value bytes field on Any: %w", mc, err) + return protoreflect.Value{}, sourceinfo.OptionSourceInfo{}, + reporter.Errorf(interp.nodeInfo(fieldNode.Name), "%vfailed to set value bytes field on Any: %w", mc, err) } - b, err := proto.MarshalOptions{Deterministic: true}.Marshal(msgVal.val.Message().Interface()) + + b, err := (proto.MarshalOptions{Deterministic: true}).Marshal(msgVal.Message().Interface()) if err != nil { - return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(fieldNode.Val), "%vfailed to serialize message value: %w", mc, err) + return protoreflect.Value{}, sourceinfo.OptionSourceInfo{}, + reporter.Errorf(interp.nodeInfo(fieldNode.Val), "%vfailed to serialize message value: %w", mc, err) } msg.Set(valueDescriptor, protoreflect.ValueOfBytes(b)) + flds[fieldNode] = &valueSrcInfo } else { var ffld protoreflect.FieldDescriptor var err error @@ -2212,9 +1739,15 @@ func (interp *interpreter) messageLiteralValue(mc *internal.MessageContext, fiel // Groups are indicated in the text format by the group name (which is // camel-case), NOT the field name (which is lower-case). // ...but only regular fields, not extensions that are groups... - if ffld != nil && ffld.Kind() == protoreflect.GroupKind && ffld.Message().Name() != protoreflect.Name(fieldNode.Name.Value()) { - // this is kind of silly to fail here, but this mimics protoc behavior - return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(fieldNode.Name), "%vfield %s not found (did you mean the group named %s?)", mc, fieldNode.Name.Value(), ffld.Message().Name()) + if ffld != nil && ffld.Kind() == protoreflect.GroupKind && + string(ffld.Name()) == strings.ToLower(string(ffld.Message().Name())) && + ffld.Message().Name() != protoreflect.Name(fieldNode.Name.Value()) { + // This is kind of silly to fail here, but this mimics protoc behavior. + // We only fail when this really looks like a group since we need to be + // able to use the field name for fields in editions files that use the + // delimited message encoding and don't use proto2 group naming. + return protoreflect.Value{}, sourceinfo.OptionSourceInfo{}, + reporter.Errorf(interp.nodeInfo(fieldNode.Name), "%vfield %s not found (did you mean the group named %s?)", mc, fieldNode.Name.Value(), ffld.Message().Name()) } if ffld == nil { err = protoregistry.NotFound @@ -2231,33 +1764,33 @@ func (interp *interpreter) messageLiteralValue(mc *internal.MessageContext, fiel } } if errors.Is(err, protoregistry.NotFound) { - return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(fieldNode.Name), - "%vfield %s not found", mc, string(fieldNode.Name.Name.AsIdentifier())) + return protoreflect.Value{}, sourceinfo.OptionSourceInfo{}, + reporter.Errorf(interp.nodeInfo(fieldNode.Name), "%vfield %s not found", mc, string(fieldNode.Name.Name.AsIdentifier())) } else if err != nil { - return interpretedFieldValue{}, reporter.Error(interp.nodeInfo(fieldNode.Name), err) + return protoreflect.Value{}, sourceinfo.OptionSourceInfo{}, + reporter.Error(interp.nodeInfo(fieldNode.Name), err) } if fieldNode.Sep == nil && ffld.Message() == nil { // If there is no separator, the field type should be a message. - // Otherwise it is an error in the text format. - return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(fieldNode.Val), "syntax error: unexpected value, expecting ':'") + // Otherwise, it is an error in the text format. + return protoreflect.Value{}, sourceinfo.OptionSourceInfo{}, + reporter.Errorf(interp.nodeInfo(fieldNode.Val), "syntax error: unexpected value, expecting ':'") } - res, index, err := interp.setOptionField(mc, msg, ffld, fieldNode.Name, fieldNode.Val, true) + srcInfo, err := interp.setOptionField(mc, msg, ffld, fieldNode.Name, fieldNode.Val, true, append(pathPrefix, int32(ffld.Number()))) if err != nil { - return interpretedFieldValue{}, err + return protoreflect.Value{}, sourceinfo.OptionSourceInfo{}, err } - flds = append(flds, &interpretedField{ - node: fieldNode, - number: int32(ffld.Number()), - index: int32(index), - kind: ffld.Kind(), - repeated: ffld.Cardinality() == protoreflect.Repeated, - packed: ffld.IsPacked(), - value: res, - }) - } - } - return interpretedFieldValue{ - val: protoreflect.ValueOfMessage(msg), - msgVal: flds, - }, nil + flds[fieldNode] = srcInfo + } + } + return protoreflect.ValueOfMessage(msg), + newSrcInfo(pathPrefix, &sourceinfo.MessageLiteralSourceInfo{Fields: flds}), + nil +} + +func newSrcInfo(path []int32, children sourceinfo.OptionChildrenSourceInfo) sourceinfo.OptionSourceInfo { + return sourceinfo.OptionSourceInfo{ + Path: internal.ClonePath(path), + Children: children, + } } diff --git a/vendor/github.com/bufbuild/protocompile/options/source_retention_options.go b/vendor/github.com/bufbuild/protocompile/options/source_retention_options.go new file mode 100644 index 00000000000..f73f8c73aa6 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/options/source_retention_options.go @@ -0,0 +1,539 @@ +// Copyright 2020-2024 Buf Technologies, 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. + +package options + +import ( + "fmt" + + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/types/descriptorpb" + + "github.com/bufbuild/protocompile/internal" +) + +// StripSourceRetentionOptionsFromFile returns a file descriptor proto that omits any +// options in file that are defined to be retained only in source. If file has no +// such options, then it is returned as is. If it does have such options, a copy is +// made; the given file will not be mutated. +// +// Even when a copy is returned, it is not a deep copy: it may share data with the +// original file. So callers should not mutate the returned file unless mutating the +// input file is also safe. +func StripSourceRetentionOptionsFromFile(file *descriptorpb.FileDescriptorProto) (*descriptorpb.FileDescriptorProto, error) { + var path sourcePath + var removedPaths *sourcePathTrie + if file.SourceCodeInfo != nil && len(file.SourceCodeInfo.Location) > 0 { + path = make(sourcePath, 0, 16) + removedPaths = &sourcePathTrie{} + } + var dirty bool + optionsPath := path.push(internal.FileOptionsTag) + newOpts, err := stripSourceRetentionOptions(file.GetOptions(), optionsPath, removedPaths) + if err != nil { + return nil, err + } + if newOpts != file.GetOptions() { + dirty = true + } + msgsPath := path.push(internal.FileMessagesTag) + newMsgs, changed, err := stripOptionsFromAll(file.GetMessageType(), stripSourceRetentionOptionsFromMessage, msgsPath, removedPaths) + if err != nil { + return nil, err + } + if changed { + dirty = true + } + enumsPath := path.push(internal.FileEnumsTag) + newEnums, changed, err := stripOptionsFromAll(file.GetEnumType(), stripSourceRetentionOptionsFromEnum, enumsPath, removedPaths) + if err != nil { + return nil, err + } + if changed { + dirty = true + } + extsPath := path.push(internal.FileExtensionsTag) + newExts, changed, err := stripOptionsFromAll(file.GetExtension(), stripSourceRetentionOptionsFromField, extsPath, removedPaths) + if err != nil { + return nil, err + } + if changed { + dirty = true + } + svcsPath := path.push(internal.FileServicesTag) + newSvcs, changed, err := stripOptionsFromAll(file.GetService(), stripSourceRetentionOptionsFromService, svcsPath, removedPaths) + if err != nil { + return nil, err + } + if changed { + dirty = true + } + + if !dirty { + return file, nil + } + + newFile, err := shallowCopy(file) + if err != nil { + return nil, err + } + newFile.Options = newOpts + newFile.MessageType = newMsgs + newFile.EnumType = newEnums + newFile.Extension = newExts + newFile.Service = newSvcs + newFile.SourceCodeInfo = stripSourcePathsForSourceRetentionOptions(newFile.SourceCodeInfo, removedPaths) + return newFile, nil +} + +type sourcePath protoreflect.SourcePath + +func (p sourcePath) push(element int32) sourcePath { + if p == nil { + return nil + } + return append(p, element) +} + +type sourcePathTrie struct { + removed bool + children map[int32]*sourcePathTrie +} + +func (t *sourcePathTrie) addPath(p sourcePath) { + if t == nil { + return + } + if len(p) == 0 { + t.removed = true + return + } + child := t.children[p[0]] + if child == nil { + if t.children == nil { + t.children = map[int32]*sourcePathTrie{} + } + child = &sourcePathTrie{} + t.children[p[0]] = child + } + child.addPath(p[1:]) +} + +func (t *sourcePathTrie) isRemoved(p []int32) bool { + if t == nil { + return false + } + if t.removed { + return true + } + if len(p) == 0 { + return false + } + child := t.children[p[0]] + if child == nil { + return false + } + return child.isRemoved(p[1:]) +} + +func stripSourceRetentionOptions[M proto.Message]( + options M, + path sourcePath, + removedPaths *sourcePathTrie, +) (M, error) { + optionsRef := options.ProtoReflect() + // See if there are any options to strip. + var hasFieldToStrip bool + var numFieldsToKeep int + var err error + optionsRef.Range(func(field protoreflect.FieldDescriptor, val protoreflect.Value) bool { + fieldOpts, ok := field.Options().(*descriptorpb.FieldOptions) + if !ok { + err = fmt.Errorf("field options is unexpected type: got %T, want %T", field.Options(), fieldOpts) + return false + } + if fieldOpts.GetRetention() == descriptorpb.FieldOptions_RETENTION_SOURCE { + hasFieldToStrip = true + } else { + numFieldsToKeep++ + } + return true + }) + var zero M + if err != nil { + return zero, err + } + if !hasFieldToStrip { + return options, nil + } + + if numFieldsToKeep == 0 { + // Stripping the message would remove *all* options. In that case, + // we'll clear out the options by returning the zero value (i.e. nil). + removedPaths.addPath(path) // clear out all source locations, too + return zero, nil + } + + // There is at least one option to remove. So we need to make a copy that does not have those options. + newOptions := optionsRef.New() + ret, ok := newOptions.Interface().(M) + if !ok { + return zero, fmt.Errorf("creating new message of same type resulted in unexpected type; got %T, want %T", newOptions.Interface(), zero) + } + optionsRef.Range(func(field protoreflect.FieldDescriptor, val protoreflect.Value) bool { + fieldOpts, ok := field.Options().(*descriptorpb.FieldOptions) + if !ok { + err = fmt.Errorf("field options is unexpected type: got %T, want %T", field.Options(), fieldOpts) + return false + } + if fieldOpts.GetRetention() != descriptorpb.FieldOptions_RETENTION_SOURCE { + newOptions.Set(field, val) + } else { + removedPaths.addPath(path.push(int32(field.Number()))) + } + return true + }) + if err != nil { + return zero, err + } + return ret, nil +} + +func stripSourceRetentionOptionsFromMessage( + msg *descriptorpb.DescriptorProto, + path sourcePath, + removedPaths *sourcePathTrie, +) (*descriptorpb.DescriptorProto, error) { + var dirty bool + optionsPath := path.push(internal.MessageOptionsTag) + newOpts, err := stripSourceRetentionOptions(msg.Options, optionsPath, removedPaths) + if err != nil { + return nil, err + } + if newOpts != msg.Options { + dirty = true + } + fieldsPath := path.push(internal.MessageFieldsTag) + newFields, changed, err := stripOptionsFromAll(msg.Field, stripSourceRetentionOptionsFromField, fieldsPath, removedPaths) + if err != nil { + return nil, err + } + if changed { + dirty = true + } + oneofsPath := path.push(internal.MessageOneofsTag) + newOneofs, changed, err := stripOptionsFromAll(msg.OneofDecl, stripSourceRetentionOptionsFromOneof, oneofsPath, removedPaths) + if err != nil { + return nil, err + } + if changed { + dirty = true + } + extRangesPath := path.push(internal.MessageExtensionRangesTag) + newExtRanges, changed, err := stripOptionsFromAll(msg.ExtensionRange, stripSourceRetentionOptionsFromExtensionRange, extRangesPath, removedPaths) + if err != nil { + return nil, err + } + if changed { + dirty = true + } + msgsPath := path.push(internal.MessageNestedMessagesTag) + newMsgs, changed, err := stripOptionsFromAll(msg.NestedType, stripSourceRetentionOptionsFromMessage, msgsPath, removedPaths) + if err != nil { + return nil, err + } + if changed { + dirty = true + } + enumsPath := path.push(internal.MessageEnumsTag) + newEnums, changed, err := stripOptionsFromAll(msg.EnumType, stripSourceRetentionOptionsFromEnum, enumsPath, removedPaths) + if err != nil { + return nil, err + } + if changed { + dirty = true + } + extsPath := path.push(internal.MessageExtensionsTag) + newExts, changed, err := stripOptionsFromAll(msg.Extension, stripSourceRetentionOptionsFromField, extsPath, removedPaths) + if err != nil { + return nil, err + } + if changed { + dirty = true + } + + if !dirty { + return msg, nil + } + + newMsg, err := shallowCopy(msg) + if err != nil { + return nil, err + } + newMsg.Options = newOpts + newMsg.Field = newFields + newMsg.OneofDecl = newOneofs + newMsg.ExtensionRange = newExtRanges + newMsg.NestedType = newMsgs + newMsg.EnumType = newEnums + newMsg.Extension = newExts + return newMsg, nil +} + +func stripSourceRetentionOptionsFromField( + field *descriptorpb.FieldDescriptorProto, + path sourcePath, + removedPaths *sourcePathTrie, +) (*descriptorpb.FieldDescriptorProto, error) { + optionsPath := path.push(internal.FieldOptionsTag) + newOpts, err := stripSourceRetentionOptions(field.Options, optionsPath, removedPaths) + if err != nil { + return nil, err + } + if newOpts == field.Options { + return field, nil + } + newField, err := shallowCopy(field) + if err != nil { + return nil, err + } + newField.Options = newOpts + return newField, nil +} + +func stripSourceRetentionOptionsFromOneof( + oneof *descriptorpb.OneofDescriptorProto, + path sourcePath, + removedPaths *sourcePathTrie, +) (*descriptorpb.OneofDescriptorProto, error) { + optionsPath := path.push(internal.OneofOptionsTag) + newOpts, err := stripSourceRetentionOptions(oneof.Options, optionsPath, removedPaths) + if err != nil { + return nil, err + } + if newOpts == oneof.Options { + return oneof, nil + } + newOneof, err := shallowCopy(oneof) + if err != nil { + return nil, err + } + newOneof.Options = newOpts + return newOneof, nil +} + +func stripSourceRetentionOptionsFromExtensionRange( + extRange *descriptorpb.DescriptorProto_ExtensionRange, + path sourcePath, + removedPaths *sourcePathTrie, +) (*descriptorpb.DescriptorProto_ExtensionRange, error) { + optionsPath := path.push(internal.ExtensionRangeOptionsTag) + newOpts, err := stripSourceRetentionOptions(extRange.Options, optionsPath, removedPaths) + if err != nil { + return nil, err + } + if newOpts == extRange.Options { + return extRange, nil + } + newExtRange, err := shallowCopy(extRange) + if err != nil { + return nil, err + } + newExtRange.Options = newOpts + return newExtRange, nil +} + +func stripSourceRetentionOptionsFromEnum( + enum *descriptorpb.EnumDescriptorProto, + path sourcePath, + removedPaths *sourcePathTrie, +) (*descriptorpb.EnumDescriptorProto, error) { + var dirty bool + optionsPath := path.push(internal.EnumOptionsTag) + newOpts, err := stripSourceRetentionOptions(enum.Options, optionsPath, removedPaths) + if err != nil { + return nil, err + } + if newOpts != enum.Options { + dirty = true + } + valsPath := path.push(internal.EnumValuesTag) + newVals, changed, err := stripOptionsFromAll(enum.Value, stripSourceRetentionOptionsFromEnumValue, valsPath, removedPaths) + if err != nil { + return nil, err + } + if changed { + dirty = true + } + + if !dirty { + return enum, nil + } + + newEnum, err := shallowCopy(enum) + if err != nil { + return nil, err + } + newEnum.Options = newOpts + newEnum.Value = newVals + return newEnum, nil +} + +func stripSourceRetentionOptionsFromEnumValue( + enumVal *descriptorpb.EnumValueDescriptorProto, + path sourcePath, + removedPaths *sourcePathTrie, +) (*descriptorpb.EnumValueDescriptorProto, error) { + optionsPath := path.push(internal.EnumValOptionsTag) + newOpts, err := stripSourceRetentionOptions(enumVal.Options, optionsPath, removedPaths) + if err != nil { + return nil, err + } + if newOpts == enumVal.Options { + return enumVal, nil + } + newEnumVal, err := shallowCopy(enumVal) + if err != nil { + return nil, err + } + newEnumVal.Options = newOpts + return newEnumVal, nil +} + +func stripSourceRetentionOptionsFromService( + svc *descriptorpb.ServiceDescriptorProto, + path sourcePath, + removedPaths *sourcePathTrie, +) (*descriptorpb.ServiceDescriptorProto, error) { + var dirty bool + optionsPath := path.push(internal.ServiceOptionsTag) + newOpts, err := stripSourceRetentionOptions(svc.Options, optionsPath, removedPaths) + if err != nil { + return nil, err + } + if newOpts != svc.Options { + dirty = true + } + methodsPath := path.push(internal.ServiceMethodsTag) + newMethods, changed, err := stripOptionsFromAll(svc.Method, stripSourceRetentionOptionsFromMethod, methodsPath, removedPaths) + if err != nil { + return nil, err + } + if changed { + dirty = true + } + + if !dirty { + return svc, nil + } + + newSvc, err := shallowCopy(svc) + if err != nil { + return nil, err + } + newSvc.Options = newOpts + newSvc.Method = newMethods + return newSvc, nil +} + +func stripSourceRetentionOptionsFromMethod( + method *descriptorpb.MethodDescriptorProto, + path sourcePath, + removedPaths *sourcePathTrie, +) (*descriptorpb.MethodDescriptorProto, error) { + optionsPath := path.push(internal.MethodOptionsTag) + newOpts, err := stripSourceRetentionOptions(method.Options, optionsPath, removedPaths) + if err != nil { + return nil, err + } + if newOpts == method.Options { + return method, nil + } + newMethod, err := shallowCopy(method) + if err != nil { + return nil, err + } + newMethod.Options = newOpts + return newMethod, nil +} + +func stripSourcePathsForSourceRetentionOptions( + sourceInfo *descriptorpb.SourceCodeInfo, + removedPaths *sourcePathTrie, +) *descriptorpb.SourceCodeInfo { + if sourceInfo == nil || len(sourceInfo.Location) == 0 || removedPaths == nil { + // nothing to do + return sourceInfo + } + newLocations := make([]*descriptorpb.SourceCodeInfo_Location, len(sourceInfo.Location)) + var i int + for _, loc := range sourceInfo.Location { + if removedPaths.isRemoved(loc.Path) { + continue + } + newLocations[i] = loc + i++ + } + newLocations = newLocations[:i] + return &descriptorpb.SourceCodeInfo{Location: newLocations} +} + +func shallowCopy[M proto.Message](msg M) (M, error) { + msgRef := msg.ProtoReflect() + other := msgRef.New() + ret, ok := other.Interface().(M) + if !ok { + return ret, fmt.Errorf("creating new message of same type resulted in unexpected type; got %T, want %T", other.Interface(), ret) + } + msgRef.Range(func(field protoreflect.FieldDescriptor, val protoreflect.Value) bool { + other.Set(field, val) + return true + }) + return ret, nil +} + +// stripOptionsFromAll applies the given function to each element in the given +// slice in order to remove source-retention options from it. It returns the new +// slice and a bool indicating whether anything was actually changed. If the +// second value is false, then the returned slice is the same slice as the input +// slice. Usually, T is a pointer type, in which case the given updateFunc should +// NOT mutate the input value. Instead, it should return the input value if only +// if there is no update needed. If a mutation is needed, it should return a new +// value. +func stripOptionsFromAll[T comparable]( + slice []T, + updateFunc func(T, sourcePath, *sourcePathTrie) (T, error), + path sourcePath, + removedPaths *sourcePathTrie, +) ([]T, bool, error) { + var updated []T // initialized lazily, only when/if a copy is needed + for i, item := range slice { + newItem, err := updateFunc(item, path.push(int32(i)), removedPaths) + if err != nil { + return nil, false, err + } + if updated != nil { + updated[i] = newItem + } else if newItem != item { + updated = make([]T, len(slice)) + copy(updated[:i], slice) + updated[i] = newItem + } + } + if updated != nil { + return updated, true, nil + } + return slice, false, nil +} diff --git a/vendor/github.com/bufbuild/protocompile/options/target_types.go b/vendor/github.com/bufbuild/protocompile/options/target_types.go index 5604eeba403..0d7807543bb 100644 --- a/vendor/github.com/bufbuild/protocompile/options/target_types.go +++ b/vendor/github.com/bufbuild/protocompile/options/target_types.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/github.com/bufbuild/protocompile/parser/ast.go b/vendor/github.com/bufbuild/protocompile/parser/ast.go index e0074a86720..f58f7ae4b20 100644 --- a/vendor/github.com/bufbuild/protocompile/parser/ast.go +++ b/vendor/github.com/bufbuild/protocompile/parser/ast.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/github.com/bufbuild/protocompile/parser/clone.go b/vendor/github.com/bufbuild/protocompile/parser/clone.go index 0eb57d2d022..04322486e0a 100644 --- a/vendor/github.com/bufbuild/protocompile/parser/clone.go +++ b/vendor/github.com/bufbuild/protocompile/parser/clone.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -106,6 +106,7 @@ func recreateNodeIndexForMessage(orig, clone *result, origProto, cloneProto *des } for i, origExtr := range origProto.ExtensionRange { cloneExtr := cloneProto.ExtensionRange[i] + updateNodeIndex(orig, clone, asExtsNode(origExtr), asExtsNode(cloneExtr)) updateNodeIndexWithOptions[*descriptorpb.ExtensionRangeOptions](orig, clone, origExtr, cloneExtr) } for i, origRr := range origProto.ReservedRange { diff --git a/vendor/github.com/bufbuild/protocompile/parser/doc.go b/vendor/github.com/bufbuild/protocompile/parser/doc.go index 2c4feb2cd27..40555543654 100644 --- a/vendor/github.com/bufbuild/protocompile/parser/doc.go +++ b/vendor/github.com/bufbuild/protocompile/parser/doc.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/github.com/bufbuild/protocompile/parser/errors.go b/vendor/github.com/bufbuild/protocompile/parser/errors.go index 0dd863df1b7..e78bddad898 100644 --- a/vendor/github.com/bufbuild/protocompile/parser/errors.go +++ b/vendor/github.com/bufbuild/protocompile/parser/errors.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/github.com/bufbuild/protocompile/parser/lexer.go b/vendor/github.com/bufbuild/protocompile/parser/lexer.go index dd4d847c07c..71cbc7ac890 100644 --- a/vendor/github.com/bufbuild/protocompile/parser/lexer.go +++ b/vendor/github.com/bufbuild/protocompile/parser/lexer.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/github.com/bufbuild/protocompile/parser/parser.go b/vendor/github.com/bufbuild/protocompile/parser/parser.go index 63b90374a1d..21314d5aacb 100644 --- a/vendor/github.com/bufbuild/protocompile/parser/parser.go +++ b/vendor/github.com/bufbuild/protocompile/parser/parser.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -155,12 +155,19 @@ type Result interface { // return nil, such as if the given oneof is not part of the // FileDescriptorProto hierarchy. If this result has no AST, this returns a // placeholder node. - OneofNode(*descriptorpb.OneofDescriptorProto) ast.Node + OneofNode(*descriptorpb.OneofDescriptorProto) ast.OneofDeclNode // ExtensionRangeNode returns the AST node corresponding to the given // extension range. This can return nil, such as if the given range is not // part of the FileDescriptorProto hierarchy. If this result has no AST, // this returns a placeholder node. ExtensionRangeNode(*descriptorpb.DescriptorProto_ExtensionRange) ast.RangeDeclNode + + // ExtensionsNode returns the AST node corresponding to the "extensions" + // statement in a message that corresponds to the given range. This will be + // the parent of the node returned by ExtensionRangeNode, which contains the + // options that apply to all child ranges. + ExtensionsNode(*descriptorpb.DescriptorProto_ExtensionRange) ast.NodeWithOptions + // MessageReservedRangeNode returns the AST node corresponding to the given // reserved range. This can return nil, such as if the given range is not // part of the FileDescriptorProto hierarchy. If this result has no AST, @@ -170,7 +177,7 @@ type Result interface { // return nil, such as if the given enum is not part of the // FileDescriptorProto hierarchy. If this result has no AST, this returns a // placeholder node. - EnumNode(*descriptorpb.EnumDescriptorProto) ast.Node + EnumNode(*descriptorpb.EnumDescriptorProto) ast.NodeWithOptions // EnumValueNode returns the AST node corresponding to the given enum. This // can return nil, such as if the given enum value is not part of the // FileDescriptorProto hierarchy. If this result has no AST, this returns a @@ -185,7 +192,7 @@ type Result interface { // can return nil, such as if the given service is not part of the // FileDescriptorProto hierarchy. If this result has no AST, this returns a // placeholder node. - ServiceNode(*descriptorpb.ServiceDescriptorProto) ast.Node + ServiceNode(*descriptorpb.ServiceDescriptorProto) ast.NodeWithOptions // MethodNode returns the AST node corresponding to the given method. This // can return nil, such as if the given method is not part of the // FileDescriptorProto hierarchy. If this result has no AST, this returns a diff --git a/vendor/github.com/bufbuild/protocompile/parser/proto.y b/vendor/github.com/bufbuild/protocompile/parser/proto.y index 7fea8b23a1c..e66cabdace2 100644 --- a/vendor/github.com/bufbuild/protocompile/parser/proto.y +++ b/vendor/github.com/bufbuild/protocompile/parser/proto.y @@ -750,6 +750,12 @@ messageGroupDecl : fieldCardinality _GROUP identifier '=' _INT_LIT '{' messageBo | fieldCardinality _GROUP identifier '=' _INT_LIT compactOptions '{' messageBody '}' semicolons { $$ = newNodeWithRunes(ast.NewGroupNode($1.ToKeyword(), $2.ToKeyword(), $3, $4, $5, $6, $7, $8, $9), $10...) } + | fieldCardinality _GROUP identifier '{' messageBody '}' semicolons { + $$ = newNodeWithRunes(ast.NewGroupNode($1.ToKeyword(), $2.ToKeyword(), $3, nil, nil, nil, $4, $5, $6), $7...) + } + | fieldCardinality _GROUP identifier compactOptions '{' messageBody '}' semicolons { + $$ = newNodeWithRunes(ast.NewGroupNode($1.ToKeyword(), $2.ToKeyword(), $3, nil, nil, $4, $5, $6, $7), $8...) + } oneofDecl : _ONEOF identifier '{' oneofBody '}' semicolons { $$ = newNodeWithRunes(ast.NewOneofNode($1.ToKeyword(), $2, $3, $4, $5), $6...) @@ -797,6 +803,12 @@ oneofFieldDecl : oneofElementTypeIdent identifier '=' _INT_LIT semicolon { | oneofElementTypeIdent identifier '=' _INT_LIT compactOptions semicolon { $$ = ast.NewFieldNode(nil, $1, $2, $3, $4, $5, $6) } + | oneofElementTypeIdent identifier semicolon { + $$ = ast.NewFieldNode(nil, $1, $2, nil, nil, nil, $3) + } + | oneofElementTypeIdent identifier compactOptions semicolon { + $$ = ast.NewFieldNode(nil, $1, $2, nil, nil, $3, $4) + } oneofGroupDecl : _GROUP identifier '=' _INT_LIT '{' messageBody '}' { $$ = ast.NewGroupNode(nil, $1.ToKeyword(), $2, $3, $4, nil, $5, $6, $7) @@ -804,6 +816,13 @@ oneofGroupDecl : _GROUP identifier '=' _INT_LIT '{' messageBody '}' { | _GROUP identifier '=' _INT_LIT compactOptions '{' messageBody '}' { $$ = ast.NewGroupNode(nil, $1.ToKeyword(), $2, $3, $4, $5, $6, $7, $8) } + | _GROUP identifier '{' messageBody '}' { + $$ = ast.NewGroupNode(nil, $1.ToKeyword(), $2, nil, nil, nil, $3, $4, $5) + } + | _GROUP identifier compactOptions '{' messageBody '}' { + $$ = ast.NewGroupNode(nil, $1.ToKeyword(), $2, nil, nil, $3, $4, $5, $6) + } + mapFieldDecl : mapType identifier '=' _INT_LIT semicolons { semi, extra := protolex.(*protoLex).requireSemicolon($5) @@ -813,6 +832,14 @@ mapFieldDecl : mapType identifier '=' _INT_LIT semicolons { semi, extra := protolex.(*protoLex).requireSemicolon($6) $$ = newNodeWithRunes(ast.NewMapFieldNode($1, $2, $3, $4, $5, semi), extra...) } + | mapType identifier semicolons { + semi, extra := protolex.(*protoLex).requireSemicolon($3) + $$ = newNodeWithRunes(ast.NewMapFieldNode($1, $2, nil, nil, nil, semi), extra...) + } + | mapType identifier compactOptions semicolons { + semi, extra := protolex.(*protoLex).requireSemicolon($4) + $$ = newNodeWithRunes(ast.NewMapFieldNode($1, $2, nil, nil, $3, semi), extra...) + } mapType : _MAP '<' mapKeyType ',' typeName '>' { $$ = ast.NewMapTypeNode($1.ToKeyword(), $2, $3, $4, $5, $6) @@ -1035,6 +1062,23 @@ messageFieldDecl : fieldCardinality notGroupElementTypeIdent identifier '=' _INT semis, extra := protolex.(*protoLex).requireSemicolon($6) $$ = newNodeWithRunes(ast.NewFieldNode(nil, $1, $2, $3, $4, $5, semis), extra...) } + | fieldCardinality notGroupElementTypeIdent identifier semicolons { + semis, extra := protolex.(*protoLex).requireSemicolon($4) + $$ = newNodeWithRunes(ast.NewFieldNode($1.ToKeyword(), $2, $3, nil, nil, nil, semis), extra...) + } + | fieldCardinality notGroupElementTypeIdent identifier compactOptions semicolons { + semis, extra := protolex.(*protoLex).requireSemicolon($5) + $$ = newNodeWithRunes(ast.NewFieldNode($1.ToKeyword(), $2, $3, nil, nil, $4, semis), extra...) + } + | msgElementTypeIdent identifier semicolons { + semis, extra := protolex.(*protoLex).requireSemicolon($3) + $$ = newNodeWithRunes(ast.NewFieldNode(nil, $1, $2, nil, nil, nil, semis), extra...) + } + | msgElementTypeIdent identifier compactOptions semicolons { + semis, extra := protolex.(*protoLex).requireSemicolon($4) + $$ = newNodeWithRunes(ast.NewFieldNode(nil, $1, $2, nil, nil, $3, semis), extra...) + } + extensionDecl : _EXTEND typeName '{' extensionBody '}' semicolons { $$ = newNodeWithRunes(ast.NewExtendNode($1.ToKeyword(), $2, $3, $4, $5), $6...) diff --git a/vendor/github.com/bufbuild/protocompile/parser/proto.y.go b/vendor/github.com/bufbuild/protocompile/parser/proto.y.go index da9cfa68aaa..048e5cccfd9 100644 --- a/vendor/github.com/bufbuild/protocompile/parser/proto.y.go +++ b/vendor/github.com/bufbuild/protocompile/parser/proto.y.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -257,7 +257,7 @@ var protoExca = [...]int16{ 69, 60, -2, 62, -1, 118, - 56, 237, + 56, 249, -2, 0, -1, 121, 55, 37, @@ -267,348 +267,362 @@ var protoExca = [...]int16{ 69, 37, -2, 35, -1, 140, - 56, 217, + 56, 225, -2, 0, -1, 142, - 56, 206, + 56, 214, -2, 0, -1, 144, - 56, 238, + 56, 250, -2, 0, -1, 198, - 56, 250, + 56, 262, -2, 0, -1, 203, 56, 83, 62, 83, -2, 0, -1, 214, - 56, 218, + 56, 226, -2, 0, -1, 271, - 56, 207, + 56, 215, -2, 0, -1, 377, - 56, 251, + 56, 263, -2, 0, - -1, 462, - 56, 153, + -1, 464, + 56, 155, -2, 0, - -1, 517, + -1, 523, 69, 144, -2, 141, - -1, 522, - 56, 154, + -1, 531, + 56, 156, -2, 0, - -1, 597, + -1, 607, 67, 52, -2, 49, - -1, 652, + -1, 665, 69, 144, -2, 142, - -1, 677, + -1, 690, 67, 52, -2, 50, - -1, 708, - 56, 261, + -1, 732, + 56, 273, -2, 0, - -1, 718, - 56, 262, + -1, 745, + 56, 274, -2, 0, } const protoPrivate = 57344 -const protoLast = 1948 +const protoLast = 2053 var protoAct = [...]int16{ - 140, 7, 139, 7, 7, 586, 18, 719, 437, 436, - 498, 440, 127, 394, 439, 96, 458, 594, 597, 100, - 492, 95, 39, 523, 518, 514, 517, 32, 34, 422, - 421, 405, 200, 435, 233, 378, 272, 106, 326, 36, - 109, 404, 21, 145, 20, 40, 90, 93, 94, 19, - 102, 85, 107, 108, 149, 215, 202, 98, 101, 650, - 33, 137, 135, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, - 78, 79, 80, 81, 82, 83, 84, 90, 124, 125, - 86, 134, 89, 119, 115, 449, 645, 643, 142, 395, - 504, 441, 453, 131, 198, 129, 130, 642, 199, 503, - 126, 133, 390, 134, 452, 641, 457, 502, 588, 714, - 9, 395, 698, 680, 459, 451, 396, 222, 667, 273, - 423, 460, 460, 460, 207, 460, 460, 120, 121, 674, - 493, 460, 138, 134, 416, 423, 692, 501, 134, 110, - 373, 395, 388, 389, 678, 40, 395, 279, 375, 653, - 387, 485, 448, 219, 9, 217, 9, 583, 323, 484, - 218, 464, 468, 386, 466, 227, 577, 9, 113, 459, - 112, 385, 661, 428, 110, 379, 414, 374, 122, 114, - 424, 732, 730, 723, 399, 392, 104, 717, 716, 709, - 705, 222, 655, 207, 397, 424, 9, 383, 697, 486, - 376, 322, 270, 213, 726, 700, 694, 462, 123, 118, - 117, 116, 5, 6, 9, 104, 104, 412, 403, 588, - 407, 408, 413, 657, 324, 40, 31, 219, 415, 217, - 384, 689, 688, 687, 218, 9, 402, 654, 23, 227, - 400, 417, 507, 506, 409, 489, 24, 488, 273, 25, - 26, 463, 456, 430, 419, 111, 461, 9, 13, 12, - 589, 381, 15, 412, 105, 103, 704, 721, 413, 519, - 8, 703, 647, 26, 210, 209, 279, 35, 418, 26, - 28, 27, 29, 30, 33, 104, 211, 212, 646, 585, - 584, 37, 38, 425, 471, 472, 473, 474, 475, 476, - 477, 478, 479, 480, 481, 482, 520, 382, 573, 406, - 508, 491, 487, 33, 707, 426, 427, 718, 40, 4, - 380, 429, 10, 11, 197, 377, 22, 143, 144, 274, - 141, 271, 220, 420, 275, 225, 411, 410, 521, 522, - 214, 231, 224, 221, 526, 147, 223, 432, 146, 525, - 216, 204, 203, 447, 379, 495, 591, 529, 150, 228, - 595, 99, 592, 327, 431, 531, 154, 234, 277, 596, - 329, 533, 434, 156, 237, 450, 470, 391, 393, 442, - 442, 465, 467, 433, 438, 207, 132, 128, 87, 88, - 206, 454, 455, 91, 444, 515, 512, 524, 445, 516, - 17, 16, 14, 3, 469, 2, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 490, 483, - 0, 0, 500, 499, 0, 0, 0, 0, 509, 510, - 0, 494, 0, 442, 0, 574, 0, 0, 505, 0, + 140, 7, 746, 7, 7, 100, 139, 18, 440, 394, + 604, 436, 607, 439, 502, 39, 524, 596, 95, 532, + 496, 127, 437, 422, 520, 200, 32, 34, 523, 233, + 421, 40, 90, 93, 94, 405, 102, 106, 36, 96, + 109, 435, 272, 85, 378, 458, 326, 404, 21, 20, + 19, 107, 108, 149, 215, 202, 145, 98, 101, 86, + 663, 89, 449, 390, 134, 706, 703, 598, 707, 513, + 9, 652, 395, 510, 465, 9, 511, 396, 717, 651, + 507, 459, 459, 460, 452, 459, 456, 9, 506, 459, + 459, 462, 739, 90, 693, 451, 655, 598, 459, 9, + 680, 653, 459, 687, 508, 459, 423, 459, 124, 125, + 453, 115, 459, 459, 459, 134, 126, 133, 142, 138, + 131, 129, 497, 395, 198, 130, 423, 134, 199, 448, + 416, 388, 389, 711, 489, 395, 505, 119, 9, 387, + 207, 666, 488, 593, 9, 468, 472, 113, 222, 112, + 273, 386, 470, 462, 587, 9, 373, 120, 121, 385, + 110, 40, 110, 691, 674, 428, 424, 414, 374, 122, + 114, 375, 279, 760, 758, 754, 750, 104, 744, 743, + 741, 733, 729, 721, 695, 9, 424, 716, 753, 219, + 217, 218, 668, 383, 227, 376, 322, 270, 213, 728, + 719, 323, 713, 658, 464, 123, 379, 118, 117, 207, + 116, 5, 6, 104, 399, 9, 598, 104, 670, 324, + 31, 702, 222, 667, 493, 490, 9, 492, 430, 392, + 419, 111, 13, 12, 403, 599, 407, 408, 413, 528, + 463, 40, 381, 748, 726, 8, 412, 724, 397, 659, + 33, 415, 15, 656, 26, 26, 9, 37, 38, 384, + 210, 209, 105, 219, 217, 218, 103, 35, 227, 400, + 595, 417, 211, 212, 402, 23, 529, 594, 104, 273, + 409, 582, 406, 24, 413, 516, 25, 26, 382, 495, + 491, 4, 412, 33, 10, 11, 731, 745, 380, 197, + 377, 279, 475, 476, 477, 478, 479, 480, 481, 482, + 483, 484, 485, 486, 418, 22, 143, 28, 27, 29, + 30, 144, 274, 425, 141, 271, 220, 420, 275, 225, + 411, 426, 427, 410, 40, 530, 531, 214, 231, 224, + 221, 535, 147, 223, 429, 146, 534, 216, 204, 203, + 447, 499, 601, 538, 150, 228, 605, 99, 602, 327, + 540, 154, 234, 277, 606, 329, 542, 156, 237, 474, + 391, 393, 438, 132, 128, 87, 88, 432, 206, 91, + 431, 521, 518, 533, 522, 379, 17, 16, 434, 14, + 3, 2, 1, 0, 0, 442, 442, 0, 0, 0, + 0, 207, 0, 0, 457, 0, 0, 454, 455, 466, + 0, 469, 471, 0, 0, 0, 0, 0, 0, 450, + 473, 445, 433, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 444, 0, 494, 0, 0, 0, 0, 0, + 0, 0, 0, 487, 0, 0, 0, 498, 0, 442, + 461, 0, 0, 0, 467, 503, 514, 0, 0, 517, + 0, 525, 526, 0, 0, 90, 504, 0, 583, 584, + 0, 0, 0, 0, 0, 0, 0, 0, 586, 0, + 0, 0, 0, 0, 585, 0, 0, 0, 588, 0, + 591, 0, 509, 0, 0, 0, 0, 0, 527, 0, + 512, 515, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 592, 0, 660, 661, 657, 590, + 0, 0, 0, 0, 0, 0, 0, 90, 0, 0, + 654, 0, 0, 589, 0, 0, 0, 0, 0, 0, + 0, 597, 0, 90, 672, 673, 664, 40, 0, 0, + 665, 669, 0, 0, 671, 0, 0, 675, 0, 0, + 0, 0, 662, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 90, 575, 0, 0, 578, 0, 581, 0, 576, 0, - 0, 511, 0, 0, 0, 0, 0, 0, 0, 0, - 579, 0, 0, 0, 0, 0, 0, 0, 587, 648, - 0, 0, 644, 0, 0, 580, 582, 0, 0, 0, - 0, 0, 0, 0, 0, 649, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 90, 0, 0, 0, 0, - 0, 651, 652, 0, 0, 0, 656, 0, 90, 659, - 660, 0, 40, 658, 0, 662, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 663, 0, 0, 0, 0, 0, - 666, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 664, 669, 0, 671, 0, 0, 0, 0, 0, 665, - 0, 668, 670, 0, 0, 0, 0, 0, 0, 675, - 672, 0, 673, 676, 677, 0, 0, 0, 0, 0, + 0, 0, 0, 676, 0, 0, 0, 0, 0, 0, + 679, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 678, 0, 0, 0, + 0, 0, 0, 682, 0, 684, 689, 0, 690, 686, + 685, 0, 0, 0, 0, 0, 0, 0, 677, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 681, 683, 0, 688, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 442, 0, + 697, 0, 0, 699, 503, 696, 0, 692, 0, 701, + 0, 0, 0, 133, 0, 504, 131, 129, 710, 0, + 709, 130, 0, 0, 0, 0, 715, 712, 0, 700, + 704, 0, 0, 0, 0, 0, 720, 0, 0, 722, + 718, 714, 694, 0, 0, 698, 0, 0, 133, 0, + 0, 131, 129, 0, 727, 0, 130, 732, 705, 708, + 730, 0, 735, 725, 723, 0, 734, 0, 0, 0, + 0, 0, 0, 0, 749, 742, 0, 0, 0, 0, + 747, 736, 737, 0, 0, 755, 752, 0, 756, 0, + 0, 757, 0, 747, 0, 0, 751, 0, 0, 0, + 759, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 738, 501, 740, 33, 137, 135, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, + 0, 0, 0, 0, 134, 0, 0, 0, 0, 0, + 0, 0, 395, 0, 441, 0, 0, 0, 500, 33, + 137, 135, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, + 79, 80, 81, 82, 83, 84, 0, 0, 0, 0, + 134, 0, 0, 0, 0, 0, 0, 0, 395, 0, + 441, 0, 0, 443, 33, 137, 135, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, + 84, 0, 0, 0, 0, 134, 0, 0, 0, 0, + 0, 0, 0, 395, 0, 441, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 682, 0, - 684, 500, 499, 679, 0, 0, 686, 0, 0, 0, - 0, 0, 442, 681, 683, 691, 131, 685, 129, 130, - 693, 0, 0, 696, 133, 0, 695, 0, 0, 0, - 0, 690, 0, 699, 701, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 706, 708, 131, - 702, 129, 130, 710, 0, 0, 0, 133, 711, 712, - 722, 0, 0, 0, 0, 720, 0, 725, 727, 724, - 713, 715, 0, 0, 729, 720, 728, 0, 497, 731, - 33, 137, 135, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, - 78, 79, 80, 81, 82, 83, 84, 0, 0, 0, - 0, 134, 0, 0, 0, 0, 0, 0, 0, 395, - 0, 441, 0, 0, 0, 496, 33, 137, 135, 41, + 0, 0, 0, 0, 205, 92, 0, 0, 519, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, - 82, 83, 84, 0, 0, 0, 0, 134, 0, 0, - 0, 0, 0, 0, 0, 395, 0, 441, 0, 0, - 443, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 82, 83, 84, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 446, 0, 205, 0, 0, 0, + 208, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 205, - 92, 0, 0, 513, 41, 42, 43, 44, 45, 46, - 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, - 77, 78, 79, 80, 81, 82, 83, 84, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 446, - 0, 205, 0, 0, 0, 208, 41, 42, 43, 44, + 201, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 208, 33, 137, 135, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, - 0, 0, 0, 0, 0, 201, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 208, 33, 137, - 135, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 0, 0, 0, 0, 134, - 0, 0, 0, 0, 0, 205, 0, 0, 0, 136, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, - 81, 82, 83, 84, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, - 423, 208, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, - 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, - 79, 80, 81, 82, 83, 84, 0, 0, 0, 0, + 0, 0, 0, 0, 134, 0, 0, 0, 0, 0, + 205, 0, 0, 0, 136, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, + 76, 77, 78, 79, 80, 81, 82, 83, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 424, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 33, 423, 208, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, + 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 424, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 92, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 97, 598, 599, 600, 601, 602, - 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, - 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, - 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, - 633, 634, 635, 636, 637, 638, 639, 590, 640, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 593, 330, - 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, - 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, - 351, 352, 353, 354, 355, 356, 357, 358, 359, 401, - 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, - 370, 371, 372, 0, 0, 0, 0, 0, 226, 0, - 0, 0, 328, 238, 239, 240, 241, 242, 243, 244, - 26, 245, 246, 247, 248, 153, 152, 151, 249, 250, - 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, - 261, 262, 263, 0, 230, 236, 229, 264, 265, 232, - 28, 27, 29, 266, 267, 268, 269, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 235, 330, 331, 332, - 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, - 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, - 353, 354, 355, 356, 357, 358, 359, 325, 360, 361, - 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, - 372, 0, 0, 0, 0, 0, 148, 0, 0, 0, - 328, 157, 158, 159, 160, 161, 162, 163, 164, 165, - 166, 167, 168, 153, 152, 151, 169, 170, 171, 172, - 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, - 183, 0, 184, 185, 186, 187, 188, 189, 190, 191, - 192, 193, 194, 195, 196, 0, 0, 0, 0, 0, - 527, 0, 0, 0, 155, 534, 535, 536, 537, 538, - 539, 540, 528, 541, 542, 543, 544, 0, 0, 0, - 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, - 555, 556, 557, 558, 559, 530, 560, 561, 562, 563, - 564, 565, 566, 567, 568, 569, 570, 571, 572, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 532, 210, - 209, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 33, 406, 0, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, - 83, 84, 276, 0, 0, 0, 0, 280, 281, 282, - 283, 284, 285, 286, 26, 287, 288, 289, 290, 291, - 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, - 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, - 312, 313, 314, 278, 315, 316, 317, 318, 319, 320, - 321, 398, 0, 0, 0, 0, 41, 42, 43, 44, + 0, 0, 0, 0, 0, 92, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 97, + 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, + 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, + 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, + 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, + 648, 649, 600, 650, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 603, 330, 331, 332, 333, 334, 335, + 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, + 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, + 356, 357, 358, 359, 401, 360, 361, 362, 363, 364, + 365, 366, 367, 368, 369, 370, 371, 372, 0, 0, + 0, 0, 0, 226, 0, 0, 0, 328, 238, 239, + 240, 241, 242, 243, 244, 26, 245, 246, 247, 248, + 153, 152, 151, 249, 250, 251, 252, 253, 254, 255, + 256, 257, 258, 259, 260, 261, 262, 263, 0, 230, + 236, 229, 264, 265, 232, 28, 27, 29, 266, 267, + 268, 269, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 235, 330, 331, 332, 333, 334, 335, 336, 337, + 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, + 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, + 358, 359, 325, 360, 361, 362, 363, 364, 365, 366, + 367, 368, 369, 370, 371, 372, 0, 0, 0, 0, + 0, 148, 0, 0, 0, 328, 157, 158, 159, 160, + 161, 162, 163, 164, 165, 166, 167, 168, 153, 152, + 151, 169, 170, 171, 172, 173, 174, 175, 176, 177, + 178, 179, 180, 181, 182, 183, 0, 184, 185, 186, + 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, + 0, 0, 0, 0, 0, 536, 0, 0, 0, 155, + 543, 544, 545, 546, 547, 548, 549, 537, 550, 551, + 552, 553, 0, 0, 0, 554, 555, 556, 557, 558, + 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, + 539, 569, 570, 571, 572, 573, 574, 575, 576, 577, + 578, 579, 580, 581, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 541, 210, 209, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, - 81, 82, 83, 84, 598, 599, 600, 601, 602, 603, - 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, - 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, - 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, - 634, 635, 636, 637, 638, 639, 0, 640, + 33, 406, 0, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, + 78, 79, 80, 81, 82, 83, 84, 276, 0, 0, + 0, 0, 280, 281, 282, 283, 284, 285, 286, 26, + 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, + 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, + 307, 308, 309, 310, 311, 312, 313, 314, 278, 315, + 316, 317, 318, 319, 320, 321, 398, 0, 0, 0, + 0, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, + 76, 77, 78, 79, 80, 81, 82, 83, 84, 608, + 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, + 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, + 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, + 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, + 649, 0, 650, } var protoPact = [...]int16{ - 234, -1000, 191, 191, -1000, 237, 236, 266, 203, -1000, - -1000, -1000, 339, 339, 266, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, 310, 1853, 1224, 1853, 1853, 1284, - 1853, -1000, 242, -1000, 241, -1000, 212, 339, 339, 144, + 203, -1000, 162, 162, -1000, 181, 180, 273, 167, -1000, + -1000, -1000, 289, 289, 273, -1000, -1000, -1000, -1000, -1000, + -1000, -1000, -1000, -1000, 246, 1958, 1329, 1958, 1958, 1389, + 1958, -1000, 213, -1000, 209, -1000, 173, 289, 289, 102, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, -1000, 233, -1000, 1224, 149, -1000, - -1000, -1000, 1284, 186, 185, 184, -1000, 1853, -1000, 1853, - 148, -1000, 183, -1000, -1000, -1000, -1000, 212, 212, -1000, - 1853, 1044, -1000, -1000, -1000, 95, 191, 191, 1554, -1000, - -1000, -1000, -1000, 191, -1000, -1000, -1000, 191, -1000, -1000, - 311, -1000, -1000, -1000, 979, -1000, 299, -1000, -1000, 177, - 1446, 176, 1760, 175, 1554, -1000, -1000, -1000, 201, 1500, - 1853, -1000, -1000, -1000, 147, 1853, -1000, -1000, -1000, -1000, + -1000, -1000, -1000, -1000, -1000, 179, -1000, 1329, 110, -1000, + -1000, -1000, 1389, 155, 153, 152, -1000, 1958, -1000, 1958, + 109, -1000, 150, -1000, -1000, -1000, -1000, 173, 173, -1000, + 1958, 1149, -1000, -1000, -1000, 52, 162, 162, 1659, -1000, + -1000, -1000, -1000, 162, -1000, -1000, -1000, 162, -1000, -1000, + 274, -1000, -1000, -1000, 1084, -1000, 255, -1000, -1000, 142, + 1551, 141, 1865, 140, 1659, -1000, -1000, -1000, 166, 1605, + 1958, -1000, -1000, -1000, 108, 1958, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, -1000, -1000, -1000, 174, 289, -1000, - 171, -1000, -1000, 1103, 140, 119, 78, -1000, 1809, -1000, - -1000, -1000, -1000, 191, 1446, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, -1000, -1000, -1000, 1392, 1853, 334, - 1853, 1853, 1711, -1000, 146, 1853, 101, -1000, -1000, -1000, + -1000, -1000, -1000, -1000, -1000, -1000, -1000, 139, 240, -1000, + 137, -1000, -1000, 1208, 98, 78, 9, -1000, 1914, -1000, + -1000, -1000, -1000, 162, 1551, -1000, -1000, -1000, -1000, -1000, + -1000, -1000, -1000, -1000, -1000, -1000, -1000, 1497, 1958, 277, + 1958, 1958, 1816, -1000, 107, 1958, 67, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - 191, 1760, -1000, -1000, -1000, -1000, -1000, 232, 1165, -1000, + 162, 1865, -1000, -1000, -1000, -1000, -1000, 178, 1270, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, 191, -1000, -1000, 1853, 1853, 143, 1853, -1000, + -1000, -1000, 162, -1000, -1000, 1958, 1958, 105, 1958, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, 231, 1853, 109, 191, 289, -1000, -1000, - -1000, -1000, 1853, -1000, -1000, -1000, -1000, -1000, -1000, 792, - 792, -1000, -1000, -1000, -1000, 917, 113, 76, 53, -1000, - -1000, 1853, 1853, 230, 83, -1000, 245, 182, 229, 138, - 133, 131, 311, -1000, 1853, 109, 300, -1000, -1000, 160, - 128, -1000, 188, -1000, 337, -1000, 225, 223, 1853, 109, - 336, -1000, -1000, -1000, 94, -1000, -1000, -1000, -1000, 311, - -1000, 1664, -1000, 726, -1000, 105, -1000, 68, -1000, 51, - -1000, -1000, 1853, -1000, 221, 220, 335, 191, 191, 334, - 854, 294, 1608, 333, 191, -1000, 339, -1000, 1853, -1000, - 135, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, 87, 160, 191, 145, -1000, 315, 314, - -1000, 85, 240, 1338, -1000, 66, -1000, 48, -1000, -1000, - -1000, -1000, -1000, 108, -1000, 47, 313, 297, 87, -1000, - -1000, -1000, -10, -1000, -1000, 1224, 118, -1000, 215, -1000, - -1000, 166, 1608, -1000, -1000, -1000, -1000, 200, 1224, 1853, - 1853, 142, 1853, -1000, -1000, -1000, -1000, -1000, -1000, -1000, + -1000, -1000, -1000, 176, 1958, 100, 162, 240, -1000, -1000, + -1000, -1000, 1958, -1000, -1000, -1000, -1000, -1000, -1000, 835, + 835, -1000, -1000, -1000, -1000, 1022, 60, 26, 41, -1000, + -1000, 1958, 1958, 34, 30, -1000, 199, 149, 22, 92, + 91, 85, 274, -1000, 1958, 100, 278, -1000, -1000, 121, + 81, -1000, 184, -1000, 285, -1000, 175, 172, 1958, 100, + 284, -1000, -1000, -1000, 56, -1000, -1000, -1000, -1000, 274, + -1000, 1769, -1000, 769, -1000, 74, -1000, 19, -1000, 35, + -1000, -1000, 1958, -1000, 21, 17, 280, -1000, 162, 959, + 162, 162, 277, 234, 1713, 276, -1000, 162, 162, -1000, + 289, -1000, 1958, -1000, 93, -1000, -1000, -1000, -1000, -1000, + -1000, -1000, -1000, -1000, -1000, -1000, -1000, 46, 121, 162, + 101, -1000, 272, 265, -1000, 44, 185, 1443, -1000, 10, + -1000, 32, -1000, -1000, -1000, -1000, -1000, 72, -1000, 27, + 248, 162, 148, 244, -1000, 162, 46, -1000, -9, -1000, + -1000, 1329, 80, -1000, 171, -1000, -1000, -1000, -1000, -1000, + 136, 1713, -1000, -1000, -1000, -1000, 165, 1329, 1958, 1958, + 104, 1958, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, 87, -1000, 311, -1000, 1284, -1000, 191, - -1000, -1000, -1000, -1000, 93, 85, -1000, 196, -1000, 94, - 1284, 92, -1000, 1853, -1000, 1897, 114, -1000, -1000, -1000, + -1000, -1000, 46, -1000, -1000, 274, -1000, 1389, -1000, 162, + -1000, -1000, -1000, -1000, 45, 44, -1000, 163, -1000, 56, + 1389, 36, -1000, 1958, -1000, 2002, 103, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, 56, -1000, -1000, -1000, 88, 87, -1000, 191, - -1000, -1000, -1000, -1000, 1044, 191, -1000, -1000, 211, 210, - 209, 1853, 109, -1000, 191, 104, -1000, 191, 181, -1000, - 196, -1000, 173, 75, -1000, -1000, -1000, -1000, -1000, -1000, - 191, 180, -1000, 191, -1000, -1000, -1000, 1044, 296, 291, - -1000, -1000, -1000, 164, 191, -1000, -1000, 191, -1000, 163, - 191, -1000, 196, 85, 84, -1000, 162, 161, 295, 191, - 157, -1000, -1000, 196, 191, 179, -1000, 191, 295, -1000, - -1000, -1000, -1000, 191, -1000, 156, 191, -1000, -1000, -1000, - -1000, 155, -1000, + -1000, -1000, 900, -1000, -1000, -1000, 39, 128, 162, 46, + -1000, -1000, 162, -1000, -1000, -1000, -1000, 1149, 162, -1000, + -1000, 169, 14, 13, 1958, 100, -1000, 162, 71, -1000, + 162, 147, -1000, 163, -1000, 132, 11, -1000, -1000, -1000, + -1000, -1000, -1000, 162, 145, 162, 127, -1000, 162, -1000, + -1000, -1000, 1149, 242, -1000, 163, 239, 162, 144, -1000, + -1000, -1000, 126, 162, -1000, -1000, 162, -1000, 125, 162, + -1000, 162, -1000, 163, 44, -1000, 37, 124, 162, -1000, + 123, 122, 241, 162, 120, -1000, -1000, -1000, 163, 162, + 133, -1000, 119, -1000, 162, 241, -1000, -1000, -1000, -1000, + 162, -1000, 118, 162, -1000, -1000, -1000, -1000, -1000, 117, + -1000, } var protoPgo = [...]int16{ - 0, 436, 435, 433, 349, 292, 432, 431, 430, 429, - 427, 6, 26, 25, 426, 425, 423, 420, 419, 112, - 110, 24, 418, 16, 33, 12, 417, 9, 13, 8, - 11, 416, 414, 10, 408, 407, 29, 19, 406, 404, - 403, 401, 400, 399, 398, 54, 58, 57, 18, 17, - 22, 397, 396, 395, 393, 392, 15, 391, 390, 21, - 389, 388, 387, 38, 386, 385, 383, 382, 56, 32, - 381, 380, 379, 378, 376, 375, 374, 373, 372, 371, - 49, 55, 370, 2, 23, 369, 368, 367, 366, 365, - 364, 34, 31, 30, 41, 363, 362, 44, 36, 361, - 360, 359, 42, 43, 358, 357, 14, 356, 35, 355, - 354, 350, 7, 347, 344, 20, 5, 0, 300, + 0, 392, 391, 390, 291, 252, 389, 387, 386, 384, + 383, 7, 28, 24, 382, 381, 379, 378, 376, 61, + 59, 16, 375, 45, 41, 21, 374, 11, 9, 22, + 8, 373, 372, 14, 371, 370, 23, 5, 369, 368, + 367, 366, 365, 364, 363, 53, 58, 57, 12, 10, + 15, 362, 361, 360, 359, 358, 39, 357, 356, 18, + 355, 354, 353, 46, 352, 351, 350, 349, 55, 25, + 348, 347, 346, 345, 343, 342, 341, 340, 339, 338, + 50, 54, 337, 6, 19, 336, 335, 333, 330, 329, + 328, 29, 35, 30, 47, 327, 326, 49, 42, 325, + 324, 322, 48, 56, 321, 316, 13, 315, 44, 300, + 299, 298, 2, 297, 296, 20, 17, 0, 245, } var protoR1 = [...]int8{ @@ -627,47 +641,48 @@ var protoR1 = [...]int8{ 66, 66, 59, 59, 60, 60, 61, 61, 62, 62, 63, 63, 64, 64, 45, 45, 45, 23, 23, 14, 14, 15, 15, 13, 13, 12, 9, 9, 75, 75, - 77, 77, 74, 86, 86, 85, 85, 84, 84, 84, - 84, 84, 72, 72, 76, 76, 78, 78, 79, 38, - 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, - 38, 96, 96, 94, 94, 92, 92, 92, 95, 95, - 93, 93, 93, 36, 36, 89, 89, 90, 90, 91, - 91, 87, 87, 88, 88, 97, 100, 100, 99, 99, - 98, 98, 98, 98, 101, 101, 80, 83, 83, 82, - 82, 81, 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 71, 71, 71, 71, 102, 105, 105, 104, - 104, 103, 103, 103, 103, 73, 73, 73, 73, 107, - 110, 110, 109, 109, 108, 108, 108, 111, 111, 115, - 115, 114, 114, 113, 113, 112, 112, 39, 39, 39, + 77, 77, 77, 77, 74, 86, 86, 85, 85, 84, + 84, 84, 84, 84, 72, 72, 72, 72, 76, 76, + 76, 76, 78, 78, 78, 78, 79, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 96, + 96, 94, 94, 92, 92, 92, 95, 95, 93, 93, + 93, 36, 36, 89, 89, 90, 90, 91, 91, 87, + 87, 88, 88, 97, 100, 100, 99, 99, 98, 98, + 98, 98, 101, 101, 80, 83, 83, 82, 82, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 71, 71, 71, 71, 71, 71, 71, 71, 102, 105, + 105, 104, 104, 103, 103, 103, 103, 73, 73, 73, + 73, 107, 110, 110, 109, 109, 108, 108, 108, 111, + 111, 115, 115, 114, 114, 113, 113, 112, 112, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, + 39, 39, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, - 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, - 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, - 44, 44, 41, 41, 41, 41, 41, 41, 41, 41, + 44, 44, 44, 44, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 41, 41, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 43, 43, 43, 43, 43, 43, + 42, 42, 42, 42, 42, 42, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 37, 37, 37, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, + 37, 37, 37, } var protoR2 = [...]int8{ @@ -686,18 +701,19 @@ var protoR2 = [...]int8{ 1, 3, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 1, 3, 2, 1, 2, 1, 2, 1, 1, 2, 3, 1, 8, 9, - 9, 10, 6, 0, 1, 2, 1, 1, 1, 1, - 2, 1, 5, 6, 7, 8, 5, 6, 6, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 4, 4, 1, 3, 1, 3, 3, 1, 3, - 1, 3, 3, 1, 2, 4, 1, 4, 1, 3, - 3, 1, 3, 1, 3, 6, 1, 2, 2, 1, - 1, 1, 1, 1, 4, 5, 6, 1, 2, 2, + 9, 10, 7, 8, 6, 0, 1, 2, 1, 1, + 1, 1, 2, 1, 5, 6, 3, 4, 7, 8, + 5, 6, 5, 6, 3, 4, 6, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, + 4, 1, 3, 1, 3, 3, 1, 3, 1, 3, + 3, 1, 2, 4, 1, 4, 1, 3, 3, 1, + 3, 1, 3, 6, 1, 2, 2, 1, 1, 1, + 1, 1, 4, 5, 6, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 6, 7, 5, 6, 6, 0, 1, 2, - 1, 1, 1, 2, 1, 6, 7, 5, 6, 6, - 1, 2, 2, 1, 1, 1, 1, 6, 9, 4, - 3, 1, 2, 2, 1, 1, 1, 1, 1, 1, + 6, 7, 5, 6, 4, 5, 3, 4, 6, 0, + 1, 2, 1, 1, 1, 2, 1, 6, 7, 5, + 6, 6, 1, 2, 2, 1, 1, 1, 1, 6, + 9, 4, 3, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -726,7 +742,7 @@ var protoR2 = [...]int8{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, + 1, 1, 1, } var protoChk = [...]int16{ @@ -775,35 +791,38 @@ var protoChk = [...]int16{ -95, -93, -36, 5, 65, -117, -37, -37, 60, -50, 52, -37, -117, -108, -37, -24, -27, -29, -32, -106, -30, 65, -37, 68, -24, -69, 62, -66, 69, 2, - -29, 69, 58, 69, -37, -37, 52, 53, -23, 61, - 68, 41, 55, 52, 53, -117, 61, -117, 61, -37, - -38, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, -36, 61, 53, 41, 5, 52, 52, - -37, 5, -115, 66, -37, -65, 69, 2, -33, -27, - -29, 62, 69, 61, 69, -56, 52, 52, 5, -117, - -117, -92, -14, 69, -13, -15, -9, -12, -21, 5, - 42, -86, -85, -84, -10, -72, -76, 2, 14, -62, - 37, -53, 60, -41, 7, 8, 9, 10, 11, 12, - 13, 15, 16, 17, 18, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, - 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 5, -117, -106, -37, 61, -117, -23, + -29, 69, 58, 69, -37, -37, 52, -117, -23, 68, + 53, -23, 61, 41, 55, 52, -117, -23, 53, -117, + 61, -117, 61, -37, -38, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, -36, 61, 53, + 41, 5, 52, 52, -37, 5, -115, 66, -37, -65, + 69, 2, -33, -27, -29, 62, 69, 61, 69, -56, + 52, 55, -23, 52, -117, -23, 5, -117, -14, 69, + -13, -15, -9, -12, -21, -117, -117, -92, 5, 42, + -86, -85, -84, -10, -72, -76, 2, 14, -62, 37, + -53, 60, -41, 7, 8, 9, 10, 11, 12, 13, + 15, 16, 17, 18, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 5, -117, -117, -106, -37, 61, -117, -23, -93, -117, -36, 42, 5, 5, -116, -23, 53, 50, 49, -64, -55, 60, -49, -58, -43, -48, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 50, 69, 61, 69, -29, 69, 5, 5, -117, -23, - 69, -13, -12, 61, 52, 56, -84, 53, -21, -37, - -37, 60, -50, -117, -23, -59, -117, 55, -23, -116, - -23, -116, -115, -59, 67, -56, -49, -48, 60, -33, - 55, -23, -117, -23, -117, -25, -117, 52, 52, 52, - -37, -117, 62, -83, 55, -116, -117, 55, 67, -83, - 55, -117, -25, 5, 5, 56, -83, -114, -117, 56, - -83, -116, -116, -23, 55, -23, 56, 56, -113, -112, - -11, 2, -117, 56, -116, -83, 55, -117, -112, -117, - 56, -83, 56, + 50, 69, 61, 69, -29, 69, 5, -83, 55, 5, + -117, -117, -23, 69, -13, -12, 61, 52, 56, -84, + 53, -21, -37, -37, 60, -50, -117, -23, -59, -117, + 55, -23, -116, -23, -116, -115, -59, 67, -56, -49, + -48, 60, -33, 55, -23, 56, -83, -117, -23, -117, + -25, -117, 52, 52, -116, -23, 52, 55, -23, -37, + -117, 62, -83, 55, -116, -117, 55, 67, -83, 55, + -117, 56, -117, -25, 5, -116, 5, -83, 55, 56, + -83, -114, -117, 56, -83, -117, -116, -116, -23, 55, + -23, 56, -83, 56, 56, -113, -112, -11, 2, -117, + 56, -116, -83, 55, 56, -117, -112, -117, 56, -83, + 56, } var protoDef = [...]int16{ @@ -811,76 +830,79 @@ var protoDef = [...]int16{ 4, 5, 0, 0, -2, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 0, 0, 0, 0, 0, 0, 19, 0, 78, 0, 8, 21, 0, 0, 21, - 30, 507, 508, 509, 510, 511, 512, 513, 514, 515, - 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, - 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, - 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, - 546, 547, 548, 549, 550, 0, 63, 0, 59, -2, + 30, 519, 520, 521, 522, 523, 524, 525, 526, 527, + 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, + 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, + 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, + 558, 559, 560, 561, 562, 0, 63, 0, 59, -2, 56, 57, 0, 0, 0, 0, 122, 0, 32, 0, 36, -2, 0, 24, 79, 25, 26, 21, 21, 29, 0, 0, -2, 64, 58, 0, 21, 21, -2, 123, 33, -2, 38, 21, 27, 28, 31, 21, 66, 67, 68, 69, 70, 71, 0, 72, 0, 74, 65, 0, - -2, 0, -2, 0, -2, 240, 241, 242, 244, 0, - 0, 134, 135, 136, 126, 0, 41, 300, 301, 302, - 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, - 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, - 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, - 333, 334, 335, 336, 337, 338, 339, 0, -2, 55, + -2, 0, -2, 0, -2, 252, 253, 254, 256, 0, + 0, 134, 135, 136, 126, 0, 41, 312, 313, 314, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, + 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, + 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, + 345, 346, 347, 348, 349, 350, 351, 0, -2, 55, 0, 81, 82, -2, 85, 90, 0, 94, 0, 73, - 75, 76, 77, 21, -2, 220, 221, 222, 223, 224, - 225, 226, 227, 228, 229, 230, 231, 0, 0, 0, - 0, 0, 0, 196, 124, 0, 293, 39, 267, 268, - 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, - 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, - 289, 290, 291, 292, 294, 295, 296, 297, 298, 299, - 21, -2, 209, 210, 211, 212, 213, 0, 0, 198, - 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, - 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, - 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, - 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, - 380, 381, 21, 239, 243, 0, 0, 130, 0, 45, - 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, - 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, - 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, - 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, - 461, 462, 463, 0, 0, 127, 21, -2, 253, 254, - 255, 256, 0, 80, 84, 86, 87, 88, 89, 0, - 0, 92, 105, 106, 107, 0, 0, 0, 0, 216, - 219, 0, 0, 0, 0, 183, 185, 0, 0, 0, - 21, 21, 201, 203, 0, 125, 0, 205, 208, 0, - 0, 188, 190, 193, 0, 236, 0, 0, 0, 131, - 0, 42, 249, 252, 0, 93, 98, 99, 100, 101, + 75, 76, 77, 21, -2, 228, 229, 230, 231, 232, + 233, 234, 235, 236, 237, 238, 239, 0, 0, 0, + 0, 0, 0, 204, 124, 0, 305, 39, 279, 280, + 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, + 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, + 301, 302, 303, 304, 306, 307, 308, 309, 310, 311, + 21, -2, 217, 218, 219, 220, 221, 0, 0, 206, + 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, + 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, + 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, + 392, 393, 21, 251, 255, 0, 0, 130, 0, 45, + 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, + 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, + 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, + 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, + 473, 474, 475, 0, 0, 127, 21, -2, 265, 266, + 267, 268, 0, 80, 84, 86, 87, 88, 89, 0, + 0, 92, 105, 106, 107, 0, 0, 0, 0, 224, + 227, 0, 0, 21, 0, 191, 193, 0, 21, 0, + 21, 21, 209, 211, 0, 125, 0, 213, 216, 0, + 0, 196, 198, 201, 0, 248, 0, 0, 0, 131, + 0, 42, 261, 264, 0, 93, 98, 99, 100, 101, 102, 0, 104, 0, 91, 0, 109, 0, 118, 0, - 120, 95, 0, 97, 0, 0, 0, 21, 21, 0, - 0, 0, -2, 0, 21, 199, 0, 200, 0, 40, - 0, 169, 170, 171, 172, 173, 174, 175, 176, 177, - 178, 179, 180, 21, 0, 21, 0, 194, 0, 0, - 46, 23, 0, 0, 103, 0, 111, 0, 113, 115, - 116, 108, 117, 0, 119, 0, 0, 0, 21, 181, - 182, 184, 0, 138, 139, 0, 143, -2, 147, 186, - 187, 0, -2, 156, 157, 158, 159, 161, 0, 0, - 0, 128, 0, 43, 382, 383, 384, 385, 386, 387, - 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, - 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, - 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, - 418, 419, 420, 21, 195, 202, 204, 0, 214, 21, - 189, 197, 191, 192, 0, 23, 247, 23, 22, 0, - 0, 0, 132, 0, 47, 0, 51, -2, 464, 465, - 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, - 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, - 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, - 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, - 506, 110, 0, 112, 121, 96, 0, 21, 234, 21, - 137, 140, -2, 145, 0, 21, 155, 160, 0, 0, - 0, 0, 129, 166, 21, 0, 215, 21, 0, 245, - 23, 248, 21, 0, 260, 133, 48, -2, 53, 114, - 21, 0, 232, 21, 235, 146, 152, 0, 0, 0, - 44, 167, 168, 0, 21, 246, 257, 21, 259, 0, - 21, 233, 23, 23, 0, 148, 0, 0, -2, 21, - 0, 54, 162, 23, 21, 0, 149, 21, -2, 264, - 265, 266, 150, 21, 163, 0, 21, 258, 263, 151, - 164, 0, 165, + 120, 95, 0, 97, 0, 21, 0, 246, 21, 0, + 21, 21, 0, 0, -2, 0, 174, 21, 21, 207, + 0, 208, 0, 40, 0, 177, 178, 179, 180, 181, + 182, 183, 184, 185, 186, 187, 188, 21, 0, 21, + 0, 202, 0, 0, 46, 23, 0, 0, 103, 0, + 111, 0, 113, 115, 116, 108, 117, 0, 119, 0, + 0, 21, 0, 0, 244, 21, 21, 247, 0, 138, + 139, 0, 143, -2, 147, 189, 190, 192, 194, 195, + 0, -2, 158, 159, 160, 161, 163, 0, 0, 0, + 128, 0, 43, 394, 395, 396, 397, 398, 399, 400, + 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, + 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, + 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, + 431, 432, 21, 175, 203, 210, 212, 0, 222, 21, + 197, 205, 199, 200, 0, 23, 259, 23, 22, 0, + 0, 0, 132, 0, 47, 0, 51, -2, 476, 477, + 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, + 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, + 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, + 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, + 518, 110, 0, 112, 121, 96, 0, 0, 21, 21, + 245, 242, 21, 137, 140, -2, 145, 0, 21, 157, + 162, 0, 23, 0, 0, 129, 172, 21, 0, 223, + 21, 0, 257, 23, 260, 21, 0, 272, 133, 48, + -2, 53, 114, 21, 0, 21, 0, 240, 21, 243, + 146, 154, 0, 0, 166, 23, 0, 21, 0, 44, + 173, 176, 0, 21, 258, 269, 21, 271, 0, 21, + 152, 21, 241, 23, 23, 167, 0, 0, 21, 148, + 0, 0, -2, 21, 0, 153, 54, 164, 23, 21, + 0, 170, 0, 149, 21, -2, 276, 277, 278, 150, + 21, 165, 0, 21, 171, 270, 275, 151, 168, 0, + 169, } var protoTok1 = [...]int8{ @@ -2030,16 +2052,26 @@ protodefault: protoVAL.msgGrp = newNodeWithRunes(ast.NewGroupNode(protoDollar[1].id.ToKeyword(), protoDollar[2].id.ToKeyword(), protoDollar[3].id, protoDollar[4].b, protoDollar[5].i, protoDollar[6].cmpctOpts, protoDollar[7].b, protoDollar[8].msgElements, protoDollar[9].b), protoDollar[10].bs...) } case 152: + protoDollar = protoS[protopt-7 : protopt+1] + { + protoVAL.msgGrp = newNodeWithRunes(ast.NewGroupNode(protoDollar[1].id.ToKeyword(), protoDollar[2].id.ToKeyword(), protoDollar[3].id, nil, nil, nil, protoDollar[4].b, protoDollar[5].msgElements, protoDollar[6].b), protoDollar[7].bs...) + } + case 153: + protoDollar = protoS[protopt-8 : protopt+1] + { + protoVAL.msgGrp = newNodeWithRunes(ast.NewGroupNode(protoDollar[1].id.ToKeyword(), protoDollar[2].id.ToKeyword(), protoDollar[3].id, nil, nil, protoDollar[4].cmpctOpts, protoDollar[5].b, protoDollar[6].msgElements, protoDollar[7].b), protoDollar[8].bs...) + } + case 154: protoDollar = protoS[protopt-6 : protopt+1] { protoVAL.oo = newNodeWithRunes(ast.NewOneofNode(protoDollar[1].id.ToKeyword(), protoDollar[2].id, protoDollar[3].b, protoDollar[4].ooElements, protoDollar[5].b), protoDollar[6].bs...) } - case 153: + case 155: protoDollar = protoS[protopt-0 : protopt+1] { protoVAL.ooElements = nil } - case 155: + case 157: protoDollar = protoS[protopt-2 : protopt+1] { if protoDollar[2].ooElement != nil { @@ -2048,7 +2080,7 @@ protodefault: protoVAL.ooElements = protoDollar[1].ooElements } } - case 156: + case 158: protoDollar = protoS[protopt-1 : protopt+1] { if protoDollar[1].ooElement != nil { @@ -2057,367 +2089,423 @@ protodefault: protoVAL.ooElements = nil } } - case 157: + case 159: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.ooElement = protoDollar[1].optRaw } - case 158: + case 160: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.ooElement = protoDollar[1].fld } - case 159: + case 161: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.ooElement = protoDollar[1].grp } - case 160: + case 162: protoDollar = protoS[protopt-2 : protopt+1] { protoVAL.ooElement = nil } - case 161: + case 163: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.ooElement = nil } - case 162: + case 164: protoDollar = protoS[protopt-5 : protopt+1] { protoVAL.fld = ast.NewFieldNode(nil, protoDollar[1].tid, protoDollar[2].id, protoDollar[3].b, protoDollar[4].i, nil, protoDollar[5].b) } - case 163: + case 165: protoDollar = protoS[protopt-6 : protopt+1] { protoVAL.fld = ast.NewFieldNode(nil, protoDollar[1].tid, protoDollar[2].id, protoDollar[3].b, protoDollar[4].i, protoDollar[5].cmpctOpts, protoDollar[6].b) } - case 164: + case 166: + protoDollar = protoS[protopt-3 : protopt+1] + { + protoVAL.fld = ast.NewFieldNode(nil, protoDollar[1].tid, protoDollar[2].id, nil, nil, nil, protoDollar[3].b) + } + case 167: + protoDollar = protoS[protopt-4 : protopt+1] + { + protoVAL.fld = ast.NewFieldNode(nil, protoDollar[1].tid, protoDollar[2].id, nil, nil, protoDollar[3].cmpctOpts, protoDollar[4].b) + } + case 168: protoDollar = protoS[protopt-7 : protopt+1] { protoVAL.grp = ast.NewGroupNode(nil, protoDollar[1].id.ToKeyword(), protoDollar[2].id, protoDollar[3].b, protoDollar[4].i, nil, protoDollar[5].b, protoDollar[6].msgElements, protoDollar[7].b) } - case 165: + case 169: protoDollar = protoS[protopt-8 : protopt+1] { protoVAL.grp = ast.NewGroupNode(nil, protoDollar[1].id.ToKeyword(), protoDollar[2].id, protoDollar[3].b, protoDollar[4].i, protoDollar[5].cmpctOpts, protoDollar[6].b, protoDollar[7].msgElements, protoDollar[8].b) } - case 166: + case 170: + protoDollar = protoS[protopt-5 : protopt+1] + { + protoVAL.grp = ast.NewGroupNode(nil, protoDollar[1].id.ToKeyword(), protoDollar[2].id, nil, nil, nil, protoDollar[3].b, protoDollar[4].msgElements, protoDollar[5].b) + } + case 171: + protoDollar = protoS[protopt-6 : protopt+1] + { + protoVAL.grp = ast.NewGroupNode(nil, protoDollar[1].id.ToKeyword(), protoDollar[2].id, nil, nil, protoDollar[3].cmpctOpts, protoDollar[4].b, protoDollar[5].msgElements, protoDollar[6].b) + } + case 172: protoDollar = protoS[protopt-5 : protopt+1] { semi, extra := protolex.(*protoLex).requireSemicolon(protoDollar[5].bs) protoVAL.mapFld = newNodeWithRunes(ast.NewMapFieldNode(protoDollar[1].mapType, protoDollar[2].id, protoDollar[3].b, protoDollar[4].i, nil, semi), extra...) } - case 167: + case 173: protoDollar = protoS[protopt-6 : protopt+1] { semi, extra := protolex.(*protoLex).requireSemicolon(protoDollar[6].bs) protoVAL.mapFld = newNodeWithRunes(ast.NewMapFieldNode(protoDollar[1].mapType, protoDollar[2].id, protoDollar[3].b, protoDollar[4].i, protoDollar[5].cmpctOpts, semi), extra...) } - case 168: + case 174: + protoDollar = protoS[protopt-3 : protopt+1] + { + semi, extra := protolex.(*protoLex).requireSemicolon(protoDollar[3].bs) + protoVAL.mapFld = newNodeWithRunes(ast.NewMapFieldNode(protoDollar[1].mapType, protoDollar[2].id, nil, nil, nil, semi), extra...) + } + case 175: + protoDollar = protoS[protopt-4 : protopt+1] + { + semi, extra := protolex.(*protoLex).requireSemicolon(protoDollar[4].bs) + protoVAL.mapFld = newNodeWithRunes(ast.NewMapFieldNode(protoDollar[1].mapType, protoDollar[2].id, nil, nil, protoDollar[3].cmpctOpts, semi), extra...) + } + case 176: protoDollar = protoS[protopt-6 : protopt+1] { protoVAL.mapType = ast.NewMapTypeNode(protoDollar[1].id.ToKeyword(), protoDollar[2].b, protoDollar[3].id, protoDollar[4].b, protoDollar[5].tid, protoDollar[6].b) } - case 181: + case 189: protoDollar = protoS[protopt-4 : protopt+1] { // TODO: Tolerate a missing semicolon here. This currnelty creates a shift/reduce conflict // between `extensions 1 to 10` and `extensions 1` followed by `to = 10`. protoVAL.ext = newNodeWithRunes(ast.NewExtensionRangeNode(protoDollar[1].id.ToKeyword(), protoDollar[2].rngs.ranges, protoDollar[2].rngs.commas, nil, protoDollar[3].b), protoDollar[4].bs...) } - case 182: + case 190: protoDollar = protoS[protopt-4 : protopt+1] { semi, extra := protolex.(*protoLex).requireSemicolon(protoDollar[4].bs) protoVAL.ext = newNodeWithRunes(ast.NewExtensionRangeNode(protoDollar[1].id.ToKeyword(), protoDollar[2].rngs.ranges, protoDollar[2].rngs.commas, protoDollar[3].cmpctOpts, semi), extra...) } - case 183: + case 191: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.rngs = &rangeSlices{ranges: []*ast.RangeNode{protoDollar[1].rng}} } - case 184: + case 192: protoDollar = protoS[protopt-3 : protopt+1] { protoDollar[1].rngs.ranges = append(protoDollar[1].rngs.ranges, protoDollar[3].rng) protoDollar[1].rngs.commas = append(protoDollar[1].rngs.commas, protoDollar[2].b) protoVAL.rngs = protoDollar[1].rngs } - case 185: + case 193: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.rng = ast.NewRangeNode(protoDollar[1].i, nil, nil, nil) } - case 186: + case 194: protoDollar = protoS[protopt-3 : protopt+1] { protoVAL.rng = ast.NewRangeNode(protoDollar[1].i, protoDollar[2].id.ToKeyword(), protoDollar[3].i, nil) } - case 187: + case 195: protoDollar = protoS[protopt-3 : protopt+1] { protoVAL.rng = ast.NewRangeNode(protoDollar[1].i, protoDollar[2].id.ToKeyword(), nil, protoDollar[3].id.ToKeyword()) } - case 188: + case 196: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.rngs = &rangeSlices{ranges: []*ast.RangeNode{protoDollar[1].rng}} } - case 189: + case 197: protoDollar = protoS[protopt-3 : protopt+1] { protoDollar[1].rngs.ranges = append(protoDollar[1].rngs.ranges, protoDollar[3].rng) protoDollar[1].rngs.commas = append(protoDollar[1].rngs.commas, protoDollar[2].b) protoVAL.rngs = protoDollar[1].rngs } - case 190: + case 198: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.rng = ast.NewRangeNode(protoDollar[1].il, nil, nil, nil) } - case 191: + case 199: protoDollar = protoS[protopt-3 : protopt+1] { protoVAL.rng = ast.NewRangeNode(protoDollar[1].il, protoDollar[2].id.ToKeyword(), protoDollar[3].il, nil) } - case 192: + case 200: protoDollar = protoS[protopt-3 : protopt+1] { protoVAL.rng = ast.NewRangeNode(protoDollar[1].il, protoDollar[2].id.ToKeyword(), nil, protoDollar[3].id.ToKeyword()) } - case 193: + case 201: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.il = protoDollar[1].i } - case 194: + case 202: protoDollar = protoS[protopt-2 : protopt+1] { protoVAL.il = ast.NewNegativeIntLiteralNode(protoDollar[1].b, protoDollar[2].i) } - case 195: + case 203: protoDollar = protoS[protopt-4 : protopt+1] { // TODO: Tolerate a missing semicolon here. This currnelty creates a shift/reduce conflict // between `reserved 1 to 10` and `reserved 1` followed by `to = 10`. protoVAL.resvd = newNodeWithRunes(ast.NewReservedRangesNode(protoDollar[1].id.ToKeyword(), protoDollar[2].rngs.ranges, protoDollar[2].rngs.commas, protoDollar[3].b), protoDollar[4].bs...) } - case 197: + case 205: protoDollar = protoS[protopt-4 : protopt+1] { // TODO: Tolerate a missing semicolon here. This currnelty creates a shift/reduce conflict // between `reserved 1 to 10` and `reserved 1` followed by `to = 10`. protoVAL.resvd = newNodeWithRunes(ast.NewReservedRangesNode(protoDollar[1].id.ToKeyword(), protoDollar[2].rngs.ranges, protoDollar[2].rngs.commas, protoDollar[3].b), protoDollar[4].bs...) } - case 199: + case 207: protoDollar = protoS[protopt-3 : protopt+1] { semi, extra := protolex.(*protoLex).requireSemicolon(protoDollar[3].bs) protoVAL.resvd = newNodeWithRunes(ast.NewReservedNamesNode(protoDollar[1].id.ToKeyword(), protoDollar[2].names.names, protoDollar[2].names.commas, semi), extra...) } - case 200: + case 208: protoDollar = protoS[protopt-3 : protopt+1] { semi, extra := protolex.(*protoLex).requireSemicolon(protoDollar[3].bs) protoVAL.resvd = newNodeWithRunes(ast.NewReservedIdentifiersNode(protoDollar[1].id.ToKeyword(), protoDollar[2].names.idents, protoDollar[2].names.commas, semi), extra...) } - case 201: + case 209: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.names = &nameSlices{names: []ast.StringValueNode{toStringValueNode(protoDollar[1].str)}} } - case 202: + case 210: protoDollar = protoS[protopt-3 : protopt+1] { protoDollar[1].names.names = append(protoDollar[1].names.names, toStringValueNode(protoDollar[3].str)) protoDollar[1].names.commas = append(protoDollar[1].names.commas, protoDollar[2].b) protoVAL.names = protoDollar[1].names } - case 203: + case 211: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.names = &nameSlices{idents: []*ast.IdentNode{protoDollar[1].id}} } - case 204: + case 212: protoDollar = protoS[protopt-3 : protopt+1] { protoDollar[1].names.idents = append(protoDollar[1].names.idents, protoDollar[3].id) protoDollar[1].names.commas = append(protoDollar[1].names.commas, protoDollar[2].b) protoVAL.names = protoDollar[1].names } - case 205: + case 213: protoDollar = protoS[protopt-6 : protopt+1] { protoVAL.en = newNodeWithRunes(ast.NewEnumNode(protoDollar[1].id.ToKeyword(), protoDollar[2].id, protoDollar[3].b, protoDollar[4].enElements, protoDollar[5].b), protoDollar[6].bs...) } - case 206: + case 214: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.enElements = prependRunes(toEnumElement, protoDollar[1].bs, nil) } - case 207: + case 215: protoDollar = protoS[protopt-2 : protopt+1] { protoVAL.enElements = prependRunes(toEnumElement, protoDollar[1].bs, protoDollar[2].enElements) } - case 208: + case 216: protoDollar = protoS[protopt-2 : protopt+1] { protoVAL.enElements = append(protoDollar[1].enElements, protoDollar[2].enElements...) } - case 209: + case 217: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.enElements = protoDollar[1].enElements } - case 210: + case 218: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.enElements = toElements[ast.EnumElement](toEnumElement, protoDollar[1].opt.Node, protoDollar[1].opt.Runes) } - case 211: + case 219: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.enElements = toElements[ast.EnumElement](toEnumElement, protoDollar[1].env.Node, protoDollar[1].env.Runes) } - case 212: + case 220: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.enElements = toElements[ast.EnumElement](toEnumElement, protoDollar[1].resvd.Node, protoDollar[1].resvd.Runes) } - case 213: + case 221: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.enElements = nil } - case 214: + case 222: protoDollar = protoS[protopt-4 : protopt+1] { semi, extra := protolex.(*protoLex).requireSemicolon(protoDollar[4].bs) protoVAL.env = newNodeWithRunes(ast.NewEnumValueNode(protoDollar[1].id, protoDollar[2].b, protoDollar[3].il, nil, semi), extra...) } - case 215: + case 223: protoDollar = protoS[protopt-5 : protopt+1] { semi, extra := protolex.(*protoLex).requireSemicolon(protoDollar[5].bs) protoVAL.env = newNodeWithRunes(ast.NewEnumValueNode(protoDollar[1].id, protoDollar[2].b, protoDollar[3].il, protoDollar[4].cmpctOpts, semi), extra...) } - case 216: + case 224: protoDollar = protoS[protopt-6 : protopt+1] { protoVAL.msg = newNodeWithRunes(ast.NewMessageNode(protoDollar[1].id.ToKeyword(), protoDollar[2].id, protoDollar[3].b, protoDollar[4].msgElements, protoDollar[5].b), protoDollar[6].bs...) } - case 217: + case 225: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.msgElements = prependRunes(toMessageElement, protoDollar[1].bs, nil) } - case 218: + case 226: protoDollar = protoS[protopt-2 : protopt+1] { protoVAL.msgElements = prependRunes(toMessageElement, protoDollar[1].bs, protoDollar[2].msgElements) } - case 219: + case 227: protoDollar = protoS[protopt-2 : protopt+1] { protoVAL.msgElements = append(protoDollar[1].msgElements, protoDollar[2].msgElements...) } - case 220: + case 228: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.msgElements = protoDollar[1].msgElements } - case 221: + case 229: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.msgElements = toElements[ast.MessageElement](toMessageElement, protoDollar[1].msgFld.Node, protoDollar[1].msgFld.Runes) } - case 222: + case 230: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.msgElements = toElements[ast.MessageElement](toMessageElement, protoDollar[1].en.Node, protoDollar[1].en.Runes) } - case 223: + case 231: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.msgElements = toElements[ast.MessageElement](toMessageElement, protoDollar[1].msg.Node, protoDollar[1].msg.Runes) } - case 224: + case 232: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.msgElements = toElements[ast.MessageElement](toMessageElement, protoDollar[1].extend.Node, protoDollar[1].extend.Runes) } - case 225: + case 233: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.msgElements = toElements[ast.MessageElement](toMessageElement, protoDollar[1].ext.Node, protoDollar[1].ext.Runes) } - case 226: + case 234: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.msgElements = toElements[ast.MessageElement](toMessageElement, protoDollar[1].msgGrp.Node, protoDollar[1].msgGrp.Runes) } - case 227: + case 235: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.msgElements = toElements[ast.MessageElement](toMessageElement, protoDollar[1].opt.Node, protoDollar[1].opt.Runes) } - case 228: + case 236: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.msgElements = toElements[ast.MessageElement](toMessageElement, protoDollar[1].oo.Node, protoDollar[1].oo.Runes) } - case 229: + case 237: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.msgElements = toElements[ast.MessageElement](toMessageElement, protoDollar[1].mapFld.Node, protoDollar[1].mapFld.Runes) } - case 230: + case 238: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.msgElements = toElements[ast.MessageElement](toMessageElement, protoDollar[1].resvd.Node, protoDollar[1].resvd.Runes) } - case 231: + case 239: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.msgElements = nil } - case 232: + case 240: protoDollar = protoS[protopt-6 : protopt+1] { semis, extra := protolex.(*protoLex).requireSemicolon(protoDollar[6].bs) protoVAL.msgFld = newNodeWithRunes(ast.NewFieldNode(protoDollar[1].id.ToKeyword(), protoDollar[2].tid, protoDollar[3].id, protoDollar[4].b, protoDollar[5].i, nil, semis), extra...) } - case 233: + case 241: protoDollar = protoS[protopt-7 : protopt+1] { semis, extra := protolex.(*protoLex).requireSemicolon(protoDollar[7].bs) protoVAL.msgFld = newNodeWithRunes(ast.NewFieldNode(protoDollar[1].id.ToKeyword(), protoDollar[2].tid, protoDollar[3].id, protoDollar[4].b, protoDollar[5].i, protoDollar[6].cmpctOpts, semis), extra...) } - case 234: + case 242: protoDollar = protoS[protopt-5 : protopt+1] { semis, extra := protolex.(*protoLex).requireSemicolon(protoDollar[5].bs) protoVAL.msgFld = newNodeWithRunes(ast.NewFieldNode(nil, protoDollar[1].tid, protoDollar[2].id, protoDollar[3].b, protoDollar[4].i, nil, semis), extra...) } - case 235: + case 243: protoDollar = protoS[protopt-6 : protopt+1] { semis, extra := protolex.(*protoLex).requireSemicolon(protoDollar[6].bs) protoVAL.msgFld = newNodeWithRunes(ast.NewFieldNode(nil, protoDollar[1].tid, protoDollar[2].id, protoDollar[3].b, protoDollar[4].i, protoDollar[5].cmpctOpts, semis), extra...) } - case 236: + case 244: + protoDollar = protoS[protopt-4 : protopt+1] + { + semis, extra := protolex.(*protoLex).requireSemicolon(protoDollar[4].bs) + protoVAL.msgFld = newNodeWithRunes(ast.NewFieldNode(protoDollar[1].id.ToKeyword(), protoDollar[2].tid, protoDollar[3].id, nil, nil, nil, semis), extra...) + } + case 245: + protoDollar = protoS[protopt-5 : protopt+1] + { + semis, extra := protolex.(*protoLex).requireSemicolon(protoDollar[5].bs) + protoVAL.msgFld = newNodeWithRunes(ast.NewFieldNode(protoDollar[1].id.ToKeyword(), protoDollar[2].tid, protoDollar[3].id, nil, nil, protoDollar[4].cmpctOpts, semis), extra...) + } + case 246: + protoDollar = protoS[protopt-3 : protopt+1] + { + semis, extra := protolex.(*protoLex).requireSemicolon(protoDollar[3].bs) + protoVAL.msgFld = newNodeWithRunes(ast.NewFieldNode(nil, protoDollar[1].tid, protoDollar[2].id, nil, nil, nil, semis), extra...) + } + case 247: + protoDollar = protoS[protopt-4 : protopt+1] + { + semis, extra := protolex.(*protoLex).requireSemicolon(protoDollar[4].bs) + protoVAL.msgFld = newNodeWithRunes(ast.NewFieldNode(nil, protoDollar[1].tid, protoDollar[2].id, nil, nil, protoDollar[3].cmpctOpts, semis), extra...) + } + case 248: protoDollar = protoS[protopt-6 : protopt+1] { protoVAL.extend = newNodeWithRunes(ast.NewExtendNode(protoDollar[1].id.ToKeyword(), protoDollar[2].tid, protoDollar[3].b, protoDollar[4].extElements, protoDollar[5].b), protoDollar[6].bs...) } - case 237: + case 249: protoDollar = protoS[protopt-0 : protopt+1] { protoVAL.extElements = nil } - case 239: + case 251: protoDollar = protoS[protopt-2 : protopt+1] { if protoDollar[2].extElement != nil { @@ -2426,7 +2514,7 @@ protodefault: protoVAL.extElements = protoDollar[1].extElements } } - case 240: + case 252: protoDollar = protoS[protopt-1 : protopt+1] { if protoDollar[1].extElement != nil { @@ -2435,133 +2523,133 @@ protodefault: protoVAL.extElements = nil } } - case 241: + case 253: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.extElement = protoDollar[1].fld } - case 242: + case 254: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.extElement = protoDollar[1].grp } - case 243: + case 255: protoDollar = protoS[protopt-2 : protopt+1] { protoVAL.extElement = nil } - case 244: + case 256: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.extElement = nil } - case 245: + case 257: protoDollar = protoS[protopt-6 : protopt+1] { protoVAL.fld = ast.NewFieldNode(protoDollar[1].id.ToKeyword(), protoDollar[2].tid, protoDollar[3].id, protoDollar[4].b, protoDollar[5].i, nil, protoDollar[6].b) } - case 246: + case 258: protoDollar = protoS[protopt-7 : protopt+1] { protoVAL.fld = ast.NewFieldNode(protoDollar[1].id.ToKeyword(), protoDollar[2].tid, protoDollar[3].id, protoDollar[4].b, protoDollar[5].i, protoDollar[6].cmpctOpts, protoDollar[7].b) } - case 247: + case 259: protoDollar = protoS[protopt-5 : protopt+1] { protoVAL.fld = ast.NewFieldNode(nil, protoDollar[1].tid, protoDollar[2].id, protoDollar[3].b, protoDollar[4].i, nil, protoDollar[5].b) } - case 248: + case 260: protoDollar = protoS[protopt-6 : protopt+1] { protoVAL.fld = ast.NewFieldNode(nil, protoDollar[1].tid, protoDollar[2].id, protoDollar[3].b, protoDollar[4].i, protoDollar[5].cmpctOpts, protoDollar[6].b) } - case 249: + case 261: protoDollar = protoS[protopt-6 : protopt+1] { protoVAL.svc = newNodeWithRunes(ast.NewServiceNode(protoDollar[1].id.ToKeyword(), protoDollar[2].id, protoDollar[3].b, protoDollar[4].svcElements, protoDollar[5].b), protoDollar[6].bs...) } - case 250: + case 262: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.svcElements = prependRunes(toServiceElement, protoDollar[1].bs, nil) } - case 251: + case 263: protoDollar = protoS[protopt-2 : protopt+1] { protoVAL.svcElements = prependRunes(toServiceElement, protoDollar[1].bs, protoDollar[2].svcElements) } - case 252: + case 264: protoDollar = protoS[protopt-2 : protopt+1] { protoVAL.svcElements = append(protoDollar[1].svcElements, protoDollar[2].svcElements...) } - case 253: + case 265: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.svcElements = protoDollar[1].svcElements } - case 254: + case 266: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.svcElements = toElements[ast.ServiceElement](toServiceElement, protoDollar[1].opt.Node, protoDollar[1].opt.Runes) } - case 255: + case 267: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.svcElements = toElements[ast.ServiceElement](toServiceElement, protoDollar[1].mtd.Node, protoDollar[1].mtd.Runes) } - case 256: + case 268: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.svcElements = nil } - case 257: + case 269: protoDollar = protoS[protopt-6 : protopt+1] { semi, extra := protolex.(*protoLex).requireSemicolon(protoDollar[6].bs) protoVAL.mtd = newNodeWithRunes(ast.NewRPCNode(protoDollar[1].id.ToKeyword(), protoDollar[2].id, protoDollar[3].mtdMsgType, protoDollar[4].id.ToKeyword(), protoDollar[5].mtdMsgType, semi), extra...) } - case 258: + case 270: protoDollar = protoS[protopt-9 : protopt+1] { protoVAL.mtd = newNodeWithRunes(ast.NewRPCNodeWithBody(protoDollar[1].id.ToKeyword(), protoDollar[2].id, protoDollar[3].mtdMsgType, protoDollar[4].id.ToKeyword(), protoDollar[5].mtdMsgType, protoDollar[6].b, protoDollar[7].mtdElements, protoDollar[8].b), protoDollar[9].bs...) } - case 259: + case 271: protoDollar = protoS[protopt-4 : protopt+1] { protoVAL.mtdMsgType = ast.NewRPCTypeNode(protoDollar[1].b, protoDollar[2].id.ToKeyword(), protoDollar[3].tid, protoDollar[4].b) } - case 260: + case 272: protoDollar = protoS[protopt-3 : protopt+1] { protoVAL.mtdMsgType = ast.NewRPCTypeNode(protoDollar[1].b, nil, protoDollar[2].tid, protoDollar[3].b) } - case 261: + case 273: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.mtdElements = prependRunes(toMethodElement, protoDollar[1].bs, nil) } - case 262: + case 274: protoDollar = protoS[protopt-2 : protopt+1] { protoVAL.mtdElements = prependRunes(toMethodElement, protoDollar[1].bs, protoDollar[2].mtdElements) } - case 263: + case 275: protoDollar = protoS[protopt-2 : protopt+1] { protoVAL.mtdElements = append(protoDollar[1].mtdElements, protoDollar[2].mtdElements...) } - case 264: + case 276: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.mtdElements = protoDollar[1].mtdElements } - case 265: + case 277: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.mtdElements = toElements[ast.RPCElement](toMethodElement, protoDollar[1].opt.Node, protoDollar[1].opt.Runes) } - case 266: + case 278: protoDollar = protoS[protopt-1 : protopt+1] { protoVAL.mtdElements = nil diff --git a/vendor/github.com/bufbuild/protocompile/parser/result.go b/vendor/github.com/bufbuild/protocompile/parser/result.go index 3916a88518e..60c0c462342 100644 --- a/vendor/github.com/bufbuild/protocompile/parser/result.go +++ b/vendor/github.com/bufbuild/protocompile/parser/result.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import ( "unicode" "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/types/descriptorpb" "github.com/bufbuild/protocompile/ast" @@ -30,32 +31,6 @@ import ( "github.com/bufbuild/protocompile/reporter" ) -var supportedEditions = map[string]descriptorpb.Edition{ - "2023": descriptorpb.Edition_EDITION_2023, -} - -// NB: protoreflect.Syntax doesn't yet know about editions, so we have to use our own type. -type syntaxType int - -const ( - syntaxProto2 = syntaxType(iota) - syntaxProto3 - syntaxEditions -) - -func (s syntaxType) String() string { - switch s { - case syntaxProto2: - return "proto2" - case syntaxProto3: - return "proto3" - case syntaxEditions: - return "editions" - default: - return fmt.Sprintf("unknown(%d)", s) - } -} - type result struct { file *ast.FileNode proto *descriptorpb.FileDescriptorProto @@ -112,14 +87,14 @@ func (r *result) createFileDescriptor(filename string, file *ast.FileNode, handl r.putFileNode(fd, file) - var syntax syntaxType + var syntax protoreflect.Syntax switch { case file.Syntax != nil: switch file.Syntax.Syntax.AsString() { case "proto3": - syntax = syntaxProto3 + syntax = protoreflect.Proto3 case "proto2": - syntax = syntaxProto2 + syntax = protoreflect.Proto2 default: nodeInfo := file.NodeInfo(file.Syntax.Syntax) if handler.HandleErrorf(nodeInfo, `syntax value must be "proto2" or "proto3"`) != nil { @@ -128,7 +103,7 @@ func (r *result) createFileDescriptor(filename string, file *ast.FileNode, handl } // proto2 is the default, so no need to set for that value - if syntax != syntaxProto2 { + if syntax != protoreflect.Proto2 { fd.Syntax = proto.String(file.Syntax.Syntax.AsString()) } case file.Edition != nil: @@ -139,14 +114,14 @@ func (r *result) createFileDescriptor(filename string, file *ast.FileNode, handl } } edition := file.Edition.Edition.AsString() - syntax = syntaxEditions + syntax = protoreflect.Editions fd.Syntax = proto.String("editions") - editionEnum, ok := supportedEditions[edition] + editionEnum, ok := internal.SupportedEditions[edition] if !ok { nodeInfo := file.NodeInfo(file.Edition.Edition) - editionStrs := make([]string, 0, len(supportedEditions)) - for supportedEdition := range supportedEditions { + editionStrs := make([]string, 0, len(internal.SupportedEditions)) + for supportedEdition := range internal.SupportedEditions { editionStrs = append(editionStrs, fmt.Sprintf("%q", supportedEdition)) } sort.Strings(editionStrs) @@ -156,6 +131,7 @@ func (r *result) createFileDescriptor(filename string, file *ast.FileNode, handl } fd.Edition = editionEnum.Enum() default: + syntax = protoreflect.Proto2 nodeInfo := file.NodeInfo(file) handler.HandleWarningWithPos(nodeInfo, ErrNoSyntax) } @@ -291,7 +267,7 @@ func (r *result) asUninterpretedOptionName(parts []*ast.FieldReferenceNode) []*d return ret } -func (r *result) addExtensions(ext *ast.ExtendNode, flds *[]*descriptorpb.FieldDescriptorProto, msgs *[]*descriptorpb.DescriptorProto, syntax syntaxType, handler *reporter.Handler, depth int) { +func (r *result) addExtensions(ext *ast.ExtendNode, flds *[]*descriptorpb.FieldDescriptorProto, msgs *[]*descriptorpb.DescriptorProto, syntax protoreflect.Syntax, handler *reporter.Handler, depth int) { extendee := string(ext.Extendee.AsIdentifier()) count := 0 for _, decl := range ext.Decls { @@ -331,17 +307,20 @@ func asLabel(lbl *ast.FieldLabel) *descriptorpb.FieldDescriptorProto_Label { } } -func (r *result) asFieldDescriptor(node *ast.FieldNode, maxTag int32, syntax syntaxType, handler *reporter.Handler) *descriptorpb.FieldDescriptorProto { - tag := node.Tag.Val - if err := r.checkTag(node.Tag, tag, maxTag); err != nil { - _ = handler.HandleError(err) +func (r *result) asFieldDescriptor(node *ast.FieldNode, maxTag int32, syntax protoreflect.Syntax, handler *reporter.Handler) *descriptorpb.FieldDescriptorProto { + var tag *int32 + if node.Tag != nil { + if err := r.checkTag(node.Tag, node.Tag.Val, maxTag); err != nil { + _ = handler.HandleError(err) + } + tag = proto.Int32(int32(node.Tag.Val)) } - fd := newFieldDescriptor(node.Name.Val, string(node.FldType.AsIdentifier()), int32(tag), asLabel(&node.Label)) + fd := newFieldDescriptor(node.Name.Val, string(node.FldType.AsIdentifier()), tag, asLabel(&node.Label)) r.putFieldNode(fd, node) if opts := node.Options.GetElements(); len(opts) > 0 { fd.Options = &descriptorpb.FieldOptions{UninterpretedOption: r.asUninterpretedOptions(opts)} } - if syntax == syntaxProto3 && fd.Label != nil && fd.GetLabel() == descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL { + if syntax == protoreflect.Proto3 && fd.Label != nil && fd.GetLabel() == descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL { fd.Proto3Optional = proto.Bool(true) } return fd @@ -365,11 +344,11 @@ var fieldTypes = map[string]descriptorpb.FieldDescriptorProto_Type{ "bytes": descriptorpb.FieldDescriptorProto_TYPE_BYTES, } -func newFieldDescriptor(name string, fieldType string, tag int32, lbl *descriptorpb.FieldDescriptorProto_Label) *descriptorpb.FieldDescriptorProto { +func newFieldDescriptor(name string, fieldType string, tag *int32, lbl *descriptorpb.FieldDescriptorProto_Label) *descriptorpb.FieldDescriptorProto { fd := &descriptorpb.FieldDescriptorProto{ Name: proto.String(name), JsonName: proto.String(internal.JSONName(name)), - Number: proto.Int32(tag), + Number: tag, Label: lbl, } t, ok := fieldTypes[fieldType] @@ -384,10 +363,13 @@ func newFieldDescriptor(name string, fieldType string, tag int32, lbl *descripto return fd } -func (r *result) asGroupDescriptors(group *ast.GroupNode, syntax syntaxType, maxTag int32, handler *reporter.Handler, depth int) (*descriptorpb.FieldDescriptorProto, *descriptorpb.DescriptorProto) { - tag := group.Tag.Val - if err := r.checkTag(group.Tag, tag, maxTag); err != nil { - _ = handler.HandleError(err) +func (r *result) asGroupDescriptors(group *ast.GroupNode, syntax protoreflect.Syntax, maxTag int32, handler *reporter.Handler, depth int) (*descriptorpb.FieldDescriptorProto, *descriptorpb.DescriptorProto) { + var tag *int32 + if group.Tag != nil { + if err := r.checkTag(group.Tag, group.Tag.Val, maxTag); err != nil { + _ = handler.HandleError(err) + } + tag = proto.Int32(int32(group.Tag.Val)) } if !unicode.IsUpper(rune(group.Name.Val[0])) { nameNodeInfo := r.file.NodeInfo(group.Name) @@ -397,7 +379,7 @@ func (r *result) asGroupDescriptors(group *ast.GroupNode, syntax syntaxType, max fd := &descriptorpb.FieldDescriptorProto{ Name: proto.String(fieldName), JsonName: proto.String(internal.JSONName(fieldName)), - Number: proto.Int32(int32(tag)), + Number: tag, Label: asLabel(&group.Label), Type: descriptorpb.FieldDescriptorProto_TYPE_GROUP.Enum(), TypeName: proto.String(group.Name.Val), @@ -407,30 +389,35 @@ func (r *result) asGroupDescriptors(group *ast.GroupNode, syntax syntaxType, max fd.Options = &descriptorpb.FieldOptions{UninterpretedOption: r.asUninterpretedOptions(opts)} } md := &descriptorpb.DescriptorProto{Name: proto.String(group.Name.Val)} - r.putMessageNode(md, group) + groupMsg := group.AsMessage() + r.putMessageNode(md, groupMsg) // don't bother processing body if we've exceeded depth - if r.checkDepth(depth, group, handler) { + if r.checkDepth(depth, groupMsg, handler) { r.addMessageBody(md, &group.MessageBody, syntax, handler, depth) } return fd, md } -func (r *result) asMapDescriptors(mapField *ast.MapFieldNode, syntax syntaxType, maxTag int32, handler *reporter.Handler, depth int) (*descriptorpb.FieldDescriptorProto, *descriptorpb.DescriptorProto) { - tag := mapField.Tag.Val - if err := r.checkTag(mapField.Tag, tag, maxTag); err != nil { - _ = handler.HandleError(err) +func (r *result) asMapDescriptors(mapField *ast.MapFieldNode, syntax protoreflect.Syntax, maxTag int32, handler *reporter.Handler, depth int) (*descriptorpb.FieldDescriptorProto, *descriptorpb.DescriptorProto) { + var tag *int32 + if mapField.Tag != nil { + if err := r.checkTag(mapField.Tag, mapField.Tag.Val, maxTag); err != nil { + _ = handler.HandleError(err) + } + tag = proto.Int32(int32(mapField.Tag.Val)) } - r.checkDepth(depth, mapField, handler) + mapEntry := mapField.AsMessage() + r.checkDepth(depth, mapEntry, handler) var lbl *descriptorpb.FieldDescriptorProto_Label - if syntax == syntaxProto2 { + if syntax == protoreflect.Proto2 { lbl = descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum() } - keyFd := newFieldDescriptor("key", mapField.MapType.KeyType.Val, 1, lbl) + keyFd := newFieldDescriptor("key", mapField.MapType.KeyType.Val, proto.Int32(1), lbl) r.putFieldNode(keyFd, mapField.KeyField()) - valFd := newFieldDescriptor("value", string(mapField.MapType.ValueType.AsIdentifier()), 2, lbl) + valFd := newFieldDescriptor("value", string(mapField.MapType.ValueType.AsIdentifier()), proto.Int32(2), lbl) r.putFieldNode(valFd, mapField.ValueField()) entryName := internal.InitCap(internal.JSONName(mapField.Name.Val)) + "Entry" - fd := newFieldDescriptor(mapField.Name.Val, entryName, int32(tag), descriptorpb.FieldDescriptorProto_LABEL_REPEATED.Enum()) + fd := newFieldDescriptor(mapField.Name.Val, entryName, tag, descriptorpb.FieldDescriptorProto_LABEL_REPEATED.Enum()) if opts := mapField.Options.GetElements(); len(opts) > 0 { fd.Options = &descriptorpb.FieldOptions{UninterpretedOption: r.asUninterpretedOptions(opts)} } @@ -440,7 +427,7 @@ func (r *result) asMapDescriptors(mapField *ast.MapFieldNode, syntax syntaxType, Options: &descriptorpb.MessageOptions{MapEntry: proto.Bool(true)}, Field: []*descriptorpb.FieldDescriptorProto{keyFd, valFd}, } - r.putMessageNode(md, mapField) + r.putMessageNode(md, mapEntry) return fd, md } @@ -456,7 +443,7 @@ func (r *result) asExtensionRanges(node *ast.ExtensionRangeNode, maxTag int32, h if len(opts) > 0 { er.Options = &descriptorpb.ExtensionRangeOptions{UninterpretedOption: opts} } - r.putExtensionRangeNode(er, rng) + r.putExtensionRangeNode(er, node, rng) ers[i] = er } return ers @@ -503,7 +490,7 @@ func (r *result) asMethodDescriptor(node *ast.RPCNode) *descriptorpb.MethodDescr return md } -func (r *result) asEnumDescriptor(en *ast.EnumNode, syntax syntaxType, handler *reporter.Handler) *descriptorpb.EnumDescriptorProto { +func (r *result) asEnumDescriptor(en *ast.EnumNode, syntax protoreflect.Syntax, handler *reporter.Handler) *descriptorpb.EnumDescriptorProto { ed := &descriptorpb.EnumDescriptorProto{Name: proto.String(en.Name.Val)} r.putEnumNode(ed, en) rsvdNames := map[string]ast.SourcePos{} @@ -536,7 +523,7 @@ func (r *result) asEnumReservedRange(rng *ast.RangeNode, handler *reporter.Handl return rr } -func (r *result) asMessageDescriptor(node *ast.MessageNode, syntax syntaxType, handler *reporter.Handler, depth int) *descriptorpb.DescriptorProto { +func (r *result) asMessageDescriptor(node *ast.MessageNode, syntax protoreflect.Syntax, handler *reporter.Handler, depth int) *descriptorpb.DescriptorProto { msgd := &descriptorpb.DescriptorProto{Name: proto.String(node.Name.Val)} r.putMessageNode(msgd, node) // don't bother processing body if we've exceeded depth @@ -546,8 +533,8 @@ func (r *result) asMessageDescriptor(node *ast.MessageNode, syntax syntaxType, h return msgd } -func (r *result) addReservedNames(names *[]string, node *ast.ReservedNode, syntax syntaxType, handler *reporter.Handler, alreadyReserved map[string]ast.SourcePos) { - if syntax == syntaxEditions { +func (r *result) addReservedNames(names *[]string, node *ast.ReservedNode, syntax protoreflect.Syntax, handler *reporter.Handler, alreadyReserved map[string]ast.SourcePos) { + if syntax == protoreflect.Editions { if len(node.Names) > 0 { nameNodeInfo := r.file.NodeInfo(node.Names[0]) _ = handler.HandleErrorf(nameNodeInfo, `must use identifiers, not string literals, to reserved names with editions`) @@ -586,7 +573,7 @@ func (r *result) checkDepth(depth int, node ast.MessageDeclNode, handler *report return true } n := ast.Node(node) - if grp, ok := n.(*ast.GroupNode); ok { + if grp, ok := n.(*ast.SyntheticGroupMessageNode); ok { // pinpoint the group keyword if the source is a group n = grp.Keyword } @@ -594,7 +581,7 @@ func (r *result) checkDepth(depth int, node ast.MessageDeclNode, handler *report return false } -func (r *result) addMessageBody(msgd *descriptorpb.DescriptorProto, body *ast.MessageBody, syntax syntaxType, handler *reporter.Handler, depth int) { +func (r *result) addMessageBody(msgd *descriptorpb.DescriptorProto, body *ast.MessageBody, syntax protoreflect.Syntax, handler *reporter.Handler, depth int) { // first process any options for _, decl := range body.Decls { if opt, ok := decl.(*ast.OptionNode); ok { @@ -612,7 +599,7 @@ func (r *result) addMessageBody(msgd *descriptorpb.DescriptorProto, body *ast.Me if err != nil { return } else if messageSetOpt != nil { - if syntax == syntaxProto3 { + if syntax == protoreflect.Proto3 { node := r.OptionNode(messageSetOpt) nodeInfo := r.file.NodeInfo(node) _ = handler.HandleErrorf(nodeInfo, "messages with message-set wire format are not allowed with proto3 syntax") @@ -696,7 +683,7 @@ func (r *result) addMessageBody(msgd *descriptorpb.DescriptorProto, body *ast.Me } // process any proto3_optional fields - if syntax == syntaxProto3 { + if syntax == protoreflect.Proto3 { r.processProto3OptionalFields(msgd) } } @@ -898,11 +885,18 @@ func (r *result) FieldNode(f *descriptorpb.FieldDescriptorProto) ast.FieldDeclNo return r.nodes[f].(ast.FieldDeclNode) } -func (r *result) OneofNode(o *descriptorpb.OneofDescriptorProto) ast.Node { +func (r *result) OneofNode(o *descriptorpb.OneofDescriptorProto) ast.OneofDeclNode { if r.nodes == nil { return ast.NewNoSourceNode(r.proto.GetName()) } - return r.nodes[o] + return r.nodes[o].(ast.OneofDeclNode) +} + +func (r *result) ExtensionsNode(e *descriptorpb.DescriptorProto_ExtensionRange) ast.NodeWithOptions { + if r.nodes == nil { + return ast.NewNoSourceNode(r.proto.GetName()) + } + return r.nodes[asExtsNode(e)].(ast.NodeWithOptions) } func (r *result) ExtensionRangeNode(e *descriptorpb.DescriptorProto_ExtensionRange) ast.RangeDeclNode { @@ -919,11 +913,11 @@ func (r *result) MessageReservedRangeNode(rr *descriptorpb.DescriptorProto_Reser return r.nodes[rr].(ast.RangeDeclNode) } -func (r *result) EnumNode(e *descriptorpb.EnumDescriptorProto) ast.Node { +func (r *result) EnumNode(e *descriptorpb.EnumDescriptorProto) ast.NodeWithOptions { if r.nodes == nil { return ast.NewNoSourceNode(r.proto.GetName()) } - return r.nodes[e] + return r.nodes[e].(ast.NodeWithOptions) } func (r *result) EnumValueNode(e *descriptorpb.EnumValueDescriptorProto) ast.EnumValueDeclNode { @@ -940,11 +934,11 @@ func (r *result) EnumReservedRangeNode(rr *descriptorpb.EnumDescriptorProto_Enum return r.nodes[rr].(ast.RangeDeclNode) } -func (r *result) ServiceNode(s *descriptorpb.ServiceDescriptorProto) ast.Node { +func (r *result) ServiceNode(s *descriptorpb.ServiceDescriptorProto) ast.NodeWithOptions { if r.nodes == nil { return ast.NewNoSourceNode(r.proto.GetName()) } - return r.nodes[s] + return r.nodes[s].(ast.NodeWithOptions) } func (r *result) MethodNode(m *descriptorpb.MethodDescriptorProto) ast.RPCDeclNode { @@ -978,7 +972,8 @@ func (r *result) putOneofNode(o *descriptorpb.OneofDescriptorProto, n ast.OneofD r.nodes[o] = n } -func (r *result) putExtensionRangeNode(e *descriptorpb.DescriptorProto_ExtensionRange, n *ast.RangeNode) { +func (r *result) putExtensionRangeNode(e *descriptorpb.DescriptorProto_ExtensionRange, er *ast.ExtensionRangeNode, n *ast.RangeNode) { + r.nodes[asExtsNode(e)] = er r.nodes[e] = n } @@ -1008,3 +1003,14 @@ func (r *result) putMethodNode(m *descriptorpb.MethodDescriptorProto, n *ast.RPC // NB: If we ever add other put*Node methods, to index other kinds of elements in the descriptor // proto hierarchy, we need to update the index recreation logic in clone.go, too. + +func asExtsNode(er *descriptorpb.DescriptorProto_ExtensionRange) proto.Message { + return extsParent{er} +} + +// a simple marker type that allows us to have two distinct keys in a map for +// the same ExtensionRange proto -- one for the range itself and another to +// associate with the enclosing/parent AST node. +type extsParent struct { + *descriptorpb.DescriptorProto_ExtensionRange +} diff --git a/vendor/github.com/bufbuild/protocompile/parser/validate.go b/vendor/github.com/bufbuild/protocompile/parser/validate.go index 769928d2fbc..9596242050c 100644 --- a/vendor/github.com/bufbuild/protocompile/parser/validate.go +++ b/vendor/github.com/bufbuild/protocompile/parser/validate.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -30,14 +30,14 @@ import ( func validateBasic(res *result, handler *reporter.Handler) { fd := res.proto - var syntax syntaxType + var syntax protoreflect.Syntax switch fd.GetSyntax() { case "", "proto2": - syntax = syntaxProto2 + syntax = protoreflect.Proto2 case "proto3": - syntax = syntaxProto3 + syntax = protoreflect.Proto3 case "editions": - syntax = syntaxEditions + syntax = protoreflect.Editions // TODO: default: error? } @@ -107,8 +107,8 @@ func validateImports(res *result, handler *reporter.Handler) error { return nil } -func validateNoFeatures(res *result, syntax syntaxType, scope string, opts []*descriptorpb.UninterpretedOption, handler *reporter.Handler) error { - if syntax == syntaxEditions { +func validateNoFeatures(res *result, syntax protoreflect.Syntax, scope string, opts []*descriptorpb.UninterpretedOption, handler *reporter.Handler) error { + if syntax == protoreflect.Editions { // Editions is allowed to use features return nil } @@ -124,10 +124,10 @@ func validateNoFeatures(res *result, syntax syntaxType, scope string, opts []*de return nil } -func validateMessage(res *result, syntax syntaxType, name protoreflect.FullName, md *descriptorpb.DescriptorProto, handler *reporter.Handler) error { +func validateMessage(res *result, syntax protoreflect.Syntax, name protoreflect.FullName, md *descriptorpb.DescriptorProto, handler *reporter.Handler) error { scope := fmt.Sprintf("message %s", name) - if syntax == syntaxProto3 && len(md.ExtensionRange) > 0 { + if syntax == protoreflect.Proto3 && len(md.ExtensionRange) > 0 { n := res.ExtensionRangeNode(md.ExtensionRange[0]) nInfo := res.file.NodeInfo(n) if err := handler.HandleErrorf(nInfo, "%s: extension ranges are not allowed in proto3", scope); err != nil { @@ -287,7 +287,7 @@ func findMessageReservedNameNode(msgNode ast.MessageDeclNode, name string) ast.N switch msgNode := msgNode.(type) { case *ast.MessageNode: decls = msgNode.Decls - case *ast.GroupNode: + case *ast.SyntheticGroupMessageNode: decls = msgNode.Decls default: // leave decls empty @@ -314,7 +314,7 @@ func findReservedNameNode[T ast.Node](parent ast.Node, decls []T, name string) a return parent } -func validateEnum(res *result, syntax syntaxType, name protoreflect.FullName, ed *descriptorpb.EnumDescriptorProto, handler *reporter.Handler) error { +func validateEnum(res *result, syntax protoreflect.Syntax, name protoreflect.FullName, ed *descriptorpb.EnumDescriptorProto, handler *reporter.Handler) error { scope := fmt.Sprintf("enum %s", name) if len(ed.Value) == 0 { @@ -353,10 +353,10 @@ func validateEnum(res *result, syntax syntaxType, name protoreflect.FullName, ed } } - if syntax == syntaxProto3 && len(ed.Value) > 0 && ed.Value[0].GetNumber() != 0 { + if syntax == protoreflect.Proto3 && len(ed.Value) > 0 && ed.Value[0].GetNumber() != 0 { evNode := res.EnumValueNode(ed.Value[0]) evNodeInfo := res.file.NodeInfo(evNode.GetNumber()) - if err := handler.HandleErrorf(evNodeInfo, "%s: proto3 requires that first value in enum have numeric value of 0", scope); err != nil { + if err := handler.HandleErrorf(evNodeInfo, "%s: proto3 requires that first value of enum have numeric value zero", scope); err != nil { return err } } @@ -447,7 +447,7 @@ func findEnumReservedNameNode(enumNode ast.Node, name string) ast.Node { return findReservedNameNode(enumNode, decls, name) } -func validateField(res *result, syntax syntaxType, name protoreflect.FullName, fld *descriptorpb.FieldDescriptorProto, handler *reporter.Handler) error { +func validateField(res *result, syntax protoreflect.Syntax, name protoreflect.FullName, fld *descriptorpb.FieldDescriptorProto, handler *reporter.Handler) error { var scope string if fld.Extendee != nil { scope = fmt.Sprintf("extension %s", name) @@ -456,7 +456,13 @@ func validateField(res *result, syntax syntaxType, name protoreflect.FullName, f } node := res.FieldNode(fld) - if syntax != syntaxProto2 { + if fld.Number == nil { + fieldTagNodeInfo := res.file.NodeInfo(node) + if err := handler.HandleErrorf(fieldTagNodeInfo, "%s: missing field tag number", scope); err != nil { + return err + } + } + if syntax != protoreflect.Proto2 { if fld.GetType() == descriptorpb.FieldDescriptorProto_TYPE_GROUP { groupNodeInfo := res.file.NodeInfo(node.GetGroupKeyword()) if err := handler.HandleErrorf(groupNodeInfo, "%s: groups are not allowed in proto3 or editions", scope); err != nil { @@ -468,7 +474,7 @@ func validateField(res *result, syntax syntaxType, name protoreflect.FullName, f return err } } - if syntax == syntaxEditions { + if syntax == protoreflect.Editions { if fld.Label != nil && fld.GetLabel() == descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL { fieldLabelNodeInfo := res.file.NodeInfo(node.FieldLabel()) if err := handler.HandleErrorf(fieldLabelNodeInfo, "%s: label 'optional' is not allowed in editions; use option features.field_presence instead", scope); err != nil { @@ -484,7 +490,7 @@ func validateField(res *result, syntax syntaxType, name protoreflect.FullName, f return err } } - } else if syntax == syntaxProto3 { + } else if syntax == protoreflect.Proto3 { if index, err := internal.FindOption(res, handler, scope, fld.Options.GetUninterpretedOption(), "default"); err != nil { return err } else if index >= 0 { diff --git a/vendor/github.com/bufbuild/protocompile/protoutil/protos.go b/vendor/github.com/bufbuild/protocompile/protoutil/protos.go index 2d30081eed1..4f0f362962e 100644 --- a/vendor/github.com/bufbuild/protocompile/protoutil/protos.go +++ b/vendor/github.com/bufbuild/protocompile/protoutil/protos.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/github.com/bufbuild/protocompile/reporter/errors.go b/vendor/github.com/bufbuild/protocompile/reporter/errors.go index 50519996d9b..d8634273c17 100644 --- a/vendor/github.com/bufbuild/protocompile/reporter/errors.go +++ b/vendor/github.com/bufbuild/protocompile/reporter/errors.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/github.com/bufbuild/protocompile/reporter/reporter.go b/vendor/github.com/bufbuild/protocompile/reporter/reporter.go index ba6c0386fdc..cfd188fc245 100644 --- a/vendor/github.com/bufbuild/protocompile/reporter/reporter.go +++ b/vendor/github.com/bufbuild/protocompile/reporter/reporter.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/github.com/bufbuild/protocompile/resolver.go b/vendor/github.com/bufbuild/protocompile/resolver.go index 9122090b38e..7ff40eb0312 100644 --- a/vendor/github.com/bufbuild/protocompile/resolver.go +++ b/vendor/github.com/bufbuild/protocompile/resolver.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/github.com/bufbuild/protocompile/sourceinfo/source_code_info.go b/vendor/github.com/bufbuild/protocompile/sourceinfo/source_code_info.go index 908fb170997..4cbbadfa47d 100644 --- a/vendor/github.com/bufbuild/protocompile/sourceinfo/source_code_info.go +++ b/vendor/github.com/bufbuild/protocompile/sourceinfo/source_code_info.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -45,6 +45,11 @@ type OptionSourceInfo struct { // The source info path to this element. If this element represents a // declaration with an array-literal value, the last element of the // path is the index of the first item in the array. + // If the first element is negative, it indicates the number of path + // components to remove from the path to the relevant options. This is + // used for field pseudo-options, so that the path indicates a field on + // the descriptor, which is a parent of the options message (since that + // is how the pseudo-options are actually stored). Path []int32 // Children can be an *ArrayLiteralSourceInfo, a *MessageLiteralSourceInfo, // or nil, depending on whether the option's value is an @@ -132,7 +137,7 @@ func (e extraOptionLocationsOption) apply(info *sourceCodeInfo) { } func generateSourceInfoForFile(opts OptionIndex, sci *sourceCodeInfo, file *ast.FileNode) { - path := make([]int32, 0, 10) + path := make([]int32, 0, 16) sci.newLocWithoutComments(file, nil) @@ -168,7 +173,10 @@ func generateSourceInfoForFile(opts OptionIndex, sci *sourceCodeInfo, file *ast. generateSourceCodeInfoForEnum(opts, sci, child, append(path, internal.FileEnumsTag, enumIndex)) enumIndex++ case *ast.ExtendNode: - generateSourceCodeInfoForExtensions(opts, sci, child, &extendIndex, &msgIndex, append(path, internal.FileExtensionsTag), append(dup(path), internal.FileMessagesTag)) + extsPath := append(path, internal.FileExtensionsTag) //nolint:gocritic // intentionally creating new slice var + // we clone the path here so that append can't mutate extsPath, since they may share storage + msgsPath := append(internal.ClonePath(path), internal.FileMessagesTag) + generateSourceCodeInfoForExtensions(opts, sci, child, &extendIndex, &msgIndex, extsPath, msgsPath) case *ast.ServiceNode: generateSourceCodeInfoForService(opts, sci, child, append(path, internal.FileServicesTag, svcIndex)) svcIndex++ @@ -257,6 +265,18 @@ func generateSourceInfoForOptionChildren(sci *sourceCodeInfo, n ast.ValueNode, p continue } fullPath := combinePathsForOption(pathPrefix, fieldInfo.Path) + locationNode := ast.Node(fieldNode) + if fieldNode.Name.IsAnyTypeReference() && fullPath[len(fullPath)-1] == internal.AnyValueTag { + // This is a special expanded Any. So also insert a location + // for the type URL field. + typeURLPath := make([]int32, len(fullPath)) + copy(typeURLPath, fullPath) + typeURLPath[len(typeURLPath)-1] = internal.AnyTypeURLTag + sci.newLoc(fieldNode.Name, fullPath) + // And create the next location so it's just the value, + // not the full field definition. + locationNode = fieldNode.Val + } _, isArrayLiteral := fieldNode.Val.(*ast.ArrayLiteralNode) if !isArrayLiteral { // We don't include this with an array literal since the path @@ -264,7 +284,7 @@ func generateSourceInfoForOptionChildren(sci *sourceCodeInfo, n ast.ValueNode, p // it would be redundant with the child info we add next, and // it wouldn't be entirely correct since it only indicates the // index of the first element in the array (and not the others). - sci.newLoc(fieldNode, fullPath) + sci.newLoc(locationNode, fullPath) } generateSourceInfoForOptionChildren(sci, fieldNode.Val, pathPrefix, fullPath, fieldInfo.Children) } @@ -290,10 +310,10 @@ func generateSourceCodeInfoForMessage(opts OptionIndex, sci *sourceCodeInfo, n a case *ast.MessageNode: openBrace = n.OpenBrace decls = n.Decls - case *ast.GroupNode: + case *ast.SyntheticGroupMessageNode: openBrace = n.OpenBrace decls = n.Decls - case *ast.MapFieldNode: + case *ast.SyntheticMapEntryNode: sci.newLoc(n, path) // map entry so nothing else to do return @@ -317,18 +337,24 @@ func generateSourceCodeInfoForMessage(opts OptionIndex, sci *sourceCodeInfo, n a generateSourceCodeInfoForField(opts, sci, child, append(path, internal.MessageFieldsTag, fieldIndex)) fieldIndex++ case *ast.GroupNode: - fldPath := path - fldPath = append(fldPath, internal.MessageFieldsTag, fieldIndex) + fldPath := append(path, internal.MessageFieldsTag, fieldIndex) //nolint:gocritic // intentionally creating new slice var generateSourceCodeInfoForField(opts, sci, child, fldPath) fieldIndex++ - generateSourceCodeInfoForMessage(opts, sci, child, fldPath, append(dup(path), internal.MessageNestedMessagesTag, nestedMsgIndex)) + // we clone the path here so that append can't mutate fldPath, since they may share storage + msgPath := append(internal.ClonePath(path), internal.MessageNestedMessagesTag, nestedMsgIndex) + generateSourceCodeInfoForMessage(opts, sci, child.AsMessage(), fldPath, msgPath) nestedMsgIndex++ case *ast.MapFieldNode: generateSourceCodeInfoForField(opts, sci, child, append(path, internal.MessageFieldsTag, fieldIndex)) fieldIndex++ nestedMsgIndex++ case *ast.OneofNode: - generateSourceCodeInfoForOneof(opts, sci, child, &fieldIndex, &nestedMsgIndex, append(path, internal.MessageFieldsTag), append(dup(path), internal.MessageNestedMessagesTag), append(dup(path), internal.MessageOneofsTag, oneofIndex)) + fldsPath := append(path, internal.MessageFieldsTag) //nolint:gocritic // intentionally creating new slice var + // we clone the path here and below so that append ops can't mutate + // fldPath or msgsPath, since they may otherwise share storage + msgsPath := append(internal.ClonePath(path), internal.MessageNestedMessagesTag) + ooPath := append(internal.ClonePath(path), internal.MessageOneofsTag, oneofIndex) + generateSourceCodeInfoForOneof(opts, sci, child, &fieldIndex, &nestedMsgIndex, fldsPath, msgsPath, ooPath) oneofIndex++ case *ast.MessageNode: generateSourceCodeInfoForMessage(opts, sci, child, nil, append(path, internal.MessageNestedMessagesTag, nestedMsgIndex)) @@ -337,7 +363,10 @@ func generateSourceCodeInfoForMessage(opts OptionIndex, sci *sourceCodeInfo, n a generateSourceCodeInfoForEnum(opts, sci, child, append(path, internal.MessageEnumsTag, nestedEnumIndex)) nestedEnumIndex++ case *ast.ExtendNode: - generateSourceCodeInfoForExtensions(opts, sci, child, &extendIndex, &nestedMsgIndex, append(path, internal.MessageExtensionsTag), append(dup(path), internal.MessageNestedMessagesTag)) + extsPath := append(path, internal.MessageExtensionsTag) //nolint:gocritic // intentionally creating new slice var + // we clone the path here so that append can't mutate extsPath, since they may share storage + msgsPath := append(internal.ClonePath(path), internal.MessageNestedMessagesTag) + generateSourceCodeInfoForExtensions(opts, sci, child, &extendIndex, &nestedMsgIndex, extsPath, msgsPath) case *ast.ExtensionRangeNode: generateSourceCodeInfoForExtensionRanges(opts, sci, child, &extRangeIndex, append(path, internal.MessageExtensionRangesTag)) case *ast.ReservedNode: @@ -440,7 +469,7 @@ func generateSourceCodeInfoForExtensions(opts OptionIndex, sci *sourceCodeInfo, fldPath = append(fldPath, *extendIndex) generateSourceCodeInfoForField(opts, sci, decl, fldPath) *extendIndex++ - generateSourceCodeInfoForMessage(opts, sci, decl, fldPath, append(msgPath, *msgIndex)) + generateSourceCodeInfoForMessage(opts, sci, decl.AsMessage(), fldPath, append(msgPath, *msgIndex)) *msgIndex++ } } @@ -463,7 +492,7 @@ func generateSourceCodeInfoForOneof(opts OptionIndex, sci *sourceCodeInfo, n *as fldPath = append(fldPath, *fieldIndex) generateSourceCodeInfoForField(opts, sci, child, fldPath) *fieldIndex++ - generateSourceCodeInfoForMessage(opts, sci, child, fldPath, append(nestedMsgPath, *nestedMsgIndex)) + generateSourceCodeInfoForMessage(opts, sci, child.AsMessage(), fldPath, append(nestedMsgPath, *nestedMsgIndex)) *nestedMsgIndex++ } } @@ -604,8 +633,6 @@ type sourceCodeInfo struct { } func (sci *sourceCodeInfo) newLocWithoutComments(n ast.Node, path []int32) { - dup := make([]int32, len(path)) - copy(dup, path) var start, end ast.SourcePos if n == sci.file { // For files, we don't want to consider trailing EOF token @@ -628,7 +655,7 @@ func (sci *sourceCodeInfo) newLocWithoutComments(n ast.Node, path []int32) { start, end = info.Start(), info.End() } sci.locs = append(sci.locs, &descriptorpb.SourceCodeInfo_Location{ - Path: dup, + Path: internal.ClonePath(path), Span: makeSpan(start, end), }) } @@ -636,11 +663,9 @@ func (sci *sourceCodeInfo) newLocWithoutComments(n ast.Node, path []int32) { func (sci *sourceCodeInfo) newLoc(n ast.Node, path []int32) { info := sci.file.NodeInfo(n) if !sci.extraComments { - dup := make([]int32, len(path)) - copy(dup, path) start, end := info.Start(), info.End() sci.locs = append(sci.locs, &descriptorpb.SourceCodeInfo_Location{ - Path: dup, + Path: internal.ClonePath(path), Span: makeSpan(start, end), }) } else { @@ -701,13 +726,11 @@ func (sci *sourceCodeInfo) newLocWithGivenComments(nodeInfo ast.NodeInfo, detach detached[i] = sci.combineComments(cmts) } - dup := make([]int32, len(path)) - copy(dup, path) sci.locs = append(sci.locs, &descriptorpb.SourceCodeInfo_Location{ LeadingDetachedComments: detached, LeadingComments: lead, TrailingComments: trail, - Path: dup, + Path: internal.ClonePath(path), Span: makeSpan(nodeInfo.Start(), nodeInfo.End()), }) } @@ -933,7 +956,3 @@ func (sci *sourceCodeInfo) combineComments(comments comments) string { } return buf.String() } - -func dup(p []int32) []int32 { - return append(([]int32)(nil), p...) -} diff --git a/vendor/github.com/bufbuild/protocompile/std_imports.go b/vendor/github.com/bufbuild/protocompile/std_imports.go index ea169235d89..58c61dac775 100644 --- a/vendor/github.com/bufbuild/protocompile/std_imports.go +++ b/vendor/github.com/bufbuild/protocompile/std_imports.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/github.com/bufbuild/protocompile/walk/walk.go b/vendor/github.com/bufbuild/protocompile/walk/walk.go index 0499b5864a0..11fceeb6c8a 100644 --- a/vendor/github.com/bufbuild/protocompile/walk/walk.go +++ b/vendor/github.com/bufbuild/protocompile/walk/walk.go @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Buf Technologies, Inc. +// Copyright 2020-2024 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/github.com/dop251/goja/LICENSE b/vendor/github.com/dop251/goja/LICENSE deleted file mode 100644 index 09c000454f7..00000000000 --- a/vendor/github.com/dop251/goja/LICENSE +++ /dev/null @@ -1,15 +0,0 @@ -Copyright (c) 2016 Dmitry Panov - -Copyright (c) 2012 Robert Krimen - -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/dop251/goja/README.md b/vendor/github.com/dop251/goja/README.md deleted file mode 100644 index a4d0c09be11..00000000000 --- a/vendor/github.com/dop251/goja/README.md +++ /dev/null @@ -1,334 +0,0 @@ -goja -==== - -ECMAScript 5.1(+) implementation in Go. - -[![Go Reference](https://pkg.go.dev/badge/github.com/dop251/goja.svg)](https://pkg.go.dev/github.com/dop251/goja) - -Goja is an implementation of ECMAScript 5.1 in pure Go with emphasis on standard compliance and -performance. - -This project was largely inspired by [otto](https://github.com/robertkrimen/otto). - -The minimum required Go version is 1.20. - -Features --------- - - * Full ECMAScript 5.1 support (including regex and strict mode). - * Passes nearly all [tc39 tests](https://github.com/tc39/test262) for the features implemented so far. The goal is to - pass all of them. See .tc39_test262_checkout.sh for the latest working commit id. - * Capable of running Babel, Typescript compiler and pretty much anything written in ES5. - * Sourcemaps. - * Most of ES6 functionality, still work in progress, see https://github.com/dop251/goja/milestone/1?closed=1 - -Known incompatibilities and caveats ------------------------------------ - -### WeakMap -WeakMap is implemented by embedding references to the values into the keys. This means that as long -as the key is reachable all values associated with it in any weak maps also remain reachable and therefore -cannot be garbage collected even if they are not otherwise referenced, even after the WeakMap is gone. -The reference to the value is dropped either when the key is explicitly removed from the WeakMap or when the -key becomes unreachable. - -To illustrate this: - -```javascript -var m = new WeakMap(); -var key = {}; -var value = {/* a very large object */}; -m.set(key, value); -value = undefined; -m = undefined; // The value does NOT become garbage-collectable at this point -key = undefined; // Now it does -// m.delete(key); // This would work too -``` - -The reason for it is the limitation of the Go runtime. At the time of writing (version 1.15) having a finalizer -set on an object which is part of a reference cycle makes the whole cycle non-garbage-collectable. The solution -above is the only reasonable way I can think of without involving finalizers. This is the third attempt -(see https://github.com/dop251/goja/issues/250 and https://github.com/dop251/goja/issues/199 for more details). - -Note, this does not have any effect on the application logic, but may cause a higher-than-expected memory usage. - -### WeakRef and FinalizationRegistry -For the reason mentioned above implementing WeakRef and FinalizationRegistry does not seem to be possible at this stage. - -### JSON -`JSON.parse()` uses the standard Go library which operates in UTF-8. Therefore, it cannot correctly parse broken UTF-16 -surrogate pairs, for example: - -```javascript -JSON.parse(`"\\uD800"`).charCodeAt(0).toString(16) // returns "fffd" instead of "d800" -``` - -### Date -Conversion from calendar date to epoch timestamp uses the standard Go library which uses `int`, rather than `float` as per -ECMAScript specification. This means if you pass arguments that overflow int to the `Date()` constructor or if there is -an integer overflow, the result will be incorrect, for example: - -```javascript -Date.UTC(1970, 0, 1, 80063993375, 29, 1, -288230376151711740) // returns 29256 instead of 29312 -``` - -FAQ ---- - -### How fast is it? - -Although it's faster than many scripting language implementations in Go I have seen -(for example it's 6-7 times faster than otto on average) it is not a -replacement for V8 or SpiderMonkey or any other general-purpose JavaScript engine. -You can find some benchmarks [here](https://github.com/dop251/goja/issues/2). - -### Why would I want to use it over a V8 wrapper? - -It greatly depends on your usage scenario. If most of the work is done in javascript -(for example crypto or any other heavy calculations) you are definitely better off with V8. - -If you need a scripting language that drives an engine written in Go so that -you need to make frequent calls between Go and javascript passing complex data structures -then the cgo overhead may outweigh the benefits of having a faster javascript engine. - -Because it's written in pure Go there are no cgo dependencies, it's very easy to build and it -should run on any platform supported by Go. - -It gives you a much better control over execution environment so can be useful for research. - -### Is it goroutine-safe? - -No. An instance of goja.Runtime can only be used by a single goroutine -at a time. You can create as many instances of Runtime as you like but -it's not possible to pass object values between runtimes. - -### Where is setTimeout()? - -setTimeout() assumes concurrent execution of code which requires an execution -environment, for example an event loop similar to nodejs or a browser. -There is a [separate project](https://github.com/dop251/goja_nodejs) aimed at providing some NodeJS functionality, -and it includes an event loop. - -### Can you implement (feature X from ES6 or higher)? - -I will be adding features in their dependency order and as quickly as time permits. Please do not ask -for ETAs. Features that are open in the [milestone](https://github.com/dop251/goja/milestone/1) are either in progress -or will be worked on next. - -The ongoing work is done in separate feature branches which are merged into master when appropriate. -Every commit in these branches represents a relatively stable state (i.e. it compiles and passes all enabled tc39 tests), -however because the version of tc39 tests I use is quite old, it may be not as well tested as the ES5.1 functionality. Because there are (usually) no major breaking changes between ECMAScript revisions -it should not break your existing code. You are encouraged to give it a try and report any bugs found. Please do not submit fixes though without discussing it first, as the code could be changed in the meantime. - -### How do I contribute? - -Before submitting a pull request please make sure that: - -- You followed ECMA standard as close as possible. If adding a new feature make sure you've read the specification, -do not just base it on a couple of examples that work fine. -- Your change does not have a significant negative impact on performance (unless it's a bugfix and it's unavoidable) -- It passes all relevant tc39 tests. - -Current Status --------------- - - * There should be no breaking changes in the API, however it may be extended. - * Some of the AnnexB functionality is missing. - -Basic Example -------------- - -Run JavaScript and get the result value. - -```go -vm := goja.New() -v, err := vm.RunString("2 + 2") -if err != nil { - panic(err) -} -if num := v.Export().(int64); num != 4 { - panic(num) -} -``` - -Passing Values to JS --------------------- -Any Go value can be passed to JS using Runtime.ToValue() method. See the method's [documentation](https://pkg.go.dev/github.com/dop251/goja#Runtime.ToValue) for more details. - -Exporting Values from JS ------------------------- -A JS value can be exported into its default Go representation using Value.Export() method. - -Alternatively it can be exported into a specific Go variable using [Runtime.ExportTo()](https://pkg.go.dev/github.com/dop251/goja#Runtime.ExportTo) method. - -Within a single export operation the same Object will be represented by the same Go value (either the same map, slice or -a pointer to the same struct). This includes circular objects and makes it possible to export them. - -Calling JS functions from Go ----------------------------- -There are 2 approaches: - -- Using [AssertFunction()](https://pkg.go.dev/github.com/dop251/goja#AssertFunction): -```go -const SCRIPT = ` -function sum(a, b) { - return +a + b; -} -` - -vm := goja.New() -_, err := vm.RunString(SCRIPT) -if err != nil { - panic(err) -} -sum, ok := goja.AssertFunction(vm.Get("sum")) -if !ok { - panic("Not a function") -} - -res, err := sum(goja.Undefined(), vm.ToValue(40), vm.ToValue(2)) -if err != nil { - panic(err) -} -fmt.Println(res) -// Output: 42 -``` -- Using [Runtime.ExportTo()](https://pkg.go.dev/github.com/dop251/goja#Runtime.ExportTo): -```go -const SCRIPT = ` -function sum(a, b) { - return +a + b; -} -` - -vm := goja.New() -_, err := vm.RunString(SCRIPT) -if err != nil { - panic(err) -} - -var sum func(int, int) int -err = vm.ExportTo(vm.Get("sum"), &sum) -if err != nil { - panic(err) -} - -fmt.Println(sum(40, 2)) // note, _this_ value in the function will be undefined. -// Output: 42 -``` - -The first one is more low level and allows specifying _this_ value, whereas the second one makes the function look like -a normal Go function. - -Mapping struct field and method names -------------------------------------- -By default, the names are passed through as is which means they are capitalised. This does not match -the standard JavaScript naming convention, so if you need to make your JS code look more natural or if you are -dealing with a 3rd party library, you can use a [FieldNameMapper](https://pkg.go.dev/github.com/dop251/goja#FieldNameMapper): - -```go -vm := goja.New() -vm.SetFieldNameMapper(TagFieldNameMapper("json", true)) -type S struct { - Field int `json:"field"` -} -vm.Set("s", S{Field: 42}) -res, _ := vm.RunString(`s.field`) // without the mapper it would have been s.Field -fmt.Println(res.Export()) -// Output: 42 -``` - -There are two standard mappers: [TagFieldNameMapper](https://pkg.go.dev/github.com/dop251/goja#TagFieldNameMapper) and -[UncapFieldNameMapper](https://pkg.go.dev/github.com/dop251/goja#UncapFieldNameMapper), or you can use your own implementation. - -Native Constructors -------------------- - -In order to implement a constructor function in Go use `func (goja.ConstructorCall) *goja.Object`. -See [Runtime.ToValue()](https://pkg.go.dev/github.com/dop251/goja#Runtime.ToValue) documentation for more details. - -Regular Expressions -------------------- - -Goja uses the embedded Go regexp library where possible, otherwise it falls back to [regexp2](https://github.com/dlclark/regexp2). - -Exceptions ----------- - -Any exception thrown in JavaScript is returned as an error of type *Exception. It is possible to extract the value thrown -by using the Value() method: - -```go -vm := goja.New() -_, err := vm.RunString(` - -throw("Test"); - -`) - -if jserr, ok := err.(*Exception); ok { - if jserr.Value().Export() != "Test" { - panic("wrong value") - } -} else { - panic("wrong type") -} -``` - -If a native Go function panics with a Value, it is thrown as a Javascript exception (and therefore can be caught): - -```go -var vm *Runtime - -func Test() { - panic(vm.ToValue("Error")) -} - -vm = goja.New() -vm.Set("Test", Test) -_, err := vm.RunString(` - -try { - Test(); -} catch(e) { - if (e !== "Error") { - throw e; - } -} - -`) - -if err != nil { - panic(err) -} -``` - -Interrupting ------------- - -```go -func TestInterrupt(t *testing.T) { - const SCRIPT = ` - var i = 0; - for (;;) { - i++; - } - ` - - vm := goja.New() - time.AfterFunc(200 * time.Millisecond, func() { - vm.Interrupt("halt") - }) - - _, err := vm.RunString(SCRIPT) - if err == nil { - t.Fatal("Err is nil") - } - // err is of type *InterruptError and its Value() method returns whatever has been passed to vm.Interrupt() -} -``` - -NodeJS Compatibility --------------------- - -There is a [separate project](https://github.com/dop251/goja_nodejs) aimed at providing some of the NodeJS functionality. diff --git a/vendor/github.com/fatih/color/color.go b/vendor/github.com/fatih/color/color.go index c4234287dcc..81094e87c56 100644 --- a/vendor/github.com/fatih/color/color.go +++ b/vendor/github.com/fatih/color/color.go @@ -269,7 +269,7 @@ func (c *Color) Printf(format string, a ...interface{}) (n int, err error) { // On Windows, users should wrap w with colorable.NewColorable() if w is of // type *os.File. func (c *Color) Fprintln(w io.Writer, a ...interface{}) (n int, err error) { - return fmt.Fprintln(w, c.wrap(fmt.Sprint(a...))) + return fmt.Fprintln(w, c.wrap(sprintln(a...))) } // Println formats using the default formats for its operands and writes to @@ -278,7 +278,7 @@ func (c *Color) Fprintln(w io.Writer, a ...interface{}) (n int, err error) { // encountered. This is the standard fmt.Print() method wrapped with the given // color. func (c *Color) Println(a ...interface{}) (n int, err error) { - return fmt.Fprintln(Output, c.wrap(fmt.Sprint(a...))) + return fmt.Fprintln(Output, c.wrap(sprintln(a...))) } // Sprint is just like Print, but returns a string instead of printing it. @@ -288,7 +288,7 @@ func (c *Color) Sprint(a ...interface{}) string { // Sprintln is just like Println, but returns a string instead of printing it. func (c *Color) Sprintln(a ...interface{}) string { - return fmt.Sprintln(c.Sprint(a...)) + return c.wrap(sprintln(a...)) + "\n" } // Sprintf is just like Printf, but returns a string instead of printing it. @@ -370,7 +370,7 @@ func (c *Color) SprintfFunc() func(format string, a ...interface{}) string { // string. Windows users should use this in conjunction with color.Output. func (c *Color) SprintlnFunc() func(a ...interface{}) string { return func(a ...interface{}) string { - return fmt.Sprintln(c.Sprint(a...)) + return c.wrap(sprintln(a...)) + "\n" } } @@ -648,3 +648,8 @@ func HiCyanString(format string, a ...interface{}) string { return colorString(f func HiWhiteString(format string, a ...interface{}) string { return colorString(format, FgHiWhite, a...) } + +// sprintln is a helper function to format a string with fmt.Sprintln and trim the trailing newline. +func sprintln(a ...interface{}) string { + return strings.TrimSuffix(fmt.Sprintln(a...), "\n") +} diff --git a/vendor/github.com/dop251/goja/.gitignore b/vendor/github.com/grafana/sobek/.gitignore similarity index 100% rename from vendor/github.com/dop251/goja/.gitignore rename to vendor/github.com/grafana/sobek/.gitignore diff --git a/vendor/github.com/dop251/goja/.tc39_test262_checkout.sh b/vendor/github.com/grafana/sobek/.tc39_test262_checkout.sh similarity index 100% rename from vendor/github.com/dop251/goja/.tc39_test262_checkout.sh rename to vendor/github.com/grafana/sobek/.tc39_test262_checkout.sh diff --git a/vendor/github.com/grafana/sobek/CODEOWNERS b/vendor/github.com/grafana/sobek/CODEOWNERS new file mode 100644 index 00000000000..6b18311e05e --- /dev/null +++ b/vendor/github.com/grafana/sobek/CODEOWNERS @@ -0,0 +1 @@ +* @grafana/k6-core diff --git a/vendor/github.com/grafana/sobek/README.md b/vendor/github.com/grafana/sobek/README.md index 51d78207ef6..c778fa75eb5 100644 --- a/vendor/github.com/grafana/sobek/README.md +++ b/vendor/github.com/grafana/sobek/README.md @@ -1,7 +1,329 @@ -## Sobek +Sobek +==== -Is a fork of [goja](https://github.com/dop251/goja) named after the [ancient Egyptian god](https://en.wikipedia.org/wiki/Sobek) of the same name +ECMAScript 5.1(+) implementation in Go. -The fork is currently just aliasing types in order to facilitate the moving of the current k6 codebase and extension to it with less friction. +[![Go Reference](https://pkg.go.dev/badge/github.com/grafana/sobek.svg)](https://pkg.go.dev/github.com/grafana/sobek) -The plan and discussion on the transition can be find in [this issue](https://github.com/grafana/k6/issues/3773). +Sobek is an implementation of ECMAScript 5.1 in pure Go with emphasis on standard compliance and +performance. + +This project is a fork of [goja](https://github.com/dop251/goja). + +This project was largely inspired by [otto](https://github.com/robertkrimen/otto). + +The minimum required Go version is 1.20. + +Features +-------- + + * Full ECMAScript 5.1 support (including regex and strict mode). + * Passes nearly all [tc39 tests](https://github.com/tc39/test262) for the features implemented so far. The goal is to + pass all of them. See .tc39_test262_checkout.sh for the latest working commit id. + * Capable of running Babel, Typescript compiler and pretty much anything written in ES5. + * Sourcemaps. + * Most of ES6 functionality, still work in progress, see https://github.com/grafana/sobek/milestone/1?closed=1 + +Known incompatibilities and caveats +----------------------------------- + +### WeakMap +WeakMap is implemented by embedding references to the values into the keys. This means that as long +as the key is reachable all values associated with it in any weak maps also remain reachable and therefore +cannot be garbage collected even if they are not otherwise referenced, even after the WeakMap is gone. +The reference to the value is dropped either when the key is explicitly removed from the WeakMap or when the +key becomes unreachable. + +To illustrate this: + +```javascript +var m = new WeakMap(); +var key = {}; +var value = {/* a very large object */}; +m.set(key, value); +value = undefined; +m = undefined; // The value does NOT become garbage-collectable at this point +key = undefined; // Now it does +// m.delete(key); // This would work too +``` + +The reason for it is the limitation of the Go runtime. At the time of writing (version 1.15) having a finalizer +set on an object which is part of a reference cycle makes the whole cycle non-garbage-collectable. The solution +above is the only reasonable way I can think of without involving finalizers. This is the third attempt +(see https://github.com/dop251/goja/issues/250 and https://github.com/dop251/goja/issues/199 for more details). + +Note, this does not have any effect on the application logic, but may cause a higher-than-expected memory usage. + +### WeakRef and FinalizationRegistry +For the reason mentioned above implementing WeakRef and FinalizationRegistry does not seem to be possible at this stage. + +### JSON +`JSON.parse()` uses the standard Go library which operates in UTF-8. Therefore, it cannot correctly parse broken UTF-16 +surrogate pairs, for example: + +```javascript +JSON.parse(`"\\uD800"`).charCodeAt(0).toString(16) // returns "fffd" instead of "d800" +``` + +### Date +Conversion from calendar date to epoch timestamp uses the standard Go library which uses `int`, rather than `float` as per +ECMAScript specification. This means if you pass arguments that overflow int to the `Date()` constructor or if there is +an integer overflow, the result will be incorrect, for example: + +```javascript +Date.UTC(1970, 0, 1, 80063993375, 29, 1, -288230376151711740) // returns 29256 instead of 29312 +``` + +FAQ +--- + +### How fast is it? + +Although it's faster than many scripting language implementations in Go I have seen +(for example it's 6-7 times faster than otto on average) it is not a +replacement for V8 or SpiderMonkey or any other general-purpose JavaScript engine. +You can find some benchmarks [here](https://github.com/dop251/goja/issues/2). + +### Why would I want to use it over a V8 wrapper? + +It greatly depends on your usage scenario. If most of the work is done in javascript +(for example crypto or any other heavy calculations) you are definitely better off with V8. + +If you need a scripting language that drives an engine written in Go so that +you need to make frequent calls between Go and javascript passing complex data structures +then the cgo overhead may outweigh the benefits of having a faster javascript engine. + +Because it's written in pure Go there are no cgo dependencies, it's very easy to build and it +should run on any platform supported by Go. + +It gives you a much better control over execution environment so can be useful for research. + +### Is it goroutine-safe? + +No. An instance of sobek.Runtime can only be used by a single goroutine +at a time. You can create as many instances of Runtime as you like but +it's not possible to pass object values between runtimes. + +### Where is setTimeout()? + +setTimeout() assumes concurrent execution of code which requires an execution +environment, for example an event loop similar to nodejs or a browser. + +### Can you implement (feature X from ES6 or higher)? + +I will be adding features in their dependency order and as quickly as time permits. Please do not ask +for ETAs. Features that are open in the [milestone](https://github.com/grafana/sobek/milestone/1) are either in progress +or will be worked on next. + +The ongoing work is done in separate feature branches which are merged into master when appropriate. +Every commit in these branches represents a relatively stable state (i.e. it compiles and passes all enabled tc39 tests), +however because the version of tc39 tests I use is quite old, it may be not as well tested as the ES5.1 functionality. Because there are (usually) no major breaking changes between ECMAScript revisions +it should not break your existing code. You are encouraged to give it a try and report any bugs found. Please do not submit fixes though without discussing it first, as the code could be changed in the meantime. + +### How do I contribute? + +Before submitting a pull request please make sure that: + +- You followed ECMA standard as close as possible. If adding a new feature make sure you've read the specification, +do not just base it on a couple of examples that work fine. +- Your change does not have a significant negative impact on performance (unless it's a bugfix and it's unavoidable) +- It passes all relevant tc39 tests. + +Current Status +-------------- + + * There should be no breaking changes in the API, however it may be extended. + * Some of the AnnexB functionality is missing. + +Basic Example +------------- + +Run JavaScript and get the result value. + +```go +vm := sobek.New() +v, err := vm.RunString("2 + 2") +if err != nil { + panic(err) +} +if num := v.Export().(int64); num != 4 { + panic(num) +} +``` + +Passing Values to JS +-------------------- +Any Go value can be passed to JS using Runtime.ToValue() method. See the method's [documentation](https://pkg.go.dev/github.com/grafana/sobek#Runtime.ToValue) for more details. + +Exporting Values from JS +------------------------ +A JS value can be exported into its default Go representation using Value.Export() method. + +Alternatively it can be exported into a specific Go variable using [Runtime.ExportTo()](https://pkg.go.dev/github.com/grafana/sobek#Runtime.ExportTo) method. + +Within a single export operation the same Object will be represented by the same Go value (either the same map, slice or +a pointer to the same struct). This includes circular objects and makes it possible to export them. + +Calling JS functions from Go +---------------------------- +There are 2 approaches: + +- Using [AssertFunction()](https://pkg.go.dev/github.com/grafana/sobek#AssertFunction): +```go +const SCRIPT = ` +function sum(a, b) { + return +a + b; +} +` + +vm := sobek.New() +_, err := vm.RunString(SCRIPT) +if err != nil { + panic(err) +} +sum, ok := sobek.AssertFunction(vm.Get("sum")) +if !ok { + panic("Not a function") +} + +res, err := sum(sobek.Undefined(), vm.ToValue(40), vm.ToValue(2)) +if err != nil { + panic(err) +} +fmt.Println(res) +// Output: 42 +``` +- Using [Runtime.ExportTo()](https://pkg.go.dev/github.com/grafana/sobek#Runtime.ExportTo): +```go +const SCRIPT = ` +function sum(a, b) { + return +a + b; +} +` + +vm := sobek.New() +_, err := vm.RunString(SCRIPT) +if err != nil { + panic(err) +} + +var sum func(int, int) int +err = vm.ExportTo(vm.Get("sum"), &sum) +if err != nil { + panic(err) +} + +fmt.Println(sum(40, 2)) // note, _this_ value in the function will be undefined. +// Output: 42 +``` + +The first one is more low level and allows specifying _this_ value, whereas the second one makes the function look like +a normal Go function. + +Mapping struct field and method names +------------------------------------- +By default, the names are passed through as is which means they are capitalised. This does not match +the standard JavaScript naming convention, so if you need to make your JS code look more natural or if you are +dealing with a 3rd party library, you can use a [FieldNameMapper](https://pkg.go.dev/github.com/grafana/sobek#FieldNameMapper): + +```go +vm := sobek.New() +vm.SetFieldNameMapper(TagFieldNameMapper("json", true)) +type S struct { + Field int `json:"field"` +} +vm.Set("s", S{Field: 42}) +res, _ := vm.RunString(`s.field`) // without the mapper it would have been s.Field +fmt.Println(res.Export()) +// Output: 42 +``` + +There are two standard mappers: [TagFieldNameMapper](https://pkg.go.dev/github.com/grafana/sobek#TagFieldNameMapper) and +[UncapFieldNameMapper](https://pkg.go.dev/github.com/grafana/sobek#UncapFieldNameMapper), or you can use your own implementation. + +Native Constructors +------------------- + +In order to implement a constructor function in Go use `func (sobek.ConstructorCall) *sobek.Object`. +See [Runtime.ToValue()](https://pkg.go.dev/github.com/grafana/sobek#Runtime.ToValue) documentation for more details. + +Regular Expressions +------------------- + +Sobek uses the embedded Go regexp library where possible, otherwise it falls back to [regexp2](https://github.com/dlclark/regexp2). + +Exceptions +---------- + +Any exception thrown in JavaScript is returned as an error of type *Exception. It is possible to extract the value thrown +by using the Value() method: + +```go +vm := sobek.New() +_, err := vm.RunString(` + +throw("Test"); + +`) + +if jserr, ok := err.(*Exception); ok { + if jserr.Value().Export() != "Test" { + panic("wrong value") + } +} else { + panic("wrong type") +} +``` + +If a native Go function panics with a Value, it is thrown as a Javascript exception (and therefore can be caught): + +```go +var vm *Runtime + +func Test() { + panic(vm.ToValue("Error")) +} + +vm = sobek.New() +vm.Set("Test", Test) +_, err := vm.RunString(` + +try { + Test(); +} catch(e) { + if (e !== "Error") { + throw e; + } +} + +`) + +if err != nil { + panic(err) +} +``` + +Interrupting +------------ + +```go +func TestInterrupt(t *testing.T) { + const SCRIPT = ` + var i = 0; + for (;;) { + i++; + } + ` + + vm := sobek.New() + time.AfterFunc(200 * time.Millisecond, func() { + vm.Interrupt("halt") + }) + + _, err := vm.RunString(SCRIPT) + if err == nil { + t.Fatal("Err is nil") + } + // err is of type *InterruptError and its Value() method returns whatever has been passed to vm.Interrupt() +} +``` diff --git a/vendor/github.com/grafana/sobek/aliases.go b/vendor/github.com/grafana/sobek/aliases.go deleted file mode 100644 index 01a8772d8a1..00000000000 --- a/vendor/github.com/grafana/sobek/aliases.go +++ /dev/null @@ -1,130 +0,0 @@ -package sobek - -import ( - "github.com/dop251/goja" - "github.com/dop251/goja/ast" - "github.com/dop251/goja/parser" -) - -const ( - FLAG_NOT_SET Flag = iota - FLAG_FALSE - FLAG_TRUE -) - -func Null() Value { return goja.Null() } - -func IsInfinity(v Value) bool { return goja.IsInfinity(v) } - -func IsNaN(v Value) bool { return goja.IsNaN(v) } - -func IsNull(v Value) bool { return goja.IsNull(v) } - -func IsUndefined(v Value) bool { return goja.IsUndefined(v) } - -func Parse(name, src string, options ...parser.Option) (prg *ast.Program, err error) { - return goja.Parse(name, src, options...) -} - -func AssertFunction(v Value) (Callable, bool) { return goja.AssertFunction(v) } - -func AssertConstructor(v Value) (Constructor, bool) { return goja.AssertConstructor(v) } - -func Undefined() Value { return goja.Undefined() } - -func CompileAST(prg *ast.Program, strict bool) (*Program, error) { - return goja.CompileAST(prg, strict) -} - -func Compile(name, src string, strict bool) (*Program, error) { - return goja.Compile(name, src, strict) -} - -func MustCompile(name, src string, strict bool) *Program { - return goja.MustCompile(name, src, strict) -} - -func New() *Runtime { - return goja.New() -} - -type ArrayBuffer = goja.ArrayBuffer - -type ( - AsyncContextTracker = goja.AsyncContextTracker - Callable = goja.Callable -) - -type ( - CompilerError = goja.CompilerError - CompilerReferenceError = goja.CompilerReferenceError -) - -type CompilerSyntaxError = goja.CompilerSyntaxError - -type Constructor = goja.Constructor - -type ConstructorCall = goja.ConstructorCall - -type ( - DynamicArray = goja.DynamicArray - DynamicObject = goja.DynamicObject - Exception = goja.Exception -) - -type FieldNameMapper = goja.FieldNameMapper - -type ( - Flag = goja.Flag - FunctionCall = goja.FunctionCall -) - -type InterruptedError = goja.InterruptedError - -type ( - JsonEncodable = goja.JsonEncodable - Now = goja.Now - Object = goja.Object -) - -type Program = goja.Program - -type Promise = goja.Promise - -type ( - PromiseRejectionOperation = goja.PromiseRejectionOperation - PromiseRejectionTracker = goja.PromiseRejectionTracker - PromiseState = goja.PromiseState - PropertyDescriptor = goja.PropertyDescriptor -) - -const ( - PromiseRejectionReject PromiseRejectionOperation = iota - PromiseRejectionHandle -) - -const ( - PromiseStatePending PromiseState = iota - PromiseStateFulfilled - PromiseStateRejected -) - -type Proxy = goja.Proxy - -type ( - ProxyTrapConfig = goja.ProxyTrapConfig - RandSource = goja.RandSource - Runtime = goja.Runtime -) - -type StackFrame = goja.StackFrame - -type ( - StackOverflowError = goja.StackOverflowError - String = goja.String - StringBuilder = goja.StringBuilder - Symbol = goja.Symbol - Value = goja.Value -) - -func UncapFieldNameMapper() FieldNameMapper { return goja.UncapFieldNameMapper() } diff --git a/vendor/github.com/dop251/goja/array.go b/vendor/github.com/grafana/sobek/array.go similarity index 99% rename from vendor/github.com/dop251/goja/array.go rename to vendor/github.com/grafana/sobek/array.go index 7a67a47c16e..ef12dc558fb 100644 --- a/vendor/github.com/dop251/goja/array.go +++ b/vendor/github.com/grafana/sobek/array.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "fmt" @@ -7,7 +7,7 @@ import ( "reflect" "strconv" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) type arrayIterObject struct { diff --git a/vendor/github.com/dop251/goja/array_sparse.go b/vendor/github.com/grafana/sobek/array_sparse.go similarity index 99% rename from vendor/github.com/dop251/goja/array_sparse.go rename to vendor/github.com/grafana/sobek/array_sparse.go index f99afd7e6dd..877d281976a 100644 --- a/vendor/github.com/dop251/goja/array_sparse.go +++ b/vendor/github.com/grafana/sobek/array_sparse.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "fmt" @@ -8,7 +8,7 @@ import ( "sort" "strconv" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) type sparseArrayItem struct { diff --git a/vendor/github.com/dop251/goja/ast/README.markdown b/vendor/github.com/grafana/sobek/ast/README.markdown similarity index 99% rename from vendor/github.com/dop251/goja/ast/README.markdown rename to vendor/github.com/grafana/sobek/ast/README.markdown index aba088e261c..65aa0018e00 100644 --- a/vendor/github.com/dop251/goja/ast/README.markdown +++ b/vendor/github.com/grafana/sobek/ast/README.markdown @@ -1,6 +1,6 @@ # ast -- - import "github.com/dop251/goja/ast" + import "github.com/grafana/sobek/ast" Package ast declares types representing a JavaScript AST. diff --git a/vendor/github.com/dop251/goja/ast/node.go b/vendor/github.com/grafana/sobek/ast/node.go similarity index 99% rename from vendor/github.com/dop251/goja/ast/node.go rename to vendor/github.com/grafana/sobek/ast/node.go index 3bec89db493..0663ba8daea 100644 --- a/vendor/github.com/dop251/goja/ast/node.go +++ b/vendor/github.com/grafana/sobek/ast/node.go @@ -9,9 +9,9 @@ node types are concerned) and may change in the future. package ast import ( - "github.com/dop251/goja/file" - "github.com/dop251/goja/token" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/file" + "github.com/grafana/sobek/token" + "github.com/grafana/sobek/unistring" ) type PropertyKind string diff --git a/vendor/github.com/dop251/goja/builtin_array.go b/vendor/github.com/grafana/sobek/builtin_array.go similarity index 99% rename from vendor/github.com/dop251/goja/builtin_array.go rename to vendor/github.com/grafana/sobek/builtin_array.go index 6ba8802c282..7121bfa7c4a 100644 --- a/vendor/github.com/dop251/goja/builtin_array.go +++ b/vendor/github.com/grafana/sobek/builtin_array.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "math" diff --git a/vendor/github.com/dop251/goja/builtin_boolean.go b/vendor/github.com/grafana/sobek/builtin_boolean.go similarity index 99% rename from vendor/github.com/dop251/goja/builtin_boolean.go rename to vendor/github.com/grafana/sobek/builtin_boolean.go index 8476328511b..757f8ad7423 100644 --- a/vendor/github.com/dop251/goja/builtin_boolean.go +++ b/vendor/github.com/grafana/sobek/builtin_boolean.go @@ -1,4 +1,4 @@ -package goja +package sobek func (r *Runtime) booleanproto_toString(call FunctionCall) Value { var b bool diff --git a/vendor/github.com/dop251/goja/builtin_date.go b/vendor/github.com/grafana/sobek/builtin_date.go similarity index 99% rename from vendor/github.com/dop251/goja/builtin_date.go rename to vendor/github.com/grafana/sobek/builtin_date.go index 84a80ac02b2..b67e7f0e179 100644 --- a/vendor/github.com/dop251/goja/builtin_date.go +++ b/vendor/github.com/grafana/sobek/builtin_date.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "fmt" diff --git a/vendor/github.com/dop251/goja/builtin_error.go b/vendor/github.com/grafana/sobek/builtin_error.go similarity index 99% rename from vendor/github.com/dop251/goja/builtin_error.go rename to vendor/github.com/grafana/sobek/builtin_error.go index b07bf6a777e..99532542cae 100644 --- a/vendor/github.com/dop251/goja/builtin_error.go +++ b/vendor/github.com/grafana/sobek/builtin_error.go @@ -1,6 +1,6 @@ -package goja +package sobek -import "github.com/dop251/goja/unistring" +import "github.com/grafana/sobek/unistring" const propNameStack = "stack" diff --git a/vendor/github.com/dop251/goja/builtin_function.go b/vendor/github.com/grafana/sobek/builtin_function.go similarity index 99% rename from vendor/github.com/dop251/goja/builtin_function.go rename to vendor/github.com/grafana/sobek/builtin_function.go index 26a1287c836..64332f95324 100644 --- a/vendor/github.com/dop251/goja/builtin_function.go +++ b/vendor/github.com/grafana/sobek/builtin_function.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "math" diff --git a/vendor/github.com/dop251/goja/builtin_global.go b/vendor/github.com/grafana/sobek/builtin_global.go similarity index 99% rename from vendor/github.com/dop251/goja/builtin_global.go rename to vendor/github.com/grafana/sobek/builtin_global.go index 5ef4176b49d..d7ba9b457b5 100644 --- a/vendor/github.com/dop251/goja/builtin_global.go +++ b/vendor/github.com/grafana/sobek/builtin_global.go @@ -1,8 +1,8 @@ -package goja +package sobek import ( "errors" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" "io" "math" "regexp" diff --git a/vendor/github.com/dop251/goja/builtin_json.go b/vendor/github.com/grafana/sobek/builtin_json.go similarity index 99% rename from vendor/github.com/dop251/goja/builtin_json.go rename to vendor/github.com/grafana/sobek/builtin_json.go index e99771cf12e..57f7ccd798c 100644 --- a/vendor/github.com/dop251/goja/builtin_json.go +++ b/vendor/github.com/grafana/sobek/builtin_json.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "bytes" @@ -12,7 +12,7 @@ import ( "unicode/utf16" "unicode/utf8" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) const hex = "0123456789abcdef" diff --git a/vendor/github.com/dop251/goja/builtin_map.go b/vendor/github.com/grafana/sobek/builtin_map.go similarity index 99% rename from vendor/github.com/dop251/goja/builtin_map.go rename to vendor/github.com/grafana/sobek/builtin_map.go index 819d025fe10..c0c887fcc5d 100644 --- a/vendor/github.com/dop251/goja/builtin_map.go +++ b/vendor/github.com/grafana/sobek/builtin_map.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "reflect" diff --git a/vendor/github.com/dop251/goja/builtin_math.go b/vendor/github.com/grafana/sobek/builtin_math.go similarity index 99% rename from vendor/github.com/dop251/goja/builtin_math.go rename to vendor/github.com/grafana/sobek/builtin_math.go index 169ea18ca4b..a31d7c32e04 100644 --- a/vendor/github.com/dop251/goja/builtin_math.go +++ b/vendor/github.com/grafana/sobek/builtin_math.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "math" diff --git a/vendor/github.com/dop251/goja/builtin_number.go b/vendor/github.com/grafana/sobek/builtin_number.go similarity index 99% rename from vendor/github.com/dop251/goja/builtin_number.go rename to vendor/github.com/grafana/sobek/builtin_number.go index 43add4ffb3e..f7b2ee040d4 100644 --- a/vendor/github.com/dop251/goja/builtin_number.go +++ b/vendor/github.com/grafana/sobek/builtin_number.go @@ -1,10 +1,10 @@ -package goja +package sobek import ( "math" "sync" - "github.com/dop251/goja/ftoa" + "github.com/grafana/sobek/ftoa" ) func (r *Runtime) toNumber(v Value) Value { diff --git a/vendor/github.com/dop251/goja/builtin_object.go b/vendor/github.com/grafana/sobek/builtin_object.go similarity index 99% rename from vendor/github.com/dop251/goja/builtin_object.go rename to vendor/github.com/grafana/sobek/builtin_object.go index 6bf1ff80ae9..d7c5aa922ac 100644 --- a/vendor/github.com/dop251/goja/builtin_object.go +++ b/vendor/github.com/grafana/sobek/builtin_object.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "fmt" diff --git a/vendor/github.com/dop251/goja/builtin_promise.go b/vendor/github.com/grafana/sobek/builtin_promise.go similarity index 98% rename from vendor/github.com/dop251/goja/builtin_promise.go rename to vendor/github.com/grafana/sobek/builtin_promise.go index d51f27d17af..a4a1255a141 100644 --- a/vendor/github.com/dop251/goja/builtin_promise.go +++ b/vendor/github.com/grafana/sobek/builtin_promise.go @@ -1,7 +1,7 @@ -package goja +package sobek import ( - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" "reflect" ) @@ -605,18 +605,18 @@ func (r *Runtime) wrapPromiseReaction(fObj *Object) func(interface{}) { // NewPromise creates and returns a Promise and resolving functions for it. // // WARNING: The returned values are not goroutine-safe and must not be called in parallel with VM running. -// In order to make use of this method you need an event loop such as the one in goja_nodejs (https://github.com/dop251/goja_nodejs) +// In order to make use of this method you need an event loop such as the one in sobek_nodejs (https://github.com/grafana/sobek_nodejs) // where it can be used like this: // // loop := NewEventLoop() // loop.Start() // defer loop.Stop() -// loop.RunOnLoop(func(vm *goja.Runtime) { +// loop.RunOnLoop(func(vm *sobek.Runtime) { // p, resolve, _ := vm.NewPromise() // vm.Set("p", p) // go func() { // time.Sleep(500 * time.Millisecond) // or perform any other blocking operation -// loop.RunOnLoop(func(*goja.Runtime) { // resolve() must be called on the loop, cannot call it here +// loop.RunOnLoop(func(*sobek.Runtime) { // resolve() must be called on the loop, cannot call it here // resolve(result) // }) // }() diff --git a/vendor/github.com/dop251/goja/builtin_proxy.go b/vendor/github.com/grafana/sobek/builtin_proxy.go similarity index 99% rename from vendor/github.com/dop251/goja/builtin_proxy.go rename to vendor/github.com/grafana/sobek/builtin_proxy.go index f589930677e..4ec5ba01745 100644 --- a/vendor/github.com/dop251/goja/builtin_proxy.go +++ b/vendor/github.com/grafana/sobek/builtin_proxy.go @@ -1,7 +1,7 @@ -package goja +package sobek import ( - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) type nativeProxyHandler struct { diff --git a/vendor/github.com/dop251/goja/builtin_reflect.go b/vendor/github.com/grafana/sobek/builtin_reflect.go similarity index 99% rename from vendor/github.com/dop251/goja/builtin_reflect.go rename to vendor/github.com/grafana/sobek/builtin_reflect.go index 17bb11a36d6..8ee0d7cf5a7 100644 --- a/vendor/github.com/dop251/goja/builtin_reflect.go +++ b/vendor/github.com/grafana/sobek/builtin_reflect.go @@ -1,4 +1,4 @@ -package goja +package sobek func (r *Runtime) builtin_reflect_apply(call FunctionCall) Value { return r.toCallable(call.Argument(0))(FunctionCall{ diff --git a/vendor/github.com/dop251/goja/builtin_regexp.go b/vendor/github.com/grafana/sobek/builtin_regexp.go similarity index 99% rename from vendor/github.com/dop251/goja/builtin_regexp.go rename to vendor/github.com/grafana/sobek/builtin_regexp.go index 89402820e99..a606da0ce0e 100644 --- a/vendor/github.com/dop251/goja/builtin_regexp.go +++ b/vendor/github.com/grafana/sobek/builtin_regexp.go @@ -1,8 +1,8 @@ -package goja +package sobek import ( "fmt" - "github.com/dop251/goja/parser" + "github.com/grafana/sobek/parser" "regexp" "strings" "unicode/utf16" diff --git a/vendor/github.com/dop251/goja/builtin_set.go b/vendor/github.com/grafana/sobek/builtin_set.go similarity index 99% rename from vendor/github.com/dop251/goja/builtin_set.go rename to vendor/github.com/grafana/sobek/builtin_set.go index eeedb887c7f..45d956f1150 100644 --- a/vendor/github.com/dop251/goja/builtin_set.go +++ b/vendor/github.com/grafana/sobek/builtin_set.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "fmt" diff --git a/vendor/github.com/dop251/goja/builtin_string.go b/vendor/github.com/grafana/sobek/builtin_string.go similarity index 99% rename from vendor/github.com/dop251/goja/builtin_string.go rename to vendor/github.com/grafana/sobek/builtin_string.go index b2a0e4ea816..2343ed236fb 100644 --- a/vendor/github.com/dop251/goja/builtin_string.go +++ b/vendor/github.com/grafana/sobek/builtin_string.go @@ -1,14 +1,14 @@ -package goja +package sobek import ( - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" "math" "strings" "sync" "unicode/utf16" "unicode/utf8" - "github.com/dop251/goja/parser" + "github.com/grafana/sobek/parser" "golang.org/x/text/collate" "golang.org/x/text/language" "golang.org/x/text/unicode/norm" diff --git a/vendor/github.com/dop251/goja/builtin_symbol.go b/vendor/github.com/grafana/sobek/builtin_symbol.go similarity index 98% rename from vendor/github.com/dop251/goja/builtin_symbol.go rename to vendor/github.com/grafana/sobek/builtin_symbol.go index 8231b7bfcb7..b0c5fc86721 100644 --- a/vendor/github.com/dop251/goja/builtin_symbol.go +++ b/vendor/github.com/grafana/sobek/builtin_symbol.go @@ -1,6 +1,6 @@ -package goja +package sobek -import "github.com/dop251/goja/unistring" +import "github.com/grafana/sobek/unistring" var ( SymHasInstance = newSymbol(asciiString("Symbol.hasInstance")) diff --git a/vendor/github.com/dop251/goja/builtin_typedarrays.go b/vendor/github.com/grafana/sobek/builtin_typedarrays.go similarity index 99% rename from vendor/github.com/dop251/goja/builtin_typedarrays.go rename to vendor/github.com/grafana/sobek/builtin_typedarrays.go index 1fd672c147b..7ad737fceb0 100644 --- a/vendor/github.com/dop251/goja/builtin_typedarrays.go +++ b/vendor/github.com/grafana/sobek/builtin_typedarrays.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "fmt" @@ -7,7 +7,7 @@ import ( "sync" "unsafe" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) type typedArraySortCtx struct { diff --git a/vendor/github.com/dop251/goja/builtin_weakmap.go b/vendor/github.com/grafana/sobek/builtin_weakmap.go similarity index 99% rename from vendor/github.com/dop251/goja/builtin_weakmap.go rename to vendor/github.com/grafana/sobek/builtin_weakmap.go index 40fc717db13..24bfdd2a41e 100644 --- a/vendor/github.com/dop251/goja/builtin_weakmap.go +++ b/vendor/github.com/grafana/sobek/builtin_weakmap.go @@ -1,4 +1,4 @@ -package goja +package sobek type weakMap uint64 diff --git a/vendor/github.com/dop251/goja/builtin_weakset.go b/vendor/github.com/grafana/sobek/builtin_weakset.go similarity index 99% rename from vendor/github.com/dop251/goja/builtin_weakset.go rename to vendor/github.com/grafana/sobek/builtin_weakset.go index cd8183e5912..e1f842ef0b0 100644 --- a/vendor/github.com/dop251/goja/builtin_weakset.go +++ b/vendor/github.com/grafana/sobek/builtin_weakset.go @@ -1,4 +1,4 @@ -package goja +package sobek type weakSetObject struct { baseObject diff --git a/vendor/github.com/dop251/goja/compiler.go b/vendor/github.com/grafana/sobek/compiler.go similarity index 99% rename from vendor/github.com/dop251/goja/compiler.go rename to vendor/github.com/grafana/sobek/compiler.go index 2abd9ba528b..edebf8c6ce9 100644 --- a/vendor/github.com/dop251/goja/compiler.go +++ b/vendor/github.com/grafana/sobek/compiler.go @@ -1,13 +1,13 @@ -package goja +package sobek import ( "fmt" - "github.com/dop251/goja/token" + "github.com/grafana/sobek/token" "sort" - "github.com/dop251/goja/ast" - "github.com/dop251/goja/file" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/ast" + "github.com/grafana/sobek/file" + "github.com/grafana/sobek/unistring" ) type blockType int diff --git a/vendor/github.com/dop251/goja/compiler_expr.go b/vendor/github.com/grafana/sobek/compiler_expr.go similarity index 99% rename from vendor/github.com/dop251/goja/compiler_expr.go rename to vendor/github.com/grafana/sobek/compiler_expr.go index 477580aecf6..69d37153cd5 100644 --- a/vendor/github.com/dop251/goja/compiler_expr.go +++ b/vendor/github.com/grafana/sobek/compiler_expr.go @@ -1,10 +1,10 @@ -package goja +package sobek import ( - "github.com/dop251/goja/ast" - "github.com/dop251/goja/file" - "github.com/dop251/goja/token" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/ast" + "github.com/grafana/sobek/file" + "github.com/grafana/sobek/token" + "github.com/grafana/sobek/unistring" ) type compiledExpr interface { diff --git a/vendor/github.com/dop251/goja/compiler_stmt.go b/vendor/github.com/grafana/sobek/compiler_stmt.go similarity index 99% rename from vendor/github.com/dop251/goja/compiler_stmt.go rename to vendor/github.com/grafana/sobek/compiler_stmt.go index 2d3d83b95e9..f9599b7e329 100644 --- a/vendor/github.com/dop251/goja/compiler_stmt.go +++ b/vendor/github.com/grafana/sobek/compiler_stmt.go @@ -1,10 +1,10 @@ -package goja +package sobek import ( - "github.com/dop251/goja/ast" - "github.com/dop251/goja/file" - "github.com/dop251/goja/token" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/ast" + "github.com/grafana/sobek/file" + "github.com/grafana/sobek/token" + "github.com/grafana/sobek/unistring" ) func (c *compiler) compileStatement(v ast.Statement, needResult bool) { diff --git a/vendor/github.com/dop251/goja/date.go b/vendor/github.com/grafana/sobek/date.go similarity index 99% rename from vendor/github.com/dop251/goja/date.go rename to vendor/github.com/grafana/sobek/date.go index ee29a21e7de..d06841db705 100644 --- a/vendor/github.com/dop251/goja/date.go +++ b/vendor/github.com/grafana/sobek/date.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "math" diff --git a/vendor/github.com/dop251/goja/date_parser.go b/vendor/github.com/grafana/sobek/date_parser.go similarity index 99% rename from vendor/github.com/dop251/goja/date_parser.go rename to vendor/github.com/grafana/sobek/date_parser.go index f8360532929..a956426d3d7 100644 --- a/vendor/github.com/dop251/goja/date_parser.go +++ b/vendor/github.com/grafana/sobek/date_parser.go @@ -1,4 +1,4 @@ -package goja +package sobek // This is a slightly modified version of the standard Go parser to make it more compatible with ECMAScript 5.1 // Changes: diff --git a/vendor/github.com/dop251/goja/destruct.go b/vendor/github.com/grafana/sobek/destruct.go similarity index 99% rename from vendor/github.com/dop251/goja/destruct.go rename to vendor/github.com/grafana/sobek/destruct.go index 66792dc3f65..01e457ace25 100644 --- a/vendor/github.com/dop251/goja/destruct.go +++ b/vendor/github.com/grafana/sobek/destruct.go @@ -1,7 +1,7 @@ -package goja +package sobek import ( - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" "reflect" ) diff --git a/vendor/github.com/dop251/goja/extract_failed_tests.sh b/vendor/github.com/grafana/sobek/extract_failed_tests.sh similarity index 100% rename from vendor/github.com/dop251/goja/extract_failed_tests.sh rename to vendor/github.com/grafana/sobek/extract_failed_tests.sh diff --git a/vendor/github.com/dop251/goja/file/README.markdown b/vendor/github.com/grafana/sobek/file/README.markdown similarity index 97% rename from vendor/github.com/dop251/goja/file/README.markdown rename to vendor/github.com/grafana/sobek/file/README.markdown index e9228c2f5e3..f64210029df 100644 --- a/vendor/github.com/dop251/goja/file/README.markdown +++ b/vendor/github.com/grafana/sobek/file/README.markdown @@ -1,6 +1,6 @@ # file -- - import "github.com/dop251/goja/file" + import "github.com/grafana/sobek/file" Package file encapsulates the file abstractions used by the ast & parser. diff --git a/vendor/github.com/dop251/goja/file/file.go b/vendor/github.com/grafana/sobek/file/file.go similarity index 100% rename from vendor/github.com/dop251/goja/file/file.go rename to vendor/github.com/grafana/sobek/file/file.go diff --git a/vendor/github.com/dop251/goja/ftoa/LICENSE_LUCENE b/vendor/github.com/grafana/sobek/ftoa/LICENSE_LUCENE similarity index 100% rename from vendor/github.com/dop251/goja/ftoa/LICENSE_LUCENE rename to vendor/github.com/grafana/sobek/ftoa/LICENSE_LUCENE diff --git a/vendor/github.com/dop251/goja/ftoa/common.go b/vendor/github.com/grafana/sobek/ftoa/common.go similarity index 100% rename from vendor/github.com/dop251/goja/ftoa/common.go rename to vendor/github.com/grafana/sobek/ftoa/common.go diff --git a/vendor/github.com/dop251/goja/ftoa/ftoa.go b/vendor/github.com/grafana/sobek/ftoa/ftoa.go similarity index 100% rename from vendor/github.com/dop251/goja/ftoa/ftoa.go rename to vendor/github.com/grafana/sobek/ftoa/ftoa.go diff --git a/vendor/github.com/dop251/goja/ftoa/ftobasestr.go b/vendor/github.com/grafana/sobek/ftoa/ftobasestr.go similarity index 100% rename from vendor/github.com/dop251/goja/ftoa/ftobasestr.go rename to vendor/github.com/grafana/sobek/ftoa/ftobasestr.go diff --git a/vendor/github.com/dop251/goja/ftoa/ftostr.go b/vendor/github.com/grafana/sobek/ftoa/ftostr.go similarity index 98% rename from vendor/github.com/dop251/goja/ftoa/ftostr.go rename to vendor/github.com/grafana/sobek/ftoa/ftostr.go index a9d2d240943..d1d9c3f1d97 100644 --- a/vendor/github.com/dop251/goja/ftoa/ftostr.go +++ b/vendor/github.com/grafana/sobek/ftoa/ftostr.go @@ -4,7 +4,7 @@ import ( "math" "strconv" - "github.com/dop251/goja/ftoa/internal/fast" + "github.com/grafana/sobek/ftoa/internal/fast" ) type FToStrMode int diff --git a/vendor/github.com/dop251/goja/ftoa/internal/fast/LICENSE_V8 b/vendor/github.com/grafana/sobek/ftoa/internal/fast/LICENSE_V8 similarity index 100% rename from vendor/github.com/dop251/goja/ftoa/internal/fast/LICENSE_V8 rename to vendor/github.com/grafana/sobek/ftoa/internal/fast/LICENSE_V8 diff --git a/vendor/github.com/dop251/goja/ftoa/internal/fast/cachedpower.go b/vendor/github.com/grafana/sobek/ftoa/internal/fast/cachedpower.go similarity index 100% rename from vendor/github.com/dop251/goja/ftoa/internal/fast/cachedpower.go rename to vendor/github.com/grafana/sobek/ftoa/internal/fast/cachedpower.go diff --git a/vendor/github.com/dop251/goja/ftoa/internal/fast/common.go b/vendor/github.com/grafana/sobek/ftoa/internal/fast/common.go similarity index 100% rename from vendor/github.com/dop251/goja/ftoa/internal/fast/common.go rename to vendor/github.com/grafana/sobek/ftoa/internal/fast/common.go diff --git a/vendor/github.com/dop251/goja/ftoa/internal/fast/diyfp.go b/vendor/github.com/grafana/sobek/ftoa/internal/fast/diyfp.go similarity index 100% rename from vendor/github.com/dop251/goja/ftoa/internal/fast/diyfp.go rename to vendor/github.com/grafana/sobek/ftoa/internal/fast/diyfp.go diff --git a/vendor/github.com/dop251/goja/ftoa/internal/fast/dtoa.go b/vendor/github.com/grafana/sobek/ftoa/internal/fast/dtoa.go similarity index 100% rename from vendor/github.com/dop251/goja/ftoa/internal/fast/dtoa.go rename to vendor/github.com/grafana/sobek/ftoa/internal/fast/dtoa.go diff --git a/vendor/github.com/dop251/goja/func.go b/vendor/github.com/grafana/sobek/func.go similarity index 99% rename from vendor/github.com/dop251/goja/func.go rename to vendor/github.com/grafana/sobek/func.go index c0469569664..ef7c846a2dd 100644 --- a/vendor/github.com/dop251/goja/func.go +++ b/vendor/github.com/grafana/sobek/func.go @@ -1,10 +1,10 @@ -package goja +package sobek import ( "fmt" "reflect" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) type resultType uint8 diff --git a/vendor/github.com/dop251/goja/ipow.go b/vendor/github.com/grafana/sobek/ipow.go similarity index 99% rename from vendor/github.com/dop251/goja/ipow.go rename to vendor/github.com/grafana/sobek/ipow.go index 5ee0d4db917..1d9ef0c3722 100644 --- a/vendor/github.com/dop251/goja/ipow.go +++ b/vendor/github.com/grafana/sobek/ipow.go @@ -1,4 +1,4 @@ -package goja +package sobek // inspired by https://gist.github.com/orlp/3551590 diff --git a/vendor/github.com/dop251/goja/map.go b/vendor/github.com/grafana/sobek/map.go similarity index 99% rename from vendor/github.com/dop251/goja/map.go rename to vendor/github.com/grafana/sobek/map.go index b092b0d0494..26dd400cf87 100644 --- a/vendor/github.com/dop251/goja/map.go +++ b/vendor/github.com/grafana/sobek/map.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "hash/maphash" diff --git a/vendor/github.com/dop251/goja/object.go b/vendor/github.com/grafana/sobek/object.go similarity index 99% rename from vendor/github.com/dop251/goja/object.go rename to vendor/github.com/grafana/sobek/object.go index 79bd67df429..906fe42e9ce 100644 --- a/vendor/github.com/dop251/goja/object.go +++ b/vendor/github.com/grafana/sobek/object.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "fmt" @@ -6,7 +6,7 @@ import ( "reflect" "sort" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) const ( diff --git a/vendor/github.com/dop251/goja/object_args.go b/vendor/github.com/grafana/sobek/object_args.go similarity index 98% rename from vendor/github.com/dop251/goja/object_args.go rename to vendor/github.com/grafana/sobek/object_args.go index eb41d01ce04..3ef097fd281 100644 --- a/vendor/github.com/dop251/goja/object_args.go +++ b/vendor/github.com/grafana/sobek/object_args.go @@ -1,6 +1,6 @@ -package goja +package sobek -import "github.com/dop251/goja/unistring" +import "github.com/grafana/sobek/unistring" type argumentsObject struct { baseObject diff --git a/vendor/github.com/dop251/goja/object_dynamic.go b/vendor/github.com/grafana/sobek/object_dynamic.go similarity index 99% rename from vendor/github.com/dop251/goja/object_dynamic.go rename to vendor/github.com/grafana/sobek/object_dynamic.go index b1e3161e944..a2ebc978485 100644 --- a/vendor/github.com/dop251/goja/object_dynamic.go +++ b/vendor/github.com/grafana/sobek/object_dynamic.go @@ -1,11 +1,11 @@ -package goja +package sobek import ( "fmt" "reflect" "strconv" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) /* diff --git a/vendor/github.com/dop251/goja/object_goarray_reflect.go b/vendor/github.com/grafana/sobek/object_goarray_reflect.go similarity index 99% rename from vendor/github.com/dop251/goja/object_goarray_reflect.go rename to vendor/github.com/grafana/sobek/object_goarray_reflect.go index e40364db9e9..05bb5d4179b 100644 --- a/vendor/github.com/dop251/goja/object_goarray_reflect.go +++ b/vendor/github.com/grafana/sobek/object_goarray_reflect.go @@ -1,10 +1,10 @@ -package goja +package sobek import ( "reflect" "strconv" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) type objectGoArrayReflect struct { diff --git a/vendor/github.com/dop251/goja/object_gomap.go b/vendor/github.com/grafana/sobek/object_gomap.go similarity index 98% rename from vendor/github.com/dop251/goja/object_gomap.go rename to vendor/github.com/grafana/sobek/object_gomap.go index 82138c28aaf..d526403ca56 100644 --- a/vendor/github.com/dop251/goja/object_gomap.go +++ b/vendor/github.com/grafana/sobek/object_gomap.go @@ -1,9 +1,9 @@ -package goja +package sobek import ( "reflect" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) type objectGoMapSimple struct { diff --git a/vendor/github.com/dop251/goja/object_gomap_reflect.go b/vendor/github.com/grafana/sobek/object_gomap_reflect.go similarity index 99% rename from vendor/github.com/dop251/goja/object_gomap_reflect.go rename to vendor/github.com/grafana/sobek/object_gomap_reflect.go index 531c165243e..bf8b41a6bf2 100644 --- a/vendor/github.com/dop251/goja/object_gomap_reflect.go +++ b/vendor/github.com/grafana/sobek/object_gomap_reflect.go @@ -1,9 +1,9 @@ -package goja +package sobek import ( "reflect" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) type objectGoMapReflect struct { diff --git a/vendor/github.com/dop251/goja/object_goreflect.go b/vendor/github.com/grafana/sobek/object_goreflect.go similarity index 99% rename from vendor/github.com/dop251/goja/object_goreflect.go rename to vendor/github.com/grafana/sobek/object_goreflect.go index f8ca6d05a6f..16f837bd38e 100644 --- a/vendor/github.com/dop251/goja/object_goreflect.go +++ b/vendor/github.com/grafana/sobek/object_goreflect.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "fmt" @@ -6,8 +6,8 @@ import ( "reflect" "strings" - "github.com/dop251/goja/parser" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/parser" + "github.com/grafana/sobek/unistring" ) // JsonEncodable allows custom JSON encoding by JSON.stringify() diff --git a/vendor/github.com/dop251/goja/object_goslice.go b/vendor/github.com/grafana/sobek/object_goslice.go similarity index 99% rename from vendor/github.com/dop251/goja/object_goslice.go rename to vendor/github.com/grafana/sobek/object_goslice.go index 1a5220746d8..7f71dfdfb17 100644 --- a/vendor/github.com/dop251/goja/object_goslice.go +++ b/vendor/github.com/grafana/sobek/object_goslice.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "math" @@ -6,7 +6,7 @@ import ( "reflect" "strconv" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) type objectGoSlice struct { diff --git a/vendor/github.com/dop251/goja/object_goslice_reflect.go b/vendor/github.com/grafana/sobek/object_goslice_reflect.go similarity index 97% rename from vendor/github.com/dop251/goja/object_goslice_reflect.go rename to vendor/github.com/grafana/sobek/object_goslice_reflect.go index 4c28d8cd00f..378322a4d2c 100644 --- a/vendor/github.com/dop251/goja/object_goslice_reflect.go +++ b/vendor/github.com/grafana/sobek/object_goslice_reflect.go @@ -1,11 +1,11 @@ -package goja +package sobek import ( "math" "math/bits" "reflect" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) type objectGoSliceReflect struct { diff --git a/vendor/github.com/dop251/goja/object_template.go b/vendor/github.com/grafana/sobek/object_template.go similarity index 99% rename from vendor/github.com/dop251/goja/object_template.go rename to vendor/github.com/grafana/sobek/object_template.go index 6d42f9f9805..fa39133b084 100644 --- a/vendor/github.com/dop251/goja/object_template.go +++ b/vendor/github.com/grafana/sobek/object_template.go @@ -1,8 +1,8 @@ -package goja +package sobek import ( "fmt" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" "math" "reflect" "sort" diff --git a/vendor/github.com/dop251/goja/parser/README.markdown b/vendor/github.com/grafana/sobek/parser/README.markdown similarity index 97% rename from vendor/github.com/dop251/goja/parser/README.markdown rename to vendor/github.com/grafana/sobek/parser/README.markdown index ec1186d4638..3d19db26957 100644 --- a/vendor/github.com/dop251/goja/parser/README.markdown +++ b/vendor/github.com/grafana/sobek/parser/README.markdown @@ -1,11 +1,11 @@ # parser -- - import "github.com/dop251/goja/parser" + import "github.com/grafana/sobek/parser" Package parser implements a parser for JavaScript. Borrowed from https://github.com/robertkrimen/otto/tree/master/parser import ( - "github.com/dop251/goja/parser" + "github.com/grafana/sobek/parser" ) Parse and return an AST diff --git a/vendor/github.com/dop251/goja/parser/error.go b/vendor/github.com/grafana/sobek/parser/error.go similarity index 98% rename from vendor/github.com/dop251/goja/parser/error.go rename to vendor/github.com/grafana/sobek/parser/error.go index cf4d2c3810a..39d61fa7747 100644 --- a/vendor/github.com/dop251/goja/parser/error.go +++ b/vendor/github.com/grafana/sobek/parser/error.go @@ -4,8 +4,8 @@ import ( "fmt" "sort" - "github.com/dop251/goja/file" - "github.com/dop251/goja/token" + "github.com/grafana/sobek/file" + "github.com/grafana/sobek/token" ) const ( diff --git a/vendor/github.com/dop251/goja/parser/expression.go b/vendor/github.com/grafana/sobek/parser/expression.go similarity index 99% rename from vendor/github.com/dop251/goja/parser/expression.go rename to vendor/github.com/grafana/sobek/parser/expression.go index 305bed499fb..74d346a014c 100644 --- a/vendor/github.com/dop251/goja/parser/expression.go +++ b/vendor/github.com/grafana/sobek/parser/expression.go @@ -3,10 +3,10 @@ package parser import ( "strings" - "github.com/dop251/goja/ast" - "github.com/dop251/goja/file" - "github.com/dop251/goja/token" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/ast" + "github.com/grafana/sobek/file" + "github.com/grafana/sobek/token" + "github.com/grafana/sobek/unistring" ) func (self *_parser) parseIdentifier() *ast.Identifier { diff --git a/vendor/github.com/dop251/goja/parser/lexer.go b/vendor/github.com/grafana/sobek/parser/lexer.go similarity index 99% rename from vendor/github.com/dop251/goja/parser/lexer.go rename to vendor/github.com/grafana/sobek/parser/lexer.go index 68d56d20b1b..234d5b963bb 100644 --- a/vendor/github.com/dop251/goja/parser/lexer.go +++ b/vendor/github.com/grafana/sobek/parser/lexer.go @@ -11,9 +11,9 @@ import ( "golang.org/x/text/unicode/rangetable" - "github.com/dop251/goja/file" - "github.com/dop251/goja/token" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/file" + "github.com/grafana/sobek/token" + "github.com/grafana/sobek/unistring" ) var ( diff --git a/vendor/github.com/dop251/goja/parser/parser.go b/vendor/github.com/grafana/sobek/parser/parser.go similarity index 97% rename from vendor/github.com/dop251/goja/parser/parser.go rename to vendor/github.com/grafana/sobek/parser/parser.go index 24b380249f5..9adfe3ab877 100644 --- a/vendor/github.com/dop251/goja/parser/parser.go +++ b/vendor/github.com/grafana/sobek/parser/parser.go @@ -2,7 +2,7 @@ Package parser implements a parser for JavaScript. import ( - "github.com/dop251/goja/parser" + "github.com/grafana/sobek/parser" ) Parse and return an AST @@ -38,10 +38,10 @@ import ( "io" "os" - "github.com/dop251/goja/ast" - "github.com/dop251/goja/file" - "github.com/dop251/goja/token" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/ast" + "github.com/grafana/sobek/file" + "github.com/grafana/sobek/token" + "github.com/grafana/sobek/unistring" ) // A Mode value is a set of flags (or 0). They control optional parser functionality. diff --git a/vendor/github.com/dop251/goja/parser/regexp.go b/vendor/github.com/grafana/sobek/parser/regexp.go similarity index 100% rename from vendor/github.com/dop251/goja/parser/regexp.go rename to vendor/github.com/grafana/sobek/parser/regexp.go diff --git a/vendor/github.com/dop251/goja/parser/scope.go b/vendor/github.com/grafana/sobek/parser/scope.go similarity index 93% rename from vendor/github.com/dop251/goja/parser/scope.go rename to vendor/github.com/grafana/sobek/parser/scope.go index 5e28ef46756..f9936dafbfe 100644 --- a/vendor/github.com/dop251/goja/parser/scope.go +++ b/vendor/github.com/grafana/sobek/parser/scope.go @@ -1,8 +1,8 @@ package parser import ( - "github.com/dop251/goja/ast" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/ast" + "github.com/grafana/sobek/unistring" ) type _scope struct { diff --git a/vendor/github.com/dop251/goja/parser/statement.go b/vendor/github.com/grafana/sobek/parser/statement.go similarity index 99% rename from vendor/github.com/dop251/goja/parser/statement.go rename to vendor/github.com/grafana/sobek/parser/statement.go index 8ec5cdeb770..03e1de46632 100644 --- a/vendor/github.com/dop251/goja/parser/statement.go +++ b/vendor/github.com/grafana/sobek/parser/statement.go @@ -6,10 +6,10 @@ import ( "os" "strings" - "github.com/dop251/goja/ast" - "github.com/dop251/goja/file" - "github.com/dop251/goja/token" "github.com/go-sourcemap/sourcemap" + "github.com/grafana/sobek/ast" + "github.com/grafana/sobek/file" + "github.com/grafana/sobek/token" ) func (self *_parser) parseBlockStatement() *ast.BlockStatement { diff --git a/vendor/github.com/dop251/goja/profiler.go b/vendor/github.com/grafana/sobek/profiler.go similarity index 99% rename from vendor/github.com/dop251/goja/profiler.go rename to vendor/github.com/grafana/sobek/profiler.go index 3d21ad1d95e..01a33b14c96 100644 --- a/vendor/github.com/dop251/goja/profiler.go +++ b/vendor/github.com/grafana/sobek/profiler.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "errors" diff --git a/vendor/github.com/dop251/goja/proxy.go b/vendor/github.com/grafana/sobek/proxy.go similarity index 99% rename from vendor/github.com/dop251/goja/proxy.go rename to vendor/github.com/grafana/sobek/proxy.go index e9bd8c96752..0662cde9d29 100644 --- a/vendor/github.com/dop251/goja/proxy.go +++ b/vendor/github.com/grafana/sobek/proxy.go @@ -1,10 +1,10 @@ -package goja +package sobek import ( "fmt" "reflect" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) // Proxy is a Go wrapper around ECMAScript Proxy. Calling Runtime.ToValue() on it diff --git a/vendor/github.com/dop251/goja/regexp.go b/vendor/github.com/grafana/sobek/regexp.go similarity index 99% rename from vendor/github.com/dop251/goja/regexp.go rename to vendor/github.com/grafana/sobek/regexp.go index 1c3e7e06dad..bdc15a1cb97 100644 --- a/vendor/github.com/dop251/goja/regexp.go +++ b/vendor/github.com/grafana/sobek/regexp.go @@ -1,9 +1,9 @@ -package goja +package sobek import ( "fmt" "github.com/dlclark/regexp2" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" "io" "regexp" "sort" diff --git a/vendor/github.com/dop251/goja/runtime.go b/vendor/github.com/grafana/sobek/runtime.go similarity index 99% rename from vendor/github.com/dop251/goja/runtime.go rename to vendor/github.com/grafana/sobek/runtime.go index e9a500da5a2..c802b4db46f 100644 --- a/vendor/github.com/dop251/goja/runtime.go +++ b/vendor/github.com/grafana/sobek/runtime.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "bytes" @@ -16,10 +16,10 @@ import ( "golang.org/x/text/collate" - js_ast "github.com/dop251/goja/ast" - "github.com/dop251/goja/file" - "github.com/dop251/goja/parser" - "github.com/dop251/goja/unistring" + js_ast "github.com/grafana/sobek/ast" + "github.com/grafana/sobek/file" + "github.com/grafana/sobek/parser" + "github.com/grafana/sobek/unistring" ) const ( @@ -1619,7 +1619,7 @@ func(FunctionCall, *Runtime) Value is treated as above, except the *Runtime is a func(ConstructorCall) *Object is treated as a native constructor, allowing to use it with the new operator: - func MyObject(call goja.ConstructorCall) *goja.Object { + func MyObject(call sobek.ConstructorCall) *sobek.Object { // call.This contains the newly created object as per http://www.ecma-international.org/ecma-262/5.1/index.html#sec-13.2.2 // call.Arguments contain arguments passed to the function @@ -1629,7 +1629,7 @@ operator: // If return value is a non-nil *Object, it will be used instead of call.This // This way it is possible to return a Go struct or a map converted - // into goja.Value using ToValue(), however in this case + // into sobek.Value using ToValue(), however in this case // instanceof will not work as expected, unless you set the prototype: // // instance := &myCustomStruct{} diff --git a/vendor/github.com/dop251/goja/staticcheck.conf b/vendor/github.com/grafana/sobek/staticcheck.conf similarity index 100% rename from vendor/github.com/dop251/goja/staticcheck.conf rename to vendor/github.com/grafana/sobek/staticcheck.conf diff --git a/vendor/github.com/dop251/goja/string.go b/vendor/github.com/grafana/sobek/string.go similarity index 99% rename from vendor/github.com/dop251/goja/string.go rename to vendor/github.com/grafana/sobek/string.go index 632f1e3b547..833bc3aa448 100644 --- a/vendor/github.com/dop251/goja/string.go +++ b/vendor/github.com/grafana/sobek/string.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "io" @@ -6,7 +6,7 @@ import ( "strings" "unicode/utf8" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) const ( diff --git a/vendor/github.com/dop251/goja/string_ascii.go b/vendor/github.com/grafana/sobek/string_ascii.go similarity index 99% rename from vendor/github.com/dop251/goja/string_ascii.go rename to vendor/github.com/grafana/sobek/string_ascii.go index 5ff21bf7b79..df622f41c3a 100644 --- a/vendor/github.com/dop251/goja/string_ascii.go +++ b/vendor/github.com/grafana/sobek/string_ascii.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "hash/maphash" @@ -8,7 +8,7 @@ import ( "strconv" "strings" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) type asciiString string diff --git a/vendor/github.com/dop251/goja/string_imported.go b/vendor/github.com/grafana/sobek/string_imported.go similarity index 98% rename from vendor/github.com/dop251/goja/string_imported.go rename to vendor/github.com/grafana/sobek/string_imported.go index 1c6cae88d09..e61cb77c41d 100644 --- a/vendor/github.com/dop251/goja/string_imported.go +++ b/vendor/github.com/grafana/sobek/string_imported.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "hash/maphash" @@ -9,8 +9,8 @@ import ( "unicode/utf16" "unicode/utf8" - "github.com/dop251/goja/parser" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/parser" + "github.com/grafana/sobek/unistring" "golang.org/x/text/cases" "golang.org/x/text/language" diff --git a/vendor/github.com/dop251/goja/string_unicode.go b/vendor/github.com/grafana/sobek/string_unicode.go similarity index 99% rename from vendor/github.com/dop251/goja/string_unicode.go rename to vendor/github.com/grafana/sobek/string_unicode.go index 49e363fe8f9..b755978cc62 100644 --- a/vendor/github.com/dop251/goja/string_unicode.go +++ b/vendor/github.com/grafana/sobek/string_unicode.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "errors" @@ -10,8 +10,8 @@ import ( "unicode/utf16" "unicode/utf8" - "github.com/dop251/goja/parser" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/parser" + "github.com/grafana/sobek/unistring" "golang.org/x/text/cases" "golang.org/x/text/language" ) diff --git a/vendor/github.com/dop251/goja/token/README.markdown b/vendor/github.com/grafana/sobek/token/README.markdown similarity index 98% rename from vendor/github.com/dop251/goja/token/README.markdown rename to vendor/github.com/grafana/sobek/token/README.markdown index 66dd2abde71..7b643660c13 100644 --- a/vendor/github.com/dop251/goja/token/README.markdown +++ b/vendor/github.com/grafana/sobek/token/README.markdown @@ -1,6 +1,6 @@ # token -- - import "github.com/dop251/goja/token" + import "github.com/grafana/sobek/token" Package token defines constants representing the lexical tokens of JavaScript (ECMA5). diff --git a/vendor/github.com/dop251/goja/token/token.go b/vendor/github.com/grafana/sobek/token/token.go similarity index 100% rename from vendor/github.com/dop251/goja/token/token.go rename to vendor/github.com/grafana/sobek/token/token.go diff --git a/vendor/github.com/dop251/goja/token/token_const.go b/vendor/github.com/grafana/sobek/token/token_const.go similarity index 100% rename from vendor/github.com/dop251/goja/token/token_const.go rename to vendor/github.com/grafana/sobek/token/token_const.go diff --git a/vendor/github.com/dop251/goja/token/tokenfmt b/vendor/github.com/grafana/sobek/token/tokenfmt similarity index 100% rename from vendor/github.com/dop251/goja/token/tokenfmt rename to vendor/github.com/grafana/sobek/token/tokenfmt diff --git a/vendor/github.com/dop251/goja/typedarrays.go b/vendor/github.com/grafana/sobek/typedarrays.go similarity index 99% rename from vendor/github.com/dop251/goja/typedarrays.go rename to vendor/github.com/grafana/sobek/typedarrays.go index 9af03503dbb..cfe19bc66d3 100644 --- a/vendor/github.com/dop251/goja/typedarrays.go +++ b/vendor/github.com/grafana/sobek/typedarrays.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "math" @@ -6,7 +6,7 @@ import ( "strconv" "unsafe" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) type byteOrder bool diff --git a/vendor/github.com/dop251/goja/unistring/string.go b/vendor/github.com/grafana/sobek/unistring/string.go similarity index 100% rename from vendor/github.com/dop251/goja/unistring/string.go rename to vendor/github.com/grafana/sobek/unistring/string.go diff --git a/vendor/github.com/dop251/goja/value.go b/vendor/github.com/grafana/sobek/value.go similarity index 99% rename from vendor/github.com/dop251/goja/value.go rename to vendor/github.com/grafana/sobek/value.go index aeb96762c8f..9faabefbf96 100644 --- a/vendor/github.com/dop251/goja/value.go +++ b/vendor/github.com/grafana/sobek/value.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "fmt" @@ -8,8 +8,8 @@ import ( "strconv" "unsafe" - "github.com/dop251/goja/ftoa" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/ftoa" + "github.com/grafana/sobek/unistring" ) var ( diff --git a/vendor/github.com/dop251/goja/vm.go b/vendor/github.com/grafana/sobek/vm.go similarity index 99% rename from vendor/github.com/dop251/goja/vm.go rename to vendor/github.com/grafana/sobek/vm.go index 30b79331628..8fa60e4c8a3 100644 --- a/vendor/github.com/dop251/goja/vm.go +++ b/vendor/github.com/grafana/sobek/vm.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "fmt" @@ -9,7 +9,7 @@ import ( "sync/atomic" "time" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) const ( diff --git a/vendor/github.com/grafana/xk6-browser/browser/browser_mapping.go b/vendor/github.com/grafana/xk6-browser/browser/browser_mapping.go index bfab5190b31..19569c09cf0 100644 --- a/vendor/github.com/grafana/xk6-browser/browser/browser_mapping.go +++ b/vendor/github.com/grafana/xk6-browser/browser/browser_mapping.go @@ -10,7 +10,7 @@ import ( ) // mapBrowser to the JS module. -func mapBrowser(vu moduleVU) mapping { //nolint:funlen,cyclop +func mapBrowser(vu moduleVU) mapping { //nolint:funlen,cyclop,gocognit return mapping{ "context": func() (mapping, error) { b, err := vu.browser() @@ -36,23 +36,24 @@ func mapBrowser(vu moduleVU) mapping { //nolint:funlen,cyclop return b.IsConnected(), nil }, "newContext": func(opts sobek.Value) (*sobek.Promise, error) { + popts := common.NewBrowserContextOptions() + if err := popts.Parse(vu.Context(), opts); err != nil { + return nil, fmt.Errorf("parsing browser.newContext options: %w", err) + } return k6ext.Promise(vu.Context(), func() (any, error) { b, err := vu.browser() if err != nil { return nil, err } - bctx, err := b.NewContext(opts) + bctx, err := b.NewContext(popts) if err != nil { return nil, err //nolint:wrapcheck } - if err := initBrowserContext(bctx, vu.testRunID); err != nil { return nil, err } - m := mapBrowserContext(vu, bctx) - - return m, nil + return mapBrowserContext(vu, bctx), nil }), nil }, "userAgent": func() (string, error) { @@ -69,23 +70,26 @@ func mapBrowser(vu moduleVU) mapping { //nolint:funlen,cyclop } return b.Version(), nil }, - "newPage": func(opts sobek.Value) *sobek.Promise { + "newPage": func(opts sobek.Value) (*sobek.Promise, error) { + popts := common.NewBrowserContextOptions() + if err := popts.Parse(vu.Context(), opts); err != nil { + return nil, fmt.Errorf("parsing browser.newPage options: %w", err) + } return k6ext.Promise(vu.Context(), func() (any, error) { b, err := vu.browser() if err != nil { return nil, err } - page, err := b.NewPage(opts) + page, err := b.NewPage(popts) if err != nil { return nil, err //nolint:wrapcheck } - if err := initBrowserContext(b.Context(), vu.testRunID); err != nil { return nil, err } return mapPage(vu, page), nil - }) + }), nil }, } } diff --git a/vendor/github.com/grafana/xk6-browser/browser/sync_browser_mapping.go b/vendor/github.com/grafana/xk6-browser/browser/sync_browser_mapping.go index 400e31ca64b..689e610a1bc 100644 --- a/vendor/github.com/grafana/xk6-browser/browser/sync_browser_mapping.go +++ b/vendor/github.com/grafana/xk6-browser/browser/sync_browser_mapping.go @@ -1,7 +1,11 @@ package browser import ( + "fmt" + "github.com/grafana/sobek" + + "github.com/grafana/xk6-browser/common" ) // syncMapBrowser is like mapBrowser but returns synchronous functions. @@ -30,11 +34,16 @@ func syncMapBrowser(vu moduleVU) mapping { //nolint:funlen,cyclop return b.IsConnected(), nil }, "newContext": func(opts sobek.Value) (*sobek.Object, error) { + popts := common.NewBrowserContextOptions() + if err := popts.Parse(vu.Context(), opts); err != nil { + return nil, fmt.Errorf("parsing browser.newContext options: %w", err) + } + b, err := vu.browser() if err != nil { return nil, err } - bctx, err := b.NewContext(opts) + bctx, err := b.NewContext(popts) if err != nil { return nil, err //nolint:wrapcheck } @@ -62,11 +71,16 @@ func syncMapBrowser(vu moduleVU) mapping { //nolint:funlen,cyclop return b.Version(), nil }, "newPage": func(opts sobek.Value) (mapping, error) { + popts := common.NewBrowserContextOptions() + if err := popts.Parse(vu.Context(), opts); err != nil { + return nil, fmt.Errorf("parsing browser.newContext options: %w", err) + } + b, err := vu.browser() if err != nil { return nil, err } - page, err := b.NewPage(opts) + page, err := b.NewPage(popts) if err != nil { return nil, err //nolint:wrapcheck } diff --git a/vendor/github.com/grafana/xk6-browser/common/browser.go b/vendor/github.com/grafana/xk6-browser/common/browser.go index c1b9bc98c3b..c8e617c0cc8 100644 --- a/vendor/github.com/grafana/xk6-browser/common/browser.go +++ b/vendor/github.com/grafana/xk6-browser/common/browser.go @@ -14,7 +14,6 @@ import ( "github.com/chromedp/cdproto/cdp" "github.com/chromedp/cdproto/target" "github.com/gorilla/websocket" - "github.com/grafana/sobek" "github.com/grafana/xk6-browser/k6ext" "github.com/grafana/xk6-browser/log" @@ -569,7 +568,7 @@ func (b *Browser) IsConnected() bool { } // NewContext creates a new incognito-like browser context. -func (b *Browser) NewContext(opts sobek.Value) (*BrowserContext, error) { +func (b *Browser) NewContext(opts *BrowserContextOptions) (*BrowserContext, error) { _, span := TraceAPICall(b.ctx, "", "browser.newContext") defer span.End() @@ -588,14 +587,7 @@ func (b *Browser) NewContext(opts sobek.Value) (*BrowserContext, error) { return nil, err } - browserCtxOpts := NewBrowserContextOptions() - if err := browserCtxOpts.Parse(b.ctx, opts); err != nil { - err := fmt.Errorf("parsing newContext options: %w", err) - spanRecordError(span, err) - return nil, err - } - - browserCtx, err := NewBrowserContext(b.ctx, b, browserContextID, browserCtxOpts, b.logger) + browserCtx, err := NewBrowserContext(b.ctx, b, browserContextID, opts, b.logger) if err != nil { err := fmt.Errorf("new context: %w", err) spanRecordError(span, err) @@ -610,7 +602,7 @@ func (b *Browser) NewContext(opts sobek.Value) (*BrowserContext, error) { } // NewPage creates a new tab in the browser window. -func (b *Browser) NewPage(opts sobek.Value) (*Page, error) { +func (b *Browser) NewPage(opts *BrowserContextOptions) (*Page, error) { _, span := TraceAPICall(b.ctx, "", "browser.newPage") defer span.End() diff --git a/vendor/github.com/grafana/xk6-browser/common/browser_context.go b/vendor/github.com/grafana/xk6-browser/common/browser_context.go index 30a10a89aea..b2a0ef8ab70 100644 --- a/vendor/github.com/grafana/xk6-browser/common/browser_context.go +++ b/vendor/github.com/grafana/xk6-browser/common/browser_context.go @@ -90,6 +90,11 @@ type BrowserContext struct { func NewBrowserContext( ctx context.Context, browser *Browser, id cdp.BrowserContextID, opts *BrowserContextOptions, logger *log.Logger, ) (*BrowserContext, error) { + // set the default options if none provided. + if opts == nil { + opts = NewBrowserContextOptions() + } + b := BrowserContext{ BaseEventEmitter: NewBaseEventEmitter(ctx), ctx: ctx, @@ -101,7 +106,7 @@ func NewBrowserContext( timeoutSettings: NewTimeoutSettings(nil), } - if opts != nil && len(opts.Permissions) > 0 { + if len(opts.Permissions) > 0 { err := b.GrantPermissions(opts.Permissions, NewGrantPermissionsOptions()) if err != nil { return nil, err diff --git a/vendor/github.com/grafana/xk6-browser/common/helpers.go b/vendor/github.com/grafana/xk6-browser/common/helpers.go index 8ff709a2903..64eb1e32866 100644 --- a/vendor/github.com/grafana/xk6-browser/common/helpers.go +++ b/vendor/github.com/grafana/xk6-browser/common/helpers.go @@ -144,16 +144,25 @@ func createWaitForEventHandler( if stringSliceContains(events, ev.typ) { if predicateFn != nil { if predicateFn(ev.data) { - ch <- ev.data + select { + case ch <- ev.data: + case <-evCancelCtx.Done(): + return + } } } else { - ch <- nil + select { + case ch <- nil: + case <-evCancelCtx.Done(): + return + } } close(ch) // We wait for one matching event only, // then remove event handler by cancelling context and stopping goroutine. evCancelFn() + return } } @@ -185,9 +194,12 @@ func createWaitForEventPredicateHandler( case ev := <-chEvHandler: if stringSliceContains(events, ev.typ) && predicateFn != nil && predicateFn(ev.data) { - ch <- ev.data - close(ch) - evCancelFn() + select { + case ch <- ev.data: + close(ch) + evCancelFn() + case <-evCancelCtx.Done(): + } return } } diff --git a/vendor/github.com/grafana/xk6-dashboard/dashboard/customize.go b/vendor/github.com/grafana/xk6-dashboard/dashboard/customize.go index 78cd4e90861..e900cf69bf2 100644 --- a/vendor/github.com/grafana/xk6-dashboard/dashboard/customize.go +++ b/vendor/github.com/grafana/xk6-dashboard/dashboard/customize.go @@ -6,30 +6,14 @@ package dashboard import ( "encoding/json" - "errors" - "fmt" "io" - "path/filepath" - "reflect" - "strings" - "github.com/grafana/sobek" - "github.com/sirupsen/logrus" - "go.k6.io/k6/js/compiler" - "go.k6.io/k6/lib" "go.k6.io/k6/lib/fsext" ) -const ( - defaultConfig = ".dashboard.js" - defaultAltConfig = ".dashboard.json" -) +const defaultAltConfig = ".dashboard.json" func findDefaultConfig(fs fsext.Fs) string { - if exists(fs, defaultConfig) { - return defaultConfig - } - if exists(fs, defaultAltConfig) { return defaultAltConfig } @@ -46,11 +30,7 @@ func customize(uiConfig json.RawMessage, proc *process) (json.RawMessage, error) } } - if filepath.Ext(filename) == ".json" { - return loadConfigJSON(filename, proc) - } - - return loadConfigJS(filename, uiConfig, proc) + return loadConfigJSON(filename, proc) } func loadConfigJSON(filename string, proc *process) (json.RawMessage, error) { @@ -80,222 +60,3 @@ func exists(fs fsext.Fs, filename string) bool { return true } - -type configLoader struct { - runtime *sobek.Runtime - compiler *compiler.Compiler - defaultConfig *sobek.Object - proc *process -} - -func newConfigLoader(defaultConfig json.RawMessage, proc *process) (*configLoader, error) { - comp := compiler.New(proc.logger) - - comp.Options.CompatibilityMode = lib.CompatibilityModeExtended - comp.Options.Strict = true - - con := newConfigConsole(proc.logger) - - runtime := sobek.New() - - runtime.SetFieldNameMapper(sobek.UncapFieldNameMapper()) - - if err := runtime.Set("console", con); err != nil { - return nil, err - } - - def, err := toObject(runtime, defaultConfig) - if err != nil { - return nil, err - } - - loader := &configLoader{ - runtime: runtime, - compiler: comp, - defaultConfig: def, - proc: proc, - } - - return loader, nil -} - -func (loader *configLoader) load(filename string) (json.RawMessage, error) { - file, err := loader.proc.fs.Open(filename) - if err != nil { - return nil, err - } - - src, err := io.ReadAll(file) - if err != nil { - return nil, err - } - - val, err := loader.eval(src, filename) - if err != nil { - return nil, err - } - - obj := val.ToObject(loader.runtime) - - return obj.MarshalJSON() -} - -func isObject(val sobek.Value) bool { - return val != nil && val.ExportType() != nil && val.ExportType().Kind() == reflect.Map -} - -func (loader *configLoader) eval(src []byte, filename string) (*sobek.Object, error) { - prog, _, err := loader.compiler.Compile(string(src), filename, false) - if err != nil { - return nil, err - } - - exports := loader.runtime.NewObject() - module := loader.runtime.NewObject() - - if err = module.Set("exports", exports); err != nil { - return nil, err - } - - val, err := loader.runtime.RunProgram(prog) - if err != nil { - return nil, err - } - - call, isCallable := sobek.AssertFunction(val) - if !isCallable { - return nil, fmt.Errorf("%w, file: %s", errNotFunction, filename) - } - - _, err = call(exports, module, exports) - if err != nil { - return nil, err - } - - def := exports.Get("default") - if def == nil { - return nil, fmt.Errorf("%w, file: %s", errNoExport, filename) - } - - if call, isCallable = sobek.AssertFunction(def); isCallable { - def, err = call(exports, loader.defaultConfig) - if err != nil { - return nil, err - } - - if !isObject(def) { - return nil, errConfigNotObject - } - } - - return def.ToObject(loader.runtime), nil -} - -// toObject use JavaScript JSON.parse to create native goja object -// there could be a better solution.... (but Object.UnmarshallJSON is missing). -func toObject(runtime *sobek.Runtime, bin json.RawMessage) (*sobek.Object, error) { - val := runtime.Get("JSON").ToObject(runtime).Get("parse") - - call, _ := sobek.AssertFunction(val) - - val, err := call(runtime.GlobalObject(), runtime.ToValue(string(bin))) - if err != nil { - return nil, err - } - - return val.ToObject(runtime), nil -} - -func loadConfigJS( - filename string, - config json.RawMessage, - proc *process, -) (json.RawMessage, error) { - loader, err := newConfigLoader(config, proc) - if err != nil { - return nil, err - } - - return loader.load(filename) -} - -// configConsole represents a JS configConsole implemented as a logrus.Logger. -type configConsole struct { - logger logrus.FieldLogger -} - -// Creates a console with the standard logrus logger. -func newConfigConsole(logger logrus.FieldLogger) *configConsole { - return &configConsole{logger.WithField("source", "console").WithField("extension", "dashboard")} -} - -func (c configConsole) log(level logrus.Level, args ...sobek.Value) { - var strs strings.Builder - - for i := 0; i < len(args); i++ { - if i > 0 { - strs.WriteString(" ") - } - - strs.WriteString(c.valueString(args[i])) - } - - msg := strs.String() - - switch level { - case logrus.DebugLevel: - c.logger.Debug(msg) - - case logrus.InfoLevel: - c.logger.Info(msg) - - case logrus.WarnLevel: - c.logger.Warn(msg) - - case logrus.ErrorLevel: - c.logger.Error(msg) - - default: - c.logger.Info(msg) - } -} - -func (c configConsole) Log(args ...sobek.Value) { - c.Info(args...) -} - -func (c configConsole) Debug(args ...sobek.Value) { - c.log(logrus.DebugLevel, args...) -} - -func (c configConsole) Info(args ...sobek.Value) { - c.log(logrus.InfoLevel, args...) -} - -func (c configConsole) Warn(args ...sobek.Value) { - c.log(logrus.WarnLevel, args...) -} - -func (c configConsole) Error(args ...sobek.Value) { - c.log(logrus.ErrorLevel, args...) -} - -func (c configConsole) valueString(value sobek.Value) string { - mv, ok := value.(json.Marshaler) - if !ok { - return value.String() - } - - bin, err := json.Marshal(mv) - if err != nil { - return value.String() - } - - return string(bin) -} - -var ( - errNotFunction = errors.New("not a function") - errNoExport = errors.New("missing default export") - errConfigNotObject = errors.New("returned configuration is not an object") -) diff --git a/vendor/github.com/grafana/xk6-websockets/websockets/blob.go b/vendor/github.com/grafana/xk6-websockets/websockets/blob.go new file mode 100644 index 00000000000..9c36acc80b2 --- /dev/null +++ b/vendor/github.com/grafana/xk6-websockets/websockets/blob.go @@ -0,0 +1,192 @@ +package websockets + +import ( + "bytes" + "errors" + "fmt" + "strconv" + "unsafe" + + "github.com/grafana/sobek" + + "go.k6.io/k6/js/common" + "go.k6.io/k6/js/modules/k6/experimental/streams" +) + +type blob struct { + typ string + data bytes.Buffer +} + +func (b *blob) text() string { + return b.data.String() +} + +func (r *WebSocketsAPI) blob(call sobek.ConstructorCall) *sobek.Object { + rt := r.vu.Runtime() + + b := &blob{} + var blobParts []interface{} + if len(call.Arguments) > 0 { + if err := rt.ExportTo(call.Arguments[0], &blobParts); err != nil { + common.Throw(rt, fmt.Errorf("failed to process [blobParts]: %w", err)) + } + } + + if len(blobParts) > 0 { + r.fillData(b, blobParts, call) + } + + if len(call.Arguments) > 1 && !sobek.IsUndefined(call.Arguments[1]) { + opts := call.Arguments[1] + if !isObject(opts) { + common.Throw(rt, errors.New("[options] must be an object")) + } + + typeOpt := opts.ToObject(rt).Get("type") + if !sobek.IsUndefined(typeOpt) { + b.typ = typeOpt.String() + } + } + + obj := rt.NewObject() + must(rt, obj.DefineAccessorProperty("size", rt.ToValue(func() sobek.Value { + return rt.ToValue(b.data.Len()) + }), nil, sobek.FLAG_FALSE, sobek.FLAG_TRUE)) + must(rt, obj.DefineAccessorProperty("type", rt.ToValue(func() sobek.Value { + return rt.ToValue(b.typ) + }), nil, sobek.FLAG_FALSE, sobek.FLAG_TRUE)) + + must(rt, obj.Set("arrayBuffer", func(_ sobek.FunctionCall) sobek.Value { + promise, resolve, _ := rt.NewPromise() + resolve(rt.NewArrayBuffer(b.data.Bytes())) + return rt.ToValue(promise) + })) + must(rt, obj.Set("bytes", func(_ sobek.FunctionCall) sobek.Value { + promise, resolve, reject := rt.NewPromise() + data, err := rt.New(rt.Get("Uint8Array"), rt.ToValue(b.data.Bytes())) + if err == nil { + resolve(data) + } else { + reject(fmt.Errorf("failed to create Uint8Array: %w", err)) + } + return rt.ToValue(promise) + })) + must(rt, obj.Set("slice", func(call sobek.FunctionCall) sobek.Value { + return r.slice(call, b, rt) + })) + must(rt, obj.Set("text", func(_ sobek.FunctionCall) sobek.Value { + promise, resolve, _ := rt.NewPromise() + resolve(b.text()) + return rt.ToValue(promise) + })) + must(rt, obj.Set("stream", func(_ sobek.FunctionCall) sobek.Value { + return rt.ToValue(streams.NewReadableStreamFromReader(r.vu, &b.data)) + })) + + proto := call.This.Prototype() + must(rt, proto.Set("toString", func(_ sobek.FunctionCall) sobek.Value { + return rt.ToValue("[object Blob]") + })) + must(rt, obj.SetPrototype(proto)) + + return obj +} + +func (r *WebSocketsAPI) fillData(b *blob, blobParts []interface{}, call sobek.ConstructorCall) { + rt := r.vu.Runtime() + + if len(blobParts) > 0 { + for n, part := range blobParts { + var err error + switch v := part.(type) { + case []uint8: + _, err = b.data.Write(v) + case []int8, []int16, []int32, []int64, []uint16, []uint32, []uint64, []float32, []float64: + _, err = b.data.Write(toByteSlice(v)) + case sobek.ArrayBuffer: + _, err = b.data.Write(v.Bytes()) + case *sobek.ArrayBuffer: + _, err = b.data.Write(v.Bytes()) + case string: + _, err = b.data.WriteString(v) + case map[string]interface{}: + obj := call.Arguments[0].ToObject(rt).Get(strconv.FormatInt(int64(n), 10)).ToObject(rt) + switch { + case isDataView(obj, rt): + _, err = b.data.Write(obj.Get("buffer").Export().(sobek.ArrayBuffer).Bytes()) + case isBlob(obj, r.blobConstructor): + _, err = b.data.Write(extractBytes(obj, rt)) + default: + err = fmt.Errorf("unsupported type: %T", part) + } + default: + err = fmt.Errorf("unsupported type: %T", part) + } + if err != nil { + common.Throw(rt, fmt.Errorf("failed to process [blobParts]: %w", err)) + } + } + } +} + +func (r *WebSocketsAPI) slice(call sobek.FunctionCall, b *blob, rt *sobek.Runtime) sobek.Value { + var ( + from int + to = b.data.Len() + ct = "" + ) + + if len(call.Arguments) > 0 { + from = int(call.Arguments[0].ToInteger()) + } + + if len(call.Arguments) > 1 { + to = int(call.Arguments[1].ToInteger()) + if to < 0 { + to = b.data.Len() + to + } + } + + if len(call.Arguments) > 2 { + ct = call.Arguments[2].String() + } + + opts := rt.NewObject() + must(rt, opts.Set("type", ct)) + + sliced, err := rt.New(r.blobConstructor, rt.ToValue([]interface{}{b.data.Bytes()[from:to]}), opts) + must(rt, err) + + return sliced +} + +// toByteSlice converts a slice of numbers to a slice of bytes. +// +//nolint:gosec +func toByteSlice(data interface{}) []byte { + switch v := data.(type) { + case []int8: + return unsafe.Slice((*byte)(unsafe.Pointer(&v[0])), len(v)) + case []uint16: + return unsafe.Slice((*byte)(unsafe.Pointer(&v[0])), len(v)*2) + case []int16: + return unsafe.Slice((*byte)(unsafe.Pointer(&v[0])), len(v)*2) + case []uint32: + return unsafe.Slice((*byte)(unsafe.Pointer(&v[0])), len(v)*4) + case []int32: + return unsafe.Slice((*byte)(unsafe.Pointer(&v[0])), len(v)*4) + case []uint64: + return unsafe.Slice((*byte)(unsafe.Pointer(&v[0])), len(v)*8) + case []int64: + return unsafe.Slice((*byte)(unsafe.Pointer(&v[0])), len(v)*8) + case []float32: + return unsafe.Slice((*byte)(unsafe.Pointer(&v[0])), len(v)*4) + case []float64: + return unsafe.Slice((*byte)(unsafe.Pointer(&v[0])), len(v)*8) + default: + // this should never happen + common.Throw(nil, fmt.Errorf("unsupported type: %T", data)) + return nil + } +} diff --git a/vendor/github.com/grafana/xk6-websockets/websockets/helpers.go b/vendor/github.com/grafana/xk6-websockets/websockets/helpers.go index 282b45f754e..a03889806b1 100644 --- a/vendor/github.com/grafana/xk6-websockets/websockets/helpers.go +++ b/vendor/github.com/grafana/xk6-websockets/websockets/helpers.go @@ -1,6 +1,10 @@ package websockets import ( + "errors" + "fmt" + "reflect" + "github.com/grafana/sobek" "go.k6.io/k6/js/common" ) @@ -11,3 +15,51 @@ func must(rt *sobek.Runtime, err error) { common.Throw(rt, err) } } + +func isString(o *sobek.Object, rt *sobek.Runtime) bool { + return o.Prototype().Get("constructor") == rt.GlobalObject().Get("String") +} + +func isArray(o *sobek.Object, rt *sobek.Runtime) bool { + return o.Prototype().Get("constructor") == rt.GlobalObject().Get("Array") +} + +func isUint8Array(o *sobek.Object, rt *sobek.Runtime) bool { + return o.Prototype().Get("constructor") == rt.GlobalObject().Get("Uint8Array") +} + +func isDataView(o *sobek.Object, rt *sobek.Runtime) bool { + return o.Prototype().Get("constructor") == rt.GlobalObject().Get("DataView") +} + +func isBlob(o *sobek.Object, blobConstructor sobek.Value) bool { + return o.Prototype().Get("constructor") == blobConstructor +} + +func isObject(val sobek.Value) bool { + return val != nil && val.ExportType() != nil && val.ExportType().Kind() == reflect.Map +} + +func extractBytes(o *sobek.Object, rt *sobek.Runtime) []byte { + arrayBuffer, ok := sobek.AssertFunction(o.Get("arrayBuffer")) + if !ok { + common.Throw(rt, errors.New("Blob.[arrayBuffer] is not a function")) + } + + buffer, err := arrayBuffer(sobek.Undefined()) + if err != nil { + common.Throw(rt, fmt.Errorf("call to Blob.[arrayBuffer] failed: %w", err)) + } + + p, ok := buffer.Export().(*sobek.Promise) + if !ok { + common.Throw(rt, errors.New("Blob.[arrayBuffer] return is not a Promise")) + } + + ab, ok := p.Result().Export().(sobek.ArrayBuffer) + if !ok { + common.Throw(rt, errors.New("Blob.[arrayBuffer] promise's return is not an ArrayBuffer")) + } + + return ab.Bytes() +} diff --git a/vendor/github.com/grafana/xk6-websockets/websockets/websockets.go b/vendor/github.com/grafana/xk6-websockets/websockets/websockets.go index 008d40fe100..0fd751acd13 100644 --- a/vendor/github.com/grafana/xk6-websockets/websockets/websockets.go +++ b/vendor/github.com/grafana/xk6-websockets/websockets/websockets.go @@ -28,7 +28,8 @@ type RootModule struct{} // WebSocketsAPI is the k6 extension implementing the websocket API as defined in https://websockets.spec.whatwg.org type WebSocketsAPI struct { //nolint:revive - vu modules.VU + vu modules.VU + blobConstructor sobek.Value } var _ modules.Module = &RootModule{} @@ -42,9 +43,11 @@ func (r *RootModule) NewModuleInstance(vu modules.VU) modules.Instance { // Exports implements the modules.Instance interface's Exports func (r *WebSocketsAPI) Exports() modules.Exports { + r.blobConstructor = r.vu.Runtime().ToValue(r.blob) return modules.Exports{ Named: map[string]interface{}{ "WebSocket": r.websocket, + "Blob": r.blobConstructor, }, } } @@ -64,7 +67,9 @@ const ( ) type webSocket struct { - vu modules.VU + vu modules.VU + blobConstructor sobek.Value + url *url.URL conn *websocket.Conn tagsAndMeta *metrics.TagsAndMeta @@ -93,14 +98,6 @@ type ping struct { timestamps map[string]time.Time } -func isString(o *sobek.Object, rt *sobek.Runtime) bool { - return o.Prototype().Get("constructor") == rt.GlobalObject().Get("String") -} - -func isArray(o *sobek.Object, rt *sobek.Runtime) bool { - return o.Prototype().Get("constructor") == rt.GlobalObject().Get("Array") -} - func (r *WebSocketsAPI) websocket(c sobek.ConstructorCall) *sobek.Object { rt := r.vu.Runtime() @@ -128,17 +125,18 @@ func (r *WebSocketsAPI) websocket(c sobek.ConstructorCall) *sobek.Object { } w := &webSocket{ - vu: r.vu, - url: url, - tq: taskqueue.New(r.vu.RegisterCallback), - readyState: CONNECTING, - builtinMetrics: r.vu.State().BuiltinMetrics, - done: make(chan struct{}), - writeQueueCh: make(chan message), - eventListeners: newEventListeners(), - obj: rt.NewObject(), - tagsAndMeta: params.tagsAndMeta, - sendPings: ping{timestamps: make(map[string]time.Time)}, + vu: r.vu, + blobConstructor: r.blobConstructor, + url: url, + tq: taskqueue.New(r.vu.RegisterCallback), + readyState: CONNECTING, + builtinMetrics: r.vu.State().BuiltinMetrics, + done: make(chan struct{}), + writeQueueCh: make(chan message), + eventListeners: newEventListeners(), + obj: rt.NewObject(), + tagsAndMeta: params.tagsAndMeta, + sendPings: ping{timestamps: make(map[string]time.Time)}, } // Maybe have this after the goroutine below ?!? @@ -203,13 +201,11 @@ func defineWebsocket(rt *sobek.Runtime, w *webSocket) { return rt.ToValue(w.binaryType) }), rt.ToValue(func(s string) error { switch s { - case blobBinaryType: - return errors.New("blob is currently not supported, only arraybuffer is") - case arraybufferBinaryType: + case blobBinaryType, arraybufferBinaryType: w.binaryType = s return nil default: - return fmt.Errorf("unknown binaryType %s, the supported one is arraybuffer", s) + return fmt.Errorf(`unknown binaryType %s, the supported ones are "blob" and "arraybuffer"`, s) } }), sobek.FLAG_FALSE, sobek.FLAG_TRUE)) @@ -425,8 +421,9 @@ func (w *webSocket) loop() { } } -const binarytypeWarning = `You have not set a Websocket binaryType to "arraybuffer", but you got a binary response. ` + - `This has been done automatically now, but in the future this will not work.` +const binarytypeError = `websocket's binaryType hasn't been set to either "blob" or "arraybuffer", ` + + `but a binary message has been received. ` + + `"blob" is still not the default so the websocket is erroring out` func (w *webSocket) queueMessage(msg *message) { w.tq.Queue(func() error { @@ -448,13 +445,25 @@ func (w *webSocket) queueMessage(msg *message) { ev := w.newEvent(events.MESSAGE, msg.t) if msg.mtype == websocket.BinaryMessage { - if w.binaryType == "" { - w.binaryType = arraybufferBinaryType - w.vu.State().Logger.Warn(binarytypeWarning) + var data any + // Lets error out for a k6 release, at least, when there's no binaryType set. + // In the future, we'll use "blob" as default, as per spec: + // https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/binaryType + switch w.binaryType { + case "": + return errors.New(binarytypeError) + case blobBinaryType: + var err error + data, err = rt.New(w.blobConstructor, rt.ToValue([]interface{}{msg.data})) + if err != nil { + return fmt.Errorf("failed to create Blob: %w", err) + } + case arraybufferBinaryType: + data = rt.NewArrayBuffer(msg.data) + default: + return fmt.Errorf(`unknown binaryType %s, the supported ones are "blob" and "arraybuffer"`, w.binaryType) } - // TODO this technically could be BLOB , but we don't support that - ab := rt.NewArrayBuffer(msg.data) - must(rt, ev.DefineDataProperty("data", rt.ToValue(ab), sobek.FLAG_FALSE, sobek.FLAG_FALSE, sobek.FLAG_TRUE)) + must(rt, ev.DefineDataProperty("data", rt.ToValue(data), sobek.FLAG_FALSE, sobek.FLAG_FALSE, sobek.FLAG_TRUE)) } else { must( rt, @@ -615,6 +624,21 @@ func (w *webSocket) send(msg sobek.Value) { data: b, t: time.Now(), } + case map[string]interface{}: + rt := w.vu.Runtime() + obj := msg.ToObject(rt) + if !isBlob(obj, w.blobConstructor) { + common.Throw(rt, fmt.Errorf("unsupported send type %T", o)) + } + + b := extractBytes(obj, rt) + w.bufferedAmount += len(b) + w.writeQueueCh <- message{ + mtype: websocket.BinaryMessage, + data: b, + t: time.Now(), + } + default: common.Throw(w.vu.Runtime(), fmt.Errorf("unsupported send type %T", o)) } diff --git a/vendor/github.com/jhump/protoreflect/desc/cache.go b/vendor/github.com/jhump/protoreflect/desc/cache.go index e67cf494e10..418632b7dec 100644 --- a/vendor/github.com/jhump/protoreflect/desc/cache.go +++ b/vendor/github.com/jhump/protoreflect/desc/cache.go @@ -46,12 +46,3 @@ func (c mapCache) get(d protoreflect.Descriptor) Descriptor { func (c mapCache) put(key protoreflect.Descriptor, val Descriptor) { c[key] = val } - -type noopCache struct{} - -func (noopCache) get(protoreflect.Descriptor) Descriptor { - return nil -} - -func (noopCache) put(protoreflect.Descriptor, Descriptor) { -} diff --git a/vendor/github.com/jhump/protoreflect/desc/convert.go b/vendor/github.com/jhump/protoreflect/desc/convert.go index 9aa72a328ae..01a6e9ea4f3 100644 --- a/vendor/github.com/jhump/protoreflect/desc/convert.go +++ b/vendor/github.com/jhump/protoreflect/desc/convert.go @@ -95,9 +95,7 @@ func convertFile(d protoreflect.FileDescriptor, fd *descriptorpb.FileDescriptorP ret.deps = make([]*FileDescriptor, len(fd.GetDependency())) for i := 0; i < d.Imports().Len(); i++ { f := d.Imports().Get(i).FileDescriptor - if c := cache.get(f); c != nil { - ret.deps[i] = c.(*FileDescriptor) - } else if c, err := wrapFile(f, cache); err != nil { + if c, err := wrapFile(f, cache); err != nil { return nil, err } else { ret.deps[i] = c diff --git a/vendor/github.com/jhump/protoreflect/desc/descriptor.go b/vendor/github.com/jhump/protoreflect/desc/descriptor.go index 6903a3ab831..38b8f51ba99 100644 --- a/vendor/github.com/jhump/protoreflect/desc/descriptor.go +++ b/vendor/github.com/jhump/protoreflect/desc/descriptor.go @@ -155,10 +155,22 @@ func (fd *FileDescriptor) String() string { } // IsProto3 returns true if the file declares a syntax of "proto3". +// +// When this returns false, the file is either syntax "proto2" (if +// Edition() returns zero) or the file uses editions. func (fd *FileDescriptor) IsProto3() bool { return fd.wrapped.Syntax() == protoreflect.Proto3 } +// Edition returns the edition of the file. If the file does not +// use editions syntax, zero is returned. +func (fd *FileDescriptor) Edition() descriptorpb.Edition { + if fd.wrapped.Syntax() == protoreflect.Editions { + return fd.proto.GetEdition() + } + return 0 +} + // GetDependencies returns all of this file's dependencies. These correspond to // import statements in the file. func (fd *FileDescriptor) GetDependencies() []*FileDescriptor { diff --git a/vendor/github.com/jhump/protoreflect/desc/internal/util.go b/vendor/github.com/jhump/protoreflect/desc/internal/util.go index fcadbd1f459..595c8720e34 100644 --- a/vendor/github.com/jhump/protoreflect/desc/internal/util.go +++ b/vendor/github.com/jhump/protoreflect/desc/internal/util.go @@ -54,6 +54,9 @@ const ( // File_syntaxTag is the tag number of the syntax element in a file // descriptor proto. File_syntaxTag = 12 + // File_editionTag is the tag number of the edition element in a file + // descriptor proto. + File_editionTag = 14 // Message_nameTag is the tag number of the name element in a message // descriptor proto. Message_nameTag = 1 diff --git a/vendor/github.com/jhump/protoreflect/desc/load.go b/vendor/github.com/jhump/protoreflect/desc/load.go index 193bbe887a7..8776ab0b9b8 100644 --- a/vendor/github.com/jhump/protoreflect/desc/load.go +++ b/vendor/github.com/jhump/protoreflect/desc/load.go @@ -53,13 +53,6 @@ func LoadFileDescriptor(file string) (*FileDescriptor, error) { var fd *FileDescriptor loadedDescriptors.withLock(func(cache descriptorCache) { - // double-check cache, in case it was concurrently added while - // we were waiting for the lock - f := cache.get(d) - if f != nil { - fd = f.(*FileDescriptor) - return - } fd, err = wrapFile(d, cache) }) return fd, err diff --git a/vendor/github.com/jhump/protoreflect/desc/protoparse/parser.go b/vendor/github.com/jhump/protoreflect/desc/protoparse/parser.go index 0ab9d1b8972..1a6763dfa42 100644 --- a/vendor/github.com/jhump/protoreflect/desc/protoparse/parser.go +++ b/vendor/github.com/jhump/protoreflect/desc/protoparse/parser.go @@ -40,7 +40,12 @@ func FileContentsFromMap(files map[string]string) FileAccessor { return func(filename string) (io.ReadCloser, error) { contents, ok := files[filename] if !ok { - return nil, os.ErrNotExist + // Try changing path separators since user-provided + // map may use different separators. + contents, ok = files[filepath.ToSlash(filename)] + if !ok { + return nil, os.ErrNotExist + } } return ioutil.NopCloser(strings.NewReader(contents)), nil } diff --git a/vendor/github.com/jhump/protoreflect/desc/sourceinfo/wrappers.go b/vendor/github.com/jhump/protoreflect/desc/sourceinfo/wrappers.go index 8cbb5bbb2f2..3106eaad2fe 100644 --- a/vendor/github.com/jhump/protoreflect/desc/sourceinfo/wrappers.go +++ b/vendor/github.com/jhump/protoreflect/desc/sourceinfo/wrappers.go @@ -2,7 +2,6 @@ package sourceinfo import ( "fmt" - "google.golang.org/protobuf/reflect/protoreflect" ) @@ -16,6 +15,14 @@ type fileDescriptor struct { locs protoreflect.SourceLocations } +func (f fileDescriptor) Edition() int32 { + ed, ok := f.FileDescriptor.(interface{ Edition() int32 }) + if ok { + return ed.Edition() + } + return 0 +} + func (f fileDescriptor) ParentFile() protoreflect.FileDescriptor { return f } diff --git a/vendor/github.com/jhump/protoreflect/desc/wrap.go b/vendor/github.com/jhump/protoreflect/desc/wrap.go index 82610a45571..5491afda1e8 100644 --- a/vendor/github.com/jhump/protoreflect/desc/wrap.go +++ b/vendor/github.com/jhump/protoreflect/desc/wrap.go @@ -21,7 +21,7 @@ type DescriptorWrapper interface { // WrapDescriptor wraps the given descriptor, returning a desc.Descriptor // value that represents the same element. func WrapDescriptor(d protoreflect.Descriptor) (Descriptor, error) { - return wrapDescriptor(d, noopCache{}) + return wrapDescriptor(d, mapCache{}) } func wrapDescriptor(d protoreflect.Descriptor, cache descriptorCache) (Descriptor, error) { @@ -65,10 +65,13 @@ func WrapFiles(d []protoreflect.FileDescriptor) ([]*FileDescriptor, error) { // WrapFile wraps the given file descriptor, returning a *desc.FileDescriptor // value that represents the same file. func WrapFile(d protoreflect.FileDescriptor) (*FileDescriptor, error) { - return wrapFile(d, noopCache{}) + return wrapFile(d, mapCache{}) } func wrapFile(d protoreflect.FileDescriptor, cache descriptorCache) (*FileDescriptor, error) { + if res := cache.get(d); res != nil { + return res.(*FileDescriptor), nil + } fdp := protoutil.ProtoFromFileDescriptor(d) return convertFile(d, fdp, cache) } @@ -76,7 +79,7 @@ func wrapFile(d protoreflect.FileDescriptor, cache descriptorCache) (*FileDescri // WrapMessage wraps the given message descriptor, returning a *desc.MessageDescriptor // value that represents the same message. func WrapMessage(d protoreflect.MessageDescriptor) (*MessageDescriptor, error) { - return wrapMessage(d, noopCache{}) + return wrapMessage(d, mapCache{}) } func wrapMessage(d protoreflect.MessageDescriptor, cache descriptorCache) (*MessageDescriptor, error) { @@ -97,7 +100,7 @@ func wrapMessage(d protoreflect.MessageDescriptor, cache descriptorCache) (*Mess // WrapField wraps the given field descriptor, returning a *desc.FieldDescriptor // value that represents the same field. func WrapField(d protoreflect.FieldDescriptor) (*FieldDescriptor, error) { - return wrapField(d, noopCache{}) + return wrapField(d, mapCache{}) } func wrapField(d protoreflect.FieldDescriptor, cache descriptorCache) (*FieldDescriptor, error) { @@ -121,7 +124,7 @@ func wrapField(d protoreflect.FieldDescriptor, cache descriptorCache) (*FieldDes // WrapOneOf wraps the given oneof descriptor, returning a *desc.OneOfDescriptor // value that represents the same oneof. func WrapOneOf(d protoreflect.OneofDescriptor) (*OneOfDescriptor, error) { - return wrapOneOf(d, noopCache{}) + return wrapOneOf(d, mapCache{}) } func wrapOneOf(d protoreflect.OneofDescriptor, cache descriptorCache) (*OneOfDescriptor, error) { @@ -138,7 +141,7 @@ func wrapOneOf(d protoreflect.OneofDescriptor, cache descriptorCache) (*OneOfDes // WrapEnum wraps the given enum descriptor, returning a *desc.EnumDescriptor // value that represents the same enum. func WrapEnum(d protoreflect.EnumDescriptor) (*EnumDescriptor, error) { - return wrapEnum(d, noopCache{}) + return wrapEnum(d, mapCache{}) } func wrapEnum(d protoreflect.EnumDescriptor, cache descriptorCache) (*EnumDescriptor, error) { @@ -159,7 +162,7 @@ func wrapEnum(d protoreflect.EnumDescriptor, cache descriptorCache) (*EnumDescri // WrapEnumValue wraps the given enum value descriptor, returning a *desc.EnumValueDescriptor // value that represents the same enum value. func WrapEnumValue(d protoreflect.EnumValueDescriptor) (*EnumValueDescriptor, error) { - return wrapEnumValue(d, noopCache{}) + return wrapEnumValue(d, mapCache{}) } func wrapEnumValue(d protoreflect.EnumValueDescriptor, cache descriptorCache) (*EnumValueDescriptor, error) { @@ -176,7 +179,7 @@ func wrapEnumValue(d protoreflect.EnumValueDescriptor, cache descriptorCache) (* // WrapService wraps the given service descriptor, returning a *desc.ServiceDescriptor // value that represents the same service. func WrapService(d protoreflect.ServiceDescriptor) (*ServiceDescriptor, error) { - return wrapService(d, noopCache{}) + return wrapService(d, mapCache{}) } func wrapService(d protoreflect.ServiceDescriptor, cache descriptorCache) (*ServiceDescriptor, error) { @@ -193,7 +196,7 @@ func wrapService(d protoreflect.ServiceDescriptor, cache descriptorCache) (*Serv // WrapMethod wraps the given method descriptor, returning a *desc.MethodDescriptor // value that represents the same method. func WrapMethod(d protoreflect.MethodDescriptor) (*MethodDescriptor, error) { - return wrapMethod(d, noopCache{}) + return wrapMethod(d, mapCache{}) } func wrapMethod(d protoreflect.MethodDescriptor, cache descriptorCache) (*MethodDescriptor, error) { diff --git a/vendor/github.com/jhump/protoreflect/grpcreflect/client.go b/vendor/github.com/jhump/protoreflect/grpcreflect/client.go index 192c11f11de..cb6bf568551 100644 --- a/vendor/github.com/jhump/protoreflect/grpcreflect/client.go +++ b/vendor/github.com/jhump/protoreflect/grpcreflect/client.go @@ -8,6 +8,7 @@ import ( "reflect" "runtime" "sync" + "sync/atomic" "time" "github.com/golang/protobuf/proto" @@ -62,14 +63,31 @@ const ( ) func symbolNotFound(symbol string, symType symbolType, cause *elementNotFoundError) error { + if cause != nil && cause.kind == elementKindSymbol && cause.name == symbol { + // no need to wrap + if symType != symbolTypeUnknown && cause.symType == symbolTypeUnknown { + // We previously didn't know symbol type but now do? + // Create a new error that has the right symbol type. + return &elementNotFoundError{name: symbol, symType: symType, kind: elementKindSymbol} + } + return cause + } return &elementNotFoundError{name: symbol, symType: symType, kind: elementKindSymbol, cause: cause} } func extensionNotFound(extendee string, tag int32, cause *elementNotFoundError) error { + if cause != nil && cause.kind == elementKindExtension && cause.name == extendee && cause.tag == tag { + // no need to wrap + return cause + } return &elementNotFoundError{name: extendee, tag: tag, kind: elementKindExtension, cause: cause} } func fileNotFound(file string, cause *elementNotFoundError) error { + if cause != nil && cause.kind == elementKindFile && cause.name == file { + // no need to wrap + return cause + } return &elementNotFoundError{name: file, kind: elementKindFile, cause: cause} } @@ -80,15 +98,15 @@ func (e *elementNotFoundError) Error() string { if first { first = false } else { - fmt.Fprint(&b, "\ncaused by: ") + _, _ = fmt.Fprint(&b, "\ncaused by: ") } switch e.kind { case elementKindSymbol: - fmt.Fprintf(&b, "%s not found: %s", e.symType, e.name) + _, _ = fmt.Fprintf(&b, "%s not found: %s", e.symType, e.name) case elementKindExtension: - fmt.Fprintf(&b, "Extension not found: tag %d for %s", e.tag, e.name) + _, _ = fmt.Fprintf(&b, "Extension not found: tag %d for %s", e.tag, e.name) default: - fmt.Fprintf(&b, "File not found: %s", e.name) + _, _ = fmt.Fprintf(&b, "File not found: %s", e.name) } } return b.String() @@ -119,10 +137,11 @@ type extDesc struct { // Client is a client connection to a server for performing reflection calls // and resolving remote symbols. type Client struct { - ctx context.Context - now func() time.Time - stubV1 refv1.ServerReflectionClient - stubV1Alpha refv1alpha.ServerReflectionClient + ctx context.Context + now func() time.Time + stubV1 refv1.ServerReflectionClient + stubV1Alpha refv1alpha.ServerReflectionClient + allowMissing atomic.Bool connMu sync.Mutex cancel context.CancelFunc @@ -186,6 +205,15 @@ func NewClientAuto(ctx context.Context, cc grpc.ClientConnInterface) *Client { return newClient(ctx, stubv1, stubv1alpha) } +// AllowMissingFileDescriptors configures the client to allow missing files +// when building descriptors when possible. Missing files are often fatal +// errors, but with this option they can sometimes be worked around. Building +// a schema can only succeed with some files missing if the files in question +// only provide custom options and/or other unused types. +func (cr *Client) AllowMissingFileDescriptors() { + cr.allowMissing.Store(true) +} + // TODO: We should also have a NewClientV1. However that should not refer to internal // generated code. So it will have to wait until the grpc-go team fixes this issue: // https://github.com/grpc/grpc-go/issues/5684 @@ -354,16 +382,34 @@ func (cr *Client) getAndCacheFileDescriptors(req *refv1alpha.ServerReflectionReq } func (cr *Client) descriptorFromProto(fd *descriptorpb.FileDescriptorProto) (*desc.FileDescriptor, error) { - deps := make([]*desc.FileDescriptor, len(fd.GetDependency())) + allowMissing := cr.allowMissing.Load() + deps := make([]*desc.FileDescriptor, 0, len(fd.GetDependency())) + var deferredErr error + var missingDeps []int for i, depName := range fd.GetDependency() { if dep, err := cr.FileByFilename(depName); err != nil { - return nil, err + if _, ok := err.(*elementNotFoundError); !ok || !allowMissing { + return nil, err + } + // We'll ignore for now to see if the file is really necessary. + // (If it only supplies custom options, we can get by without it.) + if deferredErr == nil { + deferredErr = err + } + missingDeps = append(missingDeps, i) } else { - deps[i] = dep + deps = append(deps, dep) } } + if len(missingDeps) > 0 { + fd = fileWithoutDeps(fd, missingDeps) + } d, err := desc.CreateFileDescriptor(fd, deps...) if err != nil { + if deferredErr != nil { + // assume the issue is the missing dep + return nil, deferredErr + } return nil, err } d = cr.cacheFile(d) @@ -701,6 +747,46 @@ func (cr *Client) ResolveExtension(extendedType string, extensionNumber int32) ( } } +func fileWithoutDeps(fd *descriptorpb.FileDescriptorProto, missingDeps []int) *descriptorpb.FileDescriptorProto { + // We need to rebuild the file without the missing deps. + fd = proto.Clone(fd).(*descriptorpb.FileDescriptorProto) + newNumDeps := len(fd.GetDependency()) - len(missingDeps) + newDeps := make([]string, 0, newNumDeps) + remapped := make(map[int]int, newNumDeps) + missingIdx := 0 + for i, dep := range fd.GetDependency() { + if missingIdx < len(missingDeps) { + if i == missingDeps[missingIdx] { + // This dep was missing. Skip it. + missingIdx++ + continue + } + } + remapped[i] = len(newDeps) + newDeps = append(newDeps, dep) + } + // Also rebuild public and weak import slices. + newPublic := make([]int32, 0, len(fd.GetPublicDependency())) + for _, idx := range fd.GetPublicDependency() { + newIdx, ok := remapped[int(idx)] + if ok { + newPublic = append(newPublic, int32(newIdx)) + } + } + newWeak := make([]int32, 0, len(fd.GetWeakDependency())) + for _, idx := range fd.GetWeakDependency() { + newIdx, ok := remapped[int(idx)] + if ok { + newWeak = append(newWeak, int32(newIdx)) + } + } + + fd.Dependency = newDeps + fd.PublicDependency = newPublic + fd.WeakDependency = newWeak + return fd +} + func findExtension(extendedType string, extensionNumber int32, scope extensionScope) *desc.FieldDescriptor { // search extensions in this scope for _, ext := range scope.extensions() { diff --git a/vendor/github.com/klauspost/compress/README.md b/vendor/github.com/klauspost/compress/README.md index 1f72cdde187..05c7359e481 100644 --- a/vendor/github.com/klauspost/compress/README.md +++ b/vendor/github.com/klauspost/compress/README.md @@ -55,6 +55,10 @@ https://github.com/klauspost/compress/pull/919 https://github.com/klauspost/comp * s2: Do 2 overlapping match checks https://github.com/klauspost/compress/pull/839 * flate: Add amd64 assembly matchlen https://github.com/klauspost/compress/pull/837 * gzip: Copy bufio.Reader on Reset by @thatguystone in https://github.com/klauspost/compress/pull/860 + +
+ See changes to v1.16.x + * July 1st, 2023 - [v1.16.7](https://github.com/klauspost/compress/releases/tag/v1.16.7) * zstd: Fix default level first dictionary encode https://github.com/klauspost/compress/pull/829 @@ -93,6 +97,7 @@ https://github.com/klauspost/compress/pull/919 https://github.com/klauspost/comp * s2: Add LZ4 block converter. https://github.com/klauspost/compress/pull/748 * s2: Support io.ReaderAt in ReadSeeker. https://github.com/klauspost/compress/pull/747 * s2c/s2sx: Use concurrent decoding. https://github.com/klauspost/compress/pull/746 +
See changes to v1.15.x @@ -560,6 +565,8 @@ the stateless compress described below. For compression performance, see: [this spreadsheet](https://docs.google.com/spreadsheets/d/1nuNE2nPfuINCZJRMt6wFWhKpToF95I47XjSsc-1rbPQ/edit?usp=sharing). +To disable all assembly add `-tags=noasm`. This works across all packages. + # Stateless compression This package offers stateless compression as a special option for gzip/deflate. diff --git a/vendor/github.com/klauspost/compress/flate/matchlen_amd64.s b/vendor/github.com/klauspost/compress/flate/matchlen_amd64.s index 9a7655c0f76..0782b86e3d1 100644 --- a/vendor/github.com/klauspost/compress/flate/matchlen_amd64.s +++ b/vendor/github.com/klauspost/compress/flate/matchlen_amd64.s @@ -5,7 +5,6 @@ #include "textflag.h" // func matchLen(a []byte, b []byte) int -// Requires: BMI TEXT ·matchLen(SB), NOSPLIT, $0-56 MOVQ a_base+0(FP), AX MOVQ b_base+24(FP), CX @@ -17,17 +16,16 @@ TEXT ·matchLen(SB), NOSPLIT, $0-56 JB matchlen_match4_standalone matchlen_loopback_standalone: - MOVQ (AX)(SI*1), BX - XORQ (CX)(SI*1), BX - TESTQ BX, BX - JZ matchlen_loop_standalone + MOVQ (AX)(SI*1), BX + XORQ (CX)(SI*1), BX + JZ matchlen_loop_standalone #ifdef GOAMD64_v3 TZCNTQ BX, BX #else BSFQ BX, BX #endif - SARQ $0x03, BX + SHRL $0x03, BX LEAL (SI)(BX*1), SI JMP gen_match_len_end diff --git a/vendor/github.com/klauspost/compress/internal/snapref/encode_other.go b/vendor/github.com/klauspost/compress/internal/snapref/encode_other.go index 2aa6a95a028..2754bac6f16 100644 --- a/vendor/github.com/klauspost/compress/internal/snapref/encode_other.go +++ b/vendor/github.com/klauspost/compress/internal/snapref/encode_other.go @@ -51,7 +51,7 @@ func emitCopy(dst []byte, offset, length int) int { i := 0 // The maximum length for a single tagCopy1 or tagCopy2 op is 64 bytes. The // threshold for this loop is a little higher (at 68 = 64 + 4), and the - // length emitted down below is is a little lower (at 60 = 64 - 4), because + // length emitted down below is a little lower (at 60 = 64 - 4), because // it's shorter to encode a length 67 copy as a length 60 tagCopy2 followed // by a length 7 tagCopy1 (which encodes as 3+2 bytes) than to encode it as // a length 64 tagCopy2 followed by a length 3 tagCopy2 (which encodes as diff --git a/vendor/github.com/klauspost/compress/s2/decode_arm64.s b/vendor/github.com/klauspost/compress/s2/decode_arm64.s index 4b63d5086a9..78e463f342b 100644 --- a/vendor/github.com/klauspost/compress/s2/decode_arm64.s +++ b/vendor/github.com/klauspost/compress/s2/decode_arm64.s @@ -60,7 +60,7 @@ // // The d variable is implicitly R_DST - R_DBASE, and len(dst)-d is R_DEND - R_DST. // The s variable is implicitly R_SRC - R_SBASE, and len(src)-s is R_SEND - R_SRC. -TEXT ·s2Decode(SB), NOSPLIT, $56-64 +TEXT ·s2Decode(SB), NOSPLIT, $56-56 // Initialize R_SRC, R_DST and R_DBASE-R_SEND. MOVD dst_base+0(FP), R_DBASE MOVD dst_len+8(FP), R_DLEN diff --git a/vendor/github.com/klauspost/compress/s2/index.go b/vendor/github.com/klauspost/compress/s2/index.go index 18a4f7acd6b..4229957b96e 100644 --- a/vendor/github.com/klauspost/compress/s2/index.go +++ b/vendor/github.com/klauspost/compress/s2/index.go @@ -17,6 +17,8 @@ const ( S2IndexHeader = "s2idx\x00" S2IndexTrailer = "\x00xdi2s" maxIndexEntries = 1 << 16 + // If distance is less than this, we do not add the entry. + minIndexDist = 1 << 20 ) // Index represents an S2/Snappy index. @@ -72,6 +74,10 @@ func (i *Index) add(compressedOffset, uncompressedOffset int64) error { if latest.compressedOffset > compressedOffset { return fmt.Errorf("internal error: Earlier compressed received (%d > %d)", latest.uncompressedOffset, uncompressedOffset) } + if latest.uncompressedOffset+minIndexDist > uncompressedOffset { + // Only add entry if distance is large enough. + return nil + } } i.info = append(i.info, struct { compressedOffset int64 @@ -122,7 +128,7 @@ func (i *Index) Find(offset int64) (compressedOff, uncompressedOff int64, err er // reduce to stay below maxIndexEntries func (i *Index) reduce() { - if len(i.info) < maxIndexEntries && i.estBlockUncomp >= 1<<20 { + if len(i.info) < maxIndexEntries && i.estBlockUncomp >= minIndexDist { return } @@ -132,7 +138,7 @@ func (i *Index) reduce() { j := 0 // Each block should be at least 1MB, but don't reduce below 1000 entries. - for i.estBlockUncomp*(int64(removeN)+1) < 1<<20 && len(i.info)/(removeN+1) > 1000 { + for i.estBlockUncomp*(int64(removeN)+1) < minIndexDist && len(i.info)/(removeN+1) > 1000 { removeN++ } for idx := 0; idx < len(src); idx++ { diff --git a/vendor/github.com/klauspost/compress/s2/s2.go b/vendor/github.com/klauspost/compress/s2/s2.go index 72bcb494531..cbd1ed64d69 100644 --- a/vendor/github.com/klauspost/compress/s2/s2.go +++ b/vendor/github.com/klauspost/compress/s2/s2.go @@ -109,7 +109,11 @@ const ( chunkTypeStreamIdentifier = 0xff ) -var crcTable = crc32.MakeTable(crc32.Castagnoli) +var ( + crcTable = crc32.MakeTable(crc32.Castagnoli) + magicChunkSnappyBytes = []byte(magicChunkSnappy) // Can be passed to functions where it escapes. + magicChunkBytes = []byte(magicChunk) // Can be passed to functions where it escapes. +) // crc implements the checksum specified in section 3 of // https://github.com/google/snappy/blob/master/framing_format.txt diff --git a/vendor/github.com/klauspost/compress/s2/writer.go b/vendor/github.com/klauspost/compress/s2/writer.go index 1253ea675c4..0a46f2b984f 100644 --- a/vendor/github.com/klauspost/compress/s2/writer.go +++ b/vendor/github.com/klauspost/compress/s2/writer.go @@ -239,6 +239,9 @@ func (w *Writer) ReadFrom(r io.Reader) (n int64, err error) { } } if n2 == 0 { + if cap(inbuf) >= w.obufLen { + w.buffers.Put(inbuf) + } break } n += int64(n2) @@ -314,9 +317,9 @@ func (w *Writer) AddSkippableBlock(id uint8, data []byte) (err error) { hWriter := make(chan result) w.output <- hWriter if w.snappy { - hWriter <- result{startOffset: w.uncompWritten, b: []byte(magicChunkSnappy)} + hWriter <- result{startOffset: w.uncompWritten, b: magicChunkSnappyBytes} } else { - hWriter <- result{startOffset: w.uncompWritten, b: []byte(magicChunk)} + hWriter <- result{startOffset: w.uncompWritten, b: magicChunkBytes} } } @@ -370,9 +373,9 @@ func (w *Writer) EncodeBuffer(buf []byte) (err error) { hWriter := make(chan result) w.output <- hWriter if w.snappy { - hWriter <- result{startOffset: w.uncompWritten, b: []byte(magicChunkSnappy)} + hWriter <- result{startOffset: w.uncompWritten, b: magicChunkSnappyBytes} } else { - hWriter <- result{startOffset: w.uncompWritten, b: []byte(magicChunk)} + hWriter <- result{startOffset: w.uncompWritten, b: magicChunkBytes} } } @@ -478,9 +481,9 @@ func (w *Writer) write(p []byte) (nRet int, errRet error) { hWriter := make(chan result) w.output <- hWriter if w.snappy { - hWriter <- result{startOffset: w.uncompWritten, b: []byte(magicChunkSnappy)} + hWriter <- result{startOffset: w.uncompWritten, b: magicChunkSnappyBytes} } else { - hWriter <- result{startOffset: w.uncompWritten, b: []byte(magicChunk)} + hWriter <- result{startOffset: w.uncompWritten, b: magicChunkBytes} } } @@ -560,6 +563,9 @@ func (w *Writer) writeFull(inbuf []byte) (errRet error) { if w.concurrency == 1 { _, err := w.writeSync(inbuf[obufHeaderLen:]) + if cap(inbuf) >= w.obufLen { + w.buffers.Put(inbuf) + } return err } @@ -569,9 +575,9 @@ func (w *Writer) writeFull(inbuf []byte) (errRet error) { hWriter := make(chan result) w.output <- hWriter if w.snappy { - hWriter <- result{startOffset: w.uncompWritten, b: []byte(magicChunkSnappy)} + hWriter <- result{startOffset: w.uncompWritten, b: magicChunkSnappyBytes} } else { - hWriter <- result{startOffset: w.uncompWritten, b: []byte(magicChunk)} + hWriter <- result{startOffset: w.uncompWritten, b: magicChunkBytes} } } @@ -637,9 +643,9 @@ func (w *Writer) writeSync(p []byte) (nRet int, errRet error) { var n int var err error if w.snappy { - n, err = w.writer.Write([]byte(magicChunkSnappy)) + n, err = w.writer.Write(magicChunkSnappyBytes) } else { - n, err = w.writer.Write([]byte(magicChunk)) + n, err = w.writer.Write(magicChunkBytes) } if err != nil { return 0, w.err(err) @@ -937,7 +943,7 @@ func WriterUncompressed() WriterOption { // WriterBlockSize allows to override the default block size. // Blocks will be this size or smaller. -// Minimum size is 4KB and and maximum size is 4MB. +// Minimum size is 4KB and maximum size is 4MB. // // Bigger blocks may give bigger throughput on systems with many cores, // and will increase compression slightly, but it will limit the possible diff --git a/vendor/github.com/klauspost/compress/zstd/blockdec.go b/vendor/github.com/klauspost/compress/zstd/blockdec.go index 9f17ce601ff..03744fbc765 100644 --- a/vendor/github.com/klauspost/compress/zstd/blockdec.go +++ b/vendor/github.com/klauspost/compress/zstd/blockdec.go @@ -554,6 +554,9 @@ func (b *blockDec) prepareSequences(in []byte, hist *history) (err error) { if debugDecoder { printf("Compression modes: 0b%b", compMode) } + if compMode&3 != 0 { + return errors.New("corrupt block: reserved bits not zero") + } for i := uint(0); i < 3; i++ { mode := seqCompMode((compMode >> (6 - i*2)) & 3) if debugDecoder { diff --git a/vendor/github.com/klauspost/compress/zstd/blockenc.go b/vendor/github.com/klauspost/compress/zstd/blockenc.go index 2cfe925ade5..32a7f401d5d 100644 --- a/vendor/github.com/klauspost/compress/zstd/blockenc.go +++ b/vendor/github.com/klauspost/compress/zstd/blockenc.go @@ -427,6 +427,16 @@ func (b *blockEnc) encodeLits(lits []byte, raw bool) error { return nil } +// encodeRLE will encode an RLE block. +func (b *blockEnc) encodeRLE(val byte, length uint32) { + var bh blockHeader + bh.setLast(b.last) + bh.setSize(length) + bh.setType(blockTypeRLE) + b.output = bh.appendTo(b.output) + b.output = append(b.output, val) +} + // fuzzFseEncoder can be used to fuzz the FSE encoder. func fuzzFseEncoder(data []byte) int { if len(data) > maxSequences || len(data) < 2 { @@ -479,6 +489,16 @@ func (b *blockEnc) encode(org []byte, raw, rawAllLits bool) error { if len(b.sequences) == 0 { return b.encodeLits(b.literals, rawAllLits) } + if len(b.sequences) == 1 && len(org) > 0 && len(b.literals) <= 1 { + // Check common RLE cases. + seq := b.sequences[0] + if seq.litLen == uint32(len(b.literals)) && seq.offset-3 == 1 { + // Offset == 1 and 0 or 1 literals. + b.encodeRLE(org[0], b.sequences[0].matchLen+zstdMinMatch+seq.litLen) + return nil + } + } + // We want some difference to at least account for the headers. saved := b.size - len(b.literals) - (b.size >> 6) if saved < 16 { diff --git a/vendor/github.com/klauspost/compress/zstd/decoder.go b/vendor/github.com/klauspost/compress/zstd/decoder.go index f04aaa21eb8..bbca17234aa 100644 --- a/vendor/github.com/klauspost/compress/zstd/decoder.go +++ b/vendor/github.com/klauspost/compress/zstd/decoder.go @@ -82,7 +82,7 @@ var ( // can run multiple concurrent stateless decodes. It is even possible to // use stateless decodes while a stream is being decoded. // -// The Reset function can be used to initiate a new stream, which is will considerably +// The Reset function can be used to initiate a new stream, which will considerably // reduce the allocations normally caused by NewReader. func NewReader(r io.Reader, opts ...DOption) (*Decoder, error) { initPredefined() diff --git a/vendor/github.com/klauspost/compress/zstd/dict.go b/vendor/github.com/klauspost/compress/zstd/dict.go index 8d5567fe64c..b7b83164bc7 100644 --- a/vendor/github.com/klauspost/compress/zstd/dict.go +++ b/vendor/github.com/klauspost/compress/zstd/dict.go @@ -273,6 +273,9 @@ func BuildDict(o BuildDictOptions) ([]byte, error) { enc.Encode(&block, b) addValues(&remain, block.literals) litTotal += len(block.literals) + if len(block.sequences) == 0 { + continue + } seqs += len(block.sequences) block.genCodes() addHist(&ll, block.coders.llEnc.Histogram()) @@ -286,6 +289,9 @@ func BuildDict(o BuildDictOptions) ([]byte, error) { if offset == 0 { continue } + if int(offset) >= len(o.History) { + continue + } if offset > 3 { newOffsets[offset-3]++ } else { @@ -336,6 +342,9 @@ func BuildDict(o BuildDictOptions) ([]byte, error) { if seqs/nUsed < 512 { // Use 512 as minimum. nUsed = seqs / 512 + if nUsed == 0 { + nUsed = 1 + } } copyHist := func(dst *fseEncoder, src *[256]int) ([]byte, error) { hist := dst.Histogram() @@ -358,6 +367,28 @@ func BuildDict(o BuildDictOptions) ([]byte, error) { fakeLength += v hist[i] = uint32(v) } + + // Ensure we aren't trying to represent RLE. + if maxCount == fakeLength { + for i := range hist { + if uint8(i) == maxSym { + fakeLength++ + maxSym++ + hist[i+1] = 1 + if maxSym > 1 { + break + } + } + if hist[0] == 0 { + fakeLength++ + hist[i] = 1 + if maxSym > 1 { + break + } + } + } + } + dst.HistogramFinished(maxSym, maxCount) dst.reUsed = false dst.useRLE = false diff --git a/vendor/github.com/klauspost/compress/zstd/enc_best.go b/vendor/github.com/klauspost/compress/zstd/enc_best.go index 87f42879a87..4613724e9d1 100644 --- a/vendor/github.com/klauspost/compress/zstd/enc_best.go +++ b/vendor/github.com/klauspost/compress/zstd/enc_best.go @@ -135,8 +135,20 @@ func (e *bestFastEncoder) Encode(blk *blockEnc, src []byte) { break } + // Add block to history s := e.addBlock(src) blk.size = len(src) + + // Check RLE first + if len(src) > zstdMinMatch { + ml := matchLen(src[1:], src) + if ml == len(src)-1 { + blk.literals = append(blk.literals, src[0]) + blk.sequences = append(blk.sequences, seq{litLen: 1, matchLen: uint32(len(src)-1) - zstdMinMatch, offset: 1 + 3}) + return + } + } + if len(src) < minNonLiteralBlockSize { blk.extraLits = len(src) blk.literals = blk.literals[:len(src)] diff --git a/vendor/github.com/klauspost/compress/zstd/enc_better.go b/vendor/github.com/klauspost/compress/zstd/enc_better.go index 20d25b0e052..a4f5bf91fc6 100644 --- a/vendor/github.com/klauspost/compress/zstd/enc_better.go +++ b/vendor/github.com/klauspost/compress/zstd/enc_better.go @@ -102,9 +102,20 @@ func (e *betterFastEncoder) Encode(blk *blockEnc, src []byte) { e.cur = e.maxMatchOff break } - + // Add block to history s := e.addBlock(src) blk.size = len(src) + + // Check RLE first + if len(src) > zstdMinMatch { + ml := matchLen(src[1:], src) + if ml == len(src)-1 { + blk.literals = append(blk.literals, src[0]) + blk.sequences = append(blk.sequences, seq{litLen: 1, matchLen: uint32(len(src)-1) - zstdMinMatch, offset: 1 + 3}) + return + } + } + if len(src) < minNonLiteralBlockSize { blk.extraLits = len(src) blk.literals = blk.literals[:len(src)] diff --git a/vendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_arm64.s b/vendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_arm64.s index 17901e08040..ae7d4d3295a 100644 --- a/vendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_arm64.s +++ b/vendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_arm64.s @@ -162,12 +162,12 @@ finalize: MOVD h, ret+24(FP) RET -// func writeBlocks(d *Digest, b []byte) int +// func writeBlocks(s *Digest, b []byte) int TEXT ·writeBlocks(SB), NOSPLIT|NOFRAME, $0-40 LDP ·primes+0(SB), (prime1, prime2) // Load state. Assume v[1-4] are stored contiguously. - MOVD d+0(FP), digest + MOVD s+0(FP), digest LDP 0(digest), (v1, v2) LDP 16(digest), (v3, v4) diff --git a/vendor/github.com/klauspost/compress/zstd/matchlen_amd64.s b/vendor/github.com/klauspost/compress/zstd/matchlen_amd64.s index 9a7655c0f76..0782b86e3d1 100644 --- a/vendor/github.com/klauspost/compress/zstd/matchlen_amd64.s +++ b/vendor/github.com/klauspost/compress/zstd/matchlen_amd64.s @@ -5,7 +5,6 @@ #include "textflag.h" // func matchLen(a []byte, b []byte) int -// Requires: BMI TEXT ·matchLen(SB), NOSPLIT, $0-56 MOVQ a_base+0(FP), AX MOVQ b_base+24(FP), CX @@ -17,17 +16,16 @@ TEXT ·matchLen(SB), NOSPLIT, $0-56 JB matchlen_match4_standalone matchlen_loopback_standalone: - MOVQ (AX)(SI*1), BX - XORQ (CX)(SI*1), BX - TESTQ BX, BX - JZ matchlen_loop_standalone + MOVQ (AX)(SI*1), BX + XORQ (CX)(SI*1), BX + JZ matchlen_loop_standalone #ifdef GOAMD64_v3 TZCNTQ BX, BX #else BSFQ BX, BX #endif - SARQ $0x03, BX + SHRL $0x03, BX LEAL (SI)(BX*1), SI JMP gen_match_len_end diff --git a/vendor/google.golang.org/grpc/CONTRIBUTING.md b/vendor/google.golang.org/grpc/CONTRIBUTING.md index 608aa6e1ac5..0854d298e41 100644 --- a/vendor/google.golang.org/grpc/CONTRIBUTING.md +++ b/vendor/google.golang.org/grpc/CONTRIBUTING.md @@ -66,7 +66,7 @@ How to get your contributions merged smoothly and quickly. - **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 + - `./scripts/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 diff --git a/vendor/google.golang.org/grpc/MAINTAINERS.md b/vendor/google.golang.org/grpc/MAINTAINERS.md index c6672c0a3ef..6a8a07781ae 100644 --- a/vendor/google.golang.org/grpc/MAINTAINERS.md +++ b/vendor/google.golang.org/grpc/MAINTAINERS.md @@ -9,6 +9,7 @@ for general contribution guidelines. ## Maintainers (in alphabetical order) +- [atollena](https://github.com/atollena), Datadog, Inc. - [cesarghali](https://github.com/cesarghali), Google LLC - [dfawley](https://github.com/dfawley), Google LLC - [easwars](https://github.com/easwars), Google LLC 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 index 856c75dd4e2..1afb1e84ac0 100644 --- 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 @@ -18,7 +18,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.25.2 // source: grpc/binlog/v1/binarylog.proto diff --git a/vendor/google.golang.org/grpc/clientconn.go b/vendor/google.golang.org/grpc/clientconn.go index c7f2607114a..2359f94b8a4 100644 --- a/vendor/google.golang.org/grpc/clientconn.go +++ b/vendor/google.golang.org/grpc/clientconn.go @@ -37,7 +37,6 @@ import ( "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" @@ -121,8 +120,9 @@ func (dcs *defaultConfigSelector) SelectConfig(rpcInfo iresolver.RPCInfo) (*ires // 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. +// The DialOptions returned by WithBlock, WithTimeout, +// WithReturnConnectionError, and FailOnNonTempDialError are ignored by this +// function. func NewClient(target string, opts ...DialOption) (conn *ClientConn, err error) { cc := &ClientConn{ target: target, @@ -196,6 +196,8 @@ func NewClient(target string, opts ...DialOption) (conn *ClientConn, err error) } // Dial calls DialContext(context.Background(), target, opts...). +// +// Deprecated: use NewClient instead. Will be supported throughout 1.x. func Dial(target string, opts ...DialOption) (*ClientConn, error) { return DialContext(context.Background(), target, opts...) } @@ -209,6 +211,8 @@ func Dial(target string, opts ...DialOption) (*ClientConn, error) { // "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. +// +// Deprecated: use NewClient instead. Will be supported throughout 1.x. 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. @@ -838,6 +842,9 @@ func (cc *ClientConn) newAddrConnLocked(addrs []resolver.Address, opts balancer. stateChan: make(chan struct{}), } ac.ctx, ac.cancel = context.WithCancel(cc.ctx) + // Start with our address set to the first address; this may be updated if + // we connect to different addresses. + ac.channelz.ChannelMetrics.Target.Store(&addrs[0].Addr) channelz.AddTraceEvent(logger, ac.channelz, 0, &channelz.TraceEvent{ Desc: "Subchannel created", @@ -929,10 +936,14 @@ func equalAddresses(a, b []resolver.Address) bool { // 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) + limit := len(addrs) + if limit > 5 { + limit = 5 + } + channelz.Infof(logger, ac.channelz, "addrConn: updateAddrs addrs (%d of %d): %v", limit, len(addrs), addrs[:limit]) + + ac.mu.Lock() if equalAddresses(ac.addrs, addrs) { ac.mu.Unlock() return @@ -1167,6 +1178,10 @@ type addrConn struct { // is received, transport is closed, ac has been torn down). transport transport.ClientTransport // The current transport. + // This mutex is used on the RPC path, so its usage should be minimized as + // much as possible. + // TODO: Find a lock-free way to retrieve the transport and state from the + // addrConn. mu sync.Mutex curAddr resolver.Address // The current address. addrs []resolver.Address // All addresses that the resolver resolved to. @@ -1292,6 +1307,7 @@ func (ac *addrConn) resetTransport() { func (ac *addrConn) tryAllAddrs(ctx context.Context, addrs []resolver.Address, connectDeadline time.Time) error { var firstConnErr error for _, addr := range addrs { + ac.channelz.ChannelMetrics.Target.Store(&addr.Addr) if ctx.Err() != nil { return errConnClosing } @@ -1739,7 +1755,7 @@ func encodeAuthority(authority string) string { return false case '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=': // Subdelim characters return false - case ':', '[', ']', '@': // Authority related delimeters + case ':', '[', ']', '@': // Authority related delimiters return false } // Everything else must be escaped. diff --git a/vendor/google.golang.org/grpc/codegen.sh b/vendor/google.golang.org/grpc/codegen.sh deleted file mode 100644 index 4cdc6ba7c09..00000000000 --- 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/codes.go b/vendor/google.golang.org/grpc/codes/codes.go index 08476ad1fe1..0b42c302b24 100644 --- a/vendor/google.golang.org/grpc/codes/codes.go +++ b/vendor/google.golang.org/grpc/codes/codes.go @@ -235,7 +235,7 @@ func (c *Code) UnmarshalJSON(b []byte) error { if ci, err := strconv.ParseUint(string(b), 10, 32); err == nil { if ci >= _maxCode { - return fmt.Errorf("invalid code: %q", ci) + return fmt.Errorf("invalid code: %d", ci) } *c = Code(ci) diff --git a/vendor/google.golang.org/grpc/credentials/credentials.go b/vendor/google.golang.org/grpc/credentials/credentials.go index f6b55c68b56..665e790bb0f 100644 --- a/vendor/google.golang.org/grpc/credentials/credentials.go +++ b/vendor/google.golang.org/grpc/credentials/credentials.go @@ -30,7 +30,7 @@ import ( "google.golang.org/grpc/attributes" icredentials "google.golang.org/grpc/internal/credentials" - "google.golang.org/protobuf/protoadapt" + "google.golang.org/protobuf/proto" ) // PerRPCCredentials defines the common interface for the credentials which need to @@ -237,7 +237,7 @@ func ClientHandshakeInfoFromContext(ctx context.Context) ClientHandshakeInfo { } // 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 +// It returns success if 1) the condition is satisfied 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. @@ -287,5 +287,5 @@ type ChannelzSecurityValue interface { type OtherChannelzSecurityValue struct { ChannelzSecurityValue Name string - Value protoadapt.MessageV1 + Value proto.Message } diff --git a/vendor/google.golang.org/grpc/dialoptions.go b/vendor/google.golang.org/grpc/dialoptions.go index 402493224e0..00273702b69 100644 --- a/vendor/google.golang.org/grpc/dialoptions.go +++ b/vendor/google.golang.org/grpc/dialoptions.go @@ -300,6 +300,9 @@ func withBackoff(bs internalbackoff.Strategy) DialOption { // // Use of this feature is not recommended. For more information, please see: // https://github.com/grpc/grpc-go/blob/master/Documentation/anti-patterns.md +// +// Deprecated: this DialOption is not supported by NewClient. +// Will be supported throughout 1.x. func WithBlock() DialOption { return newFuncDialOption(func(o *dialOptions) { o.block = true @@ -314,10 +317,8 @@ func WithBlock() DialOption { // 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. +// Deprecated: this DialOption is not supported by NewClient. +// Will be supported throughout 1.x. func WithReturnConnectionError() DialOption { return newFuncDialOption(func(o *dialOptions) { o.block = true @@ -387,8 +388,8 @@ func WithCredentialsBundle(b credentials.Bundle) DialOption { // 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. +// Deprecated: this DialOption is not supported by NewClient. +// Will be supported throughout 1.x. func WithTimeout(d time.Duration) DialOption { return newFuncDialOption(func(o *dialOptions) { o.timeout = d @@ -470,9 +471,8 @@ func withBinaryLogger(bl binarylog.Logger) DialOption { // 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 +// Deprecated: this DialOption is not supported by NewClient. +// This API may be changed or removed in a // later release. func FailOnNonTempDialError(f bool) DialOption { return newFuncDialOption(func(o *dialOptions) { @@ -601,12 +601,22 @@ func WithDisableRetry() DialOption { }) } +// MaxHeaderListSizeDialOption is a DialOption that specifies the maximum +// (uncompressed) size of header list that the client is prepared to accept. +type MaxHeaderListSizeDialOption struct { + MaxHeaderListSize uint32 +} + +func (o MaxHeaderListSizeDialOption) apply(do *dialOptions) { + do.copts.MaxHeaderListSize = &o.MaxHeaderListSize +} + // 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 - }) + return MaxHeaderListSizeDialOption{ + MaxHeaderListSize: s, + } } // WithDisableHealthCheck disables the LB channel health checking for all @@ -648,7 +658,7 @@ func defaultDialOptions() dialOptions { } } -// withGetMinConnectDeadline specifies the function that clientconn uses to +// withMinConnectDeadline specifies the function that clientconn uses to // get minConnectDeadline. This can be used to make connection attempts happen // faster/slower. // diff --git a/vendor/google.golang.org/grpc/health/grpc_health_v1/health.pb.go b/vendor/google.golang.org/grpc/health/grpc_health_v1/health.pb.go index 5bf880d4190..6a93475a7fb 100644 --- a/vendor/google.golang.org/grpc/health/grpc_health_v1/health.pb.go +++ b/vendor/google.golang.org/grpc/health/grpc_health_v1/health.pb.go @@ -17,7 +17,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.25.2 // source: grpc/health/v1/health.proto diff --git a/vendor/google.golang.org/grpc/health/grpc_health_v1/health_grpc.pb.go b/vendor/google.golang.org/grpc/health/grpc_health_v1/health_grpc.pb.go index 4c46c098dc6..8f793e6e89f 100644 --- a/vendor/google.golang.org/grpc/health/grpc_health_v1/health_grpc.pb.go +++ b/vendor/google.golang.org/grpc/health/grpc_health_v1/health_grpc.pb.go @@ -32,8 +32,8 @@ import ( // 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 +// Requires gRPC-Go v1.62.0 or later. +const _ = grpc.SupportPackageIsVersion8 const ( Health_Check_FullMethodName = "/grpc.health.v1.Health/Check" @@ -81,8 +81,9 @@ func NewHealthClient(cc grpc.ClientConnInterface) HealthClient { } func (c *healthClient) Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(HealthCheckResponse) - err := c.cc.Invoke(ctx, Health_Check_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, Health_Check_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -90,11 +91,12 @@ func (c *healthClient) Check(ctx context.Context, in *HealthCheckRequest, opts . } func (c *healthClient) Watch(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (Health_WatchClient, error) { - stream, err := c.cc.NewStream(ctx, &Health_ServiceDesc.Streams[0], Health_Watch_FullMethodName, opts...) + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + stream, err := c.cc.NewStream(ctx, &Health_ServiceDesc.Streams[0], Health_Watch_FullMethodName, cOpts...) if err != nil { return nil, err } - x := &healthWatchClient{stream} + x := &healthWatchClient{ClientStream: stream} if err := x.ClientStream.SendMsg(in); err != nil { return nil, err } @@ -198,7 +200,7 @@ func _Health_Watch_Handler(srv interface{}, stream grpc.ServerStream) error { if err := stream.RecvMsg(m); err != nil { return err } - return srv.(HealthServer).Watch(m, &healthWatchServer{stream}) + return srv.(HealthServer).Watch(m, &healthWatchServer{ServerStream: stream}) } type Health_WatchServer interface { diff --git a/vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/config.go b/vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/config.go index 6bf7f87396f..13821a92660 100644 --- a/vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/config.go +++ b/vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/config.go @@ -75,7 +75,6 @@ func ParseConfig(cfg json.RawMessage) (serviceconfig.LoadBalancingConfig, error) if err != nil { return nil, fmt.Errorf("error parsing config for policy %q: %v", name, err) } - return &lbConfig{childBuilder: builder, childConfig: cfg}, nil } diff --git a/vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/gracefulswitch.go b/vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/gracefulswitch.go index 45d5e50ea9b..73bb4c4ee9a 100644 --- a/vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/gracefulswitch.go +++ b/vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/gracefulswitch.go @@ -169,7 +169,6 @@ func (gsb *Balancer) latestBalancer() *balancerWrapper { 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. diff --git a/vendor/google.golang.org/grpc/internal/binarylog/method_logger.go b/vendor/google.golang.org/grpc/internal/binarylog/method_logger.go index e8456a77c25..aa4505a871d 100644 --- a/vendor/google.golang.org/grpc/internal/binarylog/method_logger.go +++ b/vendor/google.golang.org/grpc/internal/binarylog/method_logger.go @@ -65,7 +65,7 @@ type TruncatingMethodLogger struct { callID uint64 idWithinCallGen *callIDGenerator - sink Sink // TODO(blog): make this plugable. + sink Sink // TODO(blog): make this pluggable. } // NewTruncatingMethodLogger returns a new truncating method logger. @@ -80,7 +80,7 @@ func NewTruncatingMethodLogger(h, m uint64) *TruncatingMethodLogger { callID: idGen.next(), idWithinCallGen: &callIDGenerator{}, - sink: DefaultSink, // TODO(blog): make it plugable. + sink: DefaultSink, // TODO(blog): make it pluggable. } } @@ -397,7 +397,7 @@ 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. + case "grpc-trace-bin": // grpc-trace-bin is special because it's visible to users. return false } return strings.HasPrefix(key, "grpc-") diff --git a/vendor/google.golang.org/grpc/internal/envconfig/envconfig.go b/vendor/google.golang.org/grpc/internal/envconfig/envconfig.go index 685a3cb41b1..9c915d9e4b2 100644 --- a/vendor/google.golang.org/grpc/internal/envconfig/envconfig.go +++ b/vendor/google.golang.org/grpc/internal/envconfig/envconfig.go @@ -28,9 +28,6 @@ import ( 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 diff --git a/vendor/google.golang.org/grpc/internal/grpcutil/compressor.go b/vendor/google.golang.org/grpc/internal/grpcutil/compressor.go index 9f409096798..e8d866984b3 100644 --- a/vendor/google.golang.org/grpc/internal/grpcutil/compressor.go +++ b/vendor/google.golang.org/grpc/internal/grpcutil/compressor.go @@ -20,8 +20,6 @@ package grpcutil import ( "strings" - - "google.golang.org/grpc/internal/envconfig" ) // RegisteredCompressorNames holds names of the registered compressors. @@ -40,8 +38,5 @@ func IsCompressorNameRegistered(name string) bool { // 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/resolver/dns/dns_resolver.go b/vendor/google.golang.org/grpc/internal/resolver/dns/dns_resolver.go index abab35e250e..f3f52a59a86 100644 --- a/vendor/google.golang.org/grpc/internal/resolver/dns/dns_resolver.go +++ b/vendor/google.golang.org/grpc/internal/resolver/dns/dns_resolver.go @@ -41,18 +41,24 @@ import ( "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") +var ( + // EnableSRVLookups controls whether the DNS resolver attempts to fetch gRPCLB + // addresses from SRV records. Must not be changed after init time. + EnableSRVLookups = false + + // MinResolutionInterval is the minimum interval at which re-resolutions are + // allowed. This helps to prevent excessive re-resolution. + MinResolutionInterval = 30 * time.Second + + // 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. + ResolvingTimeout = 30 * time.Second + + logger = grpclog.Component("dns") +) func init() { resolver.Register(NewBuilder()) @@ -208,7 +214,7 @@ func (d *dnsResolver) watcher() { // 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 + waitTime = MinResolutionInterval select { case <-d.ctx.Done(): return 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 index c7fc557d00c..a7ecaf8d522 100644 --- a/vendor/google.golang.org/grpc/internal/resolver/dns/internal/internal.go +++ b/vendor/google.golang.org/grpc/internal/resolver/dns/internal/internal.go @@ -28,7 +28,7 @@ import ( // 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. +// overridden 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) @@ -50,10 +50,6 @@ var ( // 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 diff --git a/vendor/google.golang.org/grpc/internal/transport/controlbuf.go b/vendor/google.golang.org/grpc/internal/transport/controlbuf.go index 83c3829826a..3deadfb4a20 100644 --- a/vendor/google.golang.org/grpc/internal/transport/controlbuf.go +++ b/vendor/google.golang.org/grpc/internal/transport/controlbuf.go @@ -193,7 +193,7 @@ type goAway struct { code http2.ErrCode debugData []byte headsUp bool - closeConn error // if set, loopyWriter will exit, resulting in conn closure + closeConn error // if set, loopyWriter will exit with this error } func (*goAway) isTransportResponseFrame() bool { return false } @@ -336,7 +336,7 @@ func (c *controlBuffer) put(it cbItem) error { return err } -func (c *controlBuffer) executeAndPut(f func(it any) bool, it cbItem) (bool, error) { +func (c *controlBuffer) executeAndPut(f func() bool, it cbItem) (bool, error) { var wakeUp bool c.mu.Lock() if c.err != nil { @@ -344,7 +344,7 @@ func (c *controlBuffer) executeAndPut(f func(it any) bool, it cbItem) (bool, err return false, c.err } if f != nil { - if !f(it) { // f wasn't successful + if !f() { // f wasn't successful c.mu.Unlock() return false, nil } @@ -495,21 +495,22 @@ type loopyWriter struct { ssGoAwayHandler func(*goAway) (bool, error) } -func newLoopyWriter(s side, fr *framer, cbuf *controlBuffer, bdpEst *bdpEstimator, conn net.Conn, logger *grpclog.PrefixLogger) *loopyWriter { +func newLoopyWriter(s side, fr *framer, cbuf *controlBuffer, bdpEst *bdpEstimator, conn net.Conn, logger *grpclog.PrefixLogger, goAwayHandler func(*goAway) (bool, error)) *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, + 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, + ssGoAwayHandler: goAwayHandler, } return l } diff --git a/vendor/google.golang.org/grpc/internal/transport/http2_client.go b/vendor/google.golang.org/grpc/internal/transport/http2_client.go index deba0c4d9ef..3c63c706986 100644 --- a/vendor/google.golang.org/grpc/internal/transport/http2_client.go +++ b/vendor/google.golang.org/grpc/internal/transport/http2_client.go @@ -114,11 +114,11 @@ type http2Client struct { 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 + nextID uint32 state transportState activeStreams map[uint32]*Stream // prevGoAway ID records the Last-Stream-ID in the previous GOAway frame. @@ -408,10 +408,10 @@ func newHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts readerErrCh := make(chan error, 1) go t.reader(readerErrCh) defer func() { - if err == nil { - err = <-readerErrCh - } if err != nil { + // writerDone should be closed since the loopy goroutine + // wouldn't have started in the case this function returns an error. + close(t.writerDone) t.Close(err) } }() @@ -458,8 +458,12 @@ func newHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts if err := t.framer.writer.Flush(); err != nil { return nil, err } + // Block until the server preface is received successfully or an error occurs. + if err = <-readerErrCh; err != nil { + return nil, err + } go func() { - t.loopy = newLoopyWriter(clientSide, t.framer, t.controlBuf, t.bdpEst, t.conn, t.logger) + t.loopy = newLoopyWriter(clientSide, t.framer, t.controlBuf, t.bdpEst, t.conn, t.logger, t.outgoingGoAwayHandler) 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 @@ -517,6 +521,17 @@ func (t *http2Client) getPeer() *peer.Peer { } } +// OutgoingGoAwayHandler writes a GOAWAY to the connection. Always returns (false, err) as we want the GoAway +// to be the last frame loopy writes to the transport. +func (t *http2Client) outgoingGoAwayHandler(g *goAway) (bool, error) { + t.mu.Lock() + defer t.mu.Unlock() + if err := t.framer.fr.WriteGoAway(t.nextID-2, http2.ErrCodeNo, g.debugData); err != nil { + return false, err + } + return false, g.closeConn +} + func (t *http2Client) createHeaderFields(ctx context.Context, callHdr *CallHdr) ([]hpack.HeaderField, error) { aud := t.createAudience(callHdr) ri := credentials.RequestInfo{ @@ -781,7 +796,7 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (*Stream, firstTry := true var ch chan struct{} transportDrainRequired := false - checkForStreamQuota := func(it any) bool { + checkForStreamQuota := func() bool { if t.streamQuota <= 0 { // Can go negative if server decreases it. if firstTry { t.waitingStreams++ @@ -793,23 +808,24 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (*Stream, 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. } + + hdr.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 = hdr.streamID + s.fc = &inFlow{limit: uint32(t.initialWindowSize)} t.activeStreams[s.id] = s t.mu.Unlock() + if t.streamQuota > 0 && t.waitingStreams > 0 { select { case t.streamsQuotaAvailable <- struct{}{}: @@ -819,13 +835,12 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (*Stream, return true } var hdrListSizeErr error - checkForHeaderListSize := func(it any) bool { + checkForHeaderListSize := func() bool { if t.maxSendHeaderListSize == nil { return true } - hdrFrame := it.(*headerFrame) var sz int64 - for _, f := range hdrFrame.hf { + for _, f := range hdr.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 @@ -834,8 +849,8 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (*Stream, return true } for { - success, err := t.controlBuf.executeAndPut(func(it any) bool { - return checkForHeaderListSize(it) && checkForStreamQuota(it) + success, err := t.controlBuf.executeAndPut(func() bool { + return checkForHeaderListSize() && checkForStreamQuota() }, hdr) if err != nil { // Connection closed. @@ -946,7 +961,7 @@ func (t *http2Client) closeStream(s *Stream, err error, rst bool, rstCode http2. rst: rst, rstCode: rstCode, } - addBackStreamQuota := func(any) bool { + addBackStreamQuota := func() bool { t.streamQuota++ if t.streamQuota > 0 && t.waitingStreams > 0 { select { @@ -966,7 +981,7 @@ func (t *http2Client) closeStream(s *Stream, err error, rst bool, rstCode http2. // 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. +// accessed anymore. func (t *http2Client) Close(err error) { t.mu.Lock() // Make sure we only close once. @@ -991,7 +1006,10 @@ func (t *http2Client) Close(err error) { t.kpDormancyCond.Signal() } t.mu.Unlock() - t.controlBuf.finish() + // Per HTTP/2 spec, a GOAWAY frame must be sent before closing the + // connection. See https://httpwg.org/specs/rfc7540.html#GOAWAY. + t.controlBuf.put(&goAway{code: http2.ErrCodeNo, debugData: []byte("client transport shutdown"), closeConn: err}) + <-t.writerDone t.cancel() t.conn.Close() channelz.RemoveEntry(t.channelz.ID) @@ -1099,7 +1117,7 @@ func (t *http2Client) updateWindow(s *Stream, n uint32) { // for the transport and the stream based on the current bdp // estimation. func (t *http2Client) updateFlowControl(n uint32) { - updateIWS := func(any) bool { + updateIWS := func() bool { t.initialWindowSize = int32(n) t.mu.Lock() for _, s := range t.activeStreams { @@ -1252,7 +1270,7 @@ func (t *http2Client) handleSettings(f *http2.SettingsFrame, isFirst bool) { } updateFuncs = append(updateFuncs, updateStreamQuota) } - t.controlBuf.executeAndPut(func(any) bool { + t.controlBuf.executeAndPut(func() bool { for _, f := range updateFuncs { f() } diff --git a/vendor/google.golang.org/grpc/internal/transport/http2_server.go b/vendor/google.golang.org/grpc/internal/transport/http2_server.go index d582e047109..cab0e2d3d44 100644 --- a/vendor/google.golang.org/grpc/internal/transport/http2_server.go +++ b/vendor/google.golang.org/grpc/internal/transport/http2_server.go @@ -330,8 +330,7 @@ func NewServerTransport(conn net.Conn, config *ServerConfig) (_ ServerTransport, t.handleSettings(sf) go func() { - t.loopy = newLoopyWriter(serverSide, t.framer, t.controlBuf, t.bdpEst, t.conn, t.logger) - t.loopy.ssGoAwayHandler = t.outgoingGoAwayHandler + t.loopy = newLoopyWriter(serverSide, t.framer, t.controlBuf, t.bdpEst, t.conn, t.logger, t.outgoingGoAwayHandler) err := t.loopy.run() close(t.loopyWriterDone) if !isIOError(err) { @@ -860,7 +859,7 @@ func (t *http2Server) handleSettings(f *http2.SettingsFrame) { } return nil }) - t.controlBuf.executeAndPut(func(any) bool { + t.controlBuf.executeAndPut(func() bool { for _, f := range updateFuncs { f() } @@ -1014,12 +1013,13 @@ func (t *http2Server) writeHeaderLocked(s *Stream) error { headerFields = append(headerFields, hpack.HeaderField{Name: "grpc-encoding", Value: s.sendCompress}) } headerFields = appendHeaderFieldsFromMD(headerFields, s.header) - success, err := t.controlBuf.executeAndPut(t.checkForHeaderListSize, &headerFrame{ + hf := &headerFrame{ streamID: s.id, hf: headerFields, endStream: false, onWrite: t.setResetPingStrikes, - }) + } + success, err := t.controlBuf.executeAndPut(func() bool { return t.checkForHeaderListSize(hf) }, hf) if !success { if err != nil { return err @@ -1208,7 +1208,7 @@ func (t *http2Server) keepalive() { continue } if outstandingPing && kpTimeoutLeft <= 0 { - t.Close(fmt.Errorf("keepalive ping not acked within timeout %s", t.kp.Time)) + t.Close(fmt.Errorf("keepalive ping not acked within timeout %s", t.kp.Timeout)) return } if !outstandingPing { diff --git a/vendor/google.golang.org/grpc/internal/transport/transport.go b/vendor/google.golang.org/grpc/internal/transport/transport.go index 0d2a6e47f67..4b39c0ade97 100644 --- a/vendor/google.golang.org/grpc/internal/transport/transport.go +++ b/vendor/google.golang.org/grpc/internal/transport/transport.go @@ -304,7 +304,7 @@ func (s *Stream) isHeaderSent() bool { } // updateHeaderSent updates headerSent and returns true -// if it was alreay set. It is valid only on server-side. +// if it was already set. It is valid only on server-side. func (s *Stream) updateHeaderSent() bool { return atomic.SwapUint32(&s.headerSent, 1) == 1 } diff --git a/vendor/google.golang.org/grpc/metadata/metadata.go b/vendor/google.golang.org/grpc/metadata/metadata.go index 1e9485fd6e2..6c01a9b359c 100644 --- a/vendor/google.golang.org/grpc/metadata/metadata.go +++ b/vendor/google.golang.org/grpc/metadata/metadata.go @@ -90,6 +90,21 @@ func Pairs(kv ...string) MD { return md } +// String implements the Stringer interface for pretty-printing a MD. +// Ordering of the values is non-deterministic as it ranges over a map. +func (md MD) String() string { + var sb strings.Builder + fmt.Fprintf(&sb, "MD{") + for k, v := range md { + if sb.Len() > 3 { + fmt.Fprintf(&sb, ", ") + } + fmt.Fprintf(&sb, "%s=[%s]", k, strings.Join(v, ", ")) + } + fmt.Fprintf(&sb, "}") + return sb.String() +} + // Len returns the number of items in md. func (md MD) Len() int { return len(md) diff --git a/vendor/google.golang.org/grpc/peer/peer.go b/vendor/google.golang.org/grpc/peer/peer.go index a821ff9b2b7..499a49c8c1c 100644 --- a/vendor/google.golang.org/grpc/peer/peer.go +++ b/vendor/google.golang.org/grpc/peer/peer.go @@ -22,7 +22,9 @@ package peer import ( "context" + "fmt" "net" + "strings" "google.golang.org/grpc/credentials" ) @@ -39,6 +41,34 @@ type Peer struct { AuthInfo credentials.AuthInfo } +// String ensures the Peer types implements the Stringer interface in order to +// allow to print a context with a peerKey value effectively. +func (p *Peer) String() string { + if p == nil { + return "Peer" + } + sb := &strings.Builder{} + sb.WriteString("Peer{") + if p.Addr != nil { + fmt.Fprintf(sb, "Addr: '%s', ", p.Addr.String()) + } else { + fmt.Fprintf(sb, "Addr: , ") + } + if p.LocalAddr != nil { + fmt.Fprintf(sb, "LocalAddr: '%s', ", p.LocalAddr.String()) + } else { + fmt.Fprintf(sb, "LocalAddr: , ") + } + if p.AuthInfo != nil { + fmt.Fprintf(sb, "AuthInfo: '%s'", p.AuthInfo.AuthType()) + } else { + fmt.Fprintf(sb, "AuthInfo: ") + } + sb.WriteString("}") + + return sb.String() +} + type peerKey struct{} // NewContext creates a new context with peer information attached. diff --git a/vendor/google.golang.org/grpc/picker_wrapper.go b/vendor/google.golang.org/grpc/picker_wrapper.go index bf56faa76d3..56e8aba783f 100644 --- a/vendor/google.golang.org/grpc/picker_wrapper.go +++ b/vendor/google.golang.org/grpc/picker_wrapper.go @@ -20,6 +20,7 @@ package grpc import ( "context" + "fmt" "io" "sync" @@ -117,7 +118,7 @@ func (pw *pickerWrapper) pick(ctx context.Context, failfast bool, info balancer. if lastPickErr != nil { errStr = "latest balancer error: " + lastPickErr.Error() } else { - errStr = ctx.Err().Error() + errStr = fmt.Sprintf("received context error while waiting for new LB policy update: %s", ctx.Err().Error()) } switch ctx.Err() { case context.DeadlineExceeded: diff --git a/vendor/google.golang.org/grpc/pickfirst.go b/vendor/google.golang.org/grpc/pickfirst.go index e3ea42ba962..8853626614e 100644 --- a/vendor/google.golang.org/grpc/pickfirst.go +++ b/vendor/google.golang.org/grpc/pickfirst.go @@ -54,7 +54,7 @@ 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 + // of endpoints received from the name resolver before attempting to // connect to them. ShuffleAddressList bool `json:"shuffleAddressList"` } @@ -94,8 +94,7 @@ func (b *pickfirstBalancer) ResolverError(err error) { } func (b *pickfirstBalancer) UpdateClientConnState(state balancer.ClientConnState) error { - addrs := state.ResolverState.Addresses - if len(addrs) == 0 { + if len(state.ResolverState.Addresses) == 0 && len(state.ResolverState.Endpoints) == 0 { // The resolver reported an empty address list. Treat it like an error by // calling b.ResolverError. if b.subConn != nil { @@ -107,22 +106,49 @@ func (b *pickfirstBalancer) UpdateClientConnState(state balancer.ClientConnState 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)) } + var addrs []resolver.Address + if endpoints := state.ResolverState.Endpoints; len(endpoints) != 0 { + // Perform the optional shuffling described in gRFC A62. The shuffling will + // change the order of endpoints but not touch the order of the addresses + // within each endpoint. - A61 + if cfg.ShuffleAddressList { + endpoints = append([]resolver.Endpoint{}, endpoints...) + grpcrand.Shuffle(len(endpoints), func(i, j int) { endpoints[i], endpoints[j] = endpoints[j], endpoints[i] }) + } + + // "Flatten the list by concatenating the ordered list of addresses for each + // of the endpoints, in order." - A61 + for _, endpoint := range endpoints { + // "In the flattened list, interleave addresses from the two address + // families, as per RFC-8304 section 4." - A61 + // TODO: support the above language. + addrs = append(addrs, endpoint.Addresses...) + } + } else { + // Endpoints not set, process addresses until we migrate resolver + // emissions fully to Endpoints. The top channel does wrap emitted + // addresses with endpoints, however some balancers such as weighted + // target do not forwarrd the corresponding correct endpoints down/split + // endpoints properly. Once all balancers correctly forward endpoints + // down, can delete this else conditional. + addrs = state.ResolverState.Addresses + 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.subConn != nil { b.cc.UpdateAddresses(b.subConn, addrs) return nil diff --git a/vendor/google.golang.org/grpc/reflection/adapt.go b/vendor/google.golang.org/grpc/reflection/adapt.go index 33b907a36da..6997e474031 100644 --- a/vendor/google.golang.org/grpc/reflection/adapt.go +++ b/vendor/google.golang.org/grpc/reflection/adapt.go @@ -19,10 +19,11 @@ package reflection import ( + "google.golang.org/grpc/reflection/internal" + v1reflectiongrpc "google.golang.org/grpc/reflection/grpc_reflection_v1" v1reflectionpb "google.golang.org/grpc/reflection/grpc_reflection_v1" v1alphareflectiongrpc "google.golang.org/grpc/reflection/grpc_reflection_v1alpha" - v1alphareflectionpb "google.golang.org/grpc/reflection/grpc_reflection_v1alpha" ) // asV1Alpha returns an implementation of the v1alpha version of the reflection @@ -44,7 +45,7 @@ type v1AlphaServerStreamAdapter struct { } func (s v1AlphaServerStreamAdapter) Send(response *v1reflectionpb.ServerReflectionResponse) error { - return s.ServerReflection_ServerReflectionInfoServer.Send(v1ToV1AlphaResponse(response)) + return s.ServerReflection_ServerReflectionInfoServer.Send(internal.V1ToV1AlphaResponse(response)) } func (s v1AlphaServerStreamAdapter) Recv() (*v1reflectionpb.ServerReflectionRequest, error) { @@ -52,136 +53,5 @@ func (s v1AlphaServerStreamAdapter) Recv() (*v1reflectionpb.ServerReflectionRequ if err != nil { return nil, err } - return v1AlphaToV1Request(resp), nil -} - -func v1ToV1AlphaResponse(v1 *v1reflectionpb.ServerReflectionResponse) *v1alphareflectionpb.ServerReflectionResponse { - var v1alpha v1alphareflectionpb.ServerReflectionResponse - v1alpha.ValidHost = v1.ValidHost - if v1.OriginalRequest != nil { - v1alpha.OriginalRequest = v1ToV1AlphaRequest(v1.OriginalRequest) - } - switch mr := v1.MessageResponse.(type) { - case *v1reflectionpb.ServerReflectionResponse_FileDescriptorResponse: - if mr != nil { - v1alpha.MessageResponse = &v1alphareflectionpb.ServerReflectionResponse_FileDescriptorResponse{ - FileDescriptorResponse: &v1alphareflectionpb.FileDescriptorResponse{ - FileDescriptorProto: mr.FileDescriptorResponse.GetFileDescriptorProto(), - }, - } - } - case *v1reflectionpb.ServerReflectionResponse_AllExtensionNumbersResponse: - if mr != nil { - v1alpha.MessageResponse = &v1alphareflectionpb.ServerReflectionResponse_AllExtensionNumbersResponse{ - AllExtensionNumbersResponse: &v1alphareflectionpb.ExtensionNumberResponse{ - BaseTypeName: mr.AllExtensionNumbersResponse.GetBaseTypeName(), - ExtensionNumber: mr.AllExtensionNumbersResponse.GetExtensionNumber(), - }, - } - } - case *v1reflectionpb.ServerReflectionResponse_ListServicesResponse: - if mr != nil { - svcs := make([]*v1alphareflectionpb.ServiceResponse, len(mr.ListServicesResponse.GetService())) - for i, svc := range mr.ListServicesResponse.GetService() { - svcs[i] = &v1alphareflectionpb.ServiceResponse{ - Name: svc.GetName(), - } - } - v1alpha.MessageResponse = &v1alphareflectionpb.ServerReflectionResponse_ListServicesResponse{ - ListServicesResponse: &v1alphareflectionpb.ListServiceResponse{ - Service: svcs, - }, - } - } - case *v1reflectionpb.ServerReflectionResponse_ErrorResponse: - if mr != nil { - v1alpha.MessageResponse = &v1alphareflectionpb.ServerReflectionResponse_ErrorResponse{ - ErrorResponse: &v1alphareflectionpb.ErrorResponse{ - ErrorCode: mr.ErrorResponse.GetErrorCode(), - ErrorMessage: mr.ErrorResponse.GetErrorMessage(), - }, - } - } - default: - // no value set - } - return &v1alpha -} - -func v1AlphaToV1Request(v1alpha *v1alphareflectionpb.ServerReflectionRequest) *v1reflectionpb.ServerReflectionRequest { - var v1 v1reflectionpb.ServerReflectionRequest - v1.Host = v1alpha.Host - switch mr := v1alpha.MessageRequest.(type) { - case *v1alphareflectionpb.ServerReflectionRequest_FileByFilename: - v1.MessageRequest = &v1reflectionpb.ServerReflectionRequest_FileByFilename{ - FileByFilename: mr.FileByFilename, - } - case *v1alphareflectionpb.ServerReflectionRequest_FileContainingSymbol: - v1.MessageRequest = &v1reflectionpb.ServerReflectionRequest_FileContainingSymbol{ - FileContainingSymbol: mr.FileContainingSymbol, - } - case *v1alphareflectionpb.ServerReflectionRequest_FileContainingExtension: - if mr.FileContainingExtension != nil { - v1.MessageRequest = &v1reflectionpb.ServerReflectionRequest_FileContainingExtension{ - FileContainingExtension: &v1reflectionpb.ExtensionRequest{ - ContainingType: mr.FileContainingExtension.GetContainingType(), - ExtensionNumber: mr.FileContainingExtension.GetExtensionNumber(), - }, - } - } - case *v1alphareflectionpb.ServerReflectionRequest_AllExtensionNumbersOfType: - v1.MessageRequest = &v1reflectionpb.ServerReflectionRequest_AllExtensionNumbersOfType{ - AllExtensionNumbersOfType: mr.AllExtensionNumbersOfType, - } - case *v1alphareflectionpb.ServerReflectionRequest_ListServices: - v1.MessageRequest = &v1reflectionpb.ServerReflectionRequest_ListServices{ - ListServices: mr.ListServices, - } - default: - // no value set - } - return &v1 -} - -func v1ToV1AlphaRequest(v1 *v1reflectionpb.ServerReflectionRequest) *v1alphareflectionpb.ServerReflectionRequest { - var v1alpha v1alphareflectionpb.ServerReflectionRequest - v1alpha.Host = v1.Host - switch mr := v1.MessageRequest.(type) { - case *v1reflectionpb.ServerReflectionRequest_FileByFilename: - if mr != nil { - v1alpha.MessageRequest = &v1alphareflectionpb.ServerReflectionRequest_FileByFilename{ - FileByFilename: mr.FileByFilename, - } - } - case *v1reflectionpb.ServerReflectionRequest_FileContainingSymbol: - if mr != nil { - v1alpha.MessageRequest = &v1alphareflectionpb.ServerReflectionRequest_FileContainingSymbol{ - FileContainingSymbol: mr.FileContainingSymbol, - } - } - case *v1reflectionpb.ServerReflectionRequest_FileContainingExtension: - if mr != nil { - v1alpha.MessageRequest = &v1alphareflectionpb.ServerReflectionRequest_FileContainingExtension{ - FileContainingExtension: &v1alphareflectionpb.ExtensionRequest{ - ContainingType: mr.FileContainingExtension.GetContainingType(), - ExtensionNumber: mr.FileContainingExtension.GetExtensionNumber(), - }, - } - } - case *v1reflectionpb.ServerReflectionRequest_AllExtensionNumbersOfType: - if mr != nil { - v1alpha.MessageRequest = &v1alphareflectionpb.ServerReflectionRequest_AllExtensionNumbersOfType{ - AllExtensionNumbersOfType: mr.AllExtensionNumbersOfType, - } - } - case *v1reflectionpb.ServerReflectionRequest_ListServices: - if mr != nil { - v1alpha.MessageRequest = &v1alphareflectionpb.ServerReflectionRequest_ListServices{ - ListServices: mr.ListServices, - } - } - default: - // no value set - } - return &v1alpha + return internal.V1AlphaToV1Request(resp), nil } diff --git a/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection.pb.go b/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection.pb.go index 8953c9d8d68..6c49c2333b1 100644 --- a/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection.pb.go +++ b/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection.pb.go @@ -21,7 +21,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.25.2 // source: grpc/reflection/v1/reflection.proto diff --git a/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection_grpc.pb.go b/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection_grpc.pb.go index d6cdd5b54c6..6e544f81e4e 100644 --- a/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection_grpc.pb.go +++ b/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection_grpc.pb.go @@ -36,8 +36,8 @@ import ( // 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 +// Requires gRPC-Go v1.62.0 or later. +const _ = grpc.SupportPackageIsVersion8 const ( ServerReflection_ServerReflectionInfo_FullMethodName = "/grpc.reflection.v1.ServerReflection/ServerReflectionInfo" @@ -61,11 +61,12 @@ func NewServerReflectionClient(cc grpc.ClientConnInterface) ServerReflectionClie } func (c *serverReflectionClient) ServerReflectionInfo(ctx context.Context, opts ...grpc.CallOption) (ServerReflection_ServerReflectionInfoClient, error) { - stream, err := c.cc.NewStream(ctx, &ServerReflection_ServiceDesc.Streams[0], ServerReflection_ServerReflectionInfo_FullMethodName, opts...) + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + stream, err := c.cc.NewStream(ctx, &ServerReflection_ServiceDesc.Streams[0], ServerReflection_ServerReflectionInfo_FullMethodName, cOpts...) if err != nil { return nil, err } - x := &serverReflectionServerReflectionInfoClient{stream} + x := &serverReflectionServerReflectionInfoClient{ClientStream: stream} return x, nil } @@ -120,7 +121,7 @@ func RegisterServerReflectionServer(s grpc.ServiceRegistrar, srv ServerReflectio } func _ServerReflection_ServerReflectionInfo_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(ServerReflectionServer).ServerReflectionInfo(&serverReflectionServerReflectionInfoServer{stream}) + return srv.(ServerReflectionServer).ServerReflectionInfo(&serverReflectionServerReflectionInfoServer{ServerStream: stream}) } type ServerReflection_ServerReflectionInfoServer interface { diff --git a/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection.pb.go b/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection.pb.go index 929733e7bda..909b24a19da 100644 --- a/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection.pb.go +++ b/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection.pb.go @@ -18,7 +18,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.25.2 // grpc/reflection/v1alpha/reflection.proto is a deprecated file. diff --git a/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection_grpc.pb.go b/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection_grpc.pb.go index ef691406355..3de5dc354f6 100644 --- a/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection_grpc.pb.go +++ b/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection_grpc.pb.go @@ -33,8 +33,8 @@ import ( // 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 +// Requires gRPC-Go v1.62.0 or later. +const _ = grpc.SupportPackageIsVersion8 const ( ServerReflection_ServerReflectionInfo_FullMethodName = "/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo" @@ -58,11 +58,12 @@ func NewServerReflectionClient(cc grpc.ClientConnInterface) ServerReflectionClie } func (c *serverReflectionClient) ServerReflectionInfo(ctx context.Context, opts ...grpc.CallOption) (ServerReflection_ServerReflectionInfoClient, error) { - stream, err := c.cc.NewStream(ctx, &ServerReflection_ServiceDesc.Streams[0], ServerReflection_ServerReflectionInfo_FullMethodName, opts...) + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + stream, err := c.cc.NewStream(ctx, &ServerReflection_ServiceDesc.Streams[0], ServerReflection_ServerReflectionInfo_FullMethodName, cOpts...) if err != nil { return nil, err } - x := &serverReflectionServerReflectionInfoClient{stream} + x := &serverReflectionServerReflectionInfoClient{ClientStream: stream} return x, nil } @@ -117,7 +118,7 @@ func RegisterServerReflectionServer(s grpc.ServiceRegistrar, srv ServerReflectio } func _ServerReflection_ServerReflectionInfo_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(ServerReflectionServer).ServerReflectionInfo(&serverReflectionServerReflectionInfoServer{stream}) + return srv.(ServerReflectionServer).ServerReflectionInfo(&serverReflectionServerReflectionInfoServer{ServerStream: stream}) } type ServerReflection_ServerReflectionInfoServer interface { diff --git a/vendor/google.golang.org/grpc/reflection/internal/internal.go b/vendor/google.golang.org/grpc/reflection/internal/internal.go new file mode 100644 index 00000000000..36ee6507507 --- /dev/null +++ b/vendor/google.golang.org/grpc/reflection/internal/internal.go @@ -0,0 +1,436 @@ +/* + * + * 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 internal contains code that is shared by both reflection package and +// the test package. The packages are split in this way inorder to avoid +// depenedency to deprecated package github.com/golang/protobuf. +package internal + +import ( + "io" + "sort" + + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protodesc" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/reflect/protoregistry" + + v1reflectiongrpc "google.golang.org/grpc/reflection/grpc_reflection_v1" + v1reflectionpb "google.golang.org/grpc/reflection/grpc_reflection_v1" + v1alphareflectiongrpc "google.golang.org/grpc/reflection/grpc_reflection_v1alpha" + v1alphareflectionpb "google.golang.org/grpc/reflection/grpc_reflection_v1alpha" +) + +// ServiceInfoProvider is an interface used to retrieve metadata about the +// services to expose. +type ServiceInfoProvider interface { + GetServiceInfo() map[string]grpc.ServiceInfo +} + +// ExtensionResolver is the interface used to query details about extensions. +// This interface is satisfied by protoregistry.GlobalTypes. +type ExtensionResolver interface { + protoregistry.ExtensionTypeResolver + RangeExtensionsByMessage(message protoreflect.FullName, f func(protoreflect.ExtensionType) bool) +} + +// ServerReflectionServer is the server API for ServerReflection service. +type ServerReflectionServer struct { + v1alphareflectiongrpc.UnimplementedServerReflectionServer + S ServiceInfoProvider + DescResolver protodesc.Resolver + ExtResolver ExtensionResolver +} + +// FileDescWithDependencies returns a slice of serialized fileDescriptors in +// wire format ([]byte). The fileDescriptors will include fd and all the +// transitive dependencies of fd with names not in sentFileDescriptors. +func (s *ServerReflectionServer) FileDescWithDependencies(fd protoreflect.FileDescriptor, sentFileDescriptors map[string]bool) ([][]byte, error) { + if fd.IsPlaceholder() { + // If the given root file is a placeholder, treat it + // as missing instead of serializing it. + return nil, protoregistry.NotFound + } + var r [][]byte + queue := []protoreflect.FileDescriptor{fd} + for len(queue) > 0 { + currentfd := queue[0] + queue = queue[1:] + if currentfd.IsPlaceholder() { + // Skip any missing files in the dependency graph. + continue + } + if sent := sentFileDescriptors[currentfd.Path()]; len(r) == 0 || !sent { + sentFileDescriptors[currentfd.Path()] = true + fdProto := protodesc.ToFileDescriptorProto(currentfd) + currentfdEncoded, err := proto.Marshal(fdProto) + if err != nil { + return nil, err + } + r = append(r, currentfdEncoded) + } + for i := 0; i < currentfd.Imports().Len(); i++ { + queue = append(queue, currentfd.Imports().Get(i)) + } + } + return r, nil +} + +// FileDescEncodingContainingSymbol finds the file descriptor containing the +// given symbol, finds all of its previously unsent transitive dependencies, +// does marshalling on them, and returns the marshalled result. The given symbol +// can be a type, a service or a method. +func (s *ServerReflectionServer) FileDescEncodingContainingSymbol(name string, sentFileDescriptors map[string]bool) ([][]byte, error) { + d, err := s.DescResolver.FindDescriptorByName(protoreflect.FullName(name)) + if err != nil { + return nil, err + } + return s.FileDescWithDependencies(d.ParentFile(), sentFileDescriptors) +} + +// FileDescEncodingContainingExtension finds the file descriptor containing +// given extension, finds all of its previously unsent transitive dependencies, +// does marshalling on them, and returns the marshalled result. +func (s *ServerReflectionServer) FileDescEncodingContainingExtension(typeName string, extNum int32, sentFileDescriptors map[string]bool) ([][]byte, error) { + xt, err := s.ExtResolver.FindExtensionByNumber(protoreflect.FullName(typeName), protoreflect.FieldNumber(extNum)) + if err != nil { + return nil, err + } + return s.FileDescWithDependencies(xt.TypeDescriptor().ParentFile(), sentFileDescriptors) +} + +// AllExtensionNumbersForTypeName returns all extension numbers for the given type. +func (s *ServerReflectionServer) AllExtensionNumbersForTypeName(name string) ([]int32, error) { + var numbers []int32 + s.ExtResolver.RangeExtensionsByMessage(protoreflect.FullName(name), func(xt protoreflect.ExtensionType) bool { + numbers = append(numbers, int32(xt.TypeDescriptor().Number())) + return true + }) + sort.Slice(numbers, func(i, j int) bool { + return numbers[i] < numbers[j] + }) + if len(numbers) == 0 { + // maybe return an error if given type name is not known + if _, err := s.DescResolver.FindDescriptorByName(protoreflect.FullName(name)); err != nil { + return nil, err + } + } + return numbers, nil +} + +// ListServices returns the names of services this server exposes. +func (s *ServerReflectionServer) ListServices() []*v1reflectionpb.ServiceResponse { + serviceInfo := s.S.GetServiceInfo() + resp := make([]*v1reflectionpb.ServiceResponse, 0, len(serviceInfo)) + for svc := range serviceInfo { + resp = append(resp, &v1reflectionpb.ServiceResponse{Name: svc}) + } + sort.Slice(resp, func(i, j int) bool { + return resp[i].Name < resp[j].Name + }) + return resp +} + +// ServerReflectionInfo is the reflection service handler. +func (s *ServerReflectionServer) ServerReflectionInfo(stream v1reflectiongrpc.ServerReflection_ServerReflectionInfoServer) error { + sentFileDescriptors := make(map[string]bool) + for { + in, err := stream.Recv() + if err == io.EOF { + return nil + } + if err != nil { + return err + } + + out := &v1reflectionpb.ServerReflectionResponse{ + ValidHost: in.Host, + OriginalRequest: in, + } + switch req := in.MessageRequest.(type) { + case *v1reflectionpb.ServerReflectionRequest_FileByFilename: + var b [][]byte + fd, err := s.DescResolver.FindFileByPath(req.FileByFilename) + if err == nil { + b, err = s.FileDescWithDependencies(fd, sentFileDescriptors) + } + if err != nil { + out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_ErrorResponse{ + ErrorResponse: &v1reflectionpb.ErrorResponse{ + ErrorCode: int32(codes.NotFound), + ErrorMessage: err.Error(), + }, + } + } else { + out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_FileDescriptorResponse{ + FileDescriptorResponse: &v1reflectionpb.FileDescriptorResponse{FileDescriptorProto: b}, + } + } + case *v1reflectionpb.ServerReflectionRequest_FileContainingSymbol: + b, err := s.FileDescEncodingContainingSymbol(req.FileContainingSymbol, sentFileDescriptors) + if err != nil { + out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_ErrorResponse{ + ErrorResponse: &v1reflectionpb.ErrorResponse{ + ErrorCode: int32(codes.NotFound), + ErrorMessage: err.Error(), + }, + } + } else { + out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_FileDescriptorResponse{ + FileDescriptorResponse: &v1reflectionpb.FileDescriptorResponse{FileDescriptorProto: b}, + } + } + case *v1reflectionpb.ServerReflectionRequest_FileContainingExtension: + typeName := req.FileContainingExtension.ContainingType + extNum := req.FileContainingExtension.ExtensionNumber + b, err := s.FileDescEncodingContainingExtension(typeName, extNum, sentFileDescriptors) + if err != nil { + out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_ErrorResponse{ + ErrorResponse: &v1reflectionpb.ErrorResponse{ + ErrorCode: int32(codes.NotFound), + ErrorMessage: err.Error(), + }, + } + } else { + out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_FileDescriptorResponse{ + FileDescriptorResponse: &v1reflectionpb.FileDescriptorResponse{FileDescriptorProto: b}, + } + } + case *v1reflectionpb.ServerReflectionRequest_AllExtensionNumbersOfType: + extNums, err := s.AllExtensionNumbersForTypeName(req.AllExtensionNumbersOfType) + if err != nil { + out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_ErrorResponse{ + ErrorResponse: &v1reflectionpb.ErrorResponse{ + ErrorCode: int32(codes.NotFound), + ErrorMessage: err.Error(), + }, + } + } else { + out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_AllExtensionNumbersResponse{ + AllExtensionNumbersResponse: &v1reflectionpb.ExtensionNumberResponse{ + BaseTypeName: req.AllExtensionNumbersOfType, + ExtensionNumber: extNums, + }, + } + } + case *v1reflectionpb.ServerReflectionRequest_ListServices: + out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_ListServicesResponse{ + ListServicesResponse: &v1reflectionpb.ListServiceResponse{ + Service: s.ListServices(), + }, + } + default: + return status.Errorf(codes.InvalidArgument, "invalid MessageRequest: %v", in.MessageRequest) + } + + if err := stream.Send(out); err != nil { + return err + } + } +} + +// V1ToV1AlphaResponse converts a v1 ServerReflectionResponse to a v1alpha. +func V1ToV1AlphaResponse(v1 *v1reflectionpb.ServerReflectionResponse) *v1alphareflectionpb.ServerReflectionResponse { + var v1alpha v1alphareflectionpb.ServerReflectionResponse + v1alpha.ValidHost = v1.ValidHost + if v1.OriginalRequest != nil { + v1alpha.OriginalRequest = V1ToV1AlphaRequest(v1.OriginalRequest) + } + switch mr := v1.MessageResponse.(type) { + case *v1reflectionpb.ServerReflectionResponse_FileDescriptorResponse: + if mr != nil { + v1alpha.MessageResponse = &v1alphareflectionpb.ServerReflectionResponse_FileDescriptorResponse{ + FileDescriptorResponse: &v1alphareflectionpb.FileDescriptorResponse{ + FileDescriptorProto: mr.FileDescriptorResponse.GetFileDescriptorProto(), + }, + } + } + case *v1reflectionpb.ServerReflectionResponse_AllExtensionNumbersResponse: + if mr != nil { + v1alpha.MessageResponse = &v1alphareflectionpb.ServerReflectionResponse_AllExtensionNumbersResponse{ + AllExtensionNumbersResponse: &v1alphareflectionpb.ExtensionNumberResponse{ + BaseTypeName: mr.AllExtensionNumbersResponse.GetBaseTypeName(), + ExtensionNumber: mr.AllExtensionNumbersResponse.GetExtensionNumber(), + }, + } + } + case *v1reflectionpb.ServerReflectionResponse_ListServicesResponse: + if mr != nil { + svcs := make([]*v1alphareflectionpb.ServiceResponse, len(mr.ListServicesResponse.GetService())) + for i, svc := range mr.ListServicesResponse.GetService() { + svcs[i] = &v1alphareflectionpb.ServiceResponse{ + Name: svc.GetName(), + } + } + v1alpha.MessageResponse = &v1alphareflectionpb.ServerReflectionResponse_ListServicesResponse{ + ListServicesResponse: &v1alphareflectionpb.ListServiceResponse{ + Service: svcs, + }, + } + } + case *v1reflectionpb.ServerReflectionResponse_ErrorResponse: + if mr != nil { + v1alpha.MessageResponse = &v1alphareflectionpb.ServerReflectionResponse_ErrorResponse{ + ErrorResponse: &v1alphareflectionpb.ErrorResponse{ + ErrorCode: mr.ErrorResponse.GetErrorCode(), + ErrorMessage: mr.ErrorResponse.GetErrorMessage(), + }, + } + } + default: + // no value set + } + return &v1alpha +} + +// V1AlphaToV1Request converts a v1alpha ServerReflectionRequest to a v1. +func V1AlphaToV1Request(v1alpha *v1alphareflectionpb.ServerReflectionRequest) *v1reflectionpb.ServerReflectionRequest { + var v1 v1reflectionpb.ServerReflectionRequest + v1.Host = v1alpha.Host + switch mr := v1alpha.MessageRequest.(type) { + case *v1alphareflectionpb.ServerReflectionRequest_FileByFilename: + v1.MessageRequest = &v1reflectionpb.ServerReflectionRequest_FileByFilename{ + FileByFilename: mr.FileByFilename, + } + case *v1alphareflectionpb.ServerReflectionRequest_FileContainingSymbol: + v1.MessageRequest = &v1reflectionpb.ServerReflectionRequest_FileContainingSymbol{ + FileContainingSymbol: mr.FileContainingSymbol, + } + case *v1alphareflectionpb.ServerReflectionRequest_FileContainingExtension: + if mr.FileContainingExtension != nil { + v1.MessageRequest = &v1reflectionpb.ServerReflectionRequest_FileContainingExtension{ + FileContainingExtension: &v1reflectionpb.ExtensionRequest{ + ContainingType: mr.FileContainingExtension.GetContainingType(), + ExtensionNumber: mr.FileContainingExtension.GetExtensionNumber(), + }, + } + } + case *v1alphareflectionpb.ServerReflectionRequest_AllExtensionNumbersOfType: + v1.MessageRequest = &v1reflectionpb.ServerReflectionRequest_AllExtensionNumbersOfType{ + AllExtensionNumbersOfType: mr.AllExtensionNumbersOfType, + } + case *v1alphareflectionpb.ServerReflectionRequest_ListServices: + v1.MessageRequest = &v1reflectionpb.ServerReflectionRequest_ListServices{ + ListServices: mr.ListServices, + } + default: + // no value set + } + return &v1 +} + +// V1ToV1AlphaRequest converts a v1 ServerReflectionRequest to a v1alpha. +func V1ToV1AlphaRequest(v1 *v1reflectionpb.ServerReflectionRequest) *v1alphareflectionpb.ServerReflectionRequest { + var v1alpha v1alphareflectionpb.ServerReflectionRequest + v1alpha.Host = v1.Host + switch mr := v1.MessageRequest.(type) { + case *v1reflectionpb.ServerReflectionRequest_FileByFilename: + if mr != nil { + v1alpha.MessageRequest = &v1alphareflectionpb.ServerReflectionRequest_FileByFilename{ + FileByFilename: mr.FileByFilename, + } + } + case *v1reflectionpb.ServerReflectionRequest_FileContainingSymbol: + if mr != nil { + v1alpha.MessageRequest = &v1alphareflectionpb.ServerReflectionRequest_FileContainingSymbol{ + FileContainingSymbol: mr.FileContainingSymbol, + } + } + case *v1reflectionpb.ServerReflectionRequest_FileContainingExtension: + if mr != nil { + v1alpha.MessageRequest = &v1alphareflectionpb.ServerReflectionRequest_FileContainingExtension{ + FileContainingExtension: &v1alphareflectionpb.ExtensionRequest{ + ContainingType: mr.FileContainingExtension.GetContainingType(), + ExtensionNumber: mr.FileContainingExtension.GetExtensionNumber(), + }, + } + } + case *v1reflectionpb.ServerReflectionRequest_AllExtensionNumbersOfType: + if mr != nil { + v1alpha.MessageRequest = &v1alphareflectionpb.ServerReflectionRequest_AllExtensionNumbersOfType{ + AllExtensionNumbersOfType: mr.AllExtensionNumbersOfType, + } + } + case *v1reflectionpb.ServerReflectionRequest_ListServices: + if mr != nil { + v1alpha.MessageRequest = &v1alphareflectionpb.ServerReflectionRequest_ListServices{ + ListServices: mr.ListServices, + } + } + default: + // no value set + } + return &v1alpha +} + +// V1AlphaToV1Response converts a v1alpha ServerReflectionResponse to a v1. +func V1AlphaToV1Response(v1alpha *v1alphareflectionpb.ServerReflectionResponse) *v1reflectionpb.ServerReflectionResponse { + var v1 v1reflectionpb.ServerReflectionResponse + v1.ValidHost = v1alpha.ValidHost + if v1alpha.OriginalRequest != nil { + v1.OriginalRequest = V1AlphaToV1Request(v1alpha.OriginalRequest) + } + switch mr := v1alpha.MessageResponse.(type) { + case *v1alphareflectionpb.ServerReflectionResponse_FileDescriptorResponse: + if mr != nil { + v1.MessageResponse = &v1reflectionpb.ServerReflectionResponse_FileDescriptorResponse{ + FileDescriptorResponse: &v1reflectionpb.FileDescriptorResponse{ + FileDescriptorProto: mr.FileDescriptorResponse.GetFileDescriptorProto(), + }, + } + } + case *v1alphareflectionpb.ServerReflectionResponse_AllExtensionNumbersResponse: + if mr != nil { + v1.MessageResponse = &v1reflectionpb.ServerReflectionResponse_AllExtensionNumbersResponse{ + AllExtensionNumbersResponse: &v1reflectionpb.ExtensionNumberResponse{ + BaseTypeName: mr.AllExtensionNumbersResponse.GetBaseTypeName(), + ExtensionNumber: mr.AllExtensionNumbersResponse.GetExtensionNumber(), + }, + } + } + case *v1alphareflectionpb.ServerReflectionResponse_ListServicesResponse: + if mr != nil { + svcs := make([]*v1reflectionpb.ServiceResponse, len(mr.ListServicesResponse.GetService())) + for i, svc := range mr.ListServicesResponse.GetService() { + svcs[i] = &v1reflectionpb.ServiceResponse{ + Name: svc.GetName(), + } + } + v1.MessageResponse = &v1reflectionpb.ServerReflectionResponse_ListServicesResponse{ + ListServicesResponse: &v1reflectionpb.ListServiceResponse{ + Service: svcs, + }, + } + } + case *v1alphareflectionpb.ServerReflectionResponse_ErrorResponse: + if mr != nil { + v1.MessageResponse = &v1reflectionpb.ServerReflectionResponse_ErrorResponse{ + ErrorResponse: &v1reflectionpb.ErrorResponse{ + ErrorCode: mr.ErrorResponse.GetErrorCode(), + ErrorMessage: mr.ErrorResponse.GetErrorMessage(), + }, + } + } + default: + // no value set + } + return &v1 +} diff --git a/vendor/google.golang.org/grpc/reflection/serverreflection.go b/vendor/google.golang.org/grpc/reflection/serverreflection.go index c3b408392f6..13a94e2dd2e 100644 --- a/vendor/google.golang.org/grpc/reflection/serverreflection.go +++ b/vendor/google.golang.org/grpc/reflection/serverreflection.go @@ -37,19 +37,13 @@ To register server reflection on a gRPC server: package reflection // import "google.golang.org/grpc/reflection" import ( - "io" - "sort" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" + "google.golang.org/grpc/reflection/internal" "google.golang.org/protobuf/reflect/protodesc" "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/reflect/protoregistry" v1reflectiongrpc "google.golang.org/grpc/reflection/grpc_reflection_v1" - v1reflectionpb "google.golang.org/grpc/reflection/grpc_reflection_v1" v1alphareflectiongrpc "google.golang.org/grpc/reflection/grpc_reflection_v1alpha" ) @@ -158,203 +152,9 @@ func NewServerV1(opts ServerOptions) v1reflectiongrpc.ServerReflectionServer { if opts.ExtensionResolver == nil { opts.ExtensionResolver = protoregistry.GlobalTypes } - return &serverReflectionServer{ - s: opts.Services, - descResolver: opts.DescriptorResolver, - extResolver: opts.ExtensionResolver, - } -} - -type serverReflectionServer struct { - v1alphareflectiongrpc.UnimplementedServerReflectionServer - s ServiceInfoProvider - descResolver protodesc.Resolver - extResolver ExtensionResolver -} - -// fileDescWithDependencies returns a slice of serialized fileDescriptors in -// wire format ([]byte). The fileDescriptors will include fd and all the -// transitive dependencies of fd with names not in sentFileDescriptors. -func (s *serverReflectionServer) fileDescWithDependencies(fd protoreflect.FileDescriptor, sentFileDescriptors map[string]bool) ([][]byte, error) { - if fd.IsPlaceholder() { - // If the given root file is a placeholder, treat it - // as missing instead of serializing it. - return nil, protoregistry.NotFound - } - var r [][]byte - queue := []protoreflect.FileDescriptor{fd} - for len(queue) > 0 { - currentfd := queue[0] - queue = queue[1:] - if currentfd.IsPlaceholder() { - // Skip any missing files in the dependency graph. - continue - } - if sent := sentFileDescriptors[currentfd.Path()]; len(r) == 0 || !sent { - sentFileDescriptors[currentfd.Path()] = true - fdProto := protodesc.ToFileDescriptorProto(currentfd) - currentfdEncoded, err := proto.Marshal(fdProto) - if err != nil { - return nil, err - } - r = append(r, currentfdEncoded) - } - for i := 0; i < currentfd.Imports().Len(); i++ { - queue = append(queue, currentfd.Imports().Get(i)) - } - } - return r, nil -} - -// fileDescEncodingContainingSymbol finds the file descriptor containing the -// given symbol, finds all of its previously unsent transitive dependencies, -// does marshalling on them, and returns the marshalled result. The given symbol -// can be a type, a service or a method. -func (s *serverReflectionServer) fileDescEncodingContainingSymbol(name string, sentFileDescriptors map[string]bool) ([][]byte, error) { - d, err := s.descResolver.FindDescriptorByName(protoreflect.FullName(name)) - if err != nil { - return nil, err - } - return s.fileDescWithDependencies(d.ParentFile(), sentFileDescriptors) -} - -// fileDescEncodingContainingExtension finds the file descriptor containing -// given extension, finds all of its previously unsent transitive dependencies, -// does marshalling on them, and returns the marshalled result. -func (s *serverReflectionServer) fileDescEncodingContainingExtension(typeName string, extNum int32, sentFileDescriptors map[string]bool) ([][]byte, error) { - xt, err := s.extResolver.FindExtensionByNumber(protoreflect.FullName(typeName), protoreflect.FieldNumber(extNum)) - if err != nil { - return nil, err - } - return s.fileDescWithDependencies(xt.TypeDescriptor().ParentFile(), sentFileDescriptors) -} - -// allExtensionNumbersForTypeName returns all extension numbers for the given type. -func (s *serverReflectionServer) allExtensionNumbersForTypeName(name string) ([]int32, error) { - var numbers []int32 - s.extResolver.RangeExtensionsByMessage(protoreflect.FullName(name), func(xt protoreflect.ExtensionType) bool { - numbers = append(numbers, int32(xt.TypeDescriptor().Number())) - return true - }) - sort.Slice(numbers, func(i, j int) bool { - return numbers[i] < numbers[j] - }) - if len(numbers) == 0 { - // maybe return an error if given type name is not known - if _, err := s.descResolver.FindDescriptorByName(protoreflect.FullName(name)); err != nil { - return nil, err - } - } - return numbers, nil -} - -// listServices returns the names of services this server exposes. -func (s *serverReflectionServer) listServices() []*v1reflectionpb.ServiceResponse { - serviceInfo := s.s.GetServiceInfo() - resp := make([]*v1reflectionpb.ServiceResponse, 0, len(serviceInfo)) - for svc := range serviceInfo { - resp = append(resp, &v1reflectionpb.ServiceResponse{Name: svc}) - } - sort.Slice(resp, func(i, j int) bool { - return resp[i].Name < resp[j].Name - }) - return resp -} - -// ServerReflectionInfo is the reflection service handler. -func (s *serverReflectionServer) ServerReflectionInfo(stream v1reflectiongrpc.ServerReflection_ServerReflectionInfoServer) error { - sentFileDescriptors := make(map[string]bool) - for { - in, err := stream.Recv() - if err == io.EOF { - return nil - } - if err != nil { - return err - } - - out := &v1reflectionpb.ServerReflectionResponse{ - ValidHost: in.Host, - OriginalRequest: in, - } - switch req := in.MessageRequest.(type) { - case *v1reflectionpb.ServerReflectionRequest_FileByFilename: - var b [][]byte - fd, err := s.descResolver.FindFileByPath(req.FileByFilename) - if err == nil { - b, err = s.fileDescWithDependencies(fd, sentFileDescriptors) - } - if err != nil { - out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_ErrorResponse{ - ErrorResponse: &v1reflectionpb.ErrorResponse{ - ErrorCode: int32(codes.NotFound), - ErrorMessage: err.Error(), - }, - } - } else { - out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_FileDescriptorResponse{ - FileDescriptorResponse: &v1reflectionpb.FileDescriptorResponse{FileDescriptorProto: b}, - } - } - case *v1reflectionpb.ServerReflectionRequest_FileContainingSymbol: - b, err := s.fileDescEncodingContainingSymbol(req.FileContainingSymbol, sentFileDescriptors) - if err != nil { - out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_ErrorResponse{ - ErrorResponse: &v1reflectionpb.ErrorResponse{ - ErrorCode: int32(codes.NotFound), - ErrorMessage: err.Error(), - }, - } - } else { - out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_FileDescriptorResponse{ - FileDescriptorResponse: &v1reflectionpb.FileDescriptorResponse{FileDescriptorProto: b}, - } - } - case *v1reflectionpb.ServerReflectionRequest_FileContainingExtension: - typeName := req.FileContainingExtension.ContainingType - extNum := req.FileContainingExtension.ExtensionNumber - b, err := s.fileDescEncodingContainingExtension(typeName, extNum, sentFileDescriptors) - if err != nil { - out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_ErrorResponse{ - ErrorResponse: &v1reflectionpb.ErrorResponse{ - ErrorCode: int32(codes.NotFound), - ErrorMessage: err.Error(), - }, - } - } else { - out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_FileDescriptorResponse{ - FileDescriptorResponse: &v1reflectionpb.FileDescriptorResponse{FileDescriptorProto: b}, - } - } - case *v1reflectionpb.ServerReflectionRequest_AllExtensionNumbersOfType: - extNums, err := s.allExtensionNumbersForTypeName(req.AllExtensionNumbersOfType) - if err != nil { - out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_ErrorResponse{ - ErrorResponse: &v1reflectionpb.ErrorResponse{ - ErrorCode: int32(codes.NotFound), - ErrorMessage: err.Error(), - }, - } - } else { - out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_AllExtensionNumbersResponse{ - AllExtensionNumbersResponse: &v1reflectionpb.ExtensionNumberResponse{ - BaseTypeName: req.AllExtensionNumbersOfType, - ExtensionNumber: extNums, - }, - } - } - case *v1reflectionpb.ServerReflectionRequest_ListServices: - out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_ListServicesResponse{ - ListServicesResponse: &v1reflectionpb.ListServiceResponse{ - Service: s.listServices(), - }, - } - default: - return status.Errorf(codes.InvalidArgument, "invalid MessageRequest: %v", in.MessageRequest) - } - - if err := stream.Send(out); err != nil { - return err - } + return &internal.ServerReflectionServer{ + S: opts.Services, + DescResolver: opts.DescriptorResolver, + ExtResolver: opts.ExtensionResolver, } } diff --git a/vendor/google.golang.org/grpc/regenerate.sh b/vendor/google.golang.org/grpc/regenerate.sh index a6f26c8ab0f..3edca296c22 100644 --- a/vendor/google.golang.org/grpc/regenerate.sh +++ b/vendor/google.golang.org/grpc/regenerate.sh @@ -63,7 +63,7 @@ LEGACY_SOURCES=( # 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\)$') + $(git ls-files --exclude-standard --cached --others "*.proto" | grep -v '^profiling/proto/service.proto$') ${WORKDIR}/grpc-proto/grpc/gcp/altscontext.proto ${WORKDIR}/grpc-proto/grpc/gcp/handshaker.proto ${WORKDIR}/grpc-proto/grpc/gcp/transport_security_common.proto @@ -93,7 +93,7 @@ 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 \ + protoc --go_out=${OPTS}:${WORKDIR}/out --go-grpc_out=${OPTS},use_generic_streams_experimental=true:${WORKDIR}/out \ -I"." \ -I${WORKDIR}/grpc-proto \ -I${WORKDIR}/googleapis \ @@ -118,6 +118,6 @@ mv ${WORKDIR}/out/google.golang.org/grpc/lookup/grpc_lookup_v1/* ${WORKDIR}/out/ # 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 +rm ${WORKDIR}/out/google.golang.org/grpc/reflection/test/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 index b54a3a3225d..ef3d6ed6c43 100644 --- a/vendor/google.golang.org/grpc/resolver/dns/dns_resolver.go +++ b/vendor/google.golang.org/grpc/resolver/dns/dns_resolver.go @@ -18,9 +18,6 @@ // 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 ( @@ -52,3 +49,12 @@ func SetResolvingTimeout(timeout time.Duration) { func NewBuilder() resolver.Builder { return dns.NewBuilder() } + +// SetMinResolutionInterval sets the default minimum interval at which DNS +// re-resolutions are allowed. This helps to prevent excessive re-resolution. +// +// It must be called only at application startup, before any gRPC calls are +// made. Modifying this value after initialization is not thread-safe. +func SetMinResolutionInterval(d time.Duration) { + dns.MinResolutionInterval = d +} diff --git a/vendor/google.golang.org/grpc/rpc_util.go b/vendor/google.golang.org/grpc/rpc_util.go index 998e251ddc4..fdd49e6e915 100644 --- a/vendor/google.golang.org/grpc/rpc_util.go +++ b/vendor/google.golang.org/grpc/rpc_util.go @@ -964,7 +964,7 @@ func setCallInfoCodec(c *callInfo) error { // 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. +// support package version is 9. // // Older versions are kept for compatibility. // @@ -976,6 +976,7 @@ const ( SupportPackageIsVersion6 = true SupportPackageIsVersion7 = true SupportPackageIsVersion8 = true + SupportPackageIsVersion9 = true ) const grpcUA = "grpc-go/" + Version diff --git a/vendor/google.golang.org/grpc/server.go b/vendor/google.golang.org/grpc/server.go index fd4558daa52..89f8e4792bf 100644 --- a/vendor/google.golang.org/grpc/server.go +++ b/vendor/google.golang.org/grpc/server.go @@ -527,12 +527,22 @@ func ConnectionTimeout(d time.Duration) ServerOption { }) } +// MaxHeaderListSizeServerOption is a ServerOption that sets the max +// (uncompressed) size of header list that the server is prepared to accept. +type MaxHeaderListSizeServerOption struct { + MaxHeaderListSize uint32 +} + +func (o MaxHeaderListSizeServerOption) apply(so *serverOptions) { + so.maxHeaderListSize = &o.MaxHeaderListSize +} + // 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 - }) + return MaxHeaderListSizeServerOption{ + MaxHeaderListSize: s, + } } // HeaderTableSize returns a ServerOption that sets the size of dynamic diff --git a/vendor/google.golang.org/grpc/service_config.go b/vendor/google.golang.org/grpc/service_config.go index 2b35c5d2130..9da8fc8027d 100644 --- a/vendor/google.golang.org/grpc/service_config.go +++ b/vendor/google.golang.org/grpc/service_config.go @@ -172,7 +172,7 @@ func parseServiceConfig(js string) *serviceconfig.ParseResult { var rsc jsonSC err := json.Unmarshal([]byte(js), &rsc) if err != nil { - logger.Warningf("grpc: unmarshaling service config %s: %v", js, err) + logger.Warningf("grpc: unmarshalling service config %s: %v", js, err) return &serviceconfig.ParseResult{Err: err} } sc := ServiceConfig{ @@ -219,7 +219,7 @@ func parseServiceConfig(js string) *serviceconfig.ParseResult { Timeout: (*time.Duration)(m.Timeout), } if mc.RetryPolicy, err = convertRetryPolicy(m.RetryPolicy); err != nil { - logger.Warningf("grpc: unmarshaling service config %s: %v", js, err) + logger.Warningf("grpc: unmarshalling service config %s: %v", js, err) return &serviceconfig.ParseResult{Err: err} } if m.MaxRequestMessageBytes != nil { @@ -239,13 +239,13 @@ func parseServiceConfig(js string) *serviceconfig.ParseResult { 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) + logger.Warningf("grpc: error unmarshalling 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) + logger.Warningf("grpc: error unmarshalling service config %s due to methodConfig[%d]: %v", js, i, err) return &serviceconfig.ParseResult{Err: err} } paths[path] = struct{}{} diff --git a/vendor/google.golang.org/grpc/stats/stats.go b/vendor/google.golang.org/grpc/stats/stats.go index 4ab70e2d462..fdb0bd65182 100644 --- a/vendor/google.golang.org/grpc/stats/stats.go +++ b/vendor/google.golang.org/grpc/stats/stats.go @@ -73,9 +73,12 @@ func (*PickerUpdated) isRPCStats() {} type InPayload struct { // Client is true if this InPayload is from client side. Client bool - // Payload is the payload with original type. + // Payload is the payload with original type. This may be modified after + // the call to HandleRPC which provides the InPayload returns and must be + // copied if needed later. Payload any // Data is the serialized message payload. + // Deprecated: Data will be removed in the next release. Data []byte // Length is the size of the uncompressed payload data. Does not include any @@ -143,9 +146,12 @@ func (s *InTrailer) isRPCStats() {} type OutPayload struct { // Client is true if this OutPayload is from client side. Client bool - // Payload is the payload with original type. + // Payload is the payload with original type. This may be modified after + // the call to HandleRPC which provides the OutPayload returns and must be + // copied if needed later. Payload any // Data is the serialized message payload. + // Deprecated: Data will be removed in the next release. Data []byte // Length is the size of the uncompressed payload data. Does not include any // framing (gRPC or HTTP/2). diff --git a/vendor/google.golang.org/grpc/stream.go b/vendor/google.golang.org/grpc/stream.go index d939ffc6348..b54563e81cd 100644 --- a/vendor/google.golang.org/grpc/stream.go +++ b/vendor/google.golang.org/grpc/stream.go @@ -516,6 +516,7 @@ func (a *csAttempt) newStream() error { return toRPCErr(nse.Err) } a.s = s + a.ctx = s.Context() a.p = &parser{r: s, recvBufferPool: a.cs.cc.dopts.recvBufferPool} return nil } diff --git a/vendor/google.golang.org/grpc/stream_interfaces.go b/vendor/google.golang.org/grpc/stream_interfaces.go new file mode 100644 index 00000000000..8b813529c0c --- /dev/null +++ b/vendor/google.golang.org/grpc/stream_interfaces.go @@ -0,0 +1,152 @@ +/* + * + * 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 + +// ServerStreamingClient represents the client side of a server-streaming (one +// request, many responses) RPC. It is generic over the type of the response +// message. It is used in generated code. +type ServerStreamingClient[Res any] interface { + Recv() (*Res, error) + ClientStream +} + +// ServerStreamingServer represents the server side of a server-streaming (one +// request, many responses) RPC. It is generic over the type of the response +// message. It is used in generated code. +type ServerStreamingServer[Res any] interface { + Send(*Res) error + ServerStream +} + +// ClientStreamingClient represents the client side of a client-streaming (many +// requests, one response) RPC. It is generic over both the type of the request +// message stream and the type of the unary response message. It is used in +// generated code. +type ClientStreamingClient[Req any, Res any] interface { + Send(*Req) error + CloseAndRecv() (*Res, error) + ClientStream +} + +// ClientStreamingServer represents the server side of a client-streaming (many +// requests, one response) RPC. It is generic over both the type of the request +// message stream and the type of the unary response message. It is used in +// generated code. +type ClientStreamingServer[Req any, Res any] interface { + Recv() (*Req, error) + SendAndClose(*Res) error + ServerStream +} + +// BidiStreamingClient represents the client side of a bidirectional-streaming +// (many requests, many responses) RPC. It is generic over both the type of the +// request message stream and the type of the response message stream. It is +// used in generated code. +type BidiStreamingClient[Req any, Res any] interface { + Send(*Req) error + Recv() (*Res, error) + ClientStream +} + +// BidiStreamingServer represents the server side of a bidirectional-streaming +// (many requests, many responses) RPC. It is generic over both the type of the +// request message stream and the type of the response message stream. It is +// used in generated code. +type BidiStreamingServer[Req any, Res any] interface { + Recv() (*Req, error) + Send(*Res) error + ServerStream +} + +// GenericClientStream implements the ServerStreamingClient, ClientStreamingClient, +// and BidiStreamingClient interfaces. It is used in generated code. +type GenericClientStream[Req any, Res any] struct { + ClientStream +} + +var _ ServerStreamingClient[string] = (*GenericClientStream[int, string])(nil) +var _ ClientStreamingClient[int, string] = (*GenericClientStream[int, string])(nil) +var _ BidiStreamingClient[int, string] = (*GenericClientStream[int, string])(nil) + +// Send pushes one message into the stream of requests to be consumed by the +// server. The type of message which can be sent is determined by the Req type +// parameter of the GenericClientStream receiver. +func (x *GenericClientStream[Req, Res]) Send(m *Req) error { + return x.ClientStream.SendMsg(m) +} + +// Recv reads one message from the stream of responses generated by the server. +// The type of the message returned is determined by the Res type parameter +// of the GenericClientStream receiver. +func (x *GenericClientStream[Req, Res]) Recv() (*Res, error) { + m := new(Res) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// CloseAndRecv closes the sending side of the stream, then receives the unary +// response from the server. The type of message which it returns is determined +// by the Res type parameter of the GenericClientStream receiver. +func (x *GenericClientStream[Req, Res]) CloseAndRecv() (*Res, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(Res) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// GenericServerStream implements the ServerStreamingServer, ClientStreamingServer, +// and BidiStreamingServer interfaces. It is used in generated code. +type GenericServerStream[Req any, Res any] struct { + ServerStream +} + +var _ ServerStreamingServer[string] = (*GenericServerStream[int, string])(nil) +var _ ClientStreamingServer[int, string] = (*GenericServerStream[int, string])(nil) +var _ BidiStreamingServer[int, string] = (*GenericServerStream[int, string])(nil) + +// Send pushes one message into the stream of responses to be consumed by the +// client. The type of message which can be sent is determined by the Res +// type parameter of the serverStreamServer receiver. +func (x *GenericServerStream[Req, Res]) Send(m *Res) error { + return x.ServerStream.SendMsg(m) +} + +// SendAndClose pushes the unary response to the client. The type of message +// which can be sent is determined by the Res type parameter of the +// clientStreamServer receiver. +func (x *GenericServerStream[Req, Res]) SendAndClose(m *Res) error { + return x.ServerStream.SendMsg(m) +} + +// Recv reads one message from the stream of requests generated by the client. +// The type of the message returned is determined by the Req type parameter +// of the clientStreamServer receiver. +func (x *GenericServerStream[Req, Res]) Recv() (*Req, error) { + m := new(Req) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} diff --git a/vendor/google.golang.org/grpc/version.go b/vendor/google.golang.org/grpc/version.go index 2556f758386..e1806e76000 100644 --- a/vendor/google.golang.org/grpc/version.go +++ b/vendor/google.golang.org/grpc/version.go @@ -19,4 +19,4 @@ package grpc // Version is the current grpc version. -const Version = "1.63.2" +const Version = "1.64.0" diff --git a/vendor/google.golang.org/grpc/vet.sh b/vendor/google.golang.org/grpc/vet.sh deleted file mode 100644 index 7e6b92e491a..00000000000 --- 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 index f47902371a6..bb2966e3b4c 100644 --- a/vendor/google.golang.org/protobuf/encoding/protojson/decode.go +++ b/vendor/google.golang.org/protobuf/encoding/protojson/decode.go @@ -102,7 +102,7 @@ type decoder struct { } // newError returns an error object with position info. -func (d decoder) newError(pos int, f string, x ...interface{}) error { +func (d decoder) newError(pos int, f string, x ...any) error { line, column := d.Position(pos) head := fmt.Sprintf("(line %d:%d): ", line, column) return errors.New(head+f, x...) @@ -114,7 +114,7 @@ func (d decoder) unexpectedTokenError(tok json.Token) error { } // syntaxError returns a syntax error for given position. -func (d decoder) syntaxError(pos int, f string, x ...interface{}) error { +func (d decoder) syntaxError(pos int, f string, x ...any) error { line, column := d.Position(pos) head := fmt.Sprintf("syntax error (line %d:%d): ", line, column) return errors.New(head+f, x...) diff --git a/vendor/google.golang.org/protobuf/encoding/protojson/encode.go b/vendor/google.golang.org/protobuf/encoding/protojson/encode.go index 3f75098b6fb..29846df222c 100644 --- a/vendor/google.golang.org/protobuf/encoding/protojson/encode.go +++ b/vendor/google.golang.org/protobuf/encoding/protojson/encode.go @@ -25,15 +25,17 @@ 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. It may change over time across -// different versions of the program. +// 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. It may change over time across -// different versions of the program. +// 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) } @@ -110,8 +112,9 @@ type MarshalOptions struct { // 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. It may change over time across -// different versions of the program. +// 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 @@ -122,8 +125,9 @@ func (o MarshalOptions) Format(m proto.Message) string { } // Marshal marshals the given [proto.Message] in the JSON format using options in -// MarshalOptions. Do not depend on the output being stable. It may change over -// time across different versions of the program. +// 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) } diff --git a/vendor/google.golang.org/protobuf/encoding/prototext/decode.go b/vendor/google.golang.org/protobuf/encoding/prototext/decode.go index a45f112bce3..24bc98ac422 100644 --- a/vendor/google.golang.org/protobuf/encoding/prototext/decode.go +++ b/vendor/google.golang.org/protobuf/encoding/prototext/decode.go @@ -84,7 +84,7 @@ type decoder struct { } // newError returns an error object with position info. -func (d decoder) newError(pos int, f string, x ...interface{}) error { +func (d decoder) newError(pos int, f string, x ...any) error { line, column := d.Position(pos) head := fmt.Sprintf("(line %d:%d): ", line, column) return errors.New(head+f, x...) @@ -96,7 +96,7 @@ func (d decoder) unexpectedTokenError(tok text.Token) error { } // syntaxError returns a syntax error for given position. -func (d decoder) syntaxError(pos int, f string, x ...interface{}) error { +func (d decoder) syntaxError(pos int, f string, x ...any) error { line, column := d.Position(pos) head := fmt.Sprintf("syntax error (line %d:%d): ", line, column) return errors.New(head+f, x...) diff --git a/vendor/google.golang.org/protobuf/encoding/prototext/encode.go b/vendor/google.golang.org/protobuf/encoding/prototext/encode.go index 95967e8112a..1f57e6610a2 100644 --- a/vendor/google.golang.org/protobuf/encoding/prototext/encode.go +++ b/vendor/google.golang.org/protobuf/encoding/prototext/encode.go @@ -27,15 +27,17 @@ 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. It may change over time across -// different versions of the program. +// 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 textproto format using default -// options. Do not depend on the output being stable. It may change over time -// across different versions of the program. +// 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) } @@ -84,8 +86,9 @@ type MarshalOptions struct { // 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. It may change over time across -// different versions of the program. +// 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 @@ -98,8 +101,9 @@ func (o MarshalOptions) Format(m proto.Message) string { } // Marshal writes the given [proto.Message] in textproto format using options in -// MarshalOptions object. Do not depend on the output being stable. It may -// change over time across different versions of the program. +// MarshalOptions object. 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) } diff --git a/vendor/google.golang.org/protobuf/internal/descfmt/stringer.go b/vendor/google.golang.org/protobuf/internal/descfmt/stringer.go index a45625c8d1f..87e46bd4dfb 100644 --- a/vendor/google.golang.org/protobuf/internal/descfmt/stringer.go +++ b/vendor/google.golang.org/protobuf/internal/descfmt/stringer.go @@ -252,6 +252,7 @@ func formatDescOpt(t protoreflect.Descriptor, isRoot, allowMulti bool, record fu {rv.MethodByName("Values"), "Values"}, {rv.MethodByName("ReservedNames"), "ReservedNames"}, {rv.MethodByName("ReservedRanges"), "ReservedRanges"}, + {rv.MethodByName("IsClosed"), "IsClosed"}, }...) case protoreflect.EnumValueDescriptor: diff --git a/vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb b/vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb index 18f07568743..ff6a38360ad 100644 Binary files a/vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb and b/vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb differ diff --git a/vendor/google.golang.org/protobuf/internal/editionssupport/editions.go b/vendor/google.golang.org/protobuf/internal/editionssupport/editions.go new file mode 100644 index 00000000000..029a6a12d74 --- /dev/null +++ b/vendor/google.golang.org/protobuf/internal/editionssupport/editions.go @@ -0,0 +1,13 @@ +// Copyright 2024 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 editionssupport defines constants for editions that are supported. +package editionssupport + +import descriptorpb "google.golang.org/protobuf/types/descriptorpb" + +const ( + Minimum = descriptorpb.Edition_EDITION_PROTO2 + Maximum = descriptorpb.Edition_EDITION_2023 +) diff --git a/vendor/google.golang.org/protobuf/internal/encoding/json/decode.go b/vendor/google.golang.org/protobuf/internal/encoding/json/decode.go index d2b3ac031e1..ea1d3e65a57 100644 --- a/vendor/google.golang.org/protobuf/internal/encoding/json/decode.go +++ b/vendor/google.golang.org/protobuf/internal/encoding/json/decode.go @@ -214,7 +214,7 @@ func (d *Decoder) parseNext() (Token, error) { // newSyntaxError returns an error with line and column information useful for // syntax errors. -func (d *Decoder) newSyntaxError(pos int, f string, x ...interface{}) error { +func (d *Decoder) newSyntaxError(pos int, f string, x ...any) error { e := errors.New(f, x...) line, column := d.Position(pos) return errors.New("syntax error (line %d:%d): %v", line, column, e) diff --git a/vendor/google.golang.org/protobuf/internal/encoding/tag/tag.go b/vendor/google.golang.org/protobuf/internal/encoding/tag/tag.go index 373d208374f..7e87c760443 100644 --- a/vendor/google.golang.org/protobuf/internal/encoding/tag/tag.go +++ b/vendor/google.golang.org/protobuf/internal/encoding/tag/tag.go @@ -32,6 +32,7 @@ var byteType = reflect.TypeOf(byte(0)) func Unmarshal(tag string, goType reflect.Type, evs protoreflect.EnumValueDescriptors) protoreflect.FieldDescriptor { f := new(filedesc.Field) f.L0.ParentFile = filedesc.SurrogateProto2 + f.L1.EditionFeatures = f.L0.ParentFile.L1.EditionFeatures for len(tag) > 0 { i := strings.IndexByte(tag, ',') if i < 0 { @@ -107,8 +108,7 @@ func Unmarshal(tag string, goType reflect.Type, evs protoreflect.EnumValueDescri f.L1.StringName.InitJSON(jsonName) } case s == "packed": - f.L1.HasPacked = true - f.L1.IsPacked = true + f.L1.EditionFeatures.IsPacked = true case strings.HasPrefix(s, "weak="): f.L1.IsWeak = true f.L1.Message = filedesc.PlaceholderMessage(protoreflect.FullName(s[len("weak="):])) diff --git a/vendor/google.golang.org/protobuf/internal/encoding/text/decode.go b/vendor/google.golang.org/protobuf/internal/encoding/text/decode.go index 87853e786d0..099b2bf451b 100644 --- a/vendor/google.golang.org/protobuf/internal/encoding/text/decode.go +++ b/vendor/google.golang.org/protobuf/internal/encoding/text/decode.go @@ -601,7 +601,7 @@ func (d *Decoder) consumeToken(kind Kind, size int, attrs uint8) Token { // newSyntaxError returns a syntax error with line and column information for // current position. -func (d *Decoder) newSyntaxError(f string, x ...interface{}) error { +func (d *Decoder) newSyntaxError(f string, x ...any) error { e := errors.New(f, x...) line, column := d.Position(len(d.orig) - len(d.in)) return errors.New("syntax error (line %d:%d): %v", line, column, e) diff --git a/vendor/google.golang.org/protobuf/internal/errors/errors.go b/vendor/google.golang.org/protobuf/internal/errors/errors.go index 20c17b35e3a..c2d6bd5265d 100644 --- a/vendor/google.golang.org/protobuf/internal/errors/errors.go +++ b/vendor/google.golang.org/protobuf/internal/errors/errors.go @@ -17,7 +17,7 @@ var Error = errors.New("protobuf error") // New formats a string according to the format specifier and arguments and // returns an error that has a "proto" prefix. -func New(f string, x ...interface{}) error { +func New(f string, x ...any) error { return &prefixError{s: format(f, x...)} } @@ -43,7 +43,7 @@ func (e *prefixError) Unwrap() error { // Wrap returns an error that has a "proto" prefix, the formatted string described // by the format specifier and arguments, and a suffix of err. The error wraps err. -func Wrap(err error, f string, x ...interface{}) error { +func Wrap(err error, f string, x ...any) error { return &wrapError{ s: format(f, x...), err: err, @@ -67,7 +67,7 @@ func (e *wrapError) Is(target error) bool { return target == Error } -func format(f string, x ...interface{}) string { +func format(f string, x ...any) string { // avoid "proto: " prefix when chaining for i := 0; i < len(x); i++ { switch e := x[i].(type) { @@ -87,3 +87,18 @@ func InvalidUTF8(name string) error { func RequiredNotSet(name string) error { return New("required field %v not set", name) } + +type SizeMismatchError struct { + Calculated, Measured int +} + +func (e *SizeMismatchError) Error() string { + return fmt.Sprintf("size mismatch (see https://github.com/golang/protobuf/issues/1609): calculated=%d, measured=%d", e.Calculated, e.Measured) +} + +func MismatchedSizeCalculation(calculated, measured int) error { + return &SizeMismatchError{ + Calculated: calculated, + Measured: measured, + } +} diff --git a/vendor/google.golang.org/protobuf/internal/filedesc/desc.go b/vendor/google.golang.org/protobuf/internal/filedesc/desc.go index 8826bcf4021..df53ff40b25 100644 --- a/vendor/google.golang.org/protobuf/internal/filedesc/desc.go +++ b/vendor/google.golang.org/protobuf/internal/filedesc/desc.go @@ -7,6 +7,7 @@ package filedesc import ( "bytes" "fmt" + "strings" "sync" "sync/atomic" @@ -108,9 +109,12 @@ func (fd *File) ParentFile() protoreflect.FileDescriptor { return fd } func (fd *File) Parent() protoreflect.Descriptor { return nil } func (fd *File) Index() int { return 0 } func (fd *File) Syntax() protoreflect.Syntax { return fd.L1.Syntax } -func (fd *File) Name() protoreflect.Name { return fd.L1.Package.Name() } -func (fd *File) FullName() protoreflect.FullName { return fd.L1.Package } -func (fd *File) IsPlaceholder() bool { return false } + +// Not exported and just used to reconstruct the original FileDescriptor proto +func (fd *File) Edition() int32 { return int32(fd.L1.Edition) } +func (fd *File) Name() protoreflect.Name { return fd.L1.Package.Name() } +func (fd *File) FullName() protoreflect.FullName { return fd.L1.Package } +func (fd *File) IsPlaceholder() bool { return false } func (fd *File) Options() protoreflect.ProtoMessage { if f := fd.lazyInit().Options; f != nil { return f() @@ -202,6 +206,9 @@ func (ed *Enum) lazyInit() *EnumL2 { ed.L0.ParentFile.lazyInit() // implicitly initializes L2 return ed.L2 } +func (ed *Enum) IsClosed() bool { + return !ed.L1.EditionFeatures.IsOpenEnum +} func (ed *EnumValue) Options() protoreflect.ProtoMessage { if f := ed.L1.Options; f != nil { @@ -251,10 +258,6 @@ type ( StringName stringName IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto IsWeak bool // promoted from google.protobuf.FieldOptions - HasPacked bool // promoted from google.protobuf.FieldOptions - IsPacked bool // promoted from google.protobuf.FieldOptions - HasEnforceUTF8 bool // promoted from google.protobuf.FieldOptions - EnforceUTF8 bool // promoted from google.protobuf.FieldOptions Default defaultValue ContainingOneof protoreflect.OneofDescriptor // must be consistent with Message.Oneofs.Fields Enum protoreflect.EnumDescriptor @@ -331,8 +334,7 @@ func (fd *Field) HasPresence() bool { if fd.L1.Cardinality == protoreflect.Repeated { return false } - explicitFieldPresence := fd.Syntax() == protoreflect.Editions && fd.L1.EditionFeatures.IsFieldPresence - return fd.Syntax() == protoreflect.Proto2 || explicitFieldPresence || fd.L1.Message != nil || fd.L1.ContainingOneof != nil + return fd.IsExtension() || fd.L1.EditionFeatures.IsFieldPresence || fd.L1.Message != nil || fd.L1.ContainingOneof != nil } func (fd *Field) HasOptionalKeyword() bool { return (fd.L0.ParentFile.L1.Syntax == protoreflect.Proto2 && fd.L1.Cardinality == protoreflect.Optional && fd.L1.ContainingOneof == nil) || fd.L1.IsProto3Optional @@ -345,14 +347,7 @@ func (fd *Field) IsPacked() bool { case protoreflect.StringKind, protoreflect.BytesKind, protoreflect.MessageKind, protoreflect.GroupKind: return false } - if fd.L0.ParentFile.L1.Syntax == protoreflect.Editions { - return fd.L1.EditionFeatures.IsPacked - } - if fd.L0.ParentFile.L1.Syntax == protoreflect.Proto3 { - // proto3 repeated fields are packed by default. - return !fd.L1.HasPacked || fd.L1.IsPacked - } - return fd.L1.IsPacked + return fd.L1.EditionFeatures.IsPacked } func (fd *Field) IsExtension() bool { return false } func (fd *Field) IsWeak() bool { return fd.L1.IsWeak } @@ -388,6 +383,10 @@ func (fd *Field) Message() protoreflect.MessageDescriptor { } return fd.L1.Message } +func (fd *Field) IsMapEntry() bool { + parent, ok := fd.L0.Parent.(protoreflect.MessageDescriptor) + return ok && parent.IsMapEntry() +} func (fd *Field) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, fd) } func (fd *Field) ProtoType(protoreflect.FieldDescriptor) {} @@ -399,13 +398,7 @@ func (fd *Field) ProtoType(protoreflect.FieldDescriptor) {} // WARNING: This method is exempt from the compatibility promise and may be // removed in the future without warning. func (fd *Field) EnforceUTF8() bool { - if fd.L0.ParentFile.L1.Syntax == protoreflect.Editions { - return fd.L1.EditionFeatures.IsUTF8Validated - } - if fd.L1.HasEnforceUTF8 { - return fd.L1.EnforceUTF8 - } - return fd.L0.ParentFile.L1.Syntax == protoreflect.Proto3 + return fd.L1.EditionFeatures.IsUTF8Validated } func (od *Oneof) IsSynthetic() bool { @@ -438,7 +431,6 @@ type ( Options func() protoreflect.ProtoMessage StringName stringName IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto - IsPacked bool // promoted from google.protobuf.FieldOptions Default defaultValue Enum protoreflect.EnumDescriptor Message protoreflect.MessageDescriptor @@ -461,7 +453,16 @@ func (xd *Extension) HasPresence() bool { return xd.L1.Cardi func (xd *Extension) HasOptionalKeyword() bool { return (xd.L0.ParentFile.L1.Syntax == protoreflect.Proto2 && xd.L1.Cardinality == protoreflect.Optional) || xd.lazyInit().IsProto3Optional } -func (xd *Extension) IsPacked() bool { return xd.lazyInit().IsPacked } +func (xd *Extension) IsPacked() bool { + if xd.L1.Cardinality != protoreflect.Repeated { + return false + } + switch xd.L1.Kind { + case protoreflect.StringKind, protoreflect.BytesKind, protoreflect.MessageKind, protoreflect.GroupKind: + return false + } + return xd.L1.EditionFeatures.IsPacked +} func (xd *Extension) IsExtension() bool { return true } func (xd *Extension) IsWeak() bool { return false } func (xd *Extension) IsList() bool { return xd.Cardinality() == protoreflect.Repeated } @@ -542,8 +543,9 @@ func (md *Method) ProtoInternal(pragma.DoNotImplement) {} // Surrogate files are can be used to create standalone descriptors // where the syntax is only information derived from the parent file. var ( - SurrogateProto2 = &File{L1: FileL1{Syntax: protoreflect.Proto2}, L2: &FileL2{}} - SurrogateProto3 = &File{L1: FileL1{Syntax: protoreflect.Proto3}, L2: &FileL2{}} + SurrogateProto2 = &File{L1: FileL1{Syntax: protoreflect.Proto2}, L2: &FileL2{}} + SurrogateProto3 = &File{L1: FileL1{Syntax: protoreflect.Proto3}, L2: &FileL2{}} + SurrogateEdition2023 = &File{L1: FileL1{Syntax: protoreflect.Editions, Edition: Edition2023}, L2: &FileL2{}} ) type ( @@ -585,6 +587,34 @@ func (s *stringName) InitJSON(name string) { s.nameJSON = name } +// Returns true if this field is structured like the synthetic field of a proto2 +// group. This allows us to expand our treatment of delimited fields without +// breaking proto2 files that have been upgraded to editions. +func isGroupLike(fd protoreflect.FieldDescriptor) bool { + // Groups are always group types. + if fd.Kind() != protoreflect.GroupKind { + return false + } + + // Group fields are always the lowercase type name. + if strings.ToLower(string(fd.Message().Name())) != string(fd.Name()) { + return false + } + + // Groups could only be defined in the same file they're used. + if fd.Message().ParentFile() != fd.ParentFile() { + return false + } + + // Group messages are always defined in the same scope as the field. File + // level extensions will compare NULL == NULL here, which is why the file + // comparison above is necessary to ensure both come from the same file. + if fd.IsExtension() { + return fd.Parent() == fd.Message().Parent() + } + return fd.ContainingMessage() == fd.Message().Parent() +} + func (s *stringName) lazyInit(fd protoreflect.FieldDescriptor) *stringName { s.once.Do(func() { if fd.IsExtension() { @@ -605,7 +635,7 @@ func (s *stringName) lazyInit(fd protoreflect.FieldDescriptor) *stringName { // Format the text name. s.nameText = string(fd.Name()) - if fd.Kind() == protoreflect.GroupKind { + if isGroupLike(fd) { s.nameText = string(fd.Message().Name()) } } diff --git a/vendor/google.golang.org/protobuf/internal/filedesc/desc_init.go b/vendor/google.golang.org/protobuf/internal/filedesc/desc_init.go index 237e64fd237..8a57d60b08c 100644 --- a/vendor/google.golang.org/protobuf/internal/filedesc/desc_init.go +++ b/vendor/google.golang.org/protobuf/internal/filedesc/desc_init.go @@ -113,8 +113,10 @@ func (fd *File) unmarshalSeed(b []byte) { switch string(v) { case "proto2": fd.L1.Syntax = protoreflect.Proto2 + fd.L1.Edition = EditionProto2 case "proto3": fd.L1.Syntax = protoreflect.Proto3 + fd.L1.Edition = EditionProto3 case "editions": fd.L1.Syntax = protoreflect.Editions default: @@ -177,11 +179,10 @@ func (fd *File) unmarshalSeed(b []byte) { // If syntax is missing, it is assumed to be proto2. if fd.L1.Syntax == 0 { fd.L1.Syntax = protoreflect.Proto2 + fd.L1.Edition = EditionProto2 } - if fd.L1.Syntax == protoreflect.Editions { - fd.L1.EditionFeatures = getFeaturesFor(fd.L1.Edition) - } + fd.L1.EditionFeatures = getFeaturesFor(fd.L1.Edition) // Parse editions features from options if any if options != nil { @@ -267,6 +268,7 @@ func (ed *Enum) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd protorefl ed.L0.ParentFile = pf ed.L0.Parent = pd ed.L0.Index = i + ed.L1.EditionFeatures = featuresFromParentDesc(ed.Parent()) var numValues int for b := b; len(b) > 0; { @@ -443,6 +445,7 @@ func (xd *Extension) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd prot xd.L0.ParentFile = pf xd.L0.Parent = pd xd.L0.Index = i + xd.L1.EditionFeatures = featuresFromParentDesc(pd) for len(b) > 0 { num, typ, n := protowire.ConsumeTag(b) @@ -467,6 +470,38 @@ func (xd *Extension) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd prot xd.L0.FullName = appendFullName(sb, pd.FullName(), v) case genid.FieldDescriptorProto_Extendee_field_number: xd.L1.Extendee = PlaceholderMessage(makeFullName(sb, v)) + case genid.FieldDescriptorProto_Options_field_number: + xd.unmarshalOptions(v) + } + default: + m := protowire.ConsumeFieldValue(num, typ, b) + b = b[m:] + } + } + + if xd.L1.Kind == protoreflect.MessageKind && xd.L1.EditionFeatures.IsDelimitedEncoded { + xd.L1.Kind = protoreflect.GroupKind + } +} + +func (xd *Extension) unmarshalOptions(b []byte) { + for len(b) > 0 { + num, typ, n := protowire.ConsumeTag(b) + b = b[n:] + switch typ { + case protowire.VarintType: + v, m := protowire.ConsumeVarint(b) + b = b[m:] + switch num { + case genid.FieldOptions_Packed_field_number: + xd.L1.EditionFeatures.IsPacked = protowire.DecodeBool(v) + } + case protowire.BytesType: + v, m := protowire.ConsumeBytes(b) + b = b[m:] + switch num { + case genid.FieldOptions_Features_field_number: + xd.L1.EditionFeatures = unmarshalFeatureSet(v, xd.L1.EditionFeatures) } default: m := protowire.ConsumeFieldValue(num, typ, b) @@ -499,7 +534,7 @@ func (sd *Service) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd protor } var nameBuilderPool = sync.Pool{ - New: func() interface{} { return new(strs.Builder) }, + New: func() any { return new(strs.Builder) }, } func getBuilder() *strs.Builder { diff --git a/vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go b/vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go index 482a61cc10e..e56c91a8dbe 100644 --- a/vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go +++ b/vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go @@ -45,6 +45,11 @@ func (file *File) resolveMessages() { case protoreflect.MessageKind, protoreflect.GroupKind: fd.L1.Message = file.resolveMessageDependency(fd.L1.Message, listFieldDeps, depIdx) depIdx++ + if fd.L1.Kind == protoreflect.GroupKind && (fd.IsMap() || fd.IsMapEntry()) { + // A map field might inherit delimited encoding from a file-wide default feature. + // But maps never actually use delimited encoding. (At least for now...) + fd.L1.Kind = protoreflect.MessageKind + } } // Default is resolved here since it depends on Enum being resolved. @@ -466,10 +471,10 @@ func (fd *Field) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd protoref b = b[m:] } } - if fd.Syntax() == protoreflect.Editions && fd.L1.Kind == protoreflect.MessageKind && fd.L1.EditionFeatures.IsDelimitedEncoded { + if fd.L1.Kind == protoreflect.MessageKind && fd.L1.EditionFeatures.IsDelimitedEncoded { fd.L1.Kind = protoreflect.GroupKind } - if fd.Syntax() == protoreflect.Editions && fd.L1.EditionFeatures.IsLegacyRequired { + if fd.L1.EditionFeatures.IsLegacyRequired { fd.L1.Cardinality = protoreflect.Required } if rawTypeName != nil { @@ -496,13 +501,11 @@ func (fd *Field) unmarshalOptions(b []byte) { b = b[m:] switch num { case genid.FieldOptions_Packed_field_number: - fd.L1.HasPacked = true - fd.L1.IsPacked = protowire.DecodeBool(v) + fd.L1.EditionFeatures.IsPacked = protowire.DecodeBool(v) case genid.FieldOptions_Weak_field_number: fd.L1.IsWeak = protowire.DecodeBool(v) case FieldOptions_EnforceUTF8: - fd.L1.HasEnforceUTF8 = true - fd.L1.EnforceUTF8 = protowire.DecodeBool(v) + fd.L1.EditionFeatures.IsUTF8Validated = protowire.DecodeBool(v) } case protowire.BytesType: v, m := protowire.ConsumeBytes(b) @@ -548,7 +551,6 @@ func (od *Oneof) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd protoref func (xd *Extension) unmarshalFull(b []byte, sb *strs.Builder) { var rawTypeName []byte var rawOptions []byte - xd.L1.EditionFeatures = featuresFromParentDesc(xd.L1.Extendee) xd.L2 = new(ExtensionL2) for len(b) > 0 { num, typ, n := protowire.ConsumeTag(b) @@ -572,7 +574,6 @@ func (xd *Extension) unmarshalFull(b []byte, sb *strs.Builder) { case genid.FieldDescriptorProto_TypeName_field_number: rawTypeName = v case genid.FieldDescriptorProto_Options_field_number: - xd.unmarshalOptions(v) rawOptions = appendOptions(rawOptions, v) } default: @@ -580,12 +581,6 @@ func (xd *Extension) unmarshalFull(b []byte, sb *strs.Builder) { b = b[m:] } } - if xd.Syntax() == protoreflect.Editions && xd.L1.Kind == protoreflect.MessageKind && xd.L1.EditionFeatures.IsDelimitedEncoded { - xd.L1.Kind = protoreflect.GroupKind - } - if xd.Syntax() == protoreflect.Editions && xd.L1.EditionFeatures.IsLegacyRequired { - xd.L1.Cardinality = protoreflect.Required - } if rawTypeName != nil { name := makeFullName(sb, rawTypeName) switch xd.L1.Kind { @@ -598,32 +593,6 @@ func (xd *Extension) unmarshalFull(b []byte, sb *strs.Builder) { xd.L2.Options = xd.L0.ParentFile.builder.optionsUnmarshaler(&descopts.Field, rawOptions) } -func (xd *Extension) unmarshalOptions(b []byte) { - for len(b) > 0 { - num, typ, n := protowire.ConsumeTag(b) - b = b[n:] - switch typ { - case protowire.VarintType: - v, m := protowire.ConsumeVarint(b) - b = b[m:] - switch num { - case genid.FieldOptions_Packed_field_number: - xd.L2.IsPacked = protowire.DecodeBool(v) - } - case protowire.BytesType: - v, m := protowire.ConsumeBytes(b) - b = b[m:] - switch num { - case genid.FieldOptions_Features_field_number: - xd.L1.EditionFeatures = unmarshalFeatureSet(v, xd.L1.EditionFeatures) - } - default: - m := protowire.ConsumeFieldValue(num, typ, b) - b = b[m:] - } - } -} - func (sd *Service) unmarshalFull(b []byte, sb *strs.Builder) { var rawMethods [][]byte var rawOptions []byte diff --git a/vendor/google.golang.org/protobuf/internal/filedesc/desc_list_gen.go b/vendor/google.golang.org/protobuf/internal/filedesc/desc_list_gen.go index 30db19fdc75..f4107c05f4e 100644 --- a/vendor/google.golang.org/protobuf/internal/filedesc/desc_list_gen.go +++ b/vendor/google.golang.org/protobuf/internal/filedesc/desc_list_gen.go @@ -8,6 +8,7 @@ package filedesc import ( "fmt" + "strings" "sync" "google.golang.org/protobuf/internal/descfmt" @@ -198,6 +199,16 @@ func (p *Fields) lazyInit() *Fields { if _, ok := p.byText[d.TextName()]; !ok { p.byText[d.TextName()] = d } + if isGroupLike(d) { + lowerJSONName := strings.ToLower(d.JSONName()) + if _, ok := p.byJSON[lowerJSONName]; !ok { + p.byJSON[lowerJSONName] = d + } + lowerTextName := strings.ToLower(d.TextName()) + if _, ok := p.byText[lowerTextName]; !ok { + p.byText[lowerTextName] = d + } + } if _, ok := p.byNum[d.Number()]; !ok { p.byNum[d.Number()] = d } diff --git a/vendor/google.golang.org/protobuf/internal/filedesc/editions.go b/vendor/google.golang.org/protobuf/internal/filedesc/editions.go index 0375a49d407..11f5f356b66 100644 --- a/vendor/google.golang.org/protobuf/internal/filedesc/editions.go +++ b/vendor/google.golang.org/protobuf/internal/filedesc/editions.go @@ -14,9 +14,13 @@ import ( ) var defaultsCache = make(map[Edition]EditionFeatures) +var defaultsKeys = []Edition{} func init() { unmarshalEditionDefaults(editiondefaults.Defaults) + SurrogateProto2.L1.EditionFeatures = getFeaturesFor(EditionProto2) + SurrogateProto3.L1.EditionFeatures = getFeaturesFor(EditionProto3) + SurrogateEdition2023.L1.EditionFeatures = getFeaturesFor(Edition2023) } func unmarshalGoFeature(b []byte, parent EditionFeatures) EditionFeatures { @@ -104,12 +108,15 @@ func unmarshalEditionDefault(b []byte) { v, m := protowire.ConsumeBytes(b) b = b[m:] switch num { - case genid.FeatureSetDefaults_FeatureSetEditionDefault_Features_field_number: + case genid.FeatureSetDefaults_FeatureSetEditionDefault_FixedFeatures_field_number: + fs = unmarshalFeatureSet(v, fs) + case genid.FeatureSetDefaults_FeatureSetEditionDefault_OverridableFeatures_field_number: fs = unmarshalFeatureSet(v, fs) } } } defaultsCache[ed] = fs + defaultsKeys = append(defaultsKeys, ed) } func unmarshalEditionDefaults(b []byte) { @@ -135,8 +142,15 @@ func unmarshalEditionDefaults(b []byte) { } func getFeaturesFor(ed Edition) EditionFeatures { - if def, ok := defaultsCache[ed]; ok { - return def + match := EditionUnknown + for _, key := range defaultsKeys { + if key > ed { + break + } + match = key + } + if match == EditionUnknown { + panic(fmt.Sprintf("unsupported edition: %v", ed)) } - panic(fmt.Sprintf("unsupported edition: %v", ed)) + return defaultsCache[match] } diff --git a/vendor/google.golang.org/protobuf/internal/filedesc/placeholder.go b/vendor/google.golang.org/protobuf/internal/filedesc/placeholder.go index 28240ebc5c4..bfb3b841704 100644 --- a/vendor/google.golang.org/protobuf/internal/filedesc/placeholder.go +++ b/vendor/google.golang.org/protobuf/internal/filedesc/placeholder.go @@ -63,6 +63,7 @@ func (e PlaceholderEnum) Options() protoreflect.ProtoMessage { return des func (e PlaceholderEnum) Values() protoreflect.EnumValueDescriptors { return emptyEnumValues } func (e PlaceholderEnum) ReservedNames() protoreflect.Names { return emptyNames } func (e PlaceholderEnum) ReservedRanges() protoreflect.EnumRanges { return emptyEnumRanges } +func (e PlaceholderEnum) IsClosed() bool { return false } func (e PlaceholderEnum) ProtoType(protoreflect.EnumDescriptor) { return } func (e PlaceholderEnum) ProtoInternal(pragma.DoNotImplement) { return } diff --git a/vendor/google.golang.org/protobuf/internal/filetype/build.go b/vendor/google.golang.org/protobuf/internal/filetype/build.go index f0e38c4ef4e..ba83fea44c3 100644 --- a/vendor/google.golang.org/protobuf/internal/filetype/build.go +++ b/vendor/google.golang.org/protobuf/internal/filetype/build.go @@ -68,7 +68,7 @@ type Builder struct { // and for input and output messages referenced by service methods. // Dependencies must come after declarations, but the ordering of // dependencies themselves is unspecified. - GoTypes []interface{} + GoTypes []any // DependencyIndexes is an ordered list of indexes into GoTypes for the // dependencies of messages, extensions, or services. @@ -268,7 +268,7 @@ func (x depIdxs) Get(i, j int32) int32 { type ( resolverByIndex struct { - goTypes []interface{} + goTypes []any depIdxs depIdxs fileRegistry } diff --git a/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go b/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go index 40272c893f7..f30ab6b586f 100644 --- a/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go +++ b/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go @@ -21,6 +21,7 @@ const ( // Enum values for google.protobuf.Edition. const ( Edition_EDITION_UNKNOWN_enum_value = 0 + Edition_EDITION_LEGACY_enum_value = 900 Edition_EDITION_PROTO2_enum_value = 998 Edition_EDITION_PROTO3_enum_value = 999 Edition_EDITION_2023_enum_value = 1000 @@ -653,6 +654,7 @@ const ( FieldOptions_Targets_field_name protoreflect.Name = "targets" FieldOptions_EditionDefaults_field_name protoreflect.Name = "edition_defaults" FieldOptions_Features_field_name protoreflect.Name = "features" + FieldOptions_FeatureSupport_field_name protoreflect.Name = "feature_support" FieldOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option" FieldOptions_Ctype_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.ctype" @@ -667,6 +669,7 @@ const ( FieldOptions_Targets_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.targets" FieldOptions_EditionDefaults_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.edition_defaults" FieldOptions_Features_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.features" + FieldOptions_FeatureSupport_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.feature_support" FieldOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.uninterpreted_option" ) @@ -684,6 +687,7 @@ const ( FieldOptions_Targets_field_number protoreflect.FieldNumber = 19 FieldOptions_EditionDefaults_field_number protoreflect.FieldNumber = 20 FieldOptions_Features_field_number protoreflect.FieldNumber = 21 + FieldOptions_FeatureSupport_field_number protoreflect.FieldNumber = 22 FieldOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999 ) @@ -767,6 +771,33 @@ const ( FieldOptions_EditionDefault_Value_field_number protoreflect.FieldNumber = 2 ) +// Names for google.protobuf.FieldOptions.FeatureSupport. +const ( + FieldOptions_FeatureSupport_message_name protoreflect.Name = "FeatureSupport" + FieldOptions_FeatureSupport_message_fullname protoreflect.FullName = "google.protobuf.FieldOptions.FeatureSupport" +) + +// Field names for google.protobuf.FieldOptions.FeatureSupport. +const ( + FieldOptions_FeatureSupport_EditionIntroduced_field_name protoreflect.Name = "edition_introduced" + FieldOptions_FeatureSupport_EditionDeprecated_field_name protoreflect.Name = "edition_deprecated" + FieldOptions_FeatureSupport_DeprecationWarning_field_name protoreflect.Name = "deprecation_warning" + FieldOptions_FeatureSupport_EditionRemoved_field_name protoreflect.Name = "edition_removed" + + FieldOptions_FeatureSupport_EditionIntroduced_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.FeatureSupport.edition_introduced" + FieldOptions_FeatureSupport_EditionDeprecated_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.FeatureSupport.edition_deprecated" + FieldOptions_FeatureSupport_DeprecationWarning_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.FeatureSupport.deprecation_warning" + FieldOptions_FeatureSupport_EditionRemoved_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.FeatureSupport.edition_removed" +) + +// Field numbers for google.protobuf.FieldOptions.FeatureSupport. +const ( + FieldOptions_FeatureSupport_EditionIntroduced_field_number protoreflect.FieldNumber = 1 + FieldOptions_FeatureSupport_EditionDeprecated_field_number protoreflect.FieldNumber = 2 + FieldOptions_FeatureSupport_DeprecationWarning_field_number protoreflect.FieldNumber = 3 + FieldOptions_FeatureSupport_EditionRemoved_field_number protoreflect.FieldNumber = 4 +) + // Names for google.protobuf.OneofOptions. const ( OneofOptions_message_name protoreflect.Name = "OneofOptions" @@ -829,11 +860,13 @@ const ( EnumValueOptions_Deprecated_field_name protoreflect.Name = "deprecated" EnumValueOptions_Features_field_name protoreflect.Name = "features" EnumValueOptions_DebugRedact_field_name protoreflect.Name = "debug_redact" + EnumValueOptions_FeatureSupport_field_name protoreflect.Name = "feature_support" EnumValueOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option" EnumValueOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.EnumValueOptions.deprecated" EnumValueOptions_Features_field_fullname protoreflect.FullName = "google.protobuf.EnumValueOptions.features" EnumValueOptions_DebugRedact_field_fullname protoreflect.FullName = "google.protobuf.EnumValueOptions.debug_redact" + EnumValueOptions_FeatureSupport_field_fullname protoreflect.FullName = "google.protobuf.EnumValueOptions.feature_support" EnumValueOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.EnumValueOptions.uninterpreted_option" ) @@ -842,6 +875,7 @@ const ( EnumValueOptions_Deprecated_field_number protoreflect.FieldNumber = 1 EnumValueOptions_Features_field_number protoreflect.FieldNumber = 2 EnumValueOptions_DebugRedact_field_number protoreflect.FieldNumber = 3 + EnumValueOptions_FeatureSupport_field_number protoreflect.FieldNumber = 4 EnumValueOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999 ) @@ -1110,17 +1144,20 @@ const ( // Field names for google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault. const ( - FeatureSetDefaults_FeatureSetEditionDefault_Edition_field_name protoreflect.Name = "edition" - FeatureSetDefaults_FeatureSetEditionDefault_Features_field_name protoreflect.Name = "features" + FeatureSetDefaults_FeatureSetEditionDefault_Edition_field_name protoreflect.Name = "edition" + FeatureSetDefaults_FeatureSetEditionDefault_OverridableFeatures_field_name protoreflect.Name = "overridable_features" + FeatureSetDefaults_FeatureSetEditionDefault_FixedFeatures_field_name protoreflect.Name = "fixed_features" - FeatureSetDefaults_FeatureSetEditionDefault_Edition_field_fullname protoreflect.FullName = "google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.edition" - FeatureSetDefaults_FeatureSetEditionDefault_Features_field_fullname protoreflect.FullName = "google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.features" + FeatureSetDefaults_FeatureSetEditionDefault_Edition_field_fullname protoreflect.FullName = "google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.edition" + FeatureSetDefaults_FeatureSetEditionDefault_OverridableFeatures_field_fullname protoreflect.FullName = "google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.overridable_features" + FeatureSetDefaults_FeatureSetEditionDefault_FixedFeatures_field_fullname protoreflect.FullName = "google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.fixed_features" ) // Field numbers for google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault. const ( - FeatureSetDefaults_FeatureSetEditionDefault_Edition_field_number protoreflect.FieldNumber = 3 - FeatureSetDefaults_FeatureSetEditionDefault_Features_field_number protoreflect.FieldNumber = 2 + FeatureSetDefaults_FeatureSetEditionDefault_Edition_field_number protoreflect.FieldNumber = 3 + FeatureSetDefaults_FeatureSetEditionDefault_OverridableFeatures_field_number protoreflect.FieldNumber = 4 + FeatureSetDefaults_FeatureSetEditionDefault_FixedFeatures_field_number protoreflect.FieldNumber = 5 ) // Names for google.protobuf.SourceCodeInfo. diff --git a/vendor/google.golang.org/protobuf/internal/genid/go_features_gen.go b/vendor/google.golang.org/protobuf/internal/genid/go_features_gen.go index fd9015e8eee..9a652a2b424 100644 --- a/vendor/google.golang.org/protobuf/internal/genid/go_features_gen.go +++ b/vendor/google.golang.org/protobuf/internal/genid/go_features_gen.go @@ -10,7 +10,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" ) -const File_reflect_protodesc_proto_go_features_proto = "reflect/protodesc/proto/go_features.proto" +const File_google_protobuf_go_features_proto = "google/protobuf/go_features.proto" // Names for google.protobuf.GoFeatures. const ( diff --git a/vendor/google.golang.org/protobuf/internal/impl/api_export.go b/vendor/google.golang.org/protobuf/internal/impl/api_export.go index a371f98de14..5d5771c2ed5 100644 --- a/vendor/google.golang.org/protobuf/internal/impl/api_export.go +++ b/vendor/google.golang.org/protobuf/internal/impl/api_export.go @@ -22,13 +22,13 @@ type Export struct{} // NewError formats a string according to the format specifier and arguments and // returns an error that has a "proto" prefix. -func (Export) NewError(f string, x ...interface{}) error { +func (Export) NewError(f string, x ...any) error { return errors.New(f, x...) } // enum is any enum type generated by protoc-gen-go // and must be a named int32 type. -type enum = interface{} +type enum = any // EnumOf returns the protoreflect.Enum interface over e. // It returns nil if e is nil. @@ -81,7 +81,7 @@ func (Export) EnumStringOf(ed protoreflect.EnumDescriptor, n protoreflect.EnumNu // message is any message type generated by protoc-gen-go // and must be a pointer to a named struct type. -type message = interface{} +type message = any // legacyMessageWrapper wraps a v2 message as a v1 message. type legacyMessageWrapper struct{ m protoreflect.ProtoMessage } diff --git a/vendor/google.golang.org/protobuf/internal/impl/checkinit.go b/vendor/google.golang.org/protobuf/internal/impl/checkinit.go index bff041edc94..f29e6a8fa88 100644 --- a/vendor/google.golang.org/protobuf/internal/impl/checkinit.go +++ b/vendor/google.golang.org/protobuf/internal/impl/checkinit.go @@ -68,7 +68,7 @@ func (mi *MessageInfo) isInitExtensions(ext *map[int32]ExtensionField) error { } for _, x := range *ext { ei := getExtensionFieldInfo(x.Type()) - if ei.funcs.isInit == nil { + if ei.funcs.isInit == nil || x.isUnexpandedLazy() { continue } v := x.Value() diff --git a/vendor/google.golang.org/protobuf/internal/impl/codec_extension.go b/vendor/google.golang.org/protobuf/internal/impl/codec_extension.go index 2b8f122c27b..4bb0a7a20ce 100644 --- a/vendor/google.golang.org/protobuf/internal/impl/codec_extension.go +++ b/vendor/google.golang.org/protobuf/internal/impl/codec_extension.go @@ -99,6 +99,28 @@ func (f *ExtensionField) canLazy(xt protoreflect.ExtensionType) bool { return false } +// isUnexpandedLazy returns true if the ExensionField is lazy and not +// yet expanded, which means it's present and already checked for +// initialized required fields. +func (f *ExtensionField) isUnexpandedLazy() bool { + return f.lazy != nil && atomic.LoadUint32(&f.lazy.atomicOnce) == 0 +} + +// lazyBuffer retrieves the buffer for a lazy extension if it's not yet expanded. +// +// The returned buffer has to be kept over whatever operation we're planning, +// as re-retrieving it will fail after the message is lazily decoded. +func (f *ExtensionField) lazyBuffer() []byte { + // This function might be in the critical path, so check the atomic without + // taking a look first, then only take the lock if needed. + if !f.isUnexpandedLazy() { + return nil + } + f.lazy.mu.Lock() + defer f.lazy.mu.Unlock() + return f.lazy.b +} + func (f *ExtensionField) lazyInit() { f.lazy.mu.Lock() defer f.lazy.mu.Unlock() diff --git a/vendor/google.golang.org/protobuf/internal/impl/codec_field.go b/vendor/google.golang.org/protobuf/internal/impl/codec_field.go index 3fadd241e1c..78ee47e44b9 100644 --- a/vendor/google.golang.org/protobuf/internal/impl/codec_field.go +++ b/vendor/google.golang.org/protobuf/internal/impl/codec_field.go @@ -233,9 +233,15 @@ func sizeMessageInfo(p pointer, f *coderFieldInfo, opts marshalOptions) int { } func appendMessageInfo(b []byte, p pointer, f *coderFieldInfo, opts marshalOptions) ([]byte, error) { + calculatedSize := f.mi.sizePointer(p.Elem(), opts) b = protowire.AppendVarint(b, f.wiretag) - b = protowire.AppendVarint(b, uint64(f.mi.sizePointer(p.Elem(), opts))) - return f.mi.marshalAppendPointer(b, p.Elem(), opts) + b = protowire.AppendVarint(b, uint64(calculatedSize)) + before := len(b) + b, err := f.mi.marshalAppendPointer(b, p.Elem(), opts) + if measuredSize := len(b) - before; calculatedSize != measuredSize && err == nil { + return nil, errors.MismatchedSizeCalculation(calculatedSize, measuredSize) + } + return b, err } func consumeMessageInfo(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (out unmarshalOutput, err error) { @@ -262,14 +268,21 @@ func isInitMessageInfo(p pointer, f *coderFieldInfo) error { return f.mi.checkInitializedPointer(p.Elem()) } -func sizeMessage(m proto.Message, tagsize int, _ marshalOptions) int { - return protowire.SizeBytes(proto.Size(m)) + tagsize +func sizeMessage(m proto.Message, tagsize int, opts marshalOptions) int { + return protowire.SizeBytes(opts.Options().Size(m)) + tagsize } func appendMessage(b []byte, m proto.Message, wiretag uint64, opts marshalOptions) ([]byte, error) { + mopts := opts.Options() + calculatedSize := mopts.Size(m) b = protowire.AppendVarint(b, wiretag) - b = protowire.AppendVarint(b, uint64(proto.Size(m))) - return opts.Options().MarshalAppend(b, m) + b = protowire.AppendVarint(b, uint64(calculatedSize)) + before := len(b) + b, err := mopts.MarshalAppend(b, m) + if measuredSize := len(b) - before; calculatedSize != measuredSize && err == nil { + return nil, errors.MismatchedSizeCalculation(calculatedSize, measuredSize) + } + return b, err } func consumeMessage(b []byte, m proto.Message, wtyp protowire.Type, opts unmarshalOptions) (out unmarshalOutput, err error) { @@ -405,8 +418,8 @@ func consumeGroupType(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInf return f.mi.unmarshalPointer(b, p.Elem(), f.num, opts) } -func sizeGroup(m proto.Message, tagsize int, _ marshalOptions) int { - return 2*tagsize + proto.Size(m) +func sizeGroup(m proto.Message, tagsize int, opts marshalOptions) int { + return 2*tagsize + opts.Options().Size(m) } func appendGroup(b []byte, m proto.Message, wiretag uint64, opts marshalOptions) ([]byte, error) { @@ -482,10 +495,14 @@ func appendMessageSliceInfo(b []byte, p pointer, f *coderFieldInfo, opts marshal b = protowire.AppendVarint(b, f.wiretag) siz := f.mi.sizePointer(v, opts) b = protowire.AppendVarint(b, uint64(siz)) + before := len(b) b, err = f.mi.marshalAppendPointer(b, v, opts) if err != nil { return b, err } + if measuredSize := len(b) - before; siz != measuredSize { + return nil, errors.MismatchedSizeCalculation(siz, measuredSize) + } } return b, nil } @@ -520,28 +537,34 @@ func isInitMessageSliceInfo(p pointer, f *coderFieldInfo) error { return nil } -func sizeMessageSlice(p pointer, goType reflect.Type, tagsize int, _ marshalOptions) int { +func sizeMessageSlice(p pointer, goType reflect.Type, tagsize int, opts marshalOptions) int { + mopts := opts.Options() s := p.PointerSlice() n := 0 for _, v := range s { m := asMessage(v.AsValueOf(goType.Elem())) - n += protowire.SizeBytes(proto.Size(m)) + tagsize + n += protowire.SizeBytes(mopts.Size(m)) + tagsize } return n } func appendMessageSlice(b []byte, p pointer, wiretag uint64, goType reflect.Type, opts marshalOptions) ([]byte, error) { + mopts := opts.Options() s := p.PointerSlice() var err error for _, v := range s { m := asMessage(v.AsValueOf(goType.Elem())) b = protowire.AppendVarint(b, wiretag) - siz := proto.Size(m) + siz := mopts.Size(m) b = protowire.AppendVarint(b, uint64(siz)) - b, err = opts.Options().MarshalAppend(b, m) + before := len(b) + b, err = mopts.MarshalAppend(b, m) if err != nil { return b, err } + if measuredSize := len(b) - before; siz != measuredSize { + return nil, errors.MismatchedSizeCalculation(siz, measuredSize) + } } return b, nil } @@ -582,11 +605,12 @@ func isInitMessageSlice(p pointer, goType reflect.Type) error { // Slices of messages func sizeMessageSliceValue(listv protoreflect.Value, tagsize int, opts marshalOptions) int { + mopts := opts.Options() list := listv.List() n := 0 for i, llen := 0, list.Len(); i < llen; i++ { m := list.Get(i).Message().Interface() - n += protowire.SizeBytes(proto.Size(m)) + tagsize + n += protowire.SizeBytes(mopts.Size(m)) + tagsize } return n } @@ -597,13 +621,17 @@ func appendMessageSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, for i, llen := 0, list.Len(); i < llen; i++ { m := list.Get(i).Message().Interface() b = protowire.AppendVarint(b, wiretag) - siz := proto.Size(m) + siz := mopts.Size(m) b = protowire.AppendVarint(b, uint64(siz)) + before := len(b) var err error b, err = mopts.MarshalAppend(b, m) if err != nil { return b, err } + if measuredSize := len(b) - before; siz != measuredSize { + return nil, errors.MismatchedSizeCalculation(siz, measuredSize) + } } return b, nil } @@ -651,11 +679,12 @@ var coderMessageSliceValue = valueCoderFuncs{ } func sizeGroupSliceValue(listv protoreflect.Value, tagsize int, opts marshalOptions) int { + mopts := opts.Options() list := listv.List() n := 0 for i, llen := 0, list.Len(); i < llen; i++ { m := list.Get(i).Message().Interface() - n += 2*tagsize + proto.Size(m) + n += 2*tagsize + mopts.Size(m) } return n } @@ -738,12 +767,13 @@ func makeGroupSliceFieldCoder(fd protoreflect.FieldDescriptor, ft reflect.Type) } } -func sizeGroupSlice(p pointer, messageType reflect.Type, tagsize int, _ marshalOptions) int { +func sizeGroupSlice(p pointer, messageType reflect.Type, tagsize int, opts marshalOptions) int { + mopts := opts.Options() s := p.PointerSlice() n := 0 for _, v := range s { m := asMessage(v.AsValueOf(messageType.Elem())) - n += 2*tagsize + proto.Size(m) + n += 2*tagsize + mopts.Size(m) } return n } diff --git a/vendor/google.golang.org/protobuf/internal/impl/codec_map.go b/vendor/google.golang.org/protobuf/internal/impl/codec_map.go index 111b9d16f99..fb35f0bae9c 100644 --- a/vendor/google.golang.org/protobuf/internal/impl/codec_map.go +++ b/vendor/google.golang.org/protobuf/internal/impl/codec_map.go @@ -9,6 +9,7 @@ import ( "sort" "google.golang.org/protobuf/encoding/protowire" + "google.golang.org/protobuf/internal/errors" "google.golang.org/protobuf/internal/genid" "google.golang.org/protobuf/reflect/protoreflect" ) @@ -240,11 +241,16 @@ func appendMapItem(b []byte, keyrv, valrv reflect.Value, mapi *mapInfo, f *coder size += mapi.keyFuncs.size(key.Value(), mapKeyTagSize, opts) size += mapi.valFuncs.size(val, mapValTagSize, opts) b = protowire.AppendVarint(b, uint64(size)) + before := len(b) b, err := mapi.keyFuncs.marshal(b, key.Value(), mapi.keyWiretag, opts) if err != nil { return nil, err } - return mapi.valFuncs.marshal(b, val, mapi.valWiretag, opts) + b, err = mapi.valFuncs.marshal(b, val, mapi.valWiretag, opts) + if measuredSize := len(b) - before; size != measuredSize && err == nil { + return nil, errors.MismatchedSizeCalculation(size, measuredSize) + } + return b, err } else { key := mapi.conv.keyConv.PBValueOf(keyrv).MapKey() val := pointerOfValue(valrv) @@ -259,7 +265,12 @@ func appendMapItem(b []byte, keyrv, valrv reflect.Value, mapi *mapInfo, f *coder } b = protowire.AppendVarint(b, mapi.valWiretag) b = protowire.AppendVarint(b, uint64(valSize)) - return f.mi.marshalAppendPointer(b, val, opts) + before := len(b) + b, err = f.mi.marshalAppendPointer(b, val, opts) + if measuredSize := len(b) - before; valSize != measuredSize && err == nil { + return nil, errors.MismatchedSizeCalculation(valSize, measuredSize) + } + return b, err } } diff --git a/vendor/google.golang.org/protobuf/internal/impl/codec_messageset.go b/vendor/google.golang.org/protobuf/internal/impl/codec_messageset.go index b7a23faf1e4..7a16ec13dd1 100644 --- a/vendor/google.golang.org/protobuf/internal/impl/codec_messageset.go +++ b/vendor/google.golang.org/protobuf/internal/impl/codec_messageset.go @@ -26,6 +26,15 @@ func sizeMessageSet(mi *MessageInfo, p pointer, opts marshalOptions) (size int) } num, _ := protowire.DecodeTag(xi.wiretag) size += messageset.SizeField(num) + if fullyLazyExtensions(opts) { + // Don't expand the extension, instead use the buffer to calculate size + if lb := x.lazyBuffer(); lb != nil { + // We got hold of the buffer, so it's still lazy. + // Don't count the tag size in the extension buffer, it's already added. + size += protowire.SizeTag(messageset.FieldMessage) + len(lb) - xi.tagsize + continue + } + } size += xi.funcs.size(x.Value(), protowire.SizeTag(messageset.FieldMessage), opts) } @@ -85,6 +94,19 @@ func marshalMessageSetField(mi *MessageInfo, b []byte, x ExtensionField, opts ma xi := getExtensionFieldInfo(x.Type()) num, _ := protowire.DecodeTag(xi.wiretag) b = messageset.AppendFieldStart(b, num) + + if fullyLazyExtensions(opts) { + // Don't expand the extension if it's still in wire format, instead use the buffer content. + if lb := x.lazyBuffer(); lb != nil { + // The tag inside the lazy buffer is a different tag (the extension + // number), but what we need here is the tag for FieldMessage: + b = protowire.AppendVarint(b, protowire.EncodeTag(messageset.FieldMessage, protowire.BytesType)) + b = append(b, lb[xi.tagsize:]...) + b = messageset.AppendFieldEnd(b) + return b, nil + } + } + b, err := xi.funcs.marshal(b, x.Value(), protowire.EncodeTag(messageset.FieldMessage, protowire.BytesType), opts) if err != nil { return b, err diff --git a/vendor/google.golang.org/protobuf/internal/impl/convert.go b/vendor/google.golang.org/protobuf/internal/impl/convert.go index 185ef2efa5b..e06ece55a26 100644 --- a/vendor/google.golang.org/protobuf/internal/impl/convert.go +++ b/vendor/google.golang.org/protobuf/internal/impl/convert.go @@ -14,7 +14,7 @@ import ( // unwrapper unwraps the value to the underlying value. // This is implemented by List and Map. type unwrapper interface { - protoUnwrap() interface{} + protoUnwrap() any } // A Converter coverts to/from Go reflect.Value types and protobuf protoreflect.Value types. diff --git a/vendor/google.golang.org/protobuf/internal/impl/convert_list.go b/vendor/google.golang.org/protobuf/internal/impl/convert_list.go index f89136516f9..18cb96fd70a 100644 --- a/vendor/google.golang.org/protobuf/internal/impl/convert_list.go +++ b/vendor/google.golang.org/protobuf/internal/impl/convert_list.go @@ -136,6 +136,6 @@ func (ls *listReflect) NewElement() protoreflect.Value { func (ls *listReflect) IsValid() bool { return !ls.v.IsNil() } -func (ls *listReflect) protoUnwrap() interface{} { +func (ls *listReflect) protoUnwrap() any { return ls.v.Interface() } diff --git a/vendor/google.golang.org/protobuf/internal/impl/convert_map.go b/vendor/google.golang.org/protobuf/internal/impl/convert_map.go index f30b0a0576d..304244a651d 100644 --- a/vendor/google.golang.org/protobuf/internal/impl/convert_map.go +++ b/vendor/google.golang.org/protobuf/internal/impl/convert_map.go @@ -116,6 +116,6 @@ func (ms *mapReflect) NewValue() protoreflect.Value { func (ms *mapReflect) IsValid() bool { return !ms.v.IsNil() } -func (ms *mapReflect) protoUnwrap() interface{} { +func (ms *mapReflect) protoUnwrap() any { return ms.v.Interface() } diff --git a/vendor/google.golang.org/protobuf/internal/impl/encode.go b/vendor/google.golang.org/protobuf/internal/impl/encode.go index 845c67d6e7e..febd2122472 100644 --- a/vendor/google.golang.org/protobuf/internal/impl/encode.go +++ b/vendor/google.golang.org/protobuf/internal/impl/encode.go @@ -49,8 +49,11 @@ func (mi *MessageInfo) sizePointer(p pointer, opts marshalOptions) (size int) { return 0 } if opts.UseCachedSize() && mi.sizecacheOffset.IsValid() { - if size := atomic.LoadInt32(p.Apply(mi.sizecacheOffset).Int32()); size >= 0 { - return int(size) + // The size cache contains the size + 1, to allow the + // zero value to be invalid, while also allowing for a + // 0 size to be cached. + if size := atomic.LoadInt32(p.Apply(mi.sizecacheOffset).Int32()); size > 0 { + return int(size - 1) } } return mi.sizePointerSlow(p, opts) @@ -60,7 +63,7 @@ func (mi *MessageInfo) sizePointerSlow(p pointer, opts marshalOptions) (size int if flags.ProtoLegacy && mi.isMessageSet { size = sizeMessageSet(mi, p, opts) if mi.sizecacheOffset.IsValid() { - atomic.StoreInt32(p.Apply(mi.sizecacheOffset).Int32(), int32(size)) + atomic.StoreInt32(p.Apply(mi.sizecacheOffset).Int32(), int32(size+1)) } return size } @@ -84,13 +87,16 @@ func (mi *MessageInfo) sizePointerSlow(p pointer, opts marshalOptions) (size int } } if mi.sizecacheOffset.IsValid() { - if size > math.MaxInt32 { + if size > (math.MaxInt32 - 1) { // The size is too large for the int32 sizecache field. // We will need to recompute the size when encoding; // unfortunately expensive, but better than invalid output. - atomic.StoreInt32(p.Apply(mi.sizecacheOffset).Int32(), -1) + atomic.StoreInt32(p.Apply(mi.sizecacheOffset).Int32(), 0) } else { - atomic.StoreInt32(p.Apply(mi.sizecacheOffset).Int32(), int32(size)) + // The size cache contains the size + 1, to allow the + // zero value to be invalid, while also allowing for a + // 0 size to be cached. + atomic.StoreInt32(p.Apply(mi.sizecacheOffset).Int32(), int32(size+1)) } } return size @@ -149,6 +155,14 @@ func (mi *MessageInfo) marshalAppendPointer(b []byte, p pointer, opts marshalOpt return b, nil } +// fullyLazyExtensions returns true if we should attempt to keep extensions lazy over size and marshal. +func fullyLazyExtensions(opts marshalOptions) bool { + // When deterministic marshaling is requested, force an unmarshal for lazy + // extensions to produce a deterministic result, instead of passing through + // bytes lazily that may or may not match what Go Protobuf would produce. + return opts.flags&piface.MarshalDeterministic == 0 +} + func (mi *MessageInfo) sizeExtensions(ext *map[int32]ExtensionField, opts marshalOptions) (n int) { if ext == nil { return 0 @@ -158,6 +172,14 @@ func (mi *MessageInfo) sizeExtensions(ext *map[int32]ExtensionField, opts marsha if xi.funcs.size == nil { continue } + if fullyLazyExtensions(opts) { + // Don't expand the extension, instead use the buffer to calculate size + if lb := x.lazyBuffer(); lb != nil { + // We got hold of the buffer, so it's still lazy. + n += len(lb) + continue + } + } n += xi.funcs.size(x.Value(), xi.tagsize, opts) } return n @@ -176,6 +198,13 @@ func (mi *MessageInfo) appendExtensions(b []byte, ext *map[int32]ExtensionField, var err error for _, x := range *ext { xi := getExtensionFieldInfo(x.Type()) + if fullyLazyExtensions(opts) { + // Don't expand the extension if it's still in wire format, instead use the buffer content. + if lb := x.lazyBuffer(); lb != nil { + b = append(b, lb...) + continue + } + } b, err = xi.funcs.marshal(b, x.Value(), xi.wiretag, opts) } return b, err @@ -191,6 +220,13 @@ func (mi *MessageInfo) appendExtensions(b []byte, ext *map[int32]ExtensionField, for _, k := range keys { x := (*ext)[int32(k)] xi := getExtensionFieldInfo(x.Type()) + if fullyLazyExtensions(opts) { + // Don't expand the extension if it's still in wire format, instead use the buffer content. + if lb := x.lazyBuffer(); lb != nil { + b = append(b, lb...) + continue + } + } b, err = xi.funcs.marshal(b, x.Value(), xi.wiretag, opts) if err != nil { return b, err diff --git a/vendor/google.golang.org/protobuf/internal/impl/extension.go b/vendor/google.golang.org/protobuf/internal/impl/extension.go index cb25b0bae1d..e31249f64f7 100644 --- a/vendor/google.golang.org/protobuf/internal/impl/extension.go +++ b/vendor/google.golang.org/protobuf/internal/impl/extension.go @@ -53,7 +53,7 @@ type ExtensionInfo struct { // type returned by InterfaceOf may not be identical. // // Deprecated: Use InterfaceOf(xt.Zero()) instead. - ExtensionType interface{} + ExtensionType any // Field is the field number of the extension. // @@ -95,16 +95,16 @@ func (xi *ExtensionInfo) New() protoreflect.Value { func (xi *ExtensionInfo) Zero() protoreflect.Value { return xi.lazyInit().Zero() } -func (xi *ExtensionInfo) ValueOf(v interface{}) protoreflect.Value { +func (xi *ExtensionInfo) ValueOf(v any) protoreflect.Value { return xi.lazyInit().PBValueOf(reflect.ValueOf(v)) } -func (xi *ExtensionInfo) InterfaceOf(v protoreflect.Value) interface{} { +func (xi *ExtensionInfo) InterfaceOf(v protoreflect.Value) any { return xi.lazyInit().GoValueOf(v).Interface() } func (xi *ExtensionInfo) IsValidValue(v protoreflect.Value) bool { return xi.lazyInit().IsValidPB(v) } -func (xi *ExtensionInfo) IsValidInterface(v interface{}) bool { +func (xi *ExtensionInfo) IsValidInterface(v any) bool { return xi.lazyInit().IsValidGo(reflect.ValueOf(v)) } func (xi *ExtensionInfo) TypeDescriptor() protoreflect.ExtensionTypeDescriptor { diff --git a/vendor/google.golang.org/protobuf/internal/impl/legacy_enum.go b/vendor/google.golang.org/protobuf/internal/impl/legacy_enum.go index c2a803bb2f9..81b2b1a763d 100644 --- a/vendor/google.golang.org/protobuf/internal/impl/legacy_enum.go +++ b/vendor/google.golang.org/protobuf/internal/impl/legacy_enum.go @@ -97,7 +97,7 @@ func (e *legacyEnumWrapper) Number() protoreflect.EnumNumber { func (e *legacyEnumWrapper) ProtoReflect() protoreflect.Enum { return e } -func (e *legacyEnumWrapper) protoUnwrap() interface{} { +func (e *legacyEnumWrapper) protoUnwrap() any { v := reflect.New(e.goTyp).Elem() v.SetInt(int64(e.num)) return v.Interface() @@ -167,6 +167,7 @@ func aberrantLoadEnumDesc(t reflect.Type) protoreflect.EnumDescriptor { ed := &filedesc.Enum{L2: new(filedesc.EnumL2)} ed.L0.FullName = AberrantDeriveFullName(t) // e.g., github_com.user.repo.MyEnum ed.L0.ParentFile = filedesc.SurrogateProto3 + ed.L1.EditionFeatures = ed.L0.ParentFile.L1.EditionFeatures ed.L2.Values.List = append(ed.L2.Values.List, filedesc.EnumValue{}) // TODO: Use the presence of a UnmarshalJSON method to determine proto2? diff --git a/vendor/google.golang.org/protobuf/internal/impl/legacy_extension.go b/vendor/google.golang.org/protobuf/internal/impl/legacy_extension.go index 87b30d0504c..6e8677ee633 100644 --- a/vendor/google.golang.org/protobuf/internal/impl/legacy_extension.go +++ b/vendor/google.golang.org/protobuf/internal/impl/legacy_extension.go @@ -118,7 +118,7 @@ func (xi *ExtensionInfo) initFromLegacy() { xd.L1.Number = protoreflect.FieldNumber(xi.Field) xd.L1.Cardinality = fd.L1.Cardinality xd.L1.Kind = fd.L1.Kind - xd.L2.IsPacked = fd.L1.IsPacked + xd.L1.EditionFeatures = fd.L1.EditionFeatures xd.L2.Default = fd.L1.Default xd.L1.Extendee = Export{}.MessageDescriptorOf(xi.ExtendedType) xd.L2.Enum = ed diff --git a/vendor/google.golang.org/protobuf/internal/impl/legacy_file.go b/vendor/google.golang.org/protobuf/internal/impl/legacy_file.go index 9ab091086c9..b649f1124b8 100644 --- a/vendor/google.golang.org/protobuf/internal/impl/legacy_file.go +++ b/vendor/google.golang.org/protobuf/internal/impl/legacy_file.go @@ -7,7 +7,7 @@ package impl import ( "bytes" "compress/gzip" - "io/ioutil" + "io" "sync" "google.golang.org/protobuf/internal/filedesc" @@ -51,7 +51,7 @@ func legacyLoadFileDesc(b []byte) protoreflect.FileDescriptor { if err != nil { panic(err) } - b2, err := ioutil.ReadAll(zr) + b2, err := io.ReadAll(zr) if err != nil { panic(err) } diff --git a/vendor/google.golang.org/protobuf/internal/impl/legacy_message.go b/vendor/google.golang.org/protobuf/internal/impl/legacy_message.go index 2ab2c629784..bf0b6049b46 100644 --- a/vendor/google.golang.org/protobuf/internal/impl/legacy_message.go +++ b/vendor/google.golang.org/protobuf/internal/impl/legacy_message.go @@ -204,6 +204,7 @@ func aberrantLoadMessageDescReentrant(t reflect.Type, name protoreflect.FullName } } + md.L1.EditionFeatures = md.L0.ParentFile.L1.EditionFeatures // Obtain a list of oneof wrapper types. var oneofWrappers []reflect.Type methods := make([]reflect.Method, 0, 2) @@ -215,7 +216,7 @@ func aberrantLoadMessageDescReentrant(t reflect.Type, name protoreflect.FullName } for _, fn := range methods { for _, v := range fn.Func.Call([]reflect.Value{reflect.Zero(fn.Type.In(0))}) { - if vs, ok := v.Interface().([]interface{}); ok { + if vs, ok := v.Interface().([]any); ok { for _, v := range vs { oneofWrappers = append(oneofWrappers, reflect.TypeOf(v)) } @@ -250,6 +251,7 @@ func aberrantLoadMessageDescReentrant(t reflect.Type, name protoreflect.FullName od := &md.L2.Oneofs.List[n] od.L0.FullName = md.FullName().Append(protoreflect.Name(tag)) od.L0.ParentFile = md.L0.ParentFile + od.L1.EditionFeatures = md.L1.EditionFeatures od.L0.Parent = md od.L0.Index = n @@ -260,6 +262,7 @@ func aberrantLoadMessageDescReentrant(t reflect.Type, name protoreflect.FullName aberrantAppendField(md, f.Type, tag, "", "") fd := &md.L2.Fields.List[len(md.L2.Fields.List)-1] fd.L1.ContainingOneof = od + fd.L1.EditionFeatures = od.L1.EditionFeatures od.L1.Fields.List = append(od.L1.Fields.List, fd) } } @@ -307,14 +310,14 @@ func aberrantAppendField(md *filedesc.Message, goType reflect.Type, tag, tagKey, fd.L0.Parent = md fd.L0.Index = n - if fd.L1.IsWeak || fd.L1.HasPacked { + if fd.L1.IsWeak || fd.L1.EditionFeatures.IsPacked { fd.L1.Options = func() protoreflect.ProtoMessage { opts := descopts.Field.ProtoReflect().New() if fd.L1.IsWeak { opts.Set(opts.Descriptor().Fields().ByName("weak"), protoreflect.ValueOfBool(true)) } - if fd.L1.HasPacked { - opts.Set(opts.Descriptor().Fields().ByName("packed"), protoreflect.ValueOfBool(fd.L1.IsPacked)) + if fd.L1.EditionFeatures.IsPacked { + opts.Set(opts.Descriptor().Fields().ByName("packed"), protoreflect.ValueOfBool(fd.L1.EditionFeatures.IsPacked)) } return opts.Interface() } @@ -344,6 +347,7 @@ func aberrantAppendField(md *filedesc.Message, goType reflect.Type, tag, tagKey, md2.L0.ParentFile = md.L0.ParentFile md2.L0.Parent = md md2.L0.Index = n + md2.L1.EditionFeatures = md.L1.EditionFeatures md2.L1.IsMapEntry = true md2.L2.Options = func() protoreflect.ProtoMessage { @@ -563,6 +567,6 @@ func (m aberrantMessage) IsValid() bool { func (m aberrantMessage) ProtoMethods() *protoiface.Methods { return aberrantProtoMethods } -func (m aberrantMessage) protoUnwrap() interface{} { +func (m aberrantMessage) protoUnwrap() any { return m.v.Interface() } diff --git a/vendor/google.golang.org/protobuf/internal/impl/message.go b/vendor/google.golang.org/protobuf/internal/impl/message.go index 629bacdcedd..019399d454d 100644 --- a/vendor/google.golang.org/protobuf/internal/impl/message.go +++ b/vendor/google.golang.org/protobuf/internal/impl/message.go @@ -35,7 +35,7 @@ type MessageInfo struct { Exporter exporter // OneofWrappers is list of pointers to oneof wrapper struct types. - OneofWrappers []interface{} + OneofWrappers []any initMu sync.Mutex // protects all unexported fields initDone uint32 @@ -47,7 +47,7 @@ type MessageInfo struct { // exporter is a function that returns a reference to the ith field of v, // where v is a pointer to a struct. It returns nil if it does not support // exporting the requested field (e.g., already exported). -type exporter func(v interface{}, i int) interface{} +type exporter func(v any, i int) any // getMessageInfo returns the MessageInfo for any message type that // is generated by our implementation of protoc-gen-go (for v2 and on). @@ -201,7 +201,7 @@ fieldLoop: } for _, fn := range methods { for _, v := range fn.Func.Call([]reflect.Value{reflect.Zero(fn.Type.In(0))}) { - if vs, ok := v.Interface().([]interface{}); ok { + if vs, ok := v.Interface().([]any); ok { oneofWrappers = vs } } @@ -256,7 +256,7 @@ func (mi *MessageInfo) Message(i int) protoreflect.MessageType { type mapEntryType struct { desc protoreflect.MessageDescriptor - valType interface{} // zero value of enum or message type + valType any // zero value of enum or message type } func (mt mapEntryType) New() protoreflect.Message { diff --git a/vendor/google.golang.org/protobuf/internal/impl/message_reflect.go b/vendor/google.golang.org/protobuf/internal/impl/message_reflect.go index d9ea010bef9..ecb4623d701 100644 --- a/vendor/google.golang.org/protobuf/internal/impl/message_reflect.go +++ b/vendor/google.golang.org/protobuf/internal/impl/message_reflect.go @@ -20,7 +20,7 @@ type reflectMessageInfo struct { // fieldTypes contains the zero value of an enum or message field. // For lists, it contains the element type. // For maps, it contains the entry value type. - fieldTypes map[protoreflect.FieldNumber]interface{} + fieldTypes map[protoreflect.FieldNumber]any // denseFields is a subset of fields where: // 0 < fieldDesc.Number() < len(denseFields) @@ -28,7 +28,7 @@ type reflectMessageInfo struct { denseFields []*fieldInfo // rangeInfos is a list of all fields (not belonging to a oneof) and oneofs. - rangeInfos []interface{} // either *fieldInfo or *oneofInfo + rangeInfos []any // either *fieldInfo or *oneofInfo getUnknown func(pointer) protoreflect.RawFields setUnknown func(pointer, protoreflect.RawFields) @@ -224,7 +224,7 @@ func (mi *MessageInfo) makeFieldTypes(si structInfo) { } if ft != nil { if mi.fieldTypes == nil { - mi.fieldTypes = make(map[protoreflect.FieldNumber]interface{}) + mi.fieldTypes = make(map[protoreflect.FieldNumber]any) } mi.fieldTypes[fd.Number()] = reflect.Zero(ft).Interface() } @@ -247,39 +247,39 @@ func (m *extensionMap) Range(f func(protoreflect.FieldDescriptor, protoreflect.V } } } -func (m *extensionMap) Has(xt protoreflect.ExtensionType) (ok bool) { +func (m *extensionMap) Has(xd protoreflect.ExtensionTypeDescriptor) (ok bool) { if m == nil { return false } - xd := xt.TypeDescriptor() x, ok := (*m)[int32(xd.Number())] if !ok { return false } + if x.isUnexpandedLazy() { + // Avoid calling x.Value(), which triggers a lazy unmarshal. + return true + } switch { case xd.IsList(): return x.Value().List().Len() > 0 case xd.IsMap(): return x.Value().Map().Len() > 0 - case xd.Message() != nil: - return x.Value().Message().IsValid() } return true } -func (m *extensionMap) Clear(xt protoreflect.ExtensionType) { - delete(*m, int32(xt.TypeDescriptor().Number())) +func (m *extensionMap) Clear(xd protoreflect.ExtensionTypeDescriptor) { + delete(*m, int32(xd.Number())) } -func (m *extensionMap) Get(xt protoreflect.ExtensionType) protoreflect.Value { - xd := xt.TypeDescriptor() +func (m *extensionMap) Get(xd protoreflect.ExtensionTypeDescriptor) protoreflect.Value { if m != nil { if x, ok := (*m)[int32(xd.Number())]; ok { return x.Value() } } - return xt.Zero() + return xd.Type().Zero() } -func (m *extensionMap) Set(xt protoreflect.ExtensionType, v protoreflect.Value) { - xd := xt.TypeDescriptor() +func (m *extensionMap) Set(xd protoreflect.ExtensionTypeDescriptor, v protoreflect.Value) { + xt := xd.Type() isValid := true switch { case !xt.IsValidValue(v): @@ -292,7 +292,7 @@ func (m *extensionMap) Set(xt protoreflect.ExtensionType, v protoreflect.Value) isValid = v.Message().IsValid() } if !isValid { - panic(fmt.Sprintf("%v: assigning invalid value", xt.TypeDescriptor().FullName())) + panic(fmt.Sprintf("%v: assigning invalid value", xd.FullName())) } if *m == nil { @@ -302,16 +302,15 @@ func (m *extensionMap) Set(xt protoreflect.ExtensionType, v protoreflect.Value) x.Set(xt, v) (*m)[int32(xd.Number())] = x } -func (m *extensionMap) Mutable(xt protoreflect.ExtensionType) protoreflect.Value { - xd := xt.TypeDescriptor() +func (m *extensionMap) Mutable(xd protoreflect.ExtensionTypeDescriptor) protoreflect.Value { if xd.Kind() != protoreflect.MessageKind && xd.Kind() != protoreflect.GroupKind && !xd.IsList() && !xd.IsMap() { panic("invalid Mutable on field with non-composite type") } if x, ok := (*m)[int32(xd.Number())]; ok { return x.Value() } - v := xt.New() - m.Set(xt, v) + v := xd.Type().New() + m.Set(xd, v) return v } @@ -394,7 +393,7 @@ var ( // MessageOf returns a reflective view over a message. The input must be a // pointer to a named Go struct. If the provided type has a ProtoReflect method, // it must be implemented by calling this method. -func (mi *MessageInfo) MessageOf(m interface{}) protoreflect.Message { +func (mi *MessageInfo) MessageOf(m any) protoreflect.Message { if reflect.TypeOf(m) != mi.GoReflectType { panic(fmt.Sprintf("type mismatch: got %T, want %v", m, mi.GoReflectType)) } @@ -422,13 +421,13 @@ func (m *messageIfaceWrapper) Reset() { func (m *messageIfaceWrapper) ProtoReflect() protoreflect.Message { return (*messageReflectWrapper)(m) } -func (m *messageIfaceWrapper) protoUnwrap() interface{} { +func (m *messageIfaceWrapper) protoUnwrap() any { return m.p.AsIfaceOf(m.mi.GoReflectType.Elem()) } // checkField verifies that the provided field descriptor is valid. // Exactly one of the returned values is populated. -func (mi *MessageInfo) checkField(fd protoreflect.FieldDescriptor) (*fieldInfo, protoreflect.ExtensionType) { +func (mi *MessageInfo) checkField(fd protoreflect.FieldDescriptor) (*fieldInfo, protoreflect.ExtensionTypeDescriptor) { var fi *fieldInfo if n := fd.Number(); 0 < n && int(n) < len(mi.denseFields) { fi = mi.denseFields[n] @@ -457,7 +456,7 @@ func (mi *MessageInfo) checkField(fd protoreflect.FieldDescriptor) (*fieldInfo, if !ok { panic(fmt.Sprintf("extension %v does not implement protoreflect.ExtensionTypeDescriptor", fd.FullName())) } - return nil, xtd.Type() + return nil, xtd } panic(fmt.Sprintf("field %v is invalid", fd.FullName())) } diff --git a/vendor/google.golang.org/protobuf/internal/impl/message_reflect_gen.go b/vendor/google.golang.org/protobuf/internal/impl/message_reflect_gen.go index 741d6e5b6bd..99dc23c6f0a 100644 --- a/vendor/google.golang.org/protobuf/internal/impl/message_reflect_gen.go +++ b/vendor/google.golang.org/protobuf/internal/impl/message_reflect_gen.go @@ -23,12 +23,13 @@ func (m *messageState) New() protoreflect.Message { func (m *messageState) Interface() protoreflect.ProtoMessage { return m.protoUnwrap().(protoreflect.ProtoMessage) } -func (m *messageState) protoUnwrap() interface{} { +func (m *messageState) protoUnwrap() any { return m.pointer().AsIfaceOf(m.messageInfo().GoReflectType.Elem()) } func (m *messageState) ProtoMethods() *protoiface.Methods { - m.messageInfo().init() - return &m.messageInfo().methods + mi := m.messageInfo() + mi.init() + return &mi.methods } // ProtoMessageInfo is a pseudo-internal API for allowing the v1 code @@ -41,8 +42,9 @@ func (m *messageState) ProtoMessageInfo() *MessageInfo { } func (m *messageState) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - m.messageInfo().init() - for _, ri := range m.messageInfo().rangeInfos { + mi := m.messageInfo() + mi.init() + for _, ri := range mi.rangeInfos { switch ri := ri.(type) { case *fieldInfo: if ri.has(m.pointer()) { @@ -52,77 +54,86 @@ func (m *messageState) Range(f func(protoreflect.FieldDescriptor, protoreflect.V } case *oneofInfo: if n := ri.which(m.pointer()); n > 0 { - fi := m.messageInfo().fields[n] + fi := mi.fields[n] if !f(fi.fieldDesc, fi.get(m.pointer())) { return } } } } - m.messageInfo().extensionMap(m.pointer()).Range(f) + mi.extensionMap(m.pointer()).Range(f) } func (m *messageState) Has(fd protoreflect.FieldDescriptor) bool { - m.messageInfo().init() - if fi, xt := m.messageInfo().checkField(fd); fi != nil { + mi := m.messageInfo() + mi.init() + if fi, xd := mi.checkField(fd); fi != nil { return fi.has(m.pointer()) } else { - return m.messageInfo().extensionMap(m.pointer()).Has(xt) + return mi.extensionMap(m.pointer()).Has(xd) } } func (m *messageState) Clear(fd protoreflect.FieldDescriptor) { - m.messageInfo().init() - if fi, xt := m.messageInfo().checkField(fd); fi != nil { + mi := m.messageInfo() + mi.init() + if fi, xd := mi.checkField(fd); fi != nil { fi.clear(m.pointer()) } else { - m.messageInfo().extensionMap(m.pointer()).Clear(xt) + mi.extensionMap(m.pointer()).Clear(xd) } } func (m *messageState) Get(fd protoreflect.FieldDescriptor) protoreflect.Value { - m.messageInfo().init() - if fi, xt := m.messageInfo().checkField(fd); fi != nil { + mi := m.messageInfo() + mi.init() + if fi, xd := mi.checkField(fd); fi != nil { return fi.get(m.pointer()) } else { - return m.messageInfo().extensionMap(m.pointer()).Get(xt) + return mi.extensionMap(m.pointer()).Get(xd) } } func (m *messageState) Set(fd protoreflect.FieldDescriptor, v protoreflect.Value) { - m.messageInfo().init() - if fi, xt := m.messageInfo().checkField(fd); fi != nil { + mi := m.messageInfo() + mi.init() + if fi, xd := mi.checkField(fd); fi != nil { fi.set(m.pointer(), v) } else { - m.messageInfo().extensionMap(m.pointer()).Set(xt, v) + mi.extensionMap(m.pointer()).Set(xd, v) } } func (m *messageState) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { - m.messageInfo().init() - if fi, xt := m.messageInfo().checkField(fd); fi != nil { + mi := m.messageInfo() + mi.init() + if fi, xd := mi.checkField(fd); fi != nil { return fi.mutable(m.pointer()) } else { - return m.messageInfo().extensionMap(m.pointer()).Mutable(xt) + return mi.extensionMap(m.pointer()).Mutable(xd) } } func (m *messageState) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { - m.messageInfo().init() - if fi, xt := m.messageInfo().checkField(fd); fi != nil { + mi := m.messageInfo() + mi.init() + if fi, xd := mi.checkField(fd); fi != nil { return fi.newField() } else { - return xt.New() + return xd.Type().New() } } func (m *messageState) WhichOneof(od protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { - m.messageInfo().init() - if oi := m.messageInfo().oneofs[od.Name()]; oi != nil && oi.oneofDesc == od { + mi := m.messageInfo() + mi.init() + if oi := mi.oneofs[od.Name()]; oi != nil && oi.oneofDesc == od { return od.Fields().ByNumber(oi.which(m.pointer())) } panic("invalid oneof descriptor " + string(od.FullName()) + " for message " + string(m.Descriptor().FullName())) } func (m *messageState) GetUnknown() protoreflect.RawFields { - m.messageInfo().init() - return m.messageInfo().getUnknown(m.pointer()) + mi := m.messageInfo() + mi.init() + return mi.getUnknown(m.pointer()) } func (m *messageState) SetUnknown(b protoreflect.RawFields) { - m.messageInfo().init() - m.messageInfo().setUnknown(m.pointer(), b) + mi := m.messageInfo() + mi.init() + mi.setUnknown(m.pointer(), b) } func (m *messageState) IsValid() bool { return !m.pointer().IsNil() @@ -143,12 +154,13 @@ func (m *messageReflectWrapper) Interface() protoreflect.ProtoMessage { } return (*messageIfaceWrapper)(m) } -func (m *messageReflectWrapper) protoUnwrap() interface{} { +func (m *messageReflectWrapper) protoUnwrap() any { return m.pointer().AsIfaceOf(m.messageInfo().GoReflectType.Elem()) } func (m *messageReflectWrapper) ProtoMethods() *protoiface.Methods { - m.messageInfo().init() - return &m.messageInfo().methods + mi := m.messageInfo() + mi.init() + return &mi.methods } // ProtoMessageInfo is a pseudo-internal API for allowing the v1 code @@ -161,8 +173,9 @@ func (m *messageReflectWrapper) ProtoMessageInfo() *MessageInfo { } func (m *messageReflectWrapper) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - m.messageInfo().init() - for _, ri := range m.messageInfo().rangeInfos { + mi := m.messageInfo() + mi.init() + for _, ri := range mi.rangeInfos { switch ri := ri.(type) { case *fieldInfo: if ri.has(m.pointer()) { @@ -172,77 +185,86 @@ func (m *messageReflectWrapper) Range(f func(protoreflect.FieldDescriptor, proto } case *oneofInfo: if n := ri.which(m.pointer()); n > 0 { - fi := m.messageInfo().fields[n] + fi := mi.fields[n] if !f(fi.fieldDesc, fi.get(m.pointer())) { return } } } } - m.messageInfo().extensionMap(m.pointer()).Range(f) + mi.extensionMap(m.pointer()).Range(f) } func (m *messageReflectWrapper) Has(fd protoreflect.FieldDescriptor) bool { - m.messageInfo().init() - if fi, xt := m.messageInfo().checkField(fd); fi != nil { + mi := m.messageInfo() + mi.init() + if fi, xd := mi.checkField(fd); fi != nil { return fi.has(m.pointer()) } else { - return m.messageInfo().extensionMap(m.pointer()).Has(xt) + return mi.extensionMap(m.pointer()).Has(xd) } } func (m *messageReflectWrapper) Clear(fd protoreflect.FieldDescriptor) { - m.messageInfo().init() - if fi, xt := m.messageInfo().checkField(fd); fi != nil { + mi := m.messageInfo() + mi.init() + if fi, xd := mi.checkField(fd); fi != nil { fi.clear(m.pointer()) } else { - m.messageInfo().extensionMap(m.pointer()).Clear(xt) + mi.extensionMap(m.pointer()).Clear(xd) } } func (m *messageReflectWrapper) Get(fd protoreflect.FieldDescriptor) protoreflect.Value { - m.messageInfo().init() - if fi, xt := m.messageInfo().checkField(fd); fi != nil { + mi := m.messageInfo() + mi.init() + if fi, xd := mi.checkField(fd); fi != nil { return fi.get(m.pointer()) } else { - return m.messageInfo().extensionMap(m.pointer()).Get(xt) + return mi.extensionMap(m.pointer()).Get(xd) } } func (m *messageReflectWrapper) Set(fd protoreflect.FieldDescriptor, v protoreflect.Value) { - m.messageInfo().init() - if fi, xt := m.messageInfo().checkField(fd); fi != nil { + mi := m.messageInfo() + mi.init() + if fi, xd := mi.checkField(fd); fi != nil { fi.set(m.pointer(), v) } else { - m.messageInfo().extensionMap(m.pointer()).Set(xt, v) + mi.extensionMap(m.pointer()).Set(xd, v) } } func (m *messageReflectWrapper) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { - m.messageInfo().init() - if fi, xt := m.messageInfo().checkField(fd); fi != nil { + mi := m.messageInfo() + mi.init() + if fi, xd := mi.checkField(fd); fi != nil { return fi.mutable(m.pointer()) } else { - return m.messageInfo().extensionMap(m.pointer()).Mutable(xt) + return mi.extensionMap(m.pointer()).Mutable(xd) } } func (m *messageReflectWrapper) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { - m.messageInfo().init() - if fi, xt := m.messageInfo().checkField(fd); fi != nil { + mi := m.messageInfo() + mi.init() + if fi, xd := mi.checkField(fd); fi != nil { return fi.newField() } else { - return xt.New() + return xd.Type().New() } } func (m *messageReflectWrapper) WhichOneof(od protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { - m.messageInfo().init() - if oi := m.messageInfo().oneofs[od.Name()]; oi != nil && oi.oneofDesc == od { + mi := m.messageInfo() + mi.init() + if oi := mi.oneofs[od.Name()]; oi != nil && oi.oneofDesc == od { return od.Fields().ByNumber(oi.which(m.pointer())) } panic("invalid oneof descriptor " + string(od.FullName()) + " for message " + string(m.Descriptor().FullName())) } func (m *messageReflectWrapper) GetUnknown() protoreflect.RawFields { - m.messageInfo().init() - return m.messageInfo().getUnknown(m.pointer()) + mi := m.messageInfo() + mi.init() + return mi.getUnknown(m.pointer()) } func (m *messageReflectWrapper) SetUnknown(b protoreflect.RawFields) { - m.messageInfo().init() - m.messageInfo().setUnknown(m.pointer(), b) + mi := m.messageInfo() + mi.init() + mi.setUnknown(m.pointer(), b) } func (m *messageReflectWrapper) IsValid() bool { return !m.pointer().IsNil() diff --git a/vendor/google.golang.org/protobuf/internal/impl/pointer_reflect.go b/vendor/google.golang.org/protobuf/internal/impl/pointer_reflect.go index 517e94434c7..da685e8a29d 100644 --- a/vendor/google.golang.org/protobuf/internal/impl/pointer_reflect.go +++ b/vendor/google.golang.org/protobuf/internal/impl/pointer_reflect.go @@ -16,7 +16,7 @@ import ( const UnsafeEnabled = false // Pointer is an opaque pointer type. -type Pointer interface{} +type Pointer any // offset represents the offset to a struct field, accessible from a pointer. // The offset is the field index into a struct. @@ -62,7 +62,7 @@ func pointerOfValue(v reflect.Value) pointer { } // pointerOfIface returns the pointer portion of an interface. -func pointerOfIface(v interface{}) pointer { +func pointerOfIface(v any) pointer { return pointer{v: reflect.ValueOf(v)} } @@ -93,7 +93,7 @@ func (p pointer) AsValueOf(t reflect.Type) reflect.Value { // AsIfaceOf treats p as a pointer to an object of type t and returns the value. // It is equivalent to p.AsValueOf(t).Interface() -func (p pointer) AsIfaceOf(t reflect.Type) interface{} { +func (p pointer) AsIfaceOf(t reflect.Type) any { return p.AsValueOf(t).Interface() } diff --git a/vendor/google.golang.org/protobuf/internal/impl/pointer_unsafe.go b/vendor/google.golang.org/protobuf/internal/impl/pointer_unsafe.go index 4b020e31164..5f20ca5d8ab 100644 --- a/vendor/google.golang.org/protobuf/internal/impl/pointer_unsafe.go +++ b/vendor/google.golang.org/protobuf/internal/impl/pointer_unsafe.go @@ -50,7 +50,7 @@ func pointerOfValue(v reflect.Value) pointer { } // pointerOfIface returns the pointer portion of an interface. -func pointerOfIface(v interface{}) pointer { +func pointerOfIface(v any) pointer { type ifaceHeader struct { Type unsafe.Pointer Data unsafe.Pointer @@ -80,7 +80,7 @@ func (p pointer) AsValueOf(t reflect.Type) reflect.Value { // AsIfaceOf treats p as a pointer to an object of type t and returns the value. // It is equivalent to p.AsValueOf(t).Interface() -func (p pointer) AsIfaceOf(t reflect.Type) interface{} { +func (p pointer) AsIfaceOf(t reflect.Type) any { // TODO: Use tricky unsafe magic to directly create ifaceHeader. return p.AsValueOf(t).Interface() } diff --git a/vendor/google.golang.org/protobuf/internal/order/range.go b/vendor/google.golang.org/protobuf/internal/order/range.go index 1665a68e5b7..a1f09162d05 100644 --- a/vendor/google.golang.org/protobuf/internal/order/range.go +++ b/vendor/google.golang.org/protobuf/internal/order/range.go @@ -18,7 +18,7 @@ type messageField struct { } var messageFieldPool = sync.Pool{ - New: func() interface{} { return new([]messageField) }, + New: func() any { return new([]messageField) }, } type ( @@ -69,7 +69,7 @@ type mapEntry struct { } var mapEntryPool = sync.Pool{ - New: func() interface{} { return new([]mapEntry) }, + New: func() any { return new([]mapEntry) }, } type ( diff --git a/vendor/google.golang.org/protobuf/internal/version/version.go b/vendor/google.golang.org/protobuf/internal/version/version.go index a50fcfb49b7..dbbf1f6862c 100644 --- a/vendor/google.golang.org/protobuf/internal/version/version.go +++ b/vendor/google.golang.org/protobuf/internal/version/version.go @@ -51,8 +51,8 @@ import ( // 10. Send out the CL for review and submit it. const ( Major = 1 - Minor = 33 - Patch = 0 + Minor = 34 + Patch = 2 PreRelease = "" ) diff --git a/vendor/google.golang.org/protobuf/proto/decode.go b/vendor/google.golang.org/protobuf/proto/decode.go index e5b03b56771..d75a6534c1b 100644 --- a/vendor/google.golang.org/protobuf/proto/decode.go +++ b/vendor/google.golang.org/protobuf/proto/decode.go @@ -51,6 +51,8 @@ type UnmarshalOptions struct { // Unmarshal parses the wire-format message in b and places the result in m. // The provided message must be mutable (e.g., a non-nil pointer to a message). +// +// See the [UnmarshalOptions] type if you need more control. func Unmarshal(b []byte, m Message) error { _, err := UnmarshalOptions{RecursionLimit: protowire.DefaultRecursionLimit}.unmarshal(b, m.ProtoReflect()) return err diff --git a/vendor/google.golang.org/protobuf/proto/encode.go b/vendor/google.golang.org/protobuf/proto/encode.go index 4fed202f9fc..1f847bcc358 100644 --- a/vendor/google.golang.org/protobuf/proto/encode.go +++ b/vendor/google.golang.org/protobuf/proto/encode.go @@ -5,12 +5,17 @@ package proto import ( + "errors" + "fmt" + "google.golang.org/protobuf/encoding/protowire" "google.golang.org/protobuf/internal/encoding/messageset" "google.golang.org/protobuf/internal/order" "google.golang.org/protobuf/internal/pragma" "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/runtime/protoiface" + + protoerrors "google.golang.org/protobuf/internal/errors" ) // MarshalOptions configures the marshaler. @@ -70,7 +75,32 @@ type MarshalOptions struct { UseCachedSize bool } +// flags turns the specified MarshalOptions (user-facing) into +// protoiface.MarshalInputFlags (used internally by the marshaler). +// +// See impl.marshalOptions.Options for the inverse operation. +func (o MarshalOptions) flags() protoiface.MarshalInputFlags { + var flags protoiface.MarshalInputFlags + + // Note: o.AllowPartial is always forced to true by MarshalOptions.marshal, + // which is why it is not a part of MarshalInputFlags. + + if o.Deterministic { + flags |= protoiface.MarshalDeterministic + } + + if o.UseCachedSize { + flags |= protoiface.MarshalUseCachedSize + } + + return flags +} + // Marshal returns the wire-format encoding of m. +// +// This is the most common entry point for encoding a Protobuf message. +// +// See the [MarshalOptions] type if you need more control. func Marshal(m Message) ([]byte, error) { // Treat nil message interface as an empty message; nothing to output. if m == nil { @@ -116,6 +146,9 @@ func emptyBytesForMessage(m Message) []byte { // MarshalAppend appends the wire-format encoding of m to b, // returning the result. +// +// This is a less common entry point than [Marshal], which is only needed if you +// need to supply your own buffers for performance reasons. func (o MarshalOptions) MarshalAppend(b []byte, m Message) ([]byte, error) { // Treat nil message interface as an empty message; nothing to append. if m == nil { @@ -145,12 +178,7 @@ func (o MarshalOptions) marshal(b []byte, m protoreflect.Message) (out protoifac in := protoiface.MarshalInput{ Message: m, Buf: b, - } - if o.Deterministic { - in.Flags |= protoiface.MarshalDeterministic - } - if o.UseCachedSize { - in.Flags |= protoiface.MarshalUseCachedSize + Flags: o.flags(), } if methods.Size != nil { sout := methods.Size(protoiface.SizeInput{ @@ -168,6 +196,10 @@ func (o MarshalOptions) marshal(b []byte, m protoreflect.Message) (out protoifac out.Buf, err = o.marshalMessageSlow(b, m) } if err != nil { + var mismatch *protoerrors.SizeMismatchError + if errors.As(err, &mismatch) { + return out, fmt.Errorf("marshaling %s: %v", string(m.Descriptor().FullName()), err) + } return out, err } if allowPartial { diff --git a/vendor/google.golang.org/protobuf/proto/extension.go b/vendor/google.golang.org/protobuf/proto/extension.go index 17899a3a767..d248f292846 100644 --- a/vendor/google.golang.org/protobuf/proto/extension.go +++ b/vendor/google.golang.org/protobuf/proto/extension.go @@ -11,18 +11,21 @@ import ( // HasExtension reports whether an extension field is populated. // It returns false if m is invalid or if xt does not extend m. func HasExtension(m Message, xt protoreflect.ExtensionType) bool { - // Treat nil message interface as an empty message; no populated fields. - if m == nil { + // Treat nil message interface or descriptor as an empty message; no populated + // fields. + if m == nil || xt == nil { return false } // As a special-case, we reports invalid or mismatching descriptors // as always not being populated (since they aren't). - if xt == nil || m.ProtoReflect().Descriptor() != xt.TypeDescriptor().ContainingMessage() { + mr := m.ProtoReflect() + xd := xt.TypeDescriptor() + if mr.Descriptor() != xd.ContainingMessage() { return false } - return m.ProtoReflect().Has(xt.TypeDescriptor()) + return mr.Has(xd) } // ClearExtension clears an extension field such that subsequent @@ -36,7 +39,7 @@ func ClearExtension(m Message, xt protoreflect.ExtensionType) { // If the field is unpopulated, it returns the default value for // scalars and an immutable, empty value for lists or messages. // It panics if xt does not extend m. -func GetExtension(m Message, xt protoreflect.ExtensionType) interface{} { +func GetExtension(m Message, xt protoreflect.ExtensionType) any { // Treat nil message interface as an empty message; return the default. if m == nil { return xt.InterfaceOf(xt.Zero()) @@ -48,7 +51,7 @@ func GetExtension(m Message, xt protoreflect.ExtensionType) interface{} { // SetExtension stores the value of an extension field. // It panics if m is invalid, xt does not extend m, or if type of v // is invalid for the specified extension field. -func SetExtension(m Message, xt protoreflect.ExtensionType, v interface{}) { +func SetExtension(m Message, xt protoreflect.ExtensionType, v any) { xd := xt.TypeDescriptor() pv := xt.ValueOf(v) @@ -75,7 +78,7 @@ func SetExtension(m Message, xt protoreflect.ExtensionType, v interface{}) { // It returns immediately if f returns false. // While iterating, mutating operations may only be performed // on the current extension field. -func RangeExtensions(m Message, f func(protoreflect.ExtensionType, interface{}) bool) { +func RangeExtensions(m Message, f func(protoreflect.ExtensionType, any) bool) { // Treat nil message interface as an empty message; nothing to range over. if m == nil { return diff --git a/vendor/google.golang.org/protobuf/proto/messageset.go b/vendor/google.golang.org/protobuf/proto/messageset.go index 312d5d45c60..575d14831ff 100644 --- a/vendor/google.golang.org/protobuf/proto/messageset.go +++ b/vendor/google.golang.org/protobuf/proto/messageset.go @@ -47,11 +47,16 @@ func (o MarshalOptions) marshalMessageSet(b []byte, m protoreflect.Message) ([]b func (o MarshalOptions) marshalMessageSetField(b []byte, fd protoreflect.FieldDescriptor, value protoreflect.Value) ([]byte, error) { b = messageset.AppendFieldStart(b, fd.Number()) b = protowire.AppendTag(b, messageset.FieldMessage, protowire.BytesType) - b = protowire.AppendVarint(b, uint64(o.Size(value.Message().Interface()))) + calculatedSize := o.Size(value.Message().Interface()) + b = protowire.AppendVarint(b, uint64(calculatedSize)) + before := len(b) b, err := o.marshalMessage(b, value.Message()) if err != nil { return b, err } + if measuredSize := len(b) - before; calculatedSize != measuredSize { + return nil, errors.MismatchedSizeCalculation(calculatedSize, measuredSize) + } b = messageset.AppendFieldEnd(b) return b, nil } diff --git a/vendor/google.golang.org/protobuf/proto/size.go b/vendor/google.golang.org/protobuf/proto/size.go index f1692b49b6c..052fb5ae313 100644 --- a/vendor/google.golang.org/protobuf/proto/size.go +++ b/vendor/google.golang.org/protobuf/proto/size.go @@ -34,6 +34,7 @@ func (o MarshalOptions) size(m protoreflect.Message) (size int) { if methods != nil && methods.Size != nil { out := methods.Size(protoiface.SizeInput{ Message: m, + Flags: o.flags(), }) return out.Size } @@ -42,6 +43,7 @@ func (o MarshalOptions) size(m protoreflect.Message) (size int) { // This case is mainly used for legacy types with a Marshal method. out, _ := methods.Marshal(protoiface.MarshalInput{ Message: m, + Flags: o.flags(), }) return len(out.Buf) } diff --git a/vendor/google.golang.org/protobuf/reflect/protodesc/desc.go b/vendor/google.golang.org/protobuf/reflect/protodesc/desc.go index baa0cc6218f..8fbecb4f58d 100644 --- a/vendor/google.golang.org/protobuf/reflect/protodesc/desc.go +++ b/vendor/google.golang.org/protobuf/reflect/protodesc/desc.go @@ -13,6 +13,7 @@ package protodesc import ( + "google.golang.org/protobuf/internal/editionssupport" "google.golang.org/protobuf/internal/errors" "google.golang.org/protobuf/internal/filedesc" "google.golang.org/protobuf/internal/pragma" @@ -91,15 +92,17 @@ func (o FileOptions) New(fd *descriptorpb.FileDescriptorProto, r Resolver) (prot switch fd.GetSyntax() { case "proto2", "": f.L1.Syntax = protoreflect.Proto2 + f.L1.Edition = filedesc.EditionProto2 case "proto3": f.L1.Syntax = protoreflect.Proto3 + f.L1.Edition = filedesc.EditionProto3 case "editions": f.L1.Syntax = protoreflect.Editions f.L1.Edition = fromEditionProto(fd.GetEdition()) default: return nil, errors.New("invalid syntax: %q", fd.GetSyntax()) } - if f.L1.Syntax == protoreflect.Editions && (fd.GetEdition() < SupportedEditionsMinimum || fd.GetEdition() > SupportedEditionsMaximum) { + if f.L1.Syntax == protoreflect.Editions && (fd.GetEdition() < editionssupport.Minimum || fd.GetEdition() > editionssupport.Maximum) { return nil, errors.New("use of edition %v not yet supported by the Go Protobuf runtime", fd.GetEdition()) } f.L1.Path = fd.GetName() @@ -114,9 +117,7 @@ func (o FileOptions) New(fd *descriptorpb.FileDescriptorProto, r Resolver) (prot opts = proto.Clone(opts).(*descriptorpb.FileOptions) f.L2.Options = func() protoreflect.ProtoMessage { return opts } } - if f.L1.Syntax == protoreflect.Editions { - initFileDescFromFeatureSet(f, fd.GetOptions().GetFeatures()) - } + initFileDescFromFeatureSet(f, fd.GetOptions().GetFeatures()) f.L2.Imports = make(filedesc.FileImports, len(fd.GetDependency())) for _, i := range fd.GetPublicDependency() { @@ -219,10 +220,10 @@ func (o FileOptions) New(fd *descriptorpb.FileDescriptorProto, r Resolver) (prot if err := validateEnumDeclarations(f.L1.Enums.List, fd.GetEnumType()); err != nil { return nil, err } - if err := validateMessageDeclarations(f.L1.Messages.List, fd.GetMessageType()); err != nil { + if err := validateMessageDeclarations(f, f.L1.Messages.List, fd.GetMessageType()); err != nil { return nil, err } - if err := validateExtensionDeclarations(f.L1.Extensions.List, fd.GetExtension()); err != nil { + if err := validateExtensionDeclarations(f, f.L1.Extensions.List, fd.GetExtension()); err != nil { return nil, err } diff --git a/vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go b/vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go index b3278163c52..85617554272 100644 --- a/vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go +++ b/vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go @@ -69,9 +69,7 @@ func (r descsByName) initMessagesDeclarations(mds []*descriptorpb.DescriptorProt if m.L0, err = r.makeBase(m, parent, md.GetName(), i, sb); err != nil { return nil, err } - if m.Base.L0.ParentFile.Syntax() == protoreflect.Editions { - m.L1.EditionFeatures = mergeEditionFeatures(parent, md.GetOptions().GetFeatures()) - } + m.L1.EditionFeatures = mergeEditionFeatures(parent, md.GetOptions().GetFeatures()) if opts := md.GetOptions(); opts != nil { opts = proto.Clone(opts).(*descriptorpb.MessageOptions) m.L2.Options = func() protoreflect.ProtoMessage { return opts } @@ -146,13 +144,15 @@ func (r descsByName) initFieldsFromDescriptorProto(fds []*descriptorpb.FieldDesc if f.L0, err = r.makeBase(f, parent, fd.GetName(), i, sb); err != nil { return nil, err } + f.L1.EditionFeatures = mergeEditionFeatures(parent, fd.GetOptions().GetFeatures()) f.L1.IsProto3Optional = fd.GetProto3Optional() if opts := fd.GetOptions(); opts != nil { opts = proto.Clone(opts).(*descriptorpb.FieldOptions) f.L1.Options = func() protoreflect.ProtoMessage { return opts } f.L1.IsWeak = opts.GetWeak() - f.L1.HasPacked = opts.Packed != nil - f.L1.IsPacked = opts.GetPacked() + if opts.Packed != nil { + f.L1.EditionFeatures.IsPacked = opts.GetPacked() + } } f.L1.Number = protoreflect.FieldNumber(fd.GetNumber()) f.L1.Cardinality = protoreflect.Cardinality(fd.GetLabel()) @@ -163,32 +163,12 @@ func (r descsByName) initFieldsFromDescriptorProto(fds []*descriptorpb.FieldDesc f.L1.StringName.InitJSON(fd.GetJsonName()) } - if f.Base.L0.ParentFile.Syntax() == protoreflect.Editions { - f.L1.EditionFeatures = mergeEditionFeatures(parent, fd.GetOptions().GetFeatures()) - - if f.L1.EditionFeatures.IsLegacyRequired { - f.L1.Cardinality = protoreflect.Required - } - // We reuse the existing field because the old option `[packed = - // true]` is mutually exclusive with the editions feature. - if canBePacked(fd) { - f.L1.HasPacked = true - f.L1.IsPacked = f.L1.EditionFeatures.IsPacked - } - - // We pretend this option is always explicitly set because the only - // use of HasEnforceUTF8 is to determine whether to use EnforceUTF8 - // or to return the appropriate default. - // When using editions we either parse the option or resolve the - // appropriate default here (instead of later when this option is - // requested from the descriptor). - // In proto2/proto3 syntax HasEnforceUTF8 might be false. - f.L1.HasEnforceUTF8 = true - f.L1.EnforceUTF8 = f.L1.EditionFeatures.IsUTF8Validated + if f.L1.EditionFeatures.IsLegacyRequired { + f.L1.Cardinality = protoreflect.Required + } - if f.L1.Kind == protoreflect.MessageKind && f.L1.EditionFeatures.IsDelimitedEncoded { - f.L1.Kind = protoreflect.GroupKind - } + if f.L1.Kind == protoreflect.MessageKind && f.L1.EditionFeatures.IsDelimitedEncoded { + f.L1.Kind = protoreflect.GroupKind } } return fs, nil @@ -201,12 +181,10 @@ func (r descsByName) initOneofsFromDescriptorProto(ods []*descriptorpb.OneofDesc if o.L0, err = r.makeBase(o, parent, od.GetName(), i, sb); err != nil { return nil, err } + o.L1.EditionFeatures = mergeEditionFeatures(parent, od.GetOptions().GetFeatures()) if opts := od.GetOptions(); opts != nil { opts = proto.Clone(opts).(*descriptorpb.OneofOptions) o.L1.Options = func() protoreflect.ProtoMessage { return opts } - if parent.Syntax() == protoreflect.Editions { - o.L1.EditionFeatures = mergeEditionFeatures(parent, opts.GetFeatures()) - } } } return os, nil @@ -220,10 +198,13 @@ func (r descsByName) initExtensionDeclarations(xds []*descriptorpb.FieldDescript if x.L0, err = r.makeBase(x, parent, xd.GetName(), i, sb); err != nil { return nil, err } + x.L1.EditionFeatures = mergeEditionFeatures(parent, xd.GetOptions().GetFeatures()) if opts := xd.GetOptions(); opts != nil { opts = proto.Clone(opts).(*descriptorpb.FieldOptions) x.L2.Options = func() protoreflect.ProtoMessage { return opts } - x.L2.IsPacked = opts.GetPacked() + if opts.Packed != nil { + x.L1.EditionFeatures.IsPacked = opts.GetPacked() + } } x.L1.Number = protoreflect.FieldNumber(xd.GetNumber()) x.L1.Cardinality = protoreflect.Cardinality(xd.GetLabel()) diff --git a/vendor/google.golang.org/protobuf/reflect/protodesc/desc_resolve.go b/vendor/google.golang.org/protobuf/reflect/protodesc/desc_resolve.go index 254ca585424..f3cebab29c8 100644 --- a/vendor/google.golang.org/protobuf/reflect/protodesc/desc_resolve.go +++ b/vendor/google.golang.org/protobuf/reflect/protodesc/desc_resolve.go @@ -46,6 +46,11 @@ func (r *resolver) resolveMessageDependencies(ms []filedesc.Message, mds []*desc if f.L1.Kind, f.L1.Enum, f.L1.Message, err = r.findTarget(f.Kind(), f.Parent().FullName(), partialName(fd.GetTypeName()), f.IsWeak()); err != nil { return errors.New("message field %q cannot resolve type: %v", f.FullName(), err) } + if f.L1.Kind == protoreflect.GroupKind && (f.IsMap() || f.IsMapEntry()) { + // A map field might inherit delimited encoding from a file-wide default feature. + // But maps never actually use delimited encoding. (At least for now...) + f.L1.Kind = protoreflect.MessageKind + } if fd.DefaultValue != nil { v, ev, err := unmarshalDefault(fd.GetDefaultValue(), f, r.allowUnresolvable) if err != nil { diff --git a/vendor/google.golang.org/protobuf/reflect/protodesc/desc_validate.go b/vendor/google.golang.org/protobuf/reflect/protodesc/desc_validate.go index e4dcaf876c9..6de31c2ebdb 100644 --- a/vendor/google.golang.org/protobuf/reflect/protodesc/desc_validate.go +++ b/vendor/google.golang.org/protobuf/reflect/protodesc/desc_validate.go @@ -45,11 +45,11 @@ func validateEnumDeclarations(es []filedesc.Enum, eds []*descriptorpb.EnumDescri if allowAlias && !foundAlias { return errors.New("enum %q allows aliases, but none were found", e.FullName()) } - if e.Syntax() == protoreflect.Proto3 { + if !e.IsClosed() { if v := e.Values().Get(0); v.Number() != 0 { - return errors.New("enum %q using proto3 semantics must have zero number for the first value", v.FullName()) + return errors.New("enum %q using open semantics must have zero number for the first value", v.FullName()) } - // Verify that value names in proto3 do not conflict if the + // Verify that value names in open enums do not conflict if the // case-insensitive prefix is removed. // See protoc v3.8.0: src/google/protobuf/descriptor.cc:4991-5055 names := map[string]protoreflect.EnumValueDescriptor{} @@ -58,7 +58,7 @@ func validateEnumDeclarations(es []filedesc.Enum, eds []*descriptorpb.EnumDescri v1 := e.Values().Get(i) s := strs.EnumValueName(strs.TrimEnumPrefix(string(v1.Name()), prefix)) if v2, ok := names[s]; ok && v1.Number() != v2.Number() { - return errors.New("enum %q using proto3 semantics has conflict: %q with %q", e.FullName(), v1.Name(), v2.Name()) + return errors.New("enum %q using open semantics has conflict: %q with %q", e.FullName(), v1.Name(), v2.Name()) } names[s] = v1 } @@ -80,7 +80,9 @@ func validateEnumDeclarations(es []filedesc.Enum, eds []*descriptorpb.EnumDescri return nil } -func validateMessageDeclarations(ms []filedesc.Message, mds []*descriptorpb.DescriptorProto) error { +func validateMessageDeclarations(file *filedesc.File, ms []filedesc.Message, mds []*descriptorpb.DescriptorProto) error { + // There are a few limited exceptions only for proto3 + isProto3 := file.L1.Edition == fromEditionProto(descriptorpb.Edition_EDITION_PROTO3) for i, md := range mds { m := &ms[i] @@ -107,25 +109,13 @@ func validateMessageDeclarations(ms []filedesc.Message, mds []*descriptorpb.Desc if isMessageSet && !flags.ProtoLegacy { return errors.New("message %q is a MessageSet, which is a legacy proto1 feature that is no longer supported", m.FullName()) } - if isMessageSet && (m.Syntax() == protoreflect.Proto3 || m.Fields().Len() > 0 || m.ExtensionRanges().Len() == 0) { + if isMessageSet && (isProto3 || m.Fields().Len() > 0 || m.ExtensionRanges().Len() == 0) { return errors.New("message %q is an invalid proto1 MessageSet", m.FullName()) } - if m.Syntax() == protoreflect.Proto3 { + if isProto3 { if m.ExtensionRanges().Len() > 0 { return errors.New("message %q using proto3 semantics cannot have extension ranges", m.FullName()) } - // Verify that field names in proto3 do not conflict if lowercased - // with all underscores removed. - // See protoc v3.8.0: src/google/protobuf/descriptor.cc:5830-5847 - names := map[string]protoreflect.FieldDescriptor{} - for i := 0; i < m.Fields().Len(); i++ { - f1 := m.Fields().Get(i) - s := strings.Replace(strings.ToLower(string(f1.Name())), "_", "", -1) - if f2, ok := names[s]; ok { - return errors.New("message %q using proto3 semantics has conflict: %q with %q", m.FullName(), f1.Name(), f2.Name()) - } - names[s] = f1 - } } for j, fd := range md.GetField() { @@ -149,7 +139,7 @@ func validateMessageDeclarations(ms []filedesc.Message, mds []*descriptorpb.Desc return errors.New("message field %q may not have extendee: %q", f.FullName(), fd.GetExtendee()) } if f.L1.IsProto3Optional { - if f.Syntax() != protoreflect.Proto3 { + if !isProto3 { return errors.New("message field %q under proto3 optional semantics must be specified in the proto3 syntax", f.FullName()) } if f.Cardinality() != protoreflect.Optional { @@ -162,26 +152,29 @@ func validateMessageDeclarations(ms []filedesc.Message, mds []*descriptorpb.Desc if f.IsWeak() && !flags.ProtoLegacy { return errors.New("message field %q is a weak field, which is a legacy proto1 feature that is no longer supported", f.FullName()) } - if f.IsWeak() && (f.Syntax() != protoreflect.Proto2 || !isOptionalMessage(f) || f.ContainingOneof() != nil) { + if f.IsWeak() && (!f.HasPresence() || !isOptionalMessage(f) || f.ContainingOneof() != nil) { return errors.New("message field %q may only be weak for an optional message", f.FullName()) } if f.IsPacked() && !isPackable(f) { return errors.New("message field %q is not packable", f.FullName()) } - if err := checkValidGroup(f); err != nil { + if err := checkValidGroup(file, f); err != nil { return errors.New("message field %q is an invalid group: %v", f.FullName(), err) } if err := checkValidMap(f); err != nil { return errors.New("message field %q is an invalid map: %v", f.FullName(), err) } - if f.Syntax() == protoreflect.Proto3 { + if isProto3 { if f.Cardinality() == protoreflect.Required { return errors.New("message field %q using proto3 semantics cannot be required", f.FullName()) } - if f.Enum() != nil && !f.Enum().IsPlaceholder() && f.Enum().Syntax() != protoreflect.Proto3 { - return errors.New("message field %q using proto3 semantics may only depend on a proto3 enum", f.FullName()) + if f.Enum() != nil && !f.Enum().IsPlaceholder() && f.Enum().IsClosed() { + return errors.New("message field %q using proto3 semantics may only depend on open enums", f.FullName()) } } + if f.Cardinality() == protoreflect.Optional && !f.HasPresence() && f.Enum() != nil && !f.Enum().IsPlaceholder() && f.Enum().IsClosed() { + return errors.New("message field %q with implicit presence may only use open enums", f.FullName()) + } } seenSynthetic := false // synthetic oneofs for proto3 optional must come after real oneofs for j := range md.GetOneofDecl() { @@ -215,17 +208,17 @@ func validateMessageDeclarations(ms []filedesc.Message, mds []*descriptorpb.Desc if err := validateEnumDeclarations(m.L1.Enums.List, md.GetEnumType()); err != nil { return err } - if err := validateMessageDeclarations(m.L1.Messages.List, md.GetNestedType()); err != nil { + if err := validateMessageDeclarations(file, m.L1.Messages.List, md.GetNestedType()); err != nil { return err } - if err := validateExtensionDeclarations(m.L1.Extensions.List, md.GetExtension()); err != nil { + if err := validateExtensionDeclarations(file, m.L1.Extensions.List, md.GetExtension()); err != nil { return err } } return nil } -func validateExtensionDeclarations(xs []filedesc.Extension, xds []*descriptorpb.FieldDescriptorProto) error { +func validateExtensionDeclarations(f *filedesc.File, xs []filedesc.Extension, xds []*descriptorpb.FieldDescriptorProto) error { for i, xd := range xds { x := &xs[i] // NOTE: Avoid using the IsValid method since extensions to MessageSet @@ -267,13 +260,13 @@ func validateExtensionDeclarations(xs []filedesc.Extension, xds []*descriptorpb. if x.IsPacked() && !isPackable(x) { return errors.New("extension field %q is not packable", x.FullName()) } - if err := checkValidGroup(x); err != nil { + if err := checkValidGroup(f, x); err != nil { return errors.New("extension field %q is an invalid group: %v", x.FullName(), err) } if md := x.Message(); md != nil && md.IsMapEntry() { return errors.New("extension field %q cannot be a map entry", x.FullName()) } - if x.Syntax() == protoreflect.Proto3 { + if f.L1.Edition == fromEditionProto(descriptorpb.Edition_EDITION_PROTO3) { switch x.ContainingMessage().FullName() { case (*descriptorpb.FileOptions)(nil).ProtoReflect().Descriptor().FullName(): case (*descriptorpb.EnumOptions)(nil).ProtoReflect().Descriptor().FullName(): @@ -309,21 +302,25 @@ func isPackable(fd protoreflect.FieldDescriptor) bool { // checkValidGroup reports whether fd is a valid group according to the same // rules that protoc imposes. -func checkValidGroup(fd protoreflect.FieldDescriptor) error { +func checkValidGroup(f *filedesc.File, fd protoreflect.FieldDescriptor) error { md := fd.Message() switch { case fd.Kind() != protoreflect.GroupKind: return nil - case fd.Syntax() == protoreflect.Proto3: + case f.L1.Edition == fromEditionProto(descriptorpb.Edition_EDITION_PROTO3): return errors.New("invalid under proto3 semantics") case md == nil || md.IsPlaceholder(): return errors.New("message must be resolvable") - case fd.FullName().Parent() != md.FullName().Parent(): - return errors.New("message and field must be declared in the same scope") - case !unicode.IsUpper(rune(md.Name()[0])): - return errors.New("message name must start with an uppercase") - case fd.Name() != protoreflect.Name(strings.ToLower(string(md.Name()))): - return errors.New("field name must be lowercased form of the message name") + } + if f.L1.Edition < fromEditionProto(descriptorpb.Edition_EDITION_2023) { + switch { + case fd.FullName().Parent() != md.FullName().Parent(): + return errors.New("message and field must be declared in the same scope") + case !unicode.IsUpper(rune(md.Name()[0])): + return errors.New("message name must start with an uppercase") + case fd.Name() != protoreflect.Name(strings.ToLower(string(md.Name()))): + return errors.New("field name must be lowercased form of the message name") + } } return nil } diff --git a/vendor/google.golang.org/protobuf/reflect/protodesc/editions.go b/vendor/google.golang.org/protobuf/reflect/protodesc/editions.go index 2a6b29d1791..804830eda36 100644 --- a/vendor/google.golang.org/protobuf/reflect/protodesc/editions.go +++ b/vendor/google.golang.org/protobuf/reflect/protodesc/editions.go @@ -17,11 +17,6 @@ import ( gofeaturespb "google.golang.org/protobuf/types/gofeaturespb" ) -const ( - SupportedEditionsMinimum = descriptorpb.Edition_EDITION_PROTO2 - SupportedEditionsMaximum = descriptorpb.Edition_EDITION_2023 -) - var defaults = &descriptorpb.FeatureSetDefaults{} var defaultsCacheMu sync.Mutex var defaultsCache = make(map[filedesc.Edition]*descriptorpb.FeatureSet) @@ -67,18 +62,20 @@ func getFeatureSetFor(ed filedesc.Edition) *descriptorpb.FeatureSet { fmt.Fprintf(os.Stderr, "internal error: unsupported edition %v (did you forget to update the embedded defaults (i.e. the bootstrap descriptor proto)?)\n", edpb) os.Exit(1) } - fs := defaults.GetDefaults()[0].GetFeatures() + fsed := defaults.GetDefaults()[0] // Using a linear search for now. // Editions are guaranteed to be sorted and thus we could use a binary search. // Given that there are only a handful of editions (with one more per year) // there is not much reason to use a binary search. for _, def := range defaults.GetDefaults() { if def.GetEdition() <= edpb { - fs = def.GetFeatures() + fsed = def } else { break } } + fs := proto.Clone(fsed.GetFixedFeatures()).(*descriptorpb.FeatureSet) + proto.Merge(fs, fsed.GetOverridableFeatures()) defaultsCache[ed] = fs return fs } diff --git a/vendor/google.golang.org/protobuf/reflect/protodesc/proto.go b/vendor/google.golang.org/protobuf/reflect/protodesc/proto.go index 9d6e05420f7..a5de8d40013 100644 --- a/vendor/google.golang.org/protobuf/reflect/protodesc/proto.go +++ b/vendor/google.golang.org/protobuf/reflect/protodesc/proto.go @@ -73,6 +73,16 @@ func ToFileDescriptorProto(file protoreflect.FileDescriptor) *descriptorpb.FileD if syntax := file.Syntax(); syntax != protoreflect.Proto2 && syntax.IsValid() { p.Syntax = proto.String(file.Syntax().String()) } + if file.Syntax() == protoreflect.Editions { + desc := file + if fileImportDesc, ok := file.(protoreflect.FileImport); ok { + desc = fileImportDesc.FileDescriptor + } + + if editionsInterface, ok := desc.(interface{ Edition() int32 }); ok { + p.Edition = descriptorpb.Edition(editionsInterface.Edition()).Enum() + } + } return p } @@ -153,6 +163,18 @@ func ToFieldDescriptorProto(field protoreflect.FieldDescriptor) *descriptorpb.Fi if field.Syntax() == protoreflect.Proto3 && field.HasOptionalKeyword() { p.Proto3Optional = proto.Bool(true) } + if field.Syntax() == protoreflect.Editions { + // Editions have no group keyword, this type is only set so that downstream users continue + // treating this as delimited encoding. + if p.GetType() == descriptorpb.FieldDescriptorProto_TYPE_GROUP { + p.Type = descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum() + } + // Editions have no required keyword, this label is only set so that downstream users continue + // treating it as required. + if p.GetLabel() == descriptorpb.FieldDescriptorProto_LABEL_REQUIRED { + p.Label = descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum() + } + } if field.HasDefault() { def, err := defval.Marshal(field.Default(), field.DefaultEnumValue(), field.Kind(), defval.Descriptor) if err != nil && field.DefaultEnumValue() != nil { diff --git a/vendor/google.golang.org/protobuf/reflect/protoreflect/proto.go b/vendor/google.golang.org/protobuf/reflect/protoreflect/proto.go index 00b01fbd8c9..c85bfaa5bb7 100644 --- a/vendor/google.golang.org/protobuf/reflect/protoreflect/proto.go +++ b/vendor/google.golang.org/protobuf/reflect/protoreflect/proto.go @@ -161,7 +161,7 @@ const ( // IsValid reports whether the syntax is valid. func (s Syntax) IsValid() bool { switch s { - case Proto2, Proto3: + case Proto2, Proto3, Editions: return true default: return false diff --git a/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go b/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go index 7dcc2ff09e9..ea154eec44d 100644 --- a/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go +++ b/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go @@ -373,6 +373,8 @@ func (p *SourcePath) appendFieldOptions(b []byte) []byte { b = p.appendRepeatedField(b, "edition_defaults", (*SourcePath).appendFieldOptions_EditionDefault) case 21: b = p.appendSingularField(b, "features", (*SourcePath).appendFeatureSet) + case 22: + b = p.appendSingularField(b, "feature_support", (*SourcePath).appendFieldOptions_FeatureSupport) case 999: b = p.appendRepeatedField(b, "uninterpreted_option", (*SourcePath).appendUninterpretedOption) } @@ -483,6 +485,8 @@ func (p *SourcePath) appendEnumValueOptions(b []byte) []byte { b = p.appendSingularField(b, "features", (*SourcePath).appendFeatureSet) case 3: b = p.appendSingularField(b, "debug_redact", nil) + case 4: + b = p.appendSingularField(b, "feature_support", (*SourcePath).appendFieldOptions_FeatureSupport) case 999: b = p.appendRepeatedField(b, "uninterpreted_option", (*SourcePath).appendUninterpretedOption) } @@ -519,6 +523,23 @@ func (p *SourcePath) appendFieldOptions_EditionDefault(b []byte) []byte { return b } +func (p *SourcePath) appendFieldOptions_FeatureSupport(b []byte) []byte { + if len(*p) == 0 { + return b + } + switch (*p)[0] { + case 1: + b = p.appendSingularField(b, "edition_introduced", nil) + case 2: + b = p.appendSingularField(b, "edition_deprecated", nil) + case 3: + b = p.appendSingularField(b, "deprecation_warning", nil) + case 4: + b = p.appendSingularField(b, "edition_removed", nil) + } + return b +} + func (p *SourcePath) appendUninterpretedOption_NamePart(b []byte) []byte { if len(*p) == 0 { return b diff --git a/vendor/google.golang.org/protobuf/reflect/protoreflect/type.go b/vendor/google.golang.org/protobuf/reflect/protoreflect/type.go index 60ff62b4c85..cd8fadbaf8f 100644 --- a/vendor/google.golang.org/protobuf/reflect/protoreflect/type.go +++ b/vendor/google.golang.org/protobuf/reflect/protoreflect/type.go @@ -510,7 +510,7 @@ type ExtensionType interface { // // ValueOf is more extensive than protoreflect.ValueOf for a given field's // value as it has more type information available. - ValueOf(interface{}) Value + ValueOf(any) Value // InterfaceOf completely unwraps the Value to the underlying Go type. // InterfaceOf panics if the input is nil or does not represent the @@ -519,13 +519,13 @@ type ExtensionType interface { // // InterfaceOf is able to unwrap the Value further than Value.Interface // as it has more type information available. - InterfaceOf(Value) interface{} + InterfaceOf(Value) any // IsValidValue reports whether the Value is valid to assign to the field. IsValidValue(Value) bool // IsValidInterface reports whether the input is valid to assign to the field. - IsValidInterface(interface{}) bool + IsValidInterface(any) bool } // EnumDescriptor describes an enum and @@ -544,6 +544,12 @@ type EnumDescriptor interface { // ReservedRanges is a list of reserved ranges of enum numbers. ReservedRanges() EnumRanges + // IsClosed reports whether this enum uses closed semantics. + // See https://protobuf.dev/programming-guides/enum/#definitions. + // Note: the Go protobuf implementation is not spec compliant and treats + // all enums as open enums. + IsClosed() bool + isEnumDescriptor } type isEnumDescriptor interface{ ProtoType(EnumDescriptor) } diff --git a/vendor/google.golang.org/protobuf/reflect/protoreflect/value_pure.go b/vendor/google.golang.org/protobuf/reflect/protoreflect/value_pure.go index 7ced876f4e8..75f83a2af03 100644 --- a/vendor/google.golang.org/protobuf/reflect/protoreflect/value_pure.go +++ b/vendor/google.golang.org/protobuf/reflect/protoreflect/value_pure.go @@ -32,11 +32,11 @@ const ( type value struct { pragma.DoNotCompare // 0B - typ valueType // 8B - num uint64 // 8B - str string // 16B - bin []byte // 24B - iface interface{} // 16B + typ valueType // 8B + num uint64 // 8B + str string // 16B + bin []byte // 24B + iface any // 16B } func valueOfString(v string) Value { @@ -45,7 +45,7 @@ func valueOfString(v string) Value { func valueOfBytes(v []byte) Value { return Value{typ: bytesType, bin: v} } -func valueOfIface(v interface{}) Value { +func valueOfIface(v any) Value { return Value{typ: ifaceType, iface: v} } @@ -55,6 +55,6 @@ func (v Value) getString() string { func (v Value) getBytes() []byte { return v.bin } -func (v Value) getIface() interface{} { +func (v Value) getIface() any { return v.iface } diff --git a/vendor/google.golang.org/protobuf/reflect/protoreflect/value_union.go b/vendor/google.golang.org/protobuf/reflect/protoreflect/value_union.go index 1603097311e..9fe83cef5a9 100644 --- a/vendor/google.golang.org/protobuf/reflect/protoreflect/value_union.go +++ b/vendor/google.golang.org/protobuf/reflect/protoreflect/value_union.go @@ -69,8 +69,8 @@ import ( // composite Value. Modifying an empty, read-only value panics. type Value value -// The protoreflect API uses a custom Value union type instead of interface{} -// to keep the future open for performance optimizations. Using an interface{} +// The protoreflect API uses a custom Value union type instead of any +// to keep the future open for performance optimizations. Using an any // always incurs an allocation for primitives (e.g., int64) since it needs to // be boxed on the heap (as interfaces can only contain pointers natively). // Instead, we represent the Value union as a flat struct that internally keeps @@ -85,7 +85,7 @@ type Value value // ValueOf returns a Value initialized with the concrete value stored in v. // This panics if the type does not match one of the allowed types in the // Value union. -func ValueOf(v interface{}) Value { +func ValueOf(v any) Value { switch v := v.(type) { case nil: return Value{} @@ -192,10 +192,10 @@ func (v Value) IsValid() bool { return v.typ != nilType } -// Interface returns v as an interface{}. +// Interface returns v as an any. // // Invariant: v == ValueOf(v).Interface() -func (v Value) Interface() interface{} { +func (v Value) Interface() any { switch v.typ { case nilType: return nil @@ -406,8 +406,8 @@ func (k MapKey) IsValid() bool { return Value(k).IsValid() } -// Interface returns k as an interface{}. -func (k MapKey) Interface() interface{} { +// Interface returns k as an any. +func (k MapKey) Interface() any { return Value(k).Interface() } diff --git a/vendor/google.golang.org/protobuf/reflect/protoreflect/value_unsafe_go120.go b/vendor/google.golang.org/protobuf/reflect/protoreflect/value_unsafe_go120.go index b1fdbe3e8e1..7f3583ead81 100644 --- a/vendor/google.golang.org/protobuf/reflect/protoreflect/value_unsafe_go120.go +++ b/vendor/google.golang.org/protobuf/reflect/protoreflect/value_unsafe_go120.go @@ -45,7 +45,7 @@ var ( // typeOf returns a pointer to the Go type information. // The pointer is comparable and equal if and only if the types are identical. -func typeOf(t interface{}) unsafe.Pointer { +func typeOf(t any) unsafe.Pointer { return (*ifaceHeader)(unsafe.Pointer(&t)).Type } @@ -80,7 +80,7 @@ func valueOfBytes(v []byte) Value { p := (*sliceHeader)(unsafe.Pointer(&v)) return Value{typ: bytesType, ptr: p.Data, num: uint64(len(v))} } -func valueOfIface(v interface{}) Value { +func valueOfIface(v any) Value { p := (*ifaceHeader)(unsafe.Pointer(&v)) return Value{typ: p.Type, ptr: p.Data} } @@ -93,7 +93,7 @@ func (v Value) getBytes() (x []byte) { *(*sliceHeader)(unsafe.Pointer(&x)) = sliceHeader{Data: v.ptr, Len: int(v.num), Cap: int(v.num)} return x } -func (v Value) getIface() (x interface{}) { +func (v Value) getIface() (x any) { *(*ifaceHeader)(unsafe.Pointer(&x)) = ifaceHeader{Type: v.typ, Data: v.ptr} return x } diff --git a/vendor/google.golang.org/protobuf/reflect/protoreflect/value_unsafe_go121.go b/vendor/google.golang.org/protobuf/reflect/protoreflect/value_unsafe_go121.go index 43547011173..f7d386990a0 100644 --- a/vendor/google.golang.org/protobuf/reflect/protoreflect/value_unsafe_go121.go +++ b/vendor/google.golang.org/protobuf/reflect/protoreflect/value_unsafe_go121.go @@ -15,7 +15,7 @@ import ( type ( ifaceHeader struct { - _ [0]interface{} // if interfaces have greater alignment than unsafe.Pointer, this will enforce it. + _ [0]any // if interfaces have greater alignment than unsafe.Pointer, this will enforce it. Type unsafe.Pointer Data unsafe.Pointer } @@ -37,7 +37,7 @@ var ( // typeOf returns a pointer to the Go type information. // The pointer is comparable and equal if and only if the types are identical. -func typeOf(t interface{}) unsafe.Pointer { +func typeOf(t any) unsafe.Pointer { return (*ifaceHeader)(unsafe.Pointer(&t)).Type } @@ -70,7 +70,7 @@ func valueOfString(v string) Value { func valueOfBytes(v []byte) Value { return Value{typ: bytesType, ptr: unsafe.Pointer(unsafe.SliceData(v)), num: uint64(len(v))} } -func valueOfIface(v interface{}) Value { +func valueOfIface(v any) Value { p := (*ifaceHeader)(unsafe.Pointer(&v)) return Value{typ: p.Type, ptr: p.Data} } @@ -81,7 +81,7 @@ func (v Value) getString() string { func (v Value) getBytes() []byte { return unsafe.Slice((*byte)(v.ptr), v.num) } -func (v Value) getIface() (x interface{}) { +func (v Value) getIface() (x any) { *(*ifaceHeader)(unsafe.Pointer(&x)) = ifaceHeader{Type: v.typ, Data: v.ptr} return x } diff --git a/vendor/google.golang.org/protobuf/reflect/protoregistry/registry.go b/vendor/google.golang.org/protobuf/reflect/protoregistry/registry.go index 6267dc52a67..de177733914 100644 --- a/vendor/google.golang.org/protobuf/reflect/protoregistry/registry.go +++ b/vendor/google.golang.org/protobuf/reflect/protoregistry/registry.go @@ -95,7 +95,7 @@ type Files struct { // multiple files. Only top-level declarations are registered. // Note that enum values are in the top-level since that are in the same // scope as the parent enum. - descsByName map[protoreflect.FullName]interface{} + descsByName map[protoreflect.FullName]any filesByPath map[string][]protoreflect.FileDescriptor numFiles int } @@ -117,7 +117,7 @@ func (r *Files) RegisterFile(file protoreflect.FileDescriptor) error { defer globalMutex.Unlock() } if r.descsByName == nil { - r.descsByName = map[protoreflect.FullName]interface{}{ + r.descsByName = map[protoreflect.FullName]any{ "": &packageDescriptor{}, } r.filesByPath = make(map[string][]protoreflect.FileDescriptor) @@ -485,7 +485,7 @@ type Types struct { } type ( - typesByName map[protoreflect.FullName]interface{} + typesByName map[protoreflect.FullName]any extensionsByMessage map[protoreflect.FullName]extensionsByNumber extensionsByNumber map[protoreflect.FieldNumber]protoreflect.ExtensionType ) @@ -570,7 +570,7 @@ func (r *Types) RegisterExtension(xt protoreflect.ExtensionType) error { return nil } -func (r *Types) register(kind string, desc protoreflect.Descriptor, typ interface{}) error { +func (r *Types) register(kind string, desc protoreflect.Descriptor, typ any) error { name := desc.FullName() prev := r.typesByName[name] if prev != nil { @@ -841,7 +841,7 @@ func (r *Types) RangeExtensionsByMessage(message protoreflect.FullName, f func(p } } -func typeName(t interface{}) string { +func typeName(t any) string { switch t.(type) { case protoreflect.EnumType: return "enum" @@ -854,7 +854,7 @@ func typeName(t interface{}) string { } } -func amendErrorWithCaller(err error, prev, curr interface{}) error { +func amendErrorWithCaller(err error, prev, curr any) error { prevPkg := goPackage(prev) currPkg := goPackage(curr) if prevPkg == "" || currPkg == "" || prevPkg == currPkg { @@ -863,7 +863,7 @@ func amendErrorWithCaller(err error, prev, curr interface{}) error { return errors.New("%s\n\tpreviously from: %q\n\tcurrently from: %q", err, prevPkg, currPkg) } -func goPackage(v interface{}) string { +func goPackage(v any) string { switch d := v.(type) { case protoreflect.EnumType: v = d.Descriptor() diff --git a/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go b/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go index 78624cf60b3..9403eb07507 100644 --- a/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go +++ b/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go @@ -54,6 +54,9 @@ type Edition int32 const ( // A placeholder for an unknown edition value. Edition_EDITION_UNKNOWN Edition = 0 + // A placeholder edition for specifying default behaviors *before* a feature + // was first introduced. This is effectively an "infinite past". + Edition_EDITION_LEGACY Edition = 900 // Legacy syntax "editions". These pre-date editions, but behave much like // distinct editions. These can't be used to specify the edition of proto // files, but feature definitions must supply proto2/proto3 defaults for @@ -82,6 +85,7 @@ const ( var ( Edition_name = map[int32]string{ 0: "EDITION_UNKNOWN", + 900: "EDITION_LEGACY", 998: "EDITION_PROTO2", 999: "EDITION_PROTO3", 1000: "EDITION_2023", @@ -95,6 +99,7 @@ var ( } Edition_value = map[string]int32{ "EDITION_UNKNOWN": 0, + "EDITION_LEGACY": 900, "EDITION_PROTO2": 998, "EDITION_PROTO3": 999, "EDITION_2023": 1000, @@ -2177,12 +2182,16 @@ type FileOptions struct { // // Deprecated: Marked as deprecated in google/protobuf/descriptor.proto. JavaGenerateEqualsAndHash *bool `protobuf:"varint,20,opt,name=java_generate_equals_and_hash,json=javaGenerateEqualsAndHash" json:"java_generate_equals_and_hash,omitempty"` - // If set true, then the Java2 code generator will generate code that - // throws an exception whenever an attempt is made to assign a non-UTF-8 - // byte sequence to a string field. - // Message reflection will do the same. - // However, an extension field still accepts non-UTF-8 byte sequences. - // This option has no effect on when used with the lite runtime. + // A proto2 file can set this to true to opt in to UTF-8 checking for Java, + // which will throw an exception if invalid UTF-8 is parsed from the wire or + // assigned to a string field. + // + // TODO: clarify exactly what kinds of field types this option + // applies to, and update these docs accordingly. + // + // Proto3 files already perform these checks. Setting the option explicitly to + // false has no effect: it cannot be used to opt proto3 files out of UTF-8 + // checks. JavaStringCheckUtf8 *bool `protobuf:"varint,27,opt,name=java_string_check_utf8,json=javaStringCheckUtf8,def=0" json:"java_string_check_utf8,omitempty"` OptimizeFor *FileOptions_OptimizeMode `protobuf:"varint,9,opt,name=optimize_for,json=optimizeFor,enum=google.protobuf.FileOptions_OptimizeMode,def=1" json:"optimize_for,omitempty"` // Sets the Go package where structs generated from this .proto will be @@ -2679,7 +2688,8 @@ type FieldOptions struct { Targets []FieldOptions_OptionTargetType `protobuf:"varint,19,rep,name=targets,enum=google.protobuf.FieldOptions_OptionTargetType" json:"targets,omitempty"` EditionDefaults []*FieldOptions_EditionDefault `protobuf:"bytes,20,rep,name=edition_defaults,json=editionDefaults" json:"edition_defaults,omitempty"` // Any features defined in the specific edition. - Features *FeatureSet `protobuf:"bytes,21,opt,name=features" json:"features,omitempty"` + Features *FeatureSet `protobuf:"bytes,21,opt,name=features" json:"features,omitempty"` + FeatureSupport *FieldOptions_FeatureSupport `protobuf:"bytes,22,opt,name=feature_support,json=featureSupport" json:"feature_support,omitempty"` // The parser stores options it doesn't recognize here. See above. UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"` } @@ -2811,6 +2821,13 @@ func (x *FieldOptions) GetFeatures() *FeatureSet { return nil } +func (x *FieldOptions) GetFeatureSupport() *FieldOptions_FeatureSupport { + if x != nil { + return x.FeatureSupport + } + return nil +} + func (x *FieldOptions) GetUninterpretedOption() []*UninterpretedOption { if x != nil { return x.UninterpretedOption @@ -2995,6 +3012,8 @@ type EnumValueOptions struct { // out when using debug formats, e.g. when the field contains sensitive // credentials. DebugRedact *bool `protobuf:"varint,3,opt,name=debug_redact,json=debugRedact,def=0" json:"debug_redact,omitempty"` + // Information about the support window of a feature value. + FeatureSupport *FieldOptions_FeatureSupport `protobuf:"bytes,4,opt,name=feature_support,json=featureSupport" json:"feature_support,omitempty"` // The parser stores options it doesn't recognize here. See above. UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"` } @@ -3058,6 +3077,13 @@ func (x *EnumValueOptions) GetDebugRedact() bool { return Default_EnumValueOptions_DebugRedact } +func (x *EnumValueOptions) GetFeatureSupport() *FieldOptions_FeatureSupport { + if x != nil { + return x.FeatureSupport + } + return nil +} + func (x *EnumValueOptions) GetUninterpretedOption() []*UninterpretedOption { if x != nil { return x.UninterpretedOption @@ -3968,6 +3994,88 @@ func (x *FieldOptions_EditionDefault) GetValue() string { return "" } +// Information about the support window of a feature. +type FieldOptions_FeatureSupport struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The edition that this feature was first available in. In editions + // earlier than this one, the default assigned to EDITION_LEGACY will be + // used, and proto files will not be able to override it. + EditionIntroduced *Edition `protobuf:"varint,1,opt,name=edition_introduced,json=editionIntroduced,enum=google.protobuf.Edition" json:"edition_introduced,omitempty"` + // The edition this feature becomes deprecated in. Using this after this + // edition may trigger warnings. + EditionDeprecated *Edition `protobuf:"varint,2,opt,name=edition_deprecated,json=editionDeprecated,enum=google.protobuf.Edition" json:"edition_deprecated,omitempty"` + // The deprecation warning text if this feature is used after the edition it + // was marked deprecated in. + DeprecationWarning *string `protobuf:"bytes,3,opt,name=deprecation_warning,json=deprecationWarning" json:"deprecation_warning,omitempty"` + // The edition this feature is no longer available in. In editions after + // this one, the last default assigned will be used, and proto files will + // not be able to override it. + EditionRemoved *Edition `protobuf:"varint,4,opt,name=edition_removed,json=editionRemoved,enum=google.protobuf.Edition" json:"edition_removed,omitempty"` +} + +func (x *FieldOptions_FeatureSupport) Reset() { + *x = FieldOptions_FeatureSupport{} + if protoimpl.UnsafeEnabled { + mi := &file_google_protobuf_descriptor_proto_msgTypes[28] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FieldOptions_FeatureSupport) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FieldOptions_FeatureSupport) ProtoMessage() {} + +func (x *FieldOptions_FeatureSupport) ProtoReflect() protoreflect.Message { + mi := &file_google_protobuf_descriptor_proto_msgTypes[28] + 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 FieldOptions_FeatureSupport.ProtoReflect.Descriptor instead. +func (*FieldOptions_FeatureSupport) Descriptor() ([]byte, []int) { + return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{12, 1} +} + +func (x *FieldOptions_FeatureSupport) GetEditionIntroduced() Edition { + if x != nil && x.EditionIntroduced != nil { + return *x.EditionIntroduced + } + return Edition_EDITION_UNKNOWN +} + +func (x *FieldOptions_FeatureSupport) GetEditionDeprecated() Edition { + if x != nil && x.EditionDeprecated != nil { + return *x.EditionDeprecated + } + return Edition_EDITION_UNKNOWN +} + +func (x *FieldOptions_FeatureSupport) GetDeprecationWarning() string { + if x != nil && x.DeprecationWarning != nil { + return *x.DeprecationWarning + } + return "" +} + +func (x *FieldOptions_FeatureSupport) GetEditionRemoved() Edition { + if x != nil && x.EditionRemoved != nil { + return *x.EditionRemoved + } + return Edition_EDITION_UNKNOWN +} + // The name of the uninterpreted option. Each string represents a segment in // a dot-separated name. is_extension is true iff a segment represents an // extension (denoted with parentheses in options specs in .proto files). @@ -3985,7 +4093,7 @@ type UninterpretedOption_NamePart struct { func (x *UninterpretedOption_NamePart) Reset() { *x = UninterpretedOption_NamePart{} if protoimpl.UnsafeEnabled { - mi := &file_google_protobuf_descriptor_proto_msgTypes[28] + mi := &file_google_protobuf_descriptor_proto_msgTypes[29] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3998,7 +4106,7 @@ func (x *UninterpretedOption_NamePart) String() string { func (*UninterpretedOption_NamePart) ProtoMessage() {} func (x *UninterpretedOption_NamePart) ProtoReflect() protoreflect.Message { - mi := &file_google_protobuf_descriptor_proto_msgTypes[28] + mi := &file_google_protobuf_descriptor_proto_msgTypes[29] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4037,14 +4145,17 @@ type FeatureSetDefaults_FeatureSetEditionDefault struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Edition *Edition `protobuf:"varint,3,opt,name=edition,enum=google.protobuf.Edition" json:"edition,omitempty"` - Features *FeatureSet `protobuf:"bytes,2,opt,name=features" json:"features,omitempty"` + Edition *Edition `protobuf:"varint,3,opt,name=edition,enum=google.protobuf.Edition" json:"edition,omitempty"` + // Defaults of features that can be overridden in this edition. + OverridableFeatures *FeatureSet `protobuf:"bytes,4,opt,name=overridable_features,json=overridableFeatures" json:"overridable_features,omitempty"` + // Defaults of features that can't be overridden in this edition. + FixedFeatures *FeatureSet `protobuf:"bytes,5,opt,name=fixed_features,json=fixedFeatures" json:"fixed_features,omitempty"` } func (x *FeatureSetDefaults_FeatureSetEditionDefault) Reset() { *x = FeatureSetDefaults_FeatureSetEditionDefault{} if protoimpl.UnsafeEnabled { - mi := &file_google_protobuf_descriptor_proto_msgTypes[29] + mi := &file_google_protobuf_descriptor_proto_msgTypes[30] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -4057,7 +4168,7 @@ func (x *FeatureSetDefaults_FeatureSetEditionDefault) String() string { func (*FeatureSetDefaults_FeatureSetEditionDefault) ProtoMessage() {} func (x *FeatureSetDefaults_FeatureSetEditionDefault) ProtoReflect() protoreflect.Message { - mi := &file_google_protobuf_descriptor_proto_msgTypes[29] + mi := &file_google_protobuf_descriptor_proto_msgTypes[30] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4080,9 +4191,16 @@ func (x *FeatureSetDefaults_FeatureSetEditionDefault) GetEdition() Edition { return Edition_EDITION_UNKNOWN } -func (x *FeatureSetDefaults_FeatureSetEditionDefault) GetFeatures() *FeatureSet { +func (x *FeatureSetDefaults_FeatureSetEditionDefault) GetOverridableFeatures() *FeatureSet { if x != nil { - return x.Features + return x.OverridableFeatures + } + return nil +} + +func (x *FeatureSetDefaults_FeatureSetEditionDefault) GetFixedFeatures() *FeatureSet { + if x != nil { + return x.FixedFeatures } return nil } @@ -4188,7 +4306,7 @@ type SourceCodeInfo_Location struct { func (x *SourceCodeInfo_Location) Reset() { *x = SourceCodeInfo_Location{} if protoimpl.UnsafeEnabled { - mi := &file_google_protobuf_descriptor_proto_msgTypes[30] + mi := &file_google_protobuf_descriptor_proto_msgTypes[31] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -4201,7 +4319,7 @@ func (x *SourceCodeInfo_Location) String() string { func (*SourceCodeInfo_Location) ProtoMessage() {} func (x *SourceCodeInfo_Location) ProtoReflect() protoreflect.Message { - mi := &file_google_protobuf_descriptor_proto_msgTypes[30] + mi := &file_google_protobuf_descriptor_proto_msgTypes[31] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4275,7 +4393,7 @@ type GeneratedCodeInfo_Annotation struct { func (x *GeneratedCodeInfo_Annotation) Reset() { *x = GeneratedCodeInfo_Annotation{} if protoimpl.UnsafeEnabled { - mi := &file_google_protobuf_descriptor_proto_msgTypes[31] + mi := &file_google_protobuf_descriptor_proto_msgTypes[32] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -4288,7 +4406,7 @@ func (x *GeneratedCodeInfo_Annotation) String() string { func (*GeneratedCodeInfo_Annotation) ProtoMessage() {} func (x *GeneratedCodeInfo_Annotation) ProtoReflect() protoreflect.Message { - mi := &file_google_protobuf_descriptor_proto_msgTypes[31] + mi := &file_google_protobuf_descriptor_proto_msgTypes[32] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4597,7 +4715,7 @@ var file_google_protobuf_descriptor_proto_rawDesc = []byte{ 0x67, 0x12, 0x30, 0x0a, 0x10, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x69, 0x6e, 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, 0x0f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, - 0x69, 0x6e, 0x67, 0x22, 0x97, 0x09, 0x0a, 0x0b, 0x46, 0x69, 0x6c, 0x65, 0x4f, 0x70, 0x74, 0x69, + 0x69, 0x6e, 0x67, 0x22, 0xad, 0x09, 0x0a, 0x0b, 0x46, 0x69, 0x6c, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x6a, 0x61, 0x76, 0x61, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6a, 0x61, 0x76, 0x61, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x30, 0x0a, 0x14, 0x6a, 0x61, 0x76, 0x61, 0x5f, 0x6f, @@ -4670,405 +4788,445 @@ var file_google_protobuf_descriptor_proto_rawDesc = []byte{ 0x45, 0x45, 0x44, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, 0x44, 0x45, 0x5f, 0x53, 0x49, 0x5a, 0x45, 0x10, 0x02, 0x12, 0x10, 0x0a, 0x0c, 0x4c, 0x49, 0x54, 0x45, 0x5f, 0x52, 0x55, 0x4e, 0x54, 0x49, 0x4d, 0x45, 0x10, 0x03, 0x2a, 0x09, 0x08, 0xe8, 0x07, 0x10, 0x80, 0x80, 0x80, 0x80, - 0x02, 0x4a, 0x04, 0x08, 0x2a, 0x10, 0x2b, 0x4a, 0x04, 0x08, 0x26, 0x10, 0x27, 0x22, 0xf4, 0x03, - 0x0a, 0x0e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x12, 0x3c, 0x0a, 0x17, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x65, 0x74, 0x5f, - 0x77, 0x69, 0x72, 0x65, 0x5f, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, 0x14, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x53, 0x65, 0x74, 0x57, 0x69, 0x72, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, 0x4c, - 0x0a, 0x1f, 0x6e, 0x6f, 0x5f, 0x73, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x5f, 0x64, 0x65, - 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x5f, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x6f, - 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, 0x1c, - 0x6e, 0x6f, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, - 0x70, 0x74, 0x6f, 0x72, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x12, 0x25, 0x0a, 0x0a, - 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, - 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, - 0x74, 0x65, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x6d, 0x61, 0x70, 0x5f, 0x65, 0x6e, 0x74, 0x72, 0x79, - 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x6d, 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, - 0x12, 0x56, 0x0a, 0x26, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x6c, - 0x65, 0x67, 0x61, 0x63, 0x79, 0x5f, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, - 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x6c, 0x69, 0x63, 0x74, 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, - 0x42, 0x02, 0x18, 0x01, 0x52, 0x22, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, - 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x4a, 0x73, 0x6f, 0x6e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x43, - 0x6f, 0x6e, 0x66, 0x6c, 0x69, 0x63, 0x74, 0x73, 0x12, 0x37, 0x0a, 0x08, 0x66, 0x65, 0x61, 0x74, - 0x75, 0x72, 0x65, 0x73, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, - 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x52, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, - 0x73, 0x12, 0x58, 0x0a, 0x14, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, - 0x65, 0x64, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, - 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, - 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x09, 0x08, 0xe8, 0x07, - 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x4a, 0x04, 0x08, 0x05, - 0x10, 0x06, 0x4a, 0x04, 0x08, 0x06, 0x10, 0x07, 0x4a, 0x04, 0x08, 0x08, 0x10, 0x09, 0x4a, 0x04, - 0x08, 0x09, 0x10, 0x0a, 0x22, 0xad, 0x0a, 0x0a, 0x0c, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x41, 0x0a, 0x05, 0x63, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x2e, 0x43, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x06, 0x53, 0x54, 0x52, 0x49, 0x4e, - 0x47, 0x52, 0x05, 0x63, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x63, 0x6b, - 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x64, - 0x12, 0x47, 0x0a, 0x06, 0x6a, 0x73, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, - 0x4a, 0x53, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x09, 0x4a, 0x53, 0x5f, 0x4e, 0x4f, 0x52, 0x4d, 0x41, - 0x4c, 0x52, 0x06, 0x6a, 0x73, 0x74, 0x79, 0x70, 0x65, 0x12, 0x19, 0x0a, 0x04, 0x6c, 0x61, 0x7a, - 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, 0x04, - 0x6c, 0x61, 0x7a, 0x79, 0x12, 0x2e, 0x0a, 0x0f, 0x75, 0x6e, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, - 0x65, 0x64, 0x5f, 0x6c, 0x61, 0x7a, 0x79, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, - 0x61, 0x6c, 0x73, 0x65, 0x52, 0x0e, 0x75, 0x6e, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x64, - 0x4c, 0x61, 0x7a, 0x79, 0x12, 0x25, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, - 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, - 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x19, 0x0a, 0x04, 0x77, - 0x65, 0x61, 0x6b, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, - 0x52, 0x04, 0x77, 0x65, 0x61, 0x6b, 0x12, 0x28, 0x0a, 0x0c, 0x64, 0x65, 0x62, 0x75, 0x67, 0x5f, - 0x72, 0x65, 0x64, 0x61, 0x63, 0x74, 0x18, 0x10, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, - 0x6c, 0x73, 0x65, 0x52, 0x0b, 0x64, 0x65, 0x62, 0x75, 0x67, 0x52, 0x65, 0x64, 0x61, 0x63, 0x74, - 0x12, 0x4b, 0x0a, 0x09, 0x72, 0x65, 0x74, 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x11, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x2d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x2e, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x74, 0x65, 0x6e, 0x74, 0x69, - 0x6f, 0x6e, 0x52, 0x09, 0x72, 0x65, 0x74, 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x48, 0x0a, - 0x07, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x18, 0x13, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x2e, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4f, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, - 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x12, 0x57, 0x0a, 0x10, 0x65, 0x64, 0x69, 0x74, 0x69, - 0x6f, 0x6e, 0x5f, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x14, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x2c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x2e, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x52, - 0x0f, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, - 0x12, 0x37, 0x0a, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, 0x15, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x52, - 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x12, 0x58, 0x0a, 0x14, 0x75, 0x6e, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x13, - 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x1a, 0x5a, 0x0a, 0x0e, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x65, - 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x32, 0x0a, 0x07, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x52, 0x07, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, - 0x2f, 0x0a, 0x05, 0x43, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x54, 0x52, 0x49, - 0x4e, 0x47, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x43, 0x4f, 0x52, 0x44, 0x10, 0x01, 0x12, 0x10, - 0x0a, 0x0c, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x5f, 0x50, 0x49, 0x45, 0x43, 0x45, 0x10, 0x02, - 0x22, 0x35, 0x0a, 0x06, 0x4a, 0x53, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0d, 0x0a, 0x09, 0x4a, 0x53, - 0x5f, 0x4e, 0x4f, 0x52, 0x4d, 0x41, 0x4c, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x4a, 0x53, 0x5f, - 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x4a, 0x53, 0x5f, 0x4e, - 0x55, 0x4d, 0x42, 0x45, 0x52, 0x10, 0x02, 0x22, 0x55, 0x0a, 0x0f, 0x4f, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x52, 0x65, 0x74, 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x15, 0x0a, 0x11, 0x52, 0x45, - 0x54, 0x45, 0x4e, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, - 0x00, 0x12, 0x15, 0x0a, 0x11, 0x52, 0x45, 0x54, 0x45, 0x4e, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x52, - 0x55, 0x4e, 0x54, 0x49, 0x4d, 0x45, 0x10, 0x01, 0x12, 0x14, 0x0a, 0x10, 0x52, 0x45, 0x54, 0x45, - 0x4e, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x10, 0x02, 0x22, 0x8c, - 0x02, 0x0a, 0x10, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x54, - 0x79, 0x70, 0x65, 0x12, 0x17, 0x0a, 0x13, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x5f, 0x54, 0x59, - 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, - 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x46, 0x49, 0x4c, 0x45, - 0x10, 0x01, 0x12, 0x1f, 0x0a, 0x1b, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x5f, 0x54, 0x59, 0x50, - 0x45, 0x5f, 0x45, 0x58, 0x54, 0x45, 0x4e, 0x53, 0x49, 0x4f, 0x4e, 0x5f, 0x52, 0x41, 0x4e, 0x47, - 0x45, 0x10, 0x02, 0x12, 0x17, 0x0a, 0x13, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x5f, 0x54, 0x59, - 0x50, 0x45, 0x5f, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x10, 0x03, 0x12, 0x15, 0x0a, 0x11, - 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x46, 0x49, 0x45, 0x4c, - 0x44, 0x10, 0x04, 0x12, 0x15, 0x0a, 0x11, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x5f, 0x54, 0x59, - 0x50, 0x45, 0x5f, 0x4f, 0x4e, 0x45, 0x4f, 0x46, 0x10, 0x05, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x41, - 0x52, 0x47, 0x45, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x45, 0x4e, 0x55, 0x4d, 0x10, 0x06, - 0x12, 0x1a, 0x0a, 0x16, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, - 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x45, 0x4e, 0x54, 0x52, 0x59, 0x10, 0x07, 0x12, 0x17, 0x0a, 0x13, - 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x45, 0x52, 0x56, - 0x49, 0x43, 0x45, 0x10, 0x08, 0x12, 0x16, 0x0a, 0x12, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x5f, - 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4d, 0x45, 0x54, 0x48, 0x4f, 0x44, 0x10, 0x09, 0x2a, 0x09, 0x08, - 0xe8, 0x07, 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x4a, 0x04, - 0x08, 0x12, 0x10, 0x13, 0x22, 0xac, 0x01, 0x0a, 0x0c, 0x4f, 0x6e, 0x65, 0x6f, 0x66, 0x4f, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x37, 0x0a, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, - 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, - 0x65, 0x53, 0x65, 0x74, 0x52, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x12, 0x58, - 0x0a, 0x14, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x5f, - 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, - 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x09, 0x08, 0xe8, 0x07, 0x10, 0x80, 0x80, - 0x80, 0x80, 0x02, 0x22, 0xd1, 0x02, 0x0a, 0x0b, 0x45, 0x6e, 0x75, 0x6d, 0x4f, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x61, 0x6c, 0x69, - 0x61, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x41, - 0x6c, 0x69, 0x61, 0x73, 0x12, 0x25, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, - 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, - 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x56, 0x0a, 0x26, 0x64, - 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, - 0x5f, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x63, 0x6f, 0x6e, 0x66, - 0x6c, 0x69, 0x63, 0x74, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x42, 0x02, 0x18, 0x01, 0x52, - 0x22, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x4c, 0x65, 0x67, 0x61, 0x63, - 0x79, 0x4a, 0x73, 0x6f, 0x6e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x6c, 0x69, - 0x63, 0x74, 0x73, 0x12, 0x37, 0x0a, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, - 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, - 0x65, 0x74, 0x52, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x12, 0x58, 0x0a, 0x14, - 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x5f, 0x6f, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x6e, + 0x02, 0x4a, 0x04, 0x08, 0x2a, 0x10, 0x2b, 0x4a, 0x04, 0x08, 0x26, 0x10, 0x27, 0x52, 0x14, 0x70, + 0x68, 0x70, 0x5f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x73, 0x22, 0xf4, 0x03, 0x0a, 0x0e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x3c, 0x0a, 0x17, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x5f, 0x73, 0x65, 0x74, 0x5f, 0x77, 0x69, 0x72, 0x65, 0x5f, 0x66, 0x6f, 0x72, 0x6d, 0x61, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, 0x14, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x65, 0x74, 0x57, 0x69, 0x72, 0x65, 0x46, 0x6f, + 0x72, 0x6d, 0x61, 0x74, 0x12, 0x4c, 0x0a, 0x1f, 0x6e, 0x6f, 0x5f, 0x73, 0x74, 0x61, 0x6e, 0x64, + 0x61, 0x72, 0x64, 0x5f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x5f, 0x61, + 0x63, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, + 0x61, 0x6c, 0x73, 0x65, 0x52, 0x1c, 0x6e, 0x6f, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, + 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, + 0x6f, 0x72, 0x12, 0x25, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, 0x0a, 0x64, + 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x6d, 0x61, 0x70, + 0x5f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x6d, 0x61, + 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x56, 0x0a, 0x26, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, + 0x61, 0x74, 0x65, 0x64, 0x5f, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x5f, 0x6a, 0x73, 0x6f, 0x6e, + 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x6c, 0x69, 0x63, 0x74, 0x73, + 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x42, 0x02, 0x18, 0x01, 0x52, 0x22, 0x64, 0x65, 0x70, 0x72, + 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x4a, 0x73, 0x6f, 0x6e, + 0x46, 0x69, 0x65, 0x6c, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x6c, 0x69, 0x63, 0x74, 0x73, 0x12, 0x37, + 0x0a, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x52, 0x08, 0x66, + 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x12, 0x58, 0x0a, 0x14, 0x75, 0x6e, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x52, 0x13, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, - 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x09, 0x08, 0xe8, 0x07, 0x10, 0x80, 0x80, 0x80, 0x80, - 0x02, 0x4a, 0x04, 0x08, 0x05, 0x10, 0x06, 0x22, 0x81, 0x02, 0x0a, 0x10, 0x45, 0x6e, 0x75, 0x6d, - 0x56, 0x61, 0x6c, 0x75, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x25, 0x0a, 0x0a, - 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, - 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, - 0x74, 0x65, 0x64, 0x12, 0x37, 0x0a, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, - 0x65, 0x74, 0x52, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x12, 0x28, 0x0a, 0x0c, - 0x64, 0x65, 0x62, 0x75, 0x67, 0x5f, 0x72, 0x65, 0x64, 0x61, 0x63, 0x74, 0x18, 0x03, 0x20, 0x01, + 0x6e, 0x2a, 0x09, 0x08, 0xe8, 0x07, 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, 0x4a, 0x04, 0x08, 0x04, + 0x10, 0x05, 0x4a, 0x04, 0x08, 0x05, 0x10, 0x06, 0x4a, 0x04, 0x08, 0x06, 0x10, 0x07, 0x4a, 0x04, + 0x08, 0x08, 0x10, 0x09, 0x4a, 0x04, 0x08, 0x09, 0x10, 0x0a, 0x22, 0x9d, 0x0d, 0x0a, 0x0c, 0x46, + 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x41, 0x0a, 0x05, 0x63, + 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, + 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x43, 0x54, 0x79, 0x70, 0x65, 0x3a, + 0x06, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x52, 0x05, 0x63, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, + 0x0a, 0x06, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, + 0x70, 0x61, 0x63, 0x6b, 0x65, 0x64, 0x12, 0x47, 0x0a, 0x06, 0x6a, 0x73, 0x74, 0x79, 0x70, 0x65, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4a, 0x53, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x09, 0x4a, 0x53, + 0x5f, 0x4e, 0x4f, 0x52, 0x4d, 0x41, 0x4c, 0x52, 0x06, 0x6a, 0x73, 0x74, 0x79, 0x70, 0x65, 0x12, + 0x19, 0x0a, 0x04, 0x6c, 0x61, 0x7a, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, + 0x61, 0x6c, 0x73, 0x65, 0x52, 0x04, 0x6c, 0x61, 0x7a, 0x79, 0x12, 0x2e, 0x0a, 0x0f, 0x75, 0x6e, + 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x64, 0x5f, 0x6c, 0x61, 0x7a, 0x79, 0x18, 0x0f, 0x20, + 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, 0x0e, 0x75, 0x6e, 0x76, 0x65, + 0x72, 0x69, 0x66, 0x69, 0x65, 0x64, 0x4c, 0x61, 0x7a, 0x79, 0x12, 0x25, 0x0a, 0x0a, 0x64, 0x65, + 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, + 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, + 0x64, 0x12, 0x19, 0x0a, 0x04, 0x77, 0x65, 0x61, 0x6b, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x3a, + 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, 0x04, 0x77, 0x65, 0x61, 0x6b, 0x12, 0x28, 0x0a, 0x0c, + 0x64, 0x65, 0x62, 0x75, 0x67, 0x5f, 0x72, 0x65, 0x64, 0x61, 0x63, 0x74, 0x18, 0x10, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, 0x0b, 0x64, 0x65, 0x62, 0x75, 0x67, - 0x52, 0x65, 0x64, 0x61, 0x63, 0x74, 0x12, 0x58, 0x0a, 0x14, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, + 0x52, 0x65, 0x64, 0x61, 0x63, 0x74, 0x12, 0x4b, 0x0a, 0x09, 0x72, 0x65, 0x74, 0x65, 0x6e, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x11, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, + 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, + 0x65, 0x74, 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x72, 0x65, 0x74, 0x65, 0x6e, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x48, 0x0a, 0x07, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x18, 0x13, + 0x20, 0x03, 0x28, 0x0e, 0x32, 0x2e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x2e, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, + 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x12, 0x57, 0x0a, + 0x10, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, + 0x73, 0x18, 0x14, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x65, + 0x66, 0x61, 0x75, 0x6c, 0x74, 0x52, 0x0f, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x65, + 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x12, 0x37, 0x0a, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, + 0x65, 0x73, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, + 0x72, 0x65, 0x53, 0x65, 0x74, 0x52, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x12, + 0x55, 0x0a, 0x0f, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x73, 0x75, 0x70, 0x70, 0x6f, + 0x72, 0x74, 0x18, 0x16, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, + 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, + 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x0e, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, + 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x58, 0x0a, 0x14, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x2a, 0x09, 0x08, 0xe8, 0x07, 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, 0x22, 0xd5, 0x01, 0x0a, 0x0e, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x37, - 0x0a, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, 0x22, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x52, 0x08, 0x66, - 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x12, 0x25, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, - 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x21, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, - 0x73, 0x65, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x58, - 0x0a, 0x14, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x5f, - 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, + 0x1a, 0x5a, 0x0a, 0x0e, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x66, 0x61, 0x75, + 0x6c, 0x74, 0x12, 0x32, 0x0a, 0x07, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x65, + 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x1a, 0x96, 0x02, 0x0a, + 0x0e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x12, + 0x47, 0x0a, 0x12, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x6e, 0x74, 0x72, 0x6f, + 0x64, 0x75, 0x63, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x64, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x11, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, + 0x74, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x64, 0x12, 0x47, 0x0a, 0x12, 0x65, 0x64, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x5f, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x11, + 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, + 0x64, 0x12, 0x2f, 0x0a, 0x13, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x77, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, + 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x57, 0x61, 0x72, 0x6e, 0x69, + 0x6e, 0x67, 0x12, 0x41, 0x0a, 0x0f, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, + 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x64, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0e, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, + 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x22, 0x2f, 0x0a, 0x05, 0x43, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0a, + 0x0a, 0x06, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x43, 0x4f, + 0x52, 0x44, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x5f, 0x50, + 0x49, 0x45, 0x43, 0x45, 0x10, 0x02, 0x22, 0x35, 0x0a, 0x06, 0x4a, 0x53, 0x54, 0x79, 0x70, 0x65, + 0x12, 0x0d, 0x0a, 0x09, 0x4a, 0x53, 0x5f, 0x4e, 0x4f, 0x52, 0x4d, 0x41, 0x4c, 0x10, 0x00, 0x12, + 0x0d, 0x0a, 0x09, 0x4a, 0x53, 0x5f, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x0d, + 0x0a, 0x09, 0x4a, 0x53, 0x5f, 0x4e, 0x55, 0x4d, 0x42, 0x45, 0x52, 0x10, 0x02, 0x22, 0x55, 0x0a, + 0x0f, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x74, 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x15, 0x0a, 0x11, 0x52, 0x45, 0x54, 0x45, 0x4e, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x55, 0x4e, + 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x15, 0x0a, 0x11, 0x52, 0x45, 0x54, 0x45, 0x4e, + 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x52, 0x55, 0x4e, 0x54, 0x49, 0x4d, 0x45, 0x10, 0x01, 0x12, 0x14, + 0x0a, 0x10, 0x52, 0x45, 0x54, 0x45, 0x4e, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x53, 0x4f, 0x55, 0x52, + 0x43, 0x45, 0x10, 0x02, 0x22, 0x8c, 0x02, 0x0a, 0x10, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x54, + 0x61, 0x72, 0x67, 0x65, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x17, 0x0a, 0x13, 0x54, 0x41, 0x52, + 0x47, 0x45, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, + 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x5f, 0x54, 0x59, 0x50, + 0x45, 0x5f, 0x46, 0x49, 0x4c, 0x45, 0x10, 0x01, 0x12, 0x1f, 0x0a, 0x1b, 0x54, 0x41, 0x52, 0x47, + 0x45, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x45, 0x58, 0x54, 0x45, 0x4e, 0x53, 0x49, 0x4f, + 0x4e, 0x5f, 0x52, 0x41, 0x4e, 0x47, 0x45, 0x10, 0x02, 0x12, 0x17, 0x0a, 0x13, 0x54, 0x41, 0x52, + 0x47, 0x45, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, + 0x10, 0x03, 0x12, 0x15, 0x0a, 0x11, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x5f, 0x54, 0x59, 0x50, + 0x45, 0x5f, 0x46, 0x49, 0x45, 0x4c, 0x44, 0x10, 0x04, 0x12, 0x15, 0x0a, 0x11, 0x54, 0x41, 0x52, + 0x47, 0x45, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4f, 0x4e, 0x45, 0x4f, 0x46, 0x10, 0x05, + 0x12, 0x14, 0x0a, 0x10, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, + 0x45, 0x4e, 0x55, 0x4d, 0x10, 0x06, 0x12, 0x1a, 0x0a, 0x16, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, + 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x45, 0x4e, 0x54, 0x52, 0x59, + 0x10, 0x07, 0x12, 0x17, 0x0a, 0x13, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x5f, 0x54, 0x59, 0x50, + 0x45, 0x5f, 0x53, 0x45, 0x52, 0x56, 0x49, 0x43, 0x45, 0x10, 0x08, 0x12, 0x16, 0x0a, 0x12, 0x54, + 0x41, 0x52, 0x47, 0x45, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4d, 0x45, 0x54, 0x48, 0x4f, + 0x44, 0x10, 0x09, 0x2a, 0x09, 0x08, 0xe8, 0x07, 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, 0x4a, 0x04, + 0x08, 0x04, 0x10, 0x05, 0x4a, 0x04, 0x08, 0x12, 0x10, 0x13, 0x22, 0xac, 0x01, 0x0a, 0x0c, 0x4f, + 0x6e, 0x65, 0x6f, 0x66, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x37, 0x0a, 0x08, 0x66, + 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, - 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x09, 0x08, 0xe8, 0x07, 0x10, 0x80, 0x80, - 0x80, 0x80, 0x02, 0x22, 0x99, 0x03, 0x0a, 0x0d, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x25, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, - 0x74, 0x65, 0x64, 0x18, 0x21, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, - 0x52, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x71, 0x0a, 0x11, - 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x5f, 0x6c, 0x65, 0x76, 0x65, - 0x6c, 0x18, 0x22, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, - 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x49, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, - 0x6e, 0x63, 0x79, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x3a, 0x13, 0x49, 0x44, 0x45, 0x4d, 0x50, 0x4f, - 0x54, 0x45, 0x4e, 0x43, 0x59, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x52, 0x10, 0x69, - 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, - 0x37, 0x0a, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, 0x23, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x52, 0x08, - 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x12, 0x58, 0x0a, 0x14, 0x75, 0x6e, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x75, - 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x22, 0x50, 0x0a, 0x10, 0x49, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, - 0x79, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x17, 0x0a, 0x13, 0x49, 0x44, 0x45, 0x4d, 0x50, 0x4f, - 0x54, 0x45, 0x4e, 0x43, 0x59, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, - 0x13, 0x0a, 0x0f, 0x4e, 0x4f, 0x5f, 0x53, 0x49, 0x44, 0x45, 0x5f, 0x45, 0x46, 0x46, 0x45, 0x43, - 0x54, 0x53, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x49, 0x44, 0x45, 0x4d, 0x50, 0x4f, 0x54, 0x45, - 0x4e, 0x54, 0x10, 0x02, 0x2a, 0x09, 0x08, 0xe8, 0x07, 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, 0x22, - 0x9a, 0x03, 0x0a, 0x13, 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, - 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x41, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, - 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4e, 0x61, 0x6d, 0x65, - 0x50, 0x61, 0x72, 0x74, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x69, 0x64, - 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, - 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x2c, 0x0a, 0x12, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, - 0x65, 0x5f, 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x04, 0x52, 0x10, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x49, 0x6e, 0x74, 0x56, 0x61, - 0x6c, 0x75, 0x65, 0x12, 0x2c, 0x0a, 0x12, 0x6e, 0x65, 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, - 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x10, 0x6e, 0x65, 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0x49, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x75, - 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0b, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, - 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x73, 0x74, 0x72, 0x69, - 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x61, 0x67, 0x67, 0x72, 0x65, - 0x67, 0x61, 0x74, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0e, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, - 0x1a, 0x4a, 0x0a, 0x08, 0x4e, 0x61, 0x6d, 0x65, 0x50, 0x61, 0x72, 0x74, 0x12, 0x1b, 0x0a, 0x09, - 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x18, 0x01, 0x20, 0x02, 0x28, 0x09, 0x52, - 0x08, 0x6e, 0x61, 0x6d, 0x65, 0x50, 0x61, 0x72, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x73, 0x5f, - 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x02, 0x28, 0x08, 0x52, - 0x0b, 0x69, 0x73, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x8c, 0x0a, 0x0a, - 0x0a, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x12, 0x8b, 0x01, 0x0a, 0x0e, - 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x70, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0e, 0x32, 0x29, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, - 0x74, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x50, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x63, 0x65, 0x42, - 0x39, 0x88, 0x01, 0x01, 0x98, 0x01, 0x04, 0x98, 0x01, 0x01, 0xa2, 0x01, 0x0d, 0x12, 0x08, 0x45, - 0x58, 0x50, 0x4c, 0x49, 0x43, 0x49, 0x54, 0x18, 0xe6, 0x07, 0xa2, 0x01, 0x0d, 0x12, 0x08, 0x49, - 0x4d, 0x50, 0x4c, 0x49, 0x43, 0x49, 0x54, 0x18, 0xe7, 0x07, 0xa2, 0x01, 0x0d, 0x12, 0x08, 0x45, - 0x58, 0x50, 0x4c, 0x49, 0x43, 0x49, 0x54, 0x18, 0xe8, 0x07, 0x52, 0x0d, 0x66, 0x69, 0x65, 0x6c, - 0x64, 0x50, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x66, 0x0a, 0x09, 0x65, 0x6e, 0x75, - 0x6d, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x24, 0x2e, 0x67, + 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x52, 0x08, 0x66, 0x65, 0x61, 0x74, + 0x75, 0x72, 0x65, 0x73, 0x12, 0x58, 0x0a, 0x14, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, + 0x72, 0x65, 0x74, 0x65, 0x64, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xe7, 0x07, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, + 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x75, 0x6e, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x09, + 0x08, 0xe8, 0x07, 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, 0x22, 0xd1, 0x02, 0x0a, 0x0b, 0x45, 0x6e, + 0x75, 0x6d, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x6c, 0x6c, + 0x6f, 0x77, 0x5f, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, + 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x41, 0x6c, 0x69, 0x61, 0x73, 0x12, 0x25, 0x0a, 0x0a, 0x64, 0x65, + 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, + 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, + 0x64, 0x12, 0x56, 0x0a, 0x26, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x5f, + 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x5f, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x66, 0x69, 0x65, 0x6c, + 0x64, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x6c, 0x69, 0x63, 0x74, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x08, 0x42, 0x02, 0x18, 0x01, 0x52, 0x22, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, + 0x64, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x4a, 0x73, 0x6f, 0x6e, 0x46, 0x69, 0x65, 0x6c, 0x64, + 0x43, 0x6f, 0x6e, 0x66, 0x6c, 0x69, 0x63, 0x74, 0x73, 0x12, 0x37, 0x0a, 0x08, 0x66, 0x65, 0x61, + 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, + 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x52, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, + 0x65, 0x73, 0x12, 0x58, 0x0a, 0x14, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, + 0x74, 0x65, 0x64, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, + 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x09, 0x08, 0xe8, + 0x07, 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, 0x4a, 0x04, 0x08, 0x05, 0x10, 0x06, 0x22, 0xd8, 0x02, + 0x0a, 0x10, 0x45, 0x6e, 0x75, 0x6d, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x12, 0x25, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, 0x0a, 0x64, + 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x37, 0x0a, 0x08, 0x66, 0x65, 0x61, + 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, + 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x52, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, + 0x65, 0x73, 0x12, 0x28, 0x0a, 0x0c, 0x64, 0x65, 0x62, 0x75, 0x67, 0x5f, 0x72, 0x65, 0x64, 0x61, + 0x63, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, + 0x0b, 0x64, 0x65, 0x62, 0x75, 0x67, 0x52, 0x65, 0x64, 0x61, 0x63, 0x74, 0x12, 0x55, 0x0a, 0x0f, + 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x75, 0x70, 0x70, + 0x6f, 0x72, 0x74, 0x52, 0x0e, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x75, 0x70, 0x70, + 0x6f, 0x72, 0x74, 0x12, 0x58, 0x0a, 0x14, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, + 0x65, 0x74, 0x65, 0x64, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xe7, 0x07, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, + 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x09, 0x08, + 0xe8, 0x07, 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, 0x22, 0xd5, 0x01, 0x0a, 0x0e, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x37, 0x0a, 0x08, 0x66, + 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, 0x22, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x52, 0x08, 0x66, 0x65, 0x61, 0x74, + 0x75, 0x72, 0x65, 0x73, 0x12, 0x25, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, + 0x65, 0x64, 0x18, 0x21, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, + 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x58, 0x0a, 0x14, 0x75, + 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x5f, 0x6f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x6e, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x13, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x09, 0x08, 0xe8, 0x07, 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, + 0x22, 0x99, 0x03, 0x0a, 0x0d, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x12, 0x25, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, + 0x18, 0x21, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, 0x0a, 0x64, + 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x71, 0x0a, 0x11, 0x69, 0x64, 0x65, + 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x5f, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x22, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x49, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, + 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x3a, 0x13, 0x49, 0x44, 0x45, 0x4d, 0x50, 0x4f, 0x54, 0x45, 0x4e, + 0x43, 0x59, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x52, 0x10, 0x69, 0x64, 0x65, 0x6d, + 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x37, 0x0a, 0x08, + 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, 0x23, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x52, 0x08, 0x66, 0x65, 0x61, + 0x74, 0x75, 0x72, 0x65, 0x73, 0x12, 0x58, 0x0a, 0x14, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xe7, 0x07, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, + 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x75, 0x6e, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, + 0x50, 0x0a, 0x10, 0x49, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4c, 0x65, + 0x76, 0x65, 0x6c, 0x12, 0x17, 0x0a, 0x13, 0x49, 0x44, 0x45, 0x4d, 0x50, 0x4f, 0x54, 0x45, 0x4e, + 0x43, 0x59, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x13, 0x0a, 0x0f, + 0x4e, 0x4f, 0x5f, 0x53, 0x49, 0x44, 0x45, 0x5f, 0x45, 0x46, 0x46, 0x45, 0x43, 0x54, 0x53, 0x10, + 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x49, 0x44, 0x45, 0x4d, 0x50, 0x4f, 0x54, 0x45, 0x4e, 0x54, 0x10, + 0x02, 0x2a, 0x09, 0x08, 0xe8, 0x07, 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, 0x22, 0x9a, 0x03, 0x0a, + 0x13, 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x41, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, + 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x50, 0x61, 0x72, + 0x74, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x69, 0x64, 0x65, 0x6e, 0x74, + 0x69, 0x66, 0x69, 0x65, 0x72, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x56, 0x61, 0x6c, + 0x75, 0x65, 0x12, 0x2c, 0x0a, 0x12, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x69, + 0x6e, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x10, + 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x49, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, + 0x12, 0x2c, 0x0a, 0x12, 0x6e, 0x65, 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x69, 0x6e, 0x74, + 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x10, 0x6e, 0x65, + 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0x49, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, + 0x0a, 0x0c, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x01, 0x52, 0x0b, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, + 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, + 0x61, 0x6c, 0x75, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, + 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x61, + 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x1a, 0x4a, 0x0a, + 0x08, 0x4e, 0x61, 0x6d, 0x65, 0x50, 0x61, 0x72, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x61, 0x6d, + 0x65, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x18, 0x01, 0x20, 0x02, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x61, + 0x6d, 0x65, 0x50, 0x61, 0x72, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x73, 0x5f, 0x65, 0x78, 0x74, + 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x02, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x73, + 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xa7, 0x0a, 0x0a, 0x0a, 0x46, 0x65, + 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x12, 0x91, 0x01, 0x0a, 0x0e, 0x66, 0x69, 0x65, + 0x6c, 0x64, 0x5f, 0x70, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x29, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x2e, 0x46, + 0x69, 0x65, 0x6c, 0x64, 0x50, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x63, 0x65, 0x42, 0x3f, 0x88, 0x01, + 0x01, 0x98, 0x01, 0x04, 0x98, 0x01, 0x01, 0xa2, 0x01, 0x0d, 0x12, 0x08, 0x45, 0x58, 0x50, 0x4c, + 0x49, 0x43, 0x49, 0x54, 0x18, 0xe6, 0x07, 0xa2, 0x01, 0x0d, 0x12, 0x08, 0x49, 0x4d, 0x50, 0x4c, + 0x49, 0x43, 0x49, 0x54, 0x18, 0xe7, 0x07, 0xa2, 0x01, 0x0d, 0x12, 0x08, 0x45, 0x58, 0x50, 0x4c, + 0x49, 0x43, 0x49, 0x54, 0x18, 0xe8, 0x07, 0xb2, 0x01, 0x03, 0x08, 0xe8, 0x07, 0x52, 0x0d, 0x66, + 0x69, 0x65, 0x6c, 0x64, 0x50, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x6c, 0x0a, 0x09, + 0x65, 0x6e, 0x75, 0x6d, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x2e, 0x45, 0x6e, 0x75, + 0x6d, 0x54, 0x79, 0x70, 0x65, 0x42, 0x29, 0x88, 0x01, 0x01, 0x98, 0x01, 0x06, 0x98, 0x01, 0x01, + 0xa2, 0x01, 0x0b, 0x12, 0x06, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x18, 0xe6, 0x07, 0xa2, 0x01, + 0x09, 0x12, 0x04, 0x4f, 0x50, 0x45, 0x4e, 0x18, 0xe7, 0x07, 0xb2, 0x01, 0x03, 0x08, 0xe8, 0x07, + 0x52, 0x08, 0x65, 0x6e, 0x75, 0x6d, 0x54, 0x79, 0x70, 0x65, 0x12, 0x98, 0x01, 0x0a, 0x17, 0x72, + 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x65, 0x6e, + 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x31, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, - 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x54, 0x79, - 0x70, 0x65, 0x42, 0x23, 0x88, 0x01, 0x01, 0x98, 0x01, 0x06, 0x98, 0x01, 0x01, 0xa2, 0x01, 0x0b, - 0x12, 0x06, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x18, 0xe6, 0x07, 0xa2, 0x01, 0x09, 0x12, 0x04, - 0x4f, 0x50, 0x45, 0x4e, 0x18, 0xe7, 0x07, 0x52, 0x08, 0x65, 0x6e, 0x75, 0x6d, 0x54, 0x79, 0x70, - 0x65, 0x12, 0x92, 0x01, 0x0a, 0x17, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x66, - 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x31, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, - 0x2e, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x45, 0x6e, - 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x27, 0x88, 0x01, 0x01, 0x98, 0x01, 0x04, 0x98, 0x01, - 0x01, 0xa2, 0x01, 0x0d, 0x12, 0x08, 0x45, 0x58, 0x50, 0x41, 0x4e, 0x44, 0x45, 0x44, 0x18, 0xe6, - 0x07, 0xa2, 0x01, 0x0b, 0x12, 0x06, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x44, 0x18, 0xe7, 0x07, 0x52, - 0x15, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x45, 0x6e, - 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x78, 0x0a, 0x0f, 0x75, 0x74, 0x66, 0x38, 0x5f, 0x76, - 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, - 0x2a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x2e, 0x55, 0x74, 0x66, - 0x38, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x23, 0x88, 0x01, 0x01, - 0x98, 0x01, 0x04, 0x98, 0x01, 0x01, 0xa2, 0x01, 0x09, 0x12, 0x04, 0x4e, 0x4f, 0x4e, 0x45, 0x18, - 0xe6, 0x07, 0xa2, 0x01, 0x0b, 0x12, 0x06, 0x56, 0x45, 0x52, 0x49, 0x46, 0x59, 0x18, 0xe7, 0x07, - 0x52, 0x0e, 0x75, 0x74, 0x66, 0x38, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x12, 0x78, 0x0a, 0x10, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x65, 0x6e, 0x63, 0x6f, - 0x64, 0x69, 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2b, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, - 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x45, - 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x20, 0x88, 0x01, 0x01, 0x98, 0x01, 0x04, 0x98, - 0x01, 0x01, 0xa2, 0x01, 0x14, 0x12, 0x0f, 0x4c, 0x45, 0x4e, 0x47, 0x54, 0x48, 0x5f, 0x50, 0x52, - 0x45, 0x46, 0x49, 0x58, 0x45, 0x44, 0x18, 0xe6, 0x07, 0x52, 0x0f, 0x6d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x7c, 0x0a, 0x0b, 0x6a, 0x73, - 0x6f, 0x6e, 0x5f, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0e, 0x32, - 0x26, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x2e, 0x4a, 0x73, 0x6f, - 0x6e, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x42, 0x33, 0x88, 0x01, 0x01, 0x98, 0x01, 0x03, 0x98, - 0x01, 0x06, 0x98, 0x01, 0x01, 0xa2, 0x01, 0x17, 0x12, 0x12, 0x4c, 0x45, 0x47, 0x41, 0x43, 0x59, - 0x5f, 0x42, 0x45, 0x53, 0x54, 0x5f, 0x45, 0x46, 0x46, 0x4f, 0x52, 0x54, 0x18, 0xe6, 0x07, 0xa2, - 0x01, 0x0a, 0x12, 0x05, 0x41, 0x4c, 0x4c, 0x4f, 0x57, 0x18, 0xe7, 0x07, 0x52, 0x0a, 0x6a, 0x73, - 0x6f, 0x6e, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x22, 0x5c, 0x0a, 0x0d, 0x46, 0x69, 0x65, 0x6c, - 0x64, 0x50, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1a, 0x0a, 0x16, 0x46, 0x49, 0x45, - 0x4c, 0x44, 0x5f, 0x50, 0x52, 0x45, 0x53, 0x45, 0x4e, 0x43, 0x45, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, - 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x45, 0x58, 0x50, 0x4c, 0x49, 0x43, 0x49, - 0x54, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x49, 0x4d, 0x50, 0x4c, 0x49, 0x43, 0x49, 0x54, 0x10, - 0x02, 0x12, 0x13, 0x0a, 0x0f, 0x4c, 0x45, 0x47, 0x41, 0x43, 0x59, 0x5f, 0x52, 0x45, 0x51, 0x55, - 0x49, 0x52, 0x45, 0x44, 0x10, 0x03, 0x22, 0x37, 0x0a, 0x08, 0x45, 0x6e, 0x75, 0x6d, 0x54, 0x79, - 0x70, 0x65, 0x12, 0x15, 0x0a, 0x11, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, - 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4f, 0x50, 0x45, - 0x4e, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x10, 0x02, 0x22, - 0x56, 0x0a, 0x15, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x46, 0x69, 0x65, 0x6c, 0x64, - 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x23, 0x0a, 0x1f, 0x52, 0x45, 0x50, 0x45, - 0x41, 0x54, 0x45, 0x44, 0x5f, 0x46, 0x49, 0x45, 0x4c, 0x44, 0x5f, 0x45, 0x4e, 0x43, 0x4f, 0x44, - 0x49, 0x4e, 0x47, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0a, 0x0a, - 0x06, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x44, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x45, 0x58, 0x50, - 0x41, 0x4e, 0x44, 0x45, 0x44, 0x10, 0x02, 0x22, 0x43, 0x0a, 0x0e, 0x55, 0x74, 0x66, 0x38, 0x56, - 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x17, 0x55, 0x54, 0x46, - 0x38, 0x5f, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x55, 0x4e, 0x4b, - 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x56, 0x45, 0x52, 0x49, 0x46, 0x59, - 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x4f, 0x4e, 0x45, 0x10, 0x03, 0x22, 0x53, 0x0a, 0x0f, - 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x12, - 0x1c, 0x0a, 0x18, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x5f, 0x45, 0x4e, 0x43, 0x4f, 0x44, - 0x49, 0x4e, 0x47, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x13, 0x0a, - 0x0f, 0x4c, 0x45, 0x4e, 0x47, 0x54, 0x48, 0x5f, 0x50, 0x52, 0x45, 0x46, 0x49, 0x58, 0x45, 0x44, - 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x44, 0x45, 0x4c, 0x49, 0x4d, 0x49, 0x54, 0x45, 0x44, 0x10, - 0x02, 0x22, 0x48, 0x0a, 0x0a, 0x4a, 0x73, 0x6f, 0x6e, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, - 0x17, 0x0a, 0x13, 0x4a, 0x53, 0x4f, 0x4e, 0x5f, 0x46, 0x4f, 0x52, 0x4d, 0x41, 0x54, 0x5f, 0x55, - 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x4c, 0x4c, 0x4f, - 0x57, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x4c, 0x45, 0x47, 0x41, 0x43, 0x59, 0x5f, 0x42, 0x45, - 0x53, 0x54, 0x5f, 0x45, 0x46, 0x46, 0x4f, 0x52, 0x54, 0x10, 0x02, 0x2a, 0x06, 0x08, 0xe8, 0x07, - 0x10, 0xe9, 0x07, 0x2a, 0x06, 0x08, 0xe9, 0x07, 0x10, 0xea, 0x07, 0x2a, 0x06, 0x08, 0xea, 0x07, - 0x10, 0xeb, 0x07, 0x2a, 0x06, 0x08, 0x8b, 0x4e, 0x10, 0x90, 0x4e, 0x2a, 0x06, 0x08, 0x90, 0x4e, - 0x10, 0x91, 0x4e, 0x4a, 0x06, 0x08, 0xe7, 0x07, 0x10, 0xe8, 0x07, 0x22, 0xfe, 0x02, 0x0a, 0x12, - 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, - 0x74, 0x73, 0x12, 0x58, 0x0a, 0x08, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, - 0x74, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, - 0x65, 0x53, 0x65, 0x74, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x66, 0x61, 0x75, - 0x6c, 0x74, 0x52, 0x08, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x12, 0x41, 0x0a, 0x0f, - 0x6d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x5f, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, - 0x0e, 0x6d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x41, 0x0a, 0x0f, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x5f, 0x65, 0x64, 0x69, 0x74, 0x69, - 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x64, 0x69, 0x74, 0x69, - 0x6f, 0x6e, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x45, 0x64, 0x69, 0x74, 0x69, - 0x6f, 0x6e, 0x1a, 0x87, 0x01, 0x0a, 0x18, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, - 0x74, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, - 0x32, 0x0a, 0x07, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x18, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x65, 0x64, 0x69, 0x74, - 0x69, 0x6f, 0x6e, 0x12, 0x37, 0x0a, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, - 0x65, 0x74, 0x52, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x22, 0xa7, 0x02, 0x0a, - 0x0e, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, - 0x44, 0x0a, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x28, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x49, 0x6e, - 0x66, 0x6f, 0x2e, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x6c, 0x6f, 0x63, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0xce, 0x01, 0x0a, 0x08, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x03, 0x28, 0x05, - 0x42, 0x02, 0x10, 0x01, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x16, 0x0a, 0x04, 0x73, 0x70, - 0x61, 0x6e, 0x18, 0x02, 0x20, 0x03, 0x28, 0x05, 0x42, 0x02, 0x10, 0x01, 0x52, 0x04, 0x73, 0x70, - 0x61, 0x6e, 0x12, 0x29, 0x0a, 0x10, 0x6c, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x63, 0x6f, - 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6c, 0x65, - 0x61, 0x64, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x2b, 0x0a, - 0x11, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x69, 0x6e, 0x67, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, - 0x74, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x69, - 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x3a, 0x0a, 0x19, 0x6c, 0x65, - 0x61, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x65, 0x74, 0x61, 0x63, 0x68, 0x65, 0x64, 0x5f, 0x63, - 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x17, 0x6c, - 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x65, 0x64, 0x43, 0x6f, - 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0xd0, 0x02, 0x0a, 0x11, 0x47, 0x65, 0x6e, 0x65, 0x72, - 0x61, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x4d, 0x0a, 0x0a, - 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x2d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x64, 0x65, - 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, - 0x0a, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0xeb, 0x01, 0x0a, 0x0a, - 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x04, 0x70, 0x61, - 0x74, 0x68, 0x18, 0x01, 0x20, 0x03, 0x28, 0x05, 0x42, 0x02, 0x10, 0x01, 0x52, 0x04, 0x70, 0x61, - 0x74, 0x68, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x66, 0x69, 0x6c, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, - 0x69, 0x6c, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x65, 0x67, 0x69, 0x6e, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x05, 0x62, 0x65, 0x67, 0x69, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x64, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x65, 0x6e, 0x64, 0x12, 0x52, 0x0a, 0x08, 0x73, - 0x65, 0x6d, 0x61, 0x6e, 0x74, 0x69, 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x36, 0x2e, + 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x2e, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, + 0x65, 0x64, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x42, + 0x2d, 0x88, 0x01, 0x01, 0x98, 0x01, 0x04, 0x98, 0x01, 0x01, 0xa2, 0x01, 0x0d, 0x12, 0x08, 0x45, + 0x58, 0x50, 0x41, 0x4e, 0x44, 0x45, 0x44, 0x18, 0xe6, 0x07, 0xa2, 0x01, 0x0b, 0x12, 0x06, 0x50, + 0x41, 0x43, 0x4b, 0x45, 0x44, 0x18, 0xe7, 0x07, 0xb2, 0x01, 0x03, 0x08, 0xe8, 0x07, 0x52, 0x15, + 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x45, 0x6e, 0x63, + 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x7e, 0x0a, 0x0f, 0x75, 0x74, 0x66, 0x38, 0x5f, 0x76, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2a, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x2e, 0x55, 0x74, 0x66, 0x38, + 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x29, 0x88, 0x01, 0x01, 0x98, + 0x01, 0x04, 0x98, 0x01, 0x01, 0xa2, 0x01, 0x09, 0x12, 0x04, 0x4e, 0x4f, 0x4e, 0x45, 0x18, 0xe6, + 0x07, 0xa2, 0x01, 0x0b, 0x12, 0x06, 0x56, 0x45, 0x52, 0x49, 0x46, 0x59, 0x18, 0xe7, 0x07, 0xb2, + 0x01, 0x03, 0x08, 0xe8, 0x07, 0x52, 0x0e, 0x75, 0x74, 0x66, 0x38, 0x56, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x7e, 0x0a, 0x10, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x5f, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x2b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x2e, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x26, 0x88, 0x01, + 0x01, 0x98, 0x01, 0x04, 0x98, 0x01, 0x01, 0xa2, 0x01, 0x14, 0x12, 0x0f, 0x4c, 0x45, 0x4e, 0x47, + 0x54, 0x48, 0x5f, 0x50, 0x52, 0x45, 0x46, 0x49, 0x58, 0x45, 0x44, 0x18, 0xe6, 0x07, 0xb2, 0x01, + 0x03, 0x08, 0xe8, 0x07, 0x52, 0x0f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x45, 0x6e, 0x63, + 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x82, 0x01, 0x0a, 0x0b, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x66, + 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, + 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x2e, 0x4a, 0x73, 0x6f, 0x6e, 0x46, 0x6f, 0x72, + 0x6d, 0x61, 0x74, 0x42, 0x39, 0x88, 0x01, 0x01, 0x98, 0x01, 0x03, 0x98, 0x01, 0x06, 0x98, 0x01, + 0x01, 0xa2, 0x01, 0x17, 0x12, 0x12, 0x4c, 0x45, 0x47, 0x41, 0x43, 0x59, 0x5f, 0x42, 0x45, 0x53, + 0x54, 0x5f, 0x45, 0x46, 0x46, 0x4f, 0x52, 0x54, 0x18, 0xe6, 0x07, 0xa2, 0x01, 0x0a, 0x12, 0x05, + 0x41, 0x4c, 0x4c, 0x4f, 0x57, 0x18, 0xe7, 0x07, 0xb2, 0x01, 0x03, 0x08, 0xe8, 0x07, 0x52, 0x0a, + 0x6a, 0x73, 0x6f, 0x6e, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x22, 0x5c, 0x0a, 0x0d, 0x46, 0x69, + 0x65, 0x6c, 0x64, 0x50, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1a, 0x0a, 0x16, 0x46, + 0x49, 0x45, 0x4c, 0x44, 0x5f, 0x50, 0x52, 0x45, 0x53, 0x45, 0x4e, 0x43, 0x45, 0x5f, 0x55, 0x4e, + 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x45, 0x58, 0x50, 0x4c, 0x49, + 0x43, 0x49, 0x54, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x49, 0x4d, 0x50, 0x4c, 0x49, 0x43, 0x49, + 0x54, 0x10, 0x02, 0x12, 0x13, 0x0a, 0x0f, 0x4c, 0x45, 0x47, 0x41, 0x43, 0x59, 0x5f, 0x52, 0x45, + 0x51, 0x55, 0x49, 0x52, 0x45, 0x44, 0x10, 0x03, 0x22, 0x37, 0x0a, 0x08, 0x45, 0x6e, 0x75, 0x6d, + 0x54, 0x79, 0x70, 0x65, 0x12, 0x15, 0x0a, 0x11, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x54, 0x59, 0x50, + 0x45, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4f, + 0x50, 0x45, 0x4e, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x10, + 0x02, 0x22, 0x56, 0x0a, 0x15, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x46, 0x69, 0x65, + 0x6c, 0x64, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x23, 0x0a, 0x1f, 0x52, 0x45, + 0x50, 0x45, 0x41, 0x54, 0x45, 0x44, 0x5f, 0x46, 0x49, 0x45, 0x4c, 0x44, 0x5f, 0x45, 0x4e, 0x43, + 0x4f, 0x44, 0x49, 0x4e, 0x47, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, + 0x0a, 0x0a, 0x06, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x44, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x45, + 0x58, 0x50, 0x41, 0x4e, 0x44, 0x45, 0x44, 0x10, 0x02, 0x22, 0x49, 0x0a, 0x0e, 0x55, 0x74, 0x66, + 0x38, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x17, 0x55, + 0x54, 0x46, 0x38, 0x5f, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x55, + 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x56, 0x45, 0x52, 0x49, + 0x46, 0x59, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x4f, 0x4e, 0x45, 0x10, 0x03, 0x22, 0x04, + 0x08, 0x01, 0x10, 0x01, 0x22, 0x53, 0x0a, 0x0f, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x45, + 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x1c, 0x0a, 0x18, 0x4d, 0x45, 0x53, 0x53, 0x41, + 0x47, 0x45, 0x5f, 0x45, 0x4e, 0x43, 0x4f, 0x44, 0x49, 0x4e, 0x47, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, + 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x13, 0x0a, 0x0f, 0x4c, 0x45, 0x4e, 0x47, 0x54, 0x48, 0x5f, + 0x50, 0x52, 0x45, 0x46, 0x49, 0x58, 0x45, 0x44, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x44, 0x45, + 0x4c, 0x49, 0x4d, 0x49, 0x54, 0x45, 0x44, 0x10, 0x02, 0x22, 0x48, 0x0a, 0x0a, 0x4a, 0x73, 0x6f, + 0x6e, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, 0x17, 0x0a, 0x13, 0x4a, 0x53, 0x4f, 0x4e, 0x5f, + 0x46, 0x4f, 0x52, 0x4d, 0x41, 0x54, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, + 0x12, 0x09, 0x0a, 0x05, 0x41, 0x4c, 0x4c, 0x4f, 0x57, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x4c, + 0x45, 0x47, 0x41, 0x43, 0x59, 0x5f, 0x42, 0x45, 0x53, 0x54, 0x5f, 0x45, 0x46, 0x46, 0x4f, 0x52, + 0x54, 0x10, 0x02, 0x2a, 0x06, 0x08, 0xe8, 0x07, 0x10, 0x8b, 0x4e, 0x2a, 0x06, 0x08, 0x8b, 0x4e, + 0x10, 0x90, 0x4e, 0x2a, 0x06, 0x08, 0x90, 0x4e, 0x10, 0x91, 0x4e, 0x4a, 0x06, 0x08, 0xe7, 0x07, + 0x10, 0xe8, 0x07, 0x22, 0xef, 0x03, 0x0a, 0x12, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, + 0x65, 0x74, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x12, 0x58, 0x0a, 0x08, 0x64, 0x65, + 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3c, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, + 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, + 0x73, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x45, 0x64, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x52, 0x08, 0x64, 0x65, 0x66, 0x61, + 0x75, 0x6c, 0x74, 0x73, 0x12, 0x41, 0x0a, 0x0f, 0x6d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x5f, + 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, - 0x6f, 0x2e, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x53, 0x65, 0x6d, - 0x61, 0x6e, 0x74, 0x69, 0x63, 0x52, 0x08, 0x73, 0x65, 0x6d, 0x61, 0x6e, 0x74, 0x69, 0x63, 0x22, - 0x28, 0x0a, 0x08, 0x53, 0x65, 0x6d, 0x61, 0x6e, 0x74, 0x69, 0x63, 0x12, 0x08, 0x0a, 0x04, 0x4e, - 0x4f, 0x4e, 0x45, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x53, 0x45, 0x54, 0x10, 0x01, 0x12, 0x09, - 0x0a, 0x05, 0x41, 0x4c, 0x49, 0x41, 0x53, 0x10, 0x02, 0x2a, 0x92, 0x02, 0x0a, 0x07, 0x45, 0x64, - 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x13, 0x0a, 0x0f, 0x45, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, - 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x13, 0x0a, 0x0e, 0x45, 0x44, - 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x50, 0x52, 0x4f, 0x54, 0x4f, 0x32, 0x10, 0xe6, 0x07, 0x12, - 0x13, 0x0a, 0x0e, 0x45, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x50, 0x52, 0x4f, 0x54, 0x4f, - 0x33, 0x10, 0xe7, 0x07, 0x12, 0x11, 0x0a, 0x0c, 0x45, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, - 0x32, 0x30, 0x32, 0x33, 0x10, 0xe8, 0x07, 0x12, 0x11, 0x0a, 0x0c, 0x45, 0x44, 0x49, 0x54, 0x49, - 0x4f, 0x4e, 0x5f, 0x32, 0x30, 0x32, 0x34, 0x10, 0xe9, 0x07, 0x12, 0x17, 0x0a, 0x13, 0x45, 0x44, - 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x31, 0x5f, 0x54, 0x45, 0x53, 0x54, 0x5f, 0x4f, 0x4e, 0x4c, - 0x59, 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x45, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x32, - 0x5f, 0x54, 0x45, 0x53, 0x54, 0x5f, 0x4f, 0x4e, 0x4c, 0x59, 0x10, 0x02, 0x12, 0x1d, 0x0a, 0x17, - 0x45, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x39, 0x39, 0x39, 0x39, 0x37, 0x5f, 0x54, 0x45, - 0x53, 0x54, 0x5f, 0x4f, 0x4e, 0x4c, 0x59, 0x10, 0x9d, 0x8d, 0x06, 0x12, 0x1d, 0x0a, 0x17, 0x45, - 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x39, 0x39, 0x39, 0x39, 0x38, 0x5f, 0x54, 0x45, 0x53, - 0x54, 0x5f, 0x4f, 0x4e, 0x4c, 0x59, 0x10, 0x9e, 0x8d, 0x06, 0x12, 0x1d, 0x0a, 0x17, 0x45, 0x44, - 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x39, 0x39, 0x39, 0x39, 0x39, 0x5f, 0x54, 0x45, 0x53, 0x54, - 0x5f, 0x4f, 0x4e, 0x4c, 0x59, 0x10, 0x9f, 0x8d, 0x06, 0x12, 0x13, 0x0a, 0x0b, 0x45, 0x44, 0x49, - 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x4d, 0x41, 0x58, 0x10, 0xff, 0xff, 0xff, 0xff, 0x07, 0x42, 0x7e, - 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x42, 0x10, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, - 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x48, 0x01, 0x5a, 0x2d, 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, 0x64, 0x65, 0x73, 0x63, - 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x70, 0x62, 0xf8, 0x01, 0x01, 0xa2, 0x02, 0x03, 0x47, 0x50, - 0x42, 0xaa, 0x02, 0x1a, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0e, 0x6d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, + 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x41, 0x0a, 0x0f, 0x6d, 0x61, 0x78, 0x69, 0x6d, + 0x75, 0x6d, 0x5f, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x18, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x69, + 0x6d, 0x75, 0x6d, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0xf8, 0x01, 0x0a, 0x18, 0x46, + 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x32, 0x0a, 0x07, 0x65, 0x64, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x64, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x52, 0x07, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x4e, 0x0a, 0x14, 0x6f, + 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x66, 0x65, 0x61, 0x74, 0x75, + 0x72, 0x65, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, + 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x52, 0x13, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x61, + 0x62, 0x6c, 0x65, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x12, 0x42, 0x0a, 0x0e, 0x66, + 0x69, 0x78, 0x65, 0x64, 0x5f, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, + 0x52, 0x0d, 0x66, 0x69, 0x78, 0x65, 0x64, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x4a, + 0x04, 0x08, 0x01, 0x10, 0x02, 0x4a, 0x04, 0x08, 0x02, 0x10, 0x03, 0x52, 0x08, 0x66, 0x65, 0x61, + 0x74, 0x75, 0x72, 0x65, 0x73, 0x22, 0xa7, 0x02, 0x0a, 0x0e, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, + 0x43, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x44, 0x0a, 0x08, 0x6c, 0x6f, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x4c, 0x6f, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0xce, + 0x01, 0x0a, 0x08, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x04, 0x70, + 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x03, 0x28, 0x05, 0x42, 0x02, 0x10, 0x01, 0x52, 0x04, 0x70, + 0x61, 0x74, 0x68, 0x12, 0x16, 0x0a, 0x04, 0x73, 0x70, 0x61, 0x6e, 0x18, 0x02, 0x20, 0x03, 0x28, + 0x05, 0x42, 0x02, 0x10, 0x01, 0x52, 0x04, 0x73, 0x70, 0x61, 0x6e, 0x12, 0x29, 0x0a, 0x10, 0x6c, + 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6c, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x43, 0x6f, + 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x2b, 0x0a, 0x11, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x69, + 0x6e, 0x67, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x10, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x65, + 0x6e, 0x74, 0x73, 0x12, 0x3a, 0x0a, 0x19, 0x6c, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x64, + 0x65, 0x74, 0x61, 0x63, 0x68, 0x65, 0x64, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, + 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x17, 0x6c, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x44, + 0x65, 0x74, 0x61, 0x63, 0x68, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, + 0xd0, 0x02, 0x0a, 0x11, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x64, + 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x4d, 0x0a, 0x0a, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x47, 0x65, 0x6e, 0x65, + 0x72, 0x61, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x41, 0x6e, + 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0xeb, 0x01, 0x0a, 0x0a, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x03, 0x28, + 0x05, 0x42, 0x02, 0x10, 0x01, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x1f, 0x0a, 0x0b, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x14, 0x0a, 0x05, + 0x62, 0x65, 0x67, 0x69, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x62, 0x65, 0x67, + 0x69, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x03, 0x65, 0x6e, 0x64, 0x12, 0x52, 0x0a, 0x08, 0x73, 0x65, 0x6d, 0x61, 0x6e, 0x74, 0x69, 0x63, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x36, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, + 0x65, 0x64, 0x43, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x41, 0x6e, 0x6e, 0x6f, 0x74, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x53, 0x65, 0x6d, 0x61, 0x6e, 0x74, 0x69, 0x63, 0x52, 0x08, + 0x73, 0x65, 0x6d, 0x61, 0x6e, 0x74, 0x69, 0x63, 0x22, 0x28, 0x0a, 0x08, 0x53, 0x65, 0x6d, 0x61, + 0x6e, 0x74, 0x69, 0x63, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x4f, 0x4e, 0x45, 0x10, 0x00, 0x12, 0x07, + 0x0a, 0x03, 0x53, 0x45, 0x54, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x4c, 0x49, 0x41, 0x53, + 0x10, 0x02, 0x2a, 0xa7, 0x02, 0x0a, 0x07, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x13, + 0x0a, 0x0f, 0x45, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, + 0x4e, 0x10, 0x00, 0x12, 0x13, 0x0a, 0x0e, 0x45, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x4c, + 0x45, 0x47, 0x41, 0x43, 0x59, 0x10, 0x84, 0x07, 0x12, 0x13, 0x0a, 0x0e, 0x45, 0x44, 0x49, 0x54, + 0x49, 0x4f, 0x4e, 0x5f, 0x50, 0x52, 0x4f, 0x54, 0x4f, 0x32, 0x10, 0xe6, 0x07, 0x12, 0x13, 0x0a, + 0x0e, 0x45, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x50, 0x52, 0x4f, 0x54, 0x4f, 0x33, 0x10, + 0xe7, 0x07, 0x12, 0x11, 0x0a, 0x0c, 0x45, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x32, 0x30, + 0x32, 0x33, 0x10, 0xe8, 0x07, 0x12, 0x11, 0x0a, 0x0c, 0x45, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, + 0x5f, 0x32, 0x30, 0x32, 0x34, 0x10, 0xe9, 0x07, 0x12, 0x17, 0x0a, 0x13, 0x45, 0x44, 0x49, 0x54, + 0x49, 0x4f, 0x4e, 0x5f, 0x31, 0x5f, 0x54, 0x45, 0x53, 0x54, 0x5f, 0x4f, 0x4e, 0x4c, 0x59, 0x10, + 0x01, 0x12, 0x17, 0x0a, 0x13, 0x45, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x32, 0x5f, 0x54, + 0x45, 0x53, 0x54, 0x5f, 0x4f, 0x4e, 0x4c, 0x59, 0x10, 0x02, 0x12, 0x1d, 0x0a, 0x17, 0x45, 0x44, + 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x39, 0x39, 0x39, 0x39, 0x37, 0x5f, 0x54, 0x45, 0x53, 0x54, + 0x5f, 0x4f, 0x4e, 0x4c, 0x59, 0x10, 0x9d, 0x8d, 0x06, 0x12, 0x1d, 0x0a, 0x17, 0x45, 0x44, 0x49, + 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x39, 0x39, 0x39, 0x39, 0x38, 0x5f, 0x54, 0x45, 0x53, 0x54, 0x5f, + 0x4f, 0x4e, 0x4c, 0x59, 0x10, 0x9e, 0x8d, 0x06, 0x12, 0x1d, 0x0a, 0x17, 0x45, 0x44, 0x49, 0x54, + 0x49, 0x4f, 0x4e, 0x5f, 0x39, 0x39, 0x39, 0x39, 0x39, 0x5f, 0x54, 0x45, 0x53, 0x54, 0x5f, 0x4f, + 0x4e, 0x4c, 0x59, 0x10, 0x9f, 0x8d, 0x06, 0x12, 0x13, 0x0a, 0x0b, 0x45, 0x44, 0x49, 0x54, 0x49, + 0x4f, 0x4e, 0x5f, 0x4d, 0x41, 0x58, 0x10, 0xff, 0xff, 0xff, 0xff, 0x07, 0x42, 0x7e, 0x0a, 0x13, + 0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x42, 0x10, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x50, + 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x48, 0x01, 0x5a, 0x2d, 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, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x6f, 0x72, 0x70, 0x62, 0xf8, 0x01, 0x01, 0xa2, 0x02, 0x03, 0x47, 0x50, 0x42, 0xaa, + 0x02, 0x1a, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, } var ( @@ -5084,8 +5242,8 @@ func file_google_protobuf_descriptor_proto_rawDescGZIP() []byte { } var file_google_protobuf_descriptor_proto_enumTypes = make([]protoimpl.EnumInfo, 17) -var file_google_protobuf_descriptor_proto_msgTypes = make([]protoimpl.MessageInfo, 32) -var file_google_protobuf_descriptor_proto_goTypes = []interface{}{ +var file_google_protobuf_descriptor_proto_msgTypes = make([]protoimpl.MessageInfo, 33) +var file_google_protobuf_descriptor_proto_goTypes = []any{ (Edition)(0), // 0: google.protobuf.Edition (ExtensionRangeOptions_VerificationState)(0), // 1: google.protobuf.ExtensionRangeOptions.VerificationState (FieldDescriptorProto_Type)(0), // 2: google.protobuf.FieldDescriptorProto.Type @@ -5131,10 +5289,11 @@ var file_google_protobuf_descriptor_proto_goTypes = []interface{}{ (*ExtensionRangeOptions_Declaration)(nil), // 42: google.protobuf.ExtensionRangeOptions.Declaration (*EnumDescriptorProto_EnumReservedRange)(nil), // 43: google.protobuf.EnumDescriptorProto.EnumReservedRange (*FieldOptions_EditionDefault)(nil), // 44: google.protobuf.FieldOptions.EditionDefault - (*UninterpretedOption_NamePart)(nil), // 45: google.protobuf.UninterpretedOption.NamePart - (*FeatureSetDefaults_FeatureSetEditionDefault)(nil), // 46: google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault - (*SourceCodeInfo_Location)(nil), // 47: google.protobuf.SourceCodeInfo.Location - (*GeneratedCodeInfo_Annotation)(nil), // 48: google.protobuf.GeneratedCodeInfo.Annotation + (*FieldOptions_FeatureSupport)(nil), // 45: google.protobuf.FieldOptions.FeatureSupport + (*UninterpretedOption_NamePart)(nil), // 46: google.protobuf.UninterpretedOption.NamePart + (*FeatureSetDefaults_FeatureSetEditionDefault)(nil), // 47: google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + (*SourceCodeInfo_Location)(nil), // 48: google.protobuf.SourceCodeInfo.Location + (*GeneratedCodeInfo_Annotation)(nil), // 49: google.protobuf.GeneratedCodeInfo.Annotation } var file_google_protobuf_descriptor_proto_depIdxs = []int32{ 18, // 0: google.protobuf.FileDescriptorSet.file:type_name -> google.protobuf.FileDescriptorProto @@ -5179,40 +5338,46 @@ var file_google_protobuf_descriptor_proto_depIdxs = []int32{ 8, // 39: google.protobuf.FieldOptions.targets:type_name -> google.protobuf.FieldOptions.OptionTargetType 44, // 40: google.protobuf.FieldOptions.edition_defaults:type_name -> google.protobuf.FieldOptions.EditionDefault 36, // 41: google.protobuf.FieldOptions.features:type_name -> google.protobuf.FeatureSet - 35, // 42: google.protobuf.FieldOptions.uninterpreted_option:type_name -> google.protobuf.UninterpretedOption - 36, // 43: google.protobuf.OneofOptions.features:type_name -> google.protobuf.FeatureSet - 35, // 44: google.protobuf.OneofOptions.uninterpreted_option:type_name -> google.protobuf.UninterpretedOption - 36, // 45: google.protobuf.EnumOptions.features:type_name -> google.protobuf.FeatureSet - 35, // 46: google.protobuf.EnumOptions.uninterpreted_option:type_name -> google.protobuf.UninterpretedOption - 36, // 47: google.protobuf.EnumValueOptions.features:type_name -> google.protobuf.FeatureSet - 35, // 48: google.protobuf.EnumValueOptions.uninterpreted_option:type_name -> google.protobuf.UninterpretedOption - 36, // 49: google.protobuf.ServiceOptions.features:type_name -> google.protobuf.FeatureSet - 35, // 50: google.protobuf.ServiceOptions.uninterpreted_option:type_name -> google.protobuf.UninterpretedOption - 9, // 51: google.protobuf.MethodOptions.idempotency_level:type_name -> google.protobuf.MethodOptions.IdempotencyLevel - 36, // 52: google.protobuf.MethodOptions.features:type_name -> google.protobuf.FeatureSet - 35, // 53: google.protobuf.MethodOptions.uninterpreted_option:type_name -> google.protobuf.UninterpretedOption - 45, // 54: google.protobuf.UninterpretedOption.name:type_name -> google.protobuf.UninterpretedOption.NamePart - 10, // 55: google.protobuf.FeatureSet.field_presence:type_name -> google.protobuf.FeatureSet.FieldPresence - 11, // 56: google.protobuf.FeatureSet.enum_type:type_name -> google.protobuf.FeatureSet.EnumType - 12, // 57: google.protobuf.FeatureSet.repeated_field_encoding:type_name -> google.protobuf.FeatureSet.RepeatedFieldEncoding - 13, // 58: google.protobuf.FeatureSet.utf8_validation:type_name -> google.protobuf.FeatureSet.Utf8Validation - 14, // 59: google.protobuf.FeatureSet.message_encoding:type_name -> google.protobuf.FeatureSet.MessageEncoding - 15, // 60: google.protobuf.FeatureSet.json_format:type_name -> google.protobuf.FeatureSet.JsonFormat - 46, // 61: google.protobuf.FeatureSetDefaults.defaults:type_name -> google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault - 0, // 62: google.protobuf.FeatureSetDefaults.minimum_edition:type_name -> google.protobuf.Edition - 0, // 63: google.protobuf.FeatureSetDefaults.maximum_edition:type_name -> google.protobuf.Edition - 47, // 64: google.protobuf.SourceCodeInfo.location:type_name -> google.protobuf.SourceCodeInfo.Location - 48, // 65: google.protobuf.GeneratedCodeInfo.annotation:type_name -> google.protobuf.GeneratedCodeInfo.Annotation - 20, // 66: google.protobuf.DescriptorProto.ExtensionRange.options:type_name -> google.protobuf.ExtensionRangeOptions - 0, // 67: google.protobuf.FieldOptions.EditionDefault.edition:type_name -> google.protobuf.Edition - 0, // 68: google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.edition:type_name -> google.protobuf.Edition - 36, // 69: google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.features:type_name -> google.protobuf.FeatureSet - 16, // 70: google.protobuf.GeneratedCodeInfo.Annotation.semantic:type_name -> google.protobuf.GeneratedCodeInfo.Annotation.Semantic - 71, // [71:71] is the sub-list for method output_type - 71, // [71:71] is the sub-list for method input_type - 71, // [71:71] is the sub-list for extension type_name - 71, // [71:71] is the sub-list for extension extendee - 0, // [0:71] is the sub-list for field type_name + 45, // 42: google.protobuf.FieldOptions.feature_support:type_name -> google.protobuf.FieldOptions.FeatureSupport + 35, // 43: google.protobuf.FieldOptions.uninterpreted_option:type_name -> google.protobuf.UninterpretedOption + 36, // 44: google.protobuf.OneofOptions.features:type_name -> google.protobuf.FeatureSet + 35, // 45: google.protobuf.OneofOptions.uninterpreted_option:type_name -> google.protobuf.UninterpretedOption + 36, // 46: google.protobuf.EnumOptions.features:type_name -> google.protobuf.FeatureSet + 35, // 47: google.protobuf.EnumOptions.uninterpreted_option:type_name -> google.protobuf.UninterpretedOption + 36, // 48: google.protobuf.EnumValueOptions.features:type_name -> google.protobuf.FeatureSet + 45, // 49: google.protobuf.EnumValueOptions.feature_support:type_name -> google.protobuf.FieldOptions.FeatureSupport + 35, // 50: google.protobuf.EnumValueOptions.uninterpreted_option:type_name -> google.protobuf.UninterpretedOption + 36, // 51: google.protobuf.ServiceOptions.features:type_name -> google.protobuf.FeatureSet + 35, // 52: google.protobuf.ServiceOptions.uninterpreted_option:type_name -> google.protobuf.UninterpretedOption + 9, // 53: google.protobuf.MethodOptions.idempotency_level:type_name -> google.protobuf.MethodOptions.IdempotencyLevel + 36, // 54: google.protobuf.MethodOptions.features:type_name -> google.protobuf.FeatureSet + 35, // 55: google.protobuf.MethodOptions.uninterpreted_option:type_name -> google.protobuf.UninterpretedOption + 46, // 56: google.protobuf.UninterpretedOption.name:type_name -> google.protobuf.UninterpretedOption.NamePart + 10, // 57: google.protobuf.FeatureSet.field_presence:type_name -> google.protobuf.FeatureSet.FieldPresence + 11, // 58: google.protobuf.FeatureSet.enum_type:type_name -> google.protobuf.FeatureSet.EnumType + 12, // 59: google.protobuf.FeatureSet.repeated_field_encoding:type_name -> google.protobuf.FeatureSet.RepeatedFieldEncoding + 13, // 60: google.protobuf.FeatureSet.utf8_validation:type_name -> google.protobuf.FeatureSet.Utf8Validation + 14, // 61: google.protobuf.FeatureSet.message_encoding:type_name -> google.protobuf.FeatureSet.MessageEncoding + 15, // 62: google.protobuf.FeatureSet.json_format:type_name -> google.protobuf.FeatureSet.JsonFormat + 47, // 63: google.protobuf.FeatureSetDefaults.defaults:type_name -> google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + 0, // 64: google.protobuf.FeatureSetDefaults.minimum_edition:type_name -> google.protobuf.Edition + 0, // 65: google.protobuf.FeatureSetDefaults.maximum_edition:type_name -> google.protobuf.Edition + 48, // 66: google.protobuf.SourceCodeInfo.location:type_name -> google.protobuf.SourceCodeInfo.Location + 49, // 67: google.protobuf.GeneratedCodeInfo.annotation:type_name -> google.protobuf.GeneratedCodeInfo.Annotation + 20, // 68: google.protobuf.DescriptorProto.ExtensionRange.options:type_name -> google.protobuf.ExtensionRangeOptions + 0, // 69: google.protobuf.FieldOptions.EditionDefault.edition:type_name -> google.protobuf.Edition + 0, // 70: google.protobuf.FieldOptions.FeatureSupport.edition_introduced:type_name -> google.protobuf.Edition + 0, // 71: google.protobuf.FieldOptions.FeatureSupport.edition_deprecated:type_name -> google.protobuf.Edition + 0, // 72: google.protobuf.FieldOptions.FeatureSupport.edition_removed:type_name -> google.protobuf.Edition + 0, // 73: google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.edition:type_name -> google.protobuf.Edition + 36, // 74: google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.overridable_features:type_name -> google.protobuf.FeatureSet + 36, // 75: google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.fixed_features:type_name -> google.protobuf.FeatureSet + 16, // 76: google.protobuf.GeneratedCodeInfo.Annotation.semantic:type_name -> google.protobuf.GeneratedCodeInfo.Annotation.Semantic + 77, // [77:77] is the sub-list for method output_type + 77, // [77:77] is the sub-list for method input_type + 77, // [77:77] is the sub-list for extension type_name + 77, // [77:77] is the sub-list for extension extendee + 0, // [0:77] is the sub-list for field type_name } func init() { file_google_protobuf_descriptor_proto_init() } @@ -5221,7 +5386,7 @@ func file_google_protobuf_descriptor_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_google_protobuf_descriptor_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*FileDescriptorSet); i { case 0: return &v.state @@ -5233,7 +5398,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*FileDescriptorProto); i { case 0: return &v.state @@ -5245,7 +5410,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*DescriptorProto); i { case 0: return &v.state @@ -5257,7 +5422,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*ExtensionRangeOptions); i { case 0: return &v.state @@ -5271,7 +5436,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*FieldDescriptorProto); i { case 0: return &v.state @@ -5283,7 +5448,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*OneofDescriptorProto); i { case 0: return &v.state @@ -5295,7 +5460,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*EnumDescriptorProto); i { case 0: return &v.state @@ -5307,7 +5472,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[7].Exporter = func(v any, i int) any { switch v := v.(*EnumValueDescriptorProto); i { case 0: return &v.state @@ -5319,7 +5484,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[8].Exporter = func(v any, i int) any { switch v := v.(*ServiceDescriptorProto); i { case 0: return &v.state @@ -5331,7 +5496,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[9].Exporter = func(v any, i int) any { switch v := v.(*MethodDescriptorProto); i { case 0: return &v.state @@ -5343,7 +5508,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[10].Exporter = func(v any, i int) any { switch v := v.(*FileOptions); i { case 0: return &v.state @@ -5357,7 +5522,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[11].Exporter = func(v any, i int) any { switch v := v.(*MessageOptions); i { case 0: return &v.state @@ -5371,7 +5536,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[12].Exporter = func(v any, i int) any { switch v := v.(*FieldOptions); i { case 0: return &v.state @@ -5385,7 +5550,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[13].Exporter = func(v any, i int) any { switch v := v.(*OneofOptions); i { case 0: return &v.state @@ -5399,7 +5564,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[14].Exporter = func(v any, i int) any { switch v := v.(*EnumOptions); i { case 0: return &v.state @@ -5413,7 +5578,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[15].Exporter = func(v any, i int) any { switch v := v.(*EnumValueOptions); i { case 0: return &v.state @@ -5427,7 +5592,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[16].Exporter = func(v any, i int) any { switch v := v.(*ServiceOptions); i { case 0: return &v.state @@ -5441,7 +5606,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[17].Exporter = func(v any, i int) any { switch v := v.(*MethodOptions); i { case 0: return &v.state @@ -5455,7 +5620,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[18].Exporter = func(v any, i int) any { switch v := v.(*UninterpretedOption); i { case 0: return &v.state @@ -5467,7 +5632,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[19].Exporter = func(v any, i int) any { switch v := v.(*FeatureSet); i { case 0: return &v.state @@ -5481,7 +5646,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[20].Exporter = func(v any, i int) any { switch v := v.(*FeatureSetDefaults); i { case 0: return &v.state @@ -5493,7 +5658,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[21].Exporter = func(v any, i int) any { switch v := v.(*SourceCodeInfo); i { case 0: return &v.state @@ -5505,7 +5670,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[22].Exporter = func(v any, i int) any { switch v := v.(*GeneratedCodeInfo); i { case 0: return &v.state @@ -5517,7 +5682,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[23].Exporter = func(v any, i int) any { switch v := v.(*DescriptorProto_ExtensionRange); i { case 0: return &v.state @@ -5529,7 +5694,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[24].Exporter = func(v any, i int) any { switch v := v.(*DescriptorProto_ReservedRange); i { case 0: return &v.state @@ -5541,7 +5706,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[25].Exporter = func(v any, i int) any { switch v := v.(*ExtensionRangeOptions_Declaration); i { case 0: return &v.state @@ -5553,7 +5718,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[26].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[26].Exporter = func(v any, i int) any { switch v := v.(*EnumDescriptorProto_EnumReservedRange); i { case 0: return &v.state @@ -5565,7 +5730,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[27].Exporter = func(v any, i int) any { switch v := v.(*FieldOptions_EditionDefault); i { case 0: return &v.state @@ -5577,7 +5742,19 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[28].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[28].Exporter = func(v any, i int) any { + switch v := v.(*FieldOptions_FeatureSupport); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_google_protobuf_descriptor_proto_msgTypes[29].Exporter = func(v any, i int) any { switch v := v.(*UninterpretedOption_NamePart); i { case 0: return &v.state @@ -5589,7 +5766,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[29].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[30].Exporter = func(v any, i int) any { switch v := v.(*FeatureSetDefaults_FeatureSetEditionDefault); i { case 0: return &v.state @@ -5601,7 +5778,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[30].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[31].Exporter = func(v any, i int) any { switch v := v.(*SourceCodeInfo_Location); i { case 0: return &v.state @@ -5613,7 +5790,7 @@ func file_google_protobuf_descriptor_proto_init() { return nil } } - file_google_protobuf_descriptor_proto_msgTypes[31].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_descriptor_proto_msgTypes[32].Exporter = func(v any, i int) any { switch v := v.(*GeneratedCodeInfo_Annotation); i { case 0: return &v.state @@ -5632,7 +5809,7 @@ func file_google_protobuf_descriptor_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_google_protobuf_descriptor_proto_rawDesc, NumEnums: 17, - NumMessages: 32, + NumMessages: 33, NumExtensions: 0, NumServices: 0, }, diff --git a/vendor/google.golang.org/protobuf/types/dynamicpb/dynamic.go b/vendor/google.golang.org/protobuf/types/dynamicpb/dynamic.go index 39b024b46b8..1ba1dfa5ad8 100644 --- a/vendor/google.golang.org/protobuf/types/dynamicpb/dynamic.go +++ b/vendor/google.golang.org/protobuf/types/dynamicpb/dynamic.go @@ -294,7 +294,7 @@ func (m *Message) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { case fd.IsMap(): return protoreflect.ValueOfMap(&dynamicMap{ desc: fd, - mapv: make(map[interface{}]protoreflect.Value), + mapv: make(map[any]protoreflect.Value), }) case fd.IsList(): return protoreflect.ValueOfList(&dynamicList{desc: fd}) @@ -450,7 +450,7 @@ func (x *dynamicList) IsValid() bool { type dynamicMap struct { desc protoreflect.FieldDescriptor - mapv map[interface{}]protoreflect.Value + mapv map[any]protoreflect.Value } func (x *dynamicMap) Get(k protoreflect.MapKey) protoreflect.Value { return x.mapv[k.Interface()] } @@ -634,11 +634,11 @@ func newListEntry(fd protoreflect.FieldDescriptor) protoreflect.Value { // // The InterfaceOf and ValueOf methods of the extension type are defined as: // -// func (xt extensionType) ValueOf(iv interface{}) protoreflect.Value { +// func (xt extensionType) ValueOf(iv any) protoreflect.Value { // return protoreflect.ValueOf(iv) // } // -// func (xt extensionType) InterfaceOf(v protoreflect.Value) interface{} { +// func (xt extensionType) InterfaceOf(v protoreflect.Value) any { // return v.Interface() // } // @@ -658,7 +658,7 @@ func (xt extensionType) New() protoreflect.Value { case xt.desc.IsMap(): return protoreflect.ValueOfMap(&dynamicMap{ desc: xt.desc, - mapv: make(map[interface{}]protoreflect.Value), + mapv: make(map[any]protoreflect.Value), }) case xt.desc.IsList(): return protoreflect.ValueOfList(&dynamicList{desc: xt.desc}) @@ -686,18 +686,18 @@ func (xt extensionType) TypeDescriptor() protoreflect.ExtensionTypeDescriptor { return xt.desc } -func (xt extensionType) ValueOf(iv interface{}) protoreflect.Value { +func (xt extensionType) ValueOf(iv any) protoreflect.Value { v := protoreflect.ValueOf(iv) typecheck(xt.desc, v) return v } -func (xt extensionType) InterfaceOf(v protoreflect.Value) interface{} { +func (xt extensionType) InterfaceOf(v protoreflect.Value) any { typecheck(xt.desc, v) return v.Interface() } -func (xt extensionType) IsValidInterface(iv interface{}) bool { +func (xt extensionType) IsValidInterface(iv any) bool { return typeIsValid(xt.desc, protoreflect.ValueOf(iv)) == nil } diff --git a/vendor/google.golang.org/protobuf/types/gofeaturespb/go_features.pb.go b/vendor/google.golang.org/protobuf/types/gofeaturespb/go_features.pb.go index 25de5ae0085..a2ca940c50f 100644 --- a/vendor/google.golang.org/protobuf/types/gofeaturespb/go_features.pb.go +++ b/vendor/google.golang.org/protobuf/types/gofeaturespb/go_features.pb.go @@ -6,9 +6,9 @@ // https://developers.google.com/open-source/licenses/bsd // Code generated by protoc-gen-go. DO NOT EDIT. -// source: reflect/protodesc/proto/go_features.proto +// source: google/protobuf/go_features.proto -package proto +package gofeaturespb import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -30,7 +30,7 @@ type GoFeatures struct { func (x *GoFeatures) Reset() { *x = GoFeatures{} if protoimpl.UnsafeEnabled { - mi := &file_reflect_protodesc_proto_go_features_proto_msgTypes[0] + mi := &file_google_protobuf_go_features_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -43,7 +43,7 @@ func (x *GoFeatures) String() string { func (*GoFeatures) ProtoMessage() {} func (x *GoFeatures) ProtoReflect() protoreflect.Message { - mi := &file_reflect_protodesc_proto_go_features_proto_msgTypes[0] + mi := &file_google_protobuf_go_features_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -56,7 +56,7 @@ func (x *GoFeatures) ProtoReflect() protoreflect.Message { // Deprecated: Use GoFeatures.ProtoReflect.Descriptor instead. func (*GoFeatures) Descriptor() ([]byte, []int) { - return file_reflect_protodesc_proto_go_features_proto_rawDescGZIP(), []int{0} + return file_google_protobuf_go_features_proto_rawDescGZIP(), []int{0} } func (x *GoFeatures) GetLegacyUnmarshalJsonEnum() bool { @@ -66,69 +66,73 @@ func (x *GoFeatures) GetLegacyUnmarshalJsonEnum() bool { return false } -var file_reflect_protodesc_proto_go_features_proto_extTypes = []protoimpl.ExtensionInfo{ +var file_google_protobuf_go_features_proto_extTypes = []protoimpl.ExtensionInfo{ { ExtendedType: (*descriptorpb.FeatureSet)(nil), ExtensionType: (*GoFeatures)(nil), Field: 1002, - Name: "google.protobuf.go", + Name: "pb.go", Tag: "bytes,1002,opt,name=go", - Filename: "reflect/protodesc/proto/go_features.proto", + Filename: "google/protobuf/go_features.proto", }, } // Extension fields to descriptorpb.FeatureSet. var ( - // optional google.protobuf.GoFeatures go = 1002; - E_Go = &file_reflect_protodesc_proto_go_features_proto_extTypes[0] + // optional pb.GoFeatures go = 1002; + E_Go = &file_google_protobuf_go_features_proto_extTypes[0] ) -var File_reflect_protodesc_proto_go_features_proto protoreflect.FileDescriptor - -var file_reflect_protodesc_proto_go_features_proto_rawDesc = []byte{ - 0x0a, 0x29, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x64, - 0x65, 0x73, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x5f, 0x66, 0x65, 0x61, - 0x74, 0x75, 0x72, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x1a, 0x20, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, - 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x6a, - 0x0a, 0x0a, 0x47, 0x6f, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x12, 0x5c, 0x0a, 0x1a, - 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x5f, 0x75, 0x6e, 0x6d, 0x61, 0x72, 0x73, 0x68, 0x61, 0x6c, - 0x5f, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, - 0x42, 0x1f, 0x88, 0x01, 0x01, 0x98, 0x01, 0x06, 0xa2, 0x01, 0x09, 0x12, 0x04, 0x74, 0x72, 0x75, - 0x65, 0x18, 0xe6, 0x07, 0xa2, 0x01, 0x0a, 0x12, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x18, 0xe7, - 0x07, 0x52, 0x17, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x55, 0x6e, 0x6d, 0x61, 0x72, 0x73, 0x68, - 0x61, 0x6c, 0x4a, 0x73, 0x6f, 0x6e, 0x45, 0x6e, 0x75, 0x6d, 0x3a, 0x49, 0x0a, 0x02, 0x67, 0x6f, - 0x12, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x18, 0xea, 0x07, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x47, 0x6f, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, - 0x73, 0x52, 0x02, 0x67, 0x6f, 0x42, 0x34, 0x5a, 0x32, 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, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x64, 0x65, 0x73, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, +var File_google_protobuf_go_features_proto protoreflect.FileDescriptor + +var file_google_protobuf_go_features_proto_rawDesc = []byte{ + 0x0a, 0x21, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2f, 0x67, 0x6f, 0x5f, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xcd, 0x01, 0x0a, 0x0a, 0x47, 0x6f, + 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x12, 0xbe, 0x01, 0x0a, 0x1a, 0x6c, 0x65, 0x67, + 0x61, 0x63, 0x79, 0x5f, 0x75, 0x6e, 0x6d, 0x61, 0x72, 0x73, 0x68, 0x61, 0x6c, 0x5f, 0x6a, 0x73, + 0x6f, 0x6e, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x42, 0x80, 0x01, + 0x88, 0x01, 0x01, 0x98, 0x01, 0x06, 0x98, 0x01, 0x01, 0xa2, 0x01, 0x09, 0x12, 0x04, 0x74, 0x72, + 0x75, 0x65, 0x18, 0x84, 0x07, 0xa2, 0x01, 0x0a, 0x12, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x18, + 0xe7, 0x07, 0xb2, 0x01, 0x5b, 0x08, 0xe8, 0x07, 0x10, 0xe8, 0x07, 0x1a, 0x53, 0x54, 0x68, 0x65, + 0x20, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x20, 0x55, 0x6e, 0x6d, 0x61, 0x72, 0x73, 0x68, 0x61, + 0x6c, 0x4a, 0x53, 0x4f, 0x4e, 0x20, 0x41, 0x50, 0x49, 0x20, 0x69, 0x73, 0x20, 0x64, 0x65, 0x70, + 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x77, 0x69, 0x6c, 0x6c, + 0x20, 0x62, 0x65, 0x20, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x20, 0x69, 0x6e, 0x20, 0x61, + 0x20, 0x66, 0x75, 0x74, 0x75, 0x72, 0x65, 0x20, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, + 0x52, 0x17, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x55, 0x6e, 0x6d, 0x61, 0x72, 0x73, 0x68, 0x61, + 0x6c, 0x4a, 0x73, 0x6f, 0x6e, 0x45, 0x6e, 0x75, 0x6d, 0x3a, 0x3c, 0x0a, 0x02, 0x67, 0x6f, 0x12, + 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x18, 0xea, 0x07, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x6f, 0x46, 0x65, 0x61, 0x74, 0x75, + 0x72, 0x65, 0x73, 0x52, 0x02, 0x67, 0x6f, 0x42, 0x2f, 0x5a, 0x2d, 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, 0x67, 0x6f, 0x66, 0x65, + 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x70, 0x62, } var ( - file_reflect_protodesc_proto_go_features_proto_rawDescOnce sync.Once - file_reflect_protodesc_proto_go_features_proto_rawDescData = file_reflect_protodesc_proto_go_features_proto_rawDesc + file_google_protobuf_go_features_proto_rawDescOnce sync.Once + file_google_protobuf_go_features_proto_rawDescData = file_google_protobuf_go_features_proto_rawDesc ) -func file_reflect_protodesc_proto_go_features_proto_rawDescGZIP() []byte { - file_reflect_protodesc_proto_go_features_proto_rawDescOnce.Do(func() { - file_reflect_protodesc_proto_go_features_proto_rawDescData = protoimpl.X.CompressGZIP(file_reflect_protodesc_proto_go_features_proto_rawDescData) +func file_google_protobuf_go_features_proto_rawDescGZIP() []byte { + file_google_protobuf_go_features_proto_rawDescOnce.Do(func() { + file_google_protobuf_go_features_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_protobuf_go_features_proto_rawDescData) }) - return file_reflect_protodesc_proto_go_features_proto_rawDescData + return file_google_protobuf_go_features_proto_rawDescData } -var file_reflect_protodesc_proto_go_features_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_reflect_protodesc_proto_go_features_proto_goTypes = []interface{}{ - (*GoFeatures)(nil), // 0: google.protobuf.GoFeatures +var file_google_protobuf_go_features_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_google_protobuf_go_features_proto_goTypes = []any{ + (*GoFeatures)(nil), // 0: pb.GoFeatures (*descriptorpb.FeatureSet)(nil), // 1: google.protobuf.FeatureSet } -var file_reflect_protodesc_proto_go_features_proto_depIdxs = []int32{ - 1, // 0: google.protobuf.go:extendee -> google.protobuf.FeatureSet - 0, // 1: google.protobuf.go:type_name -> google.protobuf.GoFeatures +var file_google_protobuf_go_features_proto_depIdxs = []int32{ + 1, // 0: pb.go:extendee -> google.protobuf.FeatureSet + 0, // 1: pb.go:type_name -> pb.GoFeatures 2, // [2:2] is the sub-list for method output_type 2, // [2:2] is the sub-list for method input_type 1, // [1:2] is the sub-list for extension type_name @@ -136,13 +140,13 @@ var file_reflect_protodesc_proto_go_features_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for field type_name } -func init() { file_reflect_protodesc_proto_go_features_proto_init() } -func file_reflect_protodesc_proto_go_features_proto_init() { - if File_reflect_protodesc_proto_go_features_proto != nil { +func init() { file_google_protobuf_go_features_proto_init() } +func file_google_protobuf_go_features_proto_init() { + if File_google_protobuf_go_features_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_reflect_protodesc_proto_go_features_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_go_features_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*GoFeatures); i { case 0: return &v.state @@ -159,19 +163,19 @@ func file_reflect_protodesc_proto_go_features_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_reflect_protodesc_proto_go_features_proto_rawDesc, + RawDescriptor: file_google_protobuf_go_features_proto_rawDesc, NumEnums: 0, NumMessages: 1, NumExtensions: 1, NumServices: 0, }, - GoTypes: file_reflect_protodesc_proto_go_features_proto_goTypes, - DependencyIndexes: file_reflect_protodesc_proto_go_features_proto_depIdxs, - MessageInfos: file_reflect_protodesc_proto_go_features_proto_msgTypes, - ExtensionInfos: file_reflect_protodesc_proto_go_features_proto_extTypes, + GoTypes: file_google_protobuf_go_features_proto_goTypes, + DependencyIndexes: file_google_protobuf_go_features_proto_depIdxs, + MessageInfos: file_google_protobuf_go_features_proto_msgTypes, + ExtensionInfos: file_google_protobuf_go_features_proto_extTypes, }.Build() - File_reflect_protodesc_proto_go_features_proto = out.File - file_reflect_protodesc_proto_go_features_proto_rawDesc = nil - file_reflect_protodesc_proto_go_features_proto_goTypes = nil - file_reflect_protodesc_proto_go_features_proto_depIdxs = nil + File_google_protobuf_go_features_proto = out.File + file_google_protobuf_go_features_proto_rawDesc = nil + file_google_protobuf_go_features_proto_goTypes = nil + file_google_protobuf_go_features_proto_depIdxs = nil } diff --git a/vendor/google.golang.org/protobuf/types/gofeaturespb/go_features.proto b/vendor/google.golang.org/protobuf/types/gofeaturespb/go_features.proto deleted file mode 100644 index d246571296e..00000000000 --- a/vendor/google.golang.org/protobuf/types/gofeaturespb/go_features.proto +++ /dev/null @@ -1,28 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2023 Google Inc. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file or at -// https://developers.google.com/open-source/licenses/bsd - -syntax = "proto2"; - -package google.protobuf; - -import "google/protobuf/descriptor.proto"; - -option go_package = "google.golang.org/protobuf/types/gofeaturespb"; - -extend google.protobuf.FeatureSet { - optional GoFeatures go = 1002; -} - -message GoFeatures { - // Whether or not to generate the deprecated UnmarshalJSON method for enums. - optional bool legacy_unmarshal_json_enum = 1 [ - retention = RETENTION_RUNTIME, - targets = TARGET_TYPE_ENUM, - edition_defaults = { edition: EDITION_PROTO2, value: "true" }, - edition_defaults = { edition: EDITION_PROTO3, value: "false" } - ]; -} diff --git a/vendor/google.golang.org/protobuf/types/known/anypb/any.pb.go b/vendor/google.golang.org/protobuf/types/known/anypb/any.pb.go index 9de51be5403..7172b43d383 100644 --- a/vendor/google.golang.org/protobuf/types/known/anypb/any.pb.go +++ b/vendor/google.golang.org/protobuf/types/known/anypb/any.pb.go @@ -445,7 +445,7 @@ func file_google_protobuf_any_proto_rawDescGZIP() []byte { } var file_google_protobuf_any_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_google_protobuf_any_proto_goTypes = []interface{}{ +var file_google_protobuf_any_proto_goTypes = []any{ (*Any)(nil), // 0: google.protobuf.Any } var file_google_protobuf_any_proto_depIdxs = []int32{ @@ -462,7 +462,7 @@ func file_google_protobuf_any_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_google_protobuf_any_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_any_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Any); i { case 0: return &v.state diff --git a/vendor/google.golang.org/protobuf/types/known/apipb/api.pb.go b/vendor/google.golang.org/protobuf/types/known/apipb/api.pb.go index 335be6eb760..4f2fe89ef11 100644 --- a/vendor/google.golang.org/protobuf/types/known/apipb/api.pb.go +++ b/vendor/google.golang.org/protobuf/types/known/apipb/api.pb.go @@ -488,7 +488,7 @@ func file_google_protobuf_api_proto_rawDescGZIP() []byte { } var file_google_protobuf_api_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_google_protobuf_api_proto_goTypes = []interface{}{ +var file_google_protobuf_api_proto_goTypes = []any{ (*Api)(nil), // 0: google.protobuf.Api (*Method)(nil), // 1: google.protobuf.Method (*Mixin)(nil), // 2: google.protobuf.Mixin @@ -517,7 +517,7 @@ func file_google_protobuf_api_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_google_protobuf_api_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_api_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Api); i { case 0: return &v.state @@ -529,7 +529,7 @@ func file_google_protobuf_api_proto_init() { return nil } } - file_google_protobuf_api_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_api_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*Method); i { case 0: return &v.state @@ -541,7 +541,7 @@ func file_google_protobuf_api_proto_init() { return nil } } - file_google_protobuf_api_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_api_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*Mixin); i { case 0: return &v.state 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 index df709a8dd4c..1b71bcd910a 100644 --- a/vendor/google.golang.org/protobuf/types/known/durationpb/duration.pb.go +++ b/vendor/google.golang.org/protobuf/types/known/durationpb/duration.pb.go @@ -323,7 +323,7 @@ func file_google_protobuf_duration_proto_rawDescGZIP() []byte { } var file_google_protobuf_duration_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_google_protobuf_duration_proto_goTypes = []interface{}{ +var file_google_protobuf_duration_proto_goTypes = []any{ (*Duration)(nil), // 0: google.protobuf.Duration } var file_google_protobuf_duration_proto_depIdxs = []int32{ @@ -340,7 +340,7 @@ func file_google_protobuf_duration_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_google_protobuf_duration_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_duration_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Duration); i { case 0: return &v.state 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 index 9a7277ba394..d87b4fb8281 100644 --- a/vendor/google.golang.org/protobuf/types/known/emptypb/empty.pb.go +++ b/vendor/google.golang.org/protobuf/types/known/emptypb/empty.pb.go @@ -115,7 +115,7 @@ func file_google_protobuf_empty_proto_rawDescGZIP() []byte { } var file_google_protobuf_empty_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_google_protobuf_empty_proto_goTypes = []interface{}{ +var file_google_protobuf_empty_proto_goTypes = []any{ (*Empty)(nil), // 0: google.protobuf.Empty } var file_google_protobuf_empty_proto_depIdxs = []int32{ @@ -132,7 +132,7 @@ func file_google_protobuf_empty_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_google_protobuf_empty_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_empty_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Empty); i { case 0: return &v.state diff --git a/vendor/google.golang.org/protobuf/types/known/fieldmaskpb/field_mask.pb.go b/vendor/google.golang.org/protobuf/types/known/fieldmaskpb/field_mask.pb.go index e8789cb331e..ac1e91bb6dd 100644 --- a/vendor/google.golang.org/protobuf/types/known/fieldmaskpb/field_mask.pb.go +++ b/vendor/google.golang.org/protobuf/types/known/fieldmaskpb/field_mask.pb.go @@ -537,7 +537,7 @@ func file_google_protobuf_field_mask_proto_rawDescGZIP() []byte { } var file_google_protobuf_field_mask_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_google_protobuf_field_mask_proto_goTypes = []interface{}{ +var file_google_protobuf_field_mask_proto_goTypes = []any{ (*FieldMask)(nil), // 0: google.protobuf.FieldMask } var file_google_protobuf_field_mask_proto_depIdxs = []int32{ @@ -554,7 +554,7 @@ func file_google_protobuf_field_mask_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_google_protobuf_field_mask_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_field_mask_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*FieldMask); i { case 0: return &v.state diff --git a/vendor/google.golang.org/protobuf/types/known/sourcecontextpb/source_context.pb.go b/vendor/google.golang.org/protobuf/types/known/sourcecontextpb/source_context.pb.go index 0980d5aed6f..fa185780056 100644 --- a/vendor/google.golang.org/protobuf/types/known/sourcecontextpb/source_context.pb.go +++ b/vendor/google.golang.org/protobuf/types/known/sourcecontextpb/source_context.pb.go @@ -125,7 +125,7 @@ func file_google_protobuf_source_context_proto_rawDescGZIP() []byte { } var file_google_protobuf_source_context_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_google_protobuf_source_context_proto_goTypes = []interface{}{ +var file_google_protobuf_source_context_proto_goTypes = []any{ (*SourceContext)(nil), // 0: google.protobuf.SourceContext } var file_google_protobuf_source_context_proto_depIdxs = []int32{ @@ -142,7 +142,7 @@ func file_google_protobuf_source_context_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_google_protobuf_source_context_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_source_context_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*SourceContext); i { case 0: return &v.state 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 index d2bac8b88ea..d45361cbc72 100644 --- a/vendor/google.golang.org/protobuf/types/known/structpb/struct.pb.go +++ b/vendor/google.golang.org/protobuf/types/known/structpb/struct.pb.go @@ -49,11 +49,11 @@ // 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{}. +// a form represented by any, map[string]any, and []any. // 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{} +// In order to convert the any, map[string]any, and []any // forms back as Value, Struct, and ListValue messages, use the NewStruct, // NewList, and NewValue constructor functions. // @@ -88,28 +88,28 @@ // // To construct a Value message representing the above JSON object: // -// m, err := structpb.NewValue(map[string]interface{}{ +// m, err := structpb.NewValue(map[string]any{ // "firstName": "John", // "lastName": "Smith", // "isAlive": true, // "age": 27, -// "address": map[string]interface{}{ +// "address": map[string]any{ // "streetAddress": "21 2nd Street", // "city": "New York", // "state": "NY", // "postalCode": "10021-3100", // }, -// "phoneNumbers": []interface{}{ -// map[string]interface{}{ +// "phoneNumbers": []any{ +// map[string]any{ // "type": "home", // "number": "212 555-1234", // }, -// map[string]interface{}{ +// map[string]any{ // "type": "office", // "number": "646 555-4567", // }, // }, -// "children": []interface{}{}, +// "children": []any{}, // "spouse": nil, // }) // if err != nil { @@ -197,7 +197,7 @@ type Struct struct { // 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) { +func NewStruct(v map[string]any) (*Struct, error) { x := &Struct{Fields: make(map[string]*Value, len(v))} for k, v := range v { if !utf8.ValidString(k) { @@ -214,9 +214,9 @@ func NewStruct(v map[string]interface{}) (*Struct, error) { // 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{} { +func (x *Struct) AsMap() map[string]any { f := x.GetFields() - vs := make(map[string]interface{}, len(f)) + vs := make(map[string]any, len(f)) for k, v := range f { vs[k] = v.AsInterface() } @@ -306,13 +306,13 @@ type Value struct { // ║ 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 ║ +// ║ map[string]any │ stored as StructValue ║ +// ║ []any │ 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) { +func NewValue(v any) (*Value, error) { switch v := v.(type) { case nil: return NewNullValue(), nil @@ -342,13 +342,13 @@ func NewValue(v interface{}) (*Value, error) { case []byte: s := base64.StdEncoding.EncodeToString(v) return NewStringValue(s), nil - case map[string]interface{}: + case map[string]any: v2, err := NewStruct(v) if err != nil { return nil, err } return NewStructValue(v2), nil - case []interface{}: + case []any: v2, err := NewList(v) if err != nil { return nil, err @@ -396,7 +396,7 @@ func NewListValue(v *ListValue) *Value { // // Floating-point values (i.e., "NaN", "Infinity", and "-Infinity") are // converted as strings to remain compatible with MarshalJSON. -func (x *Value) AsInterface() interface{} { +func (x *Value) AsInterface() any { switch v := x.GetKind().(type) { case *Value_NumberValue: if v != nil { @@ -580,7 +580,7 @@ type ListValue struct { // NewList constructs a ListValue from a general-purpose Go slice. // The slice elements are converted using NewValue. -func NewList(v []interface{}) (*ListValue, error) { +func NewList(v []any) (*ListValue, error) { x := &ListValue{Values: make([]*Value, len(v))} for i, v := range v { var err error @@ -594,9 +594,9 @@ func NewList(v []interface{}) (*ListValue, error) { // AsSlice converts x to a general-purpose Go slice. // The slice elements are converted by calling Value.AsInterface. -func (x *ListValue) AsSlice() []interface{} { +func (x *ListValue) AsSlice() []any { vals := x.GetValues() - vs := make([]interface{}, len(vals)) + vs := make([]any, len(vals)) for i, v := range vals { vs[i] = v.AsInterface() } @@ -716,7 +716,7 @@ func file_google_protobuf_struct_proto_rawDescGZIP() []byte { 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{}{ +var file_google_protobuf_struct_proto_goTypes = []any{ (NullValue)(0), // 0: google.protobuf.NullValue (*Struct)(nil), // 1: google.protobuf.Struct (*Value)(nil), // 2: google.protobuf.Value @@ -743,7 +743,7 @@ func file_google_protobuf_struct_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_google_protobuf_struct_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_struct_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Struct); i { case 0: return &v.state @@ -755,7 +755,7 @@ func file_google_protobuf_struct_proto_init() { return nil } } - file_google_protobuf_struct_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_struct_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*Value); i { case 0: return &v.state @@ -767,7 +767,7 @@ func file_google_protobuf_struct_proto_init() { return nil } } - file_google_protobuf_struct_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_struct_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*ListValue); i { case 0: return &v.state @@ -780,7 +780,7 @@ func file_google_protobuf_struct_proto_init() { } } } - file_google_protobuf_struct_proto_msgTypes[1].OneofWrappers = []interface{}{ + file_google_protobuf_struct_proto_msgTypes[1].OneofWrappers = []any{ (*Value_NullValue)(nil), (*Value_NumberValue)(nil), (*Value_StringValue)(nil), diff --git a/vendor/google.golang.org/protobuf/types/known/timestamppb/timestamp.pb.go b/vendor/google.golang.org/protobuf/types/known/timestamppb/timestamp.pb.go index 81511a3363e..83a5a645b08 100644 --- a/vendor/google.golang.org/protobuf/types/known/timestamppb/timestamp.pb.go +++ b/vendor/google.golang.org/protobuf/types/known/timestamppb/timestamp.pb.go @@ -332,7 +332,7 @@ func file_google_protobuf_timestamp_proto_rawDescGZIP() []byte { } var file_google_protobuf_timestamp_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_google_protobuf_timestamp_proto_goTypes = []interface{}{ +var file_google_protobuf_timestamp_proto_goTypes = []any{ (*Timestamp)(nil), // 0: google.protobuf.Timestamp } var file_google_protobuf_timestamp_proto_depIdxs = []int32{ @@ -349,7 +349,7 @@ func file_google_protobuf_timestamp_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_google_protobuf_timestamp_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_timestamp_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Timestamp); i { case 0: return &v.state diff --git a/vendor/google.golang.org/protobuf/types/known/typepb/type.pb.go b/vendor/google.golang.org/protobuf/types/known/typepb/type.pb.go index 4cb8d0a59c9..52887fd5db6 100644 --- a/vendor/google.golang.org/protobuf/types/known/typepb/type.pb.go +++ b/vendor/google.golang.org/protobuf/types/known/typepb/type.pb.go @@ -868,7 +868,7 @@ func file_google_protobuf_type_proto_rawDescGZIP() []byte { var file_google_protobuf_type_proto_enumTypes = make([]protoimpl.EnumInfo, 3) var file_google_protobuf_type_proto_msgTypes = make([]protoimpl.MessageInfo, 5) -var file_google_protobuf_type_proto_goTypes = []interface{}{ +var file_google_protobuf_type_proto_goTypes = []any{ (Syntax)(0), // 0: google.protobuf.Syntax (Field_Kind)(0), // 1: google.protobuf.Field.Kind (Field_Cardinality)(0), // 2: google.protobuf.Field.Cardinality @@ -907,7 +907,7 @@ func file_google_protobuf_type_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_google_protobuf_type_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_type_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Type); i { case 0: return &v.state @@ -919,7 +919,7 @@ func file_google_protobuf_type_proto_init() { return nil } } - file_google_protobuf_type_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_type_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*Field); i { case 0: return &v.state @@ -931,7 +931,7 @@ func file_google_protobuf_type_proto_init() { return nil } } - file_google_protobuf_type_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_type_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*Enum); i { case 0: return &v.state @@ -943,7 +943,7 @@ func file_google_protobuf_type_proto_init() { return nil } } - file_google_protobuf_type_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_type_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*EnumValue); i { case 0: return &v.state @@ -955,7 +955,7 @@ func file_google_protobuf_type_proto_init() { return nil } } - file_google_protobuf_type_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_type_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*Option); i { case 0: return &v.state 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 index 762a87130f8..e473f826aa3 100644 --- a/vendor/google.golang.org/protobuf/types/known/wrapperspb/wrappers.pb.go +++ b/vendor/google.golang.org/protobuf/types/known/wrapperspb/wrappers.pb.go @@ -605,7 +605,7 @@ func file_google_protobuf_wrappers_proto_rawDescGZIP() []byte { } var file_google_protobuf_wrappers_proto_msgTypes = make([]protoimpl.MessageInfo, 9) -var file_google_protobuf_wrappers_proto_goTypes = []interface{}{ +var file_google_protobuf_wrappers_proto_goTypes = []any{ (*DoubleValue)(nil), // 0: google.protobuf.DoubleValue (*FloatValue)(nil), // 1: google.protobuf.FloatValue (*Int64Value)(nil), // 2: google.protobuf.Int64Value @@ -630,7 +630,7 @@ func file_google_protobuf_wrappers_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_google_protobuf_wrappers_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_wrappers_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*DoubleValue); i { case 0: return &v.state @@ -642,7 +642,7 @@ func file_google_protobuf_wrappers_proto_init() { return nil } } - file_google_protobuf_wrappers_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_wrappers_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*FloatValue); i { case 0: return &v.state @@ -654,7 +654,7 @@ func file_google_protobuf_wrappers_proto_init() { return nil } } - file_google_protobuf_wrappers_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_wrappers_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*Int64Value); i { case 0: return &v.state @@ -666,7 +666,7 @@ func file_google_protobuf_wrappers_proto_init() { return nil } } - file_google_protobuf_wrappers_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_wrappers_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*UInt64Value); i { case 0: return &v.state @@ -678,7 +678,7 @@ func file_google_protobuf_wrappers_proto_init() { return nil } } - file_google_protobuf_wrappers_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_wrappers_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*Int32Value); i { case 0: return &v.state @@ -690,7 +690,7 @@ func file_google_protobuf_wrappers_proto_init() { return nil } } - file_google_protobuf_wrappers_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_wrappers_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*UInt32Value); i { case 0: return &v.state @@ -702,7 +702,7 @@ func file_google_protobuf_wrappers_proto_init() { return nil } } - file_google_protobuf_wrappers_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_wrappers_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*BoolValue); i { case 0: return &v.state @@ -714,7 +714,7 @@ func file_google_protobuf_wrappers_proto_init() { return nil } } - file_google_protobuf_wrappers_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_wrappers_proto_msgTypes[7].Exporter = func(v any, i int) any { switch v := v.(*StringValue); i { case 0: return &v.state @@ -726,7 +726,7 @@ func file_google_protobuf_wrappers_proto_init() { return nil } } - file_google_protobuf_wrappers_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_wrappers_proto_msgTypes[8].Exporter = func(v any, i int) any { switch v := v.(*BytesValue); i { case 0: return &v.state diff --git a/vendor/google.golang.org/protobuf/types/pluginpb/plugin.pb.go b/vendor/google.golang.org/protobuf/types/pluginpb/plugin.pb.go index 620728f8cca..9066bcc7f3b 100644 --- a/vendor/google.golang.org/protobuf/types/pluginpb/plugin.pb.go +++ b/vendor/google.golang.org/protobuf/types/pluginpb/plugin.pb.go @@ -591,7 +591,7 @@ func file_google_protobuf_compiler_plugin_proto_rawDescGZIP() []byte { var file_google_protobuf_compiler_plugin_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_google_protobuf_compiler_plugin_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_google_protobuf_compiler_plugin_proto_goTypes = []interface{}{ +var file_google_protobuf_compiler_plugin_proto_goTypes = []any{ (CodeGeneratorResponse_Feature)(0), // 0: google.protobuf.compiler.CodeGeneratorResponse.Feature (*Version)(nil), // 1: google.protobuf.compiler.Version (*CodeGeneratorRequest)(nil), // 2: google.protobuf.compiler.CodeGeneratorRequest @@ -619,7 +619,7 @@ func file_google_protobuf_compiler_plugin_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_google_protobuf_compiler_plugin_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_compiler_plugin_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Version); i { case 0: return &v.state @@ -631,7 +631,7 @@ func file_google_protobuf_compiler_plugin_proto_init() { return nil } } - file_google_protobuf_compiler_plugin_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_compiler_plugin_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*CodeGeneratorRequest); i { case 0: return &v.state @@ -643,7 +643,7 @@ func file_google_protobuf_compiler_plugin_proto_init() { return nil } } - file_google_protobuf_compiler_plugin_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_compiler_plugin_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*CodeGeneratorResponse); i { case 0: return &v.state @@ -655,7 +655,7 @@ func file_google_protobuf_compiler_plugin_proto_init() { return nil } } - file_google_protobuf_compiler_plugin_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_compiler_plugin_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*CodeGeneratorResponse_File); i { case 0: return &v.state diff --git a/vendor/modules.txt b/vendor/modules.txt index 8ac8bdb447b..765507dfa3f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -10,7 +10,7 @@ github.com/Azure/go-ntlmssp # github.com/DataDog/datadog-go v0.0.0-20180330214955-e67964b4021a ## explicit github.com/DataDog/datadog-go/statsd -# github.com/PuerkitoBio/goquery v1.9.1 +# github.com/PuerkitoBio/goquery v1.9.2 ## explicit; go 1.18 github.com/PuerkitoBio/goquery # github.com/Soontao/goHttpDigestClient v0.0.0-20170320082612-6d28bb1415c5 @@ -26,8 +26,8 @@ github.com/andybalholm/cascadia # github.com/beorn7/perks v1.0.1 ## explicit; go 1.11 github.com/beorn7/perks/quantile -# github.com/bufbuild/protocompile v0.8.0 -## explicit; go 1.19 +# github.com/bufbuild/protocompile v0.10.0 +## explicit; go 1.20 github.com/bufbuild/protocompile github.com/bufbuild/protocompile/ast github.com/bufbuild/protocompile/internal @@ -105,16 +105,6 @@ github.com/dgryski/go-rendezvous ## explicit; go 1.13 github.com/dlclark/regexp2 github.com/dlclark/regexp2/syntax -# github.com/dop251/goja v0.0.0-20240610225006-393f6d42497b -## explicit; go 1.20 -github.com/dop251/goja -github.com/dop251/goja/ast -github.com/dop251/goja/file -github.com/dop251/goja/ftoa -github.com/dop251/goja/ftoa/internal/fast -github.com/dop251/goja/parser -github.com/dop251/goja/token -github.com/dop251/goja/unistring # github.com/evanw/esbuild v0.21.2 ## explicit; go 1.13 github.com/evanw/esbuild/internal/api_helpers @@ -142,7 +132,7 @@ github.com/evanw/esbuild/internal/runtime github.com/evanw/esbuild/internal/sourcemap github.com/evanw/esbuild/internal/xxhash github.com/evanw/esbuild/pkg/api -# github.com/fatih/color v1.16.0 +# github.com/fatih/color v1.17.0 ## explicit; go 1.17 github.com/fatih/color # github.com/fsnotify/fsnotify v1.5.4 @@ -173,10 +163,17 @@ github.com/google/uuid # github.com/gorilla/websocket v1.5.1 ## explicit; go 1.20 github.com/gorilla/websocket -# github.com/grafana/sobek v0.0.0-20240613124309-cb36746e8fee +# github.com/grafana/sobek v0.0.0-20240626131919-5be1e93c7efc ## explicit; go 1.20 github.com/grafana/sobek -# github.com/grafana/xk6-browser v1.6.0 +github.com/grafana/sobek/ast +github.com/grafana/sobek/file +github.com/grafana/sobek/ftoa +github.com/grafana/sobek/ftoa/internal/fast +github.com/grafana/sobek/parser +github.com/grafana/sobek/token +github.com/grafana/sobek/unistring +# github.com/grafana/xk6-browser v1.6.1-0.20240701105714-29f6ef3049fe ## explicit; go 1.20 github.com/grafana/xk6-browser/browser github.com/grafana/xk6-browser/chromium @@ -189,7 +186,7 @@ github.com/grafana/xk6-browser/keyboardlayout github.com/grafana/xk6-browser/log github.com/grafana/xk6-browser/storage github.com/grafana/xk6-browser/trace -# github.com/grafana/xk6-dashboard v0.7.4 +# github.com/grafana/xk6-dashboard v0.7.5 ## explicit; go 1.20 github.com/grafana/xk6-dashboard/dashboard # github.com/grafana/xk6-output-prometheus-remote v0.4.0 @@ -203,7 +200,7 @@ github.com/grafana/xk6-redis/redis # github.com/grafana/xk6-webcrypto v0.4.0 ## explicit; go 1.20 github.com/grafana/xk6-webcrypto/webcrypto -# github.com/grafana/xk6-websockets v0.5.1 +# github.com/grafana/xk6-websockets v0.6.0 ## explicit; go 1.20 github.com/grafana/xk6-websockets/websockets github.com/grafana/xk6-websockets/websockets/events @@ -225,8 +222,8 @@ github.com/inconshreveable/mousetrap github.com/influxdata/influxdb1-client/models github.com/influxdata/influxdb1-client/pkg/escape github.com/influxdata/influxdb1-client/v2 -# github.com/jhump/protoreflect v1.15.6 -## explicit; go 1.18 +# github.com/jhump/protoreflect v1.16.0 +## explicit; go 1.19 github.com/jhump/protoreflect/desc github.com/jhump/protoreflect/desc/internal github.com/jhump/protoreflect/desc/protoparse @@ -237,7 +234,7 @@ github.com/jhump/protoreflect/internal # github.com/josharian/intern v1.0.0 ## explicit; go 1.5 github.com/josharian/intern -# github.com/klauspost/compress v1.17.7 +# github.com/klauspost/compress v1.17.9 ## explicit; go 1.20 github.com/klauspost/compress github.com/klauspost/compress/flate @@ -412,7 +409,7 @@ go.uber.org/goleak/internal/stack golang.org/x/crypto/md4 golang.org/x/crypto/ocsp golang.org/x/crypto/ripemd160 -# golang.org/x/crypto/x509roots/fallback v0.0.0-20240604170348-d4e7c9cb6cb8 +# golang.org/x/crypto/x509roots/fallback v0.0.0-20240624163532-1c7450041f58 ## explicit; go 1.20 golang.org/x/crypto/x509roots/fallback # golang.org/x/net v0.26.0 @@ -458,14 +455,14 @@ golang.org/x/text/unicode/rangetable # golang.org/x/time v0.5.0 ## explicit; go 1.18 golang.org/x/time/rate -# google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de +# google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 ## explicit; go 1.19 google.golang.org/genproto/googleapis/api/httpbody -# google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de +# google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 ## explicit; go 1.19 google.golang.org/genproto/googleapis/rpc/errdetails google.golang.org/genproto/googleapis/rpc/status -# google.golang.org/grpc v1.63.2 +# google.golang.org/grpc v1.64.0 ## explicit; go 1.19 google.golang.org/grpc google.golang.org/grpc/attributes @@ -517,6 +514,7 @@ google.golang.org/grpc/peer google.golang.org/grpc/reflection google.golang.org/grpc/reflection/grpc_reflection_v1 google.golang.org/grpc/reflection/grpc_reflection_v1alpha +google.golang.org/grpc/reflection/internal google.golang.org/grpc/resolver google.golang.org/grpc/resolver/dns google.golang.org/grpc/serviceconfig @@ -524,8 +522,8 @@ google.golang.org/grpc/stats google.golang.org/grpc/status google.golang.org/grpc/tap google.golang.org/grpc/test/bufconn -# google.golang.org/protobuf v1.33.0 -## explicit; go 1.17 +# google.golang.org/protobuf v1.34.2 +## explicit; go 1.20 google.golang.org/protobuf/encoding/protojson google.golang.org/protobuf/encoding/prototext google.golang.org/protobuf/encoding/protowire @@ -533,6 +531,7 @@ google.golang.org/protobuf/internal/descfmt google.golang.org/protobuf/internal/descopts 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