Skip to content

Commit 2a297d2

Browse files
change regex pattern
Signed-off-by: LiZhenCheng9527 <lizhencheng6@huawei.com>
1 parent 33d0ce2 commit 2a297d2

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

ctl/version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func getVersion(client kube.CLIClient, podName string) (version version.Info) {
142142

143143
// match release version vx.y.z-(alpha)
144144
func stringMatch(str string) bool {
145-
pattern := `^v\d+\.\d+\.\d+(-[a-zA-Z0-9]+)?$`
145+
pattern := `^v\d+\.\d+\.\d+(-[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)*)?$`
146146
regex := regexp.MustCompile(pattern)
147147

148148
return regex.MatchString(str)

ctl/version/version_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,18 @@ func Test_stringMatch(t *testing.T) {
4949
want: false,
5050
},
5151
{
52-
name: "Incorrect Suffix",
52+
name: "alpha.0 Suffix",
5353
args: args{
5454
str: "v1.1.1-alpha.0",
5555
},
56-
want: false,
56+
want: true,
57+
},
58+
{
59+
name: "alpha.bate suffix",
60+
args: args{
61+
str: "v1.1.1-alpha.beta",
62+
},
63+
want: true,
5764
},
5865
}
5966
for _, tt := range tests {

0 commit comments

Comments
 (0)