Skip to content

Commit

Permalink
Merge branch 'main' into olove/add-control-plane-firewall
Browse files Browse the repository at this point in the history
  • Loading branch information
llDrLove authored Jun 14, 2024
2 parents e9ff4fc + 5dc52ae commit 22718aa
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
2 changes: 2 additions & 0 deletions args.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ const (
ArgGlobalLoadBalancerCDNSettings = "glb-cdn-settings"
// ArgTargetLoadBalancerIDs is a list of target load balancer IDs.
ArgTargetLoadBalancerIDs = "target-lb-ids"
// ArgLoadBalancerNetwork is the type of network the load balancer is accessible from.
ArgLoadBalancerNetwork = "network"

// ArgFirewallName is a name of the firewall.
ArgFirewallName = "name"
Expand Down
9 changes: 9 additions & 0 deletions commands/load_balancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ 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 "+
"(NOTE: this is a closed beta feature, contact DigitalOcean support to review its public availability.)")
AddStringFlag(cmdLoadBalancerCreate, doctl.ArgLoadBalancerNetwork, "", "", "The type of network the load balancer is accessible from, e.g.: `EXTERNAL` or `INTERNAL`"+
"(NOTE: this is a closed beta feature, contact DigitalOcean support to review its public availability.)")
cmdLoadBalancerCreate.Flags().MarkHidden(doctl.ArgLoadBalancerType)
cmdLoadBalancerCreate.Flags().MarkHidden(doctl.ArgLoadBalancerNetwork)

cmdRecordUpdate := CmdBuilder(cmd, RunLoadBalancerUpdate, "update <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 @@ -705,6 +708,12 @@ func buildRequestFromArgs(c *CmdConfig, r *godo.LoadBalancerRequest) error {
}
r.TargetLoadBalancerIDs = lbIDsList

network, err := c.Doit.GetString(c.NS, doctl.ArgLoadBalancerNetwork)
if err != nil {
return err
}
r.Network = strings.ToUpper(network)

return nil
}

Expand Down
4 changes: 4 additions & 0 deletions commands/load_balancers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ 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",
}
disableLetsEncryptDNSRecords := true
r.DisableLetsEncryptDNSRecords = &disableLetsEncryptDNSRecords
Expand All @@ -135,6 +136,7 @@ func TestLoadBalancerCreate(t *testing.T) {
config.Doit.Set(config.NS, doctl.ArgHTTPIdleTimeoutSeconds, 120)
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")

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

err := RunLoadBalancerCreate(config)
assert.NoError(t, err)
Expand Down
10 changes: 7 additions & 3 deletions commands/vpc_peerings.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import (
"strings"
"time"

"github.com/digitalocean/godo"
"github.com/spf13/cobra"

"github.com/digitalocean/doctl"
"github.com/digitalocean/doctl/commands/displayers"
"github.com/digitalocean/doctl/do"
"github.com/digitalocean/godo"
"github.com/spf13/cobra"
)

// VPCPeerings creates the vpc peerings command.
Expand Down Expand Up @@ -222,12 +223,15 @@ func RunVPCPeeringDelete(c *CmdConfig) error {
if err != nil {
return fmt.Errorf("VPC Peering couldn't be deleted : %v", err)
}
notice("VPC Peering is successfully deleted")
} else {
notice("VPC Peering deletion request accepted")
}

} else {
return fmt.Errorf("operation aborted")
}
notice("VPC Peering is successfully deleted")

return nil
}

Expand Down

0 comments on commit 22718aa

Please sign in to comment.