diff --git a/pkg/rbd/controllerserver_test.go b/pkg/rbd/controllerserver_test.go index ab92ba112..d9eadc25d 100644 --- a/pkg/rbd/controllerserver_test.go +++ b/pkg/rbd/controllerserver_test.go @@ -49,18 +49,18 @@ func TestLoadExDataFromMetadataStore(t *testing.T) { cs := &ControllerServer{ MetadataStore: &testCachePersister{ volumes: map[string]rbdVolume{ - "item1": rbdVolume{ + "item1": { VolID: "1", }, - "item2": rbdVolume{ + "item2": { VolID: "2", }, }, snapshots: map[string]rbdSnapshot{ - "item1": rbdSnapshot{ + "item1": { SnapID: "1", }, - "item2": rbdSnapshot{ + "item2": { SnapID: "2", }, }, diff --git a/pkg/rbd/rbd_util.go b/pkg/rbd/rbd_util.go index 0b04d8a7f..6a5555de6 100644 --- a/pkg/rbd/rbd_util.go +++ b/pkg/rbd/rbd_util.go @@ -408,7 +408,8 @@ func getRBDVolumeByID(volumeID string) (*rbdVolume, error) { func getRBDVolumeByName(volName string) (*rbdVolume, error) { for _, rbdVol := range rbdVolumes { if rbdVol.VolName == volName { - return &rbdVol, nil + v := rbdVol + return &v, nil } } return nil, fmt.Errorf("volume name %s does not exit in the volumes list", volName) @@ -417,7 +418,8 @@ func getRBDVolumeByName(volName string) (*rbdVolume, error) { func getRBDSnapshotByName(snapName string) (*rbdSnapshot, error) { for _, rbdSnap := range rbdSnapshots { if rbdSnap.SnapName == snapName { - return &rbdSnap, nil + s := rbdSnap + return &s, nil } } return nil, fmt.Errorf("snapshot name %s does not exit in the snapshots list", snapName)