From 55143fc283cf7ca6ae46348c40516d089c70abb6 Mon Sep 17 00:00:00 2001 From: Marcio Goda Date: Thu, 7 Dec 2023 12:46:38 +0000 Subject: [PATCH] fixed issues --- config/container.go | 3 +-- docker/iface.go | 3 +-- docker/official/client.go | 9 +++++---- terraform/container.go | 3 +-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/config/container.go b/config/container.go index bb5a795..7d1a34d 100644 --- a/config/container.go +++ b/config/container.go @@ -7,7 +7,6 @@ import ( "errors" "fmt" "io" - "time" "github.com/mergermarket/cdflow2/command" "github.com/mergermarket/cdflow2/docker" @@ -363,7 +362,7 @@ func SetupTerraform(state *command.GlobalState, stateShouldExist *bool, envName, // Done stops and removes the config container. func (configContainer *Container) Done() error { if !configContainer.finished { - if err := configContainer.dockerClient.Stop(configContainer.id, 2*time.Second); err != nil { + if err := configContainer.dockerClient.Stop(configContainer.id, 2); err != nil { return err } } diff --git a/docker/iface.go b/docker/iface.go index 1623239..54ca93c 100644 --- a/docker/iface.go +++ b/docker/iface.go @@ -2,7 +2,6 @@ package docker import ( "io" - "time" ) // Iface is an interface for interracting with docker. @@ -12,7 +11,7 @@ type Iface interface { PullImage(image string, outputStream io.Writer) error GetImageRepoDigests(image string) ([]string, error) Exec(options *ExecOptions) error - Stop(id string, timeout time.Duration) error + Stop(id string, timeout int) error CreateVolume(name string) (string, error) VolumeExists(name string) (bool, error) RemoveVolume(id string) error diff --git a/docker/official/client.go b/docker/official/client.go index eda8e83..832e4ca 100644 --- a/docker/official/client.go +++ b/docker/official/client.go @@ -9,7 +9,6 @@ import ( "io" "os" "strings" - "time" "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" @@ -79,6 +78,7 @@ func (dockerClient *Client) Run(options *docker.RunOptions) error { Init: &options.Init, }, nil, + nil, util.RandomName(options.NamePrefix), ) if err != nil { @@ -396,13 +396,13 @@ func (dockerClient *Client) Exec(options *docker.ExecOptions) error { } // Stop stops a container. -func (dockerClient *Client) Stop(id string, timeout time.Duration) error { - return dockerClient.client.ContainerStop(context.Background(), id, &timeout) +func (dockerClient *Client) Stop(id string, timeout int) error { + return dockerClient.client.ContainerStop(context.Background(), id, container.StopOptions{Timeout: &timeout}) } // CreateVolume creates a docker volume and returns its ID. func (dockerClient *Client) CreateVolume(name string) (string, error) { - volume, err := dockerClient.client.VolumeCreate(context.Background(), volume.VolumeCreateBody{ + volume, err := dockerClient.client.VolumeCreate(context.Background(), volume.CreateOptions{ Name: name, }) if err != nil { @@ -439,6 +439,7 @@ func (dockerClient *Client) CreateContainer(options *docker.CreateContainerOptio Binds: options.Binds, }, nil, + nil, "", ) if err != nil { diff --git a/terraform/container.go b/terraform/container.go index 5ac08ec..4a6be5f 100644 --- a/terraform/container.go +++ b/terraform/container.go @@ -10,7 +10,6 @@ import ( "sort" "strconv" "strings" - "time" "github.com/mergermarket/cdflow2/config" "github.com/mergermarket/cdflow2/docker" @@ -430,7 +429,7 @@ func (terraformContainer *Container) RunInteractiveCommand( // Done stops and removes the terraform container. func (terraformContainer *Container) Done() error { - if err := terraformContainer.dockerClient.Stop(terraformContainer.id, 10*time.Second); err != nil { + if err := terraformContainer.dockerClient.Stop(terraformContainer.id, 10); err != nil { return err } return <-terraformContainer.done