providercache

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package providercache provides initialization of the Terragrunt provider caching server for caching OpenTofu providers.

Index

Constants

View Source
const (

	// The status returned when making a request to the caching provider.
	// It is needed to prevent further loading of providers by terraform, and at the same time make sure that the request was processed successfully.
	CacheProviderHTTPStatusCode = http.StatusLocked

	// Authentication type on the Terragrunt Provider Cache server.
	APIKeyAuth = "x-api-key"
)

Variables

This section is empty.

Functions

func ResolveModulesURL added in v1.0.0

func ResolveModulesURL(registryName, modulesV1 string) string

ResolveModulesURL resolves the modules.v1 URL from registry discovery. If the URL is already absolute (contains "://"), it is returned as-is. Otherwise, it is treated as a relative path and combined with the registry name.

Types

type ProviderCache

type ProviderCache struct {
	*cache.Server
	// contains filtered or unexported fields
}

func InitServer

func InitServer(l log.Logger, pcOpts *pcoptions.ProviderCacheOptions, rootWorkingDir string) (*ProviderCache, error)

InitServer creates and initializes a new ProviderCache with the given logger and options. This is a convenience function that combines NewProviderCache() and Init().

func NewProviderCache added in v1.0.0

func NewProviderCache() *ProviderCache

NewProviderCache creates a new ProviderCache with sensible defaults. Use builder methods like WithFS() to customize the configuration.

func (*ProviderCache) FS added in v1.0.0

func (pc *ProviderCache) FS() vfs.FS

FS returns the configured filesystem.

func (*ProviderCache) Init added in v1.0.0

func (pc *ProviderCache) Init(l log.Logger, pcOpts *pcoptions.ProviderCacheOptions, rootWorkingDir string) error

Init initializes the ProviderCache with the given logger and options. Call this after configuring the ProviderCache with builder methods.

func (*ProviderCache) TerraformCommandHook

func (pc *ProviderCache) TerraformCommandHook(
	ctx context.Context,
	l log.Logger,
	tfOpts *tf.TFOptions,
	args clihelper.Args,
) (*util.CmdOutput, error)

TerraformCommandHook warms up the providers cache, creates `.terraform.lock.hcl` and runs the `tofu/terraform init` command with using this cache. Used as a hook function that is called after running the target tofu/terraform command. For example, if the target command is `tofu plan`, it will be intercepted before it is run in the `/shell` package, then control will be passed to this function to init the working directory using cached providers.

func (*ProviderCache) WithFS added in v1.0.0

func (pc *ProviderCache) WithFS(fs vfs.FS) *ProviderCache

WithFS sets the filesystem for file operations and returns the ProviderCache for method chaining. If not called, defaults to the real OS filesystem.

Directories

Path Synopsis
Package options groups provider-cache-specific configuration that is resolved at startup and shared with the ProviderCache server and hook functions.
Package options groups provider-cache-specific configuration that is resolved at startup and shared with the ProviderCache server and hook functions.

Jump to

Keyboard shortcuts

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