Commit Graph

24371 Commits

Author SHA1 Message Date
Kristin Laemmert e697e7d733 port compact function 2018-10-16 18:49:20 -07:00
Kristin Laemmert 1901d5d184 port coalescelist function 2018-10-16 18:49:20 -07:00
Kristin Laemmert 04ac87747c base64decode: check that the decoded (not encoded) string is valid UTF-8 2018-10-16 18:49:20 -07:00
Martin Atkins 153021dd08 core: NewResourceConfigShimmed not to crash without schema
Although there isn't really a good reason why there should be no schema
in practice, it's better for us not to crash right now while we're still
updating all of the callers (mostly tests) to make schema available.
2018-10-16 18:49:20 -07:00
James Bardin c6b2799ee9 add "unknown" computed attribute
Having a compute value of "unknown" will trigger the testDifFn to always
insert a computed value to cause an unknown value suring apply
2018-10-16 18:49:20 -07:00
James Bardin edacd9ff4d add Provider schema to the contextFixture 2018-10-16 18:49:20 -07:00
James Bardin 672221e38e it is valid to have no provider config 2018-10-16 18:49:20 -07:00
Martin Atkins fe105bfc3f core: Fix TestContext2Input_submoduleTriggersInvalidCount
This test now needs to provide a mock schema so its fixture can assign
to the "foo" argument in null_data_source.
2018-10-16 18:49:20 -07:00
Martin Atkins 93ff9f4233 core: Fix TestContext2Input_submoduleTriggersInvalidCount
Its fixture was using a module variable called "count", and that name is
now reserved.
2018-10-16 18:49:20 -07:00
Martin Atkins e7cfbb9737 core: Fix TestContext2Input_hcl
This test now needs to provide a mock schema for its resource type so that
the two test arguments can be assigned.
2018-10-16 18:49:20 -07:00
Martin Atkins b6fe705985 core: fix buggy test TestContext2Input_providerMulti
This was trying to test gathering input from a default and an alias
provider configuration, but it was incorrectly setting the provider ref
on the instance that was supposed to belong to the alias. This was working
before because Terraform would gather input from the aliased provider
anyway, but now the invalid "alias" argument in the resource is producing
a validation error.

This doesn't actually make the test work again yet, because we still have
provider input disabled at this time, pending a forthcoming change to
how provider input is handled.
2018-10-16 18:49:20 -07:00
Martin Atkins f65f51c023 core: fix syntax of input-bad-var-default test fixture
This was incorrectly using block syntax to assign a value to the "default"
attribute.
2018-10-16 18:49:20 -07:00
Martin Atkins 6cf4835714 core: Fix output from context input tests
The previous test output made it hard to understand what was going on when
a test failed. We'll now produce more verbose output.
2018-10-16 18:49:20 -07:00
Martin Atkins 74873838e0 core: Fix TestContext2Input
This test was previously not setting InputModeVarUnset, causing us to
overwrite the "amis" map that _is_ already set. This worked before because
we used to treat the empty result as an empty map and then merge it with
the given value, but since we no longer do that merging behavior we were
ending up with an empty map after input.

Since the intent of this test is to see that the "foo" variable gets
populated by input, here we add InputModeVarUnset which then matches how
the input walk is triggered by the "real" codepath in the local backend.

This also includes some updates to make the test fixture v0.12-idiomatic
(applied after it was seen to work with the old fixture) and to properly
handle the "diags" return value from the various context methods.
2018-10-16 18:49:20 -07:00
Martin Atkins 1b55f09891 core: remove redundant rule lines in BasicGraphBuilder logs
The "------" is useful when we produce the multi-line graph description,
but just adds noise when we're showing "(no changes)".
2018-10-16 18:49:20 -07:00
Martin Atkins 7673a0d850 core: Include "id" attribute in schema for cbd depends datasource test
This attribute is referenced in order to include a computed value into
another resource, and so it must be present in the schema so that it can
be properly resolved.
2018-10-16 18:49:20 -07:00
Martin Atkins 588f4930f2 core: Rename typoed fixture for TestContext2Plan "CBD" test
The intent here was for this to be "cbd" for "create_before_destroy", but
it was typoed.
2018-10-16 18:49:20 -07:00
Martin Atkins dd6b171f62 core: Make provisioner schemas available to plan resource instance nodes
This requires making the "components" object available to the resource
node so it can be used during DynamicExpand. It also involved splitting
the provisioner schema attachment into a separate interface from
GraphNodeProvisionerConsumer so that it can now be handled within
AttachSchemaTransformer, along with all of the other schema attachment
steps.
2018-10-16 18:49:20 -07:00
Martin Atkins 559f65bf3d core: Fix ignore_changes = all
The initial rework of this function to support traversals didn't correctly
handle the "all" case, due to a logic error where the ignoreAll branch
could be visited only if ignoreChanges were non-empty, but yet the two
are mutually exclusive in practice.

Now we process ignoreAll separately from ignoreChanges, and invert the
two loops so that we will visit all attributes regardless of what is
in the ignoreChanges slice.
2018-10-16 18:49:20 -07:00
Martin Atkins 3f4b7f847d core: Fix TestContext2Plan_ignoreChangesWithFlatmaps
Prior to our v0.12 changes this test was confusingly using an attribute
named "set", but assigning a map to it. The expected test result suggested
that it was actually expecting legacy HCL2's weird interpretation of a
single map as a list of maps, and so to retain the intent of the test here
(in spite of the contrary name) we type "set" as list of map of string,
update the fixture to _actually_ be a list of maps, and then we get the
expected test result.
2018-10-16 18:49:20 -07:00
James Bardin c6787d0266 update test fixtures
Update test fixtures to work in our new world.
This is mostly changing out attribute names for those in the schema,
adding Providers to states, and updating the test-fixture
configurations.
2018-10-16 18:49:20 -07:00
James Bardin d0693d0db5 fix InstanceInfo.HumanId
The module no longer has a "root" component, and use the
normalizeModulePath function for consistency
2018-10-16 18:49:20 -07:00
Martin Atkins b8df11bc33 govendor fetch github.com/hashicorp/hcl2/...
This includes an upstream fix to the hcldec.Variables function that fixes
its behavior when dealing with specs that contain DefaultSpec, and other
similar wrapper specs.
2018-10-16 18:49:20 -07:00
Kristin Laemmert 74f2d58b8b base64decode: check that the decoded (not encoded) string is valid UTF-8 2018-10-16 18:49:20 -07:00
Kristin Laemmert 6171ba3b8a base64decodeFunc now checks for valid UTF-8 2018-10-16 18:49:20 -07:00
Martin Atkins f8a8f26c0d govendor fetch github.com/zclconf/go-cty/cty/...
This includes upstream fixes, and in particular a converter for going
between map types with different element types.
2018-10-16 18:49:20 -07:00
Martin Atkins d9a26bae26 govendor fetch github.com/hashicorp/hcl2/...
This includes a number of upstream fixes, but in particular fixes a race
on evaluating the same splat expression concurrently for multiple separate
EvalContexts.
2018-10-16 18:49:20 -07:00
Martin Atkins d236a9e4cd core: update TestContext2Plan_computedList for changed assumptions
Previously this test's fixture was depending on the fact that attribute
access of an unknown value would always succeed and return another unknown
value, but under the new language interpreter an unknown value still
retains type information and so accessing this "bar" attribute would fail
the semantic check.

We also have to fuss a bit here to work around the limitations of the
testDiffFn implementation, which doesn't have enough context to understand
that "list" in the ResourceConfig is the same as "list.#" in its result.
Since this part of the provider API will change soon to use cty values
directly, this change just accepts a slightly-odd-looking diff in the mean
time, with both "list" and "list.#" populated.
2018-10-16 18:49:20 -07:00
Kristin Laemmert b6d3d69d3a port cidr functions 2018-10-16 18:49:20 -07:00
Martin Atkins ebef145980 core: Update expected error message for plan countComputedModule test
Previously we only handled the "count cannot be computed" check during
validate, leaving other walks to just report "a number is required"
(because "unknown" was represented as a special string) but now we have
unknown as first-class we handle it during all walks, and so this error
message is now the more appropriate one saying that the value is not
yet known.
2018-10-16 18:49:20 -07:00
Kristin Laemmert 10ef61c71c porting many functions 2018-10-16 18:49:20 -07:00
Martin Atkins 083ea05295 core: Context plan tests update for "count" behavior change
The behavior of the "count" meta-argument has changed so that its presence
(rather than its value) chooses whether the associated resource has
indexes. As a consequence, these tests which set count = 1 now produce
a single indexed instance with index 0.
2018-10-16 18:49:20 -07:00
Martin Atkins 0ac663bb2b core: context plan tests update wanted output for new behavior
Previously Terraform Core was unaware of the structure of a resource type
schema and so the strange behavior of our testDiffFn caused some
attributes to not appear at all in the result. With core now more aware,
it "fills in" these missing items before calling, and as a result they
now appear in the diff even with the testDiffFn.

In real code, where helper/schema is constructing diffs, this situation
doesn't arise because the framework always produces schema-compatible
diffs.
2018-10-16 18:49:20 -07:00
Kristin Laemmert 602b59cdc4 porting functions 2018-10-16 18:49:20 -07:00
Kristin Laemmert 4ad3676934 port ceil function 2018-10-16 18:49:20 -07:00
Kristin Laemmert c4f4dddff5 porting crypto functions 2018-10-16 18:49:20 -07:00
Kristin Laemmert eb1d8b7909 cleanup comments for nicer godocs 2018-10-16 18:49:20 -07:00
Kristin Laemmert 9aa9b18658 porting crypto functions 2018-10-16 18:49:20 -07:00
Kristin Laemmert 1a5299efcb porting encoding functions 2018-10-16 18:49:20 -07:00
Martin Atkins e850becf64 core: update context plan tests for new module address rendering
The diff stringer now uses the standard serialization of a module address,
so we need to update the golden representations to restore their
associated tests to passing.
2018-10-16 18:49:20 -07:00
Martin Atkins 1a547b5351 core: Rename "count" variables in context plan fixtures
This variable name is now reserved so we can support the count
meta-argument inside module blocks in a later release.
2018-10-16 18:49:20 -07:00
Martin Atkins dc7f793be9 command: terraform fmt to use new HCL formatter
This doesn't yet include test updates, since there are problems in core
currently blocking these tests from running. The tests will therefore be
updated in a subsequent commit.
2018-10-16 18:49:20 -07:00
Martin Atkins ebc6238bee backend/local: Update tests for changes in "terraform" package
This mainly consists of adding schema information to the mock providers.
2018-10-16 18:49:20 -07:00
Martin Atkins a270a18a4d command: Update tests for changes in "terraform" package
This is not exhaustive, but it gets the tests in this package compiling
again and gets most of them working.
2018-10-16 18:49:20 -07:00
James Bardin cdc8abdae0 add missing Operation to the Evaluator 2018-10-16 18:48:28 -07:00
James Bardin d55d623ef0 handle unset computed values in tests
The old testDiffFn used th raw config to dynamically set computed values
in the diff. Since the schema now defines what values should be there,
all test diffs end up with unkown computed values. Filter these out by
looking for a value set to "compute"
2018-10-16 18:48:28 -07:00
Martin Atkins 77bc36abce core: Make context_plan_test failure output more helpful
Lots of the tests were previously only producing the actual result, and
not what was expected. Now we'll show both, to make debugging easier.
2018-10-16 18:48:28 -07:00
Martin Atkins cc5b1d452f core: NewInstanceInfo now produces correct "id" for data resources
We need to mimic the old API here, and we weren't doing that quite right
since the "data" prefix was missing from data resources.
2018-10-16 18:48:28 -07:00
Martin Atkins 299fe25a04 hcl2shim: Handle unknown values when shimming to/from flatmap
Previously unknown values were round-tripping through flatmap and coming
out as known strings containing the UnknownVariableValue. (The classic bug
that, ironically, was one of the big reasons to write cty!)

Now we properly handle unknown values in both directions: going in to
flatmap we write UnknownVariableValue at the appropriate key (as the count
for sequences or maps) and then coming out of flatmap we turn
UnknownVariableValue back into a cty unknown value of the requested type.
2018-10-16 18:48:28 -07:00
Martin Atkins eb54715902 core: fix string rendering of modules in diffs
This was assuming our old practice of a slice starting with the string
"root". We'll normalize here and then stringify the result to ensure that
we get a string consistent with what's used elsewhere.

This is primarily aimed at fixing some of the context plan tests.
2018-10-16 18:48:28 -07:00