cnabtooci

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: Apache-2.0 Imports: 23 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetInsecureRegistryTransport added in v1.0.1

func GetInsecureRegistryTransport() *http.Transport

GetInsecureRegistryTransport returns a copy of the default http transport with InsecureSkipVerify set so that we can use it with insecure registries.

Types

type BundleMetadata added in v1.0.1

type BundleMetadata struct {
	cnab.BundleReference
}

BundleMetadata represents summary information about a bundle in a registry.

type ErrNoContentDigest added in v0.30.0

type ErrNoContentDigest error

ErrNoContentDigest represents an error due to an image not having a corresponding content digest in a bundle definition

func NewErrNoContentDigest added in v0.30.0

func NewErrNoContentDigest(image string) ErrNoContentDigest

NewErrNoContentDigest returns an ErrNoContentDigest formatted with the provided image name

type ErrNotFound added in v1.0.1

type ErrNotFound struct {
	Reference cnab.OCIReference
}

ErrNotFound represents when a bundle or image is not found.

func (ErrNotFound) Error added in v1.0.1

func (e ErrNotFound) Error() string

func (ErrNotFound) Is added in v1.0.1

func (e ErrNotFound) Is(target error) bool

func (ErrNotFound) String added in v1.0.1

func (e ErrNotFound) String() string

type ImageSummary added in v1.0.1

type ImageSummary struct {
	types.ImageInspect
	// contains filtered or unexported fields
}

ImageSummary contains information about an OCI image.

func NewImageSummary added in v1.0.1

func NewImageSummary(imageRef string, sum types.ImageInspect) (ImageSummary, error)

func (ImageSummary) Digest added in v1.0.1

func (i ImageSummary) Digest() (digest.Digest, error)

Digest returns the image digest for the image reference.

func (ImageSummary) GetImageReference added in v1.0.1

func (i ImageSummary) GetImageReference() cnab.OCIReference

func (ImageSummary) IsZero added in v1.0.1

func (i ImageSummary) IsZero() bool

type Registry

type Registry struct {
	*portercontext.Context
}

func NewRegistry

func NewRegistry(c *portercontext.Context) *Registry

func (*Registry) GetBundleMetadata added in v1.0.1

func (r *Registry) GetBundleMetadata(ctx context.Context, ref cnab.OCIReference, opts RegistryOptions) (BundleMetadata, error)

GetBundleMetadata returns information about a bundle in a registry Use ErrNotFound to detect if the error is because the bundle is not in the registry.

func (*Registry) GetCachedImage added in v1.0.1

func (r *Registry) GetCachedImage(ctx context.Context, ref cnab.OCIReference) (ImageSummary, error)

GetCachedImage returns information about an image from local docker cache.

func (*Registry) ListTags added in v1.0.1

func (r *Registry) ListTags(ctx context.Context, ref cnab.OCIReference, opts RegistryOptions) ([]string, error)

func (*Registry) PullBundle

PullBundle pulls a bundle from an OCI registry. Returns the bundle, and an optional image relocation mapping, if applicable.

func (*Registry) PullImage added in v1.0.1

func (r *Registry) PullImage(ctx context.Context, ref cnab.OCIReference, opts RegistryOptions) error

PullImage pulls an image from an OCI registry.

func (*Registry) PushBundle

func (r *Registry) PushBundle(ctx context.Context, bundleRef cnab.BundleReference, opts RegistryOptions) (cnab.BundleReference, error)

func (*Registry) PushImage added in v1.0.1

func (r *Registry) PushImage(ctx context.Context, ref cnab.OCIReference, opts RegistryOptions) (digest.Digest, error)

PushImage pushes the image from the Docker image cache to the specified location the expected format of the image is REGISTRY/NAME:TAG. Returns the image digest from the registry.

type RegistryOptions added in v1.0.1

type RegistryOptions struct {
	// InsecureRegistry allows connecting to an unsecured registry or one without verifiable certificates.
	InsecureRegistry bool
}

RegistryOptions is the set of options for interacting with an OCI registry.

type RegistryProvider

type RegistryProvider interface {
	// PullBundle pulls a bundle from an OCI registry.
	PullBundle(ctx context.Context, ref cnab.OCIReference, opts RegistryOptions) (cnab.BundleReference, error)

	// PushBundle pushes a bundle to an OCI registry.
	PushBundle(ctx context.Context, ref cnab.BundleReference, opts RegistryOptions) (cnab.BundleReference, error)

	// PushImage pushes the image from the Docker image cache to the specified location
	// the expected format of the image is REGISTRY/NAME:TAG.
	// Returns the image digest from the registry.
	PushImage(ctx context.Context, ref cnab.OCIReference, opts RegistryOptions) (digest.Digest, error)

	// GetCachedImage returns a particular image from the local image cache.
	// Use ErrNotFound to detect if the failure is because the image is not in the local Docker cache.
	GetCachedImage(ctx context.Context, ref cnab.OCIReference) (ImageSummary, error)

	// ListTags returns all tags defined on the specified repository.
	ListTags(ctx context.Context, repo cnab.OCIReference, opts RegistryOptions) ([]string, error)

	// PullImage pulls an image from an OCI registry and returns the image's digest
	PullImage(ctx context.Context, image cnab.OCIReference, opts RegistryOptions) error

	// GetBundleMetadata returns information about a bundle in a registry
	// Use ErrNotFound to detect if the error is because the bundle is not in the registry.
	GetBundleMetadata(ctx context.Context, ref cnab.OCIReference, opts RegistryOptions) (BundleMetadata, error)
}

RegistryProvider handles talking with an OCI registry.

type TestRegistry

type TestRegistry struct {
	MockPullBundle        func(ctx context.Context, ref cnab.OCIReference, opts RegistryOptions) (cnab.BundleReference, error)
	MockPushBundle        func(ctx context.Context, ref cnab.BundleReference, opts RegistryOptions) (bundleReference cnab.BundleReference, err error)
	MockPushImage         func(ctx context.Context, ref cnab.OCIReference, opts RegistryOptions) (imageDigest digest.Digest, err error)
	MockGetCachedImage    func(ctx context.Context, ref cnab.OCIReference) (ImageSummary, error)
	MockListTags          func(ctx context.Context, ref cnab.OCIReference, opts RegistryOptions) ([]string, error)
	MockPullImage         func(ctx context.Context, ref cnab.OCIReference, opts RegistryOptions) error
	MockGetBundleMetadata func(ctx context.Context, ref cnab.OCIReference, opts RegistryOptions) (BundleMetadata, error)
	// contains filtered or unexported fields
}

func NewTestRegistry

func NewTestRegistry() *TestRegistry

func (TestRegistry) GetBundleMetadata added in v1.0.1

func (t TestRegistry) GetBundleMetadata(ctx context.Context, ref cnab.OCIReference, opts RegistryOptions) (BundleMetadata, error)

func (*TestRegistry) GetCachedImage added in v1.0.1

func (t *TestRegistry) GetCachedImage(ctx context.Context, ref cnab.OCIReference) (ImageSummary, error)

func (*TestRegistry) ListTags added in v1.0.1

func (t *TestRegistry) ListTags(ctx context.Context, ref cnab.OCIReference, opts RegistryOptions) ([]string, error)

func (TestRegistry) PullBundle

func (*TestRegistry) PullImage added in v1.0.1

func (t *TestRegistry) PullImage(ctx context.Context, ref cnab.OCIReference, opts RegistryOptions) error

func (*TestRegistry) PushBundle

func (*TestRegistry) PushImage added in v1.0.1

func (t *TestRegistry) PushImage(ctx context.Context, ref cnab.OCIReference, opts RegistryOptions) (digest.Digest, error)

Jump to

Keyboard shortcuts

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