Skip to content

Commit

Permalink
load_balancing: Add DrainDuration to session affinity attributes (c…
Browse files Browse the repository at this point in the history
…loudflare#560)

Discovered while adding Terraform support for session affinity
attributes.

API: https://api.cloudflare.com/#load-balancers-create-load-balancer
  • Loading branch information
jacobbednarz authored Dec 7, 2020
1 parent efb289d commit 20d8c26
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
5 changes: 3 additions & 2 deletions load_balancing.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ type LoadBalancer struct {

// SessionAffinityAttributes represents the fields used to set attributes in a load balancer session affinity cookie.
type SessionAffinityAttributes struct {
SameSite string `json:"samesite,omitempty"`
Secure string `json:"secure,omitempty"`
SameSite string `json:"samesite,omitempty"`
Secure string `json:"secure,omitempty"`
DrainDuration int `json:"drain_duration,omitempty"`
}

// LoadBalancerOriginHealth represents the health of the origin.
Expand Down
16 changes: 10 additions & 6 deletions load_balancing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,8 @@ func TestCreateLoadBalancer(t *testing.T) {
"session_affinity_ttl": 5000,
"session_affinity_attributes": {
"samesite": "Strict",
"secure": "Always"
"secure": "Always",
"drain_duration": 60
}
}`, string(b))
}
Expand Down Expand Up @@ -871,7 +872,8 @@ func TestCreateLoadBalancer(t *testing.T) {
"session_affinity_ttl": 5000,
"session_affinity_attributes": {
"samesite": "Strict",
"secure": "Always"
"secure": "Always",
"drain_duration": 60
}
}
}`)
Expand Down Expand Up @@ -919,8 +921,9 @@ func TestCreateLoadBalancer(t *testing.T) {
Persistence: "cookie",
PersistenceTTL: 5000,
SessionAffinityAttributes: &SessionAffinityAttributes{
SameSite: "Strict",
Secure: "Always",
SameSite: "Strict",
Secure: "Always",
DrainDuration: 60,
},
}
request := LoadBalancer{
Expand Down Expand Up @@ -959,8 +962,9 @@ func TestCreateLoadBalancer(t *testing.T) {
Persistence: "cookie",
PersistenceTTL: 5000,
SessionAffinityAttributes: &SessionAffinityAttributes{
SameSite: "Strict",
Secure: "Always",
SameSite: "Strict",
Secure: "Always",
DrainDuration: 60,
},
}

Expand Down

0 comments on commit 20d8c26

Please sign in to comment.