Skip to content

Commit

Permalink
Merge pull request #59 from Backblaze/fix-bucket-with-file-lock
Browse files Browse the repository at this point in the history
Fix bucket with file lock
  • Loading branch information
vbaltrusaitis-reef authored Dec 13, 2023
2 parents 0cf516e + e576675 commit e12dadf
Show file tree
Hide file tree
Showing 11 changed files with 302 additions and 444 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ on:
tags: 'v*' # push events to matching v*, i.e. v1.0, v20.15.10

env:
PYTHON_DEFAULT_VERSION: 3.9
GO_DEFAULT_VERSION: 1.19
PYTHON_DEFAULT_VERSION: '3.9'
GO_DEFAULT_VERSION: '1.20'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ on:
branches: [master]

env:
PYTHON_DEFAULT_VERSION: 3.9
GO_DEFAULT_VERSION: 1.19
PYTHON_DEFAULT_VERSION: '3.9'
GO_DEFAULT_VERSION: '1.20'

jobs:
lint:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.8.5] - 2023-11-24

### Changed
* Upgraded go to 1.20 and github.com/hashicorp/terraform-plugin-sdk to v2.30.0

### Infrastructure
* Disable changelog verification for dependabot PRs
* Upgrade macOS version in CI/CD
Expand All @@ -16,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
* Reconcile missing Application Key caused by the resource drift
* Fix reconciliation of missing Bucket caused by the resource drift
* Fix bucket cleanup after failed creation

## [0.8.4] - 2023-03-13

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Requirements
------------

- [Terraform](https://www.terraform.io/downloads.html) >= 1.0.0
- [Go](https://golang.org/doc/install) >= 1.18
- [Go](https://golang.org/doc/install) >= 1.20
- [Python](https://github.com/pyenv/pyenv) >= 3.9

Dependencies
Expand Down
40 changes: 40 additions & 0 deletions b2/resource_b2_bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,46 @@ func TestAccResourceB2Bucket_update(t *testing.T) {
})
}

func TestAccResourceB2Bucket_defaultRetention(t *testing.T) {
resourceName := "b2_bucket.test"

bucketName := acctest.RandomWithPrefix("test-b2-tfp")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: providerFactories,
Steps: []resource.TestStep{
{
Config: testAccResourceB2BucketConfig_defaultRetention(bucketName, false),
ExpectError: regexp.MustCompile("default_retention"),
},
{
Config: testAccResourceB2BucketConfig_defaultRetention(bucketName, true),
Check: resource.TestCheckResourceAttr(resourceName, "bucket_name", bucketName),
},
},
})
}

func testAccResourceB2BucketConfig_defaultRetention(bucketName string, fileLockEnabled bool) string {
return fmt.Sprintf(`
resource "b2_bucket" "test" {
bucket_name = "%s"
bucket_type = "allPublic"
file_lock_configuration {
is_file_lock_enabled = %t
default_retention {
mode = "governance"
period {
duration = 7
unit = "days"
}
}
}
}
`, bucketName, fileLockEnabled)
}

func testAccResourceB2BucketConfig_basic(bucketName string) string {
return fmt.Sprintf(`
resource "b2_bucket" "test" {
Expand Down
2 changes: 1 addition & 1 deletion b2/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func getDataSourceFileLockConfiguration() *schema.Resource {
Computed: true,
},
"default_retention": {
Description: "Default retention settings for files uploaded to this bucket",
Description: "Default retention settings for files uploaded to this bucket. This can only be set if is_file_lock_enabled is true",
Type: schema.TypeList,
Optional: true,
Computed: true,
Expand Down
57 changes: 52 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,59 @@
module github.com/Backblaze/terraform-provider-b2

go 1.16
go 1.20

require (
github.com/gobuffalo/here v0.6.6 // indirect
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1
github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0
github.com/markbates/pkger v0.17.1
golang.org/x/net v0.7.0 // indirect
)

require (
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/gobuffalo/here v0.6.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.5.1 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/hc-install v0.6.1 // indirect
github.com/hashicorp/hcl/v2 v2.19.1 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.19.0 // indirect
github.com/hashicorp/terraform-json v0.17.1 // indirect
github.com/hashicorp/terraform-plugin-go v0.19.0 // indirect
github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
github.com/hashicorp/terraform-registry-address v0.2.2 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/zclconf/go-cty v1.14.1 // indirect
golang.org/x/crypto v0.15.0 // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220623142657-077d458a5694 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect
google.golang.org/grpc v1.57.1 // indirect
google.golang.org/protobuf v1.31.0 // indirect
)
Loading

0 comments on commit e12dadf

Please sign in to comment.