mirror

package
v1.222.0 Latest Latest
Warning

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

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

Documentation

Overview

Package mirror implements eager, multi-platform pre-seeding of the Terraform registry cache. It is the eager counterpart to the lazy proxy in pkg/terraform/cache: where the proxy populates the cache on demand for the host platform during a normal `init`, the mirror uses `terraform/tofu providers mirror` to pre-fetch a component's required providers for every configured platform into the same canonical filesystem_mirror layout. The shared directory then serves three ways: lazily (proxy), eagerly (mirror), and offline (filesystem_mirror) — the foundation for air-gapped reproducible builds.

Mirroring providers has no inter-component dependencies, so multi-component runs (--all/--components/--query) iterate the selected components in no particular order, unlike the dependency-ordered plan/apply scheduler.

Package mirror's TUI renders a package-manager-style progress view for provider mirroring (spinner + per-provider×platform checkmark lines), matching the look of `atmos vendor pull` (internal/exec/vendor_model.go). Progress is driven by parsing the `terraform/tofu providers mirror` output stream so each provider/platform that finishes downloading scrolls past as its own line.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolvePlatforms

func ResolvePlatforms(flag, configured []string) []string

ResolvePlatforms applies the platform precedence: the CLI flag wins, then the configured components.terraform.platforms, then the current host platform (<os>_<arch>).

func Run

func Run(opts Options) error

Run resolves the target platforms and cache root, then mirrors the selected components' required providers into <root>/providers for every platform by driving `terraform/tofu providers mirror` through the standard Atmos execution pipeline.

Types

type CacheStats

type CacheStats struct {
	Objects        int    `json:"objects" yaml:"objects"`
	Providers      int    `json:"providers" yaml:"providers"`
	Modules        int    `json:"modules" yaml:"modules"`
	TotalSizeBytes int64  `json:"total_size_bytes" yaml:"total_size_bytes"`
	TotalSize      string `json:"total_size" yaml:"total_size"`
}

CacheStats is the on-disk cache summary included in the result.

type Options

type Options struct {
	// Component is the single Atmos component to mirror. Empty when a multi-component
	// selector (All/Components/Query) or a bare stack is used.
	Component string
	// Stack is the Atmos stack. Required for a single component; an optional scope for
	// the multi-component selectors.
	Stack string
	// PlatformsFlag is the optional CLI override for target platforms. When empty,
	// the configured platforms (else the host platform) are used.
	PlatformsFlag []string
	// All mirrors every component in every stack (or in Stack, when set).
	All bool
	// Components filters the mirror to specific components.
	Components []string
	// Query filters the mirror with a YQ expression.
	Query string
	// Format selects the output: "" (human) streams the mirror progress and prints a
	// summary; "json"/"yaml" suppress the progress and emit a structured result.
	Format string
}

Options configures a mirror run. Targeting mirrors the multi-component flags of `atmos terraform plan`: a single component, --all, --components, or --query, with an optional --stack scope.

type Result

type Result struct {
	Components []Target   `json:"components" yaml:"components"`
	Platforms  []string   `json:"platforms" yaml:"platforms"`
	Cache      CacheStats `json:"cache" yaml:"cache"`
}

Result is the structured outcome of a mirror run, for --format json|yaml.

type Target

type Target struct {
	Component string `json:"component" yaml:"component"`
	Stack     string `json:"stack" yaml:"stack"`
}

Target identifies a mirrored component/stack in the result.

Jump to

Keyboard shortcuts

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