buffetch

package
v1.61.2 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MessageFormatsString is the string representation of all message formats.
	//
	// This does not include deprecated formats.
	MessageFormatsString = xstrings.SliceToString(messageFormatsNotDeprecated)
	// SourceDirFormatsString is the string representation of all source directory formats.
	// This includes all of the formats in SourceFormatsString except the protofile format.
	//
	// This does not include deprecated formats.
	SourceDirFormatsString = xstrings.SliceToString(sourceDirFormatsNotDeprecated)
	// SourceFormatsString is the string representation of all source formats.
	//
	// This does not include deprecated formats.
	SourceFormatsString = xstrings.SliceToString(sourceFormatsNotDeprecated)
	// ModuleFormatsString is the string representation of all module formats.
	//
	// Module formats are also source formats.
	//
	// This does not include deprecated formats.
	ModuleFormatsString = xstrings.SliceToString(moduleFormatsNotDeprecated)
	// SourceOrModuleFormatsString is the string representation of all source or module formats.
	//
	// This does not include deprecated formats.
	SourceOrModuleFormatsString = xstrings.SliceToString(sourceOrModuleFormatsNotDeprecated)
	// DirOrProtoFileFormatsString is the string representation of all dir or proto file formats.
	//
	// This does not include deprecated formats.
	DirOrProtoFileFormatsString = xstrings.SliceToString(dirOrProtoFileFormats)
	// AllFormatsString is the string representation of all formats.
	//
	// This does not include deprecated formats.
	AllFormatsString = xstrings.SliceToString(allFormatsNotDeprecated)

	// ErrModuleFormatDetectedForDirOrProtoFileRef is the error returned if a module is the
	// detected format in the DirOrProtoFileRefParser. We have a special heuristic to determine
	// if a path is a module or directory, and if a user specifies a suspected module, we want to error.
	ErrModuleFormatDetectedForDirOrProtoFileRef = errors.New("module format detected when parsing dir or proto file refs")
)

Functions

func GetInputConfigForString

func GetInputConfigForString(
	ctx context.Context,
	refParser RefParser,
	value string,
) (bufconfig.InputConfig, error)

GetInputConfigForString returns the input config for the input string.

Types

type BucketExtender

type BucketExtender internal.BucketExtender

BucketExtender matches the internal type.

type DirOrProtoFileRef

type DirOrProtoFileRef interface {
	// contains filtered or unexported methods
}

DirOrProtoFileRef is a directory or proto file reference.

type DirOrProtoFileRefParser

type DirOrProtoFileRefParser interface {
	// GetDirOrProtoFileRef gets the reference for the value.
	//
	// The value cannot be stdin, stdout, or stderr.
	GetDirOrProtoFileRef(ctx context.Context, value string) (DirOrProtoFileRef, error)
	// GetDirOrProtoFileRefForInputConfig gets the reference for the InputConfig.
	//
	// The input cannot be stdin, stdout, or stderr.
	GetDirOrProtoFileRefForInputConfig(
		ctx context.Context,
		inputConfig bufconfig.InputConfig,
	) (DirOrProtoFileRef, error)
}

DirOrProtoFileRefParser is a dir or proto file ref parser for Buf.

func NewDirOrProtoFileRefParser

func NewDirOrProtoFileRefParser(logger *slog.Logger) DirOrProtoFileRefParser

NewDirOrProtoFileRefParser returns a new RefParser for dirs only.

type DirReader

type DirReader interface {
	// GetDirReadWriteBucket gets the dir bucket.
	GetDirReadWriteBucket(
		ctx context.Context,
		container app.EnvStdinContainer,
		dirRef DirRef,
		options ...GetReadWriteBucketOption,
	) (ReadWriteBucket, buftarget.BucketTargeting, error)
}

DirReader is a dir reader.

func NewDirReader

func NewDirReader(
	logger *slog.Logger,
	storageosProvider storageos.Provider,
) DirReader

NewDirReader returns a new DirReader.

type DirRef

type DirRef interface {
	SourceRef
	DirOrProtoFileRef
	DirPath() string
	// contains filtered or unexported methods
}

DirRef is a dir bucket reference.

type DirRefParser

type DirRefParser interface {
	// GetDirRef gets the reference for the value.
	//
	// The value cannot be stdin, stdout, or stderr.
	GetDirRef(ctx context.Context, value string) (DirRef, error)
	// GetDirRefForInputConfig gets the reference for the InputConfig.
	//
	// The input cannot be stdin, stdout, or stderr.
	GetDirRefForInputConfig(
		ctx context.Context,
		inputConfig bufconfig.InputConfig,
	) (DirRef, error)
}

DirRefParser is a dir ref parser for Buf.

func NewDirRefParser

func NewDirRefParser(logger *slog.Logger) DirRefParser

NewDirRefParser returns a new RefParser for dirs only.

type GetReadBucketCloserOption

type GetReadBucketCloserOption func(*getReadBucketCloserOptions)

GetReadBucketCloserOption is an option for a GetSourceReadBucketCloser call.

func GetReadBucketCloserWithCopyToInMemory

func GetReadBucketCloserWithCopyToInMemory() GetReadBucketCloserOption

GetReadBucketCloserWithCopyToInMemory says to copy the returned ReadBucketCloser to an in-memory ReadBucketCloser. This can be a performance optimization at the expense of memory.

func GetReadBucketCloserWithNoSearch

func GetReadBucketCloserWithNoSearch() GetReadBucketCloserOption

GetReadBucketCloserWithNoSearch says to not search for buf.work.yamls or buf.yamls, instead just returning a bucket for the direct SourceRef or DirRef given.

This is used for when the --config flag is specified.

func GetReadBucketCloserWithTargetExcludePaths

func GetReadBucketCloserWithTargetExcludePaths(targetExcludePaths []string) GetReadBucketCloserOption

GetReadBucketCloserWithTargetExcludePaths sets the target exclude paths for bucket targeting information returned with the bucket.

func GetReadBucketCloserWithTargetPaths

func GetReadBucketCloserWithTargetPaths(targetPaths []string) GetReadBucketCloserOption

GetReadBucketCloserWithTargetPaths sets the targets paths for bucket targeting information returned with the bucket.

type GetReadWriteBucketOption

type GetReadWriteBucketOption func(*getReadWriteBucketOptions)

GetReadWriteBucketOption is an option for a GetDirReadWriteBucket call.

func GetReadWriteBucketWithNoSearch

func GetReadWriteBucketWithNoSearch() GetReadWriteBucketOption

GetReadWriteBucketWithNoSearch says to not search for buf.work.yamls or buf.yamls, instead just returning a bucket for the direct SourceRef or DirRef given.

This is used for when the --config flag is specified.

func GetReadWriteBucketWithTargetExcludePaths

func GetReadWriteBucketWithTargetExcludePaths(targetExcludePaths []string) GetReadWriteBucketOption

GetReadWriteBucketWithTargetExcludePaths sets the target exclude paths for the bucket targeting information returned with the bucket.

func GetReadWriteBucketWithTargetPaths

func GetReadWriteBucketWithTargetPaths(targetPaths []string) GetReadWriteBucketOption

GetReadWriteBucketWithTargetPaths sets the target paths for the bucket targeting information returned with the bucket.

type MessageEncoding

type MessageEncoding int

MessageEncoding is the encoding of the message.

const (
	// MessageEncodingBinpb is the binary message encoding.
	MessageEncodingBinpb MessageEncoding = iota + 1
	// MessageEncodingJSON is the JSON message encoding.
	MessageEncodingJSON
	// MessageEncodingTxtpb is the text protobuf message encoding.
	MessageEncodingTxtpb
	// MessageEncodingYAML is the YAML message encoding.
	MessageEncodingYAML
)

type MessageReader

type MessageReader interface {
	// GetMessageFile gets the message file.
	//
	// The returned file will be uncompressed.
	GetMessageFile(
		ctx context.Context,
		container app.EnvStdinContainer,
		messageRef MessageRef,
	) (io.ReadCloser, error)
}

MessageReader is a message reader.

func NewMessageReader

func NewMessageReader(
	logger *slog.Logger,
	storageosProvider storageos.Provider,
	httpClient *http.Client,
	httpAuthenticator httpauth.Authenticator,
	gitCloner git.Cloner,
) MessageReader

NewMessageReader returns a new MessageReader.

type MessageRef

type MessageRef interface {
	Ref
	MessageEncoding() MessageEncoding
	// Path returns the path of the file.
	//
	// May be used for items such as YAML unmarshalling errors.
	Path() string
	// UseProtoNames only applies for MessageEncodingYAML at this time.
	UseProtoNames() bool
	// UseEnumNumbers only applies for MessageEncodingYAML at this time.
	UseEnumNumbers() bool
	IsNull() bool
	// contains filtered or unexported methods
}

MessageRef is a message file reference.

type MessageRefParser

type MessageRefParser interface {
	// GetMessageRef gets the reference for the message file.
	GetMessageRef(ctx context.Context, value string) (MessageRef, error)
	// GetMessageRefForInputConfig gets the reference for the message file.
	GetMessageRefForInputConfig(
		ctx context.Context,
		inputConfig bufconfig.InputConfig,
	) (MessageRef, error)
}

MessageRefParser is an message ref parser for Buf.

func NewMessageRefParser

func NewMessageRefParser(logger *slog.Logger, options ...MessageRefParserOption) MessageRefParser

NewMessageRefParser returns a new RefParser for messages only.

type MessageRefParserOption

type MessageRefParserOption func(*messageRefParserOptions)

MessageRefParserOption is an option for a new MessageRefParser.

func MessageRefParserWithDefaultMessageEncoding

func MessageRefParserWithDefaultMessageEncoding(defaultMessageEncoding MessageEncoding) MessageRefParserOption

MessageRefParserWithDefaultMessageEncoding says to use the default MessageEncoding.

The default default is MessageEncodingBinpb.

type ModuleFetcher

type ModuleFetcher interface {
	// GetModuleKey gets the ModuleKey.
	// Unresolved ModuleRef's are automatically resolved.
	GetModuleKey(
		ctx context.Context,
		container app.EnvStdinContainer,
		moduleRef ModuleRef,
	) (bufmodule.ModuleKey, error)
}

ModuleFetcher is a module fetcher.

func NewModuleFetcher

func NewModuleFetcher(
	logger *slog.Logger,
	storageosProvider storageos.Provider,
	moduleKeyProvider bufmodule.ModuleKeyProvider,
) ModuleFetcher

NewModuleFetcher returns a new ModuleFetcher.

type ModuleRef

type ModuleRef interface {
	SourceOrModuleRef
	// contains filtered or unexported methods
}

ModuleRef is a module reference.

type ModuleRefParser

type ModuleRefParser interface {
	// GetModuleRef gets the reference for the source file.
	//
	// A module is a special type of source with additional properties.
	GetModuleRef(ctx context.Context, value string) (ModuleRef, error)
}

ModuleRefParser is a source ref parser for Buf.

func NewModuleRefParser

func NewModuleRefParser(logger *slog.Logger) ModuleRefParser

NewModuleRefParser returns a new RefParser for modules only.

type ProtoFileRef

type ProtoFileRef interface {
	SourceRef
	DirOrProtoFileRef
	ProtoFilePath() string
	// IsDevPath returns true if the FileScheme is Stdio, Stdout, Stdin, or Null.
	IsDevPath() bool
	IncludePackageFiles() bool
	// contains filtered or unexported methods
}

ProtoFileRef is a proto file reference.

type ProtoFileWriter

type ProtoFileWriter interface {
	// PutProtoFile puts the proto file.
	PutProtoFile(
		ctx context.Context,
		container app.EnvStdoutContainer,
		protoFileRef ProtoFileRef,
	) (io.WriteCloser, error)
}

ProtoFileWriter is a writer of proto files.

func NewProtoFileWriter

func NewProtoFileWriter(
	logger *slog.Logger,
) ProtoFileWriter

NewProtoFileWriter returns a new ProtoFileWriter.

type ReadBucketCloser

type ReadBucketCloser internal.ReadBucketCloser

ReadBucketCloser matches the internal type.

type ReadWriteBucket

type ReadWriteBucket internal.ReadWriteBucket

ReadWriteBucket matches the internal type.

type Reader

Reader is a reader for Buf.

func NewReader

func NewReader(
	logger *slog.Logger,
	storageosProvider storageos.Provider,
	httpClient *http.Client,
	httpAuthenticator httpauth.Authenticator,
	gitCloner git.Cloner,
	moduleKeyProvider bufmodule.ModuleKeyProvider,
) Reader

NewReader returns a new Reader.

type Ref

type Ref interface {
	// contains filtered or unexported methods
}

Ref is an message file or source bucket reference.

type RefParser

type RefParser interface {
	MessageRefParser
	SourceRefParser
	DirRefParser
	SourceOrModuleRefParser

	// GetRef gets the reference for the message file, source bucket, or module.
	// TODO FUTURE: should this be renamed to GetRefForString?
	GetRef(ctx context.Context, value string) (Ref, error)
	// GetRefForInputConfig gets the reference for the message file, source bucket, or module.
	GetRefForInputConfig(ctx context.Context, inputConfig bufconfig.InputConfig) (Ref, error)
}

RefParser is a ref parser for Buf.

func NewRefParser

func NewRefParser(logger *slog.Logger) RefParser

NewRefParser returns a new RefParser.

This defaults to dir or module.

type SourceOrModuleRef

type SourceOrModuleRef interface {
	Ref
	// contains filtered or unexported methods
}

SourceOrModuleRef is a source bucket or module reference.

type SourceOrModuleRefParser

type SourceOrModuleRefParser interface {
	SourceRefParser
	ModuleRefParser

	// GetSourceOrModuleRef gets the reference for the message file or source bucket.
	GetSourceOrModuleRef(ctx context.Context, value string) (SourceOrModuleRef, error)
	// GetSourceOrModuleRefForInputConfig gets the reference for the message file or source bucket.
	GetSourceOrModuleRefForInputConfig(
		ctx context.Context,
		inputConfig bufconfig.InputConfig,
	) (SourceOrModuleRef, error)
}

SourceOrModuleRefParser is a source or module ref parser for Buf.

func NewSourceOrModuleRefParser

func NewSourceOrModuleRefParser(logger *slog.Logger) SourceOrModuleRefParser

NewSourceOrModuleRefParser returns a new RefParser for sources or modules only.

This defaults to dir or module.

type SourceReader

type SourceReader interface {
	// GetSourceReadBucketCloser gets the source bucket.
	GetSourceReadBucketCloser(
		ctx context.Context,
		container app.EnvStdinContainer,
		sourceRef SourceRef,
		options ...GetReadBucketCloserOption,
	) (ReadBucketCloser, buftarget.BucketTargeting, error)
}

SourceReader is a source reader.

func NewSourceReader

func NewSourceReader(
	logger *slog.Logger,
	storageosProvider storageos.Provider,
	httpClient *http.Client,
	httpAuthenticator httpauth.Authenticator,
	gitCloner git.Cloner,
) SourceReader

NewSourceReader returns a new SourceReader.

type SourceRef

type SourceRef interface {
	SourceOrModuleRef
	// contains filtered or unexported methods
}

SourceRef is a source bucket reference.

type SourceRefParser

type SourceRefParser interface {
	// GetSourceRef gets the reference for the source file.
	GetSourceRef(ctx context.Context, value string) (SourceRef, error)
	// GetSourceRefForInputConfig gets the reference for the source file.
	GetSourceRefForInputConfig(
		ctx context.Context,
		inputConfig bufconfig.InputConfig,
	) (SourceRef, error)
}

SourceRefParser is a source ref parser for Buf.

func NewSourceRefParser

func NewSourceRefParser(logger *slog.Logger) SourceRefParser

NewSourceRefParser returns a new RefParser for sources only.

This defaults to dir.

type Writer

type Writer interface {
	// PutMessageFile puts the message file.
	PutMessageFile(
		ctx context.Context,
		container app.EnvStdoutContainer,
		messageRef MessageRef,
	) (io.WriteCloser, error)
}

Writer is a writer for Buf.

func NewWriter

func NewWriter(
	logger *slog.Logger,
) Writer

NewWriter returns a new Writer.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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