handler

package
v0.6.7-256-gba4d382 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: BSD-3-Clause Imports: 43 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file except in compliance with the License.

SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file except in compliance with the License.

SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file except in compliance with the License.

SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file except in compliance with the License.

SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file except in compliance with the License.

Index

Constants

View Source
const (
	ContainerdGCLayerPrefix    = "containerd.io/gc.ref.content.l"
	ContainerdGCManifestPrefix = "containerd.io/gc.ref.content.m"
	KraftKitLabelPrefix        = "kraftkit.sh/oci."
	KraftKitLabelMediaType     = KraftKitLabelPrefix + "mediaType"
)
View Source
const (
	DirectoryHandlerDigestsDir = "digests"
	DirectoryHandlerIndexesDir = "indexes"
)

Variables

This section is empty.

Functions

func ListContainerdObjectsByType added in v0.7.0

func ListContainerdObjectsByType[T any](ctx context.Context, mediaType string, handle *ContainerdHandler) (map[string]*T, error)

ListContainerdObjectsByType is a utility method which iterates across all containerd objects in the store and attempts to typecast the object to the type T. A successful type conversion is added to the hashmap which is ordered by digest.

func ResolveContainerdObjectFromDigest added in v0.7.0

func ResolveContainerdObjectFromDigest[T any](ctx context.Context, handle *ContainerdHandler, digest digest.Digest) (*T, error)

ResolveContainerdObjectFromDigest is a generic method that traverses containerd's content store and attempts to retrieve an object from the store based on its type and digest. This is accomplished by attempting to type-cast the object into the relevant generic T.

Types

type ContainerdHandler

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

func NewContainerdHandler

func NewContainerdHandler(ctx context.Context, address, namespace string, auths map[string]config.AuthConfig, opts ...containerd.ClientOpt) (context.Context, *ContainerdHandler, error)

NewContainerdHandler creates a Resolver-compatible interface given the containerd address and namespace.

func NewContainerdWithClient

func NewContainerdWithClient(ctx context.Context, client *containerd.Client) (context.Context, *ContainerdHandler, error)

NewContainerdWithClient create a containerd Resolver-compatible with an existing containerd client connection.

func (*ContainerdHandler) DeleteIndex added in v0.7.0

func (handle *ContainerdHandler) DeleteIndex(ctx context.Context, fullref string) error

func (*ContainerdHandler) DeleteManifest added in v0.7.0

func (handle *ContainerdHandler) DeleteManifest(ctx context.Context, fullref string, dgst digest.Digest) error

func (*ContainerdHandler) DigestExists

func (handle *ContainerdHandler) DigestExists(ctx context.Context, dgst digest.Digest) (exists bool, err error)

DigestExists implements DigestResolver.

func (*ContainerdHandler) FinalizeImage

func (handle *ContainerdHandler) FinalizeImage(ctx context.Context, image ocispec.Image) error

FinalizeImage implements ImageFinalizer.

func (*ContainerdHandler) ListIndexes added in v0.7.0

func (handle *ContainerdHandler) ListIndexes(ctx context.Context) (map[string]*ocispec.Index, error)

ListIndexes implements IndexLister.

func (*ContainerdHandler) ListManifests

func (handle *ContainerdHandler) ListManifests(ctx context.Context) (manifests map[string]*ocispec.Manifest, err error)

ListManifests implements DigestResolver.

func (*ContainerdHandler) PullDigest added in v0.7.0

func (handle *ContainerdHandler) PullDigest(ctx context.Context, mediaType, fullref string, dgst digest.Digest, plat *ocispec.Platform, onProgress func(float64)) error

PullDigest implements DigestPuller.

func (*ContainerdHandler) PushDescriptor added in v0.7.0

func (handle *ContainerdHandler) PushDescriptor(ctx context.Context, ref string, target *ocispec.Descriptor) error

PushDescriptor implements DescriptorPusher.

func (*ContainerdHandler) ResolveIndex added in v0.7.0

func (handle *ContainerdHandler) ResolveIndex(ctx context.Context, fullref string) (*ocispec.Index, error)

ResolveIndex implements IndexResolver.

func (*ContainerdHandler) ResolveManifest added in v0.7.0

func (handle *ContainerdHandler) ResolveManifest(ctx context.Context, _ string, digest digest.Digest) (*ocispec.Manifest, error)

ResolveManifest implements ManifestResolver.

func (*ContainerdHandler) SaveDescriptor added in v0.7.0

func (handle *ContainerdHandler) SaveDescriptor(ctx context.Context, fullref string, desc ocispec.Descriptor, reader io.Reader, onProgress func(float64)) (err error)

SaveDescriptor implements DescriptorSaver.

func (*ContainerdHandler) UnpackImage

func (handle *ContainerdHandler) UnpackImage(ctx context.Context, ref string, dgst digest.Digest, dest string) (*ocispec.Image, error)

UnpackImage implements ImageUnpacker.

type DescriptorPusher added in v0.7.0

type DescriptorPusher interface {
	// PushDescriptor accepts an input descriptor and an optional canonical name
	// for the descriptor (such as a tag) and uses the handler to push this to a
	// remote registry.
	PushDescriptor(context.Context, string, *ocispec.Descriptor) error
}

type DescriptorSaver added in v0.7.0

type DescriptorSaver interface {
	// SaveDescriptor accepts an optional name reference which represents
	// descriptor (but this is not always necessary and can be left blank if the
	// descriptor is unnamed, e.g. an untagged config, a layer, etc) as well as an
	// io.Reader which is prepared to pass in the byte slice of the descriptor.
	// An optional progress method callback can be provided which is used to
	// deliver the progress of writing the descriptor by the implementing method.
	SaveDescriptor(context.Context, string, ocispec.Descriptor, io.Reader, func(float64)) error
}

type DigestPuller added in v0.7.0

type DigestPuller interface {
	// PullDigest retrieves the provided mediaType, full canonically referencable
	// image and its digest for the given platform and returns the progress of
	// retrieving said digest via the onProgress callback.
	PullDigest(ctx context.Context, mediaType, fullref string, dgst digest.Digest, plat *ocispec.Platform, onProgress func(float64)) error
}

type DigestResolver

type DigestResolver interface {
	DigestExists(context.Context, digest.Digest) (bool, error)
}

type DirectoryHandler added in v0.6.4

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

func NewDirectoryHandler added in v0.6.4

func NewDirectoryHandler(path string, auths map[string]config.AuthConfig) (*DirectoryHandler, error)

func (*DirectoryHandler) DeleteIndex added in v0.7.0

func (handle *DirectoryHandler) DeleteIndex(ctx context.Context, fullref string) error

func (*DirectoryHandler) DeleteManifest added in v0.7.0

func (handle *DirectoryHandler) DeleteManifest(ctx context.Context, fullref string, dgst digest.Digest) error

func (*DirectoryHandler) DigestExists added in v0.6.4

func (handle *DirectoryHandler) DigestExists(ctx context.Context, needle digest.Digest) (exists bool, err error)

DigestExists implements DigestResolver.

func (*DirectoryHandler) FinalizeImage added in v0.6.4

func (handle *DirectoryHandler) FinalizeImage(ctx context.Context, image ocispec.Image) error

FinalizeImage implements ImageFinalizer.

func (*DirectoryHandler) ListIndexes added in v0.7.0

func (handle *DirectoryHandler) ListIndexes(ctx context.Context) (map[string]*ocispec.Index, error)

ListIndexes implements IndexLister.

func (*DirectoryHandler) ListManifests added in v0.6.4

func (handle *DirectoryHandler) ListManifests(ctx context.Context) (map[string]*ocispec.Manifest, error)

ListManifests implements DigestResolver.

func (*DirectoryHandler) PullDigest added in v0.7.0

func (handle *DirectoryHandler) PullDigest(ctx context.Context, mediaType, fullref string, dgst digest.Digest, plat *ocispec.Platform, onProgress func(float64)) error

PullDigest implements DigestPuller.

func (*DirectoryHandler) PushDescriptor added in v0.7.0

func (handle *DirectoryHandler) PushDescriptor(ctx context.Context, fullref string, desc *ocispec.Descriptor) error

PushDescriptor implements DescriptorPusher.

func (*DirectoryHandler) ResolveIndex added in v0.7.0

func (handle *DirectoryHandler) ResolveIndex(ctx context.Context, fullref string) (*ocispec.Index, error)

ResolveIndex implements IndexResolver.

func (*DirectoryHandler) ResolveManifest added in v0.7.0

func (handle *DirectoryHandler) ResolveManifest(ctx context.Context, fullref string, dgst digest.Digest) (*ocispec.Manifest, error)

ResolveManifest implements ManifestResolver.

func (*DirectoryHandler) SaveDescriptor added in v0.7.0

func (handle *DirectoryHandler) SaveDescriptor(ctx context.Context, ref string, desc ocispec.Descriptor, reader io.Reader, onProgress func(float64)) error

SaveDescriptor implements DescriptorSaver.

func (*DirectoryHandler) UnpackImage added in v0.6.4

func (handle *DirectoryHandler) UnpackImage(ctx context.Context, fullref string, dgst digest.Digest, dest string) (*ocispec.Image, error)

UnpackImage implements ImageUnpacker.

type DirectoryIndex added in v0.7.0

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

func (*DirectoryIndex) Digest added in v0.7.0

func (di *DirectoryIndex) Digest() (v1.Hash, error)

Digest implements v1.ImageIndex

func (*DirectoryIndex) Image added in v0.7.0

func (di *DirectoryIndex) Image(manifestDigest v1.Hash) (v1.Image, error)

Image implements v1.ImageIndex

func (*DirectoryIndex) ImageIndex added in v0.7.0

func (di *DirectoryIndex) ImageIndex(v1.Hash) (v1.ImageIndex, error)

ImageIndex implements v1.ImageIndex

func (*DirectoryIndex) IndexManifest added in v0.7.0

func (di *DirectoryIndex) IndexManifest() (*v1.IndexManifest, error)

IndexManifest implements v1.ImageIndex

func (*DirectoryIndex) MediaType added in v0.7.0

func (di *DirectoryIndex) MediaType() (types.MediaType, error)

MediaType implements v1.ImageIndex

func (*DirectoryIndex) RawManifest added in v0.7.0

func (di *DirectoryIndex) RawManifest() ([]byte, error)

RawManifest implements v1.ImageIndex

func (*DirectoryIndex) Size added in v0.7.0

func (di *DirectoryIndex) Size() (int64, error)

Size implements v1.ImageIndex

type DirectoryLayer added in v0.6.5

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

func (DirectoryLayer) Compressed added in v0.6.5

func (dl DirectoryLayer) Compressed() (io.ReadCloser, error)

Compressed returns the compressed layer as a ReadCloser It reads the layer from the filesystem

func (DirectoryLayer) DiffID added in v0.6.5

func (dl DirectoryLayer) DiffID() (v1.Hash, error)

DiffID returns the diffID of the layer as a Hash

func (DirectoryLayer) Digest added in v0.6.5

func (dl DirectoryLayer) Digest() (v1.Hash, error)

Digest returns the digest of the layer as a Hash

func (DirectoryLayer) MediaType added in v0.6.5

func (dl DirectoryLayer) MediaType() (types.MediaType, error)

MediaType returns the mediatype of the layer

func (DirectoryLayer) Size added in v0.6.5

func (dl DirectoryLayer) Size() (int64, error)

Size returns the size of the layer

func (DirectoryLayer) Uncompressed added in v0.6.5

func (dl DirectoryLayer) Uncompressed() (io.ReadCloser, error)

Uncompressed is not implemented

type DirectoryManifest added in v0.7.0

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

func (DirectoryManifest) ConfigFile added in v0.7.0

func (dm DirectoryManifest) ConfigFile() (*v1.ConfigFile, error)

ConfigFile returns the structured config file of the image

func (DirectoryManifest) ConfigName added in v0.7.0

func (dm DirectoryManifest) ConfigName() (v1.Hash, error)

ConfigName returns the hash of the image config

func (DirectoryManifest) Digest added in v0.7.0

func (dm DirectoryManifest) Digest() (v1.Hash, error)

Digest returns the hash of the image manifest

func (DirectoryManifest) LayerByDiffID added in v0.7.0

func (dm DirectoryManifest) LayerByDiffID(hash v1.Hash) (v1.Layer, error)

LayerByDiffID returns the layer with the given hash Unused by push

func (DirectoryManifest) LayerByDigest added in v0.7.0

func (dm DirectoryManifest) LayerByDigest(hash v1.Hash) (v1.Layer, error)

LayerByDigest returns the layer with the given hash Unused by push

func (DirectoryManifest) Layers added in v0.7.0

func (dm DirectoryManifest) Layers() ([]v1.Layer, error)

Layers returns the layers of the image

func (DirectoryManifest) Manifest added in v0.7.0

func (dm DirectoryManifest) Manifest() (*v1.Manifest, error)

Manifest returns the structured manifest of the image

func (DirectoryManifest) MediaType added in v0.7.0

func (dm DirectoryManifest) MediaType() (types.MediaType, error)

MediaType returns the mediatype of the image

func (DirectoryManifest) RawConfigFile added in v0.7.0

func (dm DirectoryManifest) RawConfigFile() ([]byte, error)

RawConfigFile returns the config file of the image in bytes It reads the config file from the filesystem

func (DirectoryManifest) RawManifest added in v0.7.0

func (dm DirectoryManifest) RawManifest() ([]byte, error)

RawManifest returns the manifest of the image in bytes It reads the manifest from the filesystem

func (DirectoryManifest) Size added in v0.7.0

func (dm DirectoryManifest) Size() (int64, error)

Size returns the size of the image manifest

type ImageUnpacker

type ImageUnpacker interface {
	UnpackImage(context.Context, string, digest.Digest, string) (*ocispec.Image, error)
}

type IndexDeleter added in v0.7.0

type IndexDeleter interface {
	DeleteIndex(context.Context, string) error
}

type IndexLister added in v0.7.0

type IndexLister interface {
	ListIndexes(context.Context) (map[string]*ocispec.Index, error)
}

type IndexResolver added in v0.7.0

type IndexResolver interface {
	ResolveIndex(context.Context, string) (*ocispec.Index, error)
}

type ManifestDeleter added in v0.7.0

type ManifestDeleter interface {
	DeleteManifest(context.Context, string, digest.Digest) error
}

type ManifestLister

type ManifestLister interface {
	ListManifests(context.Context) (map[string]*ocispec.Manifest, error)
}

type ManifestResolver added in v0.7.0

type ManifestResolver interface {
	ResolveManifest(context.Context, string, digest.Digest) (*ocispec.Manifest, error)
}

Jump to

Keyboard shortcuts

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