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

extend data storage_bucket_object with generation #7866

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/11335.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
storage: added `generation` field to `storage_bucket_object` resource
```
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ func dataSourceGoogleStorageBucketObjectRead(d *schema.ResourceData, meta interf
if err := d.Set("metadata", res["metadata"]); err != nil {
return fmt.Errorf("Error setting metadata: %s", err)
}
if err := d.Set("generation", res["generation"]); err != nil {
return fmt.Errorf("Error setting generation: %s", err)
}

d.SetId(bucket + "-" + name)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ func ResourceStorageBucketObject() *schema.Resource {
Description: `Data as string to be uploaded. Must be defined if source is not. Note: The content field is marked as sensitive. To view the raw contents of the object, please define an output.`,
},

"generation": {
Type: schema.TypeInt,
Computed: true,
Description: `The content generation of this object. Used for object versioning and soft delete.`,
},

"crc32c": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -456,6 +462,9 @@ func resourceStorageBucketObjectRead(d *schema.ResourceData, meta interface{}) e
if err := d.Set("detect_md5hash", res.Md5Hash); err != nil {
return fmt.Errorf("Error setting detect_md5hash: %s", err)
}
if err := d.Set("generation", res.Generation); err != nil {
return fmt.Errorf("Error setting generation: %s", err)
}
if err := d.Set("crc32c", res.Crc32c); err != nil {
return fmt.Errorf("Error setting crc32c: %s", err)
}
Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/storage_bucket_object.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ The following attributes are exported:

* `content_type` - (Computed) [Content-Type](https://tools.ietf.org/html/rfc7231#section-3.1.1.5) of the object data. Defaults to "application/octet-stream" or "text/plain; charset=utf-8".

* `generation` - (Computed) The content generation of this object. Used for object [versioning](https://cloud.google.com/storage/docs/object-versioning) and [soft delete](https://cloud.google.com/storage/docs/soft-delete).

* `crc32c` - (Computed) Base 64 CRC32 hash of the uploaded data.

* `md5hash` - (Computed) Base 64 MD5 hash of the uploaded data.
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/storage_bucket_object.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ One of the following is required:
In addition to the arguments listed above, the following computed attributes are
exported:

* `generation` - (Computed) The content generation of this object. Used for object [versioning](https://cloud.google.com/storage/docs/object-versioning) and [soft delete](https://cloud.google.com/storage/docs/soft-delete).

* `crc32c` - (Computed) Base 64 CRC32 hash of the uploaded data.

* `md5hash` - (Computed) Base 64 MD5 hash of the uploaded data.
Expand Down