Merge pull request #19374 from hashicorp/b-state-migration

Fix wildcard dependencies when upgrading states
This commit is contained in:
Sander van Harmelen 2018-11-15 17:11:52 +01:00 committed by GitHub
commit 7a268f1e48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 53 additions and 9 deletions

View File

@ -19,7 +19,8 @@
"null_resource.bar": {
"type": "null_resource",
"depends_on": [
"null_resource.foo"
"null_resource.foo.*",
"null_resource.foobar"
],
"primary": {
"id": "5388490630832483079",
@ -65,6 +66,22 @@
},
"deposed": [],
"provider": ""
},
"null_resource.foobar": {
"type": "null_resource",
"depends_on": [],
"primary": {
"id": "7388490630832483079",
"attributes": {
"id": "7388490630832483079",
"triggers.%": "1",
"triggers.whaaat": "0,1"
},
"meta": {},
"tainted": false
},
"deposed": [],
"provider": ""
}
},
"depends_on": []

View File

@ -23,7 +23,10 @@
"triggers.%": "1",
"triggers.whaaat": "0,1"
},
"depends_on": ["null_resource.foo"]
"depends_on": [
"null_resource.foo",
"null_resource.foobar"
]
}
]
},
@ -53,6 +56,22 @@
}
}
]
},
{
"mode": "managed",
"type": "null_resource",
"name": "foobar",
"provider": "provider.null",
"instances": [
{
"schema_version": 0,
"attributes_flat": {
"id": "7388490630832483079",
"triggers.%": "1",
"triggers.whaaat": "0,1"
}
}
]
}
]
}

View File

@ -299,12 +299,17 @@ func upgradeInstanceObjectV3ToV4(rsOld *resourceStateV2, isOld *instanceStateV2,
}
}
dependencies := make([]string, len(rsOld.Dependencies))
for i, v := range rsOld.Dependencies {
dependencies[i] = strings.TrimSuffix(v, ".*")
}
return &instanceObjectStateV4{
IndexKey: instKeyRaw,
Status: status,
Deposed: string(deposedKey),
AttributesFlat: attributes,
Dependencies: rsOld.Dependencies,
Dependencies: dependencies,
SchemaVersion: schemaVersion,
PrivateRaw: privateJSON,
}, nil

View File

@ -8,14 +8,15 @@ const (
_ValueSourceType_name_0 = "ValueFromUnknown"
_ValueSourceType_name_1 = "ValueFromCLIArg"
_ValueSourceType_name_2 = "ValueFromConfig"
_ValueSourceType_name_3 = "ValueFromEnvVarValueFromFile"
_ValueSourceType_name_3 = "ValueFromEnvVarValueFromAutoFile"
_ValueSourceType_name_4 = "ValueFromInput"
_ValueSourceType_name_5 = "ValueFromPlan"
_ValueSourceType_name_6 = "ValueFromCaller"
_ValueSourceType_name_5 = "ValueFromNamedFile"
_ValueSourceType_name_6 = "ValueFromPlan"
_ValueSourceType_name_7 = "ValueFromCaller"
)
var (
_ValueSourceType_index_3 = [...]uint8{0, 15, 28}
_ValueSourceType_index_3 = [...]uint8{0, 15, 32}
)
func (i ValueSourceType) String() string {
@ -31,10 +32,12 @@ func (i ValueSourceType) String() string {
return _ValueSourceType_name_3[_ValueSourceType_index_3[i]:_ValueSourceType_index_3[i+1]]
case i == 73:
return _ValueSourceType_name_4
case i == 80:
case i == 78:
return _ValueSourceType_name_5
case i == 83:
case i == 80:
return _ValueSourceType_name_6
case i == 83:
return _ValueSourceType_name_7
default:
return "ValueSourceType(" + strconv.FormatInt(int64(i), 10) + ")"
}