Commit Graph

25733 Commits

Author SHA1 Message Date
James Bardin 92837e6296 return unknown module expansions during validate
There is no expansion during validation, so in order for module
references to work we need to ensure that the returned values are
unknown.
2020-04-20 10:20:55 -04:00
James Bardin d152d13bea fix error output in repl test
The module error is unfortunately less specific at the moment, but
change the error text here to match.
2020-04-14 14:50:43 -04:00
James Bardin 42cee86ee2 remove GetModuleInstanceOutput
There is no codepath that can use this any longer, since we need to
evaluate the modules as whole objects.

This means we're going to have to live for now with invalid module
output references returning "object" errors rather that "module".
2020-04-14 14:49:10 -04:00
James Bardin ad069b7416 update evaluation to use state ModuleOutputs
This way we don't need the extra copy of the entire module.
2020-04-14 14:49:10 -04:00
James Bardin 2c4c027a97 Add ModuleOutputs method to states
In order to efficiently build the module objects for evaluation, we need
to collect the outputs from a set of module instances. The ModuleOutputs
method will return a copy of the state outputs, while not requiring the
unnecessary copying of each entire module.
2020-04-13 17:59:09 -04:00
James Bardin e9eb8e04cc add AbsOutputAddrs to state outputs
We need all module instance outputs to build the objects for evaluation,
but there is no need to copy all the resource instances along with that.
This allows us to only return the output states, with enough information
to connect them with their module instances.
2020-04-13 16:37:59 -04:00
James Bardin 27cc2aeb9c change evaluation to use whole modules
The evaluationStateData needs the change to the GetModule method to work
with the new evaluator. This is using a deep copy of module instances,
which we will clean up after some changes to the states package.
2020-04-13 16:23:24 -04:00
James Bardin 323d9fb69f plans fix 2020-04-13 16:21:09 -04:00
James Bardin 2490e6c84b provide a method to get all modules changes
Since modules need to be evaluated as whole objects, yet the outputs are
all handled individually, we need a method to collect and return all
output changes for a module from the plan, including all known
module instances.
2020-04-12 11:29:21 -04:00
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
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
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
Petros Kolyvas e760927408
Update .github/CONTRIBUTING.md
Co-Authored-By: Pam Selle <pamela.selle@gmail.com>
2020-04-06 16:43:46 -04:00
Petros Kolyvas e92b8a82f4 Pam & Kristin's feedback & some more suggested changed. 2020-04-06 16:43:11 -04:00
Petros Kolyvas 783c06b6da
Kristin's corrections
Co-Authored-By: Kristin Laemmert <mildwonkey@users.noreply.github.com>
2020-04-06 13:25:17 -04:00
James Bardin b1532c0f04 make the module closer referenceable
This is all that is required to make module reference ordering work
during apply, by adding and edge to the nodeCloseModule node, which will
be the last node evaluated in the module.
2020-04-06 13:04:24 -04:00