store

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

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 = config.DefaultDaemonRootPath + "content"
)

Variables

This section is empty.

Functions

func ErrCouldNotCreateClient

func ErrCouldNotCreateClient(address string) error

func ErrUnknownContentStoreType

func ErrUnknownContentStoreType(contentStoreType ContentStoreType) error

func GetContentStorePath

func GetContentStorePath(contentStoreType ContentStoreType, root string) (string, error)

GetContentStorePath returns the top level directory for the content store.

func IsErrAlreadyExists

func IsErrAlreadyExists(err error) bool

IsErrAlreadyExists is a store-type-agnostic way to check if the content exists in the 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 NopCleanup

func NopCleanup(context.Context) error

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 ContainerdClient

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

This struct allows SOCI to create a connection to the containerd on-demand instead of on startup, allowing the daemon to start without containerd

func NewContainerdClient

func NewContainerdClient(containerdAddress string) *ContainerdClient

func (*ContainerdClient) Client

func (c *ContainerdClient) Client() (*containerd.Client, error)

type ContainerdStore

type ContainerdStore struct {
	ContentStoreConfig
}

func NewContainerdStore

func NewContainerdStore(storeConfig ContentStoreConfig) (*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 ContentStoreConfig

type ContentStoreConfig struct {
	config.ContentStoreConfig

	SnapshotterRoot string
	// contains filtered or unexported fields
}

func NewStoreConfig

func NewStoreConfig(opts ...Option) ContentStoreConfig

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(*ContentStoreConfig)

func WithClient

func WithClient(client *ContainerdClient) Option

func WithContainerdAddress

func WithContainerdAddress(address string) Option

This func will trim the leading 'unix://' if it is provided

func WithSnapshotterRoot

func WithSnapshotterRoot(root 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(path string) (*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(opts ...Option) (Store, error)

Jump to

Keyboard shortcuts

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