-
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
New data source: compute region instance group #851
New data source: compute region instance group #851
Conversation
Vet found suspicious constructs. Please check the reported constructs |
func dataSourceComputeRegionInstanceGroupRead(d *schema.ResourceData, meta interface{}) error { | ||
config := meta.(*Config) | ||
var project, region, name string | ||
// add self_link parsing here. |
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.
It looks like you've already added self_link parsing below
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.
Ha, true, removed.
Computed: true, | ||
}, | ||
|
||
"items": { |
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 tend to not pluralize field names (no always followed). Would that make more sense to call it instance
instead of item
?
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.
No strong feelings - I thought it would be best to stick to exactly the field names that come back from the /listInstances call. Do you prefer instance
to items
given that items
is what's used here?
https://cloud.google.com/compute/docs/reference/latest/regionInstanceGroups/listInstances
FWIW I agree that "items" is a lousy name! It's probably the least specific you can be about what's in the list.
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.
instance
is definitely better. I think actually the pluralized version would be better since it is read only.
people will use it for interpolation in their data source this way:
instance = "${data.google_compute_region_instance_group_manager.instances.0.self_link}"
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.
Agreed, and done.
@@ -110,6 +112,12 @@ func resourceComputeRegionInstanceGroupManager() *schema.Resource { | |||
Optional: true, | |||
}, | |||
|
|||
"wait_for_instances": &schema.Schema{ |
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.
Documentation for this
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.
} | ||
} | ||
}() | ||
select { |
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.
why using goroutine if you are blocking the main thread anyway here?
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.
In this case, because there are two goroutines - time.After() returns a channel that sends "true" after the duration specified. This serves as an (apparently) idiomatic timeout mechanism. I like it, but willing to reformulate it if you prefer. Definitely need to comment it.
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 could probably rely on state.WaitForState() and wait until the creating + creatingwhitoutretries is equal to 0.
It would be more consistent with the rest of the waiting logic in Terraform
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.
Aha, yes, state.WaitForState is a much better version of what I've written here. Will do!
…m in resourceComputeRegionInstanceGroupManagerCreate.
I really like the addition of the |
I think so! I've rewritten it to be extensible. I'll do that in a followup PR. |
|
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.
Just missing the documentation for this data source
Added docs - how can I preview them to make sure they look right? Also,
|
You can follow these instructions: |
page_title: "Google: google_compute_instance_group" | ||
sidebar_current: "docs-google-datasource-compute-instance-group" | ||
description: |- | ||
Get a Compute Region Instance Group within GCE. |
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 big feature is being able to list the instances inside the instance group. We should make that clear here.
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! Took a lot of tiny commits to test the website - sorry about the mess, of course I'll squash before I merge.
* Add new data source: compute region instance group manager's groups. * Add documentation for wait_for_instances and for the timeout mechanism in resourceComputeRegionInstanceGroupManagerCreate.
Signed-off-by: Modular Magician <magic-modules@google.com>
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 👉 hashibot-feedback@hashicorp.com. Thanks! |
This closes #765... I think! :) This is my first data source - let me know if I've missed something, please! The timeout logic I wrote in the manager resource could use some special attention since I'm relatively new to Go.