Skip to content

Commit

Permalink
Extend error handling
Browse files Browse the repository at this point in the history
These should not return errors under normal circumstances but they can
and we should return that to the caller.

Signed-off-by: Dimitrios Karagiannis <[email protected]>
  • Loading branch information
alkar committed Oct 29, 2019
1 parent 78952ac commit 2fd2c0a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 16 deletions.
16 changes: 12 additions & 4 deletions megaport/resource_megaport_aws_vxc.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,21 @@ func resourceMegaportAwsVxcRead(d *schema.ResourceData, m interface{}) error {
d.SetId("")
return nil
}
d.Set("name", p.ProductName)
d.Set("rate_limit", p.RateLimit)
d.Set("a_end", flattenVxcEnd(p.AEnd))
if err := d.Set("name", p.ProductName); err != nil {
return err
}
if err := d.Set("rate_limit", p.RateLimit); err != nil {
return err
}
if err := d.Set("a_end", flattenVxcEnd(p.AEnd)); err != nil {
return err
}
if err := d.Set("b_end", flattenVxcEndAws(p.BEnd, p.Resources)); err != nil {
return err
}
d.Set("invoice_reference", p.CostCentre)
if err := d.Set("invoice_reference", p.CostCentre); err != nil {
return err
}
return nil
}

Expand Down
28 changes: 21 additions & 7 deletions megaport/resource_megaport_port.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,28 @@ func resourceMegaportPortRead(d *schema.ResourceData, m interface{}) error {
d.SetId("")
return nil
}
d.Set("location_id", p.LocationId)
d.Set("name", p.ProductName)
d.Set("speed", p.PortSpeed)
d.Set("term", p.ContractTermMonths)
d.Set("associated_vxcs", schema.NewSet(schema.HashResource(resourceMegaportPrivateVxc()), flattenVxcList(p.AssociatedVxcs)))
d.Set("marketplace_visibility", "private")
if err := d.Set("location_id", p.LocationId); err != nil {
return err
}
if err := d.Set("name", p.ProductName); err != nil {
return err
}
if err := d.Set("speed", p.PortSpeed); err != nil {
return err
}
if err := d.Set("term", p.ContractTermMonths); err != nil {
return err
}
if err := d.Set("associated_vxcs", schema.NewSet(schema.HashResource(resourceMegaportPrivateVxc()), flattenVxcList(p.AssociatedVxcs))); err != nil {
return err
}
if err := d.Set("marketplace_visibility", "private"); err != nil {
return err
}
if p.MarketplaceVisibility {
d.Set("marketplace_visibility", "public")
if err := d.Set("marketplace_visibility", "public"); err != nil {
return err
}
}
//d.Set("invoice_reference", p.) // TODO: is this even exported?
return nil
Expand Down
20 changes: 15 additions & 5 deletions megaport/resource_megaport_private_vxc.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,21 @@ func resourceMegaportPrivateVxcRead(d *schema.ResourceData, m interface{}) error
d.SetId("")
return nil
}
d.Set("name", p.ProductName)
d.Set("rate_limit", p.RateLimit)
d.Set("a_end", flattenVxcEnd(p.AEnd))
d.Set("b_end", flattenVxcEnd(p.BEnd))
d.Set("invoice_reference", p.CostCentre)
if err := d.Set("name", p.ProductName); err != nil {
return err
}
if err := d.Set("rate_limit", p.RateLimit); err != nil {
return err
}
if err := d.Set("a_end", flattenVxcEnd(p.AEnd)); err != nil {
return err
}
if err := d.Set("b_end", flattenVxcEnd(p.BEnd)); err != nil {
return err
}
if err := d.Set("invoice_reference", p.CostCentre); err != nil {
return err
}
return nil
}

Expand Down

0 comments on commit 2fd2c0a

Please sign in to comment.