Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed a bug in update #3757

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .changelog/5336.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
compute: fixed a bug in updating multiple `ttl` fields on `google_compute_backend_bucket`
```
10 changes: 5 additions & 5 deletions google-beta/resource_compute_backend_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,28 +699,28 @@ func expandComputeBackendBucketCdnPolicy(v interface{}, d TerraformResourceData,
transformedSignedUrlCacheMaxAgeSec, err := expandComputeBackendBucketCdnPolicySignedUrlCacheMaxAgeSec(original["signed_url_cache_max_age_sec"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedSignedUrlCacheMaxAgeSec); val.IsValid() && !isEmptyValue(val) {
} else {
transformed["signedUrlCacheMaxAgeSec"] = transformedSignedUrlCacheMaxAgeSec
}

transformedDefaultTtl, err := expandComputeBackendBucketCdnPolicyDefaultTtl(original["default_ttl"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedDefaultTtl); val.IsValid() && !isEmptyValue(val) {
} else {
transformed["defaultTtl"] = transformedDefaultTtl
}

transformedMaxTtl, err := expandComputeBackendBucketCdnPolicyMaxTtl(original["max_ttl"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedMaxTtl); val.IsValid() && !isEmptyValue(val) {
} else {
transformed["maxTtl"] = transformedMaxTtl
}

transformedClientTtl, err := expandComputeBackendBucketCdnPolicyClientTtl(original["client_ttl"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedClientTtl); val.IsValid() && !isEmptyValue(val) {
} else {
transformed["clientTtl"] = transformedClientTtl
}

Expand Down Expand Up @@ -795,7 +795,7 @@ func expandComputeBackendBucketCdnPolicyNegativeCachingPolicy(v interface{}, d T
transformedTtl, err := expandComputeBackendBucketCdnPolicyNegativeCachingPolicyTtl(original["ttl"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedTtl); val.IsValid() && !isEmptyValue(val) {
} else {
transformed["ttl"] = transformedTtl
}

Expand Down
56 changes: 54 additions & 2 deletions google-beta/resource_compute_backend_bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,30 @@ func TestAccComputeBackendBucket_withCdnPolicy(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccComputeBackendBucket_withCdnPolicy2(backendName, storageName, 1000, 301, 2, 1),
},
{
ResourceName: "google_compute_backend_bucket.foobar",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccComputeBackendBucket_withCdnPolicy2(backendName, storageName, 0, 404, 0, 0),
},
{
ResourceName: "google_compute_backend_bucket.foobar",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccComputeBackendBucket_withCdnPolicy(backendName, storageName),
},
{
ResourceName: "google_compute_backend_bucket.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Expand Down Expand Up @@ -103,13 +127,41 @@ resource "google_compute_backend_bucket" "foobar" {
bucket_name = google_storage_bucket.bucket.name
enable_cdn = true
cdn_policy {
signed_url_cache_max_age_sec = 1000
signed_url_cache_max_age_sec = 1000
negative_caching = false
}
}

resource "google_storage_bucket" "bucket" {
name = "%s"
location = "EU"
}
`, backendName, storageName)
}

func testAccComputeBackendBucket_withCdnPolicy2(backendName, storageName string, age, code, max_ttl, ttl int) string {
return fmt.Sprintf(`
resource "google_compute_backend_bucket" "foobar" {
name = "%s"
bucket_name = google_storage_bucket.bucket.name
enable_cdn = true
cdn_policy {
cache_mode = "CACHE_ALL_STATIC"
signed_url_cache_max_age_sec = %d
max_ttl = %d
default_ttl = %d
client_ttl = %d
serve_while_stale = %d
negative_caching_policy {
code = %d
ttl = %d
}
negative_caching = true
}
}

resource "google_storage_bucket" "bucket" {
name = "%s"
location = "EU"
}
`, backendName, age, max_ttl, ttl, ttl, ttl, code, ttl, storageName)
}
3 changes: 2 additions & 1 deletion google-beta/resource_dataproc_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"

dataproc "google.golang.org/api/dataproc/v1beta2"
"google.golang.org/api/googleapi"

"google.golang.org/api/dataproc/v1beta2"
)

func TestDataprocExtractInitTimeout(t *testing.T) {
Expand Down