Skip to content

Commit

Permalink
addressed pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
guptado committed May 17, 2024
1 parent 9745aab commit bbf3a0f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
6 changes: 2 additions & 4 deletions commands/vpc_peerings.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ With the VPC Peerings commands, you can get, list, create, update, or delete VPC
- The VPC Peering creation date, in ISO8601 combined date and time format
`
cmdPeeringGet := CmdBuilder(cmd, RunVPCPeeringGet, "get <id>",
"Retrieve a VPC network", "Retrieve information about a VPC Peering, including:"+peeringDetails, Writer,
"Retrieve a VPC network", "Retrieves information about a VPC Peering, including:"+peeringDetails, Writer,
aliasOpt("g"), displayerType(&displayers.VPCPeering{}))
cmdPeeringGet.Example = `The following example retrieves information about a VPC Peering with the ID ` + "`" + `f81d4fae-7dec-11d0-a765-00a0c91e6bf6` + "`" + `: doctl vpc-peerings get f81d4fae-7dec-11d0-a765-00a0c91e6bf6`

Expand All @@ -56,7 +56,7 @@ With the VPC Peerings commands, you can get, list, create, update, or delete VPC
` : doctl vpc-peerings create --name example-peering --first-vpc-id f81d4fae-7dec-11d0-a765-00a0c91e6bf6 --second-vpc-id 3f900b61-30d7-40d8-9711-8c5d6264b268`

cmdPeeringUpdate := CmdBuilder(cmd, RunVPCPeeringUpdate, "update <id>",
"Update a VPC Peering's configuration", `Updates a VPC network's configuration. You can update its name.`, Writer, aliasOpt("u"))
"Update a VPC Peering's configuration", `Updates a VPC Peering's configuration. You can update its name.`, Writer, aliasOpt("u"))
AddStringFlag(cmdPeeringUpdate, doctl.ArgVPCPeeringName, "", "",
"The VPC network's name")
cmdPeeringUpdate.Example = `The following example updates the name of a VPC Peering with the ID ` +
Expand Down Expand Up @@ -92,7 +92,6 @@ func RunVPCPeeringGet(c *CmdConfig) error {

// RunVPCPeeringCreate creates a new VPC Peering with a given configuration.
func RunVPCPeeringCreate(c *CmdConfig) error {

r := new(godo.VPCPeeringCreateRequest)
name, err := c.Doit.GetString(c.NS, doctl.ArgVPCPeeringName)
if err != nil {
Expand Down Expand Up @@ -131,7 +130,6 @@ func RunVPCPeeringCreate(c *CmdConfig) error {

// RunVPCPeeringList lists VPC Peerings
func RunVPCPeeringList(c *CmdConfig) error {

vpcID, err := c.Doit.GetString(c.NS, doctl.ArgVPCPeeringVPCID)
if err != nil {
return err
Expand Down
15 changes: 15 additions & 0 deletions commands/vpc_peerings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,21 @@ func TestVPCPeeringCreate(t *testing.T) {
err := RunVPCPeeringCreate(config)
assert.NoError(t, err)
})

withTestClient(t, func(config *CmdConfig, tm *tcMocks) {
config.Doit.Set(config.NS, doctl.ArgVPCPeeringName, "peering-name")

err := RunVPCPeeringCreate(config)
assert.EqualError(t, err, "first VPC ID is empty")
})

withTestClient(t, func(config *CmdConfig, tm *tcMocks) {
config.Doit.Set(config.NS, doctl.ArgVPCPeeringName, "peering-name")
config.Doit.Set(config.NS, doctl.ArgVPCPeeringFirstVPCID, "f81d4fae-7dec-11d0-a765-00a0c91e6bf6")

err := RunVPCPeeringCreate(config)
assert.EqualError(t, err, "second VPC ID is empty")
})
}

func TestVPCPeeringUpdate(t *testing.T) {
Expand Down
2 changes: 0 additions & 2 deletions do/vpcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ func (v *vpcsService) GetPeering(peeringID string) (*VPCPeering, error) {
}

func (v *vpcsService) ListVPCPeerings() (VPCPeerings, error) {

f := func(opt *godo.ListOptions) ([]any, *godo.Response, error) {
list, resp, err := v.client.VPCs.ListVPCPeerings(context.TODO(), opt)
if err != nil {
Expand Down Expand Up @@ -195,7 +194,6 @@ func (v *vpcsService) CreateVPCPeering(req *godo.VPCPeeringCreateRequest) (*VPCP
}

func (v *vpcsService) ListVPCPeeringsByVPCID(vpcID string) (VPCPeerings, error) {

f := func(opt *godo.ListOptions) ([]any, *godo.Response, error) {
list, resp, err := v.client.VPCs.ListVPCPeeringsByVPCID(context.TODO(), vpcID, opt)
if err != nil {
Expand Down

0 comments on commit bbf3a0f

Please sign in to comment.