LB: Adding tag support for creating LB (#196)

* lb: adding tag support for creating LB

* lb: changing Tags to accept array of strings

* lb: set CHANGELOG to unreleased
This commit is contained in:
Sebastian Döll 2018-12-18 11:29:37 +01:00 committed by GitHub
parent e8cd8327b4
commit 017f7aceec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View File

@ -1,5 +1,9 @@
# Change Log
## [v1.7.3] - UNRELEASED
- #196 Expose tag support for creating Load Balancers.
## [v1.7.2] - 2018-12-04
- #192 Exposes more options for Kubernetes clusters.

View File

@ -26,6 +26,7 @@ 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"`
@ -39,6 +40,7 @@ type LoadBalancer struct {
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"`
}
@ -63,6 +65,7 @@ func (l LoadBalancer) AsRequest() *LoadBalancerRequest {
RedirectHttpToHttps: l.RedirectHttpToHttps,
HealthCheck: l.HealthCheck,
}
if l.HealthCheck != nil {
r.HealthCheck = &HealthCheck{}
*r.HealthCheck = *l.HealthCheck
@ -130,6 +133,7 @@ type LoadBalancerRequest struct {
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"`
}

View File

@ -138,7 +138,8 @@ var lbCreateJSONResponse = `
"storage"
],
"available":true
},
},
"tags": ["my-tag"],
"droplet_ids":[
2,
21
@ -365,6 +366,7 @@ func TestLoadBalancers_Create(t *testing.T) {
CookieTtlSeconds: 5,
},
Tag: "my-tag",
Tags: []string{"my-tag"},
DropletIDs: []int{2, 21},
RedirectHttpToHttps: true,
}
@ -433,6 +435,7 @@ func TestLoadBalancers_Create(t *testing.T) {
Available: true,
Features: []string{"private_networking", "backups", "ipv6", "metadata", "storage"},
},
Tags: []string{"my-tag"},
DropletIDs: []int{2, 21},
RedirectHttpToHttps: true,
}