terrars
terrars copied to clipboard
Implement provisioners
So just taking a quick look, I think implementation would basically just be extending structs with fields and methods to include provisioner data. Slightly more specifically:
-
Make a
BuildProvisionerstruct with required fields, abuildmethod to get aProvisioner, and mutator methods to set the non-required fields onProvisioner(this sounds really similar to building resources). Since there are multiple provisioner types, this may be provisioner specific, likeBuildLocalExecProvisioner. (I can't remember how I handled resource polymorphism, I think maybe resources implement a trait? So there might be aProvisionertrait here) -
During code generation, add a
provisionerfield + appropriate methods to each resource that's aVec<Rc<dyn Provisioner>>or whatever -
Also add a
Vec<Rc<dyn Provisioner>>to the schema itself with methods for non-resource provisioners?
I might be off base with some of this stuff.
All in all, it's basically adding a few structs manually with the correct types so it should be fairly straightforward and not a huge amount of work. I think there are similar "automatic" fields in resources like depends_on and lifecycle stuff, so adding a provisioners list will be done similarly.
FWIW I think the generation code is pretty straight forward, but code generation in general is fairly gnarly because of how meta it is, plus working around terraform non-orthogonalities made it gnarlier, so while it shouldn't be a big change it may be a bit difficult to navigate that code.
Originally posted by @andrewbaxter in https://github.com/andrewbaxter/terrars/issues/4#issuecomment-2517683458