Merge pull request #7370 from tpounds/show-tf-ver-on-state-mismatch

Show Terraform version on state version mismatch.
This commit is contained in:
Paul Hinze 2016-06-29 10:48:13 -05:00 committed by GitHub
commit 40fbb8d2e8
2 changed files with 7 additions and 7 deletions

View File

@ -1496,8 +1496,8 @@ func ReadState(src io.Reader) (*State, error) {
} }
return v3State, nil return v3State, nil
default: default:
return nil, fmt.Errorf("State version %d not supported, please update.", return nil, fmt.Errorf("Terraform %s does not support state version %d, please update.",
versionIdentifier.Version) SemVersion.String(), versionIdentifier.Version)
} }
} }
@ -1524,8 +1524,8 @@ func ReadStateV2(jsonBytes []byte) (*State, error) {
// Check the version, this to ensure we don't read a future // Check the version, this to ensure we don't read a future
// version that we don't understand // version that we don't understand
if state.Version > StateVersion { if state.Version > StateVersion {
return nil, fmt.Errorf("State version %d not supported, please update.", return nil, fmt.Errorf("Terraform %s does not support state version %d, please update.",
state.Version) SemVersion.String(), state.Version)
} }
// Make sure the version is semantic // Make sure the version is semantic
@ -1556,8 +1556,8 @@ func ReadStateV3(jsonBytes []byte) (*State, error) {
// Check the version, this to ensure we don't read a future // Check the version, this to ensure we don't read a future
// version that we don't understand // version that we don't understand
if state.Version > StateVersion { if state.Version > StateVersion {
return nil, fmt.Errorf("State version %d not supported, please update.", return nil, fmt.Errorf("Terraform %s does not support state version %d, please update.",
state.Version) SemVersion.String(), state.Version)
} }
// Make sure the version is semantic // Make sure the version is semantic

View File

@ -1348,7 +1348,7 @@ func TestReadStateNewVersion(t *testing.T) {
if s != nil { if s != nil {
t.Fatalf("unexpected: %#v", s) t.Fatalf("unexpected: %#v", s)
} }
if !strings.Contains(err.Error(), "not supported") { if !strings.Contains(err.Error(), "does not support state version") {
t.Fatalf("err: %v", err) t.Fatalf("err: %v", err)
} }
} }