terragruntexec

package
v1.235.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 15 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package terragruntexec runs a Terragrunt unit through a pinned `terragrunt` executable.

Executable mode is the migration path next to native adaptation. Atmos still owns which units run, their order, authentication, the toolchain, the environment, and the UI. This package only translates one Atmos terraform invocation into one `terragrunt run` command for one unit, and never schedules anything: `--all` is expanded by Atmos into one command per unit.

Index

Constants

View Source
const (
	// Engine is the engine name executable-mode units are listed with.
	Engine = "terragrunt"
	// Binary is the tool name pinned in `dependencies.tools` or `.tool-versions`.
	Binary = "terragrunt"
	// MinimumVersion is the oldest Terragrunt with the `run` command and `--working-dir` this mode uses.
	MinimumVersion = "1.0.0"
)

Variables

This section is empty.

Functions

func CheckCommand

func CheckCommand(info *schema.ConfigAndStacksInfo, command string) error

CheckCommand rejects an Atmos terraform subcommand that has no Terragrunt equivalent for a unit.

func CheckSupported

func CheckSupported(info *schema.ConfigAndStacksInfo) error

CheckSupported rejects invocations that executable mode cannot honor, before anything runs.

func CheckVersion

func CheckVersion(ctx context.Context, host Host, binary string, env []string) error

CheckVersion verifies that the executable exists and is not older than MinimumVersion.

func Owns

func Owns(info *schema.ConfigAndStacksInfo) bool

Owns reports whether the component runs through the terragrunt executable. The discovery engine recorded in the component settings decides, so one project section always runs in one mode.

func Run

func Run(ctx context.Context, host Host, request *Request) error

Run checks the executable and runs the unit's command. A dry run skips the version probe, so it works without the executable installed and has no side effects.

func UnitDirectory

func UnitDirectory(root, unit string) (directory, config string)

UnitDirectory returns the directory that holds the unit file and the `--config` value needed when the file is not named terragrunt.hcl.

Types

type Command

type Command struct {
	Binary     string
	Args       []string
	Env        []string
	WorkingDir string
	DryRun     bool
}

Command is one terragrunt invocation.

func BuildCommand

func BuildCommand(request *Request) *Command

BuildCommand translates one Atmos invocation into a `terragrunt run` command. Provider options become flags of `run`, which is where Terragrunt defines them; a sensitive option travels through the environment so it never appears in an argument list. Engine arguments follow `--` untouched.

type Host

type Host interface {
	// Version runs `<binary> --version` and returns its output.
	Version(ctx context.Context, binary string, env []string) (string, error)
	// Execute runs the command to completion.
	Execute(ctx context.Context, command *Command) error
}

Host supplies what the executable needs from Atmos. Production code runs commands through the Atmos shell layer, which streams output through the UI, masks secrets, forwards interrupts, and returns the process exit code; tests inject a fake.

type Request

type Request struct {
	Component, Stack string
	// Binary is the resolved terragrunt executable and Engine the resolved OpenTofu or Terraform one.
	Binary, Engine string
	// Unit is the project-relative path of the unit file; Root is the project directory.
	Unit, Root  string
	SubCommand  string
	SubCommand2 string
	// Arguments are the engine arguments passed after `--` on the Atmos command line.
	Arguments []string
	// Options are the provider options the user set; only explicit ones are present.
	Options map[string]schema.ComponentProviderOption
	// Features are the `features` of the provider configuration. Options of the command line and the
	// environment replace them per name.
	Features    map[string]any
	Environment []string
	DryRun      bool
	SkipInit    bool
}

Request describes one unit invocation.

Jump to

Keyboard shortcuts

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