mirror of
https://github.com/kreuzwerker/terraform-provider-docker.git
synced 2026-01-04 05:49:35 -05:00
feat: support max replicas of Docker Service Task Spec (#112)
Closes #111
This commit is contained in:
parent
0042d2654a
commit
2101f471c3
5 changed files with 15 additions and 0 deletions
|
|
@ -651,6 +651,12 @@ func resourceDockerService() *schema.Resource {
|
|||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
"max_replicas": {
|
||||
Type: schema.TypeInt,
|
||||
Description: "Maximum number of replicas for per node (default value is 0, which is unlimited)",
|
||||
Optional: true,
|
||||
ValidateFunc: validateIntegerGeqThan(0),
|
||||
},
|
||||
"platforms": {
|
||||
Type: schema.TypeSet,
|
||||
Description: "Platforms stores all the platforms that the service's image can run on",
|
||||
|
|
|
|||
|
|
@ -1102,6 +1102,9 @@ func createPlacement(v interface{}) (*swarm.Placement, error) {
|
|||
if v, ok := rawPlacement["platforms"]; ok {
|
||||
placement.Platforms = mapSetToPlacementPlatforms(v.(*schema.Set))
|
||||
}
|
||||
if v, ok := rawPlacement["max_replicas"]; ok {
|
||||
placement.MaxReplicas = uint64(v.(int))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -344,6 +344,7 @@ func TestAccDockerService_fullSpec(t *testing.T) {
|
|||
os = "linux"
|
||||
}
|
||||
|
||||
max_replicas = 2
|
||||
}
|
||||
|
||||
force_update = 0
|
||||
|
|
@ -451,6 +452,7 @@ func TestAccDockerService_fullSpec(t *testing.T) {
|
|||
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.restart_policy.window", "10s"),
|
||||
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.placement.0.constraints.4248571116", "node.role==manager"),
|
||||
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.placement.0.prefs.1751004438", "spread=node.role.manager"),
|
||||
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.placement.0.max_replicas", "2"),
|
||||
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.force_update", "0"),
|
||||
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.networks.#", "1"),
|
||||
resource.TestCheckResourceAttr("docker_service.foo", "task_spec.0.log_driver.0.name", "json-file"),
|
||||
|
|
|
|||
|
|
@ -444,6 +444,7 @@ func flattenTaskPlacement(in *swarm.Placement) []interface{} {
|
|||
if len(in.Platforms) > 0 {
|
||||
m["platforms"] = flattenPlacementPlatforms(in.Platforms)
|
||||
}
|
||||
m["max_replicas"] = in.MaxReplicas
|
||||
out[0] = m
|
||||
return out
|
||||
}
|
||||
|
|
|
|||
|
|
@ -215,6 +215,8 @@ resource "docker_service" "foo" {
|
|||
prefs = [
|
||||
"spread=node.role.manager",
|
||||
]
|
||||
|
||||
max_replicas = 1
|
||||
}
|
||||
|
||||
force_update = 0
|
||||
|
|
@ -486,6 +488,7 @@ the extra mount mappings for the container. Each `configs` is a reference to a s
|
|||
* `platforms` (Optional, set of) Platforms stores all the platforms that the service's image can run on
|
||||
* `architecture` (Required, string) The architecture, e.g., `amd64`
|
||||
* `os` (Required, string) The operation system, e.g., `linux`
|
||||
* `max_replicas` (Optional, int) Maximum number of replicas for per node (default value is 0, which is unlimited)
|
||||
|
||||
<!-- end task-placement-spec -->
|
||||
<!-- end log-driver-spec -->
|
||||
|
|
|
|||
Loading…
Reference in a new issue