From c5a26e3f86b7b4d8d14cae5d2671ac80c029f308 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vykintas=20Baltru=C5=A1aitis?= Date: Fri, 5 Jan 2024 17:21:21 +0200 Subject: [PATCH 1/3] Fix bucket update when file_lock_configuration omitted Bucket updates used to fail if `file_lock_configuration` is omitted. This happened because on bucket update, pybindings get an empty `default_retention` list instead of a missing field / None. --- CHANGELOG.md | 8 +++++++- b2/resource_b2_bucket_test.go | 17 +++++++++++++++++ python-bindings/b2_terraform/provider_tool.py | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af4d83f..327099a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.8.9] - 2024-01-05 + +### Fixed +* Fixed bucket update when is_file_lock_enabled is not set + ## [0.8.8] - 2023-12-28 ### Changed @@ -156,7 +161,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added * Implementation of PoC (simple `b2_application_key` data source) -[Unreleased]: https://github.com/Backblaze/terraform-provider-b2/compare/v0.8.8...HEAD +[Unreleased]: https://github.com/Backblaze/terraform-provider-b2/compare/v0.8.9...HEAD +[0.8.9]: https://github.com/Backblaze/terraform-provider-b2/compare/v0.8.9...v0.8.9 [0.8.8]: https://github.com/Backblaze/terraform-provider-b2/compare/v0.8.7...v0.8.8 [0.8.7]: https://github.com/Backblaze/terraform-provider-b2/compare/v0.8.6...v0.8.7 [0.8.6]: https://github.com/Backblaze/terraform-provider-b2/compare/v0.8.5...v0.8.6 diff --git a/b2/resource_b2_bucket_test.go b/b2/resource_b2_bucket_test.go index b742f71..84e8635 100644 --- a/b2/resource_b2_bucket_test.go +++ b/b2/resource_b2_bucket_test.go @@ -152,6 +152,11 @@ func TestAccResourceB2Bucket_update(t *testing.T) { { Config: testAccResourceB2BucketConfig_basic(bucketName), }, + // We're testing a minimal change here to check if omitted optional + // fields do not cause an update to fail. + { + Config: testAccResourceB2BucketConfig_basicWithFileInfo(bucketName), + }, { Config: testAccResourceB2BucketConfig_all(bucketName), Check: resource.ComposeTestCheckFunc( @@ -254,6 +259,18 @@ resource "b2_bucket" "test" { `, bucketName) } +func testAccResourceB2BucketConfig_basicWithFileInfo(bucketName string) string { + return fmt.Sprintf(` +resource "b2_bucket" "test" { + bucket_name = "%s" + bucket_type = "allPublic" + bucket_info = { + key = "value" + } +} +`, bucketName) +} + func testAccResourceB2BucketConfig_lifecycleRulesDefaults(bucketName string) string { return fmt.Sprintf(` resource "b2_bucket" "test" { diff --git a/python-bindings/b2_terraform/provider_tool.py b/python-bindings/b2_terraform/provider_tool.py index 48b6bb1..12d5bf5 100644 --- a/python-bindings/b2_terraform/provider_tool.py +++ b/python-bindings/b2_terraform/provider_tool.py @@ -298,7 +298,7 @@ def _preprocess(self, **kwargs): for file_lock_configuration in kwargs.pop('file_lock_configuration', ()): lock_enabled = file_lock_configuration.get('is_file_lock_enabled') - default_retention_set = file_lock_configuration.get('default_retention') is not None + default_retention_set = bool(file_lock_configuration.get('default_retention')) if default_retention_set and not lock_enabled: raise RuntimeError( 'default_retention can only be set if is_file_lock_enabled is true' From 6dcbd548964550947b2de15d1bec1211a3141528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vykintas=20Baltru=C5=A1aitis?= Date: Wed, 10 Jan 2024 12:46:37 +0200 Subject: [PATCH 2/3] Update github.com/cloudflare/circl --- CHANGELOG.md | 3 +++ go.mod | 2 +- go.sum | 3 ++- tools/go.mod | 2 +- tools/go.sum | 4 ++-- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 327099a..0d3adc6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.8.9] - 2024-01-05 +### Changed +* Upgraded github.com/cloudflare/circl from v1.3.3 to v1.3.7 + ### Fixed * Fixed bucket update when is_file_lock_enabled is not set diff --git a/go.mod b/go.mod index 333ec8d..bc095de 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ 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/cloudflare/circl v1.3.7 // 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 diff --git a/go.sum b/go.sum index 618a003..beb8886 100644 --- a/go.sum +++ b/go.sum @@ -9,8 +9,9 @@ github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= -github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= +github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= +github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/tools/go.mod b/tools/go.mod index 7eb5a97..2aee269 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -12,7 +12,7 @@ require ( github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect github.com/armon/go-radix v1.0.0 // indirect github.com/bgentry/speakeasy v0.1.0 // indirect - github.com/cloudflare/circl v1.3.3 // indirect + github.com/cloudflare/circl v1.3.7 // indirect github.com/fatih/color v1.13.0 // indirect github.com/google/uuid v1.3.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect diff --git a/tools/go.sum b/tools/go.sum index e263b65..be8c65e 100644 --- a/tools/go.sum +++ b/tools/go.sum @@ -18,8 +18,8 @@ github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I= -github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= -github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= +github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= +github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From dc131d52ef520c316d054fcc7ef26c984719f1a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vykintas=20Baltru=C5=A1aitis?= Date: Wed, 10 Jan 2024 13:40:21 +0200 Subject: [PATCH 3/3] Fix typo in CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d3adc6..4fbfa1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -165,7 +165,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Implementation of PoC (simple `b2_application_key` data source) [Unreleased]: https://github.com/Backblaze/terraform-provider-b2/compare/v0.8.9...HEAD -[0.8.9]: https://github.com/Backblaze/terraform-provider-b2/compare/v0.8.9...v0.8.9 +[0.8.9]: https://github.com/Backblaze/terraform-provider-b2/compare/v0.8.8...v0.8.9 [0.8.8]: https://github.com/Backblaze/terraform-provider-b2/compare/v0.8.7...v0.8.8 [0.8.7]: https://github.com/Backblaze/terraform-provider-b2/compare/v0.8.6...v0.8.7 [0.8.6]: https://github.com/Backblaze/terraform-provider-b2/compare/v0.8.5...v0.8.6