From 017f7aceec582c640f51fb78619fece6b800f03f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20D=C3=B6ll?= Date: Tue, 18 Dec 2018 11:29:37 +0100 Subject: [PATCH] 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 --- CHANGELOG.md | 4 ++++ load_balancers.go | 4 ++++ load_balancers_test.go | 5 ++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6264feb..a8207c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/load_balancers.go b/load_balancers.go index 1472fff..b873483 100644 --- a/load_balancers.go +++ b/load_balancers.go @@ -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"` } diff --git a/load_balancers_test.go b/load_balancers_test.go index 52e673a..a3f287c 100644 --- a/load_balancers_test.go +++ b/load_balancers_test.go @@ -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, }