close
Skip to content

fix: respect autodiscover.ignore_paths during apply-all#6397

Merged
chenrui333 merged 13 commits into
runatlantis:mainfrom
jholm117:refactor/parse-repo-cfg-helper
Apr 29, 2026
Merged

fix: respect autodiscover.ignore_paths during apply-all#6397
chenrui333 merged 13 commits into
runatlantis:mainfrom
jholm117:refactor/parse-repo-cfg-helper

Conversation

@jholm117
Copy link
Copy Markdown
Contributor

@jholm117 jholm117 commented Apr 16, 2026

Summary

Fixes apply-all handling for pending plan files in paths covered by autodiscover.ignore_paths.

When Atlantis discovers unapplied .tfplan files for a plain atlantis apply, it now filters ignored autodiscovery paths so stale or copied plan files under ignored directories are not applied. The filtering is limited to autodiscovery behavior and preserves real pending plans that Atlantis already recorded in pull status, including explicit atlantis plan -d <dir> runs under an ignored path.

Notes

  • Extracts shared repo config parsing into parseRepoCfg.
  • Preserves configured project directories while filtering autodiscovered ignored paths.
  • Matches named pending plans by workspace, project name, and repo-relative directory before preserving them.
  • References autodiscover.ignore_paths not respected during apply #6325.

jholm117 and others added 3 commits April 16, 2026 11:58
buildAllProjectCommandsByPlan() used PendingPlanFinder.Find() which only
filtered .terragrunt-cache/ directories. This meant atlantis apply (without
-p) would discover and attempt to apply .tfplan files in paths that should
be ignored per autodiscover.ignore_paths (e.g. .terraform/modules/).

Fix: after PendingPlanFinder.Find() returns, load the repo config and filter
plans through isAutoDiscoverPathIgnored() before building commands. This
mirrors the filtering already done in the plan path (getMergedProjectCfgs).

Also fix isAutoDiscoverPathIgnored() to fall through to repo-level config
when the global config has AutoDiscover set but no IgnorePaths. Previously,
the default global config (which always sets AutoDiscover with mode=auto)
would shadow repo-level ignore_paths from atlantis.yaml.

Fixes: runatlantis#6325

Signed-off-by: Jeff Holm <jholm117@gmail.com>
- Use IgnorePaths != nil instead of len() > 0 so an explicitly empty
  global ignore_paths can override repo-level config
- Skip explicitly configured project dirs when filtering apply plans,
  matching the plan-path behavior in getMergedProjectCfgs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Jeffrey Holm <jeff.holm@scale.com>
Both buildAllCommandsByCfg and buildAllProjectCommandsByPlan were
doing the same HasRepoCfg then ParseRepoCfg sequence. Extract it
into a single helper so the logic lives in one place.

Addresses review feedback on runatlantis#6332.
Copilot AI review requested due to automatic review settings April 16, 2026 16:10
@dosubot dosubot Bot added go Pull requests that update Go code refactoring Code refactoring that doesn't add additional functionality labels Apr 16, 2026

This comment was marked as resolved.

jamengual and others added 7 commits April 16, 2026 11:27
When global AutoDiscover is set with mode enabled but no IgnorePaths,
the guard change (from '!= nil' to '!= nil && IgnorePaths != nil')
causes fallthrough to the repo config's ignore_paths. This test
verifies that repo-level ignore_paths takes effect in this scenario.

Signed-off-by: Rui Chen <rui@chenrui.dev>
The plan path in getMergedProjectCfgs only applies ignore_paths when
autoDiscoverModeEnabled is true. Without the same gate on the apply
path, explicitly planned dirs matching ignore_paths would be silently
dropped during apply-all.

Signed-off-by: Rui Chen <rui@chenrui.dev>
@chenrui333 chenrui333 changed the title refactor: extract shared parseRepoCfg helper fix: apply ignoring autodiscover.ignore_paths; refactor parseRepoCfg Apr 29, 2026
@chenrui333 chenrui333 changed the title fix: apply ignoring autodiscover.ignore_paths; refactor parseRepoCfg fix: respect autodiscover.ignore_paths during apply-all Apr 29, 2026
@chenrui333 chenrui333 added bug Something isn't working and removed refactoring Code refactoring that doesn't add additional functionality labels Apr 29, 2026
PendingPlan doesn't track whether a plan was auto-discovered or
explicitly requested. If a user explicitly plans in an ignored path
and runs apply-all, the plan is filtered out. Workaround: use
'apply -d <dir>'.

Signed-off-by: Rui Chen <rui@chenrui.dev>
Signed-off-by: Rui Chen <rui@chenrui.dev>
Signed-off-by: Rui Chen <rui@chenrui.dev>
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Apr 29, 2026
@chenrui333 chenrui333 merged commit aeafd54 into runatlantis:main Apr 29, 2026
39 of 40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update Go code lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants