-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add billing subaccount #2640
Add billing subaccount #2640
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@googlebot I signed it! |
Hello! I am a robot who works on Magic Modules PRs. I have detected that you are a community contributor, so your PR will be assigned to someone with a commit-bit on this repo for initial review. They will authorize it to run through our CI pipeline, which will generate downstream PRs. Thanks for your contribution! A human will be with you soon. @rambleraptor, please review this PR or find an appropriate assignee. |
Hello! Thanks for the PR. I've added @rileykarson who can better help get this merged in. Before we begin, we have to make sure that @googlebot recognizes that you've signed the CLA. I'm hoping that tagging it will cause it to kick off again. |
@googlebot I signed 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.
I made a first pass, leaning fairly nitpicky for consistency with other provider resource files.
Are you able to add an acceptance test? https://github.com/terraform-providers/terraform-provider-google/blob/master/google/resource_compute_address_generated_test.go is a good reference for what most acceptance tests look like, while https://github.com/terraform-providers/terraform-provider-google/blob/master/google/resource_google_billing_account_iam_test.go is a good example of how to work with billing accounts.
third_party/terraform/resources/resource_google_billing_subaccount.go
Outdated
Show resolved
Hide resolved
third_party/terraform/resources/resource_google_billing_subaccount.go
Outdated
Show resolved
Hide resolved
third_party/terraform/resources/resource_google_billing_subaccount.go
Outdated
Show resolved
Hide resolved
third_party/terraform/resources/resource_google_billing_subaccount.go
Outdated
Show resolved
Hide resolved
third_party/terraform/resources/resource_google_billing_subaccount.go
Outdated
Show resolved
Hide resolved
third_party/terraform/website/docs/r/google_billing_subaccount.html.markdown
Outdated
Show resolved
Hide resolved
third_party/terraform/website/docs/r/google_billing_subaccount.html.markdown
Show resolved
Hide resolved
third_party/terraform/website/docs/r/google_billing_subaccount.html.markdown
Show resolved
Hide resolved
@rileykarson I'll take a try at adding an acceptance test and go through your comments. I'm not sure what the deal with the CLA is, a Corporate CLA was signed last week and I am a member of the group. |
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.
Can you confirm that the email listed on the second line at https://github.com/GoogleCloudPlatform/magic-modules/commit/f865406be26aa27c14f1fb7558d406f1ffeea162.patch is the email covered by your corporate CLA?
Since these changes are to a third_party
directory the CLA doesn't actually apply. I'd slightly prefer that the bot is happy, but it's not strictly necessary.
@rileykarson I have made changes based on your comments and wrote some tests. As far as the CLA, we had an authorized signer fill out the form late last week, but it looks like it hasn't been approved fully yet. |
@rileykarson @adarobin are ye still haggling on the CLA yet ? Any plans to progress this ? |
@sokoow I am still pushing for the CLA on my end. I believe it was close, but then all of this COVID-19 stuff happened. |
respect, keep us posted pls |
third_party/terraform/website/docs/r/google_billing_subaccount.html.markdown
Outdated
Show resolved
Hide resolved
@googlebot I signed it! |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
@rileykarson Finally have a CLA, what are my next steps? |
@samos123 Just realized I didn't ping you too, I have the CLA now! |
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.
Thanks for picking this back up! I've made a review pass. Sorry if any of it conflicts with previous comments of mine, it's been a while 🙂
third_party/terraform/website/docs/r/google_billing_subaccount.html.markdown
Outdated
Show resolved
Hide resolved
third_party/terraform/website/docs/r/google_billing_subaccount.html.markdown
Outdated
Show resolved
Hide resolved
third_party/terraform/resources/resource_google_billing_subaccount.go
Outdated
Show resolved
Hide resolved
third_party/terraform/resources/resource_google_billing_subaccount.go
Outdated
Show resolved
Hide resolved
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"rename_on_destroy": { |
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.
Instead of {{action}}_on_destroy
, can you call this field deletion_policy
and allow ""
and "RENAME_ON_DESTROY"
to be specified? https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_user#deletion_policy is a good model, where we've done the same.
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 looked at that resource and I think I have implemented it as you have requested
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
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'm working on getting a test master billing account, I'll get back to this once I've done so. I've submitted a ticket- that hopefully won't be long!
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.
Alright, environment set up. _basic
succeeded, _renameOnDestroy
failed- I think it's just because we're still using the old rename_on_destroy
field (inline).
third_party/terraform/tests/resource_google_billing_subaccount_test.go
Outdated
Show resolved
Hide resolved
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
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.
Alright, just a couple of lint errors left. Sorry for not catching these in my prior pass! I lost track when digging into registering a parent billing account.
==> Checking source code against linters...
google/resource_google_billing_subaccount.go:96:7: Error return value of `d.Set` is not checked (errcheck)
d.Set("name", billingAccount.Name)
^
google/resource_google_billing_subaccount.go:97:7: Error return value of `d.Set` is not checked (errcheck)
d.Set("display_name", billingAccount.DisplayName)
^
google/resource_google_billing_subaccount.go:98:7: Error return value of `d.Set` is not checked (errcheck)
d.Set("open", billingAccount.Open)
^
google/resource_google_billing_subaccount.go:99:7: Error return value of `d.Set` is not checked (errcheck)
d.Set("master_billing_account", billingAccount.MasterBillingAccount)
^
google/resource_google_billing_subaccount.go:100:7: Error return value of `d.Set` is not checked (errcheck)
d.Set("billing_account_id", strings.TrimPrefix(d.Get("name").(string), "billingAccounts/"))
^
google/resource_google_billing_subaccount_test.go:92:6: `testAccBillingSubccount_updateRenameOnDestroy` is unused (deadcode)
func testAccBillingSubccount_updateRenameOnDestroy(masterBillingAccountId string) string {
^
make: *** [lint] Error 1
`, masterBillingAccountId) | ||
} | ||
|
||
func testAccBillingSubccount_updateRenameOnDestroy(masterBillingAccountId string) string { |
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 is unused, and can be removed.
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.
removed testAccBillingSubccount_updateRenameOnDestroy
return handleNotFoundError(err, d, fmt.Sprintf("Billing Subaccount Not Found : %s", id)) | ||
} | ||
|
||
d.Set("name", billingAccount.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.
Mind checking the error returned from these d.Set
calls, and returning a message including the field name if there's a problem? Like in https://github.com/hashicorp/terraform-provider-google-beta/blob/master/google-beta/resource_container_cluster.go#L1584.
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.
added error checking for d.Set
calls
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
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.
LGTM. Thanks @adarobin!
Hi
nvm https://cloud.google.com/billing/docs/reference/rest/v1/billingAccounts#BillingAccount |
This implements a new
google_billing_subaccount
resource and would close hashicorp/terraform-provider-google#4033Release Note Template for Downstream PRs (will be copied)