Skip to content

Commit

Permalink
feat(baremetal): export ips and domain (#406)
Browse files Browse the repository at this point in the history
Signed-off-by: Patrik Cyvoct <[email protected]>
  • Loading branch information
Sh4d1 authored Feb 21, 2020
1 parent bd742c7 commit 3d76d10
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
15 changes: 15 additions & 0 deletions scaleway/helpers_baremetal.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,18 @@ func flattenBaremetalMemory(memories []*baremetal.Memory) interface{} {
}
return flattenedMemories
}

func flattenBaremetalIPs(ips []*baremetal.IP) interface{} {
if ips == nil {
return nil
}
flattendIPs := []map[string]interface{}(nil)
for _, ip := range ips {
flattendIPs = append(flattendIPs, map[string]interface{}{
"id": ip.ID,
"address": ip.Address,
"reverse": ip.Reverse,
})
}
return flattendIPs
}
29 changes: 29 additions & 0 deletions scaleway/resource_baremetal_server_beta.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,33 @@ func resourceScalewayBaremetalServerBeta() *schema.Resource {
Optional: true,
Removed: "Please use offer instead",
},
"ips": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Computed: true,
Description: "The ID of the IP",
},
"address": {
Type: schema.TypeString,
Computed: true,
Description: "The IP address of the IP",
},
"reverse": {
Type: schema.TypeString,
Computed: true,
Description: "The Reverse of the IP",
},
},
},
},
"domain": {
Type: schema.TypeString,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -178,6 +205,8 @@ func resourceScalewayBaremetalServerBetaRead(d *schema.ResourceData, m interface
_ = d.Set("organization_id", res.OrganizationID)
_ = d.Set("offer", flattenLabelUUID(offer.Name, offer.ID))
_ = d.Set("tags", res.Tags)
_ = d.Set("domain", res.Domain)
_ = d.Set("ips", flattenBaremetalIPs(res.IPs))
if res.Install != nil {
_ = d.Set("os_id", res.Install.OsID)
_ = d.Set("ssh_key_ids", res.Install.SSHKeyIDs)
Expand Down
5 changes: 5 additions & 0 deletions website/docs/r/baremetal_server_beta.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ Use [this endpoint](https://developers.scaleway.com/en/products/baremetal/api/#g
In addition to all above arguments, the following attributes are exported:

- `id` - The ID of the server.
- `ips` - (List of) The IPs of the server.
- `id` - The ID of the IP.
- `address` - The address of the IP.
- `reverse` - The reverse of the IP.
- `domain` - The domain of the server.

## Import

Expand Down

0 comments on commit 3d76d10

Please sign in to comment.