Closed reidmv closed 4 years ago
I noticed that the current tests seem to want to raise an exception if a file is absent. Is that design intent, or happenstance?
My use case:
I am the purveyor of a Bolt project which:
When I have cloned a new, fresh copy of my project
I want to be able to run bolt inventory show
showing no systems before I have provisioned them
I want to be able to run bolt inventory show
showing new systems, after provisioning
I want to be able to do this without modifying the inventory.yaml file I ship in my project
In the current design, in which the inventory plugin raises an exception if no Terraform statefile is found, this is impossible. Prior to the provision plan running terraform init
command and terraform apply
, there will be no statefile.
I propose that rather than raising an exception, in the event a Terraform statefile does not exist, we interpret this as "there is no state". In terms of inventory data, this means "there is no inventory". I propose that this is not considered an exception, but rather a simple empty inventory situation.
That use case makes sense to me.
I would imagine the reasoning behind failing if no state exists was simply that the anticipated use case was integrating with an existing terraform project and thus is seemed like a non-existent statefile was most likely due to a typo or wrong path.
Supporting your real use case seems more important than protecting against hypothetical user mistakes.
The plugin should not crash when the statefile is absent. Rather, it should return no inventory.