Commit Graph

44 Commits

Author SHA1 Message Date
Martin Atkins
e1590d0a70 command/cliconfig: Factor out CLI config handling
This is just a wholesale move of the CLI configuration types and functions
from the main package into its own package, leaving behind some type
aliases and wrappers for now to keep existing callers working.

This commit alone doesn't really achieve anything, but in future commits
we'll expand the functionality in this package.
2019-08-01 10:56:41 -07:00
Martin Atkins
e9816c60f1 main: allow overriding host-based discovery in CLI config
For situations where the default network-based discovery is inappropriate
or inconvenient, this allows users to provide a hard-coded discovery
document for a particular hostname in the CLI config.

This is a new config block, rather than combined with the existing
"credentials" block, because credentials should ideally live in separate
files from other config so that they can be managed more carefully.
However, this new "host" block _is_ designed to have room for additional
host-specific configuration _other than_ credentials in future, which
might include TLS certificate overrides or other such things used during
the discovery step.
2017-10-26 08:58:52 -07:00
Martin Atkins
1feb26f196 main: load CLI config files from ~/.terraform.d/*.tfrc
Now that we are looking into the CLI config file for service host
credentials, it's important to support multiple separate files so that
users can keep credentials separate from other settings and credentials
for different hosts separate from one another.

There is no restriction on which settings can appear in which locations.
This is up to the user to decide, depending on their security needs and
e.g. on whether certain files are generated vs. manually-edited.
2017-10-21 09:37:05 -07:00
Martin Atkins
11ba1d2a4c main: factor out CLI config loading into its own function
Previously we handled all of the config sources directly within the main
function. We're going to make CLI config loading more complex shortly, so
having this encapsulated in its own function will avoid creating even more
clutter inside the main function.

Along the way here we also switch from using native Go "error" to using
tfdiags.Diagnostics, so that we can potentially issue warnings here too
in future, and so that we can return multiple errors.
2017-10-21 09:37:05 -07:00
Martin Atkins
a2c59c6ecd main: validate credentials blocks in CLI config
We require that each "credentials" block has a valid hostname and that
there be no more than one "credentials_helper" block.

There are some more sophisticated validations we could do here, such as
checking if the same host is declared more than once, but since this
config handling will be rewritten to use HCL2 in the near future, and this
sort of check is easier to do in the HCL2 API, we just check the basic
stuff for now and plan to revisit later.
2017-10-21 09:37:05 -07:00
Martin Atkins
fe7ef7ae5d main: include credentials and credentials_helper when merging CLI configs 2017-10-21 09:37:05 -07:00
Martin Atkins
35a058fb3d main: configure credentials from the CLI config file 2017-10-21 09:37:05 -07:00
Martin Atkins
cb17a9a607 main: allow enabling plugin caching via config file or environment
Either the environment variable TF_PLUGIN_CACHE_DIR or a setting in the
CLI config file (~/.terraformrc on Unix) allow opting in to the plugin
caching behavior.

This is opt-in because for new users we don't want to pollute their system
with extra directories they don't know about. By opting in to caching, the
user is assuming the responsibility to occasionally prune the cache over
time as older plugins become stale and unused.
2017-09-29 14:03:09 -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
Mitchell Hashimoto
41a4235eb3
terraformrc can contain env var references
This allows the use case where installation of a plugin can simply say
to add `$GOPATH/bin/foo` to your terraformrc and the user can do that
verbatim. Additionally terraformrc files become portable for certain
environments which are self-contained.

I was hesitant at first about this because it diverges the syntax a bit
from our standard interpolation syntax. However, due to the special
nature of terraformrc and the strong use cases cited I'm okay with this.
2017-02-13 17:52:51 -08: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 Nugent
a0a59d3fb7 core: Log local overrides as INFO rather than WARN
A user has at some point explicitly specified in .terraformrc that
overriding should take place (unlike PATH based overrides), so this
should log as INFO rather than WARN.

It is still of value for debugging purposes, however!
2016-09-14 09:19:03 +01:00
Jonty Wareing
e0c068f09d Warn when plugins are locally overridden
It is currently very easy to miss that a provider/provisioner has a
local override in your .terraformrc, leading to unexpected behaviour
that can be difficult to debug as no information is output about the
overrides.
2016-09-13 13:05:37 +01:00
Chris Bednarski
8d50238f7a Added TF_PLUGIN_DEV to silence internal plugin warnings 2016-05-27 11:49:09 -07:00
Chris Bednarski
9d6326545a Hide plugin discovery log message when we are running a plugin 2016-05-27 10:51:23 -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
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
84214437b3 Use hashicorp/go-plugin for plugin system
This replaces this plugin system with the extracted hashicorp/go-plugin
library.

This doesn't introduce any new features such as binary flattening but
opens us up to that a lot more easily and removes a lot of code from TF
in favor of the upstream lib.

This will introduce a protocol change that will cause all existing
plugins to have to be recompiled to work properly. There is no actual
API changes so they just have to recompile, but it is technically
backwards incompatible.
2016-05-10 14:14:47 -04:00
Mitchell Hashimoto
c2fdb7171e use upstream osext, which fixes some bugs 2015-10-17 17:33:45 -07:00
Jeff Mitchell
f7512ca29f Initial commit. This adds the initial bits of a Docker provider.
Docker's API is huge and only a small subset is currently implemented,
but this is expected to grow over time. Currently it's enough to
satisfy the use cases of probably 95% of Docker users.

I'm preparing this initial pull request as a preview step for feedback.
My ideal scenario would be to develop this within a branch in the main
repository; the more eyes and testing and pitching in on the code, the
better (this would avoid a merge request-to-the-merge-request scenario,
as I figure this will be built up over the longer term, even before
a merge into master).

Unit tests do not exist yet. Right now I've just been focused on getting
initial functionality ported over. I've been testing each option
extensively via the Docker inspect capabilities.

This code (C)2014-2015 Akamai Technologies, Inc. <opensource@akamai.com>
2015-03-10 15:38:52 +00:00
Mitchell Hashimoto
70191d22a6 Add checkpoint 2014-10-13 14:05:43 -07:00
Mitchell Hashimoto
1e3dbee278 main: use new RPC mechanisms 2014-09-28 11:40:15 -07:00
Mitchell Hashimoto
2e39b8eaf3 config looks in a plugin directory if it exists 2014-09-27 12:36:13 -07:00
Mitchell Hashimoto
eabd8b1cc5 Fix CWD plugin loading. 2014-09-25 22:39:46 -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
bec5a2a9c5 main: look up executables locally before PATH [GH-157] 2014-08-27 20:46:50 -07:00
Mitchell Hashimoto
efaedbabb0 fmt 2014-08-20 22:24:35 -07:00
Mitchell Hashimoto
2e2f6bf0f4 main: clean up the code surrounding config file loading 2014-08-19 10:58:23 -07:00
Mitchell Hashimoto
04975827ac Remove all traces of libucl 2014-08-19 09:57:04 -07:00
Armon Dadgar
61841467c4 provider/consul: Skeleton 2014-07-25 17:03:17 -04:00
Mitchell Hashimoto
f82b0552e0 DRY up the config.go 2014-07-24 07:30:26 -07:00
Jack Pearkes
d8c83a1a95 providers/dnsimple: init commit 2014-07-23 17:43:49 -04:00
Mitchell Hashimoto
fa175113fe config: case sensitive templates 2014-07-23 08:38:43 -07:00
Jack Pearkes
e81b3998ce heroku: initial commit 2014-07-23 00:03:30 -04:00
Jack Pearkes
4455a6120c providers/digitalocean: initial commit 2014-07-18 20:20:28 -04:00
Armon Dadgar
a9cad200d8 provisioner/file: Skeleton files 2014-07-16 10:33:44 -07:00
Armon Dadgar
6381fbd226 provisioner/remote-exec: Adding initial skeleton 2014-07-15 12:34:06 -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
a6ae7230d1 command: use new API 2014-07-03 11:46:40 -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
6c6bc0ae3e commands/diff: starting up, got it loading a Terraform 2014-06-09 11:53:41 -07:00
Mitchell Hashimoto
5d40725139 main: add main config 2014-05-25 17:39:44 -07:00