From 036335f58032f17b3c1b33744bf1ae5e25bc9a3c Mon Sep 17 00:00:00 2001 From: Roman Dodin Date: Fri, 14 Oct 2022 10:02:57 +0200 Subject: [PATCH 1/3] relax version string parsing from tag --- api/types/v1alpha1/srl_version.go | 4 ++-- api/types/v1alpha1/srl_version_test.go | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/api/types/v1alpha1/srl_version.go b/api/types/v1alpha1/srl_version.go index dce2e32..d19a96e 100644 --- a/api/types/v1alpha1/srl_version.go +++ b/api/types/v1alpha1/srl_version.go @@ -29,9 +29,9 @@ func parseVersionString(s string) (*SrlVersion, error) { return &SrlVersion{"0", "", "", "", ""}, nil } - // https://regex101.com/r/eWS6Ms/1 + // https://regex101.com/r/eWS6Ms/3 re := regexp.MustCompile( - `^v?(?P\d{1,3})\.(?P\d{1,2})\.?(?P\d{1,2})?-?(?P\d{1,10})?-?(?P\S+)?`, + `(?P\d{1,3})\.(?P\d{1,2})\.?(?P\d{1,2})?-?(?P\d{1,10})?-?(?P\S+)?`, ) v := re.FindStringSubmatch(s) diff --git a/api/types/v1alpha1/srl_version_test.go b/api/types/v1alpha1/srl_version_test.go index 071072e..4dc3058 100644 --- a/api/types/v1alpha1/srl_version_test.go +++ b/api/types/v1alpha1/srl_version_test.go @@ -63,6 +63,11 @@ func TestParseVersionString(t *testing.T) { got: "0.0.0-34652", want: &SrlVersion{"0", "0", "0", "34652", ""}, }, + { + desc: "version_0.0.0-34652", + got: "version_0.0.0-34652", + want: &SrlVersion{"0", "0", "0", "34652", ""}, + }, { desc: "latest", got: "latest", From 0092192ebdebd9c1a067ec4d7544a12da8f24b62 Mon Sep 17 00:00:00 2001 From: Roman Dodin Date: Fri, 14 Oct 2022 10:12:39 +0200 Subject: [PATCH 2/3] fix getimageversion tests --- api/types/v1alpha1/srlinux_types_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/types/v1alpha1/srlinux_types_test.go b/api/types/v1alpha1/srlinux_types_test.go index b07c300..ca001b8 100644 --- a/api/types/v1alpha1/srlinux_types_test.go +++ b/api/types/v1alpha1/srlinux_types_test.go @@ -95,7 +95,7 @@ func TestGetImageVersion(t *testing.T) { { desc: "invalid version is present", spec: &SrlinuxSpec{ - Version: "abc21.11.1", + Version: "abc", Config: &NodeConfig{Image: "ghcr.io/nokia/srlinux:somever"}, }, err: ErrVersionParse, @@ -110,7 +110,7 @@ func TestGetImageVersion(t *testing.T) { { desc: "version is not present, invalid image tag is given", spec: &SrlinuxSpec{ - Config: &NodeConfig{Image: "ghcr.io/nokia/srlinux:21"}, + Config: &NodeConfig{Image: "ghcr.io/nokia/srlinux:somesrl"}, }, err: ErrVersionParse, }, From beaf7b061bda78a4705df06faa18bc74fd95e6a9 Mon Sep 17 00:00:00 2001 From: Roman Dodin Date: Fri, 14 Oct 2022 10:22:41 +0200 Subject: [PATCH 3/3] updated tag --- config/manager/kustomization.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 839d3da..1033201 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -17,4 +17,4 @@ kind: Kustomization images: - name: controller newName: ghcr.io/srl-labs/srl-controller - newTag: 0.4.4 + newTag: 0.4.5