Documentation ¶
Overview ¶
Package storage implements the various backend storage types
Index ¶
- func Export(s Storage, id string, w io.Writer) error
- func Import(s Storage, id string, r io.Reader) error
- func Register(name string, s func(config.Config) (Storage, error))
- type BlobReader
- type BlobWriter
- type DiffEntry
- type DiffReport
- type Dir
- type DirEntry
- type EntryKind
- type FSStorage
- func (fs *FSStorage) BlobCreate() (BlobWriter, error)
- func (fs *FSStorage) BlobOpen(blob string) (BlobReader, error)
- func (fs *FSStorage) Flush() error
- func (fs *FSStorage) Index() Index
- func (fs *FSStorage) PruneCache(time.Duration) error
- func (fs *FSStorage) PruneStorage() error
- func (fs *FSStorage) RootCreate() (string, *Root, error)
- func (fs *FSStorage) RootCreateFrom(hash string) (string, *Root, error)
- func (fs *FSStorage) RootOpen(name string) (*Root, error)
- func (fs *FSStorage) RootSave(r *Root) (string, error)
- type File
- type Index
- type IndexRoot
- type MemStorage
- func (m *MemStorage) BlobCreate() (BlobWriter, error)
- func (m *MemStorage) BlobOpen(blob string) (BlobReader, error)
- func (m *MemStorage) Flush() error
- func (m *MemStorage) Index() Index
- func (m *MemStorage) PruneCache(time.Duration) error
- func (m *MemStorage) PruneStorage() error
- func (m *MemStorage) RootCreate() (string, *Root, error)
- func (m *MemStorage) RootCreateFrom(hash string) (string, *Root, error)
- func (m *MemStorage) RootOpen(name string) (*Root, error)
- func (m *MemStorage) RootSave(r *Root) (string, error)
- type Root
- func (r *Root) EntryHash(path []string) (string, error)
- func (r *Root) Link(path []string, blob string) error
- func (r *Root) List(path []string) (map[string]*DirEntry, error)
- func (r *Root) ListHashes() ([]string, error)
- func (r *Root) Read(path []string) (BlobReader, error)
- func (r *Root) ReadOnly() bool
- func (r *Root) Save() (string, error)
- func (r *Root) Walk(fns WalkFns) error
- func (r *Root) Write(path []string) (BlobWriter, error)
- type Storage
- type WalkFns
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BlobReader ¶
type BlobReader interface { io.ReadSeekCloser Size() int64 }
BlobReader is used to read blobs
type BlobWriter ¶
type BlobWriter interface { io.WriteCloser // Hash is available after the writer is closed Hash() (string, error) }
BlobWriter is used when writing blobs
type DiffReport ¶
type DiffReport struct { R1 string `json:"r1"` // hash of root 1 R2 string `json:"r2"` // hash of root 2 Entries []DiffEntry `json:"entries"` }
func DiffRoots ¶
func DiffRoots(r1, r2 *Root) (DiffReport, error)
DiffRoots compares two roots and returns a list of differences TODO: improve entry to show more than the hash and to package request/response into a single entry?
type EntryKind ¶
type EntryKind int
func (EntryKind) MarshalText ¶
func (*EntryKind) UnmarshalText ¶
type FSStorage ¶
type FSStorage struct {
// contains filtered or unexported fields
}
func (*FSStorage) BlobCreate ¶
func (fs *FSStorage) BlobCreate() (BlobWriter, error)
BlobCreate returns a writer for a blob
func (*FSStorage) BlobOpen ¶
func (fs *FSStorage) BlobOpen(blob string) (BlobReader, error)
BlobOpen returns a reader for a blob
func (*FSStorage) PruneCache ¶
PruneCache deletes any data from memory or cache that hasn't been recently accessed
func (*FSStorage) PruneStorage ¶
PruneStorage deletes any blobs that are not used by any root
func (*FSStorage) RootCreate ¶
RootCreate returns a new root using a uuid
func (*FSStorage) RootCreateFrom ¶
RootCreateFrom returns a new root using a uuid initialized from an existing hash
type MemStorage ¶
type MemStorage struct {
// contains filtered or unexported fields
}
func (*MemStorage) BlobCreate ¶
func (m *MemStorage) BlobCreate() (BlobWriter, error)
BlobCreate returns a writer for a blob
func (*MemStorage) BlobOpen ¶
func (m *MemStorage) BlobOpen(blob string) (BlobReader, error)
BlobOpen returns a reader for a blob
func (*MemStorage) Flush ¶
func (m *MemStorage) Flush() error
Flush writes any data cached to the backend storage
func (*MemStorage) PruneCache ¶
func (m *MemStorage) PruneCache(time.Duration) error
PruneCache deletes any data from memory or cache that hasn't been recently accessed
func (*MemStorage) PruneStorage ¶
func (m *MemStorage) PruneStorage() error
PruneStorage deletes any blobs that are not used by any root
func (*MemStorage) RootCreate ¶
func (m *MemStorage) RootCreate() (string, *Root, error)
RootCreate returns a new root using a uuid
func (*MemStorage) RootCreateFrom ¶
func (m *MemStorage) RootCreateFrom(hash string) (string, *Root, error)
RootCreateFrom returns a new root using a uuid initialized from an existing hash
type Root ¶
type Root struct {
// contains filtered or unexported fields
}
func (*Root) ListHashes ¶
ListHashes returns a slice of hashes representing all entries in a root
func (*Root) Read ¶
func (r *Root) Read(path []string) (BlobReader, error)
Read returns a reader for a given file
func (*Root) ReadOnly ¶
ReadOnly returns true if the root is read-only (loaded from an immutable hash)
type Storage ¶
type Storage interface { // BlobOpen returns a reader for a blob BlobOpen(blob string) (BlobReader, error) // BlobCreate returns a writer for a blob BlobCreate() (BlobWriter, error) // Flush writes any data cached to the backend storage Flush() error // Index returns the current index Index() Index // PruneCache deletes any data from memory or cache that hasn't been recently accessed PruneCache(time.Duration) error // PruneStorage deletes any blobs that are not used by any root PruneStorage() error // RootCreate returns a new root using a uuid RootCreate() (string, *Root, error) // RootCreateFrom returns a new root using a uuid initialized from an existing hash RootCreateFrom(hash string) (string, *Root, error) // RootOpen returns an existing root RootOpen(name string) (*Root, error) // RootSave saves a root and adds the hash to the index RootSave(r *Root) (string, error) }
Storage is implemented by various backings (memory, disk, OCI registry)