chunkedarchive

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileArchive

func FileArchive(location string, archive string) error

func FileUnarchive

func FileUnarchive(archive, dest string) error

func StreamArchive

func StreamArchive(output io.Writer, location string) (err error)

StreamArchive and UnarchiveStream stick the chunked archive into a single file. So far this use case is just for local archiving and replacing bytes, but it implements some of the patterns present in crfs/stargz in case that is a future use-case for this format. For the time being we'll assume any network requests for files will download individual chunks from an index, but for now it seemed good to follow in this general direction over picking something arbitrary.

func StreamUnarchive

func StreamUnarchive(sr *io.SectionReader, location string) (err error)

func Unarchive

func Unarchive(toc []TOCEntry, fetcher HashFetcher, location string) (err error)

Types

type BodyWriter

type BodyWriter interface {
	NewChunk(io.ReadCloser) (func() ([]string, error), error)
}

type HashFetcher

type HashFetcher interface {
	Lookup(hash string) (io.ReadCloser, error)
}

type ParallelBodyWriter

type ParallelBodyWriter struct {
	// contains filtered or unexported fields
}

func NewParallelBodyWriter

func NewParallelBodyWriter(numParallel int, cb func(io.ReadCloser) ([]string, error)) *ParallelBodyWriter

func (*ParallelBodyWriter) NewChunk

func (bw *ParallelBodyWriter) NewChunk(body io.ReadCloser) (func() ([]string, error), error)

type TOCEntry

type TOCEntry struct {
	// Name is the tar entry's name. It is the complete path
	// stored in the tar file, not just the base name.
	Name string `json:"name"`

	// Type is one of "dir", "reg", "symlink", "hardlink", "char",
	// "block", "fifo"
	Type string `json:"type"`

	// Size, for regular files, is the logical size of the file.
	Size int64 `json:"size,omitempty"`

	// LinkName, for symlinks and hardlinks, is the link target.
	LinkName string `json:"linkName,omitempty"`

	// Mode is the permission and mode bits.
	Mode int64 `json:"mode,omitempty"`

	// DevMajor is the major device number for "char" and "block" types.
	DevMajor int `json:"devMajor,omitempty"`

	// DevMinor is the major device number for "char" and "block" types.
	DevMinor int `json:"devMinor,omitempty"`

	// NumLink is the number of entry names pointing to this entry.
	// Zero means one name references this entry.
	NumLink int

	// Xattrs are the extended attribute for the entry.
	Xattrs map[string][]byte `json:"xattrs,omitempty"`

	// Body references hashes of body content
	Body []string `json:"digest,omitempty"`
}

TOCEntry is an entry in the file index's TOC (Table of Contents).

func Archive

func Archive(bw BodyWriter, location string) (toc []TOCEntry, err error)

Jump to

Keyboard shortcuts

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