From 53f6cbfe9be833fbf044dae33f874e0a39e4c6d8 Mon Sep 17 00:00:00 2001 From: sodkiewiczm Date: Tue, 24 Oct 2023 12:07:58 +0200 Subject: [PATCH 1/4] Configurable image name for localstack --- frContainers/runContainer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frContainers/runContainer.go b/frContainers/runContainer.go index 4e816a5..fbe4ee9 100644 --- a/frContainers/runContainer.go +++ b/frContainers/runContainer.go @@ -32,7 +32,7 @@ func RunLocalstackServices(ctx context.Context, services string) (testcontainers } func getLocalStackImage() string { - localstackImage := os.Getenv("TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX") + localstackImage := os.Getenv("TESTCONTAINERS_HUB_IMAGE_NAME") if len(localstackImage) != 0 { return localstackImage } From 17db49da3366742399fb7aec4dac07482ae93df0 Mon Sep 17 00:00:00 2001 From: sodkiewiczm Date: Mon, 19 Aug 2024 11:31:56 +0200 Subject: [PATCH 2/4] Upgrade dependencies --- .../BaseLocalstackIntegrationSuite.go | 15 +++ go.mod | 122 +++++++++++------- 2 files changed, 87 insertions(+), 50 deletions(-) diff --git a/frContainers/BaseLocalstackIntegrationSuite.go b/frContainers/BaseLocalstackIntegrationSuite.go index ff0dfa3..3229f0f 100644 --- a/frContainers/BaseLocalstackIntegrationSuite.go +++ b/frContainers/BaseLocalstackIntegrationSuite.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/config" + "github.com/aws/aws-sdk-go-v2/credentials" "github.com/stretchr/testify/suite" "github.com/testcontainers/testcontainers-go" ) @@ -21,6 +22,12 @@ func NewBaseLocalstackIntegrationSuite(provideContainer func() (testcontainers.C return BaseLocalstackIntegrationSuite{provideContainer: provideContainer} } +// GetLocalstackConfig +// +// Example use: +// return dynamodb.NewFromConfig(suite.BaseLocalstackIntegrationSuite.GetLocalstackConfig(), func(o *dynamodb.Options) { +// o.Credentials = suite.GetCredentials() +// }) func (this *BaseLocalstackIntegrationSuite) GetLocalstackConfig() aws.Config { cfg, err := config.LoadDefaultConfig(context.Background(), func(options *config.LoadOptions) error { options.EndpointResolverWithOptions = aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (aws.Endpoint, error) { @@ -39,6 +46,14 @@ func (this *BaseLocalstackIntegrationSuite) GetLocalstackConfig() aws.Config { return cfg } +func (this *BaseLocalstackIntegrationSuite) GetCredentials() credentials.StaticCredentialsProvider { + return credentials.NewStaticCredentialsProvider("test", "test", "") +} + +func (this *BaseLocalstackIntegrationSuite) GetEndpoint() string { + return this.awsEndpoint +} + func (this *BaseLocalstackIntegrationSuite) SetupSuite() { container, serviceUrl := this.provideContainer() this.container = container diff --git a/go.mod b/go.mod index 51dc60b..1f48023 100644 --- a/go.mod +++ b/go.mod @@ -1,72 +1,94 @@ module github.com/Ryanair/gofrlib-test -go 1.20 +go 1.21 require ( - github.com/Ryanair/gofrlib v1.0.25 - github.com/aws/aws-sdk-go-v2 v1.21.0 - github.com/aws/aws-sdk-go-v2/config v1.18.37 - github.com/docker/go-connections v0.4.0 - github.com/stretchr/testify v1.8.4 - github.com/testcontainers/testcontainers-go v0.23.0 + github.com/Ryanair/gofrlib v1.0.41 + github.com/aws/aws-sdk-go-v2 v1.30.4 + github.com/aws/aws-sdk-go-v2/config v1.27.28 + github.com/docker/go-connections v0.5.0 + github.com/stretchr/testify v1.9.0 + github.com/testcontainers/testcontainers-go v0.32.0 ) require ( - dario.cat/mergo v1.0.0 // indirect - github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/andybalholm/brotli v1.0.5 // indirect - github.com/aws/aws-lambda-go v1.41.0 // indirect - github.com/aws/aws-sdk-go v1.44.287 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.13.35 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 // indirect - github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.13.5 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.5 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.21.5 // indirect - github.com/aws/aws-xray-sdk-go v1.8.1 // indirect - github.com/aws/smithy-go v1.14.2 // indirect - github.com/cenkalti/backoff/v4 v4.2.1 // indirect - github.com/containerd/containerd v1.7.3 // indirect + dario.cat/mergo v1.0.1 // indirect + github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect + github.com/Microsoft/go-winio v0.6.2 // indirect + github.com/Microsoft/hcsshim v0.12.5 // indirect + github.com/andybalholm/brotli v1.1.0 // indirect + github.com/aws/aws-lambda-go v1.47.0 // indirect + github.com/aws/aws-sdk-go v1.55.5 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.17.28 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.12 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.16 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.16 // indirect + github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.4 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.18 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.22.5 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.5 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.30.4 // indirect + github.com/aws/aws-xray-sdk-go v1.8.4 // indirect + github.com/aws/smithy-go v1.20.4 // indirect + github.com/cenkalti/backoff/v4 v4.3.0 // indirect + github.com/containerd/containerd v1.7.20 // indirect + github.com/containerd/log v0.1.0 // indirect + github.com/containerd/platforms v0.2.1 // indirect github.com/cpuguy83/dockercfg v0.3.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/docker/distribution v2.8.2+incompatible // indirect - github.com/docker/docker v24.0.5+incompatible // indirect + github.com/distribution/reference v0.6.0 // indirect + github.com/docker/distribution v2.8.3+incompatible // indirect + github.com/docker/docker v27.1.2+incompatible // indirect github.com/docker/go-units v0.5.0 // indirect + github.com/felixge/httpsnoop v1.0.4 // indirect + github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-ole/go-ole v1.3.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/protobuf v1.5.3 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/golang/protobuf v1.5.4 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect - github.com/klauspost/compress v1.16.6 // indirect + github.com/klauspost/compress v1.17.9 // indirect + github.com/lufia/plan9stats v0.0.0-20240513124658-fba389f38bae // indirect github.com/magiconair/properties v1.8.7 // indirect - github.com/moby/patternmatcher v0.5.0 // indirect - github.com/moby/sys/sequential v0.5.0 // indirect + github.com/moby/docker-image-spec v1.3.1 // indirect + github.com/moby/patternmatcher v0.6.0 // indirect + github.com/moby/sys/sequential v0.6.0 // indirect + github.com/moby/sys/user v0.3.0 // indirect + github.com/moby/sys/userns v0.1.0 // indirect github.com/moby/term v0.5.0 // indirect github.com/morikuni/aec v1.0.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect - github.com/opencontainers/image-spec v1.1.0-rc4 // indirect - github.com/opencontainers/runc v1.1.5 // indirect + github.com/opencontainers/image-spec v1.1.0 // indirect + github.com/opencontainers/runc v1.1.13 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/sirupsen/logrus v1.9.0 // indirect + github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect + github.com/shirou/gopsutil/v3 v3.24.5 // indirect + github.com/shoenig/go-m1cpu v0.1.6 // indirect + github.com/sirupsen/logrus v1.9.3 // indirect + github.com/tklauser/go-sysconf v0.3.14 // indirect + github.com/tklauser/numcpus v0.8.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect - github.com/valyala/fasthttp v1.48.0 // indirect - go.opentelemetry.io/otel v1.16.0 // indirect - go.opentelemetry.io/otel/trace v1.16.0 // indirect - go.uber.org/atomic v1.11.0 // indirect + github.com/valyala/fasthttp v1.55.0 // indirect + github.com/yusufpapurcu/wmi v1.2.4 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect + go.opentelemetry.io/otel v1.28.0 // indirect + go.opentelemetry.io/otel/metric v1.28.0 // indirect + go.opentelemetry.io/otel/trace v1.28.0 // indirect go.uber.org/multierr v1.11.0 // indirect - go.uber.org/zap v1.24.0 // indirect - golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea // indirect - golang.org/x/mod v0.9.0 // indirect - golang.org/x/net v0.11.0 // indirect - golang.org/x/sys v0.11.0 // indirect - golang.org/x/text v0.10.0 // indirect - golang.org/x/tools v0.7.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect - google.golang.org/grpc v1.57.0 // indirect - google.golang.org/protobuf v1.30.0 // indirect + go.uber.org/zap v1.27.0 // indirect + golang.org/x/crypto v0.26.0 // indirect + golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa // indirect + golang.org/x/mod v0.20.0 // indirect + golang.org/x/net v0.28.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.24.0 // indirect + golang.org/x/text v0.17.0 // indirect + golang.org/x/tools v0.24.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect + google.golang.org/grpc v1.65.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) From 88b3be740e6f2465e2646e3c401e0b9d977b9c5f Mon Sep 17 00:00:00 2001 From: sodkiewiczm Date: Mon, 19 Aug 2024 11:42:36 +0200 Subject: [PATCH 3/4] Add Makefile --- Makefile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b766f17 --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +build: + go build ./... + +upgradeLibs: + go get -u ./... + go mod tidy + +ifndef version + @echo 'version is not defined' + exit 1 +endif +release: + git fetch + git tag ${version} + git push --tags From fa1354ffbf66b9e80c4d4c843b32c71b4b54a3fb Mon Sep 17 00:00:00 2001 From: sodkiewiczm Date: Mon, 19 Aug 2024 11:54:40 +0200 Subject: [PATCH 4/4] test logger config --- testDefaults/logger.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testDefaults/logger.go b/testDefaults/logger.go index 0863673..c199bd1 100644 --- a/testDefaults/logger.go +++ b/testDefaults/logger.go @@ -2,4 +2,4 @@ package testDefaults import "github.com/Ryanair/gofrlib/log" -var LoggerConfig = log.NewConfiguration("DEBUG", "TEST-APP", "TEST-PROJECT", "TEST-PROJECT-GROUP", "TEST-VERSION", "TEST-PREFIX") +var LoggerConfig = log.NewConfiguration("DEBUG", "TEST-APP", "TEST-PROJECT", "TEST-PROJECT-GROUP", "TEST-VERSION", "TEST-PREFIX", "TEST")