Commit Graph

7839 Commits

Author SHA1 Message Date
James Bardin eddf676c1f add provider test with a nested list in a set
in some cases helper/schema misses the list counts.
2018-11-16 15:11:16 -05:00
James Bardin a681124301 verify DiffSuppresFunc behavior
Terraform used to provide empty diffs to the provider when calculating
`ignore_changes`, which would cause some DiffSuppressFunc to fail, as
can be seen in #18209.

Verify that this is no longer the case in 0.12
2018-11-16 11:17:23 -05:00
James Bardin 83317975fe add more tests with carious set combinations 2018-11-16 09:59:03 -05:00
James Bardin 71b55601ce new failing tests for nested sets 2018-11-16 09:59:03 -05:00
James Bardin d2bd41c260 add a nested set test 2018-11-13 18:53:02 -05:00
James Bardin c4d0be8a52 failing test for schemas with a single set attr
Resources with certain combinations of attributes in a nested single set
fail to perperly coerce their shimmed values.
2018-11-13 18:41:53 -05:00
Sander van Harmelen 52a1b22f7a Implement the remote enhanced backend
This is a refactored version of the `remote` backend that was initially added to Terraform v0.11.8 which should now be compatible with v0.12.0.
2018-11-06 16:29:46 +01:00
James Bardin e91f381cc4 test case for optional bools in schema
Booleans in the legacy form were stored as strings, and can appear as
the incorrect type in the new type system.

Unset fields in sets also might show up erroneously in diffs, with
equal old and new values.
2018-11-01 16:19:03 -04:00
James Bardin 8212a6a9d0 add provider tests for force-new with a map
Adding and removing a single map that requires a new resource can cause
empty diffs, relying on the core proposed state values for destruction.
2018-10-31 13:42:28 -04:00
James Bardin 36cede09f7 add provider tests for SuppressDiffFunc 2018-10-30 14:53:38 -04:00
James Bardin 121c9c127f add timeout tests to the test provider 2018-10-30 13:14:08 -04:00
James Bardin ac5f08c5d8 PrepareProviderConfig for terraform provider 2018-10-18 11:12:56 -04:00
Martin Atkins 541952bb8f Revert some work that happened since v0.12-dev branched
This work was done against APIs that were already changed in the branch
before work began, and so it doesn't apply to the v0.12 development work.

To allow v0.12 to merge down to master, we'll revert this work out for now
and then re-introduce equivalent functionality in later commits that works
against the new APIs.
2018-10-16 19:48:28 -07:00
James Bardin 5303137b8c udpate test configs to work with hcl2
The last 2 broken tests will be hanlded later
2018-10-16 19:14:54 -07:00
Martin Atkins 9f1098ac5f builtin/providers/terraform: Fix tests
Various things drifted since these tests were originally written. This
catches them up to the latest implementations of state decoding,
upgrading, etc.
2018-10-16 19:14:11 -07:00
Martin Atkins 8c67fd52b0 builtin/providers: Don't panic if requested remote state isn't present 2018-10-16 19:14:11 -07:00
Martin Atkins d11dd20bf3 builtin/providers/test: use new API for root module address
terraform.RootModulePath is no longer present, but
addrs.RootModuleInstance is equivalent to it.
2018-10-16 19:14:11 -07:00
Martin Atkins 630b0d147d providers/terraform: Always produce correctly-typed result
We need to produce values for all of the attributes implied by our schema,
even if some of them are null.
2018-10-16 19:14:11 -07:00
Martin Atkins 235f582ae5 core: Re-implement EvalReadDataApply against new provider interface 2018-10-16 19:14:11 -07:00
James Bardin faa46d4727 add Close method to the terraform provider
Close is now part of the plugin interfaces, so needs to be implemented
by the terraform provider.
2018-10-16 19:11:09 -07:00
Martin Atkins a3403f2766 terraform: Ugly huge change to weave in new State and Plan types
Due to how often the state and plan types are referenced throughout
Terraform, there isn't a great way to switch them out gradually. As a
consequence, this huge commit gets us from the old world to a _compilable_
new world, but still has a large number of known test failures due to
key functionality being stubbed out.

The stubs here are for anything that interacts with providers, since we
now need to do the follow-up work to similarly replace the old
terraform.ResourceProvider interface with its replacement in the new
"providers" package. That work, along with work to fix the remaining
failing tests, will follow in subsequent commits.

The aim here was to replace all references to terraform.State and its
downstream types with states.State, terraform.Plan with plans.Plan,
state.State with statemgr.State, and switch to the new implementations of
the state and plan file formats. However, due to the number of times those
types are used, this also ended up affecting numerous other parts of core
such as terraform.Hook, the backend.Backend interface, and most of the CLI
commands.

Just as with 5861dbf3fc49b19587a31816eb06f511ab861bb4 before, I apologize
in advance to the person who inevitably just found this huge commit while
spelunking through the commit history.
2018-10-16 19:11:09 -07:00
Kristin Laemmert 52ae93cf97 builtin/providers: terraform remote state datasource (#18446)
* builtin/providers: implement terraform remote state datasource as providers.Interface

* append and return diags separately (to match the idiomatic usage
elsewhere in Terraform)
* diagnostic summary style improvements
* update tests to pass config to schema.CoerceValue
* trust that the schema will be enforced and there is no need to check
that a given attribute exists
* added dataSourceRemoteStateGetSchema() (effectively replacing a
function that was inappropriately removed) for consistency with other
terraform providers
* builtin/provider terraform test: added InternalValidate() test for dataSourceRemoteStateGetSchema
2018-10-16 18:53:51 -07:00
Martin Atkins 5782357c28 backend: Update interface and implementations for new config loader
The new config loader requires some steps to happen in a different
order, particularly in regard to knowing the schema in order to
decode the configuration.

Here we lean directly on the configschema package, rather than
on helper/schema.Backend as before, because it's generally
sufficient for our needs here and this prepares us for the
helper/schema package later moving out into its own repository
to seed a "plugin SDK".
2018-10-16 18:39:12 -07:00
Sander van Harmelen 56e6c60f76
Merge pull request #18533 from alice-sawatzky/master
change chef linux provisioner to use user:group chown syntax
2018-10-11 10:29:01 +02:00
Sean Chittenden d749420a25
Fix drift caused from gofmt when running make dev and go 1.11.
A fresh checkout of `origin/master` does not build atm using the `dev`
target because `master` has not been formatted using `gofmt` from Go
1.11 (tis has been the case for a while if you've been running devel).

None of the drift in question is especially new but now that Go 1.11
has been released and gofmt's formatting guidelines have been updated,
it would be *really* nice if the code in `master` reflected the current
tooling in order to avoid having to fight this drift locally.

* 8mo: https://github.com/hashicorp/terraform/blame/master/backend/remote-state/s3/backend_test.go#L260-L261
* 6mo: https://github.com/hashicorp/terraform/blame/master/builtin/provisioners/chef/linux_provisioner_test.go#L124
* 1yr: 7cfeffe36b/command/init.go (L75-L76)
* 12d: 7cfeffe36b/command/meta_backend_test.go (L1437)
* 2yr: 7cfeffe36b/helper/schema/resource_timeout_test.go (L26)
* 4yr: 7cfeffe36b/helper/schema/schema_test.go (L2059)
* 1yr: 7cfeffe36b/plugin/discovery/get_test.go (L151)
2018-09-09 10:18:08 -07:00
Sander van Harmelen 3e935c846f terraform/terraform_remote_state: accept complex configs
The `remote` backend config contains an attribute that is defined as a `*schema.Set`, but currently only `string` values are accepted as the `config` attribute is defined as a `schema.TypeMap`.

Additionally the `b.Validate()` method wasn’t called to prevent a possible panic in case of unexpected configurations being passed to `b.Configure()`.

This commit is a bit of a hack to be able to support this in the 0.11 series. The 0.12 series will have proper support, so when merging 0.12 this should be reverted again.
2018-08-29 20:21:47 +02:00
Sander van Harmelen 7fb2d1b8de Implement the Enterprise enhanced remote backend 2018-08-03 22:22:55 +02:00
Sander van Harmelen 97d1c46602 Update the backend import names
It’s a purely cosmetic change, but I find it easier to read them like this.
2018-08-03 11:29:11 +02:00
Alice Sawatzky 15c65f981b
change chef linux provisioner to use user:group chown syntax 2018-07-24 19:12:40 -05:00
Skyler Layne d1124a4e3d
Update resource_provisioner.go
fix spacing for service url.
2018-07-05 15:37:42 -04:00
Andre Bindewald de43f01d65 provisioner/local-exec: Support custom environment variables on Windows
Due to an incorrect slice allocation, the environment variable list was created with an empty string
element for each real element added.

It appears that this was silently ignored on Unix, but caused the following environment settings
to be ignored altogether on Windows.
2018-06-15 18:26:43 -07:00
James Bardin f8b691f743
Merge pull request #17781 from hashicorp/jbardin/habitat
`enable` habitat supervisor service before `start`
2018-04-05 08:43:50 -04:00
James Bardin c1edaadc7b
Merge pull request #17403 from rwc/hab-provisioner-updates
[provisioner-habitat] Fix package channel honoring and documentation
2018-04-04 16:55:24 -04:00
Marko Springfeldt a201b04b26 `enable` habitat supervisor service before `start`
Signed-off-by: Arash Zandi <arash.zandi@smartb.eu>
2018-04-04 16:51:26 -04:00
James Bardin e9e4ee4940
Merge pull request #17609 from hashicorp/jbardin/remote-command
clean up remote.Cmd api
2018-03-23 17:34:06 -04:00
James Bardin ad8642e2c2 have remote.ExitError format errors and status
Since all use cases of ExitStatus are just putting it into fmt.Errorf,
usually with the command string, have ExitStatus do that for the caller.
2018-03-23 11:36:57 -04:00
James Bardin 56acda00bc add timeout test to remote-exec
Add a test to remote-exec to make sure the proper timeout is honored
during apply.

TODO: we need some test helpers for provisioners, so they can all be
verified.
2018-03-20 14:24:01 -04:00
James Bardin 9b4b5f2a72 use correct context for communicator.Retry
The timeout for a provisioner is expected to only apply to the initial
connection. Keep the context for the communicator.Retry separate from
the global cancellation context.
2018-03-20 13:06:28 -04:00
Scott Hain 07aeea51da Updates the chef provisioner to allow specifying a channel (#17355)
* Updates the chef provisioner to allow specifying a channel

This also updates the omnitruck url to the current url.

Signed-off-by: Scott Hain <shain@chef.io>

* Update omnitruck URL

Signed-off-by: Scott Hain <shain@chef.io>
2018-03-20 11:51:14 +01:00
James Bardin 3fbdee0777 clean up remote.Cmd api
Combine the ExitStatus and Err values from remote.Cmd into an error
returned by Wait, better matching the behavior of the os/exec package.

Non-zero exit codes are returned from Wait as a remote.ExitError.
Communicator related errors are returned directly.

Clean up all the error handling in the provisioners using a
communicator. Also remove the extra copyOutput synchronization that was
copied from package to package.
2018-03-16 14:29:48 -04:00
James Bardin a1061ed931 update the chef and habitat error handling
Use the new ExitStatus method, and also check the cmd.Err() method for
errors.

Remove leaks from the output goroutines in both provisioners by
deferring their cleanup, and returning early on all error conditions.
2018-03-15 16:04:05 -04:00
James Bardin a715430d24 fix exit status handling in salt-masterless
Convert to the new Cmd.ExitStatus() method in the salt-masterless
provisioner. Add calls to Wait and remove race conditions around setting
the status.
2018-03-15 16:04:00 -04:00
James Bardin af132a186d remove timeout from remote-exec command context
The timeout for the remote command was taken from the wrong config
field, and the connection timeout was being used which is 5 min. Any
remote command taking more than 5 min would be terminated by
disconnecting the communicator. Remove the timeout from the context, and
rely on the global timeout provided by terraform.

There was no way to get the error from the communicator previously, so
the broken connection was silently ignored and the provisioner returned
successfully. Now we can use the new cmd.Err() method to retrieve any
errors encountered during execution.
2018-03-15 16:03:40 -04:00
James Bardin e011dd95f3 don't let default workspace override environment
The workspace attribute should only override the environment if it's not
the default value.
2018-03-09 10:27:06 -05:00
James Bardin 13433687cb filter null output values from state
While null values should not normally appear in a state file, we should
filter the values rather than crash.
2018-03-08 11:39:29 -05:00
Kristiyan Nikolov 999f9096c1 provisioner/local-exec: Allow passing environment variables 2018-03-05 15:58:49 -08:00
Paweł Socha be8d39210d Wait for ssh connection 2018-02-26 15:40:26 +01:00
Paweł Socha 627bb24ea6 fix ssh problem with communicator.Retry 2018-02-26 10:27:14 +01:00
Rob Campbell bbd3d7f7a2 Updates the capitalization of the bind documenation for habitat
provisioner. Also fixes an issue where channels and URLs are
not honored in the initial package install.

Signed-off-by: Rob Campbell <rcampbell@chef.io>
2018-02-21 11:47:45 -05:00
chrisjob1021 10bb21e9c4 provisioner/local-exec: Optional "working_dir" argument
This new argument allows overriding of the working directory of the child process, with the default still being the working directory of Terraform itself.
2018-02-16 11:31:11 -08:00