buf: github.com/bufbuild/buf/internal/pkg/app/appproto/appprotoexec Index | Files

package appprotoexec

import "github.com/bufbuild/buf/internal/pkg/app/appproto/appprotoexec"

Package appprotoexec provides protoc plugin handling and execution.

Note this is currently implicitly tested through buf's protoc command. If this were split out into a separate package, testing would need to be moved to this package.


Package Files

appprotoexec.go binary_handler.go normalize.go protoc_proxy_handler.go


const (
    // DefaultMajorVersion is the default major version.
    DefaultMajorVersion = 3
    // DefaultMinorVersion is the default minor version.
    DefaultMinorVersion = 13
    // DefaultPatchVersion is the default patch version.
    DefaultPatchVersion = 0
    // DefaultSuffixVersion is the default suffix version.
    DefaultSuffixVersion = ""


var (
    // ProtocProxyPluginNames are the names of the plugins that should be proxied through protoc
    // in the absence of a binary.
    ProtocProxyPluginNames = map[string]struct{}{
        "cpp":    {},
        "csharp": {},
        "java":   {},
        "js":     {},
        "objc":   {},
        "php":    {},
        "python": {},
        "ruby":   {},

func NewHandler Uses

func NewHandler(
    logger *zap.Logger,
    pluginName string,
    options ...HandlerOption,
) (appproto.Handler, error)

NewHandler returns a new Handler based on the plugin name and optional path.

protocPath and pluginPath are optional.

- If the plugin path is set, this returns a new binary handler for that path. - If the plugin path is unset, this does exec.LookPath for a binary named protoc-gen-pluginName,

and if one is found, a new binary handler is returned for this.

- Else, if the name is in ProtocProxyPluginNames, this returns a new protoc proxy handler. - Else, this returns error.

type HandlerOption Uses

type HandlerOption func(*handlerOptions)

HandlerOption is an option for a new Handler.

func HandlerWithPluginPath Uses

func HandlerWithPluginPath(pluginPath string) HandlerOption

HandlerWithPluginPath returns a new HandlerOption that sets the path to the plugin binary.

The default is to do exec.LookPath on "protoc-gen-" + pluginName.

func HandlerWithProtocPath Uses

func HandlerWithProtocPath(protocPath string) HandlerOption

HandlerWithProtocPath returns a new HandlerOption that sets the path to the protoc binary.

The default is to do exec.LookPath on "protoc".

Package appprotoexec imports 22 packages (graph) and is imported by 1 packages. Updated 2020-10-20. Refresh now. Tools for package owners.