Skip to content

Commit

Permalink
Merge pull request #658 from l1b0k/main
Browse files Browse the repository at this point in the history
fix: requested ip count
  • Loading branch information
l1b0k authored Jul 25, 2024
2 parents 0329274 + 5bbd590 commit 94795f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/aliyun/client/ecs_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ func (c *CreateNetworkInterfaceOptions) ApplyCreateNetworkInterface(options *Cre
if c.NetworkInterfaceOptions.SecurityGroupIDs != nil {
options.NetworkInterfaceOptions.SecurityGroupIDs = c.NetworkInterfaceOptions.SecurityGroupIDs
}
if c.NetworkInterfaceOptions.IPCount > 1 {
if c.NetworkInterfaceOptions.IPCount >= 1 {
options.NetworkInterfaceOptions.IPCount = c.NetworkInterfaceOptions.IPCount
}

if c.NetworkInterfaceOptions.IPv6Count > 1 {
if c.NetworkInterfaceOptions.IPv6Count >= 1 {
options.NetworkInterfaceOptions.IPv6Count = c.NetworkInterfaceOptions.IPv6Count
}
if c.NetworkInterfaceOptions.Tags != nil {
Expand Down
6 changes: 5 additions & 1 deletion pkg/aliyun/client/ecs_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package client
import (
"testing"

"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
"github.com/stretchr/testify/assert"
"k8s.io/apimachinery/pkg/util/wait"
)
Expand Down Expand Up @@ -56,6 +57,8 @@ func TestCreateNetworkInterfaceOptions_Finish(t *testing.T) {
assert.Equal(t, niOptions.ResourceGroupID, req.ResourceGroupId)
assert.Equal(t, eniDescription, req.Description)
assert.Equal(t, "mockToken", req.ClientToken)
assert.Equal(t, requests.NewInteger(1), req.SecondaryPrivateIpAddressCount)
assert.Equal(t, requests.NewInteger(1), req.Ipv6AddressCount)
assert.NotNil(t, c.Backoff)

// Cleanup
Expand Down Expand Up @@ -87,6 +90,7 @@ func TestCreateNetworkInterfaceOptions_ApplyCreateNetworkInterface(t *testing.T)
Trunk: true,
ERDMA: true,
IPCount: 2,
IPv6Count: 1,
},
},
args: args{
Expand All @@ -102,7 +106,7 @@ func TestCreateNetworkInterfaceOptions_ApplyCreateNetworkInterface(t *testing.T)
SecurityGroupIDs: []string{"sg-xxxxxx"},
ResourceGroupID: "rg-xxxxxx",
IPCount: 2,
IPv6Count: 0,
IPv6Count: 1,
Tags: map[string]string{"key1": "value1", "key2": "value2"},
InstanceID: "",
InstanceType: "",
Expand Down

0 comments on commit 94795f0

Please sign in to comment.