File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
pkg/api/deploymentapi/deploymentsize Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -29,8 +29,9 @@ const minsize = 512
29
29
// ParseGb converts the stringified gigabyte size notation to an int32 Megabyte
30
30
// notation. The minimum size allowed is 0.5g Megabytes with 0.5g increments.
31
31
func ParseGb (strSize string ) (int32 , error ) {
32
+ strSize = strings .ToLower (strSize )
32
33
re := regexp .MustCompile (`(?m)(.*\w)(g)` )
33
- matches := re .FindStringSubmatch (strings . ToLower ( strSize ) )
34
+ matches := re .FindStringSubmatch (strSize )
34
35
if len (matches ) < 2 {
35
36
fmt .Println (matches , "length" , len (matches ))
36
37
return 0 , fmt .Errorf (`failed to convert "%s" to <size><g>` , strSize )
Original file line number Diff line number Diff line change @@ -42,6 +42,14 @@ func TestParse(t *testing.T) {
42
42
name : "parses a 8gb (gigabyte notation)" ,
43
43
args : args {strSize : "8gb" }, want : 8 * 1024 ,
44
44
},
45
+ {
46
+ name : "parses a 0.5G (gigabyte notation)" ,
47
+ args : args {strSize : "0.5G" }, want : 512 ,
48
+ },
49
+ {
50
+ name : "parses a 8GB (gigabyte notation)" ,
51
+ args : args {strSize : "8GB" }, want : 8 * 1024 ,
52
+ },
45
53
{
46
54
name : "trying to parse 512m returns a failure" ,
47
55
args : args {strSize : "512m" },
You can’t perform that action at this time.
0 commit comments