Skip to content

Commit

Permalink
Fix content in the google_storage_bucket_object_content data sour…
Browse files Browse the repository at this point in the history
…ce which is incorrectly marked as a non-computed attribute (GoogleCloudPlatform#10778)
  • Loading branch information
wafrelka authored and pcostell committed Jul 16, 2024
1 parent 80e44f1 commit 293c27a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ func DataSourceGoogleStorageBucketObjectContent() *schema.Resource {

tpgresource.AddRequiredFieldsToSchema(dsSchema, "bucket")
tpgresource.AddRequiredFieldsToSchema(dsSchema, "name")
tpgresource.AddOptionalFieldsToSchema(dsSchema, "content")

return &schema.Resource{
Read: dataSourceGoogleStorageBucketObjectContentRead,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,30 @@ resource "google_storage_bucket" "contenttest" {
force_destroy = true
}`, content, bucket)
}

func TestAccDataSourceStorageBucketObjectContent_Issue15717(t *testing.T) {

bucket := "tf-bucket-object-content-" + acctest.RandString(t, 10)
content := "qwertyuioasdfghjk1234567!!@#$*"

config := fmt.Sprintf(`
%s
output "output" {
value = replace(data.google_storage_bucket_object_content.default.content, "q", "Q")
}`, testAccDataSourceStorageBucketObjectContent_Basic(content, bucket))

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("data.google_storage_bucket_object_content.default", "content"),
resource.TestCheckResourceAttr("data.google_storage_bucket_object_content.default", "content", content),
),
},
},
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ The following arguments are supported:

The following attributes are exported:

* `content` - (Computed) [Content-Language](https://tools.ietf.org/html/rfc7231#section-3.1.3.2) of the object content.
* `content` - (Computed) The content of the object.

0 comments on commit 293c27a

Please sign in to comment.