mirror of
https://github.com/kreuzwerker/terraform-provider-docker.git
synced 2025-12-24 16:49:41 -05:00
Fix no-op in container when all 'ports' blocks are deleted. (#168)
* docker_container Fix no-op when all port blocks are deleted * Update changelog for v2.1.1 * Closes #167
This commit is contained in:
parent
f02d302323
commit
53f74755e4
3 changed files with 19 additions and 3 deletions
|
|
@ -1,4 +1,8 @@
|
||||||
## 2.1.1 (Unreleased)
|
## 2.1.1 (Unreleased)
|
||||||
|
|
||||||
|
BUG FIXES
|
||||||
|
* Fixes 'No changes' for containers when all port blocks have been removed ([#167](https://github.com/terraform-providers/terraform-provider-docker/issues/167))
|
||||||
|
|
||||||
## 2.1.0 (July 19, 2019)
|
## 2.1.0 (July 19, 2019)
|
||||||
|
|
||||||
IMPROVEMENTS
|
IMPROVEMENTS
|
||||||
|
|
|
||||||
|
|
@ -718,6 +718,10 @@ func resourceDockerContainer() *schema.Resource {
|
||||||
|
|
||||||
func suppressIfPortsDidNotChangeForMigrationV0ToV1() schema.SchemaDiffSuppressFunc {
|
func suppressIfPortsDidNotChangeForMigrationV0ToV1() schema.SchemaDiffSuppressFunc {
|
||||||
return func(k, old, new string, d *schema.ResourceData) bool {
|
return func(k, old, new string, d *schema.ResourceData) bool {
|
||||||
|
if k == "ports.#" && old != new {
|
||||||
|
log.Printf("[DEBUG] suppress diff ports: old and new don't have the same length")
|
||||||
|
return false
|
||||||
|
}
|
||||||
portsOldRaw, portsNewRaw := d.GetChange("ports")
|
portsOldRaw, portsNewRaw := d.GetChange("ports")
|
||||||
portsOld := portsOldRaw.([]interface{})
|
portsOld := portsOldRaw.([]interface{})
|
||||||
portsNew := portsNewRaw.([]interface{})
|
portsNew := portsNewRaw.([]interface{})
|
||||||
|
|
|
||||||
|
|
@ -717,6 +717,14 @@ func TestAccDockerContainer_port(t *testing.T) {
|
||||||
resource.TestCheckResourceAttr("docker_container.foo", "ports.0.external", "32787"),
|
resource.TestCheckResourceAttr("docker_container.foo", "ports.0.external", "32787"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Config: testAccDockerContainerConfig,
|
||||||
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
testAccContainerRunning("docker_container.foo", &c),
|
||||||
|
resource.TestCheckResourceAttr("docker_container.foo", "name", "tf-test"),
|
||||||
|
resource.TestCheckResourceAttr("docker_container.foo", "ports.#", "0"),
|
||||||
|
),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue