fix: service state upgradeV2 for empty auth

which caused a panic. Closes #203.
This commit is contained in:
Manuel Vogel 2021-05-25 16:46:25 +02:00
parent a99c73c28b
commit ebe61896e9
No known key found for this signature in database
GPG key ID: 24E54F214569A8A5

View file

@ -9,7 +9,7 @@ import (
func resourceDockerServiceStateUpgradeV2(ctx context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) {
taskSpec, _ := rawState["task_spec"].([]interface{})[0].(map[string]interface{})
r, ok := taskSpec["restart_policy"]
if !ok && r == nil {
if !ok || r == nil {
taskSpec["restart_policy"] = []interface{}{}
} else {
restartPolicy := r.(map[string]interface{})
@ -20,7 +20,7 @@ func resourceDockerServiceStateUpgradeV2(ctx context.Context, rawState map[strin
}
a, ok := rawState["auth"]
if !ok && a == nil {
if !ok || a == nil {
rawState["auth"] = []interface{}{}
} else {
auth := a.(map[string]interface{})