Merge pull request #91660 from ZeroMagic/get-azurefile

Add function GetFileShare in Azure Cloud Provider
This commit is contained in:
Kubernetes Prow Robot 2020-06-02 06:28:29 -07:00 committed by GitHub
commit 3995c1a54d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 44 additions and 3 deletions

View File

@ -18,6 +18,10 @@ limitations under the License.
package azure package azure
import (
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-06-01/storage"
)
// create file share // create file share
func (az *Cloud) createFileShare(resourceGroupName, accountName, name string, sizeGiB int) error { func (az *Cloud) createFileShare(resourceGroupName, accountName, name string, sizeGiB int) error {
return az.FileClient.CreateFileShare(resourceGroupName, accountName, name, sizeGiB) return az.FileClient.CreateFileShare(resourceGroupName, accountName, name, sizeGiB)
@ -30,3 +34,7 @@ func (az *Cloud) deleteFileShare(resourceGroupName, accountName, name string) er
func (az *Cloud) resizeFileShare(resourceGroupName, accountName, name string, sizeGiB int) error { func (az *Cloud) resizeFileShare(resourceGroupName, accountName, name string, sizeGiB int) error {
return az.FileClient.ResizeFileShare(resourceGroupName, accountName, name, sizeGiB) return az.FileClient.ResizeFileShare(resourceGroupName, accountName, name, sizeGiB)
} }
func (az *Cloud) getFileShare(resourceGroupName, accountName, name string) (storage.FileShare, error) {
return az.FileClient.GetFileShare(resourceGroupName, accountName, name)
}

View File

@ -66,3 +66,8 @@ func (az *Cloud) DeleteFileShare(resourceGroup, accountName, shareName string) e
func (az *Cloud) ResizeFileShare(resourceGroup, accountName, name string, sizeGiB int) error { func (az *Cloud) ResizeFileShare(resourceGroup, accountName, name string, sizeGiB int) error {
return az.resizeFileShare(resourceGroup, accountName, name, sizeGiB) return az.resizeFileShare(resourceGroup, accountName, name, sizeGiB)
} }
// GetFileShare gets a file share
func (az *Cloud) GetFileShare(resourceGroupName, accountName, name string) (storage.FileShare, error) {
return az.getFileShare(resourceGroupName, accountName, name)
}

View File

@ -89,3 +89,8 @@ func (c *Client) ResizeFileShare(resourceGroupName, accountName, name string, si
return nil return nil
} }
// GetFileShare gets a file share
func (c *Client) GetFileShare(resourceGroupName, accountName, name string) (storage.FileShare, error) {
return c.fileSharesClient.Get(context.Background(), resourceGroupName, accountName, name)
}

View File

@ -18,10 +18,15 @@ limitations under the License.
package fileclient package fileclient
import (
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-06-01/storage"
)
// Interface is the client interface for creating file shares, interface for test injection. // Interface is the client interface for creating file shares, interface for test injection.
// 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 // 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
type Interface interface { type Interface interface {
CreateFileShare(resourceGroupName, accountName, name string, sizeGiB int) error CreateFileShare(resourceGroupName, accountName, name string, sizeGiB int) error
DeleteFileShare(resourceGroupName, accountName, name string) error DeleteFileShare(resourceGroupName, accountName, name string) error
ResizeFileShare(resourceGroupName, accountName, name string, sizeGiB int) error ResizeFileShare(resourceGroupName, accountName, name string, sizeGiB int) error
GetFileShare(resourceGroupName, accountName, name string) (storage.FileShare, error)
} }

View File

@ -9,7 +9,10 @@ go_library(
importmap = "k8s.io/kubernetes/vendor/k8s.io/legacy-cloud-providers/azure/clients/fileclient/mockfileclient", importmap = "k8s.io/kubernetes/vendor/k8s.io/legacy-cloud-providers/azure/clients/fileclient/mockfileclient",
importpath = "k8s.io/legacy-cloud-providers/azure/clients/fileclient/mockfileclient", importpath = "k8s.io/legacy-cloud-providers/azure/clients/fileclient/mockfileclient",
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = ["//vendor/github.com/golang/mock/gomock:go_default_library"], deps = [
"//vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-06-01/storage:go_default_library",
"//vendor/github.com/golang/mock/gomock:go_default_library",
],
) )
filegroup( filegroup(

View File

@ -19,9 +19,9 @@ limitations under the License.
package mockfileclient package mockfileclient
import ( import (
reflect "reflect" storage "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-06-01/storage"
gomock "github.com/golang/mock/gomock" gomock "github.com/golang/mock/gomock"
reflect "reflect"
) )
// MockInterface is a mock of Interface interface // MockInterface is a mock of Interface interface
@ -88,3 +88,18 @@ func (mr *MockInterfaceMockRecorder) ResizeFileShare(resourceGroupName, accountN
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ResizeFileShare", reflect.TypeOf((*MockInterface)(nil).ResizeFileShare), resourceGroupName, accountName, name, sizeGiB) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ResizeFileShare", reflect.TypeOf((*MockInterface)(nil).ResizeFileShare), resourceGroupName, accountName, name, sizeGiB)
} }
// GetFileShare mocks base method
func (m *MockInterface) GetFileShare(resourceGroupName, accountName, name string) (storage.FileShare, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetFileShare", resourceGroupName, accountName, name)
ret0, _ := ret[0].(storage.FileShare)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetFileShare indicates an expected call of GetFileShare
func (mr *MockInterfaceMockRecorder) GetFileShare(resourceGroupName, accountName, name interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetFileShare", reflect.TypeOf((*MockInterface)(nil).GetFileShare), resourceGroupName, accountName, name)
}