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

Release Disk resource - autogenerated. #1521

Merged
merged 2 commits into from
Jun 1, 2018

Conversation

modular-magician
Copy link
Collaborator

@nat-henderson
Copy link
Contributor

Running tests in the cloud now. :)

@nat-henderson nat-henderson requested a review from danawillow May 22, 2018 22:11
@nat-henderson
Copy link
Contributor

Tests pass:

==> Checking that code complies with gofmt requirements...                     
TF_ACC=1 go test ./google -v -run=TestAccComputeDisk -timeout 120m             
=== RUN   TestAccComputeDisk_imageDiffSuppressPublicVendorsFamilyNames         
=== RUN   TestAccComputeDisk_basic     
=== RUN   TestAccComputeDisk_timeout   
=== RUN   TestAccComputeDisk_update    
=== RUN   TestAccComputeDisk_fromSnapshot                                      
=== RUN   TestAccComputeDisk_encryption                                        
=== RUN   TestAccComputeDisk_deleteDetach                                      
=== RUN   TestAccComputeDisk_deleteDetachIGM                                   
=== RUN   TestAccComputeDisk_computeDiskUserRegex                              
--- PASS: TestAccComputeDisk_computeDiskUserRegex (0.00s)                      
--- PASS: TestAccComputeDisk_imageDiffSuppressPublicVendorsFamilyNames (1.42s) 
--- PASS: TestAccComputeDisk_encryption (24.02s)                               
--- PASS: TestAccComputeDisk_timeout (0.04s)                                   
--- PASS: TestAccComputeDisk_update (45.89s)                                   
--- PASS: TestAccComputeDisk_basic (23.35s)                                    
--- PASS: TestAccComputeDisk_fromSnapshot (108.15s)                            
--- PASS: TestAccComputeDisk_deleteDetach (104.83s)                            
--- PASS: TestAccComputeDisk_deleteDetachIGM (485.19s)                         
PASS                                   
ok      github.com/terraform-providers/terraform-provider-google/google 485.206s          

Copy link
Contributor

@danawillow danawillow left a 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!

Type: schema.TypeString,
Optional: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name should be required

Copy link
Contributor

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": {
Copy link
Contributor

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

Copy link
Contributor

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)),
}
Copy link
Contributor

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

Copy link
Contributor

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. 🤦‍♂️

return new.(int) < old.(int)
}
d.SetId(id)
if zone, err := getZone(d, config); err != nil || zone == "" {
Copy link
Contributor

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

Copy link
Contributor

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.

// 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 {
Copy link
Contributor

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?

Copy link
Contributor

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.
Copy link
Contributor

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 :)

Copy link
Contributor

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` -
Copy link
Contributor

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

Copy link
Contributor

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
}

Copy link
Contributor

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

Copy link
Contributor

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
Copy link
Contributor

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

Copy link
Contributor

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.
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

@nat-henderson nat-henderson left a 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.

Type: schema.TypeString,
Optional: true,
Copy link
Contributor

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": {
Copy link
Contributor

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)),
}
Copy link
Contributor

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. 🤦‍♂️

return new.(int) < old.(int)
}
d.SetId(id)
if zone, err := getZone(d, config); err != nil || zone == "" {
Copy link
Contributor

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
}

Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

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` -
Copy link
Contributor

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
Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

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")
Copy link
Contributor

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.

Copy link
Contributor

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` -
Copy link
Contributor

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?

Copy link
Contributor

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.
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged.

@modular-magician modular-magician force-pushed the codegen-pr-209 branch 2 times, most recently from f939e9d to 3bbc975 Compare May 31, 2018 01:04
@nat-henderson
Copy link
Contributor

@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),
Copy link
Contributor

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"

@nat-henderson
Copy link
Contributor

Okay, that should do it. It doesn't seem to recreate the resource anymore!

@nat-henderson nat-henderson merged commit fd208dc into hashicorp:master Jun 1, 2018
chrisst pushed a commit to chrisst/terraform-provider-google that referenced this pull request Nov 9, 2018
@ghost
Copy link

ghost commented Nov 18, 2018

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!

@ghost ghost locked and limited conversation to collaborators Nov 18, 2018
@modular-magician modular-magician deleted the codegen-pr-209 branch November 16, 2024 20:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants