Commit Graph

31288 Commits

Author SHA1 Message Date
Nick Fagerlund
0df3c143bb New plans.Quality type for display-relevant facts about a plan
This commit replaces the existing jsonformat.PlanRendererOpt type with a new
type with identical semantics, located in the plans package.

We needed to be able to exchange the facts represented by
`jsonformat.PlanRendererOpt` across some package boundaries, but the jsonformat
package is implicated in too many dependency chains to be safe for that purpose!
So, we had to make a new one. The plans package seems safe to import from all
the places that must emit or accept this info, and already contains plans.Mode,
which is effectively a sibling of this type.
2023-07-24 14:12:44 -04:00
Nick Fagerlund
da963a13b9 Implement plan -out for Cloud
- Don't save errored plans.
- Call op.View.PlanNextStep for terraform plan in cloud mode (We never used to
  show this footer, because we didn't support -out.)
- Create non-speculative config version if saving plan
- Rewrite TestCloud_planWithPath to expect success!
2023-07-24 14:12:44 -04:00
Nick Fagerlund
f9d937a4dd Apply a confirmable run when given a saved cloud plan (#33270)
It displays a run header with link to web UI, like starting a new plan does, then confirms the run
and streams the apply logs. If you can't apply the run (it's from a different workspace, is in an
unconfirmable state, etc. etc.), it displays an error instead.

Notable points along the way:

* Implement `WrappedPlanFile` sum type, and update planfile consumers to use it instead of a plain `planfile.Reader`.

* Enable applying a saved cloud plan

* Update TFC mocks — add org name to workspace, and minimal support for includes on MockRuns.ReadWithOptions.
2023-07-24 14:12:40 -04:00
Nick Fagerlund
9d85f18930 Add NewSavedPlanBookmark function
so we don't have to remember the format version number
2023-07-24 14:07:16 -04:00
Lauren
dcccd3b266 Add error handling and tests for saved plan bookmark load/save (#33268) 2023-07-24 14:07:16 -04:00
Nick Fagerlund
df7a1c821a Move SavedPlanBookmark to dedicated internal/cloud/cloudplan package
Having this sitting loose in `cloud` proved problematic because of circular
import dependencies. Putting it in a sub-package under cloud frees us up to
reference the type from places like `internal/backend`!
2023-07-24 14:07:16 -04:00
Lauren
717a36036d codify saved plan artifact contents (#33185) 2023-07-24 14:07:16 -04:00
Nick Fagerlund
b3f254e08d Upgrade to go-tfe v1.29.0 (for saved plan run support) 2023-07-24 14:07:16 -04:00
Brandon Croft
5fa956e1cb
Merge pull request #33432 from hashicorp/TF-7327-using-multiple-terraform-remote-state-data-sources-can-cause-race-conditions-when-the-backend-configuring-localterraform-com
Relocate localterraform.com aliasing to backend configurators
2023-07-21 15:01:22 -06: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
Martin Atkins
4b2b34929d version: Clean up after 1.6.0-alpha20230719 release 2023-07-19 10:58:07 -07:00
Martin Atkins
4d0966c780 version: Prepare for v1.6.0-alpha20230719 release 2023-07-19 09:41:45 -07:00
Liam Cervante
72135c462b Update CHANGELOG.md for new testing framework 2023-07-19 09:32:31 -07: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
CJ Horton
4530e36ae7
Merge pull request #32973 from hashicorp/radditude/one-version-to-rule-them-all
consolidate version information
2023-07-18 10:41:59 -07: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
CJ Horton
1e2a6be689 elaborate further on experiments and cgo 2023-07-17 11:56:13 -07:00
CJ Horton
16ae079c22 add documentation on Terraform's available build options 2023-07-17 11:22:31 -07:00
CJ Horton
11a68eaa40 set useDevelopmentVersion correctly for release builds 2023-07-17 11:11:35 -07:00
CJ Horton
49e308e57b unify version information
Instead of having two different places where we keep the current version
which must be manually kept in sync, let's use the same one that the
release process uses (version/VERSION).

Local builds will remain tagged with -dev by default, and we'll
disable this behavior with a linker flag at release time.
2023-07-17 11:11:31 -07:00
Craig Wright
7d1e918a38
Merge pull request #32074 from bendrucker/patch-1 2023-07-14 10:24:31 -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
503896af54 main: Be explicit that OTEL_TRACES_EXPORTER is very experimental 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
hashicorp-tsccr[bot]
4671514676
Result of tsccr-helper -log-level=info -pin-all-workflows . (#33527)
Co-authored-by: hashicorp-tsccr[bot] <hashicorp-tsccr[bot]@users.noreply.github.com>
2023-07-14 18:02:38 +01:00
Jason Murray
4c8e560120
Update get CLI docs 2023-07-13 09:35:07 -07:00
Craig Wright
8b210951d9
Merge pull request #31995 from sed-i/yamlencode-cloudconfig 2023-07-12 14:46:31 -07:00
Liam Cervante
87ed762619
Make flaky 'TestTest_DoubleInterrupt' test more robust (#33503) 2023-07-11 10:35:26 +01:00
Leon
0181c4e2d9
Update website/docs/language/resources/provisioners/syntax.mdx
Co-authored-by: trujillo-adam <47586768+trujillo-adam@users.noreply.github.com>
2023-07-11 00:52:51 -04:00
Craig Wright
19a8850748
Merge pull request #33499 from MusicDin/main 2023-07-10 11:17:31 -07:00
Din Mušić
8501d07dff
Fix typo in connection.mdx 2023-07-10 20:09:18 +02: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
Martin Atkins
9e6cc4ae6f go.mod: go get google.golang.org/grpc@v1.53.0
This is to upgrade past the vulnerability described here:
    https://github.com/advisories/GHSA-cfgp-2977-2fmm

Terraform does not seem to be significantly affected by it since our use
is primarily between Terraform Core and provider plugins where at worst
a provider could just make its own connection to Terraform malfunction.
However, this also appears to be a relatively low-risk upgrade.

This does force upgrading some of the Google Cloud Platform dependencies,
which the "gcs" (Google Cloud Storage) backend depends on, so there is
some minor risk to that backend but the upstream changes to those
dependencies do not seem to be significant.
2023-07-06 13:14:07 -07:00