-
Notifications
You must be signed in to change notification settings - Fork 208
chore: Improve TF schema attribute name generation #3840
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
Conversation
4d2dc20 to
5cdcd83
Compare
| method: PATCH | ||
| version_header: application/vnd.atlas.2023-01-01+json | ||
| schema: | ||
| aliases: |
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.
nice with simplified config!
| path: /api/atlas/v2/groups/{groupId}/auditLog | ||
| version_header: application/vnd.atlas.2023-01-01+json | ||
| name: auditing_api | ||
| packageName: auditingapi |
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.
[nit] Aren't these always following the same rule. Do we need to be explicit?
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.
No need to be explicit but would rather calculate once and avoid maintaining consistency in multiple places.
We now set it once during spec generation and reuse it during code generation, which also makes it configurable in the intermediate model.
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.
Nice just a few nit comments
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.
nice!
| groupId: projectId | ||
| group_id: project_id | ||
| nested_list_array_attr.inner_num_attr: inner_num_attr_alias | ||
| outer_object.nested_level1.level_field1: level_field1_alias |
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.
nit: should we adjust these overrides? Not certain if the snake case is still supported
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.
These are still supported!
We can provide aliases for TF schema attributes. I expect that we'll do this for group_id -> project_id before releasing an autogen resource.
Description
Improving the generation of TF schema attribute names to provide better default UX.
Implemented a custom snake case conversion that treats multiple consecutive uppercase letters as part of the same word, except for the last one.
Examples:
Before:
MongoDBMajorVersion->mongo_dbmajor_versionAfter:
MongoDBMajorVersion->mongo_db_major_versionBefore:
AwsIAMType->aws_iamtypeAfter:
AwsIAMType->aws_iam_typeRemoved
xstringsusage fromstringcasepackage.Removed
snake_casetocamelCaseconversions across the autogen code.Converting from camelCase to snake_case is fine but its not a reversible operation (see #3740).
Config aliases are no longer case converted (preventing potential inconsistencies).
Example:
To add an alias for the cluster name in path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}
Before we would provide
cluster_name: name.cluster_namewould be converted toclusterNameand replaced in the path.Now we directly provide
clusterName: name.Link to any related issue(s): CLOUDP-349435
Type of change:
Required Checklist:
Further comments