Skip to content

Commit

Permalink
Use k8s utils pointer instead of Azure autorest/to
Browse files Browse the repository at this point in the history
  • Loading branch information
umagnus committed Dec 21, 2022
1 parent d239db6 commit ebef122
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0
github.com/Azure/go-autorest/autorest v0.11.28
github.com/Azure/go-autorest/autorest/adal v0.9.21
github.com/Azure/go-autorest/autorest/to v0.4.0
github.com/Azure/go-autorest/autorest/to v0.4.0 // indirect
github.com/container-storage-interface/spec v1.5.0
github.com/gofrs/uuid v4.2.0+incompatible // indirect
github.com/golang/mock v1.6.0
Expand Down
14 changes: 7 additions & 7 deletions pkg/blob/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ import (

"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2021-09-01/storage"
azstorage "github.com/Azure/azure-sdk-for-go/storage"
"github.com/Azure/go-autorest/autorest/to"
"github.com/container-storage-interface/spec/lib/go/csi"

"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/klog/v2"
"k8s.io/utils/pointer"

"sigs.k8s.io/blob-csi-driver/pkg/util"
azcache "sigs.k8s.io/cloud-provider-azure/pkg/cache"
Expand Down Expand Up @@ -72,7 +72,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
var vnetResourceGroup, vnetName, subnetName, accessTier string
var matchTags, useDataPlaneAPI bool
// set allowBlobPublicAccess as false by default
allowBlobPublicAccess := to.BoolPtr(false)
allowBlobPublicAccess := pointer.Bool(false)

containerNameReplaceMap := map[string]string{}

Expand Down Expand Up @@ -111,19 +111,19 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
secretNamespace = v
case isHnsEnabledField:
if strings.EqualFold(v, trueValue) {
isHnsEnabled = to.BoolPtr(true)
isHnsEnabled = pointer.Bool(true)
}
case storeAccountKeyField:
if strings.EqualFold(v, falseValue) {
storeAccountKey = false
}
case allowBlobPublicAccessField:
if strings.EqualFold(v, trueValue) {
allowBlobPublicAccess = to.BoolPtr(true)
allowBlobPublicAccess = pointer.Bool(true)
}
case requireInfraEncryptionField:
if strings.EqualFold(v, trueValue) {
requireInfraEncryption = to.BoolPtr(true)
requireInfraEncryption = pointer.Bool(true)
}
case pvcNamespaceKey:
pvcNamespace = v
Expand Down Expand Up @@ -207,8 +207,8 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
enableNfsV3 *bool
)
if protocol == NFS {
isHnsEnabled = to.BoolPtr(true)
enableNfsV3 = to.BoolPtr(true)
isHnsEnabled = pointer.Bool(true)
enableNfsV3 = pointer.Bool(true)
// set VirtualNetworkResourceIDs for storage account firewall setting
vnetResourceID := d.getSubnetResourceID(vnetResourceGroup, vnetName, subnetName)
klog.V(2).Infof("set vnetResourceID(%s) for NFS protocol", vnetResourceID)
Expand Down
4 changes: 2 additions & 2 deletions pkg/blob/controllerserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import (

"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"k8s.io/utils/pointer"

"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2021-09-01/storage"
"github.com/Azure/go-autorest/autorest/to"
"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -1038,7 +1038,7 @@ func TestValidateVolumeCapabilities(t *testing.T) {

for _, test := range testCases {
res, err := d.ValidateVolumeCapabilities(context.Background(), test.req)
d.cloud.BlobClient = newMockBlobClient(&test.clientErr, to.StringPtr(""), test.containerProp)
d.cloud.BlobClient = newMockBlobClient(&test.clientErr, pointer.String(""), test.containerProp)
assert.Equal(t, test.expectedErr, err, "Error in testcase (%s): Errors must match", test.name)
assert.Equal(t, test.expectedRes, res, "Error in testcase (%s): Response must match", test.name)
}
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/testsuites/testsuites.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (

"sigs.k8s.io/blob-csi-driver/pkg/blob"

"github.com/Azure/go-autorest/autorest/to"
"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/onsi/ginkgo"
"github.com/onsi/gomega"
Expand All @@ -48,6 +47,7 @@ import (
e2epv "k8s.io/kubernetes/test/e2e/framework/pv"
testutil "k8s.io/kubernetes/test/utils"
imageutils "k8s.io/kubernetes/test/utils/image"
"k8s.io/utils/pointer"
)

const (
Expand Down Expand Up @@ -448,7 +448,7 @@ func NewTestPod(c clientset.Interface, ns *v1.Namespace, command string) *TestPo
},
RestartPolicy: v1.RestartPolicyNever,
Volumes: make([]v1.Volume, 0),
AutomountServiceAccountToken: to.BoolPtr(false),
AutomountServiceAccountToken: pointer.Bool(false),
},
},
}
Expand Down Expand Up @@ -556,7 +556,7 @@ func (t *TestPod) SetupInlineVolume(name, mountPath, secretName, containerName s
"containerName": containerName,
"mountOptions": "-o allow_other --file-cache-timeout-in-seconds=240",
},
ReadOnly: to.BoolPtr(readOnly),
ReadOnly: pointer.Bool(readOnly),
},
},
}
Expand Down
6 changes: 3 additions & 3 deletions test/utils/azure/authorization_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import (
"context"
"fmt"

"k8s.io/utils/pointer"
"sigs.k8s.io/blob-csi-driver/test/utils/credentials"

"github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/adal"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/to"
uuid "github.com/satori/go.uuid"
)

Expand Down Expand Up @@ -65,8 +65,8 @@ func (a *AuthorizationClient) AssignRole(ctx context.Context, resourceID, princi
uuid.NewV1().String(),
authorization.RoleAssignmentCreateParameters{
RoleAssignmentProperties: &authorization.RoleAssignmentProperties{
PrincipalID: to.StringPtr(principalID),
RoleDefinitionID: to.StringPtr(roleDefID),
PrincipalID: pointer.String(principalID),
RoleDefinitionID: pointer.String(roleDefID),
},
})
}
Expand Down

0 comments on commit ebef122

Please sign in to comment.