Commit Graph

1662 Commits

Author SHA1 Message Date
Kuba Martin
ebcf7455eb
Rename root module name. (#4)
* Rename module name from "github.com/hashicorp/terraform" to "github.com/placeholderplaceholderplaceholder/opentf".

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Gofmt.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Regenerate protobuf.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Fix comments.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Undo issue and pull request link changes.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Undo comment changes.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Fix comment.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Undo some link changes.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* make generate && make protobuf

Signed-off-by: Jakub Martin <kubam@spacelift.io>

---------

Signed-off-by: Jakub Martin <kubam@spacelift.io>
2023-08-17 14:45:11 +02:00
Brandon Croft
8a085b427b
Merge pull request #33590 from hashicorp/TF-7652-terraform-make-plan-out-create-provisional-configuration-versions
Create provisional configuration version when saving plan using cloud backend
2023-08-10 11:50:37 -06:00
Liam Cervante
126f34e4e8 Implement updates to testing framework based on recent feedback 2023-08-10 10:49:01 +02:00
Liam Cervante
3cce200d0e Fix root cause of race condition in testing framework tests 2023-08-09 16:47:59 +02:00
Liam Cervante
f1ca74f09f Update JSON_UI_VERSION after test framework changes 2023-08-09 16:47:27 +02:00
Liam Cervante
f8b1fe47dd
Make config errors more important during init operations (#33628)
* make config errors more important during init operations

* address comments
2023-08-09 11:19:00 +02:00
James Bardin
e26d07dda4
Merge pull request #33634 from hashicorp/jbardin/init-from-module-warnings
Allow `get` and `init -from-module` to complete when there are configuration validation errors
2023-08-08 12:40:57 -04:00
James Bardin
ea1144995f update callers of InstallModules
Update callers of InstallModules and have `get` return only install
errors.
2023-08-07 15:22:02 -04:00
James Bardin
f6768de218 handle install errs in installDescendentModules
This will allow us to use the same logic for `get` too.
2023-08-07 15:06:47 -04:00
Brandon Croft
b1d4f18a9b
Create provisional configuration version when saving cloud plan 2023-08-07 11:35:48 -06:00
James Bardin
09d91eb675 test -from-module with invalid root module
Add a test for `init -from-module` with a module which is not a valid
root module.
2023-08-04 10:43:21 -04:00
James Bardin
29c3f650cd allow config errors when using -from-module
When initializing the working directory from a module, some use cases
may still want the module source even when the configuration cannot be
loaded due to validation errors.

Isolate the installation errors during the initialization sequence, so
we can report them if there is a problem fetching the actual module
source. Once we have the module, convert configuration errors to
warnings so the cli initialization can proceed.
2023-08-03 16:05:47 -04:00
kmoe
765c25d2ed
allow interpolation in import block id (#33618)
The import block id field can now reference variables, attributes, and module outputs, as long as the result is a known non-empty string at plan time. A null or unknown value will result in an error.

This commit slightly modifies the legacy CLI terraform import code path to construct a synthetic hcl.Expression from the import id passed in from the command line, with no intended change of functionality.
2023-08-02 10:20:27 +01:00
Liam Cervante
8b764f2e1b
fix race condition in no_provides_in_main test (#33616) 2023-08-02 11:02:26 +02:00
Karl Kirch
d7e07e66fc
Add ability to specify Terraform Cloud Project in cloud block (#33489)
* Add ability to specify Terraform Cloud Project in cloud block

Adds project configuration to the workspaces section of the cloud block.
Also configurable via the `TF_CLOUD_PROJECT` environment variable.
When a project is configured, the following behaviors will occur:
- `terraform init` with workspaces.name configured will create the workspace in the given project
- `terraform workspace new <name>` with workspaces.tags configured will create workspaces in the given project
- `terraform workspace list` will list workspaces only from the given project

The following behaviors are NOT affected by project configuration
- `terraform workspace delete <name>` does not validate the workspace's inclusion in the given project
- When initializing a workspace that already exists in Terraform Cloud, the workspace's parent project is NOT validated against the given project

Adds tests for cloud block configuration of project
Update changelog

* Update cloud block docs

* Fix typos and changelog entry

* Add speculative project lookup early in the cloud initialize process to capture inability to find a configured project

* Add project config for alias test
2023-08-01 13:43:07 -07:00
Liam Cervante
3bea1171af
test framework: expand variables available to test assertions (#33611) 2023-08-01 09:59:29 +02:00
Liam Cervante
bf6f32c19a
test framework: fix bug preventing remaining assertions being checked after one has failed (#33601) 2023-08-01 09:56:51 +02:00
Liam Cervante
4560a83721
test framework: include transformed config before validating config (#33608) 2023-08-01 09:47:00 +02:00
Graham Davison
84edaaed57
Merge pull request #33571 from hashicorp/s3/add-legacy-acceptance-tests
S3 Backend: Add legacy authentication flow tests
2023-07-31 13:27:02 -07:00
Liam Cervante
f397954c52
testing framework: allow users to specify deeply nested testing directories (#33584) 2023-07-27 10:38:21 +02:00
Liam Cervante
4122ba86fc
terraform test: fix crash when using nested modules from test run blocks (#33589) 2023-07-27 10:22:53 +02:00
Liam Cervante
e1019b3641
testing framework: validate the configuration before terraform test (#33559)
* testing framework: call validate on the configuration before running terraform test

* address comments

* make tests pass after merge

* fix tests
2023-07-26 10:56:44 +02:00
Liam Cervante
55792309eb
test framework: add support for testing files to fmt command (#33576) 2023-07-26 10:38:47 +02:00
Liam Cervante
080ddead6e
testing framework: perform a plan before starting any tests (#33561) 2023-07-26 10:24:25 +02:00
Liam Cervante
083c9afd5b
testing framework: add trace and debug statements during test executions (#33554) 2023-07-26 10:11:27 +02:00
Liam Cervante
222676390c
testing framework: add validation for provider blocks in test files (#33542)
* testing framework: add validation for provider blocks in test files

* .tftest -> .tftest.hcl
2023-07-26 10:01:18 +02:00
Liam Cervante
dff447bc9f
fix crash when nested data blocks are mixed with the import command (#33578) 2023-07-26 09:41:00 +02:00
Brandon Croft
14628b9246
Update cloudproto1.pb.go 2023-07-25 09:30:25 -06:00
Brandon Croft
e5ce25099c
Apply suggestions from code review
Co-authored-by: Sebastian Rivera <sebastian.rivera@hashicorp.com>
2023-07-25 09:28:32 -06:00
Brandon Croft
9bb566dcdb
Update cloudplugin type casting to simplify adding future versions 2023-07-25 09:28:32 -06:00
Brandon Croft
2c3d134705
Adds cloud subcommand with some toy options 2023-07-25 09:28:32 -06:00
Brandon Croft
a806f6220a
Tests the cloudplugin1 gRPC client 2023-07-25 09:28:31 -06:00
Brandon Croft
539e140d3e
Introduces cloudproto1 plugin interface 2023-07-25 09:28:31 -06:00
Brandon Croft
fec1ca69ac
Fix console godoc 2023-07-25 09:28:30 -06:00
Sebastian Rivera
dceb8453af
Merge pull request #33492 from hashicorp/cli-team/saved-cloud-plans
Implement saved cloud plans
2023-07-25 10:29:19 -04:00
Sebastian Rivera
08e58fd484 Fix saved plan test regressions, fixtures 2023-07-25 10:22:46 -04:00
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
Graham Davison
47fc769da9 Adds tests for region 2023-07-24 17:20:16 -07:00
Graham Davison
f3ce646756 Adds authentication tests 2023-07-24 16:23:52 -07:00
Sebastian Rivera
31cf55fe12 Reword error message when using local exec 2023-07-24 14:12:44 -04:00
Nick Fagerlund
1cbc95ce56 Use wrapped types to clean up error reporting in show command
Since terraform show can accept three different kinds of file to act on, its
error messages were starting to become untidy and unhelpful. The main issue was
that if we successfully identified the file type but then ran into some problem
while reading or processing it, the "real" error would be obscured by some other
useless errors (since a file of one type is necessarily invalid as the other
types).

This commit tries to winnow it down to just one best error message, in the
"happy path" case where we know what we're dealing with but hit a snag. (If we
still have no idea, then we fall back to dumping everything.)
2023-07-24 14:12:44 -04:00
Nick Fagerlund
f98f920b67 Add error wrapper types to highlight bad plan/state data
This commit uses Go's error wrapping features to transparently add some optional
info to certain planfile/state read errors. Specifically, we wrap errors when we
think we've identified the file type but are somehow unable to use it.

Callers that aren't interested in what we think about our input can just ignore
the wrapping; callers that ARE interested can use `errors.As()`.
2023-07-24 14:12:44 -04:00
Nick Fagerlund
1f35173192 Tests: Add tests for (*Cloud).ShowPlanForRun() 2023-07-24 14:12:44 -04:00
Nick Fagerlund
7f6b827987 Modify tfe client mocks to meet some new requirements
- Add plausible unredacted plan json for `plan-json-{basic,full}` testdata --
  Created by just running the relevant terraform commands locally.

- Add plan-json-no-changes testdata --
  The unredacted json was organically grown, but I edited the log and redacted
  json by hand to match what I observed from a real but unrelated
  planned-and-finished run in TFC.

- Add plan-json-basic-no-unredacted testdata --
  This mimics a lack of admin permissions, resulting in a 404.

- Hook up `MockPlans.ReadJSONOutput` to test fixtures, when present.
  This method has been implemented for ages, and has had a backing store for
  unredacted plan json, but has been effectively a no-op since nothing ever
  fills that backing store. So, when creating a mock plan, make an attempt to
  read unredacted json and stow it in the mocks on success.

- Make it possible to get the entire MockClient for a test backend
  In order to test some things, I'm going to need to mess with the internal
  state of runs and plans beyond what the go-tfe client API allows. I could add
  magic special-casing to the mock API methods, or I could locate the
  shenanigans next to the test that actually exploits it. The latter seems more
  comprehensible, but I need access to the full mock client struct in order to
  mess with its interior.

- Fill in some missing expectations around HasChanges when retrieving a run +
  plan.
2023-07-24 14:12:44 -04:00
Nick Fagerlund
ed27fa096e command/views/show_test: Update method arguments, add test cases 2023-07-24 14:12:44 -04:00
Nick Fagerlund
12af8518ff command/show_test: Update expected error text 2023-07-24 14:12:44 -04:00
Nick Fagerlund
3a9ce2afb1 Update show command and view to support inspecting cloud plans
One funny bit: We need to know the ViewType at the point where we ask the Cloud
backend for the plan JSON, because we need to switch between two distinctly
different formats for human show vs. `show -json`. I chose to pass that by
stashing it on the command struct; passing it as an argument would also work,
but one, the argument lists in these nested method calls were getting a little
unwieldy, and two, many of these functions had to be receiver methods anyway in
order to call methods on Meta.
2023-07-24 14:12:44 -04:00
Nick Fagerlund
d5938f6b45 Add (*Cloud).ShowPlanForRun method to support terraform show
To do the "human" version of showing a plan, we need more than just the redacted
plan JSON itself; we also need a bunch of extra information that only the Cloud
backend is in a position to find out (since it's the only one holding a
configured go-tfe client instance). So, this method takes a run ID and hostname,
finds out everything we're going to need, and returns it wrapped up in a
RemotePlanJSON struct.
2023-07-24 14:12:44 -04:00
Nick Fagerlund
e0af3e25e0 Add cloudplan.RemotePlanJSON wrapper struct for keeping plan metadata together 2023-07-24 14:12:44 -04:00