bufcli

package
v0.43.3-0...-9926edd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2021 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Version is the version of buf.
	Version = "0.44.0-dev"

	// 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.`
)
View Source
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

View Source
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 beta 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

func BindAsFileDescriptorSet(flagSet *pflag.FlagSet, addr *bool, flagName string)

BindAsFileDescriptorSet binds the exclude-imports flag.

func BindExcludeImports

func BindExcludeImports(flagSet *pflag.FlagSet, addr *bool, flagName string)

BindExcludeImports binds the exclude-imports flag.

func BindExcludeSourceInfo

func BindExcludeSourceInfo(flagSet *pflag.FlagSet, addr *bool, flagName string)

BindExcludeSourceInfo binds the exclude-source-info flag.

func BindInputHashtag

func BindInputHashtag(flagSet *pflag.FlagSet, addr *string)

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 BindPaths

func BindPaths(
	flagSet *pflag.FlagSet,
	pathsAddr *[]string,
	pathsFlagName string,
)

BindPaths binds the paths flag.

func BindPathsAndDeprecatedFiles

func BindPathsAndDeprecatedFiles(
	flagSet *pflag.FlagSet,
	pathsAddr *[]string,
	pathsFlagName string,
	filesAddr *[]string,
	filesFlagName string,
)

BindPathAndDeprecatedFiles binds the paths flag and the deprecated files flag.

func DeleteRemote

func DeleteRemote(container appflag.Container, address string) (bool, error)

DeleteRemote deletes the user credentials from the user configuration.

func GetInputLong

func GetInputLong(inputArgDescription string) string

GetInputLong gets the long command description for an input-based command.

func GetInputValue

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

func GetSourceOrModuleLong(inputArgDescription string) string

GetSourceOrModuleLong gets the long command description for an input-based command.

func GetStringFlagOrDeprecatedFlag

func GetStringFlagOrDeprecatedFlag(
	flag string,
	flagName string,
	deprecatedFlag string,
	deprecatedFlagName string,
) (string, error)

GetStringFlagOrDeprecatedFlag gets the flag, or the deprecated flag.

func GetStringSliceFlagOrDeprecatedFlag

func GetStringSliceFlagOrDeprecatedFlag(
	flag []string,
	flagName string,
	deprecatedFlag []string,
	deprecatedFlagName string,
) ([]string, error)

GetStringSliceFlagOrDeprecatedFlag gets the flag, or the deprecated flag.

func NewBranchOrTagNameAlreadyExistsError

func NewBranchOrTagNameAlreadyExistsError(name string) error

NewBranchOrTagNameAlreadyExistsError informs the user that a branch or tag with that name already exists.

func NewConfig

func NewConfig(container appflag.Container) (*bufapp.Config, error)

NewConfig creates a new Config.

func NewContextModifierProvider

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

func NewErrorInterceptor() appflag.Interceptor

NewErrorInterceptor returns a CLI interceptor that wraps Buf CLI errors.

func NewFetchImageReader

func NewFetchImageReader(
	logger *zap.Logger,
	storageosProvider storageos.Provider,
) buffetch.ImageReader

NewFetchImageReader creates a new buffetch.ImageReader with the default HTTP client and git cloner.

func NewFetchReader

func NewFetchReader(
	logger *zap.Logger,
	storageosProvider storageos.Provider,
	moduleResolver bufmodule.ModuleResolver,
	moduleReader bufmodule.ModuleReader,
) buffetch.Reader

NewFetchReader creates a new buffetch.Reader with the default HTTP client and git cloner.

func NewFetchSourceReader

func NewFetchSourceReader(
	logger *zap.Logger,
	storageosProvider storageos.Provider,
) buffetch.SourceReader

NewFetchSourceReader creates a new buffetch.SourceReader with the default HTTP client and git cloner.

func NewFlagIsRequiredError

func NewFlagIsRequiredError(flagName string) error

NewFlagIsRequiredError informs the user that a given flag is required.

func NewInternalError

func NewInternalError(err error) error

NewInternalError represents an internal error encountered by the buf CLI. These errors should not happen and therefore warrant a bug report.

func NewModuleRefError

func NewModuleRefError(moduleRef string) error

NewModuleRefError is used when the client fails to parse a module ref.

func NewModuleReferenceNotFoundError

func NewModuleReferenceNotFoundError(reference bufmodule.ModuleReference) error

NewModuleReferenceNotFoundError informs the user that a module reference does not exist.

func NewOrganizationNameAlreadyExistsError

func NewOrganizationNameAlreadyExistsError(name string) error

NewOrganizationNameAlreadyExistsError informs the user that an organization with that name already exists.

func NewOrganizationNotFoundError

func NewOrganizationNotFoundError(name string) error

NewOrganizationNotFoundError informs the user that an organization with that name does not exist.

func NewRegistryProvider

func NewRegistryProvider(ctx context.Context, container appflag.Container) (registryv1alpha1apiclient.Provider, error)

NewRegistryProvider creates a new registryv1alpha1apiclient.Provider.

func NewRepositoryNameAlreadyExistsError

func NewRepositoryNameAlreadyExistsError(name string) error

NewRepositoryNameAlreadyExistsError informs the user that a repository with that name already exists.

func NewRepositoryNotFoundError

func NewRepositoryNotFoundError(name string) error

NewRepositoryNotFoundError informs the user that a repository with that name does not exist.

func NewTokenNotFoundError

func NewTokenNotFoundError(tokenID string) error

NewTokenNotFoundError informs the user that a token with that identifier does not exist.

func NewTooManyEmptyAnswersError

func NewTooManyEmptyAnswersError(attempts int) error

NewTooManyEmptyAnswersError is used when the user does not answer a prompt in the given number of attempts.

func NewWireFileLister

func NewWireFileLister(
	logger *zap.Logger,
	storageosProvider storageos.Provider,
	configProvider bufconfig.Provider,
	workspaceConfigProvider bufwork.Provider,
	moduleResolver bufmodule.ModuleResolver,
	moduleReader bufmodule.ModuleReader,
) bufwire.FileLister

NewWireFileLister returns a new FileLister.

func NewWireImageConfigReader

func NewWireImageConfigReader(
	logger *zap.Logger,
	storageosProvider storageos.Provider,
	configProvider bufconfig.Provider,
	workspaceConfigProvider bufwork.Provider,
	moduleResolver bufmodule.ModuleResolver,
	moduleReader bufmodule.ModuleReader,
) bufwire.ImageConfigReader

NewWireImageConfigReader returns a new ImageConfigReader.

func NewWireImageReader

func NewWireImageReader(
	logger *zap.Logger,
	storageosProvider storageos.Provider,
) bufwire.ImageReader

NewWireImageReader returns a new ImageReader.

func NewWireImageWriter

func NewWireImageWriter(
	logger *zap.Logger,
) bufwire.ImageWriter

NewWireImageWriter returns a new ImageWriter.

func NewWireModuleConfigReader

func NewWireModuleConfigReader(
	logger *zap.Logger,
	storageosProvider storageos.Provider,
	configProvider bufconfig.Provider,
	workspaceConfigProvider bufwork.Provider,
	moduleResolver bufmodule.ModuleResolver,
	moduleReader bufmodule.ModuleReader,
) bufwire.ModuleConfigReader

NewWireModuleConfigReader returns a new ModuleConfigReader.

func PrintOrganizations

func PrintOrganizations(
	ctx context.Context,
	address string,
	writer io.Writer,
	formatString string,
	organizations ...*registryv1alpha1.Organization,
) error

PrintOrganizations prints the provided organizations to the writer.

func PrintRepositories

func PrintRepositories(
	ctx context.Context,
	apiProvider registryv1alpha1apiclient.Provider,
	address string,
	writer io.Writer,
	formatString string,
	repositories ...*registryv1alpha1.Repository,
) error

PrintRepositories prints the provided repositories to the writer.

func PrintRepositoryBranches

func PrintRepositoryBranches(
	ctx context.Context,
	writer io.Writer,
	formatString string,
	repositoryBranches ...*registryv1alpha1.RepositoryBranch,
) error

PrintRepositoryBranches prints the provided repositoryBranches to the writer.

func PrintRepositoryTags

func PrintRepositoryTags(
	ctx context.Context,
	writer io.Writer,
	formatString string,
	repositoryTags ...*registryv1alpha1.RepositoryTag,
) error

PrintRepositoryTags prints the provided repositoryTags to the writer.

func PrintUsers

func PrintUsers(
	ctx context.Context,
	writer io.Writer,
	formatString string,
	users ...*registryv1alpha1.User,
) error

PrintUsers prints the provided users to the writer.

func PromptUserForDelete

func PromptUserForDelete(container app.Container, entityType string, expectedAnswer string) error

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.

func ReadModule

func ReadModule(
	ctx context.Context,
	container appflag.Container,
	storageosProvider storageos.Provider,
	source string,
) (bufmodule.Module, bufmodule.ModuleIdentity, error)

ReadModule gets a module from a source ref. Workspaces are disabled for this function.

func UpdateRemote

func UpdateRemote(container appflag.Container, address string, token string) error

UpdateRemote writes the user credentials to the user configuration.

Types

type ModuleResolverReaderProvider

type ModuleResolverReaderProvider interface {
	GetModuleReader(context.Context, appflag.Container) (bufmodule.ModuleReader, error)
	GetModuleResolver(context.Context, appflag.Container) (bufmodule.ModuleResolver, error)
}

ModuleResolverReaderProvider provides ModuleResolvers and ModuleReaders.

func NewRegistryModuleResolverReaderProvider

func NewRegistryModuleResolverReaderProvider() ModuleResolverReaderProvider

NewRegistryModuleResolverReaderProvider returns a new registry-backed ModuleResolverReaderProvider.

type NopModuleResolverReaderProvider

type NopModuleResolverReaderProvider struct{}

NopModuleResolverReaderProvider is a no-op ModuleResolverReaderProvider.

func (NopModuleResolverReaderProvider) GetModuleReader

GetModuleReader returns a no-op module reader.

func (NopModuleResolverReaderProvider) GetModuleResolver

GetModuleResolver returns a no-op module resolver.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL