From 0cdee57798d01a9c57a93056bc5eee54c085b381 Mon Sep 17 00:00:00 2001 From: Philip Wong Date: Wed, 5 Oct 2022 13:12:38 -0500 Subject: [PATCH] add volume wwn (#70) * add volume wwn * fixed format * changed WWN to computed * added error check * fix lint * more fix * back to original * fixed syntax * fixed lint * Update internal/resources/resource_volume.go Co-authored-by: Neil Gierman * Update internal/resources/resource_volume.go Co-authored-by: Neil Gierman * Apply suggestions from code review Co-authored-by: Ron Saito Co-authored-by: Neil Gierman Co-authored-by: Louis Laborde HPE <33261715+llabordehpe@users.noreply.github.com> Co-authored-by: Ron Saito --- internal/resources/resource_volume.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/internal/resources/resource_volume.go b/internal/resources/resource_volume.go index 17f27bc..a4501e7 100644 --- a/internal/resources/resource_volume.go +++ b/internal/resources/resource_volume.go @@ -26,6 +26,7 @@ const ( vState = "state" vStatus = "status" vLabels = "labels" + vWWN = "wwn" // volume Info constants. vID = "id" @@ -115,7 +116,12 @@ func volumeSchema() map[string]*schema.Schema { vLabels: { Type: schema.TypeMap, Optional: true, - Description: "volume labels as (name, value) pairs", + Description: "The volume labels as (name, value) pairs.", + }, + vWWN: { + Type: schema.TypeString, + Computed: true, + Description: "The volume serial number.", }, } } @@ -256,12 +262,18 @@ func resourceMetalVolumeRead(d *schema.ResourceData, meta interface{}) (err erro loc, _ := p.GetLocationName(volume.LocationID) d.Set(vLocation, loc) d.Set(vLocationID, volume.LocationID) + if err = d.Set(vShareable, volume.Shareable); err != nil { return err } + d.Set(vState, volume.State) d.Set(vStatus, volume.Status) + if err = d.Set(vWWN, volume.WWN); err != nil { + return fmt.Errorf("set WWN: %v", err) + } + if volume.Labels != nil { tags := make(map[string]string, len(volume.Labels))