bufcli

package
v1.32.2 Latest Latest
Warning

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

Go to latest
Published: May 28, 2024 License: Apache-2.0 Imports: 45 Imported by: 94

Documentation

Index

Constants

View Source
const Version = "1.32.2"

Version is the CLI version of buf.

Variables

View Source
var (
	// 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")

	// ErrNoConfigFile is used when the user tries to execute a command without a configuration file.
	ErrNoConfigFile = errors.New(`no buf.yaml file discovered in the specified directory`)
)
View Source
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,
		v2CacheModuleRelDirPath,
		v3CacheModuleRelDirPath,
		v3CacheCommitsRelDirPath,
		v3CacheWKTRelDirPath,
	}
)

Functions

func BindAsFileDescriptorSet

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

BindAsFileDescriptorSet binds the exclude-imports flag.

func BindCreateVisibility added in v1.19.0

func BindCreateVisibility(flagSet *pflag.FlagSet, addr *string, flagName string, createFlagName string)

BindCreateVisibility binds the create-visibility flag. Kept in this package so we can keep allVisibilityStrings private.

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

BindDisableSymlinks binds the disable-symlinks flag.

func BindExcludeImports

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

BindExcludeImports binds the exclude-imports flag.

func BindExcludePaths added in v1.0.0

func BindExcludePaths(
	flagSet *pflag.FlagSet,
	excludePathsAddr *[]string,
	excludePathsFlagName string,
)

BindExcludePaths binds the exclude-path 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 BindVisibility added in v1.4.0

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

BindVisibility binds the visibility flag.

func BufYAMLFileExistsForDirPath added in v1.32.0

func BufYAMLFileExistsForDirPath(
	ctx context.Context,
	dirPath string,
) (bool, error)

BufYAMLFileExistsForDirPath returns true if the buf.yaml file exists at the dir path.

func GetBufYAMLFileForDirPath added in v1.32.0

func GetBufYAMLFileForDirPath(
	ctx context.Context,
	dirPath string,
) (bufconfig.BufYAMLFile, error)

GetBufYAMLFileForDirPath gets the buf.yaml file for the directory path.

func GetBufYAMLFileForDirPathOrOverride added in v1.32.0

func GetBufYAMLFileForDirPathOrOverride(
	ctx context.Context,
	dirPath string,
	override string,
) (bufconfig.BufYAMLFile, error)

GetBufYAMLFileForDirPathOrOverride get the buf.yaml file for either the usually-flag-based override, or if the override is not set, the directory path.

func GetInputLong

func GetInputLong(inputArgDescription string) string

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

func GetInputValue

func GetInputValue(
	container app.ArgContainer,
	inputHashtag string,
	defaultValue string,
) (string, error)

GetInputValue gets the first arg.

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 GetSourceDirLong added in v1.7.0

func GetSourceDirLong(inputArgDescription string) string

GetSourceDirLong gets the long command description for a directory-based command.

func GetSourceLong added in v1.0.0

func GetSourceLong(inputArgDescription string) string

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

func GetSourceOrModuleLong

func GetSourceOrModuleLong(inputArgDescription string) string

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

func NewCommitProvider added in v1.32.0

func NewCommitProvider(container appext.Container) (bufmodule.CommitProvider, error)

NewCommitProvider returns a new CommitProvider while creating the required cache directories.

func NewConnectClientConfig added in v1.10.0

func NewConnectClientConfig(container appext.Container) (*connectclient.Config, error)

NewConnectClientConfig creates a new connect.ClientConfig which uses a token reader to look up the token in the container or in netrc based on the address of each individual client. It is then set in the header of all outgoing requests from clients created using this config.

func NewConnectClientConfigWithToken added in v1.10.0

func NewConnectClientConfigWithToken(container appext.Container, token string) (*connectclient.Config, error)

NewConnectClientConfigWithToken creates a new connect.ClientConfig with a given token. The provided token is set in the header of all outgoing requests from this provider

func NewController added in v1.32.0

func NewController(
	container appext.Container,
	options ...bufctl.ControllerOption,
) (bufctl.Controller, error)

NewController returns a new Controller.

func NewGraphProvider added in v1.32.0

func NewGraphProvider(container appext.Container) (bufmodule.GraphProvider, error)

NewGraphProvider returns a new GraphProvider.

func NewInvalidRemoteError added in v1.27.0

func NewInvalidRemoteError(err error, remote string, moduleFullName string) error

NewInvalidRemoteError informs the user that the given remote is invalid.

func NewModuleDataProvider added in v1.32.0

func NewModuleDataProvider(container appext.Container) (bufmodule.ModuleDataProvider, error)

NewModuleDataProvider returns a new ModuleDataProvider while creating the required cache directories.

func NewModuleKeyProvider added in v1.32.0

func NewModuleKeyProvider(container appext.Container) (bufmodule.ModuleKeyProvider, error)

NewModuleKeyProvider returns a new ModuleKeyProvider.

func NewModuleRefNotFoundError added in v1.32.0

func NewModuleRefNotFoundError(moduleRef bufmodule.ModuleRef) error

NewModuleRefNotFoundError informs the user that a ModuleRef 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 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 NewTagOrDraftNameAlreadyExistsError added in v1.7.0

func NewTagOrDraftNameAlreadyExistsError(name string) error

NewTagOrDraftNameAlreadyExistsError informs the user that a tag or draft with that name already exists.

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 NewUploader added in v1.32.0

func NewUploader(container appext.Container) (bufmodule.Uploader, error)

NewUploader returns a new Uploader.

func PromptUser

func PromptUser(container app.Container, prompt string) (string, error)

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

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

PromptUserForDelete is used to receive 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

func PromptUserForPassword(container app.Container, prompt string) (string, error)

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 PutBufYAMLFileForDirPath added in v1.32.0

func PutBufYAMLFileForDirPath(
	ctx context.Context,
	dirPath string,
	bufYAMLFile bufconfig.BufYAMLFile,
) error

PutBufYAMLFileForDirPath write the buf.yaml file to the directory path.

func ValidateErrorFormatFlagLint

func ValidateErrorFormatFlagLint(errorFormatString string, errorFormatFlagName string) error

ValidateErrorFormatFlagLint validates the error format flag for lint.

func ValidateRequiredFlag added in v1.32.0

func ValidateRequiredFlag[T comparable](flagName string, value T) error

ValidateRequiredFlag validates that the required flag is set.

func VisibilityFlagToVisibility added in v1.4.0

func VisibilityFlagToVisibility(visibility string) (registryv1alpha1.Visibility, error)

VisibilityFlagToVisibility parses the given string as a registryv1alpha1.Visibility.

func VisibilityFlagToVisibilityAllowUnspecified added in v1.4.0

func VisibilityFlagToVisibilityAllowUnspecified(visibility string) (registryv1alpha1.Visibility, error)

VisibilityFlagToVisibilityAllowUnspecified parses the given string as a registryv1alpha1.Visibility, where an empty string will be parsed as unspecified

func WarnAlphaCommand added in v1.0.0

func WarnAlphaCommand(_ context.Context, container appext.Container)

WarnAlphaCommand prints a warning for a alpha command unless the alphaSuppressWarningsEnvKey environment variable is set.

func WarnBetaCommand added in v1.0.0

func WarnBetaCommand(_ context.Context, container appext.Container)

WarnBetaCommand prints a warning for a beta command unless the betaSuppressWarningsEnvKey environment variable is set.

Types

type ModuleOwner added in v1.32.0

type ModuleOwner interface {
	// String returns "registry/owner".
	fmt.Stringer

	// Registry returns the hostname of the BSR instance that this owner is contained within.
	Registry() string
	// Owner returns the name of the user or organization.
	Owner() string
	// contains filtered or unexported methods
}

ModuleOwner represents a module owner, consisting of a registry and owner.

This concept used to live in bufmodule but it doesn't really make sense there, as it isn't use anywhere else. We only use this in buf beta registry organization commands at the moment.

func NewModuleOwner added in v1.32.0

func NewModuleOwner(
	registry string,
	owner string,
) (ModuleOwner, error)

NewModuleOwner returns a new ModuleOwner for the given components.

func ParseModuleOwner added in v1.32.0

func ParseModuleOwner(moduleOwnerString string) (ModuleOwner, error)

ParseModuleOwner parses a ModuleOwner from a string in the form "registry/owner".

Jump to

Keyboard shortcuts

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