Skip to content

Commit

Permalink
Export configuration information in shell launched by Atmos
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuru committed Dec 8, 2024
1 parent 3f2f103 commit f874777
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/exec/shell_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,20 @@ func execTerraformShellCommand(
}
}()

// Set the Terraform environment variables to reference the var file
componentEnvList = append(componentEnvList, fmt.Sprintf("TF_CLI_ARGS_plan=-var-file=%s", varFile))
componentEnvList = append(componentEnvList, fmt.Sprintf("TF_CLI_ARGS_apply=-var-file=%s", varFile))
componentEnvList = append(componentEnvList, fmt.Sprintf("TF_CLI_ARGS_refresh=-var-file=%s", varFile))
componentEnvList = append(componentEnvList, fmt.Sprintf("TF_CLI_ARGS_import=-var-file=%s", varFile))
componentEnvList = append(componentEnvList, fmt.Sprintf("TF_CLI_ARGS_destroy=-var-file=%s", varFile))
componentEnvList = append(componentEnvList, fmt.Sprintf("TF_CLI_ARGS_console=-var-file=%s", varFile))

// Set environment variables to indicate the details of the Atmos shell configuration
componentEnvList = append(componentEnvList, fmt.Sprintf("ATMOS_STACK=%s", stack))
componentEnvList = append(componentEnvList, fmt.Sprintf("ATMOS_COMPONENT=%s", component))
componentEnvList = append(componentEnvList, fmt.Sprintf("ATMOS_SHELL_WORKING_DIR=%s", workingDir))
componentEnvList = append(componentEnvList, fmt.Sprintf("ATMOS_TERRAFORM_WORKSPACE=%s", workspaceName))

hasCustomShellPrompt := cliConfig.Components.Terraform.Shell.Prompt != ""
if hasCustomShellPrompt {
// Template for the custom shell prompt
Expand Down Expand Up @@ -255,6 +262,9 @@ func execTerraformShellCommand(

shellName := filepath.Base(shellCommand)

// This means you cannot have a custom shell prompt inside Geodesic (Geodesic requires "-l").
// Perhaps we should have special detection for Geodesic?
// We could test if env var GEODESIC_SHELL is set to "true" (or set at all).
if !hasCustomShellPrompt {
shellCommand = shellCommand + " -l"
}
Expand Down

0 comments on commit f874777

Please sign in to comment.