From 2358a356f4187a56a142553e2c3a1da26b14223a Mon Sep 17 00:00:00 2001 From: marco Date: Fri, 9 Aug 2024 13:47:52 +0200 Subject: [PATCH] fix build --- pkg/acquisition/modules/docker/docker.go | 11 ++++++----- pkg/acquisition/modules/docker/docker_test.go | 2 +- pkg/metabase/container.go | 12 ++++++------ 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/pkg/acquisition/modules/docker/docker.go b/pkg/acquisition/modules/docker/docker.go index 9a6e13feee4..32d9428eba4 100644 --- a/pkg/acquisition/modules/docker/docker.go +++ b/pkg/acquisition/modules/docker/docker.go @@ -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" @@ -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 { @@ -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, @@ -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, @@ -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 } @@ -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 { diff --git a/pkg/acquisition/modules/docker/docker_test.go b/pkg/acquisition/modules/docker/docker_test.go index e332569fb3a..0b626164e18 100644 --- a/pkg/acquisition/modules/docker/docker_test.go +++ b/pkg/acquisition/modules/docker/docker_test.go @@ -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 } diff --git a/pkg/metabase/container.go b/pkg/metabase/container.go index 8b3dd4084c0..73e4596fcde 100644 --- a/pkg/metabase/container.go +++ b/pkg/metabase/container.go @@ -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" @@ -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) } @@ -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) } @@ -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) } @@ -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 @@ -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