store

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 15 Imported by: 3

Documentation

Index

Constants

View Source
const (
	ContainerdContentStoreType = config.ContainerdContentStoreType
	SociContentStoreType       = config.SociContentStoreType
)
View Source
const (
	// Default path to containerd content addressable storage
	DefaultContainerdContentStorePath = "/var/lib/containerd/io.containerd.content.v1.content"

	// Default path to soci content addressable storage
	DefaultSociContentStorePath = "/var/lib/soci-snapshotter-grpc/content"
)

Variables

This section is empty.

Functions

func ErrUnknownContentStoreType

func ErrUnknownContentStoreType(contentStoreType ContentStoreType) error

func GetContentStorePath

func GetContentStorePath(contentStoreType ContentStoreType) (string, error)

GetContentStorePath returns the top level directory for the content store.

func LabelGCRefContent

func LabelGCRefContent(ctx context.Context, store Store, target ocispec.Descriptor, ref string, digest string) error

LabelGCRefContent labels the target resource to prevent garbage collection of another resource identified by digest with an optional ref to allow and disambiguate multiple content labels.

func LabelGCRoot

func LabelGCRoot(ctx context.Context, store Store, target ocispec.Descriptor) error

LabelGCRoot labels the target resource to prevent garbage collection of itself.

func NewStoreConfig

func NewStoreConfig(opts ...Option) config.ContentStoreConfig

Types

type BasicStore

type BasicStore interface {
	Exists(ctx context.Context, target ocispec.Descriptor) (bool, error)
	Fetch(ctx context.Context, target ocispec.Descriptor) (io.ReadCloser, error)
	Push(ctx context.Context, expected ocispec.Descriptor, reader io.Reader) error
}

BasicStore describes the functionality common to oras-go oci.Store, oras-go memory.Store, and containerd ContentStore.

type CleanupFunc

type CleanupFunc func(context.Context) error

type ContainerdStore

type ContainerdStore struct {
	config.ContentStoreConfig
	// contains filtered or unexported fields
}

func NewContainerdStore

func NewContainerdStore(ctx context.Context, storeConfig config.ContentStoreConfig) (context.Context, *ContainerdStore, error)

func (*ContainerdStore) BatchOpen

BatchOpen creates a lease, ensuring that no content created within the batch will be garbage collected. It returns a cleanup function that ends the lease, which should be called after content is created and labeled.

func (*ContainerdStore) Delete

func (s *ContainerdStore) Delete(ctx context.Context, dgst digest.Digest) error

Delete removes the described content.

func (*ContainerdStore) Exists

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

Exists returns true iff the described content exists.

func (*ContainerdStore) Fetch

Fetch fetches the content identified by the descriptor.

func (*ContainerdStore) Label

func (s *ContainerdStore) Label(ctx context.Context, target ocispec.Descriptor, name string, value string) error

Label creates or updates the named label with the given value.

func (*ContainerdStore) Push

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

Push pushes the content, matching the expected descriptor. This should be done within a Batch and followed by Label calls to prevent garbage collection.

type ContentStoreType

type ContentStoreType = config.ContentStoreType

func CanonicalizeContentStoreType

func CanonicalizeContentStoreType(contentStoreType ContentStoreType) (ContentStoreType, error)

CanonicalizeContentStoreType resolves the empty string to DefaultContentStoreType, returns other types, or errors on unrecognized types.

func ContentStoreTypes

func ContentStoreTypes() []ContentStoreType

ContentStoreTypes returns a slice of all supported content store types.

type Option

type Option func(*config.ContentStoreConfig)

func WithContainerdAddress added in v0.5.0

func WithContainerdAddress(address string) Option

func WithNamespace

func WithNamespace(namespace string) Option

func WithType

func WithType(contentStoreType ContentStoreType) Option

type SociStore

type SociStore struct {
	*oci.Store
}

SociStore wraps oci.Store and adds or stubs additional functionality of the Store interface.

func NewSociStore

func NewSociStore(ctx context.Context) (context.Context, *SociStore, error)

NewSociStore creates a sociStore.

func (*SociStore) BatchOpen

func (s *SociStore) BatchOpen(ctx context.Context) (context.Context, CleanupFunc, error)

BatchOpen is a no-op for sociStore; it does not support batching operations.

func (*SociStore) Delete

func (s *SociStore) Delete(_ context.Context, _ digest.Digest) error

Delete is a no-op for sociStore until oci.Store provides this method.

func (*SociStore) Label

Label is a no-op for sociStore until sociStore and ArtifactsDb are better integrated.

type Store

type Store interface {
	BasicStore
	Label(ctx context.Context, target ocispec.Descriptor, label string, value string) error
	Delete(ctx context.Context, dgst digest.Digest) error
	// BatchOpen starts a series of operations that should not be interrupted by garbage collection.
	// It returns a cleanup function that ends the batch, which should be called after
	// all associated content operations are finished.
	BatchOpen(ctx context.Context) (context.Context, CleanupFunc, error)
}

Store extends BasicStore with functionality that in not present in some BasicStore implementations and may be stubbed in some Store implementations

func NewContentStore

func NewContentStore(ctx context.Context, opts ...Option) (context.Context, Store, error)

Jump to

Keyboard shortcuts

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