Skip to content

Commit 967fa37

Browse files
committed
add context chaining to tags
1 parent f5f86fb commit 967fa37

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

pkg/providers/v1/create_tags_batch.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"sync"
2828
"time"
2929

30-
"github.com/aws/aws-sdk-go/service/ec2"
30+
"github.com/aws/aws-sdk-go-v2/service/ec2"
3131
)
3232

3333
// createTagsBatcher contains the batcher details
@@ -43,7 +43,7 @@ func newCreateTagsBatcher(ctx context.Context, ec2api iface.EC2) *createTagsBatc
4343
MaxTimeout: 1 * time.Second,
4444
MaxItems: 50,
4545
RequestHasher: createTagsHasher,
46-
BatchExecutor: execCreateTagsBatch(ec2api),
46+
BatchExecutor: execCreateTagsBatch(ctx, ec2api),
4747
}
4848
return &createTagsBatcher{batcher: batcher.NewBatcher(ctx, options)}
4949
}
@@ -67,7 +67,7 @@ func createTagsHasher(ctx context.Context, input *ec2.CreateTagsInput) uint64 {
6767
return hash
6868
}
6969

70-
func execCreateTagsBatch(ec2api iface.EC2) batcher.BatchExecutor[ec2.CreateTagsInput, ec2.CreateTagsOutput] {
70+
func execCreateTagsBatch(ctx context.Context, ec2api iface.EC2) batcher.BatchExecutor[ec2.CreateTagsInput, ec2.CreateTagsOutput] {
7171
return func(ctx context.Context, inputs []*ec2.CreateTagsInput) []batcher.Result[ec2.CreateTagsOutput] {
7272
results := make([]batcher.Result[ec2.CreateTagsOutput], len(inputs))
7373
firstInput := inputs[0]
@@ -80,7 +80,7 @@ func execCreateTagsBatch(ec2api iface.EC2) batcher.BatchExecutor[ec2.CreateTagsI
8080
Tags: firstInput.Tags,
8181
}
8282
klog.Infof("Batched create tags %v", batchedInput)
83-
output, err := ec2api.CreateTags(batchedInput)
83+
output, err := ec2api.CreateTags(ctx, batchedInput)
8484

8585
if err != nil {
8686
klog.Errorf("Error occurred trying to batch tag resources, trying individually, %v", err)
@@ -89,7 +89,7 @@ func execCreateTagsBatch(ec2api iface.EC2) batcher.BatchExecutor[ec2.CreateTagsI
8989
wg.Add(1)
9090
go func(input *ec2.CreateTagsInput) {
9191
defer wg.Done()
92-
out, err := ec2api.CreateTags(input)
92+
out, err := ec2api.CreateTags(ctx, input)
9393
results[idx] = batcher.Result[ec2.CreateTagsOutput]{Output: out, Err: err}
9494

9595
}(input)

pkg/providers/v1/delete_tags_batch.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"sync"
2828
"time"
2929

30-
"github.com/aws/aws-sdk-go/service/ec2"
30+
"github.com/aws/aws-sdk-go-v2/service/ec2"
3131
)
3232

3333
// deleteTagsBatcher contains the batcher details
@@ -43,7 +43,7 @@ func newDeleteTagsBatcher(ctx context.Context, ec2api iface.EC2) *deleteTagsBatc
4343
MaxTimeout: 1 * time.Second,
4444
MaxItems: 50,
4545
RequestHasher: deleteTagsHasher,
46-
BatchExecutor: execDeleteTagsBatch(ec2api),
46+
BatchExecutor: execDeleteTagsBatch(ctx, ec2api),
4747
}
4848
return &deleteTagsBatcher{batcher: batcher.NewBatcher(ctx, options)}
4949
}
@@ -67,7 +67,7 @@ func deleteTagsHasher(ctx context.Context, input *ec2.DeleteTagsInput) uint64 {
6767
return hash
6868
}
6969

70-
func execDeleteTagsBatch(ec2api iface.EC2) batcher.BatchExecutor[ec2.DeleteTagsInput, ec2.DeleteTagsOutput] {
70+
func execDeleteTagsBatch(ctx context.Context, ec2api iface.EC2) batcher.BatchExecutor[ec2.DeleteTagsInput, ec2.DeleteTagsOutput] {
7171
return func(ctx context.Context, inputs []*ec2.DeleteTagsInput) []batcher.Result[ec2.DeleteTagsOutput] {
7272
results := make([]batcher.Result[ec2.DeleteTagsOutput], len(inputs))
7373
firstInput := inputs[0]
@@ -80,7 +80,7 @@ func execDeleteTagsBatch(ec2api iface.EC2) batcher.BatchExecutor[ec2.DeleteTagsI
8080
Tags: firstInput.Tags,
8181
}
8282
klog.Infof("Batched delete tags %v", batchedInput)
83-
output, err := ec2api.DeleteTags(batchedInput)
83+
output, err := ec2api.DeleteTags(ctx, batchedInput)
8484

8585
if err != nil {
8686
klog.Errorf("Error occurred trying to batch tag resources, trying individually, %v", err)
@@ -89,7 +89,7 @@ func execDeleteTagsBatch(ec2api iface.EC2) batcher.BatchExecutor[ec2.DeleteTagsI
8989
wg.Add(1)
9090
go func(input *ec2.DeleteTagsInput) {
9191
defer wg.Done()
92-
out, err := ec2api.DeleteTags(input)
92+
out, err := ec2api.DeleteTags(ctx, input)
9393
results[idx] = batcher.Result[ec2.DeleteTagsOutput]{Output: out, Err: err}
9494

9595
}(input)

0 commit comments

Comments
 (0)