Update internal/states folder to OpenTofu (#465)

This commit is contained in:
Elbaz 2023-09-20 14:53:01 +03:00 committed by GitHub
parent c8acedd885
commit 8aad786548
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 16 deletions

View File

@ -94,8 +94,8 @@ func readState(src []byte) (*File, error) {
tfdiags.Error,
unsupportedFormat,
// This is a user-facing usage of Terraform but refers to a very old historical version of Terraform
// which has no corresponding OpenTF version, and is unlikely to get one.
// If we ever get OpenTF 0.6.16 and 0.7.x, we should update this message to mention OpenTF instead.
// which has no corresponding OpenTofu version, and is unlikely to get one.
// If we ever get OpenTofu 0.6.16 and 0.7.x, we should update this message to mention OpenTofu instead.
"The state is stored in a legacy binary format that is not supported since Terraform v0.7. To continue, first upgrade the state using Terraform 0.6.16 or earlier.",
))
return nil, errUnusable(diags.Err())
@ -135,13 +135,13 @@ func readState(src []byte) (*File, error) {
diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error,
unsupportedFormat,
fmt.Sprintf("The state file uses format version %d, which is not supported by OpenTF %s. This state file was created by OpenTF %s.", version, thisVersion, creatingVersion),
fmt.Sprintf("The state file uses format version %d, which is not supported by OpenTofu %s. This state file was created by OpenTofu %s.", version, thisVersion, creatingVersion),
))
default:
diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error,
unsupportedFormat,
fmt.Sprintf("The state file uses format version %d, which is not supported by OpenTF %s. This state file may have been created by a newer version of OpenTF.", version, thisVersion),
fmt.Sprintf("The state file uses format version %d, which is not supported by OpenTofu %s. This state file may have been created by a newer version of OpenTofu.", version, thisVersion),
))
}
}

View File

@ -63,9 +63,9 @@ func upgradeStateV3ToV4(old *stateV3) (*stateV4, error) {
//
// This is a user-facing usage of Terraform but refers to a very
// old historical version of Terraform which has no corresponding
// OpenTF version yet.
// If we ever get OpenTF 0.11.x and 0.12.x, we should update this
// message to mention OpenTF instead.
// OpenTofu version yet.
// If we ever get OpenTofu 0.11.x and 0.12.x, we should update this
// message to mention OpenTofu instead.
return nil, fmt.Errorf("state contains invalid module path %#v: %q is not a valid identifier; rename it in Terraform 0.11 before upgrading to Terraform 0.12", msOld.Path, name)
}
moduleAddr[i] = addrs.ModuleInstanceStep{
@ -124,9 +124,9 @@ func upgradeStateV3ToV4(old *stateV3) (*stateV4, error) {
//
// This is a user-facing usage of Terraform but refers
// to a very old historical version of Terraform
// which has no corresponding OpenTF version.
// If we ever get OpenTF 0.11.x and 0.12.x, we should
// update this message to mention OpenTF instead.
// which has no corresponding OpenTofu version.
// If we ever get OpenTofu 0.11.x and 0.12.x, we should
// update this message to mention OpenTofu instead.
return nil, fmt.Errorf("invalid provider config reference %q for %s: this alias seems to contain a template interpolation sequence, which was not supported but also not error-checked in Terraform 0.11. To proceed, rename the associated provider alias to a valid identifier and apply the change with Terraform 0.11 before upgrading to Terraform 0.12", oldProviderAddr, instAddr)
}
return nil, fmt.Errorf("invalid provider config reference %q for %s: %w", oldProviderAddr, instAddr, diags.Err())
@ -148,9 +148,9 @@ func upgradeStateV3ToV4(old *stateV3) (*stateV4, error) {
//
// This is a user-facing usage of Terraform but refers
// to a very old historical version of Terraform
// which has no corresponding OpenTF version.
// If we ever get OpenTF 0.11.x and 0.12.x, we should
// update this message to mention OpenTF instead.
// which has no corresponding OpenTofu version.
// If we ever get OpenTofu 0.11.x and 0.12.x, we should
// update this message to mention OpenTofu instead.
return nil, fmt.Errorf("invalid legacy provider config reference %q for %s: this alias seems to contain a template interpolation sequence, which was not supported but also not error-checked in Terraform 0.11. To proceed, rename the associated provider alias to a valid identifier and apply the change with Terraform 0.11 before upgrading to Terraform 0.12", oldProviderAddr, instAddr)
}
return nil, fmt.Errorf("invalid legacy provider config reference %q for %s: %w", oldProviderAddr, instAddr, diags.Err())

View File

@ -44,8 +44,8 @@ func prepareStateV4(sV4 *stateV4) (*File, tfdiags.Diagnostics) {
if err != nil {
diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error,
"Invalid OpenTF version string",
fmt.Sprintf("State file claims to have been written by OpenTF version %q, which is not a valid version string.", sV4.TerraformVersion),
"Invalid OpenTofu version string",
fmt.Sprintf("State file claims to have been written by OpenTofu version %q, which is not a valid version string.", sV4.TerraformVersion),
))
}
}
@ -427,7 +427,7 @@ func writeStateV4(file *File, w io.Writer) tfdiags.Diagnostics {
diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error,
"Failed to serialize state",
fmt.Sprintf("An error occured while serializing the state to save it. This is a bug in OpenTF and should be reported: %s.", err),
fmt.Sprintf("An error occured while serializing the state to save it. This is a bug in OpenTofu and should be reported: %s.", err),
))
return diags
}