Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ad4c570
refactor(terraform): extract the component provider runtime
osterman Nov 8, 2026
a749378
fix(terraform): classify only the final init attempt and bound provid…
osterman Nov 8, 2026
451c724
fix(terraform): harden the component runtime pipeline
osterman Nov 8, 2026
23b92bb
fix(terraform): reconcile provider request metadata with execution info
osterman Nov 8, 2026
cc316f6
fix(terraform): drop the atmos.Component cache for a target after it …
osterman Nov 8, 2026
1b1d575
test(terraform): honor the fake subprocess exit code after writing ou…
osterman Nov 8, 2026
cdd533d
ci(docker): allow get.trivy.dev for the Trivy installer
osterman Nov 9, 2026
b09d8c0
fix(affected): honor --base and the error mode in GetAffectedComponents
osterman Nov 10, 2026
d9126f2
fix(terraform): clean the workspace file in the component's TF_DATA_DIR
osterman Nov 10, 2026
12ebad9
fix(terraform): keep sensitive root variables out of test varfiles
osterman Nov 10, 2026
17c557d
fix(terraform): pass the execution context through artifact generation
osterman Nov 10, 2026
87abded
docs(terraform): state that capture writers receive unmasked output
osterman Nov 10, 2026
b35c7d4
Merge remote-tracking branch 'origin/main' into refactor/terraform-pr…
osterman Nov 10, 2026
cd6442d
fix(terraform): invalidate caches for stack aliases
osterman Nov 11, 2026
d9eab53
Merge remote-tracking branch 'origin/main' into refactor/terraform-pr…
osterman Nov 12, 2026
12f9b3b
Merge commit '1805eb0ce735c567a365709634a0a86d42ecfb1a' into refactor…
osterman Nov 13, 2026
cba896a
fix(terraform): filter mixed-case plugin cache env on Windows
osterman Nov 13, 2026
48bbcfb
fix(lint): resolve golangci-lint findings in files changed by the pro…
osterman Nov 14, 2026
f03540c
fix(ci): filter golangci-lint with git on pull requests
osterman Nov 14, 2026
8c43f7d
revert(ci): move the golangci-lint filter change up the stack
osterman Nov 14, 2026
30feca8
fix(terraform): exclude declared-sensitive variables from batch varfiles
osterman Nov 15, 2026
efc8fb7
fix(terraform): reload the module after generation and redact secret …
osterman Nov 15, 2026
2f92485
Merge branch 'main' into refactor/terraform-provider-core
osterman Nov 16, 2026
c68a6ac
fix(terraform): reject computed test vars and encode secret env by de…
osterman Nov 16, 2026
a4bf27e
fix(terraform): escape nested secret strings before HCL environment t…
osterman Nov 16, 2026
a6af185
fix(terraform): encode secret env strings with HCL-only escapes
osterman Nov 16, 2026
97093c0
fix(terraform): keep numeric precision in collection secret env values
osterman Nov 16, 2026
a529951
fix(terraform): classify secret environment encoding failures
osterman Nov 17, 2026
f1754b6
Merge main into Terraform provider core and preserve metadata compone…
osterman Nov 17, 2026
5be4945
test(git): separate HTTP cooldown timing from publisher contention
osterman Nov 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/exec/atmos.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func executeTerraformUISelection(atmosConfig *schema.AtmosConfiguration, command
// Route it directly to ExecuteTerraformShell to avoid ExecuteTerraform passing
// it to the terraform executable.
if subcommand == "shell" {
return ExecuteTerraformShell(shellOptionsForUI(component, stack), atmosConfig)
return terraformExecutor.ExecuteTerraformShell(shellOptionsForUI(component, stack), atmosConfig)
}

configAndStacksInfo := schema.ConfigAndStacksInfo{}
Expand Down
5 changes: 3 additions & 2 deletions internal/exec/clean_adapter_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"path/filepath"

errUtils "github.com/cloudposse/atmos/errors"
terraformcomponent "github.com/cloudposse/atmos/pkg/component/terraform"
"github.com/cloudposse/atmos/pkg/perf"
"github.com/cloudposse/atmos/pkg/schema"
tfclean "github.com/cloudposse/atmos/pkg/terraform/clean"
Expand Down Expand Up @@ -85,8 +86,8 @@ func ConstructTerraformComponentVarfilePath(atmosConfig *schema.AtmosConfigurati
func ComputeTerraformSecretVarEnv(info *schema.ConfigAndStacksInfo) ([]string, error) {
defer perf.Track(nil, "exec.ComputeTerraformSecretVarEnv")()

computeTerraformSecretVarKeys(info)
return secretVarEnv(info)
terraformcomponent.ComputeTerraformSecretVarKeys(info)
return terraformcomponent.SecretVarEnv(info)
}

// ConstructTerraformComponentPlanfileNameForClean exports the planfile name constructor for clean.
Expand Down
4 changes: 2 additions & 2 deletions internal/exec/command_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func TestComponentAdmissionRunsBeforeAuthentication(t *testing.T) {
atmosConfig := setup(t)
calls := countAuth(t)
info := tc.info
_, err := setupTerraformAuth(&atmosConfig, &info)
_, err := terraformExecutor.SetupComponentAuthForCLI(&atmosConfig, &info)
require.ErrorIs(t, err, errUtils.ErrPolicyDenied)
require.Zero(t, *calls, "auth must not run for a denied command")
})
Expand All @@ -247,7 +247,7 @@ func TestComponentAdmissionRunsBeforeAuthentication(t *testing.T) {
atmosConfig := setup(t)
calls := countAuth(t)
info := newInfo("plan")
_, err := setupTerraformAuth(&atmosConfig, &info)
_, err := terraformExecutor.SetupComponentAuthForCLI(&atmosConfig, &info)
require.NoError(t, err)
require.Equal(t, 1, *calls)
})
Expand Down
9 changes: 5 additions & 4 deletions internal/exec/deferred_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/cloudposse/atmos/pkg/auth"
authdeferred "github.com/cloudposse/atmos/pkg/auth/deferred"
terraformcomponent "github.com/cloudposse/atmos/pkg/component/terraform"
cfg "github.com/cloudposse/atmos/pkg/config"
"github.com/cloudposse/atmos/pkg/deferred"
"github.com/cloudposse/atmos/pkg/schema"
Expand Down Expand Up @@ -46,21 +47,21 @@ func deferredTargetAuthAndCache(ac *schema.AtmosConfiguration, component, stack
}
cache := stackdeferred.CacheFor(ac, info)
if info.AuthDisabled {
manager := cache.LoadOrStore("auth.disabled", &authContextWrapper{stackInfo: info})
return manager.(*authContextWrapper), cache, nil
manager := cache.LoadOrStore("auth.disabled", &terraformcomponent.AuthContextWrapper{StackInfo: info})
return manager.(*terraformcomponent.AuthContextWrapper), cache, nil
}
manager, _ := info.AuthManager.(auth.AuthManager)
return manager, cache, nil
}

func inheritDeferredAuth(section map[string]any, parents []auth.AuthManager) map[string]any {
targetAuth, _ := section[cfg.AuthSectionName].(map[string]any)
if hasDefaultIdentity(targetAuth) || len(parents) == 0 || parents[0] == nil {
if terraformcomponent.HasDefaultIdentity(targetAuth) || len(parents) == 0 || parents[0] == nil {
return section
}
if parent := parents[0].GetStackInfo(); parent != nil {
parentAuth, _ := parent.ComponentSection[cfg.AuthSectionName].(map[string]any)
if hasDefaultIdentity(parentAuth) {
if terraformcomponent.HasDefaultIdentity(parentAuth) {
section = maps.Clone(section)
section[cfg.AuthSectionName] = parentAuth
}
Expand Down
7 changes: 4 additions & 3 deletions internal/exec/deferred_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/cloudposse/atmos/pkg/auth"
authdeferred "github.com/cloudposse/atmos/pkg/auth/deferred"
"github.com/cloudposse/atmos/pkg/auth/types"
terraformcomponent "github.com/cloudposse/atmos/pkg/component/terraform"
cfg "github.com/cloudposse/atmos/pkg/config"
"github.com/cloudposse/atmos/pkg/schema"
)
Expand Down Expand Up @@ -65,10 +66,10 @@ func TestDeferredTargetDoesNotReuseCallerAuthContext(t *testing.T) {
require.Same(t, prior, resolvedTargetAuthContext(ac, nil, prior, false), "eager execution retains its fallback")
authdeferred.ConfigureAuth(ac, "")
require.Nil(t, resolvedTargetAuthContext(ac, nil, prior, false))
manager := &authContextWrapper{stackInfo: &schema.ConfigAndStacksInfo{}}
manager := &terraformcomponent.AuthContextWrapper{StackInfo: &schema.ConfigAndStacksInfo{}}
require.Nil(t, resolvedTargetAuthContext(ac, manager, prior, false))
resolved := &schema.AuthContext{AWS: &schema.AWSAuthContext{Profile: "resolved-account"}}
manager.stackInfo.AuthContext = resolved
manager.StackInfo.AuthContext = resolved
require.Same(t, resolved, resolvedTargetAuthContext(ac, manager, prior, false))
require.Nil(t, resolvedTargetAuthContext(ac, manager, prior, true), "disabled auth must discard all Atmos contexts")
}
Expand Down Expand Up @@ -171,7 +172,7 @@ func TestDeferredStateCacheSkipsFailuresAndSeparatesIdentities(t *testing.T) {
ac, factory, path := setupDeferredCacheTarget(t)
factory.EXPECT().Create(ac, gomock.Any(), "dev").Return(nil, nil).Times(2)
load := func(profile string, skip bool) (any, error) {
var parent auth.AuthManager = &authContextWrapper{stackInfo: deferredCacheParent(profile)}
var parent auth.AuthManager = &terraformcomponent.AuthContextWrapper{StackInfo: deferredCacheParent(profile)}
return GetTerraformState(ac, "!terraform.state", "dev", "target", "id", skip, nil, parent)
}
_, err := load("first", false)
Expand Down
24 changes: 7 additions & 17 deletions internal/exec/deferred_contexts.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,21 @@ package exec
import (
"fmt"

"github.com/cloudposse/atmos/pkg/component"
"github.com/cloudposse/atmos/pkg/deferred"
m "github.com/cloudposse/atmos/pkg/merge"
"github.com/cloudposse/atmos/pkg/perf"
"github.com/cloudposse/atmos/pkg/schema"
)

// ComponentDeferredContexts holds the per-section *merge.DeferredMergeContext produced while
// merging a single component's configuration, keyed by section name (vars, settings, env, auth,
// providers, required_providers, hooks, test, generate — see the cfg.*SectionName constants used
// as keys). Each context tracks the deferred YAML functions (!template, !terraform.output,
// !labels, etc.) collected for that section during the raw structural merge; a later,
// per-invocation stage resolves them with a real YAMLFunctionProcessor and deep-merges the result
// against any concrete override at the same path.
type ComponentDeferredContexts map[string]*m.DeferredMergeContext
// ComponentDeferredContexts holds deferred sections for one component.
type ComponentDeferredContexts = component.ComponentDeferredContexts

// StackComponentDeferredContexts holds, for a single stack, every component's
// ComponentDeferredContexts keyed by [componentType][component] (e.g.
// ["terraform"]["vpc"]). It is the shape ProcessStackConfig produces per stack.
type StackComponentDeferredContexts map[string]map[string]ComponentDeferredContexts
// StackComponentDeferredContexts holds deferred sections by type and component.
type StackComponentDeferredContexts = component.StackComponentDeferredContexts

// AllStacksDeferredContexts holds every stack's deferred contexts keyed by
// [stack][componentType][component]. This is the shape threaded from
// ProcessYAMLConfigFiles through FindStacksMap to the per-invocation Stage 3
// resolver (see resolveDeferredYamlFunctions).
type AllStacksDeferredContexts map[string]StackComponentDeferredContexts
// AllStacksDeferredContexts holds deferred sections by stack.
type AllStacksDeferredContexts = component.AllStacksDeferredContexts

// cloneComponentSectionWithOverrides returns a fresh copy of raw (a component's complete merged
// section, straight from FindStacksMap) with overrides layered on top. Used by the terraform
Expand Down
40 changes: 2 additions & 38 deletions internal/exec/describe_affected.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/cloudposse/atmos/internal/tui/templates/term"
"github.com/cloudposse/atmos/pkg/auth"
"github.com/cloudposse/atmos/pkg/ci"
"github.com/cloudposse/atmos/pkg/component"
cfg "github.com/cloudposse/atmos/pkg/config"
flagsPkg "github.com/cloudposse/atmos/pkg/flags"
atmosgit "github.com/cloudposse/atmos/pkg/git"
Expand All @@ -38,44 +39,7 @@ var ErrRepoPathConflict = errors.New("if the '--repo-path' flag is specified, th

type DescribeAffectedExecCreator func(atmosConfig *schema.AtmosConfiguration) DescribeAffectedExec

type DescribeAffectedCmdArgs struct {
CLIConfig *schema.AtmosConfiguration
Base string // Unified base commit (ref or SHA). Takes precedence over Ref/SHA.
CloneTargetRef bool
Format string
IncludeDependents bool
IncludeSettings bool
IncludeSpaceliftAdminStacks bool
OutputFile string
GithubOutputFile string // Output file for $GITHUB_OUTPUT format (key=value).
Ref string
RepoPath string
SHA string
SSHKeyPath string
SSHKeyPassword string
Verbose bool
Upload bool
Stack string
Query string
ProcessTemplates bool
ProcessYamlFunctions bool
Skip []string
ExcludeLocked bool
Tags []string // Keep only components whose `metadata.tags` contain any of these (from --tags).
LabelsRaw string // Raw --labels value (comma-separated key=value pairs).
Labels map[string]string // Parsed --labels: keep only components whose `metadata.labels` contain all of these.
TagsEnvVar string // Environment variable that supplied Tags (for example ATMOS_TAGS); empty when Tags came from the command line or are unset.
LabelsEnvVar string // Environment variable that supplied Labels; empty when Labels came from the command line or are unset.
Flatten bool // Lift every dependent into the top-level list as `affected: dependent` (from --flatten); requires IncludeDependents.
FlattenEnvVar string // Environment variable that supplied Flatten; empty when it came from the command line or is unset.
AuthManager auth.AuthManager // Optional: Auth manager for credential management (from --identity flag).
AuthDisabled bool // True when --identity=false (or alias) explicitly disables authentication; routes stack resolution to ExecuteDescribeStacksWithAuthDisabled.
HeadSHAOverride string // PR head SHA from CI event payload, used for upload correlation with Atmos Pro.
CIEventType string // CI event type (e.g., "pull_request", "push") for upload validation.
TargetBranch string // PR target branch (e.g., "main") used to auto-fetch when refs are missing locally.
ErrorMode string // How to handle recoverable errors: "strict" (default), "warn", or "silent".
Cmd *cobra.Command // The invoking Cobra command, used to derive Flags for the exec-metadata sync capture (proexec.FlagsFromCommand).
}
type DescribeAffectedCmdArgs component.DescribeAffectedCmdArgs

//go:generate go run go.uber.org/mock/mockgen@v0.6.0 -source=$GOFILE -destination=mock_$GOFILE -package=$GOPACKAGE
type DescribeAffectedExec interface {
Expand Down
111 changes: 111 additions & 0 deletions internal/exec/describe_affected_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import (
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/transport/ssh"

errUtils "github.com/cloudposse/atmos/errors"
"github.com/cloudposse/atmos/pkg/auth"
"github.com/cloudposse/atmos/pkg/ci"
g "github.com/cloudposse/atmos/pkg/git"
log "github.com/cloudposse/atmos/pkg/logger"
"github.com/cloudposse/atmos/pkg/perf"
Expand Down Expand Up @@ -437,3 +439,112 @@ func ExecuteDescribeAffectedWithTargetRepoPathWithOptions(

return affected, localRepoHead, remoteRepoHead, localRepoInfo.RepoUrl, nil
}

// GetAffectedComponents retrieves the list of affected components based on the
// provided arguments, dispatching to the right git-target resolution mode
// (repo path / clone-and-diff / local ref checkout). Exported so other
// affected-target dispatchers (e.g. `atmos terraform lint --affected`) reuse
// this switch instead of re-declaring it against the same three
// ExecuteDescribeAffectedWith* functions. The args.ErrorMode field selects how recoverable
// discovery errors are handled; an empty or "strict" mode keeps the historical fail-fast behavior.
func GetAffectedComponents(args *DescribeAffectedCmdArgs) ([]schema.Affected, error) {
defer perf.Track(nil, "exec.GetAffectedComponents")()

if args == nil {
return nil, errUtils.ErrNilParam
}
errOptions, collector := ErrorOptionsFromMode(args.ErrorMode)
defer PrintErrorModeSummary(args.ErrorMode, collector)
return GetAffectedComponentsWithOptions(args, errOptions)
}

// GetAffectedComponentsWithOptions is GetAffectedComponents plus opt-in graceful degradation
// for recoverable per-value YAML function errors (see DescribeStacksErrorOptions), dispatching
// to the *WithOptions variant of whichever git-target resolution mode applies.
//
//nolint:gocritic // Preserve the existing value-based options API shared by describe entry points.
func GetAffectedComponentsWithOptions(args *DescribeAffectedCmdArgs, errOptions DescribeStacksErrorOptions) ([]schema.Affected, error) {
defer perf.Track(nil, "exec.GetAffectedComponentsWithOptions")()

if args == nil {
return nil, errUtils.ErrNilParam
}
return dispatchAffectedComponentsWithOptions(args, errOptions)
}

// dispatchAffectedComponentsWithOptions is GetAffectedComponentsWithOptions's git-target
// dispatch switch, split out so the exported entry point stays a short nil-check + delegate.
//
//nolint:gocritic // Forward the value-based options consistently with the describe entry points below.
func dispatchAffectedComponentsWithOptions(args *DescribeAffectedCmdArgs, errOptions DescribeStacksErrorOptions) ([]schema.Affected, error) {
ref, sha := affectedComparisonRevision(args)
switch {
case args.RepoPath != "":
affectedList, _, _, _, err := ExecuteDescribeAffectedWithTargetRepoPathWithOptions(
args.CLIConfig,
args.RepoPath,
args.IncludeSpaceliftAdminStacks,
args.IncludeSettings,
args.Stack,
args.ProcessTemplates,
args.ProcessYamlFunctions,
args.Skip,
args.affectedFilter(),
args.AuthManager,
args.AuthDisabled,
errOptions,
)
return affectedList, err
case args.CloneTargetRef:
affectedList, _, _, _, err := ExecuteDescribeAffectedWithTargetRefCloneWithOptions(
args.CLIConfig,
ref,
sha,
args.SSHKeyPath,
args.SSHKeyPassword,
args.IncludeSpaceliftAdminStacks,
args.IncludeSettings,
args.Stack,
args.ProcessTemplates,
args.ProcessYamlFunctions,
args.Skip,
args.affectedFilter(),
args.AuthManager,
args.AuthDisabled,
errOptions,
)
return affectedList, err
default:
affectedList, _, _, _, err := ExecuteDescribeAffectedWithTargetRefCheckoutWithOptions(
args.CLIConfig,
ref,
sha,
args.TargetBranch,
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
args.IncludeSpaceliftAdminStacks,
args.IncludeSettings,
args.Stack,
args.ProcessTemplates,
args.ProcessYamlFunctions,
args.Skip,
args.affectedFilter(),
args.AuthManager,
args.AuthDisabled,
errOptions,
)
return affectedList, err
}
}

// affectedComparisonRevision returns the Ref and SHA to compare against. A non-empty Base
// takes precedence over both, matching the --base flag: a commit SHA selects that commit
// (keeping Ref as the clone target), and anything else selects that ref.
func affectedComparisonRevision(args *DescribeAffectedCmdArgs) (string, string) {
switch {
case args.Base == "":
return args.Ref, args.SHA
case ci.IsCommitSHA(args.Base):
return args.Ref, args.Base
default:
return args.Base, ""
}
}
21 changes: 2 additions & 19 deletions internal/exec/describe_component.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
errUtils "github.com/cloudposse/atmos/errors"
tuiTerm "github.com/cloudposse/atmos/internal/tui/templates/term"
"github.com/cloudposse/atmos/pkg/auth"
"github.com/cloudposse/atmos/pkg/component"
"github.com/cloudposse/atmos/pkg/component/typedetect"
cfg "github.com/cloudposse/atmos/pkg/config"
"github.com/cloudposse/atmos/pkg/data"
Expand Down Expand Up @@ -293,25 +294,7 @@ type DescribeComponentResult struct {
}

// ExecuteDescribeComponentParams contains parameters for ExecuteDescribeComponent.
type ExecuteDescribeComponentParams struct {
// ResolveSecrets retrieves actual secrets for internal value-producing callers.
// The default preserves credential-free, masked inspection.
ResolveSecrets bool
AtmosConfig *schema.AtmosConfiguration // Optional: Use provided config instead of initializing new one.
Component string
Stack string
ComponentType string // Optional: if set, only try this component type.
ProcessTemplates bool
ProcessYamlFunctions bool
UseMocks bool
Skip []string
AuthManager auth.AuthManager
AuthDisabled bool
ErrorOptions DescribeStacksErrorOptions
// CommandPath names the CLI command that needs the component, such as
// ["secret", "shell"], for component admission. Empty means `describe component`.
CommandPath []string
}
type ExecuteDescribeComponentParams = component.ExecuteDescribeComponentParams

// ExecuteDescribeComponent describes component config.
func ExecuteDescribeComponent(params *ExecuteDescribeComponentParams) (map[string]any, error) {
Expand Down
4 changes: 2 additions & 2 deletions internal/exec/describe_component_auth_override_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func TestResolveAuthManagerForNestedComponent(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
resolvedAuthMgr, err := resolveAuthManagerForNestedComponent(
resolvedAuthMgr, err := terraformExecutor.ResolveAuthManagerForNestedComponent(
&atmosConfig,
tt.component,
"test",
Expand Down Expand Up @@ -252,7 +252,7 @@ func TestAuthOverrideErrorHandling(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := resolveAuthManagerForNestedComponent(
_, err := terraformExecutor.ResolveAuthManagerForNestedComponent(
&atmosConfig,
tt.component,
tt.stack,
Expand Down
Loading
Loading