image

package
v0.0.0-...-80cfa99 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2017 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultDockerfileName string = "Dockerfile"
View Source
const WhiteoutMetaPrefix = WhiteoutPrefix + WhiteoutPrefix
View Source
const WhiteoutOpaqueDir = WhiteoutMetaPrefix + ".opq"
View Source
const WhiteoutPrefix = ".wh."

WhiteoutPrefix prefix means file is a whiteout. If this is followed by a filename this means that file has been removed from the base layer.

Variables

View Source
var (
	// BufioReader32KPool is a pool which returns bufio.Reader with a 32K buffer.
	BufioReader32KPool = newBufioReaderPoolWithSize(buffer32K)
	// BufioWriter32KPool is a pool which returns bufio.Writer with a 32K buffer.
	BufioWriter32KPool = newBufioWriterPoolWithSize(buffer32K)
)

Functions

func BuildImageStream

func BuildImageStream(options *BuildOptions) (io.ReadCloser, string, error)

BuildImageStream Build the tar stream for the context to send to a docker build

func Copy

func Copy(dst io.Writer, src io.Reader) (written int64, err error)

Copy is a convenience wrapper which uses a buffer to avoid allocation in io.Copy.

func FileInfoHeader

func FileInfoHeader(name string, fi os.FileInfo, link string) (*tar.Header, error)

FileInfoHeader creates a populated Header from fi. Compared to archive pkg this function fills in more information. Also, regardless of Go version, this function fills file type bits (e.g. hdr.Mode |= modeISDIR), which have been deleted since Go 1.9 archive/tar.

func GenerateNonCryptoID

func GenerateNonCryptoID() string

GenerateNonCryptoID generates unique id without using cryptographically secure sources of random. It helps you to save entropy.

func GenerateRandomID

func GenerateRandomID() string

GenerateRandomID returns a unique id.

func IsShortID

func IsShortID(id string) bool

IsShortID determines if an arbitrary string *looks like* a short ID.

func Matches

func Matches(file string, patterns []string) (bool, error)

Matches returns true if file matches any of the patterns and isn't excluded by any of the subsequent patterns.

func NewReadCloserWrapper

func NewReadCloserWrapper(r io.Reader, closer func() error) io.ReadCloser

NewReadCloserWrapper returns a new io.ReadCloser.

func NewWriteCloserWrapper

func NewWriteCloserWrapper(r io.Writer, closer func() error) io.WriteCloser

NewWriteCloserWrapper returns a new io.WriteCloser.

func OpenFileSequential

func OpenFileSequential(name string, flag int, perm os.FileMode) (*os.File, error)

OpenFileSequential is the generalized open call; most users will use Open or Create instead. It opens the named file with specified flag (O_RDONLY etc.) and perm, (0666 etc.) if applicable. If successful, methods on the returned File can be used for I/O. If there is an error, it will be of type *PathError.

func OpenSequential

func OpenSequential(name string) (*os.File, error)

OpenSequential opens the named file for reading. If successful, methods on the returned file can be used for reading; the associated file descriptor has mode O_RDONLY. If there is an error, it will be of type *PathError.

func ReadSecurityXattrToTarHeader

func ReadSecurityXattrToTarHeader(path string, hdr *tar.Header) error

ReadSecurityXattrToTarHeader reads security.capability xattr from filesystem to a tar header

func TruncateID

func TruncateID(id string) string

TruncateID returns a shorthand version of a string identifier for convenience. A collision with other shorthands is very unlikely, but possible. In case of a collision a lookup with TruncIndex.Get() will fail, and the caller will need to use a longer prefix, or the full-length Id.

func ValidateID

func ValidateID(id string) error

ValidateID checks whether an ID string is a valid image ID.

Types

type Archiver

type Archiver struct {
	Untar      func(io.Reader, string, *TarOptions) error
	IDMappings *IDMappings
}

Archiver allows the reuse of most utility functions of this package with a pluggable Untar function. Also, to facilitate the passing of specific id mappings for untar, an archiver can be created with maps which will then be passed to Untar operations

type BufioReaderPool

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

BufioReaderPool is a bufio reader that uses sync.Pool.

func (*BufioReaderPool) Get

func (bufPool *BufioReaderPool) Get(r io.Reader) *bufio.Reader

Get returns a bufio.Reader which reads from r. The buffer size is that of the pool.

func (*BufioReaderPool) NewReadCloserWrapper

func (bufPool *BufioReaderPool) NewReadCloserWrapper(buf *bufio.Reader, r io.Reader) io.ReadCloser

NewReadCloserWrapper returns a wrapper which puts the bufio.Reader back into the pool and closes the reader if it's an io.ReadCloser.

func (*BufioReaderPool) Put

func (bufPool *BufioReaderPool) Put(b *bufio.Reader)

Put puts the bufio.Reader back into the pool.

type BufioWriterPool

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

BufioWriterPool is a bufio writer that uses sync.Pool.

func (*BufioWriterPool) Get

func (bufPool *BufioWriterPool) Get(w io.Writer) *bufio.Writer

Get returns a bufio.Writer which writes to w. The buffer size is that of the pool.

func (*BufioWriterPool) NewWriteCloserWrapper

func (bufPool *BufioWriterPool) NewWriteCloserWrapper(buf *bufio.Writer, w io.Writer) io.WriteCloser

NewWriteCloserWrapper returns a wrapper which puts the bufio.Writer back into the pool and closes the writer if it's an io.Writecloser.

func (*BufioWriterPool) Put

func (bufPool *BufioWriterPool) Put(b *bufio.Writer)

Put puts the bufio.Writer back into the pool.

type BuildOptions

type BuildOptions struct {
	ContextDirectory  string
	DockerfilePath    string
	Dockerignore      string
	SourceIncludes    []string
	SourceExcludes    []string
	ScriptName        string
	DockerfileContent io.Reader
	ScriptContent     io.Reader
}

BuildOptions Options for building an image

type Compression

type Compression int

Compression is the state represents if compressed or not.

const (
	// Uncompressed represents the uncompressed.
	Uncompressed Compression = iota
	// Bzip2 is bzip2 compression algorithm.
	Bzip2
	// Gzip is gzip compression algorithm.
	Gzip
	// Xz is xz compression algorithm.
	Xz
)

func (*Compression) Extension

func (compression *Compression) Extension() string

Extension returns the extension of a file that uses the specified compression algorithm.

type IDMap

type IDMap struct {
	ContainerID int `json:"container_id"`
	HostID      int `json:"host_id"`
	Size        int `json:"size"`
}

IDMap contains a single entry for user namespace range remapping. An array of IDMap entries represents the structure that will be provided to the Linux kernel for creating a user namespace.

type IDMappings

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

IDMappings contains a mappings of UIDs and GIDs

func NewIDMappingsFromMaps

func NewIDMappingsFromMaps(uids []IDMap, gids []IDMap) *IDMappings

NewIDMappingsFromMaps creates a new mapping from two slices Deprecated: this is a temporary shim while transitioning to IDMapping

func (*IDMappings) Empty

func (i *IDMappings) Empty() bool

Empty returns true if there are no id mappings

func (*IDMappings) ToContainer

func (i *IDMappings) ToContainer(pair IDPair) (int, int, error)

ToContainer returns the container UID and GID for the host uid and gid

type IDPair

type IDPair struct {
	UID int
	GID int
}

IDPair is a UID and GID pair

type Pattern

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

Pattern defines a single regexp used used to filter file paths.

func (*Pattern) Exclusion

func (p *Pattern) Exclusion() bool

Exclusion returns true if this pattern defines exclusion

func (*Pattern) String

func (p *Pattern) String() string

type PatternMatcher

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

PatternMatcher allows checking paths agaist a list of patterns

func (*PatternMatcher) Exclusions

func (pm *PatternMatcher) Exclusions() bool

Exclusions returns true if any of the patterns define exclusions

func (*PatternMatcher) Matches

func (pm *PatternMatcher) Matches(file string) (bool, error)

Matches matches path against all the patterns. Matches is not safe to be called concurrently

func (*PatternMatcher) Patterns

func (pm *PatternMatcher) Patterns() []*Pattern

Patterns returns array of active patterns

type TarModifierFunc

type TarModifierFunc func(path string, header *tar.Header, content io.Reader) (*tar.Header, []byte, error)

TarModifierFunc is a function that can be passed to ReplaceFileTarWrapper to modify the contents or header of an entry in the archive. If the file already exists in the archive the TarModifierFunc will be called with the Header and a reader which will return the files content. If the file does not exist both header and content will be nil.

type TarOptions

type TarOptions struct {
	IncludeFiles     []string
	ExcludePatterns  []string
	Compression      Compression
	NoLchown         bool
	UIDMaps          []IDMap
	GIDMaps          []IDMap
	ChownOpts        *IDPair
	IncludeSourceDir bool
	// WhiteoutFormat is the expected on disk format for whiteout files.
	// This format will be converted to the standard format on pack
	// and from the standard format on unpack.
	WhiteoutFormat WhiteoutFormat
	// When unpacking, specifies whether overwriting a directory with a
	// non-directory is allowed and vice versa.
	NoOverwriteDirNonDir bool
	// For each include when creating an archive, the included name will be
	// replaced with the matching name from this map.
	RebaseNames map[string]string
	InUserNS    bool
}

TarOptions wraps the tar options.

type TempArchive

type TempArchive struct {
	*os.File
	Size int64 // Pre-computed from Stat().Size() as a convenience
	// contains filtered or unexported fields
}

TempArchive is a temporary archive. The archive can only be read once - as soon as reading completes, the file will be deleted.

func NewTempArchive

func NewTempArchive(src io.Reader, dir string) (*TempArchive, error)

NewTempArchive reads the content of src into a temporary file, and returns the contents of that file as an archive. The archive can only be read once - as soon as reading completes, the file will be deleted.

func (*TempArchive) Close

func (archive *TempArchive) Close() error

Close closes the underlying file if it's still open, or does a no-op to allow callers to try to close the TempArchive multiple times safely.

func (*TempArchive) Read

func (archive *TempArchive) Read(data []byte) (int, error)

type WhiteoutFormat

type WhiteoutFormat int

WhiteoutFormat is the format of whiteouts unpacked

const (
	// AUFSWhiteoutFormat is the default format for whiteouts
	AUFSWhiteoutFormat WhiteoutFormat = iota
	// OverlayWhiteoutFormat formats whiteout according to the overlay
	// standard.
	OverlayWhiteoutFormat
)

Jump to

Keyboard shortcuts

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