From 5904f41ac68c0e37f05c0c29ff16175634a8b8c2 Mon Sep 17 00:00:00 2001 From: Matt Siwiec Date: Thu, 29 Jun 2023 22:22:52 +0000 Subject: [PATCH] correct fragment location Signed-off-by: Matt Siwiec --- pkg/lbapi/client_test.go | 37 +++++++++++++++++++++---------------- pkg/lbapi/types.go | 19 +++++++++---------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/pkg/lbapi/client_test.go b/pkg/lbapi/client_test.go index 54e6455a1..1e582d33e 100644 --- a/pkg/lbapi/client_test.go +++ b/pkg/lbapi/client_test.go @@ -18,21 +18,25 @@ func TestGetLoadBalancer(t *testing.T) { "loadBalancer": { "id": "loadbal-randovalue", "name": "some lb", + "IPAddresses": [ + { + "id": "ipamipa-randovalue", + "ip": "192.168.1.42", + "reserved": false + }, + { + "id": "ipamipa-randovalue2", + "ip": "192.168.1.1", + "reserved": true + } + ], "ports": { "edges": [ { "node": { "name": "porty", "id": "loadprt-randovalue", - "number": 80, - "nodeID": "loadbal-randovalue", - "IPAddresses": [ - { - "id": "ipamipa-randovalue", - "ip": "192.168.1.42", - "reserved": false - } - ] + "number": 80 } } ] @@ -59,17 +63,18 @@ func TestGetLoadBalancer(t *testing.T) { assert.Equal(t, "loadbal-randovalue", lb.LoadBalancer.ID) assert.Equal(t, "some lb", lb.LoadBalancer.Name) - - require.Len(t, lb.LoadBalancer.Ports.Edges, 1) - assert.Equal(t, "loadprt-randovalue", lb.LoadBalancer.Ports.Edges[0].Node.ID) assert.Equal(t, "porty", lb.LoadBalancer.Ports.Edges[0].Node.Name) assert.Equal(t, int64(80), lb.LoadBalancer.Ports.Edges[0].Node.Number) assert.Empty(t, lb.LoadBalancer.Ports.Edges[0].Node.Pools) - require.Len(t, lb.LoadBalancer.Ports.Edges[0].Node.IPAddresses, 1) - assert.Equal(t, "ipamipa-randovalue", lb.LoadBalancer.Ports.Edges[0].Node.IPAddresses[0].ID) - assert.Equal(t, "192.168.1.42", lb.LoadBalancer.Ports.Edges[0].Node.IPAddresses[0].IP) - assert.False(t, lb.LoadBalancer.Ports.Edges[0].Node.IPAddresses[0].Reserved) + require.Len(t, lb.LoadBalancer.IPAddresses, 2) + assert.Equal(t, "ipamipa-randovalue", lb.LoadBalancer.IPAddresses[0].ID) + assert.Equal(t, "192.168.1.42", lb.LoadBalancer.IPAddresses[0].IP) + assert.False(t, lb.LoadBalancer.IPAddresses[0].Reserved) + + assert.Equal(t, "ipamipa-randovalue2", lb.LoadBalancer.IPAddresses[1].ID) + assert.Equal(t, "192.168.1.1", lb.LoadBalancer.IPAddresses[1].IP) + assert.True(t, lb.LoadBalancer.IPAddresses[1].Reserved) }) } diff --git a/pkg/lbapi/types.go b/pkg/lbapi/types.go index c0d103c0d..ef7d9890d 100644 --- a/pkg/lbapi/types.go +++ b/pkg/lbapi/types.go @@ -24,11 +24,10 @@ type Pool struct { } type PortNode struct { - ID string - Name string - Number int64 - IPAddressableFragment `graphql:"... on IPAddressable"` - Pools []Pool + ID string + Name string + Number int64 + Pools []Pool } type PortEdges struct { @@ -40,9 +39,10 @@ type Ports struct { } type LoadBalancer struct { - ID string - Name string - Ports Ports + ID string + Name string + IPAddressableFragment `graphql:"... on IPAddressable"` + Ports Ports } type GetLoadBalancer struct { @@ -56,7 +56,6 @@ type IPAddress struct { } type IPAddressableFragment struct { - NodeID string `graphql:"nodeID: id"` // alias ID to nodeID IPAddresses []IPAddress } @@ -65,12 +64,12 @@ type IPAddressableFragment struct { // LoadBalancer struct { // ID string // Name string +// IPAddressableFragment // Ports struct { // Edges []struct { // Node struct { // Name string // Number int64 -// IPAddressableFragment // Pools []struct { // Name string // Protocol string