Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit 1724f2c

Browse files
author
[Partner] Alexander Sokolov
committed
instance's interface read fixed
gcore_lblistener example updated
1 parent 772e88d commit 1724f2c

File tree

3 files changed

+12
-24
lines changed

3 files changed

+12
-24
lines changed

docs/resources/gcore_lblistener.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,11 @@ provider gcore {
1717
permanent_api_token = "251$d3361.............1b35f26d8"
1818
}
1919
20-
resource "gcore_loadbalancer" "lb" {
20+
resource "gcore_loadbalancerv2" "lb" {
2121
project_id = 1
2222
region_id = 1
2323
name = "test"
2424
flavor = "lb1-1-2"
25-
26-
listener {
27-
name = "test3"
28-
protocol = "HTTP"
29-
protocol_port = 8080
30-
}
3125
}
3226
3327
resource "gcore_lblistener" "listener" {
@@ -36,7 +30,7 @@ resource "gcore_lblistener" "listener" {
3630
name = "test"
3731
protocol = "TCP"
3832
protocol_port = 36621
39-
loadbalancer_id = gcore_loadbalancer.lb.id
33+
loadbalancer_id = gcore_loadbalancerv2.lb.id
4034
}
4135
```
4236

examples/resources/gcore_lblistener/resource.tf

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,11 @@ provider gcore {
22
permanent_api_token = "251$d3361.............1b35f26d8"
33
}
44

5-
resource "gcore_loadbalancer" "lb" {
5+
resource "gcore_loadbalancerv2" "lb" {
66
project_id = 1
77
region_id = 1
88
name = "test"
99
flavor = "lb1-1-2"
10-
11-
listener {
12-
name = "test3"
13-
protocol = "HTTP"
14-
protocol_port = 8080
15-
}
1610
}
1711

1812
resource "gcore_lblistener" "listener" {
@@ -21,5 +15,5 @@ resource "gcore_lblistener" "listener" {
2115
name = "test"
2216
protocol = "TCP"
2317
protocol_port = 36621
24-
loadbalancer_id = gcore_loadbalancer.lb.id
18+
loadbalancer_id = gcore_loadbalancerv2.lb.id
2519
}

gcore/resource_gcore_instance.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ func resourceInstanceRead(ctx context.Context, d *schema.ResourceData, m interfa
539539
}
540540

541541
var cleanInterfaces []interface{}
542-
for _, iface := range ifs {
542+
for ifOrder, iface := range ifs {
543543
if len(iface.IPAssignments) == 0 {
544544
continue
545545
}
@@ -560,20 +560,20 @@ func resourceInstanceRead(ctx context.Context, d *schema.ResourceData, m interfa
560560
}
561561
}
562562

563+
i := make(map[string]interface{})
563564
if !ok {
564-
continue
565+
orderedIOpts = OrderedInterfaceOpts{Order: ifOrder}
566+
} else {
567+
i["type"] = iOpts.Type.String()
565568
}
566569

567-
i := make(map[string]interface{})
568-
569-
i["type"] = iOpts.Type.String()
570570
i["network_id"] = iface.NetworkID
571571
i["subnet_id"] = subnetID
572572
i["port_id"] = iface.PortID
573573
i["order"] = orderedIOpts.Order
574-
if iOpts.FloatingIP != nil {
575-
i["fip_source"] = iOpts.FloatingIP.Source.String()
576-
i["existing_fip_id"] = iOpts.FloatingIP.ExistingFloatingID
574+
if len(iface.FloatingIPDetails) > 0 {
575+
i["fip_source"] = types.ExistingFloatingIP
576+
i["existing_fip_id"] = iface.FloatingIPDetails[0].ID
577577
}
578578
i["ip_address"] = assignment.IPAddress.String()
579579

0 commit comments

Comments
 (0)