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

aws-sdk-go-v2 0.30.0 update #20

Merged
merged 1 commit into from
Dec 9, 2020
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
14 changes: 7 additions & 7 deletions eventbridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (e *eventbridgeClient) testEventPattern(ctx context.Context, inputEvent, ev
return err
}

if *res.Result == false {
if res.Result == false {
log.Printf("%s: %s", *r.Name, color.RedString("✘"))
continue
}
Expand Down Expand Up @@ -84,7 +84,7 @@ func (e *eventbridgeClient) createRule(ctx context.Context, eventPattern string)
func (e *eventbridgeClient) deleteRule(ctx context.Context) error {
_, err := e.client.DeleteRule(ctx, &eventbridge.DeleteRuleInput{
EventBusName: aws.String(e.eventBusName),
Force: aws.Bool(true),
Force: true,
Name: aws.String(namespace + "-" + runID),
})
if err != nil {
Expand All @@ -108,7 +108,7 @@ func (e *eventbridgeClient) putEvent(ctx context.Context, event string) error {
}

resp, err := e.client.PutEvents(ctx, &eventbridge.PutEventsInput{
Entries: []*types.PutEventsRequestEntry{
Entries: []types.PutEventsRequestEntry{
{
Source: aws.String(ev.Source),
Detail: aws.String(ev.Detail),
Expand All @@ -121,7 +121,7 @@ func (e *eventbridgeClient) putEvent(ctx context.Context, event string) error {
return err
}

if *resp.FailedEntryCount > 0 {
if resp.FailedEntryCount > 0 {
return fmt.Errorf("%s", *resp.Entries[0].ErrorMessage)
}

Expand All @@ -132,7 +132,7 @@ func (e *eventbridgeClient) putTarget(ctx context.Context, sqsArn string) error
_, err := e.client.PutTargets(ctx, &eventbridge.PutTargetsInput{
Rule: aws.String(namespace + "-" + runID),
EventBusName: aws.String(e.eventBusName),
Targets: []*types.Target{
Targets: []types.Target{
{
Id: aws.String(namespace + "-" + runID),
Arn: aws.String(sqsArn),
Expand All @@ -149,8 +149,8 @@ func (e *eventbridgeClient) putTarget(ctx context.Context, sqsArn string) error

func (e *eventbridgeClient) removeTarget(ctx context.Context) error {
_, err := e.client.RemoveTargets(ctx, &eventbridge.RemoveTargetsInput{
Ids: []*string{
aws.String(namespace + "-" + runID),
Ids: []string{
namespace + "-" + runID,
},
Rule: aws.String(namespace + "-" + runID),
EventBusName: aws.String(e.eventBusName),
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ go 1.13

require (
github.com/TylerBrock/colorjson v0.0.0-20200706003622-8a50f05110d2
github.com/aws/aws-sdk-go-v2 v0.29.0
github.com/aws/aws-sdk-go-v2/config v0.2.2
github.com/aws/aws-sdk-go-v2/service/eventbridge v0.29.0
github.com/aws/aws-sdk-go-v2/service/sqs v0.29.0
github.com/aws/aws-sdk-go-v2 v0.30.0
github.com/aws/aws-sdk-go-v2/config v0.3.0
github.com/aws/aws-sdk-go-v2/service/eventbridge v0.30.0
github.com/aws/aws-sdk-go-v2/service/sqs v0.30.0
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.10.0
Expand All @@ -17,8 +17,8 @@ require (
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/stretchr/testify v1.5.1
github.com/urfave/cli/v2 v2.3.0
golang.org/x/sys v0.0.0-20201112073958-5cba982894dd // indirect
golang.org/x/sys v0.0.0-20201207223542-d4d67f95c62d // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/yaml.v2 v2.3.0
gopkg.in/yaml.v2 v2.4.0
)
21 changes: 21 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,36 @@ github.com/TylerBrock/colorjson v0.0.0-20200706003622-8a50f05110d2 h1:ZBbLwSJqkH
github.com/TylerBrock/colorjson v0.0.0-20200706003622-8a50f05110d2/go.mod h1:VSw57q4QFiWDbRnjdX8Cb3Ow0SFncRw+bA/ofY6Q83w=
github.com/aws/aws-sdk-go-v2 v0.29.0 h1:V/KKvuMO2hwHRg2SXJc5aasBHhD1AWbS6KMWg/Ueq1w=
github.com/aws/aws-sdk-go-v2 v0.29.0/go.mod h1:4d1/Ee0vCwCF7BfG1hCT3zu82493cRy5+VZ8JHvMPf0=
github.com/aws/aws-sdk-go-v2 v0.30.0 h1:/CjXUnWXnvdgOqHa65UIs2TODa5D5lm3ty7O0wWuYHY=
github.com/aws/aws-sdk-go-v2 v0.30.0/go.mod h1:vEDjzdktTH+FoEOV6BWgYLEzvPti13Onp5/qQrSiLPg=
github.com/aws/aws-sdk-go-v2/config v0.2.2 h1:CBZGPlpL5h+BDoNBNTgypqMxlWgCome/O/i8gdjaOtE=
github.com/aws/aws-sdk-go-v2/config v0.2.2/go.mod h1:rty/i5U/IiXxO4kQmSXKwneNiTVqCxYVoO5BVXjCbfY=
github.com/aws/aws-sdk-go-v2/config v0.3.0 h1:Vl7ljyGdyZ6AK/WaqHPpweS3xE8OVKQcwU3kt99ofYU=
github.com/aws/aws-sdk-go-v2/config v0.3.0/go.mod h1:grBHx/eKZPbNpGcmntBEu97/nUGCDHfjPhIyJx0e1lc=
github.com/aws/aws-sdk-go-v2/credentials v0.1.4 h1:ReVvyoYW/HriCnCWMoWC2ftvh0g9U4wS7lB5GFYK/ZE=
github.com/aws/aws-sdk-go-v2/credentials v0.1.4/go.mod h1:o0z92KOE6YJ/DyGSJmt83dG9YlGUc2n04QYwbfNsA8Q=
github.com/aws/aws-sdk-go-v2/credentials v0.1.5 h1:yPU5tFqRUJoO8RT4vp5O6AINP+W3kN6xHxukDJY0nZY=
github.com/aws/aws-sdk-go-v2/credentials v0.1.5/go.mod h1:DvGY5cZFiPbp++xv8eco5ZF3bO7jp67QuL0OzaChnVQ=
github.com/aws/aws-sdk-go-v2/ec2imds v0.1.4 h1:N3atV6naU7rFtS3gg/XU2ZuiPqzFm3HONBbnGDdPq1A=
github.com/aws/aws-sdk-go-v2/ec2imds v0.1.4/go.mod h1:h5WB2P4CTnVroyw/gvIiyMTtl/zvnKAC4H74EWiKOco=
github.com/aws/aws-sdk-go-v2/ec2imds v0.1.5 h1:9vrHx+lXUiFAFHq8n6W/p7XEJ3gGPjFI+CIu243PXbE=
github.com/aws/aws-sdk-go-v2/ec2imds v0.1.5/go.mod h1:DPESW4tlbYYOFLmRThVEKSWsux39VKDIG+5DMKCyoII=
github.com/aws/aws-sdk-go-v2/service/eventbridge v0.29.0 h1:FqJaQnCK2YGmSPpsDIXsDat2aCWghSsQWcDzkmem4C4=
github.com/aws/aws-sdk-go-v2/service/eventbridge v0.29.0/go.mod h1:voUpOTpn1UBEB48McyxaXdqqdmwhEdl0n9lpDjoZq0E=
github.com/aws/aws-sdk-go-v2/service/eventbridge v0.30.0 h1:P+Pf4KHjVYNoKxiW2uXD3ogyltZ6VgSGWIPSIk8DYSM=
github.com/aws/aws-sdk-go-v2/service/eventbridge v0.30.0/go.mod h1:2sP3ur3l+UUeflV0GoAaKFO+4E18QqPO2phMLDioMHk=
github.com/aws/aws-sdk-go-v2/service/sqs v0.29.0 h1:tNUvLwVXDkJB6esfAcYhW68P/q12Vt8B0GgjbmpWubQ=
github.com/aws/aws-sdk-go-v2/service/sqs v0.29.0/go.mod h1:JCxLIhmZPNP/RY5R07RcwbofC2tMhx+V5uc8/ZiWjs8=
github.com/aws/aws-sdk-go-v2/service/sqs v0.30.0 h1:Ptdzb9rMAyWiQDpf9cLrbsgZ8uyJwQYOi+OXDx+hx/g=
github.com/aws/aws-sdk-go-v2/service/sqs v0.30.0/go.mod h1:bcxQMgQgSOko40uXW5515253s89mqIKQ4xZYrIo4SUI=
github.com/aws/aws-sdk-go-v2/service/sts v0.29.0 h1:EOEsrzOQh+xU4lKbrkRoTybsP704I32GczRFsW6apEw=
github.com/aws/aws-sdk-go-v2/service/sts v0.29.0/go.mod h1:zV0Fx4GE1wPZJ3iHn1g7UxoPb+uJfqOkvBp3UQAq3bc=
github.com/aws/aws-sdk-go-v2/service/sts v0.30.0 h1:uLJi5/2SHMRarGhWegpzTLNmLWfQHDh38jJz4My1DZM=
github.com/aws/aws-sdk-go-v2/service/sts v0.30.0/go.mod h1:Lef/s/jQBl/f4DXNdq1UhxmjuLrLK1t1a/cJPbeYo20=
github.com/awslabs/smithy-go v0.3.0 h1:I1EQ1P+VtxpuNnGYymATewaKrlnaYQwFvO8lNTsafbs=
github.com/awslabs/smithy-go v0.3.0/go.mod h1:hPOQwnmBLHsUphH13tVSjQhTAFma0/0XoZGbBcOuABI=
github.com/awslabs/smithy-go v0.4.0 h1:El0KyKn4zdM3pLuWJlgoeitQuu/mjwUPssr7L3xu3vs=
github.com/awslabs/smithy-go v0.4.0/go.mod h1:hPOQwnmBLHsUphH13tVSjQhTAFma0/0XoZGbBcOuABI=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
Expand All @@ -29,6 +45,7 @@ github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg=
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/google/go-cmp v0.4.1 h1:/exdXoGamhu5ONeUJH0deniYLWYvQwW66yvlfiiKTu0=
github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hokaccha/go-prettyjson v0.0.0-20190818114111-108c894c2c0e h1:0aewS5NTyxftZHSnFaJmWE5oCCrj4DyEXkAiMa1iZJM=
Expand Down Expand Up @@ -62,6 +79,8 @@ golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepx
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201112073958-5cba982894dd h1:5CtCZbICpIOFdgO940moixOPjc0178IU44m4EjOO5IY=
golang.org/x/sys v0.0.0-20201112073958-5cba982894dd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201207223542-d4d67f95c62d h1:MiWWjyhUzZ+jvhZvloX6ZrUsdEghn8a64Upd8EMHglE=
golang.org/x/sys v0.0.0-20201207223542-d4d67f95c62d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
Expand All @@ -77,3 +96,5 @@ gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
26 changes: 13 additions & 13 deletions sqs.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func newSQSClient(cfg aws.Config, accountID, queueName string) *sqsClient {
func (s *sqsClient) createQueue(ctx context.Context, ruleArn string) error {
resp, err := s.client.CreateQueue(ctx, &sqs.CreateQueueInput{
QueueName: aws.String(s.queueName),
Attributes: map[string]*string{
"Policy": aws.String(fmt.Sprintf(`{
Attributes: map[string]string{
"Policy": fmt.Sprintf(`{
"Version": "2012-10-17",
"Id": "%s",
"Statement": [{
Expand All @@ -59,7 +59,7 @@ func (s *sqsClient) createQueue(ctx context.Context, ruleArn string) error {
}
}
}]
}`, runID, s.arn, ruleArn)),
}`, runID, s.arn, ruleArn),
},
})
if err != nil {
Expand Down Expand Up @@ -98,9 +98,9 @@ func (s *sqsClient) pollQueue(ctx context.Context, signalChan chan os.Signal, pr
default:
resp, err := s.client.ReceiveMessage(ctx, &sqs.ReceiveMessageInput{
QueueUrl: aws.String(s.queueURL),
MaxNumberOfMessages: aws.Int32(10),
WaitTimeSeconds: aws.Int32(5),
MessageAttributeNames: []*string{aws.String("All")},
MaxNumberOfMessages: 10,
WaitTimeSeconds: 5,
MessageAttributeNames: []string{"All"},
})
// handle recovery from 'dial tcp' errors
if err != nil && strings.Contains(err.Error(), "dial tcp") {
Expand All @@ -120,9 +120,9 @@ func (s *sqsClient) pollQueue(ctx context.Context, signalChan chan os.Signal, pr
continue
}

entries := []*types.DeleteMessageBatchRequestEntry{}
entries := []types.DeleteMessageBatchRequestEntry{}
for _, m := range resp.Messages {
entries = append(entries, &types.DeleteMessageBatchRequestEntry{
entries = append(entries, types.DeleteMessageBatchRequestEntry{
Id: m.MessageId,
ReceiptHandle: m.ReceiptHandle,
})
Expand Down Expand Up @@ -171,9 +171,9 @@ func (s *sqsClient) pollQueueCI(ctx context.Context, signalChan chan os.Signal,
default:
resp, err := s.client.ReceiveMessage(ctx, &sqs.ReceiveMessageInput{
QueueUrl: aws.String(s.queueURL),
MaxNumberOfMessages: aws.Int32(10),
WaitTimeSeconds: aws.Int32(5),
MessageAttributeNames: []*string{aws.String("All")},
MaxNumberOfMessages: 10,
WaitTimeSeconds: 5,
MessageAttributeNames: []string{"All"},
})
if err != nil {
log.Printf("sqs.ReceiveMessage error: %s", err)
Expand All @@ -184,9 +184,9 @@ func (s *sqsClient) pollQueueCI(ctx context.Context, signalChan chan os.Signal,
continue
}

entries := []*types.DeleteMessageBatchRequestEntry{}
entries := []types.DeleteMessageBatchRequestEntry{}
for _, m := range resp.Messages {
entries = append(entries, &types.DeleteMessageBatchRequestEntry{
entries = append(entries, types.DeleteMessageBatchRequestEntry{
Id: m.MessageId,
ReceiptHandle: m.ReceiptHandle,
})
Expand Down
8 changes: 4 additions & 4 deletions sqs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type mockSQSclient struct {
err error

queueURL *string
receiveMessages []*types.Message
receiveMessages []types.Message
}

const (
Expand Down Expand Up @@ -174,7 +174,7 @@ func Test_pollQueue(t *testing.T) {
{
name: "poll SQS queue",
client: &mockSQSclient{
receiveMessages: []*types.Message{
receiveMessages: []types.Message{
{
MessageId: aws.String("dc909f9a-377b-cc13-627d-6fdbc2ea458c"),
Body: aws.String(`{"detail-type":"Tag Change on Resource","source":"aws.tag"}`),
Expand All @@ -186,14 +186,14 @@ func Test_pollQueue(t *testing.T) {
{
name: "poll SQS queue - no messages",
client: &mockSQSclient{
receiveMessages: []*types.Message{},
receiveMessages: []types.Message{},
},
err: false,
},
{
name: "poll SQS queue - prettyJSON",
client: &mockSQSclient{
receiveMessages: []*types.Message{
receiveMessages: []types.Message{
{
MessageId: aws.String("dc909f9a-377b-cc13-627d-6fdbc2ea458c"),
Body: aws.String(`{"detail-type":"Tag Change on Resource","source":"aws.tag"}`),
Expand Down