mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Adapt user-facing usages of terraform in internal/states (#133)
This commit is contained in:
parent
a9a78c000d
commit
26c2e3a4d1
@ -94,6 +94,9 @@ func readState(src []byte) (*File, error) {
|
||||
diags = diags.Append(tfdiags.Sourceless(
|
||||
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.
|
||||
"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())
|
||||
@ -133,13 +136,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 Terraform %s. This state file was created by Terraform %s.", version, thisVersion, creatingVersion),
|
||||
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),
|
||||
))
|
||||
default:
|
||||
diags = diags.Append(tfdiags.Sourceless(
|
||||
tfdiags.Error,
|
||||
unsupportedFormat,
|
||||
fmt.Sprintf("The state file uses format version %d, which is not supported by Terraform %s. This state file may have been created by a newer version of Terraform.", version, thisVersion),
|
||||
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),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
@ -60,6 +60,12 @@ func upgradeStateV3ToV4(old *stateV3) (*stateV4, error) {
|
||||
// version 4 which subsequent operations will reject, so we'll
|
||||
// fail early here for safety to make sure we can never
|
||||
// inadvertently commit an invalid snapshot to a backend.
|
||||
//
|
||||
// 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.
|
||||
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{
|
||||
@ -115,6 +121,12 @@ func upgradeStateV3ToV4(old *stateV3) (*stateV4, error) {
|
||||
// interpolation was valid in provider aliases
|
||||
// in 0.11, so we'll use a specialized error
|
||||
// message for that case.
|
||||
//
|
||||
// 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.
|
||||
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: %s", oldProviderAddr, instAddr, diags.Err())
|
||||
@ -133,6 +145,12 @@ func upgradeStateV3ToV4(old *stateV3) (*stateV4, error) {
|
||||
// interpolation was valid in provider aliases
|
||||
// in 0.11, so we'll use a specialized error
|
||||
// message for that case.
|
||||
//
|
||||
// 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.
|
||||
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: %s", oldProviderAddr, instAddr, diags.Err())
|
||||
|
@ -44,8 +44,8 @@ func prepareStateV4(sV4 *stateV4) (*File, tfdiags.Diagnostics) {
|
||||
if err != nil {
|
||||
diags = diags.Append(tfdiags.Sourceless(
|
||||
tfdiags.Error,
|
||||
"Invalid Terraform version string",
|
||||
fmt.Sprintf("State file claims to have been written by Terraform version %q, which is not a valid version string.", sV4.TerraformVersion),
|
||||
"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),
|
||||
))
|
||||
}
|
||||
}
|
||||
@ -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 Terraform and should be reported: %s.", err),
|
||||
fmt.Sprintf("An error occured while serializing the state to save it. This is a bug in OpenTF and should be reported: %s.", err),
|
||||
))
|
||||
return diags
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user