Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
mmetc committed Aug 20, 2024
1 parent 7b99323 commit 2358a35
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
11 changes: 6 additions & 5 deletions pkg/acquisition/modules/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"strings"
"time"

dockerContainer "github.com/docker/docker/api/types/container"
dockerTypes "github.com/docker/docker/api/types"
"github.com/docker/docker/client"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -56,7 +57,7 @@ type DockerSource struct {
logger *log.Entry
Client client.CommonAPIClient
t *tomb.Tomb
containerLogsOptions *dockerTypes.ContainerLogsOptions
containerLogsOptions *dockerContainer.LogsOptions
}

type ContainerConfig struct {
Expand Down Expand Up @@ -120,7 +121,7 @@ func (d *DockerSource) UnmarshalConfig(yamlConfig []byte) error {
d.Config.Since = time.Now().UTC().Format(time.RFC3339)
}

d.containerLogsOptions = &dockerTypes.ContainerLogsOptions{
d.containerLogsOptions = &dockerContainer.LogsOptions{
ShowStdout: d.Config.FollowStdout,
ShowStderr: d.Config.FollowStdErr,
Follow: true,
Expand Down Expand Up @@ -192,7 +193,7 @@ func (d *DockerSource) ConfigureByDSN(dsn string, labels map[string]string, logg
return err
}

d.containerLogsOptions = &dockerTypes.ContainerLogsOptions{
d.containerLogsOptions = &dockerContainer.LogsOptions{
ShowStdout: d.Config.FollowStdout,
ShowStderr: d.Config.FollowStdErr,
Follow: false,
Expand Down Expand Up @@ -288,7 +289,7 @@ func (d *DockerSource) SupportedModes() []string {
// OneShotAcquisition reads a set of file and returns when done
func (d *DockerSource) OneShotAcquisition(out chan types.Event, t *tomb.Tomb) error {
d.logger.Debug("In oneshot")
runningContainer, err := d.Client.ContainerList(context.Background(), dockerTypes.ContainerListOptions{})
runningContainer, err := d.Client.ContainerList(context.Background(), dockerContainer.ListOptions{})
if err != nil {
return err
}
Expand Down Expand Up @@ -477,7 +478,7 @@ func (d *DockerSource) WatchContainer(monitChan chan *ContainerConfig, deleteCha
case <-ticker.C:
// to track for garbage collection
runningContainersID := make(map[string]bool)
runningContainer, err := d.Client.ContainerList(context.Background(), dockerTypes.ContainerListOptions{})
runningContainer, err := d.Client.ContainerList(context.Background(), dockerContainer.ListOptions{})
if err != nil {
if strings.Contains(strings.ToLower(err.Error()), "cannot connect to the docker daemon at") {
for idx, container := range d.runningContainerState {
Expand Down
2 changes: 1 addition & 1 deletion pkg/acquisition/modules/docker/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func (cli *mockDockerCli) ContainerList(ctx context.Context, options dockerTypes
return containers, nil
}

func (cli *mockDockerCli) ContainerLogs(ctx context.Context, container string, options dockerTypes.ContainerLogsOptions) (io.ReadCloser, error) {
func (cli *mockDockerCli) ContainerLogs(ctx context.Context, container string, options dockerContainer.LogsOptions) (io.ReadCloser, error) {
if readLogs {
return io.NopCloser(strings.NewReader("")), nil
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/metabase/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"context"
"fmt"

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
typesImage "github.com/docker/docker/api/types/image"
"github.com/docker/docker/api/types/mount"
"github.com/docker/docker/client"
"github.com/docker/go-connections/nat"
Expand Down Expand Up @@ -47,7 +47,7 @@ func NewContainer(listenAddr string, listenPort string, sharedFolder string, con
func (c *Container) Create() error {
ctx := context.Background()
log.Printf("Pulling docker image %s", c.Image)
reader, err := c.CLI.ImagePull(ctx, c.Image, types.ImagePullOptions{})
reader, err := c.CLI.ImagePull(ctx, c.Image, typesImage.PullOptions{})
if err != nil {
return fmt.Errorf("failed to pull docker image : %s", err)
}
Expand Down Expand Up @@ -105,7 +105,7 @@ func (c *Container) Create() error {

func (c *Container) Start() error {
ctx := context.Background()
if err := c.CLI.ContainerStart(ctx, c.Name, types.ContainerStartOptions{}); err != nil {
if err := c.CLI.ContainerStart(ctx, c.Name, container.StartOptions{}); err != nil {
return fmt.Errorf("failed while starting %s : %s", c.ID, err)
}

Expand All @@ -118,7 +118,7 @@ func StartContainer(name string) error {
return fmt.Errorf("failed to create docker client : %s", err)
}
ctx := context.Background()
if err := cli.ContainerStart(ctx, name, types.ContainerStartOptions{}); err != nil {
if err := cli.ContainerStart(ctx, name, container.StartOptions{}); err != nil {
return fmt.Errorf("failed while starting %s : %s", name, err)
}

Expand Down Expand Up @@ -146,7 +146,7 @@ func RemoveContainer(name string) error {
}
ctx := context.Background()
log.Printf("Removing docker metabase %s", name)
if err := cli.ContainerRemove(ctx, name, types.ContainerRemoveOptions{}); err != nil {
if err := cli.ContainerRemove(ctx, name, container.RemoveOptions{}); err != nil {
return fmt.Errorf("failed to remove container %s : %s", name, err)
}
return nil
Expand All @@ -159,7 +159,7 @@ func RemoveImageContainer(image string) error {
}
ctx := context.Background()
log.Printf("Removing docker image '%s'", image)
if _, err := cli.ImageRemove(ctx, image, types.ImageRemoveOptions{}); err != nil {
if _, err := cli.ImageRemove(ctx, image, typesImage.RemoveOptions{}); err != nil {
return fmt.Errorf("failed to remove image container %s : %s", image, err)
}
return nil
Expand Down

0 comments on commit 2358a35

Please sign in to comment.