Skip to content
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

feat(labels): adds a variable to support labels on a root module level #39

Merged
merged 1 commit into from
Jan 9, 2025

Conversation

gberenice
Copy link
Member

@gberenice gberenice commented Jan 9, 2025

what

  • Adds a variable that allows to set labels for all the stacks created by this spacelift-automation root module.

why

  • Support cases when all the stacks need to have a common label, e.g. nobackend.

references

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for custom labels in stack configurations
    • Enhanced stack management with flexible label assignment
  • Improvements

    • Updated runner_image default value for better configuration
    • Expanded configuration options for stack labeling
  • Testing

    • Added new test case to verify label creation and management

The update provides more granular control over stack labeling and improves overall configuration flexibility.

@gberenice gberenice requested a review from a team as a code owner January 9, 2025 16:08
Copy link
Contributor

coderabbitai bot commented Jan 9, 2025

Walkthrough

This pull request introduces a new labels input variable across multiple files in the Terraform module. The changes allow users to specify custom labels for Spacelift stacks, enhancing configuration flexibility. The runner_image variable's default value was also updated from a string "null" to the native null value. These modifications provide more granular control over stack labeling and improve type consistency in the configuration.

Changes

File Change Summary
README.md Added labels input variable; Updated runner_image default value
variables.tf Added new labels variable with list(string) type and empty list default
main.tf Incorporated var.labels into labels local variable
examples/complete/components/spacelift-automation/... Added labels parameter to module and example configuration
tests/main.tftest.hcl Added new test case for labels verification

Possibly related PRs

  • /terraform-spacelift-automation#3: Adds labels input variable in README
  • /terraform-spacelift-automation#9: Introduces labels key in configuration files
  • /terraform-spacelift-automation#34: Modifies runner_image variable and related resources

Poem

🏷️ Labels dancing, free and bright,
Stacks adorned with metadata's might
Null replaced, configurations gleam
Terraform's magic in each code stream
Flexibility blooms, configuration's delight! 🚀

Finishing Touches

  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai 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.

Documentation and Community

  • 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: 0

🧹 Nitpick comments (2)
examples/complete/components/spacelift-automation/main.tf (1)

13-14: Consider maintaining consistent spacing between module arguments.

While the implementation is correct, consider removing the extra newline before labels to maintain consistent formatting with other module arguments.

   aws_integration_id      = var.aws_integration_id
   aws_integration_enabled = true
-

   labels = var.labels
tests/main.tftest.hcl (1)

18-25: Good test coverage! Consider adding edge cases.

The test case effectively verifies the basic label functionality. Consider adding tests for:

  • Empty labels list
  • Multiple labels
  • Label name validation (if any constraints exist)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bfea293 and 3ce4927.

📒 Files selected for processing (7)
  • README.md (1 hunks)
  • examples/complete/components/spacelift-automation/main.tf (1 hunks)
  • examples/complete/components/spacelift-automation/tfvars/example.tfvars (1 hunks)
  • examples/complete/components/spacelift-automation/variables.tf (1 hunks)
  • main.tf (1 hunks)
  • tests/main.tftest.hcl (1 hunks)
  • variables.tf (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
examples/complete/components/spacelift-automation/main.tf (1)

Pattern **/*.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.

examples/complete/components/spacelift-automation/variables.tf (1)

Pattern **/*.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.

variables.tf (1)

Pattern **/*.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.

main.tf (1)

Pattern **/*.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.

🔇 Additional comments (7)
examples/complete/components/spacelift-automation/tfvars/example.tfvars (1)

8-8: LGTM! Label configuration looks good.

The label is correctly formatted as a list of strings and follows naming conventions.

examples/complete/components/spacelift-automation/variables.tf (1)

26-30: Well-structured variable declaration!

The variable declaration follows Terraform best practices with appropriate type constraints, a sensible default value, and a clear description.

tests/main.tftest.hcl (1)

13-16: LGTM! Labels variable is well-defined.

The variable declaration in the test configuration is clear and matches the example usage.

variables.tf (1)

271-275: Well-structured variable declaration!

The labels variable follows Terraform best practices with a clear type definition, meaningful description, and appropriate default value.

main.tf (1)

247-247: Clean integration of the new labels variable!

The new var.labels is properly integrated into the existing labels merge logic, maintaining the current functionality while adding the ability to specify global labels.

README.md (2)

262-262: Documentation matches implementation!

The new labels input variable is well-documented in the README, maintaining consistency with the code implementation.


268-268: Good cleanup of runner_image default value!

Changed the default value from string "null" to native null for better type consistency.

Copy link
Contributor

@oycyc oycyc left a comment

Choose a reason for hiding this comment

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

Simple & straightforward, thanks! 👍

@gberenice gberenice merged commit f84d9ac into main Jan 9, 2025
4 checks passed
@gberenice gberenice deleted the feature/support-global-labels branch January 9, 2025 16:13
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.

2 participants