If a router interface or peer is the last one, ensure it's removed. (#1877)

This commit is contained in:
Nathan McKinley 2018-08-15 22:49:36 -07:00 committed by GitHub
parent a79fbac1c5
commit 0909aa5b20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -240,6 +240,10 @@ func resourceComputeRouterInterfaceDelete(d *schema.ResourceData, meta interface
Interfaces: newIfaces,
}
if len(newIfaces) == 0 {
patchRouter.ForceSendFields = append(patchRouter.ForceSendFields, "Interfaces")
}
log.Printf("[DEBUG] Updating router %s/%s with interfaces: %+v", region, routerName, newIfaces)
op, err := routersService.Patch(project, region, router.Name, patchRouter).Do()
if err != nil {

View File

@ -261,6 +261,10 @@ func resourceComputeRouterPeerDelete(d *schema.ResourceData, meta interface{}) e
BgpPeers: newPeers,
}
if len(newPeers) == 0 {
patchRouter.ForceSendFields = append(patchRouter.ForceSendFields, "BgpPeers")
}
log.Printf("[DEBUG] Updating router %s/%s with peers: %+v", region, routerName, newPeers)
op, err := routersService.Patch(project, region, router.Name, patchRouter).Do()
if err != nil {