oci

package
v0.23.8 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: Apache-2.0 Imports: 26 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Client             client.Client
	OCIRepositoryAddr  string
	InsecureSkipVerify bool
	Namespace          string
	CertSecretName     string
	// contains filtered or unexported fields
}

Client implements the caching layer and the OCI layer.

func NewClient

func NewClient(ociAddress string, opts ...ClientOptsFunc) *Client

NewClient creates a new OCI Client.

func (*Client) DeleteData

func (c *Client) DeleteData(ctx context.Context, name, tag string) error

DeleteData removes a specific tag from the cache.

func (*Client) FetchDataByDigest

func (c *Client) FetchDataByDigest(ctx context.Context, name, digest string) (io.ReadCloser, error)

FetchDataByDigest returns a reader for a given digest.

func (*Client) FetchDataByIdentity

func (c *Client) FetchDataByIdentity(ctx context.Context, name, tag string) (io.ReadCloser, string, int64, error)

FetchDataByIdentity fetches an existing resource. Errors if there is no resource available. It's advised to call IsCached before fetching. Returns the digest of the resource alongside the data for further processing.

func (*Client) IsCached

func (c *Client) IsCached(ctx context.Context, name, tag string) (bool, error)

IsCached returns whether a certain tag with a given name exists in cache.

func (*Client) PushData

func (c *Client) PushData(ctx context.Context, data io.ReadCloser, mediaType, name, tag string) (string, int64, error)

PushData takes a blob of data and caches it using OCI as a background.

func (*Client) WithTransport

func (c *Client) WithTransport(ctx context.Context) Option

WithTransport sets up insecure TLS so the library is forced to use HTTPS.

type ClientOptsFunc

type ClientOptsFunc func(opts *Client)

ClientOptsFunc options are used to leave the cache backwards compatible. If the certificate isn't defined, we will use `WithInsecure`.

func WithCertificateSecret

func WithCertificateSecret(name string) ClientOptsFunc

WithCertificateSecret defines the name of the secret holding the certificates.

func WithClient

func WithClient(client client.Client) ClientOptsFunc

WithClient sets up certificates for the client.

func WithInsecureSkipVerify

func WithInsecureSkipVerify(value bool) ClientOptsFunc

WithInsecureSkipVerify sets up certificates for the client.

func WithNamespace

func WithNamespace(namespace string) ClientOptsFunc

WithNamespace sets up certificates for the client.

type Option

type Option func(o *options) error

Option is a functional option for Repository.

type Repository

type Repository struct {
	ociname.Repository
	// contains filtered or unexported fields
}

Repository is a wrapper around go-container registry's name.Repository. It provides a few convenience methods for interacting with OCI registries.

func NewRepository

func NewRepository(repositoryName string, opts ...Option) (*Repository, error)

NewRepository returns a new Repository. It points to the given remote repository. It accepts a list of options to configure the repository and the underlying remote client.

func (*Repository) FetchBlob

func (r *Repository) FetchBlob(digest string) (io.ReadCloser, error)

FetchBlob fetches a blob from the repository.

func (*Repository) FetchManifest

func (r *Repository) FetchManifest(reference string, filters []string) (*ocispec.Manifest, []byte, error)

FetchManifest fetches a manifest from the repository. It returns the manifest as an oci.Manifest struct and the raw manifest as a byte slice. The oci.Manifest struct can be used to retrieve the layers digests. Optionally, the manifest annotations can be verified against the given slice of strings keys.

func (*Repository) PushStreamBlob

func (r *Repository) PushStreamBlob(blob io.ReadCloser, mediaType string) (*ocispec.Descriptor, error)

PushStreamBlob pushes by streaming a blob to the repository. It accepts an io.ReadCloser interface. A media type can be specified to override the default media type. Default media type is "application/vnd.oci.image.layer.v1.tar+gzip".

func (*Repository) PushStreamingImage

func (r *Repository) PushStreamingImage(
	reference string,
	reader io.ReadCloser,
	mediaType string,
	annotations map[string]string,
) (*v1.Manifest, error)

PushStreamingImage pushes a reader to the repository as a streaming OCI image. It accepts a media type and a byte slice as the blob. Default media type is "application/vnd.oci.image.layer.v1.tar+gzip". Annotations can be passed to the image manifest.

type ResourceOptions

type ResourceOptions struct {
	ComponentVersion *v1alpha1.ComponentVersion
	Resource         v1alpha1.ResourceReference
	Owner            metav1.Object
	SnapshotName     string
}

ResourceOptions contains all parameters necessary to fetch / push resources.

type Verifier

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

Verifier is a wrapper around go-digest.Verifier.

func NewVerifier

func NewVerifier(d string) *Verifier

NewVerifier returns a new Verifier. It accepts a string, which is the digest of the blob to verify. The digest must be of the form <algorithm>:<hex>. The returned Verifier can be used to verify the blob.

func (*Verifier) Verify

func (v *Verifier) Verify(rd io.ReadCloser) (bool, error)

Verify verifies the blob. It accepts an io.Reader, which is the blob to verify. It returns a boolean, which is true if the blob is verified, and an error.

Jump to

Keyboard shortcuts

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