Skip to content

Commit 841e519

Browse files
authored
Merge pull request #2666 from kubernetes-sigs/clientID-sc
cleanup: refine clientID parameter parsing
2 parents 3dd6a60 + 8d3d57e commit 841e519

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

pkg/azurefile/azurefile.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ const (
128128
podNameField = "csi.storage.k8s.io/pod.name"
129129
podNamespaceField = "csi.storage.k8s.io/pod.namespace"
130130
serviceAccountTokenField = "csi.storage.k8s.io/serviceAccount.tokens"
131-
clientIDField = "clientID"
132-
tenantIDField = "tenantID"
131+
clientIDField = "clientid"
132+
tenantIDField = "tenantid"
133133
mountOptionsField = "mountoptions"
134134
mountPermissionsField = "mountpermissions"
135135
encryptInTransitField = "encryptintransit"
@@ -807,9 +807,9 @@ func (d *Driver) GetAccountInfo(ctx context.Context, volumeID string, secrets, r
807807
if getLatestAccountKey, err = strconv.ParseBool(v); err != nil {
808808
return rgName, accountName, accountKey, fileShareName, diskName, subsID, fmt.Errorf("invalid %s: %s in volume context", getLatestAccountKeyField, v)
809809
}
810-
case strings.ToLower(clientIDField):
810+
case clientIDField:
811811
clientID = v
812-
case strings.ToLower(tenantIDField):
812+
case tenantIDField:
813813
tenantID = v
814814
case strings.ToLower(serviceAccountTokenField):
815815
serviceAccountToken = v

pkg/azurefile/controllerserver.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
228228
// no op, only used in NodeStageVolume
229229
case folderNameField:
230230
// no op, only used in NodeStageVolume
231+
case clientIDField:
232+
// no op, only used in NodeStageVolume
231233
case fsGroupChangePolicyField:
232234
fsGroupChangePolicy = v
233235
case mountPermissionsField:

pkg/azurefile/controllerserver_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,7 @@ var _ = ginkgo.Describe("TestCreateVolume", func() {
919919
mountPermissionsField: "0755",
920920
accountQuotaField: "1000",
921921
useDataPlaneAPIField: "oauth",
922+
clientIDField: "client-id",
922923
}
923924

924925
req := &csi.CreateVolumeRequest{

pkg/azurefile/nodeserver.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (d *Driver) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolu
7777
context := req.GetVolumeContext()
7878
if context != nil {
7979
// token request
80-
if context[serviceAccountTokenField] != "" && getValueInMap(context, clientIDField) != "" {
80+
if getValueInMap(context, serviceAccountTokenField) != "" && getValueInMap(context, clientIDField) != "" {
8181
klog.V(2).Infof("NodePublishVolume: volume(%s) mount on %s with service account token, clientID: %s", volumeID, target, getValueInMap(context, clientIDField))
8282
_, err := d.NodeStageVolume(ctx, &csi.NodeStageVolumeRequest{
8383
StagingTargetPath: target,
@@ -233,7 +233,7 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
233233
volumeID := req.GetVolumeId()
234234
context := req.GetVolumeContext()
235235

236-
if getValueInMap(context, clientIDField) != "" && context[serviceAccountTokenField] == "" {
236+
if getValueInMap(context, clientIDField) != "" && getValueInMap(context, serviceAccountTokenField) == "" {
237237
klog.V(2).Infof("Skip NodeStageVolume for volume(%s) since clientID %s is provided but service account token is empty", volumeID, getValueInMap(context, clientIDField))
238238
return &csi.NodeStageVolumeResponse{}, nil
239239
}

0 commit comments

Comments
 (0)