Fixes validation of helm charts to include URLs 44/14044/3
authorGabriel Cuba <gcuba@whitestack.com>
Mon, 20 Nov 2023 06:43:05 +0000 (01:43 -0500)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Tue, 5 Dec 2023 09:45:44 +0000 (10:45 +0100)
Change-Id: Ifc01ff100aaa22bc1dfeada849b41fe1824e4c7f
Signed-off-by: Gabriel Cuba <gcuba@whitestack.com>
osm_nbi/descriptor_topics.py

index 9695866..98a41d1 100644 (file)
@@ -31,6 +31,7 @@ from time import time
 from uuid import uuid4
 from re import fullmatch
 from zipfile import ZipFile
+from urllib.parse import urlparse
 from osm_nbi.validation import (
     ValidationError,
     pdu_new_schema,
@@ -858,12 +859,18 @@ class VnfdTopic(DescriptorTopic):
 
     @staticmethod
     def validate_helm_chart(indata):
+        def is_url(url):
+            result = urlparse(url)
+            return all([result.scheme, result.netloc])
+
         kdus = indata.get("kdu", [])
         for kdu in kdus:
             helm_chart_value = kdu.get("helm-chart")
             if not helm_chart_value:
                 continue
-            if not valid_helm_chart_re.match(helm_chart_value):
+            if not (
+                valid_helm_chart_re.match(helm_chart_value) or is_url(helm_chart_value)
+            ):
                 raise EngineException(
                     "helm-chart '{}' is not valid".format(helm_chart_value),
                     http_code=HTTPStatus.UNPROCESSABLE_ENTITY,