Skip to content

Commit 8a1afad

Browse files
jtopjianjrperritt
authored andcommitted
SharedFileSystems v2: Restrict ExtractExportLocations to only GetExportLocationsResults (#449)
* SharedFileSystems v2: Restrict ExtractExportLocations to only GetExportLocationsResults * SharedFileSystems v2: Further changes to ExportLocations results * SharedFileSystems v2: Fix comment
1 parent c4df12e commit 8a1afad

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

openstack/sharedfilesystems/v2/shares/results.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,27 @@ func (r commonResult) Extract() (*Share, error) {
9696
return s.Share, err
9797
}
9898

99-
// CreateResult contains the result..
99+
// CreateResult contains the response body and error from a Create request.
100100
type CreateResult struct {
101101
commonResult
102102
}
103103

104-
// DeleteResult contains the delete results
104+
// DeleteResult contains the response body and error from a Delete request.
105105
type DeleteResult struct {
106106
gophercloud.ErrResult
107107
}
108108

109-
// GetResult contains the get result
109+
// GetResult contains the response body and error from a Get request.
110110
type GetResult struct {
111111
commonResult
112112
}
113113

114+
// GetExportLocationsResult contains the result body and error from an
115+
// GetExportLocations request.
116+
type GetExportLocationsResult struct {
117+
gophercloud.Result
118+
}
119+
114120
// ExportLocation contains all information associated with a share export location
115121
type ExportLocation struct {
116122
// The export location path that should be used for mount operation.
@@ -130,16 +136,11 @@ type ExportLocation struct {
130136
Preferred bool `json:"preferred"`
131137
}
132138

133-
// ExtractExportLocations will get the Export Locations from the commonResult
134-
func (r commonResult) ExtractExportLocations() ([]ExportLocation, error) {
139+
// Extract will get the Export Locations from the commonResult
140+
func (r GetExportLocationsResult) Extract() ([]ExportLocation, error) {
135141
var s struct {
136142
ExportLocations []ExportLocation `json:"export_locations"`
137143
}
138144
err := r.ExtractInto(&s)
139145
return s.ExportLocations, err
140146
}
141-
142-
// GetExportLocationsResult contains the result.
143-
type GetExportLocationsResult struct {
144-
commonResult
145-
}

openstack/sharedfilesystems/v2/shares/testing/request_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func TestGetExportLocationsSuccess(t *testing.T) {
9393
// Client c must have Microversion set; minimum supported microversion for Get Export Locations is 2.14
9494
c.Microversion = "2.14"
9595

96-
s, err := shares.GetExportLocations(c, shareID).ExtractExportLocations()
96+
s, err := shares.GetExportLocations(c, shareID).Extract()
9797

9898
th.AssertNoErr(t, err)
9999
th.AssertDeepEquals(t, s, []shares.ExportLocation{

0 commit comments

Comments
 (0)