Skip to content

Commit

Permalink
add volume wwn (#70)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* Update internal/resources/resource_volume.go

Co-authored-by: Neil Gierman <[email protected]>

* Apply suggestions from code review

Co-authored-by: Ron Saito <[email protected]>

Co-authored-by: Neil Gierman <[email protected]>
Co-authored-by: Louis Laborde HPE <[email protected]>
Co-authored-by: Ron Saito <[email protected]>
  • Loading branch information
4 people authored Oct 5, 2022
1 parent cbf0c36 commit 0cdee57
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion internal/resources/resource_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const (
vState = "state"
vStatus = "status"
vLabels = "labels"
vWWN = "wwn"

// volume Info constants.
vID = "id"
Expand Down Expand Up @@ -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.",
},
}
}
Expand Down Expand Up @@ -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))

Expand Down

0 comments on commit 0cdee57

Please sign in to comment.