2015-02-17 11:28:33 -05:00
|
|
|
package docker
|
|
|
|
|
|
|
|
|
|
import (
|
2019-03-05 09:55:17 -05:00
|
|
|
"log"
|
|
|
|
|
|
2015-02-17 11:28:33 -05:00
|
|
|
"github.com/hashicorp/terraform/helper/schema"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func resourceDockerContainer() *schema.Resource {
|
|
|
|
|
return &schema.Resource{
|
2019-03-05 09:55:17 -05:00
|
|
|
Create: resourceDockerContainerCreate,
|
|
|
|
|
Read: resourceDockerContainerRead,
|
|
|
|
|
Update: resourceDockerContainerUpdate,
|
|
|
|
|
Delete: resourceDockerContainerDelete,
|
|
|
|
|
MigrateState: resourceDockerContainerMigrateState,
|
|
|
|
|
SchemaVersion: 1,
|
2015-02-17 11:28:33 -05:00
|
|
|
|
|
|
|
|
Schema: map[string]*schema.Schema{
|
2019-03-01 16:02:17 -05:00
|
|
|
"name": {
|
2015-02-17 11:28:33 -05:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Required: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"rm": {
|
2018-10-25 02:01:38 -04:00
|
|
|
Type: schema.TypeBool,
|
|
|
|
|
Default: false,
|
|
|
|
|
Optional: true,
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"start": {
|
2018-10-08 14:14:01 -04:00
|
|
|
Type: schema.TypeBool,
|
|
|
|
|
Default: true,
|
|
|
|
|
Optional: true,
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"attach": {
|
2018-10-28 13:41:10 -04:00
|
|
|
Type: schema.TypeBool,
|
|
|
|
|
Default: false,
|
|
|
|
|
Optional: true,
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"logs": {
|
2018-10-28 13:41:10 -04:00
|
|
|
Type: schema.TypeBool,
|
|
|
|
|
Default: false,
|
|
|
|
|
Optional: true,
|
|
|
|
|
},
|
|
|
|
|
|
2015-02-17 11:28:33 -05:00
|
|
|
// Indicates whether the container must be running.
|
|
|
|
|
//
|
|
|
|
|
// An assumption is made that configured containers
|
|
|
|
|
// should be running; if not, they should not be in
|
|
|
|
|
// the configuration. Therefore a stopped container
|
|
|
|
|
// should be started. Set to false to have the
|
|
|
|
|
// provider leave the container alone.
|
|
|
|
|
//
|
|
|
|
|
// Actively-debugged containers are likely to be
|
|
|
|
|
// stopped and started manually, and Docker has
|
|
|
|
|
// some provisions for restarting containers that
|
|
|
|
|
// stop. The utility here comes from the fact that
|
|
|
|
|
// this will delete and re-create the container
|
|
|
|
|
// following the principle that the containers
|
|
|
|
|
// should be pristine when started.
|
2019-03-01 16:02:17 -05:00
|
|
|
"must_run": {
|
2015-02-17 11:28:33 -05:00
|
|
|
Type: schema.TypeBool,
|
|
|
|
|
Default: true,
|
|
|
|
|
Optional: true,
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"exit_code": {
|
2018-10-25 02:01:38 -04:00
|
|
|
Type: schema.TypeInt,
|
|
|
|
|
Computed: true,
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"container_logs": {
|
2018-10-28 13:41:10 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Computed: true,
|
|
|
|
|
},
|
|
|
|
|
|
2015-02-17 11:28:33 -05:00
|
|
|
// ForceNew is not true for image because we need to
|
|
|
|
|
// sane this against Docker image IDs, as each image
|
|
|
|
|
// can have multiple names/tags attached do it.
|
2019-03-01 16:02:17 -05:00
|
|
|
"image": {
|
2015-02-17 11:28:33 -05:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Required: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"hostname": {
|
2015-02-17 11:28:33 -05:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"domainname": {
|
2015-02-17 11:28:33 -05:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"command": {
|
2015-02-17 11:28:33 -05:00
|
|
|
Type: schema.TypeList,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
Elem: &schema.Schema{Type: schema.TypeString},
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"entrypoint": {
|
2015-10-26 17:24:48 -04:00
|
|
|
Type: schema.TypeList,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
Elem: &schema.Schema{Type: schema.TypeString},
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"user": {
|
2016-04-04 22:43:59 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
Elem: &schema.Schema{Type: schema.TypeString},
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"dns": {
|
2015-02-17 11:28:33 -05:00
|
|
|
Type: schema.TypeSet,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
Elem: &schema.Schema{Type: schema.TypeString},
|
2016-02-07 18:51:26 -05:00
|
|
|
Set: schema.HashString,
|
2015-02-17 11:28:33 -05:00
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"dns_opts": {
|
2016-06-29 08:38:46 -04:00
|
|
|
Type: schema.TypeSet,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
Elem: &schema.Schema{Type: schema.TypeString},
|
|
|
|
|
Set: schema.HashString,
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"dns_search": {
|
2016-06-29 08:38:46 -04:00
|
|
|
Type: schema.TypeSet,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
Elem: &schema.Schema{Type: schema.TypeString},
|
|
|
|
|
Set: schema.HashString,
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"publish_all_ports": {
|
2015-02-17 11:28:33 -05:00
|
|
|
Type: schema.TypeBool,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"restart": {
|
2018-01-29 06:01:46 -05:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
Default: "no",
|
|
|
|
|
ValidateFunc: validateStringMatchesPattern(`^(no|on-failure|always|unless-stopped)$`),
|
2015-10-27 12:08:57 -04:00
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"max_retry_count": {
|
2015-10-27 12:08:57 -04:00
|
|
|
Type: schema.TypeInt,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"capabilities": {
|
2017-03-07 11:48:20 -05:00
|
|
|
Type: schema.TypeSet,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
MaxItems: 1,
|
|
|
|
|
Elem: &schema.Resource{
|
|
|
|
|
Schema: map[string]*schema.Schema{
|
2019-03-01 16:02:17 -05:00
|
|
|
"add": {
|
2017-03-07 11:48:20 -05:00
|
|
|
Type: schema.TypeSet,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
Elem: &schema.Schema{Type: schema.TypeString},
|
|
|
|
|
Set: schema.HashString,
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"drop": {
|
2017-03-07 11:48:20 -05:00
|
|
|
Type: schema.TypeSet,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
Elem: &schema.Schema{Type: schema.TypeString},
|
|
|
|
|
Set: schema.HashString,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"volumes": {
|
2015-02-17 11:28:33 -05:00
|
|
|
Type: schema.TypeSet,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
2015-12-03 05:51:59 -05:00
|
|
|
Elem: &schema.Resource{
|
|
|
|
|
Schema: map[string]*schema.Schema{
|
2019-03-01 16:02:17 -05:00
|
|
|
"from_container": {
|
2015-12-03 05:51:59 -05:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"container_path": {
|
2015-12-03 05:51:59 -05:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"host_path": {
|
2017-05-15 06:09:50 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
ValidateFunc: validateDockerContainerPath,
|
2016-01-15 16:59:33 -05:00
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"volume_name": {
|
2016-01-15 16:59:33 -05:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
2015-12-03 05:51:59 -05:00
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"read_only": {
|
2015-12-03 05:51:59 -05:00
|
|
|
Type: schema.TypeBool,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2015-02-17 11:28:33 -05:00
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"ports": {
|
2018-10-16 12:49:57 -04:00
|
|
|
Type: schema.TypeList,
|
2015-02-17 11:28:33 -05:00
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
2015-12-03 05:51:59 -05:00
|
|
|
Elem: &schema.Resource{
|
|
|
|
|
Schema: map[string]*schema.Schema{
|
2019-03-01 16:02:17 -05:00
|
|
|
"internal": {
|
2015-12-03 05:51:59 -05:00
|
|
|
Type: schema.TypeInt,
|
|
|
|
|
Required: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"external": {
|
2015-12-03 05:51:59 -05:00
|
|
|
Type: schema.TypeInt,
|
|
|
|
|
Optional: true,
|
2018-10-16 12:49:57 -04:00
|
|
|
Computed: true,
|
2015-12-03 05:51:59 -05:00
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"ip": {
|
2015-12-03 05:51:59 -05:00
|
|
|
Type: schema.TypeString,
|
2018-10-09 16:32:26 -04:00
|
|
|
Default: "0.0.0.0",
|
2015-12-03 05:51:59 -05:00
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
2019-03-07 04:15:42 -05:00
|
|
|
StateFunc: func(val interface{}) string {
|
|
|
|
|
// Empty IP assignments default to 0.0.0.0
|
|
|
|
|
if val.(string) == "" {
|
|
|
|
|
return "0.0.0.0"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return val.(string)
|
|
|
|
|
},
|
2015-12-03 05:51:59 -05:00
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"protocol": {
|
2015-12-03 05:51:59 -05:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Default: "tcp",
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2019-03-05 09:55:17 -05:00
|
|
|
DiffSuppressFunc: suppressIfPortsDidNotChangeForMigrationV0ToV1(),
|
2015-02-17 11:28:33 -05:00
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"host": {
|
2015-10-09 09:05:43 -04:00
|
|
|
Type: schema.TypeSet,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
Elem: &schema.Resource{
|
|
|
|
|
Schema: map[string]*schema.Schema{
|
2019-03-01 16:02:17 -05:00
|
|
|
"ip": {
|
2015-10-09 09:05:43 -04:00
|
|
|
Type: schema.TypeString,
|
2016-10-27 05:54:05 -04:00
|
|
|
Required: true,
|
2015-10-09 09:05:43 -04:00
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"host": {
|
2015-10-09 09:05:43 -04:00
|
|
|
Type: schema.TypeString,
|
2016-10-27 05:54:05 -04:00
|
|
|
Required: true,
|
2015-10-09 09:05:43 -04:00
|
|
|
ForceNew: true,
|
2018-04-20 05:35:49 -04:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"ulimit": {
|
2018-04-20 05:35:49 -04:00
|
|
|
Type: schema.TypeSet,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
Elem: &schema.Resource{
|
|
|
|
|
Schema: map[string]*schema.Schema{
|
2019-03-01 16:02:17 -05:00
|
|
|
"name": {
|
2018-04-20 05:35:49 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Required: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2019-03-01 16:02:17 -05:00
|
|
|
"soft": {
|
2018-04-20 05:35:49 -04:00
|
|
|
Type: schema.TypeInt,
|
|
|
|
|
Required: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2019-03-01 16:02:17 -05:00
|
|
|
"hard": {
|
2018-04-20 05:35:49 -04:00
|
|
|
Type: schema.TypeInt,
|
|
|
|
|
Required: true,
|
|
|
|
|
ForceNew: true,
|
2015-10-09 09:05:43 -04:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2015-02-17 11:28:33 -05:00
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"env": {
|
2015-02-17 11:28:33 -05:00
|
|
|
Type: schema.TypeSet,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
Elem: &schema.Schema{Type: schema.TypeString},
|
2016-02-07 18:51:26 -05:00
|
|
|
Set: schema.HashString,
|
2015-02-17 11:28:33 -05:00
|
|
|
},
|
2015-04-16 15:42:21 -04:00
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"links": {
|
2018-04-02 02:19:45 -04:00
|
|
|
Type: schema.TypeSet,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
Elem: &schema.Schema{Type: schema.TypeString},
|
|
|
|
|
Set: schema.HashString,
|
|
|
|
|
Deprecated: "The --link flag is a legacy feature of Docker. It may eventually be removed.",
|
2015-04-16 15:42:21 -04:00
|
|
|
},
|
2015-04-16 09:21:14 -04:00
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"ip_address": {
|
2018-10-25 01:21:48 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Computed: true,
|
|
|
|
|
Deprecated: "Use ip_adresses_data instead. This field exposes the data of the container's first network.",
|
2015-04-20 15:18:46 -04:00
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"ip_prefix_length": {
|
2018-10-25 01:21:48 -04:00
|
|
|
Type: schema.TypeInt,
|
|
|
|
|
Computed: true,
|
|
|
|
|
Deprecated: "Use ip_prefix_length from ip_adresses_data instead. This field exposes the data of the container's first network.",
|
2015-04-20 15:18:46 -04:00
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"gateway": {
|
2018-10-25 01:21:48 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Computed: true,
|
|
|
|
|
Deprecated: "Use gateway from ip_adresses_data instead. This field exposes the data of the container's first network.",
|
2015-04-20 15:18:46 -04:00
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"bridge": {
|
2015-04-20 15:18:46 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Computed: true,
|
|
|
|
|
},
|
2015-06-04 06:57:38 -04:00
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"network_data": {
|
2018-10-25 01:21:48 -04:00
|
|
|
Type: schema.TypeList,
|
|
|
|
|
Computed: true,
|
|
|
|
|
Elem: &schema.Resource{
|
|
|
|
|
Schema: map[string]*schema.Schema{
|
2019-03-01 16:02:17 -05:00
|
|
|
"network_name": {
|
2018-10-25 01:21:48 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Computed: true,
|
|
|
|
|
},
|
2019-03-01 16:02:17 -05:00
|
|
|
"ip_address": {
|
2018-10-25 01:21:48 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Computed: true,
|
|
|
|
|
},
|
2019-03-01 16:02:17 -05:00
|
|
|
"ip_prefix_length": {
|
2018-10-25 01:21:48 -04:00
|
|
|
Type: schema.TypeInt,
|
|
|
|
|
Computed: true,
|
|
|
|
|
},
|
2019-03-01 16:02:17 -05:00
|
|
|
"gateway": {
|
2018-10-25 01:21:48 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Computed: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"privileged": {
|
2015-06-04 06:57:38 -04:00
|
|
|
Type: schema.TypeBool,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2015-10-27 19:53:49 -04:00
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"devices": {
|
2018-04-20 05:14:44 -04:00
|
|
|
Type: schema.TypeSet,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
Elem: &schema.Resource{
|
|
|
|
|
Schema: map[string]*schema.Schema{
|
2019-03-01 16:02:17 -05:00
|
|
|
"host_path": {
|
2018-04-20 05:14:44 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Required: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"container_path": {
|
2018-04-20 05:14:44 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"permissions": {
|
2018-04-20 05:14:44 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"destroy_grace_seconds": {
|
2016-07-11 11:03:02 -04:00
|
|
|
Type: schema.TypeInt,
|
|
|
|
|
Optional: true,
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"labels": {
|
2015-11-03 15:20:58 -05:00
|
|
|
Type: schema.TypeMap,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"memory": {
|
2018-01-29 06:01:46 -05:00
|
|
|
Type: schema.TypeInt,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
ValidateFunc: validateIntegerGeqThan(0),
|
2015-10-27 19:53:49 -04:00
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"memory_swap": {
|
2018-01-29 06:01:46 -05:00
|
|
|
Type: schema.TypeInt,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
ValidateFunc: validateIntegerGeqThan(-1),
|
2015-10-27 19:53:49 -04:00
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"cpu_shares": {
|
2018-01-29 06:01:46 -05:00
|
|
|
Type: schema.TypeInt,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
ValidateFunc: validateIntegerGeqThan(0),
|
2015-10-27 19:53:49 -04:00
|
|
|
},
|
2015-11-04 12:42:55 -05:00
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"cpu_set": {
|
2018-10-28 04:12:38 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
ValidateFunc: validateStringMatchesPattern(`^\d+([,-]\d+)*$`),
|
2018-01-24 16:03:01 -05:00
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"log_driver": {
|
2018-01-29 06:01:46 -05:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
Default: "json-file",
|
|
|
|
|
ValidateFunc: validateStringMatchesPattern(`^(json-file|syslog|journald|gelf|fluentd|awslogs)$`),
|
2015-11-04 12:42:55 -05:00
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"log_opts": {
|
2015-11-04 12:42:55 -05:00
|
|
|
Type: schema.TypeMap,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2016-01-01 03:57:21 -05:00
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"network_alias": {
|
2018-10-29 01:36:21 -04:00
|
|
|
Type: schema.TypeSet,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
Elem: &schema.Schema{Type: schema.TypeString},
|
|
|
|
|
Set: schema.HashString,
|
|
|
|
|
Description: "Set an alias for the container in all specified networks",
|
|
|
|
|
Deprecated: "Use networks_advanced instead. Will be removed in v2.0.0",
|
2017-05-22 09:20:32 -04:00
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"network_mode": {
|
2018-10-25 01:21:48 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
2016-01-01 03:57:21 -05:00
|
|
|
},
|
2016-01-14 02:01:03 -05:00
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"networks": {
|
2018-10-29 01:36:21 -04:00
|
|
|
Type: schema.TypeSet,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
Elem: &schema.Schema{Type: schema.TypeString},
|
|
|
|
|
Set: schema.HashString,
|
|
|
|
|
Deprecated: "Use networks_advanced instead. Will be removed in v2.0.0",
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"networks_advanced": {
|
2016-01-04 14:58:54 -05:00
|
|
|
Type: schema.TypeSet,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
2018-10-29 01:36:21 -04:00
|
|
|
Elem: &schema.Resource{
|
|
|
|
|
Schema: map[string]*schema.Schema{
|
2019-03-01 16:02:17 -05:00
|
|
|
"name": {
|
2018-10-29 01:36:21 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Required: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2019-03-01 16:02:17 -05:00
|
|
|
"aliases": {
|
2018-10-29 01:36:21 -04:00
|
|
|
Type: schema.TypeSet,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
Elem: &schema.Schema{Type: schema.TypeString},
|
|
|
|
|
Set: schema.HashString,
|
|
|
|
|
},
|
2019-03-01 16:02:17 -05:00
|
|
|
"ipv4_address": {
|
2018-10-29 01:36:21 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2019-03-01 16:02:17 -05:00
|
|
|
"ipv6_address": {
|
2018-10-29 01:36:21 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2016-01-04 14:58:54 -05:00
|
|
|
},
|
2016-12-05 06:06:34 -05:00
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"pid_mode": {
|
2018-10-11 04:55:18 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2019-03-01 16:02:17 -05:00
|
|
|
"userns_mode": {
|
2018-10-11 04:55:18 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"upload": {
|
2016-12-05 06:06:34 -05:00
|
|
|
Type: schema.TypeSet,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
Elem: &schema.Resource{
|
|
|
|
|
Schema: map[string]*schema.Schema{
|
2019-03-01 16:02:17 -05:00
|
|
|
"content": {
|
2016-12-05 06:06:34 -05:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Required: true,
|
|
|
|
|
// This is intentional. The container is mutated once, and never updated later.
|
|
|
|
|
// New configuration forces a new deployment, even with the same binaries.
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2019-03-01 16:02:17 -05:00
|
|
|
"file": {
|
2016-12-05 06:06:34 -05:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Required: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2019-03-01 16:02:17 -05:00
|
|
|
"executable": {
|
2018-04-20 05:30:45 -04:00
|
|
|
Type: schema.TypeBool,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
Default: false,
|
|
|
|
|
},
|
2016-12-05 06:06:34 -05:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2018-10-08 09:02:13 -04:00
|
|
|
|
2019-03-01 16:02:17 -05:00
|
|
|
"healthcheck": {
|
2018-10-08 09:02:13 -04:00
|
|
|
Type: schema.TypeList,
|
|
|
|
|
Description: "A test to perform to check that the container is healthy",
|
|
|
|
|
MaxItems: 1,
|
|
|
|
|
Optional: true,
|
|
|
|
|
Elem: &schema.Resource{
|
|
|
|
|
Schema: map[string]*schema.Schema{
|
2019-03-01 16:02:17 -05:00
|
|
|
"test": {
|
2018-10-08 09:02:13 -04:00
|
|
|
Type: schema.TypeList,
|
|
|
|
|
Description: "The test to perform as list",
|
|
|
|
|
Required: true,
|
|
|
|
|
Elem: &schema.Schema{Type: schema.TypeString},
|
|
|
|
|
},
|
2019-03-01 16:02:17 -05:00
|
|
|
"interval": {
|
2018-10-08 09:02:13 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Description: "Time between running the check (ms|s|m|h)",
|
|
|
|
|
Optional: true,
|
|
|
|
|
Default: "0s",
|
|
|
|
|
ValidateFunc: validateDurationGeq0(),
|
|
|
|
|
},
|
2019-03-01 16:02:17 -05:00
|
|
|
"timeout": {
|
2018-10-08 09:02:13 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Description: "Maximum time to allow one check to run (ms|s|m|h)",
|
|
|
|
|
Optional: true,
|
|
|
|
|
Default: "0s",
|
|
|
|
|
ValidateFunc: validateDurationGeq0(),
|
|
|
|
|
},
|
2019-03-01 16:02:17 -05:00
|
|
|
"start_period": {
|
2018-10-08 09:02:13 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Description: "Start period for the container to initialize before counting retries towards unstable (ms|s|m|h)",
|
|
|
|
|
Optional: true,
|
|
|
|
|
Default: "0s",
|
|
|
|
|
ValidateFunc: validateDurationGeq0(),
|
|
|
|
|
},
|
2019-03-01 16:02:17 -05:00
|
|
|
"retries": {
|
2018-10-08 09:02:13 -04:00
|
|
|
Type: schema.TypeInt,
|
|
|
|
|
Description: "Consecutive failures needed to report unhealthy",
|
|
|
|
|
Optional: true,
|
|
|
|
|
Default: 0,
|
|
|
|
|
ValidateFunc: validateIntegerGeqThan(0),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2015-02-17 11:28:33 -05:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-05 09:55:17 -05:00
|
|
|
|
|
|
|
|
func suppressIfPortsDidNotChangeForMigrationV0ToV1() schema.SchemaDiffSuppressFunc {
|
|
|
|
|
return func(k, old, new string, d *schema.ResourceData) bool {
|
|
|
|
|
portsOldRaw, portsNewRaw := d.GetChange("ports")
|
|
|
|
|
portsOld := portsOldRaw.([]interface{})
|
|
|
|
|
portsNew := portsNewRaw.([]interface{})
|
|
|
|
|
if len(portsOld) != len(portsNew) {
|
|
|
|
|
log.Printf("[DEBUG] suppress diff ports: old and new don't have the same length")
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
log.Printf("[DEBUG] suppress diff ports: old and new have same length")
|
|
|
|
|
|
|
|
|
|
for _, portOld := range portsOld {
|
|
|
|
|
portOldMapped := portOld.(map[string]interface{})
|
|
|
|
|
oldInternalPort := portOldMapped["internal"]
|
|
|
|
|
portFound := false
|
|
|
|
|
for _, portNew := range portsNew {
|
|
|
|
|
portNewMapped := portNew.(map[string]interface{})
|
|
|
|
|
newInternalPort := portNewMapped["internal"]
|
|
|
|
|
// port is still there in new
|
|
|
|
|
if newInternalPort == oldInternalPort {
|
|
|
|
|
log.Printf("[DEBUG] suppress diff ports: comparing port '%v'", oldInternalPort)
|
|
|
|
|
portFound = true
|
|
|
|
|
if portNewMapped["external"] != portOldMapped["external"] {
|
|
|
|
|
log.Printf("[DEBUG] suppress diff ports: 'external' changed for '%v'", oldInternalPort)
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
if portNewMapped["ip"] != portOldMapped["ip"] {
|
|
|
|
|
log.Printf("[DEBUG] suppress diff ports: 'ip' changed for '%v'", oldInternalPort)
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
if portNewMapped["protocol"] != portOldMapped["protocol"] {
|
|
|
|
|
log.Printf("[DEBUG] suppress diff ports: 'protocol' changed for '%v'", oldInternalPort)
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// port was deleted or exchanges in new
|
|
|
|
|
if !portFound {
|
|
|
|
|
log.Printf("[DEBUG] suppress diff ports: port was deleted '%v'", oldInternalPort)
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|