provider: Ensured Go 1.11 in TravisCI and README

provider: Run go fix
provider: Run go fmt
provider: Encode go version 1.11.5 to .go-version file
This commit is contained in:
Alex Pilon 2019-03-01 16:02:17 -05:00
parent d524630c3a
commit aab8fac508
No known key found for this signature in database
GPG key ID: 95659F6AEFC48D7E
20 changed files with 354 additions and 353 deletions

1
.go-version Normal file
View file

@ -0,0 +1 @@
1.11.5

View file

@ -4,7 +4,7 @@ services:
- docker - docker
language: go language: go
go: go:
- 1.9.1 - "1.11.x"
before_install: before_install:
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

View file

@ -11,7 +11,7 @@ Requirements
------------ ------------
- [Terraform](https://www.terraform.io/downloads.html) 0.10.x - [Terraform](https://www.terraform.io/downloads.html) 0.10.x
- [Go](https://golang.org/doc/install) 1.9.1 (to build the provider plugin) - [Go](https://golang.org/doc/install) 1.11.1 (to build the provider plugin)
Building The Provider Building The Provider
--------------------- ---------------------
@ -37,7 +37,7 @@ Using the provider
Developing the Provider Developing the Provider
--------------------------- ---------------------------
If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (version 1.8+ is *required*). You'll also need to correctly setup a [GOPATH](http://golang.org/doc/code.html#GOPATH), as well as adding `$GOPATH/bin` to your `$PATH`. If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (version 1.11+ is *required*). You'll also need to correctly setup a [GOPATH](http://golang.org/doc/code.html#GOPATH), as well as adding `$GOPATH/bin` to your `$PATH`.
To compile the provider, run `make build`. This will build the provider and put the provider binary in the `$GOPATH/bin` directory. To compile the provider, run `make build`. This will build the provider and put the provider binary in the `$GOPATH/bin` directory.

View file

@ -19,12 +19,12 @@ func dataSourceDockerRegistryImage() *schema.Resource {
Read: dataSourceDockerRegistryImageRead, Read: dataSourceDockerRegistryImageRead,
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"name": &schema.Schema{ "name": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
}, },
"sha256_digest": &schema.Schema{ "sha256_digest": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },

View file

@ -16,7 +16,7 @@ func TestAccDockerRegistryImage_basic(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerImageDataSourceConfig, Config: testAccDockerImageDataSourceConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
resource.TestMatchResourceAttr("data.docker_registry_image.foo", "sha256_digest", registryDigestRegexp), resource.TestMatchResourceAttr("data.docker_registry_image.foo", "sha256_digest", registryDigestRegexp),
@ -31,7 +31,7 @@ func TestAccDockerRegistryImage_private(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerImageDataSourcePrivateConfig, Config: testAccDockerImageDataSourcePrivateConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
resource.TestMatchResourceAttr("data.docker_registry_image.bar", "sha256_digest", registryDigestRegexp), resource.TestMatchResourceAttr("data.docker_registry_image.bar", "sha256_digest", registryDigestRegexp),
@ -48,7 +48,7 @@ func TestAccDockerRegistryImage_auth(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: fmt.Sprintf(testAccDockerImageDataSourceAuthConfig, registry, image), Config: fmt.Sprintf(testAccDockerImageDataSourceAuthConfig, registry, image),
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
resource.TestMatchResourceAttr("data.docker_registry_image.foobar", "sha256_digest", registryDigestRegexp), resource.TestMatchResourceAttr("data.docker_registry_image.foobar", "sha256_digest", registryDigestRegexp),

View file

@ -21,51 +21,51 @@ import (
func Provider() terraform.ResourceProvider { func Provider() terraform.ResourceProvider {
return &schema.Provider{ return &schema.Provider{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"host": &schema.Schema{ "host": {
Type: schema.TypeString, Type: schema.TypeString,
Required: true, Required: true,
DefaultFunc: schema.EnvDefaultFunc("DOCKER_HOST", "unix:///var/run/docker.sock"), DefaultFunc: schema.EnvDefaultFunc("DOCKER_HOST", "unix:///var/run/docker.sock"),
Description: "The Docker daemon address", Description: "The Docker daemon address",
}, },
"ca_material": &schema.Schema{ "ca_material": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
DefaultFunc: schema.EnvDefaultFunc("DOCKER_CA_MATERIAL", ""), DefaultFunc: schema.EnvDefaultFunc("DOCKER_CA_MATERIAL", ""),
Description: "PEM-encoded content of Docker host CA certificate", Description: "PEM-encoded content of Docker host CA certificate",
}, },
"cert_material": &schema.Schema{ "cert_material": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
DefaultFunc: schema.EnvDefaultFunc("DOCKER_CERT_MATERIAL", ""), DefaultFunc: schema.EnvDefaultFunc("DOCKER_CERT_MATERIAL", ""),
Description: "PEM-encoded content of Docker client certificate", Description: "PEM-encoded content of Docker client certificate",
}, },
"key_material": &schema.Schema{ "key_material": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
DefaultFunc: schema.EnvDefaultFunc("DOCKER_KEY_MATERIAL", ""), DefaultFunc: schema.EnvDefaultFunc("DOCKER_KEY_MATERIAL", ""),
Description: "PEM-encoded content of Docker client private key", Description: "PEM-encoded content of Docker client private key",
}, },
"cert_path": &schema.Schema{ "cert_path": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
DefaultFunc: schema.EnvDefaultFunc("DOCKER_CERT_PATH", ""), DefaultFunc: schema.EnvDefaultFunc("DOCKER_CERT_PATH", ""),
Description: "Path to directory with Docker TLS config", Description: "Path to directory with Docker TLS config",
}, },
"registry_auth": &schema.Schema{ "registry_auth": {
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"address": &schema.Schema{ "address": {
Type: schema.TypeString, Type: schema.TypeString,
Required: true, Required: true,
Description: "Address of the registry", Description: "Address of the registry",
}, },
"username": &schema.Schema{ "username": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ConflictsWith: []string{"registry_auth.config_file"}, ConflictsWith: []string{"registry_auth.config_file"},
@ -73,7 +73,7 @@ func Provider() terraform.ResourceProvider {
Description: "Username for the registry", Description: "Username for the registry",
}, },
"password": &schema.Schema{ "password": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
Sensitive: true, Sensitive: true,
@ -82,7 +82,7 @@ func Provider() terraform.ResourceProvider {
Description: "Password for the registry", Description: "Password for the registry",
}, },
"config_file": &schema.Schema{ "config_file": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ConflictsWith: []string{"registry_auth.username", "registry_auth.password"}, ConflictsWith: []string{"registry_auth.username", "registry_auth.password"},

View file

@ -17,14 +17,14 @@ func resourceDockerConfig() *schema.Resource {
Delete: resourceDockerConfigDelete, Delete: resourceDockerConfigDelete,
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"name": &schema.Schema{ "name": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "User-defined name of the config", Description: "User-defined name of the config",
Required: true, Required: true,
ForceNew: true, ForceNew: true,
}, },
"data": &schema.Schema{ "data": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Base64-url-safe-encoded config data", Description: "Base64-url-safe-encoded config data",
Required: true, Required: true,

View file

@ -15,7 +15,7 @@ func TestAccDockerConfig_basic(t *testing.T) {
Providers: testAccProviders, Providers: testAccProviders,
CheckDestroy: testCheckDockerConfigDestroy, CheckDestroy: testCheckDockerConfigDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_config" "foo" { resource "docker_config" "foo" {
name = "foo-config" name = "foo-config"
@ -36,7 +36,7 @@ func TestAccDockerConfig_basicUpdatable(t *testing.T) {
Providers: testAccProviders, Providers: testAccProviders,
CheckDestroy: testCheckDockerConfigDestroy, CheckDestroy: testCheckDockerConfigDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_config" "foo" { resource "docker_config" "foo" {
name = "tftest-myconfig-${replace(timestamp(),":", ".")}" name = "tftest-myconfig-${replace(timestamp(),":", ".")}"
@ -52,7 +52,7 @@ func TestAccDockerConfig_basicUpdatable(t *testing.T) {
resource.TestCheckResourceAttr("docker_config.foo", "data", "Ymxhc2RzYmxhYmxhMTI0ZHNkd2VzZA=="), resource.TestCheckResourceAttr("docker_config.foo", "data", "Ymxhc2RzYmxhYmxhMTI0ZHNkd2VzZA=="),
), ),
}, },
resource.TestStep{ {
Config: ` Config: `
resource "docker_config" "foo" { resource "docker_config" "foo" {
name = "tftest-myconfig2-${replace(timestamp(),":", ".")}" name = "tftest-myconfig2-${replace(timestamp(),":", ".")}"

View file

@ -16,31 +16,31 @@ func resourceDockerContainer() *schema.Resource {
SchemaVersion: 1, SchemaVersion: 1,
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"name": &schema.Schema{ "name": {
Type: schema.TypeString, Type: schema.TypeString,
Required: true, Required: true,
ForceNew: true, ForceNew: true,
}, },
"rm": &schema.Schema{ "rm": {
Type: schema.TypeBool, Type: schema.TypeBool,
Default: false, Default: false,
Optional: true, Optional: true,
}, },
"start": &schema.Schema{ "start": {
Type: schema.TypeBool, Type: schema.TypeBool,
Default: true, Default: true,
Optional: true, Optional: true,
}, },
"attach": &schema.Schema{ "attach": {
Type: schema.TypeBool, Type: schema.TypeBool,
Default: false, Default: false,
Optional: true, Optional: true,
}, },
"logs": &schema.Schema{ "logs": {
Type: schema.TypeBool, Type: schema.TypeBool,
Default: false, Default: false,
Optional: true, Optional: true,
@ -61,18 +61,18 @@ func resourceDockerContainer() *schema.Resource {
// this will delete and re-create the container // this will delete and re-create the container
// following the principle that the containers // following the principle that the containers
// should be pristine when started. // should be pristine when started.
"must_run": &schema.Schema{ "must_run": {
Type: schema.TypeBool, Type: schema.TypeBool,
Default: true, Default: true,
Optional: true, Optional: true,
}, },
"exit_code": &schema.Schema{ "exit_code": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
}, },
"container_logs": &schema.Schema{ "container_logs": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
@ -80,46 +80,46 @@ func resourceDockerContainer() *schema.Resource {
// ForceNew is not true for image because we need to // ForceNew is not true for image because we need to
// sane this against Docker image IDs, as each image // sane this against Docker image IDs, as each image
// can have multiple names/tags attached do it. // can have multiple names/tags attached do it.
"image": &schema.Schema{ "image": {
Type: schema.TypeString, Type: schema.TypeString,
Required: true, Required: true,
ForceNew: true, ForceNew: true,
}, },
"hostname": &schema.Schema{ "hostname": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"domainname": &schema.Schema{ "domainname": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"command": &schema.Schema{ "command": {
Type: schema.TypeList, Type: schema.TypeList,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
}, },
"entrypoint": &schema.Schema{ "entrypoint": {
Type: schema.TypeList, Type: schema.TypeList,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
}, },
"user": &schema.Schema{ "user": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
}, },
"dns": &schema.Schema{ "dns": {
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
@ -127,7 +127,7 @@ func resourceDockerContainer() *schema.Resource {
Set: schema.HashString, Set: schema.HashString,
}, },
"dns_opts": &schema.Schema{ "dns_opts": {
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
@ -135,7 +135,7 @@ func resourceDockerContainer() *schema.Resource {
Set: schema.HashString, Set: schema.HashString,
}, },
"dns_search": &schema.Schema{ "dns_search": {
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
@ -143,13 +143,13 @@ func resourceDockerContainer() *schema.Resource {
Set: schema.HashString, Set: schema.HashString,
}, },
"publish_all_ports": &schema.Schema{ "publish_all_ports": {
Type: schema.TypeBool, Type: schema.TypeBool,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"restart": &schema.Schema{ "restart": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
@ -157,20 +157,20 @@ func resourceDockerContainer() *schema.Resource {
ValidateFunc: validateStringMatchesPattern(`^(no|on-failure|always|unless-stopped)$`), ValidateFunc: validateStringMatchesPattern(`^(no|on-failure|always|unless-stopped)$`),
}, },
"max_retry_count": &schema.Schema{ "max_retry_count": {
Type: schema.TypeInt, Type: schema.TypeInt,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"capabilities": &schema.Schema{ "capabilities": {
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
MaxItems: 1, MaxItems: 1,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"add": &schema.Schema{ "add": {
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
@ -178,7 +178,7 @@ func resourceDockerContainer() *schema.Resource {
Set: schema.HashString, Set: schema.HashString,
}, },
"drop": &schema.Schema{ "drop": {
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
@ -189,38 +189,38 @@ func resourceDockerContainer() *schema.Resource {
}, },
}, },
"volumes": &schema.Schema{ "volumes": {
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"from_container": &schema.Schema{ "from_container": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"container_path": &schema.Schema{ "container_path": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"host_path": &schema.Schema{ "host_path": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
ValidateFunc: validateDockerContainerPath, ValidateFunc: validateDockerContainerPath,
}, },
"volume_name": &schema.Schema{ "volume_name": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"read_only": &schema.Schema{ "read_only": {
Type: schema.TypeBool, Type: schema.TypeBool,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
@ -229,26 +229,26 @@ func resourceDockerContainer() *schema.Resource {
}, },
}, },
"ports": &schema.Schema{ "ports": {
Type: schema.TypeList, Type: schema.TypeList,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"internal": &schema.Schema{ "internal": {
Type: schema.TypeInt, Type: schema.TypeInt,
Required: true, Required: true,
ForceNew: true, ForceNew: true,
}, },
"external": &schema.Schema{ "external": {
Type: schema.TypeInt, Type: schema.TypeInt,
Optional: true, Optional: true,
Computed: true, Computed: true,
ForceNew: true, ForceNew: true,
}, },
"ip": &schema.Schema{ "ip": {
Type: schema.TypeString, Type: schema.TypeString,
Default: "0.0.0.0", Default: "0.0.0.0",
Optional: true, Optional: true,
@ -263,7 +263,7 @@ func resourceDockerContainer() *schema.Resource {
}, },
}, },
"protocol": &schema.Schema{ "protocol": {
Type: schema.TypeString, Type: schema.TypeString,
Default: "tcp", Default: "tcp",
Optional: true, Optional: true,
@ -274,19 +274,19 @@ func resourceDockerContainer() *schema.Resource {
DiffSuppressFunc: suppressIfPortsDidNotChangeForMigrationV0ToV1(), DiffSuppressFunc: suppressIfPortsDidNotChangeForMigrationV0ToV1(),
}, },
"host": &schema.Schema{ "host": {
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"ip": &schema.Schema{ "ip": {
Type: schema.TypeString, Type: schema.TypeString,
Required: true, Required: true,
ForceNew: true, ForceNew: true,
}, },
"host": &schema.Schema{ "host": {
Type: schema.TypeString, Type: schema.TypeString,
Required: true, Required: true,
ForceNew: true, ForceNew: true,
@ -295,23 +295,23 @@ func resourceDockerContainer() *schema.Resource {
}, },
}, },
"ulimit": &schema.Schema{ "ulimit": {
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"name": &schema.Schema{ "name": {
Type: schema.TypeString, Type: schema.TypeString,
Required: true, Required: true,
ForceNew: true, ForceNew: true,
}, },
"soft": &schema.Schema{ "soft": {
Type: schema.TypeInt, Type: schema.TypeInt,
Required: true, Required: true,
ForceNew: true, ForceNew: true,
}, },
"hard": &schema.Schema{ "hard": {
Type: schema.TypeInt, Type: schema.TypeInt,
Required: true, Required: true,
ForceNew: true, ForceNew: true,
@ -320,7 +320,7 @@ func resourceDockerContainer() *schema.Resource {
}, },
}, },
"env": &schema.Schema{ "env": {
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
@ -328,7 +328,7 @@ func resourceDockerContainer() *schema.Resource {
Set: schema.HashString, Set: schema.HashString,
}, },
"links": &schema.Schema{ "links": {
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
@ -337,47 +337,47 @@ func resourceDockerContainer() *schema.Resource {
Deprecated: "The --link flag is a legacy feature of Docker. It may eventually be removed.", Deprecated: "The --link flag is a legacy feature of Docker. It may eventually be removed.",
}, },
"ip_address": &schema.Schema{ "ip_address": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
Deprecated: "Use ip_adresses_data instead. This field exposes the data of the container's first network.", Deprecated: "Use ip_adresses_data instead. This field exposes the data of the container's first network.",
}, },
"ip_prefix_length": &schema.Schema{ "ip_prefix_length": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
Deprecated: "Use ip_prefix_length from ip_adresses_data instead. This field exposes the data of the container's first network.", Deprecated: "Use ip_prefix_length from ip_adresses_data instead. This field exposes the data of the container's first network.",
}, },
"gateway": &schema.Schema{ "gateway": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
Deprecated: "Use gateway from ip_adresses_data instead. This field exposes the data of the container's first network.", Deprecated: "Use gateway from ip_adresses_data instead. This field exposes the data of the container's first network.",
}, },
"bridge": &schema.Schema{ "bridge": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"network_data": &schema.Schema{ "network_data": {
Type: schema.TypeList, Type: schema.TypeList,
Computed: true, Computed: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"network_name": &schema.Schema{ "network_name": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"ip_address": &schema.Schema{ "ip_address": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"ip_prefix_length": &schema.Schema{ "ip_prefix_length": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
}, },
"gateway": &schema.Schema{ "gateway": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
@ -385,31 +385,31 @@ func resourceDockerContainer() *schema.Resource {
}, },
}, },
"privileged": &schema.Schema{ "privileged": {
Type: schema.TypeBool, Type: schema.TypeBool,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"devices": &schema.Schema{ "devices": {
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"host_path": &schema.Schema{ "host_path": {
Type: schema.TypeString, Type: schema.TypeString,
Required: true, Required: true,
ForceNew: true, ForceNew: true,
}, },
"container_path": &schema.Schema{ "container_path": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"permissions": &schema.Schema{ "permissions": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
@ -418,46 +418,46 @@ func resourceDockerContainer() *schema.Resource {
}, },
}, },
"destroy_grace_seconds": &schema.Schema{ "destroy_grace_seconds": {
Type: schema.TypeInt, Type: schema.TypeInt,
Optional: true, Optional: true,
}, },
"labels": &schema.Schema{ "labels": {
Type: schema.TypeMap, Type: schema.TypeMap,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"memory": &schema.Schema{ "memory": {
Type: schema.TypeInt, Type: schema.TypeInt,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
ValidateFunc: validateIntegerGeqThan(0), ValidateFunc: validateIntegerGeqThan(0),
}, },
"memory_swap": &schema.Schema{ "memory_swap": {
Type: schema.TypeInt, Type: schema.TypeInt,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
ValidateFunc: validateIntegerGeqThan(-1), ValidateFunc: validateIntegerGeqThan(-1),
}, },
"cpu_shares": &schema.Schema{ "cpu_shares": {
Type: schema.TypeInt, Type: schema.TypeInt,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
ValidateFunc: validateIntegerGeqThan(0), ValidateFunc: validateIntegerGeqThan(0),
}, },
"cpu_set": &schema.Schema{ "cpu_set": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
ValidateFunc: validateStringMatchesPattern(`^\d+([,-]\d+)*$`), ValidateFunc: validateStringMatchesPattern(`^\d+([,-]\d+)*$`),
}, },
"log_driver": &schema.Schema{ "log_driver": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
@ -465,13 +465,13 @@ func resourceDockerContainer() *schema.Resource {
ValidateFunc: validateStringMatchesPattern(`^(json-file|syslog|journald|gelf|fluentd|awslogs)$`), ValidateFunc: validateStringMatchesPattern(`^(json-file|syslog|journald|gelf|fluentd|awslogs)$`),
}, },
"log_opts": &schema.Schema{ "log_opts": {
Type: schema.TypeMap, Type: schema.TypeMap,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"network_alias": &schema.Schema{ "network_alias": {
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
@ -481,13 +481,13 @@ func resourceDockerContainer() *schema.Resource {
Deprecated: "Use networks_advanced instead. Will be removed in v2.0.0", Deprecated: "Use networks_advanced instead. Will be removed in v2.0.0",
}, },
"network_mode": &schema.Schema{ "network_mode": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"networks": &schema.Schema{ "networks": {
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
@ -496,30 +496,30 @@ func resourceDockerContainer() *schema.Resource {
Deprecated: "Use networks_advanced instead. Will be removed in v2.0.0", Deprecated: "Use networks_advanced instead. Will be removed in v2.0.0",
}, },
"networks_advanced": &schema.Schema{ "networks_advanced": {
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"name": &schema.Schema{ "name": {
Type: schema.TypeString, Type: schema.TypeString,
Required: true, Required: true,
ForceNew: true, ForceNew: true,
}, },
"aliases": &schema.Schema{ "aliases": {
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
Set: schema.HashString, Set: schema.HashString,
}, },
"ipv4_address": &schema.Schema{ "ipv4_address": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"ipv6_address": &schema.Schema{ "ipv6_address": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
@ -528,36 +528,36 @@ func resourceDockerContainer() *schema.Resource {
}, },
}, },
"pid_mode": &schema.Schema{ "pid_mode": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"userns_mode": &schema.Schema{ "userns_mode": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"upload": &schema.Schema{ "upload": {
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"content": &schema.Schema{ "content": {
Type: schema.TypeString, Type: schema.TypeString,
Required: true, Required: true,
// This is intentional. The container is mutated once, and never updated later. // This is intentional. The container is mutated once, and never updated later.
// New configuration forces a new deployment, even with the same binaries. // New configuration forces a new deployment, even with the same binaries.
ForceNew: true, ForceNew: true,
}, },
"file": &schema.Schema{ "file": {
Type: schema.TypeString, Type: schema.TypeString,
Required: true, Required: true,
ForceNew: true, ForceNew: true,
}, },
"executable": &schema.Schema{ "executable": {
Type: schema.TypeBool, Type: schema.TypeBool,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
@ -567,41 +567,41 @@ func resourceDockerContainer() *schema.Resource {
}, },
}, },
"healthcheck": &schema.Schema{ "healthcheck": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "A test to perform to check that the container is healthy", Description: "A test to perform to check that the container is healthy",
MaxItems: 1, MaxItems: 1,
Optional: true, Optional: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"test": &schema.Schema{ "test": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "The test to perform as list", Description: "The test to perform as list",
Required: true, Required: true,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
}, },
"interval": &schema.Schema{ "interval": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Time between running the check (ms|s|m|h)", Description: "Time between running the check (ms|s|m|h)",
Optional: true, Optional: true,
Default: "0s", Default: "0s",
ValidateFunc: validateDurationGeq0(), ValidateFunc: validateDurationGeq0(),
}, },
"timeout": &schema.Schema{ "timeout": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Maximum time to allow one check to run (ms|s|m|h)", Description: "Maximum time to allow one check to run (ms|s|m|h)",
Optional: true, Optional: true,
Default: "0s", Default: "0s",
ValidateFunc: validateDurationGeq0(), ValidateFunc: validateDurationGeq0(),
}, },
"start_period": &schema.Schema{ "start_period": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Start period for the container to initialize before counting retries towards unstable (ms|s|m|h)", Description: "Start period for the container to initialize before counting retries towards unstable (ms|s|m|h)",
Optional: true, Optional: true,
Default: "0s", Default: "0s",
ValidateFunc: validateDurationGeq0(), ValidateFunc: validateDurationGeq0(),
}, },
"retries": &schema.Schema{ "retries": {
Type: schema.TypeInt, Type: schema.TypeInt,
Description: "Consecutive failures needed to report unhealthy", Description: "Consecutive failures needed to report unhealthy",
Optional: true, Optional: true,

View file

@ -35,7 +35,7 @@ func TestAccDockerContainer_basic(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerContainerConfig, Config: testAccDockerContainerConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccContainerRunning("docker_container.foo", &c), testAccContainerRunning("docker_container.foo", &c),
@ -50,7 +50,7 @@ func TestAccDockerContainer_basic_network(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerContainerWith2BridgeNetworkConfig, Config: testAccDockerContainerWith2BridgeNetworkConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccContainerRunning("docker_container.foo", &c), testAccContainerRunning("docker_container.foo", &c),
@ -79,7 +79,7 @@ func TestAccDockerContainer_2networks_withmode(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerContainer2NetworksConfig, Config: testAccDockerContainer2NetworksConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccContainerRunning("docker_container.foo", &c), testAccContainerRunning("docker_container.foo", &c),
@ -166,7 +166,7 @@ func TestAccDockerContainer_volume(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerContainerVolumeConfig, Config: testAccDockerContainerVolumeConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccContainerRunning("docker_container.foo", &c), testAccContainerRunning("docker_container.foo", &c),
@ -338,7 +338,7 @@ func TestAccDockerContainer_customized(t *testing.T) {
PreCheck: func() { testAccPreCheck(t); testAccCheckSwapLimit(t) }, PreCheck: func() { testAccPreCheck(t); testAccCheckSwapLimit(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerContainerCustomizedConfig, Config: testAccDockerContainerCustomizedConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccContainerRunning("docker_container.foo", &c), testAccContainerRunning("docker_container.foo", &c),
@ -398,7 +398,7 @@ func TestAccDockerContainer_upload(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerContainerUploadConfig, Config: testAccDockerContainerUploadConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccContainerRunning("docker_container.foo", &c), testAccContainerRunning("docker_container.foo", &c),
@ -460,7 +460,7 @@ func TestAccDockerContainer_device(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerContainerDeviceConfig, Config: testAccDockerContainerDeviceConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccContainerRunning("docker_container.foo", &c), testAccContainerRunning("docker_container.foo", &c),
@ -501,7 +501,7 @@ func TestAccDockerContainer_port_internal(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerContainerInternalPortConfig, Config: testAccDockerContainerInternalPortConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccContainerRunning("docker_container.foo", &c), testAccContainerRunning("docker_container.foo", &c),
@ -566,7 +566,7 @@ func TestAccDockerContainer_port_multiple_internal(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerContainerMultipleInternalPortConfig, Config: testAccDockerContainerMultipleInternalPortConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccContainerRunning("docker_container.foo", &c), testAccContainerRunning("docker_container.foo", &c),
@ -617,7 +617,7 @@ func TestAccDockerContainer_port(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerContainerPortConfig, Config: testAccDockerContainerPortConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccContainerRunning("docker_container.foo", &c), testAccContainerRunning("docker_container.foo", &c),
@ -682,7 +682,7 @@ func TestAccDockerContainer_multiple_ports(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerContainerMultiplePortConfig, Config: testAccDockerContainerMultiplePortConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccContainerRunning("docker_container.foo", &c), testAccContainerRunning("docker_container.foo", &c),
@ -719,7 +719,7 @@ func TestAccDockerContainer_rm(t *testing.T) {
Providers: testAccProviders, Providers: testAccProviders,
CheckDestroy: testAccContainerWaitConditionRemoved("docker_container.foo", &c), CheckDestroy: testAccContainerWaitConditionRemoved("docker_container.foo", &c),
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerContainerRmConfig, Config: testAccDockerContainerRmConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccContainerRunning("docker_container.foo", &c), testAccContainerRunning("docker_container.foo", &c),
@ -756,7 +756,7 @@ func TestAccDockerContainer_healthcheck(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerContainerHealthcheckConfig, Config: testAccDockerContainerHealthcheckConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccContainerRunning("docker_container.foo", &c), testAccContainerRunning("docker_container.foo", &c),
@ -773,7 +773,7 @@ func TestAccDockerContainer_nostart(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerContainerNoStartConfig, Config: testAccDockerContainerNoStartConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccContainerNotRunning("docker_container.foo", &c), testAccContainerNotRunning("docker_container.foo", &c),
@ -790,7 +790,7 @@ func TestAccDockerContainer_attach(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerContainerAttachConfig, Config: testAccDockerContainerAttachConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccContainerNotRunning("docker_container.foo", &c), testAccContainerNotRunning("docker_container.foo", &c),
@ -810,7 +810,7 @@ func TestAccDockerContainer_logs(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerContainerLogsConfig, Config: testAccDockerContainerLogsConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccContainerNotRunning("docker_container.foo", &c), testAccContainerNotRunning("docker_container.foo", &c),
@ -832,7 +832,7 @@ func TestAccDockerContainer_exitcode(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerContainerExitCodeConfig, Config: testAccDockerContainerExitCodeConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccContainerWaitConditionNotRunning("docker_container.foo", &c), testAccContainerWaitConditionNotRunning("docker_container.foo", &c),
@ -870,7 +870,7 @@ func TestAccDockerContainer_ipv4address(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerContainerNetworksIPv4AddressConfig, Config: testAccDockerContainerNetworksIPv4AddressConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccContainerRunning("docker_container.foo", &c), testAccContainerRunning("docker_container.foo", &c),
@ -908,7 +908,7 @@ func TestAccDockerContainer_ipv6address(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerContainerNetworksIPv6AddressConfig, Config: testAccDockerContainerNetworksIPv6AddressConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccContainerRunning("docker_container.foo", &c), testAccContainerRunning("docker_container.foo", &c),
@ -949,7 +949,7 @@ func TestAccDockerContainer_dualstackaddress(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerContainerNetworksDualStackAddressConfig, Config: testAccDockerContainerNetworksDualStackAddressConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccContainerRunning("docker_container.foo", &c), testAccContainerRunning("docker_container.foo", &c),

View file

@ -12,22 +12,22 @@ func resourceDockerImage() *schema.Resource {
Delete: resourceDockerImageDelete, Delete: resourceDockerImageDelete,
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"name": &schema.Schema{ "name": {
Type: schema.TypeString, Type: schema.TypeString,
Required: true, Required: true,
}, },
"latest": &schema.Schema{ "latest": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"keep_locally": &schema.Schema{ "keep_locally": {
Type: schema.TypeBool, Type: schema.TypeBool,
Optional: true, Optional: true,
}, },
"pull_trigger": &schema.Schema{ "pull_trigger": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
@ -35,7 +35,7 @@ func resourceDockerImage() *schema.Resource {
Deprecated: "Use field pull_triggers instead", Deprecated: "Use field pull_triggers instead",
}, },
"pull_triggers": &schema.Schema{ "pull_triggers": {
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,

View file

@ -19,7 +19,7 @@ func TestAccDockerImage_basic(t *testing.T) {
Providers: testAccProviders, Providers: testAccProviders,
CheckDestroy: testAccDockerImageDestroy, CheckDestroy: testAccDockerImageDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerImageConfig, Config: testAccDockerImageConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
resource.TestMatchResourceAttr("docker_image.foo", "latest", contentDigestRegexp), resource.TestMatchResourceAttr("docker_image.foo", "latest", contentDigestRegexp),
@ -35,7 +35,7 @@ func TestAccDockerImage_private(t *testing.T) {
Providers: testAccProviders, Providers: testAccProviders,
CheckDestroy: testAccDockerImageDestroy, CheckDestroy: testAccDockerImageDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAddDockerPrivateImageConfig, Config: testAddDockerPrivateImageConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
resource.TestMatchResourceAttr("docker_image.foobar", "latest", contentDigestRegexp), resource.TestMatchResourceAttr("docker_image.foobar", "latest", contentDigestRegexp),
@ -64,7 +64,7 @@ func TestAccDockerImage_destroy(t *testing.T) {
return nil return nil
}, },
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerImageKeepLocallyConfig, Config: testAccDockerImageKeepLocallyConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
resource.TestMatchResourceAttr("docker_image.foobarzoo", "latest", contentDigestRegexp), resource.TestMatchResourceAttr("docker_image.foobarzoo", "latest", contentDigestRegexp),
@ -80,7 +80,7 @@ func TestAccDockerImage_data(t *testing.T) {
Providers: testAccProviders, Providers: testAccProviders,
PreventPostDestroyRefresh: true, PreventPostDestroyRefresh: true,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerImageFromDataConfig, Config: testAccDockerImageFromDataConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
resource.TestMatchResourceAttr("docker_image.foobarbaz", "latest", contentDigestRegexp), resource.TestMatchResourceAttr("docker_image.foobarbaz", "latest", contentDigestRegexp),
@ -96,7 +96,7 @@ func TestAccDockerImage_data_pull_trigger(t *testing.T) {
Providers: testAccProviders, Providers: testAccProviders,
PreventPostDestroyRefresh: true, PreventPostDestroyRefresh: true,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerImageFromDataConfigWithPullTrigger, Config: testAccDockerImageFromDataConfigWithPullTrigger,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
resource.TestMatchResourceAttr("docker_image.foobarbazoo", "latest", contentDigestRegexp), resource.TestMatchResourceAttr("docker_image.foobarbazoo", "latest", contentDigestRegexp),
@ -115,7 +115,7 @@ func TestAccDockerImage_data_private(t *testing.T) {
Providers: testAccProviders, Providers: testAccProviders,
PreventPostDestroyRefresh: true, PreventPostDestroyRefresh: true,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: fmt.Sprintf(testAccDockerImageFromDataPrivateConfig, registry, image), Config: fmt.Sprintf(testAccDockerImageFromDataPrivateConfig, registry, image),
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
resource.TestMatchResourceAttr("docker_image.foo_private", "latest", contentDigestRegexp), resource.TestMatchResourceAttr("docker_image.foo_private", "latest", contentDigestRegexp),
@ -131,7 +131,7 @@ func TestAccDockerImage_sha265(t *testing.T) {
Providers: testAccProviders, Providers: testAccProviders,
CheckDestroy: testAccDockerImageDestroy, CheckDestroy: testAccDockerImageDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAddDockerImageWithSHA256RepoDigest, Config: testAddDockerImageWithSHA256RepoDigest,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
resource.TestMatchResourceAttr("docker_image.foobar", "latest", contentDigestRegexp), resource.TestMatchResourceAttr("docker_image.foobar", "latest", contentDigestRegexp),

View file

@ -16,94 +16,94 @@ func resourceDockerNetwork() *schema.Resource {
Delete: resourceDockerNetworkDelete, Delete: resourceDockerNetworkDelete,
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"name": &schema.Schema{ "name": {
Type: schema.TypeString, Type: schema.TypeString,
Required: true, Required: true,
ForceNew: true, ForceNew: true,
}, },
"labels": &schema.Schema{ "labels": {
Type: schema.TypeMap, Type: schema.TypeMap,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"check_duplicate": &schema.Schema{ "check_duplicate": {
Type: schema.TypeBool, Type: schema.TypeBool,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"driver": &schema.Schema{ "driver": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
Computed: true, Computed: true,
}, },
"options": &schema.Schema{ "options": {
Type: schema.TypeMap, Type: schema.TypeMap,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
Computed: true, Computed: true,
}, },
"internal": &schema.Schema{ "internal": {
Type: schema.TypeBool, Type: schema.TypeBool,
Optional: true, Optional: true,
Computed: true, Computed: true,
ForceNew: true, ForceNew: true,
}, },
"attachable": &schema.Schema{ "attachable": {
Type: schema.TypeBool, Type: schema.TypeBool,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"ingress": &schema.Schema{ "ingress": {
Type: schema.TypeBool, Type: schema.TypeBool,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"ipv6": &schema.Schema{ "ipv6": {
Type: schema.TypeBool, Type: schema.TypeBool,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"ipam_driver": &schema.Schema{ "ipam_driver": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"ipam_config": &schema.Schema{ "ipam_config": {
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"subnet": &schema.Schema{ "subnet": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"ip_range": &schema.Schema{ "ip_range": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"gateway": &schema.Schema{ "gateway": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"aux_address": &schema.Schema{ "aux_address": {
Type: schema.TypeMap, Type: schema.TypeMap,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
@ -113,7 +113,7 @@ func resourceDockerNetwork() *schema.Resource {
Set: resourceDockerIpamConfigHash, Set: resourceDockerIpamConfigHash,
}, },
"scope": &schema.Schema{ "scope": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },

View file

@ -17,7 +17,7 @@ func TestAccDockerNetwork_basic(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerNetworkConfig, Config: testAccDockerNetworkConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccNetwork("docker_network.foo", &n), testAccNetwork("docker_network.foo", &n),
@ -72,7 +72,7 @@ func TestAccDockerNetwork_internal(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerNetworkInternalConfig, Config: testAccDockerNetworkInternalConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccNetwork("docker_network.foo", &n), testAccNetwork("docker_network.foo", &n),
@ -106,7 +106,7 @@ func TestAccDockerNetwork_attachable(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerNetworkAttachableConfig, Config: testAccDockerNetworkAttachableConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccNetwork("docker_network.foo", &n), testAccNetwork("docker_network.foo", &n),
@ -174,7 +174,7 @@ func TestAccDockerNetwork_ipv4(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerNetworkIPv4Config, Config: testAccDockerNetworkIPv4Config,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccNetwork("docker_network.foo", &n), testAccNetwork("docker_network.foo", &n),
@ -213,7 +213,7 @@ func TestAccDockerNetwork_ipv6(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerNetworkIPv6Config, Config: testAccDockerNetworkIPv6Config,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccNetwork("docker_network.foo", &n), testAccNetwork("docker_network.foo", &n),
@ -256,7 +256,7 @@ func TestAccDockerNetwork_labels(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerNetworkLabelsConfig, Config: testAccDockerNetworkLabelsConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccNetwork("docker_network.foo", &n), testAccNetwork("docker_network.foo", &n),

View file

@ -16,14 +16,14 @@ func resourceDockerSecret() *schema.Resource {
Delete: resourceDockerSecretDelete, Delete: resourceDockerSecretDelete,
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"name": &schema.Schema{ "name": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "User-defined name of the secret", Description: "User-defined name of the secret",
Required: true, Required: true,
ForceNew: true, ForceNew: true,
}, },
"data": &schema.Schema{ "data": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "User-defined name of the secret", Description: "User-defined name of the secret",
Required: true, Required: true,
@ -32,7 +32,7 @@ func resourceDockerSecret() *schema.Resource {
ValidateFunc: validateStringIsBase64Encoded(), ValidateFunc: validateStringIsBase64Encoded(),
}, },
"labels": &schema.Schema{ "labels": {
Type: schema.TypeMap, Type: schema.TypeMap,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,

View file

@ -15,7 +15,7 @@ func TestAccDockerSecret_basic(t *testing.T) {
Providers: testAccProviders, Providers: testAccProviders,
CheckDestroy: testCheckDockerSecretDestroy, CheckDestroy: testCheckDockerSecretDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_secret" "foo" { resource "docker_secret" "foo" {
name = "foo-secret" name = "foo-secret"
@ -37,7 +37,7 @@ func TestAccDockerSecret_basicUpdatable(t *testing.T) {
Providers: testAccProviders, Providers: testAccProviders,
CheckDestroy: testCheckDockerSecretDestroy, CheckDestroy: testCheckDockerSecretDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_secret" "foo" { resource "docker_secret" "foo" {
name = "tftest-mysecret-${replace(timestamp(),":", ".")}" name = "tftest-mysecret-${replace(timestamp(),":", ".")}"
@ -53,7 +53,7 @@ func TestAccDockerSecret_basicUpdatable(t *testing.T) {
resource.TestCheckResourceAttr("docker_secret.foo", "data", "Ymxhc2RzYmxhYmxhMTI0ZHNkd2VzZA=="), resource.TestCheckResourceAttr("docker_secret.foo", "data", "Ymxhc2RzYmxhYmxhMTI0ZHNkd2VzZA=="),
), ),
}, },
resource.TestStep{ {
Config: ` Config: `
resource "docker_secret" "foo" { resource "docker_secret" "foo" {
name = "tftest-mysecret2-${replace(timestamp(),":", ".")}" name = "tftest-mysecret2-${replace(timestamp(),":", ".")}"
@ -79,7 +79,7 @@ func TestAccDockerSecret_labels(t *testing.T) {
Providers: testAccProviders, Providers: testAccProviders,
CheckDestroy: testCheckDockerSecretDestroy, CheckDestroy: testCheckDockerSecretDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_secret" "foo" { resource "docker_secret" "foo" {
name = "foo-secret" name = "foo-secret"

View file

@ -15,24 +15,24 @@ func resourceDockerService() *schema.Resource {
Exists: resourceDockerServiceExists, Exists: resourceDockerServiceExists,
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"auth": &schema.Schema{ "auth": {
Type: schema.TypeMap, Type: schema.TypeMap,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"server_address": &schema.Schema{ "server_address": {
Type: schema.TypeString, Type: schema.TypeString,
Required: true, Required: true,
ForceNew: true, ForceNew: true,
}, },
"username": &schema.Schema{ "username": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
DefaultFunc: schema.EnvDefaultFunc("DOCKER_REGISTRY_USER", ""), DefaultFunc: schema.EnvDefaultFunc("DOCKER_REGISTRY_USER", ""),
}, },
"password": &schema.Schema{ "password": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
@ -42,103 +42,103 @@ func resourceDockerService() *schema.Resource {
}, },
}, },
}, },
"name": &schema.Schema{ "name": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Name of the service", Description: "Name of the service",
Required: true, Required: true,
ForceNew: true, ForceNew: true,
}, },
"labels": &schema.Schema{ "labels": {
Type: schema.TypeMap, Type: schema.TypeMap,
Description: "User-defined key/value metadata", Description: "User-defined key/value metadata",
Optional: true, Optional: true,
Computed: true, Computed: true,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
}, },
"task_spec": &schema.Schema{ "task_spec": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "User modifiable task configuration", Description: "User modifiable task configuration",
MaxItems: 1, MaxItems: 1,
Required: true, Required: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"container_spec": &schema.Schema{ "container_spec": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "The spec for each container", Description: "The spec for each container",
Required: true, Required: true,
MaxItems: 1, MaxItems: 1,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"image": &schema.Schema{ "image": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "The image name to use for the containers of the service", Description: "The image name to use for the containers of the service",
Required: true, Required: true,
}, },
"labels": &schema.Schema{ "labels": {
Type: schema.TypeMap, Type: schema.TypeMap,
Description: "User-defined key/value metadata", Description: "User-defined key/value metadata",
Optional: true, Optional: true,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
}, },
"command": &schema.Schema{ "command": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "The command to be run in the image", Description: "The command to be run in the image",
Optional: true, Optional: true,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
}, },
"args": &schema.Schema{ "args": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "Arguments to the command", Description: "Arguments to the command",
Optional: true, Optional: true,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
}, },
"hostname": &schema.Schema{ "hostname": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "The hostname to use for the container, as a valid RFC 1123 hostname", Description: "The hostname to use for the container, as a valid RFC 1123 hostname",
Optional: true, Optional: true,
}, },
"env": &schema.Schema{ "env": {
Type: schema.TypeMap, Type: schema.TypeMap,
Description: "A list of environment variables in the form VAR=\"value\"", Description: "A list of environment variables in the form VAR=\"value\"",
Optional: true, Optional: true,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
}, },
"dir": &schema.Schema{ "dir": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "The working directory for commands to run in", Description: "The working directory for commands to run in",
Optional: true, Optional: true,
}, },
"user": &schema.Schema{ "user": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "The user inside the container", Description: "The user inside the container",
Optional: true, Optional: true,
}, },
"groups": &schema.Schema{ "groups": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "A list of additional groups that the container process will run as", Description: "A list of additional groups that the container process will run as",
Optional: true, Optional: true,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
}, },
"privileges": &schema.Schema{ "privileges": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "Security options for the container", Description: "Security options for the container",
MaxItems: 1, MaxItems: 1,
Optional: true, Optional: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"credential_spec": &schema.Schema{ "credential_spec": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "CredentialSpec for managed service account (Windows only)", Description: "CredentialSpec for managed service account (Windows only)",
MaxItems: 1, MaxItems: 1,
Optional: true, Optional: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"file": &schema.Schema{ "file": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Load credential spec from this file", Description: "Load credential spec from this file",
Optional: true, Optional: true,
}, },
"registry": &schema.Schema{ "registry": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Load credential spec from this value in the Windows registry", Description: "Load credential spec from this value in the Windows registry",
Optional: true, Optional: true,
@ -146,34 +146,34 @@ func resourceDockerService() *schema.Resource {
}, },
}, },
}, },
"se_linux_context": &schema.Schema{ "se_linux_context": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "SELinux labels of the container", Description: "SELinux labels of the container",
MaxItems: 1, MaxItems: 1,
Optional: true, Optional: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"disable": &schema.Schema{ "disable": {
Type: schema.TypeBool, Type: schema.TypeBool,
Description: "Disable SELinux", Description: "Disable SELinux",
Optional: true, Optional: true,
}, },
"user": &schema.Schema{ "user": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "SELinux user label", Description: "SELinux user label",
Optional: true, Optional: true,
}, },
"role": &schema.Schema{ "role": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "SELinux role label", Description: "SELinux role label",
Optional: true, Optional: true,
}, },
"type": &schema.Schema{ "type": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "SELinux type label", Description: "SELinux type label",
Optional: true, Optional: true,
}, },
"level": &schema.Schema{ "level": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "SELinux level label", Description: "SELinux level label",
Optional: true, Optional: true,
@ -184,46 +184,46 @@ func resourceDockerService() *schema.Resource {
}, },
}, },
}, },
"read_only": &schema.Schema{ "read_only": {
Type: schema.TypeBool, Type: schema.TypeBool,
Description: "Mount the container's root filesystem as read only", Description: "Mount the container's root filesystem as read only",
Optional: true, Optional: true,
}, },
"mounts": &schema.Schema{ "mounts": {
Type: schema.TypeSet, Type: schema.TypeSet,
Description: "Specification for mounts to be added to containers created as part of the service", Description: "Specification for mounts to be added to containers created as part of the service",
Optional: true, Optional: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"target": &schema.Schema{ "target": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Container path", Description: "Container path",
Required: true, Required: true,
}, },
"source": &schema.Schema{ "source": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Mount source (e.g. a volume name, a host path)", Description: "Mount source (e.g. a volume name, a host path)",
Required: true, Required: true,
}, },
"type": &schema.Schema{ "type": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "The mount type", Description: "The mount type",
Required: true, Required: true,
ValidateFunc: validateStringMatchesPattern(`^(bind|volume|tmpfs)$`), ValidateFunc: validateStringMatchesPattern(`^(bind|volume|tmpfs)$`),
}, },
"read_only": &schema.Schema{ "read_only": {
Type: schema.TypeBool, Type: schema.TypeBool,
Description: "Whether the mount should be read-only", Description: "Whether the mount should be read-only",
Optional: true, Optional: true,
}, },
"bind_options": &schema.Schema{ "bind_options": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "Optional configuration for the bind type", Description: "Optional configuration for the bind type",
Optional: true, Optional: true,
MaxItems: 1, MaxItems: 1,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"propagation": &schema.Schema{ "propagation": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "A propagation mode with the value", Description: "A propagation mode with the value",
Optional: true, Optional: true,
@ -232,30 +232,30 @@ func resourceDockerService() *schema.Resource {
}, },
}, },
}, },
"volume_options": &schema.Schema{ "volume_options": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "Optional configuration for the volume type", Description: "Optional configuration for the volume type",
Optional: true, Optional: true,
MaxItems: 1, MaxItems: 1,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"no_copy": &schema.Schema{ "no_copy": {
Type: schema.TypeBool, Type: schema.TypeBool,
Description: "Populate volume with data from the target", Description: "Populate volume with data from the target",
Optional: true, Optional: true,
}, },
"labels": &schema.Schema{ "labels": {
Type: schema.TypeMap, Type: schema.TypeMap,
Description: "User-defined key/value metadata", Description: "User-defined key/value metadata",
Optional: true, Optional: true,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
}, },
"driver_name": &schema.Schema{ "driver_name": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Name of the driver to use to create the volume.", Description: "Name of the driver to use to create the volume.",
Optional: true, Optional: true,
}, },
"driver_options": &schema.Schema{ "driver_options": {
Type: schema.TypeMap, Type: schema.TypeMap,
Description: "key/value map of driver specific options", Description: "key/value map of driver specific options",
Optional: true, Optional: true,
@ -264,19 +264,19 @@ func resourceDockerService() *schema.Resource {
}, },
}, },
}, },
"tmpfs_options": &schema.Schema{ "tmpfs_options": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "Optional configuration for the tmpfs type", Description: "Optional configuration for the tmpfs type",
Optional: true, Optional: true,
MaxItems: 1, MaxItems: 1,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"size_bytes": &schema.Schema{ "size_bytes": {
Type: schema.TypeInt, Type: schema.TypeInt,
Description: "The size for the tmpfs mount in bytes", Description: "The size for the tmpfs mount in bytes",
Optional: true, Optional: true,
}, },
"mode": &schema.Schema{ "mode": {
Type: schema.TypeInt, Type: schema.TypeInt,
Description: "The permission mode for the tmpfs mount in an integer", Description: "The permission mode for the tmpfs mount in an integer",
Optional: true, Optional: true,
@ -287,19 +287,19 @@ func resourceDockerService() *schema.Resource {
}, },
}, },
}, },
"stop_signal": &schema.Schema{ "stop_signal": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Signal to stop the container", Description: "Signal to stop the container",
Optional: true, Optional: true,
}, },
"stop_grace_period": &schema.Schema{ "stop_grace_period": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Amount of time to wait for the container to terminate before forcefully removing it (ms|s|m|h)", Description: "Amount of time to wait for the container to terminate before forcefully removing it (ms|s|m|h)",
Optional: true, Optional: true,
Computed: true, Computed: true,
ValidateFunc: validateDurationGeq0(), ValidateFunc: validateDurationGeq0(),
}, },
"healthcheck": &schema.Schema{ "healthcheck": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "A test to perform to check that the container is healthy", Description: "A test to perform to check that the container is healthy",
MaxItems: 1, MaxItems: 1,
@ -307,34 +307,34 @@ func resourceDockerService() *schema.Resource {
Computed: true, Computed: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"test": &schema.Schema{ "test": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "The test to perform as list", Description: "The test to perform as list",
Required: true, Required: true,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
}, },
"interval": &schema.Schema{ "interval": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Time between running the check (ms|s|m|h)", Description: "Time between running the check (ms|s|m|h)",
Optional: true, Optional: true,
Default: "0s", Default: "0s",
ValidateFunc: validateDurationGeq0(), ValidateFunc: validateDurationGeq0(),
}, },
"timeout": &schema.Schema{ "timeout": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Maximum time to allow one check to run (ms|s|m|h)", Description: "Maximum time to allow one check to run (ms|s|m|h)",
Optional: true, Optional: true,
Default: "0s", Default: "0s",
ValidateFunc: validateDurationGeq0(), ValidateFunc: validateDurationGeq0(),
}, },
"start_period": &schema.Schema{ "start_period": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Start period for the container to initialize before counting retries towards unstable (ms|s|m|h)", Description: "Start period for the container to initialize before counting retries towards unstable (ms|s|m|h)",
Optional: true, Optional: true,
Default: "0s", Default: "0s",
ValidateFunc: validateDurationGeq0(), ValidateFunc: validateDurationGeq0(),
}, },
"retries": &schema.Schema{ "retries": {
Type: schema.TypeInt, Type: schema.TypeInt,
Description: "Consecutive failures needed to report unhealthy", Description: "Consecutive failures needed to report unhealthy",
Optional: true, Optional: true,
@ -344,20 +344,20 @@ func resourceDockerService() *schema.Resource {
}, },
}, },
}, },
"hosts": &schema.Schema{ "hosts": {
Type: schema.TypeSet, Type: schema.TypeSet,
Description: "A list of hostname/IP mappings to add to the container's hosts file.", Description: "A list of hostname/IP mappings to add to the container's hosts file.",
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"ip": &schema.Schema{ "ip": {
Type: schema.TypeString, Type: schema.TypeString,
Required: true, Required: true,
ForceNew: true, ForceNew: true,
}, },
"host": &schema.Schema{ "host": {
Type: schema.TypeString, Type: schema.TypeString,
Required: true, Required: true,
ForceNew: true, ForceNew: true,
@ -365,7 +365,7 @@ func resourceDockerService() *schema.Resource {
}, },
}, },
}, },
"dns_config": &schema.Schema{ "dns_config": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "Specification for DNS related configurations in resolver configuration file (resolv.conf)", Description: "Specification for DNS related configurations in resolver configuration file (resolv.conf)",
MaxItems: 1, MaxItems: 1,
@ -373,19 +373,19 @@ func resourceDockerService() *schema.Resource {
Computed: true, Computed: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"nameservers": &schema.Schema{ "nameservers": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "The IP addresses of the name servers", Description: "The IP addresses of the name servers",
Required: true, Required: true,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
}, },
"search": &schema.Schema{ "search": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "A search list for host-name lookup", Description: "A search list for host-name lookup",
Optional: true, Optional: true,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
}, },
"options": &schema.Schema{ "options": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "A list of internal resolver variables to be modified (e.g., debug, ndots:3, etc.)", Description: "A list of internal resolver variables to be modified (e.g., debug, ndots:3, etc.)",
Optional: true, Optional: true,
@ -394,23 +394,23 @@ func resourceDockerService() *schema.Resource {
}, },
}, },
}, },
"secrets": &schema.Schema{ "secrets": {
Type: schema.TypeSet, Type: schema.TypeSet,
Description: "References to zero or more secrets that will be exposed to the service", Description: "References to zero or more secrets that will be exposed to the service",
Optional: true, Optional: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"secret_id": &schema.Schema{ "secret_id": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "ID of the specific secret that we're referencing", Description: "ID of the specific secret that we're referencing",
Required: true, Required: true,
}, },
"secret_name": &schema.Schema{ "secret_name": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Name of the secret that this references, but this is just provided for lookup/display purposes. The config in the reference will be identified by its ID", Description: "Name of the secret that this references, but this is just provided for lookup/display purposes. The config in the reference will be identified by its ID",
Optional: true, Optional: true,
}, },
"file_name": &schema.Schema{ "file_name": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Represents the final filename in the filesystem", Description: "Represents the final filename in the filesystem",
Required: true, Required: true,
@ -418,23 +418,23 @@ func resourceDockerService() *schema.Resource {
}, },
}, },
}, },
"configs": &schema.Schema{ "configs": {
Type: schema.TypeSet, Type: schema.TypeSet,
Description: "References to zero or more configs that will be exposed to the service", Description: "References to zero or more configs that will be exposed to the service",
Optional: true, Optional: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"config_id": &schema.Schema{ "config_id": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "ID of the specific config that we're referencing", Description: "ID of the specific config that we're referencing",
Required: true, Required: true,
}, },
"config_name": &schema.Schema{ "config_name": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Name of the config that this references, but this is just provided for lookup/display purposes. The config in the reference will be identified by its ID", Description: "Name of the config that this references, but this is just provided for lookup/display purposes. The config in the reference will be identified by its ID",
Optional: true, Optional: true,
}, },
"file_name": &schema.Schema{ "file_name": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Represents the final filename in the filesystem", Description: "Represents the final filename in the filesystem",
Required: true, Required: true,
@ -442,7 +442,7 @@ func resourceDockerService() *schema.Resource {
}, },
}, },
}, },
"isolation": &schema.Schema{ "isolation": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Isolation technology of the containers running the service. (Windows only)", Description: "Isolation technology of the containers running the service. (Windows only)",
Optional: true, Optional: true,
@ -452,7 +452,7 @@ func resourceDockerService() *schema.Resource {
}, },
}, },
}, },
"resources": &schema.Schema{ "resources": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "Resource requirements which apply to each individual container created as part of the service", Description: "Resource requirements which apply to each individual container created as part of the service",
Optional: true, Optional: true,
@ -460,38 +460,38 @@ func resourceDockerService() *schema.Resource {
MaxItems: 1, MaxItems: 1,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"limits": &schema.Schema{ "limits": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "Describes the resources which can be advertised by a node and requested by a task", Description: "Describes the resources which can be advertised by a node and requested by a task",
Optional: true, Optional: true,
MaxItems: 1, MaxItems: 1,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"nano_cpus": &schema.Schema{ "nano_cpus": {
Type: schema.TypeInt, Type: schema.TypeInt,
Description: "CPU shares in units of 1/1e9 (or 10^-9) of the CPU. Should be at least 1000000", Description: "CPU shares in units of 1/1e9 (or 10^-9) of the CPU. Should be at least 1000000",
Optional: true, Optional: true,
}, },
"memory_bytes": &schema.Schema{ "memory_bytes": {
Type: schema.TypeInt, Type: schema.TypeInt,
Description: "The amounf of memory in bytes the container allocates", Description: "The amounf of memory in bytes the container allocates",
Optional: true, Optional: true,
}, },
"generic_resources": &schema.Schema{ "generic_resources": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "User-defined resources can be either Integer resources (e.g, SSD=3) or String resources (e.g, GPU=UUID1)", Description: "User-defined resources can be either Integer resources (e.g, SSD=3) or String resources (e.g, GPU=UUID1)",
MaxItems: 1, MaxItems: 1,
Optional: true, Optional: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"named_resources_spec": &schema.Schema{ "named_resources_spec": {
Type: schema.TypeSet, Type: schema.TypeSet,
Description: "The String resources", Description: "The String resources",
Optional: true, Optional: true,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
Set: schema.HashString, Set: schema.HashString,
}, },
"discrete_resources_spec": &schema.Schema{ "discrete_resources_spec": {
Type: schema.TypeSet, Type: schema.TypeSet,
Description: "The Integer resources", Description: "The Integer resources",
Optional: true, Optional: true,
@ -504,37 +504,37 @@ func resourceDockerService() *schema.Resource {
}, },
}, },
}, },
"reservation": &schema.Schema{ "reservation": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "An object describing the resources which can be advertised by a node and requested by a task", Description: "An object describing the resources which can be advertised by a node and requested by a task",
Optional: true, Optional: true,
MaxItems: 1, MaxItems: 1,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"nano_cpus": &schema.Schema{ "nano_cpus": {
Description: "CPU shares in units of 1/1e9 (or 10^-9) of the CPU. Should be at least 1000000", Description: "CPU shares in units of 1/1e9 (or 10^-9) of the CPU. Should be at least 1000000",
Type: schema.TypeInt, Type: schema.TypeInt,
Optional: true, Optional: true,
}, },
"memory_bytes": &schema.Schema{ "memory_bytes": {
Type: schema.TypeInt, Type: schema.TypeInt,
Description: "The amounf of memory in bytes the container allocates", Description: "The amounf of memory in bytes the container allocates",
Optional: true, Optional: true,
}, },
"generic_resources": &schema.Schema{ "generic_resources": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "User-defined resources can be either Integer resources (e.g, SSD=3) or String resources (e.g, GPU=UUID1)", Description: "User-defined resources can be either Integer resources (e.g, SSD=3) or String resources (e.g, GPU=UUID1)",
MaxItems: 1, MaxItems: 1,
Optional: true, Optional: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"named_resources_spec": &schema.Schema{ "named_resources_spec": {
Type: schema.TypeSet, Type: schema.TypeSet,
Description: "The String resources", Description: "The String resources",
Optional: true, Optional: true,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
}, },
"discrete_resources_spec": &schema.Schema{ "discrete_resources_spec": {
Type: schema.TypeSet, Type: schema.TypeSet,
Description: "The Integer resources", Description: "The Integer resources",
Optional: true, Optional: true,
@ -549,32 +549,32 @@ func resourceDockerService() *schema.Resource {
}, },
}, },
}, },
"restart_policy": &schema.Schema{ "restart_policy": {
Type: schema.TypeMap, Type: schema.TypeMap,
Description: "Specification for the restart policy which applies to containers created as part of this service.", Description: "Specification for the restart policy which applies to containers created as part of this service.",
Optional: true, Optional: true,
Computed: true, Computed: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"condition": &schema.Schema{ "condition": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Condition for restart", Description: "Condition for restart",
Optional: true, Optional: true,
ValidateFunc: validateStringMatchesPattern(`^(none|on-failure|any)$`), ValidateFunc: validateStringMatchesPattern(`^(none|on-failure|any)$`),
}, },
"delay": &schema.Schema{ "delay": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Delay between restart attempts (ms|s|m|h)", Description: "Delay between restart attempts (ms|s|m|h)",
Optional: true, Optional: true,
ValidateFunc: validateDurationGeq0(), ValidateFunc: validateDurationGeq0(),
}, },
"max_attempts": &schema.Schema{ "max_attempts": {
Type: schema.TypeInt, Type: schema.TypeInt,
Description: "Maximum attempts to restart a given container before giving up (default value is 0, which is ignored)", Description: "Maximum attempts to restart a given container before giving up (default value is 0, which is ignored)",
Optional: true, Optional: true,
ValidateFunc: validateIntegerGeqThan(0), ValidateFunc: validateIntegerGeqThan(0),
}, },
"window": &schema.Schema{ "window": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "The time window used to evaluate the restart policy (default value is 0, which is unbounded) (ms|s|m|h)", Description: "The time window used to evaluate the restart policy (default value is 0, which is unbounded) (ms|s|m|h)",
Optional: true, Optional: true,
@ -583,7 +583,7 @@ func resourceDockerService() *schema.Resource {
}, },
}, },
}, },
"placement": &schema.Schema{ "placement": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "The placement preferences", Description: "The placement preferences",
Optional: true, Optional: true,
@ -591,32 +591,32 @@ func resourceDockerService() *schema.Resource {
MaxItems: 1, MaxItems: 1,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"constraints": &schema.Schema{ "constraints": {
Type: schema.TypeSet, Type: schema.TypeSet,
Description: "An array of constraints. e.g.: node.role==manager", Description: "An array of constraints. e.g.: node.role==manager",
Optional: true, Optional: true,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
Set: schema.HashString, Set: schema.HashString,
}, },
"prefs": &schema.Schema{ "prefs": {
Type: schema.TypeSet, Type: schema.TypeSet,
Description: "Preferences provide a way to make the scheduler aware of factors such as topology. They are provided in order from highest to lowest precedence, e.g.: spread=node.role.manager", Description: "Preferences provide a way to make the scheduler aware of factors such as topology. They are provided in order from highest to lowest precedence, e.g.: spread=node.role.manager",
Optional: true, Optional: true,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
Set: schema.HashString, Set: schema.HashString,
}, },
"platforms": &schema.Schema{ "platforms": {
Type: schema.TypeSet, Type: schema.TypeSet,
Description: "Platforms stores all the platforms that the service's image can run on", Description: "Platforms stores all the platforms that the service's image can run on",
Optional: true, Optional: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"architecture": &schema.Schema{ "architecture": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "The architecture, e.g. amd64", Description: "The architecture, e.g. amd64",
Required: true, Required: true,
}, },
"os": &schema.Schema{ "os": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "The operation system, e.g. linux", Description: "The operation system, e.g. linux",
Required: true, Required: true,
@ -627,41 +627,41 @@ func resourceDockerService() *schema.Resource {
}, },
}, },
}, },
"force_update": &schema.Schema{ "force_update": {
Type: schema.TypeInt, Type: schema.TypeInt,
Description: "A counter that triggers an update even if no relevant parameters have been changed. See https://github.com/docker/swarmkit/blob/master/api/specs.proto#L126", Description: "A counter that triggers an update even if no relevant parameters have been changed. See https://github.com/docker/swarmkit/blob/master/api/specs.proto#L126",
Optional: true, Optional: true,
Computed: true, Computed: true,
ValidateFunc: validateIntegerGeqThan(0), ValidateFunc: validateIntegerGeqThan(0),
}, },
"runtime": &schema.Schema{ "runtime": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Runtime is the type of runtime specified for the task executor. See https://github.com/moby/moby/blob/master/api/types/swarm/runtime.go", Description: "Runtime is the type of runtime specified for the task executor. See https://github.com/moby/moby/blob/master/api/types/swarm/runtime.go",
Optional: true, Optional: true,
Computed: true, Computed: true,
ValidateFunc: validateStringMatchesPattern("^(container|plugin)$"), ValidateFunc: validateStringMatchesPattern("^(container|plugin)$"),
}, },
"networks": &schema.Schema{ "networks": {
Type: schema.TypeSet, Type: schema.TypeSet,
Description: "Ids of the networks in which the container will be put in.", Description: "Ids of the networks in which the container will be put in.",
Optional: true, Optional: true,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
Set: schema.HashString, Set: schema.HashString,
}, },
"log_driver": &schema.Schema{ "log_driver": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "Specifies the log driver to use for tasks created from this spec. If not present, the default one for the swarm will be used, finally falling back to the engine default if not specified", Description: "Specifies the log driver to use for tasks created from this spec. If not present, the default one for the swarm will be used, finally falling back to the engine default if not specified",
MaxItems: 1, MaxItems: 1,
Optional: true, Optional: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"name": &schema.Schema{ "name": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "The logging driver to use: one of none|json-file|syslog|journald|gelf|fluentd|awslogs|splunk|etwlogs|gcplogs", Description: "The logging driver to use: one of none|json-file|syslog|journald|gelf|fluentd|awslogs|splunk|etwlogs|gcplogs",
Required: true, Required: true,
ValidateFunc: validateStringMatchesPattern("(none|json-file|syslog|journald|gelf|fluentd|awslogs|splunk|etwlogs|gcplogs)"), ValidateFunc: validateStringMatchesPattern("(none|json-file|syslog|journald|gelf|fluentd|awslogs|splunk|etwlogs|gcplogs)"),
}, },
"options": &schema.Schema{ "options": {
Type: schema.TypeMap, Type: schema.TypeMap,
Description: "The options for the logging driver", Description: "The options for the logging driver",
Optional: true, Optional: true,
@ -673,7 +673,7 @@ func resourceDockerService() *schema.Resource {
}, },
}, },
}, },
"mode": &schema.Schema{ "mode": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "Scheduling mode for the service", Description: "Scheduling mode for the service",
MaxItems: 1, MaxItems: 1,
@ -682,7 +682,7 @@ func resourceDockerService() *schema.Resource {
ForceNew: true, ForceNew: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"replicated": &schema.Schema{ "replicated": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "The replicated service mode", Description: "The replicated service mode",
MaxItems: 1, MaxItems: 1,
@ -691,7 +691,7 @@ func resourceDockerService() *schema.Resource {
ConflictsWith: []string{"mode.0.global"}, ConflictsWith: []string{"mode.0.global"},
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"replicas": &schema.Schema{ "replicas": {
Type: schema.TypeInt, Type: schema.TypeInt,
Description: "The amount of replicas of the service", Description: "The amount of replicas of the service",
Optional: true, Optional: true,
@ -701,7 +701,7 @@ func resourceDockerService() *schema.Resource {
}, },
}, },
}, },
"global": &schema.Schema{ "global": {
Type: schema.TypeBool, Type: schema.TypeBool,
Description: "The global service mode", Description: "The global service mode",
Optional: true, Optional: true,
@ -711,49 +711,49 @@ func resourceDockerService() *schema.Resource {
}, },
}, },
}, },
"update_config": &schema.Schema{ "update_config": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "Specification for the update strategy of the service", Description: "Specification for the update strategy of the service",
MaxItems: 1, MaxItems: 1,
Optional: true, Optional: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"parallelism": &schema.Schema{ "parallelism": {
Type: schema.TypeInt, Type: schema.TypeInt,
Description: "Maximum number of tasks to be updated in one iteration", Description: "Maximum number of tasks to be updated in one iteration",
Optional: true, Optional: true,
Default: 1, Default: 1,
ValidateFunc: validateIntegerGeqThan(0), ValidateFunc: validateIntegerGeqThan(0),
}, },
"delay": &schema.Schema{ "delay": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Delay between task updates (ns|us|ms|s|m|h)", Description: "Delay between task updates (ns|us|ms|s|m|h)",
Optional: true, Optional: true,
Default: "0s", Default: "0s",
ValidateFunc: validateDurationGeq0(), ValidateFunc: validateDurationGeq0(),
}, },
"failure_action": &schema.Schema{ "failure_action": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Action on update failure: pause | continue | rollback", Description: "Action on update failure: pause | continue | rollback",
Optional: true, Optional: true,
Default: "pause", Default: "pause",
ValidateFunc: validateStringMatchesPattern("^(pause|continue|rollback)$"), ValidateFunc: validateStringMatchesPattern("^(pause|continue|rollback)$"),
}, },
"monitor": &schema.Schema{ "monitor": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Duration after each task update to monitor for failure (ns|us|ms|s|m|h)", Description: "Duration after each task update to monitor for failure (ns|us|ms|s|m|h)",
Optional: true, Optional: true,
Default: "5s", Default: "5s",
ValidateFunc: validateDurationGeq0(), ValidateFunc: validateDurationGeq0(),
}, },
"max_failure_ratio": &schema.Schema{ "max_failure_ratio": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Failure rate to tolerate during an update", Description: "Failure rate to tolerate during an update",
Optional: true, Optional: true,
Default: "0.0", Default: "0.0",
ValidateFunc: validateStringIsFloatRatio(), ValidateFunc: validateStringIsFloatRatio(),
}, },
"order": &schema.Schema{ "order": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Update order: either 'stop-first' or 'start-first'", Description: "Update order: either 'stop-first' or 'start-first'",
Optional: true, Optional: true,
@ -763,49 +763,49 @@ func resourceDockerService() *schema.Resource {
}, },
}, },
}, },
"rollback_config": &schema.Schema{ "rollback_config": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "Specification for the rollback strategy of the service", Description: "Specification for the rollback strategy of the service",
Optional: true, Optional: true,
MaxItems: 1, MaxItems: 1,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"parallelism": &schema.Schema{ "parallelism": {
Type: schema.TypeInt, Type: schema.TypeInt,
Description: "Maximum number of tasks to be rollbacked in one iteration", Description: "Maximum number of tasks to be rollbacked in one iteration",
Optional: true, Optional: true,
Default: 1, Default: 1,
ValidateFunc: validateIntegerGeqThan(0), ValidateFunc: validateIntegerGeqThan(0),
}, },
"delay": &schema.Schema{ "delay": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Delay between task rollbacks (ns|us|ms|s|m|h)", Description: "Delay between task rollbacks (ns|us|ms|s|m|h)",
Optional: true, Optional: true,
Default: "0s", Default: "0s",
ValidateFunc: validateDurationGeq0(), ValidateFunc: validateDurationGeq0(),
}, },
"failure_action": &schema.Schema{ "failure_action": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Action on rollback failure: pause | continue", Description: "Action on rollback failure: pause | continue",
Optional: true, Optional: true,
Default: "pause", Default: "pause",
ValidateFunc: validateStringMatchesPattern("(pause|continue)"), ValidateFunc: validateStringMatchesPattern("(pause|continue)"),
}, },
"monitor": &schema.Schema{ "monitor": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Duration after each task rollback to monitor for failure (ns|us|ms|s|m|h)", Description: "Duration after each task rollback to monitor for failure (ns|us|ms|s|m|h)",
Optional: true, Optional: true,
Default: "5s", Default: "5s",
ValidateFunc: validateDurationGeq0(), ValidateFunc: validateDurationGeq0(),
}, },
"max_failure_ratio": &schema.Schema{ "max_failure_ratio": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Failure rate to tolerate during a rollback", Description: "Failure rate to tolerate during a rollback",
Optional: true, Optional: true,
Default: "0.0", Default: "0.0",
ValidateFunc: validateStringIsFloatRatio(), ValidateFunc: validateStringIsFloatRatio(),
}, },
"order": &schema.Schema{ "order": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Rollback order: either 'stop-first' or 'start-first'", Description: "Rollback order: either 'stop-first' or 'start-first'",
Optional: true, Optional: true,
@ -815,7 +815,7 @@ func resourceDockerService() *schema.Resource {
}, },
}, },
}, },
"endpoint_spec": &schema.Schema{ "endpoint_spec": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "Properties that can be configured to access and load balance a service", Description: "Properties that can be configured to access and load balance a service",
Optional: true, Optional: true,
@ -823,42 +823,42 @@ func resourceDockerService() *schema.Resource {
MaxItems: 1, MaxItems: 1,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"mode": &schema.Schema{ "mode": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "The mode of resolution to use for internal load balancing between tasks", Description: "The mode of resolution to use for internal load balancing between tasks",
Optional: true, Optional: true,
Computed: true, Computed: true,
ValidateFunc: validateStringMatchesPattern(`^(vip|dnsrr)$`), ValidateFunc: validateStringMatchesPattern(`^(vip|dnsrr)$`),
}, },
"ports": &schema.Schema{ "ports": {
Type: schema.TypeSet, Type: schema.TypeSet,
Description: "List of exposed ports that this service is accessible on from the outside. Ports can only be provided if 'vip' resolution mode is used.", Description: "List of exposed ports that this service is accessible on from the outside. Ports can only be provided if 'vip' resolution mode is used.",
Optional: true, Optional: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"name": &schema.Schema{ "name": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "A random name for the port", Description: "A random name for the port",
Optional: true, Optional: true,
}, },
"protocol": &schema.Schema{ "protocol": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Rrepresents the protocol of a port: 'tcp', 'udp' or 'sctp'", Description: "Rrepresents the protocol of a port: 'tcp', 'udp' or 'sctp'",
Optional: true, Optional: true,
Default: "tcp", Default: "tcp",
ValidateFunc: validateStringMatchesPattern(`^(tcp|udp|sctp)$`), ValidateFunc: validateStringMatchesPattern(`^(tcp|udp|sctp)$`),
}, },
"target_port": &schema.Schema{ "target_port": {
Type: schema.TypeInt, Type: schema.TypeInt,
Description: "The port inside the container", Description: "The port inside the container",
Required: true, Required: true,
}, },
"published_port": &schema.Schema{ "published_port": {
Type: schema.TypeInt, Type: schema.TypeInt,
Description: "The port on the swarm hosts.", Description: "The port on the swarm hosts.",
Optional: true, Optional: true,
}, },
"publish_mode": &schema.Schema{ "publish_mode": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "Represents the mode in which the port is to be published: 'ingress' or 'host'", Description: "Represents the mode in which the port is to be published: 'ingress' or 'host'",
Optional: true, Optional: true,
@ -871,7 +871,7 @@ func resourceDockerService() *schema.Resource {
}, },
}, },
}, },
"converge_config": &schema.Schema{ "converge_config": {
Type: schema.TypeList, Type: schema.TypeList,
Description: "A configuration to ensure that a service converges aka reaches the desired that of all task up and running", Description: "A configuration to ensure that a service converges aka reaches the desired that of all task up and running",
MaxItems: 1, MaxItems: 1,
@ -879,14 +879,14 @@ func resourceDockerService() *schema.Resource {
ConflictsWith: []string{"mode.0.global"}, ConflictsWith: []string{"mode.0.global"},
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"delay": &schema.Schema{ "delay": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "The interval to check if the desired state is reached (ms|s). Default: 7s", Description: "The interval to check if the desired state is reached (ms|s). Default: 7s",
Optional: true, Optional: true,
Default: "7s", Default: "7s",
ValidateFunc: validateDurationGeq0(), ValidateFunc: validateDurationGeq0(),
}, },
"timeout": &schema.Schema{ "timeout": {
Type: schema.TypeString, Type: schema.TypeString,
Description: "The timeout of the service to reach the desired state (s|m). Default: 3m", Description: "The timeout of the service to reach the desired state (s|m). Default: 3m",
Optional: true, Optional: true,

View file

@ -80,7 +80,7 @@ func TestAccDockerService_minimal(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-basic" name = "tftest-service-basic"
@ -106,7 +106,7 @@ func TestAccDockerService_full(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_volume" "test_volume" { resource "docker_volume" "test_volume" {
name = "tftest-volume" name = "tftest-volume"
@ -382,7 +382,7 @@ func TestAccDockerService_partialReplicated(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-basic" name = "tftest-service-basic"
@ -401,7 +401,7 @@ func TestAccDockerService_partialReplicated(t *testing.T) {
resource.TestCheckResourceAttr("docker_service.foo", "mode.0.replicated.0.replicas", "1"), resource.TestCheckResourceAttr("docker_service.foo", "mode.0.replicated.0.replicas", "1"),
), ),
}, },
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-basic" name = "tftest-service-basic"
@ -422,7 +422,7 @@ func TestAccDockerService_partialReplicated(t *testing.T) {
resource.TestCheckResourceAttr("docker_service.foo", "mode.0.replicated.0.replicas", "1"), resource.TestCheckResourceAttr("docker_service.foo", "mode.0.replicated.0.replicas", "1"),
), ),
}, },
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-basic" name = "tftest-service-basic"
@ -454,7 +454,7 @@ func TestAccDockerService_basicGlobal(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-basic" name = "tftest-service-basic"
@ -484,7 +484,7 @@ func TestAccDockerService_GlobalAndReplicated(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-basic" name = "tftest-service-basic"
@ -512,7 +512,7 @@ func TestAccDockerService_GlobalWithConvergeConfig(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-basic" name = "tftest-service-basic"
@ -541,7 +541,7 @@ func TestAccDockerService_updateImage(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-fnf-service-up-image" name = "tftest-fnf-service-up-image"
@ -605,7 +605,7 @@ func TestAccDockerService_updateImage(t *testing.T) {
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "2"), resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "2"),
), ),
}, },
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-fnf-service-up-image" name = "tftest-fnf-service-up-image"
@ -678,7 +678,7 @@ func TestAccDockerService_updateConfigReplicasImageAndHealthIncreaseAndDecreaseR
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_config" "service_config" { resource "docker_config" "service_config" {
name = "tftest-myconfig-${uuid()}" name = "tftest-myconfig-${uuid()}"
@ -763,7 +763,7 @@ func TestAccDockerService_updateConfigReplicasImageAndHealthIncreaseAndDecreaseR
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "2"), resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "2"),
), ),
}, },
resource.TestStep{ {
Config: ` Config: `
resource "docker_config" "service_config" { resource "docker_config" "service_config" {
name = "tftest-myconfig-${uuid()}" name = "tftest-myconfig-${uuid()}"
@ -855,7 +855,7 @@ func TestAccDockerService_updateConfigReplicasImageAndHealthIncreaseAndDecreaseR
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "4"), resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "4"),
), ),
}, },
resource.TestStep{ {
Config: ` Config: `
resource "docker_config" "service_config" { resource "docker_config" "service_config" {
name = "tftest-myconfig-${uuid()}" name = "tftest-myconfig-${uuid()}"
@ -957,7 +957,7 @@ func TestAccDockerService_nonExistingPrivateImageConverge(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-privateimagedoesnotexist" name = "tftest-service-privateimagedoesnotexist"
@ -993,7 +993,7 @@ func TestAccDockerService_nonExistingPublicImageConverge(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-publicimagedoesnotexist" name = "tftest-service-publicimagedoesnotexist"
@ -1029,7 +1029,7 @@ func TestAccDockerService_basicConvergeAndStopGracefully(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-basic-converge" name = "tftest-service-basic-converge"
@ -1081,7 +1081,7 @@ func TestAccDockerService_updateFailsAndRollbackConverge(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-updateFailsAndRollbackConverge" name = "tftest-service-updateFailsAndRollbackConverge"
@ -1147,7 +1147,7 @@ func TestAccDockerService_updateFailsAndRollbackConverge(t *testing.T) {
resource.TestCheckResourceAttr("docker_service.foo", "mode.0.replicated.0.replicas", "2"), resource.TestCheckResourceAttr("docker_service.foo", "mode.0.replicated.0.replicas", "2"),
), ),
}, },
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-updateFailsAndRollbackConverge" name = "tftest-service-updateFailsAndRollbackConverge"
@ -1223,7 +1223,7 @@ func TestAccDockerService_updateNetworksConverge(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_network" "test_network" { resource "docker_network" "test_network" {
name = "tftest-network" name = "tftest-network"
@ -1273,7 +1273,7 @@ func TestAccDockerService_updateNetworksConverge(t *testing.T) {
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.networks.#", "1"), resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.networks.#", "1"),
), ),
}, },
resource.TestStep{ {
Config: ` Config: `
resource "docker_network" "test_network" { resource "docker_network" "test_network" {
name = "tftest-network" name = "tftest-network"
@ -1322,7 +1322,7 @@ func TestAccDockerService_updateNetworksConverge(t *testing.T) {
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.networks.#", "1"), resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.networks.#", "1"),
), ),
}, },
resource.TestStep{ {
Config: ` Config: `
resource "docker_network" "test_network" { resource "docker_network" "test_network" {
name = "tftest-network" name = "tftest-network"
@ -1384,7 +1384,7 @@ func TestAccDockerService_updateMountsConverge(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_volume" "foo" { resource "docker_volume" "foo" {
name = "tftest-volume" name = "tftest-volume"
@ -1432,7 +1432,7 @@ func TestAccDockerService_updateMountsConverge(t *testing.T) {
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.mounts.#", "1"), resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.mounts.#", "1"),
), ),
}, },
resource.TestStep{ {
Config: ` Config: `
resource "docker_volume" "foo" { resource "docker_volume" "foo" {
name = "tftest-volume" name = "tftest-volume"
@ -1506,7 +1506,7 @@ func TestAccDockerService_updateHostsConverge(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-up-hosts" name = "tftest-service-up-hosts"
@ -1543,7 +1543,7 @@ func TestAccDockerService_updateHostsConverge(t *testing.T) {
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.hosts.#", "1"), resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.hosts.#", "1"),
), ),
}, },
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-up-hosts" name = "tftest-service-up-hosts"
@ -1581,7 +1581,7 @@ func TestAccDockerService_updateHostsConverge(t *testing.T) {
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.hosts.#", "1"), resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.hosts.#", "1"),
), ),
}, },
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-up-hosts" name = "tftest-service-up-hosts"
@ -1630,7 +1630,7 @@ func TestAccDockerService_updateLoggingConverge(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-up-logging" name = "tftest-service-up-logging"
@ -1673,7 +1673,7 @@ func TestAccDockerService_updateLoggingConverge(t *testing.T) {
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.log_driver.0.options.max-file", "3"), resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.log_driver.0.options.max-file", "3"),
), ),
}, },
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-up-logging" name = "tftest-service-up-logging"
@ -1715,7 +1715,7 @@ func TestAccDockerService_updateLoggingConverge(t *testing.T) {
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.log_driver.0.options.max-file", "5"), resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.log_driver.0.options.max-file", "5"),
), ),
}, },
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-up-logging" name = "tftest-service-up-logging"
@ -1755,7 +1755,7 @@ func TestAccDockerService_updateHealthcheckConverge(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-up-healthcheck" name = "tftest-service-up-healthcheck"
@ -1825,7 +1825,7 @@ func TestAccDockerService_updateHealthcheckConverge(t *testing.T) {
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "4"), resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "4"),
), ),
}, },
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-up-healthcheck" name = "tftest-service-up-healthcheck"
@ -1902,7 +1902,7 @@ func TestAccDockerService_updateIncreaseReplicasConverge(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-increase-replicas" name = "tftest-service-increase-replicas"
@ -1972,7 +1972,7 @@ func TestAccDockerService_updateIncreaseReplicasConverge(t *testing.T) {
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "4"), resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "4"),
), ),
}, },
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-increase-replicas" name = "tftest-service-increase-replicas"
@ -2051,7 +2051,7 @@ func TestAccDockerService_updateDecreaseReplicasConverge(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-decrease-replicas" name = "tftest-service-decrease-replicas"
@ -2120,7 +2120,7 @@ func TestAccDockerService_updateDecreaseReplicasConverge(t *testing.T) {
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "4"), resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "4"),
), ),
}, },
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-decrease-replicas" name = "tftest-service-decrease-replicas"
@ -2198,7 +2198,7 @@ func TestAccDockerService_updateImageConverge(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-up-image" name = "tftest-service-up-image"
@ -2267,7 +2267,7 @@ func TestAccDockerService_updateImageConverge(t *testing.T) {
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "2"), resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "2"),
), ),
}, },
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-up-image" name = "tftest-service-up-image"
@ -2345,7 +2345,7 @@ func TestAccDockerService_updateConfigConverge(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_config" "service_config" { resource "docker_config" "service_config" {
name = "tftest-myconfig-${uuid()}" name = "tftest-myconfig-${uuid()}"
@ -2432,7 +2432,7 @@ func TestAccDockerService_updateConfigConverge(t *testing.T) {
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "4"), resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "4"),
), ),
}, },
resource.TestStep{ {
Config: ` Config: `
resource "docker_config" "service_config" { resource "docker_config" "service_config" {
name = "tftest-myconfig-${uuid()}" name = "tftest-myconfig-${uuid()}"
@ -2526,7 +2526,7 @@ func TestAccDockerService_updateConfigAndSecretConverge(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_config" "service_config" { resource "docker_config" "service_config" {
name = "tftest-myconfig-${uuid()}" name = "tftest-myconfig-${uuid()}"
@ -2631,7 +2631,7 @@ func TestAccDockerService_updateConfigAndSecretConverge(t *testing.T) {
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "4"), resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "4"),
), ),
}, },
resource.TestStep{ {
Config: ` Config: `
resource "docker_config" "service_config" { resource "docker_config" "service_config" {
name = "tftest-myconfig-${uuid()}" name = "tftest-myconfig-${uuid()}"
@ -2745,7 +2745,7 @@ func TestAccDockerService_updatePortConverge(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-up-port" name = "tftest-service-up-port"
@ -2814,7 +2814,7 @@ func TestAccDockerService_updatePortConverge(t *testing.T) {
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "2"), resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "2"),
), ),
}, },
resource.TestStep{ {
Config: ` Config: `
resource "docker_service" "foo" { resource "docker_service" "foo" {
name = "tftest-service-up-port" name = "tftest-service-up-port"
@ -2899,7 +2899,7 @@ func TestAccDockerService_updateConfigReplicasImageAndHealthConverge(t *testing.
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_config" "service_config" { resource "docker_config" "service_config" {
name = "tftest-myconfig-${uuid()}" name = "tftest-myconfig-${uuid()}"
@ -2984,7 +2984,7 @@ func TestAccDockerService_updateConfigReplicasImageAndHealthConverge(t *testing.
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "2"), resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "2"),
), ),
}, },
resource.TestStep{ {
Config: ` Config: `
resource "docker_config" "service_config" { resource "docker_config" "service_config" {
name = "tftest-myconfig-${uuid()}" name = "tftest-myconfig-${uuid()}"
@ -3086,7 +3086,7 @@ func TestAccDockerService_updateConfigAndDecreaseReplicasConverge(t *testing.T)
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_config" "service_config" { resource "docker_config" "service_config" {
name = "tftest-myconfig-${uuid()}" name = "tftest-myconfig-${uuid()}"
@ -3171,7 +3171,7 @@ func TestAccDockerService_updateConfigAndDecreaseReplicasConverge(t *testing.T)
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "4"), resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "4"),
), ),
}, },
resource.TestStep{ {
Config: ` Config: `
resource "docker_config" "service_config" { resource "docker_config" "service_config" {
name = "tftest-myconfig-${uuid()}" name = "tftest-myconfig-${uuid()}"
@ -3265,7 +3265,7 @@ func TestAccDockerService_updateConfigReplicasImageAndHealthIncreaseAndDecreaseR
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: ` Config: `
resource "docker_config" "service_config" { resource "docker_config" "service_config" {
name = "tftest-myconfig-${uuid()}" name = "tftest-myconfig-${uuid()}"
@ -3350,7 +3350,7 @@ func TestAccDockerService_updateConfigReplicasImageAndHealthIncreaseAndDecreaseR
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "2"), resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "2"),
), ),
}, },
resource.TestStep{ {
Config: ` Config: `
resource "docker_config" "service_config" { resource "docker_config" "service_config" {
name = "tftest-myconfig-${uuid()}" name = "tftest-myconfig-${uuid()}"
@ -3443,7 +3443,7 @@ func TestAccDockerService_updateConfigReplicasImageAndHealthIncreaseAndDecreaseR
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "4"), resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.container_spec.0.healthcheck.0.retries", "4"),
), ),
}, },
resource.TestStep{ {
Config: ` Config: `
resource "docker_config" "service_config" { resource "docker_config" "service_config" {
name = "tftest-myconfig-${uuid()}" name = "tftest-myconfig-${uuid()}"
@ -3548,7 +3548,7 @@ func TestAccDockerService_privateConverge(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: fmt.Sprintf(` Config: fmt.Sprintf(`
provider "docker" { provider "docker" {
alias = "private" alias = "private"

View file

@ -19,29 +19,29 @@ func resourceDockerVolume() *schema.Resource {
Delete: resourceDockerVolumeDelete, Delete: resourceDockerVolumeDelete,
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"name": &schema.Schema{ "name": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
Computed: true, Computed: true,
ForceNew: true, ForceNew: true,
}, },
"labels": &schema.Schema{ "labels": {
Type: schema.TypeMap, Type: schema.TypeMap,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"driver": &schema.Schema{ "driver": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
Computed: true, Computed: true,
ForceNew: true, ForceNew: true,
}, },
"driver_opts": &schema.Schema{ "driver_opts": {
Type: schema.TypeMap, Type: schema.TypeMap,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"mountpoint": &schema.Schema{ "mountpoint": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },

View file

@ -16,7 +16,7 @@ func TestAccDockerVolume_basic(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerVolumeConfig, Config: testAccDockerVolumeConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
checkDockerVolume("docker_volume.foo", &v), checkDockerVolume("docker_volume.foo", &v),
@ -65,7 +65,7 @@ func TestAccDockerVolume_labels(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccDockerVolumeLabelsConfig, Config: testAccDockerVolumeLabelsConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
checkDockerVolume("docker_volume.foo", &v), checkDockerVolume("docker_volume.foo", &v),