Documentation ¶
Overview ¶
Package oci provides tools for interacting with artifacts stored in OCI registries
Index ¶
- Constants
- func Copy(ctx context.Context, src *OrasRemote, dst *OrasRemote, ...) (err error)
- func FetchJSONFile[T any](ctx context.Context, ...) (result T, err error)
- func FetchUnmarshal[T any](ctx context.Context, ...) (result T, err error)
- func FetchYAMLFile[T any](ctx context.Context, ...) (result T, err error)
- func IsEmptyDescriptor(desc ocispec.Descriptor) bool
- func PlatformForArch(arch string) ocispec.Platform
- func RemoveDuplicateDescriptors(descriptors []ocispec.Descriptor) []ocispec.Descriptor
- func SumDescsSize(descs []ocispec.Descriptor) int64
- type ConfigPartial
- type Manifest
- type Modifier
- type OrasRemote
- func (o *OrasRemote) ClearProgressWriter()
- func (o *OrasRemote) CopyToTarget(ctx context.Context, layers []ocispec.Descriptor, target oras.Target, ...) error
- func (o *OrasRemote) CreateAndPushManifestConfig(ctx context.Context, annotations map[string]string, configMediaType string) (*ocispec.Descriptor, error)
- func (o *OrasRemote) FetchLayer(ctx context.Context, desc ocispec.Descriptor) (bytes []byte, err error)
- func (o *OrasRemote) FetchManifest(ctx context.Context, desc ocispec.Descriptor) (manifest *Manifest, err error)
- func (o *OrasRemote) FetchRoot(ctx context.Context) (*Manifest, error)
- func (o *OrasRemote) FileDescriptorExists(desc ocispec.Descriptor, destinationDir string) bool
- func (o *OrasRemote) GetDefaultCopyOpts() oras.CopyOptions
- func (o *OrasRemote) Log() *slog.Logger
- func (o *OrasRemote) PackAndTagManifest(ctx context.Context, src *file.Store, descs []ocispec.Descriptor, ...) (ocispec.Descriptor, error)
- func (o *OrasRemote) PullPath(ctx context.Context, destinationDir string, desc ocispec.Descriptor) error
- func (o *OrasRemote) PullPaths(ctx context.Context, destinationDir string, paths []string) ([]ocispec.Descriptor, error)
- func (o *OrasRemote) PushLayer(ctx context.Context, b []byte, mediaType string) (*ocispec.Descriptor, error)
- func (o *OrasRemote) Repo() *remote.Repository
- func (o *OrasRemote) ResolveRoot(ctx context.Context) (ocispec.Descriptor, error)
- func (o *OrasRemote) SetProgressWriter(bar helpers.ProgressWriter)
- func (o *OrasRemote) UpdateIndex(ctx context.Context, tag string, publishedDesc ocispec.Descriptor) error
Constants ¶
const (
// MultiOS is the OS used for multi-platform packages
MultiOS = "multi"
)
Variables ¶
This section is empty.
Functions ¶
func Copy ¶
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 ¶
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 ¶
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 ¶
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 ¶
func IsEmptyDescriptor(desc ocispec.Descriptor) bool
IsEmptyDescriptor returns true if the given descriptor is empty.
func PlatformForArch ¶
PlatformForArch sets the target architecture for the remote
func RemoveDuplicateDescriptors ¶
func RemoveDuplicateDescriptors(descriptors []ocispec.Descriptor) []ocispec.Descriptor
RemoveDuplicateDescriptors removes duplicate descriptors from the given list.
func SumDescsSize ¶
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 ¶
Manifest is a wrapper around the OCI manifest
func (*Manifest) Locate ¶
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 ¶
MarshalJSON returns the JSON encoding of the manifest.
type Modifier ¶
type Modifier func(*OrasRemote)
Modifier is a function that modifies an OrasRemote
func WithInsecureSkipVerify ¶
WithInsecureSkipVerify sets the insecure TLS flag for the remote
func WithLogger ¶
WithLogger sets the logger for the remote
func WithPlainHTTP ¶
WithPlainHTTP sets the plain HTTP flag for the remote
func WithUserAgent ¶
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 ¶
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 ¶
func (o *OrasRemote) ClearProgressWriter()
ClearProgressWriter clears the progress writer for the remote
func (*OrasRemote) CopyToTarget ¶
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 ¶
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 ¶
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 ¶
func (o *OrasRemote) GetDefaultCopyOpts() oras.CopyOptions
GetDefaultCopyOpts returns the default copy options
func (*OrasRemote) Log ¶
func (o *OrasRemote) Log() *slog.Logger
Log gives you access to the OrasRemote logger
func (*OrasRemote) PackAndTagManifest ¶
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 ¶
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 ¶
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 ¶
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 ¶
func (o *OrasRemote) Repo() *remote.Repository
Repo gives you access to the underlying remote repository
func (*OrasRemote) ResolveRoot ¶
func (o *OrasRemote) ResolveRoot(ctx context.Context) (ocispec.Descriptor, error)
ResolveRoot returns the root descriptor for the remote repository
func (*OrasRemote) SetProgressWriter ¶
func (o *OrasRemote) SetProgressWriter(bar helpers.ProgressWriter)
SetProgressWriter sets the progress writer for the remote
func (*OrasRemote) UpdateIndex ¶
func (o *OrasRemote) UpdateIndex(ctx context.Context, tag string, publishedDesc ocispec.Descriptor) error
UpdateIndex updates the index for the given package.