Skip to content

Commit

Permalink
Add support for GLB active-passive failover config (#1526)
Browse files Browse the repository at this point in the history
* Vendor godo v1.115.0

* Support GLB failover config
  • Loading branch information
asaha2 authored May 9, 2024
1 parent 75b63a5 commit 35306b4
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 34 deletions.
12 changes: 12 additions & 0 deletions commands/load_balancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,18 @@ func fillStructFromStringSliceArgs(obj any, s string, delimiter string) error {
}
case reflect.String:
f.Set(reflect.ValueOf(val))
case reflect.Map:
for _, kvPair := range strings.Split(val, " ") {
kv := strings.Split(kvPair, "=")
if len(kv) == 2 {
if v32, err := strconv.ParseUint(kv[1], 10, 32); err == nil {
if f.IsZero() {
f.Set(reflect.MakeMap(f.Type()))
}
f.SetMapIndex(reflect.ValueOf(kv[0]), reflect.ValueOf(uint32(v32)))
}
}
}
default:
return fmt.Errorf("Unexpected type for struct field %v", val)
}
Expand Down
20 changes: 12 additions & 8 deletions commands/load_balancers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,11 @@ func TestLoadBalancerCreateGLB(t *testing.T) {
UnhealthyThreshold: 3,
},
GLBSettings: &godo.GLBSettings{
TargetProtocol: "http",
TargetPort: 80,
CDN: &godo.CDNSettings{IsEnabled: true},
TargetProtocol: "http",
TargetPort: 80,
CDN: &godo.CDNSettings{IsEnabled: true},
RegionPriorities: map[string]uint32{"nyc1": 1, "nyc2": 2},
FailoverThreshold: 10,
},
DropletIDs: []int{1, 2},
Domains: []*godo.LBDomain{
Expand Down Expand Up @@ -189,7 +191,7 @@ func TestLoadBalancerCreateGLB(t *testing.T) {
config.Doit.Set(config.NS, doctl.ArgLoadBalancerType, "GLOBAL")
config.Doit.Set(config.NS, doctl.ArgStickySessions, "type:none")
config.Doit.Set(config.NS, doctl.ArgHealthCheck, "protocol:http,port:80,path:/,check_interval_seconds:10,response_timeout_seconds:5,healthy_threshold:5,unhealthy_threshold:3")
config.Doit.Set(config.NS, doctl.ArgGlobalLoadBalancerSettings, "target_protocol:http,target_port:80")
config.Doit.Set(config.NS, doctl.ArgGlobalLoadBalancerSettings, "target_protocol:http,target_port:80,region_priorities:nyc1=1 nyc2=2,failover_threshold:10")
config.Doit.Set(config.NS, doctl.ArgGlobalLoadBalancerCDNSettings, "is_enabled:true")
config.Doit.Set(config.NS, doctl.ArgDropletIDs, []string{"1", "2"})
config.Doit.Set(config.NS, doctl.ArgLoadBalancerDomains, []string{
Expand Down Expand Up @@ -286,9 +288,11 @@ func TestLoadBalancerUpdateGLB(t *testing.T) {
UnhealthyThreshold: 3,
},
GLBSettings: &godo.GLBSettings{
TargetProtocol: "http",
TargetPort: 80,
CDN: &godo.CDNSettings{IsEnabled: true},
TargetProtocol: "http",
TargetPort: 80,
CDN: &godo.CDNSettings{IsEnabled: true},
RegionPriorities: map[string]uint32{"nyc1": 1, "nyc2": 2},
FailoverThreshold: 10,
},
DropletIDs: []int{1, 2},
Domains: []*godo.LBDomain{
Expand Down Expand Up @@ -317,7 +321,7 @@ func TestLoadBalancerUpdateGLB(t *testing.T) {
config.Doit.Set(config.NS, doctl.ArgLoadBalancerType, "GLOBAL")
config.Doit.Set(config.NS, doctl.ArgStickySessions, "type:none")
config.Doit.Set(config.NS, doctl.ArgHealthCheck, "protocol:http,port:80,path:/,check_interval_seconds:10,response_timeout_seconds:5,healthy_threshold:5,unhealthy_threshold:3")
config.Doit.Set(config.NS, doctl.ArgGlobalLoadBalancerSettings, "target_protocol:http,target_port:80")
config.Doit.Set(config.NS, doctl.ArgGlobalLoadBalancerSettings, "target_protocol:http,target_port:80,region_priorities:nyc1=1 nyc2=2,failover_threshold:10")
config.Doit.Set(config.NS, doctl.ArgGlobalLoadBalancerCDNSettings, "is_enabled:true")
config.Doit.Set(config.NS, doctl.ArgDropletIDs, []string{"1", "2"})
config.Doit.Set(config.NS, doctl.ArgLoadBalancerDomains, []string{
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21
require (
github.com/blang/semver v3.5.1+incompatible
github.com/creack/pty v1.1.11
github.com/digitalocean/godo v1.113.0
github.com/digitalocean/godo v1.115.0
github.com/docker/cli v24.0.5+incompatible
github.com/docker/docker v24.0.9+incompatible
github.com/docker/docker-credential-helpers v0.7.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/digitalocean/godo v1.113.0 h1:CLtCxlP4wDAjKIQ+Hshht/UNbgAp8/J/XBH1ZtDCF9Y=
github.com/digitalocean/godo v1.113.0/go.mod h1:Z2mTP848Vi3IXXl5YbPekUgr4j4tOePomA+OE1Ag98w=
github.com/digitalocean/godo v1.115.0 h1:Xv0gwN0t7ldD61QKeYeHHwCEKfTXzAOmnUDgGAzoZw4=
github.com/digitalocean/godo v1.115.0/go.mod h1:Vk0vpCot2HOAJwc5WE8wljZGtJ3ZtWIc8MQ8rF38sdo=
github.com/docker/cli v24.0.5+incompatible h1:WeBimjvS0eKdH4Ygx+ihVq1Q++xg36M/rMi4aXAvodc=
github.com/docker/cli v24.0.5+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8=
Expand Down
10 changes: 10 additions & 0 deletions vendor/github.com/digitalocean/godo/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 44 additions & 19 deletions vendor/github.com/digitalocean/godo/apps.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions vendor/github.com/digitalocean/godo/apps_accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/digitalocean/godo/godo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions vendor/github.com/digitalocean/godo/load_balancers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ github.com/creack/pty
# github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
## explicit
github.com/davecgh/go-spew/spew
# github.com/digitalocean/godo v1.113.0
# github.com/digitalocean/godo v1.115.0
## explicit; go 1.20
github.com/digitalocean/godo
github.com/digitalocean/godo/metrics
Expand Down

0 comments on commit 35306b4

Please sign in to comment.