Commit Graph

42 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 9b5ae9143a main: enable basic subcommand autocomplete
The CLI package has automatic support for shell autocomplete (bash and
zsh, at time of writing) for subcommands, so all we need to do here is
just opt into it.

Users can install this into their shells by running:
    terraform -install-autocomplete
2017-09-26 14:01:13 -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
Martin Atkins 5ac311e2a9 main: synchronize writes to VT100-faker on Windows
We use a third-party library "colorable" to translate VT100 color
sequences into Windows console attribute-setting calls when Terraform is
running on Windows.

colorable is not concurrency-safe for multiple writes to the same console,
because it writes to the console one character at a time and so two
concurrent writers get their characters interleaved, creating unreadable
garble.

Here we wrap around it a synchronization mechanism to ensure that there
can be only one Write call outstanding across both stderr and stdout,
mimicking the usual behavior we expect (when stderr/stdout are a normal
file handle) of each Write being completed atomically.
2017-05-04 15:36:51 -07:00
Mitchell Hashimoto 3dfc46abd3
log the Go runtime version at TF startup
This will help us debug issues which have been caused by Go bugs.
2017-02-15 16:11:42 -08:00
Mitchell Hashimoto 518ae5ef02
support nested subcommands with TF_CLI_ARGS 2017-02-13 15:18:50 -08:00
Mitchell Hashimoto df93e5120c
allow targeted TF_CLI_ARGS_x 2017-02-13 15:12:29 -08:00
Mitchell Hashimoto 53796fcdb0
test for blank args for TF_CLI_ARGS 2017-02-13 14:53:50 -08:00
Mitchell Hashimoto 7f67b32169
main: add TF_CLI_ARGS to specify additional CLI args 2017-02-13 14:05:37 -08:00
Mitchell Hashimoto e9c35eae32
Forward SIGTERM and handle that as an interrupt 2016-12-08 12:20:25 -05:00
Mitchell Hashimoto 557375f2a2
Update panicwrap to pass through all interrupt signals 2016-12-07 20:51:45 -05:00
Justin Nauman bf48d0132c Checkpoint signature fixes
- Currently the disable_checkpoint setting from $HOME/.terraformrc is never
respsected due to:
-- The runCheckpoint go routine being fired off prior to loading configuration
-- The config.Merge method not actually merging in the c2s settings
2016-11-17 17:54:14 -06:00
James Bardin 797a1b339d DebugInfo and DebugGraph
Implement debugInfo and the DebugGraph

DebugInfo will be a global variable through which graph debug
information can we written to a compressed archive. The DebugInfo
methods are all safe for concurrent use, and noop with a nil receiver.
The API outside of the terraform package will be to call SetDebugInfo
to create the archive, and CloseDebugInfo() to properly close the file.
Each write to the archive will be flushed and sync'ed individually, so
in the event of a crash or a missing call to Close, the archive can
still be recovered.

The DebugGraph is a representation of a terraform Graph to be written to
the debug archive, currently in dot format. The DebugGraph also contains
an internal buffer with Printf and Write methods to add to this buffer.
The buffer will be written to an accompanying file in the debug archive
along with the graph.

This also adds a GraphNodeDebugger interface. Any node implementing
`NodeDebug() string` can output information to annotate the debug graph
node, and add the data to the log. This interface may change or be
removed to provide richer options for debugging graph nodes.

The new graph builders all delegate the build to the BasicGraphBuilder.
Having a Name field lets us differentiate the actual builder
implementation in the debug graphs.
2016-11-04 11:30:51 -04:00
James Bardin 6b7a079bff Add a way to avoid panicwrap when debugging
When trying to use a debugger, you don't want the terraform to run in a
new child process. Setting TF_FORK=0 will skip panicwrap and continue
running the program in the current process. This will also give direct
access to log output, and stdout.
2016-09-21 14:13:05 -04:00
Mitchell Hashimoto b8036095d4
Logs contain CLI args 2016-08-17 07:50:18 -07:00
Chris Bednarski 3c774af9c2 Warn when an internal plugin is overridden
Also added documentation explaining what happened and how to fix it
2016-05-10 14:49:13 -04:00
Chris Bednarski e942a74def Set a log prefix for each plugin and remove go-dynect global log prefix (#6336) 2016-05-10 14:49:13 -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
James Nugent 8e4da4e2a1 deps: Vendor github.com/hashicorp/go-plugin 2016-05-10 14:14:47 -04:00
James Nugent c77144bd5b core: Fix console colors on Windows
This brings in the go-colorable library when running on Windows in order
to output console colors correctly instead of leaving the codes in place
as is currently the case.
2016-03-18 17:10:20 +00:00
Paul Hinze 4bd4e18def core: use same logging setup for acctests
We weren't doing any log setup for acceptance tests, which made it
difficult to wrangle log output in CI.

This moves the log setup functions we use in `main` over into a helper
package so we can use them for acceptance tests as well.

This means that acceptance tests will by default be a _lot_ quieter,
only printing out actual test output. Setting `TF_LOG=trace` will
restore the full prior noise level.

Only minor behavior change is to make `ioutil.Discard` the default
return value rather than a `nil` that needs to be checked for.
2015-12-08 17:50:36 -06:00
Sander van Harmelen a465c6f4cc Remove duplicate code
Seems to be a refactoring leftover of some kind as on lines 146-148
these calls are done again…
2015-06-16 17:40:59 +02:00
Mitchell Hashimoto c84af741de Log the version info for easier debugging 2014-10-20 22:32:00 -07:00
Mitchell Hashimoto 70191d22a6 Add checkpoint 2014-10-13 14:05:43 -07:00
Mitchell Hashimoto 1510f12efc output errors to the proper location in main.go [GH-288] 2014-10-11 13:03:11 -07:00
Mitchell Hashimoto 238ec05f2f Fix issue where output could be truncated 2014-10-03 13:02:16 -07:00
Mitchell Hashimoto 4fd3dff829 main: auto-discover plugins [GH-190]
/cc @pearkes @armon - exe dir and pwd
2014-08-28 17:27:15 -07:00
Mitchell Hashimoto 2e2f6bf0f4 main: clean up the code surrounding config file loading 2014-08-19 10:58:23 -07:00
Camilo Aguilar fd361c1eb6 Clarifies that what failed loading is the CLI configuration as opposed to Terraform TF files 2014-08-14 12:50:19 -04:00
Camilo Aguilar d3a609ac52 Ports Packer code to load CLI configuration and external plugins 2014-08-14 12:45:58 -04:00
Mitchell Hashimoto 3a8606c117 Recognize -version 2014-07-13 10:37:25 -07:00
Armon Dadgar 1c4321a503 Setup provisioners for CLI 2014-07-10 11:38:57 -07:00
Mitchell Hashimoto 0e88867052 Compile 2014-07-03 12:01:20 -07:00
Mitchell Hashimoto ae6b85e11b terraform: diff hooks 2014-06-26 17:17:10 -07:00
Mitchell Hashimoto 01319e1dc9 Ui hook 2014-06-26 17:05:21 -07:00
Mitchell Hashimoto 92e1e09a69 main: fix the help output to show up 2014-06-26 10:24:51 -07:00
Mitchell Hashimoto 743c3684c5 comments 2014-06-10 10:32:59 -07:00
Mitchell Hashimoto f9e830705d Prefixed IO to make sure stdout/stderr match up 2014-06-10 10:28:47 -07:00
Mitchell Hashimoto 582229969e main: instantiate the config and set it up 2014-06-09 21:57:37 -07:00
Mitchell Hashimoto 61f4684931 Create resource provider factories and cleanup clients in main 2014-06-09 21:44:13 -07:00
Mitchell Hashimoto 7b64c2597b Setup panicwrap 2014-05-30 16:07:26 -07:00
Mitchell Hashimoto a4a4e3784d Implement CLI, version command 2014-05-24 12:04:43 -07:00