Documentation ¶
Overview ¶
Package oci contains functions for interacting with Zarf packages stored in OCI registries.
Package oci contains functions for interacting with Zarf packages stored in OCI registries.
Package oci contains functions for interacting with Zarf packages stored in OCI registries.
Package oci contains functions for interacting with Zarf packages stored in OCI registries.
Package oci contains functions for interacting with Zarf packages stored in OCI registries.
Package oci contains functions for interacting with Zarf packages stored in OCI registries.
Package oci contains functions for interacting with Zarf packages stored in OCI registries.
Package oci contains functions for interacting with Zarf packages stored in OCI registries.
Index ¶
- Constants
- Variables
- func CopyPackage(ctx context.Context, src *OrasRemote, dst *OrasRemote, ...) error
- func FetchJSONFile[T any](fetcher func(desc ocispec.Descriptor) (bytes []byte, err error), ...) (result T, err error)
- func FetchUnmarshal[T any](fetcher func(desc ocispec.Descriptor) (bytes []byte, err error), ...) (result T, err error)
- func FetchYAMLFile[T any](fetcher func(desc ocispec.Descriptor) (bytes []byte, err error), ...) (result T, err error)
- func GetInitPackageURL(version string) string
- func IsEmptyDescriptor(desc ocispec.Descriptor) bool
- func ReferenceFromMetadata(registryLocation string, metadata *types.ZarfMetadata, ...) (string, error)
- func RemoveDuplicateDescriptors(descriptors []ocispec.Descriptor) []ocispec.Descriptor
- func ValidateReference(url string) error
- type ConfigPartial
- type Modifier
- func WithArch(arch string) Modifier
- func WithContext(ctx context.Context) Modifier
- func WithCopyOpts(opts oras.CopyOptions) Modifier
- func WithInsecureSkipVerify(insecure bool) Modifier
- func WithPlainHTTP(plainHTTP bool) Modifier
- func WithSkeletonArch() Modifier
- func WithTargetPlatform(platform *ocispec.Platform) Modifier
- type OrasRemote
- func (o *OrasRemote) CopyWithProgress(layers []ocispec.Descriptor, store oras.Target, copyOpts oras.CopyOptions, ...) error
- func (o *OrasRemote) FetchImagesIndex() (index *ocispec.Index, err error)
- func (o *OrasRemote) FetchLayer(desc ocispec.Descriptor) (bytes []byte, err error)
- func (o *OrasRemote) FetchManifest(desc ocispec.Descriptor) (manifest *ZarfOCIManifest, err error)
- func (o *OrasRemote) FetchRoot() (*ZarfOCIManifest, error)
- func (o *OrasRemote) FetchZarfYAML() (pkg types.ZarfPackage, err error)
- func (o *OrasRemote) FileDescriptorExists(desc ocispec.Descriptor, destinationDir string) bool
- func (o *OrasRemote) LayersFromPaths(requestedPaths []string) (layers []ocispec.Descriptor, err error)
- func (o *OrasRemote) LayersFromRequestedComponents(requestedComponents []string) (layers []ocispec.Descriptor, err error)
- func (o *OrasRemote) PublishPackage(pkg *types.ZarfPackage, paths *layout.PackagePaths, concurrency int) error
- func (o *OrasRemote) PullLayer(desc ocispec.Descriptor, destinationDir string) error
- func (o *OrasRemote) PullPackage(destinationDir string, concurrency int, layersToPull ...ocispec.Descriptor) ([]ocispec.Descriptor, error)
- func (o *OrasRemote) PullPackageMetadata(destinationDir string) ([]ocispec.Descriptor, error)
- func (o *OrasRemote) PullPackagePaths(paths []string, destinationDir string) ([]ocispec.Descriptor, error)
- func (o *OrasRemote) PullPackageSBOM(destinationDir string) ([]ocispec.Descriptor, error)
- func (o *OrasRemote) PushLayer(b []byte, mediaType string) (ocispec.Descriptor, error)
- func (o *OrasRemote) Repo() *remote.Repository
- func (o *OrasRemote) ResolveRoot() (ocispec.Descriptor, error)
- func (o *OrasRemote) UpdateIndex(tag string, arch string, publishedDesc ocispec.Descriptor) error
- type ZarfOCIManifest
Constants ¶
const ( // ZarfLayerMediaTypeBlob is the media type for all Zarf layers due to the range of possible content ZarfLayerMediaTypeBlob = "application/vnd.zarf.layer.v1.blob" // ZarfConfigMediaType is the media type for the manifest config ZarfConfigMediaType = "application/vnd.zarf.config.v1+json" // SkeletonArch is the architecture used for skeleton packages SkeletonArch = "skeleton" // MultiOS is the OS used for multi-platform packages MultiOS = "multi" )
Variables ¶
var ( // ZarfPackageIndexPath is the path to the index.json file in the OCI package. ZarfPackageIndexPath = filepath.Join("images", "index.json") // ZarfPackageLayoutPath is the path to the oci-layout file in the OCI package. ZarfPackageLayoutPath = filepath.Join("images", "oci-layout") // ZarfPackageImagesBlobsDir is the path to the directory containing the image blobs in the OCI package. ZarfPackageImagesBlobsDir = filepath.Join("images", "blobs", "sha256") )
Functions ¶
func CopyPackage ¶ added in v0.29.0
func CopyPackage(ctx context.Context, src *OrasRemote, dst *OrasRemote, include func(d ocispec.Descriptor) bool, concurrency int) error
CopyPackage copies a package from one OCI registry to another
func FetchJSONFile ¶ added in v0.29.0
func FetchJSONFile[T any](fetcher func(desc ocispec.Descriptor) (bytes []byte, err error), manifest *ZarfOCIManifest, 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](fetcher func(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](fetcher func(desc ocispec.Descriptor) (bytes []byte, err error), manifest *ZarfOCIManifest, path string) (result T, err error)
FetchYAMLFile fetches the given YAML file from the remote repository.
func GetInitPackageURL ¶ added in v0.29.1
GetInitPackageURL returns the URL for the init package for the given version.
func IsEmptyDescriptor ¶ added in v0.29.0
func IsEmptyDescriptor(desc ocispec.Descriptor) bool
IsEmptyDescriptor returns true if the given descriptor is empty.
func ReferenceFromMetadata ¶
func ReferenceFromMetadata(registryLocation string, metadata *types.ZarfMetadata, build *types.ZarfBuildData) (string, error)
ReferenceFromMetadata returns a reference for the given metadata.
func RemoveDuplicateDescriptors ¶ added in v0.29.0
func RemoveDuplicateDescriptors(descriptors []ocispec.Descriptor) []ocispec.Descriptor
RemoveDuplicateDescriptors removes duplicate descriptors from the given list.
func ValidateReference ¶ added in v0.29.0
ValidateReference validates the given url is a valid OCI reference.
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
the contents of this file are not used by Zarf
type Modifier ¶ added in v0.32.0
type Modifier func(*OrasRemote)
Modifier is a function that modifies an OrasRemote
func WithContext ¶ added in v0.32.0
WithContext sets the context for the remote
func WithCopyOpts ¶ added in v0.32.0
func WithCopyOpts(opts oras.CopyOptions) Modifier
WithCopyOpts sets the copy options for the remote
func WithInsecureSkipVerify ¶ added in v0.32.0
WithInsecureSkipVerify sets the insecure TLS flag for the remote
func WithPlainHTTP ¶ added in v0.32.0
WithPlainHTTP sets the plain HTTP flag for the remote
func WithSkeletonArch ¶ added in v0.32.0
func WithSkeletonArch() Modifier
WithSkeletonArch sets the target architecture for the remote to skeleton
func WithTargetPlatform ¶ added in v0.32.0
WithTargetPlatform sets the target platform for the remote
type OrasRemote ¶
type OrasRemote struct { Transport *utils.Transport CopyOpts oras.CopyOptions // 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, 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) CopyWithProgress ¶ added in v0.29.0
func (o *OrasRemote) CopyWithProgress(layers []ocispec.Descriptor, store oras.Target, copyOpts oras.CopyOptions, destinationDir string) error
CopyWithProgress copies the given layers from the remote repository to the given store.
func (*OrasRemote) FetchImagesIndex ¶
func (o *OrasRemote) FetchImagesIndex() (index *ocispec.Index, err error)
FetchImagesIndex fetches the images/index.json file from the remote repository.
func (*OrasRemote) FetchLayer ¶
func (o *OrasRemote) FetchLayer(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(desc ocispec.Descriptor) (manifest *ZarfOCIManifest, err error)
FetchManifest fetches the manifest with the given descriptor from the remote repository.
func (*OrasRemote) FetchRoot ¶
func (o *OrasRemote) FetchRoot() (*ZarfOCIManifest, error)
FetchRoot fetches the root manifest from the remote repository.
func (*OrasRemote) FetchZarfYAML ¶
func (o *OrasRemote) FetchZarfYAML() (pkg types.ZarfPackage, err error)
FetchZarfYAML fetches the zarf.yaml file 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) LayersFromPaths ¶
func (o *OrasRemote) LayersFromPaths(requestedPaths []string) (layers []ocispec.Descriptor, err error)
LayersFromPaths returns the descriptors for the given paths from the root manifest.
func (*OrasRemote) LayersFromRequestedComponents ¶
func (o *OrasRemote) LayersFromRequestedComponents(requestedComponents []string) (layers []ocispec.Descriptor, err error)
LayersFromRequestedComponents returns the descriptors for the given components from the root manifest.
It also retrieves the descriptors for all image layers that are required by the components.
It also respects the `required` flag on components, and will retrieve all necessary layers for required components.
func (*OrasRemote) PublishPackage ¶
func (o *OrasRemote) PublishPackage(pkg *types.ZarfPackage, paths *layout.PackagePaths, concurrency int) error
PublishPackage publishes the package to the remote repository.
func (*OrasRemote) PullLayer ¶
func (o *OrasRemote) PullLayer(desc ocispec.Descriptor, destinationDir string) error
PullLayer pulls a layer from the remote repository and saves it to `destinationDir/annotationTitle`.
func (*OrasRemote) PullPackage ¶
func (o *OrasRemote) PullPackage(destinationDir string, concurrency int, layersToPull ...ocispec.Descriptor) ([]ocispec.Descriptor, error)
PullPackage pulls the package from the remote repository and saves it to the given path.
layersToPull is an optional parameter that allows the caller to specify which layers to pull.
The following layers will ALWAYS be pulled if they exist:
- zarf.yaml
- checksums.txt
- zarf.yaml.sig
func (*OrasRemote) PullPackageMetadata ¶
func (o *OrasRemote) PullPackageMetadata(destinationDir string) ([]ocispec.Descriptor, error)
PullPackageMetadata pulls the package metadata from the remote repository and saves it to `destinationDir`.
func (*OrasRemote) PullPackagePaths ¶ added in v0.29.0
func (o *OrasRemote) PullPackagePaths(paths []string, destinationDir string) ([]ocispec.Descriptor, error)
PullPackagePaths pulls multiple files from the remote repository and saves them to `destinationDir`.
func (*OrasRemote) PullPackageSBOM ¶ added in v0.30.0
func (o *OrasRemote) PullPackageSBOM(destinationDir string) ([]ocispec.Descriptor, error)
PullPackageSBOM pulls the package's sboms.tar from the remote repository and saves it to `destinationDir`.
func (*OrasRemote) PushLayer ¶ added in v0.28.2
func (o *OrasRemote) PushLayer(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() (ocispec.Descriptor, error)
ResolveRoot returns the root descriptor for the remote repository
func (*OrasRemote) UpdateIndex ¶ added in v0.32.0
func (o *OrasRemote) UpdateIndex(tag string, arch string, publishedDesc ocispec.Descriptor) error
UpdateIndex updates the index for the given package.
type ZarfOCIManifest ¶
ZarfOCIManifest is a wrapper around the OCI manifest
it includes the path to the index.json, oci-layout, and image blobs. as well as a few helper functions for locating layers and calculating the size of the layers.
func NewZarfOCIManifest ¶
func NewZarfOCIManifest(manifest *ocispec.Manifest) *ZarfOCIManifest
NewZarfOCIManifest returns a new ZarfOCIManifest.
func (*ZarfOCIManifest) Locate ¶
func (m *ZarfOCIManifest) Locate(pathOrDigest string) ocispec.Descriptor
Locate returns the descriptor for the first layer with the given path or digest.
func (*ZarfOCIManifest) MarshalJSON ¶ added in v0.30.0
func (m *ZarfOCIManifest) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of the manifest.
func (*ZarfOCIManifest) SumLayersSize ¶
func (m *ZarfOCIManifest) SumLayersSize() int64
SumLayersSize returns the sum of the size of all the layers in the manifest.