-
Notifications
You must be signed in to change notification settings - Fork 2.1k
SDK automation, support TypeSpec folder structure v2 #45617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,15 +127,17 @@ def sdk_automation(input_file: str, output_file: str): | |
| logging.error("[GENERATE] Code generation failed. Unknown exception", exc_info=True) | ||
| if packages and len(packages) == 1: | ||
| packages[0]["result"] = "failed" | ||
| else: | ||
| sys.exit(1) | ||
| sys.exit(1) | ||
|
|
||
| with open(output_file, "w", encoding="utf-8") as fout: | ||
| output = { | ||
| "packages": packages, | ||
| } | ||
| json.dump(output, fout) | ||
|
|
||
| if packages and len(packages) == 1 and packages[0]["result"] == "failed": | ||
| sys.exit(1) | ||
|
|
||
|
|
||
| def sdk_automation_autorest(config: dict) -> List[dict]: | ||
| base_dir = os.path.abspath(os.path.dirname(sys.argv[0])) | ||
|
|
@@ -250,8 +252,22 @@ def sdk_automation_typespec(config: dict) -> List[dict]: | |
| tsp_projects = [tsp_projects] | ||
|
|
||
| for tsp_project in tsp_projects: | ||
| # folder structure v2: specification/{service}/[data-plane|resource-manager]/{provider}/ | ||
| folder_structure_v2_pattern = r"specification/.*/(data-plane|resource-manager)" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @XiaofeiCao {service} folder in V2 is only one level. So the regex should be
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it. This is only for TypeSpec, and in v1 we don't have |
||
| match = re.compile(folder_structure_v2_pattern).search(tsp_project) | ||
XiaofeiCao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if match: | ||
| sdk_type = match.group(1) | ||
| if sdk_type == "data-plane": | ||
| logging.info("[GENERATE] Generating data-plane from folder structure v2: " + tsp_project) | ||
| packages.append(sdk_automation_typespec_project_data(tsp_project, config)) | ||
| elif sdk_type == "resource-manager": | ||
| logging.info("[GENERATE] Generating mgmt-plane from folder structure v2: " + tsp_project) | ||
| packages.append(sdk_automation_typespec_project(tsp_project, config)) | ||
| else: | ||
| raise ValueError("Unexpected sdk type: " + sdk_type) | ||
| # folder structure v1 | ||
| # mgmt tsp project folder follow the pattern, e.g. specification/deviceregistry/DeviceRegistry.Management | ||
| if re.match(r"specification[\\/](.*)[\\/](.*)[\\.]Management", tsp_project): | ||
| elif re.match(r"specification[\\/](.*)[\\/](.*)[\\.]Management", tsp_project): | ||
| packages.append(sdk_automation_typespec_project(tsp_project, config)) | ||
| else: | ||
| packages.append(sdk_automation_typespec_project_data(tsp_project, config)) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.