chore: Add deprecation for docker_service.networks_advanced.name (#837)
Some checks are pending
Acc Tests / acc-test (TestAccDockerConfig, 0.15.x) (push) Waiting to run
Acc Tests / acc-test (TestAccDockerConfig, 1.8.x) (push) Waiting to run
Acc Tests / acc-test (TestAccDockerNetwork, 0.15.x) (push) Waiting to run
Acc Tests / acc-test (TestAccDockerNetwork, 1.8.x) (push) Waiting to run
Acc Tests / acc-test (TestAccDockerPlugin, 0.15.x) (push) Waiting to run
Acc Tests / acc-test (TestAccDockerPlugin, 1.8.x) (push) Waiting to run
Acc Tests / acc-test (TestAccDockerSecret, 0.15.x) (push) Waiting to run
Acc Tests / acc-test (TestAccDockerSecret, 1.8.x) (push) Waiting to run
Acc Tests / acc-test (TestAccDockerTag, 0.15.x) (push) Waiting to run
Acc Tests / acc-test (TestAccDockerTag, 1.8.x) (push) Waiting to run
Acc Tests / acc-test (TestAccDockerVolume, 0.15.x) (push) Waiting to run
Acc Tests / acc-test (TestAccDockerVolume, 1.8.x) (push) Waiting to run
Acc Tests / acc-test (true, TestAccDockerContainer, 0.15.x) (push) Waiting to run
Acc Tests / acc-test (true, TestAccDockerContainer, 1.8.x) (push) Waiting to run
Acc Tests / acc-test (true, TestAccDockerImage, 0.15.x) (push) Waiting to run
Acc Tests / acc-test (true, TestAccDockerImage, 1.8.x) (push) Waiting to run
Acc Tests / acc-test (true, TestAccDockerRegistryImage, 0.15.x) (push) Waiting to run
Acc Tests / acc-test (true, TestAccDockerRegistryImage, 1.8.x) (push) Waiting to run
Acc Tests / acc-test (true, TestAccDockerService, 0.15.x) (push) Waiting to run
Acc Tests / acc-test (true, TestAccDockerService, 1.8.x) (push) Waiting to run
Compile Binaries / compile-fast (push) Waiting to run
Compile Binaries / compile (push) Waiting to run
golangci-lint / lint (push) Waiting to run
Unit Tests / unit-test (push) Waiting to run
Website Checks / markdown-link-check (push) Waiting to run
Docs and Website Lint / website-generation (push) Waiting to run
Docs and Website Lint / website-lint-spellcheck-tffmt (push) Waiting to run
Docs and Website Lint / markdown-lint (push) Waiting to run

This commit is contained in:
Martin 2026-01-20 23:43:28 +01:00 committed by GitHub
parent 8bacb0d8c8
commit 2890a9e77d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 43 additions and 20 deletions

View file

@ -22,7 +22,9 @@
The documentation for the provider is available on the [Terraform Registry](https://registry.terraform.io/providers/kreuzwerker/docker/latest/docs).
Do you want to migrate from `v2.x` to `v3.x`? Please read the [migration guide](docs/v2_v3_migration.md)
Migration guides:
* Do you want to migrate from `v3.x` to `v4.x`? Please read the [V3 - V4 migration guide](docs/v3_v4_migration.md)
* Do you want to migrate from `v2.x` to `v3.x`? Please read the [V2 - V3 migration guide](docs/v2_v3_migration.md)
## Example usage

View file

@ -28,7 +28,6 @@ resource "docker_network" "private_network" {
### Optional
- `attachable` (Boolean) Enable manual container attachment to the network.
- `check_duplicate` (Boolean, Deprecated) Requests daemon to check for networks with same name.
- `driver` (String) The driver of the Docker network. Possible values are `bridge`, `host`, `overlay`, `macvlan`. See [network docs](https://docs.docker.com/network/#network-drivers) for more details.
- `ingress` (Boolean) Create swarm routing-mesh network. Defaults to `false`.
- `internal` (Boolean) Whether the network is internal.

View file

@ -558,14 +558,12 @@ Optional:
<a id="nestedblock--task_spec--networks_advanced"></a>
### Nested Schema for `task_spec.networks_advanced`
Required:
- `name` (String) The name/id of the network.
Optional:
- `aliases` (Set of String) The network aliases of the container in the specific network.
- `driver_opts` (Set of String) An array of driver options for the network, e.g. `opts1=value`
- `id` (String) The id of the docker network to use. Please use `docker_network.id`. Using the name attribute of the docker network will lead to constant replacements.
- `name` (String, Deprecated) Deprecated attribute. The name/id of the docker network. Conflicts with `id` attribute.
<a id="nestedblock--task_spec--placement"></a>

18
docs/v3_v4_migration.md Normal file
View file

@ -0,0 +1,18 @@
# V3 to V4 Migration Guide
## `docker_network`
Removed attributes:
* `check_duplicate`
## `docker_service`
New attribute:
* `networks_advanced.id`
Deprecated attribute:
* `networks_advanced.name`: Replaced by `id` attribute to make it clear that the `docker_network.id` needs to be used to prevent constant recreation of the service

View file

@ -37,14 +37,6 @@ func resourceDockerNetwork() *schema.Resource {
Elem: labelSchema,
},
"check_duplicate": {
Type: schema.TypeBool,
Description: "Requests daemon to check for networks with same name.",
Optional: true,
ForceNew: true,
Deprecated: "This option is deprecated and will be removed in a future version. The Docker daemon will always check for duplicate networks.",
},
"driver": {
Type: schema.TypeString,
Description: "The driver of the Docker network. Possible values are `bridge`, `host`, `overlay`, `macvlan`. See [network docs](https://docs.docker.com/network/#network-drivers) for more details.",

View file

@ -78,7 +78,6 @@ func resourceDockerNetworkCreate(ctx context.Context, d *schema.ResourceData, me
}
d.SetId(retNetwork.ID)
// d.Set("check_duplicate") TODO mavogel
return resourceDockerNetworkRead(ctx, d, meta)
}

View file

@ -700,9 +700,16 @@ func resourceDockerService() *schema.Resource {
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Description: "The name/id of the network.",
Required: true,
Description: "Deprecated attribute. The name/id of the docker network. Conflicts with `id` attribute.",
ForceNew: true,
Optional: true,
Deprecated: "Use the id attribute.",
},
"id": {
Type: schema.TypeString,
Description: "The id of the docker network to use. Please use `docker_network.id`. Using the name attribute of the docker network will lead to constant replacements.",
ForceNew: true,
Optional: true,
},
"aliases": {
Type: schema.TypeSet,

View file

@ -1,6 +1,7 @@
package provider
import (
"fmt"
"log"
"os"
"strconv"
@ -515,7 +516,7 @@ func flattenTaskNetworksAdvanced(in []swarm.NetworkAttachmentConfig) *schema.Set
out := make([]interface{}, len(in))
for i, v := range in {
m := make(map[string]interface{})
m["name"] = v.Target
m["id"] = v.Target
m["driver_opts"] = stringSliceToSchemaSet(mapTypeMapValsToStringSlice(mapStringStringToMapStringInterface(v.DriverOpts)))
if len(v.Aliases) > 0 {
m["aliases"] = stringSliceToSchemaSet(v.Aliases)
@ -1112,7 +1113,14 @@ func createServiceAdvancedNetworks(v interface{}) ([]swarm.NetworkAttachmentConf
if len(v.(*schema.Set).List()) > 0 {
for _, rawNetwork := range v.(*schema.Set).List() {
rawNetwork := rawNetwork.(map[string]interface{})
networkID := rawNetwork["name"].(string)
networkID := ""
if id, ok := rawNetwork["id"]; ok && id.(string) != "" {
networkID = id.(string)
} else if name, ok := rawNetwork["name"]; ok && name.(string) != "" {
networkID = name.(string)
} else {
return networks, fmt.Errorf("network 'name' or 'id' must be specified")
}
networkAliases := stringSetToStringSlice(rawNetwork["aliases"].(*schema.Set))
network := swarm.NetworkAttachmentConfig{
Target: networkID,

View file

@ -177,7 +177,7 @@ resource "docker_service" "foo" {
runtime = "container"
networks_advanced {
name = docker_network.test_network.id
id = docker_network.test_network.id
aliases = ["tftest-foobar"]
driver_opts = [
"foo=bar"