Skip to content

Commit

Permalink
extend data storage_bucket_object with generation (GoogleCloudPlatfor…
Browse files Browse the repository at this point in the history
  • Loading branch information
prauc authored and BBBmau committed Aug 21, 2024
1 parent e6b3051 commit 7ec59d4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,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 @@ -95,6 +95,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 @@ -454,6 +460,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
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
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

0 comments on commit 7ec59d4

Please sign in to comment.