layer

package
v0.0.0-...-3d2dcd1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package layer extracts OCI image layer tarballs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractDir

func ExtractDir(h *tar.Header, _ io.Reader, path string) error

ExtractDir is a HeaderHandler that creates a directory at the supplied path per the supplied tar header.

func ExtractFIFO

func ExtractFIFO(h *tar.Header, _ io.Reader, path string) error

ExtractFIFO is a HeaderHandler that creates a FIFO at the supplied path per the supplied tar header.

func ExtractFile

func ExtractFile(h *tar.Header, tr io.Reader, path string) error

ExtractFile is a HeaderHandler that creates a regular file at the supplied path per the supplied tar header.

func ExtractSymlink(h *tar.Header, _ io.Reader, path string) error

ExtractSymlink is a HeaderHandler that creates a symlink at the supplied path per the supplied tar header.

Types

type ExtractHandler

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

An ExtractHandler extracts from a tarball per the supplied tar header by calling a handler that knows how to extract the type of file.

func NewExtractHandler

func NewExtractHandler() *ExtractHandler

NewExtractHandler returns a HeaderHandler that extracts from a tarball per the supplied tar header by calling a handler that knows how to extract the type of file.

func (*ExtractHandler) Handle

func (e *ExtractHandler) Handle(h *tar.Header, tr io.Reader, path string) error

Handle creates a file at the supplied path per the supplied tar header.

type HeaderHandler

type HeaderHandler interface {
	// Handle the supplied tarball header by applying it to the supplied path,
	// e.g. creating a file, directory, etc. The supplied io.Reader is expected
	// to be a tarball advanced to the supplied header, i.e. via tr.Next().
	Handle(h *tar.Header, tr io.Reader, path string) error
}

A HeaderHandler handles a single file (header) within a tarball.

type HeaderHandlerFn

type HeaderHandlerFn func(h *tar.Header, tr io.Reader, path string) error

A HeaderHandlerFn is a function that acts as a HeaderHandler.

func (HeaderHandlerFn) Handle

func (fn HeaderHandlerFn) Handle(h *tar.Header, tr io.Reader, path string) error

Handle the supplied tarball header.

type StackingExtractor

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

A StackingExtractor is a Extractor that extracts an OCI layer by 'stacking' it atop the supplied root directory.

func NewStackingExtractor

func NewStackingExtractor(h HeaderHandler) *StackingExtractor

NewStackingExtractor extracts an OCI layer by 'stacking' it atop the supplied root directory.

func (*StackingExtractor) Apply

func (e *StackingExtractor) Apply(ctx context.Context, tb io.Reader, root string) error

Apply calls the StackingExtractor's HeaderHandler for each file in the supplied layer tarball, adjusting their path to be rooted under the supplied root directory. That is, /foo would be extracted to /bar as /bar/foo.

type WhiteoutHandler

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

A WhiteoutHandler handles OCI whiteouts by deleting the corresponding files. It passes anything that is not a whiteout to an underlying HeaderHandler. It avoids deleting any file created by the underling HeaderHandler.

func NewWhiteoutHandler

func NewWhiteoutHandler(hh HeaderHandler) *WhiteoutHandler

NewWhiteoutHandler returns a HeaderHandler that handles OCI whiteouts by deleting the corresponding files.

func (*WhiteoutHandler) Handle

func (w *WhiteoutHandler) Handle(h *tar.Header, tr io.Reader, path string) error

Handle the supplied tar header.

Jump to

Keyboard shortcuts

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