images

package
v0.68.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Overview

Package images provides functions for building and pushing images.

Package images provides functions for building and pushing images.

Package images provides functions for building and pushing images.

Package images provides functions for building and pushing images.

Index

Constants

View Source
const (
	//DockerMediaTypeManifest is the Legacy Docker manifest format, replaced by OCI manifest
	DockerMediaTypeManifest = "application/vnd.docker.distribution.manifest.v2+json"
	// DockerMediaTypeManifestList is the legacy Docker manifest list, replaced by OCI index
	DockerMediaTypeManifestList = "application/vnd.docker.distribution.manifest.list.v2+json"
)
View Source
const (
	DockerLayer             = "application/vnd.docker.image.rootfs.diff.tar.gzip"
	DockerUncompressedLayer = "application/vnd.docker.image.rootfs.diff.tar"
	DockerForeignLayer      = "application/vnd.docker.image.rootfs.foreign.diff.tar.gzip"
)

Legacy Docker image layers

Variables

This section is empty.

Functions

func NoopOpt

func NoopOpt(*crane.Options)

NoopOpt is a no-op option for crane.

func OnlyHasImageLayers

func OnlyHasImageLayers(manifest ocispec.Manifest) bool

OnlyHasImageLayers returns true when an OCI manifest only containers container image layers.

func Ping

func Ping(ctx context.Context, plainHTTP bool, registryURL string, client *auth.Client) (err error)

Ping verifies if a user can connect to a registry

func Push

func Push(ctx context.Context, imageList []transform.Image, sourceDirectory string, registryInfo state.RegistryInfo, cfg PushOptions) error

Push pushes images to a registry.

func ShouldUsePlainHTTP

func ShouldUsePlainHTTP(ctx context.Context, registryURL string, client *auth.Client) (bool, error)

ShouldUsePlainHTTP returns true if the registryURL is an http endpoint This is inspired by the Crane functionality to determine the schema to be used - https://github.com/google/go-containerregistry/blob/main/pkg/v1/remote/transport/ping.go Zarf relies heavily on this logic, as the internal registry communicates over HTTP, however we want Zarf to be flexible should the registry be over https in the future

func WithBasicAuth

func WithBasicAuth(username, password string) crane.Option

WithBasicAuth returns an option for crane that sets basic auth.

func WithGlobalInsecureFlag

func WithGlobalInsecureFlag() []crane.Option

WithGlobalInsecureFlag returns an option for crane that configures insecure based upon Zarf's global --insecure-skip-tls-verify (and --insecure) flags.

func WithPullAuth

func WithPullAuth(ri state.RegistryInfo) crane.Option

WithPullAuth returns an option for crane that sets pull auth from a given registry info.

func WithPushAuth

func WithPushAuth(ri state.RegistryInfo) crane.Option

WithPushAuth returns an option for crane that sets push auth from a given registry info.

Types

type ImageWithManifest added in v0.68.0

type ImageWithManifest struct {
	Image    transform.Image
	Manifest ocispec.Manifest
}

ImageWithManifest represents an image reference and its associated OCI manifest.

func Pull

func Pull(ctx context.Context, imageList []transform.Image, destinationDirectory string, opts PullOptions) ([]ImageWithManifest, error)

Pull pulls all images to the destination directory.

func Unpack added in v0.68.0

func Unpack(ctx context.Context, imageArchive v1alpha1.ImageArchive, destDir string, arch string) (_ []ImageWithManifest, err error)

Unpack extracts an image tar and loads it into an OCI layout directory. It returns a list of ImageWithManifest for all images in the tar.

type PullOptions

type PullOptions struct {
	OCIConcurrency        int
	Arch                  string
	RegistryOverrides     []RegistryOverride
	CacheDirectory        string
	PlainHTTP             bool
	InsecureSkipTLSVerify bool
	ResponseHeaderTimeout time.Duration
}

PullOptions is the configuration for pulling images.

type PushOptions

type PushOptions struct {
	OCIConcurrency        int
	NoChecksum            bool
	Arch                  string
	Retries               int
	PlainHTTP             bool
	InsecureSkipTLSVerify bool
	Cluster               *cluster.Cluster
	ResponseHeaderTimeout time.Duration
}

PushOptions is the configuration for pushing images.

type RegistryOverride

type RegistryOverride struct {
	// Source describes the source registry.
	// May be of the form:
	// - docker.io/library
	// - docker.io
	Source string
	// Override replaces the source registry as a string prefix.
	Override string
}

RegistryOverride describes an override for a specific registry.

type Report

type Report func(bytesRead, totalBytes int64)

Report defines a function to log progress

func DefaultReport

func DefaultReport(l *slog.Logger, msg string, imageName string) Report

DefaultReport returns a default report function

type TrackedTarget

type TrackedTarget struct {
	oras.Target
	*Tracker
}

TrackedTarget wraps an oras.Target to track progress

func NewTrackedTarget

func NewTrackedTarget(target oras.Target, totalBytes int64, reporter Report) *TrackedTarget

NewTrackedTarget creates a new TrackedTarget

func (*TrackedTarget) Push

func (tt *TrackedTarget) Push(ctx context.Context, desc ocispec.Descriptor, content io.Reader) error

Push wraps the target push method with an appropriate tracked reader.

type Tracker

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

Tracker reports progress against totalBytes as bytesRead gets updated

func (*Tracker) StartReporting

func (tt *Tracker) StartReporting(ctx context.Context)

StartReporting starts the reporting goroutine

func (*Tracker) StopReporting

func (tt *Tracker) StopReporting()

StopReporting stops the reporting goroutine

Jump to

Keyboard shortcuts

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