terrars icon indicating copy to clipboard operation
terrars copied to clipboard

Implement provisioners

Open andrewbaxter opened this issue 9 months ago • 0 comments

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 BuildProvisioner struct with required fields, a build method to get a Provisioner, and mutator methods to set the non-required fields on Provisioner (this sounds really similar to building resources). Since there are multiple provisioner types, this may be provisioner specific, like BuildLocalExecProvisioner. (I can't remember how I handled resource polymorphism, I think maybe resources implement a trait? So there might be a Provisioner trait here)

  • During code generation, add a provisioner field + appropriate methods to each resource that's a Vec<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

andrewbaxter avatar Jan 02 '25 17:01 andrewbaxter