Skip to content

Commit

Permalink
Fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
emcfarlane committed Dec 18, 2024
1 parent 6dda977 commit 662ae5f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 27 deletions.
10 changes: 5 additions & 5 deletions private/buf/bufctl/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ type Controller interface {
defaultMessageEncoding buffetch.MessageEncoding,
options ...FunctionOption,
) error
// NewCheckClient returns a new CheckClient for the given input.
// NewCheckClient returns a new bufcheck.Client for the given input.
//
// CheckClients are bound to a specific input to ensure that the correct
// Clients are bound to a specific input to ensure that the correct
// plugin dependencies are used. Where the input is resolvable to a
// Workspace, this function wraps NewCheckClientForWorkspace. For
// message inputs, the local directory or config override is used.
Expand All @@ -142,9 +142,9 @@ type Controller interface {
wasmRuntime wasm.Runtime,
options ...FunctionOption,
) (bufcheck.Client, error)
// NewCheckClientForWorkspace returns a new CheckClient for the given Workspace.
// NewCheckClientForWorkspace returns a new bufcheck.Client for the given Workspace.
//
// CheckClients are bound to a specific Workspace to ensure that the correct
// Clients are bound to a specific Workspace to ensure that the correct
// plugin dependencies are used.
NewCheckClientForWorkspace(
ctx context.Context,
Expand Down Expand Up @@ -1334,7 +1334,7 @@ func (c *controller) getPluginKeyProviderForDirPath(
}
pluginConfigs = bufYAMLFile.PluginConfigs()
if len(pluginConfigs) == 0 || bufYAMLFile.FileVersion() != bufconfig.FileVersionV2 {
// No plugins were found or are supported by the current version.
// No plugins were found or they are not supported by the current version.
return bufplugin.NopPluginKeyProvider, nil
}
bufLockFile, err := bufconfig.GetBufLockFileForPrefix(
Expand Down
11 changes: 1 addition & 10 deletions private/bufpkg/bufconfig/plugin_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,7 @@ type PluginConfigType int
type PluginConfig interface {
// Type returns the plugin type. This is never the zero value.
Type() PluginConfigType
// Name returns the plugin name.
//
// If the plugin is of Type PluginConfigTypeLocal, the Name is the command
// name or path to the command.
// If the plugin is of Type PluginConfigTypeLocalWasm, the Name is the
// path to the Wasm file. It must end with .wasm.
// If the plugin is of Type PluginConfigTypeRemoteWasm, the Name is a
// vaild bufparse.Ref and Ref returns the plugin reference.
//
// This is never empty.
// Name returns the plugin name. This is never empty.
Name() string
// Options returns the plugin options.
//
Expand Down
29 changes: 17 additions & 12 deletions private/bufpkg/bufplugin/plugin_key_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,7 @@ type PluginKeyProvider interface {
// When resolving Refs, the Ref will be matched to the PluginKey by FullName.
// If the Ref is not found in the set of provided keys, an fs.ErrNotExist will be returned.
func NewStaticPluginKeyProvider(pluginKeys []PluginKey) (PluginKeyProvider, error) {
if len(pluginKeys) == 0 {
return NopPluginKeyProvider, nil
}
pluginKeysByFullName, err := slicesext.ToUniqueValuesMap(pluginKeys, func(pluginKey PluginKey) string {
return pluginKey.FullName().String()
})
if err != nil {
return nil, err
}
return staticPluginKeyProvider{
pluginKeysByFullName: pluginKeysByFullName,
}, nil
return newStaticPluginKeyProvider(pluginKeys)
}

// *** PRIVATE ***
Expand All @@ -81,6 +70,22 @@ type staticPluginKeyProvider struct {
pluginKeysByFullName map[string]PluginKey
}

func newStaticPluginKeyProvider(pluginKeys []PluginKey) (*staticPluginKeyProvider, error) {
var pluginKeysByFullName map[string]PluginKey
if len(pluginKeys) > 0 {
var err error
pluginKeysByFullName, err = slicesext.ToUniqueValuesMap(pluginKeys, func(pluginKey PluginKey) string {
return pluginKey.FullName().String()
})
if err != nil {
return nil, err
}
}
return &staticPluginKeyProvider{
pluginKeysByFullName: pluginKeysByFullName,
}, nil
}

func (s staticPluginKeyProvider) GetPluginKeysForPluginRefs(
_ context.Context,
refs []bufparse.Ref,
Expand Down

0 comments on commit 662ae5f

Please sign in to comment.