oci

package
v1.0.0-alpha0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2017 License: Apache-2.0, CC-BY-SA-4.0 Imports: 9 Imported by: 1,071

Documentation

Overview

Package oci provides basic operations for manipulating OCI images.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteBlob

func DeleteBlob(img string, d digest.Digest) error

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

func Init(img, imageLayoutVersion string) error

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 ReadBlob

func ReadBlob(img string, d digest.Digest) ([]byte, error)

ReadBlob reads an OCI blob.

func ReadImageLayout

func ReadImageLayout(img string) (spec.ImageLayout, error)

ReadImageLayout returns the image layout.

func ReadIndex

func ReadIndex(img string) (spec.Index, error)

ReadIndex returns the index.

func RemoveManifestDescriptorFromIndex

func RemoveManifestDescriptorFromIndex(img string, refName string) error

RemoveManifestDescriptorFromIndex removes the manifest descriptor from the index. Returns nil error when the entry not found.

func WriteBlob

func WriteBlob(img string, 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 string, layout spec.ImageLayout) error

WriteImageLayout writes the image layout.

func WriteIndex

func WriteIndex(img string, idx spec.Index) error

WriteIndex writes the index.

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.

Jump to

Keyboard shortcuts

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