"github.com/crowdsecurity/crowdsec/pkg/types"
"github.com/crowdsecurity/dlog"
dockerTypes "github.com/docker/docker/api/types"
+ dockerContainer "github.com/docker/docker/api/types/container"
"github.com/docker/docker/client"
"github.com/pkg/errors"
logger *log.Entry
Client client.CommonAPIClient
t *tomb.Tomb
- containerLogsOptions *dockerTypes.ContainerLogsOptions
+ containerLogsOptions *dockerContainer.LogsOptions
}
type ContainerConfig struct {
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,
return err
}
- d.containerLogsOptions = &dockerTypes.ContainerLogsOptions{
+ d.containerLogsOptions = &dockerContainer.LogsOptions{
ShowStdout: d.Config.FollowStdout,
ShowStderr: d.Config.FollowStdErr,
Follow: false,
//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
}
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 {
}
-func (cli *mockDockerCli) ContainerList(ctx context.Context, options dockerTypes.ContainerListOptions) ([]dockerTypes.Container, error) {
+func (cli *mockDockerCli) ContainerList(ctx context.Context, options dockerContainer.ListOptions) ([]dockerTypes.Container, error) {
if readLogs == true {
return []dockerTypes.Container{}, nil
}
"context"
"fmt"
"runtime"
- "time"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
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)
}
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)
}
return fmt.Errorf("failed to create docker client : %s", err)
}
ctx := context.Background()
- var to time.Duration = 20 * time.Second
- if err := cli.ContainerStop(ctx, name, &to); err != nil {
+ timeoutSeconds := 20
+ var to container.StopOptions
+ to.Timeout = &timeoutSeconds
+ if err := cli.ContainerStop(ctx, name, to); err != nil {
return fmt.Errorf("failed while stopping %s : %s", name, err)
}
log.Printf("container stopped successfully")
}
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