Commit Graph

26833 Commits

Author SHA1 Message Date
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
Pam Selle 81a6cde3cf
Merge pull request #26203 from hashicorp/pselle/deprecate-vendor-provisioners
Deprecate vendor (3rd party) provisioners
2020-09-15 13:52:10 -04:00
Alisdair McDiarmid b395887775
Update CHANGELOG.md 2020-09-15 10:04:49 -04:00
Alisdair McDiarmid e183163739
Merge pull request #25856 from remilapeyre/consul-split-state
Split the state in chunks when they outgrow the limit of Consul KV store
2020-09-15 10:00:25 -04:00
Alisdair McDiarmid aa8c73cd18 website: Credentials helper response for no creds
For a credentials helper plugin to be useful with Terraform 0.13+, we
need to cope with the case of having no credentials for a host without
this being an error. This is to allow the public Terraform Registry to
be accessed without supplying a token.

The way to implement this is to respond to queries for credentials for a
host which has no credentials stored with an empty object and a success
exit code. This contradicts the previous documentation, which calls for
an error response in this case.
2020-09-15 09:00:44 -04:00
Kristin Laemmert f5bce1bd39
terraform: refactor graphNodeImportState and graphNodeImportState (#26243)
EvalTrees

The import EvalTree()s have been replaced with Execute +
straight-through code, which let me remove eval_import_state.go.

graphNodeImportStateSub's Execute() function is still using the
old-style (not-refactored) calls to EvalRefresh and EvalWriteState;
those are being saved for a later refactor once all (or at least most)
of the EvalTree()s are gone.

I've added incredibly basic tests for both Execute() functions; they are
only enough to verify basics - the real testing happens in
context_import_test.go.
2020-09-14 16:53:37 -04:00
Brian Flad db2b710776
docs/function/timestamp: Mention Time Provider (#26232)
This utility Terraform Provider has resources designed to handle and store time information by participating normally in the graph.
2020-09-14 16:40:36 -04:00