Commit Graph

392 Commits

Author SHA1 Message Date
David Glasser
b44f7f28e0 Document saved plan use in terraform apply -help (#6126)
Wording borrowed from the website docs.
2016-04-11 12:24:08 -05:00
David Glasser
320773d6c1 command: delete unused class 2016-04-05 18:42:09 -07: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
d883b76070 command/fmt: Test non-default options
To ensure that these are passed over to `fmtcmd` correctly.
2016-03-07 15:07:15 +00:00
Dan Carley
79e2753e41 command/fmt: Disable list/write when using STDIN
These options don't make sense when passing STDIN. `-write` will raise an
error because there is no file to write to. `-list` will always say
`<standard input>`. So disable whenever using STDIN, making the command
much simpler:

    cat main.tf | terraform fmt -
2016-03-07 15:07:15 +00:00
Dan Carley
e9128769b5 command/fmt: Accept input from STDIN
So that you can do automatic formatting from an editor. You probably want to
disable the `-write` and `-list` options so that you just get the
re-formatted content, e.g.

    cat main.tf | terraform fmt -write=false -list=false -

I've added a non-exported field called `input` so that we can override this
for the tests. If not specified, like in `commands.go`, then it will default
to `os.Stdin` which works on the command line.
2016-03-07 15:07:15 +00:00
Dan Carley
1b967e612f command/fmt: Accept optional directory argument
So that you can operate on files in a directory other than your current
working directory.
2016-03-07 15:07:14 +00:00
Dan Carley
c753390399 command/fmt: Default write and list to true
The most common usage usage will be enabling the `-write` and `-list`
options so that files are updated in place and a list of any modified files
is printed. This matches the default behaviour of `go fmt` (not `gofmt`). So
enable these options by default.

This does mean that you will have to explicitly disable these if you want to
generate valid patches, e.g. `terraform fmt -diff -write=false -list=false`
2016-03-07 15:07:14 +00: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
James Nugent
b787fe2798 Merge pull request #5012 from jrnt30/TF-5011-Backend-flag-normalization
Fixes #5011 - Backend downcased for init
2016-02-08 17:59:20 -05:00
stack72
1628f19bc1 Fixing some golint issues on the new validate command 2016-02-08 22:04:24 +00:00
Soren Mathiasen
db69a2959b Added verify command 2016-02-08 12:48:14 +01:00
Justin Nauman
61240b4250 Fixes #5011 - Backend downcased for init 2016-02-05 06:26:12 -06:00
Paul Hinze
4a51e4fe91 core: write planfile even on empty plans
This makes the planfile workflow more consistent. If a plan yields a
noop, the apply of that planfile will noop.

Fixes #1783
2016-01-20 16:00:20 -06:00
Paul Hinze
e67fc0fe9b command: Change module-depth default to -1
This means that terraform commands like `plan`, `apply`, `show`, and
`graph` will expand all modules by default.

While modules-as-black-boxes is still very true in the conceptual design
of modules, feedback on this behavior has consistently suggested that
users would prefer to see more verbose output by default.

The `-module-depth` flag and env var are retained to allow output to be
optionally limited / summarized by these commands.
2016-01-20 13:58:02 -06:00
Mitchell Hashimoto
6a972a7713 command/init: put remote state config at proper path [GH-2927] 2016-01-19 17:13:19 -08:00
James Nugent
a5e51f6dad command/refresh: Fix import formats to prevent flapping 2015-11-27 15:10:42 +00:00
Paul Hinze
0e277a6714 core: test coverage around map key regression
tests to cover the HCL-level issue fixed in
https://github.com/hashicorp/hcl/pull/65
2015-11-24 16:00:02 -06:00
James Nugent
50b5e7c1a5 Validate context after input of vars on refresh
Fixes #4013.
2015-11-23 10:33:40 +02:00
James Nugent
890e214c00 Add failing test replicating #4013 2015-11-23 10:32:46 +02:00
Jake Champlin
39e7f42490 Clear up destroy --target message
When destroying infrastructure with `--target`, print out which
infrastructure will be destroyed instead of saying `Terraform will
delete all your managed infrastructure`.

```
 terraform destroy --target aws_instance.test2 --target aws_instance.test1
Do you really want to destroy?
  Terraform will delete the following infrastructure:
        aws_instance.test2
        aws_instance.test1
  There is no undo. Only 'yes' will be accepted to confirm
```

Omitting `--target` arguments will use the default input description.

```
$ terraform destroy
Do you really want to destroy?
  Terraform will delete all your managed infrastructure.
  There is no undo. Only 'yes' will be accepted to confirm.
```
2015-11-11 12:04:58 -05:00
James Nugent
a49b162dd1 Prompt for input variables before context validate
Also adds a regression test using Mock UI. Fixes #3767.
2015-11-10 14:03:56 -05:00
James Nugent
f4c03ec2a6 Reflect new comment format in stringer.go
As of November 8th 2015, (4b07c5ce8a), the word "Code" is prepended to
the comments in Go source files generated by the stringer utility.
2015-11-09 11:38:51 -05:00
Paul Hinze
9428e9f1d1 command: fix failing TestPlan_noState test
Turns out that isolating statefiles in the Apply tests is an important
step to prevent leaking .tfstate in a common dir, which can affect other
tests.
2015-10-29 18:07:44 -05:00
Paul Hinze
715437537d command: fix flaky parallelism tests
Thanks to @mitchellh for helping sort out concurrency stuff here.
2015-10-29 15:16:34 -05:00
John Gosset
61e890ecc9 Update list of backends in RemoteConfigCommand's Help() method 2015-10-25 16:46:02 -04:00
Martin Atkins
e4e9c13c20 Merge #3136: Colorize the 'forces new resource' message 2015-10-22 08:44:37 -07:00
Mitchell Hashimoto
344e7c26b5 fix a bunch of tests from go-getter import 2015-10-15 13:48:58 -07:00
Panagiotis Moustafellos
e4845f75cc removed extra parentheses 2015-10-08 15:48:04 +03:00
Paul Hinze
374070d066 website: docs for parallelism setting
/cc @stack72 @knuckolls @mitchellh
2015-10-05 17:21:29 -05:00
Paul Hinze
e1a46904d6 command: pull parallelism default up to CLI layer
/cc @knuckolls @josephholsten
2015-10-05 15:06:08 -05:00
Kevin Nuckolls
bf9c5c46d0 Tests for apply parallelism=1 and parallelism=2 2015-09-29 22:41:26 -07:00
Kevin Nuckolls
fc60b2858c Added -parallelism to refresh and plan cli UI 2015-09-29 22:41:26 -07:00
Kevin Nuckolls
f59c71b35a works for apply, no tests yet 2015-09-29 22:41:26 -07:00
Radek Simko
57bea9f26c Merge pull request #3223 from scalp42/typos
remove various typos
2015-09-14 07:48:59 +01:00
Mitchell Hashimoto
4d37704d53 command/get: fix typo 2015-09-13 14:40:36 -07:00
Anthony Scalisi
198e1a5186 remove various typos 2015-09-11 11:56:20 -07:00
Martin Atkins
7c56550633 In plan summary, be more honest about force-new changes.
Previously the plan summary output would consider -/+ diffs as changes
even though they actually destroy and create instances. This was
misleadning and inconsistent with the accounting that gets done for the
similar summary written out after "apply".

Instead we now count the -/+ diffs as both adds and removes, which should
mean that the counts output in the plan summary should match those in
the apply summary, as long as no errors occur during apply.

This fixes #3163.
2015-09-04 08:07:16 -07:00
Sharif Nassar
2e51915431 Colorize the 'forces new resource' message.
Sometimes in all the output from ```terraform plan```, it is difficult
to see the ```(forces new resource)``` message.
This patch adds a little bit of color.
2015-08-31 15:37:09 -07:00
Paul Hinze
5a12608dc3 tests: remove unnecessary symlink 2015-08-31 15:45:43 -05:00
Radek Simko
9596271b36 Code formatted via gofmt 2015-08-14 12:02:32 +01:00
Radek Simko
10f04c90a5 'terraform output' helptext spacing fixed 2015-08-14 12:01:58 +01:00
Radek Simko
382c0ba23d command/output: Update test since we now allow printing everything 2015-08-03 12:44:41 +01:00
Eric Connell
85d1d15d81 output command supports printing all outputs
if no output name is specified all outputs are displayed
fixed formating and added missing help for -module parameter
2015-08-03 12:22:40 +01:00
Radek Simko
7a60174dd1 Do not print errors via UiHook 2015-07-22 14:09:23 +02:00
Sander van Harmelen
4a8ef78d33 Fixes #2676 by prefixing all Windows commands
By prefixing them with `cmd /c` it will work with both `winner` and
`ssh` connection types.

This PR also reverts some bad stringer changes made in PR #2673
2015-07-10 12:56:27 +02:00
Sander van Harmelen
97fd4f5b7d Tweaking the tests 2015-07-09 21:29:27 +02:00
Radek Simko
e376f61d1d core: Return correct number of planned updates 2015-07-03 13:22:10 +02:00
Mitchell Hashimoto
1f92dd5b40 command/push: update output 2015-06-29 13:58:54 -07:00
Mitchell Hashimoto
c5d3c585c6 command/push: update var name 2015-06-29 13:57:58 -07:00
Mitchell Hashimoto
9d9bcc2f6e command/push: update flag to -overwrite, update docs 2015-06-29 13:53:05 -07:00
Mitchell Hashimoto
8ee3281858 command/push: UX 2015-06-29 13:41:07 -07:00
Mitchell Hashimoto
dc40f044f0 command/push: prefer Atlas over local, add -set flag 2015-06-29 12:24:13 -07:00
Mitchell Hashimoto
8ebdc1e786 terraform: orphans should call post-apply hook [GH-1938] 2015-06-25 20:11:29 -07:00
Mitchell Hashimoto
a76105b0f1 command: make error message clearer for invalid tfvars format [GH-1889] 2015-06-25 17:56:37 -07:00
Mitchell Hashimoto
96b53cc06c command: ask for input even if tfvars is set [GH-2161] 2015-06-25 15:29:46 -07:00
Radek Simko
b505d15e1e Add resource sums to terraform plan
- closes #2355
2015-06-25 10:25:16 +01:00
Paul Hinze
3f2119c6e7 Merge pull request #2414 from TimeIncOSS/no-color-for-subcommands
Add -no-color option for subcommands
2015-06-23 15:43:37 -05:00
Paul Hinze
74fb179127 Merge pull request #2371 from hashicorp/b-fix-tf-show-with-remote-state
core: fix `terraform show` with remote state
2015-06-23 15:01:10 -05:00
Radek Simko
b7d41d2eed Add -no-color to help text 2015-06-22 13:14:01 +01:00
Radek Simko
cdcd11419e Add -no-color option for subcommands 2015-06-21 21:52:11 +01:00
Paul Hinze
cb5c2567b3 core: fix terraform show with remote state
fixes #1810
2015-06-16 12:26:04 -05:00
Paul Hinze
ad680b1832 core: show outputs after terraform refresh
closes #25
2015-06-15 10:41:42 -05:00
Paul Hinze
18924d24fe command/apply: flatten multierrors
Before:

```
Error applying plan:

1 error(s) occurred:

* 1 error(s) occurred:

* 1 error(s) occurred:

* 1 error(s) occurred:

* Error creating ...
```

After:

```
Error applying plan:

1 error(s) occurred:

* Error creating ...
```

Muuuch better! :D
2015-06-07 21:32:00 -05:00
Paul Hinze
aa39dc71de command/output: fix error msg typo 2015-06-03 09:24:20 -05:00
Kirill Shirinkin
b05e36a6e3 Add module outputs 2015-05-27 16:46:12 +02:00
Mitchell Hashimoto
77a61157fb command/push: var/var-file supported, note in help [GH-1950] 2015-05-13 20:18:40 -07:00
Paul Hinze
8ce3e1d5b4 command/push: local vars override remote ones
Otherwise once you push a variable it becomes very difficult to change.
2015-05-08 18:54:38 -05:00
Andrew Langhorn
bb4f7415ca Rename "The The" so that they can play songs again
Other than the fact that "The the" doesn't really make any sense anywhere
that it's used in Terraform, they're a post-punk band from the UK.

Fixes "The The" so that they can get back to playing songs.
2015-05-06 22:53:11 +01:00
Paul Hinze
29d34cd5a4 command: allow module depth to be set via env var
Another convienence env var here with TF_MODULE_DEPTH.

Works like you'd expect it to!
2015-04-30 16:19:43 -05:00
Paul Hinze
d30d88e327 Merge pull request #1655 from hashicorp/f-build-graph-during-plan
core: validate on verbose graph to detect some cycles earlier
2015-04-30 16:08:33 -05:00
Paul Hinze
5f1ea7fccc command: add env var equivalent to -input arg
Setting TF_INPUT has the equivalent effect of setting the flag.
I got sick of specifying this when iterating on TF config locally.
2015-04-30 09:59:14 -05:00
Luke Amdor
b08ba78341 adding new AskSecret to ColorizeUi 2015-04-29 13:07:13 -05:00
Paul Hinze
ce49dd6080 core: graph command gets -verbose and -draw-cycles
When you specify `-verbose` you'll get the whole graph of operations,
which gives a better idea of the operations terraform performs and in
what order.

The DOT graph is now generated with a small internal library instead of
simple string building. This allows us to ensure the graph generation is
as consistent as possible, among other benefits.

We set `newrank = true` in the graph, which I've found does just as good
a job organizing things visually as manually attempting to rank the nodes
based on depth.

This also fixes `-module-depth`, which was broken post-AST refector.
Modules are now expanded into subgraphs with labels and borders. We
have yet to regain the plan graphing functionality, so I removed that
from the docs for now.

Finally, if `-draw-cycles` is added, extra colored edges will be drawn
to indicate the path of any cycles detected in the graph.

A notable implementation change included here is that
{Reverse,}DepthFirstWalk has been made deterministic. (Before it was
dependent on `map` ordering.) This turned out to be unnecessary to gain
determinism in the final DOT-level implementation, but it seemed
a desirable enough of a property that I left it in.
2015-04-27 09:23:47 -05:00
Paul Hinze
d4b9362518 core: validate on verbose graph to detect some cycles earlier
Most CBD-related cycles include destroy nodes, and destroy nodes were
all being pruned from the graph before staring the Validate walk.

In practice this meant that we had scenarios that would error out with
graph cycles on Apply that _seemed_ fine during Plan.

This introduces a Verbose option to the GraphBuilder that tells it to
generate a "worst-case" graph. Validate sets this to true so that cycle
errors will always trigger at this step if they're going to happen.

(This Verbose option will be exposed as a CLI flag to `terraform graph`
in a second incoming PR.)

refs #1651
2015-04-23 11:07:13 -05:00
Mitchell Hashimoto
e91b5136bf Merge pull request #1356 from koendc/b-remote-plugin-case
command/state: fix for state files containing an upper case remote type
2015-04-14 08:34:28 -07:00
Paul Hinze
a2cb77058c command: fix push tests when running outside repo
VCS detection was on by default, and blows up when the tests are run in
a copy of the Terraform source that is not a git repository, like - say
- during a Homebrew formula install, just to pick a random example. :)
2015-04-09 18:46:25 -05:00
Mitchell Hashimoto
650a9f372b command: implement proper module.Storage interface 2015-04-07 16:46:56 -07:00
Mitchell Hashimoto
000d28c489 command/push: read terraform.tfvars 2015-04-07 15:34:06 -07:00
Mitchell Hashimoto
1fac7b6488 state: cache should use State.Equal to check equality
reflect.DeepEqual was returning false, sometimes.
2015-04-07 15:03:04 -07:00
Koen De Causmaecker
428fd98ba0 Handles upper case characters in the cached state file's remote type
If the cached state file contains a remote type field with upper case
characters, eg 'Consul', it was no longer possible to find the 'consul'
remote plugin.
2015-04-01 21:42:39 +02:00
Ryan Uber
9a091ffa78 command: plan supports detailed exit code 2015-04-01 09:38:19 -07:00
Paul Hinze
97acccd3ed core: targeted operations
Add `-target=resource` flag to core operations, allowing users to
target specific resources in their infrastructure. When `-target` is
used, the operation will only apply to that resource and its
dependencies.

The calculated dependencies are different depending on whether we're
running a normal operation or a `terraform destroy`.

Generally, "dependencies" refers to ancestors: resources falling
_before_ the target in the graph, because their changes are required to
accurately act on the target.

For destroys, "dependencies" are descendents: those resources which fall
_after_ the target. These resources depend on our target, which is going
to be destroyed, so they should also be destroyed.
2015-03-31 14:49:38 -05:00
Mitchell Hashimoto
da7f307e56 command/remote-config: failing tests 2015-03-26 18:14:24 -07:00
Mitchell Hashimoto
4a7b554cf7 command/remote-config: do a pull with terraform remote config 2015-03-26 17:57:45 -07:00
Mitchell Hashimoto
6379a888fb command/remote-{pull,push}: colorize and show success output 2015-03-26 17:40:39 -07:00
Mitchell Hashimoto
38b1a727bf command/remote-config: lowercase the type so that Atlas works, for
example
2015-03-26 17:37:05 -07:00
Mitchell Hashimoto
7bfa5afd00 command/remote-config: show flag parse errors
/cc @sethvargo
2015-03-26 17:33:58 -07:00
Mitchell Hashimoto
35da19cc1f command/remote-config: remove weird error case that shows no error
message

/cc @sethvargo
2015-03-26 17:31:50 -07:00
Seth Vargo
1adb3fbfa0 command: when setting up state, only write back if local is newer 2015-03-26 17:16:54 -07:00
Mitchell Hashimoto
83cb277583 command/output: don't panic if no root module in state [GH-1263] 2015-03-25 16:35:27 -07:00
Mitchell Hashimoto
431f5e6706 command/remote-config: syntax 2015-03-25 15:26:38 -07:00
Mitchell Hashimoto
2796f83950 command/remote-config: make the error message nicer for remote init
/cc @sethvargo - based on UX issues you ran into yesterday
2015-03-25 15:23:04 -07:00
Mitchell Hashimoto
280635d2b0 command/push: add -atlas-address 2015-03-24 17:45:19 -07:00
Mitchell Hashimoto
51614b6365 command/push: upload-modules 2015-03-24 17:42:40 -07:00
Mitchell Hashimoto
8d47f26bb7 command/push: address PR comments 2015-03-24 17:41:26 -07:00
Mitchell Hashimoto
0229852e48 command/push: change wording on error message 2015-03-24 17:39:37 -07:00
Mitchell Hashimoto
395dd04861 command/push: accept -vcs 2015-03-24 17:03:59 -07:00
Mitchell Hashimoto
86f92119e2 command/push: no version on GET should be okay 2015-03-24 13:59:13 -07:00