Commit graph

1067 commits

Author SHA1 Message Date
Daniel Banck
dcb0486c44
Update query complete message to a struct (#37395) 2025-08-04 15:47:28 +02:00
Samsondeen
3f7d043566
Append warning in CLI output when query result is empty (#37379) 2025-08-01 16:39:58 +02:00
Daniel Schmidt
8a88bbbff3 use constants 2025-07-31 16:07:38 +02:00
Daniel Schmidt
fb0445faf2 allow language experiments for terraform show 2025-07-31 16:07:38 +02:00
Daniel Schmidt
ccd89c58b2 fail on marked values in action config
this will be supported, but we skip this right now to keep the PR size more manageable
2025-07-31 16:07:38 +02:00
Daniel Schmidt
4fb4c3f056 render action config values 2025-07-31 16:07:38 +02:00
Daniel Schmidt
dd86671056 marshal action schemas into json provider representation 2025-07-31 16:07:38 +02:00
Daniel Schmidt
eb26b72d55 display lifecycle triggered actions aside their triggering resources 2025-07-31 16:07:38 +02:00
Daniel Schmidt
7d8b79a596 add a simple first rendering of action invocations to be run 2025-07-31 16:07:38 +02:00
Daniel Schmidt
5e288f56e2 add new planfile fields to terraform show -json 2025-07-31 16:07:38 +02:00
Sarah French
f494ff5540
Pull init command's Run method logic into separate method in new file, enable accessing experimental version of init logic via experiments and flags or ENVs (#37327)
* Pull `init` `Run` method into new method in a separate file, in preparation for adding experimental fork.

* Add license header

* Allow init args to be accessed before calling separate init run logic

* Add -enable-pss flag to the init command, to be used for accessing experimental init logic

* Fix- put call to `run` in else block!

* Make flag name more explicit

* Add an environment variable alternative to the CLI flag

* Make the panic text more user-friendly

* go fmt
2025-07-30 19:11:33 +01:00
Liam Cervante
dec0edfd5a
terraform test: enable deferrals in Terraform Test with the specified flag (#37370) 2025-07-30 11:03:41 +02:00
Mark DeCrane
14d378f9ce Ignore cmd arg parsing errors, we can expect these to happen 2025-07-29 11:39:43 -04:00
Sarah French
7b28a5d842
PSS: Allow backend or state_store config to be passed via BackendOpts into method for initialising the operations backend for a command (#37346)
* Allow backend or state_store config to be passed via BackendOpts from calling code

* Update messages sent to view: make message specific to state storage mechanism in use

* Add nil pointer check

* Fix typos

* Pivot to `Len` method approach of nil check

* Pivot to the point of pirouetting
2025-07-29 10:03:57 +01:00
Liam Cervante
84c2e2f9e5
terraform test: override prevent_destroy meta attribute (#37364) 2025-07-25 13:54:56 +02:00
Samsondeen
36836fd456
Tests for query command outputs (#37343) 2025-07-24 12:16:39 +02:00
Daniel Schmidt
c2b35e7ee7 remove duplicate place to store action invocations from plan 2025-07-24 11:28:29 +02:00
Daniel Schmidt
834665e332 use better hook identity 2025-07-24 11:28:29 +02:00
Liam Cervante
160b6b35b0
terraform test: include expected diagnostics in verbose mode (#37362) 2025-07-24 11:02:37 +02:00
Daniel Banck
c177897320
Improve list result output (#37344) 2025-07-23 16:52:37 +02:00
Daniel Banck
3607089016
Support tfquery files in terraform fmt (#37347) 2025-07-23 16:52:19 +02:00
Liam Cervante
0a7701f19a
terraform test: refactor graph edge calculation (#37357)
* terraform test: refactor graph edge calculation

* remove unused attribute
2025-07-23 16:09:45 +02:00
Sarah French
d1e412fcf0
PSS: Add initial (incomplete) version of code changes to the init command for using pluggable state storage (#37321)
* Store the FQN of the provider used in PSS in representations of the parsed config.

This can only be done once modules have been parsed and the required providers data is available. There are multiple places where config is parsed, into either Config or Module structs, so this needs to be implemented in multiple places.

* Update affected tests, improve error diagnostic

* Begin enabling method to return a backend.Backend made using state_store config.

State store config can now be received via BackendOpts and there is rough validation of whether the config makes sense (does the provider offer a store with the given name?).

* Update code's logic to include possibility of a state store being in use

At this point there are no cases that actually handle the state store scenarios though!

* Add empty cases for handle all broad init scenarios involving PSS

* Update default case's error to report state store variables

* Improve how we resolve the builtin terraform provider's address

* Add test that hits the code path for adding a state store to a new (or implied local) project

* Add test for use of `-reconfigure` flag; show that it hits the code path for adding a state store for the first time

* Add test that hits the code path for removing use of a state store, migrating to (implied) local backend

* Add test that hits the code path for changing a state store's configuration

* Update existing test names to be backend-specific

* Add tests that hits the code path for migrating between PSS and backends

* Consolidate PSS-related tests at end of the file

* Fix log text

* Add test showing that using variables is disallowed with state_store and nested provider blocks

* Update test name

* Fix test cases

* Add TODOs so we remember to remove experiments from tests

* Update state store-related tests to use 	t.Cleanup

* Remove use of `testChdir`
2025-07-18 14:08:18 +01:00
Kristin Laemmert
9256074c43
Actions in plan/changes (#37320)
* Add actions to the plans and change
* jsonplan - ignoring LinkedResources for now, those are not in the MVP
* pausing here: we'll work on the plan rendering later
2025-07-17 08:19:57 -04:00
Sarah French
7199fbd2bb
Update use of testChdir to standard library's t.Chdir, remove testChdir function from codebase (#37334)
* Replace use of `testChdir` with `t.Chdir`

* Update tests to use temporary directories with copied content, instead of using directories in the repo directly.

* Remove stacks copy of testChdir function

This has been replaced with t.Chdir from the standard library

* Replace remaining simple usage of testChdir

* Update guidance for using `tempWorkingDir`

* Replace use of testChdir in a function reused in a single test

* Update comments to no longer recommend using testChdir

* Remove testChdir function!
2025-07-16 16:04:10 +01:00
Sarah French
e79b5a1628
Replace custom testCwd function with standard testing library (#37335)
* Replace custom testCwd function with standard `testing` library

* Update comments that reference testCwd function
2025-07-16 10:41:51 +00:00
Sarah French
15840b3eae
Replace use of defer with t.Cleanup in majority of command package tests, update testChdir to work with t.Cleanup (#37326)
* Replace use of `defer` with `t.Cleanup` in tests

* Fix test failures by making cleanup function permissive of the temp dir being already deleted.
2025-07-16 10:24:56 +01:00
Sarah French
7a27366b39
PSS: Add ability to create hashes of the state_store block and of its nested provider block (#37278)
* Add the ability to make a hash of state store config

* Add test demonstrating that the provider block doesn't impact the hash of a state_store block

* Make sure test asserts what would happen if the schema DID include the provider block

* Update the Hash method to return diagnostics, ignore nested provider blocks, and validate incoming schema and config

* Update tests to use more representative config, fix code under test as a result

* Update Hash method to return hashes for both the state_store and provider blocks

* Add test cases to cover how required fields are tolerated when making the hash

This is because ENVs may supply those values.

* Fix inaccurate comments

* Add test to show that hashes are consistent and exclude the provider block

* Update backend state file to contain hash of provider block's config

* Fix test to expect a hash for the provider config block.

* Fix bug in DeepCopy method, update test to have better error messages when diffs are detected

* Update test to explicitly check hash values

* Try make test intention clearer

* Improve user feedback when state store schema contains the protected word "provider"

* Update tests

* Update test to test the Hash method in a more true-to-life way

Copy of 04a1201878cd1f6f117c43c43c1ee9d0fc17cec1 by Radek Simko

* Update test to use new approach

* Fix `TestInit_stateStoreBlockIsExperimental` test failure
2025-07-14 13:52:27 +01:00
Sarah French
145e152a57
Clarify usage of BackendOpts, rename field in struct to enable usage with PSS in future (#37085)
* Update comments to distinguish between operations and state-storage backends more clearly

* Rename `BackendOpts` field `Config` to more specific `BackendConfig`
2025-07-11 11:08:56 +01:00
Radek Simko
5437cd7c8a
Prepare main branch for 1.14 development (cleanup) (#37312)
* Prepare main branch for 1.14 development (cleanup)

* fix version-dependent tests

* update PR template
2025-07-09 17:42:04 +01:00
Samsondeen
0f7a690d25
Skip query e2e test when we cannot build at runtime (#37307) 2025-07-09 13:51:16 +01:00
Samsondeen
870bf99593
List implementation for simple provider and e2e tests (#37297) 2025-07-09 12:19:26 +02:00
Sarah French
677e5ea276
Add test coverage for Meta's determineInitReason method, fix error in diagnostic (#37303)
* Add test coverage for Meta's determineInitReason method, fix error in diagnostic when migrating away from HCP Terraform

* Add godoc comment to determineInitReason method
2025-07-08 16:34:43 +01:00
Sarah French
d02a1ed1b7
PSS: Make the state storage provider's config stateful (backend state, planfiles) (#37286) 2025-07-08 15:32:27 +01:00
Daniel Schmidt
8649eae35d rename ActionInvocation for clarity 2025-07-08 16:24:38 +02:00
Daniel Schmidt
8c657163b2 add hooks for action invocation lifecycle 2025-07-08 16:24:38 +02:00
Samsondeen
a1332299a5
Test run Parallelism of 1 should not result in deadlock (#37292) 2025-07-07 09:44:32 +02:00
Samsondeen
8d8b2bb694
Generate config for list results (#37173) 2025-07-04 11:35:39 +02:00
Daniel Banck
2b9d25c7fd
Add terraform query subcommand (TF-25494) (#37174)
* WIP

* Reuse plan command for query CLI

* Basic CLI output

* Only fail a list request on error

* poc: store query results in separate field

* WIP: odd mixture between JSONs

* Fix list references

* Separate JSON rendering

The structured JSON now only logs a status on which list query is
currently running. The new jsonlist package can marshal the query fields
of a plan.

* Remove matcher

* Store results in an extra struct

* Structured list result logging

* Move list result output into hooks

* Add help text and additional flag

* Disable query runs with the cloud backend for now

* Review feedback
2025-07-02 15:06:25 +02:00
Mark DeCrane
577f8f02ae
Merge pull request #37283 from hashicorp/TF-26979/central-binary-download-tf-stacks-cli
Move `stacksplugin` cache to `.terraform.d`
2025-07-02 07:00:21 -04:00
Mark DeCrane
1529739017 remove the cache override arg from the args passed to the plugin 2025-07-01 19:31:22 -04:00
Mark DeCrane
60dbc8b12f Move stacksplugin cache to .terraform.d, allow for overriding of cache dir location 2025-07-01 19:04:01 -04:00
Sarah French
2349481b23
Update data stored in plan files to enable using PSS with saved plans (#37246)
* Implement `ForPlan` method on `StateStoreConfigState`, add `Planner` interface

* Rename `ForPlan` method to `Plan`

* Allow plan files to contain information about state stores

* Add code needed for representing a state store in the Plan struct, which is used when handling plan files

* Add ability to read/write either a backend or state store's data in a plan file. Add some test coverage.

* Update plan's `ProviderAddrs` method to include the provider used for PSS, if present

* Split interfaces

* Apply feedback from code review

* Refactor `SetVersion` to use appropriate constructor

* Split `ProviderAddrs` method test into two

* Fix method call after rename

* Fix test

* Remove change to `(p *Plan) ProviderAddrs()`

We may re-add this when we implement PSS for use during apply commands with plan files

* Remove changes to test, now that the plan doesn't report the provider used for PSS anymore.
2025-06-30 11:39:15 +01:00
Daniel Banck
ab04e5cfec
Include list resource schemas in provider json schemas (TF-25497) (#37163)
* Include list schemas in provider json schemas

* Only include list schemas in experimental builds
2025-06-30 10:59:19 +02:00
Sarah French
38e2ed42c4
Make the workspace command explicitly protect the default workspace, instead of relying on backend implementations (#37256)
* Add test showing that users cannot delete the default workspace

Note: in the test this validation is being returned from the local backend's `DeleteWorkspace` method, not the command itself.

* Make the `workspace delete` command return early if the user is trying to delete the default workspace. Update test.

* Clean up redundant parts of test
2025-06-27 19:17:43 +01:00
Sarah French
d3b02a8469
Refactor code to use backend config state's SetConfig method, protect against nil receiver (#37254)
* Add protection against nil receivers to SetConfig

* Refactor code to use SetConfig method instead of setting ConfigRaw directly
2025-06-27 19:16:44 +01:00
Sarah French
a91d3aafa8
Fix bug in DeepCopy of backend state data that causes loss of StateStore data (#37276) 2025-06-26 21:38:45 +01:00
Sarah French
3617b909c1
Make workspace delete command reject empty string arguments (#37275)
* Disallow "" as the argument to workspaces delete command

* Add change file
2025-06-26 15:36:29 +01:00
Sarah French
9212a2efdd
Make Terraform reject empty strings as invalid workspace names (#37267)
* Add tests defining what are valid workspace names

* Update workspace name validation to mark an empty string as not valid

* Add change file

* Add command-level test showing the "" workspace cannot be created or selected

* Update invalid name error text to include empty string as invalid.
2025-06-26 12:26:58 +01:00
Matej Risek
a9b67a6cdc
stacks: Don't require built-in providers to be listed under required providers. (#37234) 2025-06-18 17:02:27 +02:00
Samsondeen
f57642d1a6
tf test: parallelize teardown operations (#37220) 2025-06-13 10:12:26 +02:00
Sarah French
2559f0a3db
Update backend state file so it can describe PSS state (#37179)
* Split code for backend state file vs backend state

* Rename BackendState to BackendConfigState

* Spelling error

* Add `StateStorageConfigState` struct as new implementation of new `ConfigState[T any]` interface.

* Split tests for backend state file vs backend config state structs

* Rename StateStorageConfigState to StateStoreConfigState

* Clarify test name, add comments

* Add tests for StateStoreConfigState methods

* Add test showing state_store in JSON is parsed correctly

* Add detection of malformed backend state files that contain both backend and state_store fields

* Add validation that stops a backend state file being written if it will contain state for both backend and state_store blocks

* Rename `state_storage` to `state_store`

* Rename `state_storage` to `state_store` in filenames

* Move`ConfigState` to its own file

* Fix test name, remove whitespace

* Update `StateStoreConfigState` comment using review suggestion

* Update error message to no longer allude to the environment TF is being run in

* Update the state_store state to use `version.Version` and an adapted version of `tfaddr.Provider` for marshalling version and source data

* Update test helper so it doesn't accidentally supply validation in tests

* Add protection against saving an empty backend state file

* Remove direct testing of (s *Source) MarshalText() and UnmarshalText() methods

* Add Validate method to StateStoreConfigState, use in backend state encoding logic

* Refactor to use new features in registry dependency
2025-06-11 14:10:26 +00:00
Sarah French
b3d7dae793
Add config parsing and validation for PSS (#37178)
* Enable parsing of  blocks in individual files

Co-authored-by: Radek Simko <radeksimko@users.noreply.github.com>

* Enable handling of state stores when parsing a module from its constituent files.

This includes: validations of duplicates and clashes, supporting override files.

Co-authored-by: Radek Simko <radeksimko@users.noreply.github.com>

* Add tests for validation that detects conflicts between state_store blocks and others

* Add tests for state_store override behavior

* Add tests for validation that detects when conflicting state-related blocks are used, either in the same file or across separate files

* Update error message summaries to explicitly say blocks conflict

* Add small changes to assertions in state_store override tests

* Update state_store block parsing to expect scoped provider block

* Update tests following syntax change

* Make config parsing experimental

* Remove testModuleFromDirWithExperiment, as testModuleFromDirWithExperiments exists!

* Update code comment

---------

Co-authored-by: Radek Simko <radeksimko@users.noreply.github.com>
Co-authored-by: Radek Simko <radek.simko@gmail.com>
2025-06-09 18:43:02 +01:00
Liam Cervante
777a916435
terraform test: move providers into the graph (#37216)
* terraform test: move providers into the graph

* consistency checks

* remove flaky cycle test

* address comments

* Update internal/moduletest/graph/node_test_run.go

Co-authored-by: Samsondeen <40821565+dsa0x@users.noreply.github.com>

* go fmt

---------

Co-authored-by: Samsondeen <40821565+dsa0x@users.noreply.github.com>
2025-06-06 16:27:34 +02:00
Liam Cervante
53afa2cd2f
terraform test: move variable evaluation into the terraform test graph (#37205)
* terraform test: move variable evaluation into the terraform test graph

* make copyrightfix
2025-06-06 10:11:35 +02:00
Liam Cervante
063b7cf62b
terraform test: check specific dependencies before skipping run blocks (#37204)
* terraform test: check specific dependencies before skipping run blocks

* fix data race

* complete comment
2025-06-05 10:44:04 +00:00
Liam Cervante
757efaed9a
terraform test: automatically create edges based on references (#37200)
* terraform test: automatically create edges based on references

* address comments

* remove unused function
2025-06-03 14:33:43 +02:00
Liam Cervante
f80762d3d5
terraform test: add variable definitions to test files (#37195)
* terraform test: add variable definitions to test files

Currently, `terraform test` attempts to work out the type of any external variables by delaying evaluation until each run block executes so it can use the definitions within the run blocks's module. This means that the values of variables can technically change between run blocks which isn't ideal.

This commit is the first in a chain which will move the evaluation of variables into the terraform test graph. We need to give the users the option of specifying the type for external variables within the file as these variables are now going to be assessed outside of the context of a run block. To do this, we introduce the optional variable blocks that are added by this commit.

* update comment
2025-06-03 07:47:12 +00:00
Liam Cervante
f3489c0480
deferred actions: should still be experimental (#37167) 2025-05-26 09:16:13 +02:00
Mattias Fjellström
3252fa8f42
Add missing JUnit XML flag to test command help string (#37161)
The test command supports outputting a JUnit XML file with the -junit-xml flag. This flag was missing from the test command help string.
2025-05-26 09:04:03 +02:00
Mark DeCrane
ffca158061
Merge pull request #37015 from hashicorp/TF-25893/handle-stacks-plugin-interupts
Handle stacks plugin interrupts
2025-05-19 09:58:02 -04:00
Daniel Banck
8213714929
Include identity in import apply UI output (#37044)
* Include identity in import apply UI output

* Add logging to hook ui errors
2025-05-16 15:24:24 +02:00
Radek Simko
4e00e1ecdb
fix: Avoid crash on test failure in BinaryOpExpr in function call (#37071)
* fix: Avoid crash on test failure in BinaryOpExpr in function call

* add changelog entry
2025-05-16 10:49:31 +00:00
Liam Cervante
c5445d4568
stacks: move the RPCAPI and deferred actions out of experimental (#37067)
* stacks: move the RPCAPI and deferred actions out of experimental

* add PR number
2025-05-16 11:11:55 +02:00
Mark DeCrane
5b33d74641 Handle the propagation of interrupt signals to stacks plugin 2025-05-14 15:19:24 -04:00
UKEME BASSEY
f7cb9097da
Merge pull request #36931 from hashicorp/TF-25178-add-stacks-plugin-proto
Add stacks plugin functionality: terraform stacks cmd
2025-05-14 12:15:55 -04:00
drewmullen
09cff2be39
include help entry for -replace (#36780)
* include help entry for -replace

* add to website docs as well

* Update internal/command/apply.go

Co-authored-by: Daniel Banck <dbanck@users.noreply.github.com>

* Update website/docs/cli/commands/apply.mdx

Co-authored-by: Daniel Banck <dbanck@users.noreply.github.com>

---------

Co-authored-by: Daniel Banck <dbanck@users.noreply.github.com>
2025-05-14 12:03:47 -04:00
Sarah French
5cc7479e0e
Update test to tolerate durations in scientific notation (very short test durations) (#37041)
It's not valid to force integer values for `time`, so this is a case where the test needs to be updated and not the code under test.
2025-05-13 16:53:41 +01:00
UKEME BASSEY
a732b606a1 make hostname and token optional, read token from cli file 2025-05-12 17:10:40 -04:00
UKEME BASSEY
3bc13593f9 add proto files gen for stacks plugin, & regenerate protofiles
add tests

update changelog
2025-05-05 16:06:49 -04:00
UKEME BASSEY
b12984470b Merge remote-tracking branch 'origin/main' into TF-25178-add-stacks-plugin-proto 2025-04-30 12:32:09 -04:00
Daniel Banck
0aa4ce972d
Add resource identities to plan file and JSON output (#36903) 2025-04-30 14:43:23 +02:00
UKEME BASSEY
509be4ea1b add stacks plugin 2025-04-28 12:57:14 -04:00
UKEME BASSEY
91b1dd3cc3 extend existing cloud plugin to accomodate new plugin 2025-04-28 12:54:23 -04:00
Sarah French
8d2dffedb3
Fix defects where done is called before the command's Run method is invoked (#36852)
* Fix defects where `done` is called before the command's `Run` method is invoked

We're attempting to reading output from a command that hasn't been executed yet!

* Another one
2025-04-14 09:47:03 +01:00
Radek Simko
36fb64f297
grpcwrap+provider-simple: Test ephemeral resource schemas in v5 protocol (#36878)
* grpcwrap+provider-simple: Test ephemeral resource schemas in v5 protocol

* Update internal/command/e2etest/providers_schema_test.go

Co-authored-by: Daniel Banck <dbanck@users.noreply.github.com>

---------

Co-authored-by: Daniel Banck <dbanck@users.noreply.github.com>
2025-04-11 09:36:47 +01:00
Sarah French
ea767aa7ad
Add comments about use of ResourceStores with TestProviders (#36856) 2025-04-08 15:24:19 -05:00
Sarah French
884fc64618
Remove unused test fixture "push-backend-new" (#36842) 2025-04-03 17:21:02 +01:00
Samsondeen
c0a7ff235b
Apply some new go collection features (#36818) 2025-04-02 16:20:16 +02:00
Liam Cervante
7fadbe34de
write-only attributes: internal providers should set write-only attributes to null (#36824)
* write-only attributes: internal providers should set write-only attributes to null

* add changelog

* fix copywrite headers
2025-04-02 15:58:42 +02:00
Daniel Banck
6917e69d12
Config-driven importing through identity (TF-23179) (#36703)
* configschema: Add identity attribute to import block

* Mark import target ID as legacy

* Add test with import identity

* Use ID or identity when importing via configuration

* Add plan import tests

* Review Feedback

* Make sure to copy identity for ResourceInstanceObjects

* Add helper for converting cty.Objects to string

* Replace getProvider calls

* Improve unknown object check
2025-04-02 13:39:16 +02:00
Sarah French
371e625ea9
Update URLs from www.terraform.io to developer.hashicorp.com (#36792)
* Update URLs from www.terraform.io to developer.hashicorp.com

* More updates to URLs linking to documentation in documentation and user-facing warnings/errors

* More updates to URLs linking to documentation, in docs, code, test fixtures

* Replace www.terraform.io/community with link to Community Forum

* Apply suggestions from code review

Co-authored-by: Rose M Koron <32436232+rkoron007@users.noreply.github.com>

---------

Co-authored-by: Rose M Koron <32436232+rkoron007@users.noreply.github.com>
2025-04-01 09:37:12 +01:00
Sarah French
2d6eda2877
Update comments about backend interfaces, enhanced vs operations, and fix copy-paste inaccuracies (#36716)
* Fix copy-pasta

* Update some comments clarifying backend-related interfaces and "enhanced" versus "operations"

* Fix more comments that refer to types and interfaces that have moved into the backendrun package
2025-03-20 16:52:00 +00:00
Samsondeen
595cd80666
CLI command for listing state identities (#36705) 2025-03-18 18:13:06 +01:00
Daniel Banck
1210d68836
Output resource identities in State JSON (TF-23753) (#36615)
* jsonstate: Marshal identity values

* jsonstate: Test identity marshalling

* Add identity to prepareStateV4

* Check identity schema version when marshaling state

* Marshal identity for deposed resources

* Marshal identity version if `0`

* Check for missing resource identity schema
2025-03-14 11:15:03 +01:00
Daniel Banck
cd433fa6d9
Marshall resource identity schemas in jsonprovider (#36675) 2025-03-12 09:53:03 +01:00
Daniel Schmidt
fec6e4b552 send resource identities to provider calls 2025-03-12 09:18:55 +01:00
Daniel Banck
b2b42c0fb4
Store resource identities in state (TF-23255) (#36464)
* Persist resource identity in Terraform state

* make syncdeps

* Move identity schema merging closer to the protocol

* mock GetResourceIdentitySchemas

* Fix identity refresh tests

* Add more tests

* Change grcpwrap upgrade identity

* Review feedback

* Remove unnecessary version conversion

* Check if GetResourceIdentitySchemas RPC call is implemented

* Update function signature docs

* Adapt protocol changes

* Check unimplemented error for identities in GetSchema
2025-03-11 20:58:44 +01:00
Guilherme Faria de Souza
d845df938d
Enhance elapsed time display in UI Hook with minutes and seconds (#36618)
* Feat: Enhance elapsed time display in UI hook with minutes and seconds format

* changelog: improve elapsed time display in UI Hook (#36368)

* update test output to use zero-padded elapsed time format
2025-03-05 10:40:57 +00:00
Liam Cervante
aaf617d6d7
Add test case to ensure no regression of already fixed crash (#36583) 2025-03-05 11:24:53 +01:00
Daniel Banck
10c9b64007
Rename schema.Block to Body (#36629) 2025-03-04 16:33:43 +01:00
Samsondeen
3f4ed7e019
Ensure that all states are cleaned up (#36616) 2025-03-04 10:49:39 +01:00
Samsondeen
1bd312f155
Produce detailed diagnostic objects when test run assertions fail (#36522) 2025-03-03 15:46:04 +01:00
James Bardin
332bce3531 diagnostics should not contain URLs
Especially if they are not permanent. Remove the URL and update the
wording/quoting to better match existing style.
2025-02-28 13:02:43 -05:00
Liam Cervante
0acd732911
Fix flaky test in test_test.go (#36566) 2025-02-25 14:11:17 +01:00
Samsondeen
85db2264db
skip flaky test (#36540) 2025-02-20 09:40:13 +01:00
Sarah French
85b482e05a
Add testing helpers that allow comparing diagnostics, refactor existing tests to use them. (#36456)
* Add testing helpers for comparing diagnostics with different levels of stringency

* Refactor some existing tests to use the new helpers

* Replace use of diag comparison test helpers in terraform package

* Add header

* Add return statement back in ephemeral test

* Update internal/terraform/context_plan2_test.go
2025-02-19 13:59:29 +00:00
Samsondeen
018110c012
No state to cleaup when it is empty (#36526) 2025-02-18 19:33:41 +01:00
Radek Simko
289a3568da
Address go vet 1.24 failures (#36485)
* address go vet failures

* avoid unnecessary .Error()
2025-02-12 16:51:53 +00:00
Samsondeen
2e91113224
Terraform test: Consolidate test execution procedure (#36459) 2025-02-11 14:48:48 +01:00
Samsondeen
4161e88391
Continue test execution after an expected failure (#36447) 2025-02-10 12:34:17 +01:00
Samsondeen
7f29df96a0
Allow terraform init when only test files are present in directory (#36429) 2025-02-06 09:20:09 +01:00
Samsondeen
86295f518c
Don't set default parallelism for cloud runs (#36441) 2025-02-06 08:54:08 +01:00
Radek Simko
70a1fd5e98
Fix diagnostic & avoid variable override via environment (#36435)
* add changie entry

* add test

* Fix diagnostic & avoid variable override via environment
2025-02-05 17:27:15 +00:00
Samsondeen
2f0f537e69
Terraform test: Execute eligible test runs in parallel (#36300) 2025-02-05 15:18:38 +01:00
Samsondeen
16a34fe47f
Accept CLI option for the number of parallel ops in a test run's plan/apply (#36323) 2025-02-05 09:48:05 +01:00
Bruno Schaatsbergen
61acb0cb3a
tfdiags: add Warnings method (#36392)
Adds a new method to the tfdiags API: Warnings() returns a new Diagnostics list containing only diagnostics with a severity of Warning.
2025-01-23 12:59:46 +00:00
Sarah French
b16a50973f
Add reusable Diagnostic comparer to tfdiags package (#36385)
* Add `DiagnosticComparer` to standardize how diagnostics are compared for equality. This uses code originally in the s3 backend.

Co-authored-by: Graham Davison <gdavison@hashicorp.com>

* Refactor `test` related code to use new comparer

* Refactor `s3` related code to use new comparer

* Replace use of reflect and go-spew with new diagnostics comparison approach

* Fix whitespace

* Make `tfdiags.DiagnosticComparer` a var

* Fix DiagnosticComparer test

---------

Co-authored-by: Graham Davison <gdavison@hashicorp.com>
2025-01-22 17:44:16 +00:00
Sarah French
6b81f7184c
Change JUnit terraform test output to include test failure details inside <failure> elements, use the error message as the message attribute (#36316)
* Add details to `<failure>` element describing which assertion failed

* Remove unused diagnostic string

* Set `message` attribute of `<failure>` element to failed assertion's error message

* Make `<failure>` contain diagnostic's message, refactor how `message` attribute is set

* Ensure that system-err is only added when needed

* Update test fixtures

* Make diags usage clearer, ensure all test failure diags in "failure" element

* Refactor how "skipped" element value is set

* Fix failing test Test_TestJUnitXMLFile_Save
2025-01-22 16:42:04 +00:00
Sarah French
39224976a8
Make test fail if JUnit feature is experimental (#36348) 2025-01-16 13:21:56 +00:00
Sarah French
21cafd70ea
Add more details to JUnit terraform test output to describe why a test was skipped (#36315)
* Add ability for TestJUnitXMLFile to access data about whether the test runner was Stopped

* Add details to XML describing why a Run was skipped

* Fix wording

* Code consistency changes

* Move all JUnit-related code down to where it's used

Away from the Views section of the code where it was relevant before

* Move JUnit-related error and warning diags to above where cancellable contexts are created

* Fix wording of user feedback

* Fix test to match updated skipped message text

* Fix test
2025-01-16 12:12:15 +00:00
Kévin Andrieux
258f91ab0c
feat: add state_key for test run blocks (#36185)
* feat: add state_alias for test run blocks

* fix: move `state_alias` to run block + rename to `state_key`

* docs: add state_key changelog entry

* docs: add state_key in run block documentation

* Revert "docs: add state_key in run block documentation"

This reverts commit ccccf62a76.

* Revert "docs: add state_key changelog entry"

This reverts commit 86e2ad8dc3.
2025-01-16 10:34:47 +01:00
Sarah French
8e1d36681c
Promote JUnit output 'terraform test' feature from experimental status, make incompatibility with remote test execution explicit via flag validation (#36324)
* Promote JUnit reports for `terraform test` out of experimental status

* Make JUnit output explicitly for local execution only

* Refactor how local test runner is passed JUnit data

* Add change file

* Add test for incompatible flags
2025-01-15 11:44:35 +00:00
Liam Cervante
408f323efa
test: also allow mock_data and mock_resource blocks to generate data during planning (#36317) 2025-01-15 08:19:05 +01:00
Sarah French
ab6e4f2299
Refactor JUnit XML output of terraform test into a new junit package (#36304)
* Refactor JUnit XML output to use new concept of an Artifact

* Move JUnit-related code into new `artifact` package

* Refactor Artifact's Save method to return diagnostics, update comments

Previously TestJUnitXMLFile implemented the View interface, which cannot return errors. Now it's not a View any more we can simplify things.

* Make junitXMLTestReport output deterministic by iterating over a slice instead of a map, add test

* Provide sources to junitXMLTestReport, allowing complete error messages in the XML

We need to ensure that artifact.NewTestJUnitXMLFile is called once the config Loader is available as a non-nil pointer

* Whitespace

* Add some test coverage for JUnit XML output for `terraform test`

* Refactor how file is saved, add tests

* Move XML structs definitions outside of `junitXMLTestReport`

* Fix nil pointer bug

* Add missing file headers

* Refactor comparison of byte slices

* Rename package to `junit`, rename structs to match

* Add a test showing JUnit output when a test is skipped by the user
2025-01-13 13:25:58 +00:00
Sarah French
43f31c43b0
Add start time timestamps to <testcase>/Run data in JUnit XML output from terraform test (#36295)
* Record metadata about the start timestamp for a Run/test case

* Add RFC3339 format timestamp attributes to `<testcase>` elements in JUnit XML output

* Ensure timestamps are saved as and rendered as UTC timestamps
2025-01-10 10:25:32 +00:00
Samsondeen
aec7c3cc89
terraform test: allow computed/mocked values override during planning (#36227) 2025-01-08 12:39:03 +01:00
Daniel Schmidt
276662f754 ephemeral: add test case for block rendering 2025-01-07 10:19:51 +01:00
Liam Cervante
672cd816d5 don't precompute actions 2025-01-07 10:19:51 +01:00
Daniel Schmidt
0e6a3ac994 ephemeral: render write-only attributes in plan UI 2025-01-07 10:19:51 +01:00
Radek Simko
908828be8a
cmd/modules: Ensure modules are sorted by reference key (#36268) 2025-01-06 15:25:24 +00:00
Liam Cervante
a4e1e60a01
logging: add trace statements when changes are ignored (#36259)
* logging: add trace statements when changes are ignored

* copywrite headers
2025-01-03 11:28:19 +01:00
Radek Simko
1d2d35b0b4
command: Update test to aid debugging of failures (#36255) 2025-01-02 15:40:06 +00:00
Mark DeCrane
e6bd282963
Merge pull request #36062 from hashicorp/TF-19313/modules-cmd-human-view
`terraform modules` cmd human view
2024-12-16 10:34:25 -05:00
Samsondeen
aa38305344
Merge pull request #36186 from hashicorp/sams/skip-graph-cycle-validation
Skip graph cycle validation when using the graph command
2024-12-11 17:32:02 +01:00
Samsondeen Dare
f41ce87644 update comments 2024-12-11 09:04:14 +01:00
James Bardin
a003a6ecaf
Merge pull request #36180 from hashicorp/jbardin/var-file-apply
Don't validate apply variables from auto files
2024-12-10 10:14:14 -05:00
Samsondeen Dare
b3cb17dead only ignore validation if -draw-cycles is enabled 2024-12-10 16:02:53 +01:00
Samsondeen Dare
d213d45cc5 pass the option via context 2024-12-10 14:53:17 +01:00
Samsondeen Dare
77c362b414 Skip graph cycle validation when using the graph command 2024-12-10 13:45:14 +01:00
James Bardin
c128eaa092 don't validate apply variables from auto files
The CLI attempts to prevent the user from inputting non-ephemeral
variables during apply which don't match the stored plan values. Since
the user can't avoid variables parsed from auto-loaded files, we have to
ignore those values.
2024-12-09 12:13:08 -05:00
Radek Simko
bfa011e88b
command/views: Fix flaky hook tests (#36104) 2024-12-09 10:23:55 +00:00
Mark DeCrane
9a3cedb499 align modules cmd with formating seen in providers cmd 2024-12-05 12:12:18 -06:00
James Bardin
4883499a89 test non-string env var input variables
Non-string input variables taken from the environment initially need to
be parsed and stored as string, since there is no type associated type
information. Make sure these are correctly handled when validated during
apply.
2024-11-27 13:16:33 -05:00
Liam Cervante
f1bd8df9b0
jsonplan: sort the relevant attributes in the correct plan (#36093) 2024-11-25 16:49:18 +01:00
Liam Cervante
36d7e8706f
jsonplan: deterministic relevant attribute order (#36076)
* jsonplan: deterministic relevant attribute order

* simplify sort function
2024-11-25 14:26:34 +01:00
Mark DeCrane
b2a90cf587 Testing updates 2024-11-21 12:54:29 -05:00
Mark DeCrane
8d0db63571 Add human view for modules cmd 2024-11-21 12:54:24 -05:00
James Bardin
16fe12ef0b synchronize schema and test fixture 2024-11-18 10:17:18 -05:00
James Bardin
c1f8152f10 undeclared variables must be allowed during apply
Plan allows undeclared config variables with only warnings, and that
behavior need to be carried forward to apply now that ephemeral
variables can be passed in at apply time.
2024-11-18 09:30:06 -05:00
Bruno Schaatsbergen
a5d8673a41
Revert "Merge pull request #35929 from bschaatsbergen/b/fix-retry-messages-in-cloud-backend-json"
This reverts commit f8cb25a246, reversing
changes made to a25831d6ef.
2024-11-13 18:22:26 -07:00
Bruno Schaatsbergen
247302f47d
Merge branch 'main' into b/fix-retry-messages-in-cloud-backend-json 2024-11-13 02:50:22 +01:00
Bruno Schaatsbergen
6b0ba4d20d
refactor: gracefully handle marshalling error with empty output 2024-11-12 18:46:53 -07:00
Bruno Schaatsbergen
b358e333ee
refactor: make methods private 2024-11-12 18:36:43 -07:00
Daniel Schmidt
6f58dbe75c
write-only attributes: emit structural data on schema rendering 2024-11-12 16:42:05 +01:00
Bruno Schaatsbergen
515897a125
copyright: add missing header
Signed-off-by: Bruno Schaatsbergen <git@bschaatsbergen.com>
2024-11-11 08:26:13 -07:00
Bruno Schaatsbergen
45c38a6469
Merge branch 'main' into b/fix-retry-messages-in-cloud-backend-json 2024-11-08 14:04:13 -06:00
Bruno Schaatsbergen
ae661f3568
views: add comments for clarity
Signed-off-by: Bruno Schaatsbergen <git@bschaatsbergen.com>
2024-11-08 14:03:28 -06:00
Bruno Schaatsbergen
f1428b3388
backend/cloud: expose View to enable reuse in a (cloud) backend
Signed-off-by: Bruno Schaatsbergen <git@bschaatsbergen.com>
2024-11-08 13:51:20 -06:00
Daniel Schmidt
90973698bf
Merge branch 'main' into pass-ephemeral-variables-to-terraform-apply 2024-11-07 17:33:39 +01:00
Liam Cervante
eeacced8f0
Add go vet as a check to the Github commit actions (#31461)
* Add go vet as a check to the Github commit actions

* deliberately break to test

* fix after successful test

* Use  directly

* fix more errors
2024-11-07 17:29:58 +01:00
James Bardin
896f9e74b6
Merge pull request #35958 from hashicorp/jbardin/uknown-ephemeral-config
Handle unknown values in ephemeral resource config
2024-11-07 08:24:08 -05:00
Daniel Schmidt
eccf39aa45
ephemeral: support interactive variable input for ephemeral values 2024-11-07 11:48:55 +01:00
Bruno Schaatsbergen
94c732b7a5
views: refactor RetryLog to use an elapsed time
Signed-off-by: Bruno Schaatsbergen <git@bschaatsbergen.com>
2024-11-06 14:00:18 -06:00
Bruno Schaatsbergen
93ae38dadf
views: add tests for cloud view
Signed-off-by: Bruno Schaatsbergen <git@bschaatsbergen.com>
2024-11-06 14:00:18 -06:00
James Bardin
c2a1070c23 create a ui hook for unknown ephemeral config
This is a stopgap to give users some feedback when an ephemeral resource
contains unknowns and cannot be opened.

There is no json hook implementation so that the machine-readable spec
is not bound to the new output until further review. It doesn't really
fit with the current json ui model to have messages about what isn't
going to happen.
2024-11-06 13:56:20 -05:00
Bruno Schaatsbergen
c1999a27ad
Merge branch 'main' into b/fix-retry-messages-in-cloud-backend-json 2024-11-06 16:58:51 +01:00
Daniel Schmidt
2e026dec0f
ephemeral: set ephemeral variables for combined plans as well
they are by definition the same as in the plan, but there is no reason to skip the validation step
2024-11-06 14:20:02 +01:00
Bruno Schaatsbergen
c71a1a775e
views: refactor retry logic with retryHelper function
Signed-off-by: Bruno Schaatsbergen <git@bschaatsbergen.com>
2024-11-06 06:52:41 -06:00
Liam Cervante
7c4aeac5f3
stacks: load credentials from config file on startup (#35952)
* stacks: load credentials from config file on startup

* delete unneeded file
2024-11-05 16:13:08 +01:00
Bruno Schaatsbergen
558aa18be7
Merge branch 'main' into b/fix-retry-messages-in-cloud-backend-json 2024-11-05 13:22:21 +01:00
Bruno Schaatsbergen
ad1f3e0adc
views: add tests for cloud view
Signed-off-by: Bruno Schaatsbergen <git@bschaatsbergen.com>
2024-11-04 18:47:34 +01:00
Bruno Schaatsbergen
c9f418d853
views: add PrepareMessage to cloud view interface
Signed-off-by: Bruno Schaatsbergen <git@bschaatsbergen.com>
2024-11-04 18:47:21 +01:00
Radek Simko
8176657c5b
command/views: Attempt to fix flaky JSON hook test (#35940) 2024-11-04 16:49:29 +00:00
Daniel Schmidt
d550c97553
ephermal: allow setting var and var files for apply 2024-11-04 15:41:44 +01:00
Daniel Schmidt
3207836729
ephemeral: tests for setting unplanned vars during apply 2024-11-04 15:35:22 +01:00
Daniel Schmidt
fa44937977
ephemeral: improve diagnostic message through compactValueStr 2024-11-04 15:35:22 +01:00
Daniel Schmidt
0e632aae86
ephemeral: allow setting non-ephemeral values during apply to same value as in plan 2024-11-04 15:35:22 +01:00
Daniel Schmidt
0a71f24453
disable interactive prompt test for now 2024-11-04 15:35:22 +01:00
Daniel Schmidt
a87b36a1a8
restructure tests 2024-11-04 15:35:22 +01:00
Daniel Schmidt
756a1a74ad
ephemeral: add apply tests 2024-11-04 15:35:22 +01:00
Daniel Schmidt
f4ff263d24
restructure existing test 2024-11-04 15:35:21 +01:00
Bruno Schaatsbergen
6c14e52d8e
test: use Cloud view
Signed-off-by: Bruno Schaatsbergen <git@bschaatsbergen.com>
2024-11-01 16:18:52 +01:00
Bruno Schaatsbergen
d8bfe7a80b
cloud: Initialize a new cloud view in the backend to render messages based on view type.
Signed-off-by: Bruno Schaatsbergen <git@bschaatsbergen.com>
2024-11-01 16:18:26 +01:00
Bruno Schaatsbergen
377c959c33
views: add cloud view
The cloud view is responsible for rendering messages related to cloud operations, presenting them to the user in either a human-readable format or as JSON output in the terminal.

Signed-off-by: Bruno Schaatsbergen <git@bschaatsbergen.com>
2024-11-01 15:40:51 +01:00
Bruno Schaatsbergen
a90930427a
chore: remove the retrylog hook from the init view
Signed-off-by: Bruno Schaatsbergen <git@bschaatsbergen.com>
2024-11-01 12:45:02 +01:00
Bruno Schaatsbergen
fb878889f2
Merge branch 'main' into b/fix-retry-messages-in-cloud-backend-json 2024-11-01 11:44:50 +01:00
Bruno Schaatsbergen
f9797595e3
chore: initialize new view in meta backend
Signed-off-by: Bruno Schaatsbergen <git@bschaatsbergen.com>
2024-11-01 11:44:32 +01:00
Radek Simko
3d4dab01a0
command/views: Attempt to fix flaky hook test (#35927)
Co-authored-by: Rose M Koron <32436232+rkoron007@users.noreply.github.com>
2024-10-31 07:47:23 +00:00
Bruno Schaatsbergen
f5dc158709
views: render retry messages using the view
Signed-off-by: Bruno Schaatsbergen <git@bschaatsbergen.com>
2024-10-30 19:57:11 +01:00
Bruno Schaatsbergen
8635cb1cfb
views: move retryLog hook to init view
The cloud backend includes a retry hook that relies on a go-tfe implementation. Since these retry messages were not rendered through a view, the `-json` flag was not respected, leading to mixed (non-pure JSON) output in the terminal whenever retry messages were printed.

Before passing the init view to the cloud backend, we ensure the retryLog hook is included in the init view.

Signed-off-by: Bruno Schaatsbergen <git@bschaatsbergen.com>
2024-10-30 19:50:33 +01:00
Radek Simko
0a266c88c4
terraform: Emit lifecycle phases of ephemeral resources to the UI (#35919) 2024-10-30 12:44:02 +00:00
Brandon Croft
c977f90bc3
Merge branch 'main' into brandonc/resource_tags_cloud_block 2024-10-29 06:52:29 -06:00
Brandon Croft
9d0133a541
Fix non-string elements in tags schema 2024-10-29 06:47:21 -06:00
Sebastian Rivera
59cea511dd Only show referenced entries, add versioning
This commit makes several modifications to the modules command. It
downcases the field names in the resulting JSON string, adds a format
version to the result. The result of this command will now only contain
entries which have been declared in configuration, as opposed to the
internal manifest which shows all installed modules for a working dir.
2024-10-28 13:31:09 -04:00
Sebastian Rivera
3498bc9815 Sort JSON objects before comparing to prevent rc error 2024-10-28 13:31:09 -04:00
Sebastian Rivera
f19d17cee7 Add missing license headers 2024-10-28 13:31:09 -04:00
Sebastian Rivera
a5294c2096 Impl tests for the modules command 2024-10-28 13:31:09 -04:00
Sebastian Rivera
ee1a2a7858 Implement the modules command
The modules command provides a holistic view of all installed modules
for a given root module. It also includes information on whether a
installed module is currently referenced by configuration. As of now,
this command only supports a machine-readable view format.
2024-10-28 13:31:09 -04:00
Brandon Croft
e87335a972
cloud: Allows object tag schema for selecting kv tagged workspaces
When key-value tags are enabled and used in the workspace, users may
define the tags attribute as a map of strings in the cloud block in order
to more precicely match workspaces using those tags.
2024-10-26 08:04:09 -06:00
Bruno Schaatsbergen
098234e244
states: check root output value changes in refresh-only mode (#35812)
* check root output values when determining plan applicability in refresh mode

In refresh-only mode, we do not anticipate proposing any actions; however, a plan is marked as “applyable” if there are changes in the state between runs. Currently, a plan is considered “applyable” only when there are differences in managed resources. This approach seems to overlook changes in root output values. As a result, a plan can be marked as non-applyable, even when there are changes in the root output value, due to the lack of detected changes since only managed resources were checked.

* set 'applyable' to true
2024-10-23 15:27:53 +02:00
Daniel Schmidt
b701e152e5
show value is ephemeral in terraform test 2024-10-17 15:07:20 +02:00
Daniel Schmidt
b9f273639d
handle ephemeral and sensitive case in diagnostics 2024-10-16 17:24:11 +02:00
Daniel Schmidt
3e7fdd0de9
improve wording of error message 2024-10-16 17:10:13 +02:00
Daniel Schmidt
ae103fc491
test: emit a nice error message if the user uses ephemeral resource in terrafom test 2024-10-16 16:30:31 +02:00
Daniel Schmidt
97ba67edea
test: ensure ephemeral values are not shown in diagnostics and warning is printed 2024-10-16 16:30:31 +02:00
Daniel Schmidt
725add6a1a
test: pass in variables during apply
ephemeral variables need to be re-supplied
2024-10-16 16:30:31 +02:00
James Bardin
3a1a9408d9 fix Descendants spelling
this has proliferated everywhere
2024-10-09 11:09:02 -04:00
Radek Simko
06fd817b7c
Remove handling of ephemeral root outputs (#35809)
* Remove handling of ephemeral root outputs

This is effectively reverting ~99% of https://github.com/hashicorp/terraform/pull/35676
The only changes not being reverted are some formatting and deprecation fixes which remain relevant.

The code being removed is basically dead code now in the context of root ephemeral outputs being rejected per https://github.com/hashicorp/terraform/pull/35791

* Remove unrelated changes
2024-10-03 18:10:30 +01:00
Radek Simko
5e1d2303fb
jsonprovider: Expose ephemeral resource schemas (#35800)
* jsonprovider: Expose ephemeral resource schemas

* add ephemeral resource to the test
2024-10-02 15:41:12 +01:00
Daniel Schmidt
fbbf59a685
Merge pull request #35706 from ndouglas/patch-1
Fix typo in test.go
2024-09-19 13:39:02 +02:00
James Bardin
2cbb6bf92f udpate code which was failing staticckeck
Some updates to staticcheck were catching more errors. Most of these
were format functions without a format string, but rather than adding
more exceptions I just fixed them all. This did also catch some
incorrectly wrapped errors.
2024-09-11 14:09:12 -04:00
Liam Cervante
332757894d
plan renderer: fix crash when updating a null attribute to unknown (#35709) 2024-09-11 14:27:36 +02:00
Liam Cervante
abd6b9ef1b
plan renderer: render unknown nested blocks properly (#35644) 2024-09-11 14:20:14 +02:00
Nate Douglas
df653772e1
Fix typo in test.go 2024-09-10 16:45:50 -04:00
kmoe
a2039517a5
states: store ephemeral output values in memory (#35676)
Ephemeral root output values must be kept in the in-memory state representation, but not written to the state file. To achieve this, we store ephemeral root outputs separately from non-ephemeral root outputs, so Terraform can access them during a single plan or apply phase.

Ephemeral root outputs always have a value of null in the state file. This means that the "terraform output" command, that reads the state file, reports null values for these outputs. Consumers of 'terraform output -json' should use the presence of '"ephemeral": true' in such output to interpret the value correctly.
2024-09-06 17:38:18 +01:00
makx
2a9a8c2aca
show deprecation warning if -state is used with plan, apply, refresh (#35660)
* show deprecation warning if -state is used with plan, apply, refresh

* show deprecation warning if -state is used with plan, apply, refresh

* updated -state flag check condition

* added better diagnostic details view

* resolved failed test

* updated the content of the -state flag warning
2024-09-05 10:55:37 +02:00
Radek Simko
91ea2cd6e0
internal/command: Avoid ignoring ephemeralasnull function (#35651) 2024-09-04 10:25:11 +01:00
kmoe
fab3673f8d
lang: stabilise ephemeral values experiment (#35636)
* lang: stabilise ephemeral values experiment

Stabilise the ephemeral values experiment and ephemeralasnull
experimental function.

* simplify handling of apply time input vars

As the final step in stabilising the ephemeral values experiment, we can
remove the separate code path for handling input variables supplied via
-var and -var-file during apply.

The intent here is conveyed in the tests: when applying a saved plan,
all ephemeral variables set in the plan (the "apply-time
variables"), must be set, and no others.

As per the TODO copied from the prototype, there is some more work to be
done here in making the handling of undeclared variables during apply as
sophisticated as that during plan, emitting helpful warnings (for
example) when input variables are supplied unnecessarily via environment
variables.

* experiments: officially conclude EV experiment

---------

Co-authored-by: Radek Simko <radek.simko@gmail.com>
2024-08-26 11:43:16 +01:00
James Bardin
2ffbd0eb4e remove old refactoring comments 2024-08-22 09:39:37 -04:00
James Bardin
0b8fbfe323 ignore unexported state field in comparison
and unify the options used to compare changes in tests
2024-08-22 09:39:37 -04:00
James Bardin
16231373a4 update changes in command pkgs 2024-08-22 09:39:37 -04:00
James Bardin
bc750192e4 POC for always using decoded changes in core
We should not need to encode and decode change values within core, since
the encoded version is only technically needed for serialization. This
pattern stems from the conversion to current changes system, but back
then we did not have easy access to the correct schemas at the time to
encode and decode the entire set of changes.

Moving the core handling of changes to only use the decoded values will
drastically improve evaluation efficiency, removing a round trip
through encoded values for every resource reference.
2024-08-22 09:39:37 -04:00
James Bardin
04b442d419 allow slashes in git url parameters
Git url refs often contain slashes, which were incorrectly being split
and appended to the path as a go-getter subdir.
2024-08-09 13:54:13 -04:00
Daniel Schmidt
3b95a5f6b1
fix formatting
Co-authored-by: Liam Cervante <liam.cervante@hashicorp.com>
2024-08-09 17:05:52 +02:00
Daniel Schmidt
8e1f02843d
jsonformat: update tests 2024-08-09 15:54:44 +02:00
Daniel Schmidt
b9933789aa
jsonformat: render deferred diff with no current changes message 2024-08-09 15:54:44 +02:00
Daniel Schmidt
c619cd2536
improve wording
Co-authored-by: Liam Cervante <liam.cervante@hashicorp.com>
2024-08-09 15:54:44 +02:00
Daniel Schmidt
a00e015e24
jsonformat: render different no changes message on deferred actions 2024-08-09 15:54:44 +02:00
Daniel Schmidt
4afb3b2b48
jsonformat: render deferred actions 2024-08-09 15:54:44 +02:00
Liam Cervante
471bddf3ba
json plan: update resource index and import ids to support unknown values (#35518) 2024-08-07 08:28:03 +02:00
Liam Cervante
4f62fcac53
init: fix invalid + duplicate required provider blocks crashing (#35533) 2024-08-06 10:38:13 +02:00
Liam Cervante
3ce9e517ae
fix flaky test in views package (#35469) 2024-07-17 13:10:11 +02:00
James Bardin
fcfbd85aa5 add suggestion to run terraform providers
On a default provider install failure we can always suggest running
`terraform providers` to help in cases where it's not apparent to the
user how to proceed. This would most commonly be encountered by
conflicting provider requirements, but if we find there are other common
situations we may want to generate a more precise error type for better
diagnostics.
2024-07-09 15:17:20 -04:00
Niklas Rosenstein
50463774b0 Fix and clarify error message when -plugin-dir can't be saved to workspace directory 2024-06-24 13:31:41 -07:00
Martin Atkins
71d14e78fd lang: Experimental "ephemeralasnull" function
This is another part of the existing ephemeral_values experiment, taking
a value of any type that might have ephemeral values in it and returning
a value of the same type which has any ephemeral value replaced with a
null value.

The primary purpose of this is to allow a module to conveniently return an
object that would normally contain nested ephemeral values -- such as an
instance of a managed resource type that has a write-only attribute --
through an output value that isn't declared as ephemeral. This would then
expose all of the non-ephemeral parts of the object but withhold the
ephemeral parts. In the case of write-only attributes, it exposes the
normal attributes while withholding the write-only ones.

The name of this function could potentially change before stabilization,
because it's quite long and clunky. I did originally consider
"nonephemeral" to match with the existing "nonsensitive", but that didn't
feel right because "nonsensitive" removes the sensitive mark while
preserving the underlying value while this function removes the mark and
the real value at the same time. (It would not be appropriate to have a
function that just removes the ephemeral mark while preserving the value,
because correct handling of ephemerality is important for correctness
while sensitivity is primarily a UI concern so we don't need to be quite
so picky about it.)
2024-06-20 09:34:13 -07:00
James Bardin
3bf06b18fc update helptext and docs 2024-06-14 16:23:36 -04:00
James Bardin
3875ea3656 add -lock-file flag to providers mirror command
The providers mirror command was updated to inspect the lock file,
however that was not part of the original intent for the command, and
it's possible that the command needs to be run without a lock file.

Since we have been honoring the lock file for the past few releases,
let's keep that consistent and allow disabling the file with
`-lock-file=false`.
2024-06-11 16:37:28 -04:00
James Bardin
e57d8add35 Check lock file diags in mirror command
The lock file diagnostic were not being checked in the mirror command,
so an incomplete or broken lock file might cause the cli to crash.
2024-06-10 15:03:28 -04:00
Martin Atkins
9dd16a7fba command: "terraform apply" accepts variable values with saved plan
To support ephemeral values we need a more complicated set of rules about
what input variables can and must be set when applying a saved plan. The
command itself does not have enough information to implement those rules
itself, so we'll let them pass through and check this in the local
backend's apply phase instead.

The local backend's apply phase already had basic support for dealing with
apply-time variable values, but it'll now also be responsible for
rejecting attempts to set variables when the experiment isn't enabled,
to keep all of this logic in roughly the same place.
2024-06-05 09:09:30 -07:00
Martin Atkins
6f84623cb6 terraform: Initial partial support for ephemeral values
This is a checkpoint commit on the path to supporting ephemeral values as
a cross-cutting concern in the Terraform language. An ephemeral value is
one that lives only in RAM during a single phase and so cannot persist
from the plan phase to the apply phase, or between consecutive plan/apply
rounds.

Terraform tracks whether each value is ephemeral using the cty "marks"
concept, thus achieving the same dynamic analysis as we already employ for
the concept of "sensitive values" that prevents displaying a value in the
user interface.

This commit is just a starting point which gets some of the basics into
place:
 - input variables and output values can both be statically declared as
   being ephemeral. Only ephemeral inputs/outputs can have ephemeral values
   assigned to them, and the recipient of the value sees it as ephemeral
   even if the assigned value was not already ephemeral.

   This creates a dynamic analysis cutoff point at module boundaries so
   that it's possible to determine in isolation whether a single module is
   using ephemeral values correctly, without having to test it in every
   possible calling context.
 - Managed and data resources cannot have ephemeral values assigned into
   their configurations because Terraform and providers both expect the
   resource attributes to persist between phases.
 - Ephemeral values _can_ be used in provider and provisioner
   configurations, because both of those effectively meet the definition
   of the new "ephemeral" concept despite it not previously having a name.
 - Ephemeral markings propagate through all of the built-in language
   features for dynamic analysis purposes, largely relying on cty's efforts
   to do that in similar vein as for sensitive marks. In particular,
   it's possible to define a local value whose expression produces
   an ephemeral result, and passing ephemeral values to functions should
   propagate the ephemeral mark to the results when appropriate. (I've not
   yet thoroughly reviewed all of the built-in functions for correct
   marks handling though, so there may be some gaps to address in later
   commits.)

The next step for this work will be to change the modules runtime to have
support for a workflow involving ephemeral _root_ input variables, where
their values must be re-supplied during the apply phase. That will then
achieve (in experimental capacity) the first goal of ephemeral values: to
be able to provide non-persistent settings such as time-limited API tokens
to use in provider configuration blocks.
2024-06-05 09:09:30 -07:00
James Bardin
a38be7d174
Merge pull request #35271 from hashicorp/jbardin/render-uknown-block
render entirely unknown blocks in the plan output
2024-06-03 13:14:21 -04:00
James Bardin
6b19b9e82a render entirely unknown blocks in the plan output
The plan renderer was missing a check for entirely unknown blocks,
causing them to be omitted from the human readable output. An unknown
block can happen when using an unknown for_each value in a dynamic block
assignment.
2024-05-31 14:24:23 -04:00
Brandon Croft
3a5221269b
Revert "Add Warning for Deprecated Modules in Init (Second Revision)" 2024-05-30 16:01:39 -06:00
kmoe
1e2d4a2ecc
lang: stabilise templatestring func experiment (#35224)
* lang: stabilise templatestring func experiment

* command/jsonfunction: marshal templatestring

* docs: add templatestring
2024-05-28 16:50:25 +01:00
Mark DeCrane
4bd790d8a4
Merge pull request #35231 from hashicorp/TF-12601/deprecated-module-version-warns-rev2
Add Warning for Deprecated Modules in `Init` (Second Revision)
2024-05-23 20:42:26 -04:00
MicahKimel
3258744166
Remove invalid warning during cleanup phase (#35172)
* stop invalid warning during cleanup phase

* stop invalid warning during cleanup phase

* invalid warning during cleanup phase

* remove unwanted comment

* update GetVariables parameter for including warnings

* invalid warning during cleanup phase test case

* update invalid warnings in cleanup test case to throw a warning for the validation variable before cleanup phase

* remove unwanted warnings
2024-05-23 10:32:39 +02:00
Mark DeCrane
1e7c29243e Added Extra field for TFC diagnostic processing 2024-05-22 18:06:00 -04:00
Sebastian Rivera
7012371d1f
Merge pull request #35176 from hashicorp/sebasslash/tf-15302_modifiable-snapshot-interval
Add `TF_STATE_PERSIST_INTERVAL` environment variable.
2024-05-17 15:01:13 -04:00
Sebastian Rivera
52c7dfceb4 Add unit tests for state persist interval env var 2024-05-17 14:16:24 -04:00
Sebastian Rivera
a72d02135b Define StatePersistInterval as command meta field 2024-05-17 14:16:24 -04:00
Liam Cervante
48fc2d3ac7
terraform test: Disallow version constraints within test files (#35161) 2024-05-16 13:15:20 +02:00
Brandon Croft
716fcce239
chore: add command ctx to GetRootOutputValues 2024-05-13 16:37:44 -06:00
Liam Cervante
b718c55b13
deferred actions: include deferred resources within JSON plan output (#35065)
* deferred actions: include deferred resources within JSON plan output

* address comments
2024-04-24 14:52:31 +02:00
Liam Cervante
14418bd198
terraform test: move override evaluation into expander (#35030)
* terraform test: move override evaluation into expander

* clarify comment
2024-04-24 07:57:29 +02:00
Nick Fagerlund
40b6f21b3d
Merge pull request #35050 from hashicorp/rebrand-hcp-terraform
Rebrand Terraform Cloud to HCP Terraform
2024-04-23 13:27:52 -07:00
Sebastian Rivera
c04d32dc26 Inject appname to backend migration prompts 2024-04-23 16:12:59 -04:00
Sebastian Rivera
015f795ff0 Rebrand Terraform Cloud to HCP Terraform 2024-04-23 16:12:59 -04:00
Liam Cervante
448775102c
terraform test: Push evaluation of variables to as late as possible (#35014)
* terraform test: Push evaluation of variables to as late as possible

* Update internal/moduletest/hcl/variable_cache.go

Co-authored-by: kmoe <5575356+kmoe@users.noreply.github.com>

* address comments

---------

Co-authored-by: kmoe <5575356+kmoe@users.noreply.github.com>
2024-04-23 13:10:41 +02:00
Liam Cervante
6963c54bec
terraform test: don't remove sensitive marks from inputs (#35021) 2024-04-18 18:58:19 +02:00