Skip to content

Commit 486959c

Browse files
authored
Merge pull request #24 from srl-labs/version-parse-relax
relaxed regexp to parse version out of a tag
2 parents 88b58e7 + beaf7b0 commit 486959c

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

api/types/v1alpha1/srl_version.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ func parseVersionString(s string) (*SrlVersion, error) {
2929
return &SrlVersion{"0", "", "", "", ""}, nil
3030
}
3131

32-
// https://regex101.com/r/eWS6Ms/1
32+
// https://regex101.com/r/eWS6Ms/3
3333
re := regexp.MustCompile(
34-
`^v?(?P<major>\d{1,3})\.(?P<minor>\d{1,2})\.?(?P<patch>\d{1,2})?-?(?P<build>\d{1,10})?-?(?P<commit>\S+)?`,
34+
`(?P<major>\d{1,3})\.(?P<minor>\d{1,2})\.?(?P<patch>\d{1,2})?-?(?P<build>\d{1,10})?-?(?P<commit>\S+)?`,
3535
)
3636

3737
v := re.FindStringSubmatch(s)

api/types/v1alpha1/srl_version_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ func TestParseVersionString(t *testing.T) {
6363
got: "0.0.0-34652",
6464
want: &SrlVersion{"0", "0", "0", "34652", ""},
6565
},
66+
{
67+
desc: "version_0.0.0-34652",
68+
got: "version_0.0.0-34652",
69+
want: &SrlVersion{"0", "0", "0", "34652", ""},
70+
},
6671
{
6772
desc: "latest",
6873
got: "latest",

api/types/v1alpha1/srlinux_types_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func TestGetImageVersion(t *testing.T) {
9595
{
9696
desc: "invalid version is present",
9797
spec: &SrlinuxSpec{
98-
Version: "abc21.11.1",
98+
Version: "abc",
9999
Config: &NodeConfig{Image: "ghcr.io/nokia/srlinux:somever"},
100100
},
101101
err: ErrVersionParse,
@@ -110,7 +110,7 @@ func TestGetImageVersion(t *testing.T) {
110110
{
111111
desc: "version is not present, invalid image tag is given",
112112
spec: &SrlinuxSpec{
113-
Config: &NodeConfig{Image: "ghcr.io/nokia/srlinux:21"},
113+
Config: &NodeConfig{Image: "ghcr.io/nokia/srlinux:somesrl"},
114114
},
115115
err: ErrVersionParse,
116116
},

config/manager/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ kind: Kustomization
1717
images:
1818
- name: controller
1919
newName: ghcr.io/srl-labs/srl-controller
20-
newTag: 0.4.4
20+
newTag: 0.4.5

0 commit comments

Comments
 (0)