Skip to content

Commit b123368

Browse files
author
Thean Lim
committed
Migrate ElasticNetworkInterfaces
- DomainName []*string -> []string - DomainNameServers []*string -> []string - Index *int64 -> *int32 - InterfaceAssociationProtocol *string -> NetworkInterfaceAssociationProtocol (string enum) - Ipv4Addresses []*IPv4AddressAssignment -> []IPv4AddressAssignment - Ipv6Addresses []*IPv6AddressAssignment -> []IPv6AddressAssignment
1 parent b0663ce commit b123368

15 files changed

+145
-139
lines changed

agent/acs/session/attach_instance_eni_responder_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131

3232
"github.com/aws/aws-sdk-go-v2/aws"
3333
ecsacs "github.com/aws/aws-sdk-go-v2/service/acs"
34+
acstypes "github.com/aws/aws-sdk-go-v2/service/acs/types"
3435
"github.com/golang/mock/gomock"
3536
"github.com/stretchr/testify/assert"
3637
)
@@ -39,13 +40,13 @@ var testAttachInstanceENIMessage = &ecsacs.AttachInstanceNetworkInterfacesMessag
3940
MessageId: aws.String(testconst.MessageID),
4041
ClusterArn: aws.String(testconst.ClusterARN),
4142
ContainerInstanceArn: aws.String(testconst.ContainerInstanceARN),
42-
ElasticNetworkInterfaces: []*ecsacs.ElasticNetworkInterface{
43+
ElasticNetworkInterfaces: []*acstypes.ElasticNetworkInterface{
4344
{
4445
Ec2Id: aws.String("1"),
4546
MacAddress: aws.String(testconst.RandomMAC),
46-
InterfaceAssociationProtocol: aws.String(testconst.InterfaceProtocol),
47+
InterfaceAssociationProtocol: testconst.InterfaceProtocol,
4748
SubnetGatewayIpv4Address: aws.String(testconst.GatewayIPv4),
48-
Ipv4Addresses: []*ecsacs.IPv4AddressAssignment{
49+
Ipv4Addresses: []acstypes.IPv4AddressAssignment{
4950
{
5051
Primary: aws.Bool(true),
5152
PrivateAddress: aws.String(testconst.IPv4Address),

agent/acs/session/payload_responder_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -620,17 +620,17 @@ func TestHandlePayloadMessageAddedENIToTask(t *testing.T) {
620620
testPayloadMessage.Tasks = []*ecsacs.Task{
621621
{
622622
Arn: aws.String(testconst.TaskARN),
623-
ElasticNetworkInterfaces: []*ecsacs.ElasticNetworkInterface{
623+
ElasticNetworkInterfaces: []*acstypes.ElasticNetworkInterface{
624624
{
625625
AttachmentArn: aws.String(attachmentARN),
626626
Ec2Id: aws.String(ec2ID),
627-
Ipv4Addresses: []*ecsacs.IPv4AddressAssignment{
627+
Ipv4Addresses: []acstypes.IPv4AddressAssignment{
628628
{
629629
Primary: aws.Bool(true),
630630
PrivateAddress: aws.String(testconst.IPv4Address),
631631
},
632632
},
633-
Ipv6Addresses: []*ecsacs.IPv6AddressAssignment{
633+
Ipv6Addresses: []acstypes.IPv6AddressAssignment{
634634
{
635635
Address: aws.String("ipv6"),
636636
},
@@ -864,25 +864,25 @@ func TestHandlePayloadMessageAddedENITrunkToTask(t *testing.T) {
864864
testPayloadMessage.Tasks = []*ecsacs.Task{
865865
{
866866
Arn: aws.String(testconst.TaskARN),
867-
ElasticNetworkInterfaces: []*ecsacs.ElasticNetworkInterface{
867+
ElasticNetworkInterfaces: []*acstypes.ElasticNetworkInterface{
868868
{
869-
InterfaceAssociationProtocol: aws.String(ni.VLANInterfaceAssociationProtocol),
869+
InterfaceAssociationProtocol: ni.VLANInterfaceAssociationProtocol,
870870
AttachmentArn: aws.String(attachmentARN),
871871
Ec2Id: aws.String(ec2ID),
872-
Ipv4Addresses: []*ecsacs.IPv4AddressAssignment{
872+
Ipv4Addresses: []acstypes.IPv4AddressAssignment{
873873
{
874874
Primary: aws.Bool(true),
875875
PrivateAddress: aws.String(testconst.IPv4Address),
876876
},
877877
},
878-
Ipv6Addresses: []*ecsacs.IPv6AddressAssignment{
878+
Ipv6Addresses: []acstypes.IPv6AddressAssignment{
879879
{
880880
Address: aws.String("ipv6"),
881881
},
882882
},
883883
SubnetGatewayIpv4Address: aws.String(testconst.GatewayIPv4),
884884
MacAddress: aws.String(testconst.RandomMAC),
885-
InterfaceVlanProperties: &ecsacs.NetworkInterfaceVlanProperties{
885+
InterfaceVlanProperties: &acstypes.NetworkInterfaceVlanProperties{
886886
VlanId: aws.String(vlanID),
887887
TrunkInterfaceMacAddress: aws.String(testconst.RandomMAC),
888888
},

agent/api/task/task_attachment_handler_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828

2929
"github.com/aws/aws-sdk-go-v2/aws"
3030
ecsacs "github.com/aws/aws-sdk-go-v2/service/acs"
31+
acstypes "github.com/aws/aws-sdk-go-v2/service/acs/types"
3132
"github.com/stretchr/testify/assert"
3233
"github.com/stretchr/testify/require"
3334
)
@@ -42,16 +43,16 @@ var (
4243
testIPv4CIDR = "127.255.0.0/16"
4344
testIPv6 = "abcd:dcba:1234:4321::"
4445
testIPv6CIDR = "2002::1234:abcd:ffff:c0a8:101/64"
45-
testIpv4ElasticNetworkInterface = &ecsacs.ElasticNetworkInterface{
46-
Ipv4Addresses: []*ecsacs.IPv4AddressAssignment{
46+
testIpv4ElasticNetworkInterface = &acstypes.ElasticNetworkInterface{
47+
Ipv4Addresses: []acstypes.IPv4AddressAssignment{
4748
{
4849
Primary: aws.Bool(true),
4950
PrivateAddress: aws.String(testIPv4),
5051
},
5152
},
5253
}
53-
testIpv6ElasticNetworkInterface = &ecsacs.ElasticNetworkInterface{
54-
Ipv6Addresses: []*ecsacs.IPv6AddressAssignment{
54+
testIpv6ElasticNetworkInterface = &acstypes.ElasticNetworkInterface{
55+
Ipv6Addresses: []acstypes.IPv6AddressAssignment{
5556
{
5657
Address: aws.String(testIPv6),
5758
},
@@ -159,7 +160,7 @@ func TestHandleTaskAttachmentsWithServiceConnectAttachment(t *testing.T) {
159160
for _, tc := range tt {
160161
t.Run(tc.testName, func(t *testing.T) {
161162
testAcsTask := &ecsacs.Task{
162-
ElasticNetworkInterfaces: []*ecsacs.ElasticNetworkInterface{testIpv6ElasticNetworkInterface},
163+
ElasticNetworkInterfaces: []*acstypes.ElasticNetworkInterface{testIpv6ElasticNetworkInterface},
163164
Containers: []*ecsacs.Container{
164165
getTestcontainerFromACS(testSCContainerName, AWSVPCNetworkMode),
165166
},
@@ -239,7 +240,7 @@ func TestHandleTaskAttachmentWithEBSVolumeAttachment(t *testing.T) {
239240
for _, tc := range tt {
240241
t.Run(tc.testName, func(t *testing.T) {
241242
testAcsTask := &ecsacs.Task{
242-
ElasticNetworkInterfaces: []*ecsacs.ElasticNetworkInterface{testIpv6ElasticNetworkInterface},
243+
ElasticNetworkInterfaces: []*acstypes.ElasticNetworkInterface{testIpv6ElasticNetworkInterface},
243244
Containers: []*ecsacs.Container{
244245
getTestcontainerFromACS(testSCContainerName, AWSVPCNetworkMode),
245246
},
@@ -298,7 +299,7 @@ func TestHandleTaskAttachmentWithEBSVolumeAttachment(t *testing.T) {
298299

299300
func TestHandleTaskAttachmentsWithoutAttachment(t *testing.T) {
300301
testAcsTask := &ecsacs.Task{
301-
ElasticNetworkInterfaces: []*ecsacs.ElasticNetworkInterface{testIpv4ElasticNetworkInterface},
302+
ElasticNetworkInterfaces: []*acstypes.ElasticNetworkInterface{testIpv4ElasticNetworkInterface},
302303
Containers: []*ecsacs.Container{
303304
getTestcontainerFromACS("C1", BridgeNetworkMode),
304305
},

agent/api/task/task_test.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import (
5858

5959
"github.com/aws/aws-sdk-go-v2/aws"
6060
ecsacs "github.com/aws/aws-sdk-go-v2/service/acs"
61+
acstypes "github.com/aws/aws-sdk-go-v2/service/acs/types"
6162
"github.com/aws/aws-sdk-go-v2/service/ecs/types"
6263
"github.com/aws/aws-sdk-go/service/secretsmanager"
6364
dockercontainer "github.com/docker/docker/api/types/container"
@@ -4589,15 +4590,15 @@ func TestTaskServiceConnectAttachment(t *testing.T) {
45894590
seqNum := int64(42)
45904591
tt := []struct {
45914592
testName string
4592-
testElasticNetworkInterface *ecsacs.ElasticNetworkInterface
4593+
testElasticNetworkInterface *acstypes.ElasticNetworkInterface
45934594
testNetworkMode string
45944595
testSCConfigValue string
45954596
testExpectedSCConfig *serviceconnect.Config
45964597
}{
45974598
{
45984599
testName: "Bridge default case",
4599-
testElasticNetworkInterface: &ecsacs.ElasticNetworkInterface{
4600-
Ipv4Addresses: []*ecsacs.IPv4AddressAssignment{
4600+
testElasticNetworkInterface: &acstypes.ElasticNetworkInterface{
4601+
Ipv4Addresses: []acstypes.IPv4AddressAssignment{
46014602
{
46024603
Primary: aws.Bool(true),
46034604
PrivateAddress: aws.String(ipv4),
@@ -4630,8 +4631,8 @@ func TestTaskServiceConnectAttachment(t *testing.T) {
46304631
},
46314632
{
46324633
testName: "AWSVPC override case with IPv6 enabled",
4633-
testElasticNetworkInterface: &ecsacs.ElasticNetworkInterface{
4634-
Ipv6Addresses: []*ecsacs.IPv6AddressAssignment{
4634+
testElasticNetworkInterface: &acstypes.ElasticNetworkInterface{
4635+
Ipv6Addresses: []acstypes.IPv6AddressAssignment{
46354636
{
46364637
Address: aws.String("ipv6"),
46374638
},
@@ -4670,7 +4671,7 @@ func TestTaskServiceConnectAttachment(t *testing.T) {
46704671
DesiredStatus: strptr("RUNNING"),
46714672
Family: strptr("myFamily"),
46724673
Version: strptr("1"),
4673-
ElasticNetworkInterfaces: []*ecsacs.ElasticNetworkInterface{tc.testElasticNetworkInterface},
4674+
ElasticNetworkInterfaces: []*acstypes.ElasticNetworkInterface{tc.testElasticNetworkInterface},
46744675
Containers: []*ecsacs.Container{
46754676
containerFromACS("C1", 33333, 0, tc.testNetworkMode),
46764677
containerFromACS(serviceConnectContainerTestName, 0, 0, tc.testNetworkMode),
@@ -4703,8 +4704,8 @@ func TestTaskServiceConnectAttachment(t *testing.T) {
47034704

47044705
func TestTaskWithoutServiceConnectAttachment(t *testing.T) {
47054706
seqNum := int64(42)
4706-
testElasticNetworkInterface := &ecsacs.ElasticNetworkInterface{
4707-
Ipv4Addresses: []*ecsacs.IPv4AddressAssignment{
4707+
testElasticNetworkInterface := &acstypes.ElasticNetworkInterface{
4708+
Ipv4Addresses: []acstypes.IPv4AddressAssignment{
47084709
{
47094710
Primary: aws.Bool(true),
47104711
PrivateAddress: aws.String(ipv4),
@@ -4716,7 +4717,7 @@ func TestTaskWithoutServiceConnectAttachment(t *testing.T) {
47164717
DesiredStatus: strptr("RUNNING"),
47174718
Family: strptr("myFamily"),
47184719
Version: strptr("1"),
4719-
ElasticNetworkInterfaces: []*ecsacs.ElasticNetworkInterface{testElasticNetworkInterface},
4720+
ElasticNetworkInterfaces: []*acstypes.ElasticNetworkInterface{testElasticNetworkInterface},
47204721
Containers: []*ecsacs.Container{
47214722
containerFromACS("C1", 33333, 0, BridgeNetworkMode),
47224723
},

ecs-agent/acs/client/acs_client_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,16 +466,16 @@ func TestAttachInstanceENIHandlerCalled(t *testing.T) {
466466
expectedMessage := &ecsacs.AttachInstanceNetworkInterfacesMessage{
467467
MessageId: aws.String("123"),
468468
ClusterArn: aws.String("default"),
469-
ElasticNetworkInterfaces: []*ecsacs.ElasticNetworkInterface{
469+
ElasticNetworkInterfaces: []*acstypes.ElasticNetworkInterface{
470470
{AttachmentArn: aws.String("attach_arn"),
471471
Ec2Id: aws.String("eni_id"),
472-
Ipv4Addresses: []*ecsacs.IPv4AddressAssignment{
472+
Ipv4Addresses: []acstypes.IPv4AddressAssignment{
473473
{
474474
Primary: aws.Bool(true),
475475
PrivateAddress: aws.String("ipv4"),
476476
},
477477
},
478-
Ipv6Addresses: []*ecsacs.IPv6AddressAssignment{
478+
Ipv6Addresses: []acstypes.IPv6AddressAssignment{
479479
{
480480
Address: aws.String("ipv6"),
481481
},

ecs-agent/acs/session/attach_instance_eni_responder.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525

2626
"github.com/aws/aws-sdk-go-v2/aws"
2727
ecsacs "github.com/aws/aws-sdk-go-v2/service/acs"
28+
acstypes "github.com/aws/aws-sdk-go-v2/service/acs/types"
2829
"github.com/pkg/errors"
2930
)
3031

@@ -94,7 +95,7 @@ func (r *attachInstanceENIResponder) handleAttachMessage(message *ecsacs.AttachI
9495

9596
// handleInstanceENIFromMessage handles the attachment of a given instance ENI from an
9697
// AttachInstanceNetworkInterfacesMessage.
97-
func (r *attachInstanceENIResponder) handleInstanceENIFromMessage(eni *ecsacs.ElasticNetworkInterface,
98+
func (r *attachInstanceENIResponder) handleInstanceENIFromMessage(eni *acstypes.ElasticNetworkInterface,
9899
messageID, clusterARN, containerInstanceARN string, receivedAt time.Time, waitTimeoutMs int64) {
99100
expiresAt := receivedAt.Add(time.Duration(waitTimeoutMs) * time.Millisecond)
100101
err := r.eniHandler.HandleENIAttachment(&ni.ENIAttachment{

ecs-agent/acs/session/attach_instance_eni_responder_test.go

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727

2828
"github.com/aws/aws-sdk-go-v2/aws"
2929
ecsacs "github.com/aws/aws-sdk-go-v2/service/acs"
30+
acstypes "github.com/aws/aws-sdk-go-v2/service/acs/types"
3031
"github.com/golang/mock/gomock"
3132
"github.com/stretchr/testify/assert"
3233
)
@@ -35,13 +36,13 @@ var testAttachInstanceENIMessage = &ecsacs.AttachInstanceNetworkInterfacesMessag
3536
MessageId: aws.String(testconst.MessageID),
3637
ClusterArn: aws.String(testconst.ClusterARN),
3738
ContainerInstanceArn: aws.String(testconst.ContainerInstanceARN),
38-
ElasticNetworkInterfaces: []*ecsacs.ElasticNetworkInterface{
39+
ElasticNetworkInterfaces: []*acstypes.ElasticNetworkInterface{
3940
{
4041
Ec2Id: aws.String("1"),
4142
MacAddress: aws.String(testconst.RandomMAC),
42-
InterfaceAssociationProtocol: aws.String(testconst.InterfaceProtocol),
43+
InterfaceAssociationProtocol: testconst.InterfaceProtocol,
4344
SubnetGatewayIpv4Address: aws.String(testconst.GatewayIPv4),
44-
Ipv4Addresses: []*ecsacs.IPv4AddressAssignment{
45+
Ipv4Addresses: []acstypes.IPv4AddressAssignment{
4546
{
4647
Primary: aws.Bool(true),
4748
PrivateAddress: aws.String(testconst.IPv4Address),
@@ -115,12 +116,12 @@ func TestAttachInstanceENIMessageWithNoInterfaces(t *testing.T) {
115116
func TestAttachInstanceENIMessageWithMultipleInterfaces(t *testing.T) {
116117
testAttachInstanceENIMessage.ElasticNetworkInterfaces = append(
117118
testAttachInstanceENIMessage.ElasticNetworkInterfaces,
118-
&ecsacs.ElasticNetworkInterface{
119+
&acstypes.ElasticNetworkInterface{
119120
Ec2Id: aws.String("2"),
120121
MacAddress: aws.String(testconst.RandomMAC),
121-
InterfaceAssociationProtocol: aws.String(testconst.InterfaceProtocol),
122+
InterfaceAssociationProtocol: testconst.InterfaceProtocol,
122123
SubnetGatewayIpv4Address: aws.String(testconst.GatewayIPv4),
123-
Ipv4Addresses: []*ecsacs.IPv4AddressAssignment{
124+
Ipv4Addresses: []acstypes.IPv4AddressAssignment{
124125
{
125126
Primary: aws.Bool(true),
126127
PrivateAddress: aws.String(testconst.IPv4Address),
@@ -170,14 +171,10 @@ func TestAttachInstanceENIMessageWithInvalidNetworkDetails(t *testing.T) {
170171

171172
tempInterfaceAssociationProtocol :=
172173
testAttachInstanceENIMessage.ElasticNetworkInterfaces[0].InterfaceAssociationProtocol
173-
unsupportedInterfaceAssociationProtocol := aws.String("unsupported")
174-
testAttachInstanceENIMessage.ElasticNetworkInterfaces[0].InterfaceAssociationProtocol =
175-
unsupportedInterfaceAssociationProtocol
174+
testAttachInstanceENIMessage.ElasticNetworkInterfaces[0].InterfaceAssociationProtocol = "unsupported"
176175
err = validateAttachInstanceNetworkInterfacesMessage(testAttachInstanceENIMessage)
177-
assert.EqualError(t, err, fmt.Sprintf("invalid interface association protocol: %s",
178-
aws.ToString(unsupportedInterfaceAssociationProtocol)))
179-
testAttachInstanceENIMessage.ElasticNetworkInterfaces[0].InterfaceAssociationProtocol =
180-
aws.String(ni.VLANInterfaceAssociationProtocol)
176+
assert.EqualError(t, err, "invalid interface association protocol: unsupported")
177+
testAttachInstanceENIMessage.ElasticNetworkInterfaces[0].InterfaceAssociationProtocol = ni.VLANInterfaceAssociationProtocol
181178
err = validateAttachInstanceNetworkInterfacesMessage(testAttachInstanceENIMessage)
182179
assert.EqualError(t, err, "vlan interface properties missing")
183180
testAttachInstanceENIMessage.ElasticNetworkInterfaces[0].InterfaceAssociationProtocol =

ecs-agent/acs/session/attach_task_eni_responder.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525

2626
"github.com/aws/aws-sdk-go-v2/aws"
2727
ecsacs "github.com/aws/aws-sdk-go-v2/service/acs"
28+
acstypes "github.com/aws/aws-sdk-go-v2/service/acs/types"
2829
"github.com/pkg/errors"
2930
)
3031

@@ -95,7 +96,7 @@ func (r *attachTaskENIResponder) handleAttachMessage(message *ecsacs.AttachTaskN
9596

9697
// handleTaskENIFromMessage handles the attachment of a given task ENI from an
9798
// AttachTaskNetworkInterfacesInput.
98-
func (r *attachTaskENIResponder) handleTaskENIFromMessage(eni ecsacs.ElasticNetworkInterface,
99+
func (r *attachTaskENIResponder) handleTaskENIFromMessage(eni acstypes.ElasticNetworkInterface,
99100
messageID, taskARN, clusterARN, containerInstanceARN string, receivedAt time.Time, waitTimeoutMs int64) {
100101
expiresAt := receivedAt.Add(time.Duration(waitTimeoutMs) * time.Millisecond)
101102
err := r.eniHandler.HandleENIAttachment(&ni.ENIAttachment{

ecs-agent/api/attachment/eni/eni.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
loggerfield "github.com/aws/amazon-ecs-agent/ecs-agent/logger/field"
2424

2525
"github.com/aws/aws-sdk-go-v2/aws"
26-
ecsacs "github.com/aws/aws-sdk-go-v2/service/acs"
26+
acstypes "github.com/aws/aws-sdk-go-v2/service/acs/types"
2727
"github.com/pkg/errors"
2828
)
2929

@@ -288,7 +288,7 @@ type ENIIPV6Address struct {
288288
}
289289

290290
// ENIFromACS validates the given ACS ENI information and creates an ENI object from it.
291-
func ENIFromACS(acsENI *ecsacs.ElasticNetworkInterface) (*ENI, error) {
291+
func ENIFromACS(acsENI *acstypes.ElasticNetworkInterface) (*ENI, error) {
292292
err := ValidateENI(acsENI)
293293
if err != nil {
294294
return nil, err
@@ -315,7 +315,7 @@ func ENIFromACS(acsENI *ecsacs.ElasticNetworkInterface) (*ENI, error) {
315315
// Read ENI association properties.
316316
var interfaceVlanProperties InterfaceVlanProperties
317317

318-
if aws.ToString(acsENI.InterfaceAssociationProtocol) == VLANInterfaceAssociationProtocol {
318+
if string(acsENI.InterfaceAssociationProtocol) == VLANInterfaceAssociationProtocol {
319319
interfaceVlanProperties.TrunkInterfaceMacAddress = aws.ToString(acsENI.InterfaceVlanProperties.TrunkInterfaceMacAddress)
320320
interfaceVlanProperties.VlanID = aws.ToString(acsENI.InterfaceVlanProperties.VlanId)
321321
}
@@ -327,22 +327,22 @@ func ENIFromACS(acsENI *ecsacs.ElasticNetworkInterface) (*ENI, error) {
327327
IPV6Addresses: ipv6Addrs,
328328
SubnetGatewayIPV4Address: aws.ToString(acsENI.SubnetGatewayIpv4Address),
329329
PrivateDNSName: aws.ToString(acsENI.PrivateDnsName),
330-
InterfaceAssociationProtocol: aws.ToString(acsENI.InterfaceAssociationProtocol),
330+
InterfaceAssociationProtocol: string(acsENI.InterfaceAssociationProtocol),
331331
InterfaceVlanProperties: &interfaceVlanProperties,
332332
}
333333

334334
for _, nameserverIP := range acsENI.DomainNameServers {
335-
eni.DomainNameServers = append(eni.DomainNameServers, aws.ToString(nameserverIP))
335+
eni.DomainNameServers = append(eni.DomainNameServers, nameserverIP)
336336
}
337337
for _, nameserverDomain := range acsENI.DomainName {
338-
eni.DomainNameSearchList = append(eni.DomainNameSearchList, aws.ToString(nameserverDomain))
338+
eni.DomainNameSearchList = append(eni.DomainNameSearchList, nameserverDomain)
339339
}
340340

341341
return eni, nil
342342
}
343343

344344
// ValidateENI validates the ENI information sent from ACS.
345-
func ValidateENI(acsENI *ecsacs.ElasticNetworkInterface) error {
345+
func ValidateENI(acsENI *acstypes.ElasticNetworkInterface) error {
346346
// At least one IPv4 address should be associated with the ENI.
347347
if len(acsENI.Ipv4Addresses) < 1 {
348348
return errors.Errorf("eni message validation: no ipv4 addresses in the message")
@@ -367,15 +367,15 @@ func ValidateENI(acsENI *ecsacs.ElasticNetworkInterface) error {
367367
}
368368

369369
// The association protocol, if specified, must be a supported value.
370-
if (acsENI.InterfaceAssociationProtocol != nil) &&
371-
(aws.ToString(acsENI.InterfaceAssociationProtocol) != VLANInterfaceAssociationProtocol) &&
372-
(aws.ToString(acsENI.InterfaceAssociationProtocol) != DefaultInterfaceAssociationProtocol) {
370+
if (acsENI.InterfaceAssociationProtocol != "") &&
371+
(acsENI.InterfaceAssociationProtocol != VLANInterfaceAssociationProtocol) &&
372+
(acsENI.InterfaceAssociationProtocol != DefaultInterfaceAssociationProtocol) {
373373
return errors.Errorf("invalid interface association protocol: %s",
374-
aws.ToString(acsENI.InterfaceAssociationProtocol))
374+
acsENI.InterfaceAssociationProtocol)
375375
}
376376

377377
// If the interface association protocol is vlan, InterfaceVlanProperties must be specified.
378-
if aws.ToString(acsENI.InterfaceAssociationProtocol) == VLANInterfaceAssociationProtocol {
378+
if acsENI.InterfaceAssociationProtocol == VLANInterfaceAssociationProtocol {
379379
if acsENI.InterfaceVlanProperties == nil ||
380380
len(aws.ToString(acsENI.InterfaceVlanProperties.VlanId)) == 0 ||
381381
len(aws.ToString(acsENI.InterfaceVlanProperties.TrunkInterfaceMacAddress)) == 0 {

0 commit comments

Comments
 (0)