tarfile

package
v5.23.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Destination

type Destination struct {
	impl.Compat
	impl.PropertyMethodsInitialize
	stubs.NoPutBlobPartialInitialize
	stubs.NoSignaturesInitialize
	// contains filtered or unexported fields
}

Destination is a partial implementation of private.ImageDestination for writing to an io.Writer.

func NewDestination

func NewDestination(sys *types.SystemContext, archive *Writer, transportName string, ref reference.NamedTagged) *Destination

NewDestination returns a tarfile.Destination adding images to the specified Writer.

func (*Destination) AddRepoTags

func (d *Destination) AddRepoTags(tags []reference.NamedTagged)

AddRepoTags adds the specified tags to the destination's repoTags.

func (*Destination) PutBlobWithOptions added in v5.22.0

func (d *Destination) PutBlobWithOptions(ctx context.Context, stream io.Reader, inputInfo types.BlobInfo, options private.PutBlobOptions) (types.BlobInfo, error)

PutBlobWithOptions writes contents of stream and returns data representing the result. inputInfo.Digest can be optionally provided if known; if provided, and stream is read to the end without error, the digest MUST match the stream contents. inputInfo.Size is the expected length of stream, if known. inputInfo.MediaType describes the blob format, if known. WARNING: The contents of stream are being verified on the fly. Until stream.Read() returns io.EOF, the contents of the data SHOULD NOT be available to any other readers for download using the supplied digest. If stream.Read() at any time, ESPECIALLY at end of input, returns an error, PutBlob MUST 1) fail, and 2) delete any data stored so far.

func (*Destination) PutManifest

func (d *Destination) PutManifest(ctx context.Context, m []byte, instanceDigest *digest.Digest) error

PutManifest writes manifest to the destination. The instanceDigest value is expected to always be nil, because this transport does not support manifest lists, so there can be no secondary manifests. FIXME? This should also receive a MIME type if known, to differentiate between schema versions. If the destination is in principle available, refuses this manifest type (e.g. it does not recognize the schema), but may accept a different manifest type, the returned error must be an ManifestTypeRejectedError.

func (*Destination) TryReusingBlobWithOptions added in v5.22.0

func (d *Destination) TryReusingBlobWithOptions(ctx context.Context, info types.BlobInfo, options private.TryReusingBlobOptions) (bool, types.BlobInfo, error)

TryReusingBlobWithOptions checks whether the transport already contains, or can efficiently reuse, a blob, and if so, applies it to the current destination (e.g. if the blob is a filesystem layer, this signifies that the changes it describes need to be applied again when composing a filesystem tree). info.Digest must not be empty. If the blob has been successfully reused, returns (true, info, nil); info must contain at least a digest and size, and may include CompressionOperation and CompressionAlgorithm fields to indicate that a change to the compression type should be reflected in the manifest that will be written. If the transport can not reuse the requested blob, TryReusingBlob returns (false, {}, nil); it returns a non-nil error only on an unexpected failure.

type ManifestItem

type ManifestItem struct {
	Config       string
	RepoTags     []string
	Layers       []string
	Parent       imageID                                      `json:",omitempty"`
	LayerSources map[digest.Digest]manifest.Schema2Descriptor `json:",omitempty"`
}

ManifestItem is an element of the array stored in the top-level manifest.json file.

type Reader

type Reader struct {
	Manifest []ManifestItem // Guaranteed to exist after the archive is created.
	// contains filtered or unexported fields
}

Reader is a ((docker save)-formatted) tar archive that allows random access to any component.

func NewReaderFromFile

func NewReaderFromFile(sys *types.SystemContext, path string) (*Reader, error)

NewReaderFromFile returns a Reader for the specified path. The caller should call .Close() on the returned archive when done.

func NewReaderFromStream

func NewReaderFromStream(sys *types.SystemContext, inputStream io.Reader) (*Reader, error)

NewReaderFromStream returns a Reader for the specified inputStream, which can be either compressed or uncompressed. The caller can close the inputStream immediately after NewReaderFromFile returns. The caller should call .Close() on the returned archive when done.

func (*Reader) ChooseManifestItem

func (r *Reader) ChooseManifestItem(ref reference.NamedTagged, sourceIndex int) (*ManifestItem, int, error)

ChooseManifestItem selects a manifest item from r.Manifest matching (ref, sourceIndex), one or both of which should be (nil, -1). On success, it returns the manifest item and an index of the matching tag, if a tag was used for matching; the index is -1 if a tag was not used.

func (*Reader) Close

func (r *Reader) Close() error

Close removes resources associated with an initialized Reader, if any.

type Source

Source is a partial implementation of types.ImageSource for reading from tarPath.

func NewSource

func NewSource(archive *Reader, closeArchive bool, transportName string, ref reference.NamedTagged, sourceIndex int) *Source

NewSource returns a tarfile.Source for an image in the specified archive matching ref and sourceIndex (or the only image if they are (nil, -1)). The archive will be closed if closeArchive

func (*Source) Close

func (s *Source) Close() error

Close removes resources associated with an initialized Source, if any.

func (*Source) GetBlob

func (s *Source) GetBlob(ctx context.Context, info types.BlobInfo, cache types.BlobInfoCache) (io.ReadCloser, int64, error)

GetBlob returns a stream for the specified blob, and the blob’s size (or -1 if unknown). The Digest field in BlobInfo is guaranteed to be provided, Size may be -1 and MediaType may be optionally provided. May update BlobInfoCache, preferably after it knows for certain that a blob truly exists at a specific location.

func (*Source) GetManifest

func (s *Source) GetManifest(ctx context.Context, instanceDigest *digest.Digest) ([]byte, string, error)

GetManifest returns the image's manifest along with its MIME type (which may be empty when it can't be determined but the manifest is available). It may use a remote (= slow) service. If instanceDigest is not nil, it contains a digest of the specific manifest instance to retrieve (when the primary manifest is a manifest list); this never happens if the primary manifest is not a manifest list (e.g. if the source never returns manifest lists). This source implementation does not support manifest lists, so the passed-in instanceDigest should always be nil, as the primary manifest can not be a list, so there can be no secondary instances.

func (*Source) TarManifest

func (s *Source) TarManifest() []ManifestItem

TarManifest returns contents of manifest.json

type Writer

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

Writer allows creating a (docker save)-formatted tar archive containing one or more images.

func NewWriter

func NewWriter(dest io.Writer) *Writer

NewWriter returns a Writer for the specified io.Writer. The caller must eventually call .Close() on the returned object to create a valid archive.

func (*Writer) Close

func (w *Writer) Close() error

Close writes all outstanding data about images to the archive, and finishes writing data to the underlying io.Writer. No more images can be added after this is called.

Jump to

Keyboard shortcuts

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