Commit Graph

1115 Commits

Author SHA1 Message Date
Kristin Laemmert e3416124cc
addrs: replace "Type string" with "Type Provider" in ProviderConfig
* huge change to weave new addrs.Provider into addrs.ProviderConfig
* terraform: do not include an empty string in the returned Providers /
Provisioners
- Fixed a minor bug where results included an extra empty string
2019-12-06 08:00:18 -05:00
Martin Atkins 97d64581c6 helper/logging: Loosen the filtering heuristic even more
Now we'll consider any message that doesn't start with a digit as a
continuation. This is _definitely_ in loose, best-effort territory now
since a continuation line could very well start with a digit, but
ultimately this is still better than the totally broken behavior that
preceded it.

Just to make sure that none of these heuristics interfere with producing
complete, accurate logs for TRACE, we'll skip the LevelFilter altogether
in that case.
2019-12-05 15:22:03 -08:00
Martin Atkins faffb3a784 helper/logging: Warn about levels other than TRACE
The filtering for other log levels is unreliable and glitchy because it's
trying to infer information from the log stream that isn't reliably
represented.

Although the previous commit has improved the situation somewhat, it is
still a tricky and unreliable heuristic, so worth a warning to anyone who
is reading such a log that if they see something confusing it could be
a result of the heuristic not working fully.
2019-12-05 15:22:03 -08:00
Martin Atkins 30bf83cdeb helper/logging: Bring the LevelFilter into our own codebase
In order to make this work reasonably we can't avoid using some funny
heuristics, which are somewhat reasonable to apply within the context of
Terraform itself but would not be good to add to the general "logutils".

Specifically, this is adding the additional heuristic that lines starting
with spaces are continuation lines and so should inherit the log level
of the most recent non-continuation line.
2019-12-05 15:22:03 -08:00
Kristin Laemmert 9891d0354a
providers: use addrs.Provider as map keys for provider.Factory (#23548)
* terraform/context: use new addrs.Provider as map key in provider factories
* added NewLegacyProviderType and LegacyString funcs to make it explicit that these are temporary placeholders

This PR introduces a new concept, provider fully-qualified name (FQN), encapsulated by the `addrs.Provider` struct.
2019-12-04 11:30:20 -05:00
James Bardin bee703360c
Merge pull request #23252 from hashicorp/jbardin/abs-state-dependencies
store absolute addresses for resource dependencies in the state
2019-11-08 10:25:32 -05:00
James Bardin 16b368e292 only need to handle depends_on to shim old state 2019-11-07 17:49:03 -05:00
James Bardin 49439d02d1 sanitize provisioner output strings
The grpc protocol requires strings to be valid utf8, but because
provisioners often don't have control over the command output, invalid
utf8 sequences can make it into the response causing grpc transport
errors.

Replace all invalid utf sequences with the standard utf replacement
character in the provisioner output. The code is a direct copy from the
go1.13 std library, and can be replaced with strings.ToValidUTF8 once
it's available.
2019-11-06 14:57:52 -05:00
Radek Simko 7860f55e4f
Version tools per Go convention under tools.go 2019-10-17 22:23:39 +02:00
Martin Atkins 39e609d5fd vendor: switch to HCL 2.0 in the HCL repository
Previously we were using the experimental HCL 2 repository, but now we'll
shift over to the v2 import path within the main HCL repository as part of
actually releasing HCL 2.0 as stable.

This is a mechanical search/replace to the new import paths. It also
switches to the v2.0.0 release of HCL, which includes some new code that
Terraform didn't previously have but should not change any behavior that
matters for Terraform's purposes.

For the moment the experimental HCL2 repository is still an indirect
dependency via terraform-config-inspect, so it remains in our go.sum and
vendor directories for the moment. Because terraform-config-inspect uses
a much smaller subset of the HCL2 functionality, this does still manage
to prune the vendor directory a little. A subsequent release of
terraform-config-inspect should allow us to completely remove that old
repository in a future commit.
2019-10-02 15:10:21 -07:00
James Bardin a3c374b227 don't lose track of private data in the ACC tests
If the resource schema version is > 0, the metadata containing the
timeout values was overwritten during acceptance tests.
2019-09-18 13:59:12 -04:00
appilon d3dc1263bf
Merge pull request #22382 from hashicorp/appilon/delete-files
[CLEANUP] Prune internal usage of config package (with 1 exception)
2019-08-08 13:01:00 -04:00
Radek Simko ecbfc365a0
Merge pull request #20157 from shinmog/conflictswith
helper/schema: Add "part" to ConflictsWith validation error
2019-08-08 14:20:35 +01:00
Radek Simko db7d1826e4
Merge pull request #22312 from ewbankkit/add-rand-ip-address
helper/acctest: Add function to return random IP address
2019-08-08 13:53:51 +01:00
Radek Simko 7861cc6141
Merge pull request #20309 from chanzuckerberg/ryanking/remove_lifecycle_comment
helper/schema: Remove comment about nested schema.Resources having their own lifecycle
2019-08-08 13:48:22 +01:00
Radek Simko 350395d804
Add better comment 2019-08-08 13:21:04 +01:00
Radek Simko a08ad08169
Merge pull request #18277 from ndmckinley/patch-1
helper/resource: Minor docs tweak on ImportStateVerify
2019-08-08 13:08:19 +01:00
Alex Pilon 77757d9f5b
prune references to config/module
delete config/module
prune references to config except in terraform/resource.go
move, cleanup, and delete inert code
2019-08-07 17:50:59 -04:00
Alex Pilon 4bf43efcfd
move hcl2shim package to configs 2019-08-06 19:58:58 -04:00
Alex Pilon ec0402a238
add case to decoder to assert to slice, then each item to a map 2019-08-05 22:08:05 -04:00
Alex Pilon 6ae281b34f
set Err to true for test
This was likely meant to be set to Err true but
the old parser mistakenly didn't raise an error
2019-08-05 22:08:04 -04:00
Alex Pilon 6de3c32652
comment out failing test 2019-08-05 22:08:04 -04:00
Alex Pilon 83aa07f907
prune NewResourceConfig and update tests 2019-08-05 22:08:03 -04:00
Kit Ewbank 949a6ae695 Add 'RandIpAddress'. 2019-08-02 14:51:40 -04:00
The Terraform Team 176f790323
Merge pull request #22262 from hashicorp/mildwonkey/b-deprecation-warnings
helper/schema: don't skip deprecation check during validation
2019-07-30 21:27:51 +01:00
Kristin Laemmert bfd66083de helper/schema: don't skip deprecation check during validation
If an attribute was not wholly known, helper/schema was skipping the
`validateType` function which (among other things) returned deprecation
messages. This PR checks for deprecation before returning when skipping
validateType.
2019-07-30 16:00:43 -04:00
Paul Tyng e400c25358
Minor typo 2019-07-30 10:43:46 -04:00
Paul Tyng 366f70a71e
Update copy for Exists
You can signal the same information in `Read` with an empty ID if the object does not exist, Implementing `Exists` is not the only way to do so and in some providers is also not the preferred way.
2019-07-30 10:37:58 -04:00
James Bardin 7648f99bca
Merge pull request #22236 from hashicorp/jbardin/nil-in-config
don't reflect nil in schema validation
2019-07-29 14:08:37 -07:00
James Bardin 016c4f782d don't reflect nil in schema validation
Nil values were not previously expected during validation, but they can
appear in some situations with the new protocol. Add checks to prevent
using zero reflect.Values.
2019-07-29 12:38:35 -04:00
James Bardin 4bed030d40 don't validate MinItems with unknowns in a block
If there are unknowns, the block may have come from a dynamic
declaration, and we can't validate MinItems. Once the blocks are
expanded, we will get the full config for validation without any unknown
values.
2019-07-27 11:50:28 -07:00
Alex Pilon 7f8f198719
remove UnknownVariabeValue from config and update references to shim 2019-07-17 22:41:24 -04:00
James Bardin 75602df5ef Revert "Remove removed attribute from applied state"
This reverts commit 2e2a363052.
2019-06-28 11:51:52 -04:00
James Bardin 8e8eb6d6d3
Merge pull request #21884 from hashicorp/jbardin/validate-null-diags
don't append nil elements to a diagnostic cty.Path
2019-06-26 09:33:04 -04:00
James Bardin d4b0788854 don't append nil elements to a diagnostic cty.Path
If a set element is nil in validateConfigNulls, we don't want to
append that element to the diagnostic path, since it doesn't offer any
useful info to the user.
2019-06-25 18:05:51 -04:00
James Bardin 0d9f84414a
Merge pull request #21879 from hashicorp/jbardin/sdk-panics
prevent sdk panics in 2 specific cases
2019-06-25 15:38:15 -04:00
James Bardin cd3ac50ddb prevent sdk panics in 2 specific cases
Fix 2 specific panics in the sdk when reading nil or computed maps from
various configurations. The legacy sdk code is too dependent on undefined
behavior to attempt to find and fix the root cause at this point.

Since the code is essentially frozen for future development, these
changes are specifically targeted to only prevent panics from within
providers.  Because any code effected by these changes would have
panicked, there cannot be anything depending on the behavior, and these
should be safe to fix.
2019-06-25 14:24:32 -04:00
James Bardin f362198467
Merge pull request #21806 from hashicorp/jbardin/lost-empty-strings
prevent an empty string from being lost
2019-06-25 12:32:06 -04:00
James Bardin 9365a2d97d private and timeout handling in grpc_provider
Load private data for read, so the resource can get it's configured
timeouts if they exist.

Ensure PlanResourceChange returns the saved private data when there is
an empty diff.

Handle the timeout decoding into Meta in the PlanResourceChange, so that
it's always there for later operations.
2019-06-19 22:48:15 -04:00
James Bardin 2448d1d38b move timeout handling to grpc_provider
simpleDiff is only called from the grpc_provider, and we always need to
make sure the timeouts are encoded in the private data.
2019-06-19 22:48:15 -04:00
James Bardin 4dcda04d96 prevent an empty string from being lost
The helper/schema diff process loses empty strings, causing them to show
up as unset (null) during apply. Besides failing to show as set by
GetOk, the absence of the value also triggers the schema to insert a
default value again during apply.

It would also be be preferable if the defaults weren't re-evaluated
again during ApplyResourceChange, but that would require a more invasive
patch to the field readers, and ensuring the empty string is stored in
the plan should block the default.
2019-06-19 17:42:00 -04:00
James Bardin 8ae31aa2db normalize empty blocks during import
Like Upgrade, Import is another case where we don't have the context of
the configuration and need to ensure missing blocks are normalized.
2019-06-17 20:29:01 -04:00
James Bardin e6ee78555a
Merge pull request #21721 from hashicorp/jbardin/remove-new-removed
Remove removed attribute from applied state
2019-06-17 09:36:23 -04:00
James Bardin 814f068dfe
Merge pull request #21711 from hashicorp/jbardin/upgrade-blocks
Ensure all object attrs & empty blocks in upgrade
2019-06-14 11:28:21 -04:00
James Bardin dbe22181ae Ensure all object attrs & empty blocks in upgrade
When upgrading from a flatmap state, unset blocks would not exist in the
state, while they will represented as empty in the new cty.Value. This
will cause an unexpected diff in the first plan after upgrade. This
situation may normally be applied with no impact, but some providers may
have unexpected behavior, and if the attributes force replacement it may
require manual alteration of the state to complete the upgrade.
2019-06-13 18:03:47 -04:00
James Bardin 2e2a363052 Remove removed attribute from applied state
When a Diff contains a NewRemoved attribute (which would have been null
in the planned state), the final value is often the "zero" value string
for the type, which the provider itself still applies to the state.
Rather than risking a change of behavior in helper/schema by fixing the
inconsistency, we'll remove the NewRemoved attributes after apply to
prevent further issues resulting from the change in planned value.
2019-06-13 17:29:25 -04:00
James Bardin a036ea0ec8 only seed math/rand once
Re-seeding the PRNG every time only serves to make the output an
obfuscated timestamp. On windows with a low clock resolution, this
manifests itself by outputting the same value on calls within the
minimum time delta of the clock.
2019-06-12 21:38:59 -04:00
Brian Flad 94078f9029
helper/plugin: Allow missing MigrateState for provider flatmap state upgrades
Reference: https://github.com/terraform-providers/terraform-provider-aws/issues/8828

Prior to Terraform 0.12, providers were not required to implement the `MigrateState` function when increasing the `SchemaVersion` above `0`. Effectively there is no flatmap state difference between version 0 and defined `SchemaVersion` or lowest `StateUpgrader` `Version` (whichever is lowest) when `MigrateState` is undefined, so here we remove the error and increase the schema version automatically.
2019-06-05 23:23:45 -04:00
James Bardin 4cb6ebe22c maintain private data through provider ACC tests
The private->meta data was lost in the test harness.
2019-06-05 19:22:46 -04:00
James Bardin a056b84cdd add delete timeout test
The timeout value is still not being persisted.

While it doesn't fix this issue, make sure to always return Private
during Plan.
2019-06-05 19:22:46 -04:00