diff --git a/CHANGELOG.md b/CHANGELOG.md index 220314aa..e8879177 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ ## 1.0.1 (Unreleased) + +BUG FIXES +* Fixes empty strings on mapping from map to slice causes GH-81 + ## 1.0.0 (July 03, 2018) NOTES: @@ -6,9 +10,9 @@ NOTES: * The `links` property on `resource_docker_container` is now marked as deprecated [#47](https://github.com/terraform-providers/terraform-provider-docker/pull/47) FEATURES: -* Add `swarm` capabilities ([#29](https://github.com/terraform-providers/terraform-provider-docker/issues/29)] [#40](https://github.com/terraform-providers/terraform-provider-docker/pull/40) with fixes [#66](https://github.com/terraform-providers/terraform-provider-docker/pull/66) up to Docker `18.03.1` and API Version `1.37` [[#64](https://github.com/terraform-providers/terraform-provider-docker/issues/64)) +* Add `swarm` capabilities ([#29](https://github.com/terraform-providers/terraform-provider-docker/issues/29), [#40](https://github.com/terraform-providers/terraform-provider-docker/pull/40) which fixes [#66](https://github.com/terraform-providers/terraform-provider-docker/pull/66) up to Docker `18.03.1` and API Version `1.37` ([#64](https://github.com/terraform-providers/terraform-provider-docker/issues/64)) * Add ability to upload executable files [#55](https://github.com/terraform-providers/terraform-provider-docker/pull/55) -* Add support to attach devices to containers [[#30](https://github.com/terraform-providers/terraform-provider-docker/issues/30)] [#54](https://github.com/terraform-providers/terraform-provider-docker/pull/54) +* Add support to attach devices to containers [#30](https://github.com/terraform-providers/terraform-provider-docker/issues/30), [#54](https://github.com/terraform-providers/terraform-provider-docker/pull/54) * Add Ulimits to containers [#35](https://github.com/terraform-providers/terraform-provider-docker/pull/35) IMPROVEMENTS: diff --git a/docker/resource_docker_container_funcs.go b/docker/resource_docker_container_funcs.go index 0ee3690b..8be51f4d 100644 --- a/docker/resource_docker_container_funcs.go +++ b/docker/resource_docker_container_funcs.go @@ -387,9 +387,11 @@ func mapTypeMapValsToString(typeMap map[string]interface{}) map[string]string { // mapTypeMapValsToStringSlice maps a map to a slice with '=': e.g. foo = "bar" -> 'foo=bar' func mapTypeMapValsToStringSlice(typeMap map[string]interface{}) []string { - mapped := make([]string, len(typeMap)) + mapped := make([]string, 0) for k, v := range typeMap { - mapped = append(mapped, k+"="+v.(string)) + if len(k) > 0 { + mapped = append(mapped, k+"="+v.(string)) + } } return mapped } diff --git a/docker/resource_docker_container_test.go b/docker/resource_docker_container_test.go index 5fd3526e..ca23e8f3 100644 --- a/docker/resource_docker_container_test.go +++ b/docker/resource_docker_container_test.go @@ -14,6 +14,16 @@ import ( "github.com/hashicorp/terraform/terraform" ) +func TestMapTypeMapValsToStringSlice(t *testing.T) { + typeMap := make(map[string]interface{}) + typeMap["foo"] = "bar" + typeMap[""] = "" + stringSlice := mapTypeMapValsToStringSlice(typeMap) + if len(stringSlice) != 1 { + t.Fatalf("slice should have length 1 but has %v", len(stringSlice)) + } +} + func TestAccDockerContainer_basic(t *testing.T) { var c types.ContainerJSON resource.Test(t, resource.TestCase{