mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-28 22:16:04 +00:00
Allow unlinking of billing account. (#138)
* Allow unlinking of billing account. Closes #133 * Add acceptance test for unlinking the billing account. * Just apply the resource definition without the billing account instead of setting an empty billing account.
This commit is contained in:
parent
23929e80f5
commit
e6e91ecbed
@ -200,8 +200,9 @@ func resourceGoogleProjectUpdate(d *schema.ResourceData, meta interface{}) error
|
||||
// Billing account has changed
|
||||
if ok := d.HasChange("billing_account"); ok {
|
||||
name := d.Get("billing_account").(string)
|
||||
ba := cloudbilling.ProjectBillingInfo{
|
||||
BillingAccountName: "billingAccounts/" + name,
|
||||
ba := cloudbilling.ProjectBillingInfo{}
|
||||
if name != "" {
|
||||
ba.BillingAccountName = "billingAccounts/" + name
|
||||
}
|
||||
_, err = config.clientBilling.Projects.UpdateBillingInfo(prefixedProject(pid), &ba).Do()
|
||||
if err != nil {
|
||||
|
@ -115,6 +115,13 @@ func TestAccGoogleProject_updateBilling(t *testing.T) {
|
||||
testAccCheckGoogleProjectHasBillingAccount("google_project.acceptance", pid, billingId2),
|
||||
),
|
||||
},
|
||||
// Unlink the billing account
|
||||
resource.TestStep{
|
||||
Config: testAccGoogleProject_create(pid, pname, org),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckGoogleProjectHasBillingAccount("google_project.acceptance", pid, ""),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user