infrablocks / ruby_terraform

A simple Ruby wrapper for invoking terraform commands.
MIT License
109 stars 33 forks source link

Refactor commands to be configuration driven and move lino logic into a builder. #52

Closed sa73917 closed 3 years ago

sa73917 commented 3 years ago

As mentioned in the earlier RFC I've bounced around a bit on how best to do this. I settled on each command listing the switches it accepts, and having an OptionsFactory that knows what all the switches are and what sort of option it should create for each (flag, boolean or standard). This does of course assume Terraform is consistent with its switches but from what I've seen so far that appears to be the case (and saves having to incorporate the option specialisation into each command).

I have a follow up PR that updates all the commands to reflect the switches they accept in Terraform 0.15 but as this one was already pretty massive I thought I'd split it out at the point where the commands are still largely "the same" as they were before I started.

I've made some notes in the second commit about the small changes I had to make in the specs to make this work. Hopefully it all makes sense.

The last commit is just a minor fix to output and a change to the rubocop.yml to get a clean bill of health from rubocop :-)