Skip to content

Commit

Permalink
Resolve plugins dynamically for ls-rules
Browse files Browse the repository at this point in the history
  • Loading branch information
emcfarlane committed Dec 11, 2024
1 parent 45f312e commit 39f6d81
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
7 changes: 3 additions & 4 deletions private/buf/bufworkspace/workspace_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,9 @@ func (w *workspaceProvider) GetWorkspaceForModuleKey(
}
if bufYAMLFile.FileVersion() == bufconfig.FileVersionV2 {
pluginConfigs = bufYAMLFile.PluginConfigs()
// To support remote plugins in the override, we need to
// resolve the remote Refs to PluginKeys. A buf.lock file
// is not expected to be present so we require the
// pluginKeyProvider to resolve these PluginKeys.
// To support remote plugins in the override, we need to resolve the remote
// Refs to PluginKeys. A buf.lock file is not required for this operation.
// We use the BSR to resolve any remote plugin Refs.
remotePluginRefs := slicesext.Filter(
slicesext.Map(pluginConfigs, func(pluginConfig bufconfig.PluginConfig) bufparse.Ref {
return pluginConfig.Ref()
Expand Down
13 changes: 12 additions & 1 deletion private/buf/cmd/buf/command/config/internal/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,20 @@ func lsRun(
defer func() {
retErr = errors.Join(retErr, wasmRuntime.Close(ctx))
}()
// To support remote plugins in the override, we need to resolve the remote
// Refs to PluginKeys. A buf.lock file is not required for this operation.
// We use the BSR to resolve any remote plugin Refs.
pluginKeyProvider, err := bufcli.NewPluginKeyProvider(container)
if err != nil {
return err
}
pluginDataProvider, err := bufcli.NewPluginDataProvider(container)
if err != nil {
return err
}
client, err := bufcheck.NewClient(
container.Logger(),
bufcheck.NewLocalRunnerProvider(wasmRuntime, bufplugin.NopPluginKeyProvider, bufplugin.NopPluginDataProvider),
bufcheck.NewLocalRunnerProvider(wasmRuntime, pluginKeyProvider, pluginDataProvider),
bufcheck.ClientWithStderr(container.Stderr()),
)
if err != nil {
Expand Down

0 comments on commit 39f6d81

Please sign in to comment.