* 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!
Previously "terraform console" always evaluated in a kinda strange context
where resource instance data comes from the prior state, but other derived
of values end up being calculated dynamically based on the current
configuration, which is okay for simple cases but can be confusing if the
configuration has changed significantly since the most recent apply, or
if there haven't yet been any applied changes.
Now we'll allow an optional new mode where Terraform runs the normal plan
phase (as if running "terraform plan") and then uses the resulting
_planned state_ as the basis for evaluation, allowing evaluation against
a partial approximation of what the world ought to look like if these
changes were applied, without having to actually apply them first.
As with the previous use of the eval walk, it's possible that an erroneous
situation will still produce a partial evaluation scope, and so the
console still allows evaluation against that scope but with a caveat that
it might produce unexpected results. In practice this can be useful for
debugging situations like when unknown values block planning of an object,
to allow inspection of the values that are contributing to that blocked
planning operation even though the plan is not yet complete.
Previously, there was mixed usage of "(sensitive)" and "(sensitive value)" and even though it was more common to see "(sensitive)", the thought is that it's a value we are hiding rather than describing something already shown.
This commit replaces `ioutil.TempDir` with `t.TempDir` in tests. The
directory created by `t.TempDir` is automatically removed when the test
and all its subtests complete.
Prior to this commit, temporary directory created using `ioutil.TempDir`
needs to be removed manually by calling `os.RemoveAll`, which is omitted
in some tests. The error handling boilerplate e.g.
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Fatal(err)
}
}
is also tedious, but `t.TempDir` handles this for us nicely.
Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This is part of a general effort to move all of Terraform's non-library
package surface under internal in order to reinforce that these are for
internal use within Terraform only.
If you were previously importing packages under this prefix into an
external codebase, you could pin to an earlier release tag as an interim
solution until you've make a plan to achieve the same functionality some
other way.
This is part of a general effort to move all of Terraform's non-library
package surface under internal in order to reinforce that these are for
internal use within Terraform only.
If you were previously importing packages under this prefix into an
external codebase, you could pin to an earlier release tag as an interim
solution until you've make a plan to achieve the same functionality some
other way.