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 ¶
- func ImageIndexFromPath(path string) (v1.ImageIndex, error)
- type Option
- type Path
- func (l Path) AppendDescriptor(desc v1.Descriptor) error
- func (l Path) AppendImage(img v1.Image, options ...Option) error
- func (l Path) AppendIndex(ii v1.ImageIndex, options ...Option) error
- func (l Path) Blob(h v1.Hash) (io.ReadCloser, error)
- func (l Path) Bytes(h v1.Hash) ([]byte, error)
- func (l Path) Image(h v1.Hash) (v1.Image, error)
- func (l Path) ImageIndex() (v1.ImageIndex, error)
- func (l Path) RemoveBlob(hash v1.Hash) error
- func (l Path) RemoveDescriptors(matcher match.Matcher) error
- func (l Path) ReplaceImage(img v1.Image, matcher match.Matcher, options ...Option) error
- func (l Path) ReplaceIndex(ii v1.ImageIndex, matcher match.Matcher, options ...Option) error
- func (l Path) WriteBlob(hash v1.Hash, r io.ReadCloser) error
- func (l Path) WriteFile(name string, data []byte, perm os.FileMode) error
- func (l Path) WriteImage(img v1.Image) error
- func (l Path) WriteIndex(ii v1.ImageIndex) error
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 ¶
WithAnnotations adds annotations to the artifact descriptor.
func WithPlatform ¶
WithPlatform sets the platform of the artifact descriptor.
type Path ¶
type Path string
Path represents an OCI image layout rooted in a file system 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 ¶
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) ImageIndex ¶
func (l Path) ImageIndex() (v1.ImageIndex, error)
ImageIndex returns a v1.ImageIndex for the Path.
func (Path) RemoveBlob ¶ added in v0.4.1
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
RemoveDescriptors removes any descriptors that match the match.Matcher from the index.json of the Path.
func (Path) ReplaceImage ¶ added in v0.3.0
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
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 ¶
WriteBlob copies a file to the blobs/ directory in the Path from the given ReadCloser at blobs/{hash.Algorithm}/{hash.Hex}.
func (Path) WriteFile ¶
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
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`.