Skip to content

Commit

Permalink
chore: make changes due to cloud provider lib change
Browse files Browse the repository at this point in the history
  • Loading branch information
andyzhangx committed Jan 25, 2025
1 parent 89b0eba commit 0905391
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 53 deletions.
7 changes: 3 additions & 4 deletions pkg/azurefile/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
"sigs.k8s.io/cloud-provider-azure/pkg/azclient/configloader"
azcache "sigs.k8s.io/cloud-provider-azure/pkg/cache"
azure "sigs.k8s.io/cloud-provider-azure/pkg/provider"
azureconfig "sigs.k8s.io/cloud-provider-azure/pkg/provider/config"
"sigs.k8s.io/cloud-provider-azure/pkg/retry"
)

Expand Down Expand Up @@ -67,7 +66,7 @@ func getRuntimeClassForPod(ctx context.Context, kubeClient clientset.Interface,
// getCloudProvider get Azure Cloud Provider
func getCloudProvider(ctx context.Context, kubeconfig, nodeID, secretName, secretNamespace, userAgent string, allowEmptyCloudConfig, enableWindowsHostProcess bool, kubeAPIQPS float64, kubeAPIBurst int) (*azure.Cloud, error) {
var (
config *azureconfig.Config
config *azure.Config
kubeClient *clientset.Clientset
fromSecret bool
)
Expand Down Expand Up @@ -98,7 +97,7 @@ func getCloudProvider(ctx context.Context, kubeconfig, nodeID, secretName, secre

if kubeClient != nil {
klog.V(2).Infof("reading cloud config from secret %s/%s", secretNamespace, secretName)
config, err = configloader.Load[azureconfig.Config](ctx, &configloader.K8sSecretLoaderConfig{
config, err = configloader.Load[azure.Config](ctx, &configloader.K8sSecretLoaderConfig{
K8sSecretConfig: configloader.K8sSecretConfig{
SecretName: secretName,
SecretNamespace: secretNamespace,
Expand Down Expand Up @@ -127,7 +126,7 @@ func getCloudProvider(ctx context.Context, kubeconfig, nodeID, secretName, secre
}
klog.V(2).Infof("use default %s env var: %v", DefaultAzureCredentialFileEnv, credFile)
}
config, err = configloader.Load[azureconfig.Config](ctx, nil, &configloader.FileLoaderConfig{
config, err = configloader.Load[azure.Config](ctx, nil, &configloader.FileLoaderConfig{
FilePath: credFile,
})
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions pkg/azurefile/azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
fake "k8s.io/client-go/kubernetes/fake"
azureprovider "sigs.k8s.io/cloud-provider-azure/pkg/provider"
azureconfig "sigs.k8s.io/cloud-provider-azure/pkg/provider/config"
)

func skipIfTestingOnWindows(t *testing.T) {
Expand Down Expand Up @@ -298,7 +297,7 @@ func TestUpdateSubnetServiceEndpoints(t *testing.T) {
defer ctrl.Finish()
mockSubnetClient := mocksubnetclient.NewMockInterface(ctrl)

config := azureconfig.Config{
config := azureprovider.Config{
ResourceGroup: "rg",
Location: "loc",
VnetName: "fake-vnet",
Expand Down
8 changes: 4 additions & 4 deletions pkg/azurefile/azurefile_mgmt_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (az *azureFileMgmtClient) CreateFileShare(ctx context.Context, shareOptions
if shareOptions.Metadata != nil {
shareOps.FileShareProperties.Metadata = shareOptions.Metadata
}
if _, err := az.fileShareClient.Create(ctx, az.accountOptions.ResourceGroup, az.accountOptions.Name, shareOptions.Name, shareOps); err != nil {
if _, err := az.fileShareClient.Create(ctx, az.accountOptions.ResourceGroup, az.accountOptions.Name, shareOptions.Name, shareOps, nil); err != nil {
return fmt.Errorf("failed to create share %s in account %s: %w", shareOptions.Name, az.accountOptions.Name, err)
}
klog.V(4).Infof("created share %s in account %s", shareOptions.Name, az.accountOptions.Name)
Expand All @@ -91,7 +91,7 @@ func (az *azureFileMgmtClient) CreateFileShare(ctx context.Context, shareOptions

// DeleteFileShare deletes a file share using storage account name and key
func (az *azureFileMgmtClient) DeleteFileShare(ctx context.Context, shareName string) error {
if err := az.fileShareClient.Delete(ctx, az.accountOptions.ResourceGroup, az.accountOptions.Name, shareName); err != nil {
if err := az.fileShareClient.Delete(ctx, az.accountOptions.ResourceGroup, az.accountOptions.Name, shareName, nil); err != nil {
return err
}
klog.V(4).Infof("share %s deleted", shareName)
Expand All @@ -100,7 +100,7 @@ func (az *azureFileMgmtClient) DeleteFileShare(ctx context.Context, shareName st

// ResizeFileShare resizes a file share
func (az *azureFileMgmtClient) ResizeFileShare(ctx context.Context, name string, sizeGiB int) error {
fileShare, err := az.fileShareClient.Get(ctx, az.accountOptions.ResourceGroup, az.accountOptions.Name, name)
fileShare, err := az.fileShareClient.Get(ctx, az.accountOptions.ResourceGroup, az.accountOptions.Name, name, nil)
if err != nil {
return err
}
Expand All @@ -117,7 +117,7 @@ func (az *azureFileMgmtClient) ResizeFileShare(ctx context.Context, name string,

// GetFileShare gets a file share
func (az *azureFileMgmtClient) GetFileShareQuota(ctx context.Context, name string) (int, error) {
share, err := az.fileShareClient.Get(ctx, az.accountOptions.ResourceGroup, az.accountOptions.Name, name)
share, err := az.fileShareClient.Get(ctx, az.accountOptions.ResourceGroup, az.accountOptions.Name, name, nil)
if err != nil {
return -1, err
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/azurefile/azurefile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func NewFakeDriver() *Driver {
driver.Name = fakeDriverName
driver.Version = vendorVersion
driver.cloud = &azure.Cloud{
Config: auth.Config{
Config: azure.Config{
AzureClientConfig: auth.AzureClientConfig{
SubscriptionID: "subscriptionID",
},
Expand All @@ -89,7 +89,7 @@ func NewFakeDriverCustomOptions(opts DriverOptions) *Driver {
driver.Name = fakeDriverName
driver.Version = vendorVersion
driver.cloud = &azure.Cloud{
Config: auth.Config{
Config: azure.Config{
AzureClientConfig: auth.AzureClientConfig{
SubscriptionID: "subscriptionID",
},
Expand Down Expand Up @@ -1018,7 +1018,7 @@ func TestGetFileShareQuota(t *testing.T) {
clientFactory := mock_azclient.NewMockClientFactory(ctrl)
clientFactory.EXPECT().GetFileShareClientForSub(gomock.Any()).Return(mockFileClient, nil).AnyTimes()
d.cloud.ComputeClientFactory = clientFactory
mockFileClient.EXPECT().Get(context.TODO(), gomock.Any(), gomock.Any(), gomock.Any()).Return(test.mockedFileShareResp, test.mockedFileShareErr).AnyTimes()
mockFileClient.EXPECT().Get(context.TODO(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(test.mockedFileShareResp, test.mockedFileShareErr).AnyTimes()
quota, err := d.getFileShareQuota(context.TODO(), &azure.AccountOptions{
ResourceGroup: resourceGroupName,
Name: accountName,
Expand Down
Loading

0 comments on commit 0905391

Please sign in to comment.