Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further specify behaviour of terraform show #273

Merged
merged 4 commits into from
Jan 31, 2022
Merged

Further specify behaviour of terraform show #273

merged 4 commits into from
Jan 31, 2022

Conversation

kmoe
Copy link
Member

@kmoe kmoe commented Jan 26, 2022

Fixes nightly main test.

This PR aims to test all terraform show scenarios described in hashicorp/terraform#30344, and a few more.

Also adds a new error type, ErrStatePlanRead, which occurs when terraform show cannot read the state or plan file at the path given.

At present, running terraform show -json in a directory with a config file, but in which terraform init has not been run, results in inconsistent behaviour across versions:

  • All released versions: ErrNoInit and exit 1.
  • Tip of main (hashicorp/terraform@0d1a04e): Prints empty state ({"format_version":"1.0"}), exit 0.

See hashicorp/terraform#30415. The old behaviour is considered incorrect, and is therefore a Terraform CLI known issue prior to v1.2.0.

@kmoe kmoe self-assigned this Jan 26, 2022
@kmoe kmoe force-pushed the kmoe/fix-show-test branch from 213b6e0 to 2d0945f Compare January 28, 2022 12:30
@kmoe kmoe marked this pull request as ready for review January 28, 2022 12:30
@kmoe kmoe requested a review from radeksimko January 28, 2022 12:30
@kmoe kmoe removed their assignment Jan 28, 2022
`run:\s+terraform init`) // v1.1.0 (ref df578afd)
noInitErrRegexp = regexp.MustCompile(
// UNINITIALISED PROVIDERS/MODULES
`Error: Could not satisfy plugin requirements|` +
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gofmt and I are of differing opinions as to the best indentation for this section of code.

Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -1,4 +1,5 @@
// This file contains tests that only compile/work in Go 1.13 and forward
//go:build go1.13
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth running go fmt ./... on the whole project and update all go build lines? Doesn't have to be in this PR though...

On a related note I guess we forgot to update the Readme.md to say that we now require Go 1.17 (as per #216)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'll add both of those to #272 as a general tidy-up, so we can get this one merged and fix all the other CI.

@kmoe kmoe merged commit 4a54429 into main Jan 31, 2022
@kmoe kmoe deleted the kmoe/fix-show-test branch January 31, 2022 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants