feat: extend autodiscover.ignore_paths to targeted -d commands#6466
Open
emanuelbesliu wants to merge 5 commits into
Open
feat: extend autodiscover.ignore_paths to targeted -d commands#6466emanuelbesliu wants to merge 5 commits into
emanuelbesliu wants to merge 5 commits into
Conversation
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>
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. |
…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>
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.