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

net private ip: fix secondary_private_ip_count #104

Merged
merged 1 commit into from
Jul 11, 2022
Merged
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
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