-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Release Disk resource - autogenerated. #1521
Release Disk resource - autogenerated. #1521
Conversation
Running tests in the cloud now. :) |
Tests pass:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, lots of stuff going on here. This is a big deal though, thanks!
google/resource_compute_disk.go
Outdated
Type: schema.TypeString, | ||
Optional: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name should be required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Type: schema.TypeString, | ||
Optional: true, | ||
ForceNew: true, | ||
DiffSuppressFunc: diskImageDiffSuppress, | ||
}, | ||
|
||
"project": &schema.Schema{ | ||
"type": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this had a default before, probably best to keep it there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks for the catch.
}, | ||
CustomizeDiff: customdiff.All( | ||
customdiff.ForceNewIfChange("size", isDiskShrinkage)), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isDiskShrinkage customizediff doesn't seem to have made it in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done - I forgot, I added that after I started working on Disk generation. 🤦♂️
google/resource_compute_disk.go
Outdated
return new.(int) < old.(int) | ||
} | ||
d.SetId(id) | ||
if zone, err := getZone(d, config); err != nil || zone == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't mind a comment in here that explains what's going on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Man, me either. I had to figure it out all over again. Done.
google/resource_compute_disk.go
Outdated
// The raw key won't be returned, so we need to use the original. | ||
transformed["raw_key"] = d.Get("source_image_encryption_key.0.raw_key") | ||
transformed["sha256"] = original["sha256"] | ||
if v, ok := d.GetOk("disk_encryption_key_raw"); ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's diskEncryptionKey stuff hanging out here in the sourceImageEncryptionKey block (and below)- intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope! Screwed up transitioning from per-attribute decoders (where they were hidden in an if block) to whole-object decoders. And it didn't trip the unit test, hm.
|
||
- - - | ||
Add a persistent disk to your instance when you need reliable and | ||
affordable storage with consistent performance characteristics. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to add an example :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
If you specify this field along with sourceImage or sourceSnapshot, | ||
the value of sizeGb must not be less than the size of the sourceImage | ||
or the size of the snapshot. | ||
* `image` - |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a bunch of ways we allow specifying the image, this may need an override so we can put them in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
if err != nil { | ||
return nil, err | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to add something here too for snapshots
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right! Dang! How did you know that?
* `snapshot` - | ||
(Optional) | ||
The source snapshot used to create this disk. You can provide this as | ||
a partial or full URL to the resource. For example, the following are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we also allow just the snapshot name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
* `self_link` - The URI of the created resource. | ||
|
||
* `users` - The Users of the created resource. | ||
|
||
* `label_fingerprint` - The fingerprint of the assigned labels. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
label_fingerprint should be added to the docs too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WHEW. Thank you for the detailed review - I completely forgot to look at the docs, and the tests didn't catch any of those issues. Fixed everything you mentioned, it's all working its way through generation now.
google/resource_compute_disk.go
Outdated
Type: schema.TypeString, | ||
Optional: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Type: schema.TypeString, | ||
Optional: true, | ||
ForceNew: true, | ||
DiffSuppressFunc: diskImageDiffSuppress, | ||
}, | ||
|
||
"project": &schema.Schema{ | ||
"type": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks for the catch.
}, | ||
CustomizeDiff: customdiff.All( | ||
customdiff.ForceNewIfChange("size", isDiskShrinkage)), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done - I forgot, I added that after I started working on Disk generation. 🤦♂️
google/resource_compute_disk.go
Outdated
return new.(int) < old.(int) | ||
} | ||
d.SetId(id) | ||
if zone, err := getZone(d, config); err != nil || zone == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Man, me either. I had to figure it out all over again. Done.
if err != nil { | ||
return nil, err | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right! Dang! How did you know that?
|
||
- - - | ||
Add a persistent disk to your instance when you need reliable and | ||
affordable storage with consistent performance characteristics. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! Added to docs
. That'll be useful for the interconnect, too.
|
||
- - - | ||
Add a persistent disk to your instance when you need reliable and | ||
affordable storage with consistent performance characteristics. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
If you specify this field along with sourceImage or sourceSnapshot, | ||
the value of sizeGb must not be less than the size of the sourceImage | ||
or the size of the snapshot. | ||
* `image` - |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
* `snapshot` - | ||
(Optional) | ||
The source snapshot used to create this disk. You can provide this as | ||
a partial or full URL to the resource. For example, the following are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
* `self_link` - The URI of the created resource. | ||
|
||
* `users` - The Users of the created resource. | ||
|
||
* `label_fingerprint` - The fingerprint of the assigned labels. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
3e7c021
to
2cbbb37
Compare
google/resource_compute_disk.go
Outdated
original := v.(map[string]interface{}) | ||
transformed := make(map[string]interface{}) | ||
// The raw key won't be returned, so we need to use the original. | ||
transformed["raw_key"] = d.Get("disk_encryption_key.0.raw_key") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these have to be rawKey
to match what the flatteners are expecting.
On another note, it would be great to have tests for some of these trickier spots.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shoot, forgot that the flatteners get called here. Writing more, better tests.
(Optional) | ||
Specifies a 256-bit customer-supplied encryption key, encoded in | ||
RFC 4648 base64 to either encrypt or decrypt this resource. | ||
* `sha256` - |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, should this be in the Attributes Reference
section?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this was the right place for it. Do you mean because it's computed? Hm. That introduces a challenge for generating the docs, but of course it's doable.
- `create` - (Default `5 minutes`) Used for creating disks. | ||
- `update` - (Default `5 minutes`) Used for resizing a disk and setting labels on disks. | ||
- `delete` - (Default `5 minutes`) Used for destroying disks (not including time to detach the disk from instances). | ||
- `create` - Default is 4 minutes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, the actual resource is showing 5 minutes. I think I fixed this in the redis pr so you might just need to merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merged.
f939e9d
to
3bbc975
Compare
@danawillow There's a test for the encryption stuff (which has changed in order to make the new test pass. :) ) |
@@ -332,6 +332,26 @@ func TestAccComputeDisk_encryption(t *testing.T) { | |||
"google_compute_disk.foobar", &disk), | |||
), | |||
}, | |||
// Update from top-level attribute to nested. | |||
resource.TestStep{ | |||
Config: testAccComputeDisk_encryptionMigrate(diskName), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test passes, but I don't think it's actually doing what you were intending:
DESTROY/CREATE: google_compute_disk.foobar
creation_timestamp: "2018-05-31T11:28:11.935-07:00" => "<computed>"
disk_encryption_key.0.sha256: "esTuF7d4eatX4cnc4JsiEiaI+Rff78JgPhA/v1zxX9E=" => "<computed>"
disk_encryption_key_raw: "SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0=" => "" (forces new resource)
disk_encryption_key_sha256: "esTuF7d4eatX4cnc4JsiEiaI+Rff78JgPhA/v1zxX9E=" => "<computed>"
image: "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-8-jessie-v20160803" => "debian-8-jessie-v20160803"
label_fingerprint: "42WmSpB8rSM=" => "<computed>"
last_attach_timestamp: "" => "<computed>"
last_detach_timestamp: "" => "<computed>"
name: "tf-test-wyqure0ffb" => "tf-test-wyqure0ffb"
project: "graphite-test-danahoffman-tf" => "<computed>"
self_link: "https://www.googleapis.com/compute/v1/projects/graphite-test-danahoffman-tf/zones/us-central1-a/disks/tf-test-wyqure0ffb" => "<computed>"
size: "50" => "50"
source_image_id: "675642609008260682" => "<computed>"
source_snapshot_id: "" => "<computed>"
type: "pd-ssd" => "pd-ssd"
users.#: "0" => "<computed>"
zone: "us-central1-a" => "us-central1-a"
4073b32
to
28c556f
Compare
Okay, that should do it. It doesn't seem to recreate the resource anymore! |
e7013d5
to
bdb824e
Compare
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
/cc @ndmckinley