Commit Graph

25503 Commits

Author SHA1 Message Date
James Bardin f0e175a835 add AbsResource.Config() ConfigResource 2020-03-16 11:16:23 -04:00
James Bardin 42f7beff31
Merge pull request #24296 from hashicorp/pselle/module-targetable
Make modules targetable
2020-03-16 11:16:05 -04:00
James Bardin e6bac359ed Missing ConfigResource checks in TargetContains
Adding some missing checks for ConfigResource, and check all
combinations of Resource types for consistency.
2020-03-13 19:01:23 -04:00
James Bardin e3ad9ffb77 added module targetting tests 2020-03-13 09:19:27 -04:00
James Bardin bf91bff2c8 TargetContains improvements
Simplify Module.TargetContains

Handle the case of a keyed instance address in
ModuleInstance.TargetContains.
2020-03-13 09:08:42 -04:00
Pam Selle 076c540076 Add a test for whole module targeting 2020-03-13 09:08:42 -04:00
Pam Selle 7407fee9c2 Make modules targetable 2020-03-13 09:08:42 -04:00
James Bardin 50077eabe9
Merge pull request #24362 from hashicorp/jbardin/module-expansion-some-more
implement addrs.ConfigResource
2020-03-13 09:08:26 -04:00
James Bardin d65bd64955 incorporate addrs.ConfigResource 2020-03-12 15:58:25 -04:00
James Bardin 9054716caf implement addrs.ConfigResource
Core needs a way to address resources through unexpanded modules, as
they are present in the configuration. There are already some cases of
paring `addrs.Module` with `addrs.Resource` for this purpose, but it is
going to be helpful to have a single type to describe that pair, as
well as have the ability to use TargetContains.
2020-03-12 15:58:25 -04:00
James Bardin 482ae66e18 minor cleanup
Remove unused variables, sync.Once, and init in BuiltinEvalContext.
Replace some shim calls.
GraphNodeAttachProvider doesn't need to be a NodeModuleInstance.
2020-03-12 14:54:47 -04:00
Martin Atkins 946eda3f3c configs: Return diagnostics (almost) directly from ParseProviderSourceString
This function can already produce suitable diagnostic messages which we'd
like to preserve, but it cannot produce source location information, and
so we'll amend the diagnostics to include that on the way out while
retaining all of the other values in the diagnostics.
2020-03-12 11:11:29 -07:00
Martin Atkins a851566c56 tfdiags: Diagnostics.ToHCL
Most of the time we're converting from HCL diagnostics to tfdiags as we
expose diagnostics directly from HCL, but occasionally we need to to the
reverse.

For example, our configs package uses hcl.Diagnostics by convention
because it's primarily working with HCL, but sometimes it interacts with
functions elsewhere (like in the "addrs" package) that return
tfdiags.Diagnostics, where they need to be adapted to return in an HCL
shape.

This should be used with some care because, similar to Diagnostics.ForRPC,
it forces immediate flattening of all of the diagnostics to a single
type and so can potentially lose internal tracking information that
appears in other tfdiags.Diagnostic information, such as the additional
metadata tracked in the ConsolidateWarnings result to allow later
appending to existing groups.
2020-03-12 11:11:29 -07:00
Kristin Laemmert 1c78b26012
terraform: provider source test (#24342)
* configs: parse provider source string during module merge

This was the smallest unit of work needed to start writing provider
source tests!

* Update configs/parser_test.go

Co-Authored-By: Alisdair McDiarmid <alisdair@users.noreply.github.com>
2020-03-12 12:00:00 -04:00
James Bardin 4a1ec05092 comment fixes 2020-03-11 14:52:15 -04:00
James Bardin 33464568e8
Merge pull request #24346 from hashicorp/jbardin/module-expansion-another-part
Continue pushing the Path calls out of the Resource and Provider types
2020-03-11 14:32:23 -04:00
James Bardin e13eecbc5b finish provider ModuleInstance replacement 2020-03-11 14:19:52 -04:00
James Bardin 98cfb51f27 convert /terraform to use new provider config
Change all ModuleInstances in provider types to plain Modules
2020-03-11 11:21:45 -04:00
James Bardin 856791ec7e
Merge pull request #24331 from hashicorp/jbardin/module-expansion-in-part
More module expansion groundwork
2020-03-11 11:10:02 -04:00
James Bardin 1252726cda update CHANGELOG.md 2020-03-11 10:31:41 -04:00
James Bardin f6221100ee
Merge pull request #24149 from mlafeldt/fix-oss-state-locking
Fix & improve state locking of OSS backend
2020-03-11 10:28:12 -04:00
James Bardin 8497adcb6e AbsProviderConfig to use addrs.Module
Change ModuleInstance to Module in AbsProviderConfig, because providers
need to be handled before module expansion, and should not be used
defined inside an expanded module at all.

Renaming of the addrs type can happen later, when there's less work
in-flight around provider configuration.
2020-03-10 20:25:44 -04:00
James Bardin fae5f9958d remove GraphNodeModuleInstance from Resource types
Remove the requirement for most *Resource types to be a
GraphNodeModuleInstance, ensuring that they never call ctx.Path while
being evaluated. This gets rid of most of the direct need for the Path
method currently implemented by NodeResourceAbstract, leaving the
provider and schema related calls for a subsequent PR.
2020-03-10 20:22:22 -04:00
James Bardin 68b500c5c7 remove abs addrs from NodeAbstractResource
This adds more shimming into that node itself, but allows us to pull it
out of the config transformer, and ensure we can create the resources
correctly from the config. The shimmed address usage can then be raised
out of the abstract resource, into the expanded node types.
2020-03-10 17:25:11 -04:00
James Bardin 245296850b fix reference transformer comments
GraphNodeSubPath/GraphNodeModuleInstance is not required for references
2020-03-10 17:25:11 -04:00
James Bardin ab9a2935ce implement NodePlannableLocal
Using this in the same manner as NodePlannableOutput, which expands the
local values within modules. All thee output and local types are used in
both plan and apply, we may rename these to better reflect their usage
in expanding. That wait until we are certain that apply won't need any
extra machinery for handling values that aren't stored in the plan.
2020-03-10 17:25:11 -04:00
James Bardin 67e06f4fbe remove more UnkeyedInstanceShim
planning variables and outputs no longer needs module instances
2020-03-10 17:25:11 -04:00
James Bardin 87776913c6 nodeExpandModule doesn't need a Path() method
Unexpanded nodes can't implement GraphNodeModuleInstance (nee
GraphNodeSubPath), because they aren't aware how they have been
expanded, and may be in multiple distinct paths.

Since that means the EvalContext won't be in the correct path during the
walk, we just have to ensure that we don't use `ctx.Path()` inside Eval.
2020-03-10 17:25:11 -04:00
James Bardin a104ecb69d GraphNodeExpand is not used 2020-03-10 17:25:11 -04:00
James Bardin be2629d2f9 GraphNodeSubPath -> GraphNodeModuleInstance 2020-03-10 17:25:11 -04:00
James Bardin 215f60d5cf remove module shims from module expansion nodes 2020-03-10 17:25:11 -04:00
James Bardin 6ae9013c3f add addrs.Module.Equal
Mirror the addrs.ModuleInstance.Equal method
2020-03-10 17:25:11 -04:00
James Bardin bd9cfca794 rename GraphNodeSubPath -> GraphNodeModuleInstance 2020-03-10 17:25:11 -04:00
James Bardin b1df763541 remove UnkeyedInstanceShim from ref transformer
Since references are always within the scope of a single module, and we
can connect all module instance outputs for proper ordering, the
existing transformer works directly with only module paths as opposed to
module instances.

TODO: TransformApplyReferences for more precise module instance
targeting?
2020-03-10 17:25:11 -04:00
James Bardin 521bdcc241 implement GraphNodeModulePath
GraphNodeModulePath is similar to GraphNodeSubPath, except that it
returns an addrs.Module rather than an addrs.ModuleInstance. This is
used by the ReferenceTransformer to connect references, when modules may
not yet be expanded.

Because references only exist within the scope of a module, we can
connect everything knowing only the module path. If the reference is to
an expanded module instance output, we can still properly order the
reference because we'll wait for the entire module to complete
evaluation.
2020-03-10 17:25:11 -04:00
James Bardin 51bdcbb48c
Merge pull request #24341 from hashicorp/jbardin/cbd-test-fix
fix a flapping test involving CreateBeforeDestroy
2020-03-10 17:21:05 -04:00
Kristin Laemmert 5901952882
command: tests should not leave dirs behind thank you (#24340) 2020-03-10 16:32:22 -04:00
James Bardin cb99dddb4d fix a flapping test involving CreateBeforeDestroy
A typo in the config caused it to disagree with the plan on whether a
resource should be CreateBeforeDestroy, preventing it from being ordered
properly. Add the new CreateBeforeDestroy field to the test fixture
state as well for completeness.
2020-03-10 16:16:50 -04:00
Kristin Laemmert c7cc0afb80
Mildwonkey/ps schema (#24312)
* add Config to AttachSchemaTransformer for providerFqn lookup
* terraform: refactor ProvidedBy() to return nil when provider is not set
in config or state
2020-03-10 14:43:57 -04:00
Pam Selle ca26efc5af
Update CODEOWNERS 2020-03-10 14:10:38 -04:00
Pam Selle 7bd0071719
Update CODEOWNERS 2020-03-10 14:10:27 -04:00
Chris Griggs 40f2511629
Merge pull request #24335 from hashicorp/cgriggs01-vmc-links
[Website] vmc provider links
2020-03-10 11:07:21 -07:00
Chris Griggs 822f608a3c [Website] vmc provider links 2020-03-10 08:59:20 -07:00
Kristin Laemmert add16fc67b
jsonstate: sort child modules by address for consistency (#24329)
* jsonstate: sort child modules by address for consistency
2020-03-09 15:57:14 -04:00
Alisdair McDiarmid ff3895ea26 Set Codecov threshold to 0.05% to avoid flicker
We have some non-deterministic tests which flap the coverage up and down
slightly, but that should not set a failing status on PRs. This commit
sets a threshold of 0.5% coverage change to prevent this.
2020-03-09 14:56:30 -04:00
James Bardin 654e880bb8
Merge pull request #24084 from hashicorp/jbardin/cbd-instance-state
Add CreateBeforeDestroy to instance state
2020-03-09 13:16:29 -04:00
Alisdair McDiarmid 94d7236cd4
Merge pull request #24313 from hashicorp/alisdair/fix-coverage-blips-in-statemgr-filesystem
states: Fix coverage blips in statemgr/filesystem
2020-03-09 09:27:45 -04:00
Paddy 1b5e2b70c6
Update CHANGELOG.md 2020-03-06 15:37:02 -08:00
Alisdair McDiarmid f54e2a62bf states: Fix coverage blips in statemgr/filesystem
Something non-deterministic in the test suite is causing a coverage blip
in a line in the filesystem state manager. This commit adds a test which
specifically covers that line, which hopefully pleases the Codecov robot.
2020-03-06 17:55:28 -05:00
Kristin Laemmert 6118d22c1f
terraform: refactor ProvidedBy() to return an addrs.ProviderConfig interface (#24295)
* terraform: refactor ProvidedBy() to return an addrs.ProviderConfig
interface

This refactor allows terraform to indicate whether a specific provider
configuration was found for the resource or if it is instead returning
the assumed default.

With that additional information the provider transformer can check if
there is a specific (non-default) provider FQN.
2020-03-06 08:33:44 -05:00