Documentation ¶
Overview ¶
Package oci provides basic operations for manipulating OCI images.
Index ¶
- func DeleteBlob(img string, d digest.Digest) error
- func GetBlobReader(img string, d digest.Digest) (io.ReadCloser, error)
- func Init(img, imageLayoutVersion string) error
- func PutManifestDescriptorToIndex(img string, desc spec.Descriptor) error
- func ReadBlob(img string, d digest.Digest) ([]byte, error)
- func ReadImageLayout(img string) (spec.ImageLayout, error)
- func ReadIndex(img string) (spec.Index, error)
- func RemoveManifestDescriptorFromIndex(img string, refName string) error
- func WriteBlob(img string, b []byte) (digest.Digest, error)
- func WriteImageLayout(img string, layout spec.ImageLayout) error
- func WriteIndex(img string, idx spec.Index) error
- func WriteJSONBlob(img string, x interface{}, mediaType string) (spec.Descriptor, error)
- type BlobWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteBlob ¶
DeleteBlob deletes an OCI blob.
func GetBlobReader ¶
func GetBlobReader(img string, d digest.Digest) (io.ReadCloser, error)
GetBlobReader returns io.ReadCloser for a blob.
func Init ¶
Init initializes the img directory as an OCI image. i.e. Creates oci-layout, index.json, and blobs.
img directory must not exist before calling this function.
imageLayoutVersion can be an empty string for specifying the default version.
func PutManifestDescriptorToIndex ¶
func PutManifestDescriptorToIndex(img string, 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 ReadImageLayout ¶
func ReadImageLayout(img string) (spec.ImageLayout, error)
ReadImageLayout returns the image layout.
func RemoveManifestDescriptorFromIndex ¶
RemoveManifestDescriptorFromIndex removes the manifest descriptor from the index. Returns nil error when the entry not found.
func WriteBlob ¶
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 string, layout spec.ImageLayout) error
WriteImageLayout writes the image layout.
func WriteJSONBlob ¶
func WriteJSONBlob(img string, 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 { io.Writer io.Closer // Digest returns the digest when closed. // Digest panics when the writer is not closed. Digest() digest.Digest }
BlobWriter writes an OCI blob and returns a digest when closed.
func NewBlobWriter ¶
func NewBlobWriter(img string, algo digest.Algorithm) (BlobWriter, error)
NewBlobWriter returns a BlobWriter.