cnabtooci

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2024 License: Apache-2.0 Imports: 26 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.

func WithRegistryOptions added in v1.2.1

func WithRegistryOptions(registryOpts RegistryOptions) func(*PushBundleOptions)

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 ImageMetadata added in v1.0.12

type ImageMetadata struct {
	Reference   cnab.OCIReference
	RepoDigests []string
}

ImageMetadata contains information about an OCI image.

func NewImageSummaryFromDigest added in v1.0.12

func NewImageSummaryFromDigest(ref cnab.OCIReference, repoDigest digest.Digest) (ImageMetadata, error)

func NewImageSummaryFromInspect added in v1.0.12

func NewImageSummaryFromInspect(ref cnab.OCIReference, sum types.ImageInspect) (ImageMetadata, error)

func (ImageMetadata) GetRepositoryDigest added in v1.0.12

func (i ImageMetadata) GetRepositoryDigest() (digest.Digest, error)

GetRepositoryDigest finds the repository digest associated with the original image reference used to create this ImageMetadata.

func (ImageMetadata) IsZero added in v1.0.12

func (i ImageMetadata) IsZero() bool

func (ImageMetadata) String added in v1.0.12

func (i ImageMetadata) String() string

type PushBundleOptions added in v1.2.1

type PushBundleOptions struct {
	RegistryOptions
}

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) (ImageMetadata, error)

GetCachedImage returns information about an image from local docker cache.

func (*Registry) GetImageMetadata added in v1.0.12

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

GetImageMetadata returns information about an image in a registry Use ErrNotFound to detect if the error is because the image is not in the registry.

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)

PushBundle pushes a bundle to an OCI registry.

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) (ImageMetadata, 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

	// GetImageMetadata returns information about an image in a registry
	// Use ErrNotFound to detect if the error is because the image is not in the registry.
	GetImageMetadata(ctx context.Context, ref cnab.OCIReference, opts RegistryOptions) (ImageMetadata, 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) (ImageMetadata, 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)
	MockGetImageMetadata  func(ctx context.Context, ref cnab.OCIReference, opts RegistryOptions) (ImageMetadata, 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) (ImageMetadata, error)

func (TestRegistry) GetImageMetadata added in v1.0.12

func (t TestRegistry) GetImageMetadata(ctx context.Context, ref cnab.OCIReference, opts RegistryOptions) (ImageMetadata, 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