close
Skip to content

feat: allow autodiscover workspace override#6378

Open
kshcherban wants to merge 2 commits into
runatlantis:mainfrom
kshcherban:feat/allow-autodiscover-workspace-override
Open

feat: allow autodiscover workspace override#6378
kshcherban wants to merge 2 commits into
runatlantis:mainfrom
kshcherban:feat/allow-autodiscover-workspace-override

Conversation

@kshcherban
Copy link
Copy Markdown

what

  • Add optional workspace field to the autodiscover config (both repo-level atlantis.yaml and server-side repos.yaml)
  • When set, all autodiscovered projects use the configured workspace instead of detecting it from terraform { cloud { workspaces { name = "..." } } } blocks or falling back to "default"
  • Fix a pre-existing bug where repo-level ignore_paths in the autodiscover section was silently ignored — the default global config always set a non-nil AutoDiscover{Mode: "auto", IgnorePaths: nil}, which caused isAutoDiscoverPathIgnored to short-circuit on the global config's nil IgnorePaths and never reach the
    repo-level config

why

  • Users running separate Atlantis instances per workspace (e.g. one for qa, one for prod) on a shared repo need autodiscovery with both ignore_paths and a non-default workspace — these two features did not compose together
  • The only existing alternative was defining explicit projects with dir globs, but ignore_paths does not apply to explicitly configured projects, leaving no way to exclude directories
  • The ignore_paths bug meant that even the documented autodiscover.ignore_paths in atlantis.yaml had no effect unless the server-side config explicitly set ignore_paths — this fix changes the nil-check so that global IgnorePaths only takes precedence when explicitly configured (non-nil)

tests

  • Added unit tests for workspace field round-trip through raw.AutoDiscover.ToValid() and YAML unmarshalling (server/core/config/raw/autodiscover_test.go)
  • Added integration test "autodiscover workspace set in autodiscover config" in server/events/project_command_builder_test.go — verifies that workspace: qa + ignore_paths produces autodiscovered projects with workspace qa and excluded paths filtered out
  • All existing tests pass (go test ./server/core/config/... ./server/events/...)

references

Copilot AI review requested due to automatic review settings April 9, 2026 15:53
@dosubot dosubot Bot added feature New functionality/enhancement go Pull requests that update Go code labels Apr 9, 2026
@github-actions github-actions Bot added the docs Documentation label Apr 9, 2026
fixes runatlantis#6375

Signed-off-by: kshcherban <kostyantyn.shcherban@auto1.com>
Signed-off-by: kshcherban <kostyantyn.shcherban@auto1.com>
@kshcherban kshcherban force-pushed the feat/allow-autodiscover-workspace-override branch from e8bf5d6 to 049fb25 Compare April 9, 2026 15:54
@kshcherban kshcherban changed the title Feature: allow autodiscover workspace override feat: allow autodiscover workspace override Apr 9, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an optional workspace field to the autodiscover configuration (both repo-level atlantis.yaml and server-side repos.yaml) that allows users to specify a non-default Terraform workspace for all autodiscovered projects. This enables scenarios where separate Atlantis instances per workspace operate on a shared repository. The PR also fixes a pre-existing bug where repo-level ignore_paths in the autodiscover section was silently ignored.

Changes:

  • Added Workspace field to autodiscover config with precedence: global config > repo-level config
  • Fixed bug where repo-level ignore_paths was bypassed when global config's IgnorePaths was nil
  • Added comprehensive unit tests for workspace field and integration test demonstrating workspace + ignore_paths composition
  • Updated documentation for both server-side and repo-level configurations

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
server/events/project_command_builder.go Added workspace determination logic with proper precedence, fixed ignore_paths check to fall through to repo-level config
server/events/project_command_builder_test.go Added integration test verifying workspace and ignore_paths work together
server/core/config/valid/autodiscover.go Added Workspace field to the valid AutoDiscover struct
server/core/config/raw/autodiscover.go Added Workspace field with YAML unmarshalling and passed through in ToValid()
server/core/config/raw/autodiscover_test.go Added unit tests for Workspace field round-trip through YAML and ToValid()
runatlantis.io/docs/server-side-repo-config.md Added documentation for workspace field
runatlantis.io/docs/repo-level-atlantis-yaml.md Added documentation with examples showing workspace field

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation feature New functionality/enhancement go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ignore_path is not behaving correctly

2 participants