Skip to content

Commit

Permalink
If a router interface or peer is the last one, ensure it's removed. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nat-henderson authored Aug 16, 2018
1 parent a79fbac commit 0909aa5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions google/resource_compute_router_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions google/resource_compute_router_peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0909aa5

Please sign in to comment.