mirror of
https://github.com/kreuzwerker/terraform-provider-docker.git
synced 2025-12-30 03:29:39 -05:00
chore: bump docker dependency to v20.10.5 (#119)
* chore: bump to docker v20.10.2 * fix: compilation errors * chore: bump to docker v20.10.5 * chore: bump to docker/cli v20.10.5 * fix: removes service generic resource from limits * fix: pass nil platform for container creation Co-authored-by: Shunsuke Suzuki <suzuki-shunsuke@users.noreply.github.com>
This commit is contained in:
parent
056a3bd7ba
commit
97ed39e2d9
7 changed files with 1170 additions and 131 deletions
|
|
@ -330,7 +330,8 @@ func resourceDockerContainerCreate(d *schema.ResourceData, meta interface{}) err
|
|||
|
||||
var retContainer container.ContainerCreateCreatedBody
|
||||
|
||||
if retContainer, err = client.ContainerCreate(context.Background(), config, hostConfig, networkingConfig, d.Get("name").(string)); err != nil {
|
||||
// TODO mavogel add platform later which comes from API v1.41. Currently we pass nil
|
||||
if retContainer, err = client.ContainerCreate(context.Background(), config, hostConfig, networkingConfig, nil, d.Get("name").(string)); err != nil {
|
||||
return fmt.Errorf("Unable to create container: %s", err)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -523,30 +523,6 @@ func resourceDockerService() *schema.Resource {
|
|||
Description: "The amounf of memory in bytes the container allocates",
|
||||
Optional: true,
|
||||
},
|
||||
"generic_resources": {
|
||||
Type: schema.TypeList,
|
||||
Description: "User-defined resources can be either Integer resources (e.g, SSD=3) or String resources (e.g, GPU=UUID1)",
|
||||
MaxItems: 1,
|
||||
Optional: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"named_resources_spec": {
|
||||
Type: schema.TypeSet,
|
||||
Description: "The String resources",
|
||||
Optional: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
"discrete_resources_spec": {
|
||||
Type: schema.TypeSet,
|
||||
Description: "The Integer resources",
|
||||
Optional: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -1430,30 +1406,6 @@ func resourceDockerServiceV0() *schema.Resource {
|
|||
Description: "The amounf of memory in bytes the container allocates",
|
||||
Optional: true,
|
||||
},
|
||||
"generic_resources": {
|
||||
Type: schema.TypeList,
|
||||
Description: "User-defined resources can be either Integer resources (e.g, SSD=3) or String resources (e.g, GPU=UUID1)",
|
||||
MaxItems: 1,
|
||||
Optional: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"named_resources_spec": {
|
||||
Type: schema.TypeSet,
|
||||
Description: "The String resources",
|
||||
Optional: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
"discrete_resources_spec": {
|
||||
Type: schema.TypeSet,
|
||||
Description: "The Integer resources",
|
||||
Optional: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -988,7 +988,7 @@ func createResources(v interface{}) (*swarm.ResourceRequirements, error) {
|
|||
rawResourcesSpec := rawResourcesSpec.(map[string]interface{})
|
||||
if value, ok := rawResourcesSpec["limits"]; ok {
|
||||
if len(value.([]interface{})) > 0 {
|
||||
resources.Limits = &swarm.Resources{}
|
||||
resources.Limits = &swarm.Limit{}
|
||||
for _, rawLimitsSpec := range value.([]interface{}) {
|
||||
rawLimitsSpec := rawLimitsSpec.(map[string]interface{})
|
||||
if value, ok := rawLimitsSpec["nano_cpus"]; ok {
|
||||
|
|
@ -997,9 +997,6 @@ func createResources(v interface{}) (*swarm.ResourceRequirements, error) {
|
|||
if value, ok := rawLimitsSpec["memory_bytes"]; ok {
|
||||
resources.Limits.MemoryBytes = int64(value.(int))
|
||||
}
|
||||
if value, ok := rawLimitsSpec["generic_resources"]; ok {
|
||||
resources.Limits.GenericResources, _ = createGenericResources(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -371,14 +371,28 @@ func flattenTaskResources(in *swarm.ResourceRequirements) []interface{} {
|
|||
out := make([]interface{}, 0)
|
||||
if in != nil {
|
||||
m := make(map[string]interface{})
|
||||
m["limits"] = flattenResourceLimitsOrReservations(in.Limits)
|
||||
m["reservation"] = flattenResourceLimitsOrReservations(in.Reservations)
|
||||
m["limits"] = flattenResourceLimits(in.Limits)
|
||||
// TODO mvogel: name reservations
|
||||
m["reservation"] = flattenResourceReservations(in.Reservations)
|
||||
out = append(out, m)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func flattenResourceLimitsOrReservations(in *swarm.Resources) []interface{} {
|
||||
func flattenResourceLimits(in *swarm.Limit) []interface{} {
|
||||
out := make([]interface{}, 0)
|
||||
if in != nil {
|
||||
m := make(map[string]interface{})
|
||||
m["nano_cpus"] = in.NanoCPUs
|
||||
m["memory_bytes"] = in.MemoryBytes
|
||||
// TODO mavogel add pids
|
||||
// m["pids"] = in.Pids
|
||||
out = append(out, m)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func flattenResourceReservations(in *swarm.Resources) []interface{} {
|
||||
out := make([]interface{}, 0)
|
||||
if in != nil {
|
||||
m := make(map[string]interface{})
|
||||
|
|
|
|||
21
go.mod
21
go.mod
|
|
@ -1,21 +1,20 @@
|
|||
module github.com/terraform-providers/terraform-provider-docker
|
||||
|
||||
require (
|
||||
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
|
||||
github.com/Microsoft/hcsshim v0.8.9 // indirect
|
||||
github.com/containerd/continuity v0.0.0-20200710164510-efbc4488d8fe // indirect
|
||||
github.com/docker/cli v0.0.0-20200303215952-eb310fca4956 // v19.03.8
|
||||
github.com/docker/distribution v0.0.0-20180522175653-f0cc92778478
|
||||
github.com/docker/docker v0.7.3-0.20190525203055-f25e0c6f3093
|
||||
github.com/docker/docker-credential-helpers v0.6.3
|
||||
github.com/docker/cli v20.10.5+incompatible
|
||||
github.com/docker/distribution v2.7.1+incompatible
|
||||
github.com/docker/docker v20.10.5+incompatible
|
||||
github.com/docker/go-connections v0.4.0
|
||||
github.com/docker/go-units v0.4.0
|
||||
github.com/gorilla/mux v1.7.2 // indirect
|
||||
github.com/hashicorp/terraform-plugin-sdk v1.0.0
|
||||
github.com/mitchellh/go-homedir v1.1.0
|
||||
github.com/morikuni/aec v0.0.0-20170113033406-39771216ff4c // indirect
|
||||
github.com/opencontainers/image-spec v0.0.0-20171125024018-577479e4dc27 // indirect
|
||||
github.com/opencontainers/runc v0.1.1 // indirect
|
||||
github.com/moby/buildkit v0.8.1 // indirect
|
||||
github.com/moby/sys/mount v0.2.0 // indirect
|
||||
github.com/moby/sys/symlink v0.1.0 // indirect
|
||||
github.com/moby/term v0.0.0-20201216013528-df9cb8a40635 // indirect
|
||||
github.com/opencontainers/image-spec v1.0.1
|
||||
golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b // indirect
|
||||
gotest.tools/v3 v3.0.3 // indirect
|
||||
)
|
||||
|
||||
go 1.15
|
||||
|
|
|
|||
|
|
@ -172,16 +172,6 @@ resource "docker_service" "foo" {
|
|||
limits {
|
||||
nano_cpus = 1000000
|
||||
memory_bytes = 536870912
|
||||
|
||||
generic_resources {
|
||||
named_resources_spec = [
|
||||
"GPU=UUID1",
|
||||
]
|
||||
|
||||
discrete_resources_spec = [
|
||||
"SSD=3",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
reservation {
|
||||
|
|
@ -454,9 +444,6 @@ the extra mount mappings for the container. Each `configs` is a reference to a s
|
|||
* `limits` - (Optional, list of strings) Describes the resources which can be advertised by a node and requested by a task.
|
||||
* `nano_cpus` (Optional, int) CPU shares in units of 1/1e9 (or 10^-9) of the CPU. Should be at least 1000000
|
||||
* `memory_bytes` (Optional, int) The amount of memory in bytes the container allocates
|
||||
* `generic_resources` (Optional, map) User-defined resources can be either Integer resources (e.g, SSD=3) or String resources (e.g, GPU=UUID1)
|
||||
* `named_resources_spec` (Optional, set of string) The String resources, delimited by `=`
|
||||
* `discrete_resources_spec` (Optional, set of string) The Integer resources, delimited by `=`
|
||||
* `reservation` - (Optional, list of strings) An object describing the resources which can be advertised by a node and requested by a task.
|
||||
* `nano_cpus` (Optional, int) CPU shares in units of 1/1e9 (or 10^-9) of the CPU. Should be at least 1000000
|
||||
* `memory_bytes` (Optional, int) The amount of memory in bytes the container allocates
|
||||
|
|
|
|||
Loading…
Reference in a new issue