feat: add Bitbucket support to code_repository and service_definition modules#445
Open
pablovilas wants to merge 3 commits into
Open
feat: add Bitbucket support to code_repository and service_definition modules#445pablovilas wants to merge 3 commits into
pablovilas wants to merge 3 commits into
Conversation
Allow git_provider to be 'bitbucket' (and 'azure', which the module already implemented but the validation silently rejected). Add an is_bitbucket local, a bitbucket-configuration provider_config resource mapping setup.workspace/project_key/email/api_token (sensitive)/ installation_url/flavor plus access.collaborators, the corresponding input variables, and a plan test.
Allow git_provider to be 'bitbucket' and fetch service/action/link spec templates from Bitbucket Cloud raw file endpoints under the canonical repository URL https://bitbucket.org/{workspace}/{repo}. Make the per-provider URL and auth-header selection an explicit conditional chain instead of a positional github-or-gitlab fallback.
Atlassian API tokens (the program's standard bot-user credential) authenticate only via HTTP Basic email:api_token and return 401 on a Bearer header. Add an optional bitbucket_email input: when set, the Bitbucket auth header becomes Basic base64(email:api_token); when null, keep Bearer for Bitbucket workspace/repository access tokens. Document both modes on the variable and in the README.
sebastiancorrea81
approved these changes
Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Bitbucket as a first-class git provider to the
nullplatform/code_repositoryandnullplatform/service_definitionmodules. This is thetofu-modulesslice of the cross-repo Bitbucket support program (Plan 09 / periphery), bringing the modules to parity with GitHub / GitLab / Azure DevOps and aligning them with the organization-setup contract that already acceptsbitbucket.Contract honored: provider value
bitbucket; provider-spec type slugbitbucket-configurationwith attributessetup.workspace,setup.project_key,setup.email,setup.api_token(sensitive),setup.installation_url(defaulthttps://bitbucket.org),setup.flavor(cloud),access.collaborators; canonical repo URLhttps://bitbucket.org/{workspace}/{slug}.nullplatform/code_repositoryvariables.tf: validation widened from["github","gitlab"]to["github","gitlab","azure","bitbucket"]. The previous list silently rejected Azure, which the module already fully implemented (resource,is_azurelocal,azure_*vars) — fixed alongside Bitbucket.locals.tf: addedis_bitbucket.main.tf: added abitbucket-configurationnullplatform_provider_configresource, mappingsetup.{workspace,project_key,email,api_token,installation_url,flavor}andaccess.collaboratorsfrom new variables, mirroring the gitlab/github/azure blocks (namespace stripped from NRN viareplace()).bitbucket_workspace,bitbucket_project_key,bitbucket_email,bitbucket_api_token(sensitive),bitbucket_installation_url(defaulthttps://bitbucket.org),bitbucket_flavor(defaultcloud),bitbucket_collaborators. Required fields validated whengit_provider == "bitbucket".bitbucket_provider_configplan test.nullplatform/service_definitionvariables.tf: validation widened from["github","gitlab","local"]to["github","gitlab","bitbucket","local"]. Azure is not added here becausedata.tfonly wires github/gitlab spec fetching — the module genuinely does not support Azure as a spec source, so it stays out.locals.tf: addedbitbucket_repo_url(https://bitbucket.org/{org}/{repo}, matching the canonical URL contract) andbitbucket_raw_prefix; made the URL/header selection an explicit per-provider chain rather than a positionalgithub ? … : (gitlab)fallback.data.tf: added an explicit Bitbucket branch to all three spec-fetch data sources.Bitbucket authentication (Basic vs Bearer)
The Bitbucket auth header adapts to the credential type:
email:api_tokenand returns 401 on a Bearer header. Set the new optionalbitbucket_emailinput and the module sendsAuthorization: Basic base64(email:api_token).bitbucket_emailnull and the token is sent asAuthorization: Bearer <token>.Both modes are documented on the
bitbucket_emailvariable and in the README.Validation
tofu validate— passes in both modules.tofu test(code_repository) — 4/4 pass, including the new Bitbucket run.tofu fmt -check -recursive— clean; terraform-docs README input tables regenerated.Repo sweep (gap 3)
Checked every
contains([...])validation and provider conditional in the repo. Onlycode_repositoryandservice_definitiongated git providers; both fixed.nullplatform/account'srepository_providerhas no validation (already permissive — acceptsbitbucket). All othercontains([...])checks are for unrelated concerns (cloud_provider, k8s_provider, dns_provider, api_key type, etc.) and were left untouched.🤖 Generated with Claude Code