Commit Graph

23373 Commits

Author SHA1 Message Date
Martin Atkins 39c3e7112f configs/configupgrade: Use break to cancel default function rendering
We're using break elsewhere in here so it was weird to have a small set
of situations that return instead, which could then cause confusion for
future maintenance if a reader doesn't notice that control doesn't always
leave the outer switch statement.
2018-12-04 11:37:39 -08:00
Martin Atkins 48f1245e6b configs/configupgrade: Replace lookup(...) with index syntax
If lookup is being used with only two arguments then it is equivalent to
index syntax and more readable that way, so we'll replace it.

Ideally we'd do similarly for element(...) here but sadly we cannot
because we can't prove in static analysis that the user is not relying
on the modulo wraparound behavior of that function.
2018-12-04 11:37:39 -08:00
Martin Atkins 4927a4105b configs/configupgrade: Replace calls to list() and map()
We now have native language features for declaring tuples and objects,
which are the idiomatic way to construct sequence and mapping values that
can then be converted to list, set, and map types as needed.
2018-12-04 11:37:39 -08:00
Martin Atkins 8cf024d45a configs/configupgrade: Upgrade expressions nested in HCL list/object
In the old world, lists and maps could be created either using functions
in HIL or list/object constructs in HCL. Here we ensure that in the HCL
case we'll apply any required expression transformations to the individual
items within HCL's compound constructs.
2018-12-04 11:37:39 -08:00
Martin Atkins e49d993d89 configs/configupgrade: Decide on blank lines by ends of items
Previously we were using the line count difference between the start of
one item and the next to decide whether to insert a blank line between
two items, but that is incorrect for multi-line items.

Instead, we'll now count the difference from the final line of the
previous item to the first line of the next, as best we can with the
limited position info recorded by the HCL1 parser.
2018-12-04 11:37:39 -08:00
Martin Atkins bdb724562c configs/configupgrade: Test that map attrs as blocks are fixed
The old parser was forgiving in allowing the use of block syntax where a
map attribute was expected, but the new parser is not (in order to allow
for dynamic map keys, for expressions, etc) and so the upgrade tool must
fix these to use attribute syntax.
2018-12-04 11:37:39 -08:00
Martin Atkins 1aa368d0d8 configs/configupgrade: Add some logging and enable it for tests 2018-12-04 11:37:39 -08:00
Martin Atkins e8999eefdc configs/configupgrade: Populate the test provider schema
This will allow us to test some schema-sensitive migration rules.
2018-12-04 11:37:39 -08:00
Martin Atkins 8e594f32aa configs/configupgrade: Upgrade rules for the "terraform" block type
This includes the backend configuration, so we need to load the requested
backend and migrate the included configuration per that schema.
2018-12-04 11:37:39 -08:00
Martin Atkins 302b29557f configs/configupgrade: Pass through diagnostics from body upgrades 2018-12-04 11:37:39 -08:00
Martin Atkins c755745285 configs/configupgrade: Generalize migration of block bodies
The main area of interest in upgrading is dealing with special cases for
individual block items, so this generalization allows us to use the same
overall body-processing logic for everything but to specialize just how
individual items are dealt with, which we match by their names as given
in the original input source code.
2018-12-04 11:37:39 -08:00
Martin Atkins cf52e224f6 configs/configupgrade: Basic migration of provider blocks
This involved some refactoring of how block bodies are migrated, which
still needs some additional work to deal with meta-arguments but is now
at least partially generalized to support both resource and provider
blocks.
2018-12-04 11:37:39 -08:00
Kristin Laemmert e3cecb7d56
format/state: added missing newline in the `outputs` output (#19542) 2018-12-04 11:37:22 -08:00
Andrey Arapov 98c8ac0862 vendor: update github.com/kardianos/osext
This adds support for some additional Go platforms.
2018-12-04 10:52:32 -08:00
James Bardin 7cec01a883
Merge pull request #19536 from hashicorp/jbardin/state-funcs
Handle StateFunc in plugin shims
2018-12-04 11:01:39 -05:00
James Bardin 924b97238f Handle StateFuncs in provider shim
Any state modifying functions can only be run once during the plan-apply
cycle. When regenerating the Diff during ApplyResourceChange, strip out
all StateFunc and CustomizeDiff functions from the schema.

Thew NewExtra diff field was where config data that was modified by a
StateFunc was stored, and needs to be maintained between plan and apply.

During PlanResourceChange, store any NewExtra data from the Diff in the
PlannedPrivate data, and re-insert the NewExtra data into the Diff
generated during ApplyResourceChange.
2018-12-03 18:12:02 -05:00
James Bardin 53ff35b9ca StateFunc tests 2018-12-03 18:03:45 -05:00
Kristin Laemmert 69c647c3dc
Merge pull request #19522 from hashicorp/mildwonkey/b-plan-msgpack
backend/local: decode variables with cty.DynamicPseudoType
2018-11-30 16:39:33 -08:00
Kristin Laemmert 67aa944166 backend/local: decode variables with cty.DynamicPseudoType
Variables values are marshalled with an explicit type of
cty.DynamicPseudoType, but were being decoded using `Implied Type` to
try and guess the type. This was causing errors because `Implied Type`
does not expect to find a late-bound value.
2018-11-30 15:15:28 -08:00
James Bardin 3dacdba678
Merge pull request #19521 from hashicorp/jbardin/prepare-provider-config
catch conversion errors in PrepareProviderConfig
2018-11-30 15:32:56 -05:00
James Bardin 5f9b189fcf catch conversion errors in PrepareProviderConfig
Errors were being ignore with the intention that they would be caught
later in validation, but it turns out we nee dto catch those earlier.

The legacy schemas also allowed providers to set and empty string for a
bool value, which we need to handle here, since it's not being handled
from user input like a normal config value.
2018-11-30 14:51:52 -05:00
Martin Atkins 12572e97bc core: Automatically upgrade resource instance states on read
If an instance object in state has an earlier schema version number then
it is likely that the schema we're holding won't be able to decode the
raw data that is stored. Instead, we must ask the provider to upgrade it
for us first, which might also include translating it from flatmap form
if it was last updated with a Terraform version earlier than v0.12.

This ends up being a "seam" between our use of int64 for schema versions
in the providers package and uint64 everywhere else. We intend to
standardize on int64 everywhere eventually, but for now this remains
consistent with existing usage in each layer to keep the type conversion
noise contained here and avoid mass-updates to other Terraform components
at this time.

This also includes a minor change to the test helpers for the
backend/local package, which were inexplicably setting a SchemaVersion of
1 on the basic test state but setting the mock schema version to zero,
creating an invalid situation where the state would need to be downgraded.
2018-11-30 11:22:39 -08:00
Martin Atkins a34eb4aa76 core: Remove some leftover dead code in ProviderSchema 2018-11-30 11:22:39 -08:00
Martin Atkins 72e279e6b2 providers: Consistently use int64 for schema versions
The rest of Terraform is still using uint64 for this in various spots, but
we'll update that gradually later. We use int64 here because that matches
what's used in our protobuf definition, and unsigned integers are not
portable across all of the protobuf target languages anyway.
2018-11-30 11:22:39 -08:00
Martin Atkins 2fd016738a core: NodePlanDeposedResourceInstanceObject populate EvalReadStateDeposed
The Provider field is required and will cause a panic if not populated.
2018-11-30 11:22:39 -08:00
Martin Atkins 444cb96b48 core: Reject provider schemas with version < 0
There's no reason for a negative version, so by blocking it now we'll
ensure that none creep in.

The more practical short-term motivation for this is that we're still
using uint64 for these internally in some cases and so this restriction
ensures that we won't run into rough edges when converting from int64 to
uint64 at those boundaries until we later fix everything to use int64
consistently.
2018-11-30 11:22:39 -08:00
Sander van Harmelen 5d3b9bdce1
Update CHANGELOG.md 2018-11-30 20:02:59 +01:00
Sander van Harmelen 97805d13fb
Merge pull request #19520 from hashicorp/svh/f-force-unlock
backend/remote: support the new force-unlock API
2018-11-30 19:57:12 +01:00
Sander van Harmelen fe05609c5e backend/remote: support the new force-unlock API
Add support for the new `force-unlock` API and at the same time improve
performance a bit by reducing the amount of API calls made when using
the remote backend for state storage only.
2018-11-30 19:39:18 +01:00
Sander van Harmelen 0e5587d091 go-mod: update go-tfe dependency 2018-11-30 19:39:18 +01:00
James Bardin 92e83e3bcf
Merge pull request #19514 from hashicorp/jbardin/computed-nil
expression with a computed nil
2018-11-29 17:43:46 -05:00
James Bardin 55a0a7d2f0 udpate go.mod and vendor 2018-11-29 15:23:38 -05:00
Chris Griggs 13e5d0fdad
Merge pull request #19502 from hashicorp/cgriggs01-patch-1
[Website] Updates path name
2018-11-29 10:05:22 -08:00
Chris Griggs 89347e9c81
Updates path name 2018-11-28 16:55:03 -08:00
Martin Atkins 61b923971f
Update CHANGELOG.md 2018-11-28 15:03:54 -08:00
James Bardin f0e51aca1a test a nil computed value within an expression
Comparing a nil-computed value was returning unknown, preventing the
data source from being evaluated.
2018-11-28 17:37:58 -05:00
Chris Griggs 4836dffd81
Merge pull request #19499 from cgriggs01/cgriggs01-rename
[Website] Provider name change "Selectel"
2018-11-28 14:13:02 -08:00
cgriggs01 c943083a4b selvpc -> selectel 2018-11-28 13:30:48 -08:00
Martin Atkins 30b7040e95 core: Validate module references
Previously we were making an invalid assumption in evaluating module call
references (like module.foo) that the module must exist, which is
incorrect for that particular case because it's a reference to a child
module, not to an object within the current module.

However, now that we have the mechanism for static validation of
references, we'll deal with this one there so it can be caught sooner.
That then makes the original assumption valid, though for a different
reason.

This is verified by two new context tests for validation:
  - TestContext2Validate_invalidModuleRef
  - TestContext2Validate_invalidModuleOutputRef
2018-11-28 13:19:57 -08:00
Kim Ngo 3794073963
Update CHANGELOG.md 2018-11-28 13:40:38 -06:00
Sander van Harmelen 68da173c93
Update CHANGELOG.md 2018-11-28 20:18:24 +01:00
Sander van Harmelen 4c878db8fd
Merge pull request #19464 from hashicorp/svh/f-context
backend/remote: implement the Local interface
2018-11-28 20:16:58 +01:00
Kim Ngo c7b495a938
Merge pull request #19494 from findkim/provider-alias
Use registry alias to fetch providers
2018-11-28 13:13:22 -06:00
findkim 5e06e39fcc Use registry alias to fetch providers 2018-11-28 11:54:39 -06:00
Daniel Schroeder 65080b9ce3 website: Fix redundant "be" in workspaces documentation 2018-11-28 07:59:37 -08:00
Martin Atkins 30497bbfb7 lang/funcs: zipmap accepts tuple of values and produces object
Now that our language supports tuple/object types in addition to list/map
types, it's convenient for zipmap to be able to produce an object type
given a tuple, since this makes it symmetrical with "keys" and "values"
such the the following identity holds for any map or object value "a"

    a == zipmap(keys(a), values(a))

When the values sequence is a tuple, the result has an object type whose
attribute types correspond to the given tuple types.

Since an object type has attribute names as part of its definition, there
is the additional constraint here that the result has an unknown type
(represented by the dynamic pseudo-type) if the given values is a tuple
and the given keys contains any unknown values. This isn't true for values
as a list because we can predict the resulting map element type using
just the list element type.
2018-11-28 07:45:43 -08:00
Sander van Harmelen 093cfacbcf
Update CHANGELOG.md 2018-11-28 16:31:50 +01:00
Sander van Harmelen a061725132
Merge pull request #19403 from hashicorp/svh/f-policies
backend/remote: also show policies when there are no changes
2018-11-28 16:30:31 +01:00
Martin Atkins 48b3612a30
Update CHANGELOG.md 2018-11-27 15:56:38 -08:00
Martin Atkins 8e14e5f33b
Update CHANGELOG.md 2018-11-27 15:56:15 -08:00