Commit Graph

25051 Commits

Author SHA1 Message Date
Martin Atkins 6ab15a80a4
Update CHANGELOG.md 2019-01-17 10:03:30 -08:00
Martin Atkins 2f8f7d6f4d lang/funcs: Type conversion functions
It's not normally necessary to make explicit type conversions in Terraform
because the language implicitly converts as necessary, but explicit
conversions are useful in a few specialized cases:

- When defining output values for a reusable module, it may be desirable
  to force a "cleaner" output type than would naturally arise from a
  computation, such as forcing a string containing digits into a number.
- Our 0.12upgrade mechanism will use some of these to replace use of the
  undocumented, hidden type conversion functions in HIL, and force
  particular type interpretations in some tricky cases.
- We've found that type conversion functions can be useful as _temporary_
  workarounds for bugs in Terraform and in providers where implicit type
  conversion isn't working correctly or a type constraint isn't specified
  precisely enough for the automatic conversion behavior.

These all follow the same convention of being named "to" followed by a
short type name. Since we've had a long-standing convention of running all
the words together in lowercase in function names, we stick to that here
even though some of these names are quite strange, because these should
be rarely-used functions anyway.
2019-01-17 10:01:47 -08:00
Kim Ngo ba6e243bd9
Merge pull request #20030 from findkim/bump-plugin-install-version
Bump provider installer protocol version to 5
2019-01-17 11:37:48 -06:00
Radek Simko 5d4946e27a
Merge pull request #20004 from hashicorp/issue-template-labels
Add labels to issue templates
2019-01-17 15:22:49 +00:00
Radek Simko b661a983b8
Add labels to issues templates 2019-01-17 15:04:16 +00:00
findkim 073d367018 tools/terraform-bundle: match plugin installer protocol with terraform's installer 2019-01-16 16:15:52 -06:00
findkim 7816e61614 Bump installer protocol version to 5 and separate client and server protocol references 2019-01-16 15:07:57 -06:00
Radek Simko 2ad9f0513a
Update CHANGELOG.md 2019-01-16 19:31:28 +00:00
Radek Simko aaf4319953
Merge pull request #20005 from hashicorp/b-statemgr-avoid-html-escaping
states/statemgr: Avoid HTML escaping when printing LockInfo
2019-01-16 19:30:50 +00:00
Martin Atkins 4e14ab7557 config: Remove "setproduct" function, which is now in lang/funcs 2019-01-16 09:57:16 -08:00
Martin Atkins da51e72cbb lang/functions: set functions from cty
The sethaselement, setintersection, and setunion functions are defined in
the cty stdlib. Making them available in Terraform will make it easier to
work with sets, and complement the currently-Terraform-specific setproduct
function.

In the long run setproduct should probably move into the cty stdlib too,
but since it was submitted as a Terraform function originally we'll leave
it here now for simplicity's sake and reorganize later.
2019-01-16 09:57:16 -08:00
Martin Atkins edb5f82de1 lang/funcs: Convert the "setproduct" function to the new approach
In our new world it produces either a set of a tuple type or a list of a
tuple type, depending on the given argument types.

The resulting collection's element tuple type is decided by the element
types of the given collections, allowing type information to propagate
even if unknown values are present.
2019-01-16 09:57:16 -08:00
Martin Atkins 9d11d427a8 config: Rename "product" function to "setproduct"
This hopefully makes it clearer that it works with sets rather than real
numbers, avoiding confusion with "sum", "min", "max", etc.
2019-01-16 09:57:16 -08:00
Fábio Matavelli acd17d9075 Create product interpolation function
This creates the product interpolation function that returns the cartesian product of a list of lists.
2019-01-16 09:57:16 -08:00
Kim Ngo 2bca828e46
Merge pull request #20015 from findkim/rm-dup-discovery-logging
Remove duplicate discovery logging
2019-01-15 16:12:54 -06:00
findkim abeb86072b Remove duplicate logging 2019-01-15 15:39:28 -06:00
James Bardin 30eead2df5
Merge pull request #20012 from hashicorp/jbardin/nested-set-shims
Fix shims with deeper nested containers
2019-01-15 15:40:16 -05:00
Riley Karson 74ec68f9d4 Fix Google Cloud Platform name across docs.
The `google` provider supports GCP, not necessarily Google Cloud as a whole.

Update the naming on this index page to match [the provider README](https://github.com/terraform-providers/terraform-provider-google#terraform-provider-for-google-cloud-platform) and the [provider docs changes](https://github.com/terraform-providers/terraform-provider-google/blob/master/website/docs/index.html.markdown#google-cloud-platform-provider) coming in the next release.
2019-01-15 12:10:20 -08:00
appilon c5e4ac9b7c
Merge pull request #20013 from appilon/go1.11.4
Require go1.11.4
2019-01-15 15:00:36 -05:00
Alex Pilon 9929bd05a3
update vagrantfile for go1.11.4 2019-01-15 14:31:51 -05:00
Alex Pilon de769533e1
require go1.11.4 2019-01-15 14:26:21 -05:00
James Bardin 7d05dee08d refactor ApplyResourceChange
Remove a bunch of indentation by returning early, and make sure we don't
fail on non-fatal error without saving the applied value.
2019-01-15 12:35:58 -05:00
James Bardin 0a731167db add a round trip through the shims during apply
Cycle through the shim operations after Apply, to ensure that we can
converge on a stable value for for Plan. While the shims produce valid
values in both directions, helper/schema sometimes does not agree on
which containers should be empty or null.
2019-01-15 11:59:15 -05:00
James Bardin 0d1252812b add more tests for a computed nested list and set 2019-01-15 11:55:02 -05:00
Radek Simko a29daf0176
Update CHANGELOG.md 2019-01-15 16:26:01 +00:00
Radek Simko cb39836705
Merge pull request #19995 from hashicorp/f-cmd-fmt-reduce-diff
command/format: Reduce whitespaces in empty fields
2019-01-15 16:25:19 +00:00
Sander van Harmelen 9ba5b1b507
Merge pull request #20010 from hashicorp/svh/f-remote-backend
backend/remote: use the correct test operation
2019-01-15 16:37:09 +01:00
Sander van Harmelen e08a7e979e backend/remote: use the correct test operation 2019-01-15 16:13:16 +01:00
Sander van Harmelen 4d9da13d85 go-mod: update dependencies 2019-01-15 15:52:37 +01:00
Radek Simko 13896d72c5
command/format: Render empty object as {} 2019-01-15 14:34:49 +00:00
Radek Simko 5f14b7a7f2
command/format: Render empty primitive list/set as [] 2019-01-15 14:34:49 +00:00
Radek Simko 09d19ca9d9
command/format: Render empty JSON object as {} 2019-01-15 14:34:48 +00:00
Radek Simko 0dd2d56f18
command/format: Render empty maps as {} 2019-01-15 14:34:46 +00:00
Radek Simko ea05da89cb
states/statemgr: Avoid HTML escaping when printing LockInfo 2019-01-15 10:57:31 +00:00
Martin Atkins 0995559934 go mod tidy 2019-01-14 17:39:16 -08:00
Kim Ngo 41a2376915
Merge pull request #19981 from findkim/colorize-protocol-mismatch-msg
Condense protocol mismatch UI error message
2019-01-14 15:12:09 -06:00
findkim 6e0de3e3f5 Nest incompatible provider protocol error to include dynamic custom msg 2019-01-14 14:56:47 -06:00
Radek Simko 1c660cc39f
Update CHANGELOG.md 2019-01-14 20:34:28 +00:00
Radek Simko aae87c7921
Merge pull request #19990 from hashicorp/f-cmd-fmt-ignore-empty-str
command/format: Ignore removal of empty strings
2019-01-14 20:33:43 +00:00
Martin Atkins 86c02d5c35 command: "terraform init" can partially initialize for 0.12upgrade
There are a few constructs from 0.11 and prior that cause 0.12 parsing to
fail altogether, which previously created a chicken/egg problem because
we need to install the providers in order to run "terraform 0.12upgrade"
and thus fix the problem.

This changes "terraform init" to use the new "early configuration" loader
for module and provider installation. This is built on the more permissive
parser in the terraform-config-inspect package, and so it allows us to
read out the top-level blocks from the configuration while accepting
legacy HCL syntax.

In the long run this will let us do version compatibility detection before
attempting a "real" config load, giving us better error messages for any
future syntax additions, but in the short term the key thing is that it
allows us to install the dependencies even if the configuration isn't
fully valid.

Because backend init still requires full configuration, this introduces a
new mode of terraform init where it detects heuristically if it seems like
we need to do a configuration upgrade and does a partial init if so,
before finally directing the user to run "terraform 0.12upgrade" before
running any other commands.

The heuristic here is based on two assumptions:
- If the "early" loader finds no errors but the normal loader does, the
  configuration is likely to be valid for Terraform 0.11 but not 0.12.
- If there's already a version constraint in the configuration that
  excludes Terraform versions prior to v0.12 then the configuration is
  probably _already_ upgraded and so it's just a normal syntax error,
  even if the early loader didn't detect it.

Once the upgrade process is removed in 0.13.0 (users will be required to
go stepwise 0.11 -> 0.12 -> 0.13 to upgrade after that), some of this can
be simplified to remove that special mode, but the idea of doing the
dependency version checks against the liberal parser will remain valuable
to increase our chances of reporting version-based incompatibilities
rather than syntax errors as we add new features in future.
2019-01-14 11:33:21 -08:00
Martin Atkins 0c0a437bcb Move module install functionality over to internal/initwd 2019-01-14 11:33:21 -08:00
Martin Atkins 047239e68c vendor: Add github.com/hashicorp/terraform-config-inspect 2019-01-14 11:33:21 -08:00
Martin Atkins e27e0ddc9e internal/init: Module installation functionality
This is an adaptation of the installation code from configs/configload,
now using the "earlyconfig" package instead of the "configs" package.

Module installation is an initialization-only process, with all other
commands assuming an already-initialized directory. Having it here can
therefore simplify the API of configs/configload, which can now focus only
on the problem of loading modules that have already been installed.

The old installer code in configs/configload is still in place for now
because the caller in "terraform init" isn't yet updated to use this.
2019-01-14 11:33:21 -08:00
Martin Atkins 53ee858851 internal/init: Package for helpers of the "terraform init" command
"terraform init" is quite a complex beast in relation to other commands
since almost everything it does is unique to it and thus not factored out
into other packages.

To get some of that sprawl out of the "command" package, this new internal
package will give us somewhere to put this init functionality that is
also useful for test code that needs to mimic the initialization behavior
against fixture directories.
2019-01-14 11:33:21 -08:00
Martin Atkins 0ce2add59f internal/modsdir: Factor out module manifest models to separate package 2019-01-14 11:33:21 -08:00
Martin Atkins 8ca1fcec51 internal/earlyconfig: Liberal config parsing for init
This is an alternative to the full config loader in the "configs" package
that is good for "early" use-cases like "terraform init", where we want
to find out what our dependencies are without getting tripped up on any
other errors that might be present.
2019-01-14 11:33:21 -08:00
Radek Simko d96f4fa77b
command/format: Ignore removal of empty strings 2019-01-13 22:56:04 +00:00
James Bardin 21d65cfa9a
Merge pull request #19988 from hashicorp/jbardin/refresh-shims
Don't add empty blocks to config, and fix ReadResource
2019-01-13 10:16:37 -05:00
James Bardin 041ed67e46 type names don't imply the resource mode
The addr type doesn't imply the resource mode, so data sources and
managed resources with the same type name could shim incorrectly.
2019-01-12 11:43:48 -05:00
James Bardin e8096e9c8b normalize values during ReadResource
Match the normalization behavior of Apply, so we don't end up causing
any diffs between zero values when refreshing resources.
2019-01-12 10:41:04 -05:00