Commit Graph

22816 Commits

Author SHA1 Message Date
Martin Atkins 17b883f592 command/format: Include variable values in diagnostic messages
When HCL encounters an error during expression evaluation, it annotates
its diagnostics with information about the expression that was being
evaluated and the EvalContext it was evaluated in.

This gives us enough information to show helpful hints to the user about
the final values of any reference expressions that are present in the
expression, which is very useful extra context for expressions that get
evaluated multiple times, such as:
- Any expression in a block with "count" or "for_each" set
- The sub-expressions within a "for" expression
2018-10-18 17:12:01 -07:00
Martin Atkins 8d100bfde9 tfdiags: Expose expression evaluation information from diagnostics
HCL diagnostics relating to expression evaluation include these, so this
is really just to pass that information through our Terraform-specific
diagnostics interface.
2018-10-18 17:12:01 -07:00
James Bardin 625145563a
Merge pull request #19121 from hashicorp/jbardin/simple-diff
add old values when computing the new InstanceDiff
2018-10-18 20:10:56 -04:00
James Bardin 9fe391cee7
Merge pull request #19120 from hashicorp/jbardin/is-known
Check IsKnown where values may panic
2018-10-18 20:06:44 -04:00
James Bardin ff4e81cc2b add old values when computing the new InstanceDiff
This was previously done in the RequiresNew code, which is skipped in
new style provider.
2018-10-18 20:05:33 -04:00
Chris Doherty 072f73a381
Merge pull request #19118 from hashicorp/cd/vagrantfile-go-1.11.1
Update the Vagrantfile to install Go 1.11.1.
2018-10-18 18:38:17 -05:00
James Bardin e08a388d3c check IsKnown on values that may panic 2018-10-18 19:21:32 -04:00
James Bardin 9434591652
Merge pull request #19117 from hashicorp/jbardin/coerce-value
use correct block types in CoerceValue
2018-10-18 19:21:09 -04:00
James Bardin 9e3c23d890 verify that all LengthInt calls are known
There were some funcs with LengthInt calls on unknown values
2018-10-18 19:19:59 -04:00
Kristin Laemmert e7907d1acd
Merge pull request #19119 from hashicorp/kristin/vendoring-fun
vendor: upgrade ssh-agent dependency
2018-10-18 16:05:56 -07:00
Kristin Laemmert 377077c060 vendor: upgrade ssh-agent dependency 2018-10-18 15:38:22 -07:00
Chris Doherty 62860a56e2 Update the Vagrantfile to install Go 1.11.1. 2018-10-18 15:34:55 -07:00
James Bardin b3a491d035 use correct block types in CoerceValue
When creating Null or Unknown values during CoerceValue, the the outer
block type was being used rather than the current block type.
2018-10-18 18:09:43 -04:00
Chris Griggs c98f2087fb
Merge pull request #19105 from cgriggs01/cgriggs01-linode-2
[Website] Linode documentation links
2018-10-18 11:12:19 -07:00
Martin Atkins ec57927ea3 build: Take protoc out of the "go generate" path
Since protoc is not go-gettable, and most development tasks in Terraform
won't involve recompiling protoc files anyway, we'll use a separate
mechanism for these.

This way "go generate" only depends on things we can "go get" in the
"make tools" target.

In a later commit we should also in some way specify a particular version
of protoc to use so that we don't get "flapping" regenerations as
developers work with different versions, but the priority here is just to
make "make generate" minimally usable again to restore the dev workflow
documented in the README.

This also includes some updates that resulted from running "make generate"
and "make protobuf" after those Makefile changes were in place.
2018-10-18 10:39:20 -07:00
James Bardin 47921bddb7
Merge pull request #19114 from hashicorp/jbardin/provider-defaults
don't set defaults for deprecated or removed
2018-10-18 13:01:02 -04:00
James Bardin a8f75bc554 don't set defaults for deprecated or removed
These may still have defaults set, even if they are not intended to be
used.
2018-10-18 12:45:55 -04:00
James Bardin fcbc896bc1
Merge pull request #19112 from hashicorp/jbardin/provider-config
Insert default values into provider config
2018-10-18 11:55:28 -04:00
James Bardin e077c9ce95 Insert default values into provider config
Add any top-level default attributes from the provider schema into Null
config values.
2018-10-18 11:40:47 -04:00
James Bardin 6317d529a9
Merge pull request #19111 from hashicorp/jbardin/provider-config
PrepareProviderConfig for terraform provider
2018-10-18 11:15:15 -04:00
James Bardin ac5f08c5d8 PrepareProviderConfig for terraform provider 2018-10-18 11:12:56 -04:00
James Bardin e377b8878d
Merge pull request #19110 from hashicorp/jbardin/provider-config
PrepareProviderConfig
2018-10-18 10:53:06 -04:00
James Bardin a3ac49b3fb GRPCProviderServer and PrepareProviderconfig
Update the server side of the plugin to match the new method signature.
2018-10-18 08:48:55 -04:00
James Bardin 155f899249 update terraform with PrepareProviderConfig
Change the call sites and update the MockProvider. No core behavior is
changed yet.
2018-10-18 08:48:55 -04:00
James Bardin 3bdd3b2a6e update plugin client with PrepareProviderConfig 2018-10-18 08:48:54 -04:00
James Bardin b173037eb3 update mock for PrepareProviderConfig 2018-10-18 08:48:54 -04:00
James Bardin ba472c7059 Update proto with new PrepareProviderConfig method 2018-10-18 08:48:54 -04:00
Radek Simko a656bcb263
Update CHANGELOG.md 2018-10-18 06:29:08 +01:00
Radek Simko d6f7577955
Merge pull request #19086 from hashicorp/f-file-exists-func
lang: Add file_exists function
2018-10-18 06:25:56 +01:00
James Bardin c1303f8482 providers PrepareProviderConfig
Change ValidateProviderConfig to PrepareProviderConfig.

Providers have a concept of "required fields with defaults" that that
was handled previously by helper/schema doing input and validation.
Because Input and Validation is mostly now handled by core, the provider
had no way of setting default values for missing required attributes.

To achieve the same behavior with new providers, there will be a
PrepareProviderConfig, which allow for manual validation, as well as
alteration of the config. The provider is free to set whatever
attributes necessary to create a valid config and return it to the
caller. If a new config is returned, it will be used instead of the
original in the subsequent Configure call, however core may still add
missing required values during an optional Input phase.
2018-10-17 21:31:52 -04:00
Martin Atkins 55c3f9b9c0 vendor: upgrade to latest github.com/zclconf/go-cty
This contains a fix for a panic in Value.HasElement when used on a set
value whose element type is an object or tuple.

A few other minor dependency upgrades came long for the ride.
2018-10-17 17:02:47 -07:00
Martin Atkins 9b4b43c077 plans/objchange: Don't panic when a prior value with a set is null
ProposedNewObject intentionally replaces a null prior with an unknown
prior in order to easily fill in unknown values where they "show through"
under values not set explicitly in config, but it was failing to handle
that situation when dealing with nested blocks that are backed by sets.
2018-10-17 17:02:47 -07:00
Martin Atkins 628c3a38b9 Catch up the CHANGELOG after the v0.12 development branch merge
Due to the unusual way v0.12 was developed (because of the large amount
of cross-cutting refactoring) we have not built out an incremental
changelog along the way as we normally would.

This is an initial catchup of the changelog for the current tree at the
time of writing, with the intent that we will maintain this in the usual
way moving forward as we head towards the v0.12-alpha1 release.
2018-10-17 16:31:59 -07:00
cgriggs01 a48dda2acc add linode documentation links 2018-10-17 14:20:39 -07:00
Sander van Harmelen 48ef7ecfa6 Updates after running `make fmt` with Go v1.11.1 2018-10-17 14:11:08 -07:00
Brian Flad 02e135bac8
Merge pull request #19102 from hashicorp/v-helper-validation-All-IntInSlice
helper/validation: Add All() and IntInSlice() SchemaValidateFunc
2018-10-17 14:39:03 -04:00
Brian Flad 17ac9a5756
helper/validation: Add All() and IntInSlice() SchemaValidateFunc
`All()` combines the outputs of multiple `SchemaValidateFunc`, to reduce the usage of custom validation functions that implement standard validation functions.

Example provider usage:

```go
ValidateFunc: validation.All(
  StringLenBetween(5, 42),
  StringMatch(regexp.MustCompile(`[a-zA-Z0-9]+`), "value must be alphanumeric"),
),
```

`IntInSlice()` is the `int` equivalent of `StringInSlice()`

Example provider usage:

```go
ValidateFunc: validation.IntInSlice([]int{30, 60, 120})
```

Output from unit testing:

```
$ make test TEST=./helper/validation
==> Checking that code complies with gofmt requirements...
go generate ./...
2018/10/17 14:16:03 Generated command/internal_plugin_list.go
go list ./helper/validation | xargs -t -n4 go test  -timeout=2m -parallel=4
go test -timeout=2m -parallel=4 github.com/hashicorp/terraform/helper/validation
ok  	github.com/hashicorp/terraform/helper/validation	1.106s
```
2018-10-17 14:22:29 -04:00
James Bardin 9143cb5b49
Merge pull request #19101 from hashicorp/jbardin/resource-tests
helper/resource tests
2018-10-17 13:10:38 -04:00
James Bardin 9c2f3ebe17
Merge pull request #19100 from hashicorp/jbardin/command-tests
Backend config and command tests
2018-10-17 13:10:21 -04:00
James Bardin 1ab96f42b7 fail nonfunctional resource tests
The helper/resource unit tests will panic, because they were using the
legacy terraform.MockResourceProvider, which doesn't have the same
internals required by the new GRPC shims.

Fail these tests for now, and a new test provider will need to be made
out of a schema.Provider instance.
2018-10-17 12:51:07 -04:00
James Bardin 3a0c2f1b67 close grpc TestListener 2018-10-17 12:13:59 -04:00
James Bardin fe9ed37dfc minor fixes for command Apply tests 2018-10-17 09:42:15 -04:00
James Bardin d707049f72 don't make a backup of a nil state
This makes sure we don't create a backup of an intermediate state if the
first read state was empty.
2018-10-17 09:42:08 -04:00
James Bardin 0a0eece15c add backend cli options after configuration
The cli should override the config
2018-10-17 09:41:58 -04:00
Radek Simko edaa4bbc82
lang: Add fileexists function 2018-10-17 10:18:07 +01:00
Martin Atkins 86e6481cc6 Merge v0.12 development so far
The master branch is now tracking towards the v0.12 release.
2018-10-16 19:52:24 -07: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
Martin Atkins fd77765154 vendor: make some transitive dependencies line up better
After a bunch of recent changes/rebasing our vendored dependencies got a
little out of sync w.r.t transitive dependencies through codebases that
are not themselves Go Modules yet.
2018-10-16 19:14:54 -07:00
Martin Atkins e25f79ed28 plugin/convert: Show approximate location context for all provider errors
Even if a provider doesn't indicate a specific attribute as the cause of
a resource operation error, we know the error relates to some aspect of
the resource, so we'll include that approximate information in the result
so that we don't produce user-hostile error messages with no context
whatsoever.

Later we can hopefully refine this to place the source range on the header
of the configuration block rather than on an empty part of the body, but
that'll require some more complex rework here and so for now we'll just
accept this as an interim state so that the user can at least figure out
which resource block the error is coming from.
2018-10-16 19:14:54 -07:00
Kristin Laemmert fd77e56fd6 lookup will return a tuple type when passed an object 2018-10-16 19:14:54 -07:00