Documentation ¶
Index ¶
- Constants
- Variables
- func AddCloser(reader io.ReadCloser, closer io.Closer, msg ...string) io.ReadCloser
- func ApplyOptions(opts Options, olist ...Option) error
- func BlobData(blob DataGetter, err error) ([]byte, error)
- func BlobReader(blob DataReader, err error) (io.ReadCloser, error)
- func Close(closer ...io.Closer) error
- func CloseTemporary(c io.Closer) error
- func DefaultedFileSystem(def vfs.FileSystem, fss ...vfs.FileSystem) vfs.FileSystem
- func Digest(access DataAccess) (digest.Digest, error)
- func ErrBlobNotFound(digest digest.Digest) error
- func ErrInvalidFileFormat(fmt string) error
- func FileSystem(fss ...vfs.FileSystem) vfs.FileSystem
- func GetFormats() []string
- func GetFormatsFor[T any](fileFormats map[FileFormat]T) []string
- func IsErrBlobNotFound(err error) bool
- func Lazy(o interface{}) bool
- func LimitWriter(w io.Writer, n int64) io.Writer
- func NewFileBuffer() (*fileBuffer, error)
- func NewOndemandReader(p ReaderProvider) io.ReadCloser
- func NopWriteCloser(w io.Writer) io.WriteCloser
- func OnceCloser(c io.Closer, callbacks ...CloserCallback) io.Closer
- func PropagateCloseTemporary(errp *error, c io.Closer)
- func ReadCloser(r io.Reader) io.ReadCloser
- func TypeForType(t string) string
- func VerifyingReader(r io.ReadCloser, digest digest.Digest) io.ReadCloser
- func VerifyingReaderWithHash(r io.ReadCloser, hash crypto.Hash, digest string) io.ReadCloser
- type Allocatable
- type AnnotatedBlobAccess
- type BlobAccess
- func BlobAccessForData(mimeType string, data []byte) BlobAccess
- func BlobAccessForFile(mimeType string, path string, fs vfs.FileSystem) BlobAccess
- func BlobAccessForString(mimeType string, data string) BlobAccess
- func BlobNopCloser(blob BlobAccess) BlobAccess
- func BlobWithMimeType(mimeType string, blob BlobAccess) BlobAccess
- type BlobCache
- func CachedAccess(src BlobSource, dst BlobSink, cache BlobCache) (BlobCache, error)
- func NewCascadedBlobCache(parent BlobCache) (BlobCache, error)
- func NewCascadedBlobCacheForCache(parent BlobSource, src BlobCache) (BlobCache, error)
- func NewCascadedBlobCacheForSource(parent BlobSource, src BlobSource) (BlobCache, error)
- func NewDefaultBlobCache(fss ...vfs.FileSystem) (BlobCache, error)
- func NewStaticBlobCache(path string, fss ...vfs.FileSystem) (BlobCache, error)
- func NoRefBlobCache(s BlobCache) BlobCache
- type BlobSink
- type BlobSource
- type Buffer
- type CleanupCache
- type Closer
- type CloserCallback
- type CloserView
- type CountingReader
- type CountingWriter
- type DataAccess
- type DataGetter
- type DataReader
- type DataSource
- type DataWriter
- type DigestReader
- type DigestSource
- type DigestWriter
- type FileFormat
- type LazyMode
- type LimitedBuffer
- type LimitedWriter
- type MimeType
- type MultiViewBlobAccess
- type NopCloser
- type OnDemandReader
- type Option
- type Options
- type ReaderProvider
- type RefMgmt
- type ReferencableCloser
- type ResettableReader
- type RootedCache
- type StandardOptions
- func (o *StandardOptions) ApplyOption(options Options) error
- func (o *StandardOptions) Default()
- func (o *StandardOptions) DefaultForPath(path string) error
- func (o *StandardOptions) DefaultFormat(fmt FileFormat)
- func (o *StandardOptions) GetFile() vfs.File
- func (o *StandardOptions) GetFileFormat() *FileFormat
- func (o *StandardOptions) GetPathFileSystem() vfs.FileSystem
- func (o *StandardOptions) GetReader() io.Reader
- func (o *StandardOptions) GetRepresentation() vfs.FileSystem
- func (o *StandardOptions) SetFile(file vfs.File)
- func (o *StandardOptions) SetFileFormat(format FileFormat)
- func (o *StandardOptions) SetPathFileSystem(fs vfs.FileSystem)
- func (o *StandardOptions) SetReader(r io.Reader)
- func (o *StandardOptions) SetRepresentation(fs vfs.FileSystem)
- func (o *StandardOptions) ValidForPath(path string) error
- func (o *StandardOptions) WriterFor(path string, mode vfs.FileMode) (io.WriteCloser, error)
- type StaticAllocatable
- type TempFile
- type TemporaryBlobAccess
- type TemporaryFileSystemBlobAccess
- type Writer
Constants ¶
const ( KIND_BLOB = "blob" KIND_MEDIATYPE = "media type" )
const ( BLOB_UNKNOWN_SIZE = int64(-1) BLOB_UNKNOWN_DIGEST = digest.Digest("") )
const ACCESS_SUFFIX = ".acc"
ACCESS_SUFFIX is the suffix of an additional blob related file used to track the last access time by its modification time, because Go does not support a platform independent way to access the last access time attribute of a filesystem.
const DESCRIPTOR_LIMIT = int64(8196 * 4)
const KIND_FILEFORMAT = "file format"
Variables ¶
var ( ErrClosed = errors.ErrClosed() ErrReadOnly = errors.ErrReadOnly() )
var ALLOC_REALM = logging.DefineSubRealm("reference counting", "refcnt")
Functions ¶
func AddCloser ¶
func AddCloser(reader io.ReadCloser, closer io.Closer, msg ...string) io.ReadCloser
func ApplyOptions ¶
ApplyOptions applies the given list options on these options.
func BlobReader ¶
func BlobReader(blob DataReader, err error) (io.ReadCloser, error)
func CloseTemporary ¶
func DefaultedFileSystem ¶
func DefaultedFileSystem(def vfs.FileSystem, fss ...vfs.FileSystem) vfs.FileSystem
func Digest ¶
func Digest(access DataAccess) (digest.Digest, error)
func ErrBlobNotFound ¶
func ErrBlobNotFound(digest digest.Digest) error
func ErrInvalidFileFormat ¶
func FileSystem ¶
func FileSystem(fss ...vfs.FileSystem) vfs.FileSystem
func GetFormats ¶
func GetFormats() []string
func GetFormatsFor ¶
func GetFormatsFor[T any](fileFormats map[FileFormat]T) []string
func IsErrBlobNotFound ¶
func LimitWriter ¶
LimitWriter returns a Writer that writes to w but stops with EOF after n bytes. The underlying implementation is a *LimitedWriter.
func NewFileBuffer ¶
func NewFileBuffer() (*fileBuffer, error)
func NewOndemandReader ¶
func NewOndemandReader(p ReaderProvider) io.ReadCloser
func NopWriteCloser ¶
func NopWriteCloser(w io.Writer) io.WriteCloser
NopWriteCloser returns a ReadCloser with a no-op Close method wrapping the provided Reader r.
func OnceCloser ¶
func OnceCloser(c io.Closer, callbacks ...CloserCallback) io.Closer
func PropagateCloseTemporary ¶
func ReadCloser ¶
func ReadCloser(r io.Reader) io.ReadCloser
func TypeForType ¶
func VerifyingReader ¶
func VerifyingReader(r io.ReadCloser, digest digest.Digest) io.ReadCloser
func VerifyingReaderWithHash ¶
func VerifyingReaderWithHash(r io.ReadCloser, hash crypto.Hash, digest string) io.ReadCloser
Types ¶
type Allocatable ¶
type AnnotatedBlobAccess ¶
type AnnotatedBlobAccess[T DataAccess] interface { Source() T // contains filtered or unexported methods }
AnnotatedBlobAccess provides access to the original underlying data source.
func BlobAccessForDataAccess ¶
func BlobAccessForDataAccess[T DataAccess](digest digest.Digest, size int64, mimeType string, access T) AnnotatedBlobAccess[T]
type BlobAccess ¶
type BlobAccess interface { DataAccess DigestSource MimeType // DigestKnown reports whether digest is already known DigestKnown() bool // Size returns the blob size Size() int64 }
BlobAccess describes the access to a blob.
func BlobAccessForData ¶
func BlobAccessForData(mimeType string, data []byte) BlobAccess
func BlobAccessForFile ¶
func BlobAccessForFile(mimeType string, path string, fs vfs.FileSystem) BlobAccess
func BlobAccessForString ¶
func BlobAccessForString(mimeType string, data string) BlobAccess
func BlobNopCloser ¶
func BlobNopCloser(blob BlobAccess) BlobAccess
func BlobWithMimeType ¶
func BlobWithMimeType(mimeType string, blob BlobAccess) BlobAccess
type BlobCache ¶
type BlobCache interface { BlobSource BlobSink AddData(data DataAccess) (int64, digest.Digest, error) }
func CachedAccess ¶
func CachedAccess(src BlobSource, dst BlobSink, cache BlobCache) (BlobCache, error)
func NewCascadedBlobCache ¶
func NewCascadedBlobCacheForCache ¶
func NewCascadedBlobCacheForCache(parent BlobSource, src BlobCache) (BlobCache, error)
func NewCascadedBlobCacheForSource ¶
func NewCascadedBlobCacheForSource(parent BlobSource, src BlobSource) (BlobCache, error)
func NewDefaultBlobCache ¶
func NewDefaultBlobCache(fss ...vfs.FileSystem) (BlobCache, error)
func NewStaticBlobCache ¶
func NewStaticBlobCache(path string, fss ...vfs.FileSystem) (BlobCache, error)
func NoRefBlobCache ¶
type BlobSink ¶
type BlobSink interface { Allocatable AddBlob(blob BlobAccess) (int64, digest.Digest, error) }
func NoRefBlobSink ¶
type BlobSource ¶
type BlobSource interface { Allocatable GetBlobData(digest digest.Digest) (int64, DataAccess, error) }
func NoRefBlobSource ¶
func NoRefBlobSource(s BlobSource) BlobSource
type CleanupCache ¶
type CleanupCache interface { // Cleanup can be implemented to offer a cache reorg. // It returns the number and size of // - handled entries (cnt, size) // - not handled entries (ncnt, nsize) // - failing entries (fcnt, fsize) Cleanup(p common.Printer, before *time.Time, dryrun bool) (cnt int, ncnt int, fcnt int, size int64, nsize int64, fsize int64, err error) }
type CloserCallback ¶
type CloserCallback func()
type CloserView ¶
type CountingReader ¶
type CountingReader struct {
// contains filtered or unexported fields
}
func NewCountingReader ¶
func NewCountingReader(r io.Reader) *CountingReader
func (*CountingReader) Size ¶
func (r *CountingReader) Size() int64
type CountingWriter ¶
type CountingWriter struct {
// contains filtered or unexported fields
}
func NewCountingWriter ¶
func NewCountingWriter(w io.Writer) *CountingWriter
func (*CountingWriter) Size ¶
func (w *CountingWriter) Size() int64
type DataAccess ¶
type DataAccess interface { DataGetter DataReader io.Closer }
DataAccess describes the access to sequence of bytes.
func DataAccessForFile ¶
func DataAccessForFile(fs vfs.FileSystem, path string) DataAccess
func DataAccessForReaderFunction ¶
func DataAccessForReaderFunction(reader func() (io.ReadCloser, error), origin string) DataAccess
type DataGetter ¶
type DataReader ¶
type DataReader interface { // Reader returns a reader to incrementally access byte stream content Reader() (io.ReadCloser, error) }
type DataSource ¶
type DataSource interface { DataAccess Origin() string }
DataSource describes some data plus its origin.
func DataAccessForBytes ¶
func DataAccessForBytes(data []byte, origin ...string) DataSource
func DataAccessForString ¶
func DataAccessForString(data string, origin ...string) DataSource
type DataWriter ¶
func NewDataAccessWriter ¶
func NewDataAccessWriter(acc DataAccess) DataWriter
func NewReaderWriter ¶
func NewReaderWriter(r io.ReadCloser) DataWriter
func NewWriteAtWriter ¶
func NewWriteAtWriter(at func(w io.WriterAt) error) DataWriter
type DigestReader ¶
type DigestReader struct {
// contains filtered or unexported fields
}
func NewDefaultDigestReader ¶
func NewDefaultDigestReader(r io.Reader) *DigestReader
func NewDigestReaderWith ¶
func NewDigestReaderWith(algorithm digest.Algorithm, r io.Reader) *DigestReader
func NewDigestReaderWithHash ¶
func NewDigestReaderWithHash(hash crypto.Hash, r io.Reader) *DigestReader
func (*DigestReader) Digest ¶
func (r *DigestReader) Digest() digest.Digest
func (*DigestReader) Size ¶
func (r *DigestReader) Size() int64
type DigestSource ¶
type DigestSource interface {
// Digest returns the blob digest
Digest() digest.Digest
}
type DigestWriter ¶
type DigestWriter struct {
// contains filtered or unexported fields
}
func NewDefaultDigestWriter ¶
func NewDefaultDigestWriter(w io.WriteCloser) *DigestWriter
func NewDigestWriterWith ¶
func NewDigestWriterWith(algorithm digest.Algorithm, w io.WriteCloser) *DigestWriter
func (*DigestWriter) Digest ¶
func (r *DigestWriter) Digest() digest.Digest
func (*DigestWriter) Size ¶
func (r *DigestWriter) Size() int64
type FileFormat ¶
type FileFormat string
const ( FormatTar FileFormat = "tar" FormatTGZ FileFormat = "tgz" FormatDirectory FileFormat = "directory" )
func DetectFormat ¶
func DetectFormat(path string, fs vfs.FileSystem) (*FileFormat, error)
func DetectFormatForFile ¶
func DetectFormatForFile(file vfs.File) (*FileFormat, error)
func FileFormatForType ¶
func FileFormatForType(t string) FileFormat
func (FileFormat) ApplyOption ¶
func (o FileFormat) ApplyOption(options Options) error
func (FileFormat) String ¶
func (f FileFormat) String() string
func (FileFormat) Suffix ¶
func (f FileFormat) Suffix() string
type LimitedBuffer ¶
type LimitedBuffer struct { *LimitedWriter // contains filtered or unexported fields }
func LimitBuffer ¶
func LimitBuffer(n int64) *LimitedBuffer
func (*LimitedBuffer) Bytes ¶
func (b *LimitedBuffer) Bytes() []byte
func (*LimitedBuffer) Exceeded ¶
func (b *LimitedBuffer) Exceeded() bool
type LimitedWriter ¶
A LimitedWriter writes to W but limits the amount of data written to just N bytes. Each call to Write updates N to reflect the new amount remaining. Write returns EOF when N <= 0 or when the underlying W returns EOF.
type MimeType ¶
type MimeType interface { // MimeType returns the mime type of the blob MimeType() string }
type MultiViewBlobAccess ¶
type MultiViewBlobAccess struct {
// contains filtered or unexported fields
}
func NewMultiViewBlobAccess ¶
func NewMultiViewBlobAccess(acc BlobAccess) *MultiViewBlobAccess
func (*MultiViewBlobAccess) View ¶
func (m *MultiViewBlobAccess) View() (BlobAccess, error)
type OnDemandReader ¶
type OnDemandReader struct {
// contains filtered or unexported fields
}
func (*OnDemandReader) Close ¶
func (o *OnDemandReader) Close() error
type Option ¶
Option is the interface to specify different archive options.
func PathFileSystem ¶
func PathFileSystem(fs vfs.FileSystem) Option
PathFileSystem set the evaluation filesystem for the path name.
func RepresentationFileSystem ¶
func RepresentationFileSystem(fs vfs.FileSystem) Option
RepresentationFileSystem set the evaltuation filesystem for the path name.
type Options ¶
type Options interface { Option SetFileFormat(FileFormat) GetFileFormat() *FileFormat SetPathFileSystem(vfs.FileSystem) GetPathFileSystem() vfs.FileSystem SetRepresentation(vfs.FileSystem) GetRepresentation() vfs.FileSystem SetFile(vfs.File) GetFile() vfs.File SetReader(closer io.Reader) GetReader() io.Reader ValidForPath(path string) error WriterFor(path string, mode vfs.FileMode) (io.WriteCloser, error) DefaultFormat(fmt FileFormat) Default() DefaultForPath(path string) error }
type ReaderProvider ¶
type ReaderProvider interface {
Reader() (io.ReadCloser, error)
}
type RefMgmt ¶
type RefMgmt interface { Allocatable UnrefLast() error IsClosed() bool WithName(name string) RefMgmt }
func NewAllocatable ¶
type ReferencableCloser ¶
type ReferencableCloser interface { Allocatable UnrefLast() error IsClosed() bool Closer() io.Closer View(main ...bool) (CloserView, error) WithName(name string) ReferencableCloser }
ReferencableCloser manages closable views to a basic closer. If the last view is closed, the basic closer is finally closed.
func NewRefCloser ¶
func NewRefCloser(closer io.Closer, unused ...bool) ReferencableCloser
type ResettableReader ¶
type ResettableReader struct {
// contains filtered or unexported fields
}
func NewResettableReader ¶
func NewResettableReader(orig io.ReadCloser, size int64) (*ResettableReader, error)
func (*ResettableReader) Close ¶
func (b *ResettableReader) Close() error
func (*ResettableReader) Reset ¶
func (b *ResettableReader) Reset() (io.ReadCloser, error)
type RootedCache ¶
type RootedCache interface {
Root() (string, vfs.FileSystem)
}
type StandardOptions ¶
type StandardOptions struct { // FilePath is the path of the repository base in the filesystem FileFormat *FileFormat `json:"fileFormat,omitempty"` // FileSystem is the virtual filesystem to evaluate the file path. Default is the OS filesytem // or the filesystem defined as base filesystem for the context // This configuration option is not available for the textual representation of // the repository specification PathFileSystem vfs.FileSystem `json:"-"` // Representation is the virtual filesystem to represent the active repository cache. // This configuration option is not available for the textual representation of // the repository specification Representation vfs.FileSystem `json:"-"` // File is an opened file object to use instead of the path and path filesystem // It should never be closed if given to support temporary files File vfs.File `json:"-"` // Reader provides a one time access to the content (archive content only) // The resulting access is therefore temporary and cannot be written back // to its origin, but to other destinations. // The reader must be closed by the provider. Reader io.Reader `json:"-"` }
func (*StandardOptions) ApplyOption ¶
func (o *StandardOptions) ApplyOption(options Options) error
func (*StandardOptions) Default ¶
func (o *StandardOptions) Default()
func (*StandardOptions) DefaultForPath ¶
func (o *StandardOptions) DefaultForPath(path string) error
func (*StandardOptions) DefaultFormat ¶
func (o *StandardOptions) DefaultFormat(fmt FileFormat)
func (*StandardOptions) GetFile ¶
func (o *StandardOptions) GetFile() vfs.File
func (*StandardOptions) GetFileFormat ¶
func (o *StandardOptions) GetFileFormat() *FileFormat
func (*StandardOptions) GetPathFileSystem ¶
func (o *StandardOptions) GetPathFileSystem() vfs.FileSystem
func (*StandardOptions) GetReader ¶
func (o *StandardOptions) GetReader() io.Reader
func (*StandardOptions) GetRepresentation ¶
func (o *StandardOptions) GetRepresentation() vfs.FileSystem
func (*StandardOptions) SetFile ¶
func (o *StandardOptions) SetFile(file vfs.File)
func (*StandardOptions) SetFileFormat ¶
func (o *StandardOptions) SetFileFormat(format FileFormat)
func (*StandardOptions) SetPathFileSystem ¶
func (o *StandardOptions) SetPathFileSystem(fs vfs.FileSystem)
func (*StandardOptions) SetReader ¶
func (o *StandardOptions) SetReader(r io.Reader)
func (*StandardOptions) SetRepresentation ¶
func (o *StandardOptions) SetRepresentation(fs vfs.FileSystem)
func (*StandardOptions) ValidForPath ¶
func (o *StandardOptions) ValidForPath(path string) error
func (*StandardOptions) WriterFor ¶
func (o *StandardOptions) WriterFor(path string, mode vfs.FileMode) (io.WriteCloser, error)
type StaticAllocatable ¶
type StaticAllocatable struct{}
func (StaticAllocatable) Ref ¶
func (_ StaticAllocatable) Ref() error
func (StaticAllocatable) Unref ¶
func (_ StaticAllocatable) Unref() error
type TempFile ¶
type TempFile struct {
// contains filtered or unexported fields
}
TempFile holds a temporary file that should be kept open. Close should never be called directly. It can be passed to another responsibility realm by calling Release For example to be transformed into a TemporaryBlobAccess. Close will close and remove an unreleased file and does nothing if it has been released. If it has been releases the new realm is responsible. to close and remove it.
func NewTempFile ¶
func (*TempFile) AsBlob ¶
func (t *TempFile) AsBlob(mime string) TemporaryFileSystemBlobAccess
func (*TempFile) FileSystem ¶
func (t *TempFile) FileSystem() vfs.FileSystem
type TemporaryBlobAccess ¶
type TemporaryBlobAccess interface { IsValid() bool // contains filtered or unexported methods }
TemporaryBlobAccess describes a blob with temporary allocated external resources. They will be releases, when the close method is called.
func ReferencingBlobAccess ¶
func ReferencingBlobAccess(b BlobAccess, closer func() error) TemporaryBlobAccess
func TemporaryBlobAccessFor ¶
func TemporaryBlobAccessFor(blob BlobAccess) TemporaryBlobAccess
func TemporaryBlobAccessForBlob ¶
func TemporaryBlobAccessForBlob(blob BlobAccess) TemporaryBlobAccess
TemporaryBlobAccessForBlob returns a temporary blob for any blob, which gets invalidated whenever closed.
type TemporaryFileSystemBlobAccess ¶
type TemporaryFileSystemBlobAccess interface { FileSystem() vfs.FileSystem Path() string // contains filtered or unexported methods }
func TempFileBlobAccess ¶
func TempFileBlobAccess(mime string, fs vfs.FileSystem, temp vfs.File) TemporaryFileSystemBlobAccess
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package resource provides support to implement closeable backing resources featuring multiple separately closeable references.
|
Package resource provides support to implement closeable backing resources featuring multiple separately closeable references. |