Skip to content

Commit

Permalink
ci: migrate to EndpointResolverV2 since old methods are deprecated
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Alvarez <[email protected]>
  • Loading branch information
pendo324 committed Aug 27, 2024
1 parent f5d8ed5 commit cc41870
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions e2e/awslogs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import (
"context"
"errors"
"fmt"
"net/url"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs"
"github.com/aws/smithy-go"
smithyendpoints "github.com/aws/smithy-go/endpoints"
"github.com/containerd/containerd/cio"
"github.com/google/uuid"
"github.com/onsi/ginkgo/v2"
Expand Down Expand Up @@ -44,23 +46,28 @@ const (
testAwslogsDatetimeFormat = "\\[%b %d, %Y %H:%M:%S\\]"
)

type cloudWatchEndpointResolver struct{}

func (cloudWatchEndpointResolver) ResolveEndpoint(
_ context.Context,
_ cloudwatchlogs.EndpointParameters,
) (smithyendpoints.Endpoint, error) {
uri, _ := url.Parse(testAwslogsEndpoint)
return smithyendpoints.Endpoint{
URI: *uri,
}, nil
}

var testAwslogs = func() {
// These tests are run in serial because we only define one log driver instance.
ginkgo.Describe("awslogs shim logger", ginkgo.Serial, func() {
var cwClient *cloudwatchlogs.Client
ginkgo.BeforeEach(func() {
// Reference to set up Go client for aws local stack: https://docs.localstack.cloud/user-guide/integrations/sdks/go/.
customResolver := aws.EndpointResolverWithOptionsFunc(func(_, _ string, _ ...interface{}) (aws.Endpoint, error) {
return aws.Endpoint{
PartitionID: "aws",
URL: testAwslogsEndpoint,
SigningRegion: testAwslogsRegion,
}, nil
})
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion(testAwslogsRegion),
config.WithEndpointResolverWithOptions(customResolver))
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion(testAwslogsRegion))
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
cwClient = cloudwatchlogs.NewFromConfig(cfg)
cwClient = cloudwatchlogs.NewFromConfig(cfg, func(opts *cloudwatchlogs.Options) {
opts.EndpointResolverV2 = cloudWatchEndpointResolver{}
})
deleteLogGroup(cwClient, testAwslogsGroup)
deleteLogGroup(cwClient, nonExistentAwslogsGroup)
_, err = cwClient.CreateLogGroup(context.TODO(), &cloudwatchlogs.CreateLogGroupInput{
Expand Down

0 comments on commit cc41870

Please sign in to comment.