Documentation
¶
Index ¶
- Constants
- Variables
- type Controller
- type ControllerOption
- type FunctionOption
- func WithConfigOverride(configOverride string) FunctionOption
- func WithIgnoreAndDisallowV1BufWorkYAMLs() FunctionOption
- func WithImageAsFileDescriptorSet(imageAsFileDescriptorSet bool) FunctionOption
- func WithImageExcludeImports(imageExcludeImports bool) FunctionOption
- func WithImageExcludeSourceInfo(imageExcludeSourceInfo bool) FunctionOption
- func WithImageExcludeTypes(imageExcludeTypes []string) FunctionOption
- func WithImageIncludeTypes(imageTypes []string) FunctionOption
- func WithMessageValidation() FunctionOption
- func WithTargetPaths(targetPaths []string, targetExcludePaths []string) FunctionOption
- type ImageWithConfig
Constants ¶
const ( // ExitCodeFileAnnotation is the exit code used when we print file annotations. // // We use a different exit code to be able to distinguish user-parsable errors from system errors. // // TODO FUTURE: Rename to something like "ExitCodeCompileError" as we use this for ImportNotExistErrors as well. ExitCodeFileAnnotation = 100 )
Variables ¶
var ( // ErrFileAnnotation is used when we print file annotations and want to return an error. // // The app package works on the concept that an error results in a non-zero exit // code, and we already print the messages with PrintFileAnnotations, so we do // not want to print any additional error message. // // We also exit with 100 to be able to distinguish user-parsable errors from system errors. ErrFileAnnotation = app.NewError(ExitCodeFileAnnotation, "") )
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller interface {
GetWorkspace(
ctx context.Context,
sourceOrModuleInput string,
options ...FunctionOption,
) (bufworkspace.Workspace, error)
GetWorkspaceDepManager(
ctx context.Context,
dirPath string,
options ...FunctionOption,
) (bufworkspace.WorkspaceDepManager, error)
GetImage(
ctx context.Context,
input string,
options ...FunctionOption,
) (bufimage.Image, error)
GetImageForInputConfig(
ctx context.Context,
inputConfig bufconfig.InputConfig,
options ...FunctionOption,
) (bufimage.Image, error)
GetImageForWorkspace(
ctx context.Context,
workspace bufworkspace.Workspace,
options ...FunctionOption,
) (bufimage.Image, error)
// GetTargetImageWithConfigsAndCheckClient gets the target ImageWithConfigs
// with a configured bufcheck Client.
//
// ImageWithConfig scopes the configuration per image for use with breaking
// and lint checks. The check Client is bound to the input to ensure that the
// correct remote plugin dependencies are used. A wasmRuntime is provided
// to evaluate Wasm plugins.
GetTargetImageWithConfigsAndCheckClient(
ctx context.Context,
input string,
wasmRuntime wasm.Runtime,
options ...FunctionOption,
) ([]ImageWithConfig, bufcheck.Client, error)
// GetImportableImageFileInfos gets the importable .proto FileInfos for the given input.
//
// This includes all files that can be possible imported. For example, if a Module
// is given, this will return FileInfos for the Module, its dependencies, and all of
// the Well-Known Types.
//
// Returned ImageFileInfos are sorted by Path.
GetImportableImageFileInfos(
ctx context.Context,
input string,
options ...FunctionOption,
) ([]bufimage.ImageFileInfo, error)
PutImage(
ctx context.Context,
imageOutput string,
image bufimage.Image,
options ...FunctionOption,
) error
GetMessage(
ctx context.Context,
schemaImage bufimage.Image,
messageInput string,
typeName string,
defaultMessageEncoding buffetch.MessageEncoding,
options ...FunctionOption,
) (proto.Message, buffetch.MessageEncoding, error)
PutMessage(
ctx context.Context,
schemaImage bufimage.Image,
messageOutput string,
message proto.Message,
defaultMessageEncoding buffetch.MessageEncoding,
options ...FunctionOption,
) error
// GetCheckClientForWorkspace returns a new bufcheck Client for the given Workspace.
//
// Clients are bound to a specific Workspace to ensure that the correct
// plugin dependencies are used. A wasmRuntime is provided to evaluate
// Wasm plugins.
GetCheckClientForWorkspace(
ctx context.Context,
workspace bufworkspace.Workspace,
wasmRuntime wasm.Runtime,
) (bufcheck.Client, error)
}
Controller is the central entrypoint for the Buf CLI.
func NewController ¶
func NewController( logger *slog.Logger, container app.EnvStdioContainer, graphProvider bufmodule.GraphProvider, moduleKeyProvider bufmodule.ModuleKeyProvider, moduleDataProvider bufmodule.ModuleDataProvider, commitProvider bufmodule.CommitProvider, pluginKeyProvider bufplugin.PluginKeyProvider, pluginDataProvider bufplugin.PluginDataProvider, policyKeyProvider bufpolicy.PolicyKeyProvider, policyDataProvider bufpolicy.PolicyDataProvider, wktStore bufwktstore.Store, httpClient *http.Client, httpauthAuthenticator httpauth.Authenticator, gitClonerOptions git.ClonerOptions, options ...ControllerOption, ) (Controller, error)
NewController returns a new Controller.
type ControllerOption ¶
type ControllerOption func(*controller)
ControllerOption is a controller option.
func WithCopyToInMemory ¶
func WithCopyToInMemory() ControllerOption
WithCopyToInMemory returns a new ControllerOption that copies to memory.
func WithDisableSymlinks ¶
func WithDisableSymlinks(disableSymlinks bool) ControllerOption
WithDisableSymlinks returns a new ControllerOption that
func WithFileAnnotationErrorFormat ¶
func WithFileAnnotationErrorFormat(fileAnnotationErrorFormat string) ControllerOption
WithFileAnnotationErrorFormat returns a new ControllerOption that sets the FileAnnotation format.
func WithFileAnnotationsToStdout ¶
func WithFileAnnotationsToStdout() ControllerOption
WithFileAnnotationsToStdout returns a new ControllerOption that sends FileAnnotations to stdout
type FunctionOption ¶
type FunctionOption func(*functionOptions)
FunctionOption is an option for a function in a Controller.
TODO FUTURE: split up to per-function.
func WithConfigOverride ¶
func WithConfigOverride(configOverride string) FunctionOption
WithConfigOverride applies the config override.
This flag will only work if no buf.work.yaml is detected, and the buf.yaml is a v1beta1 buf.yaml, v1 buf.yaml, or no buf.yaml. This flag will not work if a buf.work.yaml is detected, or a v2 buf.yaml is detected.
If used with an image or module ref, this has no effect on the build, i.e. excludes are not respected, and the module name is ignored. This matches old behavior.
This implements the soon-to-be-deprecated --config flag.
See bufconfig.GetBufYAMLFileForPrefixOrOverride for more details.
*** DO NOT USE THIS OUTSIDE OF THE CLI AND/OR IF YOU DON'T UNDERSTAND IT. *** *** DO NOT ADD THIS TO ANY NEW COMMANDS. ***
Current commands that use this: build, breaking, lint, generate, format, export, ls-breaking-rules, ls-lint-rules.
func WithIgnoreAndDisallowV1BufWorkYAMLs ¶
func WithIgnoreAndDisallowV1BufWorkYAMLs() FunctionOption
WithIgnoreAndDisallowV1BufWorkYAMLs returns a new FunctionOption that says to ignore dependencies from buf.work.yamls at the root of the bucket, and to also disallow directories with buf.work.yamls to be directly targeted.
See bufworkspace.WithIgnoreAndDisallowV1BufWorkYAMLs for more details.
func WithImageAsFileDescriptorSet ¶
func WithImageAsFileDescriptorSet(imageAsFileDescriptorSet bool) FunctionOption
WithImageAsFileDescriptorSet returns a new FunctionOption that returns the image as a FileDescriptorSet.
func WithImageExcludeImports ¶
func WithImageExcludeImports(imageExcludeImports bool) FunctionOption
WithImageExcludeImports returns a new FunctionOption that excludes imports.
func WithImageExcludeSourceInfo ¶
func WithImageExcludeSourceInfo(imageExcludeSourceInfo bool) FunctionOption
WithImageExcludeSourceInfo returns a new FunctionOption that excludes source code info.
func WithImageExcludeTypes ¶ added in v1.51.0
func WithImageExcludeTypes(imageExcludeTypes []string) FunctionOption
WithImageExcludeTypes returns a new FunctionOption that excludes the given types.
func WithImageIncludeTypes ¶ added in v1.51.0
func WithImageIncludeTypes(imageTypes []string) FunctionOption
WithImageIncludeTypes returns a new FunctionOption that includes the given types.
func WithMessageValidation ¶
func WithMessageValidation() FunctionOption
WithMessageValidation returns a new FunctionOption that says to validate the message as it is being read.
We want to do this as part of the read/unmarshal, as protoyaml has specific logic on unmarshal that will pretty print validations.
func WithTargetPaths ¶
func WithTargetPaths(targetPaths []string, targetExcludePaths []string) FunctionOption
WithTargetPaths returns a new FunctionOption that sets the target paths.
type ImageWithConfig ¶
type ImageWithConfig interface {
bufimage.Image
ModuleFullName() bufparse.FullName
ModuleOpaqueID() string
LintConfig() bufconfig.LintConfig
BreakingConfig() bufconfig.BreakingConfig
PluginConfigs() []bufconfig.PluginConfig
PolicyConfigs() []bufconfig.PolicyConfig
// contains filtered or unexported methods
}
ImageWithConfig pairs an Image with its corresponding bufmodule.Module full name (which may be nil), bufmodule.Module opaque ID, and lint and breaking configurations.