oras

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoImageIndexToPush = errors.New("no image index to push")
	ErrNoImageToPush      = errors.New("no image to push")
)

Functions

func AuthConfig

func AuthConfig(username, password string) remote.Option

AuthConfig returns option for the authentication to a remote registry.

func CompatibleManifest

func CompatibleManifest(mt types.MediaType) bool

CompatibleManifest returns if the media type corresponds to a compatible ORAS manifest.

func GetLayer added in v0.0.6

func GetLayer(manifest *v1.Manifest, mediaType types.MediaType) (v1.Descriptor, error)

func GetLayerFilter added in v0.0.6

func GetLayerFilter(manifest *v1.Manifest, mediaTypeFilter MediaTypeFilter) (v1.Descriptor, error)

func GetManifest

func GetManifest(ref name.Reference, options ...remote.Option) (*v1.Manifest, error)

GetManifest returns the manifest corresponding to the reference.

func HeadManifest

func HeadManifest(ref name.Reference, options ...remote.Option) (types.MediaType, string, error)

HeadManifest returns the media type and digest of the manifest corresponding to the reference.

func Pull

func Pull(puller Puller, options ...remote.Option) error

Pull pulls an image from a remote OCI registry.

func PullIndex

func PullIndex(puller Puller, options ...remote.Option) error

PullIndex pulls an image index from a remote OCI registry.

func Push

func Push(pusher Pusher, options ...remote.Option) error

Push images to a remote OCI registry.

Types

type Image

type Image struct {
	// contains filtered or unexported fields
}

Image defines an ORAS artifact manifest with the associated images layers.

func NewImage

func NewImage() *Image

NewImage returns a Image instance for uploading artifacts to OCI registries.

func (*Image) AddConfig

func (i *Image) AddConfig(mt types.MediaType, rawConfig []byte) error

func (*Image) AddLayer

func (i *Image) AddLayer(layer Layer) error

AddLayer adds a blob layer to the image manifest.

func (*Image) ConfigFile

func (i *Image) ConfigFile() (*v1.ConfigFile, error)

ConfigFile returns this image's config file.

func (*Image) ConfigName

func (i *Image) ConfigName() (v1.Hash, error)

ConfigName returns the hash of the image's config file, also known as the Image ID.

func (*Image) Digest

func (i *Image) Digest() (v1.Hash, error)

Digest returns the sha256 of this image's manifest.

func (*Image) LayerByDiffID

func (i *Image) LayerByDiffID(v1.Hash) (v1.Layer, error)

LayerByDiffID is an analog to LayerByDigest, looking up by "diff id" (not supported by ORAS).

func (*Image) LayerByDigest

func (i *Image) LayerByDigest(hash v1.Hash) (v1.Layer, error)

LayerByDigest returns a Layer for interacting with a particular layer of the image, looking it up by "digest" (the compressed hash).

func (*Image) Layers

func (i *Image) Layers() ([]v1.Layer, error)

Layers returns a unordered collection of SIF file.

func (*Image) Manifest

func (i *Image) Manifest() (*v1.Manifest, error)

Manifest returns this image's Manifest object.

func (*Image) MediaType

func (i *Image) MediaType() (types.MediaType, error)

MediaType of this image's manifest.

func (*Image) RawConfigFile

func (i *Image) RawConfigFile() ([]byte, error)

RawConfigFile returns the serialized bytes of ConfigFile().

func (*Image) RawManifest

func (i *Image) RawManifest() ([]byte, error)

RawManifest returns the serialized bytes of Manifest().

func (*Image) Size

func (i *Image) Size() (int64, error)

Size returns the size of the manifest.

type ImageIndex

type ImageIndex struct {
	// contains filtered or unexported fields
}

ImageIndex defines an image index.

func ImageIndexFromReference

func ImageIndexFromReference(ref name.Reference, options ...remote.Option) (*ImageIndex, error)

ImageIndexIndexFromReference returns an image index populated with the remote image reference to update an existing image index.

func NewImageIndex

func NewImageIndex() *ImageIndex

NewImageIndex returns an image index.

func (*ImageIndex) AddImage

func (i *ImageIndex) AddImage(image *Image) error

AddImage adds an image to the image index.

func (*ImageIndex) Digest

func (i *ImageIndex) Digest() (v1.Hash, error)

Digest returns the sha256 of this index's manifest.

func (*ImageIndex) Image

func (i *ImageIndex) Image(hash v1.Hash) (v1.Image, error)

Image returns a v1.Image that this ImageIndex references.

func (*ImageIndex) ImageIndex

func (i *ImageIndex) ImageIndex(v1.Hash) (v1.ImageIndex, error)

ImageIndex returns a v1.ImageIndex that this ImageIndex references. Not supported for ORAS.

func (*ImageIndex) IndexManifest

func (i *ImageIndex) IndexManifest() (*v1.IndexManifest, error)

IndexManifest returns this image index's manifest object.

func (*ImageIndex) MediaType

func (i *ImageIndex) MediaType() (types.MediaType, error)

MediaType of this image's manifest.

func (*ImageIndex) RawManifest

func (i *ImageIndex) RawManifest() ([]byte, error)

RawManifest returns the serialized bytes of IndexManifest().

func (*ImageIndex) RemoveImage

func (i *ImageIndex) RemoveImage(hash v1.Hash)

RemoveImage removes image manifest and layers if any from the current image index.

func (*ImageIndex) Size

func (i *ImageIndex) Size() (int64, error)

Size returns the size of the manifest.

type Layer

type Layer interface {
	v1.Layer
	Annotations() map[string]string
	Platform() *v1.Platform
}

Layer defines the image layer interface.

type LayerOption added in v0.0.20

type LayerOption func(*LayerOptions)

func WithLayerAnnotations added in v0.0.20

func WithLayerAnnotations(annotations map[string]string) LayerOption

func WithLayerMediaType added in v0.0.20

func WithLayerMediaType(mediaType string) LayerOption

func WithLayerPlatform added in v0.0.20

func WithLayerPlatform(platform *v1.Platform) LayerOption

type LayerOptions added in v0.0.20

type LayerOptions struct {
	// contains filtered or unexported fields
}

type LocalFileLayer added in v0.0.10

type LocalFileLayer struct {
	// contains filtered or unexported fields
}

LocalFileLayer defines an OCI layer descriptor associated to a local file.

func NewLocalFileLayer added in v0.0.10

func NewLocalFileLayer(path string, options ...LayerOption) *LocalFileLayer

NewLocalLayer returns an OCI layer descriptor for the corresponding local file.

func (*LocalFileLayer) Annotations added in v0.0.10

func (l *LocalFileLayer) Annotations() map[string]string

Annotations returns annotations associated to this layer.

func (*LocalFileLayer) Compressed added in v0.0.10

func (l *LocalFileLayer) Compressed() (io.ReadCloser, error)

Compressed returns an io.ReadCloser for the file content.

func (*LocalFileLayer) DiffID added in v0.0.10

func (l *LocalFileLayer) DiffID() (v1.Hash, error)

DiffID returns the Hash of the uncompressed layer (not supported by ORAS).

func (*LocalFileLayer) Digest added in v0.0.10

func (l *LocalFileLayer) Digest() (_ v1.Hash, err error)

Digest returns the Hash of the local file.

func (*LocalFileLayer) MediaType added in v0.0.10

func (l *LocalFileLayer) MediaType() (types.MediaType, error)

MediaType returns the media type of the Layer.

func (*LocalFileLayer) Platform added in v0.0.10

func (l *LocalFileLayer) Platform() *v1.Platform

Platform returns platform information for this layer.

func (*LocalFileLayer) Size added in v0.0.10

func (l *LocalFileLayer) Size() (int64, error)

Size returns the size of the local file.

func (*LocalFileLayer) Uncompressed added in v0.0.10

func (l *LocalFileLayer) Uncompressed() (io.ReadCloser, error)

Uncompressed returns an io.ReadCloser for the uncompressed layer contents (not supported by ORAS).

type ManifestConfig added in v0.0.10

type ManifestConfig interface {
	RawConfig() []byte
	MediaType() types.MediaType
}

ManifestConfig defines the interface for manifest configs.

func NewManifestConfig added in v0.0.10

func NewManifestConfig(mediaType string, rawConfig []byte) ManifestConfig

NewManifestConfig returns a ManifestConfig to push.

type MediaTypeFilter added in v0.0.6

type MediaTypeFilter func(types.MediaType) bool

type Puller

type Puller interface {
	// Reference returns the image reference to pull.
	Reference() name.Reference
	// IndexManifest returns the image hash manifest to pull from.
	IndexManifest(*v1.IndexManifest) *v1.Hash
	// Config inspects manifest config descriptor.
	Config(v1.Descriptor) error
	// RawConfig parses config blob descriptor content.
	RawConfig([]byte) error
	// Layers downloads image blobs.
	Layers([]v1.Layer) error
}

Puller defines the interface for pulling images.

type Pusher

type Pusher interface {
	// Reference returns the image reference to pull.
	Reference() name.Reference
	ImageIndex() (v1.ImageIndex, error)
	Image() (v1.Image, error)
}

func NewGenericPusher added in v0.0.10

func NewGenericPusher(ref name.Reference, manifestConfig ManifestConfig, layer Layer) Pusher

NewGenericPusher returns a pusher to push a manifest and a blob to a registry.

type StreamLayer added in v0.0.20

type StreamLayer struct {
	io.Reader
	// contains filtered or unexported fields
}

StreamLayer defines an OCI layer descriptor associated to a stream.

func NewStreamLayer added in v0.0.20

func NewStreamLayer(stream io.Reader, options ...LayerOption) *StreamLayer

NewStreamLayer returns an OCI layer descriptor for the corresponding stream.

func (*StreamLayer) Annotations added in v0.0.20

func (sl *StreamLayer) Annotations() map[string]string

Annotations returns annotations associated to this layer.

func (*StreamLayer) Close added in v0.0.20

func (sl *StreamLayer) Close() error

Close closes the underlying stream and computes the digest.

func (*StreamLayer) Compressed added in v0.0.20

func (sl *StreamLayer) Compressed() (io.ReadCloser, error)

Compressed returns an io.ReadCloser for the file content.

func (*StreamLayer) DiffID added in v0.0.20

func (sl *StreamLayer) DiffID() (v1.Hash, error)

DiffID returns the Hash of the uncompressed layer (not supported by ORAS).

func (*StreamLayer) Digest added in v0.0.20

func (sl *StreamLayer) Digest() (v1.Hash, error)

Digest returns the Hash of the consumed stream.

func (*StreamLayer) MediaType added in v0.0.20

func (sl *StreamLayer) MediaType() (types.MediaType, error)

MediaType returns the media type of the Layer.

func (*StreamLayer) Platform added in v0.0.20

func (sl *StreamLayer) Platform() *v1.Platform

Platform returns platform information for this layer.

func (*StreamLayer) Size added in v0.0.20

func (sl *StreamLayer) Size() (int64, error)

Size returns the size of the consumed stream.

func (*StreamLayer) Uncompressed added in v0.0.20

func (sl *StreamLayer) Uncompressed() (io.ReadCloser, error)

Uncompressed returns an io.ReadCloser for the uncompressed layer contents (not supported by ORAS).

Jump to

Keyboard shortcuts

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