mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-07-03 08:42:39 +00:00
Minor cleanup of disk's labelFingerprint. (#1651)
This commit is contained in:
parent
8591ab1577
commit
43cccf3e2c
|
@ -371,6 +371,10 @@ func resourceComputeDisk() *schema.Resource {
|
|||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"label_fingerprint": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"last_attach_timestamp": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
|
@ -408,11 +412,6 @@ func resourceComputeDisk() *schema.Resource {
|
|||
Computed: true,
|
||||
Deprecated: "Use disk_encryption_key.sha256 instead.",
|
||||
},
|
||||
|
||||
"label_fingerprint": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"project": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
|
@ -560,6 +559,9 @@ func resourceComputeDiskRead(d *schema.ResourceData, meta interface{}) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if err := d.Set("label_fingerprint", flattenComputeDiskLabelFingerprint(res["labelFingerprint"])); err != nil {
|
||||
return fmt.Errorf("Error reading Disk: %s", err)
|
||||
}
|
||||
if err := d.Set("creation_timestamp", flattenComputeDiskCreationTimestamp(res["creationTimestamp"])); err != nil {
|
||||
return fmt.Errorf("Error reading Disk: %s", err)
|
||||
}
|
||||
|
@ -636,15 +638,17 @@ func resourceComputeDiskUpdate(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
d.Partial(true)
|
||||
|
||||
if d.HasChange("labels") {
|
||||
if d.HasChange("label_fingerprint") || d.HasChange("labels") {
|
||||
labelFingerprintProp := d.Get("label_fingerprint")
|
||||
labelsProp, err := expandComputeDiskLabels(d.Get("labels"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
obj = map[string]interface{}{
|
||||
"labelFingerprint": labelFingerprintProp,
|
||||
"labels": labelsProp,
|
||||
"labelFingerprint": d.Get("label_fingerprint").(string)}
|
||||
}
|
||||
url, err = replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/zones/{{zone}}/disks/{{name}}/setLabels")
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -667,6 +671,7 @@ func resourceComputeDiskUpdate(d *schema.ResourceData, meta interface{}) error {
|
|||
return err
|
||||
}
|
||||
|
||||
d.SetPartial("label_fingerprint")
|
||||
d.SetPartial("labels")
|
||||
}
|
||||
if d.HasChange("size") {
|
||||
|
@ -834,6 +839,10 @@ func resourceComputeDiskImport(d *schema.ResourceData, meta interface{}) ([]*sch
|
|||
return []*schema.ResourceData{d}, nil
|
||||
}
|
||||
|
||||
func flattenComputeDiskLabelFingerprint(v interface{}) interface{} {
|
||||
return v
|
||||
}
|
||||
|
||||
func flattenComputeDiskCreationTimestamp(v interface{}) interface{} {
|
||||
return v
|
||||
}
|
||||
|
@ -1140,7 +1149,5 @@ func resourceComputeDiskDecoder(d *schema.ResourceData, meta interface{}, res ma
|
|||
res["sourceSnapshotEncryptionKey"] = transformed
|
||||
}
|
||||
|
||||
d.Set("label_fingerprint", res["labelFingerprint"])
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
|
|
@ -187,6 +187,9 @@ The `source_snapshot_encryption_key` block supports:
|
|||
|
||||
In addition to the arguments listed above, the following computed attributes are exported:
|
||||
|
||||
* `label_fingerprint` -
|
||||
The fingerprint used for optimistic locking of this resource. Used
|
||||
internally during updates.
|
||||
* `creation_timestamp` -
|
||||
Creation timestamp in RFC3339 text format.
|
||||
* `last_attach_timestamp` -
|
||||
|
@ -216,8 +219,6 @@ In addition to the arguments listed above, the following computed attributes are
|
|||
`disk_encryption_key.sha256`. It is deprecated to enhance
|
||||
consistency with `source_image_encryption_key` and
|
||||
`source_snapshot_encryption_key`.
|
||||
* `label_fingerprint`: The fingerprint of the assigned labels. Provided
|
||||
when labels are updated to prevent contention (first-write-wins).
|
||||
## Timeouts
|
||||
|
||||
This resource provides the following
|
||||
|
|
Loading…
Reference in New Issue
Block a user