You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Terraform Providers seem to be 95% boilerplate code, and could be generated via the OpenAPI spec along with vendor extensions and support for user-written code
Describe the solution you'd like
I would like to generate the resource and data resource schemas, and the read/create/update/delete methods based on the data in an openapi spec.
A generated provider may depend on a pre-generated go client. I'm not sure if theres any other examples in openapi-generator of a generated client depending on another generated client, or if the terraform client should just generate its own prepackaged go client.
Describe alternatives you've considered
The google and google-beta providers are already mostly auto-generated via a custom tool called Magic Modules. The tool supports generated code (with plenty of terraform-specific decorators) as well as handwritten code. However, it would be better to use OpenAPI as its a ubiquitous standard.
@jasondamour thanks for the suggestion. Would you be able to contribute a PR to add the Terraform Provider client generator or sponsor the community to work on it?
@wing328 Do you know any reference or other instance where one generated client depends on another? In this case, terraform client might depend on golang client. Or does the terraform client need to be entirely self-contained, and generate its own golang client?
Another instance I think this could apply is if OpenAPI supported generating a CLI in another language other than bash, for example with Python. It would require first generating a Python client SDK, then that could be used to generate a Python CLI.
Is there any guidance on how to support these 2nd level generated clients?
Previously the PowerShell client generator depended on the C# SDK (auto-generated API client).
In this case, terraform client might depend on golang client.
I would suggest generating the terraform client and go client via 2 separate generators to start with. In other words, you only need to create Terraform client generator (TerraformClientCodegen.java) for day 1 requirement and we will start from there.
@roopakv thanks for informing us there's another generator available out there. As we told the author of another generator in our Slack channel a few weeks ago, we're not against any other specifications/generators but this is not the right place to market other specifications/generators so we've deleted your message.
Activity
wing328 commentedon Jun 21, 2023
@jasondamour thanks for the suggestion. Would you be able to contribute a PR to add the Terraform Provider client generator or sponsor the community to work on it?
jasondamour commentedon Jun 21, 2023
I'll take a first stab
wing328 commentedon Jun 21, 2023
π
let me know if you need any help
wing328 commentedon Jun 21, 2023
I think a good starting point is to find an existing generator that's similar to Terraform Provider client and clone it to start with.
jasondamour commentedon Jun 21, 2023
@wing328 Do you know any reference or other instance where one generated client depends on another? In this case, terraform client might depend on golang client. Or does the terraform client need to be entirely self-contained, and generate its own golang client?
Another instance I think this could apply is if OpenAPI supported generating a CLI in another language other than bash, for example with Python. It would require first generating a Python client SDK, then that could be used to generate a Python CLI.
Is there any guidance on how to support these 2nd level generated clients?
wing328 commentedon Jun 22, 2023
Previously the PowerShell client generator depended on the C# SDK (auto-generated API client).
I would suggest generating the terraform client and go client via 2 separate generators to start with. In other words, you only need to create Terraform client generator (TerraformClientCodegen.java) for day 1 requirement and we will start from there.
wing328 commentedon Sep 5, 2023
@roopakv thanks for informing us there's another generator available out there. As we told the author of another generator in our Slack channel a few weeks ago, we're not against any other specifications/generators but this is not the right place to market other specifications/generators so we've deleted your message.