Skip to content
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

change error wrap formatting #5607

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3089.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:none

```
10 changes: 5 additions & 5 deletions google/resource_google_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,14 @@ func resourceGoogleProjectCreate(d *schema.ResourceData, meta interface{}) error
if !d.Get("auto_create_network").(bool) {
// The compute API has to be enabled before we can delete a network.
if err = enableServiceUsageProjectServices([]string{"compute.googleapis.com"}, project.ProjectId, config, d.Timeout(schema.TimeoutCreate)); err != nil {
return errwrap.Wrapf("Error enabling the Compute Engine API required to delete the default network: ", err)
return errwrap.Wrapf("Error enabling the Compute Engine API required to delete the default network: {{err}} ", err)
}

if err = forceDeleteComputeNetwork(d, config, project.ProjectId, "default"); err != nil {
if isGoogleApiErrorWithCode(err, 404) {
log.Printf("[DEBUG] Default network not found for project %q, no need to delete it", project.ProjectId)
} else {
return errwrap.Wrapf(fmt.Sprintf("Error deleting default network in project %s: ", project.ProjectId), err)
return errwrap.Wrapf(fmt.Sprintf("Error deleting default network in project %s: {{err}}", project.ProjectId), err)
}
}
}
Expand Down Expand Up @@ -397,15 +397,15 @@ func forceDeleteComputeNetwork(d *schema.ResourceData, config *Config, projectId
filter := fmt.Sprintf("network eq %s", networkLink)
resp, err := config.clientCompute.Firewalls.List(projectId).Filter(filter).Do()
if err != nil {
return errwrap.Wrapf("Error listing firewall rules in proj:", err)
return errwrap.Wrapf("Error listing firewall rules in proj: {{err}}", err)
}

log.Printf("[DEBUG] Found %d firewall rules in %q network", len(resp.Items), networkName)

for _, firewall := range resp.Items {
op, err := config.clientCompute.Firewalls.Delete(projectId, firewall.Name).Do()
if err != nil {
return errwrap.Wrapf("Error deleting firewall: ", err)
return errwrap.Wrapf("Error deleting firewall: {{err}}", err)
}
err = computeOperationWait(config, op, projectId, "Deleting Firewall")
if err != nil {
Expand Down Expand Up @@ -456,7 +456,7 @@ func deleteComputeNetwork(project, network string, config *Config) error {
op, err := config.clientCompute.Networks.Delete(
project, network).Do()
if err != nil {
return errwrap.Wrapf("Error deleting network: ", err)
return errwrap.Wrapf("Error deleting network: {{err}}", err)
}

err = computeOperationWaitTime(config, op, project, "Deleting Network", 10)
Expand Down