Documentation ¶
Index ¶
- Constants
- Variables
- func BindAsFileDescriptorSet(flagSet *pflag.FlagSet, addr *bool, flagName string)
- func BindExcludeImports(flagSet *pflag.FlagSet, addr *bool, flagName string)
- func BindExcludeSourceInfo(flagSet *pflag.FlagSet, addr *bool, flagName string)
- func BindInputHashtag(flagSet *pflag.FlagSet, addr *string)
- func BindPaths(flagSet *pflag.FlagSet, pathsAddr *[]string, pathsFlagName string)
- func BindPathsAndDeprecatedFiles(flagSet *pflag.FlagSet, pathsAddr *[]string, pathsFlagName string, ...)
- func GetInputLong(inputArgDescription string) string
- func GetInputValue(container appflag.Container, inputHashtag string, deprecatedFlag string, ...) (string, error)
- func GetSourceOrModuleLong(inputArgDescription string) string
- func GetStringFlagOrDeprecatedFlag(flag string, flagName string, deprecatedFlag string, deprecatedFlagName string) (string, error)
- func GetStringSliceFlagOrDeprecatedFlag(flag []string, flagName string, deprecatedFlag []string, ...) ([]string, error)
- func NewBranchOrTagNameAlreadyExistsError(name string) error
- func NewConfig(container appflag.Container) (*bufapp.Config, error)
- func NewContextModifierProvider(container appflag.Container) func(string) (func(context.Context) context.Context, error)
- func NewErrorInterceptor() appflag.Interceptor
- func NewInternalError(err error) error
- func NewModuleReaderAndCreateCacheDirs(container appflag.Container, ...) (bufmodule.ModuleReader, error)
- func NewModuleRefError(moduleRef string) error
- func NewModuleReferenceNotFoundError(reference bufmodule.ModuleReference) error
- func NewOrganizationNameAlreadyExistsError(name string) error
- func NewOrganizationNotFoundError(name string) error
- func NewPluginNotFoundError(owner string, name string) error
- func NewRegistryProvider(ctx context.Context, container appflag.Container) (registryv1alpha1apiclient.Provider, error)
- func NewRepositoryNameAlreadyExistsError(name string) error
- func NewRepositoryNotFoundError(name string) error
- func NewTemplateNotFoundError(owner string, name string) error
- func NewTokenNotFoundError(tokenID string) error
- func NewTooManyEmptyAnswersError(attempts int) error
- func NewUnimplementedRemoteError(err error, remote string, moduleIdentity string) error
- func NewWireFileLister(container appflag.Container, storageosProvider storageos.Provider, ...) (bufwire.FileLister, error)
- func NewWireImageConfigReader(container appflag.Container, storageosProvider storageos.Provider, ...) (bufwire.ImageConfigReader, error)
- func NewWireImageReader(logger *zap.Logger, storageosProvider storageos.Provider) bufwire.ImageReader
- func NewWireImageWriter(logger *zap.Logger) bufwire.ImageWriter
- func NewWireModuleConfigReader(container appflag.Container, storageosProvider storageos.Provider, ...) (bufwire.ModuleConfigReader, error)
- func NewWireModuleConfigReaderForModuleReader(container appflag.Container, storageosProvider storageos.Provider, ...) (bufwire.ModuleConfigReader, error)
- func PromptUser(container app.Container, prompt string) (string, error)
- func PromptUserForDelete(container app.Container, entityType string, expectedAnswer string) error
- func PromptUserForPassword(container app.Container, prompt string) (string, error)
- func ReadModuleWithWorkspacesDisabled(ctx context.Context, container appflag.Container, ...) (bufmodule.Module, bufmodule.ModuleIdentity, error)
- func ValidateErrorFormatFlag(errorFormatString string, errorFormatFlagName string) error
- func ValidateErrorFormatFlagLint(errorFormatString string, errorFormatFlagName string) error
- type GlobalFlags
Constants ¶
const ( // Version is the CLI version of buf. Version = "0.52.0" // FlagDeprecationMessageSuffix is the suffix for flag deprecation messages. FlagDeprecationMessageSuffix = ` We recommend migrating, however this flag continues to work. See https://docs.buf.build/faq for more details.` )
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. ExitCodeFileAnnotation = 100 )
Variables ¶
var ( // AllCacheModuleRelDirPaths are all directory paths for all time concerning the module cache. // // These are normalized. // These are relative to container.CacheDirPath(). // // This variable is used for clearing the cache. AllCacheModuleRelDirPaths = []string{ v1beta1CacheModuleDataRelDirPath, v1beta1CacheModuleLockRelDirPath, v1CacheModuleDataRelDirPath, v1CacheModuleLockRelDirPath, v1CacheModuleSumRelDirPath, } // ErrNotATTY is returned when an input io.Reader is not a TTY where it is expected. ErrNotATTY = errors.New("reader was not a TTY as expected") )
var ( // ErrNoModuleName is used when the user does not specify a module name in their configuration file. ErrNoModuleName = errors.New(`please specify a module name in your configuration file with the "name" key`) // ErrNoConfigFile is used when the user tries to execute a command without a configuration file. ErrNoConfigFile = errors.New(`please define a configuration file in the current directory; you can create one by running "buf mod init"`) // 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 ¶
func BindAsFileDescriptorSet ¶ added in v0.30.1
BindAsFileDescriptorSet binds the exclude-imports flag.
func BindExcludeImports ¶ added in v0.30.1
BindExcludeImports binds the exclude-imports flag.
func BindExcludeSourceInfo ¶ added in v0.30.1
BindExcludeSourceInfo binds the exclude-source-info flag.
func BindInputHashtag ¶ added in v0.30.1
BindInputHashtag binds the input hashtag flag.
This needs to be added to any command that has the input as the first argument. This deals with the situation "buf build -#format=json" which results in a parse error from pflag.
func BindPathsAndDeprecatedFiles ¶ added in v0.31.0
func BindPathsAndDeprecatedFiles( flagSet *pflag.FlagSet, pathsAddr *[]string, pathsFlagName string, filesAddr *[]string, filesFlagName string, )
BindPathAndDeprecatedFiles binds the paths flag and the deprecated files flag.
func GetInputLong ¶ added in v0.30.1
GetInputLong gets the long command description for an input-based command.
func GetInputValue ¶ added in v0.30.1
func GetInputValue( container appflag.Container, inputHashtag string, deprecatedFlag string, deprecatedFlagName string, defaultValue string, ) (string, error)
GetInputValue gets either the first arg or the deprecated flag, but not both.
Also parses the special input hashtag flag that deals with the situation "buf build -#format=json". The existence of 0 or 1 args should be handled by the Args field on Command.
func GetSourceOrModuleLong ¶ added in v0.30.1
GetSourceOrModuleLong gets the long command description for an input-based command.
func GetStringFlagOrDeprecatedFlag ¶ added in v0.31.0
func GetStringFlagOrDeprecatedFlag( flag string, flagName string, deprecatedFlag string, deprecatedFlagName string, ) (string, error)
GetStringFlagOrDeprecatedFlag gets the flag, or the deprecated flag.
func GetStringSliceFlagOrDeprecatedFlag ¶ added in v0.31.0
func GetStringSliceFlagOrDeprecatedFlag( flag []string, flagName string, deprecatedFlag []string, deprecatedFlagName string, ) ([]string, error)
GetStringSliceFlagOrDeprecatedFlag gets the flag, or the deprecated flag.
func NewBranchOrTagNameAlreadyExistsError ¶ added in v0.40.0
NewBranchOrTagNameAlreadyExistsError informs the user that a branch or tag with that name already exists.
func NewContextModifierProvider ¶ added in v0.37.1
func NewContextModifierProvider( container appflag.Container, ) func(string) (func(context.Context) context.Context, error)
NewContextModifierProvider returns a new context modifier provider for API providers.
Public for use in other packages that provide API provider constructors.
func NewErrorInterceptor ¶ added in v0.37.1
func NewErrorInterceptor() appflag.Interceptor
NewErrorInterceptor returns a CLI interceptor that wraps Buf CLI errors.
func NewInternalError ¶ added in v0.37.0
NewInternalError represents an internal error encountered by the buf CLI. These errors should not happen and therefore warrant a bug report.
func NewModuleReaderAndCreateCacheDirs ¶ added in v0.45.0
func NewModuleReaderAndCreateCacheDirs( container appflag.Container, registryProvider registryv1alpha1apiclient.Provider, ) (bufmodule.ModuleReader, error)
NewModuleReaderAndCreateCacheDirs returns a new ModuleReader while creating the required cache directories.
func NewModuleRefError ¶ added in v0.37.0
NewModuleRefError is used when the client fails to parse a module ref.
func NewModuleReferenceNotFoundError ¶ added in v0.40.0
func NewModuleReferenceNotFoundError(reference bufmodule.ModuleReference) error
NewModuleReferenceNotFoundError informs the user that a module reference does not exist.
func NewOrganizationNameAlreadyExistsError ¶ added in v0.37.0
NewOrganizationNameAlreadyExistsError informs the user that an organization with that name already exists.
func NewOrganizationNotFoundError ¶ added in v0.37.0
NewOrganizationNotFoundError informs the user that an organization with that name does not exist.
func NewPluginNotFoundError ¶ added in v0.45.0
NewPluginNotFoundError informs the user that a plugin with that owner and name does not exist.
func NewRegistryProvider ¶ added in v0.37.0
func NewRegistryProvider(ctx context.Context, container appflag.Container) (registryv1alpha1apiclient.Provider, error)
NewRegistryProvider creates a new registryv1alpha1apiclient.Provider.
func NewRepositoryNameAlreadyExistsError ¶ added in v0.37.0
NewRepositoryNameAlreadyExistsError informs the user that a repository with that name already exists.
func NewRepositoryNotFoundError ¶ added in v0.37.0
NewRepositoryNotFoundError informs the user that a repository with that name does not exist.
func NewTemplateNotFoundError ¶ added in v0.45.0
NewTemplateNotFoundError informs the user that a template with that owner and name does not exist.
func NewTokenNotFoundError ¶ added in v0.37.0
NewTokenNotFoundError informs the user that a token with that identifier does not exist.
func NewTooManyEmptyAnswersError ¶ added in v0.37.0
NewTooManyEmptyAnswersError is used when the user does not answer a prompt in the given number of attempts.
func NewUnimplementedRemoteError ¶ added in v0.45.0
func NewWireFileLister ¶ added in v0.25.0
func NewWireFileLister( container appflag.Container, storageosProvider storageos.Provider, registryProvider registryv1alpha1apiclient.Provider, ) (bufwire.FileLister, error)
NewWireFileLister returns a new FileLister.
func NewWireImageConfigReader ¶ added in v0.30.1
func NewWireImageConfigReader( container appflag.Container, storageosProvider storageos.Provider, registryProvider registryv1alpha1apiclient.Provider, ) (bufwire.ImageConfigReader, error)
NewWireImageConfigReader returns a new ImageConfigReader.
func NewWireImageReader ¶ added in v0.25.0
func NewWireImageReader( logger *zap.Logger, storageosProvider storageos.Provider, ) bufwire.ImageReader
NewWireImageReader returns a new ImageReader.
func NewWireImageWriter ¶ added in v0.25.0
func NewWireImageWriter( logger *zap.Logger, ) bufwire.ImageWriter
NewWireImageWriter returns a new ImageWriter.
func NewWireModuleConfigReader ¶ added in v0.30.1
func NewWireModuleConfigReader( container appflag.Container, storageosProvider storageos.Provider, registryProvider registryv1alpha1apiclient.Provider, ) (bufwire.ModuleConfigReader, error)
NewWireModuleConfigReader returns a new ModuleConfigReader.
func NewWireModuleConfigReaderForModuleReader ¶ added in v0.48.0
func NewWireModuleConfigReaderForModuleReader( container appflag.Container, storageosProvider storageos.Provider, registryProvider registryv1alpha1apiclient.Provider, moduleReader bufmodule.ModuleReader, ) (bufwire.ModuleConfigReader, error)
NewWireModuleConfigReaderForModuleReader returns a new ModuleConfigReader using the given ModuleReader.
func PromptUser ¶ added in v0.46.0
PromptUser reads a line from Stdin, prompting the user with the prompt first. The prompt is repeatedly shown until the user provides a non-empty response. ErrNotATTY is returned if the input containers Stdin is not a terminal.
func PromptUserForDelete ¶ added in v0.37.0
PromptUserForDelete is used to receieve user confirmation that a specific entity should be deleted. If the user's answer does not match the expected answer, an error is returned. ErrNotATTY is returned if the input containers Stdin is not a terminal.
func PromptUserForPassword ¶ added in v0.46.0
PromptUserForPassword reads a line from Stdin, prompting the user with the prompt first. The prompt is repeatedly shown until the user provides a non-empty response. ErrNotATTY is returned if the input containers Stdin is not a terminal.
func ReadModuleWithWorkspacesDisabled ¶ added in v0.45.0
func ReadModuleWithWorkspacesDisabled( ctx context.Context, container appflag.Container, storageosProvider storageos.Provider, source string, ) (bufmodule.Module, bufmodule.ModuleIdentity, error)
ReadModuleWithWorkspacesDisabled gets a module from a source ref.
Workspaces are disabled for this function.
func ValidateErrorFormatFlag ¶ added in v0.46.0
ValidateErrorFormatFlag validates the error format flag for all commands but lint.
func ValidateErrorFormatFlagLint ¶ added in v0.46.0
ValidateErrorFormatFlagLint validates the error format flag for lint.
Types ¶
type GlobalFlags ¶ added in v0.45.0
type GlobalFlags struct{}
GlobalFlags contains global flags for buf commands.
func NewGlobalFlags ¶ added in v0.45.0
func NewGlobalFlags() *GlobalFlags
NewGlobalFlags creates a new GlobalFlags with default values..
func (*GlobalFlags) BindRoot ¶ added in v0.45.0
func (*GlobalFlags) BindRoot(*pflag.FlagSet)
BindRoot binds the global flags to the root command flag set.