Skip to content

Commit

Permalink
fix: compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mavogel committed Jan 8, 2021
1 parent ca96c14 commit 32c7ad6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
8 changes: 7 additions & 1 deletion docker/resource_docker_container_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/docker/go-connections/nat"
"github.com/docker/go-units"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
)

var creationTime time.Time
Expand Down Expand Up @@ -328,7 +329,12 @@ 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
platform := &v1.Platform{
Architecture: "amd64",
OS: "linux",
}
if retContainer, err = client.ContainerCreate(context.Background(), config, hostConfig, networkingConfig, platform, d.Get("name").(string)); err != nil {
return fmt.Errorf("Unable to create container: %s", err)
}

Expand Down
10 changes: 6 additions & 4 deletions docker/resource_docker_service_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,8 @@ 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{}
// TODO mavogel
resources.Limits = &swarm.Limit{}
for _, rawLimitsSpec := range value.([]interface{}) {
rawLimitsSpec := rawLimitsSpec.(map[string]interface{})
if value, ok := rawLimitsSpec["nano_cpus"]; ok {
Expand All @@ -997,9 +998,10 @@ 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)
}
// TODO mavogel
// if value, ok := rawLimitsSpec["generic_resources"]; ok {
// resources.Limits.GenericResources, _ = createGenericResources(value)
// }
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions docker/structures_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,19 +372,21 @@ func flattenTaskResources(in *swarm.ResourceRequirements) []interface{} {
if in != nil {
m := make(map[string]interface{})
m["limits"] = flattenResourceLimitsOrReservations(in.Limits)
m["reservation"] = flattenResourceLimitsOrReservations(in.Reservations)
// TODO mavogel
// m["reservation"] = flattenResourceLimitsOrReservations(in.Reservations)
out = append(out, m)
}
return out
}

func flattenResourceLimitsOrReservations(in *swarm.Resources) []interface{} {
func flattenResourceLimitsOrReservations(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
m["generic_resources"] = flattenResourceGenericResource(in.GenericResources)
// TODO mavogel
// m["generic_resources"] = flattenResourceGenericResource(in.GenericResources)
out = append(out, m)
}
return out
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
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
gotest.tools/v3 v3.0.3 // indirect
)

Expand Down

0 comments on commit 32c7ad6

Please sign in to comment.