beelit94 / python-terraform

MIT License
475 stars 171 forks source link

fixed a bug with var-file argument, allow workspace commands to pass flags and options #57

Closed BNMetrics closed 5 years ago

BNMetrics commented 5 years ago

Why am I sending this PR?

  1. There is a bug with the Terraform.apply method, when passing in var_file as an argument, it would also create an empty tmp var-file, which results in an error: An argument or block definition is required here.
  2. terraform workspace commands are structured differently than the rest of the command, as new, select, etc are considered subcommands. It'd be nice if we could be able to pass flags and options into those commands without them being jumbled up as such terraform workspace --no-color select workspace_name, and terraform would not be able to interpret this command.

What has changed?

  1. Added explicit condition to check if the option is var, continue if empty.
  2. added a constant COMMAND_WITH_SUBCOMMANDS, to store commands that may have subcommands. Should terraform add new commands with subcommands, we will be able to append to this list easily.
  3. Allowing workspace related method to pass flags and options.
  4. Added tests to cover the changes made.

Next Steps

  1. Workspace commands can be refined further, for now, what we have is okay.
  2. If you could release a new version on PyPi after merging this PR, that would be amazing! 😸