mirror

package
v1.16.1 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2025 License: MIT Imports: 51 Imported by: 0

Documentation

Overview

Package mirror implements the logic for the mirror commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clone

func Clone(ctx context.Context, opts CloneOptions) error

Clone will take a list of OCI references and scatter them according to the mapping spec.

func Copy

func Copy(ctx context.Context, c *Copier) error

Copy copies a source target to a destination target while handling cross-repo mounting. It uses the ExtendedCopyGraph function in oras to capture predecessor references.

func CopyFilterOnPlatform

func CopyFilterOnPlatform(ctx context.Context, c *Copier) ([]ocispec.Descriptor, error)

CopyFilterOnPlatform will copy from the root descriptor only the manifests that match the platforms defined.

func DescIsMirrorArtifact

func DescIsMirrorArtifact(ctx context.Context, desc ocispec.Descriptor, repo oras.GraphTarget) (bool, *ocispec.Index, error)

DescIsMirrorArtifact takes a descriptor and a graph target and returns whether the descriptor is a mirror artifact, the index, and/or an error.

func Deserialize

func Deserialize(ctx context.Context, opts DeserializeOptions) (ocispec.Descriptor, error)

Deserialize will extract the oci artifacts from a tar file (generated by ace-dt mirror serialize) to a destination target.

func Gather

func Gather(ctx context.Context, dataToolVersion string, opts GatherOptions) (ocispec.Descriptor, error)

Gather will take the references defined in a SourceFile and consolidate them to a destination target.

func ListArtifacts

func ListArtifacts(ctx context.Context, opts DiffOptions) ([][]string, error)

ListArtifacts handles the logic to list artifacts, expand artifacts, and filter artifacts in the mirror ls command.

func Scatter

func Scatter(ctx context.Context, opts ScatterOptions) error

Scatter will fetch the artifacts located in a target (generated by gather or deserialize) and distribute them according to the mapping spec.

func Serialize

func Serialize(ctx context.Context, destFile, checkpointFile, dataToolVersion string, opts SerializeOptions) error

Serialize takes the artifact created in a gather operation and serializes it to tar.

Types

type BlockBufOptions

type BlockBufOptions struct {
	Buffer        int
	BlockSize     int
	HighWaterMark int
}

BlockBufOptions define the requirements to serialize with blockbuf.

type ByteTracker

type ByteTracker struct {
	Total        int64
	Deduplicated int64
	// contains filtered or unexported fields
}

ByteTracker is an object for tracking digests seen, total bytes seen, and deduplication size.

func (*ByteTracker) AddDescriptor

func (bt *ByteTracker) AddDescriptor(desc ocispec.Descriptor)

AddDescriptor adds a digest to the tracker.

type CloneOptions

type CloneOptions struct {
	MappingSpec     string
	Selectors       []string
	ConcurrentHTTP  int
	Platforms       []string
	Log             *slog.Logger
	SourceFile      string
	RootUI          *ui.Task
	Targeter        reg.GraphTargeter
	Recursive       bool
	DryRun          bool
	ContinueOnError bool
}

CloneOptions define the options required to run a Clone operation.

type Copier

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

Copier represents a copy object for mirror operations.

func NewCopier

func NewCopier(ctx context.Context,
	log *slog.Logger,
	src content.ReadOnlyGraphStorage,
	dest content.Storage,
	root ocispec.Descriptor,
	referrers bool,
	platforms []*ocispec.Platform,
	opts oras.CopyGraphOptions) (*Copier, error)

NewCopier creates a new Copier.

type DeserializeOptions

type DeserializeOptions struct {
	DestStorage         content.Storage
	DestTargetReference registry.Reference
	SourceFile          string
	BufferSize          int
	DryRun              bool
	RootUI              *ui.Task
	Strict              bool
	Log                 *slog.Logger
}

DeserializeOptions specify the requirements to run the mirror deserialize command.

type DiffOptions

type DiffOptions struct {
	ExistingImages        []string
	RootArtifactReference string
	Targeter              reg.GraphTargeter
	Expanded              bool
}

DiffOptions represent the necessary options for the mirror ls command.

type GatherOptions

type GatherOptions struct {
	Platforms      []string
	ConcurrentHTTP int
	DestStorage    content.GraphStorage
	Log            *slog.Logger
	RootUI         *ui.Task
	SourceFile     string
	Dest           string
	Annotations    map[string]string
	IndexFallback  bool
	DestReference  registry.Reference
	Recursive      bool
	Targeter       reg.GraphTargeter
}

GatherOptions specify the requirements to run a mirror gather operation.

type ResumeFromLedger

type ResumeFromLedger struct {
	// Path is the path to the local file where the checkpoint ledger is stored
	Path string

	// Offset number of bytes to resume from.  We assume all blobs referenced before this number exist at the destination.
	Offset int64
}

ResumeFromLedger contains the data necessary to resume from a checkpoint.

type ScatterOptions

type ScatterOptions struct {
	SubsetFile      string
	Source          content.ReadOnlyGraphStorage
	SourceDesc      ocispec.Descriptor
	SourceReference registry.Reference
	MappingSpec     string
	Selectors       []string
	ConcurrentHTTP  int
	RootUI          *ui.Task
	DryRun          bool
	Recursive       bool
	Targeter        reg.GraphTargeter
}

ScatterOptions specify the requirements to run the mirror scatter command.

type SerializeOptions

type SerializeOptions struct {
	BufferOpts          BlockBufOptions
	ExistingCheckpoints []ResumeFromLedger
	ExistingImages      []string
	Recursive           bool
	RepoFunc            func(context.Context, string) (*remote.Repository, error)
	SourceStorage       content.ReadOnlyStorage
	SourceReference     string
	Compression         string
	SourceDesc          ocispec.Descriptor
	WithManifestJSON    bool
}

SerializeOptions define the requirements to run a serialize operation.

type Source

type Source struct {
	Name   string
	Labels map[string]string
}

Source represents a single source line in the `sources.list` file. It includes the source reference (name) and any user-defined labels.

func ProcessSourcesFile

func ProcessSourcesFile(ctx context.Context,
	sourceFile string,
	sels selectors.LabelSelectorSet,
	concurrency int,
) ([]Source, error)

ProcessSourcesFile processes the `sources.list` file and returns a slice of Source objects that include the source reference, remote repository, descriptor, and the user-defined labels. If selectors or platforms filters are passed, then the source list will be modified to only include entries that follow those filters.

type WorkTracker

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

WorkTracker is an object for tracking the number of blobs and bytes actually pushed.

func (*WorkTracker) Add

func (wt *WorkTracker) Add(desc ocispec.Descriptor)

Add adds the digest and blob to the work tracker count.

Directories

Path Synopsis
Package blockbuf implements a functionality similar to "mbuffer".
Package blockbuf implements a functionality similar to "mbuffer".
Package encoding implements the protocol used to serialize and deserialize data across the wire.
Package encoding implements the protocol used to serialize and deserialize data across the wire.
Package multiplex implements a multiplex and demultiplexer for streams of binary data
Package multiplex implements a multiplex and demultiplexer for streams of binary data
Package testing helps generate test data for use in testing telemetry
Package testing helps generate test data for use in testing telemetry

Jump to

Keyboard shortcuts

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