distribution

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2018 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MediaTypeManifest specifies the mediaType for the current version.
	MediaTypeManifest = "application/vnd.docker.distribution.manifest.v2+json"

	// MediaTypeImageConfig specifies the mediaType for the image configuration.
	MediaTypeImageConfig = "application/vnd.docker.container.image.v1+json"

	// MediaTypePluginConfig specifies the mediaType for plugin configuration.
	MediaTypePluginConfig = "application/vnd.docker.plugin.v1+json"

	// MediaTypeLayer is the mediaType used for layers referenced by the
	// manifest.
	MediaTypeLayer = "application/vnd.docker.image.rootfs.diff.tar.gzip"

	// MediaTypeForeignLayer is the mediaType used for layers that must be
	// downloaded from foreign URLs.
	MediaTypeForeignLayer = "application/vnd.docker.image.rootfs.foreign.diff.tar.gzip"

	// MediaTypeUncompressedLayer is the mediaType used for layers which
	// are not compressed.
	MediaTypeUncompressedLayer = "application/vnd.docker.image.rootfs.diff.tar"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ArchiveManifest

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

ArchiveManifest represents the json manifest in an image archive such as that produced by docker save

type Blob

type Blob interface {
	GetMediaType() string
	GetDigest() digest.Digest
	GetSize() int64
	GetFilename() string
	SetFilename(filename string)
	ReadCloser() (io.ReadCloser, error)
}

Blob represents an entry for a blob in the image manifest

type CompressedBlob

type CompressedBlob interface {
	Blob
	Decompress(outfile string) (DecompressedBlob, error)
}

CompressedBlob is a blob that may be decompressed

type DecConfig

type DecConfig interface {
	Encrypt(key, nonce, salt []byte) (EncConfig, error)
}

DecConfig is config that may be encrypted

func NewDecConfig

func NewDecConfig() DecConfig

NewDecConfig creates a new DecConfig

type DecompressedBlob

type DecompressedBlob interface {
	Blob
	Compress(outfile string) (CompressedBlob, error)
}

DecompressedBlob is a blob that may be compressed

func NewPlainConfig

func NewPlainConfig(
	filename string,
	d digest.Digest,
	size int64,
) DecompressedBlob

NewPlainConfig creates a new LayerJSON for an unencrypted data layer

func NewPlainLayer

func NewPlainLayer(
	filename string,
	d digest.Digest,
	size int64,
) DecompressedBlob

NewPlainLayer creates a new LayerJSON for an unencrypted data layer

type DecryptedBlob

type DecryptedBlob interface {
	Blob
	// EncryptBlob compresses the blob file and encryptes
	//     The Key encryption key contained in the "DeCrypto" struct
	//     The data stream in the FileHandle io.Reader
	EncryptBlob(opts *crypto.Opts, outfile string) (EncryptedBlob, error)
}

DecryptedBlob is a blob that may be encrypted

func NewConfig

func NewConfig(
	filename string,
	d digest.Digest,
	size int64,
	dec *crypto.DeCrypto,
) DecryptedBlob

NewConfig creates a new blob for a config

func NewLayer

func NewLayer(
	filename string,
	d digest.Digest,
	size int64,
	dec *crypto.DeCrypto,
) DecryptedBlob

NewLayer creates a new LayerJSON for a data layer

type EncConfig

type EncConfig interface {
	Decrypt(key, nonce, salt []byte, opts *crypto.Opts) (DecConfig, error)
}

EncConfig has the secretFields encrypted

type EncryptedBlob

type EncryptedBlob interface {
	Blob
	// DecryptBlob decrypts:
	//     The Key encryption key contained in the "EnCrypto" struct
	//     The data stream in the FileHandle io.Reader
	// The data is also decompressed and written to a file which is referenced
	// in the "Filename"
	DecryptBlob(opts *crypto.Opts, outfile string) (DecryptedBlob, error)
	DecryptKey(opts *crypto.Opts) (KeyDecryptedBlob, error)
}

EncryptedBlob is a blob that may be decrypted

type ImageArchiveManifest added in v0.0.1

type ImageArchiveManifest struct {
	Config string
	Layers []string
}

ImageArchiveManifest collects the filenames of the config and layers in the image archive obtained from a docker save command

func NewImageArchiveManifest added in v0.0.1

func NewImageArchiveManifest(manifestFH io.Reader) (a *ImageArchiveManifest, err error)

NewImageArchiveManifest reads a image archive manifest file

type ImageManifest

type ImageManifest struct {
	SchemaVersion int    `json:"schemaVersion"`
	MediaType     string `json:"mediaType"`
	Config        Blob   `json:"config"`
	Layers        []Blob `json:"layers"`
	DirName       string `json:"-"`
}

ImageManifest represents a docker image manifest schema v2.2

func NewManifest

func NewManifest(
	ref names.NamedTaggedRepository,
	opts *crypto.Opts,
	tempDir string,
) (
	manifest *ImageManifest,
	err error,
)

NewManifest creates an unencrypted manifest (with the data necessary for encryption)

func (*ImageManifest) Decrypt

func (m *ImageManifest) Decrypt(
	ref names.NamedTaggedRepository,
	opts *crypto.Opts,
) (out *ImageManifest, err error)

Decrypt decrypt a manifest, both the keys and layer data

func (*ImageManifest) DecryptKeys

func (m *ImageManifest) DecryptKeys(
	ref names.NamedTaggedRepository,
	opts *crypto.Opts,
) (err error)

DecryptKeys decrypts all keys in a manifest

func (*ImageManifest) Encrypt

func (m *ImageManifest) Encrypt(
	ref names.NamedTaggedRepository,
	opts *crypto.Opts,
) (
	out *ImageManifest,
	err error,
)

Encrypt an image, generating an image manifest suitable for upload to a repo

func (*ImageManifest) MarshalJSON

func (m *ImageManifest) MarshalJSON() (bs []byte, err error)

MarshalJSON customises the marshalling of an ImageManifest

func (*ImageManifest) UnmarshalJSON

func (m *ImageManifest) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON converts json into a image manifest, chosing the appropriate types for the blob subobjects

type KeyDecryptedBlob

type KeyDecryptedBlob interface {
	Blob
	DecryptFile(opts *crypto.Opts, outfile string) (DecryptedBlob, error)
	EncryptKey(opts *crypto.Opts) (EncryptedBlob, error)
}

KeyDecryptedBlob is a type for blobs that have had their key objects decrypted but not their files

type NoncryptedBlob

type NoncryptedBlob struct {
	MediaType string        `json:"mediaType"`
	Size      int64         `json:"size"`
	Digest    digest.Digest `json:"digest"`
	Filename  string        `json:"-"`
}

NoncryptedBlob is a vanilla blob with no encryption data Despite appearnces, the MediaType type is not indicative of whether the blob is compressed or not

func (*NoncryptedBlob) Compress

func (b *NoncryptedBlob) Compress(outfile string) (_ CompressedBlob, err error)

Compress compresses a blob

func (*NoncryptedBlob) Decompress

func (b *NoncryptedBlob) Decompress(outfile string) (_ DecompressedBlob, err error)

Decompress decompresses a blob

func (*NoncryptedBlob) GetDigest

func (b *NoncryptedBlob) GetDigest() digest.Digest

GetDigest returnts the digest

func (*NoncryptedBlob) GetFilename

func (b *NoncryptedBlob) GetFilename() string

GetFilename retun the filename of the file that the blob is stored in

func (*NoncryptedBlob) GetMediaType added in v0.0.1

func (b *NoncryptedBlob) GetMediaType() string

GetMediaType returns the content type

func (*NoncryptedBlob) GetSize

func (b *NoncryptedBlob) GetSize() int64

GetSize returns the size

func (*NoncryptedBlob) ReadCloser

func (b *NoncryptedBlob) ReadCloser() (io.ReadCloser, error)

ReadCloser opens the file that backs the blob and returns a handle to it It is the user's responsibility to close the file handle

func (*NoncryptedBlob) SetFilename

func (b *NoncryptedBlob) SetFilename(filename string)

SetFilename set the filename of the file that the blob is stored in

Jump to

Keyboard shortcuts

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