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

chore(nodeadm): remove aws sdk v1 refs #1887

Merged
merged 1 commit into from
Jul 16, 2024
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
1 change: 0 additions & 1 deletion nodeadm/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/awslabs/amazon-eks-ami/nodeadm
go 1.22.5

require (
github.com/aws/aws-sdk-go v1.54.19
github.com/aws/aws-sdk-go-v2/config v1.27.26
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.11
github.com/aws/aws-sdk-go-v2/service/ec2 v1.170.0
Expand Down
2 changes: 0 additions & 2 deletions nodeadm/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
github.com/aws/aws-sdk-go v1.54.19 h1:tyWV+07jagrNiCcGRzRhdtVjQs7Vy41NwsuOcl0IbVI=
github.com/aws/aws-sdk-go v1.54.19/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU=
github.com/aws/aws-sdk-go-v2 v1.30.3 h1:jUeBtG0Ih+ZIFH0F4UkmL9w3cSpaMv9tYYDbzILP8dY=
github.com/aws/aws-sdk-go-v2 v1.30.3/go.mod h1:nIQjQVp5sfpQcTc9mPSr1B0PaWK5ByX9MOoDadSN4lc=
github.com/aws/aws-sdk-go-v2/config v1.27.26 h1:T1kAefbKuNum/AbShMsZEro6eRkeOT8YILfE9wyjAYQ=
Expand Down
6 changes: 3 additions & 3 deletions nodeadm/internal/api/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"io"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/feature/ec2/imds"
"github.com/aws/aws-sdk-go-v2/service/ec2"
"github.com/aws/aws-sdk-go/aws"
ec2extra "github.com/awslabs/amazon-eks-ami/nodeadm/internal/aws/ec2"
)

Expand Down Expand Up @@ -59,13 +59,13 @@ func getPrivateDNSName(ec2Client *ec2.Client, instanceID string) (string, error)
if err != nil {
return "", err
}
privateDNSName := aws.StringValue(out.Reservations[0].Instances[0].PrivateDnsName)
privateDNSName := aws.ToString(out.Reservations[0].Instances[0].PrivateDnsName)
return privateDNSName, nil
}

func privateDNSNameAvailable(out *ec2.DescribeInstancesOutput) (bool, error) {
if out == nil || len(out.Reservations) != 1 || len(out.Reservations[0].Instances) != 1 {
return false, fmt.Errorf("reservation or instance not found")
}
return aws.StringValue(out.Reservations[0].Instances[0].PrivateDnsName) != "", nil
return aws.ToString(out.Reservations[0].Instances[0].PrivateDnsName) != "", nil
}
18 changes: 10 additions & 8 deletions nodeadm/internal/util/ec2_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package util
package util_test

import (
"context"
"errors"
"fmt"
"testing"

"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/aws/aws-sdk-go/aws"
ec2util "github.com/awslabs/amazon-eks-ami/nodeadm/internal/util"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"testing"
)

type MockEC2Client struct {
Expand All @@ -24,14 +26,14 @@ func (m *MockEC2Client) DescribeInstanceTypes(ctx context.Context, params *ec2.D
func TestGetEniInfoForInstanceType(t *testing.T) {
tests := []struct {
instanceType string
expectedResult EniInfo
expectedResult ec2util.EniInfo
mockResponse ec2.DescribeInstanceTypesOutput
mockError error
expectedError error
}{
{
instanceType: "t3.medium",
expectedResult: EniInfo{
expectedResult: ec2util.EniInfo{
EniCount: int32(3),
PodsPerEniCount: int32(6),
},
Expand All @@ -51,7 +53,7 @@ func TestGetEniInfoForInstanceType(t *testing.T) {
},
{
instanceType: "t3.medium",
expectedResult: EniInfo{},
expectedResult: ec2util.EniInfo{},
mockResponse: ec2.DescribeInstanceTypesOutput{
InstanceTypes: []types.InstanceTypeInfo{},
},
Expand All @@ -60,7 +62,7 @@ func TestGetEniInfoForInstanceType(t *testing.T) {
},
{
instanceType: "mock-type.large",
expectedResult: EniInfo{},
expectedResult: ec2util.EniInfo{},
mockResponse: ec2.DescribeInstanceTypesOutput{
InstanceTypes: []types.InstanceTypeInfo{},
},
Expand All @@ -73,7 +75,7 @@ func TestGetEniInfoForInstanceType(t *testing.T) {
mockEC2 := &MockEC2Client{}
mockEC2.On("DescribeInstanceTypes", mock.Anything, mock.AnythingOfType("*ec2.DescribeInstanceTypesInput")).Return(&test.mockResponse, test.mockError)

result, err := GetEniInfoForInstanceType(mockEC2, test.instanceType)
result, err := ec2util.GetEniInfoForInstanceType(mockEC2, test.instanceType)
assert.Equal(t, test.expectedError, err)
assert.Equal(t, test.expectedResult, result)
}
Expand Down
202 changes: 0 additions & 202 deletions nodeadm/vendor/github.com/aws/aws-sdk-go/LICENSE.txt

This file was deleted.

3 changes: 0 additions & 3 deletions nodeadm/vendor/github.com/aws/aws-sdk-go/NOTICE.txt

This file was deleted.

Loading
Loading