-
Notifications
You must be signed in to change notification settings - Fork 2
feat: support prefix for project root #104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThis pull request introduces a new Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (6)
🧰 Additional context used📓 Path-based instructions (1)**/*.tf⚙️ CodeRabbit configuration file
Files:
🧠 Learnings (12)📓 Common learnings📚 Learning: 2024-10-30T17:11:38.812ZApplied to files:
📚 Learning: 2024-10-30T17:04:09.798ZApplied to files:
📚 Learning: 2024-10-28T12:47:36.579ZApplied to files:
📚 Learning: 2024-10-29T00:06:05.693ZApplied to files:
📚 Learning: 2025-09-09T13:21:15.616ZApplied to files:
📚 Learning: 2024-10-23T18:20:57.022ZApplied to files:
📚 Learning: 2024-10-23T14:10:26.952ZApplied to files:
📚 Learning: 2024-10-30T17:01:23.897ZApplied to files:
📚 Learning: 2024-10-29T17:52:31.823ZApplied to files:
📚 Learning: 2025-05-12T15:44:10.001ZApplied to files:
📚 Learning: 2024-11-18T12:59:36.156ZApplied to files:
🔇 Additional comments (7)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
7ab5d97 to
794cd52
Compare
Gowiem
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confused and need some clarification. See question below.
| # Use specified project_root, if not: | ||
| # - If project_root_prefix is set, use project_root_prefix/module | ||
| # - Otherwise, use root_modules_path/module with "../" stripped | ||
| "project_root" = try( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm confused while reading this logic: Why is this necessary? if the only difference between using var.project_root_prefix and var.root_modules_path here is that we're replacing "../"... can we just pass var.project_root_prefix without the local directory paths? Does that not accomplish the same thing or am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And let me clarify the above:
Can we just pass var.root_modules_path WITHOUT the ../../ and pass it as terraform/root-modules?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we can't.
root_modules_path helps to discover sibling root modules and their stacks/*.yaml, while
project_root tells Spacelift where to find the Terraform code in the repo for each stack.
So from spacelift-automation/:
../../root-modules→ correctly findsnetwork/,tfstate-backend/, etc. for discovery- but Spacelift needs
terraform/root-modules/network(from repo root) to run the stack
project_root_prefix bridges this gap:
- module discovers stacks using ../../root-modules
- module sets each stack's project_root to terraform/root-modules/<module_name>
I think the root_modules_path name is a bit confusing here. I updated variables description to clarify the difference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @gberenice, alongside the upcoming major revision to fix stack naming that I'm asking to do as part of #101... I'm thinking that we introduce another variable here that provides what you're looking for and removes the usage of root module's path. If we do that as a breaking change, then we can keep this code cleaner while still providing the functionality that you need here.
What are your thoughts on that? Do you want to continue the conversation live?
what
project_root_prefixglobally when set, falling back to existing behavior otherwise.why
some-dir/root-modules) differs from theroot_modules_path, which uses relative paths.project_rootin each stack config, e.g.:references
Summary by CodeRabbit
Release Notes
New Features
project_root_prefixvariable to prepend a prefix to calculated project_root across all stacksDocumentation
project_root_prefixinput parameter with examples and precedence behavior✏️ Tip: You can customize this high-level summary in your review settings.