Skip to content

Commit 3995c1a

Browse files
authored
Merge pull request kubernetes#91660 from ZeroMagic/get-azurefile
Add function GetFileShare in Azure Cloud Provider
2 parents 84861d2 + 07d334f commit 3995c1a

File tree

6 files changed

+44
-3
lines changed

6 files changed

+44
-3
lines changed

staging/src/k8s.io/legacy-cloud-providers/azure/azure_file.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ limitations under the License.
1818

1919
package azure
2020

21+
import (
22+
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-06-01/storage"
23+
)
24+
2125
// create file share
2226
func (az *Cloud) createFileShare(resourceGroupName, accountName, name string, sizeGiB int) error {
2327
return az.FileClient.CreateFileShare(resourceGroupName, accountName, name, sizeGiB)
@@ -30,3 +34,7 @@ func (az *Cloud) deleteFileShare(resourceGroupName, accountName, name string) er
3034
func (az *Cloud) resizeFileShare(resourceGroupName, accountName, name string, sizeGiB int) error {
3135
return az.FileClient.ResizeFileShare(resourceGroupName, accountName, name, sizeGiB)
3236
}
37+
38+
func (az *Cloud) getFileShare(resourceGroupName, accountName, name string) (storage.FileShare, error) {
39+
return az.FileClient.GetFileShare(resourceGroupName, accountName, name)
40+
}

staging/src/k8s.io/legacy-cloud-providers/azure/azure_storage.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,8 @@ func (az *Cloud) DeleteFileShare(resourceGroup, accountName, shareName string) e
6666
func (az *Cloud) ResizeFileShare(resourceGroup, accountName, name string, sizeGiB int) error {
6767
return az.resizeFileShare(resourceGroup, accountName, name, sizeGiB)
6868
}
69+
70+
// GetFileShare gets a file share
71+
func (az *Cloud) GetFileShare(resourceGroupName, accountName, name string) (storage.FileShare, error) {
72+
return az.getFileShare(resourceGroupName, accountName, name)
73+
}

staging/src/k8s.io/legacy-cloud-providers/azure/clients/fileclient/azure_fileclient.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,8 @@ func (c *Client) ResizeFileShare(resourceGroupName, accountName, name string, si
8989

9090
return nil
9191
}
92+
93+
// GetFileShare gets a file share
94+
func (c *Client) GetFileShare(resourceGroupName, accountName, name string) (storage.FileShare, error) {
95+
return c.fileSharesClient.Get(context.Background(), resourceGroupName, accountName, name)
96+
}

staging/src/k8s.io/legacy-cloud-providers/azure/clients/fileclient/interface.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@ limitations under the License.
1818

1919
package fileclient
2020

21+
import (
22+
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-06-01/storage"
23+
)
24+
2125
// Interface is the client interface for creating file shares, interface for test injection.
2226
// mockgen -source=$GOPATH/src/k8s.io/kubernetes/staging/src/k8s.io/legacy-cloud-providers/azure/clients/fileclient/interface.go -package=mockfileclient Interface > $GOPATH/src/k8s.io/kubernetes/staging/src/k8s.io/legacy-cloud-providers/azure/clients/fileclient/mockfileclient/interface.go
2327
type Interface interface {
2428
CreateFileShare(resourceGroupName, accountName, name string, sizeGiB int) error
2529
DeleteFileShare(resourceGroupName, accountName, name string) error
2630
ResizeFileShare(resourceGroupName, accountName, name string, sizeGiB int) error
31+
GetFileShare(resourceGroupName, accountName, name string) (storage.FileShare, error)
2732
}

staging/src/k8s.io/legacy-cloud-providers/azure/clients/fileclient/mockfileclient/BUILD

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ go_library(
99
importmap = "k8s.io/kubernetes/vendor/k8s.io/legacy-cloud-providers/azure/clients/fileclient/mockfileclient",
1010
importpath = "k8s.io/legacy-cloud-providers/azure/clients/fileclient/mockfileclient",
1111
visibility = ["//visibility:public"],
12-
deps = ["//vendor/github.com/golang/mock/gomock:go_default_library"],
12+
deps = [
13+
"//vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-06-01/storage:go_default_library",
14+
"//vendor/github.com/golang/mock/gomock:go_default_library",
15+
],
1316
)
1417

1518
filegroup(

staging/src/k8s.io/legacy-cloud-providers/azure/clients/fileclient/mockfileclient/interface.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ limitations under the License.
1919
package mockfileclient
2020

2121
import (
22-
reflect "reflect"
23-
22+
storage "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-06-01/storage"
2423
gomock "github.com/golang/mock/gomock"
24+
reflect "reflect"
2525
)
2626

2727
// MockInterface is a mock of Interface interface
@@ -88,3 +88,18 @@ func (mr *MockInterfaceMockRecorder) ResizeFileShare(resourceGroupName, accountN
8888
mr.mock.ctrl.T.Helper()
8989
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ResizeFileShare", reflect.TypeOf((*MockInterface)(nil).ResizeFileShare), resourceGroupName, accountName, name, sizeGiB)
9090
}
91+
92+
// GetFileShare mocks base method
93+
func (m *MockInterface) GetFileShare(resourceGroupName, accountName, name string) (storage.FileShare, error) {
94+
m.ctrl.T.Helper()
95+
ret := m.ctrl.Call(m, "GetFileShare", resourceGroupName, accountName, name)
96+
ret0, _ := ret[0].(storage.FileShare)
97+
ret1, _ := ret[1].(error)
98+
return ret0, ret1
99+
}
100+
101+
// GetFileShare indicates an expected call of GetFileShare
102+
func (mr *MockInterfaceMockRecorder) GetFileShare(resourceGroupName, accountName, name interface{}) *gomock.Call {
103+
mr.mock.ctrl.T.Helper()
104+
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetFileShare", reflect.TypeOf((*MockInterface)(nil).GetFileShare), resourceGroupName, accountName, name)
105+
}

0 commit comments

Comments
 (0)