Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(baremetal): export ips and domain #406

Merged
merged 1 commit into from
Feb 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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