bufcli

package
v1.48.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 55 Imported by: 94

Documentation

Index

Constants

View Source
const (
	DefaultArchiveStatus = unarchivedArchiveStatus
)
View Source
const Version = "1.48.0"

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 (
	// AllCacheRelDirPaths are all directory paths for all time
	// concerning the module and plugin caches.
	//
	// These are normalized.
	// These are relative to container.CacheDirPath().
	//
	// This variable is used for clearing the cache.
	AllCacheRelDirPaths = []string{
		v1CacheModuleDataRelDirPath,
		v1CacheModuleLockRelDirPath,
		v1CacheModuleSumRelDirPath,
		v1beta1CacheModuleDataRelDirPath,
		v1beta1CacheModuleLockRelDirPath,
		v2CacheModuleRelDirPath,
		v3CacheCommitsRelDirPath,
		v3CacheModuleLockRelDirPath,
		v3CacheModuleRelDirPath,
		v3CachePluginRelDirPath,
		v3CacheWKTRelDirPath,
		v3CacheWasmRuntimeRelDirPath,
	}
)
View Source
var AllLintFormatStrings = append(
	bufanalysis.AllFormatStrings,
	"config-ignore-yaml",
)

AllLintFormatStrings are all format strings for lint.

View Source
var AllRuleFormatStrings = []string{
	"text",
	"json",
}

AllRuleFormatStrings is all rule format strings.

Functions

func ArchiveStatusFlagToModuleArchiveStatusFilter added in v1.48.0

func ArchiveStatusFlagToModuleArchiveStatusFilter(archiveStatus string) (modulev1.ListLabelsRequest_ArchiveFilter, error)

ArchiveStatusFlagToModuleArchiveStatusFilter parses the given string as a modulev1.ListLabelsRequest_ArchiveFilter.

func ArchiveStatusFlagToPluginArchiveStatusFilter added in v1.48.0

func ArchiveStatusFlagToPluginArchiveStatusFilter(archiveStatus string) (pluginv1beta1.ListLabelsRequest_ArchiveFilter, error)

ArchiveStatusFlagToPluginArchiveStatusFilter parses the given string as a pluginv1beta1.ListLabelsRequest_ArchiveFilter.

func BindArchiveStatus added in v1.33.0

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

BindArchiveStatus binds the archive-status flag. Kept in this package so we can keep allArchiveStatusStrings private.

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 BindStringPointer added in v1.36.0

func BindStringPointer(flagSet *pflag.FlagSet, name string, value **string, usage string)

Binds a string pointer flag, which indicates flag presence, i.e. `--flag ""` is not the same as not passing the flag.

This is useful for buf registry organization/module update, where we only modify the fields specified.

Value must not be nil.

func BindVisibility added in v1.4.0

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

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 CreateWasmRuntimeCacheDir added in v1.44.0

func CreateWasmRuntimeCacheDir(container appext.Container) (string, error)

CreateWasmRuntimeCacheDir creates the cache directory for the Wasm runtime.

This is used by the Wasm runtime to cache compiled Wasm plugins. This is an implementation specific cache and opaque outside of the runtime. The runtime will manage the cache versioning itself within this directory.

func GetBufWorkYAMLFileForDirPath added in v1.34.0

func GetBufWorkYAMLFileForDirPath(
	ctx context.Context,
	dirPath string,
) (bufconfig.BufWorkYAMLFile, error)

GetBufWorkYAMLFileForDirPath gets the buf.work.yaml file for the directory 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 NewLabelNameAlreadyExistsError added in v1.33.0

func NewLabelNameAlreadyExistsError(name string) error

NewLabelNameAlreadyExistsError informs the user that a label with that name already exists.

func NewLabelNotFoundError added in v1.33.0

func NewLabelNotFoundError(ref bufparse.Ref) error

NewLabelNotFoundError informs the user that a Ref does not exist as a label.

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 NewModuleNameAlreadyExistsError added in v1.36.0

func NewModuleNameAlreadyExistsError(name string) error

NewModuleNameAlreadyExistsError informs the user that a module with that name already exists.

func NewModuleNotFoundError added in v1.36.0

func NewModuleNotFoundError(name string) error

NewModuleNotFoundError informs the user that a module with that name does not exist.

func NewModuleUploader added in v1.48.0

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

NewModuleUploader returns a new Uploader for ModuleSets.

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 NewOrganizationOrUserNotFoundError added in v1.33.0

func NewOrganizationOrUserNotFoundError(name string) error

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

func NewPluginDataProvider added in v1.48.0

func NewPluginDataProvider(container appext.Container) (bufplugin.PluginDataProvider, error)

NewPluginDataProvider returns a new PluginDataProvider while creating the required cache directories.

func NewPluginKeyProvider added in v1.48.0

func NewPluginKeyProvider(container appext.Container) (bufplugin.PluginKeyProvider, error)

NewPluginKeyProvider returns a new PluginKeyProvider.

func NewPluginNameAlreadyExistsError added in v1.48.0

func NewPluginNameAlreadyExistsError(name string) error

NewPluginNameAlreadyExistsError informs the user that a plugin with that name already exists.

func NewPluginNotFoundError

func NewPluginNotFoundError(name string) error

NewPluginNotFoundError informs the user that a plugin with that name does not exist.

func NewPluginUploader added in v1.48.0

func NewPluginUploader(container appext.Container) (bufplugin.Uploader, error)

NewPluginUploader returns a new Uploader for Plugins.

func NewRefNotFoundError added in v1.47.0

func NewRefNotFoundError(ref bufparse.Ref) error

NewRefNotFoundError informs the user that a Ref 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 NewWKTStore added in v1.46.0

func NewWKTStore(container appext.Container) (bufwktstore.Store, error)

NewWKTStore returns a new bufwktstore.Store while creating the required cache directories.

func PrintFileAnnotationSetLintConfigIgnoreYAMLV1 added in v1.40.0

func PrintFileAnnotationSetLintConfigIgnoreYAMLV1(
	writer io.Writer,
	fileAnnotationSet bufanalysis.FileAnnotationSet,
) error

PrintFileAnnotationSetLintConfigIgnoreYAMLV1 prints the FileAnnotationSet to the Writer for the lint config-ignore-yaml format.

TODO FUTURE: This is messed.

func PrintRules added in v1.37.0

func PrintRules(writer io.Writer, rules []bufcheck.Rule, format string, includeDeprecated bool) error

PrintRules prints the Rules to the writer given the --format and --include-deprecated flag values.

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 VisibilityFlagToPluginVisibilityAllowUnspecified added in v1.48.0

func VisibilityFlagToPluginVisibilityAllowUnspecified(visibility string) (pluginv1beta1.PluginVisibility, error)

VisibilityFlagToPluginVisibilityAllowUnspecified parses the given string as a pluginv1.PluginVisibility where an empty string will be parsed as unspecified.

func VisibilityFlagToVisibilityAllowUnspecified added in v1.4.0

func VisibilityFlagToVisibilityAllowUnspecified(visibility string) (modulev1.ModuleVisibility, error)

VisibilityFlagToVisibilityAllowUnspecified parses the given string as a modulev1.ModuleVisibility 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 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