projects
/
osm
/
NBI.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixes validation of helm charts to include URLs
[osm/NBI.git]
/
osm_nbi
/
descriptor_topics.py
diff --git
a/osm_nbi/descriptor_topics.py
b/osm_nbi/descriptor_topics.py
index
d986963
..
98a41d1
100644
(file)
--- a/
osm_nbi/descriptor_topics.py
+++ b/
osm_nbi/descriptor_topics.py
@@
-31,6
+31,7
@@
from time import time
from uuid import uuid4
from re import fullmatch
from zipfile import ZipFile
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,
from osm_nbi.validation import (
ValidationError,
pdu_new_schema,
@@
-681,7
+682,7
@@
class DescriptorTopic(BaseTopic):
# to preserve current expected behaviour
if "userDefinedData" in indata:
data = indata.pop("userDefinedData")
# to preserve current expected behaviour
if "userDefinedData" in indata:
data = indata.pop("userDefinedData")
- if
type(data) == dict
:
+ if
isinstance(data, dict)
:
indata["_admin"]["userDefinedData"] = data
else:
raise EngineException(
indata["_admin"]["userDefinedData"] = data
else:
raise EngineException(
@@
-858,12
+859,18
@@
class VnfdTopic(DescriptorTopic):
@staticmethod
def validate_helm_chart(indata):
@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
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,
raise EngineException(
"helm-chart '{}' is not valid".format(helm_chart_value),
http_code=HTTPStatus.UNPROCESSABLE_ENTITY,
@@
-1524,7
+1531,7
@@
class NsdTopic(DescriptorTopic):
# to preserve current expected behaviour
if "userDefinedData" in indata:
data = indata.pop("userDefinedData")
# to preserve current expected behaviour
if "userDefinedData" in indata:
data = indata.pop("userDefinedData")
- if
type(data) == dict
:
+ if
isinstance(data, dict)
:
indata["_admin"]["userDefinedData"] = data
else:
raise EngineException(
indata["_admin"]["userDefinedData"] = data
else:
raise EngineException(