fix: panic to migrate schema of docker_container from v1 to v2 (#271). Closes #264

* Fix panic to migrate schema from v0 to v1
* Remove Computed setting from docker_container.env to suppress diff
* Remove Computed setting from docker_container.labels to suppress diff
This commit is contained in:
Shunsuke Suzuki 2020-08-03 01:25:44 +09:00 committed by GitHub
parent 06a1b8880a
commit 863fc4cb38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View file

@ -15,7 +15,14 @@ func replaceLabelsMapFieldWithSetField(rawState map[string]interface{}) map[stri
func migrateContainerLabels(rawState map[string]interface{}) map[string]interface{} {
replaceLabelsMapFieldWithSetField(rawState)
mounts := rawState["mounts"].([]interface{})
m, ok := rawState["mounts"]
if !ok || m == nil {
// https://github.com/terraform-providers/terraform-provider-docker/issues/264
rawState["mounts"] = []interface{}{}
return rawState
}
mounts := m.([]interface{})
newMounts := make([]interface{}, len(mounts))
for i, mountI := range mounts {
mount := mountI.(map[string]interface{})

View file

@ -459,7 +459,6 @@ func resourceDockerContainer() *schema.Resource {
Type: schema.TypeSet,
Optional: true,
ForceNew: true,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: schema.HashString,
},
@ -563,7 +562,6 @@ func resourceDockerContainer() *schema.Resource {
Type: schema.TypeSet,
Optional: true,
ForceNew: true,
Computed: true,
Elem: labelSchema,
},