@@ -35,45 +35,49 @@ func New() cloud.Interface {
3535 ID : "0d7107a3-94d2-44e7-89b8-8930881309a5" ,
3636 ZoneID : zoneID ,
3737 }
38+
3839 return & fakeConnector {
3940 node : node ,
4041 volumesByID : map [string ]cloud.Volume {volume .ID : volume },
4142 volumesByName : map [string ]cloud.Volume {volume .Name : volume },
4243 }
4344}
4445
45- func (f * fakeConnector ) GetVMByID (ctx context.Context , vmID string ) (* cloud.VM , error ) {
46+ func (f * fakeConnector ) GetVMByID (_ context.Context , vmID string ) (* cloud.VM , error ) {
4647 if vmID == f .node .ID {
4748 return f .node , nil
4849 }
50+
4951 return nil , cloud .ErrNotFound
5052}
5153
52- func (f * fakeConnector ) GetNodeInfo (ctx context.Context , vmName string ) (* cloud.VM , error ) {
54+ func (f * fakeConnector ) GetNodeInfo (_ context.Context , _ string ) (* cloud.VM , error ) {
5355 return f .node , nil
5456}
5557
56- func (f * fakeConnector ) ListZonesID (ctx context.Context ) ([]string , error ) {
58+ func (f * fakeConnector ) ListZonesID (_ context.Context ) ([]string , error ) {
5759 return []string {zoneID }, nil
5860}
5961
60- func (f * fakeConnector ) GetVolumeByID (ctx context.Context , volumeID string ) (* cloud.Volume , error ) {
62+ func (f * fakeConnector ) GetVolumeByID (_ context.Context , volumeID string ) (* cloud.Volume , error ) {
6163 vol , ok := f .volumesByID [volumeID ]
6264 if ok {
6365 return & vol , nil
6466 }
67+
6568 return nil , cloud .ErrNotFound
6669}
6770
68- func (f * fakeConnector ) GetVolumeByName (ctx context.Context , name string ) (* cloud.Volume , error ) {
71+ func (f * fakeConnector ) GetVolumeByName (_ context.Context , name string ) (* cloud.Volume , error ) {
6972 vol , ok := f .volumesByName [name ]
7073 if ok {
7174 return & vol , nil
7275 }
76+
7377 return nil , cloud .ErrNotFound
7478}
7579
76- func (f * fakeConnector ) CreateVolume (ctx context.Context , diskOfferingID , zoneID , name string , sizeInGB int64 ) (string , error ) {
80+ func (f * fakeConnector ) CreateVolume (_ context.Context , diskOfferingID , zoneID , name string , sizeInGB int64 ) (string , error ) {
7781 id , _ := uuid .GenerateUUID ()
7882 vol := cloud.Volume {
7983 ID : id ,
@@ -84,37 +88,39 @@ func (f *fakeConnector) CreateVolume(ctx context.Context, diskOfferingID, zoneID
8488 }
8589 f .volumesByID [vol .ID ] = vol
8690 f .volumesByName [vol .Name ] = vol
91+
8792 return vol .ID , nil
8893}
8994
90- func (f * fakeConnector ) DeleteVolume (ctx context.Context , id string ) error {
95+ func (f * fakeConnector ) DeleteVolume (_ context.Context , id string ) error {
9196 if vol , ok := f .volumesByID [id ]; ok {
9297 name := vol .Name
9398 delete (f .volumesByName , name )
9499 }
95100 delete (f .volumesByID , id )
101+
96102 return nil
97103}
98104
99- func (f * fakeConnector ) AttachVolume (ctx context.Context , volumeID , vmID string ) (string , error ) {
105+ func (f * fakeConnector ) AttachVolume (_ context.Context , _ , _ string ) (string , error ) {
100106 return "1" , nil
101107}
102108
103- func (f * fakeConnector ) DetachVolume (ctx context.Context , volumeID string ) error {
109+ func (f * fakeConnector ) DetachVolume (_ context.Context , _ string ) error {
104110 return nil
105111}
106- func (f * fakeConnector ) ExpandVolume (ctx context.Context , volumeID string , newSizeInGB int64 ) error {
112+
113+ func (f * fakeConnector ) ExpandVolume (_ context.Context , volumeID string , newSizeInGB int64 ) error {
107114 if vol , ok := f .volumesByID [volumeID ]; ok {
108115 newSizeInBytes := newSizeInGB * 1024 * 1024 * 1024
109116 if newSizeInBytes > vol .Size {
110117 vol .Size = newSizeInBytes
111118 f .volumesByID [volumeID ] = vol
112119 f .volumesByName [vol .Name ] = vol
113- return nil
114- } else {
115- return nil
116120 }
117- } else {
121+
118122 return nil
119123 }
124+
125+ return cloud .ErrNotFound
120126}
0 commit comments