squasher

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2019 License: MIT Imports: 12 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeserializedTar

type DeserializedTar struct {
	Content map[string]*TarEntry // map of path -> entry
	Order   []string             // paths in the order they are read in the stream
}

DeserializedTar represents a deserialized tar stream

func NewDeserializedTar

func NewDeserializedTar() *DeserializedTar

NewDeserializedTar returns an initialized empty DeserializedTar

func (*DeserializedTar) Append

func (dt *DeserializedTar) Append(te *TarEntry) error

Append adds a new entry to the end of the tar stream

func (*DeserializedTar) Remove

func (dt *DeserializedTar) Remove(p string) error

Remove deletes the entry p from the tar file

func (*DeserializedTar) Serialize

func (dt *DeserializedTar) Serialize(output io.Writer) (int64, error)

Serialize writes the serialized tar stream to output

type DockerImageConfig

type DockerImageConfig struct {
	Architecture    string                   `json:"architecture"`
	Config          map[string]interface{}   `json:"config"`
	Container       string                   `json:"container"`
	ContainerConfig map[string]interface{}   `json:"container_config"`
	Created         string                   `json:"created"`
	DockerVersion   string                   `json:"docker_version"`
	History         []map[string]interface{} `json:"history"`
	OS              string                   `json:"os"`
	RootFS          struct {
		Type    string   `json:"type"`
		DiffIDs []string `json:"diff_ids"`
	} `json:"rootfs"`
}

DockerImageConfig represents the image config json file in the root of an image archive

type DockerImageManifest

type DockerImageManifest struct {
	Config   string
	RepoTags []string
	Layers   []string
}

DockerImageManifest represents manifest.json in the root of an image archive

type DockerImageSquasher

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

DockerImageSquasher squashes an image repository to its last layer

func (*DockerImageSquasher) DeserializeTarStream

func (dis *DockerImageSquasher) DeserializeTarStream(ctx context.Context, in io.Reader) (*DeserializedTar, int64, error)

DeserializeTarStream deserializes a tar stream returns the struct and the total bytes read (not including tar metadata)

func (*DockerImageSquasher) Squash

func (dis *DockerImageSquasher) Squash(ctx context.Context, input io.Reader, output io.Writer) (*SquashInfo, error)

Squash processes the input (Docker image tar stream), squashes the image to its last layer and returns the tar stream of the squashed image

type DockerLayerJSON

type DockerLayerJSON struct {
	ID              string                 `json:"id"`
	Parent          string                 `json:"parent,omitempty"`
	Created         string                 `json:"created"`
	Container       string                 `json:"container"`
	ContainerConfig map[string]interface{} `json:"container_config"`
	DockerVersion   string                 `json:"docker_version"`
	Config          map[string]interface{} `json:"config"`
	Architecture    string                 `json:"architecture"`
	OS              string                 `json:"os"`
}

DockerLayerJSON represents the 'json' file within a layer in an image archive

type ImageSquasher

type ImageSquasher interface {
	Squash(context.Context, io.Reader, io.Writer) (*SquashInfo, error)
}

ImageSquasher represents an object capable of squashing a container image

func NewDockerImageSquasher

func NewDockerImageSquasher(logger *log.Logger) ImageSquasher

NewDockerImageSquasher returns a Docker Image Squasher using the specified logger

type SquashInfo

type SquashInfo struct {
	InputBytes        uint64
	OutputBytes       uint64
	SizeDifference    int64
	SizePctDifference float64
	FilesRemovedCount uint
	FilesRemoved      []WhiteoutFile
	LayersRemoved     uint
}

SquashInfo represents data about an individual squashing operation

type TarEntry

type TarEntry struct {
	Header   *tar.Header // tar header
	Contents []byte      // file contents
	Index    uint64      // index within the stream
}

TarEntry represents a deserialized tar entry

type WhiteoutFile

type WhiteoutFile struct {
	Name string // Name of target removed file
	Size uint64 // Size in bytes
}

WhiteoutFile represents a file that was removed from final squashed image via whiteout

Jump to

Keyboard shortcuts

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