oci

package
v0.32.6 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package oci contains functions for interacting with artifacts stored in OCI registries.

Package oci contains functions for interacting with artifacts stored in OCI registries.

Package oci contains functions for interacting with artifacts stored in OCI registries.

Package oci contains functions for interacting with artifacts stored in OCI registries.

Package oci contains functions for interacting with artifacts stored in OCI registries.

Package oci contains functions for interacting with artifacts stored in OCI registries.

Package oci contains functions for interacting with artifacts stored in OCI registries.

Package oci contains functions for interacting with artifacts stored in OCI registries.

Index

Constants

View Source
const (
	// MultiOS is the OS used for multi-platform packages
	MultiOS = "multi"
)

Variables

This section is empty.

Functions

func Copy added in v0.32.5

func Copy(ctx context.Context, src *OrasRemote, dst *OrasRemote,
	include func(d ocispec.Descriptor) bool, concurrency int, progressBar helpers.ProgressWriter) (err error)

Copy copies an artifact from one OCI registry to another

func FetchJSONFile added in v0.29.0

func FetchJSONFile[T any](ctx context.Context, fetcher func(ctx context.Context, desc ocispec.Descriptor) (bytes []byte, err error), manifest *Manifest, path string) (result T, err error)

FetchJSONFile fetches the given JSON file from the remote repository.

func FetchUnmarshal added in v0.29.0

func FetchUnmarshal[T any](ctx context.Context, fetcher func(ctx context.Context, desc ocispec.Descriptor) (bytes []byte, err error), unmarshaler func(data []byte, v interface{}) error, descriptor ocispec.Descriptor) (result T, err error)

FetchUnmarshal fetches the given descriptor from the remote repository and unmarshals it.

func FetchYAMLFile added in v0.29.0

func FetchYAMLFile[T any](ctx context.Context, fetcher func(ctx context.Context, desc ocispec.Descriptor) (bytes []byte, err error), manifest *Manifest, path string) (result T, err error)

FetchYAMLFile fetches the given YAML file from the remote repository.

func IsEmptyDescriptor added in v0.29.0

func IsEmptyDescriptor(desc ocispec.Descriptor) bool

IsEmptyDescriptor returns true if the given descriptor is empty.

func PlatformForArch added in v0.32.2

func PlatformForArch(arch string) ocispec.Platform

PlatformForArch sets the target architecture for the remote

func RemoveDuplicateDescriptors added in v0.29.0

func RemoveDuplicateDescriptors(descriptors []ocispec.Descriptor) []ocispec.Descriptor

RemoveDuplicateDescriptors removes duplicate descriptors from the given list.

func SumDescsSize added in v0.32.5

func SumDescsSize(descs []ocispec.Descriptor) int64

SumDescsSize returns the size of all the descriptors added together

Types

type ConfigPartial

type ConfigPartial struct {
	Architecture string            `json:"architecture"`
	OCIVersion   string            `json:"ociVersion"`
	Annotations  map[string]string `json:"annotations,omitempty"`
}

ConfigPartial is a partial OCI config that is used to create the manifest config.

Unless specified, an empty manifest config will be used: `{}` which causes an error on Google Artifact Registry

to negate this, we create a simple manifest config with some build metadata

type Manifest added in v0.32.5

type Manifest struct {
	ocispec.Manifest
}

Manifest is a wrapper around the OCI manifest

func (*Manifest) Locate added in v0.32.5

func (m *Manifest) Locate(pathOrDigest string) ocispec.Descriptor

Locate returns the descriptor for the first layer with the given path or digest.

func (*Manifest) MarshalJSON added in v0.32.5

func (m *Manifest) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of the manifest.

type Modifier added in v0.32.0

type Modifier func(*OrasRemote)

Modifier is a function that modifies an OrasRemote

func WithInsecureSkipVerify added in v0.32.0

func WithInsecureSkipVerify(insecure bool) Modifier

WithInsecureSkipVerify sets the insecure TLS flag for the remote

func WithLogger added in v0.32.5

func WithLogger(logger *slog.Logger) Modifier

WithLogger sets the logger for the remote

func WithPlainHTTP added in v0.32.0

func WithPlainHTTP(plainHTTP bool) Modifier

WithPlainHTTP sets the plain HTTP flag for the remote

func WithUserAgent added in v0.32.5

func WithUserAgent(userAgent string) Modifier

WithUserAgent sets the user agent for the remote

type OrasRemote

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

OrasRemote is a wrapper around the Oras remote repository that includes a progress bar for interactive feedback.

func NewOrasRemote

func NewOrasRemote(url string, platform ocispec.Platform, mods ...Modifier) (*OrasRemote, error)

NewOrasRemote returns an oras remote repository client and context for the given url.

Registry auth is handled by the Docker CLI's credential store and checked before returning the client

func (*OrasRemote) ClearProgressWriter added in v0.32.5

func (o *OrasRemote) ClearProgressWriter()

ClearProgressWriter clears the progress writer for the remote

func (*OrasRemote) CopyToTarget added in v0.32.5

func (o *OrasRemote) CopyToTarget(ctx context.Context, layers []ocispec.Descriptor, target oras.Target, copyOpts oras.CopyOptions) error

CopyToTarget copies the given layers from the remote repository to the given target

func (*OrasRemote) CreateAndPushManifestConfig added in v0.32.5

func (o *OrasRemote) CreateAndPushManifestConfig(ctx context.Context, annotations map[string]string, configMediaType string) (*ocispec.Descriptor, error)

CreateAndPushManifestConfig pushes the manifest config with metadata to the remote repository.

func (*OrasRemote) FetchLayer

func (o *OrasRemote) FetchLayer(ctx context.Context, desc ocispec.Descriptor) (bytes []byte, err error)

FetchLayer fetches the layer with the given descriptor from the remote repository.

func (*OrasRemote) FetchManifest

func (o *OrasRemote) FetchManifest(ctx context.Context, desc ocispec.Descriptor) (manifest *Manifest, err error)

FetchManifest fetches the manifest with the given descriptor from the remote repository.

func (*OrasRemote) FetchRoot

func (o *OrasRemote) FetchRoot(ctx context.Context) (*Manifest, error)

FetchRoot fetches the root manifest from the remote repository.

func (*OrasRemote) FileDescriptorExists added in v0.29.0

func (o *OrasRemote) FileDescriptorExists(desc ocispec.Descriptor, destinationDir string) bool

FileDescriptorExists returns true if the given file exists in the given directory with the expected SHA.

func (*OrasRemote) GetDefaultCopyOpts added in v0.32.5

func (o *OrasRemote) GetDefaultCopyOpts() oras.CopyOptions

GetDefaultCopyOpts returns the default copy options

func (*OrasRemote) Log added in v0.32.5

func (o *OrasRemote) Log() *slog.Logger

Log gives you access to the OrasRemote logger

func (*OrasRemote) PackAndTagManifest added in v0.32.5

func (o *OrasRemote) PackAndTagManifest(ctx context.Context, src *file.Store, descs []ocispec.Descriptor,
	configDesc *ocispec.Descriptor, annotations map[string]string) (ocispec.Descriptor, error)

PackAndTagManifest generates an OCI Image Manifest based on the given parameters pushes that manifest to the remote repository and returns the manifest descriptor.

func (*OrasRemote) PullPath added in v0.32.5

func (o *OrasRemote) PullPath(ctx context.Context, destinationDir string, desc ocispec.Descriptor) error

PullPath pulls a layer from the remote repository and saves it to `destinationDir/annotationTitle`.

func (*OrasRemote) PullPaths added in v0.32.5

func (o *OrasRemote) PullPaths(ctx context.Context, destinationDir string, paths []string) ([]ocispec.Descriptor, error)

PullPaths pulls multiple files from the remote repository and saves them to `destinationDir`.

func (*OrasRemote) PushLayer added in v0.28.2

func (o *OrasRemote) PushLayer(ctx context.Context, b []byte, mediaType string) (*ocispec.Descriptor, error)

PushLayer pushes the given layer (bytes) to the remote repository.

func (*OrasRemote) Repo added in v0.29.0

func (o *OrasRemote) Repo() *remote.Repository

Repo gives you access to the underlying remote repository

func (*OrasRemote) ResolveRoot added in v0.29.0

func (o *OrasRemote) ResolveRoot(ctx context.Context) (ocispec.Descriptor, error)

ResolveRoot returns the root descriptor for the remote repository

func (*OrasRemote) SetProgressWriter added in v0.32.5

func (o *OrasRemote) SetProgressWriter(bar helpers.ProgressWriter)

SetProgressWriter sets the progress writer for the remote

func (*OrasRemote) UpdateIndex added in v0.32.0

func (o *OrasRemote) UpdateIndex(ctx context.Context, tag string, publishedDesc ocispec.Descriptor) error

UpdateIndex updates the index for the given package.

Jump to

Keyboard shortcuts

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