From 6cc2d9ea573ea33bb8e8c0dd7c1323a59b602649 Mon Sep 17 00:00:00 2001 From: Florent Delannoy Date: Sun, 18 Aug 2024 15:12:20 +0200 Subject: [PATCH 1/4] Upgrade to AWS SDK for Go v2 --- go.mod | 19 ++++++++- go.sum | 34 +++++++++++++--- remote/dependency/dependency.go | 9 ++++- remote/dependency/dependency_test.go | 16 ++++---- upstream/ami.go | 40 +++++++++++-------- upstream/ami_test.go | 60 +++++++++++++++++----------- 6 files changed, 119 insertions(+), 59 deletions(-) diff --git a/go.mod b/go.mod index 7722436b..2307c57b 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module sigs.k8s.io/zeitgeist go 1.22.5 require ( - github.com/aws/aws-sdk-go v1.55.5 + github.com/aws/aws-sdk-go-v2 v1.30.4 github.com/blang/semver/v4 v4.0.0 github.com/google/go-containerregistry v0.20.2 github.com/maxbrunsfeld/counterfeiter/v6 v6.8.1 @@ -18,6 +18,20 @@ require ( sigs.k8s.io/release-utils v0.8.4 ) +require ( + 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/smithy-go v1.20.4 // indirect +) + require ( dario.cat/mergo v1.0.0 // indirect github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect @@ -26,6 +40,8 @@ require ( github.com/Microsoft/go-winio v0.6.1 // indirect github.com/Microsoft/hcsshim v0.11.4 // indirect github.com/ProtonMail/go-crypto v1.0.0 // indirect + github.com/aws/aws-sdk-go-v2/config v1.27.28 + github.com/aws/aws-sdk-go-v2/service/ec2 v1.175.1 github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cloudflare/circl v1.3.7 // indirect @@ -72,7 +88,6 @@ require ( github.com/imdario/mergo v0.3.16 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect - github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect diff --git a/go.sum b/go.sum index 6388e27d..4777eb39 100644 --- a/go.sum +++ b/go.sum @@ -23,8 +23,34 @@ github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFI github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= -github.com/aws/aws-sdk-go v1.55.5 h1:KKUZBfBoyqy5d3swXyiC7Q76ic40rYcbqH7qjh59kzU= -github.com/aws/aws-sdk-go v1.55.5/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU= +github.com/aws/aws-sdk-go-v2 v1.30.4 h1:frhcagrVNrzmT95RJImMHgabt99vkXGslubDaDagTk8= +github.com/aws/aws-sdk-go-v2 v1.30.4/go.mod h1:CT+ZPWXbYrci8chcARI3OmI/qgd+f6WtuLOoaIA8PR0= +github.com/aws/aws-sdk-go-v2/config v1.27.28 h1:OTxWGW/91C61QlneCtnD62NLb4W616/NM1jA8LhJqbg= +github.com/aws/aws-sdk-go-v2/config v1.27.28/go.mod h1:uzVRVtJSU5EFv6Fu82AoVFKozJi2ZCY6WRCXj06rbvs= +github.com/aws/aws-sdk-go-v2/credentials v1.17.28 h1:m8+AHY/ND8CMHJnPoH7PJIRakWGa4gbfbxuY9TGTUXM= +github.com/aws/aws-sdk-go-v2/credentials v1.17.28/go.mod h1:6TF7dSc78ehD1SL6KpRIPKMA1GyyWflIkjqg+qmf4+c= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.12 h1:yjwoSyDZF8Jth+mUk5lSPJCkMC0lMy6FaCD51jm6ayE= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.12/go.mod h1:fuR57fAgMk7ot3WcNQfb6rSEn+SUffl7ri+aa8uKysI= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.16 h1:TNyt/+X43KJ9IJJMjKfa3bNTiZbUP7DeCxfbTROESwY= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.16/go.mod h1:2DwJF39FlNAUiX5pAc0UNeiz16lK2t7IaFcm0LFHEgc= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.16 h1:jYfy8UPmd+6kJW5YhY0L1/KftReOGxI/4NtVSTh9O/I= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.16/go.mod h1:7ZfEPZxkW42Afq4uQB8H2E2e6ebh6mXTueEpYzjCzcs= +github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 h1:VaRN3TlFdd6KxX1x3ILT5ynH6HvKgqdiXoTxAF4HQcQ= +github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1/go.mod h1:FbtygfRFze9usAadmnGJNc8KsP346kEe+y2/oyhGAGc= +github.com/aws/aws-sdk-go-v2/service/ec2 v1.175.1 h1:7B5ppg4i5N2B6t+aH77WLbAu8sD98MLlzruWzq5scyY= +github.com/aws/aws-sdk-go-v2/service/ec2 v1.175.1/go.mod h1:ISODge3zgdwOEa4Ou6WM9PKbxJWJ15DYKnr2bfmCAIA= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.4 h1:KypMCbLPPHEmf9DgMGw51jMj77VfGPAN2Kv4cfhlfgI= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.4/go.mod h1:Vz1JQXliGcQktFTN/LN6uGppAIRoLBR2bMvIMP0gOjc= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.18 h1:tJ5RnkHCiSH0jyd6gROjlJtNwov0eGYNz8s8nFcR0jQ= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.18/go.mod h1:++NHzT+nAF7ZPrHPsA+ENvsXkOO8wEu+C6RXltAG4/c= +github.com/aws/aws-sdk-go-v2/service/sso v1.22.5 h1:zCsFCKvbj25i7p1u94imVoO447I/sFv8qq+lGJhRN0c= +github.com/aws/aws-sdk-go-v2/service/sso v1.22.5/go.mod h1:ZeDX1SnKsVlejeuz41GiajjZpRSWR7/42q/EyA/QEiM= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.5 h1:SKvPgvdvmiTWoi0GAJ7AsJfOz3ngVkD/ERbs5pUnHNI= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.5/go.mod h1:20sz31hv/WsPa3HhU3hfrIet2kxM4Pe0r20eBZ20Tac= +github.com/aws/aws-sdk-go-v2/service/sts v1.30.4 h1:iAckBT2OeEK/kBDyN/jDtpEExhjeeA/Im2q4X0rJZT8= +github.com/aws/aws-sdk-go-v2/service/sts v1.30.4/go.mod h1:vmSqFK+BVIwVpDAGZB3CoCXHzurt4qBE8lf+I/kRTh0= +github.com/aws/smithy-go v1.20.4 h1:2HK1zBdPgRbjFOHlfeQZfpC4r72MOb9bZkiFwggKO+4= +github.com/aws/smithy-go v1.20.4/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -205,10 +231,6 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= -github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= -github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= -github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= -github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= diff --git a/remote/dependency/dependency.go b/remote/dependency/dependency.go index eb58b035..0d4278b5 100644 --- a/remote/dependency/dependency.go +++ b/remote/dependency/dependency.go @@ -18,13 +18,14 @@ limitations under the License. package dependency import ( + "context" "fmt" "os" "path/filepath" "regexp" "strings" - "github.com/aws/aws-sdk-go/service/ec2/ec2iface" + "github.com/aws/aws-sdk-go-v2/service/ec2" "github.com/mitchellh/mapstructure" log "github.com/sirupsen/logrus" @@ -38,7 +39,11 @@ func init() { type RemoteClient struct { LocalClient deppkg.Client - AWSEC2Client ec2iface.EC2API + AWSEC2Client EC2DescribeImagesAPI +} + +type EC2DescribeImagesAPI interface { + DescribeImages(ctx context.Context, params *ec2.DescribeImagesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeImagesOutput, error) } func NewRemoteClient() (deppkg.Client, error) { diff --git a/remote/dependency/dependency_test.go b/remote/dependency/dependency_test.go index 68681f18..0166a5b5 100644 --- a/remote/dependency/dependency_test.go +++ b/remote/dependency/dependency_test.go @@ -17,34 +17,34 @@ limitations under the License. package dependency import ( + "context" "os" "path/filepath" "reflect" "testing" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/ec2" - "github.com/aws/aws-sdk-go/service/ec2/ec2iface" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/ec2" + "github.com/aws/aws-sdk-go-v2/service/ec2/types" "github.com/stretchr/testify/require" deppkg "sigs.k8s.io/zeitgeist/dependency" ) -type mockedReceiveMsgs struct { - ec2iface.EC2API +type mockedEc2DescribeImagesAPI struct { Resp ec2.DescribeImagesOutput } -func (m mockedReceiveMsgs) DescribeImages(_ *ec2.DescribeImagesInput) (*ec2.DescribeImagesOutput, error) { +func (m mockedEc2DescribeImagesAPI) DescribeImages(ctx context.Context, params *ec2.DescribeImagesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeImagesOutput, error) { // Only need to return mocked response output return &m.Resp, nil } func TestRemoteSuccess(t *testing.T) { var client RemoteClient - client.AWSEC2Client = mockedReceiveMsgs{ + client.AWSEC2Client = mockedEc2DescribeImagesAPI{ Resp: ec2.DescribeImagesOutput{ - Images: []*ec2.Image{ + Images: []types.Image{ { CreationDate: aws.String("2019-05-10T13:17:12.000Z"), ImageId: aws.String("ami-09bbefc07310f7914"), diff --git a/upstream/ami.go b/upstream/ami.go index 03dafeb8..84154d58 100644 --- a/upstream/ami.go +++ b/upstream/ami.go @@ -17,13 +17,14 @@ limitations under the License. package upstream import ( + "context" "fmt" "sort" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/ec2" - "github.com/aws/aws-sdk-go/service/ec2/ec2iface" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/config" + "github.com/aws/aws-sdk-go-v2/service/ec2" + "github.com/aws/aws-sdk-go-v2/service/ec2/types" log "github.com/sirupsen/logrus" ) @@ -41,7 +42,11 @@ type AMI struct { Name string // ServiceClient is the AWS client to talk to AWS API - ServiceClient ec2iface.EC2API + ServiceClient EC2DescribeImagesAPI +} + +type EC2DescribeImagesAPI interface { + DescribeImages(ctx context.Context, params *ec2.DescribeImagesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeImagesOutput, error) } // NewAWSClient return a new aws service client for ec2 @@ -50,13 +55,14 @@ type AMI struct { // `~/.aws/config` and `~/.aws/credentials` files, and support environment variables. // See AWS documentation for more details: // https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/sessions.html -func NewAWSClient() *ec2.EC2 { +func NewAWSClient() *ec2.Client { // Create a new session based on shared / env credentials - s := session.Must(session.NewSessionWithOptions(session.Options{ - SharedConfigState: session.SharedConfigEnable, - })) + cfg, err := config.LoadDefaultConfig(context.TODO()) + if err != nil { + log.Fatal("failed to load aws config", err) + } - return ec2.New(s) + return ec2.NewFromConfig(cfg) } // LatestVersion returns the latest version of an AMI. @@ -68,19 +74,19 @@ func (upstream AMI) LatestVersion() (string, error) { log.Debug("Using AMI upstream") // Generate filters based on configuration - var filters []*ec2.Filter - filters = append(filters, &ec2.Filter{ + var filters []types.Filter + filters = append(filters, types.Filter{ Name: aws.String("name"), - Values: []*string{aws.String(upstream.Name)}, + Values: []string{upstream.Name}, }) input := &ec2.DescribeImagesInput{ - Owners: []*string{aws.String(upstream.Owner)}, + Owners: []string{upstream.Owner}, Filters: filters, } // Do the actual API call - result, err := upstream.ServiceClient.DescribeImages(input) + result, err := upstream.ServiceClient.DescribeImages(context.TODO(), input) if err != nil { return "", err } @@ -89,14 +95,14 @@ func (upstream AMI) LatestVersion() (string, error) { // Sort images by creation time, so we can return the latest sort.Slice(images, func(i, j int) bool { return *images[i].CreationDate > *images[j].CreationDate }) - log.Debugf("Matched AMIs:\n%s", images) + log.Debugf("Matched AMIs:\n%v", images) if len(images) < 1 { return "", fmt.Errorf("no AMI found for upstream %s", upstream.Name) } latestImage := images[0] - log.Debugf("Latest AMI: %s\n", latestImage) + log.Debugf("Latest AMI ID: %v\n", *latestImage.ImageId) return *latestImage.ImageId, nil } diff --git a/upstream/ami_test.go b/upstream/ami_test.go index a33d3154..c487b628 100644 --- a/upstream/ami_test.go +++ b/upstream/ami_test.go @@ -17,22 +17,26 @@ limitations under the License. package upstream import ( + "context" "testing" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/ec2" - "github.com/aws/aws-sdk-go/service/ec2/ec2iface" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/ec2" + "github.com/aws/aws-sdk-go-v2/service/ec2/types" "github.com/stretchr/testify/require" ) +/* type mockedReceiveMsgs struct { - ec2iface.EC2API + ec2.Client Resp ec2.DescribeImagesOutput } +*/ -func (m mockedReceiveMsgs) DescribeImages(_ *ec2.DescribeImagesInput) (*ec2.DescribeImagesOutput, error) { - // Only need to return mocked response output - return &m.Resp, nil +type mockEc2Api func(ctx context.Context, params *ec2.DescribeImagesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeImagesOutput, error) + +func (m mockEc2Api) DescribeImages(ctx context.Context, params *ec2.DescribeImagesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeImagesOutput, error) { + return m(ctx, params, optFns...) } func TestGetAMI(t *testing.T) { @@ -40,6 +44,7 @@ func TestGetAMI(t *testing.T) { Name string Input AMI Resp ec2.DescribeImagesOutput + Client func(t *testing.T) mockEc2Api Expected string ExpectedError bool }{ @@ -49,19 +54,23 @@ func TestGetAMI(t *testing.T) { Owner: "amazon", Name: "amazon-eks-node-1.13-*", }, - Resp: ec2.DescribeImagesOutput{ - Images: []*ec2.Image{ - { - CreationDate: aws.String("2019-05-10T13:17:12.000Z"), - ImageId: aws.String("ami-123oldimage"), - Name: aws.String("amazon-eks-node-1.13-honk"), - }, - { - CreationDate: aws.String("2019-05-12T13:17:12.000Z"), - ImageId: aws.String("ami-honk"), - Name: aws.String("amazon-eks-node-1.13-old"), - }, - }, + Client: func(t *testing.T) mockEc2Api { + return mockEc2Api(func(ctx context.Context, params *ec2.DescribeImagesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeImagesOutput, error) { + return &ec2.DescribeImagesOutput{ + Images: []types.Image{ + { + CreationDate: aws.String("2019-05-10T13:17:12.000Z"), + ImageId: aws.String("ami-123oldimage"), + Name: aws.String("amazon-eks-node-1.13-honk"), + }, + { + CreationDate: aws.String("2019-05-12T13:17:12.000Z"), + ImageId: aws.String("ami-honk"), + Name: aws.String("amazon-eks-node-1.13-old"), + }, + }, + }, nil + }) }, Expected: "ami-honk", ExpectedError: false, @@ -72,8 +81,12 @@ func TestGetAMI(t *testing.T) { Owner: "honk", Name: "this-ami-doesnt-exist-zeitgeist", }, - Resp: ec2.DescribeImagesOutput{ - Images: []*ec2.Image{}, + Client: func(t *testing.T) mockEc2Api { + return mockEc2Api(func(ctx context.Context, params *ec2.DescribeImagesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeImagesOutput, error) { + return &ec2.DescribeImagesOutput{ + Images: []types.Image{}, + }, nil + }) }, Expected: "no AMI found for upstream this-ami-doesnt-exist-zeitgeist", ExpectedError: true, @@ -82,8 +95,7 @@ func TestGetAMI(t *testing.T) { for _, tc := range testCases { t.Run(tc.Name, func(t *testing.T) { - tc.Input.ServiceClient = mockedReceiveMsgs{Resp: tc.Resp} - + tc.Input.ServiceClient = tc.Client(t) latestImage, err := tc.Input.LatestVersion() if tc.ExpectedError { require.Error(t, err) From 29575181b998298852e23523f807e688970c0eee Mon Sep 17 00:00:00 2001 From: Florent Delannoy Date: Sun, 18 Aug 2024 15:23:00 +0200 Subject: [PATCH 2/4] Use context.Background instead of TODO --- upstream/ami.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/upstream/ami.go b/upstream/ami.go index 84154d58..8a2f2a71 100644 --- a/upstream/ami.go +++ b/upstream/ami.go @@ -57,7 +57,7 @@ type EC2DescribeImagesAPI interface { // https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/sessions.html func NewAWSClient() *ec2.Client { // Create a new session based on shared / env credentials - cfg, err := config.LoadDefaultConfig(context.TODO()) + cfg, err := config.LoadDefaultConfig(context.Background()) if err != nil { log.Fatal("failed to load aws config", err) } @@ -86,7 +86,7 @@ func (upstream AMI) LatestVersion() (string, error) { } // Do the actual API call - result, err := upstream.ServiceClient.DescribeImages(context.TODO(), input) + result, err := upstream.ServiceClient.DescribeImages(context.Background(), input) if err != nil { return "", err } From 08edcf7e335d6505a6741ed979d0fb379e9acea2 Mon Sep 17 00:00:00 2001 From: Florent Delannoy Date: Sun, 18 Aug 2024 15:33:44 +0200 Subject: [PATCH 3/4] Lint --- remote/dependency/dependency_test.go | 2 +- upstream/ami_test.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/remote/dependency/dependency_test.go b/remote/dependency/dependency_test.go index 0166a5b5..628dcced 100644 --- a/remote/dependency/dependency_test.go +++ b/remote/dependency/dependency_test.go @@ -35,7 +35,7 @@ type mockedEc2DescribeImagesAPI struct { Resp ec2.DescribeImagesOutput } -func (m mockedEc2DescribeImagesAPI) DescribeImages(ctx context.Context, params *ec2.DescribeImagesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeImagesOutput, error) { +func (m mockedEc2DescribeImagesAPI) DescribeImages(_ context.Context, _ *ec2.DescribeImagesInput, _ ...func(*ec2.Options)) (*ec2.DescribeImagesOutput, error) { // Only need to return mocked response output return &m.Resp, nil } diff --git a/upstream/ami_test.go b/upstream/ami_test.go index c487b628..0b33cec5 100644 --- a/upstream/ami_test.go +++ b/upstream/ami_test.go @@ -54,8 +54,8 @@ func TestGetAMI(t *testing.T) { Owner: "amazon", Name: "amazon-eks-node-1.13-*", }, - Client: func(t *testing.T) mockEc2Api { - return mockEc2Api(func(ctx context.Context, params *ec2.DescribeImagesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeImagesOutput, error) { + Client: func(_ *testing.T) mockEc2Api { + return mockEc2Api(func(_ context.Context, _ *ec2.DescribeImagesInput, _ ...func(*ec2.Options)) (*ec2.DescribeImagesOutput, error) { return &ec2.DescribeImagesOutput{ Images: []types.Image{ { @@ -81,8 +81,8 @@ func TestGetAMI(t *testing.T) { Owner: "honk", Name: "this-ami-doesnt-exist-zeitgeist", }, - Client: func(t *testing.T) mockEc2Api { - return mockEc2Api(func(ctx context.Context, params *ec2.DescribeImagesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeImagesOutput, error) { + Client: func(_ *testing.T) mockEc2Api { + return mockEc2Api(func(_ context.Context, _ *ec2.DescribeImagesInput, _ ...func(*ec2.Options)) (*ec2.DescribeImagesOutput, error) { return &ec2.DescribeImagesOutput{ Images: []types.Image{}, }, nil From 85fcf5b0f6a5f6e882cd910bde1ff81fc9b77aa2 Mon Sep 17 00:00:00 2001 From: Florent Delannoy Date: Mon, 19 Aug 2024 09:53:15 +0200 Subject: [PATCH 4/4] Reorder dependencies in go.mod --- go.mod | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 2307c57b..7af3eef7 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,8 @@ go 1.22.5 require ( github.com/aws/aws-sdk-go-v2 v1.30.4 + github.com/aws/aws-sdk-go-v2/config v1.27.28 + github.com/aws/aws-sdk-go-v2/service/ec2 v1.175.1 github.com/blang/semver/v4 v4.0.0 github.com/google/go-containerregistry v0.20.2 github.com/maxbrunsfeld/counterfeiter/v6 v6.8.1 @@ -19,6 +21,13 @@ require ( ) require ( + dario.cat/mergo v1.0.0 // indirect + github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect + github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect + github.com/Masterminds/semver/v3 v3.2.1 // indirect + github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/Microsoft/hcsshim v0.11.4 // indirect + github.com/ProtonMail/go-crypto v1.0.0 // 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 @@ -30,18 +39,6 @@ require ( 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/smithy-go v1.20.4 // indirect -) - -require ( - dario.cat/mergo v1.0.0 // indirect - github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect - github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect - github.com/Masterminds/semver/v3 v3.2.1 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/Microsoft/hcsshim v0.11.4 // indirect - github.com/ProtonMail/go-crypto v1.0.0 // indirect - github.com/aws/aws-sdk-go-v2/config v1.27.28 - github.com/aws/aws-sdk-go-v2/service/ec2 v1.175.1 github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cloudflare/circl v1.3.7 // indirect