oci

package
v0.82.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Package oci provides a way to interact with Datadog Packages OCIs.

Index

Constants

View Source
const (
	// RegistryAuthDefault is the default registry authentication method. Under the hood, it uses the Docker configuration.
	RegistryAuthDefault string = "docker"
	// RegistryAuthGCR is the Google Container Registry authentication method.
	RegistryAuthGCR string = "gcr"
	// RegistryAuthPassword is the password registry authentication method.
	RegistryAuthPassword string = "password"
)
View Source
const (
	// AnnotationPackage is the annotiation used to identify the package name.
	AnnotationPackage = "com.datadoghq.package.name"
	// AnnotationVersion is the annotiation used to identify the package version.
	AnnotationVersion = "com.datadoghq.package.version"
	// AnnotationSize is the annotiation used to identify the package size.
	AnnotationSize = "com.datadoghq.package.size"

	// VariantFIPS is the value used in oci.Platform.Variant to mark a FIPS-compliant
	// build. The OCI spec defines variant for CPU variants; Datadog overloads it as a
	// build flavor to distinguish sibling manifests for the same os/arch within a single
	// OCI index.
	VariantFIPS = "fips"

	// DatadogPackageLayerMediaType is the media type for the main Datadog Package layer.
	DatadogPackageLayerMediaType types.MediaType = "application/vnd.datadog.package.layer.v1.tar+zstd"
	// DatadogPackageConfigLayerMediaType is the media type for the optional Datadog Package config layer.
	DatadogPackageConfigLayerMediaType types.MediaType = "application/vnd.datadog.package.config.layer.v1.tar+zstd"
	// DatadogPackageInstallerLayerMediaType is the media type for the optional Datadog Package installer layer.
	DatadogPackageInstallerLayerMediaType types.MediaType = "application/vnd.datadog.package.installer.layer.v1"
	// DatadogPackageExtensionLayerMediaType is the media type for the optional Datadog Package extension layer.
	DatadogPackageExtensionLayerMediaType types.MediaType = "application/vnd.datadog.package.extension.layer.v1.tar+zstd"
)

Variables

View Source
var ErrNoLayerMatchesAnnotations = errors.New("no layer matches the requested annotations")

ErrNoLayerMatchesAnnotations is the error returned when no layer matches the requested annotations.

Functions

func PackageURL

func PackageURL(env *env.Env, pkg string, version string) string

PackageURL returns the package URL for the given site, package and version. Both base and FIPS flavors live under the same URL — flavor selection happens at download time via Platform.Variant in downloadIndex.

Types

type DownloadedPackage

type DownloadedPackage struct {
	Image   oci.Image
	Name    string
	Version string
	Size    uint64
}

DownloadedPackage is the downloaded package.

func (*DownloadedPackage) ExtractLayers

func (d *DownloadedPackage) ExtractLayers(ctx context.Context, mediaType types.MediaType, dir string, annotationFilters ...LayerAnnotation) (err error)

ExtractLayers extracts the layers of the downloaded package with the given media type to the given directory.

func (*DownloadedPackage) WriteOCILayout

func (d *DownloadedPackage) WriteOCILayout(ctx context.Context, dir string) (err error)

WriteOCILayout writes the image as an OCI layout to the given directory.

type Downloader

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

Downloader is the Downloader used by the installer to download packages.

func NewDownloader

func NewDownloader(env *env.Env, client *http.Client) *Downloader

NewDownloader returns a new Downloader.

func (*Downloader) Download

func (d *Downloader) Download(ctx context.Context, packageURL string) (_ *DownloadedPackage, err error)

Download downloads the Datadog Package referenced in the given Package struct.

func (*Downloader) WithRegistryOverride added in v0.78.0

func (d *Downloader) WithRegistryOverride(url, auth, username, password string) *Downloader

WithRegistryOverride returns a new Downloader with the given registry overrides applied. The returned Downloader shares the same HTTP client as the original. Image-scoped override maps (from DD_INSTALLER_REGISTRY_URL_<IMAGE> env vars) are preserved and take precedence over the per-extension override, matching the existing priority order.

type LayerAnnotation added in v0.77.0

type LayerAnnotation struct {
	Key   string
	Value string
}

LayerAnnotation is the annotation used to identify the layer.

type RegistryError

type RegistryError struct {
	Registry string // the registry URL / reference that was attempted
	Err      error  // the underlying error returned by that registry
}

RegistryError annotates an error returned while talking to a specific OCI registry. When Downloader.Download has to try multiple registries, each per-registry failure is wrapped in a RegistryError so callers can iterate them (see RegistryErrors) and present each attempt to the user with its registry context — similar to how os.LinkError carries the path alongside the underlying error.

Registry is the ref returned by getRefAndKeychain, which guarantees no embedded userinfo (formatImageRef strips it). Callers do not need to re-redact before logging or exporting Registry.

func RegistryErrors

func RegistryErrors(err error) []*RegistryError

RegistryErrors walks err and returns all *RegistryError values found in its chain, across multierr branches. Useful for presenting per-registry failure summaries when a multi-registry download fails. Returns an empty slice if there are no RegistryError values.

func (*RegistryError) Error

func (e *RegistryError) Error() string

Error implements the error interface.

func (*RegistryError) Unwrap

func (e *RegistryError) Unwrap() error

Unwrap lets errors.Is / errors.As reach the underlying error (e.g. a go-containerregistry *transport.Error, a *net.DNSError, etc.).

Jump to

Keyboard shortcuts

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