@@ -31,9 +31,7 @@ import (
3131func (c * client ) GetSnapshotByID (ctx context.Context , snapshotID string ) (* Snapshot , error ) {
3232 logger := klog .FromContext (ctx )
3333 p := c .Snapshot .NewListSnapshotsParams ()
34- if snapshotID != "" {
35- p .SetId (snapshotID )
36- }
34+ p .SetId (snapshotID )
3735 logger .V (2 ).Info ("CloudStack API call" , "command" , "ListSnapshots" , "params" , map [string ]string {
3836 "id" : snapshotID ,
3937 })
@@ -63,9 +61,7 @@ func (c *client) GetSnapshotByID(ctx context.Context, snapshotID string) (*Snaps
6361func (c * client ) CreateSnapshot (ctx context.Context , volumeID , name string ) (* Snapshot , error ) {
6462 logger := klog .FromContext (ctx )
6563 p := c .Snapshot .NewCreateSnapshotParams (volumeID )
66- if name != "" {
67- p .SetName (name )
68- }
64+ p .SetName (name )
6965 logger .V (2 ).Info ("CloudStack API call" , "command" , "CreateSnapshot" , "params" , map [string ]string {
7066 "volumeid" : volumeID ,
7167 "name" : name ,
@@ -103,9 +99,6 @@ func (c *client) DeleteSnapshot(_ context.Context, snapshotID string) error {
10399
104100func (c * client ) GetSnapshotByName (ctx context.Context , name string ) (* Snapshot , error ) {
105101 logger := klog .FromContext (ctx )
106- if name == "" {
107- return nil , ErrNotFound
108- }
109102 p := c .Snapshot .NewListSnapshotsParams ()
110103 p .SetName (name )
111104 logger .V (2 ).Info ("CloudStack API call" , "command" , "ListSnapshots" , "params" , map [string ]string {
@@ -138,12 +131,16 @@ func (c *client) GetSnapshotByName(ctx context.Context, name string) (*Snapshot,
138131func (c * client ) ListSnapshots (ctx context.Context , volumeID , snapshotID string ) ([]* Snapshot , error ) {
139132 logger := klog .FromContext (ctx )
140133 p := c .Snapshot .NewListSnapshotsParams ()
134+
135+ // snapshotID is optional: csi.ListSnapshotsRequest
141136 if snapshotID != "" {
142137 p .SetId (snapshotID )
143138 }
139+ // volumeID is optional: csi.ListSnapshotsRequest
144140 if volumeID != "" {
145141 p .SetVolumeid (volumeID )
146142 }
143+
147144 logger .V (2 ).Info ("CloudStack API call" , "command" , "ListSnapshots" , "params" , map [string ]string {
148145 "id" : snapshotID ,
149146 "volumeid" : volumeID ,
0 commit comments