layout

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: Apache-2.0 Imports: 13 Imported by: 107

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(*v1.Descriptor) error

Option is a functional option for Layout.

TODO: We'll need to change this signature to support Sparse/Thin images. Or, alternatively, wrap it in a sparse.Image that returns an empty list for layers?

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) 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.

Jump to

Keyboard shortcuts

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