Skip to content

Commit

Permalink
Merge pull request #1441 from yuh-indeed/master
Browse files Browse the repository at this point in the history
Add support for virtual network id in origin
  • Loading branch information
jacobbednarz committed Nov 16, 2023
2 parents 871524d + 665b54b commit 05ffe97
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .changelog/1441.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
load_balancing: Add support for virtual network id in origins
```
3 changes: 3 additions & 0 deletions load_balancing.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ type LoadBalancerOrigin struct {
// weight is used to scale the origin's open connections.
Weight float64 `json:"weight"`
Header map[string][]string `json:"header"`
// The virtual network subnet ID the origin belongs in.
// Virtual network must also belong to the account.
VirtualNetworkID string `json:"virtual_network_id,omitempty"`
}

// LoadBalancerOriginSteering controls origin selection for new sessions and traffic without session affinity.
Expand Down
40 changes: 26 additions & 14 deletions load_balancing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ func TestCreateLoadBalancerPool(t *testing.T) {
"Host": [
"example.com"
]
}
},
"virtual_network_id":"a5624d4e-044a-4ff0-b3e1-e2465353d4b4"
}
],
"notification_email": "someone@example.com",
Expand Down Expand Up @@ -90,7 +91,8 @@ func TestCreateLoadBalancerPool(t *testing.T) {
"Host": [
"example.com"
]
}
},
"virtual_network_id":"a5624d4e-044a-4ff0-b3e1-e2465353d4b4"
}
],
"notification_email": "someone@example.com",
Expand Down Expand Up @@ -137,6 +139,7 @@ func TestCreateLoadBalancerPool(t *testing.T) {
Header: map[string][]string{
"Host": {"example.com"},
},
VirtualNetworkID: "a5624d4e-044a-4ff0-b3e1-e2465353d4b4",
},
},
NotificationEmail: "someone@example.com",
Expand Down Expand Up @@ -169,6 +172,7 @@ func TestCreateLoadBalancerPool(t *testing.T) {
Header: map[string][]string{
"Host": {"example.com"},
},
VirtualNetworkID: "a5624d4e-044a-4ff0-b3e1-e2465353d4b4",
},
},
NotificationEmail: "someone@example.com",
Expand Down Expand Up @@ -286,7 +290,8 @@ func TestListLoadBalancerPools(t *testing.T) {
"name": "app-server-1",
"address": "198.51.100.1",
"enabled": true,
"weight": 1
"weight": 1,
"virtual_network_id":"a5624d4e-044a-4ff0-b3e1-e2465353d4b4"
}
],
"notification_email": "someone@example.com"
Expand Down Expand Up @@ -318,10 +323,11 @@ func TestListLoadBalancerPools(t *testing.T) {
},
Origins: []LoadBalancerOrigin{
{
Name: "app-server-1",
Address: "198.51.100.1",
Enabled: true,
Weight: 1,
Name: "app-server-1",
Address: "198.51.100.1",
Enabled: true,
Weight: 1,
VirtualNetworkID: "a5624d4e-044a-4ff0-b3e1-e2465353d4b4",
},
},
NotificationEmail: "someone@example.com",
Expand Down Expand Up @@ -371,7 +377,8 @@ func TestGetLoadBalancerPool(t *testing.T) {
"name": "app-server-1",
"address": "198.51.100.1",
"enabled": true,
"weight": 1
"weight": 1,
"virtual_network_id":"a5624d4e-044a-4ff0-b3e1-e2465353d4b4"
}
],
"notification_email": "someone@example.com"
Expand All @@ -395,10 +402,11 @@ func TestGetLoadBalancerPool(t *testing.T) {
},
Origins: []LoadBalancerOrigin{
{
Name: "app-server-1",
Address: "198.51.100.1",
Enabled: true,
Weight: 1,
Name: "app-server-1",
Address: "198.51.100.1",
Enabled: true,
Weight: 1,
VirtualNetworkID: "a5624d4e-044a-4ff0-b3e1-e2465353d4b4",
},
},
NotificationEmail: "someone@example.com",
Expand Down Expand Up @@ -483,7 +491,8 @@ func TestUpdateLoadBalancerPool(t *testing.T) {
"Host": [
"example.com"
]
}
},
"virtual_network_id":"a5624d4e-044a-4ff0-b3e1-e2465353d4b4"
}
],
"notification_email": "nobody@example.com",
Expand Down Expand Up @@ -516,7 +525,8 @@ func TestUpdateLoadBalancerPool(t *testing.T) {
"Host": [
"example.com"
]
}
},
"virtual_network_id":"a5624d4e-044a-4ff0-b3e1-e2465353d4b4"
}
],
"notification_email": "nobody@example.com",
Expand Down Expand Up @@ -549,6 +559,7 @@ func TestUpdateLoadBalancerPool(t *testing.T) {
Header: map[string][]string{
"Host": {"example.com"},
},
VirtualNetworkID: "a5624d4e-044a-4ff0-b3e1-e2465353d4b4",
},
},
NotificationEmail: "nobody@example.com",
Expand All @@ -573,6 +584,7 @@ func TestUpdateLoadBalancerPool(t *testing.T) {
Header: map[string][]string{
"Host": {"example.com"},
},
VirtualNetworkID: "a5624d4e-044a-4ff0-b3e1-e2465353d4b4",
},
},
NotificationEmail: "nobody@example.com",
Expand Down

0 comments on commit 05ffe97

Please sign in to comment.