-
Notifications
You must be signed in to change notification settings - Fork 2.1k
bring back enum generation #158
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
Fixes #155 |
@lsegal using the ExportableName method yields some enums that are not go style guide approved, is this ok? I think the exportable func is more stylistically correct? For instance
|
@lsegal got rid of the map. Still seems to be an issue with ExportableName though. any advice? |
ResourceTypeAWSEC2VPC = "AWS::EC2::VPC" | ||
ResourceTypeAWSEC2Volume = "AWS::EC2::Volume" | ||
ResourceTypeAWSEC2Vpnconnection = "AWS::EC2::VPNConnection" | ||
ResourceTypeAWSEC2Vpngateway = "AWS::EC2::VPNGateway" |
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.
@lsegal here is a bad one.
@sclasen |
sclasen#1 shows the diff of using the original |
@sclasen only for those very specific examples, and it doesn't work in all cases. In order to guarantee consistency across all exported names going forward we need to explicitly whitelist all words (see inflections.csv) we will have to rely on |
@sclasen basically the |
@lsegal do you mean not set up properly for enums alone somehow or in general not set up correctly? is there a setup func that one can call on |
@sclasen given that it works on other shapes, it's probably not setup correctly for enums. I mentioned above how to use the load passes to correctly setup enums while loading instead of while generating template output-- it doesn't look like this is being done. |
Aha missed that comment. wired it in passes instead, and make complains about a ton of missing inflections, I added them and things are looking better. |
Looks good, but we probably need to go through those inflections and make sure they are correct. I see a few that need some changes. |
@lsegal looking better, though now I am noticing that the generator is picking up older schemas, for example cloudfront has 2 schemas. Is there an incantation to make the generator pick the later schema? |
@sclasen you can explicitly call |
@lsegal ok, I deleted the older cloudfront schemas and ran the generator and it is of course correct. Should older shcemas be deleted? |
@sclasen no, old schemas are supported and may be generated in the future under different packages. |
Alright, is there a mechanism for using only the latest generator other than explicitly enumerating the go:generate calls in service/generate.go ? |
moved the old ones to the side for generation for now |
@sclasen this is not yet supported. As mentioned in the comments, the SDK should be generating with the latest API version, but there might be another (unrelated) generator bug here. |
Between: | ||
Eip:EIP | ||
Vpnconnection:VPNconnection | ||
Vpngateway:VPNgateway |
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.
Assume these 2 should be VPNConnection and VPNGateway @lsegal ?
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.
👍
@lsegal deduped inflections, were a ton! let me know if anything else is needed. |
squashed commits |
👏 |
…that build complained are missing.
@lsegal anything needed here? we have a pile of code that uses the pre develop-merge code, and we use quite a ton of the consts, so we cant switch over till this goes in. |
@sclasen looking through the generated inflections, I'm still seeing a lot of missing or incorrect entries. Ideally all country codes, for example, should be capitalized. We'll still need some time to look through the code in this PR and make sure it's generating the right things. I think there's also still a general question about how these enums will be exposed and what kind of possible bloat will they be providing. Some of this discussion may change how the generation is done. Right now, the generated constants have no association to the structure types they are being used inside of, which makes for a poor documentation story. One thing that could alleviate this would be to create special string alias types for these constants, which would give better visibility to where these constants are used. Another thing I noticed is that the type prefix on these constants occasionally makes for very long names, which could potentially be resolved by relying on the type alias for communicating part of that name. Finally, I'm concerned about some constants bloating the package, specifically the country codes in Route53 Domains, which seems a little superfluous to me. Having a list of 100+ constants in documentation might be distracting and not really provide that much value. Again, I'm not opposed to constants, but I'd like to see if we can address some of these points before merging. In the meantime, while we look at the inflections and think about how to improve visibility in documentation, you should be able to generate these constant names in a separate package in your own codebase (i.e. copy paste the string consts you use) and import that for now. That should unblock you until this gets merged in while still allowing you to switch over the rest of your code. |
Thanks @lsegal fwiw I have found the type prefixes on the constants pretty helpful, especially from an autocomplete perspective, you type My fear is that if we use type aliasing instead of prefixes, the tooling will have to be much smarter to give you a reasonable dropdown. Long names are not a problem with tooling. Do you think adding a enum generation blacklist mechanism would help? Unhelpful enums such as route53domains country code could simply be skipped. Let me know if you'd like me to add that feature. |
@lsegal another question here, but more general. Is it sane to consider building other (external to this project) generators, based on If it were fairly well documented/stable it would be pretty easy to show folks how to generate arbitrary code that you dont necessarily want in this project. For instance
|
@dpiddy @sclasen we're still looking at this. I think the best way to move forward is to use the generated enums in an external (vendored) package so you are not blocked by this pull request. Specifically, given the simplicity of the enums themselves, you don't even need to rely on the internal logic (i.e. #201) to parse the JSON models and pull out enum structures into Go code. |
For example, here's a playground link for parsing enums out of an abridged version of the It would be fairly simple to convert this into a generalized executable to write enums for various service packages. |
add back the enum template, and restore the needed funcs for massaging the enums from the schemata.
/cc @dpiddy