Skip to content

Commit

Permalink
LBAAS-2450 Support project id for loadbalancers (#1309)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenVarela authored Nov 16, 2022
1 parent 076f589 commit 4a3132b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 10 additions & 0 deletions commands/load_balancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ With the load-balancer command, you can list, create, or delete load balancers,
AddStringFlag(cmdRecordCreate, doctl.ArgForwardingRules, "", "",
forwardingRulesTxt)
AddBoolFlag(cmdRecordCreate, doctl.ArgCommandWait, "", false, "Boolean that specifies whether to wait for a load balancer to complete before returning control to the terminal")
AddStringFlag(cmdRecordCreate, doctl.ArgProjectID, "", "", "Indicates which project to associate the Load Balancer with. If not specified, the Load Balancer will be placed in your default project.")

cmdRecordUpdate := CmdBuilder(cmd, RunLoadBalancerUpdate, "update <id>",
"Update a load balancer's configuration", `Use this command to update the configuration of a specified load balancer.`, Writer, aliasOpt("u"))
Expand Down Expand Up @@ -114,6 +115,8 @@ With the load-balancer command, you can list, create, or delete load balancers,
AddStringFlag(cmdRecordUpdate, doctl.ArgForwardingRules, "", "", forwardingRulesTxt)
AddBoolFlag(cmdRecordUpdate, doctl.ArgDisableLetsEncryptDNSRecords, "", false,
"disable automatic DNS record creation for Let's Encrypt certificates that are added to the load balancer")
AddStringFlag(cmdRecordUpdate, doctl.ArgProjectID, "", "",
"Indicates which project to associate the Load Balancer with. If not specified, the Load Balancer will be placed in your default project.")

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{}))
Expand Down Expand Up @@ -519,6 +522,13 @@ func buildRequestFromArgs(c *CmdConfig, r *godo.LoadBalancerRequest) error {
}
r.ForwardingRules = forwardingRules

projectID, err := c.Doit.GetString(c.NS, doctl.ArgProjectID)
if err != nil {
return err
}

r.ProjectID = projectID

return nil
}

Expand Down
6 changes: 5 additions & 1 deletion commands/load_balancers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ func TestLoadBalancerCreate(t *testing.T) {
TlsPassthrough: true,
},
},
VPCUUID: vpcUUID,
VPCUUID: vpcUUID,
ProjectID: "project-id-uuid",
}
disableLetsEncryptDNSRecords := true
r.DisableLetsEncryptDNSRecords = &disableLetsEncryptDNSRecords
Expand All @@ -122,6 +123,7 @@ func TestLoadBalancerCreate(t *testing.T) {
config.Doit.Set(config.NS, doctl.ArgHealthCheck, "protocol:http,port:80,check_interval_seconds:4,response_timeout_seconds:23,healthy_threshold:5,unhealthy_threshold:10")
config.Doit.Set(config.NS, doctl.ArgForwardingRules, "entry_protocol:tcp,entry_port:3306,target_protocol:tcp,target_port:3306,tls_passthrough:true")
config.Doit.Set(config.NS, doctl.ArgDisableLetsEncryptDNSRecords, true)
config.Doit.Set(config.NS, doctl.ArgProjectID, "project-id-uuid")

err := RunLoadBalancerCreate(config)
assert.NoError(t, err)
Expand Down Expand Up @@ -157,6 +159,7 @@ func TestLoadBalancerUpdate(t *testing.T) {
TargetPort: 80,
},
},
ProjectID: "project-id-uuid",
}
disableLetsEncryptDNSRecords := true
r.DisableLetsEncryptDNSRecords = &disableLetsEncryptDNSRecords
Expand All @@ -172,6 +175,7 @@ func TestLoadBalancerUpdate(t *testing.T) {
config.Doit.Set(config.NS, doctl.ArgHealthCheck, "protocol:http,port:80,check_interval_seconds:4,response_timeout_seconds:23,healthy_threshold:5,unhealthy_threshold:10")
config.Doit.Set(config.NS, doctl.ArgForwardingRules, "entry_protocol:http,entry_port:80,target_protocol:http,target_port:80")
config.Doit.Set(config.NS, doctl.ArgDisableLetsEncryptDNSRecords, true)
config.Doit.Set(config.NS, doctl.ArgProjectID, "project-id-uuid")

err := RunLoadBalancerUpdate(config)
assert.NoError(t, err)
Expand Down

0 comments on commit 4a3132b

Please sign in to comment.