Commit Graph

1606 Commits

Author SHA1 Message Date
Graham Davison
5588603822
Merge pull request #33534 from hashicorp/s3/update-configschema
S3 Backend: Converts from `legacy/helper/schema` to `configschema`
2023-07-24 17:46:09 -07:00
Graham Davison
8564a5bf0e Fixes type of parameter skip_credentials_validation 2023-07-24 17:36:51 -07:00
Brandon Croft
c1a730314d
Relocate localterraform.com aliasing to backend configurators
Previously, remote and cloud backends would automatically alias localterraform.com as the configured hostname during configuration. This turned out to be an issue with how backends could potentially be used within the builtin terraform_remote_state data source. Those data sources each configure the same service discovery with different targets for localterraform.com, and do so simultaneously, creating an occasional concurrent map read & write panic when multiple data sources are defined.

localterraform.com is obviously not useful for every backend configuration. Therefore, I relocated the alias configuration to the callers, so they may specify when to use it. The modified design adds a new method to backend.Enhanced to allow configurators to ask which aliases should be defined.
2023-07-21 09:55:41 -06:00
Liam Cervante
ad26644578
Fix flaky test in views package (#33560) 2023-07-20 18:57:35 +02:00
Liam Cervante
c91f91cc9e
testing framework: change test file extension to .tftest.hcl (#33553) 2023-07-20 16:57:05 +02:00
Liam Cervante
ca85d3bf85
Implement word wrapping in the terraform test view functions (#33547)
* Implement word wrapping in the terraform test view functions

* Update internal/command/views/test.go

Co-authored-by: CJ Horton <17039873+radditude@users.noreply.github.com>

---------

Co-authored-by: CJ Horton <17039873+radditude@users.noreply.github.com>
2023-07-20 08:29:09 +02:00
James Bardin
62ee606752
Merge pull request #33543 from hashicorp/jbardin/get-schema-client-cache
always set schema caches from provider clients
2023-07-19 08:47:25 -04:00
Liam Cervante
6c7db16566
testing framework: refactor interrupt logic for immediate exits (#33532)
* testing framework: refactor interrupt logic

* fix formatting
2023-07-19 10:31:32 +02:00
Liam Cervante
6882dd9530
testing framework: introduce test command optional flags (#33504)
* testing framework: introduce test command optional flags

* address consistency checks
2023-07-19 10:07:46 +02:00
Liam Cervante
2cc81cfec6
testing framework: implement panic handling (#33525) 2023-07-19 09:57:09 +02:00
Liam Cervante
837716a703
testing framework: finalise expect_failures functionality (#33506) 2023-07-19 09:44:40 +02:00
James Bardin
e14b03f7b0 always set schema caches from provider clients
Allow core to always use the global schema cache, so that providers
without GetProviderSchemaOptional are not spun up repeatedly. Rather
than conditionally setting the cache, we just conditionally use the
cache in the client to work around providers without
GetProviderSchemaOptional.
2023-07-18 13:52:41 -04:00
James Bardin
f5d94b35a0
Merge pull request #33486 from hashicorp/jbardin/schema-cache-proto
enable schema caching and add `get_provider_schema_optional` server capability
2023-07-18 11:18:11 -04:00
Graham Davison
344e9de6b9 Linting fixes 2023-07-17 11:34:33 -07:00
Martin Atkins
7bee77bdd3 command: Start of propagating OpenTelemetry context
Several times over the years we've considered adding tracing
instrumentation to Terraform, since even when running in isolation as a
CLI program it has a "distributed system-like" structure, with lots of
concurrent internal work and also some work delegated to provider plugins
that are essentially temporarily-running microservices.

However, it's always felt a bit overwhelming to do it because much of
Terraform predates the Go context.Context idiom and so it's tough to get
a clean chain of context.Context values all the way down the stack without
disturbing a lot of existing APIs.

This commit aims to just get that process started by establishing how a
context can propagate from "package main" into the command package,
focusing initially on "terraform init" and some other commands that share
some underlying functions with that command.

OpenTelemetry has emerged as a de-facto industry standard and so this uses
its API directly, without any attempt to hide it behind an abstraction.
The OpenTelemetry API is itself already an adapter layer, so we should be
able to swap in any backend that uses comparable concepts. For now we just
discard the tracing reports by default, and allow users to opt in to
delivering traces over OTLP by setting an environment variable when
running Terraform (the environment variable was established in an earlier
commit, so this commit builds on that.)

When tracing collection is enabled, every Terraform CLI run will generate
at least one overall span representing the command that was run. Some
commands might also create child spans, but most currently do not.
2023-07-14 10:24:10 -07:00
Martin Atkins
a7807dac16 main: Optionally configure an OpenTelemetry OTLP exporter
Terraform CLI is sometimes used as part of a larger distributed system, in
which case it would be helpful to be able to gather telemetry from it
as part of the larger request it's being run in response to.

We'll now support optionally enabling an OTLP exporter by setting the
environment variable OTEL_TRACES_EXPORTER=otlp (a standard OpenTelemetry
convention). As of this commit there isn't actually anything emitting
traces to the specified collector, but we'll gradually add tracing
instrumentation to parts of Terraform CLI and Core in later commits.
2023-07-14 10:24:10 -07:00
Craig Wright
8f5064e6b4
Merge pull request #33433 from chaosaffe/fix-getcommand-helptext 2023-07-14 10:12:10 -07:00
Liam Cervante
87ed762619
Make flaky 'TestTest_DoubleInterrupt' test more robust (#33503) 2023-07-11 10:35:26 +01:00
James Bardin
642904204a enable global schema cache 2023-07-10 11:01:19 -04:00
James Bardin
fb35d7fd89 add get_provider_schema_optional server capability 2023-07-10 10:59:15 -04:00
Liam Cervante
4862812c94
testing framework: introduce interrupts for stopping tests (#33477)
* [testing framework] prepare for beta phase of development

* [Testing Framework] Add module block to test run blocks

* [testing framework] allow tests to define and override providers

* testing framework: introduce interrupts for stopping tests

* remove panic handling, will do it properly later
2023-07-10 14:53:13 +01:00
Liam Cervante
4b34902fab
[testing framework] allow tests to define and override providers (#33466)
* [testing framework] prepare for beta phase of development

* [Testing Framework] Add module block to test run blocks

* [testing framework] allow tests to define and override providers
2023-07-10 14:33:15 +01:00
Liam Cervante
5acc95dda7
[Testing Framework] Add module block to test run blocks (#33456)
* [testing framework] prepare for beta phase of development

* [Testing Framework] Add module block to test run blocks
2023-07-10 11:42:05 +01:00
Liam Cervante
c9bc7e8479
Add input validation into the 'checks' outputs and tracking (#33481) 2023-07-10 11:33:45 +01:00
Liam Cervante
f74a8d16cf
[testing framework] implement expect_failures functionality (#33443) 2023-07-10 11:30:44 +01:00
CJ Horton
2622e89cfb
Merge pull request #33448 from agustinguayama/fix/small_typo
fix typo in terraform/internal/command /init.go
2023-07-07 09:45:44 -07:00
James Bardin
c42d3b4e51
Merge pull request #33462 from hashicorp/jbardin/destroy-output-provider-refs
always evaluate module outputs during destroy
2023-07-07 09:44:27 -04:00
Graham Davison
d179b686d9 Consolidates endpoint tests 2023-07-06 16:05:52 -07:00
Graham Davison
2f00c86255 Adds endpoint tests when configured in configuration 2023-07-06 16:05:52 -07:00
Graham Davison
90c10ebbe9 Removes redundant ARN parsing 2023-07-06 16:05:52 -07:00
Graham Davison
29e14d148b Reorders skip_... parameters 2023-07-06 16:05:52 -07:00
Graham Davison
c3f4f9cedd Fixes region validation 2023-07-06 16:05:52 -07:00
Graham Davison
454eed63e7 Adds KMS Key validation 2023-07-06 16:05:52 -07:00
Graham Davison
2fda09aab2 Updates attribute validation messages 2023-07-06 16:05:52 -07:00
Graham Davison
e8c7722d3e Restores conflict between kms_key_id and envvar AWS_SSE_CUSTOMER_KEY 2023-07-06 16:05:52 -07:00
Graham Davison
827d7bd384 Combines sse_customer_key and AWS_SSE_CUSTOMER_KEY validation 2023-07-06 16:05:52 -07:00
Graham Davison
4eaa44c5a5 Adds functions for clearing all envvars 2023-07-06 16:05:52 -07:00
Graham Davison
2d12f242c7 Adds checks for not getting validation errors when they are expected 2023-07-06 16:05:52 -07:00
Graham Davison
95eb523c02 Sets service endpoints from envvar and adds tests 2023-07-06 16:05:52 -07:00
Graham Davison
8d018cfef3 Adds test for setting region from envvars 2023-07-06 16:05:52 -07:00
Graham Davison
9bea21e8b2 Moves schema to ConfigSchema and removes references to legacy schema 2023-07-06 16:05:52 -07:00
Graham Davison
467e6256da Moves configuration to Configure 2023-07-06 16:05:52 -07:00
Graham Davison
381006742b Moves validation to PrepareConfig 2023-07-06 16:05:52 -07:00
Graham Davison
b5de540643 Fully populates schema values 2023-07-06 16:05:52 -07:00
Graham Davison
9257dfa8a7 S3 backend: Adds tests for defaults and validation 2023-07-06 16:05:52 -07:00
James Bardin
6be6f69d61
Merge pull request #33482 from hashicorp/jbardin/schema-cache
Refactor providers.Schemas and add a global schema cache
2023-07-06 16:06:32 -04:00
James Bardin
a77baa866d additional schema handling comment 2023-07-06 15:53:08 -04:00
kmoe
d1a5dfa1ad
command: test plan -refresh= arg ordering (#33483)
* main: disambiguate arg ordering test

Make it extra clear what order of args we are asserting.

* command: fix plan -refresh=false test

The test for plan -refresh=false was not functioning, since ReadResource will not be called if the resource is not in prior state.

Add a new fixture directory with state, and also test the converse, to prevent regression.

* command: add test for refresh flag precedence

A consumer relies on the fact that running terraform plan -refresh=false -refresh true gives the same result as terraform plan -refresh=true.
2023-07-06 19:28:09 +01:00
James Bardin
76332db98d fix locking and race in test mocks 2023-07-06 11:46:17 -04:00
James Bardin
b9d8d99b04 remove fixed FIXME 2023-07-06 10:56:03 -04:00