Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
c141355
ignore 404 error for forked repo pipeline config
giveadamakick Oct 20, 2023
fdb570d
Merge pull request #179 from giveadamakick/fix-forked-repository-404-…
DrFaust92 Oct 25, 2023
f5f4902
bump deps + golang
DrFaust92 Oct 25, 2023
e71931a
bump bb api
DrFaust92 Oct 25, 2023
0128903
add webhooks secrets
DrFaust92 Oct 25, 2023
41d08d0
Merge pull request #181 from DrFaust92/webhook-secret
DrFaust92 Oct 25, 2023
ef305bd
fix project update
DrFaust92 Oct 29, 2023
6b04a68
Merge pull request #182 from DrFaust92/project-update
DrFaust92 Oct 29, 2023
31dbd43
update hook types + patch
DrFaust92 Nov 4, 2023
9d82454
document repo group permissions oauth limitation
giveadamakick Nov 10, 2023
0433290
Merge pull request #184 from giveadamakick/document-repo-group-perm-o…
DrFaust92 Nov 22, 2023
8d9c011
Fix headline in repository_group_permission.md
giveadamakick Nov 23, 2023
23554ad
Fix headline in repository_user_permission.md
giveadamakick Nov 23, 2023
92d2b25
Merge pull request #188 from giveadamakick/patch-2
DrFaust92 Nov 24, 2023
4598e3b
Merge pull request #187 from giveadamakick/patch-1
DrFaust92 Nov 24, 2023
a5f37ac
allow importing repo vars
DrFaust92 Nov 24, 2023
e469656
Merge pull request #189 from DrFaust92/repo-var-import
DrFaust92 Nov 24, 2023
c408e13
bump deps
DrFaust92 Dec 23, 2023
ed3b604
bump deps
DrFaust92 Feb 10, 2024
48260b3
sort
DrFaust92 Feb 10, 2024
ae87f80
deployments data source
DrFaust92 Feb 10, 2024
0518324
Merge pull request #194 from DrFaust92/deployments
DrFaust92 Feb 10, 2024
4f00007
use api for deploy delete
DrFaust92 Feb 10, 2024
8f8b5ba
Merge pull request #195 from DrFaust92/deployment-api
DrFaust92 Feb 10, 2024
c7dd69e
project user and grp perms
DrFaust92 Feb 10, 2024
f5a9824
Merge pull request #196 from DrFaust92/project_perm
DrFaust92 Feb 10, 2024
29031d3
members
DrFaust92 Feb 18, 2024
f872265
Merge pull request #198 from DrFaust92/members
DrFaust92 Feb 18, 2024
85e43ea
add perimeter
DrFaust92 Feb 18, 2024
e49bdb4
default reviewers use sdk
DrFaust92 Feb 18, 2024
5c0562c
project default reviewers use sdk
DrFaust92 Feb 18, 2024
df4537c
fix: make sure the authorization error is correctly shown to the end …
Nkmol Apr 1, 2024
902f7b3
Merge pull request #200 from Nkmol/fix-authorization-diagnostic-error
DrFaust92 Apr 28, 2024
8073d42
chore(doc): extend branch-restriction documentation example to show u…
Nkmol May 1, 2024
3c7b99e
Merge pull request #202 from Nkmol/extend-branch-restriction-doc-for-…
DrFaust92 May 2, 2024
3146d63
BranchingModel: use_mainbranch field is required in JSON
May 14, 2024
00b93d7
Fix multiple bugs in handling of branch_types.enabled
May 14, 2024
177e314
Renaming bitbucket_repository fails with 404 (not found) error
May 15, 2024
fac6dcc
Merge pull request #206 from barrywhart/fix-issue-96-renaming-bitbuck…
DrFaust92 May 17, 2024
1e43554
Merge pull request #205 from barrywhart/fix-issue-183-disabling-a-bra…
DrFaust92 May 17, 2024
3bf2b3a
Merge pull request #204 from barrywhart/fix-issue-167-use_mainbranch-…
DrFaust92 May 17, 2024
b86e741
Attempting to enable the production branch_type never seems to get "f…
May 18, 2024
c4e4049
Prevent using user name with bitbucket_repository_user_permission. Mu…
May 18, 2024
30f949f
Safer version of the fix: Only copy "Enabled" for "production"
May 18, 2024
bb787af
Merge pull request #209 from barrywhart/fix-issue-repository-user-per…
DrFaust92 May 30, 2024
8de67e9
Merge pull request #208 from barrywhart/fix-issue-207-enabling-produc…
DrFaust92 Jun 4, 2024
7cbf383
use more consistent endpoint
SamuZad Sep 2, 2024
23980ce
bump go + deps
DrFaust92 Oct 18, 2024
f9f0091
bump to deps
DrFaust92 Nov 9, 2024
1ba1821
Merge pull request #218 from SamuZad/master
DrFaust92 Nov 9, 2024
ecc6b68
bump deps + release process
DrFaust92 Dec 15, 2024
f864026
pass passphrase
DrFaust92 Jan 2, 2025
49ac45e
bump deps
DrFaust92 Apr 4, 2025
d4b7c68
default_branch_deletion
DrFaust92 May 5, 2025
896fa69
default_branch_deletion
DrFaust92 May 5, 2025
36c5975
default_branch_deletion
DrFaust92 May 5, 2025
f9e5b13
default_branch_deletion
DrFaust92 May 5, 2025
1798f84
default_branch_deletion
DrFaust92 May 5, 2025
e665d3d
default_branch_deletion
DrFaust92 May 5, 2025
58e11f2
Merge pull request #229 from DrFaust92/default_branch_deletion
DrFaust92 May 5, 2025
3267731
Built out datasources for bitbucket projects, repositories, and file …
Jul 1, 2025
c52ed52
Fix markdown complaint
Jul 1, 2025
fd97110
Fix general linter error
Jul 1, 2025
855bfdc
Had to also lowercase error messages in the other files
Jul 1, 2025
e0145f6
Merge pull request #232 from estein9825/add-project-repo-and-file-dat…
DrFaust92 Jul 10, 2025
9dd341e
fix referencing potentially nil http response
Ner0theHer0 Aug 2, 2025
8794e2e
gracefully handle oauth retrieval and scoping errors
Ner0theHer0 Aug 2, 2025
4e97589
Merge pull request #236 from Ner0theHer0/improve-oauth-error-handling
DrFaust92 Sep 17, 2025
2d82472
refresh
DrFaust92 Oct 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
markdown-link-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v5
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-quiet-mode: 'yes'
Expand All @@ -26,7 +26,7 @@ jobs:
markdown-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v5
- uses: avto-dev/markdown-lint@v1
with:
config: '.markdownlint.yml'
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ jobs:
name: Run linter
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: '1.19'
- uses: actions/checkout@v3
go-version-file: "go.mod"
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v8
with:
version: v1.50.1
only-new-issues: true
only-new-issues: true
46 changes: 11 additions & 35 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,27 @@
# This GitHub action can publish assets for release when a tag is created.
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0).
#
# This uses an action (hashicorp/ghaction-import-gpg) that assumes you set your
# This uses an action (hashicorp/ghaction-import-gpg) that assumes you set your
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE`
# secret. If you would rather own your own GPG handling, please fork this action
# or use an alternative one for key handling.
#
# You will need to pass the `--batch` flag to `gpg` in your signing step
# You will need to pass the `--batch` flag to `gpg` in your signing step
# in `goreleaser` to indicate this is being used in a non-interactive mode.
#
name: release
on:
push:
tags:
- 'v*'
- "v*"
permissions:
contents: write
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Unshallow
run: git fetch --prune --unshallow
-
name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
cache: true
-
name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v5
id: import_gpg
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
-
name: Run GoReleaser
uses: goreleaser/[email protected]
with:
version: latest
args: release --rm-dist
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
# GitHub sets this automatically
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
terraform-provider-release:
name: "Terraform Provider Release"
uses: hashicorp/ghaction-terraform-provider-release/.github/workflows/community.yml@v5
secrets:
gpg-private-key: "${{ secrets.GPG_PRIVATE_KEY }}"
gpg-private-key-passphrase: "${{ secrets.PASSPHRASE }}"
with:
setup-go-version-file: "go.mod"
36 changes: 33 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
linters-settings:
errcheck:
ignore: Set
version: "2"
linters:
default: none
enable:
- durationcheck
- govet
- ineffassign
- makezero
- misspell
- nilerr
- staticcheck
- unconvert
- unused
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
59 changes: 30 additions & 29 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
# Visit https://goreleaser.com for documentation on how to customize this
# behavior.
version: 2
before:
hooks:
# this is just an example and not a requirement for provider building/publishing
- go mod tidy
builds:
- env:
# goreleaser does not work with CGO, it could also complicate
# usage by users in CI/CD systems like Terraform Cloud where
# they are unable to install libraries.
- CGO_ENABLED=0
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath
ldflags:
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
goos:
- freebsd
- windows
- linux
- darwin
goarch:
- amd64
- '386'
- arm
- arm64
ignore:
- goos: darwin
goarch: '386'
binary: '{{ .ProjectName }}_v{{ .Version }}'
- env:
# goreleaser does not work with CGO, it could also complicate
# usage by users in CI/CD systems like Terraform Cloud where
# they are unable to install libraries.
- CGO_ENABLED=0
mod_timestamp: "{{ .CommitTimestamp }}"
flags:
- -trimpath
ldflags:
- "-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}"
goos:
- freebsd
- windows
- linux
- darwin
goarch:
- amd64
- "386"
- arm
- arm64
ignore:
- goos: darwin
goarch: "386"
binary: "{{ .ProjectName }}_v{{ .Version }}"
archives:
- format: zip
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
- format: zip
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
checksum:
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
name_template: "{{ .ProjectName }}_{{ .Version }}_SHA256SUMS"
algorithm: sha256
signs:
- artifacts: checksum
args:
# if you are using this in a GitHub action or some other automated pipeline, you
# if you are using this in a GitHub action or some other automated pipeline, you
# need to pass the batch flag to indicate its not interactive.
- "--batch"
- "--local-user"
Expand All @@ -51,4 +52,4 @@ release:
# If you want to manually examine the release before its live, uncomment this line:
# draft: true
changelog:
skip: true
disable: true
2 changes: 2 additions & 0 deletions .markdownlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ MD010:
# https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md

MD013: false
MD033: false
MD022: false
4 changes: 2 additions & 2 deletions bitbucket/data_current_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ func dataReadCurrentUser(ctx context.Context, d *schema.ResourceData, m interfac
httpClient := m.(Clients).httpClient
usersApi := c.ApiClient.UsersApi

curUser, _, err := usersApi.UserGet(c.AuthContext)
if err := handleClientError(err); err != nil {
curUser, res, err := usersApi.UserGet(c.AuthContext)
if err := handleClientError(res, err); err != nil {
return diag.FromErr(err)
}

Expand Down
4 changes: 2 additions & 2 deletions bitbucket/data_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ func dataReadDeployment(ctx context.Context, d *schema.ResourceData, m interface
}

if res.StatusCode == http.StatusNotFound {
return diag.Errorf("user not found")
return diag.Errorf("deployment not found")
}

if res.StatusCode >= http.StatusInternalServerError {
return diag.Errorf("internal server error fetching user")
return diag.Errorf("internal server error fetching deployment")
}

var deploy Deployment
Expand Down
70 changes: 70 additions & 0 deletions bitbucket/data_deployments.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package bitbucket

import (
"context"
"fmt"
"log"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataDeployments() *schema.Resource {
return &schema.Resource{
ReadWithoutTimeout: dataReadDeployments,

Schema: map[string]*schema.Schema{
"uuids": {
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
},
"workspace": {
Type: schema.TypeString,
Required: true,
},
"repository": {
Type: schema.TypeString,
Required: true,
},
"names": {
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
},
},
}
}

func dataReadDeployments(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
c := m.(Clients).genClient
deployApi := c.ApiClient.DeploymentsApi

workspace := d.Get("workspace").(string)
repoId := d.Get("repository").(string)

deploymentsResp, res, err := deployApi.GetEnvironmentsForRepository(c.AuthContext, workspace, repoId, nil)
if err := handleClientError(res, err); err != nil {
return diag.FromErr(err)
}

deployments := deploymentsResp.Values

log.Printf("haha %#v", deployments)

var uuids []string
for _, deployment := range deployments {
uuids = append(uuids, deployment.Uuid)
}

var names []string
for _, deployment := range deployments {
names = append(names, deployment.Name)
}

d.SetId(fmt.Sprintf("%s/%s", workspace, repoId))
d.Set("uuids", uuids)
d.Set("names", names)

return nil
}
46 changes: 46 additions & 0 deletions bitbucket/data_deployments_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package bitbucket

import (
"fmt"
"os"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccDataSourceDeployments_basic(t *testing.T) {
dataSourceName := "data.bitbucket_deployments.test"
resourceName := "bitbucket_deployment.test"

rName := acctest.RandomWithPrefix("tf-test")

workspace := os.Getenv("BITBUCKET_TEAM")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccBitbucketDeploymentsConfig(workspace, rName, rName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(dataSourceName, "workspace", workspace),
resource.TestCheckResourceAttr(dataSourceName, "uuids.#", "1"),
resource.TestCheckResourceAttr(dataSourceName, "names.#", "1"),
resource.TestCheckResourceAttrPair(dataSourceName, "uuids.0", resourceName, "uuid"),
resource.TestCheckResourceAttrPair(dataSourceName, "names.0", resourceName, "name"),
),
},
},
})
}

func testAccBitbucketDeploymentsConfig(workspace, repoName, deployName string) string {
return testAccBitbucketDeployment(workspace, repoName, deployName) + fmt.Sprintf(`
data "bitbucket_deployments" "test" {
workspace = %[1]q
repository = bitbucket_repository.test.slug

depends_on = [bitbucket_deployment.test]
}
`, workspace)
}
Loading