archive

package
v1.7.20 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: Apache-2.0 Imports: 20 Imported by: 656

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(ctx context.Context, root string, r io.Reader, opts ...ApplyOpt) (int64, error)

Apply applies a tar stream of an OCI style diff tar. See https://github.com/opencontainers/image-spec/blob/main/layer.md#applying-changesets

func AufsConvertWhiteout added in v1.3.0

func AufsConvertWhiteout(_ *tar.Header, _ string) (bool, error)

AufsConvertWhiteout converts whiteout files for aufs.

func Diff

func Diff(ctx context.Context, a, b string, opts ...WriteDiffOpt) io.ReadCloser

Diff returns a tar stream of the computed filesystem difference between the provided directories.

Produces a tar using OCI style file markers for deletions. Deleted files will be prepended with the prefix ".wh.". This style is based off AUFS whiteouts. See https://github.com/opencontainers/image-spec/blob/main/layer.md

func OverlayConvertWhiteout added in v1.3.0

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

OverlayConvertWhiteout converts whiteout files for overlay.

func WriteDiff

func WriteDiff(ctx context.Context, w io.Writer, a, b string, opts ...WriteDiffOpt) error

WriteDiff writes a tar stream of the computed difference between the provided paths.

Produces a tar using OCI style file markers for deletions. Deleted files will be prepended with the prefix ".wh.". This style is based off AUFS whiteouts. See https://github.com/opencontainers/image-spec/blob/main/layer.md

Types

type ApplyOpt added in v1.1.0

type ApplyOpt func(options *ApplyOptions) error

ApplyOpt allows setting mutable archive apply properties on creation

func WithConvertWhiteout added in v1.3.0

func WithConvertWhiteout(c ConvertWhiteout) ApplyOpt

WithConvertWhiteout uses the convert function to convert the whiteout files.

func WithFilter added in v1.2.0

func WithFilter(f Filter) ApplyOpt

WithFilter uses the filter to select which files are to be extracted.

func WithNoSameOwner added in v1.7.0

func WithNoSameOwner() ApplyOpt

WithNoSameOwner is same as '--no-same-owner` in 'tar' command. It'll skip attempt to preserve the owner specified in the tar archive.

func WithParents added in v1.3.0

func WithParents(p []string) ApplyOpt

WithParents provides parent directories for resolving inherited attributes directory from the filesystem. Inherited attributes are searched from first to last, making the first element in the list the most immediate parent directory. NOTE: When applying to a filesystem which supports CoW, file attributes should be inherited by the filesystem.

type ApplyOptions added in v1.1.0

type ApplyOptions struct {
	Filter          Filter          // Filter tar headers
	ConvertWhiteout ConvertWhiteout // Convert whiteout files
	Parents         []string        // Parent directories to handle inherited attributes without CoW
	NoSameOwner     bool            // NoSameOwner will not attempt to preserve the owner specified in the tar archive.
	// contains filtered or unexported fields
}

ApplyOptions provides additional options for an Apply operation

type ChangeWriter added in v1.6.0

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

ChangeWriter provides tar stream from filesystem change information. The privided tar stream is styled as an OCI layer. Change information (add/modify/delete/unmodified) for each file needs to be passed to this writer through HandleChange method.

This should be used combining with continuity's diff computing functionality (e.g. `fs.Change` of github.com/containerd/continuity/fs).

See also https://github.com/opencontainers/image-spec/blob/main/layer.md for details about OCI layers

func NewChangeWriter added in v1.6.0

func NewChangeWriter(w io.Writer, source string, opts ...ChangeWriterOpt) *ChangeWriter

NewChangeWriter returns ChangeWriter that writes tar stream of the source directory to the privided writer. Change information (add/modify/delete/unmodified) for each file needs to be passed through HandleChange method.

func (*ChangeWriter) Close added in v1.6.0

func (cw *ChangeWriter) Close() error

Close closes this writer.

func (*ChangeWriter) HandleChange added in v1.6.0

func (cw *ChangeWriter) HandleChange(k fs.ChangeKind, p string, f os.FileInfo, err error) error

HandleChange receives filesystem change information and reflect that information to the result tar stream. This function implements `fs.ChangeFunc` of continuity (github.com/containerd/continuity/fs) and should be used with that package.

type ChangeWriterOpt added in v1.7.0

type ChangeWriterOpt func(cw *ChangeWriter)

ChangeWriterOpt can be specified in NewChangeWriter.

func WithModTimeUpperBound added in v1.7.0

func WithModTimeUpperBound(tm time.Time) ChangeWriterOpt

WithModTimeUpperBound sets the mod time upper bound.

func WithWhiteoutTime added in v1.7.0

func WithWhiteoutTime(tm time.Time) ChangeWriterOpt

WithWhiteoutTime sets the whiteout timestamp.

type ConvertWhiteout added in v1.3.0

type ConvertWhiteout func(*tar.Header, string) (bool, error)

ConvertWhiteout converts whiteout files from the archive

type Filter added in v1.2.0

type Filter func(*tar.Header) (bool, error)

Filter specific files from the archive

type WriteDiffOpt added in v1.5.0

type WriteDiffOpt func(options *WriteDiffOptions) error

WriteDiffOpt allows setting mutable archive write properties on creation

func WithSourceDateEpoch added in v1.7.0

func WithSourceDateEpoch(tm *time.Time) WriteDiffOpt

WithSourceDateEpoch specifies the SOURCE_DATE_EPOCH without touching the env vars.

type WriteDiffOptions added in v1.5.0

type WriteDiffOptions struct {
	ParentLayers []string // Windows needs the full list of parent layers

	// SourceDateEpoch specifies the following timestamps to provide control for reproducibility.
	//   - The upper bound timestamp of the diff contents
	//   - The timestamp of the whiteouts
	//
	// See also https://reproducible-builds.org/docs/source-date-epoch/ .
	SourceDateEpoch *time.Time
	// contains filtered or unexported fields
}

WriteDiffOptions provides additional options for a WriteDiff operation

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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