Skip to content

Commit efc568d

Browse files
authored
Merge pull request #1739 from grycap/devel
Use template_file in repo imports
2 parents 31e5903 + 35ca77c commit efc568d

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

IM/tosca/Tosca.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,15 @@ def _get_placement_property(self, sys_name, prop):
102102
return None
103103

104104
def _get_tosca_from_repo(self, input_yaml):
105-
if 'tosca_definitions_version' not in input_yaml or not input_yaml.get('imports'):
105+
if ('tosca_definitions_version' not in input_yaml or
106+
not input_yaml.get('imports') or
107+
len(input_yaml.get('imports')) != 1 or
108+
not isinstance(input_yaml.get('imports')[0], dict) or
109+
input_yaml.get('imports')[0].get("template_file") is None):
106110
return input_yaml
107111

108112
# Check if the import URL
109-
import_file = input_yaml.get('imports')[0]
113+
import_file = input_yaml.get('imports')[0].get("template_file")
110114
if self.tosca_repo:
111115
import_file_url = urlparse(import_file)
112116
# If the import is a URL, check if it is in the TOSCA repository

test/files/tosca_repo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0
33
description: TOSCA test for the IM
44

55
imports:
6-
- simple-node-disk.yml
6+
- template_file: simple-node-disk.yml
77

88
topology_template:
99

test/unit/Tosca.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,8 @@ def test_tosca_repo(self):
518518

519519
# Test with a full URL in the template_file and not in the repo
520520
tosca_yaml = yaml.safe_load(tosca_data)
521-
tosca_yaml["imports"][0] = "https://raw.githubusercontent.com/grycap/tosca/main/templates/simple-node-disk.yml"
521+
tosca_yaml["imports"][0]["template_file"] = \
522+
"https://raw.githubusercontent.com/grycap/tosca/main/templates/simple-node-disk.yml"
522523
tosca = Tosca(yaml.safe_dump(tosca_yaml))
523524
_, radl = tosca.to_radl()
524525
radl = parse_radl(str(radl))

0 commit comments

Comments
 (0)