Skip to content

Commit

Permalink
LB: Adding tag support for creating LB (#196)
Browse files Browse the repository at this point in the history
* lb: adding tag support for creating LB

* lb: changing Tags to accept array of strings

* lb: set CHANGELOG to unreleased
  • Loading branch information
katallaxie authored Dec 18, 2018
1 parent e8cd832 commit 017f7ac
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 4 additions & 0 deletions load_balancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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"`
}

Expand All @@ -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
Expand Down Expand Up @@ -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"`
}

Expand Down
5 changes: 4 additions & 1 deletion load_balancers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ var lbCreateJSONResponse = `
"storage"
],
"available":true
},
},
"tags": ["my-tag"],
"droplet_ids":[
2,
21
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -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,
}
Expand Down

0 comments on commit 017f7ac

Please sign in to comment.