7 "github.com/hashicorp/terraform/tfdiags"
10 func readStateV3(src []byte) (*File, tfdiags.Diagnostics) {
11 var diags tfdiags.Diagnostics
13 err := json.Unmarshal(src, sV3)
15 diags = diags.Append(jsonUnmarshalDiags(err))
19 file, prepDiags := prepareStateV3(sV3)
20 diags = diags.Append(prepDiags)
24 func prepareStateV3(sV3 *stateV3) (*File, tfdiags.Diagnostics) {
25 var diags tfdiags.Diagnostics
26 sV4, err := upgradeStateV3ToV4(sV3)
28 diags = diags.Append(tfdiags.Sourceless(
31 fmt.Sprintf("Error upgrading state file format from version 3 to version 4: %s.", err),
36 file, prepDiags := prepareStateV4(sV4)
37 diags = diags.Append(prepDiags)
41 // stateV2 is a representation of the legacy JSON state format version 3.
43 // It is only used to read version 3 JSON files prior to upgrading them to
44 // the current format.
46 // The differences between version 2 and version 3 are only in the data and
47 // not in the structure, so stateV3 actually shares the same structs as
48 // stateV2. Type stateV3 represents that the data within is formatted as
49 // expected by the V3 format, rather than the V2 format.