Commit Graph

27220 Commits

Author SHA1 Message Date
Alisdair McDiarmid 0a5f2d9047
Merge pull request #26334 from hashicorp/alisdair/deprecate-nested-redundant-interpolation-expressions
configs: Deprecate nested redundant interpolations
2020-09-22 14:11:52 -04:00
Pam Selle 3ba38f9b1f (docs) Vendor provisioner deprecation version 2020-09-22 14:06:39 -04:00
Alisdair McDiarmid 13ed5af5c8 configs: Deprecate nested redundant interpolations
Previous deprecations only included direct assignment of template-only
expressions to arguments. That is, this was not deprecated:

locals {
  foo = ["${var.foo}"]
}

This commit uses hclsyntax.VisitAll to detect and show deprecations for
all template-only expressions, no matter how deep they are in a given
expression.
2020-09-22 13:40:08 -04:00
Alisdair McDiarmid 85ddb386ec
Merge pull request #26318 from hashicorp/alisdair/providers-schema-required-providers
command: Providers schema shows required_providers
2020-09-22 12:42:06 -04:00
James Bardin 87676358e7 update CHANGELOG.md 2020-09-22 10:57:47 -04:00
Alisdair McDiarmid 18f9ea53b9 command: Providers schema shows required_providers
The providers schema command is using the Config.ProviderTypes method,
which had not been kept up to date with the changes to provider
requirements detection made in Config.ProviderRequirements. This
resulted in any currently-unused providers being omitted from the
output.

This commit changes the ProviderTypes method to use the same underlying
logic as ProviderRequirements, which ensures that `required_providers`
blocks are taken into account.

Includes an integration test case to verify that this fixes the provider
schemas command bug.
2020-09-22 10:28:32 -04:00
James Bardin 906d399189 remove refresh!
Delete all the code associated with the Refresh walk
2020-09-22 10:27:45 -04:00
James Bardin 915d4e4b45
Merge pull request #26321 from hashicorp/jbardin/simplify-data-lifecycle
simplify data lifecycle
2020-09-22 10:27:16 -04:00
Justin Campbell 1554e04108
website: Add Registry email to publishing doc (#26327) 2020-09-22 10:26:29 -04:00
James Bardin 522df46d91 test output was incorrectly changed
Roll back this part of the change. The incorrect output never passed the
test.
2020-09-22 10:05:52 -04:00
James Bardin ab06f0c9f8 we can roll back the e2e tests
the data sources no longer show up in the tests
2020-09-22 09:55:19 -04:00
James Bardin 6039622111 Simplify data lifecycle for the no-refresh world
Now that we don't have to handle data sources that may or may not have
been updated during a refresh phase, and the plan phase can save the
data source to the refreshed state, we can remove a lot of the logic
involved in detecting whether the data source needs to be planned or
not.

When there is no separate refresh phase, we always must attempt to read
the data source during planning, and the only conditions are based on
having a known configuration, and not having any dependencies on which
we're waiting. If the data source is read during plan, we can now save
that directly to the refreshed state, and don't need to smuggle the
value as a change to be saved during apply.
2020-09-22 09:55:19 -04:00
James Bardin 921f36a361
Merge pull request #26317 from hashicorp/jbardin/remove-refresh-walk
Replace internal Refresh command with Plan
2020-09-22 09:54:24 -04:00
Paul Tyng 59e77685cb
Merge pull request #26326 from hashicorp/paultyng-patch-1
Minor instructions update for GPG key creation
2020-09-22 09:37:34 -04:00
Justin Campbell 45666f8216
website: Update Registry key management docs (#26299) 2020-09-22 09:37:26 -04:00
Paul Tyng 192c4337c3
Update publishing.html.md 2020-09-22 09:35:30 -04:00
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
James Bardin bc82347a04 fix tests
Update tests to match the new behavior. Some were incorrect, some no
longer make sense, and some just weren't setup to handle th plan api
calls.
2020-09-21 16:17:46 -04:00
James Bardin 4a6dac39a5 Use Plan instead of Refresh
Now that the planning process generates a refreshed state, and can
handle changes between the configuration and the state which the refresh
process cannot, we can use the plan for the refresh command.
2020-09-21 16:17:45 -04:00
James Bardin 8105096ec8 attach dependencies during plan
This was previously done during refresh alone, now we need to insert
these during the refresh portion of plan.
2020-09-21 16:17:45 -04:00
James Bardin c3182bd589 mock provider needs to return a valid response 2020-09-21 16:17:45 -04:00
James Bardin 3b3ff98356 Revert "fix show -json tests"
This reverts commit e54949f2e1.

Changes incorrectly applied to the planned state tests
2020-09-21 16:17:45 -04:00
James Bardin f222ed7479 write updated outputs to the refresh state
If we can evaluate a new output value during plan, write it to the
refreshed state as well.
2020-09-21 16:17:45 -04:00
James Bardin 7951b55f88 remove planned resources from refreshed state 2020-09-21 16:17:45 -04:00
kmoe f12bb4698e
remove link to deprecated provider 2020-09-21 17:04:46 +01: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