Commit Graph

26599 Commits

Author SHA1 Message Date
James Bardin a7507e140d parse module references as whole modules
Module references, like resource references, need to always return the
and object containing all instances in order to handle modules as single
values, and to postpone index evaluation to when the expression as whole
is evaluated.
2020-04-12 11:26:44 -04:00
James Bardin 600d4c3e1f eval Data needs to operate on whole modules
In order to be able to use module values, and handle operations like
possibly invalid module indexes in conditional statements, whole modules
must always be returned during evaluation.
2020-04-12 10:50:31 -04:00
James Bardin aeadb8ca90 start with a failing test 2020-04-10 16:52:47 -04:00
Pam Selle 65c4ba9c85 First docs for count/for_each on modules 2020-04-10 15:14:06 -04:00
Kristin Laemmert 4079247270
Update CHANGELOG.md 2020-04-10 15:11:46 -04:00
Kristin Laemmert 269d511481 command/providers: refactor with new provider types and functions
The providers command has been refactored to use the modern provider types and
ProviderRequirements() functions. This resulted in a breaking change to
the output: it no longer outputs the providers by module and no longer
prints `(inherited)` or `(from state)` to show why a provider is
included. We decided that at this time it was best to stick with the
existing functions and make this change, but if we get feedback from the
community we will revisit.

Additional tests to exercise providers in modules and providers from
state have been included.
2020-04-10 15:08:10 -04:00
Kristin Laemmert 0a5fb40fdf configs: include provider configs in ProviderRequirements()
This PR adds iteration through any provider configuration blocks in the
config in addProviderRequirements().

A stale comment (of mine!) would leave one expecting the
module.ProviderRequirements to include any requirements from provider
configs. The comment was inaccurate and has been updated.
2020-04-10 15:08:10 -04:00
James Bardin 5ddb1a5808
Merge pull request #24623 from hashicorp/jbardin/module-output-references
Correctly connect module output references during plan
2020-04-10 14:46:25 -04:00
James Bardin 46b85820ba
Update addrs/module_call.go
Co-Authored-By: Pam Selle <pam@hashicorp.com>
2020-04-10 14:45:36 -04:00
Eduard Tamsa 534ba630e4
docs(flatten): Fix typos (#24492) 2020-04-10 08:59:17 -04:00
Kyler Middleton 89bef596fc
docs: Fix typo in maintainer-etiquette (#24609) 2020-04-10 08:55:19 -04:00
Danny Guo b7b981fbe1
website/docs: Fix a typo in the import command docs (#24622) 2020-04-10 08:54:19 -04:00
Stanislav Petrashov 0add5d4915 Update community-index.html.markdown 2020-04-09 15:59:36 -07:00
Michael Conlon 1ec6fc6643
website: note special behavior for modules in us-east-1 S3 buckets (#24155)
* Keep s3 docs in line with functionality

Related to https://github.com/hashicorp/terraform/issues/16442

* @nfagerlund's suggested markdown and wording changes
2020-04-09 15:56:59 -07:00
James Bardin b9ddec33e9 de-specify module output references
Like resource references, we need to make instance references less
specific when they aren't expanded yet during plan.
2020-04-09 15:41:35 -04:00
James Bardin a805e14283 module output expansion test 2020-04-09 15:39:48 -04:00
James Bardin a0f92f9d6a remove extra brackets in state string output 2020-04-09 15:36:16 -04:00
Alisdair McDiarmid 1593b8b8e5 vendor: go get github.com/zclconf/go-cty@v1.4.0
This fixes several bugs:

- `substr("abc", 0, 0)` would previously return `"abc"`, despite the
  length argument being `0`. This has been changed to return an empty
  string when length is zero.

- `ceil(1/0)` and `floor(1/0)` would previously return a large integer
  value, rather than infinity. This has been fixed.
2020-04-09 14:19:05 -04:00
Petros Kolyvas 2bb020193b
Merge pull request #24556 from pkolyvas/contribution-codeowners
An update to our CODEOWNERS and Contribution Guide
2020-04-09 14:12:09 -04:00
Chris Griggs c71716e6d2
Merge pull request #24618 from hashicorp/cgriggs01-sumologic-link
[Website] Add SumoLogic provider links
2020-04-09 10:11:07 -07:00
Chris Griggs 7c5b0e509a [Website] Add SumoLogic provider links 2020-04-09 09:39:29 -07:00
James Bardin 9c75cfd403
Merge pull request #24605 from hashicorp/jbardin/validate-module-variable
Allow module variables to pass validation
2020-04-09 11:54:50 -04:00
James Bardin 3d8b1dea97
Update terraform/eval_for_each.go
Co-Authored-By: Pam Selle <pam@hashicorp.com>
2020-04-09 11:47:16 -04:00
James Bardin 73a20bfb17 fixup mangled comments 2020-04-09 10:13:03 -04:00
James Bardin b1bc7a792b rename and cleanup use of count/for_each eval func
Stop evaluating count and for each if they aren't set in the config.
Remove "Resource" from the function names, as they are also now used
with modules.
2020-04-08 17:21:23 -04:00
James Bardin 4f7d30900e
Merge pull request #24599 from hashicorp/jbardin/races
Fix races in GetVariableValue and login
2020-04-08 17:13:21 -04:00
James Bardin d060a3d0e8 eval variables with unknown expansion data
While we don't have any expansion info during validation, we can try to
evaluate variable expressions to catch some basic errors. Do this by
creating module instance RepetitionData with unknown values. This
unfortunately will still miss the incorrect usage of count/each values,
but that would require the module call's each mode, which is not
available at this time.
2020-04-08 15:37:38 -04:00
James Bardin c59ecac870 rename module variables and remove extra methods
The variable nodes are not only used during plan and apply, so remove
those from there names. The "plan" node is now
`nodeExpandModuleVariable` and the "apply" node is now just
`nodeModuleVariable`.

Remove unnecessary methods, as the nodeModuleVariable is no longer used
in the full graph transformations.
2020-04-08 14:41:52 -04:00
James Bardin f0abc7e2e6
Merge pull request #24574 from hashicorp/jbardin/module-references
Point module references to the close node
2020-04-08 12:41:05 -04:00
James Bardin 43d93b2036 remove excess logging from dag
The dag Update messages were not particularly helpful in the debugging
of terraform, and since we're going to be relying on DynamicExpand to an
even greater extent, this will eliminate a log of extra log output.
2020-04-08 12:30:35 -04:00
James Bardin 700e20de5d connect references to the module closer
NodeModuleRemoved is redundant now with the concept of
nodeCloseModule, so we can replace it within the graph. This does mean
that nodeCloseModule needs to know if it's evaluating an orphaned module
that can't be expanded, but the overhead to checking this isn't too
bad.

Now that nodeModuleClose is referenceable, and we can ensure it's always
in the graph at the correct time, we can eliminate the need to connect
each resource to every single node within a module it references, and
instead connect only to the nodeModuleClose, which acts as the module
root. Since module expansion can cause exponential growth in the number
of edges in graphs, this will help with performance problems when
transforming and reducing these graphs by eliminating the bulk of
redundant edges. This will also help with general debugging, making the
graphs easier to read.
2020-04-08 12:30:35 -04:00
James Bardin 3ee9cf49ce missing wg.Wait in concurrent test 2020-04-08 10:55:20 -04:00
James Bardin b84e6f7f95 remove race from closed-over err variable 2020-04-08 10:12:46 -04:00
James Bardin 85593b432e add locks to testHook 2020-04-08 10:02:43 -04:00
James Bardin 695a5fe27d lock was missing in the call to GetVariableValue 2020-04-08 09:59:27 -04:00
Sathija Pavuluri a0832b9886
website: In import usage doc, use aws_network_acl as an example of complex import with secondary resources (#24525)
A proposed pull request to the AWS provider would change the import behavior of 
`aws_security_group`. This preemptive change will help keep the docs accurate if 
that gets merged.
2020-04-07 17:36:02 -07:00
James Bardin 2eba39a671
Merge pull request #24587 from hashicorp/jbardin/disallow-count-and-foreach
don't allow count && for_each in module calls
2020-04-07 17:30:04 -04:00
Martin Atkins 82ad9fd635
Update CHANGELOG.md 2020-04-07 11:25:05 -07:00
James Bardin 939d045a0b don't allow count && for_each 2020-04-07 14:18:08 -04:00
Martin Atkins 6ec5e0fc88 internal/getproviders: Tests for MemoizeSource
Due to other pressures at the time this was implemented, it was tested
only indirectly through integration tests in other packages. This now
introduces tests for the two main entry points on MemoizeSource.
2020-04-07 08:55:52 -07:00
Martin Atkins c6535a0fa4 internal/getproviders: Tests for MultiSource
Due to other pressures at the time this was implemented, it was tested
only indirectly through integration tests in other packages.

This now introduces tests for the two main entry points on the
MultiSource, along with its provider-address pattern matching logic.

This does not yet include thorough tests for
ParseMultiSourceMatchingPatterns, because that function still needs some
adjustments to do the same case folding as for normal provider address
parsing, which will follow in a latter commit along with suitable tests.

With that said, the tests added here do _indirectly_ test the happy path
of ParseMultiSourceMatchingPatterns, so we have some incomplete testing
of that function in the meantime.
2020-04-07 08:55:13 -07:00
Chris Griggs f8cbb1f5a2
Merge pull request #24578 from hashicorp/cgriggs01-community
[Website] New community providers
2020-04-07 08:48:44 -07:00
Pam Selle d109f79678
Merge pull request #24575 from hashicorp/pselle/mod-expansion-keywords
Enable count.index and each.key/value in module expansion
2020-04-07 10:03:13 -04:00
Pam Selle 66a9c51f74 Update comment to reflect new code 2020-04-07 06:20:30 -04:00
Chris Griggs e055ac80ae [Website] New community providers 2020-04-06 18:34:28 -07:00
Martin Atkins 0ad4c1be2f internal/getproviders: Tidy up some confusion about package hashes
Earlier on in the stubbing of this package we realized that it wasn't
going to be possible to populate the authentication-related bits for all
packages because the relevant metadata just isn't available for packages
that are already local.

However, we just moved ahead with that awkward design at the time because
we needed to get other work done, and so we've been mostly producing
PackageMeta values with all-zeros hashes and just ignoring them entirely
as a temporary workaround.

This is a first step towards what is hopefully a more intuitive model:
authentication is an optional thing in a PackageMeta that is currently
populated only for packages coming from a registry.

So far this still just models checking a SHA256 hash, which is not a
sufficient set of checks for a real release but hopefully the "real"
implementation is a natural iteration of this starting point, and if not
then at least this interim step is a bit more honest about the fact that
Authentication will not be populated on every PackageMeta.
2020-04-06 16:31:23 -07:00
Pam Selle 6962562a78 Update diagnostic messages 2020-04-06 17:15:46 -04:00
Pam Selle 57c26fc11b Evaluate ModuleCallArguments using the appropriate ModuleInstance scope 2020-04-06 17:15:46 -04:00
Petros Kolyvas 9d1d8c0212 Merge branch 'contribution-codeowners' of github:pkolyvas/terraform into contribution-codeowners 2020-04-06 16:44:43 -04:00
Petros Kolyvas 02d67b8049 Merge branch 'contribution-codeowners' of github:pkolyvas/terraform into contribution-codeowners 2020-04-06 16:44:33 -04:00