opentofu/internal/states/statefile/write.go
Martin Atkins f40800b3a4 Move states/ to internal/states/
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.
2021-05-17 14:09:07 -07:00

27 lines
728 B
Go

package statefile
import (
"io"
tfversion "github.com/hashicorp/terraform/version"
)
// Write writes the given state to the given writer in the current state
// serialization format.
func Write(s *File, w io.Writer) error {
// Always record the current terraform version in the state.
s.TerraformVersion = tfversion.SemVer
diags := writeStateV4(s, w)
return diags.Err()
}
// WriteForTest writes the given state to the given writer in the current state
// serialization format without recording the current terraform version. This is
// intended for use in tests that need to override the current terraform
// version.
func WriteForTest(s *File, w io.Writer) error {
diags := writeStateV4(s, w)
return diags.Err()
}