tarsum

package
v1.6.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2015 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotVersion            = errors.New("string does not include a TarSum Version")
	ErrVersionNotImplemented = errors.New("TarSum Version is not yet implemented")
)

Errors that may be returned by functions in this package

View Source
var DefaultTHash = NewTHash("sha256", sha256.New)

TarSum default is "sha256"

Functions

func VersionLabelForChecksum added in v1.5.0

func VersionLabelForChecksum(checksum string) string

VersionLabelForChecksum returns the label for the given tarsum checksum, i.e., everything before the first `+` character in the string or an empty string if no label separator is found.

Types

type BuilderContext added in v1.5.0

type BuilderContext interface {
	TarSum
	Remove(string)
}

This interface extends TarSum by adding the Remove method. In general there was concern about adding this method to TarSum itself so instead it is being added just to "BuilderContext" which will then only be used during the .dockerignore file processing - see builder/evaluator.go

type FileInfoSumInterface added in v1.3.0

type FileInfoSumInterface interface {
	// File name
	Name() string
	// Checksum of this particular file and its headers
	Sum() string
	// Position of file in the tar
	Pos() int64
}

This info will be accessed through interface so the actual name and sum cannot be medled with

type FileInfoSums added in v1.3.0

type FileInfoSums []FileInfoSumInterface

func (FileInfoSums) GetAllFile added in v1.3.0

func (fis FileInfoSums) GetAllFile(name string) FileInfoSums

GetAllFile returns a FileInfoSums with all matching names

func (FileInfoSums) GetDuplicatePaths added in v1.3.0

func (fis FileInfoSums) GetDuplicatePaths() (dups FileInfoSums)

func (FileInfoSums) GetFile added in v1.3.0

func (fis FileInfoSums) GetFile(name string) FileInfoSumInterface

GetFile returns the first FileInfoSumInterface with a matching name

func (FileInfoSums) Len added in v1.3.0

func (fis FileInfoSums) Len() int

func (FileInfoSums) SortByNames added in v1.3.0

func (fis FileInfoSums) SortByNames()

func (FileInfoSums) SortByPos added in v1.3.0

func (fis FileInfoSums) SortByPos()

func (FileInfoSums) SortBySums added in v1.3.0

func (fis FileInfoSums) SortBySums()

func (FileInfoSums) Swap added in v1.3.0

func (fis FileInfoSums) Swap(i, j int)

type THash added in v1.3.0

type THash interface {
	Hash() hash.Hash
	Name() string
}

A hash.Hash type generator and its name

func NewTHash added in v1.3.0

func NewTHash(name string, h func() hash.Hash) THash

Convenience method for creating a THash

type TarSum

type TarSum interface {
	io.Reader
	GetSums() FileInfoSums
	Sum([]byte) string
	Version() Version
	Hash() THash
}

TarSum is the generic interface for calculating fixed time checksums of a tar archive

func NewTarSum added in v1.3.0

func NewTarSum(r io.Reader, dc bool, v Version) (TarSum, error)

NewTarSum creates a new interface for calculating a fixed time checksum of a tar archive.

This is used for calculating checksums of layers of an image, in some cases including the byte payload of the image's json metadata as well, and for calculating the checksums for buildcache.

func NewTarSumForLabel added in v1.5.0

func NewTarSumForLabel(r io.Reader, disableCompression bool, label string) (TarSum, error)

Create a new TarSum using the provided TarSum version+hash label.

func NewTarSumHash added in v1.3.0

func NewTarSumHash(r io.Reader, dc bool, v Version, tHash THash) (TarSum, error)

Create a new TarSum, providing a THash to use rather than the DefaultTHash

type Version added in v1.3.0

type Version int

versioning of the TarSum algorithm based on the prefix of the hash used i.e. "tarsum+sha256:e58fcf7418d4390dec8e8fb69d88c06ec07039d651fedd3aa72af9972e7d046b"

const (
	Version0 Version = iota
	Version1
	// NOTE: this variable will be either the latest or an unsettled next-version of the TarSum calculation
	VersionDev
)

Prefix of "tarsum"

func GetVersionFromTarsum added in v1.3.0

func GetVersionFromTarsum(tarsum string) (Version, error)

GetVersionFromTarsum returns the Version from the provided string

func GetVersions added in v1.3.0

func GetVersions() []Version

Get a list of all known tarsum Version

func (Version) String added in v1.3.0

func (tsv Version) String() string

Jump to

Keyboard shortcuts

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