Skip to content

Commit

Permalink
LBAAS-3620: support load balancers network_stack
Browse files Browse the repository at this point in the history
  • Loading branch information
jvasilevsky committed Jan 27, 2025
1 parent 688f5b2 commit f8958e1
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 20 deletions.
2 changes: 2 additions & 0 deletions args.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ const (
ArgTargetLoadBalancerIDs = "target-lb-ids"
// ArgLoadBalancerNetwork is the type of network the load balancer is accessible from.
ArgLoadBalancerNetwork = "network"
// ArgLoadBalancerNetworkStack is the network stack type the load balancer will be configured with (e.g IPv4, Dual Stack: IPv4 and IPv6).
ArgLoadBalancerNetworkStack = "network_stack"

// ArgFirewallName is a name of the firewall.
ArgFirewallName = "name"
Expand Down
8 changes: 8 additions & 0 deletions commands/load_balancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ With the load-balancer command, you can list, create, or delete load balancers,
AddStringSliceFlag(cmdLoadBalancerCreate, doctl.ArgTargetLoadBalancerIDs, "", []string{},
"A comma-separated list of Load Balancer IDs to add as target to the global load balancer ")
AddStringFlag(cmdLoadBalancerCreate, doctl.ArgLoadBalancerNetwork, "", "", "The type of network the load balancer is accessible from, e.g.: `EXTERNAL` or `INTERNAL`")
AddStringFlag(cmdLoadBalancerCreate, doctl.ArgLoadBalancerNetworkStack, "", "", "The network stack type determines the allocation of ipv4/ipv6 addresses to the load balancer, e.g.: `IPV4` or `DUALSTACK`"+
" (NOTE: this is a closed beta feature, contact DigitalOcean support to review its public availability.)")

cmdRecordUpdate := CmdBuilder(cmd, RunLoadBalancerUpdate, "update <load-balancer-id>",
"Update a load balancer's configuration", `Use this command to update the configuration of a specified load balancer. Using all applicable flags, the command should contain a full representation of the load balancer including existing attributes, such as the load balancer's name, region, forwarding rules, and Droplet IDs. Any attribute that is not provided is reset to its default value.`, Writer, aliasOpt("u"))
Expand Down Expand Up @@ -702,6 +704,12 @@ func buildRequestFromArgs(c *CmdConfig, r *godo.LoadBalancerRequest) error {
}
r.Network = strings.ToUpper(network)

networkStack, err := c.Doit.GetString(c.NS, doctl.ArgLoadBalancerNetworkStack)
if err != nil {
return err
}
r.NetworkStack = strings.ToUpper(networkStack)

return nil
}

Expand Down
8 changes: 6 additions & 2 deletions commands/load_balancers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ func TestLoadBalancerCreate(t *testing.T) {
Deny: []string{"cidr:1.2.0.0/16"},
Allow: []string{"ip:1.2.3.4", "ip:1.2.3.5"},
},
Network: "EXTERNAL",
Network: "EXTERNAL",
NetworkStack: "IPV4",
}
disableLetsEncryptDNSRecords := true
r.DisableLetsEncryptDNSRecords = &disableLetsEncryptDNSRecords
Expand All @@ -137,6 +138,7 @@ func TestLoadBalancerCreate(t *testing.T) {
config.Doit.Set(config.NS, doctl.ArgDenyList, []string{"cidr:1.2.0.0/16"})
config.Doit.Set(config.NS, doctl.ArgAllowList, []string{"ip:1.2.3.4", "ip:1.2.3.5"})
config.Doit.Set(config.NS, doctl.ArgLoadBalancerNetwork, "EXTERNAL")
config.Doit.Set(config.NS, doctl.ArgLoadBalancerNetworkStack, "IPV4")

err := RunLoadBalancerCreate(config)
assert.NoError(t, err)
Expand Down Expand Up @@ -184,7 +186,8 @@ func TestLoadBalancerCreateGLB(t *testing.T) {
"019cb059-603f-4828-8be4-641a20f25006",
"023da268-bc81-468f-aa4d-9abdc4f69935",
},
Network: "EXTERNAL",
Network: "EXTERNAL",
NetworkStack: "IPV4",
}
disableLetsEncryptDNSRecords := true
r.DisableLetsEncryptDNSRecords = &disableLetsEncryptDNSRecords
Expand All @@ -207,6 +210,7 @@ func TestLoadBalancerCreateGLB(t *testing.T) {
"023da268-bc81-468f-aa4d-9abdc4f69935",
})
config.Doit.Set(config.NS, doctl.ArgLoadBalancerNetwork, "EXTERNAL")
config.Doit.Set(config.NS, doctl.ArgLoadBalancerNetworkStack, "IPV4")

err := RunLoadBalancerCreate(config)
assert.NoError(t, err)
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.22
require (
github.com/blang/semver v3.5.1+incompatible
github.com/creack/pty v1.1.21
github.com/digitalocean/godo v1.134.0
github.com/digitalocean/godo v1.135.0
github.com/docker/cli v24.0.5+incompatible
github.com/docker/docker v25.0.6+incompatible
github.com/docker/docker-credential-helpers v0.7.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/digitalocean/godo v1.134.0 h1:dT7aQR9jxNOQEZwzP+tAYcxlj5szFZScC33+PAYGQVM=
github.com/digitalocean/godo v1.134.0/go.mod h1:PU8JB6I1XYkQIdHFop8lLAY9ojp6M0XcU0TWaQSxbrc=
github.com/digitalocean/godo v1.135.0 h1:H/A2wFBLo3hUDAw0xjHayHaNxY2hRvM3xxa+lTpriT8=
github.com/digitalocean/godo v1.135.0/go.mod h1:PU8JB6I1XYkQIdHFop8lLAY9ojp6M0XcU0TWaQSxbrc=
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
github.com/docker/cli v24.0.5+incompatible h1:WeBimjvS0eKdH4Ygx+ihVq1Q++xg36M/rMi4aXAvodc=
Expand Down

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

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

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

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

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

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 @@ -61,7 +61,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.134.0
# github.com/digitalocean/godo v1.135.0
## explicit; go 1.22
github.com/digitalocean/godo
github.com/digitalocean/godo/metrics
Expand Down

0 comments on commit f8958e1

Please sign in to comment.