From 9251ac011562d3ba1eae94f4912eb1d48a105736 Mon Sep 17 00:00:00 2001 From: vaspahomov Date: Mon, 31 Jan 2022 11:59:02 +0500 Subject: [PATCH] Add Ipv6Prefixes option support in ec2.Instance (review fixes) Signed-off-by: vaspahomov --- apis/ec2/manualv1alpha1/common.go | 2 +- pkg/clients/ec2/instance.go | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apis/ec2/manualv1alpha1/common.go b/apis/ec2/manualv1alpha1/common.go index c3bd8e552e..ba0f033e00 100644 --- a/apis/ec2/manualv1alpha1/common.go +++ b/apis/ec2/manualv1alpha1/common.go @@ -559,7 +559,7 @@ type InstanceNetworkInterfaceSpecification struct { // cannot use this option if you use the Ipv6PrefixCount option. // +optional // +immutable - Ipv6Prefixes []Ipv6PrefixSpecificationRequest `json:"ipv6Prefixes"` + Ipv6Prefixes []Ipv6PrefixSpecificationRequest `json:"ipv6Prefixes,omitempty"` // The ID of the network interface. // diff --git a/pkg/clients/ec2/instance.go b/pkg/clients/ec2/instance.go index cf1cbe995c..8e9be6f8d5 100644 --- a/pkg/clients/ec2/instance.go +++ b/pkg/clients/ec2/instance.go @@ -505,16 +505,16 @@ func GenerateEC2InstanceIPV6Addresses(addrs []manualv1alpha1.InstanceIPv6Address // GenerateEC2Ipv6PrefixSpecificationRequest coverts an internal slice of Ipv6PrefixSpecificationRequest into a slice of ec2.Ipv6PrefixSpecificationRequest func GenerateEC2Ipv6PrefixSpecificationRequest(prefixes []manualv1alpha1.Ipv6PrefixSpecificationRequest) []types.Ipv6PrefixSpecificationRequest { - if prefixes != nil { - res := make([]types.Ipv6PrefixSpecificationRequest, len(prefixes)) - for i, a := range prefixes { - res[i] = types.Ipv6PrefixSpecificationRequest{ - Ipv6Prefix: aws.String(a.Ipv6Prefix), - } + if len(prefixes) == 0 { + return nil + } + res := make([]types.Ipv6PrefixSpecificationRequest, len(prefixes)) + for i, a := range prefixes { + res[i] = types.Ipv6PrefixSpecificationRequest{ + Ipv6Prefix: aws.String(a.Ipv6Prefix), } - return res } - return nil + return res } // GenerateInstanceIPV6Addresses coverts a slice of ec2.InstanceIpv6Address into a slice of internal InstanceIPv6Address