Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function GetFileShare in Azure Cloud Provider #91660

Merged
merged 1 commit into from Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions staging/src/k8s.io/legacy-cloud-providers/azure/azure_file.go
Expand Up @@ -18,6 +18,10 @@ limitations under the License.

package azure

import (
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-06-01/storage"
)

// create file share
func (az *Cloud) createFileShare(resourceGroupName, accountName, name string, sizeGiB int) error {
return az.FileClient.CreateFileShare(resourceGroupName, accountName, name, sizeGiB)
Expand All @@ -30,3 +34,7 @@ func (az *Cloud) deleteFileShare(resourceGroupName, accountName, name string) er
func (az *Cloud) resizeFileShare(resourceGroupName, accountName, name string, sizeGiB int) error {
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use az.FileClient directly in CSI driver?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, i see, it's for mock client

}
Expand Up @@ -66,3 +66,8 @@ func (az *Cloud) DeleteFileShare(resourceGroup, accountName, shareName string) e
func (az *Cloud) ResizeFileShare(resourceGroup, accountName, name string, sizeGiB int) error {
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)
}
Expand Up @@ -89,3 +89,8 @@ func (c *Client) ResizeFileShare(resourceGroupName, accountName, name string, si

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)
}
Expand Up @@ -18,10 +18,15 @@ limitations under the License.

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.
// 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 {
CreateFileShare(resourceGroupName, accountName, name string, sizeGiB int) error
DeleteFileShare(resourceGroupName, accountName, name string) error
ResizeFileShare(resourceGroupName, accountName, name string, sizeGiB int) error
GetFileShare(resourceGroupName, accountName, name string) (storage.FileShare, error)
}
Expand Up @@ -9,7 +9,10 @@ go_library(
importmap = "k8s.io/kubernetes/vendor/k8s.io/legacy-cloud-providers/azure/clients/fileclient/mockfileclient",
importpath = "k8s.io/legacy-cloud-providers/azure/clients/fileclient/mockfileclient",
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(
Expand Down
Expand Up @@ -19,9 +19,9 @@ limitations under the License.
package mockfileclient

import (
reflect "reflect"

storage "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-06-01/storage"
gomock "github.com/golang/mock/gomock"
reflect "reflect"
)

// MockInterface is a mock of Interface interface
Expand Down Expand Up @@ -88,3 +88,18 @@ func (mr *MockInterfaceMockRecorder) ResizeFileShare(resourceGroupName, accountN
mr.mock.ctrl.T.Helper()
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)
}