Skip to content

Commit

Permalink
Merge pull request #316 from anitgandhi/anitgandhi/lb-backend-keepalive
Browse files Browse the repository at this point in the history
load balancers: add new enable_backend_keepalive field
  • Loading branch information
bentranter authored Mar 20, 2020
2 parents 4acd72d + e534d34 commit b81daab
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 44 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## unreleased

- #310 Add BillingHistory service and List endpoint - @rbutler
- #316 load balancers: add new enable_backend_keepalive field - @anitgandhi

## [v1.32.0] - 2020-03-04

Expand Down
77 changes: 40 additions & 37 deletions load_balancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,23 @@ type LoadBalancersService interface {
// LoadBalancer represents a DigitalOcean load balancer configuration.
// Tags can only be provided upon the creation of a Load Balancer.
type LoadBalancer struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
IP string `json:"ip,omitempty"`
Algorithm string `json:"algorithm,omitempty"`
Status string `json:"status,omitempty"`
Created string `json:"created_at,omitempty"`
ForwardingRules []ForwardingRule `json:"forwarding_rules,omitempty"`
HealthCheck *HealthCheck `json:"health_check,omitempty"`
StickySessions *StickySessions `json:"sticky_sessions,omitempty"`
Region *Region `json:"region,omitempty"`
DropletIDs []int `json:"droplet_ids,omitempty"`
Tag string `json:"tag,omitempty"`
Tags []string `json:"tags,omitempty"`
RedirectHttpToHttps bool `json:"redirect_http_to_https,omitempty"`
EnableProxyProtocol bool `json:"enable_proxy_protocol,omitempty"`
VPCUUID string `json:"vpc_uuid,omitempty"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
IP string `json:"ip,omitempty"`
Algorithm string `json:"algorithm,omitempty"`
Status string `json:"status,omitempty"`
Created string `json:"created_at,omitempty"`
ForwardingRules []ForwardingRule `json:"forwarding_rules,omitempty"`
HealthCheck *HealthCheck `json:"health_check,omitempty"`
StickySessions *StickySessions `json:"sticky_sessions,omitempty"`
Region *Region `json:"region,omitempty"`
DropletIDs []int `json:"droplet_ids,omitempty"`
Tag string `json:"tag,omitempty"`
Tags []string `json:"tags,omitempty"`
RedirectHttpToHttps bool `json:"redirect_http_to_https,omitempty"`
EnableProxyProtocol bool `json:"enable_proxy_protocol,omitempty"`
EnableBackendKeepalive bool `json:"enable_backend_keepalive,omitempty"`
VPCUUID string `json:"vpc_uuid,omitempty"`
}

// String creates a human-readable description of a LoadBalancer.
Expand All @@ -59,15 +60,16 @@ func (l LoadBalancer) URN() string {
// Modifying the returned LoadBalancerRequest will not modify the original LoadBalancer.
func (l LoadBalancer) AsRequest() *LoadBalancerRequest {
r := LoadBalancerRequest{
Name: l.Name,
Algorithm: l.Algorithm,
ForwardingRules: append([]ForwardingRule(nil), l.ForwardingRules...),
DropletIDs: append([]int(nil), l.DropletIDs...),
Tag: l.Tag,
RedirectHttpToHttps: l.RedirectHttpToHttps,
EnableProxyProtocol: l.EnableProxyProtocol,
HealthCheck: l.HealthCheck,
VPCUUID: l.VPCUUID,
Name: l.Name,
Algorithm: l.Algorithm,
ForwardingRules: append([]ForwardingRule(nil), l.ForwardingRules...),
DropletIDs: append([]int(nil), l.DropletIDs...),
Tag: l.Tag,
RedirectHttpToHttps: l.RedirectHttpToHttps,
EnableProxyProtocol: l.EnableProxyProtocol,
EnableBackendKeepalive: l.EnableBackendKeepalive,
HealthCheck: l.HealthCheck,
VPCUUID: l.VPCUUID,
}

if l.HealthCheck != nil {
Expand Down Expand Up @@ -129,18 +131,19 @@ func (s StickySessions) String() string {

// LoadBalancerRequest represents the configuration to be applied to an existing or a new load balancer.
type LoadBalancerRequest struct {
Name string `json:"name,omitempty"`
Algorithm string `json:"algorithm,omitempty"`
Region string `json:"region,omitempty"`
ForwardingRules []ForwardingRule `json:"forwarding_rules,omitempty"`
HealthCheck *HealthCheck `json:"health_check,omitempty"`
StickySessions *StickySessions `json:"sticky_sessions,omitempty"`
DropletIDs []int `json:"droplet_ids,omitempty"`
Tag string `json:"tag,omitempty"`
Tags []string `json:"tags,omitempty"`
RedirectHttpToHttps bool `json:"redirect_http_to_https,omitempty"`
EnableProxyProtocol bool `json:"enable_proxy_protocol,omitempty"`
VPCUUID string `json:"vpc_uuid,omitempty"`
Name string `json:"name,omitempty"`
Algorithm string `json:"algorithm,omitempty"`
Region string `json:"region,omitempty"`
ForwardingRules []ForwardingRule `json:"forwarding_rules,omitempty"`
HealthCheck *HealthCheck `json:"health_check,omitempty"`
StickySessions *StickySessions `json:"sticky_sessions,omitempty"`
DropletIDs []int `json:"droplet_ids,omitempty"`
Tag string `json:"tag,omitempty"`
Tags []string `json:"tags,omitempty"`
RedirectHttpToHttps bool `json:"redirect_http_to_https,omitempty"`
EnableProxyProtocol bool `json:"enable_proxy_protocol,omitempty"`
EnableBackendKeepalive bool `json:"enable_backend_keepalive,omitempty"`
VPCUUID string `json:"vpc_uuid,omitempty"`
}

// String creates a human-readable description of a LoadBalancerRequest.
Expand Down
16 changes: 9 additions & 7 deletions load_balancers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -829,9 +829,10 @@ func TestLoadBalancers_AsRequest(t *testing.T) {
Region: &Region{
Slug: "lon1",
},
RedirectHttpToHttps: true,
EnableProxyProtocol: true,
VPCUUID: "880b7f98-f062-404d-b33c-458d545696f6",
RedirectHttpToHttps: true,
EnableProxyProtocol: true,
EnableBackendKeepalive: true,
VPCUUID: "880b7f98-f062-404d-b33c-458d545696f6",
}
lb.DropletIDs = make([]int, 1, 2)
lb.DropletIDs[0] = 12345
Expand Down Expand Up @@ -867,10 +868,11 @@ func TestLoadBalancers_AsRequest(t *testing.T) {
CookieName: "nomnom",
CookieTtlSeconds: 32,
},
DropletIDs: []int{12345},
RedirectHttpToHttps: true,
EnableProxyProtocol: true,
VPCUUID: "880b7f98-f062-404d-b33c-458d545696f6",
DropletIDs: []int{12345},
RedirectHttpToHttps: true,
EnableProxyProtocol: true,
EnableBackendKeepalive: true,
VPCUUID: "880b7f98-f062-404d-b33c-458d545696f6",
}

r := lb.AsRequest()
Expand Down

0 comments on commit b81daab

Please sign in to comment.