Merge pull request #12936 from hashicorp/b-state-v1

terraform: V1 to V2 upgrade should treat nil path as root path
This commit is contained in:
Mitchell Hashimoto 2017-03-21 11:24:08 -07:00 committed by GitHub
commit fe0733b560
2 changed files with 6 additions and 1 deletions

View File

@ -68,6 +68,11 @@ func (old *moduleStateV1) upgradeToV2() (*ModuleState, error) {
if err != nil {
return nil, fmt.Errorf("Error upgrading ModuleState V1: %v", err)
}
if path == nil {
// We found some V1 states with a nil path. Assume root and catch
// duplicate path errors later (as part of Validate).
path = rootModulePath
}
// Outputs needs upgrading to use the new structure
outputs := make(map[string]*OutputState)

View File

@ -18,7 +18,7 @@ func upgradeStateV2ToV3(old *State) (*State, error) {
// Ensure the copied version is v2 before attempting to upgrade
if new.Version != 2 {
return nil, fmt.Errorf("Cannot appply v2->v3 state upgrade to " +
return nil, fmt.Errorf("Cannot apply v2->v3 state upgrade to " +
"a state which is not version 2.")
}