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, tfdiags.Error,
unsupportedFormat, unsupportedFormat,
// This is a user-facing usage of Terraform but refers to a very old historical version of Terraform // 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. // which has no corresponding OpenTofu 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. // 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.", "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()) return nil, errUnusable(diags.Err())
@ -135,13 +135,13 @@ func readState(src []byte) (*File, error) {
diags = diags.Append(tfdiags.Sourceless( diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error, tfdiags.Error,
unsupportedFormat, 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: default:
diags = diags.Append(tfdiags.Sourceless( diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error, tfdiags.Error,
unsupportedFormat, 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 // This is a user-facing usage of Terraform but refers to a very
// old historical version of Terraform which has no corresponding // old historical version of Terraform which has no corresponding
// OpenTF version yet. // OpenTofu version yet.
// If we ever get OpenTF 0.11.x and 0.12.x, we should update this // If we ever get OpenTofu 0.11.x and 0.12.x, we should update this
// message to mention OpenTF instead. // 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) 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{ moduleAddr[i] = addrs.ModuleInstanceStep{
@ -124,9 +124,9 @@ func upgradeStateV3ToV4(old *stateV3) (*stateV4, error) {
// //
// This is a user-facing usage of Terraform but refers // This is a user-facing usage of Terraform but refers
// to a very old historical version of Terraform // to a very old historical version of Terraform
// which has no corresponding OpenTF version. // which has no corresponding OpenTofu version.
// If we ever get OpenTF 0.11.x and 0.12.x, we should // If we ever get OpenTofu 0.11.x and 0.12.x, we should
// update this message to mention OpenTF instead. // 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: 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()) 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 // This is a user-facing usage of Terraform but refers
// to a very old historical version of Terraform // to a very old historical version of Terraform
// which has no corresponding OpenTF version. // which has no corresponding OpenTofu version.
// If we ever get OpenTF 0.11.x and 0.12.x, we should // If we ever get OpenTofu 0.11.x and 0.12.x, we should
// update this message to mention OpenTF instead. // 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: 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()) 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 { if err != nil {
diags = diags.Append(tfdiags.Sourceless( diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error, tfdiags.Error,
"Invalid OpenTF version string", "Invalid OpenTofu version string",
fmt.Sprintf("State file claims to have been written by OpenTF version %q, which is not a valid version string.", sV4.TerraformVersion), 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( diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error, tfdiags.Error,
"Failed to serialize state", "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 return diags
} }