Skip to content

Conversation

@Jgeissler14
Copy link
Contributor

@Jgeissler14 Jgeissler14 commented Sep 2, 2025

what

This change will allow a user to assign a workerpool to a stack by either workerpool name or id, mutually exclusive. The name can be passed as a var and then compared to the data block pulling all private workers to match name=name, and grab the id for reference later in the codebase.

All tf tests passed

why

It can be confusing to read when only looking at ids to know which it is referencing. This should help prevent these problems in the future.

references

Summary by CodeRabbit

  • New Features

    • Added support to select Spacelift worker pools by name in addition to ID.
    • Automatically resolves worker pool assignment per stack using explicit ID/name first, then global ID/name, falling back to none if unavailable.
  • Enhancements

    • Improved reliability by mapping worker pool names to IDs to streamline configuration across stacks.
  • Documentation

    • Updated variable descriptions to clarify that worker_pool_id and worker_pool_name are mutually exclusive.
    • Noted that self-hosted instances require specifying either worker_pool_id or worker_pool_name.

@Jgeissler14 Jgeissler14 requested a review from a team as a code owner September 2, 2025 20:13
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 2, 2025

Walkthrough

Adds a Spacelift worker pools data source in data.tf. Introduces a new input variable worker_pool_name in variables.tf and clarifies mutual exclusivity with worker_pool_id; both default to null. In main.tf, creates a worker_pool_name_to_id map and a resolved_worker_pool_ids local that prioritizes per-stack worker_pool_id, then per-stack worker_pool_name, then global worker_pool_id, then global worker_pool_name. Updates spacelift_stack.default to use resolved_worker_pool_ids for worker_pool_id. Existing data sources and schema validation remain unchanged.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Small file set with cohesive changes
  • New resolution logic with clear precedence chain
  • Minor risk around name->ID mapping and null handling
  • Limited heterogeneity; mostly Terraform locals and variable additions

Possibly related PRs

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/workerpool-by-name

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (3)
data.tf (1)

4-6: Data source added — consider scope and intent

Looks good. If the PR intent is “private workers only,” ensure downstream mapping filters to private pools; otherwise this will include public/default pools as well.

Would you like me to add a small filter in the mapping (see main.tf comment) once we confirm the provider attribute that denotes “private”?

variables.tf (2)

353-357: Good clarification on mutual exclusivity

Docs look clear. Enforcement currently lives only in prose; see suggested check blocks in main.tf to hard-enforce this at plan time.

I can open a follow-up PR adding those checks if you’d like.


359-366: New variable reads well

Definition and defaults are appropriate. Pair with the plan-time checks in main.tf for a complete UX.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f757d8f and c8ac601.

📒 Files selected for processing (3)
  • data.tf (1 hunks)
  • main.tf (3 hunks)
  • variables.tf (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.tf

⚙️ CodeRabbit configuration file

**/*.tf: You're a Terraform expert who has thoroughly studied all the documentation from Hashicorp https://developer.hashicorp.com/terraform/docs and OpenTofu https://opentofu.org/docs/.
You have a strong grasp of Terraform syntax and prioritize providing accurate and insightful code suggestions.
As a fan of the Cloud Posse / SweetOps ecosystem, you incorporate many of their best practices https://docs.cloudposse.com/best-practices/terraform/ while balancing them with general Terraform guidelines.

Files:

  • data.tf
  • main.tf
  • variables.tf
🧠 Learnings (3)
📓 Common learnings
Learnt from: gberenice
PR: masterpointio/terraform-spacelift-automation#3
File: modules/spacelift-automation/variables.tf:235-242
Timestamp: 2024-10-29T17:54:26.382Z
Learning: In `modules/spacelift-automation/variables.tf`, the `worker_pool_id` variable does not follow the UUID format.
Learnt from: Gowiem
PR: masterpointio/terraform-spacelift-automation#3
File: variables.tf:245-251
Timestamp: 2024-10-30T17:05:18.442Z
Learning: When users are expected to know certain requirements, such as `worker_pool_id` being required for self-hosted Spacelift instances, avoid adding additional variables solely for validation purposes.
📚 Learning: 2024-10-29T17:54:26.382Z
Learnt from: gberenice
PR: masterpointio/terraform-spacelift-automation#3
File: modules/spacelift-automation/variables.tf:235-242
Timestamp: 2024-10-29T17:54:26.382Z
Learning: In `modules/spacelift-automation/variables.tf`, the `worker_pool_id` variable does not follow the UUID format.

Applied to files:

  • main.tf
  • variables.tf
📚 Learning: 2024-10-30T17:05:18.442Z
Learnt from: Gowiem
PR: masterpointio/terraform-spacelift-automation#3
File: variables.tf:245-251
Timestamp: 2024-10-30T17:05:18.442Z
Learning: When users are expected to know certain requirements, such as `worker_pool_id` being required for self-hosted Spacelift instances, avoid adding additional variables solely for validation purposes.

Applied to files:

  • variables.tf
🔇 Additional comments (1)
main.tf (1)

455-455: Stack wiring LGTM

Using local.resolved_worker_pool_ids here aligns with the new resolution flow.

Copy link
Member

@gberenice gberenice left a comment

Choose a reason for hiding this comment

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

@Jgeissler14 looks good!
A couple of suggestions + since we're adding one more complex local expression, could you please add TF tests to check if a correct worker pool ID is selected?

@Gowiem Gowiem changed the title Feat: Ability to assign workerpool by name feat: ability to assign workerpool by name Sep 3, 2025
Gowiem
Gowiem previously requested changes Sep 3, 2025
Copy link
Member

@Gowiem Gowiem left a comment

Choose a reason for hiding this comment

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

Couple small things 👍

@oycyc oycyc requested review from Gowiem and gberenice September 9, 2025 03:42
@oycyc
Copy link
Contributor

oycyc commented Sep 9, 2025

Thanks for the PR Josh!

Pushing this PR through -- committed some updates here to address PR reviews and added tests. No need to test existing worker ID behavior as that already has coverage. So testing new behavior with worker_pool_name and ensuring that configs in stack.yaml takes precedence in the global variable.

Copy link
Member

@gberenice gberenice left a comment

Choose a reason for hiding this comment

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

Thanks for moving this ahead, Yang ❤️

@oycyc oycyc merged commit 7597e4d into main Sep 9, 2025
5 checks passed
@oycyc oycyc deleted the feat/workerpool-by-name branch September 9, 2025 12:17
westonplatter pushed a commit that referenced this pull request Sep 15, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.7.0](v1.6.0...v1.7.0)
(2025-09-15)


### Features

* ability to assign workerpool by name
([#89](#89))
([7597e4d](7597e4d))
* enable integration with ADO
([#93](#93))
([f3b0da4](f3b0da4))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: masterpointbot[bot] <177651640+masterpointbot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants