mirror of
https://github.com/kreuzwerker/terraform-provider-docker.git
synced 2025-12-30 03:29:39 -05:00
fix: assign map to rawState when it is nil to prevent panic (#180)
* fix: assign map to rawState when it is nil to prevent panic * refactor: return nil
This commit is contained in:
parent
2845519dce
commit
f8d20403bd
1 changed files with 8 additions and 0 deletions
|
|
@ -908,6 +908,9 @@ func updateV0ToV1PortsOrder(is *terraform.InstanceState, meta interface{}) error
|
|||
}
|
||||
|
||||
func replaceLabelsMapFieldWithSetField(rawState map[string]interface{}) map[string]interface{} {
|
||||
if rawState == nil {
|
||||
return nil
|
||||
}
|
||||
labelMapIFace := rawState["labels"]
|
||||
if labelMapIFace != nil {
|
||||
labelMap := labelMapIFace.(map[string]interface{})
|
||||
|
|
@ -920,6 +923,11 @@ func replaceLabelsMapFieldWithSetField(rawState map[string]interface{}) map[stri
|
|||
}
|
||||
|
||||
func migrateContainerLabels(rawState map[string]interface{}) map[string]interface{} {
|
||||
if rawState == nil {
|
||||
// https://github.com/kreuzwerker/terraform-provider-docker/issues/176
|
||||
// to prevent error `assignment to entry in nil map`
|
||||
rawState = map[string]interface{}{}
|
||||
}
|
||||
replaceLabelsMapFieldWithSetField(rawState)
|
||||
|
||||
m, ok := rawState["mounts"]
|
||||
|
|
|
|||
Loading…
Reference in a new issue