package layout
import "github.com/google/go-containerregistry/pkg/v1/layout"
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
- func WithAnnotations(annotations map[string]string) Option
- func WithPlatform(platform v1.Platform) Option
- func WithURLs(urls []string) Option
- type Path
- func FromPath(path string) (Path, error)
- func Write(path string, ii v1.ImageIndex) (Path, error)
- 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) WriteBlob(hash v1.Hash, r io.ReadCloser) error
- func (l Path) WriteFile(name string, data []byte, perm os.FileMode) error
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 ¶
WithAnnotations adds annotations to the artifact descriptor.
func WithPlatform ¶
WithPlatform sets the platform of the artifact descriptor.
func WithURLs ¶
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 ¶
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 ¶
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 ¶
Blob returns a blob with the given hash from the Path.
func (Path) Bytes ¶
Bytes is a convenience function to return a blob from the Path as a byte slice.
func (Path) Image ¶
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 ¶
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.
Source Files ¶
blob.go doc.go image.go index.go layoutpath.go options.go read.go write.go
- Version
- v0.1.4
- Published
- Oct 22, 2020
- Platform
- js/wasm
- Imports
- 13 packages
- Last checked
- 2 hours ago –
Tools for package owners.