Skip to content

Commit

Permalink
fixed issues
Browse files Browse the repository at this point in the history
  • Loading branch information
marciogoda authored and Ian Jones committed Mar 8, 2024
1 parent e5eb650 commit 55143fc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
3 changes: 1 addition & 2 deletions config/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"errors"
"fmt"
"io"
"time"

"github.com/mergermarket/cdflow2/command"
"github.com/mergermarket/cdflow2/docker"
Expand Down Expand Up @@ -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
}
}
Expand Down
3 changes: 1 addition & 2 deletions docker/iface.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package docker

import (
"io"
"time"
)

// Iface is an interface for interracting with docker.
Expand All @@ -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
Expand Down
9 changes: 5 additions & 4 deletions docker/official/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"io"
"os"
"strings"
"time"

"github.com/docker/distribution/reference"
"github.com/docker/docker/api/types"
Expand Down Expand Up @@ -79,6 +78,7 @@ func (dockerClient *Client) Run(options *docker.RunOptions) error {
Init: &options.Init,
},
nil,
nil,
util.RandomName(options.NamePrefix),
)
if err != nil {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -439,6 +439,7 @@ func (dockerClient *Client) CreateContainer(options *docker.CreateContainerOptio
Binds: options.Binds,
},
nil,
nil,
"",
)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions terraform/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"sort"
"strconv"
"strings"
"time"

"github.com/mergermarket/cdflow2/config"
"github.com/mergermarket/cdflow2/docker"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 55143fc

Please sign in to comment.