rc

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: 11 Imported by: 0

Documentation

Overview

Package rc renders Atmos's `components.terraform.rc` section into Terraform's native CLI configuration (HCL) and exposes it to the terraform/tofu subprocess via TF_CLI_CONFIG_FILE. The section is a near-opaque passthrough: keys map directly to Terraform CLI-config directives (provider_installation, host, credentials, plugin_cache_dir, ...), so new directives need no Atmos schema change. Both terraform and tofu honor TF_CLI_CONFIG_FILE and the same grammar, so no binary-specific branching is required.

Index

Constants

View Source
const (
	// EnvKeyTFCLIConfigFile is the Terraform CLI config env var (also honored by OpenTofu).
	EnvKeyTFCLIConfigFile = "TF_CLI_CONFIG_FILE"
	// EnvKeyTofuCLIConfigFile is the OpenTofu CLI config env var (takes precedence in tofu).
	EnvKeyTofuCLIConfigFile = "TOFU_CLI_CONFIG_FILE"
	// EnvKeyLegacyTerraformConfig is Terraform's deprecated CLI config env var, still honored.
	EnvKeyLegacyTerraformConfig = "TERRAFORM_CONFIG"
)

CLI config environment variables.

Terraform reads TF_CLI_CONFIG_FILE (and the legacy TERRAFORM_CONFIG). OpenTofu reads TOFU_CLI_CONFIG_FILE first, then falls back to TF_CLI_CONFIG_FILE. Atmos sets BOTH primary vars to the generated file so the config is honored regardless of which binary (terraform or tofu) runs, and treats any of them being set by the user as a signal to defer.

Variables

This section is empty.

Functions

func Generate

func Generate(rcMap map[string]any, atmosConfig *schema.AtmosConfiguration, info *schema.ConfigAndStacksInfo) (env []string, closer func() error, err error)

Generate renders the given CLI-config map to a temporary file and returns the TF_CLI_CONFIG_FILE env entry plus a removal closer. It is the lower-level seam the registry cache also drives (it contributes network_mirror/host directives into rcMap). User precedence is honored exactly as in Setup.

func Render

func Render(rc map[string]any) ([]byte, error)

Render converts the opaque Terraform CLI-config map (the `rc` section minus `enabled`) into Terraform's native CLI configuration (HCL) bytes.

The CLI-config grammar is a small, fixed set of constructs that a generic map-walker renders incorrectly, so this is a targeted renderer:

  • provider_installation → one block with repeated, ORDER-PRESERVING method sub-blocks (network_mirror, direct, filesystem_mirror).
  • host / credentials / credentials_helper → labeled blocks keyed by the map key.
  • scalars and lists at the top level → top-level attributes (plugin_cache_dir, disable_checkpoint, and any future scalar directive).
  • any other map → a best-effort unlabeled block (forward-compatible passthrough).

func Setup

func Setup(atmosConfig *schema.AtmosConfiguration, info *schema.ConfigAndStacksInfo) (env []string, closer func() error, err error)

Setup renders `components.terraform.rc` to a temporary Terraform CLI config file and returns the environment variable that points Terraform at it, plus a closer that removes the file.

It returns an empty env and a no-op closer when RC management is disabled, or when the user already controls TF_CLI_CONFIG_FILE (via OS env, the atmos.yaml `env:` section, or the component `env:` section) — Atmos defers to the user, mirroring how TF_PLUGIN_CACHE_DIR is handled.

The closer must be invoked after the entire terraform pipeline (init, workspace, plan/apply) completes so the file survives every subprocess.

Types

This section is empty.

Jump to

Keyboard shortcuts

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