Skip to content

Commit

Permalink
fix: ShowSnapshots() now takes two parameters, snapshot id and source…
Browse files Browse the repository at this point in the history
… volume id

This update was made to properly handle CSI ListSnapshots calls

Signed-off-by: Joe Skazinski <[email protected]>
  • Loading branch information
jskazinski committed Nov 18, 2021
1 parent 42401a3 commit 539fafe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func ShowSnapshot(t *testing.T, name string) {
var err error
var status *ResponseStatus
var response *Response
response, status, err = client.ShowSnapshots(name)
response, status, err = client.ShowSnapshots(name, "")
g.Expect(err).To(BeNil())
g.Expect(status.ResponseTypeNumeric).To(Equal(0))

Expand Down
12 changes: 7 additions & 5 deletions endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,14 @@ func (client *Client) ShowHostMaps(host string) ([]Volume, *ResponseStatus, erro
return mappings, status, err
}

// ShowSnapshots : Show one snaphot, or all snapshots if name = ""
func (client *Client) ShowSnapshots(names ...string) (*Response, *ResponseStatus, error) {
if len(names) == 0 {
return client.FormattedRequest("/show/snapshots")
// ShowSnapshots : Show one snaphot, or all snapshots, or all snapshots for a volume
func (client *Client) ShowSnapshots(snapshotId string, sourceVolumeId string) (*Response, *ResponseStatus, error) {
if sourceVolumeId != "" {
return client.FormattedRequest("/show/snapshots/volume/%q", sourceVolumeId)
} else if snapshotId != "" {
return client.FormattedRequest("/show/snapshots/pattern/%q", snapshotId)
}
return client.FormattedRequest("/show/snapshots/pattern/%q", strings.Join(names, ","))
return client.FormattedRequest("/show/snapshots")
}

// CreateSnapshot : create a snapshot in a snap pool and the snap pool if it doesn't exsits
Expand Down

0 comments on commit 539fafe

Please sign in to comment.