Skip to content

Commit e0b5ce8

Browse files
authored
Merge pull request #7957 from huangpixu/master
fix: 修改导入兼容旧版本yaml文件 #7907
2 parents f9e4513 + 7194d6b commit e0b5ce8

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

gcloud/template_base/domains/schema_converter.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ class YamlSchemaConverter(BaseSchemaConverter):
5959
"retryable": True,
6060
"skippable": True,
6161
"stage_name": "",
62+
"auto_retry": {
63+
"enable": False,
64+
"times": 0,
65+
"interval": 0,
66+
},
6267
},
6368
"SubProcess": {
6469
"error_ignorable": False,
@@ -146,13 +151,21 @@ def validate_data(self, yaml_docs: list):
146151
if "id" not in node or "type" not in node:
147152
error.append("模版下所有节点都必须包含id和type字段")
148153
continue
149-
if not set(self.NODE_NECESSARY_FIELDS[node["type"]]).issubset(node.keys()):
150-
error.append(
151-
"节点{}所属的节点类型{}需缺少必须字段:{}".format(
152-
node["id"], node["type"], set(self.NODE_NECESSARY_FIELDS[node["type"]]) - set(node.keys())
153-
)
154-
)
155-
continue
154+
missing_fields = set(self.NODE_NECESSARY_FIELDS[node["type"]]) - set(node.keys())
155+
if missing_fields:
156+
node_defaults = self.NODE_DEFAULT_FIELD_VALUE.get(node["type"], {})
157+
filled_fields = set()
158+
159+
for field in missing_fields:
160+
if field in node_defaults:
161+
node[field] = node_defaults[field]
162+
filled_fields.add(field)
163+
164+
missing_fields -= filled_fields
165+
166+
if missing_fields:
167+
error.append("节点{}所属的节点类型{}需缺少必须字段:{}".format(node["id"], node["type"], sorted(missing_fields)))
168+
continue
156169
if node["type"] in ["ExclusiveGateway", "ConditionalParallelGateway"]:
157170
for condition in node["conditions"].keys():
158171
if condition not in nodes_set:

0 commit comments

Comments
 (0)