Documentation ¶
Overview ¶
Package oci provides basic operations for manipulating OCI images. This package can be used even outside of containerd, and contains some functions not used in containerd itself.
Index ¶
- func DeleteBlob(img ImageDriver, d digest.Digest) error
- func GetBlobReader(img ImageDriver, d digest.Digest) (io.ReadCloser, error)
- func Init(img ImageDriver, opts InitOpts) error
- func PutManifestDescriptorToIndex(img ImageDriver, desc spec.Descriptor) error
- func ReadBlob(img ImageDriver, d digest.Digest) ([]byte, error)
- func ReadImageLayout(img ImageDriver) (spec.ImageLayout, error)
- func ReadIndex(img ImageDriver) (spec.Index, error)
- func RemoveManifestDescriptorFromIndex(img ImageDriver, refName string) error
- func WriteBlob(img ImageDriver, b []byte) (digest.Digest, error)
- func WriteImageLayout(img ImageDriver, layout spec.ImageLayout) error
- func WriteIndex(img ImageDriver, idx spec.Index) error
- func WriteJSONBlob(img ImageDriver, x interface{}, mediaType string) (spec.Descriptor, error)
- type BlobWriter
- type ErrUnexpectedDigest
- type ErrUnexpectedSize
- type ImageDriver
- type InitOpts
- type TarWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteBlob ¶
func DeleteBlob(img ImageDriver, d digest.Digest) error
DeleteBlob deletes an OCI blob.
func GetBlobReader ¶
func GetBlobReader(img ImageDriver, d digest.Digest) (io.ReadCloser, error)
GetBlobReader returns io.ReadCloser for a blob.
func Init ¶
func Init(img ImageDriver, opts InitOpts) error
Init initializes an OCI image structure. Init calls img.Init, creates `oci-layout`(0444), and creates `index.json`(0644).
func PutManifestDescriptorToIndex ¶
func PutManifestDescriptorToIndex(img ImageDriver, desc spec.Descriptor) error
PutManifestDescriptorToIndex puts a manifest descriptor to the index. If ref name is set and conflicts with the existing descriptors, the old ones are removed.
func ReadBlob ¶
func ReadBlob(img ImageDriver, d digest.Digest) ([]byte, error)
ReadBlob reads an OCI blob.
func ReadImageLayout ¶
func ReadImageLayout(img ImageDriver) (spec.ImageLayout, error)
ReadImageLayout returns the image layout.
func RemoveManifestDescriptorFromIndex ¶
func RemoveManifestDescriptorFromIndex(img ImageDriver, refName string) error
RemoveManifestDescriptorFromIndex removes the manifest descriptor from the index. Returns nil error when the entry not found.
func WriteBlob ¶
func WriteBlob(img ImageDriver, b []byte) (digest.Digest, error)
WriteBlob writes bytes as an OCI blob and returns its digest using the canonical digest algorithm. If you need to specify certain algorithm, you can use NewBlobWriter(img string, algo digest.Algorithm).
func WriteImageLayout ¶
func WriteImageLayout(img ImageDriver, layout spec.ImageLayout) error
WriteImageLayout writes the image layout.
func WriteIndex ¶
func WriteIndex(img ImageDriver, idx spec.Index) error
WriteIndex writes the index.
func WriteJSONBlob ¶
func WriteJSONBlob(img ImageDriver, x interface{}, mediaType string) (spec.Descriptor, error)
WriteJSONBlob is an utility function that writes x as a JSON blob with the specified media type, and returns the descriptor.
Types ¶
type BlobWriter ¶
type BlobWriter interface { // Close is expected to be called after Commit() when commission is needed. io.WriteCloser // Digest may return empty digest or panics until committed. Digest() digest.Digest // Commit commits the blob (but no roll-back is guaranteed on an error). // size and expected can be zero-value when unknown. Commit(size int64, expected digest.Digest) error }
BlobWriter writes an OCI blob and returns a digest when committed.
func NewBlobWriter ¶
func NewBlobWriter(img ImageDriver, algo digest.Algorithm) (BlobWriter, error)
NewBlobWriter returns a BlobWriter.
type ErrUnexpectedDigest ¶
type ErrUnexpectedDigest struct { Expected digest.Digest Actual digest.Digest }
ErrUnexpectedDigest can be returned from BlobWriter.Commit()
func (ErrUnexpectedDigest) Error ¶
func (e ErrUnexpectedDigest) Error() string
type ErrUnexpectedSize ¶
ErrUnexpectedSize can be returned from BlobWriter.Commit()
func (ErrUnexpectedSize) Error ¶
func (e ErrUnexpectedSize) Error() string
type ImageDriver ¶
type ImageDriver interface { Init() error Remove(path string) error Reader(path string) (io.ReadCloser, error) Writer(path string, perm os.FileMode) (io.WriteCloser, error) BlobWriter(algo digest.Algorithm) (BlobWriter, error) }
ImageDriver corresponds to the representation of an image. Path uses os.PathSeparator as the separator. The methods of ImageDriver should only be called from oci package.
func Tar ¶
func Tar(w TarWriter) ImageDriver
Tar is ImageDriver for TAR representation of an OCI image.