Skip to content

Commit 5a3acc7

Browse files
authored
script change (#45617)
1 parent c1275a2 commit 5a3acc7

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

eng/automation/generate.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,17 @@ def sdk_automation(input_file: str, output_file: str):
127127
logging.error("[GENERATE] Code generation failed. Unknown exception", exc_info=True)
128128
if packages and len(packages) == 1:
129129
packages[0]["result"] = "failed"
130-
else:
131-
sys.exit(1)
130+
sys.exit(1)
132131

133132
with open(output_file, "w", encoding="utf-8") as fout:
134133
output = {
135134
"packages": packages,
136135
}
137136
json.dump(output, fout)
138137

138+
if packages and len(packages) == 1 and packages[0]["result"] == "failed":
139+
sys.exit(1)
140+
139141

140142
def sdk_automation_autorest(config: dict) -> List[dict]:
141143
base_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
@@ -250,8 +252,22 @@ def sdk_automation_typespec(config: dict) -> List[dict]:
250252
tsp_projects = [tsp_projects]
251253

252254
for tsp_project in tsp_projects:
255+
# folder structure v2: specification/{service}/[data-plane|resource-manager]/{provider}/
256+
folder_structure_v2_pattern = r"specification/.*/(data-plane|resource-manager)"
257+
match = re.compile(folder_structure_v2_pattern).search(tsp_project)
258+
if match:
259+
sdk_type = match.group(1)
260+
if sdk_type == "data-plane":
261+
logging.info("[GENERATE] Generating data-plane from folder structure v2: " + tsp_project)
262+
packages.append(sdk_automation_typespec_project_data(tsp_project, config))
263+
elif sdk_type == "resource-manager":
264+
logging.info("[GENERATE] Generating mgmt-plane from folder structure v2: " + tsp_project)
265+
packages.append(sdk_automation_typespec_project(tsp_project, config))
266+
else:
267+
raise ValueError("Unexpected sdk type: " + sdk_type)
268+
# folder structure v1
253269
# mgmt tsp project folder follow the pattern, e.g. specification/deviceregistry/DeviceRegistry.Management
254-
if re.match(r"specification[\\/](.*)[\\/](.*)[\\.]Management", tsp_project):
270+
elif re.match(r"specification[\\/](.*)[\\/](.*)[\\.]Management", tsp_project):
255271
packages.append(sdk_automation_typespec_project(tsp_project, config))
256272
else:
257273
packages.append(sdk_automation_typespec_project_data(tsp_project, config))

0 commit comments

Comments
 (0)