Commit Graph

26739 Commits

Author SHA1 Message Date
Alisdair McDiarmid 48bedb0321
Update CHANGELOG.md 2020-09-22 09:09:04 -04:00
Arthur Burkart 6ed47c7241
lang/funcs: Add "alltrue" function (#25656)
This commit adds an `alltrue` function to Terraform configuration. A
reason we might want this function is because it will enable more
powerful custom variable validations. For example:

```hcl
variable "amis" {
  type = list(object({
    id = string
  }))

  validation {
    condition = (alltrue([
      for a in var.amis : length(a.id) > 4 && substr(a.id, 0, 4) == "ami-"
    ]))
    error_message = "The ID of at least one AMI was invalid."
  }
}
```
2020-09-22 09:06:42 -04:00
James Bardin 7222bad59c update CHANGELOG.md 2020-09-21 21:19:13 -04:00
James Bardin abf30de16e
Merge pull request #26284 from hashicorp/jbardin/data-resource-reference
delay data source reads with pending resource ref
2020-09-21 16:34:19 -04:00
Martin Atkins 72aea4bc64
Update CHANGELOG.md 2020-09-18 15:31:57 -07:00
James Bardin 8b31808843 delay data source reads with pending resource ref
Treat any reference from a data source to a managed resource as a
dependency on the entire resource. While a resource's
attribute may be statically resolvable from the configuration, if the
user added a reference to that resource, it stands to reason that the
user intended there to be a dependency which we need to wait on.

This is an extension of an implicit behavior that existed previously in
Terraform, but was lost in the 0.13 release. That behavior was emergent
from the fact that the Refresh walk did not process the configuration
for managed resources, so any new resources in the config would be
evaluate as entirely unknown during Refresh, even if some attributes
were statically resolvable at that point.

This new implementation restores the old behavior, and extends it to
updates and replacements of the referenced resource.
2020-09-18 09:10:45 -04:00
James Bardin 6d7904c17b
Merge pull request #26285 from hashicorp/jbardin/save-refreshed-data
save read data in the refresh state during plan
2020-09-18 08:52:13 -04:00
James Bardin 669da06515 saved read data in the refresh state during plan
This only changes the refreshed state stored in the plan file. Since the
change is stored in the plan, the applied result would be the same, but
we should still store the refreshed data in the plan file for tools that
consume the plan file.

This will also be needed in order to implement a new refresh command
based on the plan itself.
2020-09-17 17:12:10 -04:00
Alisdair McDiarmid e77c367345
Merge pull request #26273 from hashicorp/alisdair/sensitive-variable-plan-tests
Extend sensitive variable plan tests
2020-09-17 12:07:17 -04:00
James Bardin 4295f1e1e3
Merge pull request #26270 from hashicorp/jbardin/refresh-plan
Move resource refreshing into plan
2020-09-17 10:19:33 -04:00
James Bardin 86dd8938c9 data sources now show up in the initial plan 2020-09-17 09:55:00 -04:00
James Bardin 312317abd0 wrong instance key in test state
This was never picked up by the tests until now
2020-09-17 09:55:00 -04:00
James Bardin 8658424059 skip plan with no refresh test
We still need to determine if `-refresh=false` is even useful with the
new planning strategy.
2020-09-17 09:55:00 -04:00
James Bardin f52d836e0a fix local backend tests to match new behavior
Leaving plan with -refresh=false tests failing for now.
2020-09-17 09:55:00 -04:00
James Bardin 88509de7db remove Refresh steps from legacy provider tests
Update the old acceptance test framework just enough to make the tests
pass.
2020-09-17 09:55:00 -04:00
James Bardin 19d67b7606 don't leave old refreshed state in the context
After apply, any refreshed state from a plan would be invalid. Normal
usage doesn't ever see this, bu internal tests may re-use the context.
2020-09-17 09:55:00 -04:00
James Bardin e54949f2e1 fix show -json tests
The prior state recorded in the plans did not match the actual prior
state. Make the plans and state match depending on whether there was
existing state or not.
2020-09-17 09:55:00 -04:00
James Bardin ad5899d8bb ReadResource is called during plan but not destroy 2020-09-17 09:55:00 -04:00
James Bardin 1fa3503acd fixup last tests that need correct state 2020-09-17 09:54:59 -04:00
James Bardin d19f440d81 contexts have a copy of the state
We need to build a new context go get at the modified state
2020-09-17 09:54:59 -04:00
James Bardin a3c9d7abc1 update comments around evaluating 0 instances 2020-09-17 09:54:59 -04:00
James Bardin ced7aedeca fixup count transition for refresh state
We need to do this for both states during plan
2020-09-17 09:54:59 -04:00
James Bardin 7d6472dad0 use plan state in contextOptsForPlanViaFile 2020-09-17 09:54:59 -04:00
James Bardin 908217acc4 try refreshing during plan as the default
This breaks a bunch of tests, and we need to figure out why before
moving on.
2020-09-17 09:54:59 -04:00
James Bardin 5cf7e237d5 return the refreshed state in the Plan result 2020-09-17 09:54:59 -04:00
James Bardin 8cef62e455 add state to plans.Plan
Since the refreshed state is now an artifact of the plan process, it
makes sense to add it to the Plan type, rather than adding an additional
return value to the Context.Plan method.
2020-09-17 09:54:59 -04:00
James Bardin 7b178b1788 add a way to selectively write to RefreshState
All resources use EvalWriteState to store their state, so we need a way
to switch the states when the resource is refreshing vs when it is
planning. (this will likely change once we factor out the EvalNode pattern)
2020-09-17 09:54:59 -04:00
James Bardin ad22e137e6 Get the new RefreshState into the right contexts 2020-09-17 09:54:59 -04:00
James Bardin d6a586709c Add RefreshState to the eval context
Since plan uses the state as a scratch space for evaluation, we need an
entirely separate state to store the refreshed resources values during
planning. Add a RefreshState method to the EvalContext to retrieve a
state used only for refreshing resources.
2020-09-17 09:54:59 -04:00
James Bardin be757bd416 Refresh instances during plan
This change refreshes the instance state during plan, so a complete
Refresh no longer needs to happen before Plan.
2020-09-17 09:54:59 -04:00
Kristin Laemmert 02fb28eeae
build: put codecov in informational mode (#26271)
While we like codecov, and the coverage goals, we've frequently ignored
the failures for various reasons. These have confused community members
submitting PRs and it can be confusing to look at a list of merged PRs
with the big X indicating failed checks ("confusing" isn't really a
problem, but if there were actually a bad merge, it could be hard to
find which in a list of commits actually had an important failure).

Fixes a mild inconvenience.
2020-09-17 08:13:50 -04:00
Alisdair McDiarmid e1a41daf9b terraform: Test sensitive values in module inputs
Passing a sensitive value as a module input variable should preserve its
sensitivity for the plan.
2020-09-16 16:54:04 -04:00
Alisdair McDiarmid 9e340ab85b terraform: Expand sensitive variable plan test
Test that the changes which use the sensitive variable have
corresponding path value marks. Also remove the unrelated validate
function from this test.
2020-09-16 16:48:28 -04:00
Alisdair McDiarmid 803c95e552
Merge pull request #26105 from hashicorp/alisdair/more-interpolation-only-expression-deprecations
configs: More interpolation-only expr deprecations
2020-09-16 16:06:45 -04:00
Kristin Laemmert 67d441b131
terraform: refactor ProviderEvalTree (#26236)
* remove leftover debug line

* terraform: refactor ProviderEvalTree

This PR refactors the ProviderEvalTree by folding the entire tree into
straight-through code in NodeApplyableProvider Execute (formally
EvalTree). The EvalConfigProvider functions were refactored into
NodeApplyableProvider functions (since that was the only place they were
used).

I also removed the unused node_provider_disabled code.

* revert removal of graphNodeCloseProvider EvalTree, replace with Execute
2020-09-16 12:17:17 -04:00
Alisdair McDiarmid 150702c100
Update CHANGELOG.md 2020-09-16 11:51:17 -04:00
Alisdair McDiarmid b5ef33b715
Merge pull request #26239 from jceresini/master
Add support for scopes to terraform login
2020-09-16 11:50:01 -04:00
Alisdair McDiarmid 3c6239f4c5
Merge pull request #26244 from hashicorp/alisdair/credentials-helper-no-credentials
website: Credentials helper response for no creds
2020-09-16 11:36:43 -04:00
James Bardin 696290e481
Merge pull request #26264 from hashicorp/jbardin/evaluate-destroy
allow evaluation of 0 instances during apply
2020-09-16 11:35:33 -04:00
Kristin Laemmert 55d58cb8be
terraform: NodeDestroyResourceInstance refactor (#26246)
* terraform: remove unused eval node

* add UpdateStateHook function to replace EvalUpdateStateHook

* early exit error isn't

* terraform: NodeDestroyResourceInstance refactor

This PR refactor's NodeDestroyResourceInstance EvalTree() into an
Execute() node. EvalRequireState and evalWriteEmptyState were used only
by this node, and they have been removed in favor of straight code.

There are still many calls to someEvalNode.Eval() in NodeDestroyResourceInstance: I plan on refactoring the remaining EvalTree()s before tacking those Eval()s (all of which are used by many graph nodes)

I've added a new function, UpdateStateHook, that is effectively the same
as EvalUpdateStateHook. The latter will be removed when the larger
EvalNode refactor project is complete.
2020-09-16 11:33:55 -04:00
Kristin Laemmert f64d5b237c
terraform: refactor nodeModuleVariable and NodeRootVariable EvalTree()s (#26245)
EvalModuleCallArguments is now a method on nodeModuleVariable, it's only
caller, and the other functions have been replaces with straight through
code (or in the case of evalVariableValidations, a standalone function).

I was unable to add tests for nodeModuleVariable.Execute, which requires
fixtures that aren't part of the MockEvalContext (a scope.evalContext is
one); it's not ideal but that function should be well covered by the
context tests so I chose to leave it as-is.

Finally, I removed the unused function hclTypeName. Deleting code is
fun!
2020-09-16 11:32:48 -04:00
James Bardin 5c69cf0851
Merge pull request #26263 from hashicorp/jbardin/cbd-from-state
always check the CreateBeforeDestroy value from state
2020-09-16 11:32:29 -04:00
James Bardin 7156649336 allow evaluation of 0 instances during apply
While this was easier to spot during plan, it is also possible to
evaluate resources with 0 instances during apply as well.

This doesn't effect the failure when scaling CBD instances, it only
changes the fact that the inconsistent value is no longer unknown.
2020-09-16 11:18:23 -04:00
James Bardin a6dffa89a3 cleanup unused CBD code
Remove the check for CreateBeforeDestroyOverride which can't happen in a
destroy node.

Remove the unnecessary GraphNodeAttachDestroyer interface, since we
don't use it now that plans can record the create+destroy order.
2020-09-16 11:14:36 -04:00
James Bardin 67fd32db7e improve failing test
Correct the initial test state, and expand the test to cause a cycle
without the previous fix.
2020-09-16 10:38:41 -04:00
James Bardin 2ea921f915 destroy nodes must rely on the state cbd status
When there is only a destroy node, there is no descendent to check for
"forced CBD", so we can only rely on the state to verify.
2020-09-16 09:52:48 -04:00
Joe Ceresini 04b39372b0 Add scopes support to password grant type 2020-09-15 19:32:41 -04:00
Joe Ceresini 2ffa84a4de Add command/login test for scopes 2020-09-15 19:30:48 -04:00
Kristin Laemmert 7b2f66c403
Update CHANGELOG.md 2020-09-15 14:21:18 -04:00
Kristin Laemmert acd8230013
vendor: upgrade go-userdirs library to fix openBSD crash (#26249)
Fixes #26175
2020-09-15 14:14:25 -04:00