This repository has been archived by the owner on Mar 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 83
add regex for different volume size format #1416
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@aravindavk PTAL |
aravindavk
suggested changes
Dec 17, 2018
glustercli/cmd/utils.go
Outdated
@@ -12,7 +12,7 @@ import ( | |||
) | |||
|
|||
var ( | |||
validSizeFormat = regexp.MustCompile(`^([0-9]+)([GMKT])?$`) | |||
validSizeFormat = regexp.MustCompile(`^([0-9]+)?([kKmMgGtT])?[iI]?[bB]?$`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- first
?
will make digit optional. - Space in between digit and number can be supported by adding
\s*
in between - sizeParts[2] will not have all suffix chars. Use this regex
^([0-9]+)\s*([kKmMgGtT]?[iI]?[bB]?)$
we should be able to create volume size with different formats like KB, Kib, Mb, MiB etc Fixes: gluster#1398 ``` [root@dhcp43-209 build]# ./glustercli volume create size1 --size=20MB --replica=3 -v size1 Volume created successfully Volume ID: b2693574-8489-4d4b-94ab-3564776d1cce [root@dhcp43-209 build]# ./glustercli volume create size2 --size=20MiB --replica=3 -v size2 Volume created successfully Volume ID: b1153478-4912-4481-a047-8d67258ab08c [root@dhcp43-209 build]# ./glustercli volume create size3 --size=20M --replica=3 -v size3 Volume created successfully Volume ID: 8ac1c9a5-cc84-45ec-b382-eff17369d024 [root@dhcp43-209 build]# ./glustercli volume create size35 --size=20 --replica=3 -v size35 Volume created successfully Volume ID: 560da74f-b7cf-466c-994c-0f03ba07bb24 [root@dhcp43-209 build]# ./glustercli volume create size --size=21mb --replica=3 -v 7size Volume created successfully Volume ID: 638d4108-bf2e-48e9-9d1d-982a34882586 [root@dhcp43-209 build]# ./glustercli volume create sizes6 --size=20971520 --replica=3 -v sizes6 Volume created successfully Volume ID: c4de7f7e-e4b4-46e6-80d1-92a9e060c4c0 [root@dhcp43-209 build]# ./glustercli volume create size6 --size=20971520sadf --replica=3 -v Invalid Volume Size specified ``` Signed-off-by: Madhu Rajanna <mrajanna@redhat.com>
@aravindavk PTAL |
aravindavk
approved these changes
Dec 17, 2018
atinmu
reviewed
Dec 17, 2018
@@ -12,7 +12,7 @@ import ( | |||
) | |||
|
|||
var ( | |||
validSizeFormat = regexp.MustCompile(`^([0-9]+)([GMKT])?$`) | |||
validSizeFormat = regexp.MustCompile(`^([0-9]+)\s*([kKmMgGtT]?[iI]?[bB]?)$`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What're iI & bB for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to support units like MB
or MiB
, kb
, kib
atinmu
approved these changes
Dec 17, 2018
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
we should be able to create volume size with
different formats like KB, Kib, Mb, MiB etc
Fixes: #1398