feat: extend autodiscover.ignore_paths to targeted -d commands#6466
Open
emanuelbesliu wants to merge 16 commits into
Open
feat: extend autodiscover.ignore_paths to targeted -d commands#6466emanuelbesliu wants to merge 16 commits into
emanuelbesliu wants to merge 16 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Extends autodiscover.ignore_paths behavior so targeted -d plan/apply commands are ignored when the target dir has no explicit project configuration, helping multi-instance Atlantis deployments avoid reacting to out-of-scope paths.
Changes:
- Added
ignore_pathsfiltering for targetedplan -dand other targeted commands when there is no explicit project config for the target dir. - Added unit tests covering global and repo-level
ignore_pathsbehavior and the “explicit project overrides ignore_paths” case. - Updated documentation to clarify that
ignore_pathsalso applies to targeted-dcommands when the path is not explicitly configured.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| server/events/project_command_builder.go | Applies ignore_paths filtering to targeted command builders (plan + non-plan targeted commands). |
| server/events/project_command_builder_test.go | Adds tests for targeted command behavior with global/repo-level ignore_paths and explicit-project override. |
| runatlantis.io/docs/server-side-repo-config.md | Documents that ignore_paths also affects targeted -d commands when no explicit project config exists. |
| runatlantis.io/docs/repo-level-atlantis-yaml.md | Expands ignore_paths docs to include targeted plan/apply -d semantics and multi-instance motivation. |
emanuelbesliu
added a commit
to emanuelbesliu/atlantis
that referenced
this pull request
May 12, 2026
…DiscoverModeEnabled Address Copilot review feedback on PR runatlantis#6466: - Extract duplicated ignore_paths logic into shouldIgnoreTargetedDir() - Gate the check behind autoDiscoverModeEnabled() for consistency - Add targeted apply -d assertions to repo-level config test Signed-off-by: emanuelbesliu <32497562+emanuelbesliu@users.noreply.github.com>
|
Hey, this would help me a ton to reduce unwanted noise in atlantis-related PRs. Any chance to merge this? |
Member
|
checking on this |
Author
|
Thank you everyone making this happen! |
chenrui333
pushed a commit
to emanuelbesliu/atlantis
that referenced
this pull request
Jun 26, 2026
…DiscoverModeEnabled Address Copilot review feedback on PR runatlantis#6466: - Extract duplicated ignore_paths logic into shouldIgnoreTargetedDir() - Gate the check behind autoDiscoverModeEnabled() for consistency - Add targeted apply -d assertions to repo-level config test Signed-off-by: emanuelbesliu <32497562+emanuelbesliu@users.noreply.github.com>
ddc7409 to
e467aee
Compare
Member
|
a bit late for me, I will continue checking tomorrow |
Previously, autodiscover.ignore_paths only filtered projects during auto-discovery (plan-all) and apply-all. Targeted commands like 'atlantis plan -d <path>' and 'atlantis apply -d <path>' bypassed this filtering entirely, causing issues in multi-instance setups where each Atlantis instance manages a different directory subtree. This change adds ignore_paths checking to buildProjectPlanCommand and buildProjectCommand (the targeted command handlers). When a user runs a targeted command against a path that matches ignore_paths and has no explicit project configuration in atlantis.yaml, the command is silently skipped (returns no projects). Paths with explicit project config are NOT affected — the ignore only applies to paths that would otherwise be auto-discovered. Fixes runatlantis#6460 Signed-off-by: emanuelbesliu <32497562+emanuelbesliu@users.noreply.github.com>
…DiscoverModeEnabled Address Copilot review feedback on PR runatlantis#6466: - Extract duplicated ignore_paths logic into shouldIgnoreTargetedDir() - Gate the check behind autoDiscoverModeEnabled() for consistency - Add targeted apply -d assertions to repo-level config test Signed-off-by: emanuelbesliu <32497562+emanuelbesliu@users.noreply.github.com>
- Skip ignore_paths check when -d uses glob patterns - Fix doc comment to reference repo config file generically - Add apply assertions to ExplicitProjectAllowed test Signed-off-by: emanuelbesliu <32497562+emanuelbesliu@users.noreply.github.com>
Update docs to reflect that ignore_paths filtering covers all targeted -d commands (plan, apply, import, state rm, etc.), not just plan/apply. Signed-off-by: emanuelbesliu <32497562+emanuelbesliu@users.noreply.github.com>
Signed-off-by: emanuelbesliu <32497562+emanuelbesliu@users.noreply.github.com>
Signed-off-by: Emanuel Besliu <32497562+emanuelbesliu@users.noreply.github.com>
Run the autodiscover.ignore_paths guard before restrict-file-list validation for targeted plan -d commands so ignored directories remain no-op even when they are not in the modified file list. Add regression coverage that verifies the ignored targeted dir returns no project contexts without calling the modified-file lookup. Assisted-by: OpenAI <noreply@openai.com> Signed-off-by: Rui Chen <rui@chenrui.dev>
Return a sentinel when targeted -d commands match autodiscover.ignore_paths so comment runners can distinguish ignored targets from ordinary zero-project results. Skip comments, combined status updates, and post-workflow hooks for ignored targeted plan/apply commands, and let API request parsing skip those targets instead of failing. Assisted-by: OpenAI <noreply@openai.com> Signed-off-by: Rui Chen <rui@chenrui.dev>
Set the plan status to failed when autoplan stops on a pre-workflow hook error now that pending status is no longer set before command construction. Assisted-by: OpenAI <noreply@openai.com> Signed-off-by: Rui Chen <rui@chenrui.dev>
Classify ignored targeted dirs before plan review dismissal and apply lock handling, and make all targeted command runners treat the sentinel as a true skipped command. Keep API command and hook lists aligned when ignored paths are dropped. Assisted-by: OpenAI <noreply@openai.com> Signed-off-by: Rui Chen <rui@chenrui.dev>
Classify ignored targeted dirs before comment pre-workflow hooks and before non-plan builders require an existing workspace. Preserve skipped API requests as no-ops when every requested path is ignored. Assisted-by: OpenAI <noreply@openai.com> Signed-off-by: Rui Chen <rui@chenrui.dev>
Classify ignored targeted directory commands before comment validations that can publish user, var-file, fork, or closed-PR errors. Assisted-by: OpenAI <noreply@openai.com> Signed-off-by: Rui Chen <rui@chenrui.dev>
Autoplan uses the plan command runner for execution, so pre-workflow hook skip checks must look up the registered plan runner instead of the synthetic autoplan command. Assisted-by: OpenAI <noreply@openai.com> Signed-off-by: Rui Chen <rui@chenrui.dev>
Avoid API PR lock cleanup for all-ignored requests, let pre-workflow hooks generate explicit config before the final ignored-target skip, and keep expected ignored-target sentinels out of builder error metrics. Assisted-by: OpenAI <noreply@openai.com> Signed-off-by: Rui Chen <rui@chenrui.dev>
Run normal command validations before pre-workflow hooks even for initially ignored targeted directories, while keeping ignored-target validation failures silent. Prefer generated local repo config for the post-hook ignored-target recheck so explicit projects added by hooks are honored. Assisted-by: OpenAI <noreply@openai.com> Signed-off-by: Rui Chen <rui@chenrui.dev>
43c4985 to
f61f28c
Compare
Use the local merged checkout config for targeted ignore checks when checkout-strategy=merge is enabled. If no merged checkout exists yet, fail open so commands can clone and evaluate the merged config instead of silently skipping from head-branch config. Assisted-by: OpenAI <noreply@openai.com> Signed-off-by: Rui Chen <rui@chenrui.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends
autodiscover.ignore_pathsto also filter targeted commands (atlantis plan -d <path>,atlantis apply -d <path>) when the path has no explicit project configuration.Fixes #6460
Problem
In multi-instance setups where each Atlantis instance manages a different directory subtree (e.g.,
environments/prod/vsenvironments/nonprod/),autodiscover.ignore_pathscorrectly prevents auto-discovery of projects in ignored paths. However, when a user runs a targeted command likeatlantis apply -d environments/prod/test, both instances would react because the targeted command path bypassedignore_pathsfiltering.Solution
Added
isAutoDiscoverPathIgnoredchecks inbuildProjectPlanCommandandbuildProjectCommand— the two functions that handle targeted-dcommands. The check:ignore_pathsand silently skips if matchedThis mirrors the existing semantics in
getMergedProjectCfgsandbuildAllProjectCommandsByPlan, whereignore_pathsonly filters auto-discovered (non-configured) paths.Why not in
buildProjectCommandCtx?The check is intentionally placed in the caller functions rather than the shared
buildProjectCommandCtxbecause the latter is also called frombuildAllProjectCommandsByPlanwhich has its own filtering logic that preserves explicitly-planned paths tracked inPullStatus. Putting the check there would break that behavior.Tests
TestDefaultProjectCommandBuilder_BuildTargetedCommand_IgnorePaths— global config ignore_paths blocks targeted plan/applyTestDefaultProjectCommandBuilder_BuildTargetedCommand_IgnorePathsRepoCfg— repo-level ignore_paths blocks targeted commandsTestDefaultProjectCommandBuilder_BuildTargetedCommand_IgnorePathsExplicitProjectAllowed— explicit project config overrides ignore_pathsDocs
Updated
repo-level-atlantis-yaml.mdandserver-side-repo-config.mdto document the broader scope ofignore_paths.