Skip to content

Commit

Permalink
SharedFileSystems v2: Restrict ExtractExportLocations to only GetExpo…
Browse files Browse the repository at this point in the history
…rtLocationsResults (#449)

* SharedFileSystems v2: Restrict ExtractExportLocations to only GetExportLocationsResults

* SharedFileSystems v2: Further changes to ExportLocations results

* SharedFileSystems v2: Fix comment
  • Loading branch information
jtopjian authored and jrperritt committed Aug 11, 2017
1 parent c4df12e commit 8a1afad
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions openstack/sharedfilesystems/v2/shares/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,27 @@ func (r commonResult) Extract() (*Share, error) {
return s.Share, err
}

// CreateResult contains the result..
// CreateResult contains the response body and error from a Create request.
type CreateResult struct {
commonResult
}

// DeleteResult contains the delete results
// DeleteResult contains the response body and error from a Delete request.
type DeleteResult struct {
gophercloud.ErrResult
}

// GetResult contains the get result
// GetResult contains the response body and error from a Get request.
type GetResult struct {
commonResult
}

// GetExportLocationsResult contains the result body and error from an
// GetExportLocations request.
type GetExportLocationsResult struct {
gophercloud.Result
}

// ExportLocation contains all information associated with a share export location
type ExportLocation struct {
// The export location path that should be used for mount operation.
Expand All @@ -130,16 +136,11 @@ type ExportLocation struct {
Preferred bool `json:"preferred"`
}

// ExtractExportLocations will get the Export Locations from the commonResult
func (r commonResult) ExtractExportLocations() ([]ExportLocation, error) {
// Extract will get the Export Locations from the commonResult
func (r GetExportLocationsResult) Extract() ([]ExportLocation, error) {
var s struct {
ExportLocations []ExportLocation `json:"export_locations"`
}
err := r.ExtractInto(&s)
return s.ExportLocations, err
}

// GetExportLocationsResult contains the result.
type GetExportLocationsResult struct {
commonResult
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func TestGetExportLocationsSuccess(t *testing.T) {
// Client c must have Microversion set; minimum supported microversion for Get Export Locations is 2.14
c.Microversion = "2.14"

s, err := shares.GetExportLocations(c, shareID).ExtractExportLocations()
s, err := shares.GetExportLocations(c, shareID).Extract()

th.AssertNoErr(t, err)
th.AssertDeepEquals(t, s, []shares.ExportLocation{
Expand Down

0 comments on commit 8a1afad

Please sign in to comment.