From 7e606beb625f116769a8f0b095957dc46be72f1e Mon Sep 17 00:00:00 2001
From: Neil-Jocelyn Schark <neil-jocelyn.schark@stud.h-da.de>
Date: Wed, 21 Sep 2022 16:16:51 +0200
Subject: [PATCH] add regex for image check

---
 applications/venv-manager/node/node.go | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/applications/venv-manager/node/node.go b/applications/venv-manager/node/node.go
index d33e3e475..bdb9e49d0 100644
--- a/applications/venv-manager/node/node.go
+++ b/applications/venv-manager/node/node.go
@@ -26,8 +26,16 @@ func (n *Node) FillAllFields(containerRegistryURL string) {
 	// Works if linux and our gnmi target is used.
 	softwareVersion := n.YangData.System.State.SoftwareVersion
 	if softwareVersion != nil {
-		n.Kind = "linux"
-		n.Image = containerRegistryURL + *softwareVersion
+		// Checks if software version is in compatible format.
+		result, _ := regexp.MatchString(`^([A-Za-z0-9\.\/])*:([A-Za-z0-9\.])*`, *softwareVersion)
+		if result {
+			n.Kind = "linux"
+			n.Image = containerRegistryURL + *softwareVersion
+			return
+		}
+
+		n.Kind = "couldn't detect kind"
+		n.Image = "couldn't detect image"
 		return
 	}
 
-- 
GitLab