Skip to content

Commit

Permalink
In logging batched requests, use slightly fewer quotes / escapes. (ha…
Browse files Browse the repository at this point in the history
…shicorp#5308)

Fixes hashicorp#7628.
Equally clear in the worst case, but less escaping most of the time.

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician committed Oct 12, 2021
1 parent 8d91965 commit b897927
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/5308.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
iam: fixed request batching bug where failed requests would show unnecessary backslash escaping to the user.
```
5 changes: 3 additions & 2 deletions google/batcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package google
import (
"context"
"fmt"
"github.com/hashicorp/errwrap"
"log"
"sync"
"time"

"github.com/hashicorp/errwrap"
)

const defaultBatchSendIntervalSec = 3
Expand Down Expand Up @@ -177,7 +178,7 @@ func (b *RequestBatcher) SendRequestWithTimeout(batchKey string, request *BatchR
case resp := <-respCh:
if resp.err != nil {
return nil, errwrap.Wrapf(
fmt.Sprintf("Request %q returned error: {{err}}", request.DebugId),
fmt.Sprintf("Request `%s` returned error: {{err}}", request.DebugId),
resp.err)
}
return resp.body, nil
Expand Down
2 changes: 1 addition & 1 deletion google/resource_iam_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func resourceIamMemberCreate(newUpdaterFunc newResourceIamUpdaterFunc, enableBat
}
if enableBatching {
err = BatchRequestModifyIamPolicy(updater, modifyF, config,
fmt.Sprintf("Create IAM Members %s %+v for %q", memberBind.Role, memberBind.Members[0], updater.DescribeResource()))
fmt.Sprintf("Create IAM Members %s %+v for %s", memberBind.Role, memberBind.Members[0], updater.DescribeResource()))
} else {
err = iamPolicyReadModifyWrite(updater, modifyF)
}
Expand Down

0 comments on commit b897927

Please sign in to comment.