Skip to content

Commit

Permalink
net private ip: fix secondary_private_ip_count
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Gatto <[email protected]>
  • Loading branch information
outscale-mgo committed Apr 14, 2022
1 parent 7aa14a1 commit 0d86ed9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions outscale/resource_outscale_nic_private_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func resourceOutscaleOAPINetworkInterfacePrivateIPCreate(d *schema.ResourceData,
}

if v, ok := d.GetOk("secondary_private_ip_count"); ok {
input.SetSecondaryPrivateIpCount(int32(v.(int) - 1))
input.SetSecondaryPrivateIpCount(int32(v.(int)))
}

if v, ok := d.GetOk("private_ips"); ok {
Expand Down Expand Up @@ -145,11 +145,13 @@ func resourceOutscaleOAPINetworkInterfacePrivateIPRead(d *schema.ResourceData, m
// We need to avoid to store inside private_ips when private IP is the primary IP
//because the primary can't remove.
var primaryPrivateID string
secondary_private_ip_count := 0
for _, v := range eni.GetPrivateIps() {
if v.GetIsPrimary() {
primaryPrivateID = v.GetPrivateIp()
} else {
ips = append(ips, v.GetPrivateIp())
secondary_private_ip_count += 1
}
}

Expand All @@ -161,7 +163,7 @@ func resourceOutscaleOAPINetworkInterfacePrivateIPRead(d *schema.ResourceData, m
if err := d.Set("private_ips", ips); err != nil {
return err
}
if err := d.Set("secondary_private_ip_count", len(eni.GetPrivateIps())); err != nil {
if err := d.Set("secondary_private_ip_count", secondary_private_ip_count); err != nil {
return err
}
if err := d.Set("nic_id", eni.GetNicId()); err != nil {
Expand Down

0 comments on commit 0d86ed9

Please sign in to comment.