oci

package
v2.0.0-...-9cac419 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package oci provides access to an OCI content store. Reference: https://github.com/opencontainers/image-spec/blob/v1.1.0-rc2/image-layout.md

Package oci provides access to an OCI content store. Reference: https://github.com/opencontainers/image-spec/blob/v1.1.0-rc2/image-layout.md

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ReadOnlyStorage

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

ReadOnlyStorage is a read-only CAS based on file system with the OCI-Image layout. Reference: https://github.com/opencontainers/image-spec/blob/v1.1.0-rc2/image-layout.md

func NewStorageFromFS

func NewStorageFromFS(fsys fs.FS) *ReadOnlyStorage

NewStorageFromFS creates a new read-only CAS from fsys.

func NewStorageFromTar

func NewStorageFromTar(path string) (*ReadOnlyStorage, error)

NewStorageFromTar creates a new read-only CAS from a tar archive located at path.

func (*ReadOnlyStorage) Exists

func (s *ReadOnlyStorage) Exists(_ context.Context, target ocispec.Descriptor) (bool, error)

Exists returns true if the described content Exists.

func (*ReadOnlyStorage) Fetch

Fetch fetches the content identified by the descriptor.

type ReadOnlyStore

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

ReadOnlyStore implements `oras.ReadonlyTarget`, and represents a read-only content store based on file system with the OCI-Image layout. Reference: https://github.com/opencontainers/image-spec/blob/v1.1.0-rc2/image-layout.md

func NewFromFS

func NewFromFS(ctx context.Context, fsys fs.FS) (*ReadOnlyStore, error)

NewFromFS creates a new read-only OCI store from fsys.

func NewFromTar

func NewFromTar(ctx context.Context, path string) (*ReadOnlyStore, error)

NewFromTar creates a new read-only OCI store from a tar archive located at path.

func (*ReadOnlyStore) Exists

func (s *ReadOnlyStore) Exists(ctx context.Context, target ocispec.Descriptor) (bool, error)

Exists returns true if the described content exists.

func (*ReadOnlyStore) Fetch

func (s *ReadOnlyStore) Fetch(ctx context.Context, target ocispec.Descriptor) (io.ReadCloser, error)

Fetch fetches the content identified by the descriptor.

func (*ReadOnlyStore) Predecessors

func (s *ReadOnlyStore) Predecessors(ctx context.Context, node ocispec.Descriptor) ([]ocispec.Descriptor, error)

Predecessors returns the nodes directly pointing to the current node. Predecessors returns nil without error if the node does not exists in the store.

func (*ReadOnlyStore) Resolve

func (s *ReadOnlyStore) Resolve(ctx context.Context, reference string) (ocispec.Descriptor, error)

Resolve resolves a reference to a descriptor.

func (*ReadOnlyStore) Tags

func (s *ReadOnlyStore) Tags(ctx context.Context, last string, fn func(tags []string) error) error

Tags lists the tags presented in the `index.json` file of the OCI layout, returned in ascending order. If `last` is NOT empty, the entries in the response start after the tag specified by `last`. Otherwise, the response starts from the top of the tags list.

See also `Tags()` in the package `registry`.

type Storage

type Storage struct {
	*ReadOnlyStorage
	// contains filtered or unexported fields
}

Storage is a CAS based on file system with the OCI-Image layout. Reference: https://github.com/opencontainers/image-spec/blob/v1.1.0-rc2/image-layout.md

func NewStorage

func NewStorage(root string) *Storage

NewStorage creates a new CAS based on file system with the OCI-Image layout.

func (*Storage) Push

func (s *Storage) Push(_ context.Context, expected ocispec.Descriptor, content io.Reader) error

Push pushes the content, matching the expected descriptor.

type Store

type Store struct {
	// AutoSaveIndex controls if the OCI store will automatically save the index
	// file on each Tag() call.
	// If AutoSaveIndex is set to true, the OCI store will automatically call
	// this method on each Tag() call.
	// If AutoSaveIndex is set to false, it's the caller's responsibility
	// to manually call SaveIndex() when needed.
	// Default value: true.
	AutoSaveIndex bool
	// contains filtered or unexported fields
}

Store implements `oras.Target`, and represents a content store based on file system with the OCI-Image layout. Reference: https://github.com/opencontainers/image-spec/blob/v1.1.0-rc2/image-layout.md

func New

func New(root string) (*Store, error)

New creates a new OCI store with context.Background().

func NewWithContext

func NewWithContext(ctx context.Context, root string) (*Store, error)

NewWithContext creates a new OCI store.

func (*Store) Exists

func (s *Store) Exists(ctx context.Context, target ocispec.Descriptor) (bool, error)

Exists returns true if the described content exists.

func (*Store) Fetch

func (s *Store) Fetch(ctx context.Context, target ocispec.Descriptor) (io.ReadCloser, error)

Fetch fetches the content identified by the descriptor.

func (*Store) Predecessors

func (s *Store) Predecessors(ctx context.Context, node ocispec.Descriptor) ([]ocispec.Descriptor, error)

Predecessors returns the nodes directly pointing to the current node. Predecessors returns nil without error if the node does not exists in the store.

func (*Store) Push

func (s *Store) Push(ctx context.Context, expected ocispec.Descriptor, reader io.Reader) error

Push pushes the content, matching the expected descriptor.

func (*Store) Resolve

func (s *Store) Resolve(ctx context.Context, reference string) (ocispec.Descriptor, error)

Resolve resolves a reference to a descriptor.

func (*Store) SaveIndex

func (s *Store) SaveIndex() error

SaveIndex writes the `index.json` file to the file system. If AutoSaveIndex is set to true (default value), the OCI store will automatically call this method on each Tag() call. If AutoSaveIndex is set to false, it's the caller's responsibility to manually call this method when needed.

func (*Store) Tag

func (s *Store) Tag(ctx context.Context, desc ocispec.Descriptor, reference string) error

Tag tags a descriptor with a reference string. reference should be a valid tag (e.g. "latest"). Reference: https://github.com/opencontainers/image-spec/blob/v1.1.0-rc2/image-layout.md#indexjson-file

func (*Store) Tags

func (s *Store) Tags(ctx context.Context, last string, fn func(tags []string) error) error

Tags lists the tags presented in the `index.json` file of the OCI layout, returned in ascending order. If `last` is NOT empty, the entries in the response start after the tag specified by `last`. Otherwise, the response starts from the top of the tags list.

See also `Tags()` in the package `registry`.

Jump to

Keyboard shortcuts

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