registry

package
v1.224.0 Latest Latest
Warning

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

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

Documentation

Overview

Package registry implements Terraform provider and module registry mirrors as adapters for the generic caching proxy (pkg/http/proxy). The provider mirror translates the Provider Network Mirror Protocol (what Terraform speaks to the proxy) into the upstream Provider Registry Protocol; the module mirror caches the module registry protocol and routes every module download — git:: sources included — back through the proxy, resolving the source with go-getter and caching it as a single servable tar artifact.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidModulePath = errors.New("invalid module mirror request path")

ErrInvalidModulePath indicates a module mirror request path that does not match the module registry protocol shape.

View Source
var ErrInvalidPlatform = errors.New("invalid provider platform")

ErrInvalidPlatform indicates a platform string that is not of the form os_arch.

View Source
var ErrInvalidProviderPath = errors.New("invalid provider mirror request path")

ErrInvalidProviderPath indicates a provider mirror request path that does not match the network-mirror protocol shape.

View Source
var ErrInvalidProviderSource = errors.New("invalid provider source address")

ErrInvalidProviderSource indicates a provider source address that is not of the form host/namespace/type.

View Source
var ErrModuleSourceFetch = errors.New("module source fetch failed")

ErrModuleSourceFetch indicates a module source could not be resolved and packed.

View Source
var ErrUpstreamStatus = errors.New("upstream registry returned non-success status")

ErrUpstreamStatus indicates a non-2xx response from an upstream registry call.

Functions

This section is empty.

Types

type ModuleMirror

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

ModuleMirror implements proxy.Mirror for the module registry protocol. It caches version listings and download resolutions, and routes every module download back through the proxy: the source is resolved with go-getter and cached as a single tar artifact, so git:: sources (the common case for the public registry and mono-repos) are cached just like HTTP archives.

func NewModuleMirror

func NewModuleMirror(resolver SourceResolver) *ModuleMirror

NewModuleMirror constructs a module mirror that resolves module sources via resolver.

func (*ModuleMirror) Handles

func (m *ModuleMirror) Handles(r *http.Request) bool

Handles reports whether the request is a module registry request.

func (*ModuleMirror) Route

func (m *ModuleMirror) Route(r *http.Request) (proxy.Route, error)

Route maps a module registry request to a Route.

type Platform

type Platform struct {
	OS   string
	Arch string
}

Platform is a Terraform provider target platform (operating system + CPU architecture), e.g. {OS: "linux", Arch: "amd64"}.

func HostPlatform

func HostPlatform() Platform

HostPlatform returns the platform Atmos is currently running on.

func ParsePlatform

func ParsePlatform(s string) (Platform, error)

ParsePlatform parses a Terraform os_arch platform token (e.g. "linux_amd64").

func (Platform) String

func (p Platform) String() string

String renders the platform as Terraform's canonical os_arch token.

type ProviderMirror

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

ProviderMirror implements proxy.Mirror for the Provider Network Mirror Protocol, translating it into the upstream Provider Registry Protocol.

func NewProviderMirror

func NewProviderMirror(client proxy.Doer) *ProviderMirror

NewProviderMirror constructs a provider mirror that uses client for upstream pre-flight calls (discovery, download resolution).

func (*ProviderMirror) DownloadInto

func (m *ProviderMirror) DownloadInto(ctx context.Context, store proxy.Store, ref ProviderRef, platform Platform) (proxy.Meta, bool, error)

DownloadInto resolves a provider version's download for a single platform and stores the zip in the canonical filesystem_mirror layout under the store root, verifying the registry-provided zh: hash. It returns the object metadata and whether the object was already cached (in which case nothing is downloaded).

Unlike the proxy's request-driven Route path, DownloadInto is callable directly so commands (e.g. `atmos terraform cache warm`) can eagerly hydrate the cache — including for platforms other than the host's — without running Terraform.

func (*ProviderMirror) Handles

func (m *ProviderMirror) Handles(r *http.Request) bool

Handles reports whether the request is a provider network-mirror request.

func (*ProviderMirror) Route

func (m *ProviderMirror) Route(r *http.Request) (proxy.Route, error)

Route maps a provider network-mirror request to a Route.

type ProviderRef

type ProviderRef struct {
	Host      string
	Namespace string
	Type      string
	Version   string
}

ProviderRef identifies a single provider version to mirror: a registry host, namespace, type, and exact version.

func ParseSource

func ParseSource(source, version string) (ProviderRef, error)

ParseSource builds a ProviderRef from a fully-qualified source address (host/namespace/type, as recorded in .terraform.lock.hcl) and an exact version.

func (ProviderRef) Source

func (r ProviderRef) Source() string

Source renders the host/namespace/type source address (without version).

type SourceResolver

type SourceResolver interface {
	Resolve(ctx context.Context, source, destDir string) error
}

SourceResolver resolves a go-getter source string (e.g. "git::https://github.com/org/repo.git?ref=v1") into destDir, populating it with the module's working tree. The production implementation wraps pkg/downloader's go-getter client (with its insteadOf/credential-broker plumbing); tests inject a fake so no network is touched.

Jump to

Keyboard shortcuts

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