Commit Graph

111 Commits

Author SHA1 Message Date
Martin Atkins 3f401f0cd4 main: make configuration available when initializing commands
This, in principle, allows us to make use of configuration information
when we populate the Meta structure, though we won't actually make use
of that until a subsequent commit.
2017-09-29 14:03:09 -07:00
Martin Atkins 0fe43c8977 cli: allow disabling "next steps" message in terraform plan
In #15884 we adjusted the plan output to give an explicit command to run
to apply a plan, whereas before this command was just alluded to in the
prose.

Since releasing that, we've got good feedback that it's confusing to
include such instructions when Terraform is running in a workflow
automation tool, because such tools usually abstract away exactly what
commands are run and require users to take different actions to
proceed through the workflow.

To accommodate such environments while retaining helpful messages for
normal CLI usage, here we introduce a new environment variable
TF_IN_AUTOMATION which, when set to a non-empty value, is a hint to
Terraform that it isn't being run in an interactive command shell and
it should thus tone down the "next steps" messaging.

The documentation for this setting is included as part of the "...in
automation" guide since it's not generally useful in other cases. We also
intentionally disclaim comprehensive support for this since we want to
avoid creating an extreme number of "if running in automation..."
codepaths that would increase the testing matrix and hurt maintainability.

The focus is specifically on the output of the three commands we give in
the automation guide, which at present means the following two situations:

* "terraform init" does not include the final paragraphs that suggest
  running "terraform plan" and tell you in what situations you might need
  to re-run "terraform init".
* "terraform plan" does not include the final paragraphs that either
  warn about not specifying "-out=..." or instruct to run
  "terraform apply" with the generated plan file.
2017-09-14 10:51:41 -07:00
James Bardin 2e7c8ab76a update commands.go to use StateMeta 2017-07-27 18:06:47 -04:00
Mike Helmick 9d7fce2f69 command: "terraform workspace show" to print current workspace name
This command serves as an alternative to the human-oriented list of workspaces for scripting use-cases where it's useful to know the _current_ workspace name.
2017-07-05 14:35:46 -07:00
Martin Atkins 31d556894f command: shallow UI-focused rename of "environment" to "workspace"
Feedback after 0.9 was that the term "environment" was confusing due to
it colliding with several other concepts, such as OS environment
variables, a non-aligned Terraform Enterprise concept, and differing ideas
of "environment" within various organizations.

This new term "workspace" is intended to ease some of that confusion. This
term is not used anywhere else in Terraform today, and we expect it to not
be used in a manner that would be confusing within user organizations.

This begins a deprecation cycle for the "terraform env" family of commands,
instead moving to an equivalent set of "terraform workspace" commands.

There are some remaining references to the old "environment" concept in
the code, which will be cleaned up in a separate change. This change is
instead focused on text visible in the UI and wording within code comments
for the benefit of human maintainers of the code.
2017-06-09 15:01:39 -07:00
Martin Atkins 3af0ecdf01 command: "terraform providers" command
This new command prints out the tree of modules annotated with their
associated required providers.

The purpose of this command is to help users answer questions such as
"why is this provider required?", "why is Terraform using an older version
of this provider?", and "what combination of modules is creating an
impossible provider version situation?"

For configurations using many modules this sort of question is likely to
come up a lot once we support versioned providers.

As a bonus use-case, this command also shows explicitly when a provider
configuration is being inherited from a parent module, to help users to
understand where the configuration is coming from for each module when
some child modules provide their own provider configurations.
2017-06-09 14:03:59 -07:00
Martin Atkins 8364383c35 Push plugin discovery down into command package
Previously we did plugin discovery in the main package, but as we move
towards versioned plugins we need more information available in order to
resolve plugins, so we move this responsibility into the command package
itself.

For the moment this is just preserving the existing behavior as long as
there are only internal and unversioned plugins present. This is the
final state for provisioners in 0.10, since we don't want to support
versioned provisioners yet. For providers this is just a checkpoint along
the way, since further work is required to apply version constraints from
configuration and support additional plugin search directories.

The automatic plugin discovery behavior is not desirable for tests because
we want to mock the plugins there, so we add a new backdoor for the tests
to use to skip the plugin discovery and just provide their own mock
implementations. Most of this diff is thus noisy rework of the tests to
use this new mechanism.
2017-06-09 14:03:59 -07:00
James Bardin 9e9d0b1bdf move force-unlock to plumbing
shouldn't be listed as a common command
2017-04-01 17:09:20 -04:00
James Bardin 39a5ddd381 Split Meta back out of StateMeta
Removing the call to StateMeta.Env, so that it doesn't need an embedded
Meta field. Embed Meta and StateMeta separately in all State commands.
2017-03-01 10:20:32 -05:00
James Bardin b53704ed87 Thread the environment through all commands
Add Env and SetEnv methods to command.Meta to retrieve the current
environment name inside any command.

Make sure all calls to Backend.State contain an environment name, and
make the package compile against the update backend package.
2017-02-28 16:35:46 -05:00
James Bardin c8526484b3 split the env command into subcommands 2017-02-28 16:07:06 -05:00
James Bardin 31f033827f Add basic env commands
Used a single command with flags for now. We may refactor this out to
subcommands.
2017-02-28 16:07:06 -05:00
James Bardin 65abe98047 Remove lock command and rename lock/force-unlock
Remove the lock command for now to avoid confusion about the behavior of
locks. Rename lock to force-unlock to make it more aparent what it does.

Add a success message, and chose red because it can be a dangerous
operation.

Add confirmation akin to `destroy`, and a `-force` option for
automation and testing.
2017-02-07 18:28:48 -05:00
Mitchell Hashimoto 1492c578de
update main commands listing to the new commands 2017-01-26 14:33:50 -08:00
Mitchell Hashimoto e9c35eae32
Forward SIGTERM and handle that as an interrupt 2016-12-08 12:20:25 -05:00
Mildred Ki'Lya 9ab7cab19e
Gracefully stops on SIGTERM 2016-12-07 20:50:03 -05:00
Martin Atkins fef5727904 Remind future maintainers to update the docs when changing CLI usage
We have a copy of the output from running just "terraform" in a page on
the website. It doesn't necessarily need to be kept 100% up to date, since
users can always run the command to get the result from the horses mouth,
but it's nice to keep it somewhat up-to-date to reduce use confusion.
2016-11-24 09:22:18 -08:00
James Bardin b8adf10236 Add debug command with json2dot
Add `terraform debug json2dot` to convert debug log graphs to dot
format. This is not meant to be in place of more advanced debug
visualization, but may continue to be a useful way to work with the
debug output.
2016-11-21 11:59:20 -05:00
Mitchell Hashimoto a867457d75
command/console 2016-11-13 23:17:04 -08:00
Mitchell Hashimoto 3fdc08a9eb core: Add `terraform state rm` command and docs
This commit adds the `state rm` command for removing an address from
state. It is the result of a rebase from pull-request #5953 which was
lost at some point during the Terraform 0.7 feature branch merges.
2016-08-16 16:45:44 +01:00
James Nugent aa5dc453ee cli: Fix registration of `state mv`.
Fixes #7259.
2016-06-22 11:46:38 +03:00
Paul Hinze 0d4c05f1e2 Revert "core: Keep errors/warning out of stdout for ease of automation" 2016-05-24 15:59:44 -05:00
Maxime Bury 56ec9b3354 Keep errors/warning out of stdout for ease of automation 2016-05-24 14:59:51 +02:00
Mitchell Hashimoto ff94381e7e
command/import wip 2016-05-11 13:02:33 -07:00
Chris Bednarski 6360e6c8b6 Implemented internal plugin calls; which allows us to compile plugins into the main terraform binary 2016-05-10 14:40:11 -04:00
Mitchell Hashimoto f6692e66ac add command/state show 2016-05-10 14:14:47 -04:00
Mitchell Hashimoto d1b46e99bd Add `terraform state list` command
This introduces the terraform state list command to list the resources
within a state. This is the first of many state management commands to
come into 0.7.

This is the first command of many to come that is considered a
"plumbing" command within Terraform (see "plumbing vs porcelain":
http://git.661346.n2.nabble.com/what-are-plumbing-and-porcelain-td2190639.html).
As such, this PR also introduces a bunch of groundwork to support
plumbing commands.

The main changes:

- Main command output is changed to split "common" and "uncommon"
  commands.

- mitchellh/cli is updated to support nested subcommands, since
  terraform state list is a nested subcommand.

- terraform.StateFilter is introduced as a way in core to filter/search
  the state files. This is very basic currently but I expect to make it
  more advanced as time goes on.

- terraform state list command is introduced to list resources in a
  state. This can take a series of arguments to filter this down.

Known issues, or things that aren't done in this PR on purpose:

- Unit tests for terraform state list are on the way. Unit tests for the
  core changes are all there.
2016-05-10 14:14:47 -04:00
Martin Atkins fa703db8a6 Merge #4955: "terraform fmt" command 2016-04-04 01:07:32 -07:00
Paul Hinze c7f5450a96 command: Add `terraform untaint`
- [x] Docs
 - [x] Command Unit Tests
 - [x] State Unit Tests

Closes #4820
2016-03-11 12:38:57 -06:00
Dan Carley cc41c7cfa0 command/fmt: Add new fmt command
This uses the `fmtcmd` package which has recently been merged into HCL. Per
the usage text, this rewrites Terraform config files to their canonical
formatting and style.

Some notes about the implementation for this initial commit:

- all of the fmtcmd options are exposed as CLI flags
- it operates on all files that have a `.tf` suffix
- it currently only operates on the working directory and doesn't accept a
  directory argument, but I'll extend this in subsequent commits
- output is proxied through `cli.UiWriter` so that we write in the same way
  as other commands and we can capture the output during tests
- the test uses a very simple fixture just to ensure that it is working
  correctly end-to-end; the fmtcmd package has more exhaustive tests
- we have to write the fixture to a file in a temporary directory because it
  will be modified and for this reason it was easier to define the fixture
  contents as a raw string
2016-03-07 15:07:04 +00:00
Soren Mathiasen db69a2959b Added verify command 2016-02-08 12:48:14 +01:00
Mitchell Hashimoto cdde9149ff command/push: start it 2015-03-24 13:30:21 -07:00
Mitchell Hashimoto 01cd761023 command: move remote configuration stuff 2015-03-04 16:17:30 -08:00
Mitchell Hashimoto b06a88d1ab main: add the taint command 2015-02-26 10:29:51 -08:00
Mitchell Hashimoto 579f102f37 command: start migrating to new state package 2015-02-23 15:13:54 -08:00
Armon Dadgar b3871c0c5a command/remote: Adding skeleton 2014-12-10 13:27:08 -08:00
Armon Dadgar 38002904f4 command/push: Adding the push command 2014-12-10 13:27:08 -08:00
Armon Dadgar 34df217514 command/pull: Adding the pull command 2014-12-10 13:27:07 -08:00
Mitchell Hashimoto 70191d22a6 Add checkpoint 2014-10-13 14:05:43 -07:00
Mitchell Hashimoto f302e7d1bb main: add Destroy 2014-09-30 21:51:45 -07:00
Mitchell Hashimoto fe4f53eb5b enable init command 2014-09-27 12:31:38 -07:00
Mitchell Hashimoto ed538a9594 command: Get command, not functional yet. Converted to use modules. 2014-09-22 10:56:50 -07:00
Mitchell Hashimoto 4e17aaf927 Always enable colors for now 2014-07-28 08:56:43 -07:00
Mitchell Hashimoto 17d085b13a Always enable color for now 2014-07-26 14:07:47 -07:00
Mitchell Hashimoto c3229aaef1 Always enable color on Windows since tty check doesn't work well 2014-07-17 09:50:58 -07:00
Mitchell Hashimoto 8dc842aa8e Don't color output if stdout is not a tty 2014-07-17 09:37:36 -07:00
Mitchell Hashimoto dde0f0f8df command/version: use Meta 2014-07-13 10:42:18 -07:00
Mitchell Hashimoto 2caff709d6 comand/output 2014-07-13 10:25:42 -07:00
Mitchell Hashimoto 77bfa5657e Fix compilation, use the new command.Meta object 2014-07-12 20:38:56 -07:00
Mitchell Hashimoto dbc1c63d79 command/show 2014-07-12 19:47:31 -07:00
Mitchell Hashimoto 0e88867052 Compile 2014-07-03 12:01:20 -07:00
Mitchell Hashimoto 5aa6ada589 command/apply: Ctrl-C works 2014-07-02 17:01:02 -07:00
Mitchell Hashimoto 93fbb9ea8f command/graph 2014-07-01 10:02:13 -07:00
Mitchell Hashimoto 1819b6fb34 command/refresh 2014-06-27 11:09:01 -07:00
Mitchell Hashimoto 01319e1dc9 Ui hook 2014-06-26 17:05:21 -07:00
Mitchell Hashimoto bff4b8a58c command: plan 2014-06-20 11:47:02 -07:00
Mitchell Hashimoto 8aa99687c3 command/apply: basic implementation 2014-06-18 16:42:13 -07:00
Mitchell Hashimoto f9e830705d Prefixed IO to make sure stdout/stderr match up 2014-06-10 10:28:47 -07:00
Mitchell Hashimoto 6c6bc0ae3e commands/diff: starting up, got it loading a Terraform 2014-06-09 11:53:41 -07:00
Mitchell Hashimoto 046e80361b commands: start apply 2014-05-24 12:27:58 -07:00
Mitchell Hashimoto a4a4e3784d Implement CLI, version command 2014-05-24 12:04:43 -07:00