From 076f5894bbaeffea1b257f9422b5605646a25930 Mon Sep 17 00:00:00 2001 From: Anit Gandhi Date: Tue, 15 Nov 2022 09:27:32 -0600 Subject: [PATCH] doctl/commands: Load Balancers updates (#1307) * doctl/commands: move Load Balancers forwarding rules details to embedded file * doctl/commands: add UDP protocol to Load Balancer docs This has been released for a while. * doctl/commands: add HTTP/3 protocol to Load Balancer docs This is currently in beta. * doctl/commands: move Load Balancers details to embedded file Co-authored-by: Andrew Starr-Bochicchio --- commands/forwarding_detail.txt | 6 +++++ commands/lb_detail.txt | 15 +++++++++++ commands/load_balancers.go | 47 +++++++++++----------------------- 3 files changed, 36 insertions(+), 32 deletions(-) create mode 100644 commands/forwarding_detail.txt create mode 100644 commands/lb_detail.txt diff --git a/commands/forwarding_detail.txt b/commands/forwarding_detail.txt new file mode 100644 index 000000000..b6ccf0d3f --- /dev/null +++ b/commands/forwarding_detail.txt @@ -0,0 +1,6 @@ +- `entry_protocol`: The entry protocol used for traffic to the load balancer. Possible values are: `http`, `https`, `http2`, `http3`, `tcp`, or `udp`. +- `entry_port`: The entry port used for incoming traffic to the load balancer. +- `target_protocol`: The target protocol used for traffic from the load balancer to the backend Droplets. Possible values are: `http`, `https`, `http2`, `http3`, `tcp`, or `udp`. +- `target_port`: The target port used to send traffic from the load balancer to the backend Droplets. +- `certificate_id`: The ID of the TLS certificate used for SSL termination, if enabled. Can be obtained with `doctl certificate list` +- `tls_passthrough`: Whether SSL passthrough is enabled on the load balancer. diff --git a/commands/lb_detail.txt b/commands/lb_detail.txt new file mode 100644 index 000000000..343302293 --- /dev/null +++ b/commands/lb_detail.txt @@ -0,0 +1,15 @@ +- The load balancer's ID +- The load balancer's name +- The load balancer's IP address +- The load balancer's traffic algorithm. Must + be either `round_robin` or `least_connections` +- The current state of the load balancer. This can be `new`, `active`, or `errored`. +- The load balancer's creation date, in ISO8601 combined date and time format. +- The load balancer's forwarding rules. See `doctl compute load-balancer add-forwarding-rules --help` for a list. +- The `health_check` settings for the load balancer. +- The `sticky_sessions` settings for the load balancer. +- The datacenter region the load balancer is located in. +- The Droplet tag corresponding to the Droplets assigned to the load balancer. +- The IDs of the Droplets assigned to the load balancer. +- Whether HTTP request to the load balancer on port 80 will be redirected to HTTPS on port 443. +- Whether the PROXY protocol is in use on the load balancer. diff --git a/commands/load_balancers.go b/commands/load_balancers.go index 66a67bbc4..cb834ae82 100644 --- a/commands/load_balancers.go +++ b/commands/load_balancers.go @@ -14,6 +14,7 @@ limitations under the License. package commands import ( + _ "embed" "fmt" "os" "reflect" @@ -28,6 +29,14 @@ import ( "github.com/spf13/cobra" ) +var ( + //go:embed forwarding_detail.txt + forwardingDetail string + + //go:embed lb_detail.txt + lbDetail string +) + // LoadBalancer creates the load balancer command. func LoadBalancer() *Command { cmd := &Command{ @@ -39,39 +48,13 @@ func LoadBalancer() *Command { With the load-balancer command, you can list, create, or delete load balancers, and manage their configuration details.`, }, } - lbDetail := ` - -- The load balancer's ID -- The load balancer's name -- The load balancer's IP address -- The load balancer's traffic algorithm. Must - be either ` + "`" + `round_robin` + "`" + ` or ` + "`" + `least_connections` + "`" + ` -- The current state of the load balancer. This can be ` + "`" + `new` + "`" + `, ` + "`" + `active` + "`" + `, or ` + "`" + `errored` + "`" + `. -- The load balancer's creation date, in ISO8601 combined date and time format. -- The load balancer's forwarding rules. See ` + "`" + `doctl compute load-balancer add-forwarding-rules --help` + "`" + ` for a list. -- The ` + "`" + `health_check` + "`" + ` settings for the load balancer. -- The ` + "`" + `sticky_sessions` + "`" + ` settings for the load balancer. -- The datacenter region the load balancer is located in. -- The Droplet tag corresponding to the Droplets assigned to the load balancer. -- The IDs of the Droplets assigned to the load balancer. -- Whether HTTP request to the load balancer on port 80 will be redirected to HTTPS on port 443. -- Whether the PROXY protocol is in use on the load balancer. -` - forwardingDetail := ` - -- ` + "`" + `entry_protocol` + "`" + `: The entry protocol used for traffic to the load balancer. Possible values are: ` + "`" + `http` + "`" + `, ` + "`" + `https` + "`" + `, ` + "`" + `http2` + "`" + `, or ` + "`" + `tcp` + "`" + `. -- ` + "`" + `entry_port` + "`" + `: The entry port used for incoming traffic to the load balancer. -- ` + "`" + `target_protocol` + "`" + `: The target protocol used for traffic from the load balancer to the backend Droplets. Possible values are: ` + "`" + `http` + "`" + `, ` + "`" + `https` + "`" + `, ` + "`" + `http2` + "`" + `, or ` + "`" + `tcp` + "`" + `. -- ` + "`" + `target_port` + "`" + `: The target port used to send traffic from the load balancer to the backend Droplets. -- ` + "`" + `certificate_id` + "`" + `: The ID of the TLS certificate used for SSL termination, if enabled. Can be obtained with ` + "`" + `doctl certificate list` + "`" + ` -- ` + "`" + `tls_passthrough` + "`" + `: Whether SSL passthrough is enabled on the load balancer. -` + forwardingRulesTxt := "A comma-separated list of key-value pairs representing forwarding rules, which define how traffic is routed, e.g.: `entry_protocol:tcp,entry_port:3306,target_protocol:tcp,target_port:3306`." - CmdBuilder(cmd, RunLoadBalancerGet, "get ", "Retrieve a load balancer", "Use this command to retrieve information about a load balancer instance, including:"+lbDetail, Writer, + CmdBuilder(cmd, RunLoadBalancerGet, "get ", "Retrieve a load balancer", "Use this command to retrieve information about a load balancer instance, including:\n\n"+lbDetail, Writer, aliasOpt("g"), displayerType(&displayers.LoadBalancer{})) cmdRecordCreate := CmdBuilder(cmd, RunLoadBalancerCreate, "create", - "Create a new load balancer", "Use this command to create a new load balancer on your account. Valid forwarding rules are:"+forwardingDetail, Writer, aliasOpt("c")) + "Create a new load balancer", "Use this command to create a new load balancer on your account. Valid forwarding rules are:\n"+forwardingDetail, Writer, aliasOpt("c")) AddStringFlag(cmdRecordCreate, doctl.ArgLoadBalancerName, "", "", "The load balancer's name", requiredOpt()) AddStringFlag(cmdRecordCreate, doctl.ArgRegionSlug, "", "", @@ -132,7 +115,7 @@ With the load-balancer command, you can list, create, or delete load balancers, AddBoolFlag(cmdRecordUpdate, doctl.ArgDisableLetsEncryptDNSRecords, "", false, "disable automatic DNS record creation for Let's Encrypt certificates that are added to the load balancer") - CmdBuilder(cmd, RunLoadBalancerList, "list", "List load balancers", "Use this command to get a list of the load balancers on your account, including the following information for each:"+lbDetail, Writer, + CmdBuilder(cmd, RunLoadBalancerList, "list", "List load balancers", "Use this command to get a list of the load balancers on your account, including the following information for each:\n\n"+lbDetail, Writer, aliasOpt("ls"), displayerType(&displayers.LoadBalancer{})) cmdRunRecordDelete := CmdBuilder(cmd, RunLoadBalancerDelete, "delete ", @@ -151,11 +134,11 @@ With the load-balancer command, you can list, create, or delete load balancers, "A comma-separated list of IDs of Droplets to remove from the load balancer, example value: `12,33`") cmdAddForwardingRules := CmdBuilder(cmd, RunLoadBalancerAddForwardingRules, - "add-forwarding-rules ", "Add forwarding rules to a load balancer", "Use this command to add forwarding rules to a load balancer, specified with the `--forwarding-rules` flag. Valid rules include:"+forwardingDetail, Writer) + "add-forwarding-rules ", "Add forwarding rules to a load balancer", "Use this command to add forwarding rules to a load balancer, specified with the `--forwarding-rules` flag. Valid rules include:\n"+forwardingDetail, Writer) AddStringFlag(cmdAddForwardingRules, doctl.ArgForwardingRules, "", "", forwardingRulesTxt) cmdRemoveForwardingRules := CmdBuilder(cmd, RunLoadBalancerRemoveForwardingRules, - "remove-forwarding-rules ", "Remove forwarding rules from a load balancer", "Use this command to remove forwarding rules from a load balancer, specified with the `--forwarding-rules` flag. Valid rules include:"+forwardingDetail, Writer) + "remove-forwarding-rules ", "Remove forwarding rules from a load balancer", "Use this command to remove forwarding rules from a load balancer, specified with the `--forwarding-rules` flag. Valid rules include:\n"+forwardingDetail, Writer) AddStringFlag(cmdRemoveForwardingRules, doctl.ArgForwardingRules, "", "", forwardingRulesTxt) return cmd