Skip to content

Commit b4d7836

Browse files
authored
Add bufplugin.RunnerProvider for remote plugins (#3548)
1 parent 9bb7b2e commit b4d7836

File tree

19 files changed

+309
-108
lines changed

19 files changed

+309
-108
lines changed

private/buf/bufmigrate/migrator.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/bufbuild/buf/private/bufpkg/bufconfig"
3030
"github.com/bufbuild/buf/private/bufpkg/bufmodule"
3131
"github.com/bufbuild/buf/private/bufpkg/bufparse"
32+
"github.com/bufbuild/buf/private/bufpkg/bufplugin"
3233
"github.com/bufbuild/buf/private/pkg/normalpath"
3334
"github.com/bufbuild/buf/private/pkg/slicesext"
3435
"github.com/bufbuild/buf/private/pkg/storage"
@@ -695,7 +696,11 @@ func equivalentCheckConfigInV2(
695696
) (bufconfig.CheckConfig, error) {
696697
// No need for custom lint/breaking plugins since there's no plugins to migrate from <=v1.
697698
// TODO: If we ever need v3, then we will have to deal with this.
698-
client, err := bufcheck.NewClient(logger, bufcheck.NewRunnerProvider(wasm.UnimplementedRuntime))
699+
client, err := bufcheck.NewClient(logger, bufcheck.NewLocalRunnerProvider(
700+
wasm.UnimplementedRuntime,
701+
bufplugin.NopPluginKeyProvider,
702+
bufplugin.NopPluginDataProvider,
703+
))
699704
if err != nil {
700705
return nil, err
701706
}

private/buf/cmd/buf/buf_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
"github.com/bufbuild/buf/private/bufpkg/bufcheck"
3636
"github.com/bufbuild/buf/private/bufpkg/bufconfig"
3737
"github.com/bufbuild/buf/private/bufpkg/bufimage"
38+
"github.com/bufbuild/buf/private/bufpkg/bufplugin"
3839
imagev1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/image/v1"
3940
"github.com/bufbuild/buf/private/pkg/app/appcmd"
4041
"github.com/bufbuild/buf/private/pkg/app/appcmd/appcmdtesting"
@@ -1350,7 +1351,11 @@ func TestCheckLsBreakingRulesFromConfigExceptDeprecated(t *testing.T) {
13501351
// Do not need any custom lint/breaking plugins here.
13511352
client, err := bufcheck.NewClient(
13521353
slogtestext.NewLogger(t),
1353-
bufcheck.NewRunnerProvider(wasm.UnimplementedRuntime),
1354+
bufcheck.NewLocalRunnerProvider(
1355+
wasm.UnimplementedRuntime,
1356+
bufplugin.NopPluginKeyProvider,
1357+
bufplugin.NopPluginDataProvider,
1358+
),
13541359
)
13551360
require.NoError(t, err)
13561361
allRules, err := client.AllRules(context.Background(), check.RuleTypeBreaking, version)

private/buf/cmd/buf/command/beta/lsp/lsp.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"github.com/bufbuild/buf/private/buf/bufcli"
2828
"github.com/bufbuild/buf/private/buf/buflsp"
2929
"github.com/bufbuild/buf/private/bufpkg/bufcheck"
30+
"github.com/bufbuild/buf/private/bufpkg/bufplugin"
3031
"github.com/bufbuild/buf/private/pkg/app/appcmd"
3132
"github.com/bufbuild/buf/private/pkg/app/appext"
3233
"github.com/bufbuild/buf/private/pkg/ioext"
@@ -115,7 +116,11 @@ func run(
115116
}()
116117
checkClient, err := bufcheck.NewClient(
117118
container.Logger(),
118-
bufcheck.NewRunnerProvider(wasmRuntime),
119+
bufcheck.NewLocalRunnerProvider(
120+
wasmRuntime,
121+
bufplugin.NopPluginKeyProvider,
122+
bufplugin.NopPluginDataProvider,
123+
),
119124
bufcheck.ClientWithStderr(container.Stderr()),
120125
)
121126
if err != nil {

private/buf/cmd/buf/command/breaking/breaking.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/bufbuild/buf/private/bufpkg/bufanalysis"
2626
"github.com/bufbuild/buf/private/bufpkg/bufcheck"
2727
"github.com/bufbuild/buf/private/bufpkg/bufimage"
28+
"github.com/bufbuild/buf/private/bufpkg/bufplugin"
2829
"github.com/bufbuild/buf/private/pkg/app/appcmd"
2930
"github.com/bufbuild/buf/private/pkg/app/appext"
3031
"github.com/bufbuild/buf/private/pkg/slicesext"
@@ -220,7 +221,11 @@ func run(
220221
for i, imageWithConfig := range imageWithConfigs {
221222
client, err := bufcheck.NewClient(
222223
container.Logger(),
223-
bufcheck.NewRunnerProvider(wasmRuntime),
224+
bufcheck.NewLocalRunnerProvider(
225+
wasmRuntime,
226+
bufplugin.NopPluginKeyProvider,
227+
bufplugin.NopPluginDataProvider,
228+
),
224229
bufcheck.ClientWithStderr(container.Stderr()),
225230
)
226231
if err != nil {

private/buf/cmd/buf/command/config/internal/internal.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/bufbuild/buf/private/buf/bufcli"
2525
"github.com/bufbuild/buf/private/bufpkg/bufcheck"
2626
"github.com/bufbuild/buf/private/bufpkg/bufconfig"
27+
"github.com/bufbuild/buf/private/bufpkg/bufplugin"
2728
"github.com/bufbuild/buf/private/pkg/app/appcmd"
2829
"github.com/bufbuild/buf/private/pkg/app/appext"
2930
"github.com/bufbuild/buf/private/pkg/normalpath"
@@ -196,7 +197,11 @@ func lsRun(
196197
}()
197198
client, err := bufcheck.NewClient(
198199
container.Logger(),
199-
bufcheck.NewRunnerProvider(wasmRuntime),
200+
bufcheck.NewLocalRunnerProvider(
201+
wasmRuntime,
202+
bufplugin.NopPluginKeyProvider,
203+
bufplugin.NopPluginDataProvider,
204+
),
200205
bufcheck.ClientWithStderr(container.Stderr()),
201206
)
202207
if err != nil {

private/buf/cmd/buf/command/lint/lint.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/bufbuild/buf/private/buf/bufctl"
2424
"github.com/bufbuild/buf/private/bufpkg/bufanalysis"
2525
"github.com/bufbuild/buf/private/bufpkg/bufcheck"
26+
"github.com/bufbuild/buf/private/bufpkg/bufplugin"
2627
"github.com/bufbuild/buf/private/pkg/app/appcmd"
2728
"github.com/bufbuild/buf/private/pkg/app/appext"
2829
"github.com/bufbuild/buf/private/pkg/stringutil"
@@ -145,7 +146,11 @@ func run(
145146
for _, imageWithConfig := range imageWithConfigs {
146147
client, err := bufcheck.NewClient(
147148
container.Logger(),
148-
bufcheck.NewRunnerProvider(wasmRuntime),
149+
bufcheck.NewLocalRunnerProvider(
150+
wasmRuntime,
151+
bufplugin.NopPluginKeyProvider,
152+
bufplugin.NopPluginDataProvider,
153+
),
149154
bufcheck.ClientWithStderr(container.Stderr()),
150155
)
151156
if err != nil {

private/buf/cmd/buf/command/mod/internal/internal.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/bufbuild/buf/private/buf/bufcli"
2525
"github.com/bufbuild/buf/private/bufpkg/bufcheck"
2626
"github.com/bufbuild/buf/private/bufpkg/bufconfig"
27+
"github.com/bufbuild/buf/private/bufpkg/bufplugin"
2728
"github.com/bufbuild/buf/private/pkg/app/appcmd"
2829
"github.com/bufbuild/buf/private/pkg/app/appext"
2930
"github.com/bufbuild/buf/private/pkg/slicesext"
@@ -175,7 +176,11 @@ func lsRun(
175176
// BufYAMLFiles <=v1 never had plugins.
176177
client, err := bufcheck.NewClient(
177178
container.Logger(),
178-
bufcheck.NewRunnerProvider(wasm.UnimplementedRuntime),
179+
bufcheck.NewLocalRunnerProvider(
180+
wasm.UnimplementedRuntime,
181+
bufplugin.NopPluginKeyProvider,
182+
bufplugin.NopPluginDataProvider,
183+
),
179184
bufcheck.ClientWithStderr(container.Stderr()),
180185
)
181186
if err != nil {

private/buf/cmd/buf/command/plugin/pluginpush/pluginpush.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ func upload(
151151
var err error
152152
plugin, err = bufplugin.NewLocalWasmPlugin(
153153
pluginFullName,
154+
nil, // args
154155
func() ([]byte, error) {
155156
wasmBinary, err := os.ReadFile(flags.Binary)
156157
if err != nil {

private/buf/cmd/protoc-gen-buf-breaking/breaking.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/bufbuild/buf/private/bufpkg/bufanalysis"
2929
"github.com/bufbuild/buf/private/bufpkg/bufcheck"
3030
"github.com/bufbuild/buf/private/bufpkg/bufimage"
31+
"github.com/bufbuild/buf/private/bufpkg/bufplugin"
3132
"github.com/bufbuild/buf/private/pkg/encoding"
3233
"github.com/bufbuild/buf/private/pkg/protodescriptor"
3334
"github.com/bufbuild/buf/private/pkg/protoencoding"
@@ -125,7 +126,11 @@ func handle(
125126
// The protoc plugins do not support custom lint/breaking change plugins for now.
126127
client, err := bufcheck.NewClient(
127128
container.Logger(),
128-
bufcheck.NewRunnerProvider(wasm.UnimplementedRuntime),
129+
bufcheck.NewLocalRunnerProvider(
130+
wasm.UnimplementedRuntime,
131+
bufplugin.NopPluginKeyProvider,
132+
bufplugin.NopPluginDataProvider,
133+
),
129134
bufcheck.ClientWithStderr(pluginEnv.Stderr),
130135
)
131136
if err != nil {

private/buf/cmd/protoc-gen-buf-lint/lint.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"github.com/bufbuild/buf/private/bufpkg/bufanalysis"
2828
"github.com/bufbuild/buf/private/bufpkg/bufcheck"
2929
"github.com/bufbuild/buf/private/bufpkg/bufimage"
30+
"github.com/bufbuild/buf/private/bufpkg/bufplugin"
3031
"github.com/bufbuild/buf/private/pkg/encoding"
3132
"github.com/bufbuild/buf/private/pkg/protodescriptor"
3233
"github.com/bufbuild/buf/private/pkg/protoencoding"
@@ -100,7 +101,11 @@ func handle(
100101
// The protoc plugins do not support custom lint/breaking change plugins for now.
101102
client, err := bufcheck.NewClient(
102103
container.Logger(),
103-
bufcheck.NewRunnerProvider(wasm.UnimplementedRuntime),
104+
bufcheck.NewLocalRunnerProvider(
105+
wasm.UnimplementedRuntime,
106+
bufplugin.NopPluginKeyProvider,
107+
bufplugin.NopPluginDataProvider,
108+
),
104109
bufcheck.ClientWithStderr(pluginEnv.Stderr),
105110
)
106111
if err != nil {

0 commit comments

Comments
 (0)