Skip to content

Conversation

@oycyc
Copy link
Contributor

@oycyc oycyc commented Sep 18, 2025

Support BitBucket Cloud as an integration for VCS for Spacelift stacks.

Terraform Spacelift Registry documentation: https://registry.terraform.io/providers/spacelift-io/spacelift/latest/docs/resources/stack#bitbucket_cloud-1

This is identical to the GitHub integration we already have in place:
image

Summary by CodeRabbit

  • New Features
    • Added support for Bitbucket Cloud integration configuration in stacks, enabling users to specify a namespace and optional ID.
  • Documentation
    • Updated Inputs documentation to include the Bitbucket Cloud configuration option with details on fields and defaults.

@oycyc oycyc requested a review from a team as a code owner September 18, 2025 13:42
@oycyc oycyc requested a review from gberenice September 18, 2025 13:42
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 18, 2025

Walkthrough

  • Adds a new Terraform variable: bitbucket_cloud (object with namespace: string, id: optional(string)), default null.
  • Updates main.tf to conditionally render a dynamic bitbucket_cloud block in spacelift_stack "default" when var.bitbucket_cloud is not null, setting namespace and id (id via try()).
  • Updates README Inputs table to document input_bitbucket_cloud with structure and defaults.
  • Minor whitespace adjustment in variables.tf with no functional impact.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • gberenice
  • Gowiem

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly and accurately captures the primary change—adding Bitbucket Cloud as a VCS integration—and aligns with the changeset which adds a bitbucket_cloud variable and dynamic block; it is concise and uses a conventional "feat:" prefix making it clear for reviewers.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/bitbucket-cloud-integration

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

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 (4)
variables.tf (1)

39-46: Doc hint: clarify “namespace” meaning for Bitbucket Cloud

Consider noting in the variable description/README that “namespace” refers to the Bitbucket Cloud workspace (to prevent confusion vs. org/project wording used by other VCS). (docs.spacelift.io)

README.md (1)

363-363: README row added correctly; consider a tiny usage example

The Inputs table entry is accurate. Add a short HCL snippet under “Usage” showing bitbucket_cloud to reduce guesswork.

bitbucket_cloud = {
  namespace = "your-workspace"
  # id = "integration-id" # optional
}
repository = "your-repo"
main.tf (2)

488-518: Guard against multiple VCS blocks being set simultaneously

At module level, users can set github_enterprise, bitbucket_cloud, azure_devops, and raw_git together, which would render multiple nested VCS blocks and cause a provider error. Add a single precondition to enforce “exactly one VCS input” to improve UX.

HCL snippet to add (outside the changed lines):

locals {
  _vcs_selected_count = length(compact([
    var.github_enterprise != null ? "x" : null,
    var.bitbucket_cloud  != null ? "x" : null,
    var.azure_devops     != null ? "x" : null,
    var.raw_git          != null ? "x" : null,
  ]))
}

resource "spacelift_stack" "default" {
  # ...existing attrs...

  lifecycle {
    precondition {
      condition     = local._vcs_selected_count == 1
      error_message = "Exactly one of github_enterprise, bitbucket_cloud, azure_devops, or raw_git must be set."
    }
  }
}

496-502: (Optional) Consistency: use attribute access over map indexing

We already use indexing (value["namespace"]). Using attribute access (value.namespace) is a tad cleaner and keeps parity with many HCL examples. Non-blocking.

-      namespace = bitbucket_cloud.value["namespace"]
-      id        = try(bitbucket_cloud.value["id"], null)
+      namespace = bitbucket_cloud.value.namespace
+      id        = try(bitbucket_cloud.value.id, null)
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3b9c795 and 497bd83.

📒 Files selected for processing (3)
  • README.md (1 hunks)
  • main.tf (1 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:

  • main.tf
  • variables.tf
🧠 Learnings (1)
📚 Learning: 2024-10-30T17:01:23.897Z
Learnt from: Gowiem
PR: masterpointio/terraform-spacelift-automation#3
File: main.tf:231-257
Timestamp: 2024-10-30T17:01:23.897Z
Learning: In `main.tf`, grouping related attributes in the `spacelift_stack` resource using locals may overcomplicate things and remove important logic elsewhere; prefer to keep attributes as is.

Applied to files:

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

39-46: Bitbucket Cloud input looks correct and consistent with other VCS inputs

Type, shape, and defaults mirror existing patterns. Nice, minimal addition.

main.tf (2)

496-502: Dynamic block is spot‑on and matches existing patterns

Conditional for_each, namespace, and try(...) for id are consistent with github_enterprise/azure_devops. Looks good.


496-502: Please verify the provider version that introduced the bitbucket_cloud nested block on spacelift_stack by inspecting the Spacelift Terraform provider’s CHANGELOG or GitHub releases (https://github.com/spacelift-io/terraform-provider-spacelift/releases) for the PR adding bitbucket_cloud; confirm which version it landed in and ensure your required_providers constraint is at least that version.

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.

:shipit:

Copy link
Member

@westonplatter westonplatter left a comment

Choose a reason for hiding this comment

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

sweet 🚢 it.

@oycyc
Copy link
Contributor Author

oycyc commented Sep 18, 2025

I'll close my PR in favor of Weston's PR as it covers this and more: #97

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.

4 participants