SamuelFisher / TerraformPluginDotNet

Write Terraform providers in C#.
MIT License
46 stars 14 forks source link

Allow custom schemas using IDataSourceSchemaProvider #40

Open ThomasBleijendaal opened 1 year ago

ThomasBleijendaal commented 1 year ago

This PR adds IDataSourceSchemaProvider which is an interface that allows plugins to provide custom schemas that are not bound to a specific concrete type. One can output a schema containing objects with certain properties, but use an type that receives those properties in something like Dictionary<string, Dictionary<string, object>>.

I don't know if you want to go this direction with this plugin, but this allows for creating a bunch of specialized schemas, but handle those using a single type.

A use case for this is, for example, create a terraform plugin that reads a certain folder for specific files, parse those files, and output a schemas for each file, containing properties from those files. Those files can then be referenced in the terraform template, and the code suggestions will reflect those exact files and their contents.

ThomasBleijendaal commented 1 year ago

On second thought, we might want to make the IDataSourceSchemaProvider.GetSchema async. That requires some more rework in the ResourceRegistry, but that makes creating dynamic schemas more easy when dealing with IO. What do you think?