Documentation
¶
Overview ¶
Package shell provides functions to run shell commands and Terraform commands.
Index ¶
- Constants
- func ExplainError(err error) string
- func GitLastReleaseTag(ctx context.Context, l log.Logger, env map[string]string, workingDir string, ...) (string, error)
- func GitRepoTags(ctx context.Context, l log.Logger, env map[string]string, workingDir string, ...) ([]string, error)
- func GitTopLevelDir(ctx context.Context, l log.Logger, env map[string]string, path string) (string, error)
- func LastReleaseTag(tags []string) string
- func PromptUserForInput(ctx context.Context, l log.Logger, prompt string, nonInteractive bool, ...) (string, error)
- func PromptUserForYesNo(ctx context.Context, l log.Logger, prompt string, nonInteractive bool, ...) (bool, error)
- func RunCommand(ctx context.Context, l log.Logger, runOpts *ShellOptions, command string, ...) error
- func RunCommandWithOutput(ctx context.Context, l log.Logger, runOpts *ShellOptions, workingDir string, ...) (*util.CmdOutput, error)
- type ShellOptions
Constants ¶
const SignalForwardingDelay = time.Second * 15
SignalForwardingDelay is the time to wait before forwarding the signal to the subcommand.
The signal can be sent to the main process (only `terragrunt`) as well as the process group (`terragrunt` and `terraform`), for example: kill -INT <pid> # sends SIGINT only to the main process kill -INT -<pid> # sends SIGINT to the process group Since we cannot know how the signal is sent, we should give `tofu`/`terraform` time to gracefully exit if it receives the signal directly from the shell, to avoid sending the second interrupt signal to `tofu`/`terraform`.
Variables ¶
This section is empty.
Functions ¶
func ExplainError ¶
ExplainError will try to explain the error to the user, if we know how to do so.
func GitLastReleaseTag ¶
func GitLastReleaseTag(ctx context.Context, l log.Logger, env map[string]string, workingDir string, gitRepo *url.URL) (string, error)
GitLastReleaseTag fetches git repository last release tag.
func GitRepoTags ¶
func GitRepoTags(ctx context.Context, l log.Logger, env map[string]string, workingDir string, gitRepo *url.URL) ([]string, error)
GitRepoTags fetches git repository tags from passed url.
func GitTopLevelDir ¶
func GitTopLevelDir(ctx context.Context, l log.Logger, env map[string]string, path string) (string, error)
GitTopLevelDir fetches git repository path from passed directory.
func LastReleaseTag ¶
LastReleaseTag returns last release tag from passed tags slice.
func PromptUserForInput ¶
func PromptUserForInput(ctx context.Context, l log.Logger, prompt string, nonInteractive bool, errWriter io.Writer) (string, error)
PromptUserForInput prompts the user for text in the CLI. Returns the text entered by the user.
func PromptUserForYesNo ¶
func PromptUserForYesNo(ctx context.Context, l log.Logger, prompt string, nonInteractive bool, errWriter io.Writer) (bool, error)
PromptUserForYesNo prompts the user for a yes/no response and return true if they entered yes.
func RunCommand ¶
func RunCommand(ctx context.Context, l log.Logger, runOpts *ShellOptions, command string, args ...string) error
RunCommand runs the given shell command.
func RunCommandWithOutput ¶
func RunCommandWithOutput( ctx context.Context, l log.Logger, runOpts *ShellOptions, workingDir string, suppressStdout bool, needsPTY bool, command string, args ...string, ) (*util.CmdOutput, error)
RunCommandWithOutput runs the specified shell command with the specified arguments.
Connect the command's stdin, stdout, and stderr to the currently running app. The command can be executed in a custom working directory by using the parameter `workingDir`. Terragrunt working directory will be assumed if empty string.
Types ¶
type ShellOptions ¶ added in v1.0.0
type ShellOptions struct {
Writers writer.Writers
EngineOptions *engine.EngineOptions
EngineConfig *engine.EngineConfig
Telemetry *telemetry.Options
Env map[string]string
RootWorkingDir string
WorkingDir string
TFPath string
Experiments experiment.Experiments
Headless bool
ForwardTFStdout bool
}
ShellOptions contains the configuration needed to run shell commands.
func (*ShellOptions) NoEngine ¶ added in v1.0.0
func (o *ShellOptions) NoEngine() bool
NoEngine returns true if the user explicitly disabled the engine via --no-engine. Returns false when EngineOptions is nil (default: don't disable), letting the other guards (EngineConfig != nil, experiment enabled) decide whether to run.