layout

package
Version: v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2022 License: Apache-2.0 Imports: 17 Imported by: 39

README

layout

GoDoc

The layout package implements support for interacting with an OCI Image Layout.

Documentation

Overview

Package layout provides facilities for reading/writing artifacts from/to an OCI image layout on disk, see:

https://github.com/opencontainers/image-spec/blob/master/image-layout.md

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ImageIndexFromPath

func ImageIndexFromPath(path string) (v1.ImageIndex, error)

ImageIndexFromPath is a convenience function which constructs a Path and returns its v1.ImageIndex.

Types

type Option

type Option func(*options)

Option is a functional option for Layout.

func WithAnnotations

func WithAnnotations(annotations map[string]string) Option

WithAnnotations adds annotations to the artifact descriptor.

func WithPlatform

func WithPlatform(platform v1.Platform) Option

WithPlatform sets the platform of the artifact descriptor.

func WithURLs

func WithURLs(urls []string) Option

WithURLs adds urls to the artifact descriptor.

type Path

type Path string

Path represents an OCI image layout rooted in a file system path

func FromPath

func FromPath(path string) (Path, error)

FromPath reads an OCI image layout at path and constructs a layout.Path.

func Write

func Write(path string, ii v1.ImageIndex) (Path, error)

Write constructs a Path at path from an ImageIndex.

The contents are written in the following format: At the top level, there is:

One oci-layout file containing the version of this image-layout.
One index.json file listing descriptors for the contained images.

Under blobs/, there is, for each image:

One file for each layer, named after the layer's SHA.
One file for each config blob, named after its SHA.
One file for each manifest blob, named after its SHA.

func (Path) AppendDescriptor

func (l Path) AppendDescriptor(desc v1.Descriptor) error

AppendDescriptor adds a descriptor to the index.json of the Path.

func (Path) AppendImage

func (l Path) AppendImage(img v1.Image, options ...Option) error

AppendImage writes a v1.Image to the Path and updates the index.json to reference it.

func (Path) AppendIndex

func (l Path) AppendIndex(ii v1.ImageIndex, options ...Option) error

AppendIndex writes a v1.ImageIndex to the Path and updates the index.json to reference it.

func (Path) Blob

func (l Path) Blob(h v1.Hash) (io.ReadCloser, error)

Blob returns a blob with the given hash from the Path.

func (Path) Bytes

func (l Path) Bytes(h v1.Hash) ([]byte, error)

Bytes is a convenience function to return a blob from the Path as a byte slice.

func (Path) Image

func (l Path) Image(h v1.Hash) (v1.Image, error)

Image reads a v1.Image with digest h from the Path.

func (Path) ImageIndex

func (l Path) ImageIndex() (v1.ImageIndex, error)

ImageIndex returns a v1.ImageIndex for the Path.

func (Path) RemoveBlob added in v0.4.1

func (l Path) RemoveBlob(hash v1.Hash) error

RemoveBlob removes a file from the blobs directory in the Path at blobs/{hash.Algorithm}/{hash.Hex} It does *not* remove any reference to it from other manifests or indexes, or from the root index.json.

func (Path) RemoveDescriptors added in v0.3.0

func (l Path) RemoveDescriptors(matcher match.Matcher) error

RemoveDescriptors removes any descriptors that match the match.Matcher from the index.json of the Path.

func (Path) ReplaceImage added in v0.3.0

func (l Path) ReplaceImage(img v1.Image, matcher match.Matcher, options ...Option) error

ReplaceImage writes a v1.Image to the Path and updates the index.json to reference it, replacing any existing one that matches matcher, if found.

func (Path) ReplaceIndex added in v0.3.0

func (l Path) ReplaceIndex(ii v1.ImageIndex, matcher match.Matcher, options ...Option) error

ReplaceIndex writes a v1.ImageIndex to the Path and updates the index.json to reference it, replacing any existing one that matches matcher, if found.

func (Path) WriteBlob

func (l Path) WriteBlob(hash v1.Hash, r io.ReadCloser) error

WriteBlob copies a file to the blobs/ directory in the Path from the given ReadCloser at blobs/{hash.Algorithm}/{hash.Hex}.

func (Path) WriteFile

func (l Path) WriteFile(name string, data []byte, perm os.FileMode) error

WriteFile write a file with arbitrary data at an arbitrary location in a v1 layout. Used mostly internally to write files like "oci-layout" and "index.json", also can be used to write other arbitrary files. Do *not* use this to write blobs. Use only WriteBlob() for that.

func (Path) WriteImage added in v0.2.0

func (l Path) WriteImage(img v1.Image) error

WriteImage writes an image, including its manifest, config and all of its layers, to the blobs directory. If any blob already exists, as determined by the hash filename, does not write it. This function does *not* update the `index.json` file. If you want to write the image and also update the `index.json`, call AppendImage(), which wraps this and also updates the `index.json`.

func (Path) WriteIndex added in v0.2.0

func (l Path) WriteIndex(ii v1.ImageIndex) error

WriteIndex writes an index to the blobs directory. Walks down the children, including its children manifests and/or indexes, and down the tree until all of config and all layers, have been written. If any blob already exists, as determined by the hash filename, does not write it. This function does *not* update the `index.json` file. If you want to write the index and also update the `index.json`, call AppendIndex(), which wraps this and also updates the `index.json`.

Jump to

Keyboard shortcuts

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