Commit Graph

7987 Commits

Author SHA1 Message Date
James Bardin 7f571b5ebb additional null checks in provisioners
Now that provisioners for directly with the plugin API and cty data
types, we need to add a few null checks to catch invalid input that
would have otherwise been masked by the legacy SDK.
2021-04-20 12:31:32 -04:00
James Bardin 47a682141a remote provisioners require a connection config 2021-02-24 13:25:58 -05:00
Kristin Laemmert ff05362d51
providers.Interface: rename ValidateDataSourceConfig to ValidateDataResourceConfig (#27874)
* providers.Interface: rename ValidateDataSourceConfig to
ValidateDataResourceConfig

This PR came about after renaming ValidateResourceTypeConfig to
ValidateResourceConfig: I now understand that we'd called it the former
instead of the latter to indicate that the function wasn't necessarily
operating on a resource that actually exists. A possibly-more-accurate
renaming of both functions might then be ValidateManagedResourceConfig
and ValidateDataResourceConfig.

The next commit will update the protocol (v6 only) as well; these are in
separate commits for reviewers and will get squashed together before
merging.

* extend renaming to protov6
2021-02-24 12:04:28 -05:00
Kristin Laemmert f6505870cc
Mildwonkey/providers interface renaming (#27805)
* providers.Interface: huge renamification

This commit renames a handful of functions in the providers.Interface to
match changes made in protocol v6. The following commit implements this
change across the rest of the codebase; I put this in a separate commit
for ease of reviewing and will squash these together when merging.

One noteworthy detail: protocol v6 removes the config from the
ValidateProviderConfigResponse, since it's never been used. I chose to
leave that in place in the interface until we deprecate support for
protocol v5 entirely.

Note that none of these changes impact current providers using protocol
v5; the protocol is unchanged. Only the translation layer between the
proto and terraform have changed.
2021-02-18 10:13:43 -05:00
Jonathan Hall 49ee3d3ef8 Grammar nit: "setup" as a verb should be spelled "set up" 2021-01-26 20:39:11 +01:00
James Bardin ff30030e4f builtin provisioners are re-used and not Closed 2021-01-19 17:48:30 -05:00
James Bardin 026ba5b013 ensure context cancel is never nil
The context used for Stop is more appropriately tied to the lifetime of
the provisioner rather than a call to the ProvisionResource method. In
some cases Stop can be called before ProvisionResource, causing a panic
the provisioner.  Rather than adding nil checks to the CancelFunc call
for Stop, create a base context to use for cancellation with both Stop
and Close methods.
2021-01-08 12:36:45 -05:00
Alisdair McDiarmid 107dc0c34f Fix terraform_remote_state backend version check
The change recently introduced to ensure that remote backend users do
not accidentally upgrade their state file needs to be disabled for all
read-only uses, including the builtin terraform_remote_state data
source.
2020-12-08 14:18:04 -05:00
James Bardin 313d3e5c4d builtin/provisioners/remote-exec: staticcheck 2020-12-02 13:59:20 -05:00
James Bardin df56a5f8ae remove dead code from tf provider 2020-12-02 13:07:10 -05:00
James Bardin 256a7ec95a rewrite file as an internal provisioner 2020-12-02 12:45:00 -05:00
James Bardin 1ec8d921d4 rewrite remote-exec as an internal provisioner 2020-12-02 12:45:00 -05:00
James Bardin 9adfaa9b5d rewrite local-exec to run internally
Use the new interface directly, so that there are no shims or plugins
involved with the execution of the provisioner.
2020-12-02 12:45:00 -05:00
James Bardin 2eb8278a0f remove unused provisioners main pkgs 2020-12-02 12:45:00 -05:00
James Bardin 01ac480a58 update provisioners to use legacy types 2020-12-02 12:16:35 -05:00
James Bardin b32362da9d internal/legacy/builtin/providers/test
Move the test provider into the interal/legacy directory, until we can
factor it out of the e2e test.
2020-12-02 12:16:35 -05:00
Pam Selle e39e0e3d04 Remove vendor provisioners and add fmt Make target
Remove chef, habitat, puppet, and salt-masterless provsioners,
which follows their deprecation. Update the documentatin for these
provisioners to clarify that they have been removed from later versions
of Terraform. Adds the fmt Make target back and updates fmtcheck script
for correctness.
2020-11-17 11:22:03 -05:00
Radek Simko bc87be384b
builtin/provider/terraform: Add field descriptions 2020-11-06 08:51:07 +00:00
James Bardin c61a893590 unused tests
these are no longer relevant
2020-10-14 14:08:09 -04:00
Martin Atkins 6b5ca49578 helper: remove a bunch of unused packages, types and functions
With the SDK moving out into its own repository, a lot of the packages
under "helper/" are no longer needed. We still need to keep around just
enough legacy SDK to support the "test" provider and some little bits and
bobs in the backends and provisioners, but a lot of this is now just dead
code.

One of the test provider tests was depending on some validation functions
only because the schema in there was originally copied from a "real"
provider. The validation rules are not actually important for the test,
so I removed them. Otherwise, this removes only dead code.
2020-10-02 09:01:37 -07:00
Kristin Laemmert d76cfc8c0c
Merge pull request #26440 from hashicorp/mildwonkey/remove-older-state-vs
refactor tests to use modern states.State in favor of terraform.State where possible
2020-10-01 08:11:27 -04:00
Kristin Laemmert 479655ad47 refactor tests to use modern states.State in favor of terraform.State where possible 2020-09-30 16:07:54 -04:00
James Bardin a3c9b33b7b output buffer must be synchronized 2020-09-30 13:44:07 -04:00
James Bardin a0fad2c6b4 always return original workspace, even when null
The returned value type needs to strictly match the proposed value type.
2020-06-24 13:41:51 -04:00
James Bardin fb06063b2b don't set remote workspace in state
The workspace attribute is not computed, and cannot be changed from the
configuration.
2020-06-18 16:34:57 -04:00
Paddy 5127f1ef8b
command: Unmanaged providers
This adds supports for "unmanaged" providers, or providers with process
lifecycles not controlled by Terraform. These providers are assumed to
be started before Terraform is launched, and are assumed to shut
themselves down after Terraform has finished running.

To do this, we must update the go-plugin dependency to v1.3.0, which
added support for the "test mode" plugin serving that powers all this.

As a side-effect of not needing to manage the process lifecycle anymore,
Terraform also no longer needs to worry about the provider's binary, as
it won't be used for anything anymore. Because of this, we can disable
the init behavior that concerns itself with downloading that provider's
binary, checking its version, and otherwise managing the binary.

This is all managed on a per-provider basis, so managed providers that
Terraform downloads, starts, and stops can be used in the same commands
as unmanaged providers. The TF_REATTACH_PROVIDERS environment variable
is added, and is a JSON encoding of the provider's address to the
information we need to connect to it.

This change enables two benefits: first, delve and other debuggers can
now be attached to provider server processes, and Terraform can connect.
This allows for attaching debuggers to provider processes, which before
was difficult to impossible. Second, it allows the SDK test framework to
host the provider in the same process as the test driver, while running
a production Terraform binary against the provider. This allows for Go's
built-in race detector and test coverage tooling to work as expected in
provider tests.

Unmanaged providers are expected to work in the exact same way as
managed providers, with one caveat: Terraform kills provider processes
and restarts them once per graph walk, meaning multiple times during
most Terraform CLI commands. As unmanaged providers can't be killed by
Terraform, and have no visibility into graph walks, unmanaged providers
are likely to have differences in how their global mutable state behaves
when compared to managed providers. Namely, unmanaged providers are
likely to retain global state when managed providers would have reset
it. Developers relying on global state should be aware of this.
2020-05-26 17:48:57 -07:00
James Bardin e912dc8551
Merge pull request #19155 from bdwyertech/chef-exit-codes
Chef: Gracefully Handle RFC062 Exit Codes
2020-05-12 17:09:05 -04:00
Martin Atkins f897863288 providers/terraform: test that validation does not configure backend 2020-05-07 11:08:10 -07:00
Ben Drucker db1a623ed4 backend/terraform: additional test coverage for error cases in getBackend 2020-05-07 11:08:10 -07:00
Ben Drucker 81b8891b90 providers/terraform: don't call backend.Configure to validate terraform_remote_state
Validation is supposed to be a local-only operation, but Configure implementations
are allowed to make outgoing requests to remote APIs to validate settings.
2020-05-07 11:08:10 -07:00
Sander van Harmelen 9453308c78 Make sure the WinRM communicator can reconnect 2020-05-05 16:18:30 -04:00
Sander van Harmelen 10aab86051 Make sure we use MaxRetries correctly
Even if MaxRetries is 0, we should still execute the loop one time in
order to run the Chef-Client at least once. Also waiting only makes
sense when we have `attempts` left. And last but not least we want to
exit immediately when the exit code is not in the retry list.

So this PR fixes three small issues to make everything work as
expected.
2020-05-05 16:18:30 -04:00
Sander van Harmelen a614056925 Refactor the code a bit to make it more idiomatic 2020-05-01 08:58:33 -04:00
Brian Dwyer 2f4067cf70
Clean up and add docs
Signed-off-by: Brian Dwyer <Brian.Dwyer@broadridge.com>
2020-04-30 08:16:17 -04:00
Brian Dwyer 4701ed2e02
Gracefully handle Chef RFC062 Exit Codes
Signed-off-by: Brian Dwyer <Brian.Dwyer@broadridge.com>
2020-04-29 23:48:19 -04:00
Pam Selle 41d2c4f172
Merge pull request #24321 from davidMcneil/master
Fix permissions of habitat provision's user.toml
2020-03-27 11:29:38 -04:00
Kristin Laemmert c8d64846ad
Mildwonkey/ps import (#24412)
* import: remove Config from ImportOpts

`Config` in ImportOpts was any provider configuration provided by the
user on the command line. This option has already been removed in favor
of only taking the provider from the configuration loaded in the current
context.

* terrafrom: add Config to ImportStateTransformer and refactor Transform
to get the resource provider FQN from the Config
2020-03-20 08:15:29 -04:00
David McNeil 3a079b04db Change file permission ordering to avoid race condition
Signed-off-by: David McNeil <mcneil.david2@gmail.com>
2020-03-09 11:04:07 -04:00
David McNeil b95daa87c8 Fix permissions of habitat provision's user.toml
Signed-off-by: David McNeil <mcneil.david2@gmail.com>
2020-03-09 10:24:29 -04:00
Paddy e6592dc710
Add support for provider metadata to modules. (#22583)
Implement a new provider_meta block in the terraform block of modules, allowing provider-keyed metadata to be communicated from HCL to provider binaries.

Bundled in this change for minimal protocol version bumping is the addition of markdown support for attribute descriptions and the ability to indicate when an attribute is deprecated, so this information can be shown in the schema dump.

Co-authored-by: Paul Tyng <paul@paultyng.net>
2020-03-05 16:53:24 -08:00
Kristin Laemmert 9891d0354a
providers: use addrs.Provider as map keys for provider.Factory (#23548)
* terraform/context: use new addrs.Provider as map key in provider factories
* added NewLegacyProviderType and LegacyString funcs to make it explicit that these are temporary placeholders

This PR introduces a new concept, provider fully-qualified name (FQN), encapsulated by the `addrs.Provider` struct.
2019-12-04 11:30:20 -05:00
Alex Harvey cbeedfca35 provisioner/puppet: fix bug when connection type was not set in config (#23057)
Before this, the Terraform Puppet provisioner would error out in a
confusing way if the type attribute in a connection block was not given.

Apparently an omitted type leads to type having a value "" which must be
then assumed to mean "ssh".

Fixes #23004
2019-10-17 11:46:55 -04:00
Pam Selle b40385772e
Merge pull request #22705 from kmott/habitat-provisioner-updates
Habitat provisioner updates
2019-10-01 14:27:52 -04:00
Kyle Mott 30895a6cf5 Merge cleanup, remove `license` parameter in favor of bool `accept_license`, adjust how license acceptance is done, update hab provisioner doc. 2019-09-29 11:16:25 -07:00
Kyle Mott e3d1876f44 Merge upstream 2019-09-27 16:38:50 -07:00
James Bardin a3c374b227 don't lose track of private data in the ACC tests
If the resource schema version is > 0, the metadata containing the
timeout values was overwritten during acceptance tests.
2019-09-18 13:59:12 -04:00
Pam Selle 80dec63917
Merge pull request #22691 from pselle/customizediff
Evaluate ignore changes before sending plan to CustomizeDiff
2019-09-11 14:45:21 -04:00
Mudassar Shafique 50a6c69ab5 Habitat License Acceptance changes. These changes add a new argument that allows users to accept Habitat End User License.
It also containts doc updates for Habitat and Chef provisioner
2019-09-09 23:03:39 +05:00
Pam Selle 2e5a8c0f6e Update when ignore_changes are evaluated, to impact customizediff 2019-09-09 09:35:10 -04:00
Kyle Mott 997761ef41 Remove commented out code. 2019-09-05 09:45:33 -07:00