Skip to content

Commit 11f8540

Browse files
committed
Merge branch 'main' into ed/bufPolicyYaml
2 parents 218a19c + 9af062e commit 11f8540

File tree

123 files changed

+3576
-951
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+3576
-951
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## [Unreleased]
44

5-
- No changes yet.
5+
- Fix buf breaking annotations for JSON format.
66

77
## [v1.52.1] - 2025-04-08
88

go.mod

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
github.com/bufbuild/protocompile v0.14.1
1818
github.com/bufbuild/protoplugin v0.0.0-20250218205857-750e09ce93e1
1919
github.com/bufbuild/protovalidate-go v0.9.3
20-
github.com/docker/docker v28.0.4+incompatible
20+
github.com/docker/docker v28.1.1+incompatible
2121
github.com/go-chi/chi/v5 v5.2.1
2222
github.com/gofrs/flock v0.12.1
2323
github.com/google/cel-go v0.24.1
@@ -30,7 +30,7 @@ require (
3030
github.com/klauspost/pgzip v1.2.6
3131
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
3232
github.com/pkg/profile v1.7.0
33-
github.com/quic-go/quic-go v0.50.1
33+
github.com/quic-go/quic-go v0.51.0
3434
github.com/rs/cors v1.11.1
3535
github.com/spf13/cobra v1.9.1
3636
github.com/spf13/pflag v1.0.6
@@ -55,7 +55,6 @@ require (
5555
require (
5656
buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.36.6-20241007202033-cf42259fcbfc.1 // indirect
5757
cel.dev/expr v0.23.1 // indirect
58-
github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 // indirect
5958
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
6059
github.com/Microsoft/go-winio v0.6.2 // indirect
6160
github.com/antlr4-go/antlr/v4 v4.13.1 // indirect
@@ -66,7 +65,7 @@ require (
6665
github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect
6766
github.com/davecgh/go-spew v1.1.1 // indirect
6867
github.com/distribution/reference v0.6.0 // indirect
69-
github.com/docker/cli v28.0.4+incompatible // indirect
68+
github.com/docker/cli v28.1.1+incompatible // indirect
7069
github.com/docker/distribution v2.8.3+incompatible // indirect
7170
github.com/docker/docker-credential-helpers v0.9.3 // indirect
7271
github.com/docker/go-connections v0.5.0 // indirect
@@ -77,13 +76,15 @@ require (
7776
github.com/go-logr/stdr v1.2.2 // indirect
7877
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
7978
github.com/gogo/protobuf v1.3.2 // indirect
80-
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect
79+
github.com/google/pprof v0.0.0-20250418163039-24c5476c6587 // indirect
8180
github.com/inconshreveable/mousetrap v1.1.0 // indirect
8281
github.com/mattn/go-isatty v0.0.20 // indirect
8382
github.com/mitchellh/go-homedir v1.1.0 // indirect
8483
github.com/moby/docker-image-spec v1.3.1 // indirect
84+
github.com/moby/go-archive v0.1.0 // indirect
8585
github.com/moby/locker v1.0.1 // indirect
8686
github.com/moby/patternmatcher v0.6.0 // indirect
87+
github.com/moby/sys/atomicwriter v0.1.0 // indirect
8788
github.com/moby/sys/mount v0.3.4 // indirect
8889
github.com/moby/sys/mountinfo v0.7.2 // indirect
8990
github.com/moby/sys/reexec v0.1.0 // indirect
@@ -119,6 +120,6 @@ require (
119120
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect
120121
golang.org/x/sys v0.32.0 // indirect
121122
golang.org/x/text v0.24.0 // indirect
122-
google.golang.org/genproto/googleapis/api v0.0.0-20250409194420-de1ac958c67a // indirect
123-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250409194420-de1ac958c67a // indirect
123+
google.golang.org/genproto/googleapis/api v0.0.0-20250414145226-207652e42e2e // indirect
124+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e // indirect
124125
)

go.sum

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
6060
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
6161
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
6262
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
63-
github.com/docker/cli v28.0.4+incompatible h1:pBJSJeNd9QeIWPjRcV91RVJihd/TXB77q1ef64XEu4A=
64-
github.com/docker/cli v28.0.4+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
63+
github.com/docker/cli v28.1.1+incompatible h1:eyUemzeI45DY7eDPuwUcmDyDj1pM98oD5MdSpiItp8k=
64+
github.com/docker/cli v28.1.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
6565
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
6666
github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
67-
github.com/docker/docker v28.0.4+incompatible h1:JNNkBctYKurkw6FrHfKqY0nKIDf5nrbxjVBtS+cdcok=
68-
github.com/docker/docker v28.0.4+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
67+
github.com/docker/docker v28.1.1+incompatible h1:49M11BFLsVO1gxY9UX9p/zwkE/rswggs8AdFmXQw51I=
68+
github.com/docker/docker v28.1.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
6969
github.com/docker/docker-credential-helpers v0.9.3 h1:gAm/VtF9wgqJMoxzT3Gj5p4AqIjCBS4wrsOh9yRqcz8=
7070
github.com/docker/docker-credential-helpers v0.9.3/go.mod h1:x+4Gbw9aGmChi3qTLZj8Dfn0TD20M/fuWy0E5+WDeCo=
7171
github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c=
@@ -104,8 +104,8 @@ github.com/google/go-containerregistry v0.20.3 h1:oNx7IdTI936V8CQRveCjaxOiegWwvM
104104
github.com/google/go-containerregistry v0.20.3/go.mod h1:w00pIgBRDVUDFM6bq+Qx8lwNWK+cxgCuX1vd3PIBDNI=
105105
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg=
106106
github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik=
107-
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 h1:BHT72Gu3keYf3ZEu2J0b1vyeLSOYI8bm5wbJM/8yDe8=
108-
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
107+
github.com/google/pprof v0.0.0-20250418163039-24c5476c6587 h1:b/8HpQhvKLSNzH5oTXN2WkNcMl6YB5K3FRbb+i+Ml34=
108+
github.com/google/pprof v0.0.0-20250418163039-24c5476c6587/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
109109
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
110110
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
111111
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1 h1:VNqngBF40hVlDloBruUehVYC3ArSgIyScOAyMRqBxRg=
@@ -137,10 +137,14 @@ github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG
137137
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
138138
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
139139
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
140+
github.com/moby/go-archive v0.1.0 h1:Kk/5rdW/g+H8NHdJW2gsXyZ7UnzvJNOy6VKJqueWdcQ=
141+
github.com/moby/go-archive v0.1.0/go.mod h1:G9B+YoujNohJmrIYFBpSd54GTUB4lt9S+xVQvsJyFuo=
140142
github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg=
141143
github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc=
142144
github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk=
143145
github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
146+
github.com/moby/sys/atomicwriter v0.1.0 h1:kw5D/EqkBwsBFi0ss9v1VG3wIkVhzGvLklJ+w3A14Sw=
147+
github.com/moby/sys/atomicwriter v0.1.0/go.mod h1:Ul8oqv2ZMNHOceF643P6FKPXeCmYtlQMvpizfsSoaWs=
144148
github.com/moby/sys/mount v0.3.4 h1:yn5jq4STPztkkzSKpZkLcmjue+bZJ0u2AuQY1iNI1Ww=
145149
github.com/moby/sys/mount v0.3.4/go.mod h1:KcQJMbQdJHPlq5lcYT+/CjatWM4PuxKe+XLSVS4J6Os=
146150
github.com/moby/sys/mountinfo v0.7.2 h1:1shs6aH5s4o5H2zQLn796ADW1wMrIwHsyJ2v9KouLrg=
@@ -180,8 +184,8 @@ github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4
180184
github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U=
181185
github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI=
182186
github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg=
183-
github.com/quic-go/quic-go v0.50.1 h1:unsgjFIUqW8a2oopkY7YNONpV1gYND6Nt9hnt1PN94Q=
184-
github.com/quic-go/quic-go v0.50.1/go.mod h1:Vim6OmUvlYdwBhXP9ZVrtGmCMWa3wEqhq3NgYrI8b4E=
187+
github.com/quic-go/quic-go v0.51.0 h1:K8exxe9zXxeRKxaXxi/GpUqYiTrtdiWP8bo1KFya6Wc=
188+
github.com/quic-go/quic-go v0.51.0/go.mod h1:MFlGGpcpJqRAfmYi6NC2cptDPSxRWTOGNuP4wqrWmzQ=
185189
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
186190
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
187191
github.com/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA=
@@ -294,8 +298,8 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
294298
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
295299
golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0=
296300
golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU=
297-
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
298-
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
301+
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac h1:7zkz7BUtwNFFqcowJ+RIgu2MaV/MapERkDIy+mwPyjs=
302+
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
299303
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
300304
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
301305
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
@@ -306,10 +310,10 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
306310
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
307311
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
308312
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
309-
google.golang.org/genproto/googleapis/api v0.0.0-20250409194420-de1ac958c67a h1:OQ7sHVzkx6L57dQpzUS4ckfWJ51KDH74XHTDe23xWAs=
310-
google.golang.org/genproto/googleapis/api v0.0.0-20250409194420-de1ac958c67a/go.mod h1:2R6XrVC8Oc08GlNh8ujEpc7HkLiEZ16QeY7FxIs20ac=
311-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250409194420-de1ac958c67a h1:GIqLhp/cYUkuGuiT+vJk8vhOP86L4+SP5j8yXgeVpvI=
312-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250409194420-de1ac958c67a/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
313+
google.golang.org/genproto/googleapis/api v0.0.0-20250414145226-207652e42e2e h1:UdXH7Kzbj+Vzastr5nVfccbmFsmYNygVLSPk1pEfDoY=
314+
google.golang.org/genproto/googleapis/api v0.0.0-20250414145226-207652e42e2e/go.mod h1:085qFyf2+XaZlRdCgKNCIZ3afY2p4HHZdoIRpId8F4A=
315+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e h1:ztQaXfzEXTmCBvbtWYRhJxW+0iJcz2qXfd38/e9l7bA=
316+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
313317
google.golang.org/grpc v1.71.0 h1:kF77BGdPTQ4/JZWMlb9VpJ5pa25aqvVqogsxNHHdeBg=
314318
google.golang.org/grpc v1.71.0/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec=
315319
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
@@ -320,7 +324,7 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV
320324
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
321325
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
322326
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
323-
gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0=
324-
gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8=
327+
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
328+
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
325329
pluginrpc.com/pluginrpc v0.5.0 h1:tOQj2D35hOmvHyPu8e7ohW2/QvAnEtKscy2IJYWQ2yo=
326330
pluginrpc.com/pluginrpc v0.5.0/go.mod h1:UNWZ941hcVAoOZUn8YZsMmOZBzbUjQa3XMns8RQLp9o=

make/go/dep_golangci_lint.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ GOLANGCI_LINT_VERSION ?= v2.0.2
3030
GOLANGCI_LINT := $(CACHE_VERSIONS)/golangci-lint/$(GOLANGCI_LINT_VERSION)
3131
$(GOLANGCI_LINT):
3232
@rm -f $(CACHE_BIN)/golangci-lint
33+
@mkdir -p $(CACHE_BIN)
3334
$(eval GOLANGCI_LINT_TMP := $(shell mktemp -d))
3435
curl -fsSL -o $(GOLANGCI_LINT_TMP)/golangci-lint.tar.gz \
3536
https://github.com/golangci/golangci-lint/releases/download/$(GOLANGCI_LINT_VERSION)/golangci-lint-$(subst v,,$(GOLANGCI_LINT_VERSION))-$(GOLANGCI_LINT_OS)-$(GOLANGCI_LINT_ARCH).tar.gz

make/go/go.mk

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,13 @@ godeps: deps
9191
go mod download
9292

9393
.PHONY: gofmtmodtidy
94-
gofmtmodtidy:
94+
gofmtmodtidy: $(GOLANGCI_LINT)
9595
@echo gofmt -s -w ALL_GO_FILES
9696
@gofmt -s -w .
9797
go mod tidy -v
98+
ifeq ($(SKIP_GOLANGCI_LINT),)
99+
golangci-lint fmt
100+
endif
98101

99102
format:: gofmtmodtidy
100103

@@ -114,6 +117,7 @@ golangcilint: $(GOLANGCI_LINT)
114117
ifneq ($(SKIP_GOLANGCI_LINT),)
115118
@echo Skipping golangci-lint...
116119
else
120+
golangci-lint fmt --diff
117121
golangci-lint run --timeout $(GOLANGCILINTTIMEOUT)
118122
endif
119123

private/buf/bufcli/cache.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package bufcli
1616

1717
import (
18+
"context"
1819
"errors"
1920
"fmt"
2021
"io/fs"
@@ -37,6 +38,7 @@ import (
3738
"github.com/bufbuild/buf/private/pkg/filelock"
3839
"github.com/bufbuild/buf/private/pkg/normalpath"
3940
"github.com/bufbuild/buf/private/pkg/storage/storageos"
41+
"github.com/bufbuild/buf/private/pkg/wasm"
4042
)
4143

4244
var (
@@ -173,17 +175,21 @@ func NewPluginDataProvider(container appext.Container) (bufplugin.PluginDataProv
173175
)
174176
}
175177

176-
// CreateWasmRuntimeCacheDir creates the cache directory for the Wasm runtime.
177-
//
178-
// This is used by the Wasm runtime to cache compiled Wasm plugins. This is an
179-
// implementation specific cache and opaque outside of the runtime. The runtime
180-
// will manage the cache versioning itself within this directory.
181-
func CreateWasmRuntimeCacheDir(container appext.Container) (string, error) {
178+
// NewWasmRuntime returns a new Wasm runtime while creating the required cache
179+
// directories.
180+
func NewWasmRuntime(ctx context.Context, container appext.Container) (wasm.Runtime, error) {
181+
// This is used by the Wasm runtime to cache compiled Wasm plugins. This is an
182+
// implementation specific cache and opaque outside of the runtime. The runtime
183+
// will manage the cache versioning itself within this directory.
182184
if err := createCacheDir(container.CacheDirPath(), v3CacheWasmRuntimeRelDirPath); err != nil {
183-
return "", err
185+
return nil, err
184186
}
185187
fullCacheDirPath := normalpath.Join(container.CacheDirPath(), v3CacheWasmRuntimeRelDirPath)
186-
return fullCacheDirPath, nil
188+
wasmRuntime, err := wasm.NewRuntime(ctx, wasm.WithLocalCacheDir(fullCacheDirPath))
189+
if err != nil {
190+
return nil, err
191+
}
192+
return wasmRuntime, nil
187193
}
188194

189195
// NewWKTStore returns a new bufwktstore.Store while creating the required cache directories.

private/buf/bufcli/flags_args.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package bufcli
1717
import (
1818
"errors"
1919
"fmt"
20+
"slices"
2021

2122
modulev1 "buf.build/gen/go/bufbuild/registry/protocolbuffers/go/buf/registry/module/v1"
2223
pluginv1beta1 "buf.build/gen/go/bufbuild/registry/protocolbuffers/go/buf/registry/plugin/v1beta1"
@@ -361,10 +362,8 @@ func ValidateErrorFormatFlagLint(errorFormatString string, errorFormatFlagName s
361362
}
362363

363364
func validateErrorFormatFlag(validFormatStrings []string, errorFormatString string, errorFormatFlagName string) error {
364-
for _, formatString := range validFormatStrings {
365-
if errorFormatString == formatString {
366-
return nil
367-
}
365+
if slices.Contains(validFormatStrings, errorFormatString) {
366+
return nil
368367
}
369368
return appcmd.NewInvalidArgumentErrorf("--%s: invalid format: %q", errorFormatFlagName, errorFormatString)
370369
}

private/buf/bufconvert/bufconvert.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package bufconvert
1616

1717
import (
1818
"fmt"
19+
"slices"
1920
"strings"
2021

2122
"github.com/bufbuild/buf/private/bufpkg/bufimage"
@@ -138,10 +139,8 @@ func checkNoMessageSetWireFormat(descriptor protoreflect.MessageDescriptor, imag
138139
// any message_set_wire_format option. So we must examine the file descriptor proto
139140
// in the image to see if the option is set. If it is, we cannot support this message.
140141
name := descriptor.FullName()
141-
for _, alreadyChecked := range checked {
142-
if name == alreadyChecked {
143-
return nil
144-
}
142+
if slices.Contains(checked, name) {
143+
return nil
145144
}
146145
checked = append(checked, name)
147146

private/buf/bufctl/controller.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"io/fs"
2323
"log/slog"
2424
"net/http"
25+
"slices"
2526
"sort"
2627

2728
"buf.build/go/protoyaml"
@@ -486,15 +487,14 @@ func (c *controller) GetTargetImageWithConfigsAndCheckClient(
486487
pluginConfigs,
487488
),
488489
}
489-
pluginRunnerProvider := bufcheck.NewLocalRunnerProvider(
490-
wasmRuntime,
491-
pluginKeyProvider,
492-
c.pluginDataProvider,
493-
)
494490
checkClient, err := bufcheck.NewClient(
495491
c.logger,
496-
pluginRunnerProvider,
497492
bufcheck.ClientWithStderr(c.container.Stderr()),
493+
bufcheck.ClientWithRunnerProvider(
494+
bufcheck.NewLocalRunnerProvider(wasmRuntime),
495+
),
496+
bufcheck.ClientWithLocalWasmPluginsFromOS(),
497+
bufcheck.ClientWithRemoteWasmPlugins(pluginKeyProvider, c.pluginDataProvider),
498498
)
499499
if err != nil {
500500
return nil, nil, err
@@ -801,15 +801,17 @@ func (c *controller) GetCheckClientForWorkspace(
801801
if err != nil {
802802
return nil, err
803803
}
804-
pluginRunnerProvider := bufcheck.NewLocalRunnerProvider(
805-
wasmRuntime,
806-
pluginKeyProvider,
807-
c.pluginDataProvider,
808-
)
809804
return bufcheck.NewClient(
810805
c.logger,
811-
pluginRunnerProvider,
812806
bufcheck.ClientWithStderr(c.container.Stderr()),
807+
bufcheck.ClientWithRunnerProvider(
808+
bufcheck.NewLocalRunnerProvider(wasmRuntime),
809+
),
810+
bufcheck.ClientWithLocalWasmPluginsFromOS(),
811+
bufcheck.ClientWithRemoteWasmPlugins(
812+
pluginKeyProvider,
813+
c.pluginDataProvider,
814+
),
813815
)
814816
}
815817

@@ -1458,10 +1460,8 @@ func validateFileAnnotationErrorFormat(fileAnnotationErrorFormat string) error {
14581460
if fileAnnotationErrorFormat == "" {
14591461
return nil
14601462
}
1461-
for _, formatString := range bufanalysis.AllFormatStrings {
1462-
if fileAnnotationErrorFormat == formatString {
1463-
return nil
1464-
}
1463+
if slices.Contains(bufanalysis.AllFormatStrings, fileAnnotationErrorFormat) {
1464+
return nil
14651465
}
14661466
// TODO FUTURE: get standard flag names and bindings into this package.
14671467
fileAnnotationErrorFormatFlagName := "error-format"

private/buf/bufcurl/invoker.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"errors"
2222
"fmt"
2323
"io"
24+
"maps"
2425
"net/http"
2526
"net/http/httptest"
2627
"sync"
@@ -130,9 +131,7 @@ func (inv *invoker) handleUnary(ctx context.Context, dataSource string, data io.
130131
}
131132

132133
req := connect.NewRequest(msg)
133-
for k, v := range headers {
134-
req.Header()[k] = v
135-
}
134+
maps.Copy(req.Header(), headers)
136135
resp, err := inv.client.CallUnary(ctx, req)
137136
if err != nil {
138137
var connErr *connect.Error
@@ -149,9 +148,7 @@ func (inv *invoker) handleClientStream(ctx context.Context, dataSource string, d
149148
provider := newStreamMessageProvider(dataSource, data, inv.res)
150149
msg := dynamicpb.NewMessage(inv.md.Input())
151150
stream := inv.client.CallClientStream(ctx)
152-
for k, v := range headers {
153-
stream.RequestHeader()[k] = v
154-
}
151+
maps.Copy(stream.RequestHeader(), headers)
155152
defer func() {
156153
if retErr != nil {
157154
var connErr *connect.Error
@@ -191,9 +188,7 @@ func (inv *invoker) handleServerStream(ctx context.Context, dataSource string, d
191188
}
192189

193190
req := connect.NewRequest(msg)
194-
for k, v := range headers {
195-
req.Header()[k] = v
196-
}
191+
maps.Copy(req.Header(), headers)
197192
defer func() {
198193
if retErr != nil {
199194
var connErr *connect.Error
@@ -215,9 +210,7 @@ func (inv *invoker) handleBidiStream(ctx context.Context, dataSource string, dat
215210
provider := newStreamMessageProvider(dataSource, data, inv.res)
216211
msg := dynamicpb.NewMessage(inv.md.Input())
217212
stream := inv.client.CallBidiStream(ctx)
218-
for k, v := range headers {
219-
stream.RequestHeader()[k] = v
220-
}
213+
maps.Copy(stream.RequestHeader(), headers)
221214

222215
defer func() {
223216
if retErr != nil {

0 commit comments

Comments
 (0)