images

package
v0.61.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2025 License: Apache-2.0 Imports: 45 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.

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 added in v0.51.0

func OnlyHasImageLayers(manifest ocispec.Manifest) bool

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

func Ping added in v0.51.0

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 Pull

Pull pulls all images from the given config.

func Push

func Push(ctx context.Context, cfg PushConfig) error

Push pushes images to a registry.

func ShouldUsePlainHTTP added in v0.59.0

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 PullConfig

type PullConfig struct {
	OCIConcurrency        int
	DestinationDirectory  string
	ImageList             []transform.Image
	Arch                  string
	RegistryOverrides     map[string]string
	CacheDirectory        string
	PlainHTTP             bool
	InsecureSkipTLSVerify bool
	ResponseHeaderTimeout time.Duration
}

PullConfig is the configuration for pulling images.

type PushConfig

type PushConfig struct {
	OCIConcurrency        int
	SourceDirectory       string
	ImageList             []transform.Image
	RegistryInfo          state.RegistryInfo
	NoChecksum            bool
	Arch                  string
	Retries               int
	PlainHTTP             bool
	InsecureSkipTLSVerify bool
	Cluster               *cluster.Cluster
	ResponseHeaderTimeout time.Duration
}

PushConfig is the configuration for pushing images.

type Report added in v0.58.0

type Report func(bytesRead, totalBytes int64)

Report defines a function to log progress

func DefaultReport added in v0.58.0

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

DefaultReport returns a default report function

type TrackedTarget added in v0.58.0

type TrackedTarget struct {
	oras.Target
	*Tracker
}

TrackedTarget wraps an oras.Target to track progress

func NewTrackedTarget added in v0.58.0

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

NewTrackedTarget creates a new TrackedTarget

func (*TrackedTarget) Push added in v0.58.0

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 added in v0.58.0

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

Tracker reports progress against totalBytes as bytesRead gets updated

func (*Tracker) StartReporting added in v0.58.0

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

StartReporting starts the reporting goroutine

func (*Tracker) StopReporting added in v0.58.0

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