mirror of
https://github.com/kreuzwerker/terraform-provider-docker.git
synced 2026-02-16 09:08:52 -05:00
docs: add network resource generation
This commit is contained in:
parent
683c437b59
commit
c2f3032d31
5 changed files with 100 additions and 73 deletions
|
|
@ -30,7 +30,7 @@ data "docker_network" "main" {
|
|||
|
||||
- **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.
|
||||
- **internal** (Boolean) Whether the network is internal.
|
||||
- **ipam_config** (Set of Object) IPAM configuration options (see [below for nested schema](#nestedatt--ipam_config))
|
||||
- **ipam_config** (Set of Object) The IPAM configuration options (see [below for nested schema](#nestedatt--ipam_config))
|
||||
- **options** (Map of String) Only available with bridge networks. See [bridge options docs](https://docs.docker.com/engine/reference/commandline/network_create/#bridge-driver-options) for more details.
|
||||
- **scope** (String) Scope of the network. One of `swarm`, `global`, or `local`.
|
||||
|
||||
|
|
|
|||
|
|
@ -3,49 +3,55 @@
|
|||
page_title: "docker_network Resource - terraform-provider-docker"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
|
||||
docker_network provides details about a specific Docker Network.
|
||||
---
|
||||
|
||||
# docker_network (Resource)
|
||||
|
||||
`docker_network` provides details about a specific Docker Network.
|
||||
|
||||
## Example Usage
|
||||
|
||||
|
||||
```terraform
|
||||
resource "docker_network" "private_network" {
|
||||
name = "my_network"
|
||||
}
|
||||
```
|
||||
|
||||
<!-- schema generated by tfplugindocs -->
|
||||
## Schema
|
||||
|
||||
### Required
|
||||
|
||||
- **name** (String)
|
||||
- **name** (String) The name of the Docker network.
|
||||
|
||||
### Optional
|
||||
|
||||
- **attachable** (Boolean)
|
||||
- **check_duplicate** (Boolean)
|
||||
- **driver** (String)
|
||||
- **attachable** (Boolean) Enable manual container attachment to the network.
|
||||
- **check_duplicate** (Boolean) 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.
|
||||
- **id** (String) The ID of this resource.
|
||||
- **ingress** (Boolean)
|
||||
- **internal** (Boolean)
|
||||
- **ipam_config** (Block Set) (see [below for nested schema](#nestedblock--ipam_config))
|
||||
- **ipam_driver** (String)
|
||||
- **ipv6** (Boolean)
|
||||
- **labels** (Block Set) (see [below for nested schema](#nestedblock--labels))
|
||||
- **options** (Map of String)
|
||||
- **ingress** (Boolean) Create swarm routing-mesh network.Defaults to `false`.
|
||||
- **internal** (Boolean) Whether the network is internal.
|
||||
- **ipam_config** (Block Set) The IPAM configuration options (see [below for nested schema](#nestedblock--ipam_config))
|
||||
- **ipam_driver** (String) Driver used by the custom IP scheme of the network.
|
||||
- **ipv6** (Boolean) Enable IPv6 networking. Defaults to `false`.
|
||||
- **labels** (Block Set) User-defined key/value metadata (see [below for nested schema](#nestedblock--labels))
|
||||
- **options** (Map of String) Only available with bridge networks. See [bridge options docs](https://docs.docker.com/engine/reference/commandline/network_create/#bridge-driver-options) for more details.
|
||||
|
||||
### Read-Only
|
||||
|
||||
- **scope** (String)
|
||||
- **scope** (String) Scope of the network. One of `swarm`, `global`, or `local`.
|
||||
|
||||
<a id="nestedblock--ipam_config"></a>
|
||||
### Nested Schema for `ipam_config`
|
||||
|
||||
Optional:
|
||||
|
||||
- **aux_address** (Map of String)
|
||||
- **gateway** (String)
|
||||
- **ip_range** (String)
|
||||
- **subnet** (String)
|
||||
- **aux_address** (Map of String) Auxiliary IPv4 or IPv6 addresses used by Network driver
|
||||
- **gateway** (String) The IP address of the gateway
|
||||
- **ip_range** (String) The ip range in CIDR form
|
||||
- **subnet** (String) The subnet in CIDR form
|
||||
|
||||
|
||||
<a id="nestedblock--labels"></a>
|
||||
|
|
|
|||
3
examples/resources/docker_network/resource.tf
Normal file
3
examples/resources/docker_network/resource.tf
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
resource "docker_network" "private_network" {
|
||||
name = "my_network"
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ func dataSourceDockerNetwork() *schema.Resource {
|
|||
|
||||
"ipam_config": {
|
||||
Type: schema.TypeSet,
|
||||
Description: "IPAM configuration options",
|
||||
Description: "The IPAM configuration options",
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import (
|
|||
|
||||
func resourceDockerNetwork() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
Description: "`docker_network` provides details about a specific Docker Network.",
|
||||
|
||||
CreateContext: resourceDockerNetworkCreate,
|
||||
ReadContext: resourceDockerNetworkRead,
|
||||
DeleteContext: resourceDockerNetworkDelete,
|
||||
|
|
@ -21,108 +23,124 @@ func resourceDockerNetwork() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
Type: schema.TypeString,
|
||||
Description: "The name of the Docker network.",
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"labels": {
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Elem: labelSchema,
|
||||
Type: schema.TypeSet,
|
||||
Description: "User-defined key/value metadata",
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Elem: labelSchema,
|
||||
},
|
||||
|
||||
"check_duplicate": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Type: schema.TypeBool,
|
||||
Description: "Requests daemon to check for networks with same name.",
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"driver": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Computed: true,
|
||||
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.",
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"options": {
|
||||
Type: schema.TypeMap,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Computed: true,
|
||||
Type: schema.TypeMap,
|
||||
Description: "Only available with bridge networks. See [bridge options docs](https://docs.docker.com/engine/reference/commandline/network_create/#bridge-driver-options) for more details.",
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"internal": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
Type: schema.TypeBool,
|
||||
Description: "Whether the network is internal.",
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"attachable": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Type: schema.TypeBool,
|
||||
Description: "Enable manual container attachment to the network.",
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"ingress": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Type: schema.TypeBool,
|
||||
Description: "Create swarm routing-mesh network.Defaults to `false`.",
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"ipv6": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Type: schema.TypeBool,
|
||||
Description: "Enable IPv6 networking. Defaults to `false`.",
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"ipam_driver": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Default: "default",
|
||||
Type: schema.TypeString,
|
||||
Description: "Driver used by the custom IP scheme of the network.",
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Default: "default",
|
||||
},
|
||||
|
||||
"ipam_config": {
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
Type: schema.TypeSet,
|
||||
Description: "The IPAM configuration options",
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
// DiffSuppressFunc: suppressIfIPAMConfigWithIpv6Changes(),
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"subnet": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Type: schema.TypeString,
|
||||
Description: "The subnet in CIDR form",
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"ip_range": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Type: schema.TypeString,
|
||||
Description: "The ip range in CIDR form",
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"gateway": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Type: schema.TypeString,
|
||||
Description: "The IP address of the gateway",
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"aux_address": {
|
||||
Type: schema.TypeMap,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Type: schema.TypeMap,
|
||||
Description: "Auxiliary IPv4 or IPv6 addresses used by Network driver",
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
"scope": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Type: schema.TypeString,
|
||||
Description: "Scope of the network. One of `swarm`, `global`, or `local`.",
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
SchemaVersion: 1,
|
||||
|
|
|
|||
Loading…
Reference in a new issue