Documentation ¶
Index ¶
- Constants
- func NewCannotSpecifyCompressionForZipError() error
- func NewCannotSpecifyGitBranchAndTagError() error
- func NewCannotSpecifyTagWithRefError() error
- func NewCompressionUnknownError(compression string) error
- func NewDepthParseError(s string) error
- func NewDepthZeroError() error
- func NewFormatCannotBeDeterminedError(value string) error
- func NewFormatNotAllowedError(format string, allowedFormats map[string]struct{}) error
- func NewFormatOverrideNotAllowedForDevNullError(devNull string) error
- func NewFormatUnknownError(formatString string) error
- func NewInvalidPathError(format string, path string) error
- func NewNoPathError() error
- func NewOptionsCouldNotParseRecurseSubmodulesError(s string) error
- func NewOptionsCouldNotParseStripComponentsError(s string) error
- func NewOptionsInvalidForFormatError(format string, s string) error
- func NewOptionsInvalidKeyError(key string) error
- func NewPathUnknownGzError(path string) error
- func NewProtoFileCannotBeDevPathError(format string, path string) error
- func NewReadDisabledError(scheme string) error
- func NewReadGitDisabledError() error
- func NewReadHTTPDisabledError() error
- func NewReadLocalDisabledError() error
- func NewReadModuleDisabledError() error
- func NewReadStdioDisabledError() error
- func NewRealCleanPathError(path string) error
- func NewWriteDisabledError(scheme string) error
- func NewWriteHTTPDisabledError() error
- func NewWriteLocalDisabledError() error
- func NewWriteStdioDisabledError() error
- type ArchiveFormatOption
- type ArchiveRef
- type ArchiveType
- type BucketRef
- type CompressionType
- type DirFormatOption
- type DirRef
- type FileRef
- type FileScheme
- type GetBucketOption
- type GetFileOption
- type GetModuleOption
- type GetParsedRefOption
- type GitFormatOption
- type GitRef
- type GitScheme
- type HasFormat
- type ModuleFormatOption
- type ModuleRef
- type ParsedArchiveRef
- type ParsedBucketRef
- type ParsedDirRef
- type ParsedFileRef
- type ParsedGitRef
- type ParsedModuleRef
- type ParsedProtoFileRef
- type ParsedRef
- type ParsedSingleRef
- type ProtoFileFormatOption
- type ProtoFileRef
- type PutFileOption
- type RawRef
- type ReadBucketCloser
- type ReadBucketCloserWithTerminateFileProvider
- type ReadWriteBucketCloser
- type Reader
- type ReaderOption
- func WithReaderGit(gitCloner git.Cloner) ReaderOption
- func WithReaderHTTP(httpClient *http.Client, httpAuthenticator httpauth.Authenticator) ReaderOption
- func WithReaderLocal() ReaderOption
- func WithReaderModule(moduleResolver bufmodule.ModuleResolver, moduleReader bufmodule.ModuleReader) ReaderOption
- func WithReaderStdio() ReaderOption
- type Ref
- type RefParser
- type RefParserOption
- func WithArchiveFormat(format string, archiveType ArchiveType, options ...ArchiveFormatOption) RefParserOption
- func WithDirFormat(format string, options ...DirFormatOption) RefParserOption
- func WithGitFormat(format string, options ...GitFormatOption) RefParserOption
- func WithModuleFormat(format string, options ...ModuleFormatOption) RefParserOption
- func WithProtoFileFormat(format string, options ...ProtoFileFormatOption) RefParserOption
- func WithRawRefProcessor(rawRefProcessor func(*RawRef) error) RefParserOption
- func WithSingleFormat(format string, options ...SingleFormatOption) RefParserOption
- type SingleFormatOption
- type SingleRef
- type TerminateFile
- type TerminateFileProvider
- type Writer
- type WriterOption
Constants ¶
const ( // FileSchemeHTTP is the http file scheme. FileSchemeHTTP FileScheme = iota + 1 // FileSchemeHTTPS is the https file scheme. FileSchemeHTTPS // FileSchemeLocal is the local file scheme. FileSchemeLocal // FileSchemeStdio is the stdio file scheme. // // This can reference either stdin or stdout depending on if we are // reading or writing. FileSchemeStdio // FileSchemeStdin is the stdin file scheme. FileSchemeStdin // FileSchemeStdout is the stdout file scheme. FileSchemeStdout // FileSchemeNull is the null file scheme. FileSchemeNull // GitSchemeHTTP is the http git scheme. GitSchemeHTTP GitScheme = iota + 1 // GitSchemeHTTPS is the https git scheme. GitSchemeHTTPS // GitSchemeLocal is the local git scheme. GitSchemeLocal // GitSchemeSSH is the ssh git scheme. GitSchemeSSH // GitSchemeGit is the git git scheme. GitSchemeGit // ArchiveTypeTar is a tar archive. ArchiveTypeTar ArchiveType = iota + 1 // ArchiveTypeZip is a zip archive. ArchiveTypeZip // CompressionTypeNone is no compression. CompressionTypeNone CompressionType = iota + 1 // CompressionTypeGzip is gzip compression. CompressionTypeGzip // CompressionTypeZstd is zstd compression. CompressionTypeZstd )
Variables ¶
This section is empty.
Functions ¶
func NewCannotSpecifyCompressionForZipError ¶
func NewCannotSpecifyCompressionForZipError() error
NewCannotSpecifyCompressionForZipError is a fetch error.
func NewCannotSpecifyGitBranchAndTagError ¶
func NewCannotSpecifyGitBranchAndTagError() error
NewCannotSpecifyGitBranchAndTagError is a fetch error.
func NewCannotSpecifyTagWithRefError ¶
func NewCannotSpecifyTagWithRefError() error
NewCannotSpecifyTagWithRefError is a fetch error.
func NewCompressionUnknownError ¶
NewCompressionUnknownError is a fetch error.
func NewDepthParseError ¶
NewDepthParseError is a fetch error.
func NewFormatCannotBeDeterminedError ¶
NewFormatCannotBeDeterminedError is a fetch error.
func NewFormatNotAllowedError ¶
NewFormatNotAllowedError is a fetch error.
func NewFormatOverrideNotAllowedForDevNullError ¶
NewFormatOverrideNotAllowedForDevNullError is a fetch error.
func NewFormatUnknownError ¶
NewFormatUnknownError is a fetch error.
func NewInvalidPathError ¶
NewInvalidPathError is a fetch error.
func NewOptionsCouldNotParseRecurseSubmodulesError ¶
NewOptionsCouldNotParseRecurseSubmodulesError is a fetch error.
func NewOptionsCouldNotParseStripComponentsError ¶
NewOptionsCouldNotParseStripComponentsError is a fetch error.
func NewOptionsInvalidForFormatError ¶
NewOptionsInvalidForFormatError is a fetch error.
func NewOptionsInvalidKeyError ¶
NewOptionsInvalidKeyError is a fetch error.
func NewPathUnknownGzError ¶
NewPathUnknownGzError is a fetch error.
func NewProtoFileCannotBeDevPathError ¶ added in v1.19.0
NewProtoFileCannotBeDevPathError is a fetch error.
func NewReadDisabledError ¶
NewReadDisabledError is a fetch error.
func NewReadGitDisabledError ¶
func NewReadGitDisabledError() error
NewReadGitDisabledError is a fetch error.
func NewReadHTTPDisabledError ¶
func NewReadHTTPDisabledError() error
NewReadHTTPDisabledError is a fetch error.
func NewReadLocalDisabledError ¶
func NewReadLocalDisabledError() error
NewReadLocalDisabledError is a fetch error.
func NewReadModuleDisabledError ¶
func NewReadModuleDisabledError() error
NewReadModuleDisabledError is a fetch error.
func NewReadStdioDisabledError ¶
func NewReadStdioDisabledError() error
NewReadStdioDisabledError is a fetch error.
func NewRealCleanPathError ¶
NewRealCleanPathError is a fetch error.
func NewWriteDisabledError ¶
NewWriteDisabledError is a fetch error.
func NewWriteHTTPDisabledError ¶
func NewWriteHTTPDisabledError() error
NewWriteHTTPDisabledError is a fetch error.
func NewWriteLocalDisabledError ¶
func NewWriteLocalDisabledError() error
NewWriteLocalDisabledError is a fetch error.
func NewWriteStdioDisabledError ¶
func NewWriteStdioDisabledError() error
NewWriteStdioDisabledError is a fetch error.
Types ¶
type ArchiveFormatOption ¶
type ArchiveFormatOption func(*archiveFormatInfo)
ArchiveFormatOption is a archive format option.
func WithArchiveDefaultCompressionType ¶
func WithArchiveDefaultCompressionType(defaultCompressionType CompressionType) ArchiveFormatOption
WithArchiveDefaultCompressionType sets the default compression type.
Note this should never be set for zip.
type ArchiveRef ¶
type ArchiveRef interface { FileRef BucketRef ArchiveType() ArchiveType // Applied before subdir StripComponents() uint32 // Will be empty instead of "." for root directory SubDirPath() string // contains filtered or unexported methods }
ArchiveRef is an archive reference.
An ArchiveRef is a special type of reference that can be either a FileRef or a BucketRef. Note that if ArchiveType is ArchiveTypeZip, CompressionType will always be CompressionTypeNone.
func NewArchiveRef ¶
func NewArchiveRef( path string, archiveType ArchiveType, compressionType CompressionType, stripComponents uint32, subDirPath string, ) (ArchiveRef, error)
NewArchiveRef returns a new ArchiveRef.
type BucketRef ¶
type BucketRef interface { Ref // contains filtered or unexported methods }
BucketRef is a bucket reference.
type DirFormatOption ¶
type DirFormatOption func(*dirFormatInfo)
DirFormatOption is a dir format option.
type DirRef ¶
type DirRef interface { // Path is the path to the reference. // // This will be the non-empty normalized directory path for directories. Path() string BucketRef // contains filtered or unexported methods }
DirRef is a local directory reference.
type FileRef ¶
type FileRef interface { Ref // Path is the path to the reference. // // This will be the non-empty path minus the scheme for http and https files. // This will be the non-empty normalized file path for local files. // This will be empty for stdio and null files. Path() string FileScheme() FileScheme CompressionType() CompressionType // contains filtered or unexported methods }
FileRef is a file reference.
type GetBucketOption ¶
type GetBucketOption func(*getBucketOptions)
GetBucketOption is a GetBucket option.
func WithGetBucketTerminateFileNames ¶
func WithGetBucketTerminateFileNames(terminateFileNames [][]string) GetBucketOption
WithGetBucketTerminateFileNames only applies if subdir is specified.
The terminate files are organized as a slice of slices of file names. Priority will be given to the first slice of terminate file names, which will be workspace configuration files. The second layer of priority will be given to modules.
This says that for a given subdir, ascend directories until you reach a file with one of these names, and if you do, the returned bucket will be for the directory with this filename, while SubDirPath on the returned bucket will be set to the original subdir relative to the terminate file.
This is used for workspaces and modules. So if you have i.e. "proto/foo" subdir, and terminate file "proto/buf.work.yaml", the returned bucket will be for "proto", and the SubDirPath will be "foo".
The terminateFileNames are expected to be valid and have no slashes. Example of terminateFileNames:
[][]string{ []string{"buf.work.yaml", "buf.work"}, []string{"buf.yaml", "buf.mod"}, }.
type GetFileOption ¶
type GetFileOption func(*getFileOptions)
GetFileOption is a GetFile option.
func WithGetFileKeepFileCompression ¶
func WithGetFileKeepFileCompression() GetFileOption
WithGetFileKeepFileCompression says to return compressed.
type GetModuleOption ¶
type GetModuleOption func(*getModuleOptions)
GetModuleOption is a GetModule option.
type GetParsedRefOption ¶
type GetParsedRefOption func(*getParsedRefOptions)
GetParsedRefOption is a GetParsedRef option.
func WithAllowedFormats ¶
func WithAllowedFormats(formats ...string) GetParsedRefOption
WithAllowedFormats limits the allowed formats to the given formats.
type GitFormatOption ¶
type GitFormatOption func(*gitFormatInfo)
GitFormatOption is a git format option.
type GitRef ¶
type GitRef interface { // Path is the path to the reference. // // This will be the non-empty path minus the scheme for http, https, ssh, and git repositories. // This will be the non-empty normalized directory path for local git repositories. Path() string BucketRef GitScheme() GitScheme // Optional. May be nil, in which case clone the default branch. GitName() git.Name // Will always be >= 1 Depth() uint32 RecurseSubmodules() bool // Will be empty instead of "." for root directory SubDirPath() string // contains filtered or unexported methods }
GitRef is a git reference.
type HasFormat ¶
type HasFormat interface {
Format() string
}
HasFormat is an object that has a format.
type ModuleFormatOption ¶
type ModuleFormatOption func(*moduleFormatInfo)
ModuleFormatOption is a module format option.
type ModuleRef ¶
type ModuleRef interface { Ref ModuleReference() bufmoduleref.ModuleReference // contains filtered or unexported methods }
ModuleRef is a module reference.
func NewModuleRef ¶
NewModuleRef returns a new ModuleRef.
The path must be in the form server/owner/repository/branch[:digest].
type ParsedArchiveRef ¶
type ParsedArchiveRef interface { ArchiveRef HasFormat }
ParsedArchiveRef is a parsed ArchiveRef.
func NewDirectParsedArchiveRef ¶
func NewDirectParsedArchiveRef( format string, path string, fileScheme FileScheme, archiveType ArchiveType, compressionType CompressionType, stripComponents uint32, subDirPath string, ) ParsedArchiveRef
NewDirectParsedArchiveRef returns a new ParsedArchiveRef with no validation checks.
This should only be used for testing.
type ParsedBucketRef ¶
ParsedBucketRef is a parsed BucketRef.
type ParsedDirRef ¶
ParsedDirRef is a parsed DirRef.
func NewDirectParsedDirRef ¶
func NewDirectParsedDirRef(format string, path string) ParsedDirRef
NewDirectParsedDirRef returns a new ParsedDirRef with no validation checks.
This should only be used for testing.
type ParsedFileRef ¶
ParsedFileRef is a parsed FileRef.
type ParsedGitRef ¶
ParsedGitRef is a parsed GitRef.
func NewDirectParsedGitRef ¶
func NewDirectParsedGitRef( format string, path string, gitScheme GitScheme, gitName git.Name, recurseSubmodules bool, depth uint32, subDirPath string, ) ParsedGitRef
NewDirectParsedGitRef returns a new ParsedGitRef with no validation checks.
This should only be used for testing.
type ParsedModuleRef ¶
ParsedModuleRef is a parsed ModuleRef.
func NewDirectParsedModuleRef ¶
func NewDirectParsedModuleRef( format string, moduleReference bufmoduleref.ModuleReference, ) ParsedModuleRef
NewDirectParsedModuleRef returns a new ParsedModuleRef with no validation checks.
This should only be used for testing.
type ParsedProtoFileRef ¶ added in v1.0.0
type ParsedProtoFileRef interface { ProtoFileRef HasFormat }
ParsedProtoFileRef is a parsed ProtoFileRef.
type ParsedSingleRef ¶
ParsedSingleRef is a parsed SingleRef.
func NewDirectParsedSingleRef ¶
func NewDirectParsedSingleRef( format string, path string, fileScheme FileScheme, compressionType CompressionType, ) ParsedSingleRef
NewDirectParsedSingleRef returns a new ParsedSingleRef with no validation checks.
This should only be used for testing.
type ProtoFileFormatOption ¶ added in v1.0.0
type ProtoFileFormatOption func(*protoFileFormatInfo)
ProtoFileFormatOption is a single file format option.
type ProtoFileRef ¶ added in v1.0.0
type ProtoFileRef interface { BucketRef // Path is the normalized path to the file reference. Path() string // IncludePackageFiles says to include the same package files TODO update comment IncludePackageFiles() bool // contains filtered or unexported methods }
ProtoFileRef is a file reference that incorporates a BucketRef.
type PutFileOption ¶
type PutFileOption func(*putFileOptions)
PutFileOption is a PutFile option.
func WithPutFileNoFileCompression ¶
func WithPutFileNoFileCompression() PutFileOption
WithPutFileNoFileCompression says to put s uncompressed.
type RawRef ¶
type RawRef struct { // Will always be set // Not normalized yet Path string // Will always be set // Set via RawRefProcessor if not explicitly set Format string // Only set for single, archive formats // Cannot be set for zip archives CompressionType CompressionType // Only set for archive, git formats SubDirPath string // Only set for git formats // Only one of GitBranch and GitTag will be set GitBranch string // Only set for git formats // Only one of GitBranch and GitTag will be set GitTag string // Only set for git formats // Specifies an exact git reference to use with git checkout. // Can be used on its own or with GitBranch. Not allowed with GitTag. // This is defined as anything that can be given to git checkout. GitRef string // Only set for git formats GitRecurseSubmodules bool // Only set for git formats. // The depth to use when cloning a repository. Only allowed when GitRef // is set. Defaults to 50 if unset. GitDepth uint32 // Only set for archive formats ArchiveStripComponents uint32 // Only set for proto file ref format. // Sets whether or not to include the files in the rest of the package // in the image for the ProtoFileRef. // This defaults to false. IncludePackageFiles bool }
RawRef is an unprocessed ref used for WithRefProcessor.
A RawRefProcessor will allow modifications to a RawRef before continuing parsing. This allows defaults to be inferred from the path.
The Path will be the only value set when the RawRefProcessor is invoked, and is not normalized. After the RawRefProcessor is called, options will be parsed.
type ReadBucketCloser ¶
type ReadBucketCloser interface { storage.ReadBucketCloser // RelativeRootPath is the relative path to the root of the bucket // based on the current working directory. // // This will be set if a terminate filename was specified and found. RelativeRootPath() string // SubDirPath is the subdir within the Bucket of the actual asset. // // This will be set if a terminate filename was specified and found. // If so, the actual Bucket will be the directory that contained // this terminate file, and the subdir will be the subdir of // the actual asset relative to the terminate file. SubDirPath() string // SetSubDirPath sets the value of `SubDirPath`. // // This should only be called if a terminate file name was specified and found outside of // a workspace where the bucket is originally closed. SetSubDirPath(string) }
ReadBucketCloser is a bucket returned from GetBucket.
type ReadBucketCloserWithTerminateFileProvider ¶ added in v1.0.0
type ReadBucketCloserWithTerminateFileProvider interface { ReadBucketCloser // TerminateFileProvider returns a TerminateFileProvider. TerminateFileProvider() TerminateFileProvider }
ReadBucketCloserWithTerminateFileProvider is a ReadBucketCloser with a TerminateFileProvider.
type ReadWriteBucketCloser ¶
type ReadWriteBucketCloser interface { ReadBucketCloser storage.WriteBucket }
ReadWriteBucketCloser is a bucket potentially returned from GetBucket.
The returned ReadBucketCloser may be upgradeable to a ReadWriteBucketCloser.
type Reader ¶
type Reader interface { // GetFile gets the file. // SingleRefs and ArchiveRefs will result in decompressed files unless KeepFileCompression is set. GetFile( ctx context.Context, container app.EnvStdinContainer, fileRef FileRef, options ...GetFileOption, ) (io.ReadCloser, error) // GetBucket gets the bucket. // // The returned ReadBucketCloser may actually be upgradeable to a ReadWriteBucketCloser. GetBucket( ctx context.Context, container app.EnvStdinContainer, bucketRef BucketRef, options ...GetBucketOption, ) (ReadBucketCloserWithTerminateFileProvider, error) // GetModule gets the module. GetModule( ctx context.Context, container app.EnvStdinContainer, moduleRef ModuleRef, options ...GetModuleOption, ) (bufmodule.Module, error) }
Reader is a reader.
type ReaderOption ¶
type ReaderOption func(*reader)
ReaderOption is a Reader option.
func WithReaderGit ¶
func WithReaderGit(gitCloner git.Cloner) ReaderOption
WithReaderGit enables Git.
func WithReaderHTTP ¶
func WithReaderHTTP(httpClient *http.Client, httpAuthenticator httpauth.Authenticator) ReaderOption
WithReaderHTTP enables HTTP.
func WithReaderModule ¶
func WithReaderModule( moduleResolver bufmodule.ModuleResolver, moduleReader bufmodule.ModuleReader, ) ReaderOption
WithReaderModule enables modules.
type RefParser ¶
type RefParser interface { // GetParsedRef gets the ParsedRef for the value. // // The returned ParsedRef will be either a ParsedSingleRef, ParsedArchiveRef, ParsedDirRef, ParsedGitRef, or ParsedModuleRef. // // The options should be used to validate that you are getting one of the correct formats. GetParsedRef(ctx context.Context, value string, options ...GetParsedRefOption) (ParsedRef, error) }
RefParser parses references.
func NewRefParser ¶
func NewRefParser(logger *zap.Logger, options ...RefParserOption) RefParser
NewRefParser returns a new RefParser.
type RefParserOption ¶
type RefParserOption func(*refParser)
RefParserOption is an RefParser option.
func WithArchiveFormat ¶
func WithArchiveFormat(format string, archiveType ArchiveType, options ...ArchiveFormatOption) RefParserOption
WithArchiveFormat attaches the given format as an archive format.
It is up to the user to not incorrectly attached a format twice.
func WithDirFormat ¶
func WithDirFormat(format string, options ...DirFormatOption) RefParserOption
WithDirFormat attaches the given format as a dir format.
It is up to the user to not incorrectly attached a format twice.
func WithGitFormat ¶
func WithGitFormat(format string, options ...GitFormatOption) RefParserOption
WithGitFormat attaches the given format as a git format.
It is up to the user to not incorrectly attached a format twice.
func WithModuleFormat ¶
func WithModuleFormat(format string, options ...ModuleFormatOption) RefParserOption
WithModuleFormat attaches the given format as a module format.
It is up to the user to not incorrectly attach a format twice.
func WithProtoFileFormat ¶ added in v1.0.0
func WithProtoFileFormat(format string, options ...ProtoFileFormatOption) RefParserOption
WithProtoFileFormat attaches the given format as a single file format.
It is up to the user to not incorrectly attach a format twice.
func WithRawRefProcessor ¶
func WithRawRefProcessor(rawRefProcessor func(*RawRef) error) RefParserOption
WithRawRefProcessor attaches the given RawRefProcessor.
If format is not manually specified, the RefParser will use this format parser with the raw path, that is not normalized.
func WithSingleFormat ¶
func WithSingleFormat(format string, options ...SingleFormatOption) RefParserOption
WithSingleFormat attaches the given format as a single format.
It is up to the user to not incorrectly attached a format twice.
type SingleFormatOption ¶
type SingleFormatOption func(*singleFormatInfo)
SingleFormatOption is a single format option.
func WithSingleDefaultCompressionType ¶
func WithSingleDefaultCompressionType(defaultCompressionType CompressionType) SingleFormatOption
WithSingleDefaultCompressionType sets the default compression type.
type SingleRef ¶
type SingleRef interface { FileRef // contains filtered or unexported methods }
SingleRef is a non-archive file reference.
func NewSingleRef ¶
func NewSingleRef(path string, compressionType CompressionType) (SingleRef, error)
NewSingleRef returns a new SingleRef.
type TerminateFile ¶ added in v1.0.0
type TerminateFile interface { // Name returns the name of the TerminateFile (i.e. the base of the fully-qualified file paths). Name() string // Path returns the normalized directory path where the TemrinateFile is located. Path() string }
TerminateFile is a terminate file.
type TerminateFileProvider ¶ added in v1.0.0
type TerminateFileProvider interface { // GetTerminateFiles returns the list of terminate files in priority order. GetTerminateFiles() []TerminateFile }
TerminateFileProvider provides TerminateFiles.
type Writer ¶
type Writer interface { // PutFile puts the file. PutFile( ctx context.Context, container app.EnvStdoutContainer, fileRef FileRef, options ...PutFileOption, ) (io.WriteCloser, error) }
Writer is a writer.
Source Files ¶
- archive_ref.go
- dir_ref.go
- errors.go
- git_ref.go
- internal.go
- module_ref.go
- proto_file_ref.go
- read_bucket_closer.go
- read_bucket_closer_terminate_file_provider.go
- read_write_bucket_closer.go
- reader.go
- ref_parser.go
- single_ref.go
- terminate_file.go
- terminate_file_provider.go
- usage.gen.go
- util.go
- writer.go