Skip to content

Commit cff775b

Browse files
authored
Multiple tags formatting issue (#102)
* Multiple tags formatting issue * Multiple tags formatting issue * Multiple tags formatting issue * Multiple tags formatting issue * Multiple tags formatting issue
1 parent 33ad087 commit cff775b

File tree

8 files changed

+51
-48
lines changed

8 files changed

+51
-48
lines changed

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ module github.com/kubernetes-sigs/ibm-vpc-block-csi-driver
33
go 1.18
44

55
require (
6-
github.com/IBM/ibm-csi-common v1.0.0-beta22
6+
github.com/IBM/ibm-csi-common v1.0.0-beta23
77
github.com/IBM/ibmcloud-volume-interface v1.0.1-beta8
8-
github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta11
8+
github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta12
99
github.com/container-storage-interface/spec v1.5.0
1010
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
1111
github.com/google/uuid v1.1.2

go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.6.7 h1:eHgfQl6IeSmzWUyiSi13CvoFYsovoyq
5555
github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.6.7/go.mod h1:RiUvKuHKTBmBApDMUQzBL14pQUGKcx/IioKQPIcRQjs=
5656
github.com/IBM/go-sdk-core/v5 v5.9.1 h1:06pXbD9Rgmqqe2HA5YAeQbB4eYRRFgIoOT+Kh3cp1zo=
5757
github.com/IBM/go-sdk-core/v5 v5.9.1/go.mod h1:axE2JrRq79gIJTjKPBwV6gWHswvVptBjbcvvCPIxARM=
58-
github.com/IBM/ibm-csi-common v1.0.0-beta22 h1:YyrsMkIVd8qY5i3W5Sb8zxenQEjLiU4Gfrt1Gv3Dc9w=
59-
github.com/IBM/ibm-csi-common v1.0.0-beta22/go.mod h1:JbgQdTw8DeltkdSnvTNWTv/+h0IqB6F4MKkLPbUtE5o=
58+
github.com/IBM/ibm-csi-common v1.0.0-beta23 h1:4RC0xZji587rAPenwLHDlsxVsQd7sX+z/mB3Q69Pgn4=
59+
github.com/IBM/ibm-csi-common v1.0.0-beta23/go.mod h1:EXMfqRpCra8jWnNklxYIkhhCUbVifPqKor8394LySeI=
6060
github.com/IBM/ibmcloud-volume-interface v1.0.1-beta8 h1:KFBRmrOeWklThDap6n8rWhN1IBdCl3gE7MXghSzzBfY=
6161
github.com/IBM/ibmcloud-volume-interface v1.0.1-beta8/go.mod h1:U30gr/DcJvI/Um4Od+DFUW36xL9VuE91wUUdu0q4IHs=
62-
github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta11 h1:9M+6xTe76s5Ka2wuQhkCEr6KFTyPl3w4qS5aTnZTmgE=
63-
github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta11/go.mod h1:fUZXzUXPiTHZzM9+Ue1ZDKrzcMqd65UI8bN2xJiFHfA=
62+
github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta12 h1:53NlPPRjUhB9lkJKYgnV7AbZRjG7hZwU/KuU4oBKmUg=
63+
github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta12/go.mod h1:fUZXzUXPiTHZzM9+Ue1ZDKrzcMqd65UI8bN2xJiFHfA=
6464
github.com/IBM/secret-common-lib v1.0.5 h1:mbOZRFcGY+3FtKMmj36kleHmDyARkbURxcexdM5EJLA=
6565
github.com/IBM/secret-common-lib v1.0.5/go.mod h1:n6UmAAPIrCwGBf+DmUWoWeiLAfBoivYssoiH/f+f1Do=
6666
github.com/IBM/secret-utils-lib v1.0.4 h1:l5ohKdW3ciRkccdyMz3dWZS68+7VgK2OH72BYQScCZw=

pkg/ibmcsidriver/controller_helper.go

+8-11
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,9 @@ func getVolumeParameters(logger *zap.Logger, req *csi.CreateVolumeRequest, confi
137137
volume.Region = value
138138
}
139139
case Tag:
140-
if len(value) > TagMaxLen {
141-
err = fmt.Errorf("%s:<%v> exceeds %d chars", key, value, TagMaxLen)
142-
}
143140
if len(value) != 0 {
144-
volume.VPCVolume.Tags = []string{value}
141+
tagstr := strings.TrimSpace(value)
142+
volume.VPCVolume.Tags = strings.Split(tagstr, ",")
145143
}
146144

147145
case ResourceGroup:
@@ -322,14 +320,13 @@ func overrideParams(logger *zap.Logger, req *csi.CreateVolumeRequest, config *co
322320
}
323321
}
324322
case Tag:
325-
if len(value) > TagMaxLen {
326-
err = fmt.Errorf("%s:<%v> exceeds %d chars", key, value, TagMaxLen)
327-
} else {
328-
if len(value) != 0 {
329-
logger.Info("append", zap.Any(Tag, value))
330-
volume.VPCVolume.Tags = append(volume.VPCVolume.Tags, value)
331-
}
323+
if len(value) != 0 {
324+
logger.Info("append", zap.Any(Tag, value))
325+
tagstr := strings.TrimSpace(value)
326+
secretTags := strings.Split(tagstr, ",")
327+
volume.VPCVolume.Tags = append(volume.VPCVolume.Tags, secretTags...)
332328
}
329+
333330
case Zone:
334331
if len(value) > ZoneNameMaxLen {
335332
err = fmt.Errorf("%s:<%v> exceeds %d chars", key, value, ZoneNameMaxLen)

pkg/ibmcsidriver/controller_helper_test.go

-22
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ const (
3333
exceededZoneName = "testzone-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
3434
exceededRegionName = "us-south-test-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
3535
exceededResourceGID = "myresourcegroups-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
36-
exceededTag = "tag-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
3736
exceededEncryptionKey = "key-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
3837
)
3938

@@ -228,16 +227,6 @@ func TestGetVolumeParameters(t *testing.T) {
228227
expectedStatus: true,
229228
expectedError: fmt.Errorf("%s:<%v> exceeds %d chars", ResourceGroup, exceededResourceGID, ResourceGroupIDMaxLen),
230229
},
231-
{
232-
testCaseName: "Max length exceeded for tag",
233-
request: &csi.CreateVolumeRequest{Parameters: map[string]string{
234-
Tag: exceededTag,
235-
},
236-
},
237-
expectedVolume: &provider.Volume{},
238-
expectedStatus: true,
239-
expectedError: fmt.Errorf("%s:<%v> exceeds %d chars", Tag, exceededTag, TagMaxLen),
240-
},
241230
{
242231
testCaseName: "Wrong encrypted key's value",
243232
request: &csi.CreateVolumeRequest{Parameters: map[string]string{
@@ -501,17 +490,6 @@ func TestOverrideParams(t *testing.T) {
501490
expectedStatus: true,
502491
expectedError: fmt.Errorf("%s exceeds %d bytes", EncryptionKey, EncryptionKeyMaxLen),
503492
},
504-
{
505-
testCaseName: "Tag key size exceeded",
506-
request: &csi.CreateVolumeRequest{Name: volumeName, CapacityRange: &csi.CapacityRange{RequiredBytes: 11811160064, LimitBytes: utils.MinimumVolumeSizeInBytes + utils.MinimumVolumeSizeInBytes},
507-
Secrets: map[string]string{
508-
Tag: exceededTag,
509-
},
510-
},
511-
expectedVolume: &provider.Volume{},
512-
expectedStatus: true,
513-
expectedError: fmt.Errorf("%s:<%v> exceeds %d chars", Tag, exceededTag, TagMaxLen),
514-
},
515493
{
516494
testCaseName: "Zone key size exceeded",
517495
request: &csi.CreateVolumeRequest{Name: volumeName, CapacityRange: &csi.CapacityRange{RequiredBytes: 11811160064, LimitBytes: utils.MinimumVolumeSizeInBytes + utils.MinimumVolumeSizeInBytes},

vendor/github.com/IBM/ibmcloud-volume-vpc/block/provider/create_volume.go

+4-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/IBM/ibmcloud-volume-vpc/common/vpcclient/models/health_reason.go

+24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/IBM/ibmcloud-volume-vpc/common/vpcclient/models/volume.go

+7-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ github.com/IBM-Cloud/ibm-cloud-cli-sdk/common/rest
88
# github.com/IBM/go-sdk-core/v5 v5.9.1
99
## explicit; go 1.14
1010
github.com/IBM/go-sdk-core/v5/core
11-
# github.com/IBM/ibm-csi-common v1.0.0-beta22
11+
# github.com/IBM/ibm-csi-common v1.0.0-beta23
1212
## explicit; go 1.18
1313
github.com/IBM/ibm-csi-common/pkg/ibmcloudprovider
1414
github.com/IBM/ibm-csi-common/pkg/messages
@@ -29,7 +29,7 @@ github.com/IBM/ibmcloud-volume-interface/lib/utils/reasoncode
2929
github.com/IBM/ibmcloud-volume-interface/provider/auth
3030
github.com/IBM/ibmcloud-volume-interface/provider/iam
3131
github.com/IBM/ibmcloud-volume-interface/provider/local
32-
# github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta11
32+
# github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta12
3333
## explicit; go 1.18
3434
github.com/IBM/ibmcloud-volume-vpc/block/provider
3535
github.com/IBM/ibmcloud-volume-vpc/block/utils

0 commit comments

Comments
 (0)