-
Notifications
You must be signed in to change notification settings - Fork 47
Read "official" default API versions from spec readmes #3996
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
base: master
Are you sure you want to change the base?
Conversation
e2f0158 to
d7436dc
Compare
Does the PR have any schema changes?Looking good! No breaking changes found. |
…le and service group case.
d7436dc to
b990681
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3996 +/- ##
==========================================
- Coverage 57.52% 57.06% -0.46%
==========================================
Files 82 83 +1
Lines 13096 13225 +129
==========================================
+ Hits 7533 7547 +14
- Misses 4987 5101 +114
- Partials 576 577 +1 ☔ View full report in Codecov by Sentry. |
| if inYamlBlock && strings.HasPrefix(line, "tag: package-") { | ||
| version = strings.TrimSpace(strings.TrimPrefix(line, "tag: package-")) | ||
| break | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at some more readme files, I think we need to do at least one more step of processing to determine what the version selection is.
Where there's an initial code block such as:
``` yaml
title: ApiManagementClient
description: ApiManagement Client
openapi-type: arm
tag: package-preview-2024-06
```The tag will correspond with other, conditional code blocks such as:
``` yaml $(tag) == 'package-preview-2024-06'
input-file:
- Microsoft.ApiManagement/preview/2024-06-01-preview/apigateway.json
- Microsoft.ApiManagement/preview/2024-06-01-preview/apimallpolicies.json
- Microsoft.ApiManagement/preview/2024-06-01-preview/apimanagement.json
- ...
```The tag can be somewhat arbitrary, but the input-file list is the ultimate output we need.
Overall, I think the parsing approach for the data from a readme file is as follows (though we could possibly short-cut some of this, given we're not needing to support user inputs on the tag to use):
- Iterate through each yaml code block.
- Check its condition against the current collected state.
- Merge the block with the current parsed yaml state.
Worked example
With the two blocks defined above, after parsing the first block would result in a state of:
title: ApiManagementClient
description: ApiManagement Client
openapi-type: arm
tag: package-preview-2024-06When evaluating the second block, the value of $(tag) would be package-preview-2024-06 and the condition evaluates to true. Therefore the state after parsing the second block is:
title: ApiManagementClient
description: ApiManagement Client
openapi-type: arm
tag: package-preview-2024-06
input-file:
- Microsoft.ApiManagement/preview/2024-06-01-preview/apigateway.json
- Microsoft.ApiManagement/preview/2024-06-01-preview/apimallpolicies.json
- Microsoft.ApiManagement/preview/2024-06-01-preview/apimanagement.json
- ...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will probably need to turn the list of files back into a list of resources with version instead to produce a lockfile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Fix paths relative root to match existing reports. - Generate diff against current v3 selection (from branch).
|
I was thinking that we would avoid duplication of their core parsing logic by having our tools consume the "code model" that is produced by autorest - the intermediate data format that autorest generates before doing language-specific code generation (across all languages supported by the Azure SDK). This is possible by running autorest with a certain flag to retain the code model, or by installing an autorest language plugin (that would target Pulumi schema). Have you considered an approach like that? Update: here's an example of that approach in action, in this case to generate the bicep schema files. What's missing here is fuller coverage of the resource functions, and perhaps more information about parentage and how to construct the full REST API path for a given resource. |
TODO
mainor close to it, we're picking versions that are too newquota/resource-manager/readme.mdcontainerservice/resource-manager/Microsoft.ContainerService/aks/readme.mdcontainerservice/resource-manager/Microsoft.ContainerService/fleet/readme.mdworkloadseven have the op-level readme and service group readmes; not sure what that means